diff options
Diffstat (limited to 'binfilter/bf_sc/source/core/data')
53 files changed, 38879 insertions, 0 deletions
diff --git a/binfilter/bf_sc/source/core/data/makefile.mk b/binfilter/bf_sc/source/core/data/makefile.mk new file mode 100644 index 000000000000..5f1abbc133e6 --- /dev/null +++ b/binfilter/bf_sc/source/core/data/makefile.mk @@ -0,0 +1,111 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# 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. +# +# 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). +# +# 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. +# +#************************************************************************* + +EXTERNAL_WARNINGS_NOT_ERRORS := TRUE + +PRJ=..$/..$/..$/.. +BFPRJ=..$/..$/.. + +PRJNAME=binfilter +TARGET=sc_data + +NO_HIDS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk +.INCLUDE : $(BFPRJ)$/util$/makefile.pmk +INC+= -I$(PRJ)$/inc$/bf_sc +# --- Files -------------------------------------------------------- + +SLOFILES = \ + $(SLO)$/sc_bclist.obj \ + $(SLO)$/sc_bcaslot.obj \ + $(SLO)$/sc_docpool.obj \ + $(SLO)$/sc_poolhelp.obj \ + $(SLO)$/sc_column.obj \ + $(SLO)$/sc_column2.obj \ + $(SLO)$/sc_column3.obj \ + $(SLO)$/sc_document.obj \ + $(SLO)$/sc_documen2.obj \ + $(SLO)$/sc_documen3.obj \ + $(SLO)$/sc_documen4.obj \ + $(SLO)$/sc_documen5.obj \ + $(SLO)$/sc_documen6.obj \ + $(SLO)$/sc_documen7.obj \ + $(SLO)$/sc_documen8.obj \ + $(SLO)$/sc_documen9.obj \ + $(SLO)$/sc_fillinfo.obj \ + $(SLO)$/sc_table1.obj \ + $(SLO)$/sc_table2.obj \ + $(SLO)$/sc_table3.obj \ + $(SLO)$/sc_table4.obj \ + $(SLO)$/sc_table5.obj \ + $(SLO)$/sc_olinetab.obj \ + $(SLO)$/sc_patattr.obj \ + $(SLO)$/sc_cell.obj \ + $(SLO)$/sc_cell2.obj \ + $(SLO)$/sc_attarray.obj \ + $(SLO)$/sc_attrib.obj \ + $(SLO)$/sc_global.obj \ + $(SLO)$/sc_global2.obj \ + $(SLO)$/sc_globalx.obj \ + $(SLO)$/sc_markarr.obj \ + $(SLO)$/sc_markdata.obj \ + $(SLO)$/sc_dociter.obj \ + $(SLO)$/sc_drwlayer.obj \ + $(SLO)$/sc_userdat.obj \ + $(SLO)$/sc_drawpage.obj \ + $(SLO)$/sc_stlsheet.obj \ + $(SLO)$/sc_stlpool.obj \ + $(SLO)$/sc_dptabsrc.obj \ + $(SLO)$/sc_dptabdat.obj \ + $(SLO)$/sc_dpshttab.obj \ + $(SLO)$/sc_dpoutput.obj \ + $(SLO)$/sc_dpobject.obj \ + $(SLO)$/sc_dpsave.obj \ + $(SLO)$/sc_pivot.obj \ + $(SLO)$/sc_pivot2.obj \ + $(SLO)$/sc_dbdocutl.obj \ + $(SLO)$/sc_pagepar.obj \ + $(SLO)$/sc_conditio.obj \ + $(SLO)$/sc_validat.obj \ + $(SLO)$/sc_sortparam.obj + +EXCEPTIONSFILES= \ + $(SLO)$/sc_documen6.obj \ + $(SLO)$/sc_dpobject.obj \ + $(SLO)$/sc_dpoutput.obj \ + $(SLO)$/sc_dpsave.obj \ + $(SLO)$/sc_dbdocutl.obj \ + $(SLO)$/sc_dptabsrc.obj \ + $(SLO)$/sc_globalx.obj + +# --- Tagets ------------------------------------------------------- + +.INCLUDE : target.mk + diff --git a/binfilter/bf_sc/source/core/data/sc_attarray.cxx b/binfilter/bf_sc/source/core/data/sc_attarray.cxx new file mode 100644 index 000000000000..1722c9990bf5 --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_attarray.cxx @@ -0,0 +1,1699 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +//------------------------------------------------------------------------ + +#include "scitems.hxx" +#include <bf_svx/algitem.hxx> +#include <bf_svx/boxitem.hxx> +#include <bf_svx/frmdiritem.hxx> +#include <bf_svx/shaditem.hxx> +#include <bf_svtools/poolcach.hxx> + +#include <bf_svx/fontitem.hxx> + +#include "attarray.hxx" +#include "document.hxx" +#include "docpool.hxx" +#include "patattr.hxx" +#include "stlsheet.hxx" +#include "stlpool.hxx" +#include "rechead.hxx" +#include "globstr.hrc" +namespace binfilter { + + +#undef DBG_INVALIDATE +/*N*/ #define DBGOUTPUT(s) \ +/*N*/ DBG_ERROR( String("Invalidate ") + String(s) + String(": ") \ +/*N*/ + String(nCol) + String('/') + String(aAdrStart.Row()) + String('/') + String(nTab) \ +/*N*/ + String(" bis ") \ +/*N*/ + String(nCol) + String('/') + String(aAdrEnd.Row()) + String('/') + String(nTab) \ +/*N*/ ); + +// STATIC DATA ----------------------------------------------------------- + + +//------------------------------------------------------------------------ + +/*N*/ ScAttrArray::ScAttrArray( USHORT nNewCol, USHORT nNewTab, ScDocument* pDoc ) : +/*N*/ nCol( nNewCol ), +/*N*/ nTab( nNewTab ), +/*N*/ pDocument( pDoc ) +/*N*/ { +/*N*/ ScDocumentPool* pDocPool = pDocument->GetPool(); +/*N*/ +/*N*/ nCount = nLimit = 1; +/*N*/ pData = new ScAttrEntry[1]; +/*N*/ if (pData) +/*N*/ { +/*N*/ pData[0].nRow = MAXROW; +/*N*/ pData[0].pPattern = pDocument->GetDefPattern(); // ohne Put !!! +/*N*/ } +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ ScAttrArray::~ScAttrArray() +/*N*/ { +/*N*/ #ifdef DBG_UTIL +/*N*/ TestData(); +/*N*/ #endif +/*N*/ +/*N*/ if (pData) +/*N*/ { +/*N*/ ScDocumentPool* pDocPool = pDocument->GetPool(); +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ pDocPool->Remove(*pData[i].pPattern); +/*N*/ +/*N*/ delete[] pData; +/*N*/ } +/*N*/ } + +//------------------------------------------------------------------------ + +#ifdef DBG_UTIL +/*N*/ void ScAttrArray::TestData() const +/*N*/ { +/*N*/ USHORT nErr = 0; +/*N*/ if (pData) +/*N*/ { +/*N*/ USHORT nPos=0; +/*N*/ for (nPos=0; nPos<nCount; nPos++) +/*N*/ { +/*N*/ if (nPos) +/*N*/ if (pData[nPos].pPattern == pData[nPos-1].pPattern || pData[nPos].nRow <= pData[nPos-1].nRow) +/*N*/ ++nErr; +/*N*/ if (pData[nPos].pPattern->Which() != ATTR_PATTERN) +/*N*/ ++nErr; +/*N*/ } +/*N*/ if ( nPos && pData[nPos-1].nRow != MAXROW ) +/*N*/ ++nErr; +/*N*/ } +/*N*/ if (nErr) +/*N*/ { +/*?*/ ByteString aMsg = ByteString::CreateFromInt32(nErr); +/*?*/ aMsg += " errors in attribute array, column "; +/*?*/ aMsg += ByteString::CreateFromInt32(nCol); +/*?*/ DBG_ERROR( aMsg.GetBuffer() ); +/*N*/ } +/*N*/ } +#endif + +//------------------------------------------------------------------------ + +/*N*/ void ScAttrArray::Reset( const ScPatternAttr* pPattern, BOOL bAlloc ) +/*N*/ { +/*N*/ if (pData) +/*N*/ { +/*N*/ ScDocumentPool* pDocPool = pDocument->GetPool(); +/*N*/ const ScPatternAttr* pOldPattern; +/*N*/ ScAddress aAdrStart( nCol, 0, nTab ); +/*N*/ ScAddress aAdrEnd ( nCol, 0, nTab ); +/*N*/ +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ { +/*N*/ // ueberpruefen, ob Attributierung die Textbreite der Zelle aendert +/*N*/ pOldPattern = pData[i].pPattern; +/*N*/ BOOL bNumFormatChanged; +/*N*/ if ( ScGlobal::CheckWidthInvalidate( bNumFormatChanged, +/*N*/ pPattern->GetItemSet(), pOldPattern->GetItemSet() ) ) +/*N*/ { +/*N*/ aAdrStart.SetRow( i ? pData[i-1].nRow+1 : 0 ); +/*N*/ aAdrEnd .SetRow( pData[i].nRow ); +/*N*/ pDocument->InvalidateTextWidth( &aAdrStart, &aAdrEnd, bNumFormatChanged ); +/*N*/ #ifdef DBG_INVALIDATE +/*N*/ DBGOUTPUT("Reset"); +/*N*/ #endif +/*N*/ } +/*N*/ // bedingtes Format gesetzt oder geloescht? +/*N*/ if ( &pPattern->GetItem(ATTR_CONDITIONAL) != &pOldPattern->GetItem(ATTR_CONDITIONAL) ) +/*N*/ { +/*?*/ pDocument->ConditionalChanged( ((const SfxUInt32Item&) +/*?*/ pOldPattern->GetItem(ATTR_CONDITIONAL)).GetValue() ); +/*?*/ pDocument->ConditionalChanged( ((const SfxUInt32Item&) +/*?*/ pPattern->GetItem(ATTR_CONDITIONAL)).GetValue() ); +/*N*/ } +/*N*/ pDocPool->Remove(*pOldPattern); +/*N*/ } +/*N*/ delete[] pData; +/*N*/ +/*N*/ if (bAlloc) +/*N*/ { +/*N*/ nCount = nLimit = 1; +/*N*/ pData = new ScAttrEntry[1]; +/*N*/ if (pData) +/*N*/ { +/*N*/ ScPatternAttr* pNewPattern = (ScPatternAttr*) &pDocPool->Put(*pPattern); +/*N*/ pData[0].nRow = MAXROW; +/*N*/ pData[0].pPattern = pNewPattern; +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ nCount = nLimit = 0; +/*N*/ pData = NULL; // muss sofort wieder belegt werden ! +/*N*/ } +/*N*/ } +/*N*/ } + + +/*N*/ BOOL ScAttrArray::Concat(USHORT nPos) +/*N*/ { +/*N*/ BOOL bRet = FALSE; +/*N*/ if (pData && (nPos < nCount)) +/*N*/ { +/*N*/ if (nPos > 0) +/*N*/ { +/*N*/ if (pData[nPos - 1].pPattern == pData[nPos].pPattern) +/*N*/ { +/*?*/ 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--; +/*?*/ bRet = TRUE; +/*N*/ } +/*N*/ } +/*N*/ if (nPos + 1 < nCount) +/*N*/ { +/*N*/ if (pData[nPos + 1].pPattern == pData[nPos].pPattern) +/*N*/ { +/*N*/ pData[nPos].nRow = pData[nPos + 1].nRow; +/*N*/ pDocument->GetPool()->Remove(*pData[nPos].pPattern); +/*N*/ memmove(&pData[nPos + 1], &pData[nPos + 2], (nCount - nPos - 2) * sizeof(ScAttrEntry)); +/*N*/ pData[nCount - 1].pPattern = NULL; +/*N*/ pData[nCount - 1].nRow = 0; +/*N*/ nCount--; +/*N*/ bRet = TRUE; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ return bRet; +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ BOOL ScAttrArray::Search( USHORT nRow, short& nIndex ) const +/*N*/ { +/*N*/ short nLo = 0; +/*N*/ short nHi = ((short) nCount) - 1; +/*N*/ short nStartRow = 0; +/*N*/ short nEndRow = 0; +/*N*/ short i = 0; +/*N*/ BOOL bFound = (nCount == 1); +/*N*/ if (pData) +/*N*/ { +/*N*/ while ( !bFound && nLo <= nHi ) +/*N*/ { +/*N*/ i = (nLo + nHi) / 2; +/*N*/ if (i > 0) +/*N*/ nStartRow = (short) pData[i - 1].nRow; +/*N*/ else +/*N*/ nStartRow = -1; +/*N*/ nEndRow = (short) pData[i].nRow; +/*N*/ if (nEndRow < (short) nRow) +/*N*/ nLo = ++i; +/*N*/ else +/*N*/ if (nStartRow >= (short) nRow) +/*N*/ nHi = --i; +/*N*/ else +/*N*/ bFound = TRUE; +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ bFound = FALSE; +/*N*/ +/*N*/ if (bFound) +/*N*/ nIndex=i; +/*N*/ else +/*N*/ nIndex=0; +/*N*/ return bFound; +/*N*/ } + + +/*N*/ const ScPatternAttr* ScAttrArray::GetPattern( USHORT nRow ) const +/*N*/ { +/*N*/ short i; +/*N*/ if (Search( nRow, i )) +/*N*/ return pData[i].pPattern; +/*N*/ else +/*N*/ return NULL; +/*N*/ } + + + +//------------------------------------------------------------------------ + +/*N*/ void ScAttrArray::SetPattern( USHORT nRow, const ScPatternAttr* pPattern, BOOL bPutToPool ) +/*N*/ { +/*N*/ SetPatternArea( nRow, nRow, pPattern, bPutToPool ); +/*N*/ } + + +/*N*/ void ScAttrArray::SetPatternArea(USHORT nStartRow, USHORT nEndRow, const ScPatternAttr *pPattern, BOOL bPutToPool ) +/*N*/ { +/*N*/ if (nStartRow >= 0 && nStartRow <= MAXROW && nEndRow >= 0 && nEndRow <= MAXROW) +/*N*/ { +/*N*/ if (bPutToPool) +/*N*/ pPattern = (const ScPatternAttr*) &pDocument->GetPool()->Put(*pPattern); +/*N*/ +/*N*/ if ((nStartRow == 0) && (nEndRow == MAXROW)) +/*N*/ Reset(pPattern); +/*N*/ else +/*N*/ { +/*N*/ USHORT nNeeded = nCount + 2; +/*N*/ if ( nLimit < nNeeded ) +/*N*/ { +/*N*/ nLimit += SC_ATTRARRAY_DELTA; +/*N*/ if ( nLimit < nNeeded ) +/*N*/ nLimit = nNeeded; +/*N*/ ScAttrEntry* pNewData = new ScAttrEntry[nLimit]; +/*N*/ memcpy( pNewData, pData, nCount*sizeof(ScAttrEntry) ); +/*N*/ delete[] pData; +/*N*/ pData = pNewData; +/*N*/ } +/*N*/ +/*N*/ ScAddress aAdrStart( nCol, 0, nTab ); +/*N*/ ScAddress aAdrEnd ( nCol, 0, nTab ); +/*N*/ +/*N*/ USHORT ni = 0; // number of entries in beginning +/*N*/ USHORT nx = 0; // track position +/*N*/ USHORT ns = 0; // start row of track position +/*N*/ if ( nStartRow > 0 ) +/*N*/ { +/*N*/ // skip beginning +/*N*/ short nIndex; +/*N*/ Search( nStartRow, nIndex ); +/*N*/ ni = nIndex; +/*N*/ +/*N*/ if ( ni ) +/*N*/ { +/*N*/ nx = ni; +/*N*/ ns = pData[ni-1].nRow+1; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // ueberpruefen, ob Attributierung die Textbreite der Zelle aendert +/*N*/ // oder bedingte Formate neu gesetzt oder geloescht werden +/*N*/ while ( ns <= nEndRow ) +/*N*/ { +/*N*/ const SfxItemSet& rNewSet = pPattern->GetItemSet(); +/*N*/ const SfxItemSet& rOldSet = pData[nx].pPattern->GetItemSet(); +/*N*/ +/*N*/ BOOL bNumFormatChanged; +/*N*/ if ( ScGlobal::CheckWidthInvalidate( bNumFormatChanged, +/*N*/ rNewSet, rOldSet ) ) +/*N*/ { +/*N*/ aAdrStart.SetRow( Max(nStartRow,ns) ); +/*N*/ aAdrEnd .SetRow( Min(nEndRow,pData[nx].nRow) ); +/*N*/ pDocument->InvalidateTextWidth( &aAdrStart, &aAdrEnd, bNumFormatChanged ); +/*N*/ #ifdef DBG_INVALIDATE +/*N*/ DBGOUTPUT("SetPatternArea"); +/*N*/ #endif +/*N*/ } +/*N*/ if ( &rNewSet.Get(ATTR_CONDITIONAL) != &rOldSet.Get(ATTR_CONDITIONAL) ) +/*N*/ { +/*N*/ pDocument->ConditionalChanged( ((const SfxUInt32Item&) +/*N*/ rOldSet.Get(ATTR_CONDITIONAL)).GetValue() ); +/*N*/ pDocument->ConditionalChanged( ((const SfxUInt32Item&) +/*N*/ rNewSet.Get(ATTR_CONDITIONAL)).GetValue() ); +/*N*/ } +/*N*/ ns = pData[nx].nRow + 1; +/*N*/ nx++; +/*N*/ } +/*N*/ +/*N*/ // continue modifying data array +/*N*/ +/*N*/ USHORT nInsert; // insert position (MAXROW+1 := no insert) +/*N*/ BOOL bCombined = FALSE; +/*N*/ BOOL bSplit = FALSE; +/*N*/ if ( nStartRow > 0 ) +/*N*/ { +/*N*/ nInsert = MAXROW+1; +/*N*/ if ( pData[ni].pPattern != pPattern ) +/*N*/ { +/*N*/ if ( ni == 0 || (pData[ni-1].nRow < nStartRow - 1) ) +/*N*/ { // may be a split or a simple insert or just a shrink, +/*N*/ // row adjustment is done further down +/*N*/ if ( pData[ni].nRow > nEndRow ) +/*N*/ bSplit = TRUE; +/*N*/ ni++; +/*N*/ nInsert = ni; +/*N*/ } +/*N*/ else if ( ni > 0 && pData[ni-1].nRow == nStartRow - 1 ) +/*N*/ nInsert = ni; +/*N*/ } +/*N*/ if ( ni > 0 && pData[ni-1].pPattern == pPattern ) +/*N*/ { // combine +/*N*/ pData[ni-1].nRow = nEndRow; +/*N*/ nInsert = MAXROW+1; +/*N*/ bCombined = TRUE; +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ nInsert = 0; +/*N*/ +/*N*/ USHORT nj = ni; // stop position of range to replace +/*N*/ while ( nj < nCount && pData[nj].nRow <= nEndRow ) +/*N*/ nj++; +/*N*/ if ( !bSplit ) +/*N*/ { +/*N*/ if ( nj < nCount && pData[nj].pPattern == pPattern ) +/*N*/ { // combine +/*N*/ if ( ni > 0 ) +/*N*/ { +/*N*/ if ( pData[ni-1].pPattern == pPattern ) +/*N*/ { // adjacent entries +/*N*/ pData[ni-1].nRow = pData[nj].nRow; +/*N*/ nj++; +/*N*/ } +/*N*/ else if ( ni == nInsert ) +/*N*/ pData[ni-1].nRow = nStartRow - 1; // shrink +/*N*/ } +/*N*/ nInsert = MAXROW+1; +/*N*/ bCombined = TRUE; +/*N*/ } +/*N*/ else if ( ni > 0 && ni == nInsert ) +/*N*/ pData[ni-1].nRow = nStartRow - 1; // shrink +/*N*/ } +/*N*/ ScDocumentPool* pDocPool = pDocument->GetPool(); +/*N*/ if ( bSplit ) +/*N*/ { // duplicate splitted entry in pool +/*N*/ pDocPool->Put( *pData[ni-1].pPattern ); +/*N*/ } +/*N*/ if ( ni < nj ) +/*N*/ { // remove middle entries +/*N*/ for ( USHORT nk=ni; nk<nj; nk++) +/*N*/ { // remove entries from pool +/*N*/ pDocPool->Remove( *pData[nk].pPattern ); +/*N*/ } +/*N*/ if ( !bCombined ) +/*N*/ { // replace one entry +/*N*/ pData[ni].nRow = nEndRow; +/*N*/ pData[ni].pPattern = pPattern; +/*N*/ ni++; +/*N*/ nInsert = MAXROW+1; +/*N*/ } +/*N*/ if ( ni < nj ) +/*N*/ { // remove entries +/*N*/ memmove( pData + ni, pData + nj, (nCount - nj) * sizeof(ScAttrEntry) ); +/*N*/ nCount -= nj - ni; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if ( nInsert <= MAXROW ) +/*N*/ { // insert or append new entry +/*N*/ if ( nInsert <= nCount ) +/*N*/ { +/*N*/ if ( !bSplit ) +/*N*/ memmove( pData + nInsert + 1, pData + nInsert, +/*N*/ (nCount - nInsert) * sizeof(ScAttrEntry) ); +/*N*/ else +/*N*/ { +/*N*/ memmove( pData + nInsert + 2, pData + nInsert, +/*N*/ (nCount - nInsert) * sizeof(ScAttrEntry) ); +/*N*/ pData[nInsert+1] = pData[nInsert-1]; +/*N*/ nCount++; +/*N*/ } +/*N*/ } +/*N*/ if ( nInsert ) +/*N*/ pData[nInsert-1].nRow = nStartRow - 1; +/*N*/ pData[nInsert].nRow = nEndRow; +/*N*/ pData[nInsert].pPattern = pPattern; +/*N*/ nCount++; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ // InfoBox(0, String(nCount) + String(" Eintraege") ).Execute(); +/*N*/ +/*N*/ #ifdef DBG_UTIL +/*N*/ TestData(); +/*N*/ #endif +/*N*/ } + + +/*N*/ void ScAttrArray::ApplyStyleArea( USHORT nStartRow, USHORT nEndRow, ScStyleSheet* pStyle ) +/*N*/ { +/*N*/ if (nStartRow >= 0 && nStartRow <= MAXROW && nEndRow >= 0 && nEndRow <= MAXROW) +/*N*/ { +/*N*/ short nPos; +/*N*/ USHORT nStart=0; +/*N*/ if (!Search( nStartRow, nPos )) +/*N*/ { +/*N*/ DBG_ERROR("Search-Fehler"); +/*N*/ return; +/*N*/ } +/*N*/ +/*N*/ ScAddress aAdrStart( nCol, 0, nTab ); +/*N*/ ScAddress aAdrEnd ( nCol, 0, nTab ); +/*N*/ +/*N*/ do +/*N*/ { +/*N*/ const ScPatternAttr* pOldPattern = pData[nPos].pPattern; +/*N*/ ScPatternAttr* pNewPattern = new ScPatternAttr(*pOldPattern); +/*N*/ pNewPattern->SetStyleSheet(pStyle); +/*N*/ USHORT nY1 = nStart; +/*N*/ USHORT nY2 = pData[nPos].nRow; +/*N*/ nStart = pData[nPos].nRow + 1; +/*N*/ +/*N*/ if ( *pNewPattern == *pOldPattern ) +/*N*/ { +/*N*/ // keep the original pattern (might be default) +/*N*/ // pNewPattern is deleted below +/*N*/ nPos++; +/*N*/ } +/*N*/ else if ( nY1 < nStartRow || nY2 > nEndRow ) +/*N*/ { +/*N*/ if (nY1 < nStartRow) nY1=nStartRow; +/*N*/ if (nY2 > nEndRow) nY2=nEndRow; +/*N*/ SetPatternArea( nY1, nY2, pNewPattern, TRUE ); +/*N*/ Search( nStart, nPos ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ // ueberpruefen, ob Attributierung die Textbreite der Zelle aendert +/*N*/ // bedingte Formate in Vorlagen gibt es (noch) nicht +/*N*/ +/*N*/ const SfxItemSet& rNewSet = pNewPattern->GetItemSet(); +/*N*/ const SfxItemSet& rOldSet = pOldPattern->GetItemSet(); +/*N*/ +/*N*/ BOOL bNumFormatChanged; +/*N*/ if ( ScGlobal::CheckWidthInvalidate( bNumFormatChanged, +/*N*/ rNewSet, rOldSet ) ) +/*N*/ { +/*N*/ aAdrStart.SetRow( nPos ? pData[nPos-1].nRow+1 : 0 ); +/*N*/ aAdrEnd .SetRow( pData[nPos].nRow ); +/*N*/ pDocument->InvalidateTextWidth( &aAdrStart, &aAdrEnd, bNumFormatChanged ); +/*N*/ #ifdef DBG_INVALIDATE +/*N*/ DBGOUTPUT("ApplyStyleArea"); +/*N*/ #endif +/*N*/ } +/*N*/ +/*N*/ pDocument->GetPool()->Remove(*pData[nPos].pPattern); +/*N*/ pData[nPos].pPattern = (const ScPatternAttr*) +/*N*/ &pDocument->GetPool()->Put(*pNewPattern); +/*N*/ if (Concat(nPos)) +/*?*/ Search(nStart, nPos); +/*N*/ else +/*N*/ nPos++; +/*N*/ } +/*N*/ delete pNewPattern; +/*N*/ } +/*N*/ while ((nStart <= nEndRow) && (nPos < (short)nCount)); +/*N*/ } +/*N*/ +/*N*/ #ifdef DBG_UTIL +/*N*/ TestData(); +/*N*/ #endif +/*N*/ } + + + // const wird weggecastet, weil es sonst + // zu ineffizient/kompliziert wird! + + + + +/*N*/ void ScAttrArray::ApplyCacheArea( USHORT nStartRow, USHORT nEndRow, SfxItemPoolCache* pCache ) +/*N*/ { +/*N*/ #ifdef DBG_UTIL +/*N*/ TestData(); +/*N*/ #endif +/*N*/ +/*N*/ if (nStartRow >= 0 && nStartRow <= MAXROW && nEndRow >= 0 && nEndRow <= MAXROW) +/*N*/ { +/*N*/ short nPos; +/*N*/ USHORT nStart=0; +/*N*/ if (!Search( nStartRow, nPos )) +/*N*/ { +/*N*/ DBG_ERROR("Search-Fehler"); +/*N*/ return; +/*N*/ } +/*N*/ +/*N*/ ScAddress aAdrStart( nCol, 0, nTab ); +/*N*/ ScAddress aAdrEnd ( nCol, 0, nTab ); +/*N*/ +/*N*/ do +/*N*/ { +/*N*/ const ScPatternAttr* pOldPattern = pData[nPos].pPattern; +/*N*/ const ScPatternAttr* pNewPattern = (const ScPatternAttr*) &pCache->ApplyTo( *pOldPattern, TRUE ); +/*N*/ ScDocumentPool::CheckRef( *pOldPattern ); +/*N*/ ScDocumentPool::CheckRef( *pNewPattern ); +/*N*/ if (pNewPattern != pOldPattern) +/*N*/ { +/*N*/ USHORT nY1 = nStart; +/*N*/ USHORT nY2 = pData[nPos].nRow; +/*N*/ nStart = pData[nPos].nRow + 1; +/*N*/ +/*N*/ if ( nY1 < nStartRow || nY2 > nEndRow ) +/*N*/ { +/*N*/ if (nY1 < nStartRow) nY1=nStartRow; +/*N*/ if (nY2 > nEndRow) nY2=nEndRow; +/*N*/ SetPatternArea( nY1, nY2, pNewPattern ); +/*N*/ Search( nStart, nPos ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ // ueberpruefen, ob Attributierung die Textbreite der Zelle aendert +/*N*/ +/*N*/ const SfxItemSet& rNewSet = pNewPattern->GetItemSet(); +/*N*/ const SfxItemSet& rOldSet = pOldPattern->GetItemSet(); +/*N*/ +/*N*/ BOOL bNumFormatChanged; +/*N*/ if ( ScGlobal::CheckWidthInvalidate( bNumFormatChanged, +/*N*/ rNewSet, rOldSet ) ) +/*N*/ { +/*N*/ aAdrStart.SetRow( nPos ? pData[nPos-1].nRow+1 : 0 ); +/*N*/ aAdrEnd .SetRow( pData[nPos].nRow ); +/*N*/ pDocument->InvalidateTextWidth( &aAdrStart, &aAdrEnd, bNumFormatChanged ); +/*N*/ #ifdef DBG_INVALIDATE +/*N*/ DBGOUTPUT("ApplyCacheArea"); +/*N*/ #endif +/*N*/ } +/*N*/ +/*N*/ // bedingte Formate neu gesetzt oder geloescht ? +/*N*/ +/*N*/ if ( &rNewSet.Get(ATTR_CONDITIONAL) != &rOldSet.Get(ATTR_CONDITIONAL) ) +/*N*/ { +/*?*/ pDocument->ConditionalChanged( ((const SfxUInt32Item&) +/*?*/ rOldSet.Get(ATTR_CONDITIONAL)).GetValue() ); +/*?*/ pDocument->ConditionalChanged( ((const SfxUInt32Item&) +/*?*/ rNewSet.Get(ATTR_CONDITIONAL)).GetValue() ); +/*N*/ } +/*N*/ +/*N*/ pDocument->GetPool()->Remove(*pData[nPos].pPattern); +/*N*/ pData[nPos].pPattern = pNewPattern; +/*N*/ if (Concat(nPos)) +/*?*/ Search(nStart, nPos); +/*N*/ else +/*N*/ ++nPos; +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*?*/ //!!!!!!!!!!!!!!!!!! mit diesem Remove gibt es Abstuerze (Calc1 Import) +/*?*/ //! pDocument->GetPool()->Remove(*pNewPattern); +/*?*/ nStart = pData[nPos].nRow + 1; +/*?*/ ++nPos; +/*N*/ } +/*N*/ } +/*N*/ while (nStart <= nEndRow); +/*N*/ } +/*N*/ +/*N*/ #ifdef DBG_UTIL +/*N*/ TestData(); +/*N*/ #endif +/*N*/ } + + +/*N*/ void lcl_MergeDeep( SfxItemSet& rMergeSet, const SfxItemSet& rSource ) +/*N*/ { +/*N*/ const SfxPoolItem* pNewItem; +/*N*/ const SfxPoolItem* pOldItem; +/*N*/ for (USHORT nId=ATTR_PATTERN_START; nId<=ATTR_PATTERN_END; nId++) +/*N*/ { +/*N*/ // pMergeSet hat keinen Parent +/*N*/ SfxItemState eOldState = rMergeSet.GetItemState( nId, FALSE, &pOldItem ); +/*N*/ +/*N*/ if ( eOldState == SFX_ITEM_DEFAULT ) // Default +/*N*/ { +/*N*/ SfxItemState eNewState = rSource.GetItemState( nId, TRUE, &pNewItem ); +/*N*/ if ( eNewState == SFX_ITEM_SET ) +/*N*/ { +/*N*/ if ( *pNewItem != rMergeSet.GetPool()->GetDefaultItem(nId) ) +/*N*/ rMergeSet.InvalidateItem( nId ); +/*N*/ } +/*N*/ } +/*N*/ else if ( eOldState == SFX_ITEM_SET ) // Item gesetzt +/*N*/ { +/*N*/ SfxItemState eNewState = rSource.GetItemState( nId, TRUE, &pNewItem ); +/*N*/ if ( eNewState == SFX_ITEM_SET ) +/*N*/ { +/*N*/ if ( pNewItem != pOldItem ) // beide gepuhlt +/*?*/ rMergeSet.InvalidateItem( nId ); +/*N*/ } +/*N*/ else // Default +/*N*/ { +/*N*/ if ( *pOldItem != rSource.GetPool()->GetDefaultItem(nId) ) +/*N*/ rMergeSet.InvalidateItem( nId ); +/*N*/ } +/*N*/ } +/*N*/ // Dontcare bleibt Dontcare +/*N*/ } +/*N*/ } + + +/*N*/ void ScAttrArray::MergePatternArea( USHORT nStartRow, USHORT nEndRow, +/*N*/ SfxItemSet** ppSet, BOOL bDeep ) const +/*N*/ { +/*N*/ if (nStartRow >= 0 && nStartRow <= MAXROW && nEndRow >= 0 && nEndRow <= MAXROW) +/*N*/ { +/*N*/ const ScPatternAttr* pOld1 = NULL; +/*N*/ const ScPatternAttr* pOld2 = NULL; +/*N*/ +/*N*/ short nPos; +/*N*/ USHORT nStart=0; +/*N*/ if (!Search( nStartRow, nPos )) +/*N*/ { +/*N*/ DBG_ERROR("Search-Fehler"); +/*N*/ return; +/*N*/ } +/*N*/ +/*N*/ do +/*N*/ { +/*N*/ // gleiche Patterns muessen nicht mehrfach angesehen werden +/*N*/ +/*N*/ const ScPatternAttr* pPattern = pData[nPos].pPattern; +/*N*/ if ( pPattern != pOld1 && pPattern != pOld2 ) +/*N*/ { +/*N*/ const SfxItemSet& rThisSet = pPattern->GetItemSet(); +/*N*/ if (*ppSet) +/*N*/ { +/*N*/ // (*ppSet)->MergeValues( rThisSet, FALSE ); +/*N*/ // geht nicht, weil die Vorlagen nicht beruecksichtigt werden +/*N*/ +/*N*/ if (bDeep) +/*N*/ lcl_MergeDeep( **ppSet, rThisSet ); +/*N*/ else +/*N*/ (*ppSet)->MergeValues( rThisSet, FALSE ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ // erstes Pattern - in Set ohne Parent kopieren +/*N*/ *ppSet = new SfxItemSet( *rThisSet.GetPool(), rThisSet.GetRanges() ); +/*N*/ (*ppSet)->Set( rThisSet, bDeep ); +/*N*/ } +/*N*/ +/*N*/ pOld2 = pOld1; +/*N*/ pOld1 = pPattern; +/*N*/ } +/*N*/ +/*N*/ nStart = pData[nPos].nRow + 1; +/*N*/ ++nPos; +/*N*/ } +/*N*/ while (nStart <= nEndRow); +/*N*/ } +/*N*/ } + + + +// Umrandung zusammenbauen + + + + + + +// +// Rahmen anwenden +// + +// ApplyFrame - auf einen Eintrag im Array + + + + + + + + + +// Testen, ob Bereich bestimmtes Attribut enthaelt + +/*N*/ BOOL ScAttrArray::HasAttrib( USHORT nRow1, USHORT nRow2, USHORT nMask ) const +/*N*/ { +/*N*/ short nStartIndex; +/*N*/ short nEndIndex; +/*N*/ Search( nRow1, nStartIndex ); +/*N*/ Search( nRow2, nEndIndex ); +/*N*/ BOOL bFound = FALSE; +/*N*/ +/*N*/ for (short i=nStartIndex; i<=nEndIndex && !bFound; i++) +/*N*/ { +/*N*/ const ScPatternAttr* pPattern = pData[i].pPattern; +/*N*/ if ( nMask & HASATTR_MERGED ) +/*N*/ { +/*N*/ const ScMergeAttr* pMerge = +/*N*/ (const ScMergeAttr*) &pPattern->GetItem( ATTR_MERGE ); +/*N*/ if ( pMerge->GetColMerge() > 1 || pMerge->GetRowMerge() > 1 ) +/*N*/ bFound = TRUE; +/*N*/ } +/*N*/ if ( nMask & ( HASATTR_OVERLAPPED | HASATTR_NOTOVERLAPPED | HASATTR_AUTOFILTER ) ) +/*N*/ { +/*N*/ const ScMergeFlagAttr* pMergeFlag = +/*N*/ (const ScMergeFlagAttr*) &pPattern->GetItem( ATTR_MERGE_FLAG ); +/*N*/ if ( (nMask & HASATTR_OVERLAPPED) && pMergeFlag->IsOverlapped() ) +/*N*/ bFound = TRUE; +/*N*/ if ( (nMask & HASATTR_NOTOVERLAPPED) && !pMergeFlag->IsOverlapped() ) +/*N*/ bFound = TRUE; +/*N*/ if ( (nMask & HASATTR_AUTOFILTER) && pMergeFlag->HasAutoFilter() ) +/*N*/ bFound = TRUE; +/*N*/ } +/*N*/ if ( nMask & HASATTR_LINES ) +/*N*/ { +/*N*/ const SvxBoxItem* pBox = +/*N*/ (const SvxBoxItem*) &pPattern->GetItem( ATTR_BORDER ); +/*N*/ if ( pBox->GetLeft() || pBox->GetRight() || pBox->GetTop() || pBox->GetBottom() ) +/*N*/ bFound = TRUE; +/*N*/ } +/*N*/ if ( nMask & HASATTR_SHADOW ) +/*N*/ { +/*N*/ const SvxShadowItem* pShadow = +/*N*/ (const SvxShadowItem*) &pPattern->GetItem( ATTR_SHADOW ); +/*N*/ if ( pShadow->GetLocation() != SVX_SHADOW_NONE ) +/*N*/ bFound = TRUE; +/*N*/ } +/*N*/ if ( nMask & HASATTR_CONDITIONAL ) +/*N*/ { +/*N*/ const SfxUInt32Item* pConditional = +/*N*/ (const SfxUInt32Item*) &pPattern->GetItem( ATTR_CONDITIONAL ); +/*N*/ if ( pConditional->GetValue() != 0 ) +/*N*/ bFound = TRUE; +/*N*/ } +/*N*/ if ( nMask & HASATTR_PROTECTED ) +/*N*/ { +/*N*/ const ScProtectionAttr* pProtect = +/*N*/ (const ScProtectionAttr*) &pPattern->GetItem( ATTR_PROTECTION ); +/*N*/ if ( pProtect->GetProtection() || pProtect->GetHideCell() ) +/*N*/ bFound = TRUE; +/*N*/ } +/*N*/ if ( nMask & HASATTR_ROTATE ) +/*N*/ { +/*N*/ const SfxInt32Item* pRotate = +/*N*/ (const SfxInt32Item*) &pPattern->GetItem( ATTR_ROTATE_VALUE ); +/*N*/ if ( pRotate->GetValue() != 0 ) +/*N*/ bFound = TRUE; +/*N*/ } +/*N*/ if ( nMask & HASATTR_NEEDHEIGHT ) +/*N*/ { +/*N*/ SvxCellOrientation eOrient = (SvxCellOrientation) +/*N*/ ((const SvxOrientationItem&)pPattern->GetItem( ATTR_ORIENTATION )).GetValue(); +/*N*/ if (eOrient != SVX_ORIENTATION_STANDARD) +/*N*/ bFound = TRUE; +/*N*/ else if (((const SfxBoolItem&)pPattern->GetItem( ATTR_LINEBREAK )).GetValue()) +/*N*/ bFound = TRUE; +/*N*/ else if ((SvxCellHorJustify)((const SvxHorJustifyItem&)pPattern-> +/*N*/ GetItem( ATTR_HOR_JUSTIFY )).GetValue() == SVX_HOR_JUSTIFY_BLOCK) +/*N*/ bFound = TRUE; +/*N*/ else if (((const SfxUInt32Item&)pPattern->GetItem( ATTR_CONDITIONAL )).GetValue()) +/*N*/ bFound = TRUE; +/*N*/ else if (((const SfxInt32Item&)pPattern->GetItem( ATTR_ROTATE_VALUE )).GetValue()) +/*N*/ bFound = TRUE; +/*N*/ } +/*N*/ if ( nMask & ( HASATTR_SHADOW_RIGHT | HASATTR_SHADOW_DOWN ) ) +/*N*/ { +/*N*/ const SvxShadowItem* pShadow = +/*N*/ (const SvxShadowItem*) &pPattern->GetItem( ATTR_SHADOW ); +/*N*/ SvxShadowLocation eLoc = pShadow->GetLocation(); +/*N*/ if ( nMask & HASATTR_SHADOW_RIGHT ) +/*N*/ if ( eLoc == SVX_SHADOW_TOPRIGHT || eLoc == SVX_SHADOW_BOTTOMRIGHT ) +/*N*/ bFound = TRUE; +/*N*/ if ( nMask & HASATTR_SHADOW_DOWN ) +/*N*/ if ( eLoc == SVX_SHADOW_BOTTOMLEFT || eLoc == SVX_SHADOW_BOTTOMRIGHT ) +/*N*/ bFound = TRUE; +/*N*/ } +/*N*/ if ( nMask & HASATTR_RTL ) +/*N*/ { +/*?*/ const SvxFrameDirectionItem& rDirection = +/*?*/ (const SvxFrameDirectionItem&) pPattern->GetItem( ATTR_WRITINGDIR ); +/*?*/ if ( rDirection.GetValue() == FRMDIR_HORI_RIGHT_TOP ) +/*?*/ bFound = TRUE; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ return bFound; +/*N*/ } + +// Bereich um evtl. enthaltene Zusammenfassungen erweitern +// und evtl. MergeFlag anpassen (bRefresh) + +/*N*/ BOOL ScAttrArray::ExtendMerge( USHORT nThisCol, USHORT nStartRow, USHORT nEndRow, +/*N*/ USHORT& rPaintCol, USHORT& rPaintRow, +/*N*/ BOOL bRefresh, BOOL bAttrs ) +/*N*/ { +/*N*/ const ScPatternAttr* pPattern; +/*N*/ const ScMergeAttr* pItem; +/*N*/ short nStartIndex; +/*N*/ short nEndIndex; +/*N*/ Search( nStartRow, nStartIndex ); +/*N*/ Search( nEndRow, nEndIndex ); +/*N*/ BOOL bFound = FALSE; +/*N*/ +/*N*/ for (short i=nStartIndex; i<=nEndIndex; i++) +/*N*/ { +/*N*/ pPattern = pData[i].pPattern; +/*N*/ pItem = (const ScMergeAttr*) &pPattern->GetItem( ATTR_MERGE ); +/*N*/ INT16 nCountX = pItem->GetColMerge(); +/*N*/ INT16 nCountY = pItem->GetRowMerge(); +/*N*/ if (nCountX>1 || nCountY>1) +/*N*/ { +/*N*/ USHORT nThisRow = (i>0) ? pData[i-1].nRow+1 : 0; +/*N*/ USHORT nMergeEndCol = nThisCol + nCountX - 1; +/*N*/ USHORT nMergeEndRow = nThisRow + nCountY - 1; +/*N*/ if (nMergeEndCol > rPaintCol && nMergeEndCol <= MAXCOL) +/*N*/ rPaintCol = nMergeEndCol; +/*N*/ if (nMergeEndRow > rPaintRow && nMergeEndRow <= MAXROW) +/*N*/ rPaintRow = nMergeEndRow; +/*N*/ bFound = TRUE; +/*N*/ +/*N*/ if (bAttrs) +/*N*/ { +/*N*/ const SvxShadowItem* pShadow = +/*N*/ (const SvxShadowItem*) &pPattern->GetItem( ATTR_SHADOW ); +/*N*/ SvxShadowLocation eLoc = pShadow->GetLocation(); +/*N*/ if ( eLoc == SVX_SHADOW_TOPRIGHT || eLoc == SVX_SHADOW_BOTTOMRIGHT ) +/*N*/ if ( nMergeEndCol+1 > rPaintCol && nMergeEndCol < MAXCOL ) +/*N*/ rPaintCol = nMergeEndCol+1; +/*N*/ if ( eLoc == SVX_SHADOW_BOTTOMLEFT || eLoc == SVX_SHADOW_BOTTOMRIGHT ) +/*?*/ if ( nMergeEndRow+1 > rPaintRow && nMergeEndRow < MAXROW ) +/*?*/ rPaintRow = nMergeEndRow+1; +/*N*/ } +/*N*/ +/*N*/ if (bRefresh) +/*N*/ { +/*?*/ 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 ); +/*?*/ +/*?*/ Search( nThisRow, i ); // Daten wurden veraendert +/*?*/ Search( nStartRow, nStartIndex ); +/*?*/ Search( nEndRow, nEndIndex ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ return bFound; +/*N*/ } + + +/*N*/ BOOL ScAttrArray::RemoveAreaMerge(USHORT nStartRow, USHORT nEndRow) +/*N*/ { +/*N*/ BOOL bFound = FALSE; +/*N*/ const ScPatternAttr* pPattern; +/*N*/ const ScMergeAttr* pItem; +/*N*/ short nIndex; +/*N*/ +/*N*/ Search( nStartRow, nIndex ); +/*N*/ USHORT nThisStart = (nIndex>0) ? pData[nIndex-1].nRow+1 : 0; +/*N*/ if (nThisStart < nStartRow) +/*N*/ nThisStart = nStartRow; +/*N*/ +/*N*/ while ( nThisStart <= nEndRow ) +/*N*/ { +/*N*/ USHORT nThisEnd = pData[nIndex].nRow; +/*N*/ if (nThisEnd > nEndRow) +/*N*/ nThisEnd = nEndRow; +/*N*/ +/*N*/ pPattern = pData[nIndex].pPattern; +/*N*/ pItem = (const ScMergeAttr*) &pPattern->GetItem( ATTR_MERGE ); +/*N*/ INT16 nCountX = pItem->GetColMerge(); +/*N*/ INT16 nCountY = pItem->GetRowMerge(); +/*N*/ if (nCountX>1 || nCountY>1) +/*N*/ { +/*N*/ const ScMergeAttr* pAttr = (const ScMergeAttr*) +/*N*/ &pDocument->GetPool()->GetDefaultItem( ATTR_MERGE ); +/*N*/ const ScMergeFlagAttr* pFlagAttr = (const ScMergeFlagAttr*) +/*N*/ &pDocument->GetPool()->GetDefaultItem( ATTR_MERGE_FLAG ); +/*N*/ +/*N*/ DBG_ASSERT( nCountY==1 || nThisStart==nThisEnd, "was'n hier los?" ); +/*N*/ +/*N*/ USHORT nThisCol = nCol; +/*N*/ USHORT nMergeEndCol = nThisCol + nCountX - 1; +/*N*/ USHORT nMergeEndRow = nThisEnd + nCountY - 1; +/*N*/ +/*N*/ //! ApplyAttr fuer Bereiche !!! +/*N*/ +/*N*/ for (USHORT nThisRow = nThisStart; nThisRow <= nThisEnd; nThisRow++) +/*N*/ pDocument->ApplyAttr( nThisCol, nThisRow, nTab, *pAttr ); +/*N*/ +/*N*/ ScPatternAttr* pNewPattern = new ScPatternAttr( pDocument->GetPool() ); +/*N*/ SfxItemSet* pSet = &pNewPattern->GetItemSet(); +/*N*/ pSet->Put( *pFlagAttr ); +/*N*/ pDocument->ApplyPatternAreaTab( nThisCol, nThisStart, nMergeEndCol, nMergeEndRow, +/*N*/ nTab, *pNewPattern ); +/*N*/ delete pNewPattern; +/*N*/ +/*N*/ Search( nThisEnd, nIndex ); // Daten wurden veraendert !!! +/*N*/ } +/*N*/ +/*N*/ ++nIndex; +/*N*/ if ( nIndex < (short) nCount ) +/*N*/ nThisStart = pData[nIndex-1].nRow+1; +/*N*/ else +/*N*/ nThisStart = MAXROW+1; // Ende +/*N*/ } +/*N*/ +/*N*/ return bFound; +/*N*/ } + + // Bereich loeschen, aber Merge-Flags stehenlassen + +/*N*/ void ScAttrArray::DeleteAreaSafe(USHORT nStartRow, USHORT nEndRow) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 SetPatternAreaSafe( nStartRow, nEndRow, pDocument->GetDefPattern(), TRUE ); +/*N*/ } + + + + +/*N*/ BOOL ScAttrArray::ApplyFlags( USHORT nStartRow, USHORT nEndRow, INT16 nFlags ) +/*N*/ { +/*N*/ const ScPatternAttr* pOldPattern; +/*N*/ +/*N*/ INT16 nOldValue; +/*N*/ short nIndex; +/*N*/ USHORT nRow; +/*N*/ USHORT nThisRow; +/*N*/ BOOL bChanged = FALSE; +/*N*/ +/*N*/ Search( nStartRow, nIndex ); +/*N*/ nThisRow = (nIndex>0) ? pData[nIndex-1].nRow+1 : 0; +/*N*/ if (nThisRow < nStartRow) nThisRow = nStartRow; +/*N*/ +/*N*/ while ( nThisRow <= nEndRow ) +/*N*/ { +/*N*/ pOldPattern = pData[nIndex].pPattern; +/*N*/ nOldValue = ((const ScMergeFlagAttr*) &pOldPattern->GetItem( ATTR_MERGE_FLAG ))->GetValue(); +/*N*/ if ( (nOldValue | nFlags) != nOldValue ) +/*N*/ { +/*N*/ nRow = pData[nIndex].nRow; +/*N*/ USHORT nAttrRow = Min( (USHORT)nRow, (USHORT)nEndRow ); +/*N*/ ScPatternAttr aNewPattern(*pOldPattern); +/*N*/ aNewPattern.GetItemSet().Put( ScMergeFlagAttr( nOldValue | nFlags ) ); +/*N*/ SetPatternArea( nThisRow, nAttrRow, &aNewPattern, TRUE ); +/*N*/ Search( nThisRow, nIndex ); // Daten wurden veraendert !!! +/*N*/ bChanged = TRUE; +/*N*/ } +/*N*/ +/*N*/ ++nIndex; +/*N*/ nThisRow = pData[nIndex-1].nRow+1; +/*N*/ } +/*N*/ +/*N*/ return bChanged; +/*N*/ } + + +/*N*/ BOOL ScAttrArray::RemoveFlags( USHORT nStartRow, USHORT nEndRow, INT16 nFlags ) +/*N*/ { +/*N*/ const ScPatternAttr* pOldPattern; +/*N*/ +/*N*/ INT16 nOldValue; +/*N*/ short nIndex; +/*N*/ USHORT nRow; +/*N*/ USHORT nThisRow; +/*N*/ BOOL bChanged = FALSE; +/*N*/ +/*N*/ Search( nStartRow, nIndex ); +/*N*/ nThisRow = (nIndex>0) ? pData[nIndex-1].nRow+1 : 0; +/*N*/ if (nThisRow < nStartRow) nThisRow = nStartRow; +/*N*/ +/*N*/ while ( nThisRow <= nEndRow ) +/*N*/ { +/*N*/ pOldPattern = pData[nIndex].pPattern; +/*N*/ nOldValue = ((const ScMergeFlagAttr*) &pOldPattern->GetItem( ATTR_MERGE_FLAG ))->GetValue(); +/*N*/ if ( (nOldValue & ~nFlags) != nOldValue ) +/*N*/ { +/*N*/ nRow = pData[nIndex].nRow; +/*N*/ USHORT nAttrRow = Min( (USHORT)nRow, (USHORT)nEndRow ); +/*N*/ ScPatternAttr aNewPattern(*pOldPattern); +/*N*/ aNewPattern.GetItemSet().Put( ScMergeFlagAttr( nOldValue & ~nFlags ) ); +/*N*/ SetPatternArea( nThisRow, nAttrRow, &aNewPattern, TRUE ); +/*N*/ Search( nThisRow, nIndex ); // Daten wurden veraendert !!! +/*N*/ bChanged = TRUE; +/*N*/ } +/*N*/ +/*N*/ ++nIndex; +/*N*/ nThisRow = pData[nIndex-1].nRow+1; +/*N*/ } +/*N*/ +/*N*/ return bChanged; +/*N*/ } + + +/*N*/ void ScAttrArray::ClearItems( USHORT nStartRow, USHORT nEndRow, const USHORT* pWhich ) +/*N*/ { +/*N*/ const ScPatternAttr* pOldPattern; +/*N*/ +/*N*/ short nIndex; +/*N*/ USHORT nRow; +/*N*/ USHORT nThisRow; +/*N*/ +/*N*/ Search( nStartRow, nIndex ); +/*N*/ nThisRow = (nIndex>0) ? pData[nIndex-1].nRow+1 : 0; +/*N*/ if (nThisRow < nStartRow) nThisRow = nStartRow; +/*N*/ +/*N*/ while ( nThisRow <= nEndRow ) +/*N*/ { +/*N*/ pOldPattern = pData[nIndex].pPattern; +/*N*/ if ( pOldPattern->HasItemsSet( pWhich ) ) +/*N*/ { +/*N*/ ScPatternAttr aNewPattern(*pOldPattern); +/*N*/ aNewPattern.ClearItems( pWhich ); +/*N*/ +/*N*/ nRow = pData[nIndex].nRow; +/*N*/ USHORT nAttrRow = Min( (USHORT)nRow, (USHORT)nEndRow ); +/*N*/ SetPatternArea( nThisRow, nAttrRow, &aNewPattern, TRUE ); +/*N*/ Search( nThisRow, nIndex ); // Daten wurden veraendert !!! +/*N*/ } +/*N*/ +/*N*/ ++nIndex; +/*N*/ nThisRow = pData[nIndex-1].nRow+1; +/*N*/ } +/*N*/ } + + + + + + +/*N*/ void ScAttrArray::FindStyleSheet( const SfxStyleSheetBase* pStyleSheet, BOOL* pUsed, BOOL bReset ) +/*N*/ { +/*N*/ USHORT nStart = 0; +/*N*/ short nPos = 0; +/*N*/ while (nPos < (short) nCount) +/*N*/ { +/*N*/ USHORT nEnd = pData[nPos].nRow; +/*N*/ if (pData[nPos].pPattern->GetStyleSheet() == pStyleSheet) +/*N*/ { +/*N*/ // for (USHORT nRow = nStart; nRow <= nEnd; nRow++) +/*N*/ // pUsed[nRow] = TRUE; +/*N*/ +/*N*/ memset( &pUsed[nStart], TRUE, nEnd-nStart+1 ); +/*N*/ +/*N*/ if (bReset) +/*N*/ { +/*?*/ 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); +/*?*/ --nPos; // wegen ++ am Ende +/*?*/ } +/*?*/ } +/*N*/ } +/*N*/ nStart = nEnd + 1; +/*N*/ ++nPos; +/*N*/ } +/*N*/ } + + +/*N*/ BOOL ScAttrArray::IsEmpty() const +/*N*/ { +/*N*/ if (nCount == 1) +/*N*/ { +/*N*/ if ( pData[0].pPattern != pDocument->GetDefPattern() ) +/*N*/ return FALSE; +/*N*/ else +/*N*/ return TRUE; +/*N*/ } +/*N*/ else +/*N*/ return FALSE; +/*N*/ } + + +/*N*/ BOOL ScAttrArray::HasVisibleAttr( USHORT& rFirstRow, USHORT& rLastRow, BOOL bSkipFirst ) const +/*N*/ { +/*N*/ DBG_ASSERT( nCount, "nCount == 0" ); +/*N*/ +/*N*/ BOOL bFound = FALSE; +/*N*/ USHORT nStart = 0; +/*N*/ +/*N*/ if ( bSkipFirst ) // Anfang ueberspringen, wenn >1 Zeile +/*N*/ { +/*N*/ USHORT nVisStart = 1; +/*N*/ while ( nVisStart < nCount && +/*N*/ pData[nVisStart].pPattern->IsVisibleEqual(*pData[nVisStart-1].pPattern) ) +/*N*/ ++nVisStart; +/*N*/ if ( nVisStart >= nCount || pData[nVisStart-1].nRow > 0 ) // mehr als 1 Zeile? +/*N*/ nStart = nVisStart; +/*N*/ } +/*N*/ +/*N*/ USHORT nVisCount = nCount-1; // am Ende zusammengehoerende weglassen +/*N*/ while ( nVisCount > nStart && +/*N*/ pData[nVisCount].pPattern->IsVisibleEqual(*pData[nVisCount-1].pPattern) ) +/*N*/ --nVisCount; +/*N*/ +/*N*/ while ( nStart < nVisCount && !bFound ) +/*N*/ { +/*N*/ if ( pData[nStart].pPattern->IsVisible() ) +/*N*/ { +/*N*/ rFirstRow = nStart ? ( pData[nStart-1].nRow + 1 ) : 0; +/*N*/ rLastRow = pData[nStart].nRow; +/*N*/ bFound = TRUE; +/*N*/ } +/*N*/ else +/*N*/ ++nStart; +/*N*/ } +/*N*/ +/*N*/ if (!bFound) +/*N*/ return FALSE; +/*N*/ +/*N*/ BOOL bEnd = FALSE; +/*N*/ USHORT nPos = nVisCount; +/*N*/ while ( nPos > nStart && !bEnd ) +/*N*/ { +/*N*/ --nPos; +/*N*/ if ( pData[nPos].pPattern->IsVisible() ) +/*N*/ { +/*N*/ rLastRow = pData[nPos].nRow; +/*N*/ bEnd = TRUE; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ return TRUE; +/*N*/ } + + + + +/*N*/ BOOL ScAttrArray::IsVisibleEqual( const ScAttrArray& rOther, +/*N*/ USHORT nStartRow, USHORT nEndRow ) const +/*N*/ { +/*N*/ BOOL bEqual = TRUE; +/*N*/ short nThisPos = 0; +/*N*/ short nOtherPos = 0; +/*N*/ if ( nStartRow ) +/*N*/ { +/*N*/ Search( nStartRow, nThisPos ); +/*N*/ rOther.Search( nStartRow, nOtherPos ); +/*N*/ } +/*N*/ +/*N*/ while ( nThisPos<nCount && nOtherPos<rOther.nCount && bEqual ) +/*N*/ { +/*N*/ USHORT nThisRow = pData[nThisPos].nRow; +/*N*/ USHORT nOtherRow = rOther.pData[nOtherPos].nRow; +/*N*/ const ScPatternAttr* pThisPattern = pData[nThisPos].pPattern; +/*N*/ const ScPatternAttr* pOtherPattern = rOther.pData[nOtherPos].pPattern; +/*N*/ bEqual = ( pThisPattern == pOtherPattern || +/*N*/ pThisPattern->IsVisibleEqual(*pOtherPattern) ); +/*N*/ +/*N*/ if ( nThisRow >= nOtherRow ) +/*N*/ { +/*N*/ if ( nOtherRow >= nEndRow ) break; +/*N*/ ++nOtherPos; +/*N*/ } +/*N*/ if ( nThisRow <= nOtherRow ) +/*N*/ { +/*N*/ if ( nThisRow >= nEndRow ) break; +/*N*/ ++nThisPos; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ return bEqual; +/*N*/ } + + +/*N*/ BOOL ScAttrArray::IsAllEqual( const ScAttrArray& rOther, USHORT nStartRow, USHORT nEndRow ) const +/*N*/ { +/*N*/ //! mit IsVisibleEqual zusammenfassen? +/*N*/ +/*N*/ BOOL bEqual = TRUE; +/*N*/ short nThisPos = 0; +/*N*/ short nOtherPos = 0; +/*N*/ if ( nStartRow ) +/*N*/ { +/*?*/ Search( nStartRow, nThisPos ); +/*?*/ rOther.Search( nStartRow, nOtherPos ); +/*N*/ } +/*N*/ +/*N*/ while ( nThisPos<nCount && nOtherPos<rOther.nCount && bEqual ) +/*N*/ { +/*N*/ USHORT nThisRow = pData[nThisPos].nRow; +/*N*/ USHORT nOtherRow = rOther.pData[nOtherPos].nRow; +/*N*/ const ScPatternAttr* pThisPattern = pData[nThisPos].pPattern; +/*N*/ const ScPatternAttr* pOtherPattern = rOther.pData[nOtherPos].pPattern; +/*N*/ bEqual = ( pThisPattern == pOtherPattern ); +/*N*/ +/*N*/ if ( nThisRow >= nOtherRow ) +/*N*/ { +/*N*/ if ( nOtherRow >= nEndRow ) break; +/*N*/ ++nOtherPos; +/*N*/ } +/*N*/ if ( nThisRow <= nOtherRow ) +/*N*/ { +/*N*/ if ( nThisRow >= nEndRow ) break; +/*N*/ ++nThisPos; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ return bEqual; +/*N*/ } + + +/*N*/ BOOL ScAttrArray::TestInsertCol( USHORT nStartRow, USHORT nEndRow) const +/*N*/ { +/*N*/ // horizontal zusammengefasste duerfen nicht herausgeschoben werden +/*N*/ // (ob die ganze Zusammenfassung betroffen ist, ist hier nicht zu erkennen) +/*N*/ +/*N*/ BOOL bTest = TRUE; +/*N*/ if (!IsEmpty()) +/*N*/ { +/*N*/ short nIndex = 0; +/*N*/ if ( nStartRow ) +/*N*/ Search( nStartRow, nIndex ); +/*N*/ +/*N*/ for ( ; nIndex < nCount; nIndex++ ) +/*N*/ { +/*N*/ if ( ((const ScMergeFlagAttr&)pData[nIndex].pPattern-> +/*N*/ GetItem(ATTR_MERGE_FLAG)).IsHorOverlapped() ) +/*N*/ { +/*N*/ bTest = FALSE; // darf nicht herausgeschoben werden +/*N*/ break; +/*N*/ } +/*N*/ if ( pData[nIndex].nRow >= nEndRow ) // Ende des Bereichs +/*N*/ break; +/*N*/ } +/*N*/ } +/*N*/ return bTest; +/*N*/ } + + +/*N*/ BOOL ScAttrArray::TestInsertRow( USHORT nSize ) const +/*N*/ { +/*N*/ // wenn die erste herausgeschobene Zeile vertikal ueberlappt ist, +/*N*/ // wuerde eine kaputte Zusammenfassung uebrigbleiben +/*N*/ +/*N*/ if (pData) +/*N*/ { +/*N*/ // MAXROW + 1 - nSize = erste herausgeschobene Zeile +/*N*/ +/*N*/ USHORT nFirstLost = nCount-1; +/*N*/ while ( nFirstLost && pData[nFirstLost-1].nRow >= MAXROW + 1 - nSize ) +/*N*/ --nFirstLost; +/*N*/ +/*N*/ if ( ((const ScMergeFlagAttr&)pData[nFirstLost].pPattern-> +/*N*/ GetItem(ATTR_MERGE_FLAG)).IsVerOverlapped() ) +/*N*/ return FALSE; +/*N*/ } +/*N*/ +/*N*/ return TRUE; +/*N*/ } + + +/*N*/ void ScAttrArray::InsertRow( USHORT nStartRow, USHORT nSize ) +/*N*/ { +/*N*/ if (!pData) +/*N*/ return; +/*N*/ +/*N*/ USHORT nSearch = nStartRow ? nStartRow - 1 : 0; // Vorgaenger erweitern +/*N*/ short nIndex; +/*N*/ Search( nSearch, nIndex ); +/*N*/ +/*N*/ // ein gesetztes ScMergeAttr darf nicht ausgedehnt werden +/*N*/ // (darum hinterher wieder loeschen) +/*N*/ +/*N*/ BOOL bDoMerge = ((const ScMergeAttr&) pData[nIndex].pPattern->GetItem(ATTR_MERGE)).IsMerged(); +/*N*/ +/*N*/ USHORT nRemove = 0; +/*N*/ USHORT i; +/*N*/ for (i = nIndex; i < nCount-1; i++) +/*N*/ { +/*N*/ USHORT nNew = pData[i].nRow + nSize; +/*N*/ if ( nNew >= MAXROW ) // Ende erreicht ? +/*N*/ { +/*N*/ nNew = MAXROW; +/*N*/ if (!nRemove) +/*N*/ nRemove = i+1; // folgende loeschen +/*N*/ } +/*N*/ pData[i].nRow = nNew; +/*N*/ } +/*N*/ +/*N*/ // muessen Eintraege am Ende geloescht werden? +/*N*/ +/*N*/ if (nRemove && nRemove < nCount) +/*N*/ DeleteRange( nRemove, nCount-1 ); +/*N*/ +/*N*/ if (bDoMerge) // ausgedehntes ScMergeAttr wieder reparieren +/*N*/ { +/*N*/ //! ApplyAttr fuer Bereiche !!! +/*N*/ +/*N*/ const SfxPoolItem& rDef = pDocument->GetPool()->GetDefaultItem( ATTR_MERGE ); +/*N*/ for (i=0; i<nSize; i++) +/*N*/ pDocument->ApplyAttr( nCol, nStartRow+i, nTab, rDef ); +/*N*/ +/*N*/ // im eingefuegten Bereich ist nichts zusammengefasst +/*N*/ } +/*N*/ +/*N*/ // Flags nicht duplizieren +/*N*/ //! direkt am Pattern testen ?? +/*N*/ RemoveFlags( nStartRow, nStartRow+nSize-1, SC_MF_HOR | SC_MF_VER | SC_MF_AUTO ); +/*N*/ } + + +/*N*/ void ScAttrArray::DeleteRow( USHORT nStartRow, USHORT nSize ) +/*N*/ { +/*N*/ if (pData) +/*N*/ { +/*N*/ BOOL bFirst=TRUE; +/*N*/ USHORT nStartIndex; +/*N*/ USHORT nEndIndex; +/*N*/ USHORT i = 0; +/*N*/ for (i = 0; i < nCount-1; i++) +/*N*/ if (pData[i].nRow >= nStartRow && pData[i].nRow <= nStartRow+nSize-1) +/*N*/ { +/*N*/ if (bFirst) +/*N*/ { +/*N*/ nStartIndex = i; +/*N*/ bFirst = FALSE; +/*N*/ } +/*N*/ nEndIndex = i; +/*N*/ } +/*N*/ if (!bFirst) +/*N*/ { +/*N*/ USHORT nStart; +/*N*/ if (nStartIndex==0) +/*N*/ nStart = 0; +/*N*/ else +/*N*/ nStart = pData[nStartIndex-1].nRow + 1; +/*N*/ +/*N*/ if (nStart < nStartRow) +/*N*/ { +/*N*/ pData[nStartIndex].nRow = nStartRow - 1; +/*N*/ ++nStartIndex; +/*N*/ } +/*N*/ if (nEndIndex >= nStartIndex) +/*N*/ { +/*N*/ DeleteRange( nStartIndex, nEndIndex ); +/*N*/ if (nStartIndex > 0) +/*N*/ if ( pData[nStartIndex-1].pPattern == pData[nStartIndex].pPattern ) +/*N*/ DeleteRange( nStartIndex-1, nStartIndex-1 ); +/*N*/ } +/*N*/ } +/*N*/ for (i = 0; i < nCount-1; i++) +/*N*/ if (pData[i].nRow >= nStartRow) +/*N*/ pData[i].nRow -= nSize; +/*N*/ +/*N*/ // unten nicht Default-Pattern nachschieben, um Druckbereiche erkennen zu koennen +/*N*/ // stattdessen nur Merge-Flags loeschen +/*N*/ +/*N*/ RemoveFlags( MAXROW-nSize+1, MAXROW, SC_MF_HOR | SC_MF_VER | SC_MF_AUTO ); +/*N*/ } +/*N*/ } + + +/*N*/ void ScAttrArray::DeleteRange( USHORT nStartIndex, USHORT nEndIndex ) +/*N*/ { +/*N*/ ScDocumentPool* pDocPool = pDocument->GetPool(); +/*N*/ for (USHORT i = nStartIndex; i <= nEndIndex; i++) +/*N*/ pDocPool->Remove(*pData[i].pPattern); +/*N*/ +/*N*/ memmove( &pData[nStartIndex], &pData[nEndIndex + 1], (nCount - nEndIndex - 1) * sizeof(ScAttrEntry) ); +/*N*/ nCount -= nEndIndex-nStartIndex+1; +/*N*/ } + + +/*N*/ void ScAttrArray::DeleteArea(USHORT nStartRow, USHORT nEndRow) +/*N*/ { +/*N*/ RemoveAreaMerge( nStartRow, nEndRow ); // von zusammengefassten auch die Flags loeschen +/*N*/ +/*N*/ if ( !HasAttrib( nStartRow, nEndRow, HASATTR_OVERLAPPED | HASATTR_AUTOFILTER) ) +/*N*/ SetPatternArea( nStartRow, nEndRow, pDocument->GetDefPattern() ); +/*N*/ else +/*?*/ DeleteAreaSafe( nStartRow, nEndRow ); // Merge-Flags stehenlassen +/*N*/ } + + +/*N*/ void ScAttrArray::DeleteHardAttr(USHORT nStartRow, USHORT nEndRow) +/*N*/ { +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 const ScPatternAttr* pDefPattern = pDocument->GetDefPattern(); +/*N*/ } + + // Verschieben innerhalb eines Dokuments + +/*N*/ void ScAttrArray::MoveTo(USHORT nStartRow, USHORT nEndRow, ScAttrArray& rAttrArray) +/*N*/ { +/*N*/ USHORT nStart = nStartRow; +/*N*/ for (USHORT i = 0; i < nCount; i++) +/*N*/ { +/*N*/ if ((pData[i].nRow >= nStartRow) && ((i==0) ? TRUE : pData[i-1].nRow < nEndRow)) +/*N*/ { +/*N*/ // Kopieren (bPutToPool=TRUE) +/*N*/ rAttrArray.SetPatternArea( nStart, Min( (USHORT)pData[i].nRow, (USHORT)nEndRow ), +/*N*/ pData[i].pPattern, TRUE ); +/*N*/ } +/*N*/ nStart = Max( (USHORT)nStart, (USHORT)(pData[i].nRow + 1) ); +/*N*/ } +/*N*/ DeleteArea(nStartRow, nEndRow); +/*N*/ } + + + // Kopieren zwischen Dokumenten (Clipboard) + +/*N*/ void ScAttrArray::CopyArea( USHORT nStartRow, USHORT nEndRow, short nDy, ScAttrArray& rAttrArray, +/*N*/ INT16 nStripFlags ) +/*N*/ { +/*N*/ nStartRow -= nDy; // Source +/*N*/ nEndRow -= nDy; +/*N*/ +/*N*/ USHORT nDestStart = Max((short)((short)nStartRow + nDy), (short) 0); +/*N*/ USHORT nDestEnd = Min((short)((short)nEndRow + nDy), (short) MAXROW); +/*N*/ +/*N*/ ScDocumentPool* pSourceDocPool = pDocument->GetPool(); +/*N*/ ScDocumentPool* pDestDocPool = rAttrArray.pDocument->GetPool(); +/*N*/ BOOL bSamePool = (pSourceDocPool==pDestDocPool); +/*N*/ +/*N*/ for (USHORT i = 0; (i < nCount) && (nDestStart <= nDestEnd); i++) +/*N*/ { +/*N*/ if (pData[i].nRow >= nStartRow) +/*N*/ { +/*N*/ const ScPatternAttr* pOldPattern = pData[i].pPattern; +/*N*/ const ScPatternAttr* pNewPattern; +/*N*/ +/*N*/ if (IsDefaultItem( pOldPattern )) +/*N*/ { +/*N*/ // am Default muss nichts veraendert werden +/*N*/ +/*N*/ pNewPattern = (const ScPatternAttr*) +/*N*/ &pDestDocPool->GetDefaultItem( ATTR_PATTERN ); +/*N*/ } +/*N*/ else if ( nStripFlags ) +/*N*/ { +/*?*/ ScPatternAttr* pTmpPattern = new ScPatternAttr( *pOldPattern ); +/*?*/ INT16 nNewFlags = 0; +/*?*/ 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; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ if (bSamePool) +/*N*/ pNewPattern = (ScPatternAttr*) &pDestDocPool->Put(*pOldPattern); +/*N*/ else +/*N*/ pNewPattern = pOldPattern->PutInPool( rAttrArray.pDocument, pDocument ); +/*N*/ } +/*N*/ +/*N*/ rAttrArray.SetPatternArea(nDestStart, +/*N*/ Min((USHORT)(pData[i].nRow + nDy), nDestEnd), pNewPattern); +/*N*/ } +/*N*/ +/*N*/ // when pasting from clipboard and skipping filtered rows, the adjusted end position +/*N*/ // can be negative +/*N*/ nDestStart = Max((short)nDestStart, (short)(pData[i].nRow + nDy + 1)); +/*N*/ } +/*N*/ } + + // Flags stehenlassen + //! mit CopyArea zusammenfassen !!! + + + + + + +//------------------------------------------------------------------------ +// +// Laden / Speichern +// + + +/*N*/ void ScAttrArray::Save( SvStream& rStream ) const +/*N*/ { +/*N*/ ScWriteHeader aHdr( rStream, 8 ); +/*N*/ +/*N*/ ScDocumentPool* pDocPool = pDocument->GetPool(); +/*N*/ +/*N*/ USHORT nSaveCount = nCount; +/*N*/ USHORT nSaveMaxRow = pDocument->GetSrcMaxRow(); +/*N*/ if ( nSaveMaxRow != MAXROW ) +/*N*/ { +/*?*/ if ( nSaveCount > 1 && pData[nSaveCount-2].nRow >= nSaveMaxRow ) +/*?*/ { +/*?*/ pDocument->SetLostData(); // Warnung ausgeben +/*?*/ do +/*?*/ --nSaveCount; +/*?*/ while ( nSaveCount > 1 && pData[nSaveCount-2].nRow >= nSaveMaxRow ); +/*?*/ } +/*N*/ } +/*N*/ +/*N*/ rStream << nSaveCount; +/*N*/ +/*N*/ const SfxPoolItem* pItem; +/*N*/ for (USHORT i=0; i<nSaveCount; i++) +/*N*/ { +/*N*/ rStream << Min( pData[i].nRow, nSaveMaxRow ); +/*N*/ +/*N*/ const ScPatternAttr* pPattern = pData[i].pPattern; +/*N*/ pDocPool->StoreSurrogate( rStream, pPattern ); +/*N*/ +/*N*/ // FALSE, weil ATTR_CONDITIONAL (noch) nicht in Vorlagen: +/*N*/ if (pPattern->GetItemSet().GetItemState(ATTR_CONDITIONAL,FALSE,&pItem) == SFX_ITEM_SET) +/*N*/ pDocument->SetConditionalUsed( ((const SfxUInt32Item*)pItem)->GetValue() ); +/*N*/ +/*N*/ if (pPattern->GetItemSet().GetItemState(ATTR_VALIDDATA,FALSE,&pItem) == SFX_ITEM_SET) +/*N*/ pDocument->SetValidationUsed( ((const SfxUInt32Item*)pItem)->GetValue() ); +/*N*/ } +/*N*/ } + + +/*N*/ void ScAttrArray::Load( SvStream& rStream ) +/*N*/ { +/*N*/ ScDocumentPool* pDocPool = pDocument->GetPool(); +/*N*/ +/*N*/ ScReadHeader aHdr( rStream ); +/*N*/ +/*N*/ USHORT nNewCount; +/*N*/ rStream >> nNewCount; +/*N*/ if ( nNewCount > MAXROW+1 ) // wuerde das Array zu gross? +/*N*/ { +/*?*/ pDocument->SetLostData(); +/*?*/ rStream.SetError( SVSTREAM_FILEFORMAT_ERROR ); +/*?*/ return; +/*N*/ } +/*N*/ +/*N*/ Reset( pDocument->GetDefPattern(), FALSE ); // loeschen +/*N*/ pData = new ScAttrEntry[nNewCount]; // neu anlegen +/*N*/ for (USHORT i=0; i<nNewCount; i++) +/*N*/ { +/*N*/ rStream >> pData[i].nRow; +/*N*/ +/*N*/ USHORT nWhich = ATTR_PATTERN; +/*N*/ const ScPatternAttr* pNewPattern = (const ScPatternAttr*) +/*N*/ pDocPool->LoadSurrogate( rStream, nWhich, ATTR_PATTERN ); +/*N*/ if (!pNewPattern) +/*N*/ { +/*?*/ // da is was schiefgelaufen +/*?*/ DBG_ERROR("ScAttrArray::Load: Surrogat nicht im Pool"); +/*?*/ pNewPattern = pDocument->GetDefPattern(); +/*N*/ } +/*N*/ ScDocumentPool::CheckRef( *pNewPattern ); +/*N*/ pData[i].pPattern = pNewPattern; +/*N*/ +/*N*/ // LoadSurrogate erhoeht auch die Ref +/*N*/ } +/*N*/ nCount = nLimit = nNewCount; +/*N*/ +/*N*/ if ( nCount > 1 && pData[nCount-2].nRow >= MAXROW ) // faengt ein Attribut hinter MAXROW an? +/*N*/ { +/*?*/ pDocument->SetLostData(); +/*?*/ rStream.SetError( SVSTREAM_FILEFORMAT_ERROR ); +/*?*/ return; +/*N*/ } +/*N*/ +/*N*/ if ( pDocument->GetSrcMaxRow() != MAXROW ) // Ende anpassen? +/*N*/ { +/*N*/ // Ende immer auf MAXROW umsetzen (nur auf 32 Bit) +/*N*/ +/*N*/ DBG_ASSERT( pData[nCount-1].nRow == pDocument->GetSrcMaxRow(), "Attribut-Ende ?!?" ); +/*N*/ pData[nCount-1].nRow = MAXROW; +/*N*/ } +/*N*/ } + + +/*N*/ void ScAttrArray::ConvertFontsAfterLoad() +/*N*/ { +/*N*/ ScFontToSubsFontConverter_AutoPtr xFontConverter; +/*N*/ const ULONG nFlags = FONTTOSUBSFONT_IMPORT | FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS; +/*N*/ short nIndex = 0; +/*N*/ USHORT nThisRow = 0; +/*N*/ +/*N*/ while ( nThisRow <= MAXROW ) +/*N*/ { +/*N*/ const ScPatternAttr* pOldPattern = pData[nIndex].pPattern; +/*N*/ const SfxPoolItem* pItem; +/*N*/ if( pOldPattern->GetItemSet().GetItemState( ATTR_FONT, FALSE, &pItem ) == SFX_ITEM_SET ) +/*N*/ { +/*N*/ const SvxFontItem* pFontItem = (const SvxFontItem*) pItem; +/*N*/ const String& rOldName = pFontItem->GetFamilyName(); +/*N*/ xFontConverter = CreateFontToSubsFontConverter( rOldName, nFlags ); +/*N*/ if ( xFontConverter ) +/*N*/ { +/*N*/ String aNewName( GetFontToSubsFontName( xFontConverter ) ); +/*N*/ if ( aNewName != rOldName ) +/*N*/ { +/*N*/ USHORT nAttrRow = pData[nIndex].nRow; +/*N*/ SvxFontItem aNewItem( pFontItem->GetFamily(), aNewName, +/*N*/ pFontItem->GetStyleName(), pFontItem->GetPitch(), +/*N*/ RTL_TEXTENCODING_DONTKNOW, ATTR_FONT ); +/*N*/ ScPatternAttr aNewPattern( *pOldPattern ); +/*N*/ aNewPattern.GetItemSet().Put( aNewItem ); +/*N*/ SetPatternArea( nThisRow, nAttrRow, &aNewPattern, TRUE ); +/*N*/ Search( nThisRow, nIndex ); //! data changed +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ ++nIndex; +/*N*/ nThisRow = pData[nIndex-1].nRow+1; +/*N*/ } +/*N*/ } + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_attrib.cxx b/binfilter/bf_sc/source/core/data/sc_attrib.cxx new file mode 100644 index 000000000000..0b59fbcb91f3 --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_attrib.cxx @@ -0,0 +1,1180 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + + +#include <com/sun/star/util/CellProtection.hpp> + +#include "scitems.hxx" +#define ITEMID_FIELD EE_FEATURE_FIELD + +#include <bf_svx/boxitem.hxx> +#include <bf_svx/editobj.hxx> + + + +#include <bf_svx/itemdata.hxx> + +#include <tools/date.hxx> + +#include <tools/time.hxx> + +#include <bf_svx/flditem.hxx> + +#include "attrib.hxx" +#include "editutil.hxx" +#include "bf_sc.hrc" +#include "globstr.hrc" + +#include "textuno.hxx" // ScHeaderFooterContentObj +namespace binfilter { + +using namespace ::com::sun::star; + +//------------------------------------------------------------------------ + +/*N*/ TYPEINIT1(ScMergeAttr, SfxPoolItem); +/*N*/ TYPEINIT1_AUTOFACTORY(ScProtectionAttr, SfxPoolItem); +/*N*/ TYPEINIT1(ScRangeItem, SfxPoolItem); +/*N*/ TYPEINIT1(ScTableListItem, SfxPoolItem); +/*N*/ TYPEINIT1(ScPageHFItem, SfxPoolItem); +/*N*/ TYPEINIT1(ScViewObjectModeItem, SfxEnumItem); +/*N*/ TYPEINIT1(ScDoubleItem, SfxPoolItem); + +//------------------------------------------------------------------------ + +// +// Item - Implementierungen +// + +//------------------------------------------------------------------------ +// Merge +//------------------------------------------------------------------------ + +/*N*/ ScMergeAttr::ScMergeAttr(): +/*N*/ SfxPoolItem(ATTR_MERGE), +/*N*/ nColMerge(0), +/*N*/ nRowMerge(0) +/*N*/ {} + +//------------------------------------------------------------------------ + +/*N*/ ScMergeAttr::ScMergeAttr( INT16 nCol, INT16 nRow): +/*N*/ SfxPoolItem(ATTR_MERGE), +/*N*/ nColMerge(nCol), +/*N*/ nRowMerge(nRow) +/*N*/ {} + +//------------------------------------------------------------------------ + +/*N*/ ScMergeAttr::ScMergeAttr(const ScMergeAttr& rItem): +/*N*/ SfxPoolItem(ATTR_MERGE) +/*N*/ { +/*N*/ nColMerge = rItem.nColMerge; +/*N*/ nRowMerge = rItem.nRowMerge; +/*N*/ } + +/*N*/ __EXPORT ScMergeAttr::~ScMergeAttr() +/*N*/ { +/*N*/ } + +//------------------------------------------------------------------------ + + +//------------------------------------------------------------------------ + +/*N*/ int __EXPORT ScMergeAttr::operator==( const SfxPoolItem& rItem ) const +/*N*/ { +/*N*/ DBG_ASSERT( Which() != rItem.Which() || Type() == rItem.Type(), "which ==, type !=" ); +/*N*/ return (Which() == rItem.Which()) +/*N*/ && (nColMerge == ((ScMergeAttr&)rItem).nColMerge) +/*N*/ && (nRowMerge == ((ScMergeAttr&)rItem).nRowMerge); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ SfxPoolItem* __EXPORT ScMergeAttr::Clone( SfxItemPool * ) const +/*N*/ { +/*N*/ return new ScMergeAttr(*this); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ SfxPoolItem* __EXPORT ScMergeAttr::Create( SvStream& rStream, USHORT nVer ) const +/*N*/ { +/*N*/ INT16 nCol; +/*N*/ INT16 nRow; +/*N*/ rStream >> nCol; +/*N*/ rStream >> nRow; +/*N*/ return new ScMergeAttr(nCol,nRow); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ SvStream& __EXPORT ScMergeAttr::Store( SvStream& rStream, USHORT nVer ) const +/*N*/ { +/*N*/ rStream << nColMerge; +/*N*/ rStream << nRowMerge; +/*N*/ return rStream; +/*N*/ } + +//------------------------------------------------------------------------ +// MergeFlag +//------------------------------------------------------------------------ + +/*N*/ ScMergeFlagAttr::ScMergeFlagAttr(): +/*N*/ SfxInt16Item(ATTR_MERGE_FLAG, 0) +/*N*/ { +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ ScMergeFlagAttr::ScMergeFlagAttr(INT16 nFlags): +/*N*/ SfxInt16Item(ATTR_MERGE_FLAG, nFlags) +/*N*/ { +/*N*/ } + +/*N*/ __EXPORT ScMergeFlagAttr::~ScMergeFlagAttr() +/*N*/ { +/*N*/ } + +//------------------------------------------------------------------------ +// Protection +//------------------------------------------------------------------------ + +/*N*/ ScProtectionAttr::ScProtectionAttr(): +/*N*/ SfxPoolItem(ATTR_PROTECTION), +/*N*/ bProtection(TRUE), +/*N*/ bHideFormula(FALSE), +/*N*/ bHideCell(FALSE), +/*N*/ bHidePrint(FALSE) +/*N*/ { +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ ScProtectionAttr::ScProtectionAttr( BOOL bProtect, BOOL bHFormula, +/*N*/ BOOL bHCell, BOOL bHPrint): +/*N*/ SfxPoolItem(ATTR_PROTECTION), +/*N*/ bProtection(bProtect), +/*N*/ bHideFormula(bHFormula), +/*N*/ bHideCell(bHCell), +/*N*/ bHidePrint(bHPrint) +/*N*/ { +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ ScProtectionAttr::ScProtectionAttr(const ScProtectionAttr& rItem): +/*N*/ SfxPoolItem(ATTR_PROTECTION) +/*N*/ { +/*N*/ bProtection = rItem.bProtection; +/*N*/ bHideFormula = rItem.bHideFormula; +/*N*/ bHideCell = rItem.bHideCell; +/*N*/ bHidePrint = rItem.bHidePrint; +/*N*/ } + +/*N*/ __EXPORT ScProtectionAttr::~ScProtectionAttr() +/*N*/ { +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ bool __EXPORT ScProtectionAttr::QueryValue( uno::Any& rVal, BYTE nMemberId ) const +/*N*/ { +/*N*/ nMemberId &= ~CONVERT_TWIPS; +/*N*/ switch ( nMemberId ) +/*N*/ { +/*N*/ case 0 : +/*N*/ { +/*N*/ util::CellProtection aProtection; +/*N*/ aProtection.IsLocked = bProtection; +/*N*/ aProtection.IsFormulaHidden = bHideFormula; +/*N*/ aProtection.IsHidden = bHideCell; +/*N*/ aProtection.IsPrintHidden = bHidePrint; +/*N*/ rVal <<= aProtection; +/*N*/ break; +/*N*/ } +/*N*/ case MID_1 : +/*N*/ rVal <<= (sal_Bool ) bProtection; break; +/*N*/ case MID_2 : +/*N*/ rVal <<= (sal_Bool ) bHideFormula; break; +/*N*/ case MID_3 : +/*N*/ rVal <<= (sal_Bool ) bHideCell; break; +/*N*/ case MID_4 : +/*N*/ rVal <<= (sal_Bool ) bHidePrint; break; +/*N*/ default: +/*N*/ DBG_ERROR("Wrong MemberID!"); +/*N*/ return false; +/*N*/ } +/*N*/ +/*N*/ return true; +/*N*/ } + +/*N*/ bool __EXPORT ScProtectionAttr::PutValue( const uno::Any& rVal, BYTE nMemberId ) +/*N*/ { +/*N*/ bool bRet = false; +/*N*/ sal_Bool bVal; +/*N*/ nMemberId &= ~CONVERT_TWIPS; +/*N*/ switch ( nMemberId ) +/*N*/ { +/*N*/ case 0 : +/*N*/ { +/*N*/ util::CellProtection aProtection; +/*N*/ if ( rVal >>= aProtection ) +/*N*/ { +/*N*/ bProtection = aProtection.IsLocked; +/*N*/ bHideFormula = aProtection.IsFormulaHidden; +/*N*/ bHideCell = aProtection.IsHidden; +/*N*/ bHidePrint = aProtection.IsPrintHidden; +/*N*/ bRet = true; +/*N*/ } +/*N*/ else +/*N*/ DBG_ERROR("exception - wrong argument"); +/*N*/ break; +/*N*/ } +/*N*/ case MID_1 : +/*N*/ bRet = (rVal >>= bVal); if (bRet) bProtection=bVal; break; +/*N*/ case MID_2 : +/*N*/ bRet = (rVal >>= bVal); if (bRet) bHideFormula=bVal; break; +/*N*/ case MID_3 : +/*N*/ bRet = (rVal >>= bVal); if (bRet) bHideCell=bVal; break; +/*N*/ case MID_4 : +/*N*/ bRet = (rVal >>= bVal); if (bRet) bHidePrint=bVal; break; +/*N*/ default: +/*N*/ DBG_ERROR("Wrong MemberID!"); +/*N*/ } +/*N*/ +/*N*/ return bRet; +/*N*/ } + +//------------------------------------------------------------------------ + + +//------------------------------------------------------------------------ + + +//------------------------------------------------------------------------ + +/*N*/ int __EXPORT ScProtectionAttr::operator==( const SfxPoolItem& rItem ) const +/*N*/ { +/*N*/ DBG_ASSERT( Which() != rItem.Which() || Type() == rItem.Type(), "which ==, type !=" ); +/*N*/ return (Which() == rItem.Which()) +/*N*/ && (bProtection == ((ScProtectionAttr&)rItem).bProtection) +/*N*/ && (bHideFormula == ((ScProtectionAttr&)rItem).bHideFormula) +/*N*/ && (bHideCell == ((ScProtectionAttr&)rItem).bHideCell) +/*N*/ && (bHidePrint == ((ScProtectionAttr&)rItem).bHidePrint); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ SfxPoolItem* __EXPORT ScProtectionAttr::Clone( SfxItemPool * ) const +/*N*/ { +/*N*/ return new ScProtectionAttr(*this); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ SfxPoolItem* __EXPORT ScProtectionAttr::Create( SvStream& rStream, USHORT n ) const +/*N*/ { +/*N*/ BOOL bProtect; +/*N*/ BOOL bHFormula; +/*N*/ BOOL bHCell; +/*N*/ BOOL bHPrint; +/*N*/ +/*N*/ rStream >> bProtect; +/*N*/ rStream >> bHFormula; +/*N*/ rStream >> bHCell; +/*N*/ rStream >> bHPrint; +/*N*/ +/*N*/ return new ScProtectionAttr(bProtect,bHFormula,bHCell,bHPrint); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ SvStream& __EXPORT ScProtectionAttr::Store( SvStream& rStream, USHORT nVer ) const +/*N*/ { +/*N*/ rStream << bProtection; +/*N*/ rStream << bHideFormula; +/*N*/ rStream << bHideCell; +/*N*/ rStream << bHidePrint; +/*N*/ +/*N*/ return rStream; +/*N*/ } + +//------------------------------------------------------------------------ + + +//------------------------------------------------------------------------ + + +//------------------------------------------------------------------------ + + +//------------------------------------------------------------------------ + + +// ----------------------------------------------------------------------- +// ScRangeItem - Tabellenbereich +// ----------------------------------------------------------------------- + + +// ----------------------------------------------------------------------- + + +// ----------------------------------------------------------------------- + +/*N*/ int __EXPORT ScRangeItem::operator==( const SfxPoolItem& rAttr ) const +/*N*/ { +/*N*/ DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" ); +/*N*/ +/*N*/ return ( aRange == ( (ScRangeItem&)rAttr ).aRange ); +/*N*/ } + +// ----------------------------------------------------------------------- + +/*N*/ SfxPoolItem* __EXPORT ScRangeItem::Clone( SfxItemPool* ) const +/*N*/ { +/*N*/ return new ScRangeItem( *this ); +/*N*/ } + +//------------------------------------------------------------------------ + + +//----------------------------------------------------------------------- + +/*N*/ USHORT __EXPORT ScRangeItem::GetVersion( USHORT nFileVersion ) const +/*N*/ { +/*N*/ return 2; +/*N*/ } + +//----------------------------------------------------------------------- + +/*N*/ SvStream& __EXPORT ScRangeItem::Store( SvStream& rStrm, USHORT nVer ) const +/*N*/ { +/*N*/ rStrm << aRange; +/*N*/ rStrm << nFlags; +/*N*/ +/*N*/ return rStrm; +/*N*/ } + +//----------------------------------------------------------------------- + +/*N*/ SfxPoolItem* __EXPORT ScRangeItem::Create( SvStream& rStream, USHORT nVersion ) const +/*N*/ { +/*N*/ ScRange aNewRange; +/*N*/ BOOL nNewFlags = FALSE; +/*N*/ +/*N*/ switch ( nVersion ) +/*N*/ { +/*N*/ case 2: +/*N*/ rStream >> aNewRange; +/*N*/ rStream >> nNewFlags; +/*N*/ break; +/*N*/ +/*N*/ case 1: +/*N*/ rStream >> aNewRange; +/*N*/ nNewFlags = 0; +/*N*/ break; +/*N*/ +/*N*/ case 0: +/*N*/ { +/*N*/ // alte Version mit ScArea -> 5 USHORTs lesen +/*N*/ ScAddress& rStart = aNewRange.aStart; +/*N*/ ScAddress& rEnd = aNewRange.aEnd; +/*N*/ USHORT n; +/*N*/ +/*N*/ rStream >> n; +/*N*/ +/*N*/ if ( n > MAXTAB ) +/*N*/ { +/*N*/ nNewFlags = SCR_ALLTABS; +/*N*/ rStart.SetTab( 0 ); rEnd.SetTab( 0 ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ nNewFlags = 0; +/*N*/ rStart.SetTab( n ); rEnd.SetTab( n ); +/*N*/ } +/*N*/ +/*N*/ rStream >> n; rStart.SetCol( n ); +/*N*/ rStream >> n; rStart.SetRow( n ); +/*N*/ rStream >> n; rEnd .SetCol( n ); +/*N*/ rStream >> n; rEnd .SetRow( n ); +/*N*/ } +/*N*/ break; +/*N*/ +/*N*/ default: +/*N*/ DBG_ERROR( "ScRangeItem::Create: Unknown Version!" ); +/*N*/ } +/*N*/ +/*N*/ return ( new ScRangeItem( Which(), aNewRange, nNewFlags ) ); +/*N*/ } + + +// ----------------------------------------------------------------------- +// ScTableListItem - Liste von Tabellen(-nummern) +// ----------------------------------------------------------------------- + +/*N*/ ScTableListItem::ScTableListItem( const ScTableListItem& rCpy ) +/*N*/ : SfxPoolItem ( rCpy.Which() ), +/*N*/ nCount ( rCpy.nCount ) +/*N*/ { +/*N*/ if ( nCount > 0 ) +/*N*/ { +/*N*/ pTabArr = new USHORT [nCount]; +/*N*/ +/*N*/ for ( USHORT i=0; i<nCount; i++ ) +/*N*/ pTabArr[i] = rCpy.pTabArr[i]; +/*N*/ } +/*N*/ else +/*N*/ pTabArr = NULL; +/*N*/ } + +// ----------------------------------------------------------------------- + +/*N*/ ScTableListItem::ScTableListItem( const USHORT nWhich, const List& rList ) +/*N*/ : SfxPoolItem ( nWhich ), +/*N*/ nCount ( 0 ), +/*N*/ pTabArr ( NULL ) +/*N*/ { +/*N*/ SetTableList( rList ); +/*N*/ } + +// ----------------------------------------------------------------------- + +/*N*/ __EXPORT ScTableListItem::~ScTableListItem() +/*N*/ { +/*N*/ delete [] pTabArr; +/*N*/ } + +// ----------------------------------------------------------------------- + + +// ----------------------------------------------------------------------- + + +// ----------------------------------------------------------------------- + + +// ----------------------------------------------------------------------- + +/*N*/ int __EXPORT ScTableListItem::operator==( const SfxPoolItem& rAttr ) const +/*N*/ { +/*N*/ DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" ); +/*N*/ +/*N*/ ScTableListItem& rCmp = (ScTableListItem&)rAttr; +/*N*/ BOOL bEqual = (nCount == rCmp.nCount); +/*N*/ +/*N*/ if ( nCount > 0 ) +/*N*/ { +/*N*/ USHORT i=0; +/*N*/ +/*N*/ bEqual = ( pTabArr && rCmp.pTabArr ); +/*N*/ +/*N*/ while ( bEqual && i<nCount ) +/*N*/ { +/*N*/ bEqual = ( pTabArr[i] == rCmp.pTabArr[i] ); +/*N*/ i++; +/*N*/ } +/*N*/ } +/*N*/ return bEqual; +/*N*/ } + +// ----------------------------------------------------------------------- + +/*N*/ SfxPoolItem* __EXPORT ScTableListItem::Clone( SfxItemPool* ) const +/*N*/ { +/*N*/ return new ScTableListItem( *this ); +/*N*/ } + +//------------------------------------------------------------------------ + + +//----------------------------------------------------------------------- + +/*N*/ SvStream& __EXPORT ScTableListItem::Store( SvStream& rStrm, USHORT nVer ) const +/*N*/ { +/*N*/ rStrm << nCount; +/*N*/ +/*N*/ if ( nCount>0 && pTabArr ) +/*N*/ for ( USHORT i=0; i<nCount; i++ ) +/*N*/ rStrm << pTabArr[i]; +/*N*/ +/*N*/ return rStrm; +/*N*/ } + +//----------------------------------------------------------------------- + +/*N*/ SfxPoolItem* __EXPORT ScTableListItem::Create( SvStream& rStrm, USHORT ) const +/*N*/ { +/*N*/ ScTableListItem* pNewItem; +/*N*/ List aList; +/*N*/ USHORT* p; +/*N*/ USHORT nTabCount; +/*N*/ USHORT nTabNo; +/*N*/ +/*N*/ rStrm >> nTabCount; +/*N*/ +/*N*/ if ( nTabCount > 0 ) +/*N*/ { +/*N*/ for ( USHORT i=0; i<nTabCount; i++ ) +/*N*/ { +/*N*/ rStrm >> nTabNo; +/*N*/ aList.Insert( new USHORT(nTabNo) ); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ pNewItem = new ScTableListItem( Which(), aList ); +/*N*/ +/*N*/ aList.First(); +/*N*/ while ( p = (USHORT*)aList.Remove() ) +/*N*/ delete p; +/*N*/ +/*N*/ return pNewItem; +/*N*/ } + +// ----------------------------------------------------------------------- + + +// ----------------------------------------------------------------------- + +/*N*/ void ScTableListItem::SetTableList( const List& rList ) +/*N*/ { +/*N*/ nCount = (USHORT)rList.Count(); +/*N*/ +/*N*/ delete [] pTabArr; +/*N*/ +/*N*/ if ( nCount > 0 ) +/*N*/ { +/*N*/ pTabArr = new USHORT [nCount]; +/*N*/ +/*N*/ for ( USHORT i=0; i<nCount; i++ ) +/*N*/ pTabArr[i] = *( (USHORT*)rList.GetObject( i ) ); +/*N*/ } +/*N*/ else +/*N*/ pTabArr = NULL; +/*N*/ } + + +// ----------------------------------------------------------------------- +// ScPageHFItem - Daten der Kopf-/Fußzeilen +// ----------------------------------------------------------------------- + +/*N*/ ScPageHFItem::ScPageHFItem( USHORT nWhich ) +/*N*/ : SfxPoolItem ( nWhich ), +/*N*/ pLeftArea ( NULL ), +/*N*/ pCenterArea ( NULL ), +/*N*/ pRightArea ( NULL ) +/*N*/ { +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ ScPageHFItem::ScPageHFItem( const ScPageHFItem& rItem ) +/*N*/ : SfxPoolItem ( rItem ), +/*N*/ pLeftArea ( NULL ), +/*N*/ pCenterArea ( NULL ), +/*N*/ pRightArea ( NULL ) +/*N*/ { +/*N*/ if ( rItem.pLeftArea ) +/*N*/ pLeftArea = rItem.pLeftArea->Clone(); +/*N*/ if ( rItem.pCenterArea ) +/*N*/ pCenterArea = rItem.pCenterArea->Clone(); +/*N*/ if ( rItem.pRightArea ) +/*N*/ pRightArea = rItem.pRightArea->Clone(); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ __EXPORT ScPageHFItem::~ScPageHFItem() +/*N*/ { +/*N*/ delete pLeftArea; +/*N*/ delete pCenterArea; +/*N*/ delete pRightArea; +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ bool __EXPORT ScPageHFItem::QueryValue( uno::Any& rVal, BYTE nMemberId ) const +/*N*/ { +/*N*/ uno::Reference<sheet::XHeaderFooterContent> xContent = +/*N*/ new ScHeaderFooterContentObj( pLeftArea, pCenterArea, pRightArea ); +/*N*/ +/*N*/ rVal <<= xContent; +/*N*/ return true; +/*N*/ } + +/*N*/ bool __EXPORT ScPageHFItem::PutValue( const uno::Any& rVal, BYTE nMemberId ) +/*N*/ { +/*N*/ bool bRet = false; +/*N*/ uno::Reference<sheet::XHeaderFooterContent> xContent; +/*N*/ if ( rVal >>= xContent ) +/*N*/ { +/*N*/ if ( xContent.is() ) +/*N*/ { +/*N*/ ScHeaderFooterContentObj* pImp = +/*N*/ ScHeaderFooterContentObj::getImplementation( xContent ); +/*N*/ if (pImp) +/*N*/ { +/*N*/ const EditTextObject* pImpLeft = pImp->GetLeftEditObject(); +/*N*/ delete pLeftArea; +/*N*/ pLeftArea = pImpLeft ? pImpLeft->Clone() : NULL; +/*N*/ +/*N*/ const EditTextObject* pImpCenter = pImp->GetCenterEditObject(); +/*N*/ delete pCenterArea; +/*N*/ pCenterArea = pImpCenter ? pImpCenter->Clone() : NULL; +/*N*/ +/*N*/ const EditTextObject* pImpRight = pImp->GetRightEditObject(); +/*N*/ delete pRightArea; +/*N*/ pRightArea = pImpRight ? pImpRight->Clone() : NULL; +/*N*/ +/*N*/ if ( !pLeftArea || !pCenterArea || !pRightArea ) +/*N*/ { +/*?*/ // keine Texte auf NULL stehen lassen +/*?*/ ScEditEngineDefaulter aEngine( EditEngine::CreatePool(), TRUE ); +/*?*/ if (!pLeftArea) +/*?*/ pLeftArea = aEngine.CreateTextObject(); +/*?*/ if (!pCenterArea) +/*?*/ pCenterArea = aEngine.CreateTextObject(); +/*?*/ if (!pRightArea) +/*?*/ pRightArea = aEngine.CreateTextObject(); +/*N*/ } +/*N*/ +/*N*/ bRet = true; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if (!bRet) +/*N*/ { +/*N*/ DBG_ERROR("exception - wrong argument"); +/*N*/ } +/*N*/ +/*N*/ return bRet; +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ String __EXPORT ScPageHFItem::GetValueText() const +/*N*/ { +/*N*/ return String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ScPageHFItem")); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ int __EXPORT ScPageHFItem::operator==( const SfxPoolItem& rItem ) const +/*N*/ { +/*N*/ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal Which or Type" ); +/*N*/ +/*N*/ const ScPageHFItem& r = (const ScPageHFItem&)rItem; +/*N*/ +/*N*/ return ScGlobal::EETextObjEqual(pLeftArea, r.pLeftArea) +/*N*/ && ScGlobal::EETextObjEqual(pCenterArea, r.pCenterArea) +/*N*/ && ScGlobal::EETextObjEqual(pRightArea, r.pRightArea); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ SfxPoolItem* __EXPORT ScPageHFItem::Clone( SfxItemPool* ) const +/*N*/ { +/*N*/ return new ScPageHFItem( *this ); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ USHORT __EXPORT ScPageHFItem::GetVersion( USHORT nFileVersion ) const +/*N*/ { +/*N*/ // 0 = ohne Feldbefehle +/*N*/ // 1 = Titel bzw. Dateiname mit SvxFileField +/*N*/ // 2 = Pfad und/oder Dateiname mit SvxExtFileField, Titel mit SvxFileField +/*N*/ return 2; +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ void lcl_SetSpace( String& rStr, const ESelection& rSel ) +/*N*/ { +/*N*/ // Text durch ein Leerzeichen ersetzen, damit Positionen stimmen: +/*N*/ +/*N*/ xub_StrLen nLen = rSel.nEndPos-rSel.nStartPos; +/*N*/ rStr.Erase( rSel.nStartPos, nLen-1 ); +/*N*/ rStr.SetChar( rSel.nStartPos, ' ' ); +/*N*/ } + +/*N*/ BOOL lcl_ConvertFields(EditEngine& rEng, const String* pCommands) +/*N*/ { +/*N*/ BOOL bChange = FALSE; +/*N*/ USHORT nParCnt = rEng.GetParagraphCount(); +/*N*/ for (USHORT nPar = 0; nPar<nParCnt; nPar++) +/*N*/ { +/*N*/ String aStr = rEng.GetText( nPar ); +/*N*/ xub_StrLen nPos; +/*N*/ +/*N*/ while ((nPos = aStr.Search(pCommands[0])) != STRING_NOTFOUND) +/*N*/ { +/*N*/ ESelection aSel( nPar,nPos, nPar,nPos+pCommands[0].Len() ); +/*N*/ rEng.QuickInsertField( SvxFieldItem(SvxPageField()), aSel ); +/*N*/ lcl_SetSpace(aStr, aSel ); bChange = TRUE; +/*N*/ } +/*N*/ while ((nPos = aStr.Search(pCommands[1])) != STRING_NOTFOUND) +/*N*/ { +/*N*/ ESelection aSel( nPar,nPos, nPar,nPos+pCommands[1].Len() ); +/*N*/ rEng.QuickInsertField( SvxFieldItem(SvxPagesField()), aSel ); +/*N*/ lcl_SetSpace(aStr, aSel ); bChange = TRUE; +/*N*/ } +/*N*/ while ((nPos = aStr.Search(pCommands[2])) != STRING_NOTFOUND) +/*N*/ { +/*N*/ ESelection aSel( nPar,nPos, nPar,nPos+pCommands[2].Len() ); +/*N*/ rEng.QuickInsertField( SvxFieldItem(SvxDateField(Date(),SVXDATETYPE_VAR)), aSel ); +/*N*/ lcl_SetSpace(aStr, aSel ); bChange = TRUE; +/*N*/ } +/*N*/ while ((nPos = aStr.Search(pCommands[3])) != STRING_NOTFOUND) +/*N*/ { +/*N*/ ESelection aSel( nPar,nPos, nPar,nPos+pCommands[3].Len() ); +/*N*/ rEng.QuickInsertField( SvxFieldItem(SvxTimeField()), aSel ); +/*N*/ lcl_SetSpace(aStr, aSel ); bChange = TRUE; +/*N*/ } +/*N*/ while ((nPos = aStr.Search(pCommands[4])) != STRING_NOTFOUND) +/*N*/ { +/*N*/ ESelection aSel( nPar,nPos, nPar,nPos+pCommands[4].Len() ); +/*N*/ rEng.QuickInsertField( SvxFieldItem(SvxFileField()), aSel ); +/*N*/ lcl_SetSpace(aStr, aSel ); bChange = TRUE; +/*N*/ } +/*N*/ while ((nPos = aStr.Search(pCommands[5])) != STRING_NOTFOUND) +/*N*/ { +/*N*/ ESelection aSel( nPar,nPos, nPar,nPos+pCommands[5].Len() ); +/*N*/ rEng.QuickInsertField( SvxFieldItem(SvxTableField()), aSel ); +/*N*/ lcl_SetSpace(aStr, aSel ); bChange = TRUE; +/*N*/ } +/*N*/ } +/*N*/ return bChange; +/*N*/ } + +#define SC_FIELD_COUNT 6 + +/*N*/ SfxPoolItem* __EXPORT ScPageHFItem::Create( SvStream& rStream, USHORT nVer ) const +/*N*/ { +/*N*/ EditTextObject* pLeft = EditTextObject::Create(rStream); +/*N*/ EditTextObject* pCenter = EditTextObject::Create(rStream); +/*N*/ EditTextObject* pRight = EditTextObject::Create(rStream); +/*N*/ +/*N*/ DBG_ASSERT( pLeft && pCenter && pRight, "Error reading ScPageHFItem" ); +/*N*/ +/*N*/ if ( pLeft == NULL || pLeft->GetParagraphCount() == 0 || +/*N*/ pCenter == NULL || pCenter->GetParagraphCount() == 0 || +/*N*/ pRight == NULL || pRight->GetParagraphCount() == 0 ) +/*N*/ { +/*?*/ // If successfully loaded, each object contains at least one paragraph. +/*?*/ // Excel import in 5.1 created broken TextObjects (#67442#) that are +/*?*/ // corrected here to avoid saving wrong files again (#90487#). +/*?*/ +/*?*/ ScEditEngineDefaulter aEngine( EditEngine::CreatePool(), TRUE ); +/*?*/ if ( pLeft == NULL || pLeft->GetParagraphCount() == 0 ) +/*?*/ { +/*?*/ delete pLeft; +/*?*/ pLeft = aEngine.CreateTextObject(); +/*?*/ } +/*?*/ if ( pCenter == NULL || pCenter->GetParagraphCount() == 0 ) +/*?*/ { +/*?*/ delete pCenter; +/*?*/ pCenter = aEngine.CreateTextObject(); +/*?*/ } +/*?*/ if ( pRight == NULL || pRight->GetParagraphCount() == 0 ) +/*?*/ { +/*?*/ delete pRight; +/*?*/ pRight = aEngine.CreateTextObject(); +/*?*/ } +/*N*/ } +/*N*/ +/*N*/ if ( nVer < 1 ) // alte Feldbefehle umsetzen +/*N*/ { +/*N*/ USHORT i; +/*N*/ const String& rDel = ScGlobal::GetRscString( STR_HFCMD_DELIMITER ); +/*N*/ String aCommands[SC_FIELD_COUNT]; +/*N*/ for (i=0; i<SC_FIELD_COUNT; i++) +/*N*/ aCommands[i] = rDel; +/*N*/ aCommands[0] += ScGlobal::GetRscString(STR_HFCMD_PAGE); +/*N*/ aCommands[1] += ScGlobal::GetRscString(STR_HFCMD_PAGES); +/*N*/ aCommands[2] += ScGlobal::GetRscString(STR_HFCMD_DATE); +/*N*/ aCommands[3] += ScGlobal::GetRscString(STR_HFCMD_TIME); +/*N*/ aCommands[4] += ScGlobal::GetRscString(STR_HFCMD_FILE); +/*N*/ aCommands[5] += ScGlobal::GetRscString(STR_HFCMD_TABLE); +/*N*/ for (i=0; i<SC_FIELD_COUNT; i++) +/*N*/ aCommands[i] += rDel; +/*N*/ +/*N*/ ScEditEngineDefaulter aEngine( EditEngine::CreatePool(), TRUE ); +/*N*/ aEngine.SetText(*pLeft); +/*N*/ if (lcl_ConvertFields(aEngine,aCommands)) +/*N*/ { +/*?*/ delete pLeft; +/*?*/ pLeft = aEngine.CreateTextObject(); +/*N*/ } +/*N*/ aEngine.SetText(*pCenter); +/*N*/ if (lcl_ConvertFields(aEngine,aCommands)) +/*N*/ { +/*?*/ delete pCenter; +/*?*/ pCenter = aEngine.CreateTextObject(); +/*N*/ } +/*N*/ aEngine.SetText(*pRight); +/*N*/ if (lcl_ConvertFields(aEngine,aCommands)) +/*N*/ { +/*?*/ delete pRight; +/*?*/ pRight = aEngine.CreateTextObject(); +/*N*/ } +/*N*/ } +/*N*/ else if ( nVer < 2 ) +/*N*/ { // nichts tun, SvxFileField nicht gegen SvxExtFileField austauschen +/*N*/ } +/*N*/ +/*N*/ ScPageHFItem* pItem = new ScPageHFItem( Which() ); +/*N*/ pItem->SetArea( pLeft, SC_HF_LEFTAREA ); +/*N*/ pItem->SetArea( pCenter, SC_HF_CENTERAREA ); +/*N*/ pItem->SetArea( pRight, SC_HF_RIGHTAREA ); +/*N*/ +/*N*/ return pItem; +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ class ScFieldChangerEditEngine : public ScEditEngineDefaulter +/*N*/ { +/*N*/ TypeId aExtFileId; +/*N*/ USHORT nConvPara; +/*N*/ xub_StrLen nConvPos; +/*N*/ BOOL bConvert; +/*N*/ +/*N*/ public: +/*N*/ ScFieldChangerEditEngine( SfxItemPool* pEnginePool, BOOL bDeleteEnginePool ); +/*N*/ virtual ~ScFieldChangerEditEngine() {} +/*N*/ +/*N*/ virtual String CalcFieldValue( const SvxFieldItem& rField, USHORT nPara, +/*N*/ USHORT nPos, Color*& rTxtColor, +/*N*/ Color*& rFldColor ); +/*N*/ +/*N*/ BOOL ConvertFields(); +/*N*/ }; +/*N*/ +/*N*/ ScFieldChangerEditEngine::ScFieldChangerEditEngine( SfxItemPool* pEnginePool, +/*N*/ BOOL bDeleteEnginePool ) : +/*N*/ ScEditEngineDefaulter( pEnginePool, bDeleteEnginePool ), +/*N*/ aExtFileId( TYPE( SvxExtFileField ) ), +/*N*/ nConvPara( 0 ), +/*N*/ nConvPos( 0 ), +/*N*/ bConvert( FALSE ) +/*N*/ { +/*N*/ } +/*N*/ +/*N*/ String ScFieldChangerEditEngine::CalcFieldValue( const SvxFieldItem& rField, +/*N*/ USHORT nPara, USHORT nPos, Color*& rTxtColor, Color*& rFldColor ) +/*N*/ { +/*N*/ const SvxFieldData* pFieldData = rField.GetField(); +/*N*/ if ( pFieldData && pFieldData->Type() == aExtFileId ) +/*N*/ { +/*N*/ bConvert = TRUE; +/*N*/ nConvPara = nPara; +/*N*/ nConvPos = nPos; +/*N*/ } +/*N*/ return EMPTY_STRING; +/*N*/ } +/*N*/ +/*N*/ BOOL ScFieldChangerEditEngine::ConvertFields() +/*N*/ { +/*N*/ BOOL bConverted = FALSE; +/*N*/ do +/*N*/ { +/*N*/ bConvert = FALSE; +/*N*/ UpdateFields(); +/*N*/ if ( bConvert ) +/*N*/ { +/*N*/ ESelection aSel( nConvPara, nConvPos, nConvPara, nConvPos+1 ); +/*N*/ QuickInsertField( SvxFileField(), aSel ); +/*N*/ bConverted = TRUE; +/*N*/ } +/*N*/ } while ( bConvert ); +/*N*/ return bConverted; +/*N*/ } + +/*N*/ void lcl_StoreOldFields( ScFieldChangerEditEngine& rEngine, +/*N*/ const EditTextObject* pArea, SvStream& rStream ) +/*N*/ { +/*N*/ rEngine.SetText( *pArea ); +/*N*/ if ( rEngine.ConvertFields() ) +/*N*/ { +/*N*/ EditTextObject* pObj = rEngine.CreateTextObject(); +/*N*/ pObj->Store( rStream ); +/*N*/ delete pObj; +/*N*/ } +/*N*/ else +/*N*/ pArea->Store( rStream ); +/*N*/ } + +/*N*/ SvStream& __EXPORT ScPageHFItem::Store( SvStream& rStream, USHORT nVer ) const +/*N*/ { +/*N*/ if ( pLeftArea && pCenterArea && pRightArea ) +/*N*/ { +/*N*/ if ( rStream.GetVersion() < SOFFICE_FILEFORMAT_50 ) +/*N*/ { +/*N*/ ScFieldChangerEditEngine aEngine( EditEngine::CreatePool(), TRUE ); +/*N*/ lcl_StoreOldFields( aEngine, pLeftArea, rStream ); +/*N*/ lcl_StoreOldFields( aEngine, pCenterArea, rStream ); +/*N*/ lcl_StoreOldFields( aEngine, pRightArea, rStream ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ pLeftArea->Store(rStream); +/*N*/ pCenterArea->Store(rStream); +/*N*/ pRightArea->Store(rStream); +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*?*/ // soll eigentlich nicht sein, kommt aber vor, wenn das Default-Item +/*?*/ // fuer ein ItemSet kopiert wird (#61826#) ... +/*?*/ +/*?*/ ScFieldChangerEditEngine aEngine( EditEngine::CreatePool(), TRUE ); +/*?*/ EditTextObject* pEmpytObj = aEngine.CreateTextObject(); +/*?*/ +/*?*/ DBG_ASSERT( pEmpytObj, "Error creating empty EditTextObject :-(" ); +/*?*/ +/*?*/ if ( rStream.GetVersion() < SOFFICE_FILEFORMAT_50 ) +/*?*/ { +/*?*/ if ( pLeftArea ) +/*?*/ lcl_StoreOldFields( aEngine, pLeftArea, rStream ); +/*?*/ else +/*?*/ pEmpytObj->Store( rStream ); +/*?*/ +/*?*/ if ( pCenterArea ) +/*?*/ lcl_StoreOldFields( aEngine, pCenterArea, rStream ); +/*?*/ else +/*?*/ pEmpytObj->Store( rStream ); +/*?*/ +/*?*/ if ( pRightArea ) +/*?*/ lcl_StoreOldFields( aEngine, pRightArea, rStream ); +/*?*/ else +/*?*/ pEmpytObj->Store( rStream ); +/*?*/ } +/*?*/ else +/*?*/ { +/*?*/ (pLeftArea ? pLeftArea : pEmpytObj )->Store(rStream); +/*?*/ (pCenterArea ? pCenterArea : pEmpytObj )->Store(rStream); +/*?*/ (pRightArea ? pRightArea : pEmpytObj )->Store(rStream); +/*?*/ } +/*?*/ +/*?*/ delete pEmpytObj; +/*N*/ } +/*N*/ +/*N*/ return rStream; +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ void __EXPORT ScPageHFItem::SetLeftArea( const EditTextObject& rNew ) +/*N*/ { +/*N*/ delete pLeftArea; +/*N*/ pLeftArea = rNew.Clone(); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ void __EXPORT ScPageHFItem::SetCenterArea( const EditTextObject& rNew ) +/*N*/ { +/*N*/ delete pCenterArea; +/*N*/ pCenterArea = rNew.Clone(); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ void __EXPORT ScPageHFItem::SetRightArea( const EditTextObject& rNew ) +/*N*/ { +/*N*/ delete pRightArea; +/*N*/ pRightArea = rNew.Clone(); +/*N*/ } + +/*N*/ void __EXPORT ScPageHFItem::SetArea( EditTextObject *pNew, int nArea ) +/*N*/ { +/*N*/ switch ( nArea ) +/*N*/ { +/*N*/ case SC_HF_LEFTAREA: delete pLeftArea; pLeftArea = pNew; break; +/*N*/ case SC_HF_CENTERAREA: delete pCenterArea; pCenterArea = pNew; break; +/*N*/ case SC_HF_RIGHTAREA: delete pRightArea; pRightArea = pNew; break; +/*N*/ default: +/*N*/ DBG_ERROR( "New Area?" ); +/*N*/ } +/*N*/ } + +//----------------------------------------------------------------------- +// ScViewObjectModeItem - Darstellungsmodus von ViewObjekten +//----------------------------------------------------------------------- + +/*N*/ ScViewObjectModeItem::ScViewObjectModeItem( USHORT nWhich ) +/*N*/ : SfxEnumItem( nWhich, VOBJ_MODE_SHOW ) +/*N*/ { +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ ScViewObjectModeItem::ScViewObjectModeItem( USHORT nWhich, ScVObjMode eMode ) +/*N*/ : SfxEnumItem( nWhich, eMode ) +/*N*/ { +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ __EXPORT ScViewObjectModeItem::~ScViewObjectModeItem() +/*N*/ { +/*N*/ } + +//------------------------------------------------------------------------ + + +//------------------------------------------------------------------------ + + +//------------------------------------------------------------------------ + +/*N*/ USHORT __EXPORT ScViewObjectModeItem::GetValueCount() const +/*N*/ { +/*N*/ return 3; +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ SfxPoolItem* __EXPORT ScViewObjectModeItem::Clone( SfxItemPool* ) const +/*N*/ { +/*N*/ return new ScViewObjectModeItem( *this ); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ USHORT __EXPORT ScViewObjectModeItem::GetVersion( USHORT nFileVersion ) const +/*N*/ { +/*N*/ return 1; +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ SfxPoolItem* __EXPORT ScViewObjectModeItem::Create( +/*N*/ SvStream& rStream, +/*N*/ USHORT nVersion ) const +/*N*/ { +/*N*/ if ( nVersion == 0 ) +/*N*/ { +/*N*/ // alte Version mit AllEnumItem -> mit Mode "Show" erzeugen +/*N*/ return new ScViewObjectModeItem( Which() ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ USHORT nVal; +/*N*/ rStream >> nVal; +/*N*/ return new ScViewObjectModeItem( Which(), (ScVObjMode)nVal ); +/*N*/ } +/*N*/ } + +// ----------------------------------------------------------------------- +// double +// ----------------------------------------------------------------------- + +/*N*/ ScDoubleItem::ScDoubleItem( USHORT nWhich, double nVal ) +/*N*/ : SfxPoolItem ( nWhich ), +/*N*/ nValue ( nVal ) +/*N*/ { +/*N*/ } +/*N*/ +//------------------------------------------------------------------------ + +/*N*/ ScDoubleItem::ScDoubleItem( const ScDoubleItem& rItem ) +/*N*/ : SfxPoolItem ( rItem ) +/*N*/ { +/*N*/ nValue = rItem.nValue; +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ String __EXPORT ScDoubleItem::GetValueText() const +/*N*/ { +/*N*/ return String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ScDoubleItem")); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ int __EXPORT ScDoubleItem::operator==( const SfxPoolItem& rItem ) const +/*N*/ { +/*N*/ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal Which or Type" ); +/*N*/ const ScDoubleItem& _rItem = (const ScDoubleItem&)rItem; +/*N*/ return int(nValue == _rItem.nValue); +/*N*/ //int(nValue == ((const ScDoubleItem&)rItem).nValue); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ SfxPoolItem* __EXPORT ScDoubleItem::Clone( SfxItemPool* ) const +/*N*/ { +/*N*/ return new ScDoubleItem( *this ); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ SfxPoolItem* __EXPORT ScDoubleItem::Create( SvStream& rStream, USHORT nVer ) const +/*N*/ { +/*N*/ double nTmp=0; +/*N*/ rStream >> nTmp; +/*N*/ +/*N*/ ScDoubleItem* pItem = new ScDoubleItem( Which(), nTmp ); +/*N*/ +/*N*/ return pItem; +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ SvStream& __EXPORT ScDoubleItem::Store( SvStream& rStream, USHORT nVer ) const +/*N*/ { +/*N*/ rStream << nValue; +/*N*/ +/*N*/ return rStream; +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ __EXPORT ScDoubleItem::~ScDoubleItem() +/*N*/ { +/*N*/ } + +// ----------------------------------------------------------------------- + + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_bcaslot.cxx b/binfilter/bf_sc/source/core/data/sc_bcaslot.cxx new file mode 100644 index 000000000000..c70d48dc75f2 --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_bcaslot.cxx @@ -0,0 +1,580 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <bf_sfx2/objsh.hxx> +#include <bf_svtools/lstner.hxx> + +// INCLUDE --------------------------------------------------------------- + +#include "document.hxx" +#include "bcaslot.hxx" +#include "scerrors.hxx" +namespace binfilter { + +// Anzahl der Slots je Dimension +// muessen ganzzahlige Teiler von MAXCOL+1 bzw. MAXROW+1 sein +#define BCA_SLOTS_COL 16 +#define BCA_SLOTS_ROW 256 +#define BCA_SLOT_COLS ((MAXCOL+1) / BCA_SLOTS_COL) +#define BCA_SLOT_ROWS ((MAXROW+1) / BCA_SLOTS_ROW) +// vielfaches? +#if (BCA_SLOT_COLS * BCA_SLOTS_COL) != (MAXCOL+1) +#error bad BCA_SLOTS_COL value! +#endif +#if (BCA_SLOT_ROWS * BCA_SLOTS_ROW) != (MAXROW+1) +#error bad BCA_SLOTS_ROW value! +#endif +// Groesse des Slot-Arrays +#define BCA_SLOTS (BCA_SLOTS_COL * BCA_SLOTS_ROW) +#if BCA_SLOTS > 16350 +#error BCA_SLOTS DOOMed! +#endif + +DECLARE_LIST( ScBroadcastAreaList, ScBroadcastArea* )//STRIP008 ; + +// STATIC DATA ----------------------------------------------------------- + +#ifdef erDEBUG +ULONG erCountBCAInserts = 0; +ULONG erCountBCAFinds = 0; +#endif + +/*N*/ SV_IMPL_OP_PTRARR_SORT( ScBroadcastAreas, ScBroadcastAreaPtr ); +/*N*/ TYPEINIT1( ScHint, SfxSimpleHint ); +TYPEINIT1( ScAreaChangedHint, SfxHint ); + + +/*N*/ ScBroadcastAreaSlot::ScBroadcastAreaSlot( ScDocument* pDocument, +/*N*/ ScBroadcastAreaSlotMachine* pBASMa ) : +/*N*/ pDoc( pDocument ), +/*N*/ pBASM( pBASMa ) +/*N*/ { +/*N*/ pBroadcastAreaTbl = new ScBroadcastAreas( BCA_INITGROWSIZE, BCA_INITGROWSIZE ); +/*N*/ pTmpSeekBroadcastArea = new ScBroadcastArea( ScRange() ); +/*N*/ } + + +/*N*/ ScBroadcastAreaSlot::~ScBroadcastAreaSlot() +/*N*/ { +/*N*/ USHORT nPos = pBroadcastAreaTbl->Count(); +/*N*/ if ( nPos ) +/*N*/ { +/*N*/ ScBroadcastArea** ppArea = +/*N*/ ((ScBroadcastArea**) pBroadcastAreaTbl->GetData()) + nPos - 1; +/*N*/ for ( ; nPos-- >0; ppArea-- ) +/*N*/ { +/*N*/ if ( !(*ppArea)->DecRef() ) +/*N*/ delete *ppArea; +/*N*/ } +/*N*/ } +/*N*/ delete pBroadcastAreaTbl; +/*N*/ delete pTmpSeekBroadcastArea; +/*N*/ } + + +// nur hier werden neue BroadcastAreas angelegt, wodurch keine doppelten entstehen. +// Ist rpArea != NULL werden keine Listener gestartet sondern nur die Area +// eingetragen und der RefCount erhoeht +/*N*/ void ScBroadcastAreaSlot::StartListeningArea( const ScRange& rRange, +/*N*/ SfxListener* pListener, ScBroadcastArea*& rpArea +/*N*/ ) +/*N*/ { +/*N*/ DBG_ASSERT(pListener, "StartListeningArea: pListener Null"); +/*N*/ if ( pDoc->GetHardRecalcState() ) +/*N*/ return; +/*N*/ if ( (long)( (pBroadcastAreaTbl->Count() + 1 + BCA_INITGROWSIZE) +/*N*/ * sizeof(ScBroadcastArea*) ) >= USHRT_MAX +/*N*/ ) +/*N*/ { +/*?*/ if ( !pDoc->GetHardRecalcState() ) +/*?*/ { +/*?*/ pDoc->SetHardRecalcState( 1 ); +/*?*/ +/*?*/ SfxObjectShell* pShell = pDoc->GetDocumentShell(); +/*?*/ DBG_ASSERT( pShell, "Missing DocShell :-/" ); +/*?*/ +/*?*/ if ( pShell ) +/*?*/ pShell->SetError( SCWARN_CORE_HARD_RECALC ); +/*?*/ +/*?*/ pDoc->SetAutoCalc( FALSE ); +/*?*/ pDoc->SetHardRecalcState( 2 ); +/*?*/ } +/*?*/ return; +/*N*/ } +/*N*/ if ( !rpArea ) +/*N*/ { +/*N*/ rpArea = new ScBroadcastArea( rRange ); +/*N*/ // meistens existiert die Area noch nicht, der Versuch sofort zu inserten +/*N*/ // erspart in diesen Faellen ein doppeltes Seek_Entry +/*N*/ if ( pBroadcastAreaTbl->Insert( rpArea ) ) +/*N*/ rpArea->IncRef(); +/*N*/ else +/*N*/ { +/*N*/ delete rpArea; +/*N*/ rpArea = GetBroadcastArea( rRange ); +/*N*/ } +/*N*/ pListener->StartListening( *rpArea, TRUE ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ if ( pBroadcastAreaTbl->Insert( rpArea ) ) +/*N*/ rpArea->IncRef(); +/*N*/ } +/*N*/ } + + +/*N*/ // Ist rpArea != NULL werden keine Listener gestopt sondern nur die Area +/*N*/ // ausgetragen und der RefCount vermindert +/*N*/ void ScBroadcastAreaSlot::EndListeningArea( const ScRange& rRange, +/*N*/ SfxListener* pListener, ScBroadcastArea*& rpArea +/*N*/ ) +/*N*/ { +/*N*/ DBG_ASSERT(pListener, "EndListeningArea: pListener Null"); +/*N*/ if ( !rpArea ) +/*N*/ { +/*N*/ USHORT nPos; +/*N*/ if ( (nPos = FindBroadcastArea( rRange )) == USHRT_MAX ) +/*N*/ return; +/*N*/ rpArea = (*pBroadcastAreaTbl)[ nPos ]; +/*N*/ pListener->EndListening( *rpArea ); +/*N*/ if ( !rpArea->HasListeners() ) +/*N*/ { // wenn keiner mehr zuhoert ist die Area ueberfluessig +/*N*/ pBroadcastAreaTbl->Remove( nPos ); +/*N*/ if ( !rpArea->DecRef() ) +/*N*/ { +/*N*/ delete rpArea; +/*N*/ rpArea = NULL; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ if ( !rpArea->HasListeners() ) +/*N*/ { +/*N*/ USHORT nPos; +/*N*/ if ( (nPos = FindBroadcastArea( rRange )) == USHRT_MAX ) +/*N*/ return; +/*N*/ pBroadcastAreaTbl->Remove( nPos ); +/*N*/ if ( !rpArea->DecRef() ) +/*N*/ { +/*N*/ delete rpArea; +/*N*/ rpArea = NULL; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ +/*N*/ USHORT ScBroadcastAreaSlot::FindBroadcastArea( const ScRange& rRange ) const +/*N*/ { +/*N*/ USHORT nPos; +/*N*/ pTmpSeekBroadcastArea->UpdateRange( rRange ); +/*N*/ if ( pBroadcastAreaTbl->Seek_Entry( pTmpSeekBroadcastArea, &nPos ) ) +/*N*/ return nPos; +/*N*/ return USHRT_MAX; +/*N*/ } + + +/*N*/ ScBroadcastArea* ScBroadcastAreaSlot::GetBroadcastArea( +/*N*/ const ScRange& rRange ) const +/*N*/ { +/*N*/ USHORT nPos; +/*N*/ if ( (nPos = FindBroadcastArea( rRange )) != USHRT_MAX ) +/*N*/ return (*pBroadcastAreaTbl)[ nPos ]; +/*N*/ return 0; +/*N*/ } + + +/*N*/ BOOL ScBroadcastAreaSlot::AreaBroadcast( const ScHint& rHint) const +/*N*/ { +/*N*/ USHORT nCount = pBroadcastAreaTbl->Count(); +/*N*/ if ( nCount == 0 ) +/*N*/ return FALSE; +/*N*/ const ScBroadcastArea** ppArea = +/*N*/ (const ScBroadcastArea**) pBroadcastAreaTbl->GetData(); +/*N*/ BOOL bIsBroadcasted = FALSE; +/*N*/ // leider laesst sich nicht nach dem erstmoeglichen suchen +/*N*/ USHORT nPos = 0; +/*N*/ // den letztmoeglichen suchen, Seek_Entry liefert naechst groesseren +/*N*/ // oder freie Position wenn nicht gefunden +/*N*/ USHORT nPosEnd; +/*N*/ const ScAddress& rAddress = rHint.GetAddress(); +/*N*/ pTmpSeekBroadcastArea->UpdateRange( ScRange( rAddress, +/*N*/ ScAddress( MAXCOL, MAXROW, MAXTAB ) ) ); +/*N*/ if ( !pBroadcastAreaTbl->Seek_Entry( pTmpSeekBroadcastArea, &nPosEnd ) +/*N*/ && nPosEnd > 0 ) +/*N*/ --nPosEnd; +/*N*/ for ( ; nPos <= nPosEnd; ++nPos, ppArea++ ) +/*N*/ { +/*N*/ if ( ((ScBroadcastArea*)*ppArea)->In( rAddress ) ) +/*N*/ { +/*N*/ ((ScBroadcastArea*)*ppArea)->Broadcast( rHint ); +/*N*/ bIsBroadcasted = TRUE; +/*N*/ } +/*N*/ } +/*N*/ return bIsBroadcasted; +/*N*/ } + + +/*N*/ BOOL ScBroadcastAreaSlot::AreaBroadcastInRange( const ScRange& rRange, +/*N*/ const ScHint& rHint) const +/*N*/ { +/*N*/ USHORT nCount = pBroadcastAreaTbl->Count(); +/*N*/ if ( nCount == 0 ) +/*N*/ return FALSE; +/*N*/ const ScBroadcastArea** ppArea = +/*N*/ (const ScBroadcastArea**) pBroadcastAreaTbl->GetData(); +/*N*/ BOOL bIsBroadcasted = FALSE; +/*N*/ // unfortunately we can't search for the first matching entry +/*N*/ USHORT nPos = 0; +/*N*/ // search the last matching entry, Seek_Entry returns the next being +/*N*/ // greater, or a free position if not found +/*N*/ USHORT nPosEnd; +/*N*/ pTmpSeekBroadcastArea->UpdateRange( rRange ); +/*N*/ if ( !pBroadcastAreaTbl->Seek_Entry( pTmpSeekBroadcastArea, &nPosEnd ) && +/*N*/ nPosEnd > 0 ) +/*N*/ --nPosEnd; +/*N*/ for ( ; nPos <= nPosEnd; ++nPos, ppArea++ ) +/*N*/ { +/*N*/ if ( ((ScBroadcastArea*)*ppArea)->Intersects( rRange ) ) +/*N*/ { +/*N*/ ((ScBroadcastArea*)*ppArea)->Broadcast( rHint ); +/*N*/ bIsBroadcasted = TRUE; +/*N*/ } +/*N*/ } +/*N*/ return bIsBroadcasted; +/*N*/ } + + +// DelBroadcastAreasInRange wird unter Windows (16 Bit) kaputtoptimiert + +#ifdef WIN +#pragma optimize("",off) +#endif + +/*N*/ void ScBroadcastAreaSlot::DelBroadcastAreasInRange( const ScRange& rRange ) +/*N*/ { +/*N*/ ScBroadcastArea* pArea; +/*N*/ ScAddress aStart( rRange.aStart ); +/*N*/ USHORT nPos = pBroadcastAreaTbl->Count(); +/*N*/ const ScBroadcastArea** ppArea = +/*N*/ (const ScBroadcastArea**) pBroadcastAreaTbl->GetData() + nPos - 1; +/*N*/ for ( ; nPos-- >0; ppArea-- ) +/*N*/ { // rueckwaerts wg. Pointer-Aufrueckerei im Array +/*N*/ pArea = (ScBroadcastArea*)*ppArea; +/*N*/ if ( pArea->aStart < aStart ) +/*N*/ return; // davor nur noch niedrigere +/*N*/ // gesuchte muessen komplett innerhalb von rRange liegen +/*N*/ if ( rRange.In( pArea->aStart ) && rRange.In( pArea->aEnd ) ) +/*N*/ { +/*N*/ pBroadcastAreaTbl->Remove( nPos ); +/*N*/ ppArea = (const ScBroadcastArea**) pBroadcastAreaTbl->GetData() +/*N*/ + nPos; +/*N*/ if ( !pArea->DecRef() ) +/*N*/ delete pArea; +/*N*/ } +/*N*/ } +/*N*/ } + +#ifdef WIN +#pragma optimize("",on) +#endif + + + + + +// --- ScBroadcastAreaSlotMachine ------------------------------------- + +/*N*/ ScBroadcastAreaSlotMachine::ScBroadcastAreaSlotMachine( +/*N*/ ScDocument* pDocument ) : +/*N*/ pDoc( pDocument ), +/*N*/ pBCAlwaysList( new ScBroadcastAreaList ), +/*N*/ pUpdateChain( NULL ), +/*N*/ pEOUpdateChain( NULL ) +/*N*/ { +/*N*/ ppSlots = new ScBroadcastAreaSlot* [ BCA_SLOTS ]; +/*N*/ memset( ppSlots, 0 , sizeof( ScBroadcastAreaSlot* ) * BCA_SLOTS ); +/*N*/ } + + +/*N*/ ScBroadcastAreaSlotMachine::~ScBroadcastAreaSlotMachine() +/*N*/ { +/*N*/ +/*N*/ ScBroadcastAreaSlot** pp = ppSlots; +/*N*/ for ( USHORT j=0; j < BCA_SLOTS; ++j, ++pp ) +/*N*/ { +/*N*/ if ( *pp ) +/*N*/ delete *pp; +/*N*/ } +/*N*/ delete[] ppSlots; +/*N*/ +/*N*/ for ( ScBroadcastArea* pBCA = pBCAlwaysList->First(); pBCA; pBCA = pBCAlwaysList->Next() ) +/*N*/ { +/*N*/ delete pBCA; +/*N*/ } +/*N*/ delete pBCAlwaysList; +/*N*/ } + + +/*N*/ inline USHORT ScBroadcastAreaSlotMachine::ComputeSlotOffset( +/*N*/ const ScAddress& rAddress ) const +/*N*/ { +/*N*/ USHORT nRow = rAddress.Row(); +/*N*/ USHORT nCol = rAddress.Col(); +/*N*/ if ( nRow > MAXROW || nCol > MAXCOL ) +/*N*/ { +/*N*/ DBG_ASSERT( FALSE, "Row/Col ungueltig!" ); +/*N*/ return 0; +/*N*/ } +/*N*/ else +/*N*/ return +/*N*/ nRow / BCA_SLOT_ROWS + +/*N*/ nCol / BCA_SLOT_COLS * BCA_SLOTS_ROW; +/*N*/ } + + +/*N*/ void ScBroadcastAreaSlotMachine::ComputeAreaPoints( const ScRange& rRange, +/*N*/ USHORT& rStart, USHORT& rEnd, USHORT& rRowBreak +/*N*/ ) const +/*N*/ { +/*N*/ rStart = ComputeSlotOffset( rRange.aStart ); +/*N*/ rEnd = ComputeSlotOffset( rRange.aEnd ); +/*N*/ // Anzahl Zeilen-Slots pro Spalte minus eins +/*N*/ rRowBreak = ComputeSlotOffset( +/*N*/ ScAddress( rRange.aStart.Col(), rRange.aEnd.Row(), 0 ) ) - rStart; +/*N*/ } + + +/*N*/ void ScBroadcastAreaSlotMachine::StartListeningArea( const ScRange& rRange, +/*N*/ SfxListener* pListener +/*N*/ ) +/*N*/ { +/*N*/ if ( rRange == BCA_LISTEN_ALWAYS ) +/*N*/ { +/*N*/ ScBroadcastArea* pBCA; +/*N*/ if ( !pBCAlwaysList->Count() ) +/*N*/ { +/*N*/ pBCA = new ScBroadcastArea( rRange ); +/*N*/ pListener->StartListening( *pBCA, FALSE ); // kein PreventDupes +/*N*/ pBCAlwaysList->Insert( pBCA, LIST_APPEND ); +/*N*/ return ; +/*N*/ } +/*N*/ ScBroadcastArea* pLast; +/*N*/ for ( pBCA = pBCAlwaysList->First(); pBCA; pBCA = pBCAlwaysList->Next() ) +/*N*/ { +/*N*/ if ( pListener->IsListening( *pBCA ) ) +/*N*/ return ; // keine Dupes +/*N*/ pLast = pBCA; +/*N*/ } +/*?*/ pBCA = pLast; +/*?*/ //! ListenerArrays don't shrink! +/*?*/ if ( pBCA->GetListenerCount() > ((USHRT_MAX / 2) / sizeof(SfxBroadcaster*)) ) +/*?*/ { // Arrays nicht zu gross werden lassen +/*?*/ pBCA = new ScBroadcastArea( rRange ); +/*?*/ pBCAlwaysList->Insert( pBCA, LIST_APPEND ); +/*?*/ } +/*?*/ pListener->StartListening( *pBCA, FALSE ); // kein PreventDupes +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ USHORT nStart, nEnd, nRowBreak; +/*N*/ ComputeAreaPoints( rRange, nStart, nEnd, nRowBreak ); +/*N*/ USHORT nOff = nStart; +/*N*/ USHORT nBreak = nOff + nRowBreak; +/*N*/ ScBroadcastAreaSlot** pp = ppSlots + nOff; +/*N*/ ScBroadcastArea* pArea = NULL; +/*N*/ while ( nOff <= nEnd ) +/*N*/ { +/*N*/ if ( !*pp ) +/*N*/ *pp = new ScBroadcastAreaSlot( pDoc, this ); +/*N*/ // der erste erzeugt ggbf. die BroadcastArea +/*N*/ (*pp)->StartListeningArea( rRange, pListener, pArea ); +/*N*/ if ( nOff < nBreak ) +/*N*/ { +/*N*/ ++nOff; +/*N*/ ++pp; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ nStart += BCA_SLOTS_ROW; +/*N*/ nOff = nStart; +/*N*/ pp = ppSlots + nOff; +/*N*/ nBreak = nOff + nRowBreak; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } + + +/*N*/ void ScBroadcastAreaSlotMachine::EndListeningArea( const ScRange& rRange, +/*N*/ SfxListener* pListener +/*N*/ ) +/*N*/ { +/*N*/ if ( rRange == BCA_LISTEN_ALWAYS ) +/*N*/ { +/*?*/ if ( pBCAlwaysList->Count() ) +/*?*/ { +/*?*/ for ( ScBroadcastArea* pBCA = pBCAlwaysList->First(); pBCA; pBCA = pBCAlwaysList->Next() ) +/*?*/ { +/*?*/ // EndListening liefert FALSE wenn !IsListening, keine Dupes +/*?*/ if ( pListener->EndListening( *pBCA, FALSE ) ) +/*?*/ { +/*?*/ if ( !pBCA->HasListeners() ) +/*?*/ { +/*?*/ pBCAlwaysList->Remove(); +/*?*/ delete pBCA; +/*?*/ } +/*?*/ return ; +/*?*/ } +/*?*/ } +/*?*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ USHORT nStart, nEnd, nRowBreak; +/*N*/ ComputeAreaPoints( rRange, nStart, nEnd, nRowBreak ); +/*N*/ USHORT nOff = nStart; +/*N*/ USHORT nBreak = nOff + nRowBreak; +/*N*/ ScBroadcastAreaSlot** pp = ppSlots + nOff; +/*N*/ ScBroadcastArea* pArea = NULL; +/*N*/ while ( nOff <= nEnd ) +/*N*/ { +/*N*/ if ( *pp ) +/*N*/ (*pp)->EndListeningArea( rRange, pListener, pArea ); +/*N*/ if ( nOff < nBreak ) +/*N*/ { +/*N*/ ++nOff; +/*N*/ ++pp; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ nStart += BCA_SLOTS_ROW; +/*N*/ nOff = nStart; +/*N*/ pp = ppSlots + nOff; +/*N*/ nBreak = nOff + nRowBreak; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ +/*N*/ BOOL ScBroadcastAreaSlotMachine::AreaBroadcast( const ScHint& rHint ) const +/*N*/ { +/*N*/ const ScAddress& rAddress = rHint.GetAddress(); +/*N*/ if ( rAddress == BCA_BRDCST_ALWAYS ) +/*N*/ { +/*N*/ if ( pBCAlwaysList->Count() ) +/*N*/ { +/*N*/ for ( ScBroadcastArea* pBCA = pBCAlwaysList->First(); pBCA; pBCA = pBCAlwaysList->Next() ) +/*N*/ { +/*N*/ pBCA->Broadcast( rHint ); +/*N*/ } +/*N*/ return TRUE; +/*N*/ } +/*N*/ else +/*N*/ return FALSE; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ ScBroadcastAreaSlot* pSlot = ppSlots[ ComputeSlotOffset( rAddress ) ]; +/*N*/ if ( pSlot ) +/*N*/ return pSlot->AreaBroadcast( rHint ); +/*N*/ else +/*N*/ return FALSE; +/*N*/ } +/*N*/ } + + +/*N*/ BOOL ScBroadcastAreaSlotMachine::AreaBroadcastInRange( const ScRange& rRange, +/*N*/ const ScHint& rHint ) const +/*N*/ { +/*N*/ BOOL bBroadcasted = FALSE; +/*N*/ USHORT nStart, nEnd, nRowBreak; +/*N*/ ComputeAreaPoints( rRange, nStart, nEnd, nRowBreak ); +/*N*/ USHORT nOff = nStart; +/*N*/ USHORT nBreak = nOff + nRowBreak; +/*N*/ ScBroadcastAreaSlot** pp = ppSlots + nOff; +/*N*/ while ( nOff <= nEnd ) +/*N*/ { +/*N*/ if ( *pp ) +/*N*/ bBroadcasted |= (*pp)->AreaBroadcastInRange( rRange, rHint ); +/*N*/ if ( nOff < nBreak ) +/*N*/ { +/*N*/ ++nOff; +/*N*/ ++pp; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ nStart += BCA_SLOTS_ROW; +/*N*/ nOff = nStart; +/*N*/ pp = ppSlots + nOff; +/*N*/ nBreak = nOff + nRowBreak; +/*N*/ } +/*N*/ } +/*N*/ return bBroadcasted; +/*N*/ } + + +/*N*/ void ScBroadcastAreaSlotMachine::DelBroadcastAreasInRange( +/*N*/ const ScRange& rRange +/*N*/ ) +/*N*/ { +/*N*/ USHORT nStart, nEnd, nRowBreak; +/*N*/ ComputeAreaPoints( rRange, nStart, nEnd, nRowBreak ); +/*N*/ USHORT nOff = nStart; +/*N*/ USHORT nBreak = nOff + nRowBreak; +/*N*/ ScBroadcastAreaSlot** pp = ppSlots + nOff; +/*N*/ while ( nOff <= nEnd ) +/*N*/ { +/*N*/ if ( *pp ) +/*N*/ (*pp)->DelBroadcastAreasInRange( rRange ); +/*N*/ if ( nOff < nBreak ) +/*N*/ { +/*N*/ ++nOff; +/*N*/ ++pp; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ nStart += BCA_SLOTS_ROW; +/*N*/ nOff = nStart; +/*N*/ pp = ppSlots + nOff; +/*N*/ nBreak = nOff + nRowBreak; +/*N*/ } +/*N*/ } +/*N*/ } + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_bclist.cxx b/binfilter/bf_sc/source/core/data/sc_bclist.cxx new file mode 100644 index 000000000000..d6f49bf0f839 --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_bclist.cxx @@ -0,0 +1,192 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +//------------------------------------------------------------------ + +#include <bf_svtools/lstner.hxx> +#include <tools/list.hxx> + +#include "bclist.hxx" +namespace binfilter { + +//------------------------------------------------------------------------ + +#define SC_LISTENERS_MAX 1024 + +/*N*/ DECLARE_LIST(ScBroadcasters, SfxBroadcaster*)//STRIP008 ; + +//------------------------------------------------------------------------ + +/*N*/ ScBroadcasterList::ScBroadcasterList() : +/*N*/ pMoreBCs( NULL ) +/*N*/ { +/*N*/ } + +/*N*/ ScBroadcasterList::~ScBroadcasterList() +/*N*/ { +/*N*/ if (pMoreBCs) +/*N*/ { +/*?*/ ULONG nCount = pMoreBCs->Count(); +/*?*/ for (ULONG i=0; i<nCount; i++) +/*?*/ { +/*?*/ SfxBroadcaster* pBC = pMoreBCs->GetObject(i); +/*?*/ delete pBC; +/*?*/ } +/*?*/ delete pMoreBCs; +/*N*/ } +/*N*/ } + +/*N*/ void ScBroadcasterList::StartBroadcasting( SfxListener& rLst, BOOL bCheckDup ) +/*N*/ { +/*N*/ if (bCheckDup) +/*N*/ { +/*N*/ if (rLst.IsListening(aFirstBC)) +/*N*/ return; +/*N*/ if (pMoreBCs) +/*N*/ { +/*?*/ ULONG nCount = pMoreBCs->Count(); +/*?*/ for (ULONG i=0; i<nCount; i++) +/*?*/ { +/*?*/ SfxBroadcaster* pBC = pMoreBCs->GetObject(i); +/*?*/ if (rLst.IsListening(*pBC)) +/*?*/ return; +/*?*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if ( aFirstBC.GetListenerCount() < SC_LISTENERS_MAX ) +/*N*/ { +/*N*/ rLst.StartListening(aFirstBC, FALSE); +/*N*/ return; +/*N*/ } +/*N*/ if (pMoreBCs) +/*N*/ { +/*?*/ ULONG nCount = pMoreBCs->Count(); +/*?*/ for (ULONG i=0; i<nCount; i++) +/*?*/ { +/*?*/ SfxBroadcaster* pBC = pMoreBCs->GetObject(i); +/*?*/ if ( pBC->GetListenerCount() < SC_LISTENERS_MAX ) +/*?*/ { +/*?*/ rLst.StartListening(*pBC, FALSE); +/*?*/ return; +/*?*/ } +/*?*/ } +/*N*/ } +/*N*/ if (!pMoreBCs) +/*?*/ pMoreBCs = new ScBroadcasters; +/*N*/ SfxBroadcaster* pNew = new SfxBroadcaster; +/*N*/ rLst.StartListening(*pNew, FALSE); +/*N*/ pMoreBCs->Insert(pNew, (ULONG)0); // vorne +/*N*/ } + +/*N*/ void ScBroadcasterList::EndBroadcasting( SfxListener& rLst ) +/*N*/ { +/*N*/ rLst.EndListening(aFirstBC); +/*N*/ if (pMoreBCs) +/*N*/ { +/*?*/ ULONG nCount = pMoreBCs->Count(); +/*?*/ for (ULONG i=0; i<nCount; i++) +/*?*/ { +/*?*/ SfxBroadcaster* pBC = pMoreBCs->GetObject(i); +/*?*/ rLst.EndListening(*pBC); +/*?*/ } +/*N*/ } +/*N*/ } + +/*N*/ BOOL ScBroadcasterList::HasListeners() const +/*N*/ { +/*N*/ if (aFirstBC.HasListeners()) +/*N*/ return TRUE; +/*N*/ if (pMoreBCs) +/*N*/ { +/*?*/ ULONG nCount = pMoreBCs->Count(); +/*?*/ for (ULONG i=0; i<nCount; i++) +/*?*/ { +/*?*/ SfxBroadcaster* pBC = pMoreBCs->GetObject(i); +/*?*/ if (pBC->HasListeners()) +/*?*/ return TRUE; +/*?*/ } +/*N*/ } +/*N*/ return FALSE; +/*N*/ } + +/*N*/ void ScBroadcasterList::Broadcast( const SfxHint &rHint ) +/*N*/ { +/*N*/ aFirstBC.Broadcast( rHint ); +/*N*/ if (pMoreBCs) +/*N*/ { +/*?*/ ULONG nCount = pMoreBCs->Count(); +/*?*/ for (ULONG i=0; i<nCount; i++) +/*?*/ { +/*?*/ SfxBroadcaster* pBC = pMoreBCs->GetObject(i); +/*?*/ pBC->Broadcast( rHint ); +/*?*/ } +/*N*/ } +/*N*/ } + +/*N*/ void ScBroadcasterList::MoveListenersTo( ScBroadcasterList& rNew ) +/*N*/ { +/*N*/ SfxBroadcaster* pNewBC = &rNew.aFirstBC; +/*N*/ +/*N*/ USHORT nLstCount, nLstPos; +/*N*/ nLstCount = aFirstBC.GetListenerCount(); +/*N*/ for (nLstPos=nLstCount; nLstPos>0;) +/*N*/ { +/*N*/ --nLstPos; +/*N*/ SfxListener* pLst = aFirstBC.GetListener(nLstPos); +/*N*/ rNew.StartBroadcasting(*pLst, TRUE); +/*N*/ pLst->EndListening(aFirstBC); +/*N*/ } +/*N*/ if (pMoreBCs) +/*N*/ { +/*N*/ ULONG nBCCount = pMoreBCs->Count(); +/*N*/ for (ULONG i=0; i<nBCCount; i++) +/*N*/ { +/*N*/ SfxBroadcaster* pBC = pMoreBCs->GetObject(i); +/*N*/ nLstCount = pBC->GetListenerCount(); +/*N*/ for (nLstPos=nLstCount; nLstPos>0;) +/*N*/ { +/*N*/ --nLstPos; +/*N*/ SfxListener* pLst = pBC->GetListener(nLstPos); +/*N*/ rNew.StartBroadcasting(*pLst, TRUE); +/*N*/ pLst->EndListening(*pBC); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } + + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_cell.cxx b/binfilter/bf_sc/source/core/data/sc_cell.cxx new file mode 100644 index 000000000000..99ed87c7904e --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_cell.cxx @@ -0,0 +1,1611 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#ifdef MAC + // StackSpace +#include <mac_start.h> +#include <Memory.h> +#include <fp.h> +#include <mac_end.h> +#endif + +#if defined (SOLARIS) || defined (FREEBSD) || defined (OPENBSD) +#include <ieeefp.h> +#elif ( defined ( LINUX ) && ( GLIBC < 2 ) ) +#include <i386/ieeefp.h> +#endif + +#include <bf_svtools/zforlist.hxx> +#include <float.h> // _finite + +#include "interpre.hxx" +#include "scmatrix.hxx" +#include "docoptio.hxx" +#include "rechead.hxx" +#include "rangenam.hxx" +#include "progress.hxx" +#include "bclist.hxx" +namespace binfilter { + +// jetzt fuer alle Systeme niedriger Wert, Rest wird per FormulaTree ausgebuegelt, +// falls wirklich eine tiefe Rekursion ist, geht das schneller, als zu versuchen +// und dann doch nicht zu schaffen.. +#define SIMPLEMAXRECURSION +#ifdef SIMPLEMAXRECURSION + #define MAXRECURSION 50 +#else +#if defined( WIN ) || defined( OS2 ) + #define MAXRECURSION 50 +#elif defined( MAC ) + // wird per StackSpace() ermittelt +#else + #define MAXRECURSION 1000 +#endif +#endif + +// STATIC DATA ----------------------------------------------------------- + +#ifdef USE_MEMPOOL +// MemPools auf 4k Boundaries - 64 Bytes ausrichten +/*N*/ const USHORT nMemPoolValueCell = (0x8000 - 64) / sizeof(ScValueCell); +/*N*/ const USHORT nMemPoolFormulaCell = (0x8000 - 64) / sizeof(ScFormulaCell); +/*N*/ const USHORT nMemPoolStringCell = (0x4000 - 64) / sizeof(ScStringCell); +/*N*/ const USHORT nMemPoolNoteCell = (0x1000 - 64) / sizeof(ScNoteCell); +/*N*/ IMPL_FIXEDMEMPOOL_NEWDEL( ScValueCell, nMemPoolValueCell, nMemPoolValueCell ) +/*N*/ IMPL_FIXEDMEMPOOL_NEWDEL( ScFormulaCell, nMemPoolFormulaCell, nMemPoolFormulaCell ) +/*N*/ IMPL_FIXEDMEMPOOL_NEWDEL( ScStringCell, nMemPoolStringCell, nMemPoolStringCell ) +/*N*/ IMPL_FIXEDMEMPOOL_NEWDEL( ScNoteCell, nMemPoolNoteCell, nMemPoolNoteCell ) +#endif + +#ifdef _MSC_VER +#pragma code_seg() +#endif + +INT8 ScFormulaCell::nIterMode = 0; + +#ifdef DBG_UTIL +static const sal_Char __FAR_DATA msgDbgInfinity[] = + "Formelzelle INFINITY ohne Err503 !!! (os/2?)\n" + "NICHTS anruehren und ER bescheid sagen!"; +#endif + +// ----------------------------------------------------------------------- + +DECLARE_LIST (ScFormulaCellList, ScFormulaCell*)//STRIP008 ; + + +/*N*/ ScBaseCell* ScBaseCell::Clone(ScDocument* pDoc) const +/*N*/ { +/*N*/ switch (eCellType) +/*N*/ { +/*N*/ case CELLTYPE_VALUE: +/*N*/ return new ScValueCell(*(const ScValueCell*)this); +/*N*/ case CELLTYPE_STRING: +/*N*/ return new ScStringCell(*(const ScStringCell*)this); +/*N*/ case CELLTYPE_EDIT: +/*N*/ return new ScEditCell(*(const ScEditCell*)this, pDoc); +/*N*/ case CELLTYPE_FORMULA: +/*N*/ return new ScFormulaCell(pDoc, ((ScFormulaCell*)this)->aPos, +/*N*/ *(const ScFormulaCell*)this); +/*N*/ case CELLTYPE_NOTE: +/*N*/ return new ScNoteCell(*(const ScNoteCell*)this); +/*N*/ default: +/*N*/ DBG_ERROR("Unbekannter Zellentyp"); +/*N*/ return NULL; +/*N*/ } +/*N*/ } + +/*N*/ ScBaseCell::~ScBaseCell() +/*N*/ { +/*N*/ delete pNote; +/*N*/ delete pBroadcaster; +/*N*/ DBG_ASSERT( eCellType == CELLTYPE_DESTROYED, "BaseCell Destructor" ); +/*N*/ } + +/*N*/ void ScBaseCell::Delete() +/*N*/ { +/*N*/ DELETEZ(pNote); +/*N*/ switch (eCellType) +/*N*/ { +/*N*/ case CELLTYPE_VALUE: +/*N*/ delete (ScValueCell*) this; +/*N*/ break; +/*N*/ case CELLTYPE_STRING: +/*N*/ delete (ScStringCell*) this; +/*N*/ break; +/*N*/ case CELLTYPE_EDIT: +/*N*/ delete (ScEditCell*) this; +/*N*/ break; +/*N*/ case CELLTYPE_FORMULA: +/*N*/ delete (ScFormulaCell*) this; +/*N*/ break; +/*N*/ case CELLTYPE_NOTE: +/*N*/ delete (ScNoteCell*) this; +/*N*/ break; +/*N*/ default: +/*N*/ DBG_ERROR("Unbekannter Zellentyp"); +/*N*/ break; +/*N*/ } +/*N*/ } + +/*N*/ void ScBaseCell::SetNote( const ScPostIt& rNote ) +/*N*/ { +/*N*/ if (rNote.GetText().Len() > 0) +/*N*/ { +/*N*/ if (!pNote) +/*N*/ pNote = new ScPostIt(rNote); +/*N*/ else +/*N*/ *pNote = rNote; +/*N*/ } +/*N*/ else +/*?*/ DELETEZ(pNote); +/*N*/ } + +/*N*/ BOOL ScBaseCell::GetNote( ScPostIt& rNote ) const +/*N*/ { +/*N*/ if ( pNote ) +/*N*/ rNote = *pNote; +/*N*/ else +/*?*/ rNote.Clear(); +/*N*/ +/*N*/ return ( pNote != NULL ); +/*N*/ } + +/*N*/ ScBaseCell* ScBaseCell::CreateTextCell( const String& rString, ScDocument* pDoc ) +/*N*/ { +/*N*/ if ( rString.Search('\n') != STRING_NOTFOUND || rString.Search(CHAR_CR) != STRING_NOTFOUND ) +/*?*/ return new ScEditCell( rString, pDoc ); +/*N*/ else +/*N*/ return new ScStringCell( rString ); +/*N*/ } + +/*N*/ void ScBaseCell::LoadNote( SvStream& rStream ) +/*N*/ { +/*N*/ pNote = new ScPostIt; +/*N*/ rStream >> *pNote; +/*N*/ } + +/*N*/ void ScBaseCell::SetBroadcaster(ScBroadcasterList* pNew) +/*N*/ { +/*N*/ delete pBroadcaster; +/*N*/ pBroadcaster = pNew; +/*N*/ } + +/*M*/ void ScBaseCell::StartListeningTo( ScDocument* pDoc, USHORT nOnlyNames ) +/*M*/ { +/*M*/ if ( eCellType == CELLTYPE_FORMULA && !pDoc->IsClipOrUndo() +/*M*/ && !pDoc->GetNoListening() +/*M*/ && !((ScFormulaCell*)this)->IsInChangeTrack() +/*M*/ ) +/*M*/ { +/*M*/ pDoc->SetDetectiveDirty(TRUE); // es hat sich was geaendert... +/*M*/ +/*M*/ ScFormulaCell* pFormCell = (ScFormulaCell*)this; +/*M*/ ScTokenArray* pArr = pFormCell->GetCode(); +/*M*/ if( pArr->IsRecalcModeAlways() ) +/*M*/ pDoc->StartListeningArea( BCA_LISTEN_ALWAYS, pFormCell ); +/*M*/ else +/*M*/ { +/*M*/ if ( nOnlyNames && ((nOnlyNames & SC_LISTENING_EXCEPT) == 0) && +/*M*/ pArr->IsReplacedSharedFormula() ) +/*M*/ nOnlyNames = 0; +/*M*/ pArr->Reset(); +/*M*/ for( ScToken* t = pArr->GetNextReferenceRPN(); t; +/*M*/ t = pArr->GetNextReferenceRPN() ) +/*M*/ { +/*M*/ StackVar eType = t->GetType(); +/*M*/ SingleRefData& rRef1 = t->GetSingleRef(); +/*M*/ SingleRefData& rRef2 = (eType == svDoubleRef ? +/*M*/ t->GetDoubleRef().Ref2 : rRef1); +/*M*/ BOOL bDo = FALSE; +/*M*/ if ( !nOnlyNames ) +/*M*/ bDo = TRUE; +/*M*/ else +/*M*/ { +/*M*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 bDo = pArr->IsReplacedSharedFormula(); +/*M*/ } +/*M*/ if ( bDo ) +/*M*/ { +/*M*/ switch( eType ) +/*M*/ { +/*M*/ case svSingleRef: +/*M*/ rRef1.CalcAbsIfRel( pFormCell->aPos ); +/*M*/ if ( rRef1.Valid() ) +/*M*/ { +/*M*/ pDoc->StartListeningCell( +/*M*/ ScAddress( rRef1.nCol, +/*M*/ rRef1.nRow, +/*M*/ rRef1.nTab ), pFormCell ); +/*M*/ } +/*M*/ break; +/*M*/ case svDoubleRef: +/*M*/ t->CalcAbsIfRel( pFormCell->aPos ); +/*M*/ if ( rRef1.Valid() && rRef2.Valid() ) +/*M*/ { +/*M*/ if ( t->GetOpCode() == ocColRowNameAuto ) +/*M*/ { // automagically +/*?*/ if ( rRef1.IsColRel() ) +/*?*/ { // ColName +/*?*/ pDoc->StartListeningArea( ScRange ( +/*?*/ 0, +/*?*/ rRef1.nRow, +/*?*/ rRef1.nTab, +/*?*/ MAXCOL, +/*?*/ rRef2.nRow, +/*?*/ rRef2.nTab ), pFormCell ); +/*?*/ } +/*?*/ else +/*?*/ { // RowName +/*?*/ pDoc->StartListeningArea( ScRange ( +/*?*/ rRef1.nCol, +/*?*/ 0, +/*?*/ rRef1.nTab, +/*?*/ rRef2.nCol, +/*?*/ MAXROW, +/*?*/ rRef2.nTab ), pFormCell ); +/*?*/ } +/*M*/ } +/*M*/ else +/*M*/ { +/*M*/ pDoc->StartListeningArea( ScRange ( +/*M*/ rRef1.nCol, +/*M*/ rRef1.nRow, +/*M*/ rRef1.nTab, +/*M*/ rRef2.nCol, +/*M*/ rRef2.nRow, +/*M*/ rRef2.nTab ), pFormCell ); +/*M*/ } +/*M*/ } +/*M*/ break; +/*M*/ } +/*M*/ } +/*M*/ } +/*M*/ } +/*M*/ pArr->SetReplacedSharedFormula( FALSE ); +/*M*/ } +/*M*/ } + +// pArr gesetzt -> Referenzen von anderer Zelle nehmen +// dann muss auch aPos uebergeben werden! + +/*N*/ void ScBaseCell::EndListeningTo( ScDocument* pDoc, USHORT nOnlyNames, +/*N*/ ScTokenArray* pArr, ScAddress aPos ) +/*N*/ { +/*N*/ if ( eCellType == CELLTYPE_FORMULA && !pDoc->IsClipOrUndo() +/*N*/ && !((ScFormulaCell*)this)->IsInChangeTrack() +/*N*/ ) +/*N*/ { +/*N*/ pDoc->SetDetectiveDirty(TRUE); // es hat sich was geaendert... +/*N*/ +/*N*/ ScFormulaCell* pFormCell = (ScFormulaCell*)this; +/*N*/ if( pFormCell->GetCode()->IsRecalcModeAlways() ) +/*?*/ pDoc->EndListeningArea( BCA_LISTEN_ALWAYS, pFormCell ); +/*N*/ else +/*N*/ { +/*N*/ if (!pArr) +/*N*/ { +/*N*/ pArr = pFormCell->GetCode(); +/*N*/ aPos = pFormCell->aPos; +/*N*/ } +/*N*/ pArr->Reset(); +/*N*/ for( ScToken* t = pArr->GetNextReferenceRPN(); t; +/*N*/ t = pArr->GetNextReferenceRPN() ) +/*N*/ { +/*N*/ StackVar eType = t->GetType(); +/*N*/ SingleRefData& rRef1 = t->GetSingleRef(); +/*N*/ SingleRefData& rRef2 = (eType == svDoubleRef ? +/*N*/ t->GetDoubleRef().Ref2 : rRef1); +/*N*/ BOOL bDo; +/*N*/ if ( !nOnlyNames ) +/*N*/ bDo = TRUE; +/*N*/ else +/*N*/ { +/*?*/ bDo = FALSE; +/*?*/ if ( nOnlyNames & SC_LISTENING_NAMES_REL ) +/*?*/ bDo |= (rRef1.IsRelName() || rRef2.IsRelName()); +/*?*/ if ( nOnlyNames & SC_LISTENING_NAMES_ABS ) +/*?*/ { DBG_BF_ASSERT(0, "STRIP");} //STRIP001 bDo |= t->IsRPNReferenceAbsName(); +/*?*/ if ( nOnlyNames & SC_LISTENING_EXCEPT ) +/*?*/ bDo = !bDo; +/*N*/ } +/*N*/ if ( bDo ) +/*N*/ { +/*N*/ switch( t->GetType() ) +/*N*/ { +/*N*/ case svSingleRef: +/*N*/ rRef1.CalcAbsIfRel( aPos ); +/*N*/ if ( rRef1.Valid() ) +/*N*/ { +/*N*/ pDoc->EndListeningCell( +/*N*/ ScAddress( rRef1.nCol, +/*N*/ rRef1.nRow, +/*N*/ rRef1.nTab ), pFormCell ); +/*N*/ } +/*N*/ break; +/*N*/ case svDoubleRef: +/*N*/ t->CalcAbsIfRel( aPos ); +/*N*/ if ( rRef1.Valid() && rRef2.Valid() ) +/*N*/ { +/*N*/ if ( t->GetOpCode() == ocColRowNameAuto ) +/*N*/ { // automagically +/*?*/ if ( rRef1.IsColRel() ) +/*?*/ { // ColName +/*?*/ pDoc->EndListeningArea( ScRange ( +/*?*/ 0, +/*?*/ rRef1.nRow, +/*?*/ rRef1.nTab, +/*?*/ MAXCOL, +/*?*/ rRef2.nRow, +/*?*/ rRef2.nTab ), pFormCell ); +/*?*/ } +/*?*/ else +/*?*/ { // RowName +/*?*/ pDoc->EndListeningArea( ScRange ( +/*?*/ rRef1.nCol, +/*?*/ 0, +/*?*/ rRef1.nTab, +/*?*/ rRef2.nCol, +/*?*/ MAXROW, +/*?*/ rRef2.nTab ), pFormCell ); +/*?*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ pDoc->EndListeningArea( ScRange ( +/*N*/ rRef1.nCol, +/*N*/ rRef1.nRow, +/*N*/ rRef1.nTab, +/*N*/ rRef2.nCol, +/*N*/ rRef2.nRow, +/*N*/ rRef2.nTab ), pFormCell ); +/*N*/ } +/*N*/ } +/*N*/ break; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } + + +/*N*/ BOOL ScBaseCell::HasValueData() const +/*N*/ { +/*N*/ switch ( eCellType ) +/*N*/ { +/*N*/ case CELLTYPE_VALUE : +/*N*/ return TRUE; +/*N*/ case CELLTYPE_FORMULA : +/*N*/ return ((ScFormulaCell*)this)->IsValue(); +/*N*/ default: +/*N*/ return FALSE; +/*N*/ } +/*N*/ } + + +/*N*/ BOOL ScBaseCell::HasStringData() const +/*N*/ { +/*N*/ switch ( eCellType ) +/*N*/ { +/*N*/ case CELLTYPE_STRING : +/*N*/ case CELLTYPE_EDIT : +/*N*/ return TRUE; +/*N*/ case CELLTYPE_FORMULA : +/*N*/ return !((ScFormulaCell*)this)->IsValue(); +/*N*/ default: +/*N*/ return FALSE; +/*N*/ } +/*N*/ } + +/*N*/ String ScBaseCell::GetStringData() const +/*N*/ { +/*N*/ String aStr; +/*N*/ switch ( eCellType ) +/*N*/ { +/*N*/ case CELLTYPE_STRING: +/*N*/ ((const ScStringCell*)this)->GetString( aStr ); +/*N*/ break; +/*N*/ case CELLTYPE_EDIT: +/*N*/ ((const ScEditCell*)this)->GetString( aStr ); +/*N*/ break; +/*N*/ case CELLTYPE_FORMULA: +/*N*/ ((ScFormulaCell*)this)->GetString( aStr ); // an der Formelzelle nicht-const +/*N*/ break; +/*N*/ } +/*N*/ return aStr; +/*N*/ } + +// static +/*N*/ BOOL ScBaseCell::CellEqual( const ScBaseCell* pCell1, const ScBaseCell* pCell2 ) +/*N*/ { +/*N*/ CellType eType1 = CELLTYPE_NONE; +/*N*/ CellType eType2 = CELLTYPE_NONE; +/*N*/ if ( pCell1 ) +/*N*/ { +/*N*/ eType1 = pCell1->GetCellType(); +/*N*/ if (eType1 == CELLTYPE_EDIT) +/*N*/ eType1 = CELLTYPE_STRING; +/*N*/ else if (eType1 == CELLTYPE_NOTE) +/*N*/ eType1 = CELLTYPE_NONE; +/*N*/ } +/*N*/ if ( pCell2 ) +/*N*/ { +/*N*/ eType2 = pCell2->GetCellType(); +/*N*/ if (eType2 == CELLTYPE_EDIT) +/*N*/ eType2 = CELLTYPE_STRING; +/*N*/ else if (eType2 == CELLTYPE_NOTE) +/*N*/ eType2 = CELLTYPE_NONE; +/*N*/ } +/*N*/ if ( eType1 != eType2 ) +/*N*/ return FALSE; +/*N*/ +/*N*/ switch ( eType1 ) // beide Typen gleich +/*N*/ { +/*N*/ case CELLTYPE_NONE: // beide leer +/*N*/ return TRUE; +/*N*/ case CELLTYPE_VALUE: // wirklich Value-Zellen +/*N*/ return ( ((const ScValueCell*)pCell1)->GetValue() == +/*N*/ ((const ScValueCell*)pCell2)->GetValue() ); +/*N*/ case CELLTYPE_STRING: // String oder Edit +/*N*/ { +/*N*/ String aText1; +/*N*/ if ( pCell1->GetCellType() == CELLTYPE_STRING ) +/*N*/ ((const ScStringCell*)pCell1)->GetString(aText1); +/*N*/ else +/*N*/ ((const ScEditCell*)pCell1)->GetString(aText1); +/*N*/ String aText2; +/*N*/ if ( pCell2->GetCellType() == CELLTYPE_STRING ) +/*N*/ ((const ScStringCell*)pCell2)->GetString(aText2); +/*N*/ else +/*N*/ ((const ScEditCell*)pCell2)->GetString(aText2); +/*N*/ return ( aText1 == aText2 ); +/*N*/ } +/*N*/ case CELLTYPE_FORMULA: +/*N*/ { +/*N*/ //! eingefuegte Zeilen / Spalten beruecksichtigen !!!!! +/*N*/ //! Vergleichsfunktion an der Formelzelle ??? +/*N*/ //! Abfrage mit ScColumn::SwapRow zusammenfassen! +/*N*/ +/*N*/ ScTokenArray* pCode1 = ((ScFormulaCell*)pCell1)->GetCode(); +/*N*/ ScTokenArray* pCode2 = ((ScFormulaCell*)pCell2)->GetCode(); +/*N*/ +/*N*/ if (pCode1->GetLen() == pCode2->GetLen()) // nicht-UPN +/*N*/ { +/*N*/ BOOL bEqual = TRUE; +/*N*/ USHORT nLen = pCode1->GetLen(); +/*N*/ ScToken** ppToken1 = pCode1->GetArray(); +/*N*/ ScToken** ppToken2 = pCode2->GetArray(); +/*N*/ for (USHORT i=0; i<nLen; i++) +/*N*/ if ( !ppToken1[i]->TextEqual(*(ppToken2[i])) ) +/*N*/ { +/*N*/ bEqual = FALSE; +/*N*/ break; +/*N*/ } +/*N*/ +/*N*/ if (bEqual) +/*N*/ return TRUE; +/*N*/ } +/*N*/ +/*N*/ return FALSE; // unterschiedlich lang oder unterschiedliche Tokens +/*N*/ } +/*N*/ default: +/*N*/ DBG_ERROR("huch, was fuer Zellen???"); +/*N*/ } +/*N*/ return FALSE; +/*N*/ } + +//----------------------------------------------------------------------------------- + +/*N*/ ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos, +/*N*/ const String& rFormula, BYTE cMatInd ) : +/*N*/ ScBaseCell( CELLTYPE_FORMULA ), +/*N*/ aPos( rPos ), +/*N*/ pCode( NULL ), +/*N*/ nErgValue( 0.0 ), +/*N*/ bIsValue( TRUE ), +/*N*/ bDirty( TRUE ), // -> wg. Benutzung im Fkt.AutoPiloten, war: cMatInd != 0 +/*N*/ bChanged( FALSE ), +/*N*/ bRunning( FALSE ), +/*N*/ bCompile( FALSE ), +/*N*/ bSubTotal( FALSE ), +/*N*/ pDocument( pDoc ), +/*N*/ nFormatType( NUMBERFORMAT_NUMBER ), +/*N*/ nFormatIndex(0), +/*N*/ cMatrixFlag ( cMatInd ), +/*N*/ pMatrix( NULL ), +/*N*/ bIsIterCell (FALSE), +/*N*/ bInChangeTrack( FALSE ), +/*N*/ bTableOpDirty( FALSE ), +/*N*/ pPrevious(0), +/*N*/ pNext(0), +/*N*/ pPreviousTrack(0), +/*N*/ pNextTrack(0), +/*N*/ nMatCols(0), +/*N*/ nMatRows(0) +/*N*/ { +/*N*/ Compile( rFormula, TRUE ); // bNoListening, erledigt Insert +/*N*/ } + +// Wird von den Importfiltern verwendet + +/*N*/ ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos, +/*N*/ const ScTokenArray* pArr, BYTE cInd ) : +/*N*/ ScBaseCell( CELLTYPE_FORMULA ), +/*N*/ aPos( rPos ), +/*N*/ pCode( pArr ? new ScTokenArray( *pArr ) : new ScTokenArray ), +/*N*/ nErgValue( 0.0 ), +/*N*/ bIsValue( TRUE ), +/*N*/ bDirty( NULL != pArr ), // -> wg. Benutzung im Fkt.AutoPiloten, war: cInd != 0 +/*N*/ bChanged( FALSE ), +/*N*/ bRunning( FALSE ), +/*N*/ bCompile( FALSE ), +/*N*/ bSubTotal( FALSE ), +/*N*/ pDocument( pDoc ), +/*N*/ nFormatType( NUMBERFORMAT_NUMBER ), +/*N*/ nFormatIndex(0), +/*N*/ cMatrixFlag ( cInd ), +/*N*/ pMatrix ( NULL ), +/*N*/ bIsIterCell (FALSE), +/*N*/ bInChangeTrack( FALSE ), +/*N*/ bTableOpDirty( FALSE ), +/*N*/ pPrevious(0), +/*N*/ pNext(0), +/*N*/ pPreviousTrack(0), +/*N*/ pNextTrack(0), +/*N*/ nMatCols(0), +/*N*/ nMatRows(0) +/*N*/ { +/*N*/ // UPN-Array erzeugen +/*N*/ if( pCode->GetLen() && !pCode->GetError() && !pCode->GetCodeLen() ) +/*N*/ { +/*N*/ ScCompiler aComp(pDocument, aPos, *pCode); +/*N*/ bSubTotal = aComp.CompileTokenArray(); +/*N*/ nFormatType = aComp.GetNumFormatType(); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ pCode->Reset(); +/*N*/ if ( pCode->GetNextOpCodeRPN( ocSubTotal ) ) +/*N*/ bSubTotal = TRUE; +/*N*/ } +/*N*/ } + +/*N*/ ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rNewPos, +/*N*/ const ScFormulaCell& rScFormulaCell, USHORT nCopyFlags ) : +/*N*/ ScBaseCell( rScFormulaCell ), +/*N*/ SfxListener(), +/*N*/ aErgString( rScFormulaCell.aErgString ), +/*N*/ nErgValue( rScFormulaCell.nErgValue ), +/*N*/ bIsValue( rScFormulaCell.bIsValue ), +/*N*/ bDirty( rScFormulaCell.bDirty ), +/*N*/ bChanged( rScFormulaCell.bChanged ), +/*N*/ bRunning( rScFormulaCell.bRunning ), +/*N*/ bCompile( rScFormulaCell.bCompile ), +/*N*/ bSubTotal( rScFormulaCell.bSubTotal ), +/*N*/ pDocument( pDoc ), +/*N*/ nFormatType( rScFormulaCell.nFormatType ), +/*N*/ nFormatIndex( pDoc == rScFormulaCell.pDocument ? rScFormulaCell.nFormatIndex : 0 ), +/*N*/ cMatrixFlag ( rScFormulaCell.cMatrixFlag ), +/*N*/ bIsIterCell (FALSE), +/*N*/ bInChangeTrack( FALSE ), +/*N*/ bTableOpDirty( FALSE ), +/*N*/ pPrevious(0), +/*N*/ pNext(0), +/*N*/ pPreviousTrack(0), +/*N*/ pNextTrack(0), +/*N*/ aPos( rNewPos ), +/*N*/ nMatCols( rScFormulaCell.nMatCols ), +/*N*/ nMatRows( rScFormulaCell.nMatRows ) +/*N*/ { +/*N*/ if (rScFormulaCell.pMatrix) +/*?*/ pMatrix = rScFormulaCell.pMatrix->Clone(); +/*N*/ else +/*N*/ pMatrix = NULL; +/*N*/ pCode = rScFormulaCell.pCode->Clone(); +/*N*/ +/*N*/ if ( nCopyFlags & 0x0001 ) +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 pCode->ReadjustRelative3DReferences( rScFormulaCell.aPos, aPos ); +/*N*/ +/*N*/ // evtl. Fehler zuruecksetzen und neu kompilieren +/*N*/ // nicht im Clipboard - da muss das Fehlerflag erhalten bleiben +/*N*/ // Spezialfall Laenge=0: als Fehlerzelle erzeugt, dann auch Fehler behalten +/*N*/ if ( pCode->GetError() && !pDocument->IsClipboard() && pCode->GetLen() ) +/*N*/ { +/*N*/ pCode->SetError( 0 ); +/*N*/ bCompile = TRUE; +/*N*/ } +/*N*/ //! Compile ColRowNames on URM_MOVE/URM_COPY _after_ UpdateReference +/*N*/ BOOL bCompileLater = FALSE; +/*N*/ BOOL bClipMode = rScFormulaCell.pDocument->IsClipboard(); +/*N*/ if( !bCompile ) +/*N*/ { // Name references with references and ColRowNames +/*N*/ pCode->Reset(); +/*N*/ for( ScToken* t = pCode->GetNextReferenceOrName(); t && !bCompile; +/*N*/ t = pCode->GetNextReferenceOrName() ) +/*N*/ { +/*N*/ if ( t->GetType() == svIndex ) +/*N*/ { +/*?*/ ScRangeData* pRangeData = pDoc->GetRangeName()->FindIndex( t->GetIndex() ); +/*?*/ if( pRangeData ) +/*?*/ { +/*?*/ if( pRangeData->HasReferences() ) +/*?*/ bCompile = TRUE; +/*?*/ } +/*?*/ else +/*?*/ bCompile = TRUE; // invalid reference! +/*N*/ } +/*N*/ else if ( t->GetOpCode() == ocColRowName ) +/*N*/ { +/*N*/ bCompile = TRUE; // new lookup needed +/*N*/ bCompileLater = bClipMode; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ if( bCompile ) +/*N*/ { +/*N*/ if ( !bCompileLater && bClipMode ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 pCode->Reset(); +/*N*/ } +/*N*/ if ( !bCompileLater ) +/*N*/ { +/*N*/ // bNoListening, bei in Clip/Undo sowieso nicht, +/*N*/ // bei aus Clip auch nicht, sondern nach Insert(Clone) und UpdateReference +/*N*/ CompileTokenArray( TRUE ); +/*N*/ } +/*N*/ } +/*N*/ } + +// +---+---+---+---+---+---+---+---+ +// | |Str|Num|Dir|cMatrix| +// +---+---+---+---+---+---+---+---+ + +/*N*/ ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos, +/*N*/ SvStream& rStream, ScMultipleReadHeader& rHdr ) : +/*N*/ ScBaseCell( CELLTYPE_FORMULA ), +/*N*/ aPos( rPos ), +/*N*/ pCode( new ScTokenArray ), +/*N*/ nErgValue( 0.0 ), +/*N*/ bIsValue( TRUE ), +/*N*/ bDirty( FALSE ), +/*N*/ bChanged( FALSE ), +/*N*/ bRunning( FALSE ), +/*N*/ bCompile( FALSE ), +/*N*/ bSubTotal( FALSE ), +/*N*/ pDocument( pDoc ), +/*N*/ nFormatType( 0 ), +/*N*/ nFormatIndex(0), +/*N*/ pMatrix ( NULL ), +/*N*/ bIsIterCell (FALSE), +/*N*/ bInChangeTrack( FALSE ), +/*N*/ bTableOpDirty( FALSE ), +/*N*/ pPrevious(0), +/*N*/ pNext(0), +/*N*/ pPreviousTrack(0), +/*N*/ pNextTrack(0), +/*N*/ nMatCols(0), +/*N*/ nMatRows(0) +/*N*/ { +/*N*/ // ScReadHeader aHdr( rStream ); +/*N*/ rHdr.StartEntry(); +/*N*/ +/*N*/ USHORT nVer = (USHORT) pDoc->GetSrcVersion(); +/*N*/ +/*N*/ if( nVer >= SC_NUMFMT ) +/*N*/ { +/*N*/ BYTE cData; +/*N*/ rStream >> cData; +/*N*/ #ifdef DBG_UTIL +/*N*/ // static BOOL bShown = 0; +/*N*/ // if ( !bShown && SOFFICE_FILEFORMAT_NOW > SOFFICE_FILEFORMAT_50 ) +/*N*/ // { +/*N*/ // bShown = 1; +/*N*/ // DBG_ERRORFILE( "bei inkompatiblem FileFormat den FormatIndex umheben!" ); +/*N*/ // } +/*N*/ #endif +/*N*/ if( cData & 0x0F ) +/*N*/ { +/*N*/ BYTE nSkip = cData & 0x0F; +/*N*/ if ( (cData & 0x10) && nSkip >= sizeof(UINT32) ) +/*N*/ { +/*N*/ UINT32 n; +/*N*/ rStream >> n; +/*N*/ nFormatIndex = n; +/*N*/ nSkip -= sizeof(UINT32); +/*N*/ } +/*N*/ if ( nSkip ) +/*?*/ rStream.SeekRel( nSkip ); +/*N*/ } +/*N*/ BYTE cFlags; +/*N*/ rStream >> cFlags >> nFormatType; +/*N*/ cMatrixFlag = (BYTE) ( cFlags & 0x03 ); +/*N*/ bDirty = BOOL( ( cFlags & 0x04 ) != 0 ); +/*N*/ if( cFlags & 0x08 ) +/*N*/ rStream >> nErgValue; +/*N*/ if( cFlags & 0x10 ) +/*N*/ { +/*N*/ rStream.ReadByteString( aErgString, rStream.GetStreamCharSet() ); +/*N*/ bIsValue = FALSE; +/*N*/ } +/*N*/ pCode->Load( rStream, nVer, aPos ); +/*N*/ if ( (cFlags & 0x18) == 0 ) +/*N*/ bDirty = TRUE; // #67161# no result stored => recalc +/*N*/ if( cFlags & 0x20 ) +/*N*/ bSubTotal = TRUE; +/*N*/ else if ( nVer < SC_SUBTOTAL_BUGFIX ) +/*N*/ { // #65285# in alten Dokumenten war Flag nicht gesetzt, wenn Formel +/*?*/ // manuell eingegeben wurde (nicht via Daten->Teilergebnisse) +/*N*/ if ( pCode->HasOpCodeRPN( ocSubTotal ) ) +/*N*/ { +/*?*/ bDirty = TRUE; // neu berechnen +/*?*/ bSubTotal = TRUE; +/*N*/ } +/*N*/ } +/*N*/ if ( cMatrixFlag == MM_FORMULA && rHdr.BytesLeft() ) +/*N*/ rStream >> nMatCols >> nMatRows; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ UINT16 nCodeLen; +/*N*/ if( pDoc->GetSrcVersion() >= SC_FORMULA_LCLVER ) +/*N*/ rStream.SeekRel( 2 ); +/*N*/ rStream >> cMatrixFlag >> nCodeLen; +/*N*/ if( cMatrixFlag == 5 ) +/*N*/ cMatrixFlag = 0; +/*N*/ cMatrixFlag &= 3; +/*N*/ if( nCodeLen ) +/*N*/ pCode->Load30( rStream, aPos ); +/*N*/ // Wir koennen hier bei Calc 3.0-Docs noch kein UPN-Array +/*N*/ // erzeugen, da die Named Ranges noch nicht eingelesen sind +/*N*/ } +/*N*/ +/*N*/ rHdr.EndEntry(); +/*N*/ +/*N*/ // after loading, it must be known if ocMacro is in any formula +/*N*/ // (for macro warning, and to insert the hidden view) +/*N*/ if ( !pDoc->GetHasMacroFunc() && pCode->HasOpCodeRPN( ocMacro ) ) +/*N*/ pDoc->SetHasMacroFunc( TRUE ); +/*N*/ } + +/*N*/ BOOL lcl_IsBeyond( ScTokenArray* pCode, USHORT nMaxRow ) +/*N*/ { +/*N*/ ScToken* t; +/*N*/ pCode->Reset(); +/*N*/ while ( t = pCode->GetNextReferenceRPN() ) // RPN -> auch in Namen +/*N*/ if ( t->GetSingleRef().nRow > nMaxRow || +/*N*/ (t->GetType() == svDoubleRef && +/*N*/ t->GetDoubleRef().Ref2.nRow > nMaxRow) ) +/*N*/ return TRUE; +/*N*/ return FALSE; +/*N*/ } + +/*N*/ void ScFormulaCell::Save( SvStream& rStream, ScMultipleWriteHeader& rHdr ) const +/*N*/ { +/*N*/ USHORT nSaveMaxRow = pDocument->GetSrcMaxRow(); +/*N*/ if ( nSaveMaxRow < MAXROW && lcl_IsBeyond( pCode, nSaveMaxRow ) ) +/*N*/ { +/*?*/ // Zelle mit Ref-Error erzeugen und speichern +/*?*/ // StartEntry/EndEntry passiert beim Speichern der neuen Zelle +/*?*/ +/*?*/ SingleRefData aRef; +/*?*/ aRef.InitAddress(ScAddress()); +/*?*/ aRef.SetColRel(TRUE); +/*?*/ aRef.SetColDeleted(TRUE); +/*?*/ aRef.SetRowRel(TRUE); +/*?*/ aRef.SetRowDeleted(TRUE); +/*?*/ aRef.CalcRelFromAbs(aPos); +/*?*/ ScTokenArray aArr; +/*?*/ aArr.AddSingleReference(aRef); +/*?*/ aArr.AddOpCode(ocStop); +/*?*/ ScFormulaCell* pErrCell = new ScFormulaCell( pDocument, aPos, &aArr ); +/*?*/ pErrCell->Save( rStream, rHdr ); +/*?*/ delete pErrCell; +/*?*/ +/*?*/ pDocument->SetLostData(); // Warnung ausgeben +/*?*/ return; +/*N*/ } +/*N*/ +/*N*/ rHdr.StartEntry(); +/*N*/ +/*N*/ if ( bIsValue && !pCode->GetError() && !::rtl::math::isFinite( nErgValue ) ) +/*N*/ { +/*N*/ DBG_ERRORFILE( msgDbgInfinity ); +/*N*/ pCode->SetError( errIllegalFPOperation ); +/*N*/ } +/*N*/ BYTE cFlags = cMatrixFlag & 0x03; +/*N*/ if( bDirty ) +/*N*/ cFlags |= 0x04; +/*N*/ // Daten speichern? +/*N*/ if( pCode->IsRecalcModeNormal() && !pCode->GetError() ) +/*N*/ cFlags |= bIsValue ? 0x08 : 0x10; +/*N*/ if ( bSubTotal ) +/*N*/ cFlags |= 0x20; +/*N*/ #ifdef DBG_UTIL +/*N*/ static BOOL bShown = 0; +/*N*/ if ( !bShown && rStream.GetVersion() > SOFFICE_FILEFORMAT_50 ) +/*N*/ { +/*N*/ bShown = 1; +/*N*/ DBG_ERRORFILE( "bei inkompatiblem FileFormat den FormatIndex umheben!" ); +/*N*/ } +/*N*/ // rStream << (BYTE) 0x00; +/*N*/ #endif +/*N*/ if ( nFormatIndex ) +/*N*/ rStream << (BYTE) (0x10 | sizeof(UINT32)) << static_cast<sal_uInt32>(nFormatIndex); +/*N*/ else +/*N*/ rStream << (BYTE) 0x00; +/*N*/ rStream << cFlags << (UINT16) nFormatType; +/*N*/ if( cFlags & 0x08 ) +/*N*/ rStream << nErgValue; +/*N*/ if( cFlags & 0x10 ) +/*N*/ rStream.WriteByteString( aErgString, rStream.GetStreamCharSet() ); +/*N*/ pCode->Store( rStream, aPos ); +/*N*/ if ( cMatrixFlag == MM_FORMULA ) +/*N*/ rStream << nMatCols << nMatRows; +/*N*/ +/*N*/ rHdr.EndEntry(); +/*N*/ } + +/*N*/ ScBaseCell* ScFormulaCell::Clone( ScDocument* pDoc, const ScAddress& rPos, +/*N*/ BOOL bNoListening ) const +/*N*/ { +/*N*/ ScFormulaCell* pCell = new ScFormulaCell( pDoc, rPos, *this ); +/*N*/ if ( !bNoListening ) +/*N*/ pCell->StartListeningTo( pDoc ); +/*N*/ return pCell; +/*N*/ } + +/*N*/ void ScFormulaCell::GetFormula( String& rFormula ) const +/*N*/ { +/*N*/ if( pCode->GetError() && !pCode->GetLen() ) +/*N*/ { +/*?*/ rFormula = ScGlobal::GetErrorString( pCode->GetError() ); return; +/*N*/ } +/*N*/ else if( cMatrixFlag == MM_REFERENCE ) +/*N*/ { +/*N*/ // Referenz auf eine andere Zelle, die eine Matrixformel enthaelt +/*N*/ pCode->Reset(); +/*N*/ ScToken* p = pCode->GetNextReferenceRPN(); +/*N*/ if( p ) +/*N*/ { +/*N*/ ScBaseCell* pCell = NULL; +/*N*/ if ( !IsInChangeTrack() ) +/*N*/ { +/*N*/ SingleRefData& rRef = p->GetSingleRef(); +/*N*/ rRef.CalcAbsIfRel( aPos ); +/*N*/ if ( rRef.Valid() ) +/*N*/ pCell = pDocument->GetCell( ScAddress( rRef.nCol, +/*N*/ rRef.nRow, rRef.nTab ) ); +/*N*/ } +/*N*/ if (pCell && pCell->GetCellType() == CELLTYPE_FORMULA) +/*N*/ { +/*N*/ ((ScFormulaCell*)pCell)->GetFormula(rFormula); +/*N*/ return; +/*N*/ } +/*N*/ else +/*N*/ { +/*?*/ ScCompiler aComp( pDocument, aPos, *pCode ); +/*?*/ aComp.CreateStringFromTokenArray( rFormula ); +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ DBG_ERROR("ScFormulaCell::GetFormula: Keine Matrix"); +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ ScCompiler aComp( pDocument, aPos, *pCode ); +/*N*/ aComp.CreateStringFromTokenArray( rFormula ); +/*N*/ } +/*N*/ +/*N*/ rFormula.Insert( '=',0 ); +/*N*/ if( cMatrixFlag ) +/*N*/ { +/*N*/ rFormula.Insert('{', 0); +/*N*/ rFormula += '}'; +/*N*/ } +/*N*/ } + +/*N*/ void ScFormulaCell::Compile( const String& rFormula, BOOL bNoListening ) +/*N*/ { +/*N*/ if ( pDocument->IsClipOrUndo() ) return; +/*N*/ BOOL bWasInFormulaTree = pDocument->IsInFormulaTree( this ); +/*N*/ if ( bWasInFormulaTree ) +/*?*/ pDocument->RemoveFromFormulaTree( this ); +/*N*/ // pCode darf fuer Abfragen noch nicht geloescht, muss aber leer sein +/*N*/ if ( pCode ) +/*N*/ pCode->Clear(); +/*N*/ ScTokenArray* pCodeOld = pCode; +/*N*/ ScCompiler aComp(pDocument, aPos); +/*N*/ if ( pDocument->IsImportingXML() ) +/*?*/ aComp.SetCompileEnglish( TRUE ); +/*N*/ pCode = aComp.CompileString( rFormula ); +/*N*/ if ( pCodeOld ) +/*N*/ delete pCodeOld; +/*N*/ if( !pCode->GetError() ) +/*N*/ { +/*N*/ if ( !pCode->GetLen() && aErgString.Len() && rFormula == aErgString ) +/*N*/ { // #65994# nicht rekursiv CompileTokenArray/Compile/CompileTokenArray +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 if ( rFormula.GetChar(0) == '=' ) +/*N*/ } +/*N*/ bCompile = TRUE; +/*N*/ CompileTokenArray( bNoListening ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ bChanged = TRUE; +/*N*/ SetTextWidth( TEXTWIDTH_DIRTY ); +/*N*/ SetScriptType( SC_SCRIPTTYPE_UNKNOWN ); +/*N*/ } +/*N*/ if ( bWasInFormulaTree ) +/*?*/ pDocument->PutInFormulaTree( this ); +/*N*/ } + + +/*N*/ void ScFormulaCell::CompileTokenArray( BOOL bNoListening ) +/*N*/ { +/*N*/ // Noch nicht compiliert? +/*N*/ if( !pCode->GetLen() && aErgString.Len() ) +/*N*/ Compile( aErgString ); +/*N*/ else if( bCompile && !pDocument->IsClipOrUndo() && !pCode->GetError() ) +/*N*/ { +/*N*/ // RPN-Laenge kann sich aendern +/*N*/ BOOL bWasInFormulaTree = pDocument->IsInFormulaTree( this ); +/*N*/ if ( bWasInFormulaTree ) +/*?*/ pDocument->RemoveFromFormulaTree( this ); +/*N*/ +/*N*/ // Laden aus Filter? Dann noch nix machen! +/*N*/ if( pDocument->IsInsertingFromOtherDoc() ) +/*N*/ bNoListening = TRUE; +/*N*/ +/*N*/ if( !bNoListening && pCode->GetCodeLen() ) +/*?*/ EndListeningTo( pDocument ); +/*N*/ ScCompiler aComp(pDocument, aPos, *pCode ); +/*N*/ bSubTotal = aComp.CompileTokenArray(); +/*N*/ if( !pCode->GetError() ) +/*N*/ { +/*N*/ nFormatType = aComp.GetNumFormatType(); +/*N*/ nFormatIndex = 0; +/*N*/ bChanged = TRUE; +/*N*/ nErgValue = 0.0; +/*N*/ aErgString.Erase(); +/*N*/ bCompile = FALSE; +/*N*/ if ( !bNoListening ) +/*N*/ StartListeningTo( pDocument ); +/*N*/ } +/*N*/ if ( bWasInFormulaTree ) +/*?*/ pDocument->PutInFormulaTree( this ); +/*N*/ } +/*N*/ } + + +/*N*/ void ScFormulaCell::CompileXML( ScProgress& rProgress ) +/*N*/ { +/*N*/ if ( cMatrixFlag == MM_REFERENCE ) +/*N*/ { // is already token code via ScDocFunc::EnterMatrix, ScDocument::InsertMatrixFormula +/*N*/ // just establish listeners +/*N*/ StartListeningTo( pDocument ); +/*N*/ return ; +/*N*/ } +/*N*/ +/*N*/ ScCompiler aComp( pDocument, aPos, *pCode ); +/*N*/ aComp.SetCompileEnglish( TRUE ); +/*N*/ aComp.SetImportXML( TRUE ); +/*N*/ String aFormula; +/*N*/ aComp.CreateStringFromTokenArray( aFormula ); +/*N*/ pDocument->DecXMLImportedFormulaCount( aFormula.Len() ); +/*N*/ rProgress.SetStateCountDownOnPercent( pDocument->GetXMLImportedFormulaCount() ); +/*N*/ // pCode darf fuer Abfragen noch nicht geloescht, muss aber leer sein +/*N*/ if ( pCode ) +/*N*/ pCode->Clear(); +/*N*/ ScTokenArray* pCodeOld = pCode; +/*N*/ pCode = aComp.CompileString( aFormula ); +/*N*/ delete pCodeOld; +/*N*/ if( !pCode->GetError() ) +/*N*/ { +/*N*/ if ( !pCode->GetLen() ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 if ( aFormula.GetChar(0) == '=' ) +/*N*/ } +/*N*/ bSubTotal = aComp.CompileTokenArray(); +/*N*/ if( !pCode->GetError() ) +/*N*/ { +/*N*/ nFormatType = aComp.GetNumFormatType(); +/*N*/ nFormatIndex = 0; +/*N*/ bChanged = TRUE; +/*N*/ bCompile = FALSE; +/*N*/ StartListeningTo( pDocument ); +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ bChanged = TRUE; +/*N*/ SetTextWidth( TEXTWIDTH_DIRTY ); +/*N*/ SetScriptType( SC_SCRIPTTYPE_UNKNOWN ); +/*N*/ } +/*N*/ +/*N*/ // Same as in Load: after loading, it must be known if ocMacro is in any formula +/*N*/ // (for macro warning, CompileXML is called at the end of loading XML file) +/*N*/ if ( !pDocument->GetHasMacroFunc() && pCode->HasOpCodeRPN( ocMacro ) ) +/*N*/ pDocument->SetHasMacroFunc( TRUE ); +/*N*/ } + + +/*N*/ void ScFormulaCell::CalcAfterLoad() +/*N*/ { +/*N*/ BOOL bNewCompiled = FALSE; +/*N*/ // Falls ein Calc 1.0-Doc eingelesen wird, haben wir ein Ergebnis, +/*N*/ // aber kein TokenArray +/*N*/ if( !pCode->GetLen() && aErgString.Len() ) +/*N*/ { +/*?*/ Compile( aErgString, TRUE ); +/*?*/ aErgString.Erase(); +/*?*/ bDirty = TRUE; +/*?*/ bNewCompiled = TRUE; +/*N*/ } +/*N*/ // Das UPN-Array wird nicht erzeugt, wenn ein Calc 3.0-Doc eingelesen +/*N*/ // wurde, da die RangeNames erst jetzt existieren. +/*N*/ if( pCode->GetLen() && !pCode->GetCodeLen() && !pCode->GetError() ) +/*N*/ { +/*N*/ ScCompiler aComp(pDocument, aPos, *pCode); +/*N*/ bSubTotal = aComp.CompileTokenArray(); +/*N*/ nFormatType = aComp.GetNumFormatType(); +/*N*/ nFormatIndex = 0; +/*N*/ bDirty = TRUE; +/*N*/ bCompile = FALSE; +/*N*/ bNewCompiled = TRUE; +/*N*/ } +/*N*/ // irgendwie koennen unter os/2 mit rotter FPU-Exception /0 ohne Err503 +/*N*/ // gespeichert werden, woraufhin spaeter im NumberFormatter die BLC Lib +/*N*/ // bei einem fabs(-NAN) abstuerzt (#32739#) +/*N*/ // hier fuer alle Systeme ausbuegeln, damit da auch Err503 steht +/*N*/ if ( bIsValue && !::rtl::math::isFinite( nErgValue ) ) +/*N*/ { +/*?*/ DBG_ERRORFILE("Formelzelle INFINITY !!! Woher kommt das Dokument?"); +/*?*/ nErgValue = 0.0; +/*?*/ pCode->SetError( errIllegalFPOperation ); +/*?*/ bDirty = TRUE; +/*N*/ } +/*N*/ // DoubleRefs bei binaeren Operatoren waren vor v5.0 immer Matrix, +/*N*/ // jetzt nur noch wenn in Matrixformel, sonst implizite Schnittmenge +/*N*/ if ( pDocument->GetSrcVersion() < SC_MATRIX_DOUBLEREF && +/*N*/ GetMatrixFlag() == MM_NONE && pCode->HasMatrixDoubleRefOps() ) +/*N*/ { +/*N*/ cMatrixFlag = MM_FORMULA; +/*N*/ nMatCols = 1; +/*N*/ nMatRows = 1; +/*N*/ } +/*N*/ // Muss die Zelle berechnet werden? +/*N*/ // Nach Load koennen Zellen einen Fehlercode enthalten, auch dann +/*N*/ // Listener starten und ggbf. neu berechnen wenn nicht RECALCMODE_NORMAL +/*N*/ if( !bNewCompiled || !pCode->GetError() ) +/*N*/ { +/*N*/ StartListeningTo( pDocument ); +/*N*/ if( !pCode->IsRecalcModeNormal() ) +/*N*/ bDirty = TRUE; +/*N*/ } +/*N*/ if ( pCode->GetError() == errInterpOverflow ) +/*N*/ { // versuchen Err527 wegzubuegeln +/*N*/ bDirty = TRUE; +/*N*/ } +/*N*/ else if ( pCode->IsRecalcModeAlways() ) +/*N*/ { // zufall(), heute(), jetzt() bleiben immer im FormulaTree, damit sie +/*N*/ // auch bei jedem F9 berechnet werden. +/*N*/ bDirty = TRUE; +/*N*/ } +/*N*/ // Noch kein SetDirty weil noch nicht alle Listener bekannt, erst in +/*N*/ // SetDirtyAfterLoad. +/*N*/ } + +/*N*/ void ScFormulaCell::Interpret() +/*N*/ { +/*N*/ static USHORT nRecCount = 0; +/*N*/ static ScFormulaCell* pLastIterInterpreted = NULL; +/*N*/ if ( !IsDirtyOrInTableOpDirty() ) +/*N*/ return; // fuer IterCircRef, nix doppelt +/*N*/ +/*N*/ //! HACK: +/*N*/ // Wenn der Aufruf aus einem Reschedule im DdeLink-Update kommt, dirty stehenlassen +/*N*/ // Besser: Dde-Link Update ohne Reschedule oder ganz asynchron !!! +/*N*/ +/*N*/ if ( pDocument->IsInDdeLinkUpdate() ) +/*N*/ return; +/*N*/ +/*N*/ if (bRunning) +/*N*/ { +/*N*/ // Keine Iterierung? +/*N*/ if (!pDocument->GetDocOptions().IsIter()) +/*N*/ pCode->SetError( errCircularReference ); +/*N*/ else +/*N*/ { +/*?*/ if (pCode->GetError() == errCircularReference) +/*?*/ pCode->SetError( 0 ); +/*?*/ nIterMode = 1; +/*?*/ bIsIterCell = TRUE; +/*?*/ pLastIterInterpreted = NULL; +/*N*/ } +/*N*/ return; +/*N*/ } +/*N*/ // #63038# fuer GetErrCode, IsValue, GetValue nicht mehrfach interpretieren +/*N*/ if ( nIterMode && pLastIterInterpreted == this ) +/*N*/ return ; +/*N*/ +/*N*/ if( !pCode->GetCodeLen() && !pCode->GetError() ) +/*N*/ { +/*N*/ // #i11719# no UPN and no error and no token code but result string present +/*N*/ // => interpretation of this cell during name-compilation and unknown names +/*N*/ // => can't exchange underlying code array in CompileTokenArray() / +/*N*/ // Compile() because interpreter's token iterator would crash. +/*N*/ // This should only be a temporary condition and, since we set an +/*N*/ // error, if ran into it again we'd bump into the dirty-clearing +/*N*/ // condition further down. +/*N*/ if ( !pCode->GetLen() && aErgString.Len() ) +/*N*/ { +/*N*/ pCode->SetError( errNoCode ); +/*N*/ // This is worth an assertion; if encountered in daily work +/*N*/ // documents we might need another solution. Or just confirm correctness. +/*N*/ DBG_ERRORFILE( "ScFormulaCell::Interpret: no UPN, no error, no token, but string" ); +/*N*/ return; +/*N*/ } +/*?*/ CompileTokenArray(); +/*N*/ } +/*N*/ +/*N*/ if( pCode->GetCodeLen() && pDocument ) +/*N*/ { +/*N*/ #if defined(MAC) && !defined(SIMPLEMAXRECURSION) +/*N*/ if( StackSpace() < 2048 ) // 2K Stack noch uebriglassen +/*N*/ #else +/*N*/ if( nRecCount > MAXRECURSION ) +/*N*/ #endif +/*N*/ { +/*?*/ pCode->SetError( errInterpOverflow ); +/*?*/ // Zelle bleibt in FormulaTree, naechstes Mal sind evtl. +/*?*/ // Vorgaenger bereits berechnet worden bzw. von der View wird +/*?*/ // via ScCellFormat::GetString CalcFormulaTree angeworfen +/*?*/ bDirty = FALSE; +/*?*/ bTableOpDirty = FALSE; +/*?*/ nErgValue = 0.0; +/*?*/ bIsValue = TRUE; +/*?*/ nIterMode = 0; +/*?*/ bIsIterCell = FALSE; +/*?*/ pLastIterInterpreted = NULL; +/*?*/ bChanged = TRUE; +/*?*/ SetTextWidth( TEXTWIDTH_DIRTY ); +/*?*/ SetScriptType( SC_SCRIPTTYPE_UNKNOWN ); +/*?*/ return; +/*N*/ } +/*N*/ nRecCount++; +/*N*/ pDocument->IncInterpretLevel(); +/*N*/ ScInterpreter* p = new ScInterpreter( this, pDocument, aPos, *pCode ); +/*N*/ USHORT nOldErrCode = pCode->GetError(); +/*N*/ USHORT nIterCount = 0; +/*N*/ if ( nIterMode == 0 ) +/*N*/ { // nur beim ersten Mal +/*N*/ // wenn neu kompilierte Zelle 0.0 ergibt wird kein Changed erkannt +/*N*/ // und die Zelle wird nicht sofort repainted! +/*N*/ // bChanged = FALSE; +/*N*/ if ( nOldErrCode == errNoConvergence +/*N*/ && pDocument->GetDocOptions().IsIter() ) +/*?*/ pCode->SetError( 0 ); +/*N*/ } +/*N*/ BOOL bRepeat = TRUE; +/*N*/ while( bRepeat ) +/*N*/ { +/*N*/ if ( pMatrix ) +/*N*/ { +/*?*/ delete pMatrix; +/*?*/ pMatrix = NULL; +/*N*/ } +/*N*/ +/*N*/ switch ( pCode->GetError() ) +/*N*/ { +/*?*/ case errCircularReference : // wird neu festgestellt +/*?*/ case errInterpOverflow : // Err527 eine Chance geben +/*?*/ pCode->SetError( 0 ); +/*?*/ break; +/*N*/ } +/*N*/ +/*N*/ bRunning = TRUE; +/*N*/ p->Interpret(); +/*N*/ bRunning = FALSE; +/*N*/ if( pCode->GetError() +/*N*/ && pCode->GetError() != errCircularReference ) +/*N*/ { +/*N*/ bDirty = FALSE; +/*N*/ bTableOpDirty = FALSE; +/*N*/ nIterMode = 0; +/*N*/ bIsIterCell = FALSE; +/*N*/ pLastIterInterpreted = NULL; +/*N*/ bChanged = TRUE; +/*N*/ bIsValue = TRUE; +/*N*/ break; +/*N*/ } +/*N*/ if( nIterMode == 1 && bIsIterCell ) +/*N*/ { +/*?*/ pLastIterInterpreted = NULL; +/*?*/ ++nIterCount; +/*?*/ // schoen konvergiert? +/*?*/ if( (p->GetResultType() == svDouble +/*?*/ && fabs( p->GetNumResult() - nErgValue ) <= +/*?*/ pDocument->GetDocOptions().GetIterEps()) +/*?*/ ) +/*?*/ { +/*?*/ nIterMode = 0; +/*?*/ bIsIterCell = FALSE; +/*?*/ bDirty = FALSE; +/*?*/ bTableOpDirty = FALSE; +/*?*/ bRepeat = FALSE; +/*?*/ } +/*?*/ // Zu oft rumgelaufen? +/*?*/ else if( nIterCount >= pDocument->GetDocOptions().GetIterCount() ) +/*?*/ { +/*?*/ nIterMode = 0; +/*?*/ bIsIterCell = FALSE; +/*?*/ bDirty = FALSE; +/*?*/ bTableOpDirty = FALSE; +/*?*/ bRepeat = FALSE; +/*?*/ pCode->SetError( errNoConvergence ); +/*?*/ } +/*?*/ if ( p->GetResultType() == svDouble ) +/*?*/ { +/*?*/ if( !bIsValue || nErgValue != p->GetNumResult() ) +/*?*/ bChanged = TRUE; +/*?*/ bIsValue = TRUE; +/*?*/ nErgValue = p->GetNumResult(); +/*?*/ } +/*N*/ } +/*N*/ else +/*N*/ bRepeat = FALSE; +/*N*/ } +/*N*/ +/*N*/ switch( p->GetResultType() ) +/*N*/ { +/*N*/ case svDouble: +/*N*/ if( nErgValue != p->GetNumResult() || !bIsValue ) +/*N*/ { +/*N*/ bChanged = TRUE; +/*N*/ bIsValue = TRUE; +/*N*/ nErgValue = p->GetNumResult(); +/*N*/ } +/*N*/ break; +/*N*/ case svString: +/*N*/ if( aErgString != p->GetStringResult() || bIsValue ) +/*N*/ { +/*N*/ bChanged = TRUE; +/*N*/ bIsValue = FALSE; +/*N*/ aErgString = p->GetStringResult(); +/*N*/ } +/*N*/ break; +/*N*/ } +/*N*/ +/*N*/ // Neuer Fehlercode? +/*N*/ if( !bChanged && pCode->GetError() != nOldErrCode ) +/*N*/ bChanged = TRUE; +/*N*/ // Anderes Zahlenformat? +/*N*/ if( nFormatType != p->GetRetFormatType() ) +/*N*/ { +/*N*/ nFormatType = p->GetRetFormatType(); +/*N*/ bChanged = TRUE; +/*N*/ } +/*N*/ if( nFormatIndex != p->GetRetFormatIndex() ) +/*N*/ { +/*N*/ nFormatIndex = p->GetRetFormatIndex(); +/*N*/ bChanged = TRUE; +/*N*/ } +/*N*/ // Genauigkeit wie angezeigt? +/*N*/ if ( bIsValue && !pCode->GetError() +/*N*/ && pDocument->GetDocOptions().IsCalcAsShown() +/*N*/ && nFormatType != NUMBERFORMAT_DATE +/*N*/ && nFormatType != NUMBERFORMAT_TIME +/*N*/ && nFormatType != NUMBERFORMAT_DATETIME ) +/*N*/ { +/*?*/ ULONG nFormat = pDocument->GetNumberFormat( aPos ); +/*?*/ if ( nFormatIndex && (nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 ) +/*?*/ nFormat = nFormatIndex; +/*?*/ if ( (nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 ) +/*?*/ nFormat = ScGlobal::GetStandardFormat( +/*?*/ *pDocument->GetFormatTable(), nFormat, nFormatType ); +/*?*/ nErgValue = pDocument->RoundValueAsShown( nErgValue, nFormat ); +/*N*/ } +/*N*/ if ( nIterMode == 0 ) +/*N*/ { +/*N*/ bDirty = FALSE; +/*N*/ bTableOpDirty = FALSE; +/*N*/ } +/*N*/ else +/*N*/ pLastIterInterpreted = this; +/*N*/ pMatrix = p->GetMatrixResult(); +/*N*/ if( pMatrix ) +/*N*/ { +/*N*/ #if 0 +/*?*/ //! MatrixFormel immer changed?!? +/*?*/ // ist bei MD's Rundumschlag von r1.167 --> r1.168 reingekommen +/*?*/ // => ewiges Repaint von MatrixFormel, besonders bei DDE laestig +/*?*/ // ab r1.260 (sv369b) probieren wir's mal ohne.. +/*?*/ if( cMatrixFlag == MM_FORMULA ) +/*?*/ bChanged = TRUE; +/*?*/ else +/*N*/ #else +/*N*/ if( cMatrixFlag != MM_FORMULA ) +/*N*/ #endif +/*N*/ { // mit linker oberer Ecke weiterleben +/*?*/ delete pMatrix; +/*?*/ pMatrix = NULL; +/*N*/ } +/*N*/ } +/*N*/ if( bChanged ) +/*N*/ { +/*N*/ SetTextWidth( TEXTWIDTH_DIRTY ); +/*N*/ SetScriptType( SC_SCRIPTTYPE_UNKNOWN ); +/*N*/ } +/*N*/ delete p; +/*N*/ nRecCount--; +/*N*/ pDocument->DecInterpretLevel(); +/*N*/ if ( pCode->GetError() != errInterpOverflow +/*N*/ && !pCode->IsRecalcModeAlways() ) +/*N*/ pDocument->RemoveFromFormulaTree( this ); +/*N*/ #ifdef DBG_UTIL +/*N*/ if ( bIsValue && !pCode->GetError() && !::rtl::math::isFinite( nErgValue ) ) +/*N*/ { +/*N*/ DBG_ERRORFILE( msgDbgInfinity ); +/*N*/ nErgValue = 0.0; +/*N*/ pCode->SetError( errIllegalFPOperation ); +/*N*/ } +/*N*/ #endif +/*N*/ +/*N*/ // FORCED Zellen auch sofort auf Gueltigkeit testen (evtl. Makro starten) +/*N*/ +/*N*/ if ( pCode->IsRecalcModeForced() ) +/*N*/ { +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 /*?*/ ULONG nValidation = ((const SfxUInt32Item*) pDocument->GetAttr( +/*N*/ } +/*N*/ +/*N*/ // Reschedule verlangsamt das ganze erheblich, nur bei Prozentaenderung ausfuehren +/*N*/ ScProgress::GetInterpretProgress()->SetStateCountDownOnPercent( +/*N*/ pDocument->GetFormulaCodeInTree() ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ // Zelle bei Compiler-Fehlern nicht ewig auf dirty stehenlassen +/*N*/ DBG_ASSERT( pCode->GetError(), "kein UPN-Code und kein Fehler ?!?!" ); +/*N*/ bDirty = FALSE; +/*N*/ bTableOpDirty = FALSE; +/*N*/ } +/*N*/ } + +/*N*/ ULONG ScFormulaCell::GetStandardFormat( SvNumberFormatter& rFormatter, ULONG nFormat ) const +/*N*/ { +/*N*/ if ( nFormatIndex && (nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 ) +/*N*/ return nFormatIndex; +/*N*/ if ( bIsValue ) //! nicht IsValue() +/*N*/ return ScGlobal::GetStandardFormat( nErgValue, rFormatter, nFormat, nFormatType ); +/*N*/ else +/*N*/ return ScGlobal::GetStandardFormat( rFormatter, nFormat, nFormatType ); +/*N*/ } + + +/*N*/ void __EXPORT ScFormulaCell::SFX_NOTIFY( SfxBroadcaster& rBC, +/*N*/ const TypeId& rBCType, const SfxHint& rHint, const TypeId& rHintType ) +/*N*/ { +/*N*/ if ( !pDocument->IsInDtorClear() && !pDocument->GetHardRecalcState() ) +/*N*/ { +/*N*/ const ScHint* p = PTR_CAST( ScHint, &rHint ); +/*N*/ if( p && (p->GetId() & (SC_HINT_DATACHANGED | SC_HINT_DYING | +/*N*/ SC_HINT_TABLEOPDIRTY)) ) +/*N*/ { +/*N*/ BOOL bForceTrack = FALSE; +/*N*/ if ( p->GetId() & SC_HINT_TABLEOPDIRTY ) +/*N*/ { +/*?*/ bForceTrack = !bTableOpDirty; +/*?*/ if ( !bTableOpDirty ) +/*?*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 pDocument->AddTableOpFormulaCell( this ); +/*?*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ bForceTrack = !bDirty; +/*N*/ bDirty = TRUE; +/*N*/ } +/*N*/ // #35962# Don't remove from FormulaTree to put in FormulaTrack to +/*N*/ // put in FormulaTree again and again, only if necessary. +/*N*/ // Any other means except RECALCMODE_ALWAYS by which a cell could +/*N*/ // be in FormulaTree if it would notify other cells through +/*N*/ // FormulaTrack which weren't in FormulaTrack/FormulaTree before?!? +/*N*/ // #87866# Yes. The new TableOpDirty made it necessary to have a +/*N*/ // forced mode where formulas may still be in FormulaTree from +/*N*/ // TableOpDirty but have to notify dependents for normal dirty. +/*N*/ if ( (bForceTrack || !pDocument->IsInFormulaTree( this ) +/*N*/ || pCode->IsRecalcModeAlways()) +/*N*/ && !pDocument->IsInFormulaTrack( this ) ) +/*N*/ pDocument->AppendToFormulaTrack( this ); +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ void ScFormulaCell::SetDirty() +/*N*/ { +/*N*/ if ( !IsInChangeTrack() ) +/*N*/ { +/*N*/ if ( pDocument->GetHardRecalcState() ) +/*N*/ bDirty = TRUE; +/*N*/ else +/*N*/ { +/*N*/ // Mehrfach-FormulaTracking in Load und in CompileAll +/*N*/ // nach CopyScenario und CopyBlockFromClip vermeiden. +/*N*/ // Wenn unbedingtes FormulaTracking noetig, vor SetDirty bDirty=FALSE +/*N*/ // setzen, z.B. in CompileTokenArray +/*N*/ if ( !bDirty || !pDocument->IsInFormulaTree( this ) ) +/*N*/ { +/*N*/ bDirty = TRUE; +/*N*/ pDocument->AppendToFormulaTrack( this ); +/*N*/ pDocument->TrackFormulas(); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ void ScFormulaCell::SetTableOpDirty() +/*N*/ { +/*N*/ if ( !IsInChangeTrack() ) +/*N*/ { +/*N*/ if ( pDocument->GetHardRecalcState() ) +/*N*/ bTableOpDirty = TRUE; +/*N*/ else +/*N*/ { +/*N*/ if ( !bTableOpDirty || !pDocument->IsInFormulaTree( this ) ) +/*N*/ { +/*N*/ if ( !bTableOpDirty ) +/*N*/ { +/*N*/ pDocument->AddTableOpFormulaCell( this ); +/*N*/ bTableOpDirty = TRUE; +/*N*/ } +/*N*/ pDocument->AppendToFormulaTrack( this ); +/*N*/ pDocument->TrackFormulas( SC_HINT_TABLEOPDIRTY ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } + + +/*N*/ BOOL ScFormulaCell::IsDirtyOrInTableOpDirty() +/*N*/ { +/*N*/ return bDirty || (bTableOpDirty && pDocument->IsInInterpreterTableOp()); +/*N*/ } + + +/*N*/ void ScFormulaCell::SetErrCode( USHORT n ) +/*N*/ { +/*N*/ pCode->SetError( n ); +/*N*/ bIsValue = FALSE; +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ ScDetectiveRefIter::ScDetectiveRefIter( ScFormulaCell* pCell ) +/*N*/ { +/*N*/ pCode = pCell->GetCode(); +/*N*/ pCode->Reset(); +/*N*/ aPos = pCell->aPos; +/*N*/ } + +/*N*/ BOOL lcl_ScDetectiveRefIter_SkipRef( ScToken* p ) +/*N*/ { +/*N*/ SingleRefData& rRef1 = p->GetSingleRef(); +/*N*/ if ( rRef1.IsColDeleted() || rRef1.IsRowDeleted() || rRef1.IsTabDeleted() +/*N*/ || !rRef1.Valid() ) +/*N*/ return TRUE; +/*N*/ if ( p->GetType() == svDoubleRef ) +/*N*/ { +/*N*/ SingleRefData& rRef2 = p->GetDoubleRef().Ref2; +/*N*/ if ( rRef2.IsColDeleted() || rRef2.IsRowDeleted() || rRef2.IsTabDeleted() +/*N*/ || !rRef2.Valid() ) +/*N*/ return TRUE; +/*N*/ } +/*N*/ return FALSE; +/*N*/ } + +/*N*/ BOOL ScDetectiveRefIter::GetNextRef( ScTripel& rStart, ScTripel& rEnd ) +/*N*/ { +/*N*/ BOOL bRet = FALSE; +/*N*/ +/*N*/ ScToken* p = pCode->GetNextReferenceRPN(); +/*N*/ if (p) +/*N*/ p->CalcAbsIfRel( aPos ); +/*N*/ +/*N*/ while ( p && lcl_ScDetectiveRefIter_SkipRef( p ) ) +/*N*/ { +/*N*/ p = pCode->GetNextReferenceRPN(); +/*N*/ if (p) +/*N*/ p->CalcAbsIfRel( aPos ); +/*N*/ } +/*N*/ +/*N*/ if( p ) +/*N*/ { +/*N*/ SingleDoubleRefProvider aProv( *p ); +/*N*/ rStart.Put( aProv.Ref1.nCol, +/*N*/ aProv.Ref1.nRow, +/*N*/ aProv.Ref1.nTab ); +/*N*/ rEnd.Put( aProv.Ref2.nCol, +/*N*/ aProv.Ref2.nRow, +/*N*/ aProv.Ref2.nTab ); +/*N*/ bRet = TRUE; +/*N*/ } +/*N*/ +/*N*/ return bRet; +/*N*/ } + +//----------------------------------------------------------------------------------- + +/*N*/ ScFormulaCell::~ScFormulaCell() +/*N*/ { +/*N*/ pDocument->RemoveFromFormulaTree( this ); +/*N*/ delete pCode; +/*N*/ delete pMatrix; +/*N*/ pMatrix = NULL; +/*N*/ #ifdef DBG_UTIL +/*N*/ eCellType = CELLTYPE_DESTROYED; +/*N*/ #endif +/*N*/ } + + +/*N*/ #ifdef DBG_UTIL +/*N*/ +/*N*/ ScStringCell::~ScStringCell() +/*N*/ { +/*N*/ eCellType = CELLTYPE_DESTROYED; +/*N*/ } +/*N*/ #endif + //! ValueCell auch nur bei DBG_UTIL, + //! auch in cell.hxx aendern !!!!!!!!!!!!!!!!!!!! + +/*N*/ ScValueCell::~ScValueCell() +/*N*/ { +/*N*/ eCellType = CELLTYPE_DESTROYED; +/*N*/ } + +/*N*/ #ifdef DBG_UTIL +/*N*/ +/*N*/ ScNoteCell::~ScNoteCell() +/*N*/ { +/*N*/ eCellType = CELLTYPE_DESTROYED; +/*N*/ } +/*N*/ #endif + + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_cell2.cxx b/binfilter/bf_sc/source/core/data/sc_cell2.cxx new file mode 100644 index 000000000000..7cc527200eaf --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_cell2.cxx @@ -0,0 +1,894 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include <vcl/mapmod.hxx> +#include <bf_svx/editobj.hxx> + +#include "cell.hxx" +#include "rangenam.hxx" +#include "rechead.hxx" +#include "refupdat.hxx" +#include "editutil.hxx" +#include "chgtrack.hxx" +#include "indexmap.hxx" +namespace binfilter { + + +// STATIC DATA ----------------------------------------------------------- + +#ifdef _MSC_VER +#pragma code_seg("SCSTATICS") +#endif + +#ifdef USE_MEMPOOL +const USHORT nMemPoolEditCell = (0x1000 - 64) / sizeof(ScNoteCell); +/*N*/ IMPL_FIXEDMEMPOOL_NEWDEL( ScEditCell, nMemPoolEditCell, nMemPoolEditCell ) +#endif + +#ifdef _MSC_VER +#pragma code_seg() +#endif + +// ----------------------------------------------------------------------- + +/*N*/ ScEditCell::ScEditCell( const EditTextObject* pObject, ScDocument* pDocP, +/*N*/ const SfxItemPool* pFromPool ) : +/*N*/ ScBaseCell( CELLTYPE_EDIT ), +/*N*/ pString( NULL ), +/*N*/ pDoc( pDocP ) +/*N*/ { +/*N*/ SetTextObject( pObject, pFromPool ); +/*N*/ } + +/*N*/ ScEditCell::ScEditCell( const ScEditCell& rEditCell, ScDocument* pDocP ) : +/*N*/ ScBaseCell( CELLTYPE_EDIT ), +/*N*/ pString( NULL ), +/*N*/ pDoc( pDocP ) +/*N*/ { +/*N*/ SetTextObject( rEditCell.pData, rEditCell.pDoc->GetEditPool() ); +/*N*/ } + +/*N*/ ScEditCell::ScEditCell( SvStream& rStream, USHORT nVer, ScDocument* pDocP ) : +/*N*/ ScBaseCell( CELLTYPE_EDIT ), +/*N*/ pString( NULL ), +/*N*/ pDoc( pDocP ) +/*N*/ { +/*N*/ if( nVer >= SC_DATABYTES2 ) +/*N*/ { +/*N*/ BYTE cData; +/*N*/ rStream >> cData; +/*N*/ if( cData & 0x0F ) +/*?*/ rStream.SeekRel( cData & 0x0F ); +/*N*/ } +/*N*/ if ( nVer < SC_VERSION_EDITPOOL ) +/*N*/ { // jedes hat seinen eigenen Pool, dem neuen zuordnen +/*?*/ EditTextObject* pTmp = EditTextObject::Create( rStream ); +/*?*/ SetTextObject( pTmp, NULL ); +/*?*/ delete pTmp; +/*N*/ } +/*N*/ else +/*N*/ pData = EditTextObject::Create( rStream, pDoc->GetEditPool() ); +/*N*/ } + +/*N*/ ScEditCell::ScEditCell( const String& rString, ScDocument* pDocP ) : +/*N*/ ScBaseCell( CELLTYPE_EDIT ), +/*N*/ pString( NULL ), +/*N*/ pDoc( pDocP ) +/*N*/ { +/*N*/ DBG_ASSERT( rString.Search('\n') != STRING_NOTFOUND || +/*N*/ rString.Search(CHAR_CR) != STRING_NOTFOUND, +/*N*/ "EditCell mit einfachem Text !?!?" ); +/*N*/ +/*N*/ EditEngine& rEngine = pDoc->GetEditEngine(); +/*N*/ rEngine.SetText( rString ); +/*N*/ pData = rEngine.CreateTextObject(); +/*N*/ } + +/*N*/ ScEditCell::~ScEditCell() +/*N*/ { +/*N*/ delete pData; +/*N*/ delete pString; +/*N*/ +/*N*/ #ifdef DBG_UTIL +/*N*/ eCellType = CELLTYPE_DESTROYED; +/*N*/ #endif +/*N*/ } + + + +/*N*/ void ScEditCell::GetData( const EditTextObject*& rpObject ) const +/*N*/ { +/*N*/ rpObject = pData; +/*N*/ } + +/*N*/ void ScEditCell::GetString( String& rString ) const +/*N*/ { +/*N*/ if ( pString ) +/*N*/ rString = *pString; +/*N*/ else if ( pData ) +/*N*/ { +/*N*/ // auch Text von URL-Feldern, Doc-Engine ist eine ScFieldEditEngine +/*N*/ EditEngine& rEngine = pDoc->GetEditEngine(); +/*N*/ rEngine.SetText( *pData ); +/*N*/ rString = ScEditUtil::GetSpaceDelimitedString(rEngine); // space between paragraphs +/*N*/ // kurze Strings fuer Formeln merken +/*N*/ if ( rString.Len() < MAXSTRLEN ) +/*N*/ ((ScEditCell*)this)->pString = new String( rString ); //! non-const +/*N*/ } +/*N*/ else +/*N*/ rString.Erase(); +/*N*/ } + +/*N*/ void ScEditCell::Save( SvStream& rStream ) const +/*N*/ { +/*N*/ DBG_ASSERT(pData,"StoreTextObject(NULL)"); +/*N*/ rStream << (BYTE) 0x00; +/*N*/ if ( rStream.GetVersion() < SOFFICE_FILEFORMAT_50 ) +/*N*/ { // jedem seinen eigenen Pool +/*?*/ ScEditEngineDefaulter aEngine( EditEngine::CreatePool(), TRUE ); +/*?*/ // #52396# richtige Metric schreiben +/*?*/ aEngine.SetRefMapMode( MAP_100TH_MM ); +/*?*/ aEngine.SetText( *pData ); +/*?*/ EditTextObject* pTmp = aEngine.CreateTextObject(); +/*?*/ pTmp->Store( rStream ); +/*?*/ delete pTmp; +/*N*/ } +/*N*/ else +/*N*/ pData->Store( rStream ); +/*N*/ } + +/*N*/ void ScEditCell::SetTextObject( const EditTextObject* pObject, +/*N*/ const SfxItemPool* pFromPool ) +/*N*/ { +/*N*/ if ( pObject ) +/*N*/ { +/*N*/ if ( pFromPool && pDoc->GetEditPool() == pFromPool ) +/*N*/ pData = pObject->Clone(); +/*N*/ else +/*N*/ { //! anderer Pool +/*?*/ // Leider gibt es keinen anderen Weg, um den Pool umzuhaengen, +/*N*/ // als das Object durch eine entsprechende Engine zu schleusen.. // cellformats.sdc +/*N*/ /*?*/ EditEngine& rEngine = pDoc->GetEditEngine(); +/*N*/ /*?*/ rEngine.SetText( *pObject ); +/*N*/ /*?*/ pData = rEngine.CreateTextObject(); +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ pData = NULL; +/*N*/ } + +//--------------------------------------------------------------------- + +/*N*/ void ScFormulaCell::GetEnglishFormula( String& rFormula, BOOL bCompileXML ) const +/*N*/ { +/*N*/ //! mit GetFormula zusammenfassen !!! +/*N*/ +/*N*/ if( pCode->GetError() && !pCode->GetLen() ) +/*N*/ { +/*N*/ rFormula = ScGlobal::GetErrorString( pCode->GetError() ); return; +/*N*/ } +/*N*/ else if( cMatrixFlag == MM_REFERENCE ) +/*N*/ { +/*N*/ // Referenz auf eine andere Zelle, die eine Matrixformel enthaelt +/*N*/ pCode->Reset(); +/*N*/ ScToken* p = pCode->GetNextReferenceRPN(); +/*N*/ if( p ) +/*N*/ { +/*N*/ ScBaseCell* pCell; +/*N*/ SingleRefData& rRef = p->GetSingleRef(); +/*N*/ rRef.CalcAbsIfRel( aPos ); +/*N*/ if ( rRef.Valid() ) +/*N*/ pCell = pDocument->GetCell( ScAddress( rRef.nCol, +/*N*/ rRef.nRow, rRef.nTab ) ); +/*N*/ else +/*N*/ pCell = NULL; +/*N*/ if (pCell && pCell->GetCellType() == CELLTYPE_FORMULA) +/*N*/ { +/*N*/ ((ScFormulaCell*)pCell)->GetEnglishFormula(rFormula, bCompileXML); +/*N*/ return; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ ScCompiler aComp( pDocument, aPos, *pCode ); +/*N*/ aComp.SetCompileEnglish( TRUE ); +/*N*/ aComp.SetCompileXML( bCompileXML ); +/*N*/ aComp.CreateStringFromTokenArray( rFormula ); +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ DBG_ERROR("ScFormulaCell::GetEnglishFormula: Keine Matrix"); +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ ScCompiler aComp( pDocument, aPos, *pCode ); +/*N*/ aComp.SetCompileEnglish( TRUE ); +/*N*/ aComp.SetCompileXML( bCompileXML ); +/*N*/ aComp.CreateStringFromTokenArray( rFormula ); +/*N*/ } +/*N*/ +/*N*/ rFormula.Insert( '=',0 ); +/*N*/ if( cMatrixFlag ) +/*N*/ { +/*N*/ rFormula.Insert('{', 0); +/*N*/ rFormula += '}'; +/*N*/ } +/*N*/ } + +/*N*/ void ScFormulaCell::GetEnglishFormula( ::rtl::OUStringBuffer& rBuffer, BOOL bCompileXML ) const +/*N*/ { +/*N*/ //! mit GetFormula zusammenfassen !!! +/*N*/ +/*N*/ if( pCode->GetError() && !pCode->GetLen() ) +/*N*/ { +/*?*/ rBuffer = ::rtl::OUStringBuffer(ScGlobal::GetErrorString( pCode->GetError() )); return; +/*N*/ } +/*N*/ else if( cMatrixFlag == MM_REFERENCE ) +/*N*/ { +/*?*/ // Referenz auf eine andere Zelle, die eine Matrixformel enthaelt +/*?*/ pCode->Reset(); +/*?*/ ScToken* p = pCode->GetNextReferenceRPN(); +/*?*/ if( p ) +/*?*/ { +/*?*/ ScBaseCell* pCell; +/*?*/ SingleRefData& rRef = p->GetSingleRef(); +/*?*/ rRef.CalcAbsIfRel( aPos ); +/*?*/ if ( rRef.Valid() ) +/*?*/ pCell = pDocument->GetCell( ScAddress( rRef.nCol, +/*?*/ rRef.nRow, rRef.nTab ) ); +/*?*/ else +/*?*/ pCell = NULL; +/*?*/ if (pCell && pCell->GetCellType() == CELLTYPE_FORMULA) +/*?*/ { +/*?*/ ((ScFormulaCell*)pCell)->GetEnglishFormula(rBuffer, bCompileXML); +/*?*/ return; +/*?*/ } +/*?*/ else +/*?*/ { +/*?*/ ScCompiler aComp( pDocument, aPos, *pCode ); +/*?*/ aComp.SetCompileEnglish( TRUE ); +/*?*/ aComp.SetCompileXML( bCompileXML ); +/*?*/ aComp.CreateStringFromTokenArray( rBuffer ); +/*?*/ } +/*?*/ } +/*?*/ else +/*?*/ { +/*?*/ DBG_ERROR("ScFormulaCell::GetEnglishFormula: Keine Matrix"); +/*?*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ ScCompiler aComp( pDocument, aPos, *pCode ); +/*N*/ aComp.SetCompileEnglish( TRUE ); +/*N*/ aComp.SetCompileXML( bCompileXML ); +/*N*/ aComp.CreateStringFromTokenArray( rBuffer ); +/*N*/ } +/*N*/ +/*N*/ sal_Unicode ch('='); +/*N*/ rBuffer.insert( 0, &ch, 1 ); +/*N*/ if( cMatrixFlag ) +/*N*/ { +/*N*/ sal_Unicode ch2('{'); +/*N*/ rBuffer.insert(0, &ch2, 1); +/*N*/ rBuffer.append(sal_Unicode('}')); +/*N*/ } +/*N*/ } + +/*N*/ BOOL ScFormulaCell::IsValue() +/*N*/ { +/*N*/ if (IsDirtyOrInTableOpDirty() && pDocument->GetAutoCalc()) +/*N*/ Interpret(); +/*N*/ return bIsValue; +/*N*/ } + +/*N*/ double ScFormulaCell::GetValue() +/*N*/ { +/*N*/ if (IsDirtyOrInTableOpDirty() && pDocument->GetAutoCalc()) +/*?*/ Interpret(); +/*N*/ if ( !pCode->GetError() || pCode->GetError() == errDoubleRef) +/*N*/ return nErgValue; +/*N*/ return 0.0; +/*N*/ } + +/*N*/ double ScFormulaCell::GetValueAlways() +/*N*/ { +/*N*/ // for goal seek: return result value even if error code is set +/*N*/ +/*N*/ if (IsDirtyOrInTableOpDirty() && pDocument->GetAutoCalc()) +/*N*/ Interpret(); +/*N*/ return nErgValue; +/*N*/ } + +/*N*/ void ScFormulaCell::GetString( String& rString ) +/*N*/ { +/*N*/ if (IsDirtyOrInTableOpDirty() && pDocument->GetAutoCalc()) +/*?*/ Interpret(); +/*N*/ if ( !pCode->GetError() || pCode->GetError() == errDoubleRef) +/*N*/ rString = aErgString; +/*N*/ else +/*?*/ rString.Erase(); +/*N*/ } + +/*N*/ void ScFormulaCell::GetMatrix(ScMatrix** ppMat) +/*N*/ { +/*N*/ if ( pDocument->GetAutoCalc() ) +/*N*/ { +/*N*/ // war !bDirty gespeichert aber zugehoerige Matrixzelle bDirty? +/*N*/ // => wir brauchen pMatrix +/*N*/ if ( !pMatrix && cMatrixFlag == MM_FORMULA ) +/*N*/ bDirty = TRUE; +/*N*/ if ( IsDirtyOrInTableOpDirty() ) +/*N*/ Interpret(); +/*N*/ } +/*N*/ if (!pCode->GetError()) +/*N*/ *ppMat = pMatrix; +/*N*/ else +/*N*/ *ppMat = NULL; +/*N*/ } + +/*N*/ BOOL ScFormulaCell::GetMatrixOrigin( ScAddress& rPos ) const +/*N*/ { +/*N*/ switch ( cMatrixFlag ) +/*N*/ { +/*N*/ case MM_FORMULA : +/*N*/ rPos = aPos; +/*N*/ return TRUE; +/*N*/ break; +/*N*/ case MM_REFERENCE : +/*N*/ { +/*N*/ pCode->Reset(); +/*N*/ ScToken* t = pCode->GetNextReferenceRPN(); +/*N*/ if( t ) +/*N*/ { +/*N*/ SingleRefData& rRef = t->GetSingleRef(); +/*N*/ rRef.CalcAbsIfRel( aPos ); +/*N*/ if ( rRef.Valid() ) +/*N*/ { +/*N*/ rPos.Set( rRef.nCol, rRef.nRow, rRef.nTab ); +/*N*/ return TRUE; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ break; +/*N*/ } +/*N*/ return FALSE; +/*N*/ } + + +/* + Edge-Values: + + 8 + 4 16 + 2 + + innerhalb: 1 + ausserhalb: 0 + (reserviert: offen: 32) + */ + +/*N*/ USHORT ScFormulaCell::GetMatrixEdge( ScAddress& rOrgPos ) +/*N*/ { +/*N*/ switch ( cMatrixFlag ) +/*N*/ { +/*N*/ case MM_FORMULA : +/*N*/ case MM_REFERENCE : +/*N*/ { +/*N*/ static USHORT nC, nR; +/*N*/ ScAddress aOrg; +/*N*/ if ( !GetMatrixOrigin( aOrg ) ) +/*N*/ return 0; // dumm gelaufen.. +/*N*/ if ( aOrg != rOrgPos ) +/*N*/ { // erstes Mal oder andere Matrix als letztes Mal +/*N*/ rOrgPos = aOrg; +/*N*/ ScFormulaCell* pFCell; +/*N*/ if ( cMatrixFlag == MM_REFERENCE ) +/*N*/ pFCell = (ScFormulaCell*) pDocument->GetCell( aOrg ); +/*N*/ else +/*N*/ pFCell = this; // this MM_FORMULA +/*N*/ // this gibt's nur einmal, kein Vergleich auf pFCell==this +/*N*/ if ( pFCell && pFCell->GetCellType() == CELLTYPE_FORMULA +/*N*/ && pFCell->cMatrixFlag == MM_FORMULA ) +/*N*/ { +/*N*/ pFCell->GetMatColsRows( nC, nR ); +/*N*/ if ( nC == 0 || nR == 0 ) +/*N*/ { // aus altem Dokument geladen, neu erzeugen +/*?*/ nC = nR = 1; +/*?*/ ScAddress aTmpOrg; +/*?*/ ScBaseCell* pCell; +/*?*/ ScAddress aAdr( aOrg ); +/*?*/ aAdr.IncCol(); +/*?*/ BOOL bCont = TRUE; +/*?*/ do +/*?*/ { +/*?*/ pCell = pDocument->GetCell( aAdr ); +/*?*/ if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA +/*?*/ && ((ScFormulaCell*)pCell)->cMatrixFlag == MM_REFERENCE +/*?*/ && GetMatrixOrigin( aTmpOrg ) && aTmpOrg == aOrg ) +/*?*/ { +/*?*/ nC++; +/*?*/ aAdr.IncCol(); +/*?*/ } +/*?*/ else +/*?*/ bCont = FALSE; +/*?*/ } while ( bCont ); +/*?*/ aAdr = aOrg; +/*?*/ aAdr.IncRow(); +/*?*/ bCont = TRUE; +/*?*/ do +/*?*/ { +/*?*/ pCell = pDocument->GetCell( aAdr ); +/*?*/ if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA +/*?*/ && ((ScFormulaCell*)pCell)->cMatrixFlag == MM_REFERENCE +/*?*/ && GetMatrixOrigin( aTmpOrg ) && aTmpOrg == aOrg ) +/*?*/ { +/*?*/ nR++; +/*?*/ aAdr.IncRow(); +/*?*/ } +/*?*/ else +/*?*/ bCont = FALSE; +/*?*/ } while ( bCont ); +/*?*/ pFCell->SetMatColsRows( nC, nR ); +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ #ifdef DBG_UTIL +/*N*/ String aTmp; +/*N*/ ByteString aMsg( "broken Matrix, no MatFormula at origin, Pos: " ); +/*N*/ aPos.Format( aTmp, SCA_VALID_COL | SCA_VALID_ROW, pDocument ); +/*N*/ aMsg += ByteString( aTmp, RTL_TEXTENCODING_ASCII_US ); +/*N*/ aMsg += ", MatOrg: "; +/*N*/ aOrg.Format( aTmp, SCA_VALID_COL | SCA_VALID_ROW, pDocument ); +/*N*/ aMsg += ByteString( aTmp, RTL_TEXTENCODING_ASCII_US ); +/*N*/ DBG_ERRORFILE( aMsg.GetBuffer() ); +/*N*/ #endif +/*N*/ return 0; // bad luck ... +/*N*/ } +/*N*/ } +/*N*/ // here we are, healthy and clean, somewhere in between +/*N*/ short dC = aPos.Col() - aOrg.Col(); +/*N*/ short dR = aPos.Row() - aOrg.Row(); +/*N*/ USHORT nEdges = 0; +/*N*/ if ( dC >= 0 && dR >= 0 && dC < nC && dR < nR ) +/*N*/ { +/*N*/ if ( dC == 0 ) +/*N*/ nEdges |= 4; // linke Kante +/*N*/ if ( dC+1 == nC ) +/*N*/ nEdges |= 16; // rechte Kante +/*N*/ if ( dR == 0 ) +/*N*/ nEdges |= 8; // obere Kante +/*N*/ if ( dR+1 == nR ) +/*N*/ nEdges |= 2; // untere Kante +/*N*/ if ( !nEdges ) +/*N*/ nEdges = 1; // mittendrin +/*N*/ } +/*N*/ #ifdef DBG_UTIL +/*N*/ else +/*N*/ { +/*?*/ String aTmp; +/*?*/ ByteString aMsg( "broken Matrix, Pos: " ); +/*?*/ aPos.Format( aTmp, SCA_VALID_COL | SCA_VALID_ROW, pDocument ); +/*?*/ aMsg += ByteString( aTmp, RTL_TEXTENCODING_ASCII_US ); +/*?*/ aMsg += ", MatOrg: "; +/*?*/ aOrg.Format( aTmp, SCA_VALID_COL | SCA_VALID_ROW, pDocument ); +/*?*/ aMsg += ByteString( aTmp, RTL_TEXTENCODING_ASCII_US ); +/*?*/ aMsg += ", MatCols: "; +/*?*/ aMsg += ByteString::CreateFromInt32( nC ); +/*?*/ aMsg += ", MatRows: "; +/*?*/ aMsg += ByteString::CreateFromInt32( nR ); +/*?*/ aMsg += ", DiffCols: "; +/*?*/ aMsg += ByteString::CreateFromInt32( dC ); +/*?*/ aMsg += ", DiffRows: "; +/*?*/ aMsg += ByteString::CreateFromInt32( dR ); +/*?*/ DBG_ERRORFILE( aMsg.GetBuffer() ); +/*N*/ } +/*N*/ #endif +/*N*/ return nEdges; +/*N*/ break; +/*N*/ } +/*N*/ default: +/*N*/ return 0; +/*N*/ } +/*N*/ } + +/*N*/ USHORT ScFormulaCell::GetErrCode() +/*N*/ { +/*N*/ if (IsDirtyOrInTableOpDirty() && pDocument->GetAutoCalc()) +/*N*/ Interpret(); +/*N*/ return pCode->GetError(); +/*N*/ } + +/*N*/ BOOL ScFormulaCell::HasRelNameReference() const +/*N*/ { +/*N*/ pCode->Reset(); +/*N*/ for( ScToken* t = pCode->GetNextReferenceRPN(); t; +/*N*/ t = pCode->GetNextReferenceRPN() ) +/*N*/ { +/*N*/ if ( t->GetSingleRef().IsRelName() || +/*N*/ (t->GetType() == svDoubleRef && +/*N*/ t->GetDoubleRef().Ref2.IsRelName()) ) +/*N*/ return TRUE; +/*N*/ } +/*N*/ return FALSE; +/*N*/ } + +/*N*/ void ScFormulaCell::UpdateReference(UpdateRefMode eUpdateRefMode, +/*N*/ const ScRange& r, +/*N*/ short nDx, short nDy, short nDz, +/*N*/ ScDocument* pUndoDoc ) +/*N*/ {DBG_BF_ASSERT(0, "STRIP");//STRIP001 +/*N*/ } + +/*N*/ void ScFormulaCell::UpdateInsertTab(USHORT nTable) +/*N*/ { +/*N*/ BOOL bPosChanged = ( aPos.Tab() >= nTable ? TRUE : FALSE ); +/*N*/ pCode->Reset(); +/*N*/ if( pCode->GetNextReferenceRPN() && !pDocument->IsClipOrUndo() ) +/*N*/ { +/*N*/ EndListeningTo( pDocument ); +/*N*/ // IncTab _nach_ EndListeningTo und _vor_ Compiler UpdateInsertTab ! +/*N*/ if ( bPosChanged ) +/*?*/ aPos.IncTab(); +/*N*/ ScRangeData* pRangeData; +/*N*/ ScCompiler aComp(pDocument, aPos, *pCode); +/*N*/ pRangeData = aComp.UpdateInsertTab( nTable, FALSE ); +/*N*/ if (pRangeData) // Shared Formula gegen echte Formel +/*N*/ { // austauschen +/*?*/ BOOL bChanged; +/*?*/ pDocument->RemoveFromFormulaTree( this ); // update formula count +/*?*/ delete pCode; +/*?*/ pCode = new ScTokenArray( *pRangeData->GetCode() ); +/*M*/ pCode->SetReplacedSharedFormula( TRUE ); +/*?*/ ScCompiler aComp2(pDocument, aPos, *pCode); +/*?*/ aComp2.MoveRelWrap(); +/*?*/ aComp2.UpdateInsertTab( nTable, FALSE ); +/*?*/ // If the shared formula contained a named range/formula containing +/*?*/ // an absolute reference to a sheet, those have to be readjusted. +/*?*/ aComp2.UpdateDeleteTab( nTable, FALSE, TRUE, bChanged ); +/*?*/ bCompile = TRUE; +/*N*/ } +/*N*/ // kein StartListeningTo weil pTab[nTab] noch nicht existiert! +/*N*/ } +/*N*/ else if ( bPosChanged ) +/*?*/ aPos.IncTab(); +/*N*/ } + +/*N*/ BOOL ScFormulaCell::UpdateDeleteTab(USHORT nTable, BOOL bIsMove) +/*N*/ { +/*N*/ BOOL bChanged = FALSE; +/*N*/ BOOL bPosChanged = ( aPos.Tab() > nTable ? TRUE : FALSE ); +/*N*/ pCode->Reset(); +/*N*/ if( pCode->GetNextReferenceRPN() && !pDocument->IsClipOrUndo() ) +/*N*/ { +/*N*/ EndListeningTo( pDocument ); +/*N*/ // IncTab _nach_ EndListeningTo und _vor_ Compiler UpdateDeleteTab ! +/*N*/ if ( bPosChanged ) +/*N*/ aPos.IncTab(-1); +/*N*/ ScRangeData* pRangeData; +/*N*/ ScCompiler aComp(pDocument, aPos, *pCode); +/*N*/ pRangeData = aComp.UpdateDeleteTab(nTable, bIsMove, FALSE, bChanged); +/*N*/ if (pRangeData) // Shared Formula gegen echte Formel +/*N*/ { // austauschen +/*N*/ pDocument->RemoveFromFormulaTree( this ); // update formula count +/*N*/ delete pCode; +/*N*/ pCode = pRangeData->GetCode()->Clone(); +/*N*/ pCode->SetReplacedSharedFormula( TRUE ); +/*N*/ ScCompiler aComp2(pDocument, aPos, *pCode); +/*N*/ aComp2.CompileTokenArray(); +/*N*/ aComp2.MoveRelWrap(); +/*N*/ aComp2.UpdateDeleteTab( nTable, FALSE, FALSE, bChanged ); +/*N*/ // If the shared formula contained a named range/formula containing +/*N*/ // an absolute reference to a sheet, those have to be readjusted. +/*N*/ aComp2.UpdateInsertTab( nTable,TRUE ); +/*N*/ // bChanged kann beim letzten UpdateDeleteTab zurueckgesetzt worden sein +/*N*/ bChanged = TRUE; +/*N*/ bCompile = TRUE; +/*N*/ } +/*N*/ // kein StartListeningTo weil pTab[nTab] noch nicht korrekt! +/*N*/ } +/*N*/ else if ( bPosChanged ) +/*N*/ aPos.IncTab(-1); +/*N*/ +/*N*/ return bChanged; +/*N*/ } + +/*N*/ BOOL ScFormulaCell::TestTabRefAbs(USHORT nTable) +/*N*/ { +/*N*/ BOOL bRet = FALSE; +DBG_BF_ASSERT(0, "STRIP"); /*N*/ if( !pDocument->IsClipOrUndo() ) +/*N*/ { +/*N*/ pCode->Reset(); +/*N*/ ScToken* p = pCode->GetNextReferenceRPN(); +/*N*/ while( p ) +/*N*/ { +/*N*/ SingleRefData& rRef1 = p->GetSingleRef(); +/*N*/ if( !rRef1.IsTabRel() ) +/*N*/ { +/*N*/ if( (short) nTable != rRef1.nTab ) +/*N*/ bRet = TRUE; +/*N*/ else if (nTable != aPos.Tab()) +/*N*/ rRef1.nTab = aPos.Tab(); +/*N*/ } +/*N*/ if( p->GetType() == svDoubleRef ) +/*N*/ { +/*N*/ SingleRefData& rRef2 = p->GetDoubleRef().Ref2; +/*N*/ if( !rRef2.IsTabRel() ) +/*N*/ { +/*N*/ if( (short) nTable != rRef2.nTab ) +/*N*/ bRet = TRUE; +/*N*/ else if (nTable != aPos.Tab()) +/*N*/ rRef2.nTab = aPos.Tab(); +/*N*/ } +/*N*/ } +/*N*/ p = pCode->GetNextReferenceRPN(); +/*N*/ } +/*N*/ } +/*N*/ return bRet; +/*N*/ } + +/*N*/ void ScFormulaCell::UpdateCompile( BOOL bForceIfNameInUse ) +/*N*/ { +/*N*/ if ( bForceIfNameInUse && !bCompile ) +/*?*/ { DBG_BF_ASSERT(0, "STRIP");} /*N*/ bCompile = pCode->HasNameOrColRowName(); +/*N*/ if ( bCompile ) +/*?*/ pCode->SetError( 0 ); // damit auch wirklich kompiliert wird +/*N*/ CompileTokenArray(); +/*N*/ } + +/*N*/ BOOL lcl_IsRangeNameInUse(USHORT nIndex, ScTokenArray* pCode, ScRangeName* pNames) +/*N*/ { +/*N*/ for (ScToken* p = pCode->First(); p; p = pCode->Next()) +/*N*/ { +/*N*/ if (p->GetOpCode() == ocName) +/*N*/ { +/*N*/ if (p->GetIndex() == nIndex) +/*N*/ return TRUE; +/*N*/ else +/*N*/ { +/*N*/ // RangeData kann Null sein in bestimmten Excel-Dateien (#31168#) +/*N*/ ScRangeData* pSubName = pNames->FindIndex(p->GetIndex()); +/*N*/ if (pSubName && lcl_IsRangeNameInUse(nIndex, +/*N*/ pSubName->GetCode(), pNames)) +/*N*/ return TRUE; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ return FALSE; +/*N*/ } + +/*N*/ BOOL ScFormulaCell::IsRangeNameInUse(USHORT nIndex) const +/*N*/ { +/*N*/ return lcl_IsRangeNameInUse( nIndex, pCode, pDocument->GetRangeName() ); +/*N*/ } + +/*N*/ void ScFormulaCell::CompileDBFormula( BOOL bCreateFormulaString ) +/*N*/ { +/*N*/ // zwei Phasen, muessen (!) nacheinander aufgerufen werden: +/*N*/ // 1. FormelString mit alten Namen erzeugen +/*N*/ // 2. FormelString mit neuen Namen kompilieren +/*N*/ if ( bCreateFormulaString ) +/*N*/ { +/*N*/ BOOL bRecompile = FALSE; +/*N*/ pCode->Reset(); +/*N*/ for ( ScToken* p = pCode->First(); p && !bRecompile; p = pCode->Next() ) +/*N*/ { +/*N*/ switch ( p->GetOpCode() ) +/*N*/ { +/*N*/ case ocBad: // DB-Bereich evtl. zugefuegt +/*N*/ case ocColRowName: // #36762# falls Namensgleichheit +/*N*/ case ocDBArea: // DB-Bereich +/*N*/ bRecompile = TRUE; +/*N*/ break; +/*N*/ case ocName: +/*?*/ if ( p->GetIndex() >= SC_START_INDEX_DB_COLL ) +/*?*/ bRecompile = TRUE; // DB-Bereich +/*N*/ } +/*N*/ } +/*N*/ if ( bRecompile ) +/*N*/ { +/*N*/ String aFormula; +/*N*/ GetFormula( aFormula ); +/*N*/ if ( GetMatrixFlag() != MM_NONE && aFormula.Len() ) +/*N*/ { +/*?*/ if ( aFormula.GetChar( aFormula.Len()-1 ) == '}' ) +/*?*/ aFormula.Erase( aFormula.Len()-1 , 1 ); +/*?*/ if ( aFormula.GetChar(0) == '{' ) +/*?*/ aFormula.Erase( 0, 1 ); +/*N*/ } +/*N*/ EndListeningTo( pDocument ); +/*N*/ pDocument->RemoveFromFormulaTree( this ); +/*N*/ pCode->Clear(); +/*N*/ aErgString = aFormula; +/*N*/ } +/*N*/ } +/*N*/ else if ( !pCode->GetLen() && aErgString.Len() ) +/*N*/ { +/*N*/ Compile( aErgString ); +/*N*/ aErgString.Erase(); +/*N*/ SetDirty(); +/*N*/ } +/*N*/ } + +/*N*/ void ScFormulaCell::CompileNameFormula( BOOL bCreateFormulaString ) +/*N*/ { +/*N*/ // zwei Phasen, muessen (!) nacheinander aufgerufen werden: +/*N*/ // 1. FormelString mit alten RangeNames erzeugen +/*N*/ // 2. FormelString mit neuen RangeNames kompilieren +/*N*/ if ( bCreateFormulaString ) +/*N*/ { +/*N*/ BOOL bRecompile = FALSE; +/*N*/ pCode->Reset(); +/*N*/ for ( ScToken* p = pCode->First(); p && !bRecompile; p = pCode->Next() ) +/*N*/ { +/*N*/ switch ( p->GetOpCode() ) +/*N*/ { +/*N*/ case ocBad: // RangeName evtl. zugefuegt +/*N*/ case ocColRowName: // #36762# falls Namensgleichheit +/*N*/ bRecompile = TRUE; +/*N*/ break; +/*N*/ default: +/*N*/ if ( p->GetType() == svIndex ) +/*N*/ bRecompile = TRUE; // RangeName +/*N*/ } +/*N*/ } +/*N*/ if ( bRecompile ) +/*N*/ { +/*N*/ String aFormula; +/*N*/ GetFormula( aFormula ); +/*N*/ if ( GetMatrixFlag() != MM_NONE && aFormula.Len() ) +/*N*/ { +/*?*/ if ( aFormula.GetChar( aFormula.Len()-1 ) == '}' ) +/*?*/ aFormula.Erase( aFormula.Len()-1 , 1 ); +/*?*/ if ( aFormula.GetChar(0) == '{' ) +/*?*/ aFormula.Erase( 0, 1 ); +/*N*/ } +/*N*/ EndListeningTo( pDocument ); +/*N*/ pDocument->RemoveFromFormulaTree( this ); +/*N*/ pCode->Clear(); +/*N*/ aErgString = aFormula; +/*N*/ } +/*N*/ } +/*N*/ else if ( !pCode->GetLen() && aErgString.Len() ) +/*N*/ { +/*N*/ Compile( aErgString ); +/*N*/ aErgString.Erase(); +/*N*/ SetDirty(); +/*N*/ } +/*N*/ } + +/*N*/ void ScFormulaCell::CompileColRowNameFormula() +/*N*/ { +/*N*/ pCode->Reset(); +/*N*/ for ( ScToken* p = pCode->First(); p; p = pCode->Next() ) +/*N*/ { +/*N*/ if ( p->GetOpCode() == ocColRowName ) +/*N*/ { +/*N*/ bCompile = TRUE; +/*N*/ CompileTokenArray(); +/*N*/ SetDirty(); +/*N*/ break; +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ ScValueCell::ScValueCell( SvStream& rStream, USHORT nVer ) : +/*N*/ ScBaseCell( CELLTYPE_VALUE ) +/*N*/ { +/*N*/ if( nVer >= SC_DATABYTES2 ) +/*N*/ { +/*N*/ BYTE cData; +/*N*/ rStream >> cData; +/*N*/ if( cData & 0x0F ) +/*?*/ rStream.SeekRel( cData & 0x0F ); +/*N*/ } +/*N*/ rStream >> aValue; +/*N*/ } + +/*N*/ void ScValueCell::Save( SvStream& rStream ) const +/*N*/ { +/*N*/ rStream << (BYTE) 0x00 << aValue; +/*N*/ } + +/*N*/ ScStringCell::ScStringCell( SvStream& rStream, USHORT nVer ) : +/*N*/ ScBaseCell( CELLTYPE_STRING ) +/*N*/ { +/*N*/ if( nVer >= SC_DATABYTES2 ) +/*N*/ { +/*N*/ BYTE cData; +/*N*/ rStream >> cData; +/*N*/ if( cData & 0x0F ) +/*?*/ rStream.SeekRel( cData & 0x0F ); +/*N*/ } +/*N*/ rStream.ReadByteString( aString, rStream.GetStreamCharSet() ); +/*N*/ } + +/*N*/ void ScStringCell::Save( SvStream& rStream, FontToSubsFontConverter hConv ) const +/*N*/ { +/*N*/ rStream << (BYTE) 0x00; +/*N*/ if ( !hConv ) +/*N*/ rStream.WriteByteString( aString, rStream.GetStreamCharSet() ); +/*N*/ else +/*N*/ { +/*N*/ String aTmp( aString ); +/*N*/ sal_Unicode* p = aTmp.GetBufferAccess(); +/*N*/ sal_Unicode const * const pStop = p + aTmp.Len(); +/*N*/ for ( ; p < pStop; ++p ) +/*N*/ { +/*N*/ *p = ConvertFontToSubsFontChar( hConv, *p ); +/*N*/ } +/*N*/ aTmp.ReleaseBufferAccess(); +/*N*/ rStream.WriteByteString( aTmp, rStream.GetStreamCharSet() ); +/*N*/ } +/*N*/ } + +/*N*/ void ScStringCell::ConvertFont( FontToSubsFontConverter hConv ) +/*N*/ { +/*N*/ if ( hConv ) +/*N*/ { +/*N*/ sal_Unicode* p = aString.GetBufferAccess(); +/*N*/ sal_Unicode const * const pStop = p + aString.Len(); +/*N*/ for ( ; p < pStop; ++p ) +/*N*/ { +/*N*/ *p = ConvertFontToSubsFontChar( hConv, *p ); +/*N*/ } +/*N*/ aString.ReleaseBufferAccess(); +/*N*/ } +/*N*/ } + +/*N*/ ScNoteCell::ScNoteCell( SvStream& rStream, USHORT nVer ) : +/*N*/ ScBaseCell( CELLTYPE_NOTE ) +/*N*/ { +/*N*/ if( nVer >= SC_DATABYTES2 ) +/*N*/ { +/*N*/ BYTE cData; +/*N*/ rStream >> cData; +/*N*/ if( cData & 0x0F ) +/*?*/ rStream.SeekRel( cData & 0x0F ); +/*N*/ } +/*N*/ } + +/*N*/ void ScNoteCell::Save( SvStream& rStream ) const +/*N*/ { +/*N*/ rStream << (BYTE) 0x00; +/*N*/ } + + + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_column.cxx b/binfilter/bf_sc/source/core/data/sc_column.cxx new file mode 100644 index 000000000000..76bf4e7d0fa2 --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_column.cxx @@ -0,0 +1,1363 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include <bf_svtools/poolcach.hxx> +#include <bf_svx/scripttypeitem.hxx> +#include <string.h> + +#include "scitems.hxx" +#include "cell.hxx" +#include "document.hxx" +#include "docpool.hxx" +#include "attarray.hxx" +#include "patattr.hxx" +#include "markdata.hxx" +namespace binfilter { + +//#pragma optimize ( "", off ) +// nur Search ohne Optimierung! + +// STATIC DATA ----------------------------------------------------------- + + +/*N*/ inline BOOL CellVisible( const ScBaseCell* pCell ) //! an Zelle verschieben +/*N*/ { +/*N*/ return ( pCell->GetCellType() != CELLTYPE_NOTE || pCell->GetNotePtr() ); +/*N*/ } + +/*N*/ inline BOOL IsAmbiguousScriptNonZero( BYTE nScript ) +/*N*/ { +/*N*/ //! move to a header file +/*N*/ return ( nScript != SCRIPTTYPE_LATIN && +/*N*/ nScript != SCRIPTTYPE_ASIAN && +/*N*/ nScript != SCRIPTTYPE_COMPLEX && +/*N*/ nScript != 0 ); +/*N*/ } + +// ----------------------------------------------------------------------------------------- + + +/*N*/ ScColumn::ScColumn() : +/*N*/ nCol( 0 ), +/*N*/ nCount( 0 ), +/*N*/ nLimit( 0 ), +/*N*/ pItems( NULL ), +/*N*/ pDocument( NULL ), +/*N*/ pAttrArray( NULL ) +/*N*/ { +/*N*/ } + + +/*N*/ ScColumn::~ScColumn() +/*N*/ { +/*N*/ FreeAll(); +/*N*/ if (pAttrArray) delete pAttrArray; +/*N*/ } + + +/*N*/ void ScColumn::Init(USHORT nNewCol, USHORT nNewTab, ScDocument* pDoc) +/*N*/ { +/*N*/ nCol = nNewCol; +/*N*/ nTab = nNewTab; +/*N*/ pDocument = pDoc; +/*N*/ pAttrArray = new ScAttrArray( nCol, nTab, pDocument ); +/*N*/ } + + + + +/*N*/ USHORT ScColumn::GetBlockMatrixEdges( USHORT nRow1, USHORT nRow2, USHORT nMask ) const +/*N*/ { +/*N*/ // nix:0, mitte:1, unten:2, links:4, oben:8, rechts:16, offen:32 +/*N*/ if ( !pItems ) +/*N*/ return 0; +/*N*/ if ( nRow1 == nRow2 ) +/*N*/ { +/*N*/ USHORT nIndex; +/*N*/ if ( Search( nRow1, nIndex ) ) +/*N*/ { +/*N*/ ScBaseCell* pCell = pItems[nIndex].pCell; +/*N*/ if ( pCell->GetCellType() == CELLTYPE_FORMULA +/*N*/ && ((ScFormulaCell*)pCell)->GetMatrixFlag() ) +/*N*/ { +/*N*/ ScAddress aOrg( (UINT32)0xFFFFFFFF ); +/*N*/ return ((ScFormulaCell*)pCell)->GetMatrixEdge( aOrg ); +/*N*/ } +/*N*/ } +/*N*/ return 0; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ ScAddress aOrg( (UINT32)0xFFFFFFFF ); +/*N*/ BOOL bOpen = FALSE; +/*N*/ USHORT nEdges = 0; +/*N*/ USHORT nIndex; +/*N*/ Search( nRow1, nIndex ); +/*N*/ while ( nIndex < nCount && pItems[nIndex].nRow <= nRow2 ) +/*N*/ { +/*N*/ ScBaseCell* pCell = pItems[nIndex].pCell; +/*N*/ if ( pCell->GetCellType() == CELLTYPE_FORMULA +/*N*/ && ((ScFormulaCell*)pCell)->GetMatrixFlag() ) +/*N*/ { +/*N*/ nEdges = ((ScFormulaCell*)pCell)->GetMatrixEdge( aOrg ); +/*N*/ if ( nEdges ) +/*N*/ { +/*N*/ if ( nEdges & 8 ) +/*N*/ bOpen = TRUE; // obere Kante oeffnet, weitersehen +/*N*/ else if ( !bOpen ) +/*N*/ return nEdges | 32; // es gibt was, was nicht geoeffnet wurde +/*N*/ else if ( nEdges & 1 ) +/*N*/ return nEdges; // mittendrin +/*N*/ // (nMask & 16 und (4 und nicht 16)) oder +/*N*/ // (nMask & 4 und (16 und nicht 4)) +/*N*/ if ( ((nMask & 16) && (nEdges & 4) && !(nEdges & 16)) +/*N*/ || ((nMask & 4) && (nEdges & 16) && !(nEdges & 4)) ) +/*N*/ return nEdges; // nur linke/rechte Kante +/*N*/ if ( nEdges & 2 ) +/*N*/ bOpen = FALSE; // untere Kante schliesst +/*N*/ } +/*N*/ } +/*N*/ nIndex++; +/*N*/ } +/*N*/ if ( bOpen ) +/*N*/ nEdges |= 32; // es geht noch weiter +/*N*/ return nEdges; +/*N*/ } +/*N*/ } + + +/*N*/ BOOL ScColumn::HasSelectionMatrixFragment(const ScMarkData& rMark) const +/*N*/ { +/*N*/ if ( rMark.IsMultiMarked() ) +/*N*/ { +/*N*/ BOOL bFound = FALSE; +/*N*/ +/*N*/ ScAddress aOrg( (UINT32)0xFFFFFFFF ); +/*N*/ ScAddress aCurOrg( (UINT32)0xFFFFFFFF ); +/*N*/ USHORT nTop, nBottom; +/*N*/ ScMarkArrayIter aMarkIter( rMark.GetArray()+nCol ); +/*N*/ while ( !bFound && aMarkIter.Next( nTop, nBottom ) ) +/*N*/ { +/*N*/ BOOL bOpen = FALSE; +/*N*/ USHORT nEdges; +/*N*/ USHORT nIndex; +/*N*/ Search( nTop, nIndex ); +/*N*/ while ( !bFound && nIndex < nCount && pItems[nIndex].nRow <= nBottom ) +/*N*/ { +/*N*/ ScBaseCell* pCell = pItems[nIndex].pCell; +/*N*/ if ( pCell->GetCellType() == CELLTYPE_FORMULA +/*N*/ && ((ScFormulaCell*)pCell)->GetMatrixFlag() ) +/*N*/ { +/*N*/ nEdges = ((ScFormulaCell*)pCell)->GetMatrixEdge( aOrg ); +/*N*/ if ( nEdges ) +/*N*/ { +/*N*/ if ( nEdges & 8 ) +/*N*/ bOpen = TRUE; // obere Kante oeffnet, weitersehen +/*N*/ else if ( !bOpen ) +/*N*/ return TRUE; // es gibt was, was nicht geoeffnet wurde +/*N*/ else if ( nEdges & 1 ) +/*N*/ bFound = TRUE; // mittendrin, alles selektiert? +/*N*/ // (4 und nicht 16) oder (16 und nicht 4) +/*N*/ if ( (((nEdges & 4) | 16) ^ ((nEdges & 16) | 4)) ) +/*N*/ bFound = TRUE; // nur linke/rechte Kante, alles selektiert? +/*N*/ if ( nEdges & 2 ) +/*N*/ bOpen = FALSE; // untere Kante schliesst +/*N*/ +/*N*/ if ( bFound ) +/*N*/ { // alles selektiert? +/*?*/ if ( aCurOrg != aOrg ) +/*?*/ { // neue Matrix zu pruefen? +/*?*/ aCurOrg = aOrg; +/*?*/ ScFormulaCell* pFCell; +/*?*/ if ( ((ScFormulaCell*)pCell)->GetMatrixFlag() +/*?*/ == MM_REFERENCE ) +/*?*/ pFCell = (ScFormulaCell*) pDocument->GetCell( aOrg ); +/*?*/ else +/*?*/ pFCell = (ScFormulaCell*)pCell; +/*?*/ USHORT nC, nR; +/*?*/ pFCell->GetMatColsRows( nC, nR ); +/*?*/ ScRange aRange( aOrg, ScAddress( +/*?*/ aOrg.Col() + nC - 1, aOrg.Row() + nR - 1, +/*?*/ aOrg.Tab() ) ); +/*?*/ if ( rMark.IsAllMarked( aRange ) ) +/*?*/ bFound = FALSE; +/*?*/ } +/*?*/ else +/*?*/ bFound = FALSE; // war schon +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ nIndex++; +/*N*/ } +/*N*/ if ( bOpen ) +/*N*/ return TRUE; +/*N*/ } +/*N*/ return bFound; +/*N*/ } +/*N*/ else +/*N*/ return FALSE; +/*N*/ } + + + + +/*N*/ BOOL ScColumn::HasAttrib( USHORT nRow1, USHORT nRow2, USHORT nMask ) const +/*N*/ { +/*N*/ return pAttrArray->HasAttrib( nRow1, nRow2, nMask ); +/*N*/ } + + + + +/*N*/ BOOL ScColumn::ExtendMerge( USHORT nThisCol, USHORT nStartRow, USHORT nEndRow, +/*N*/ USHORT& rPaintCol, USHORT& rPaintRow, +/*N*/ BOOL bRefresh, BOOL bAttrs ) +/*N*/ { +/*N*/ return pAttrArray->ExtendMerge( nThisCol, nStartRow, nEndRow, rPaintCol, rPaintRow, bRefresh, bAttrs ); +/*N*/ } + + +/*N*/ void ScColumn::MergeSelectionPattern( SfxItemSet** ppSet, const ScMarkData& rMark, BOOL bDeep ) const +/*N*/ { +/*N*/ USHORT nTop; +/*N*/ USHORT nBottom; +/*N*/ +/*N*/ if ( rMark.IsMultiMarked() ) +/*N*/ { +/*N*/ ScMarkArrayIter aMarkIter( rMark.GetArray() + nCol ); +/*N*/ while (aMarkIter.Next( nTop, nBottom )) +/*N*/ pAttrArray->MergePatternArea( nTop, nBottom, ppSet, bDeep ); +/*N*/ } +/*N*/ } + + +/*N*/ void ScColumn::MergePatternArea( SfxItemSet** ppSet, USHORT nRow1, USHORT nRow2, BOOL bDeep ) const +/*N*/ { +/*N*/ pAttrArray->MergePatternArea( nRow1, nRow2, ppSet, bDeep ); +/*N*/ } + + + + + + +/*N*/ const ScPatternAttr* ScColumn::GetPattern( USHORT nRow ) const +/*N*/ { +/*N*/ return pAttrArray->GetPattern( nRow ); +/*N*/ } + + +/*N*/ const SfxPoolItem* ScColumn::GetAttr( USHORT nRow, USHORT nWhich ) const +/*N*/ { +/*N*/ return &pAttrArray->GetPattern( nRow )->GetItemSet().Get(nWhich); +/*N*/ } + + +/*N*/ ULONG ScColumn::GetNumberFormat( USHORT nRow ) const +/*N*/ { +/*N*/ return pAttrArray->GetPattern( nRow )->GetNumberFormat( pDocument->GetFormatTable() ); +/*N*/ } + + +/*N*/ short ScColumn::ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark ) +/*N*/ { +/*N*/ USHORT nTop; +/*N*/ USHORT nBottom; +/*N*/ BOOL bFound = FALSE; +/*N*/ +/*N*/ if ( rMark.IsMultiMarked() ) +/*N*/ { +/*N*/ ScMarkArrayIter aMarkIter( rMark.GetArray() + nCol ); +/*N*/ while (aMarkIter.Next( nTop, nBottom )) +/*N*/ { +/*N*/ pAttrArray->ApplyCacheArea( nTop, nBottom, pCache ); +/*N*/ bFound = TRUE; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if (!bFound) +/*N*/ return -1; +/*N*/ else if (nTop==0 && nBottom==MAXROW) +/*N*/ return 0; +/*N*/ else +/*N*/ return (short) nBottom; +/*N*/ } + + + + + + + + + + +/*N*/ void ScColumn::ApplyPatternArea( USHORT nStartRow, USHORT nEndRow, const ScPatternAttr& rPatAttr ) +/*N*/ { +/*N*/ const SfxItemSet* pSet = &rPatAttr.GetItemSet(); +/*N*/ SfxItemPoolCache aCache( pDocument->GetPool(), pSet ); +/*N*/ pAttrArray->ApplyCacheArea( nStartRow, nEndRow, &aCache ); +/*N*/ } + + + + + + +/*N*/ void ScColumn::ApplyStyleArea( USHORT nStartRow, USHORT nEndRow, const ScStyleSheet& rStyle ) +/*N*/ { +/*N*/ pAttrArray->ApplyStyleArea(nStartRow, nEndRow, (ScStyleSheet*)&rStyle); +/*N*/ } + + +/*N*/ void ScColumn::ApplySelectionStyle(const ScStyleSheet& rStyle, const ScMarkData& rMark) +/*N*/ { +/*N*/ USHORT nTop; +/*N*/ USHORT nBottom; +/*N*/ +/*N*/ if ( rMark.IsMultiMarked() ) +/*N*/ { +/*N*/ ScMarkArrayIter aMarkIter( rMark.GetArray() + nCol ); +/*N*/ while (aMarkIter.Next( nTop, nBottom )) +/*N*/ pAttrArray->ApplyStyleArea(nTop, nBottom, (ScStyleSheet*)&rStyle); +/*N*/ } +/*N*/ } + +/*N*/ const ScStyleSheet* ScColumn::GetSelectionStyle( const ScMarkData& rMark, BOOL& rFound ) const +/*N*/ { +/*N*/ rFound = FALSE; +/*N*/ if (!rMark.IsMultiMarked()) +/*N*/ { +/*N*/ DBG_ERROR("ScColumn::GetSelectionStyle ohne Selektion"); +/*N*/ return NULL; +/*N*/ } +/*N*/ +/*N*/ BOOL bEqual = TRUE; +/*N*/ +/*N*/ const ScStyleSheet* pStyle = NULL; +/*N*/ const ScStyleSheet* pNewStyle; +/*N*/ +/*N*/ ScMarkArrayIter aMarkIter( rMark.GetArray() + nCol ); +/*N*/ USHORT nTop; +/*N*/ USHORT nBottom; +/*N*/ while (bEqual && aMarkIter.Next( nTop, nBottom )) +/*N*/ { +/*N*/ ScAttrIterator aAttrIter( pAttrArray, nTop, nBottom ); +/*N*/ USHORT nRow; +/*N*/ USHORT nDummy; +/*N*/ const ScPatternAttr* pPattern; +/*N*/ while (bEqual && ( pPattern = aAttrIter.Next( nRow, nDummy ) )) +/*N*/ { +/*N*/ pNewStyle = pPattern->GetStyleSheet(); +/*N*/ rFound = TRUE; +/*N*/ if ( !pNewStyle || ( pStyle && pNewStyle != pStyle ) ) +/*N*/ bEqual = FALSE; // unterschiedliche +/*N*/ pStyle = pNewStyle; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ return bEqual ? pStyle : NULL; +/*N*/ } + + +/*N*/ const ScStyleSheet* ScColumn::GetAreaStyle( BOOL& rFound, USHORT nRow1, USHORT nRow2 ) const +/*N*/ { +/*N*/ rFound = FALSE; +/*N*/ +/*N*/ BOOL bEqual = TRUE; +/*N*/ +/*N*/ const ScStyleSheet* pStyle = NULL; +/*N*/ const ScStyleSheet* pNewStyle; +/*N*/ +/*N*/ ScAttrIterator aAttrIter( pAttrArray, nRow1, nRow2 ); +/*N*/ USHORT nRow; +/*N*/ USHORT nDummy; +/*N*/ const ScPatternAttr* pPattern; +/*N*/ while (bEqual && ( pPattern = aAttrIter.Next( nRow, nDummy ) )) +/*N*/ { +/*N*/ pNewStyle = pPattern->GetStyleSheet(); +/*N*/ rFound = TRUE; +/*N*/ if ( !pNewStyle || ( pStyle && pNewStyle != pStyle ) ) +/*N*/ bEqual = FALSE; // unterschiedliche +/*N*/ pStyle = pNewStyle; +/*N*/ } +/*N*/ +/*N*/ return bEqual ? pStyle : NULL; +/*N*/ } + + +/*N*/ void ScColumn::FindStyleSheet( const SfxStyleSheetBase* pStyleSheet, BOOL* pUsed, BOOL bReset ) +/*N*/ { +/*N*/ pAttrArray->FindStyleSheet( pStyleSheet, pUsed, bReset ); +/*N*/ } + + +/*N*/ BOOL ScColumn::ApplyFlags( USHORT nStartRow, USHORT nEndRow, INT16 nFlags ) +/*N*/ { +/*N*/ return pAttrArray->ApplyFlags( nStartRow, nEndRow, nFlags ); +/*N*/ } + + +/*N*/ BOOL ScColumn::RemoveFlags( USHORT nStartRow, USHORT nEndRow, INT16 nFlags ) +/*N*/ { +/*N*/ return pAttrArray->RemoveFlags( nStartRow, nEndRow, nFlags ); +/*N*/ } + + +/*N*/ void ScColumn::ClearItems( USHORT nStartRow, USHORT nEndRow, const USHORT* pWhich ) +/*N*/ { +/*N*/ pAttrArray->ClearItems( nStartRow, nEndRow, pWhich ); +/*N*/ } + + +/*N*/ void ScColumn::ApplyAttr( USHORT nRow, const SfxPoolItem& rAttr ) +/*N*/ { +/*N*/ // um nur ein neues SetItem zu erzeugen, brauchen wir keinen SfxItemPoolCache. +/*N*/ //! Achtung: der SfxItemPoolCache scheint zuviele Refs fuer das neue SetItem zu erzeugen ?? +/*N*/ +/*N*/ ScDocumentPool* pDocPool = pDocument->GetPool(); +/*N*/ +/*N*/ const ScPatternAttr* pOldPattern = pAttrArray->GetPattern( nRow ); +/*N*/ ScPatternAttr* pTemp = new ScPatternAttr(*pOldPattern); +/*N*/ pTemp->GetItemSet().Put(rAttr); +/*N*/ const ScPatternAttr* pNewPattern = (const ScPatternAttr*) &pDocPool->Put( *pTemp ); +/*N*/ +/*N*/ if ( pNewPattern != pOldPattern ) +/*N*/ pAttrArray->SetPattern( nRow, pNewPattern ); +/*N*/ else +/*?*/ pDocPool->Remove( *pNewPattern ); // ausser Spesen nichts gewesen +/*N*/ +/*N*/ delete pTemp; +/*N*/ +/*N*/ // alte Version mit SfxItemPoolCache: +/*N*/ #if 0 +/*?*/ SfxItemPoolCache aCache( pDocument->GetPool(), &rAttr ); +/*?*/ +/*?*/ const ScPatternAttr* pPattern = pAttrArray->GetPattern( nRow ); +/*?*/ +/*?*/ // TRUE = alten Eintrag behalten +/*?*/ +/*?*/ ScPatternAttr* pNewPattern = (ScPatternAttr*) &aCache.ApplyTo( *pPattern, TRUE ); +/*?*/ ScDocumentPool::CheckRef( *pPattern ); +/*?*/ ScDocumentPool::CheckRef( *pNewPattern ); +/*?*/ +/*?*/ if (pNewPattern != pPattern) +/*?*/ pAttrArray->SetPattern( nRow, pNewPattern ); +/*N*/ #endif +/*N*/ } + +#ifdef _MSC_VER +#pragma optimize ( "", off ) +#endif + + +/*N*/ BOOL ScColumn::Search( USHORT nRow, USHORT& nIndex ) const +/*N*/ { +/*N*/ if ( !pItems || !nCount ) +/*N*/ { +/*N*/ nIndex = 0; +/*N*/ return FALSE; +/*N*/ } +/*N*/ USHORT nMinRow = pItems[0].nRow; +/*N*/ if ( nRow <= nMinRow ) +/*N*/ { +/*N*/ nIndex = 0; +/*N*/ return nRow == nMinRow; +/*N*/ } +/*N*/ USHORT nMaxRow = pItems[nCount-1].nRow; +/*N*/ if ( nRow >= nMaxRow ) +/*N*/ { +/*N*/ if ( nRow == nMaxRow ) +/*N*/ { +/*N*/ nIndex = nCount - 1; +/*N*/ return TRUE; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ nIndex = nCount; +/*N*/ return FALSE; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ short nOldLo, nOldHi; +/*N*/ short nLo = nOldLo = 0; +/*N*/ short nHi = nOldHi = Min( (short)(nCount-1), (short)nRow ); +/*N*/ short i = 0; +/*N*/ BOOL bFound = FALSE; +/*N*/ // einigermassen durchgaengige Belegung? => interpolierende Suche +/*N*/ BOOL bInterpol = (nMaxRow - nMinRow < nCount * 2); +/*N*/ USHORT nR; +/*N*/ +/*N*/ while ( !bFound && nLo <= nHi ) +/*N*/ { +/*N*/ if ( !bInterpol || nHi - nLo < 3 ) +/*N*/ i = (nLo+nHi) / 2; // kein Aufwand, kein division by zero +/*N*/ else +/*N*/ { // interpolierende Suche +/*N*/ long nLoRow = pItems[nLo].nRow; // kein USHORT Unterlauf bei Subtraktion +/*N*/ i = nLo + (short)((long)(nRow - nLoRow) * (nHi - nLo) +/*N*/ / (pItems[nHi].nRow - nLoRow)); +/*N*/ if ( i < 0 || i >= nCount ) +/*N*/ { // oops ... +/*N*/ i = (nLo+nHi) / 2; +/*N*/ bInterpol = FALSE; +/*N*/ } +/*N*/ } +/*N*/ nR = pItems[i].nRow; +/*N*/ if ( nR < nRow ) +/*N*/ { +/*N*/ nLo = i+1; +/*N*/ if ( bInterpol ) +/*N*/ { +/*N*/ if ( nLo <= nOldLo ) +/*N*/ bInterpol = FALSE; +/*N*/ else +/*N*/ nOldLo = nLo; +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ if ( nR > nRow ) +/*N*/ { +/*N*/ nHi = i-1; +/*N*/ if ( bInterpol ) +/*N*/ { +/*N*/ if ( nHi >= nOldHi ) +/*N*/ bInterpol = FALSE; +/*N*/ else +/*N*/ nOldHi = nHi; +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ bFound = TRUE; +/*N*/ } +/*N*/ } +/*N*/ if (bFound) +/*N*/ nIndex = i; +/*N*/ else +/*N*/ nIndex = nLo; // hinterer Index +/*N*/ return bFound; +/*N*/ } + +#ifdef _MSC_VER +#pragma optimize ( "", on ) +#endif + + +/*N*/ ScBaseCell* ScColumn::GetCell( USHORT nRow ) const +/*N*/ { +/*N*/ USHORT nIndex; +/*N*/ if (Search(nRow, nIndex)) +/*N*/ return pItems[nIndex].pCell; +/*N*/ return NULL; +/*N*/ } + + +/*N*/ void ScColumn::Resize( USHORT nSize ) +/*N*/ { +/*N*/ if (nSize > MAXROW+1) +/*N*/ nSize = MAXROW+1; +/*N*/ if (nSize < nCount) +/*N*/ nSize = nCount; +/*N*/ +/*N*/ ColEntry* pNewItems; +/*N*/ if (nSize) +/*N*/ { +/*N*/ USHORT nNewSize = nSize + COLUMN_DELTA - 1; +/*N*/ nNewSize -= nNewSize % COLUMN_DELTA; +/*N*/ nLimit = nNewSize; +/*N*/ pNewItems = new ColEntry[nLimit]; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ nLimit = 0; +/*N*/ pNewItems = NULL; +/*N*/ } +/*N*/ if (pItems) +/*N*/ { +/*N*/ if (pNewItems) +/*N*/ memmove( pNewItems, pItems, nCount * sizeof(ColEntry) ); +/*N*/ delete[] pItems; +/*N*/ } +/*N*/ pItems = pNewItems; +/*N*/ } + +// SetNewRow gehoert zu SwapRow + + +// SwapRow zum Sortieren + + + + + +/*N*/ BOOL ScColumn::TestInsertCol( USHORT nStartRow, USHORT nEndRow) const +/*N*/ { +/*N*/ if (!IsEmpty()) +/*N*/ { +/*N*/ BOOL bTest = TRUE; +/*N*/ if (pItems) +/*N*/ for (USHORT i=0; (i<nCount) && bTest; i++) +/*N*/ bTest = ((pItems[i].nRow < nStartRow) && (pItems[i].nRow > nEndRow)) +/*N*/ || !CellVisible(pItems[i].pCell); +/*N*/ +/*N*/ // AttrArray testet nur zusammengefasste +/*N*/ +/*N*/ if ((bTest) && (pAttrArray)) +/*N*/ bTest = pAttrArray->TestInsertCol(nStartRow, nEndRow); +/*N*/ +/*N*/ //! rausgeschobene Attribute bei Undo beruecksichtigen +/*N*/ +/*N*/ return bTest; +/*N*/ } +/*N*/ else +/*N*/ return TRUE; +/*N*/ } + + +/*N*/ BOOL ScColumn::TestInsertRow( USHORT nSize ) const +/*N*/ { +/*N*/ // AttrArray testet nur zusammengefasste +/*N*/ +/*N*/ if ( pItems && nCount ) +/*N*/ return ( pItems[nCount-1].nRow <= MAXROW-nSize && pAttrArray->TestInsertRow( nSize ) ); +/*N*/ else +/*N*/ return pAttrArray->TestInsertRow( nSize ); +/*N*/ +/*N*/ //! rausgeschobene Attribute bei Undo beruecksichtigen +/*N*/ +/*N*/ if ( nSize > MAXROW ) +/*N*/ return FALSE; +/*N*/ +/*N*/ USHORT nVis = nCount; +/*N*/ while ( nVis && !CellVisible(pItems[nVis-1].pCell) ) +/*N*/ --nVis; +/*N*/ +/*N*/ if ( nVis ) +/*N*/ return ( pItems[nVis-1].nRow <= MAXROW-nSize ); +/*N*/ else +/*N*/ return TRUE; +/*N*/ } + + +/*N*/ void ScColumn::InsertRow( USHORT nStartRow, USHORT nSize ) +/*N*/ { +/*N*/ pAttrArray->InsertRow( nStartRow, nSize ); +/*N*/ +/*N*/ //! Search +/*N*/ +/*N*/ if ( !pItems || !nCount ) +/*N*/ return; +/*N*/ +/*N*/ USHORT i; +/*N*/ Search( nStartRow, i ); +/*N*/ if ( i >= nCount ) +/*N*/ return ; +/*N*/ +/*N*/ BOOL bOldAutoCalc = pDocument->GetAutoCalc(); +/*N*/ pDocument->SetAutoCalc( FALSE ); // Mehrfachberechnungen vermeiden +/*N*/ +/*N*/ USHORT nNewCount = nCount; +/*N*/ BOOL bCountChanged = FALSE; +/*N*/ ScAddress aAdr( nCol, 0, nTab ); +/*N*/ ScHint aHint( SC_HINT_DATACHANGED, aAdr, NULL ); // only areas (ScBaseCell* == NULL) +/*N*/ ScAddress& rAddress = aHint.GetAddress(); +/*N*/ // for sparse occupation use single broadcasts, not ranges +/*N*/ BOOL bSingleBroadcasts = (((pItems[nCount-1].nRow - pItems[i].nRow) / +/*N*/ (nCount - i)) > 1); +/*N*/ if ( bSingleBroadcasts ) +/*N*/ { +/*N*/ USHORT nLastBroadcast = MAXROW+1; +/*N*/ for ( ; i < nCount; i++) +/*N*/ { +/*N*/ USHORT nOldRow = pItems[i].nRow; +/*N*/ // #43940# Aenderung Quelle broadcasten +/*N*/ if ( nLastBroadcast != nOldRow ) +/*N*/ { // direkt aufeinanderfolgende nicht doppelt broadcasten +/*N*/ rAddress.SetRow( nOldRow ); +/*N*/ pDocument->AreaBroadcast( aHint ); +/*N*/ } +/*N*/ USHORT nNewRow = (pItems[i].nRow += nSize); +/*N*/ // #43940# Aenderung Ziel broadcasten +/*N*/ rAddress.SetRow( nNewRow ); +/*N*/ pDocument->AreaBroadcast( aHint ); +/*N*/ nLastBroadcast = nNewRow; +/*N*/ ScBaseCell* pCell = pItems[i].pCell; +/*N*/ if ( pCell->GetCellType() == CELLTYPE_FORMULA ) +/*N*/ ((ScFormulaCell*)pCell)->aPos.SetRow( nNewRow ); +/*N*/ if ( nNewRow > MAXROW && !bCountChanged ) +/*N*/ { +/*N*/ nNewCount = i; +/*N*/ bCountChanged = TRUE; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ rAddress.SetRow( pItems[i].nRow ); +/*N*/ ScRange aRange( rAddress ); +/*N*/ for ( ; i < nCount; i++) +/*N*/ { +/*N*/ USHORT nNewRow = (pItems[i].nRow += nSize); +/*N*/ ScBaseCell* pCell = pItems[i].pCell; +/*N*/ if ( pCell->GetCellType() == CELLTYPE_FORMULA ) +/*N*/ ((ScFormulaCell*)pCell)->aPos.SetRow( nNewRow ); +/*N*/ if ( nNewRow > MAXROW && !bCountChanged ) +/*N*/ { +/*N*/ nNewCount = i; +/*N*/ bCountChanged = TRUE; +/*N*/ aRange.aEnd.SetRow( MAXROW ); +/*N*/ } +/*N*/ } +/*N*/ if ( !bCountChanged ) +/*N*/ aRange.aEnd.SetRow( pItems[nCount-1].nRow ); +/*N*/ pDocument->AreaBroadcastInRange( aRange, aHint ); +/*N*/ } +/*N*/ +/*N*/ if (bCountChanged) +/*N*/ { +/*N*/ USHORT nDelCount = nCount - nNewCount; +/*N*/ ScBaseCell** ppDelCells = new ScBaseCell*[nDelCount]; +/*N*/ USHORT* pDelRows = new USHORT[nDelCount]; +/*N*/ for (i = 0; i < nDelCount; i++) +/*N*/ { +/*N*/ ppDelCells[i] = pItems[nNewCount+i].pCell; +/*N*/ pDelRows[i] = pItems[nNewCount+i].nRow; +/*N*/ } +/*N*/ nCount = nNewCount; +/*N*/ +/*N*/ for (i = 0; i < nDelCount; i++) +/*N*/ { +/*N*/ ScBaseCell* pCell = ppDelCells[i]; +/*N*/ DBG_ASSERT( !CellVisible(pCell), "sichtbare Zelle weggeschoben" ); +/*N*/ ScBroadcasterList* pBC = pCell->GetBroadcaster(); +/*N*/ if (pBC) +/*N*/ { +/*N*/ MoveListeners( *pBC, pDelRows[i] - nSize ); +/*N*/ pCell->SetBroadcaster(NULL); +/*N*/ pCell->Delete(); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ delete[] pDelRows; +/*N*/ delete[] ppDelCells; +/*N*/ } +/*N*/ +/*N*/ pDocument->SetAutoCalc( bOldAutoCalc ); +/*N*/ } + + + + +/*N*/ void ScColumn::CopyToColumn(USHORT nRow1, USHORT nRow2, USHORT nFlags, BOOL bMarked, +/*N*/ ScColumn& rColumn, const ScMarkData* pMarkData, BOOL bAsLink ) +/*N*/ { +/*N*/ if (bMarked) +/*N*/ { +/*N*/ USHORT nStart, nEnd; +/*N*/ if (pMarkData && pMarkData->IsMultiMarked()) +/*N*/ { +/*N*/ ScMarkArrayIter aIter( pMarkData->GetArray()+nCol ); +/*N*/ +/*N*/ while ( aIter.Next( nStart, nEnd ) && nStart <= nRow2 ) +/*N*/ { +/*N*/ if ( nEnd >= nRow1 ) +/*N*/ CopyToColumn( Max(nRow1,nStart), Min(nRow2,nEnd), +/*N*/ nFlags, FALSE, rColumn, pMarkData, bAsLink ); +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ DBG_ERROR("CopyToColumn: bMarked, aber keine Markierung"); +/*N*/ return; +/*N*/ } +/*N*/ +/*N*/ if ( (nFlags & IDF_ATTRIB) != 0 ) +/*N*/ { +/*N*/ if ( (nFlags & IDF_STYLES) != IDF_STYLES ) +/*N*/ { // StyleSheets im Zieldokument bleiben erhalten +/*?*/ // z.B. DIF und RTF Clipboard-Import +/*?*/ for ( USHORT nRow = nRow1; nRow <= nRow2; nRow++ ) +/*?*/ { +/*?*/ const ScStyleSheet* pStyle = +/*?*/ rColumn.pAttrArray->GetPattern( nRow )->GetStyleSheet(); +/*?*/ const ScPatternAttr* pPattern = pAttrArray->GetPattern( nRow ); +/*?*/ ScPatternAttr* pNewPattern = new ScPatternAttr( *pPattern ); +/*?*/ pNewPattern->SetStyleSheet( (ScStyleSheet*)pStyle ); +/*?*/ rColumn.pAttrArray->SetPattern( nRow, pNewPattern, TRUE ); +/*?*/ delete pNewPattern; +/*?*/ } +/*N*/ } +/*N*/ else +/*N*/ pAttrArray->CopyArea( nRow1, nRow2, 0, *rColumn.pAttrArray); +/*N*/ } +/*N*/ +/*N*/ +/*N*/ if ((nFlags & IDF_CONTENTS) != 0) +/*N*/ { +/*N*/ USHORT i; +/*N*/ USHORT nBlockCount = 0; +/*N*/ USHORT nStartIndex, nEndIndex; +/*N*/ for (i = 0; i < nCount; i++) +/*N*/ if ((pItems[i].nRow >= nRow1) && (pItems[i].nRow <= nRow2)) +/*N*/ { +/*N*/ if (!nBlockCount) +/*N*/ nStartIndex = i; +/*N*/ nEndIndex = i; +/*N*/ ++nBlockCount; +/*N*/ } +/*N*/ +/*N*/ if (nBlockCount) +/*N*/ { +/*N*/ rColumn.Resize( rColumn.GetCellCount() + nBlockCount ); +/*N*/ ScAddress aAdr( rColumn.nCol, 0, rColumn.nTab ); +/*N*/ for (i = nStartIndex; i <= nEndIndex; i++) +/*N*/ { +/*N*/ ScBaseCell* pOld = pItems[i].pCell; +/*N*/ aAdr.SetRow( pItems[i].nRow ); +/*N*/ ScBaseCell* pNew = NULL; +/*N*/ if (bAsLink) +/*N*/ { + DBG_BF_ASSERT(0, "STRIP"); //STRIP001 /*?*/ pNew = CreateRefCell( rColumn.pDocument, aAdr, i, nFlags ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ pNew = CloneCell( i, nFlags, rColumn.pDocument, aAdr ); +/*N*/ +/*N*/ if ( pNew && pNew->GetNotePtr() && (nFlags & IDF_NOTE) == 0 ) +/*?*/ pNew->DeleteNote(); +/*N*/ } +/*N*/ +/*N*/ if (pNew) +/*N*/ rColumn.Insert(pItems[i].nRow, pNew); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } + + + + + + + + + + + + +/*N*/ void ScColumn::MarkScenarioIn( ScMarkData& rDestMark ) const +/*N*/ { +/*N*/ ScRange aRange( nCol, 0, nTab ); +/*N*/ +/*N*/ ScAttrIterator aAttrIter( pAttrArray, 0, MAXROW ); +/*N*/ USHORT nStart, nEnd; +/*N*/ const ScPatternAttr* pPattern = aAttrIter.Next( nStart, nEnd ); +/*N*/ while (pPattern) +/*N*/ { +/*N*/ if ( ((ScMergeFlagAttr&)pPattern->GetItem( ATTR_MERGE_FLAG )).IsScenario() ) +/*N*/ { +/*N*/ aRange.aStart.SetRow( nStart ); +/*N*/ aRange.aEnd.SetRow( nEnd ); +/*N*/ rDestMark.SetMultiMarkArea( aRange, TRUE ); +/*N*/ } +/*N*/ +/*N*/ pPattern = aAttrIter.Next( nStart, nEnd ); +/*N*/ } +/*N*/ } + + +/*N*/ void ScColumn::SwapCol(ScColumn& rCol) +/*N*/ { +/*N*/ USHORT nTemp; +/*N*/ +/*N*/ nTemp = rCol.nCount; +/*N*/ rCol.nCount = nCount; +/*N*/ nCount = nTemp; +/*N*/ +/*N*/ nTemp = rCol.nLimit; +/*N*/ rCol.nLimit = nLimit; +/*N*/ nLimit = nTemp; +/*N*/ +/*N*/ ColEntry* pTempItems = rCol.pItems; +/*N*/ rCol.pItems = pItems; +/*N*/ pItems = pTempItems; +/*N*/ +/*N*/ ScAttrArray* pTempAttr = rCol.pAttrArray; +/*N*/ rCol.pAttrArray = pAttrArray; +/*N*/ pAttrArray = pTempAttr; +/*N*/ +/*N*/ // #38415# AttrArray muss richtige Spaltennummer haben +/*N*/ pAttrArray->SetCol(nCol); +/*N*/ rCol.pAttrArray->SetCol(rCol.nCol); +/*N*/ +/*N*/ USHORT i; +/*N*/ if (pItems) +/*N*/ for (i = 0; i < nCount; i++) +/*N*/ { +/*N*/ ScFormulaCell* pCell = (ScFormulaCell*) pItems[i].pCell; +/*N*/ if( pCell->GetCellType() == CELLTYPE_FORMULA) +/*N*/ pCell->aPos.SetCol(nCol); +/*N*/ } +/*N*/ if (rCol.pItems) +/*N*/ for (i = 0; i < rCol.nCount; i++) +/*N*/ { +/*N*/ ScFormulaCell* pCell = (ScFormulaCell*) rCol.pItems[i].pCell; +/*N*/ if( pCell->GetCellType() == CELLTYPE_FORMULA) +/*N*/ pCell->aPos.SetCol(rCol.nCol); +/*N*/ } +/*N*/ } + + +/*N*/ void ScColumn::MoveTo(USHORT nStartRow, USHORT nEndRow, ScColumn& rCol) +/*N*/ { +/*N*/ pAttrArray->MoveTo(nStartRow, nEndRow, *rCol.pAttrArray); +/*N*/ +/*N*/ if (pItems) +/*N*/ { +/*N*/ USHORT nStartPos; +/*N*/ USHORT nMoveCount=0; +/*N*/ USHORT i; +/*N*/ for (i=0; i < nCount; i++) +/*N*/ { +/*N*/ if ((pItems[i].nRow >= nStartRow) && (pItems[i].nRow <= nEndRow)) +/*N*/ { +/*N*/ if (nMoveCount==0) +/*N*/ nStartPos=i; +/*N*/ ++nMoveCount; +/*N*/ +/*N*/ rCol.Insert(pItems[i].nRow, pItems[i].pCell); +/*N*/ } +/*N*/ } +/*N*/ if (nMoveCount > 0) +/*N*/ { +/*N*/ // Formeln benachrichtigen, dass sich etwas aendert +/*N*/ +/*N*/ ScNoteCell* pNoteCell = new ScNoteCell; // Dummy wie in DeleteRange +/*N*/ USHORT nEndPos = nStartPos+nMoveCount-1; +/*N*/ for (i=nStartPos; i<=nEndPos; i++) +/*N*/ pItems[i].pCell = pNoteCell; // nicht auf die verschobenen zugreifen +/*N*/ ScAddress aAdr( nCol, 0, nTab ); +/*N*/ ScHint aHint( SC_HINT_DYING, aAdr, NULL ); // areas only +/*N*/ ScAddress& rAddress = aHint.GetAddress(); +/*N*/ for (i=nStartPos; i<=nEndPos; i++) +/*N*/ { +/*N*/ rAddress.SetRow( pItems[i].nRow ); +/*N*/ pDocument->AreaBroadcast( aHint ); +/*N*/ } +/*N*/ delete pNoteCell; +/*N*/ +/*N*/ nCount -= nMoveCount; +/*N*/ memmove( &pItems[nStartPos], &pItems[nStartPos+nMoveCount], +/*N*/ (nCount - nStartPos) * sizeof(ColEntry) ); +/*N*/ pItems[nCount].nRow = 0; +/*N*/ pItems[nCount].pCell = NULL; +/*N*/ } +/*N*/ } +/*N*/ } + + +/*N*/ void ScColumn::UpdateReference( UpdateRefMode eUpdateRefMode, USHORT nCol1, USHORT nRow1, USHORT nTab1, +/*N*/ USHORT nCol2, USHORT nRow2, USHORT nTab2, short nDx, short nDy, short nDz, +/*N*/ ScDocument* pUndoDoc ) +/*N*/ { +/*N*/ if (pItems) +/*N*/ { +/*N*/ ScRange aRange( ScAddress( nCol1, nRow1, nTab1 ), +/*N*/ ScAddress( nCol2, nRow2, nTab2 ) ); +/*N*/ if ( eUpdateRefMode == URM_COPY && nRow1 == nRow2 ) +/*N*/ { // z.B. eine einzelne Zelle aus dem Clipboard eingefuegt +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 /*?*/ USHORT nIndex; +/*N*/ } +/*N*/ else +/*N*/ { +/*?*/ // #90279# For performance reasons two loop bodies instead of +/*?*/ // testing for update mode in each iteration. +/*?*/ // Anyways, this is still a bottleneck on large arrays with few +/*?*/ // formulas cells. +/*?*/ if ( eUpdateRefMode == URM_COPY ) +/*?*/ { +/*?*/ USHORT i; +/*?*/ Search( nRow1, i ); +/*?*/ for ( ; i < nCount; i++ ) +/*?*/ { +/*?*/ USHORT nRow = pItems[i].nRow; +/*?*/ if ( nRow > nRow2 ) +/*?*/ break; +/*?*/ ScBaseCell* pCell = pItems[i].pCell; +/*?*/ if( pCell->GetCellType() == CELLTYPE_FORMULA) +/*?*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 ((ScFormulaCell*)pCell)->UpdateReference( eUpdateRefMode, aRange, nDx, nDy, nDz, pUndoDoc ); +/*?*/ } +/*?*/ } +/*?*/ } +/*?*/ else +/*?*/ { +/*?*/ USHORT i = 0; +/*?*/ for ( ; i < nCount; i++ ) +/*?*/ { +/*?*/ ScBaseCell* pCell = pItems[i].pCell; +/*?*/ if( pCell->GetCellType() == CELLTYPE_FORMULA) +/*?*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 USHORT nRow = pItems[i].nRow; +/*?*/ } +/*?*/ } +/*?*/ } +/*N*/ } +/*N*/ } +/*N*/ } + + + + + + +/*N*/ void ScColumn::UpdateInsertTab( USHORT nTable) +/*N*/ { +/*N*/ if (nTab >= nTable) nTab++; +/*N*/ if( pItems ) +/*N*/ UpdateInsertTabOnlyCells( nTable ); +/*N*/ } + + +/*N*/ void ScColumn::UpdateInsertTabOnlyCells( USHORT nTable) +/*N*/ { +/*N*/ if (pItems) +/*N*/ for (USHORT i = 0; i < nCount; i++) +/*N*/ { +/*N*/ ScFormulaCell* pCell = (ScFormulaCell*) pItems[i].pCell; +/*N*/ if( pCell->GetCellType() == CELLTYPE_FORMULA) +/*N*/ { +/*N*/ USHORT nRow = pItems[i].nRow; +/*N*/ pCell->UpdateInsertTab(nTable); +/*N*/ if ( nRow != pItems[i].nRow ) +/*N*/ Search( nRow, i ); // Listener geloescht/eingefuegt? +/*N*/ } +/*N*/ } +/*N*/ } + + + + +/*N*/ void ScColumn::UpdateDeleteTab( USHORT nTable, BOOL bIsMove, ScColumn* pRefUndo ) +/*N*/ { +/*N*/ if (nTab > nTable) +/*N*/ pAttrArray->SetTab(--nTab); +/*N*/ +/*N*/ if (pItems) +/*N*/ for (USHORT i = 0; i < nCount; i++) +/*N*/ if ( pItems[i].pCell->GetCellType() == CELLTYPE_FORMULA ) +/*N*/ { +/*N*/ USHORT nRow = pItems[i].nRow; +/*N*/ ScFormulaCell* pOld = (ScFormulaCell*)pItems[i].pCell; +/*N*/ +/*N*/ ScFormulaCell* pSave = NULL; +/*N*/ if (pRefUndo) +/*N*/ pSave = (ScFormulaCell*)pOld->Clone( pDocument, +/*N*/ ScAddress( nCol, nRow, nTab ), TRUE ); +/*N*/ +/*N*/ BOOL bChanged = pOld->UpdateDeleteTab(nTable, bIsMove); +/*N*/ if ( nRow != pItems[i].nRow ) +/*N*/ Search( nRow, i ); // Listener geloescht/eingefuegt? +/*N*/ +/*N*/ if (pRefUndo) +/*N*/ { +/*N*/ if (bChanged) +/*N*/ pRefUndo->Insert( nRow, pSave ); +/*N*/ else +/*N*/ delete pSave; +/*N*/ } +/*N*/ } +/*N*/ } + + +/*N*/ void ScColumn::UpdateCompile( BOOL bForceIfNameInUse ) +/*N*/ { +/*N*/ if (pItems) +/*N*/ for (USHORT i = 0; i < nCount; i++) +/*N*/ { +/*N*/ ScFormulaCell* p = (ScFormulaCell*) pItems[i].pCell; +/*N*/ if( p->GetCellType() == CELLTYPE_FORMULA ) +/*N*/ { +/*N*/ USHORT nRow = pItems[i].nRow; +/*N*/ p->UpdateCompile( bForceIfNameInUse ); +/*N*/ if ( nRow != pItems[i].nRow ) +/*?*/ Search( nRow, i ); // Listener geloescht/eingefuegt? +/*N*/ } +/*N*/ } +/*N*/ } + + +/*N*/ void ScColumn::SetTabNo(USHORT nNewTab) +/*N*/ { +/*N*/ nTab = nNewTab; +/*N*/ pAttrArray->SetTab( nNewTab ); +/*N*/ if (pItems) +/*N*/ for (USHORT i = 0; i < nCount; i++) +/*N*/ { +/*N*/ ScFormulaCell* p = (ScFormulaCell*) pItems[i].pCell; +/*N*/ if( p->GetCellType() == CELLTYPE_FORMULA ) +/*?*/ p->aPos.SetTab( nNewTab ); +/*N*/ } +/*N*/ } + + +/*N*/ BOOL ScColumn::IsRangeNameInUse(USHORT nRow1, USHORT nRow2, USHORT nIndex) const +/*N*/ { +/*N*/ BOOL bInUse = FALSE; +/*N*/ if (pItems) +/*N*/ for (USHORT i = 0; !bInUse && (i < nCount); i++) +/*N*/ if ((pItems[i].nRow >= nRow1) && +/*N*/ (pItems[i].nRow <= nRow2) && +/*N*/ (pItems[i].pCell->GetCellType() == CELLTYPE_FORMULA)) +/*N*/ bInUse = ((ScFormulaCell*)pItems[i].pCell)->IsRangeNameInUse(nIndex); +/*N*/ return bInUse; +/*N*/ } + + + + +/*N*/ void ScColumn::SetDirtyVar() +/*N*/ { +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ { +/*N*/ ScFormulaCell* p = (ScFormulaCell*) pItems[i].pCell; +/*N*/ if( p->GetCellType() == CELLTYPE_FORMULA ) +/*N*/ p->SetDirtyVar(); +/*N*/ } +/*N*/ } + + +/*N*/ void ScColumn::SetDirty() +/*N*/ { +/*N*/ // wird nur dokumentweit verwendet, kein FormulaTrack +/*N*/ BOOL bOldAutoCalc = pDocument->GetAutoCalc(); +/*N*/ pDocument->SetAutoCalc( FALSE ); // Mehrfachberechnungen vermeiden +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ { +/*N*/ ScFormulaCell* p = (ScFormulaCell*) pItems[i].pCell; +/*N*/ if( p->GetCellType() == CELLTYPE_FORMULA ) +/*N*/ { +/*N*/ p->SetDirtyVar(); +/*N*/ if ( !pDocument->IsInFormulaTree( p ) ) +/*N*/ pDocument->PutInFormulaTree( p ); +/*N*/ } +/*N*/ } +/*N*/ pDocument->SetAutoCalc( bOldAutoCalc ); +/*N*/ } + + + + +/*N*/ void ScColumn::SetTableOpDirty( const ScRange& rRange ) +/*N*/ { +/*N*/ if ( !pItems || !nCount ) +/*N*/ return ; +/*N*/ BOOL bOldAutoCalc = pDocument->GetAutoCalc(); +/*N*/ pDocument->SetAutoCalc( FALSE ); // no multiple recalculation +/*N*/ USHORT nRow2 = rRange.aEnd.Row(); +/*N*/ ScAddress aPos( nCol, 0, nTab ); +/*N*/ ScHint aHint( SC_HINT_TABLEOPDIRTY, aPos, NULL ); +/*N*/ USHORT nRow, nIndex; +/*N*/ Search( rRange.aStart.Row(), nIndex ); +/*N*/ while ( nIndex < nCount && (nRow = pItems[nIndex].nRow) <= nRow2 ) +/*N*/ { +/*N*/ ScBaseCell* pCell = pItems[nIndex].pCell; +/*N*/ if ( pCell->GetCellType() == CELLTYPE_FORMULA ) +/*N*/ ((ScFormulaCell*)pCell)->SetTableOpDirty(); +/*N*/ else +/*N*/ { +/*N*/ aHint.GetAddress().SetRow( nRow ); +/*N*/ aHint.SetCell( pCell ); +/*N*/ pDocument->Broadcast( aHint ); +/*N*/ } +/*N*/ nIndex++; +/*N*/ } +/*N*/ pDocument->SetAutoCalc( bOldAutoCalc ); +/*N*/ } + + +/*N*/ void ScColumn::SetDirtyAfterLoad() +/*N*/ { +/*N*/ BOOL bOldAutoCalc = pDocument->GetAutoCalc(); +/*N*/ pDocument->SetAutoCalc( FALSE ); // Mehrfachberechnungen vermeiden +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ { +/*N*/ ScFormulaCell* p = (ScFormulaCell*) pItems[i].pCell; +/*N*/ if ( p->GetCellType() == CELLTYPE_FORMULA && p->GetDirty() ) +/*N*/ p->SetDirty(); +/*N*/ // wenn die Zelle durch CalcAfterLoad schon bDirty war, muss +/*N*/ // jetzt noch FormulaTracking stattfinden +/*N*/ } +/*N*/ pDocument->SetAutoCalc( bOldAutoCalc ); +/*N*/ } + + +/*N*/ void ScColumn::SetRelNameDirty() +/*N*/ { +/*N*/ BOOL bOldAutoCalc = pDocument->GetAutoCalc(); +/*N*/ pDocument->SetAutoCalc( FALSE ); // Mehrfachberechnungen vermeiden +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ { +/*N*/ ScFormulaCell* p = (ScFormulaCell*) pItems[i].pCell; +/*N*/ if( p->GetCellType() == CELLTYPE_FORMULA && p->HasRelNameReference() ) +/*N*/ p->SetDirty(); +/*N*/ } +/*N*/ pDocument->SetAutoCalc( bOldAutoCalc ); +/*N*/ } + + +/*N*/ void ScColumn::CalcAll() +/*N*/ { +/*N*/ if (pItems) +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ { +/*N*/ ScBaseCell* pCell = pItems[i].pCell; +/*N*/ if (pCell->GetCellType() == CELLTYPE_FORMULA) +/*N*/ { +/*N*/ #if OSL_DEBUG_LEVEL > 1 +/*N*/ // nach F9 ctrl-F9: ueberprueft die Berechnung per FormulaTree +/*N*/ ScFormulaCell* pFCell = (ScFormulaCell*)pCell; +/*N*/ double nOldVal, nNewVal; +/*N*/ nOldVal = pFCell->GetValue(); +/*N*/ #endif +/*N*/ ((ScFormulaCell*)pCell)->Interpret(); +/*N*/ #if OSL_DEBUG_LEVEL > 1 +/*N*/ if ( pFCell->GetCode()->IsRecalcModeNormal() ) +/*N*/ nNewVal = pFCell->GetValue(); +/*N*/ else +/*N*/ nNewVal = nOldVal; // random(), jetzt() etc. +/*N*/ DBG_ASSERT( nOldVal==nNewVal, "CalcAll: nOldVal != nNewVal" ); +/*N*/ #endif +/*N*/ } +/*N*/ } +/*N*/ } + + +/*N*/ void ScColumn::CompileAll() +/*N*/ { +/*N*/ if (pItems) +/*N*/ for (USHORT i = 0; i < nCount; i++) +/*N*/ { +/*N*/ ScBaseCell* pCell = pItems[i].pCell; +/*N*/ if ( pCell->GetCellType() == CELLTYPE_FORMULA ) +/*N*/ { +/*?*/ USHORT nRow = pItems[i].nRow; +/*?*/ // fuer unbedingtes kompilieren +/*?*/ // bCompile=TRUE und pCode->nError=0 +/*?*/ ((ScFormulaCell*)pCell)->GetCode()->SetError( 0 ); +/*?*/ ((ScFormulaCell*)pCell)->SetCompile( TRUE ); +/*?*/ ((ScFormulaCell*)pCell)->CompileTokenArray(); +/*?*/ if ( nRow != pItems[i].nRow ) +/*?*/ Search( nRow, i ); // Listener geloescht/eingefuegt? +/*N*/ } +/*N*/ } +/*N*/ } + + +/*N*/ void ScColumn::CompileXML( ScProgress& rProgress ) +/*N*/ { +/*N*/ if (pItems) +/*N*/ for (USHORT i = 0; i < nCount; i++) +/*N*/ { +/*N*/ ScBaseCell* pCell = pItems[i].pCell; +/*N*/ if ( pCell->GetCellType() == CELLTYPE_FORMULA ) +/*N*/ { +/*N*/ USHORT nRow = pItems[i].nRow; +/*N*/ ((ScFormulaCell*)pCell)->CompileXML( rProgress ); +/*N*/ if ( nRow != pItems[i].nRow ) +/*N*/ Search( nRow, i ); // Listener geloescht/eingefuegt? +/*N*/ } +/*N*/ } +/*N*/ } + + +/*N*/ void ScColumn::CalcAfterLoad() +/*N*/ { +/*N*/ if (pItems) +/*N*/ for (USHORT i = 0; i < nCount; i++) +/*N*/ { +/*N*/ ScBaseCell* pCell = pItems[i].pCell; +/*N*/ if ( pCell->GetCellType() == CELLTYPE_FORMULA ) +/*N*/ ((ScFormulaCell*)pCell)->CalcAfterLoad(); +/*N*/ } +/*N*/ } + + +/*N*/ void ScColumn::ResetChanged( USHORT nStartRow, USHORT nEndRow ) +/*N*/ { +/*N*/ if (pItems) +/*N*/ { +/*N*/ USHORT nIndex; +/*N*/ Search(nStartRow,nIndex); +/*N*/ while (nIndex<nCount && pItems[nIndex].nRow <= nEndRow) +/*N*/ { +/*N*/ ScBaseCell* pCell = pItems[nIndex].pCell; +/*N*/ if (pCell->GetCellType() == CELLTYPE_FORMULA) +/*N*/ ((ScFormulaCell*)pCell)->ResetChanged(); +/*N*/ ++nIndex; +/*N*/ } +/*N*/ } +/*N*/ } + + +/*N*/ BOOL ScColumn::HasEditCells(USHORT nStartRow, USHORT nEndRow, USHORT& rFirst) const +/*N*/ { +/*N*/ // used in GetOptimalHeight - ambiguous script type counts as edit cell +/*N*/ +/*N*/ USHORT nRow; +/*N*/ USHORT nIndex; +/*N*/ Search(nStartRow,nIndex); +/*N*/ while ( (nIndex < nCount) ? ((nRow=pItems[nIndex].nRow) <= nEndRow) : FALSE ) +/*N*/ { +/*N*/ ScBaseCell* pCell = pItems[nIndex].pCell; +/*N*/ if ( pCell->GetCellType() == CELLTYPE_EDIT || +/*N*/ IsAmbiguousScriptNonZero( pDocument->GetScriptType(nCol, nRow, nTab, pCell) ) ) +/*N*/ { +/*N*/ rFirst = nRow; +/*N*/ return TRUE; +/*N*/ } +/*N*/ ++nIndex; +/*N*/ } +/*N*/ +/*N*/ return FALSE; +/*N*/ } + + + + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_column2.cxx b/binfilter/bf_sc/source/core/data/sc_column2.cxx new file mode 100644 index 000000000000..64275fc797d9 --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_column2.cxx @@ -0,0 +1,1792 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "scitems.hxx" +#define ITEMID_FIELD EE_FEATURE_FIELD + +#include <bf_svx/algitem.hxx> +#include <bf_svx/editobj.hxx> +#include <bf_svx/emphitem.hxx> +#include <bf_svx/fhgtitem.hxx> +#include <bf_svx/forbiddencharacterstable.hxx> +#include <bf_svx/rotmodit.hxx> +#include <bf_svx/scripttypeitem.hxx> +#include <bf_svx/unolingu.hxx> +#include <vcl/outdev.hxx> +#include <math.h> + +#include "cell.hxx" +#include "document.hxx" +#include "attarray.hxx" +#include "patattr.hxx" +#include "cellform.hxx" +#include "rechead.hxx" +#include "editutil.hxx" +#include "subtotal.hxx" +#include "markdata.hxx" +#include "dbcolect.hxx" +#include "bclist.hxx" +namespace binfilter { + +// ----------------------------------------------------------------------- + +// factor from font size to optimal cell height (text width) +#define SC_ROT_BREAK_FACTOR 6 + +// ----------------------------------------------------------------------- + +/*N*/ inline BOOL CellVisible( const ScBaseCell* pCell ) +/*N*/ { +/*N*/ return ( pCell->GetCellType() != CELLTYPE_NOTE || pCell->GetNotePtr() ); +/*N*/ } +/*N*/ +/*N*/ inline BOOL IsAmbiguousScript( BYTE nScript ) +/*N*/ { +/*N*/ //! move to a header file +/*N*/ return ( nScript != SCRIPTTYPE_LATIN && +/*N*/ nScript != SCRIPTTYPE_ASIAN && +/*N*/ nScript != SCRIPTTYPE_COMPLEX ); +/*N*/ } + +// ----------------------------------------------------------------------------------------- + +// +// Datei-Operationen +// + +// ----------------------------------------------------------------------------------------- + +// special handling for non-convertable characters is no longer needed +#if 0 + +// read string from a string cell in original CharSet + + +#endif + +// ----------------------------------------------------------------------------------------- + +/*N*/ void ScColumn::LoadData( SvStream& rStream ) +/*N*/ { +/*N*/ USHORT nNewCount; +/*N*/ USHORT nNewRow; +/*N*/ BYTE nByte; +/*N*/ USHORT nVer = (USHORT) pDocument->GetSrcVersion(); +/*N*/ +/*N*/ ScMultipleReadHeader aHdr( rStream ); +/*N*/ +/*N*/ rStream >> nNewCount; +/*N*/ if ( nNewCount > MAXROW+1 ) // wuerde das Array zu gross? +/*N*/ { +/*?*/ pDocument->SetLostData(); +/*?*/ rStream.SetError( SVSTREAM_FILEFORMAT_ERROR ); +/*?*/ return; +/*N*/ } +/*N*/ +/*N*/ Resize( nNewCount ); // veraendert nCount nicht +/*N*/ for (USHORT i=0; i<nNewCount; i++) +/*N*/ { +/*N*/ rStream >> nNewRow; +/*N*/ rStream >> nByte; +/*N*/ +/*N*/ if ( nNewRow > MAXROW ) // Zeilennummer zu gross? +/*N*/ { +/*?*/ pDocument->SetLostData(); +/*?*/ rStream.SetError( SVSTREAM_FILEFORMAT_ERROR ); +/*?*/ return; +/*N*/ } +/*N*/ +/*N*/ switch ((CellType) nByte) +/*N*/ { +/*N*/ case CELLTYPE_VALUE: +/*N*/ { +/*N*/ ScValueCell* pCell = new ScValueCell( rStream, nVer ); +/*N*/ Append( nNewRow, pCell ); +/*N*/ } +/*N*/ break; +/*N*/ case CELLTYPE_STRING: +/*N*/ { +/*N*/ ScStringCell* pCell = new ScStringCell( rStream, nVer ); +/*N*/ Append( nNewRow, pCell ); +/*N*/ } +/*N*/ break; +/*N*/ case CELLTYPE_SYMBOLS: +/*N*/ { +/*N*/ CharSet eOld = rStream.GetStreamCharSet(); +/*N*/ // convert into true symbol characters +/*N*/ rStream.SetStreamCharSet( RTL_TEXTENCODING_SYMBOL ); +/*N*/ ScStringCell* pCell = new ScStringCell( rStream, nVer ); +/*N*/ Append( nNewRow, pCell ); +/*N*/ rStream.SetStreamCharSet( eOld ); +/*N*/ ScSymbolStringCellEntry * pEntry = new ScSymbolStringCellEntry; +/*N*/ pEntry->pCell = pCell; +/*N*/ pEntry->nRow = nNewRow; +/*N*/ pDocument->GetLoadedSymbolStringCellsList().Insert( +/*N*/ pEntry, LIST_APPEND ); +/*N*/ } +/*N*/ break; +/*N*/ case CELLTYPE_EDIT: +/*N*/ { +/*N*/ ScEditCell* pCell = new ScEditCell( rStream, nVer, pDocument ); +/*N*/ Append( nNewRow, pCell ); +/*N*/ } +/*N*/ break; +/*N*/ case CELLTYPE_FORMULA: +/*N*/ { +/*N*/ ScFormulaCell* pCell = new ScFormulaCell( +/*N*/ pDocument, ScAddress( nCol, nNewRow, nTab ), rStream, aHdr ); +/*N*/ Append( nNewRow, pCell); +/*N*/ } +/*N*/ break; +/*N*/ case CELLTYPE_NOTE: +/*N*/ { +/*N*/ ScNoteCell *pCell = new ScNoteCell( rStream, nVer ); +/*N*/ Append( nNewRow, pCell); +/*N*/ } +/*N*/ break; +/*N*/ default: +/*N*/ DBG_ERROR( "Falscher Zellentyp" ); +/*N*/ rStream.SetError( SVSTREAM_FILEFORMAT_ERROR ); +/*N*/ return; +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ BOOL lcl_RemoveAny( ScDocument* pDocument, USHORT nCol, USHORT nTab ) +/*N*/ { +/*N*/ ScDBCollection* pDBColl = pDocument->GetDBCollection(); +/*N*/ if ( pDBColl ) +/*N*/ { +/*N*/ USHORT nCount = pDBColl->GetCount(); +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ { +/*N*/ ScDBData* pData = (*pDBColl)[i]; +/*N*/ if ( pData->IsStripData() && +/*N*/ pData->HasImportParam() && !pData->HasImportSelection() ) +/*N*/ { +/*?*/ ScRange aDBRange; +/*?*/ pData->GetArea(aDBRange); +/*?*/ if ( nTab == aDBRange.aStart.Tab() && +/*?*/ nCol >= aDBRange.aStart.Col() && nCol <= aDBRange.aEnd.Col() ) +/*?*/ return TRUE; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ return FALSE; +/*N*/ } + +BOOL lcl_RemoveThis( ScDocument* pDocument, USHORT nCol, USHORT nRow, USHORT nTab ) +{ + DBG_BF_ASSERT(0, "STRIP"); //STRIP001 ScDBCollection* pDBColl = pDocument->GetDBCollection(); + + return FALSE; +} + +/*N*/ void ScColumn::SaveData( SvStream& rStream ) const +/*N*/ { +/*N*/ CellType eCellType; +/*N*/ ScBaseCell* pCell; +/*N*/ USHORT i; +/*N*/ ScFontToSubsFontConverter_AutoPtr xFontConverter; +/*N*/ const ULONG nFontConverterFlags = FONTTOSUBSFONT_EXPORT | FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS; +/*N*/ +/*N*/ ScMultipleWriteHeader aHdr( rStream ); +/*N*/ +/*N*/ USHORT nSaveCount = nCount; +/*N*/ +/*N*/ // Zeilen hinter MAXROW abziehen +/*N*/ USHORT nSaveMaxRow = pDocument->GetSrcMaxRow(); +/*N*/ if ( nSaveMaxRow != MAXROW ) +/*N*/ { +/*N*/ if ( nSaveCount && pItems[nSaveCount-1].nRow > nSaveMaxRow ) +/*N*/ { +/*?*/ pDocument->SetLostData(); // Warnung ausgeben +/*?*/ do +/*?*/ --nSaveCount; +/*?*/ while ( nSaveCount && pItems[nSaveCount-1].nRow > nSaveMaxRow ); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // Zellen abziehen, die wegen Import nicht gespeichert werden +/*N*/ BOOL bRemoveAny = lcl_RemoveAny( pDocument, nCol, nTab ); +/*N*/ USHORT nEffCount = nSaveCount; +/*N*/ if ( bRemoveAny ) +/*N*/ { +/*?*/ for (i=0; i<nSaveCount; i++) +/*?*/ if ( lcl_RemoveThis( pDocument, nCol, pItems[i].nRow, nTab ) ) +/*?*/ --nEffCount; +/*?*/ +/*?*/ // String aDbg("Tab ");aDbg+=nTab;aDbg+=" Col ";aDbg+=nCol; +/*?*/ // aDbg+=" Remove ";aDbg+=nSaveCount-nEffCount; DBG_ERROR(aDbg); +/*N*/ } +/*N*/ +/*N*/ rStream << nEffCount; // nEffCount: Zellen, die wirklich gespeichert werden +/*N*/ +/*N*/ ScAttrIterator aIter( pAttrArray, 0, MAXROW ); +/*N*/ USHORT nStt, nEnd; +/*N*/ const ScPatternAttr* pAttr; +/*N*/ do +/*N*/ { +/*N*/ pAttr = aIter.Next( nStt, nEnd ); +/*N*/ } +/*N*/ while( pAttr && !( +/*N*/ (xFontConverter = pAttr->GetSubsFontConverter( nFontConverterFlags )) +/*N*/ || pAttr->IsSymbolFont()) ); +/*N*/ +/*N*/ for (i=0; i<nSaveCount; i++) // nSaveCount: Ende auf MAXROW angepasst +/*N*/ { +/*N*/ USHORT nRow = pItems[i].nRow; +/*N*/ +/*N*/ if ( !bRemoveAny || !lcl_RemoveThis( pDocument, nCol, nRow, nTab ) ) +/*N*/ { +/*N*/ rStream << nRow; +/*N*/ +/*N*/ pCell = pItems[i].pCell; +/*N*/ eCellType = pCell->GetCellType(); +/*N*/ +/*N*/ switch( eCellType ) +/*N*/ { +/*N*/ case CELLTYPE_VALUE: +/*N*/ rStream << (BYTE) eCellType; +/*N*/ ((ScValueCell*)pCell)->Save( rStream ); +/*N*/ break; +/*N*/ case CELLTYPE_STRING: +/*N*/ if( pAttr ) +/*N*/ { +/*N*/ if( nRow > nEnd ) +/*N*/ { +/*N*/ do +/*N*/ { +/*N*/ do +/*N*/ { +/*N*/ pAttr = aIter.Next( nStt, nEnd ); +/*N*/ } +/*N*/ while ( pAttr && nRow > nEnd ); // #99139# skip all formats before this cell +/*N*/ } +/*N*/ while( pAttr && !( +/*N*/ (xFontConverter = pAttr->GetSubsFontConverter( nFontConverterFlags )) +/*N*/ || pAttr->IsSymbolFont()) ); +/*N*/ } +/*N*/ if( pAttr && nRow >= nStt && nRow <= nEnd ) +/*N*/ eCellType = CELLTYPE_SYMBOLS; +/*N*/ } +/*N*/ rStream << (BYTE) eCellType; +/*N*/ if ( eCellType == CELLTYPE_SYMBOLS ) +/*N*/ { +/*N*/ // cell string contains true symbol characters +/*N*/ CharSet eOld = rStream.GetStreamCharSet(); +/*N*/ rStream.SetStreamCharSet( RTL_TEXTENCODING_SYMBOL ); +/*N*/ ((ScStringCell*)pCell)->Save( rStream, xFontConverter ); +/*N*/ rStream.SetStreamCharSet( eOld ); +/*N*/ } +/*N*/ else +/*N*/ ((ScStringCell*)pCell)->Save( rStream ); +/*N*/ break; +/*N*/ case CELLTYPE_EDIT: +/*N*/ rStream << (BYTE) eCellType; +/*N*/ ((ScEditCell*)pCell)->Save( rStream ); +/*N*/ break; +/*N*/ case CELLTYPE_FORMULA: +/*N*/ rStream << (BYTE) eCellType; +/*N*/ ((ScFormulaCell*)pCell)->Save( rStream, aHdr ); +/*N*/ break; +/*N*/ case CELLTYPE_NOTE: +/*N*/ rStream << (BYTE) eCellType; +/*N*/ ((ScNoteCell*)pCell)->Save( rStream ); +/*N*/ break; +/*?*/ default: +/*?*/ { +/*?*/ // #53846# soll zwar nicht vorkommen, aber falls doch, +/*?*/ // eine leere NoteCell speichern, damit das Dokument +/*?*/ // ueberhaupt wieder geladen werden kann. +/*?*/ rStream << (BYTE) CELLTYPE_NOTE; +/*?*/ ScNoteCell aDummyCell; +/*?*/ aDummyCell.Save( rStream ); +/*?*/ DBG_ERROR( "Falscher Zellentyp" ); +/*?*/ } +/*?*/ break; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } + +// ----------------------------------------------------------------------------------------- + +/*N*/ void ScColumn::LoadNotes( SvStream& rStream ) +/*N*/ { +/*N*/ ScReadHeader aHdr(rStream); +/*N*/ +/*N*/ USHORT nNoteCount; +/*N*/ rStream >> nNoteCount; +/*N*/ for (USHORT i=0; i<nNoteCount && rStream.GetError() == SVSTREAM_OK; i++) +/*N*/ { +/*N*/ USHORT nPos; +/*N*/ rStream >> nPos; +/*N*/ if (nPos < nCount) +/*N*/ pItems[nPos].pCell->LoadNote(rStream); +/*N*/ else +/*N*/ { +/*N*/ DBG_ERROR("falsche Pos in ScColumn::LoadNotes"); +/*N*/ rStream.SetError( SVSTREAM_FILEFORMAT_ERROR ); +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ USHORT ScColumn::NoteCount( USHORT nMaxRow ) const +/*N*/ { +/*N*/ USHORT nNoteCount = 0; +/*N*/ USHORT i; +/*N*/ +/*N*/ for (i=0; i<nCount; i++) +/*N*/ if ( pItems[i].pCell->GetNotePtr() && pItems[i].nRow<=nMaxRow ) +/*N*/ ++nNoteCount; +/*N*/ +/*N*/ return nNoteCount; +/*N*/ } + +/*N*/ void ScColumn::SaveNotes( SvStream& rStream ) const +/*N*/ { +/*N*/ USHORT nSaveMaxRow = pDocument->GetSrcMaxRow(); +/*N*/ USHORT i; +/*N*/ +/*N*/ BOOL bRemoveAny = lcl_RemoveAny( pDocument, nCol, nTab ); +/*N*/ USHORT nNoteCount; +/*N*/ if ( bRemoveAny ) +/*N*/ { +/*?*/ // vorher zaehlen, wieviele Notizen es werden +/*?*/ +/*?*/ nNoteCount = 0; +/*?*/ for (i=0; i<nCount; i++) +/*?*/ if ( pItems[i].pCell->GetNotePtr() && pItems[i].nRow<=nSaveMaxRow && +/*?*/ !lcl_RemoveThis( pDocument, nCol, pItems[i].nRow, nTab ) ) +/*?*/ ++nNoteCount; +/*N*/ } +/*N*/ else +/*N*/ nNoteCount = NoteCount(nSaveMaxRow); +/*N*/ +/*N*/ // Speichern +/*N*/ // Als Positionen muessen die Indizes gespeichert werden, die beim Laden entstehen, +/*N*/ // also ohne die weggelassenen Zellen mitzuzaehlen. +/*N*/ +/*N*/ ScWriteHeader aHdr(rStream); +/*N*/ rStream << nNoteCount; +/*N*/ +/*N*/ USHORT nDestPos = 0; +/*N*/ for (i=0; i<nCount && rStream.GetError() == SVSTREAM_OK; i++) +/*N*/ { +/*N*/ USHORT nRow = pItems[i].nRow; +/*N*/ if ( !bRemoveAny || !lcl_RemoveThis( pDocument, nCol, nRow, nTab ) ) +/*N*/ { +/*N*/ const ScPostIt* pNote = pItems[i].pCell->GetNotePtr(); +/*N*/ if ( pNote && nRow <= nSaveMaxRow ) +/*N*/ { +/*N*/ rStream << nDestPos; +/*N*/ rStream << *pNote; +/*N*/ } +/*N*/ ++nDestPos; // nDestPos zaehlt die in SaveData gespeicherten Zellen +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // SetLostData ist schon in SaveData passiert, wenn noetig +/*N*/ } + +// ----------------------------------------------------------------------------------------- + +/*N*/ void ScColumn::CorrectSymbolCells( CharSet eStreamCharSet ) +/*N*/ { +/*N*/ // #99139# find and correct string cells that are formatted with a symbol font, +/*N*/ // but are not in the LoadedSymbolStringCellsList +/*N*/ // (because CELLTYPE_SYMBOLS wasn't written in the file) +/*N*/ +/*N*/ ScFontToSubsFontConverter_AutoPtr xFontConverter; +/*N*/ const ULONG nFontConverterFlags = FONTTOSUBSFONT_EXPORT | FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS; +/*N*/ +/*N*/ BOOL bListInitialized = FALSE; +/*N*/ ScSymbolStringCellEntry* pCurrentEntry = NULL; +/*N*/ +/*N*/ ScAttrIterator aAttrIter( pAttrArray, 0, MAXROW ); +/*N*/ USHORT nStt, nEnd; +/*N*/ const ScPatternAttr* pAttr = aAttrIter.Next( nStt, nEnd ); +/*N*/ while ( pAttr ) +/*N*/ { +/*N*/ if ( (xFontConverter = pAttr->GetSubsFontConverter( nFontConverterFlags )) || +/*N*/ pAttr->IsSymbolFont() ) +/*N*/ { +/*N*/ ScColumnIterator aCellIter( this, nStt, nEnd ); +/*N*/ USHORT nRow; +/*N*/ ScBaseCell* pCell; +/*N*/ while ( aCellIter.Next( nRow, pCell ) ) +/*N*/ { +/*N*/ if ( pCell->GetCellType() == CELLTYPE_STRING ) +/*N*/ { +/*N*/ List& rList = pDocument->GetLoadedSymbolStringCellsList(); +/*N*/ if (!bListInitialized) +/*N*/ { +/*N*/ pCurrentEntry = (ScSymbolStringCellEntry*)rList.First(); +/*N*/ bListInitialized = TRUE; +/*N*/ } +/*N*/ +/*N*/ while ( pCurrentEntry && pCurrentEntry->nRow < nRow ) +/*N*/ pCurrentEntry = (ScSymbolStringCellEntry*)rList.Next(); +/*N*/ +/*N*/ if ( pCurrentEntry && pCurrentEntry->nRow == nRow ) +/*N*/ { +/*N*/ // found +/*N*/ } +/*N*/ else +/*N*/ { +/*?*/ // not in list -> convert and put into list +/*?*/ +/*?*/ ScStringCell* pStrCell = (ScStringCell*)pCell; +/*?*/ String aOldStr; +/*?*/ pStrCell->GetString( aOldStr ); +/*?*/ +/*?*/ // convert back to stream character set (get original data) +/*?*/ ByteString aByteStr( aOldStr, eStreamCharSet ); +/*?*/ +/*?*/ // convert using symbol encoding, as for CELLTYPE_SYMBOLS cells +/*?*/ String aNewStr( aByteStr, RTL_TEXTENCODING_SYMBOL ); +/*?*/ pStrCell->SetString( aNewStr ); +/*?*/ +/*?*/ ScSymbolStringCellEntry * pEntry = new ScSymbolStringCellEntry; +/*?*/ pEntry->pCell = pStrCell; +/*?*/ pEntry->nRow = nRow; +/*?*/ +/*?*/ if ( pCurrentEntry ) +/*?*/ rList.Insert( pEntry ); // before current entry - pCurrentEntry stays valid +/*?*/ else +/*?*/ rList.Insert( pEntry, LIST_APPEND ); // append if already behind last entry +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ pAttr = aAttrIter.Next( nStt, nEnd ); +/*N*/ } +/*N*/ } + +/*N*/ BOOL ScColumn::Load( SvStream& rStream, ScMultipleReadHeader& rHdr ) +/*N*/ { +/*N*/ rHdr.StartEntry(); +/*N*/ while (rHdr.BytesLeft() && rStream.GetError() == SVSTREAM_OK) +/*N*/ { +/*N*/ USHORT nID; +/*N*/ rStream >> nID; +/*N*/ switch (nID) +/*N*/ { +/*N*/ case SCID_COLDATA: +/*N*/ LoadData( rStream ); +/*N*/ break; +/*N*/ case SCID_COLNOTES: +/*N*/ LoadNotes( rStream ); +/*N*/ break; +/*N*/ case SCID_COLATTRIB: +/*N*/ pAttrArray->Load( rStream ); +/*N*/ break; +/*N*/ default: +/*N*/ { +/*N*/ DBG_ERROR("unbekannter Sub-Record in ScColumn::Load"); +/*N*/ ScReadHeader aDummyHeader( rStream ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ rHdr.EndEntry(); +/*N*/ +/*N*/ // #99139# old versions didn't always write CELLTYPE_SYMBOLS for symbol string cells, +/*N*/ // so we have to look for remaining string cells in areas that are formatted with +/*N*/ // symbol font: +/*N*/ CorrectSymbolCells( rStream.GetStreamCharSet() ); +/*N*/ +/*N*/ if ( pDocument->SymbolStringCellsPending() ) +/*N*/ { +/*N*/ ScFontToSubsFontConverter_AutoPtr xFontConverter; +/*N*/ const ULONG nFontConverterFlags = FONTTOSUBSFONT_IMPORT | FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS; +/*N*/ ScSymbolStringCellEntry* pE; +/*N*/ USHORT nStt, nEnd; +/*N*/ +/*N*/ ScAttrIterator aIter( pAttrArray, 0, MAXROW ); +/*N*/ const ScPatternAttr* pAttr = aIter.Next( nStt, nEnd ); +/*N*/ xFontConverter = pAttr->GetSubsFontConverter( nFontConverterFlags ); +/*N*/ +/*N*/ List& rList = pDocument->GetLoadedSymbolStringCellsList(); +/*N*/ for ( pE = (ScSymbolStringCellEntry*) rList.First(); pE; +/*N*/ pE = (ScSymbolStringCellEntry*) rList.Next() ) +/*N*/ { +/*N*/ const ScPatternAttr* pLastAttr = pAttr; +/*N*/ while ( nEnd < pE->nRow ) +/*N*/ { +/*N*/ pAttr = aIter.Next( nStt, nEnd ); +/*N*/ } +/*N*/ if ( pAttr != pLastAttr ) +/*N*/ xFontConverter = pAttr->GetSubsFontConverter( nFontConverterFlags ); +/*N*/ pE->pCell->ConvertFont( xFontConverter ); +/*N*/ delete pE; +/*N*/ } +/*N*/ rList.Clear(); +/*N*/ } +/*N*/ pAttrArray->ConvertFontsAfterLoad(); +/*N*/ +/*N*/ return TRUE; +/*N*/ } + +/*N*/ BOOL ScColumn::Save( SvStream& rStream, ScMultipleWriteHeader& rHdr ) const +/*N*/ { +/*N*/ rHdr.StartEntry(); +/*N*/ +/*N*/ if (!IsEmptyData()) //! Test, ob alles weggelassen wird? +/*N*/ { +/*N*/ rStream << (USHORT) SCID_COLDATA; +/*N*/ SaveData( rStream ); +/*N*/ } +/*N*/ USHORT nNotes = NoteCount(); //! Test, ob alles weggelassen wird? +/*N*/ if (nNotes) +/*N*/ { +/*N*/ rStream << (USHORT) SCID_COLNOTES; +/*N*/ SaveNotes( rStream ); +/*N*/ } +/*N*/ if (!IsEmptyAttr()) +/*N*/ { +/*N*/ rStream << (USHORT) SCID_COLATTRIB; +/*N*/ pAttrArray->Save( rStream ); +/*N*/ } +/*N*/ +/*N*/ rHdr.EndEntry(); +/*N*/ +/*N*/ return TRUE; +/*N*/ } + +// ----------------------------------------------------------------------------------------- + + // GetNeededSize: optimale Hoehe / Breite in Pixeln + +/*N*/ long ScColumn::GetNeededSize( USHORT nRow, OutputDevice* pDev, +/*N*/ double nPPTX, double nPPTY, +/*N*/ const Fraction& rZoomX, const Fraction& rZoomY, +/*N*/ BOOL bWidth, const ScNeededSizeOptions& rOptions ) +/*N*/ { +/*N*/ long nValue=0; +/*N*/ USHORT nIndex; +/*N*/ double nPPT = bWidth ? nPPTX : nPPTY; +/*N*/ if (Search(nRow,nIndex)) +/*N*/ { +/*N*/ const ScPatternAttr* pPattern = rOptions.pPattern; +/*N*/ if (!pPattern) +/*N*/ pPattern = pAttrArray->GetPattern( nRow ); +/*N*/ +/*N*/ // zusammengefasst? +/*N*/ // Merge nicht in bedingter Formatierung +/*N*/ +/*N*/ const ScMergeAttr* pMerge = (const ScMergeAttr*)&pPattern->GetItem(ATTR_MERGE); +/*N*/ const ScMergeFlagAttr* pFlag = (const ScMergeFlagAttr*)&pPattern->GetItem(ATTR_MERGE_FLAG); +/*N*/ +/*N*/ if ( bWidth ) +/*N*/ { +/*N*/ if ( pFlag->IsHorOverlapped() ) +/*N*/ return 0; +/*N*/ if ( rOptions.bSkipMerged && pMerge->GetColMerge() > 1 ) +/*N*/ return 0; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ if ( pFlag->IsVerOverlapped() ) +/*N*/ return 0; +/*N*/ if ( rOptions.bSkipMerged && pMerge->GetRowMerge() > 1 ) +/*N*/ return 0; +/*N*/ } +/*N*/ +/*N*/ // bedingte Formatierung +/*N*/ const SfxItemSet* pCondSet = NULL; +/*N*/ if ( ((const SfxUInt32Item&)pPattern->GetItem(ATTR_CONDITIONAL)).GetValue() ) +/*N*/ pCondSet = pDocument->GetCondResult( nCol, nRow, nTab ); +/*N*/ +/*N*/ // Zeilenumbruch? +/*N*/ +/*N*/ const SfxPoolItem* pCondItem; +/*N*/ SvxCellHorJustify eHorJust; +/*N*/ if (pCondSet && +/*N*/ pCondSet->GetItemState(ATTR_HOR_JUSTIFY, TRUE, &pCondItem) == SFX_ITEM_SET) +/*N*/ eHorJust = (SvxCellHorJustify)((const SvxHorJustifyItem*)pCondItem)->GetValue(); +/*N*/ else +/*N*/ eHorJust = (SvxCellHorJustify)((const SvxHorJustifyItem&) +/*N*/ pPattern->GetItem( ATTR_HOR_JUSTIFY )).GetValue(); +/*N*/ BOOL bBreak; +/*N*/ if ( eHorJust == SVX_HOR_JUSTIFY_BLOCK ) +/*N*/ bBreak = TRUE; +/*N*/ else if ( pCondSet && +/*N*/ pCondSet->GetItemState(ATTR_LINEBREAK, TRUE, &pCondItem) == SFX_ITEM_SET) +/*?*/ bBreak = ((const SfxBoolItem*)pCondItem)->GetValue(); +/*N*/ else +/*N*/ bBreak = ((const SfxBoolItem&)pPattern->GetItem(ATTR_LINEBREAK)).GetValue(); +/*N*/ +/*N*/ // get other attributes from pattern and conditional formatting +/*N*/ +/*N*/ SvxCellOrientation eOrient; +/*N*/ if (pCondSet && +/*N*/ pCondSet->GetItemState(ATTR_ORIENTATION, TRUE, &pCondItem) == SFX_ITEM_SET) +/*?*/ eOrient = (SvxCellOrientation)((const SvxOrientationItem*)pCondItem)->GetValue(); +/*N*/ else +/*N*/ eOrient = (SvxCellOrientation)((const SvxOrientationItem&) +/*N*/ pPattern->GetItem(ATTR_ORIENTATION)).GetValue(); +/*N*/ BOOL bAsianVertical = ( eOrient == SVX_ORIENTATION_STACKED && +/*N*/ ((const SfxBoolItem&)pPattern->GetItem( ATTR_VERTICAL_ASIAN, pCondSet )).GetValue() ); +/*N*/ if ( bAsianVertical ) +/*N*/ bBreak = FALSE; +/*N*/ +/*N*/ if ( bWidth && bBreak ) // after determining bAsianVertical (bBreak may be reset) +/*N*/ return 0; +/*N*/ +/*N*/ long nRotate = 0; +/*N*/ SvxRotateMode eRotMode = SVX_ROTATE_MODE_STANDARD; +/*N*/ if ( eOrient == SVX_ORIENTATION_STANDARD ) +/*N*/ { +/*N*/ if (pCondSet && +/*N*/ pCondSet->GetItemState(ATTR_ROTATE_VALUE, TRUE, &pCondItem) == SFX_ITEM_SET) +/*?*/ nRotate = ((const SfxInt32Item*)pCondItem)->GetValue(); +/*N*/ else +/*N*/ nRotate = ((const SfxInt32Item&)pPattern->GetItem(ATTR_ROTATE_VALUE)).GetValue(); +/*N*/ if ( nRotate ) +/*N*/ { +/*?*/ if (pCondSet && +/*?*/ pCondSet->GetItemState(ATTR_ROTATE_MODE, TRUE, &pCondItem) == SFX_ITEM_SET) +/*?*/ eRotMode = (SvxRotateMode)((const SvxRotateModeItem*)pCondItem)->GetValue(); +/*?*/ else +/*?*/ eRotMode = (SvxRotateMode)((const SvxRotateModeItem&) +/*?*/ pPattern->GetItem(ATTR_ROTATE_MODE)).GetValue(); +/*?*/ +/*?*/ if ( nRotate == 18000 ) +/*?*/ eRotMode = SVX_ROTATE_MODE_STANDARD; // keinen Ueberlauf +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ const SvxMarginItem* pMargin; +/*N*/ if (pCondSet && +/*N*/ pCondSet->GetItemState(ATTR_MARGIN, TRUE, &pCondItem) == SFX_ITEM_SET) +/*?*/ pMargin = (const SvxMarginItem*) pCondItem; +/*N*/ else +/*N*/ pMargin = (const SvxMarginItem*) &pPattern->GetItem(ATTR_MARGIN); +/*N*/ USHORT nIndent = 0; +/*N*/ if ( eHorJust == SVX_HOR_JUSTIFY_LEFT ) +/*N*/ { +/*N*/ if (pCondSet && +/*N*/ pCondSet->GetItemState(ATTR_INDENT, TRUE, &pCondItem) == SFX_ITEM_SET) +/*?*/ nIndent = ((const SfxUInt16Item*)pCondItem)->GetValue(); +/*N*/ else +/*N*/ nIndent = ((const SfxUInt16Item&)pPattern->GetItem(ATTR_INDENT)).GetValue(); +/*N*/ } +/*N*/ +/*N*/ ScBaseCell* pCell = pItems[nIndex].pCell; +/*N*/ BYTE nScript = pDocument->GetScriptType( nCol, nRow, nTab, pCell ); +/*N*/ if (nScript == 0) nScript = ScGlobal::GetDefaultScriptType(); +/*N*/ +/*N*/ // also call SetFont for edit cells, because bGetFont may be set only once +/*N*/ // bGetFont is set also if script type changes +/*N*/ if (rOptions.bGetFont) +/*N*/ { +/*N*/ Fraction aFontZoom = ( eOrient == SVX_ORIENTATION_STANDARD ) ? rZoomX : rZoomY; +/*N*/ Font aFont; +/*N*/ // font color doesn't matter here +/*N*/ pPattern->GetFont( aFont, SC_AUTOCOL_BLACK, pDev, &aFontZoom, pCondSet, nScript ); +/*N*/ pDev->SetFont(aFont); +/*N*/ } +/*N*/ +/*N*/ BOOL bAddMargin = TRUE; +/*N*/ BOOL bEditEngine = ( pCell->GetCellType() == CELLTYPE_EDIT || +/*N*/ eOrient == SVX_ORIENTATION_STACKED || +/*N*/ IsAmbiguousScript( nScript ) ); +/*N*/ +/*N*/ if (!bEditEngine) // direkte Ausgabe +/*N*/ { +/*N*/ String aValStr; +/*N*/ Color* pColor; +/*N*/ SvNumberFormatter* pFormatter = pDocument->GetFormatTable(); +/*N*/ ULONG nFormat = pPattern->GetNumberFormat( pFormatter, pCondSet ); +/*N*/ ScCellFormat::GetString( pCell, nFormat, aValStr, &pColor, +/*N*/ *pFormatter, +/*N*/ TRUE, rOptions.bFormula, ftCheck ); +/*N*/ if (aValStr.Len()) +/*N*/ { +/*N*/ // SetFont ist nach oben verschoben +/*N*/ +/*N*/ Size aSize( pDev->GetTextWidth( aValStr ), pDev->GetTextHeight() ); +/*N*/ if ( eOrient != SVX_ORIENTATION_STANDARD ) +/*N*/ { +/*?*/ long nTemp = aSize.Width(); +/*?*/ aSize.Width() = aSize.Height(); +/*?*/ aSize.Height() = nTemp; +/*N*/ } +/*N*/ else if ( nRotate ) +/*N*/ { +/*?*/ //! unterschiedliche Skalierung X/Y beruecksichtigen +/*?*/ +/*?*/ double nRealOrient = nRotate * F_PI18000; // nRotate sind 1/100 Grad +/*?*/ double nCosAbs = fabs( cos( nRealOrient ) ); +/*?*/ double nSinAbs = fabs( sin( nRealOrient ) ); +/*?*/ long nHeight = (long)( aSize.Height() * nCosAbs + aSize.Width() * nSinAbs ); +/*?*/ long nWidth; +/*?*/ if ( eRotMode == SVX_ROTATE_MODE_STANDARD ) +/*?*/ nWidth = (long)( aSize.Width() * nCosAbs + aSize.Height() * nSinAbs ); +/*?*/ else if ( rOptions.bTotalSize ) +/*?*/ { +/*?*/ nWidth = (long) ( pDocument->GetColWidth( nCol,nTab ) * nPPT ); +/*?*/ bAddMargin = FALSE; +/*?*/ // nur nach rechts: +/*?*/ //! unterscheiden nach Ausrichtung oben/unten (nur Text/ganze Hoehe) +DBG_BF_ASSERT(0, "STRIP"); +/*?*/ } +/*?*/ else +/*?*/ nWidth = (long)( aSize.Height() / nSinAbs ); //! begrenzen? +/*?*/ +/*?*/ if ( bBreak && !rOptions.bTotalSize ) +/*?*/ { +/*?*/ // #47744# limit size for line break +/*?*/ long nCmp = pDev->GetFont().GetSize().Height() * SC_ROT_BREAK_FACTOR; +/*?*/ if ( nHeight > nCmp ) +/*?*/ nHeight = nCmp; +/*?*/ } +/*?*/ +/*?*/ aSize = Size( nWidth, nHeight ); +/*N*/ } +/*N*/ nValue = bWidth ? aSize.Width() : aSize.Height(); +/*N*/ +/*N*/ if ( bAddMargin ) +/*N*/ { +/*N*/ if (bWidth) +/*N*/ { +/*?*/ nValue += (long) ( pMargin->GetLeftMargin() * nPPT ) + +/*?*/ (long) ( pMargin->GetRightMargin() * nPPT ); +/*?*/ if ( nIndent ) +/*?*/ nValue += (long) ( nIndent * nPPT ); +/*N*/ } +/*N*/ else +/*N*/ nValue += (long) ( pMargin->GetTopMargin() * nPPT ) + +/*N*/ (long) ( pMargin->GetBottomMargin() * nPPT ); +/*N*/ } +/*N*/ +/*N*/ // Zeilenumbruch ausgefuehrt ? +/*N*/ +/*N*/ if ( bBreak && !bWidth ) +/*N*/ { +/*N*/ // Test mit EditEngine zur Sicherheit schon bei 90% +/*N*/ // (wegen Rundungsfehlern und weil EditEngine teilweise anders formatiert) +/*N*/ +/*N*/ long nDocPixel = (long) ( ( pDocument->GetColWidth( nCol,nTab ) - +/*N*/ pMargin->GetLeftMargin() - pMargin->GetRightMargin() - +/*N*/ nIndent ) +/*N*/ * nPPT ); +/*N*/ nDocPixel = (nDocPixel * 9) / 10; // zur Sicherheit +/*N*/ if ( aSize.Width() > nDocPixel ) +/*N*/ bEditEngine = TRUE; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if (bEditEngine) +/*N*/ { +/*N*/ // der Font wird bei !bEditEngine nicht jedesmal neu gesetzt +/*N*/ Font aOldFont = pDev->GetFont(); +/*N*/ +/*N*/ MapMode aHMMMode( MAP_100TH_MM, Point(), rZoomX, rZoomY ); +/*N*/ +/*N*/ // am Dokument speichern ? +/*N*/ ScFieldEditEngine* pEngine = pDocument->CreateFieldEditEngine(); +/*N*/ +/*N*/ pEngine->SetUpdateMode( FALSE ); +/*N*/ MapMode aOld = pDev->GetMapMode(); +/*N*/ pDev->SetMapMode( aHMMMode ); +/*N*/ pEngine->SetRefDevice( pDev ); +/*N*/ pEngine->SetForbiddenCharsTable( pDocument->GetForbiddenCharacters() ); +/*N*/ pEngine->SetAsianCompressionMode( pDocument->GetAsianCompression() ); +/*N*/ pEngine->SetKernAsianPunctuation( pDocument->GetAsianKerning() ); +/*N*/ SfxItemSet* pSet = new SfxItemSet( pEngine->GetEmptyItemSet() ); +/*N*/ pPattern->FillEditItemSet( pSet, pCondSet ); +/*N*/ +/*N*/ // no longer needed, are setted with the text (is faster) +/*N*/ // pEngine->SetDefaults( pSet ); +/*N*/ +/*N*/ +/*N*/ Size aPaper = Size( 1000000, 1000000 ); +/*N*/ if ( eOrient==SVX_ORIENTATION_STACKED && !bAsianVertical ) +/*?*/ aPaper.Width() = 1; +/*N*/ else if (bBreak) +/*N*/ { +/*N*/ double fWidthFactor = nPPTX; +/*N*/ BOOL bTextWysiwyg = ( pDev->GetOutDevType() == OUTDEV_PRINTER ); +/*N*/ if ( bTextWysiwyg ) +/*N*/ { +/*N*/ // #95593# if text is formatted for printer, don't use PixelToLogic, +/*N*/ // to ensure the exact same paper width (and same line breaks) as in +/*N*/ // ScEditUtil::GetEditArea, used for output. +/*N*/ +/*N*/ fWidthFactor = HMM_PER_TWIPS; +/*N*/ } +/*N*/ +/*N*/ // use original width for hidden columns: +/*N*/ long nDocWidth = (long) ( pDocument->GetOriginalWidth(nCol,nTab) * fWidthFactor ); +/*N*/ USHORT nColMerge = pMerge->GetColMerge(); +/*N*/ if (nColMerge > 1) +/*N*/ for (USHORT nColAdd=1; nColAdd<nColMerge; nColAdd++) +/*N*/ nDocWidth += (long) ( pDocument->GetColWidth(nCol+nColAdd,nTab) * fWidthFactor ); +/*N*/ nDocWidth -= (long) ( pMargin->GetLeftMargin() * fWidthFactor ) +/*N*/ + (long) ( pMargin->GetRightMargin() * fWidthFactor ) +/*N*/ + 1; // Ausgabebereich ist Breite-1 Pixel (wegen Gitterlinien) +/*N*/ if ( nIndent ) +/*N*/ nDocWidth -= (long) ( nIndent * fWidthFactor ); +/*N*/ +/*N*/ // space for AutoFilter button: 20 * nZoom/100 +/*N*/ if ( pFlag->HasAutoFilter() && !bTextWysiwyg ) +/*?*/ nDocWidth -= (rZoomX.GetNumerator()*20)/rZoomX.GetDenominator(); +/*N*/ +/*N*/ aPaper.Width() = nDocWidth; +/*N*/ +/*N*/ if ( !bTextWysiwyg ) +/*N*/ aPaper = pDev->PixelToLogic( aPaper, aHMMMode ); +/*N*/ } +/*N*/ pEngine->SetPaperSize(aPaper); +/*N*/ +/*N*/ if ( pCell->GetCellType() == CELLTYPE_EDIT ) +/*N*/ { +/*N*/ const EditTextObject* pData; +/*N*/ ((ScEditCell*)pCell)->GetData(pData); +/*N*/ pEngine->SetTextNewDefaults(*pData, pSet); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ Color* pColor; +/*N*/ SvNumberFormatter* pFormatter = pDocument->GetFormatTable(); +/*N*/ ULONG nFormat = pPattern->GetNumberFormat( pFormatter, pCondSet ); +/*N*/ String aString; +/*N*/ ScCellFormat::GetString( pCell, nFormat, aString, &pColor, +/*N*/ *pFormatter, +/*N*/ TRUE, rOptions.bFormula, ftCheck ); +/*N*/ if (aString.Len()) +/*N*/ pEngine->SetTextNewDefaults(aString, pSet); +/*N*/ else +/*?*/ pEngine->SetDefaults(pSet); +/*N*/ } +/*N*/ +/*N*/ BOOL bEngineVertical = pEngine->IsVertical(); +/*N*/ pEngine->SetVertical( bAsianVertical ); +/*N*/ pEngine->SetUpdateMode( TRUE ); +/*N*/ +/*N*/ BOOL bEdWidth = bWidth; +/*N*/ if ( eOrient != SVX_ORIENTATION_STANDARD && eOrient != SVX_ORIENTATION_STACKED ) +/*N*/ bEdWidth = !bEdWidth; +/*N*/ if ( nRotate ) +/*N*/ { +/*?*/ //! unterschiedliche Skalierung X/Y beruecksichtigen +/*?*/ +/*?*/ Size aSize( pEngine->CalcTextWidth(), pEngine->GetTextHeight() ); +/*?*/ double nRealOrient = nRotate * F_PI18000; // nRotate sind 1/100 Grad +/*?*/ double nCosAbs = fabs( cos( nRealOrient ) ); +/*?*/ double nSinAbs = fabs( sin( nRealOrient ) ); +/*?*/ long nHeight = (long)( aSize.Height() * nCosAbs + aSize.Width() * nSinAbs ); +/*?*/ long nWidth; +/*?*/ if ( eRotMode == SVX_ROTATE_MODE_STANDARD ) +/*?*/ nWidth = (long)( aSize.Width() * nCosAbs + aSize.Height() * nSinAbs ); +/*?*/ else if ( rOptions.bTotalSize ) +/*?*/ { +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 /*?*/ nWidth = (long) ( pDocument->GetColWidth( nCol,nTab ) * nPPT ); +/*?*/ } +/*?*/ else +/*?*/ nWidth = (long)( aSize.Height() / nSinAbs ); //! begrenzen? +/*?*/ aSize = Size( nWidth, nHeight ); +/*?*/ +/*?*/ Size aPixSize = pDev->LogicToPixel( aSize, aHMMMode ); +/*?*/ if ( bEdWidth ) +/*?*/ nValue = aPixSize.Width(); +/*?*/ else +/*?*/ { +/*?*/ nValue = aPixSize.Height(); +/*?*/ +/*?*/ if ( bBreak && !rOptions.bTotalSize ) +/*?*/ { +/*?*/ // #47744# limit size for line break +/*?*/ long nCmp = aOldFont.GetSize().Height() * SC_ROT_BREAK_FACTOR; +/*?*/ if ( nValue > nCmp ) +/*?*/ nValue = nCmp; +/*?*/ } +/*?*/ } +/*N*/ } +/*N*/ else if ( bEdWidth ) +/*N*/ { +/*N*/ if (bBreak) +/*N*/ nValue = 0; +/*N*/ else +/*N*/ nValue = pDev->LogicToPixel(Size( pEngine->CalcTextWidth(), 0 ), +/*N*/ aHMMMode).Width(); +/*N*/ } +/*N*/ else // Hoehe +/*N*/ { +/*N*/ nValue = pDev->LogicToPixel(Size( 0, pEngine->GetTextHeight() ), +/*N*/ aHMMMode).Height(); +/*N*/ } +/*N*/ +/*N*/ if ( nValue && bAddMargin ) +/*N*/ { +/*N*/ if (bWidth) +/*N*/ { +/*N*/ nValue += (long) ( pMargin->GetLeftMargin() * nPPT ) + +/*N*/ (long) ( pMargin->GetRightMargin() * nPPT ); +/*N*/ if (nIndent) +/*?*/ nValue += (long) ( nIndent * nPPT ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ nValue += (long) ( pMargin->GetTopMargin() * nPPT ) + +/*N*/ (long) ( pMargin->GetBottomMargin() * nPPT ); +/*N*/ +/*N*/ if ( bAsianVertical && pDev->GetOutDevType() != OUTDEV_PRINTER ) +/*N*/ { +/*N*/ // add 1pt extra (default margin value) for line breaks with SetVertical +/*N*/ nValue += (long) ( 20 * nPPT ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // EditEngine is cached and re-used, so the old vertical flag must be restored +/*N*/ pEngine->SetVertical( bEngineVertical ); +/*N*/ +/*N*/ pDocument->DisposeFieldEditEngine(pEngine); +/*N*/ +/*N*/ pDev->SetMapMode( aOld ); +/*N*/ pDev->SetFont( aOldFont ); +/*N*/ } +/*N*/ +/*N*/ if (bWidth) +/*N*/ { +/*N*/ // Platz fuer Autofilter-Button +/*N*/ // 20 * nZoom/100 +/*N*/ // bedingte Formatierung hier nicht interessant +/*N*/ +/*N*/ INT16 nFlags = ((const ScMergeFlagAttr&)pPattern->GetItem(ATTR_MERGE_FLAG)).GetValue(); +/*N*/ if (nFlags & SC_MF_AUTO) +/*?*/ nValue += (rZoomX.GetNumerator()*20)/rZoomX.GetDenominator(); +/*N*/ } +/*N*/ } +/*N*/ return nValue; +/*N*/ } + +/*N*/ long ScColumn::GetSimpleTextNeededSize( USHORT nIndex, OutputDevice* pDev, +/*N*/ BOOL bWidth ) +/*N*/ { +/*N*/ long nValue=0; +/*N*/ if ( nIndex < nCount ) +/*N*/ { +/*N*/ USHORT nRow = pItems[nIndex].nRow; +/*N*/ const ScPatternAttr* pPattern = pAttrArray->GetPattern( nRow ); +/*N*/ ScBaseCell* pCell = pItems[nIndex].pCell; +/*N*/ String aValStr; +/*N*/ Color* pColor; +/*N*/ SvNumberFormatter* pFormatter = pDocument->GetFormatTable(); +/*N*/ ULONG nFormat = pPattern->GetNumberFormat( pFormatter ); +/*N*/ ScCellFormat::GetString( pCell, nFormat, aValStr, &pColor, +/*N*/ *pFormatter, TRUE, FALSE, ftCheck ); +/*N*/ if ( aValStr.Len() ) +/*N*/ { +/*N*/ if ( bWidth ) +/*N*/ nValue = pDev->GetTextWidth( aValStr ); +/*N*/ else +/*?*/ nValue = pDev->GetTextHeight(); +/*N*/ } +/*N*/ } +/*N*/ return nValue; +/*N*/ } + +/*N*/ USHORT ScColumn::GetOptimalColWidth( OutputDevice* pDev, double nPPTX, double nPPTY, +/*N*/ const Fraction& rZoomX, const Fraction& rZoomY, +/*N*/ BOOL bFormula, USHORT nOldWidth, +/*N*/ const ScMarkData* pMarkData, +/*N*/ BOOL bSimpleTextImport ) +/*N*/ { +/*N*/ if (nCount == 0) +/*N*/ return nOldWidth; +/*N*/ +/*N*/ USHORT nWidth = (USHORT) (nOldWidth * nPPTX); +/*N*/ BOOL bFound = FALSE; +/*N*/ +/*N*/ USHORT nIndex; +/*N*/ ScMarkedDataIter aDataIter(this, pMarkData, TRUE); +/*N*/ if ( bSimpleTextImport ) +/*N*/ { // alles eins bis auf NumberFormate +/*N*/ const ScPatternAttr* pPattern = GetPattern( 0 ); +/*N*/ Font aFont; +/*N*/ // font color doesn't matter here +/*N*/ pPattern->GetFont( aFont, SC_AUTOCOL_BLACK, pDev, &rZoomX, NULL ); +/*N*/ pDev->SetFont( aFont ); +/*N*/ const SvxMarginItem* pMargin = (const SvxMarginItem*) &pPattern->GetItem(ATTR_MARGIN); +/*N*/ long nMargin = (long) ( pMargin->GetLeftMargin() * nPPTX ) + +/*N*/ (long) ( pMargin->GetRightMargin() * nPPTX ); +/*N*/ +/*N*/ while (aDataIter.Next( nIndex )) +/*N*/ { +/*N*/ USHORT nThis = (USHORT) (GetSimpleTextNeededSize( nIndex, pDev, +/*N*/ TRUE ) + nMargin); +/*N*/ if (nThis) +/*N*/ { +/*N*/ if (nThis>nWidth || !bFound) +/*N*/ { +/*N*/ nWidth = nThis; +/*N*/ bFound = TRUE; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*?*/ ScNeededSizeOptions aOptions; +/*?*/ aOptions.bFormula = bFormula; +/*?*/ const ScPatternAttr* pOldPattern = NULL; +/*?*/ BYTE nOldScript = 0; +/*?*/ +/*?*/ while (aDataIter.Next( nIndex )) +/*?*/ { +/*?*/ USHORT nRow = pItems[nIndex].nRow; +/*?*/ +/*?*/ BYTE nScript = pDocument->GetScriptType( nCol, nRow, nTab, pItems[nIndex].pCell ); +/*?*/ if (nScript == 0) nScript = ScGlobal::GetDefaultScriptType(); +/*?*/ +/*?*/ const ScPatternAttr* pPattern = GetPattern( nRow ); +/*?*/ aOptions.pPattern = pPattern; +/*?*/ aOptions.bGetFont = (pPattern != pOldPattern || nScript != nOldScript); +/*?*/ USHORT nThis = (USHORT) GetNeededSize( nRow, pDev, nPPTX, nPPTY, +/*?*/ rZoomX, rZoomY, TRUE, aOptions ); +/*?*/ pOldPattern = pPattern; +/*?*/ if (nThis) +/*?*/ { +/*?*/ if (nThis>nWidth || !bFound) +/*?*/ { +/*?*/ nWidth = nThis; +/*?*/ bFound = TRUE; +/*?*/ } +/*?*/ } +/*?*/ } +/*N*/ } +/*N*/ +/*N*/ if (bFound) +/*N*/ { +/*N*/ nWidth += 2; +/*N*/ USHORT nTwips = (USHORT) (nWidth / nPPTX); +/*N*/ return nTwips; +/*N*/ } +/*N*/ else +/*N*/ return nOldWidth; +/*N*/ } + +/*N*/ USHORT lcl_GetAttribHeight( const ScPatternAttr& rPattern, USHORT nFontHeightId ) +/*N*/ { +/*N*/ USHORT nHeight = (USHORT) ((const SvxFontHeightItem&) rPattern.GetItem(nFontHeightId)).GetHeight(); +/*N*/ const SvxMarginItem* pMargin = (const SvxMarginItem*) &rPattern.GetItem(ATTR_MARGIN); +/*N*/ nHeight += nHeight / 5; +/*N*/ // gibt bei 10pt 240 +/*N*/ +/*N*/ if ( ((const SvxEmphasisMarkItem&)rPattern. +/*N*/ GetItem(ATTR_FONT_EMPHASISMARK)).GetEmphasisMark() != EMPHASISMARK_NONE ) +/*N*/ { +/*N*/ // add height for emphasis marks +/*N*/ //! font metrics should be used instead +/*N*/ nHeight += nHeight / 4; +/*N*/ } +/*N*/ +/*N*/ if ( nHeight + 240 > ScGlobal::nDefFontHeight ) +/*N*/ { +/*N*/ nHeight += ScGlobal::nDefFontHeight; +/*N*/ nHeight -= 240; +/*N*/ } +/*N*/ +/*N*/ // Standard-Hoehe: TextHeight + Raender - 23 +/*N*/ // -> 257 unter Windows +/*N*/ +/*N*/ if (nHeight > STD_ROWHEIGHT_DIFF) +/*N*/ nHeight -= STD_ROWHEIGHT_DIFF; +/*N*/ +/*N*/ nHeight += pMargin->GetTopMargin() + pMargin->GetBottomMargin(); +/*N*/ +/*N*/ return nHeight; +/*N*/ } + +// pHeight in Twips +// nMinHeight, nMinStart zur Optimierung: ab nRow >= nMinStart ist mindestens nMinHeight +// (wird nur bei bStdAllowed ausgewertet) + +/*N*/ void ScColumn::GetOptimalHeight( USHORT nStartRow, USHORT nEndRow, USHORT* pHeight, +/*N*/ OutputDevice* pDev, +/*N*/ double nPPTX, double nPPTY, +/*N*/ const Fraction& rZoomX, const Fraction& rZoomY, +/*N*/ BOOL bShrink, USHORT nMinHeight, USHORT nMinStart ) +/*N*/ { +/*N*/ ScAttrIterator aIter( pAttrArray, nStartRow, nEndRow ); +/*N*/ +/*N*/ USHORT nStart; +/*N*/ USHORT nEnd; +/*N*/ USHORT nEditPos = 0; +/*N*/ USHORT nNextEnd = 0; +/*N*/ +/*N*/ // bei bedingter Formatierung werden immer die einzelnen Zellen angesehen +/*N*/ +/*N*/ const ScPatternAttr* pPattern = aIter.Next(nStart,nEnd); +/*N*/ while ( pPattern ) +/*N*/ { +/*N*/ const ScMergeAttr* pMerge = (const ScMergeAttr*)&pPattern->GetItem(ATTR_MERGE); +/*N*/ const ScMergeFlagAttr* pFlag = (const ScMergeFlagAttr*)&pPattern->GetItem(ATTR_MERGE_FLAG); +/*N*/ if ( pMerge->GetRowMerge() > 1 || pFlag->IsOverlapped() ) +/*N*/ { +/*N*/ // nix - vertikal bei der zusammengefassten und den ueberdeckten, +/*N*/ // horizontal nur bei den ueberdeckten (unsichtbaren) - +/*N*/ // eine nur horizontal zusammengefasste wird aber beruecksichtigt +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ USHORT nRow; +/*N*/ BOOL bStdAllowed = ((const SvxOrientationItem&) pPattern->GetItem(ATTR_ORIENTATION)). +/*N*/ GetValue() == (USHORT) SVX_ORIENTATION_STANDARD; +/*N*/ BOOL bStdOnly = FALSE; +/*N*/ if (bStdAllowed) +/*N*/ { +/*N*/ BOOL bBreak = ((SfxBoolItem&)pPattern->GetItem(ATTR_LINEBREAK)).GetValue() || +/*N*/ ((SvxCellHorJustify)((const SvxHorJustifyItem&)pPattern-> +/*N*/ GetItem( ATTR_HOR_JUSTIFY )).GetValue() == +/*N*/ SVX_HOR_JUSTIFY_BLOCK); +/*N*/ bStdOnly = !bBreak; +/*N*/ +/*N*/ // bedingte Formatierung: Zellen durchgehen +/*N*/ if ( bStdOnly && ((const SfxUInt32Item&)pPattern-> +/*N*/ GetItem(ATTR_CONDITIONAL)).GetValue() ) +/*N*/ bStdOnly = FALSE; +/*N*/ +/*N*/ // gedrehter Text: Zellen durchgehen +/*N*/ if ( bStdOnly && ((const SfxInt32Item&)pPattern-> +/*N*/ GetItem(ATTR_ROTATE_VALUE)).GetValue() ) +/*N*/ bStdOnly = FALSE; +/*N*/ } +/*N*/ +/*N*/ if (bStdOnly) +/*N*/ if (HasEditCells(nStart,nEnd,nEditPos)) // includes mixed script types +/*N*/ { +/*N*/ if (nEditPos == nStart) +/*N*/ { +/*N*/ bStdOnly = FALSE; +/*N*/ if (nEnd > nEditPos) +/*N*/ nNextEnd = nEnd; +/*N*/ nEnd = nEditPos; // einzeln ausrechnen +/*N*/ bStdAllowed = FALSE; // wird auf jeden Fall per Zelle berechnet +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ nNextEnd = nEnd; +/*N*/ nEnd = nEditPos - 1; // Standard - Teil +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if (bStdAllowed) +/*N*/ { +/*N*/ USHORT nLatHeight = 0; +/*N*/ USHORT nCjkHeight = 0; +/*N*/ USHORT nCtlHeight = 0; +/*N*/ USHORT nDefHeight; +/*N*/ BYTE nDefScript = ScGlobal::GetDefaultScriptType(); +/*N*/ if ( nDefScript == SCRIPTTYPE_ASIAN ) +/*N*/ nDefHeight = nCjkHeight = lcl_GetAttribHeight( *pPattern, ATTR_CJK_FONT_HEIGHT ); +/*N*/ else if ( nDefScript == SCRIPTTYPE_COMPLEX ) +/*?*/ nDefHeight = nCtlHeight = lcl_GetAttribHeight( *pPattern, ATTR_CTL_FONT_HEIGHT ); +/*N*/ else +/*?*/ nDefHeight = nLatHeight = lcl_GetAttribHeight( *pPattern, ATTR_FONT_HEIGHT ); +/*N*/ +/*N*/ // if everything below is already larger, the loop doesn't have to +/*N*/ // be run again +/*N*/ USHORT nStdEnd = nEnd; +/*N*/ if ( nDefHeight <= nMinHeight && nStdEnd >= nMinStart ) +/*N*/ nStdEnd = nMinStart ? nMinStart-1 : 0; +/*N*/ +/*N*/ for (nRow=nStart; nRow<=nStdEnd; nRow++) +/*N*/ if (nDefHeight > pHeight[nRow-nStartRow]) +/*N*/ pHeight[nRow-nStartRow] = nDefHeight; +/*N*/ +/*N*/ if ( bStdOnly ) +/*N*/ { +/*N*/ // if cells are not handled individually below, +/*N*/ // check for cells with different script type +/*N*/ +/*N*/ USHORT nIndex; +/*N*/ Search(nStart,nIndex); +/*N*/ while ( nIndex < nCount && (nRow=pItems[nIndex].nRow) <= nEnd ) +/*N*/ { +/*N*/ BYTE nScript = pDocument->GetScriptType( nCol, nRow, nTab, pItems[nIndex].pCell ); +/*N*/ if ( nScript != nDefScript ) +/*N*/ { +/*N*/ if ( nScript == SCRIPTTYPE_ASIAN ) +/*N*/ { +/*?*/ if ( nCjkHeight == 0 ) +/*?*/ nCjkHeight = lcl_GetAttribHeight( *pPattern, ATTR_CJK_FONT_HEIGHT ); +/*?*/ if (nCjkHeight > pHeight[nRow-nStartRow]) +/*?*/ pHeight[nRow-nStartRow] = nCjkHeight; +/*N*/ } +/*N*/ else if ( nScript == SCRIPTTYPE_COMPLEX ) +/*N*/ { +/*?*/ if ( nCtlHeight == 0 ) +/*?*/ nCtlHeight = lcl_GetAttribHeight( *pPattern, ATTR_CTL_FONT_HEIGHT ); +/*?*/ if (nCtlHeight > pHeight[nRow-nStartRow]) +/*?*/ pHeight[nRow-nStartRow] = nCtlHeight; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ if ( nLatHeight == 0 ) +/*N*/ nLatHeight = lcl_GetAttribHeight( *pPattern, ATTR_FONT_HEIGHT ); +/*N*/ if (nLatHeight > pHeight[nRow-nStartRow]) +/*N*/ pHeight[nRow-nStartRow] = nLatHeight; +/*N*/ } +/*N*/ } +/*N*/ ++nIndex; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if (!bStdOnly) // belegte Zellen suchen +/*N*/ { +/*N*/ ScNeededSizeOptions aOptions; +/*N*/ +/*N*/ USHORT nIndex; +/*N*/ Search(nStart,nIndex); +/*N*/ while ( (nIndex < nCount) ? ((nRow=pItems[nIndex].nRow) <= nEnd) : FALSE ) +/*N*/ { +/*N*/ // Zellhoehe nur berechnen, wenn sie spaeter auch gebraucht wird (#37928#) +/*N*/ +/*N*/ if ( bShrink || !(pDocument->GetRowFlags(nRow, nTab) & CR_MANUALSIZE) ) +/*N*/ { +/*N*/ aOptions.pPattern = pPattern; +/*N*/ USHORT nHeight = (USHORT) +/*N*/ ( GetNeededSize( nRow, pDev, nPPTX, nPPTY, +/*N*/ rZoomX, rZoomY, FALSE, aOptions ) / nPPTY ); +/*N*/ if (nHeight > pHeight[nRow-nStartRow]) +/*N*/ pHeight[nRow-nStartRow] = nHeight; +/*N*/ } +/*N*/ ++nIndex; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if (nNextEnd) +/*N*/ { +/*N*/ nStart = nEnd + 1; +/*N*/ nEnd = nNextEnd; +/*N*/ nNextEnd = 0; +/*N*/ } +/*N*/ else +/*N*/ pPattern = aIter.Next(nStart,nEnd); +/*N*/ } +/*N*/ } + + +// ========================================================================================= + + + +// ========================================================================================= + +/*N*/ BOOL ScColumn::TestTabRefAbs(USHORT nTable) +/*N*/ { +/*N*/ BOOL bRet = FALSE; +/*N*/ if (pItems) +/*N*/ for (USHORT i = 0; i < nCount; i++) +/*N*/ if ( pItems[i].pCell->GetCellType() == CELLTYPE_FORMULA ) +/*?*/ if (((ScFormulaCell*)pItems[i].pCell)->TestTabRefAbs(nTable)) +/*?*/ bRet = TRUE; +/*N*/ return bRet; +/*N*/ } + +// ========================================================================================= + +/*N*/ ScColumnIterator::ScColumnIterator( const ScColumn* pCol, USHORT nStart, USHORT nEnd ) : +/*N*/ pColumn( pCol ), +/*N*/ nTop( nStart ), +/*N*/ nBottom( nEnd ) +/*N*/ { +/*N*/ pColumn->Search( nTop, nPos ); +/*N*/ } + +/*N*/ ScColumnIterator::~ScColumnIterator() +/*N*/ { +/*N*/ } + +/*N*/ BOOL ScColumnIterator::Next( USHORT& rRow, ScBaseCell*& rpCell ) +/*N*/ { +/*N*/ if ( nPos < pColumn->nCount ) +/*N*/ { +/*N*/ rRow = pColumn->pItems[nPos].nRow; +/*N*/ if ( rRow <= nBottom ) +/*N*/ { +/*N*/ rpCell = pColumn->pItems[nPos].pCell; +/*N*/ ++nPos; +/*N*/ return TRUE; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ rRow = 0; +/*N*/ rpCell = NULL; +/*N*/ return FALSE; +/*N*/ } + +// ----------------------------------------------------------------------------------------- + +/*N*/ ScMarkedDataIter::ScMarkedDataIter( const ScColumn* pCol, const ScMarkData* pMarkData, +/*N*/ BOOL bAllIfNone ) : +/*N*/ pColumn( pCol ), +/*N*/ pMarkIter( NULL ), +/*N*/ bNext( TRUE ), +/*N*/ bAll( bAllIfNone ) +/*N*/ { +/*N*/ if (pMarkData && pMarkData->IsMultiMarked()) +/*N*/ pMarkIter = new ScMarkArrayIter( pMarkData->GetArray() + pCol->GetCol() ); +/*N*/ } + +/*N*/ ScMarkedDataIter::~ScMarkedDataIter() +/*N*/ { +/*N*/ delete pMarkIter; +/*N*/ } + +/*N*/ BOOL ScMarkedDataIter::Next( USHORT& rIndex ) +/*N*/ { +/*N*/ BOOL bFound = FALSE; +/*N*/ do +/*N*/ { +/*N*/ if (bNext) +/*N*/ { +/*N*/ if (!pMarkIter || !pMarkIter->Next( nTop, nBottom )) +/*N*/ { +/*N*/ if (bAll) // ganze Spalte +/*N*/ { +/*N*/ nTop = 0; +/*N*/ nBottom = MAXROW; +/*N*/ } +/*N*/ else +/*N*/ return FALSE; +/*N*/ } +/*N*/ pColumn->Search( nTop, nPos ); +/*N*/ bNext = FALSE; +/*N*/ bAll = FALSE; // nur beim ersten Versuch +/*N*/ } +/*N*/ +/*N*/ if ( nPos >= pColumn->nCount ) +/*N*/ return FALSE; +/*N*/ +/*N*/ if ( pColumn->pItems[nPos].nRow <= nBottom ) +/*N*/ bFound = TRUE; +/*N*/ else +/*N*/ bNext = TRUE; +/*N*/ } +/*N*/ while (!bFound); +/*N*/ +/*N*/ rIndex = nPos++; +/*N*/ return TRUE; +/*N*/ } + + +//------------ + +/*N*/ BOOL ScColumn::IsEmptyData() const +/*N*/ { +/*N*/ return (nCount == 0); +/*N*/ } + +/*N*/ BOOL ScColumn::IsEmptyVisData(BOOL bNotes) const +/*N*/ { +/*N*/ if (!pItems || nCount == 0) +/*N*/ return TRUE; +/*N*/ else +/*N*/ { +/*N*/ BOOL bVisData = FALSE; +/*N*/ USHORT i; +/*N*/ for (i=0; i<nCount && !bVisData; i++) +/*N*/ { +/*N*/ ScBaseCell* pCell = pItems[i].pCell; +/*N*/ if ( pCell->GetCellType() != CELLTYPE_NOTE || (bNotes && pCell->GetNotePtr()) ) +/*N*/ bVisData = TRUE; +/*N*/ } +/*N*/ return !bVisData; +/*N*/ } +/*N*/ } + + +/*N*/ USHORT ScColumn::GetLastVisDataPos(BOOL bNotes) const +/*N*/ { +/*N*/ USHORT nRet = 0; +/*N*/ if (pItems) +/*N*/ { +/*N*/ USHORT i; +/*N*/ BOOL bFound = FALSE; +/*N*/ for (i=nCount; i>0 && !bFound; ) +/*N*/ { +/*N*/ --i; +/*N*/ ScBaseCell* pCell = pItems[i].pCell; +/*N*/ if ( pCell->GetCellType() != CELLTYPE_NOTE || (bNotes && pCell->GetNotePtr()) ) +/*N*/ { +/*N*/ bFound = TRUE; +/*N*/ nRet = pItems[i].nRow; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ return nRet; +/*N*/ } + +/*N*/ USHORT ScColumn::GetFirstVisDataPos(BOOL bNotes) const +/*N*/ { +/*N*/ USHORT nRet = 0; +/*N*/ if (pItems) +/*N*/ { +/*N*/ USHORT i; +/*N*/ BOOL bFound = FALSE; +/*N*/ for (i=0; i<nCount && !bFound; i++) +/*N*/ { +/*N*/ ScBaseCell* pCell = pItems[i].pCell; +/*N*/ if ( pCell->GetCellType() != CELLTYPE_NOTE || (bNotes && pCell->GetNotePtr()) ) +/*N*/ { +/*N*/ bFound = TRUE; +/*N*/ nRet = pItems[i].nRow; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ return nRet; +/*N*/ } + + +/*N*/ BOOL ScColumn::IsEmptyAttr() const +/*N*/ { +/*N*/ if (pAttrArray) +/*N*/ return pAttrArray->IsEmpty(); +/*N*/ else +/*N*/ return TRUE; +/*N*/ } + +/*N*/ BOOL ScColumn::IsEmpty() const +/*N*/ { +/*N*/ return (IsEmptyData() && IsEmptyAttr()); +/*N*/ } + + + + + + + + +/*N*/ BOOL ScColumn::HasDataAt(USHORT nRow) const +/*N*/ { +/* USHORT nIndex; + return Search( nRow, nIndex ); +*/ +/*N*/ // immer nur sichtbare interessant ? +/*N*/ //! dann HasVisibleDataAt raus +/*N*/ +/*N*/ USHORT nIndex; +/*N*/ if (Search(nRow, nIndex)) +/*N*/ if (CellVisible(pItems[nIndex].pCell)) +/*N*/ return TRUE; +/*N*/ +/*N*/ return FALSE; +/*N*/ +/*N*/ } + + + + +/*N*/ BOOL ScColumn::IsAllAttrEqual( const ScColumn& rCol, USHORT nStartRow, USHORT nEndRow ) const +/*N*/ { +/*N*/ if (pAttrArray && rCol.pAttrArray) +/*N*/ return pAttrArray->IsAllEqual( *rCol.pAttrArray, nStartRow, nEndRow ); +/*N*/ else +/*N*/ return !pAttrArray && !rCol.pAttrArray; +/*N*/ } + +/*N*/ BOOL ScColumn::IsVisibleAttrEqual( const ScColumn& rCol, USHORT nStartRow, USHORT nEndRow ) const +/*N*/ { +/*N*/ if (pAttrArray && rCol.pAttrArray) +/*N*/ return pAttrArray->IsVisibleEqual( *rCol.pAttrArray, nStartRow, nEndRow ); +/*N*/ else +/*N*/ return !pAttrArray && !rCol.pAttrArray; +/*N*/ } + +/*N*/ BOOL ScColumn::HasVisibleAttr( USHORT& rFirstRow, USHORT& rLastRow, BOOL bSkipFirst ) const +/*N*/ { +/*N*/ if (pAttrArray) +/*N*/ return pAttrArray->HasVisibleAttr(rFirstRow,rLastRow,bSkipFirst); +/*N*/ else +/*N*/ return FALSE; +/*N*/ } + + + +/*N*/ void ScColumn::StartListening( SfxListener& rLst, USHORT nRow ) +/*N*/ { +/*N*/ ScBroadcasterList* pBC = NULL; +/*N*/ ScBaseCell* pCell; +/*N*/ +/*N*/ USHORT nIndex; +/*N*/ if (Search(nRow,nIndex)) +/*N*/ { +/*N*/ pCell = pItems[nIndex].pCell; +/*N*/ pBC = pCell->GetBroadcaster(); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ pCell = new ScNoteCell; +/*N*/ Insert(nRow, pCell); +/*N*/ } +/*N*/ +/*N*/ if (!pBC) +/*N*/ { +/*N*/ pBC = new ScBroadcasterList; +/*N*/ pCell->SetBroadcaster(pBC); +/*N*/ } +/*N*/ // rLst.StartListening(*pBC,TRUE); +/*N*/ pBC->StartBroadcasting( rLst, TRUE ); +/*N*/ } + +/*N*/ void ScColumn::MoveListeners( ScBroadcasterList& rSource, USHORT nDestRow ) +/*N*/ { +/*N*/ ScBroadcasterList* pBC = NULL; +/*N*/ ScBaseCell* pCell; +/*N*/ +/*N*/ USHORT nIndex; +/*N*/ if (Search(nDestRow,nIndex)) +/*N*/ { +/*N*/ pCell = pItems[nIndex].pCell; +/*N*/ pBC = pCell->GetBroadcaster(); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ pCell = new ScNoteCell; +/*N*/ Insert(nDestRow, pCell); +/*N*/ } +/*N*/ +/*N*/ if (!pBC) +/*N*/ { +/*N*/ pBC = new ScBroadcasterList; +/*N*/ pCell->SetBroadcaster(pBC); +/*N*/ } +/*N*/ +/*N*/ rSource.MoveListenersTo( *pBC ); +/*N*/ } + +/*N*/ void ScColumn::EndListening( SfxListener& rLst, USHORT nRow ) +/*N*/ { +/*N*/ USHORT nIndex; +/*N*/ if (Search(nRow,nIndex)) +/*N*/ { +/*N*/ ScBaseCell* pCell = pItems[nIndex].pCell; +/*N*/ ScBroadcasterList* pBC = pCell->GetBroadcaster(); +/*N*/ if (pBC) +/*N*/ { +/*N*/ // rLst.EndListening(*pBC); +/*N*/ pBC->EndBroadcasting(rLst); +/*N*/ +/*N*/ if (!pBC->HasListeners()) +/*N*/ { +/*N*/ if (pCell->GetCellType() == CELLTYPE_NOTE && !pCell->GetNotePtr()) +/*N*/ DeleteAtIndex(nIndex); +/*N*/ else +/*N*/ pCell->SetBroadcaster(NULL); +/*N*/ } +/*N*/ } +/*N*/ // else +/*N*/ // DBG_ERROR("ScColumn::EndListening - kein Broadcaster"); +/*N*/ } +/*N*/ // else +/*N*/ // DBG_ERROR("ScColumn::EndListening - keine Zelle"); +/*N*/ } + + +/*N*/ void ScColumn::CompileDBFormula( BOOL bCreateFormulaString ) +/*N*/ { +/*N*/ if (pItems) +/*N*/ for (USHORT i = 0; i < nCount; i++) +/*N*/ { +/*N*/ ScBaseCell* pCell = pItems[i].pCell; +/*N*/ if ( pCell->GetCellType() == CELLTYPE_FORMULA ) +/*N*/ ((ScFormulaCell*) pCell)->CompileDBFormula( bCreateFormulaString ); +/*N*/ } +/*N*/ } + +/*N*/ void ScColumn::CompileNameFormula( BOOL bCreateFormulaString ) +/*N*/ { +/*N*/ if (pItems) +/*N*/ for (USHORT i = 0; i < nCount; i++) +/*N*/ { +/*N*/ ScBaseCell* pCell = pItems[i].pCell; +/*N*/ if ( pCell->GetCellType() == CELLTYPE_FORMULA ) +/*N*/ ((ScFormulaCell*) pCell)->CompileNameFormula( bCreateFormulaString ); +/*N*/ } +/*N*/ } + +/*N*/ void ScColumn::CompileColRowNameFormula() +/*N*/ { +/*N*/ if (pItems) +/*N*/ for (USHORT i = 0; i < nCount; i++) +/*N*/ { +/*N*/ ScBaseCell* pCell = pItems[i].pCell; +/*N*/ if ( pCell->GetCellType() == CELLTYPE_FORMULA ) +/*N*/ ((ScFormulaCell*) pCell)->CompileColRowNameFormula(); +/*N*/ } +/*N*/ } + +/*N*/ void lcl_UpdateSubTotal( ScFunctionData& rData, ScBaseCell* pCell ) +/*N*/ { +/*N*/ double nValue; +/*N*/ BOOL bVal = FALSE; +/*N*/ BOOL bCell = TRUE; +/*N*/ switch (pCell->GetCellType()) +/*N*/ { +/*?*/ case CELLTYPE_VALUE: +/*?*/ nValue = ((ScValueCell*)pCell)->GetValue(); +/*?*/ bVal = TRUE; +/*?*/ break; +/*?*/ case CELLTYPE_FORMULA: +/*?*/ { +/*?*/ if ( rData.eFunc != SUBTOTAL_FUNC_CNT2 ) // da interessiert's nicht +/*?*/ { +/*?*/ ScFormulaCell* pFC = (ScFormulaCell*)pCell; +/*?*/ if ( pFC->GetErrCode() ) +/*?*/ { +/*?*/ if ( rData.eFunc != SUBTOTAL_FUNC_CNT ) // fuer Anzahl einfach weglassen +/*?*/ rData.bError = TRUE; +/*?*/ } +/*?*/ else if (pFC->IsValue()) +/*?*/ { +/*?*/ nValue = pFC->GetValue(); +/*?*/ bVal = TRUE; +/*?*/ } +/*?*/ // sonst Text +/*?*/ } +/*?*/ } +/*?*/ break; +/*?*/ case CELLTYPE_NOTE: +/*?*/ bCell = FALSE; +/*?*/ break; +/*?*/ // bei Strings nichts +/*N*/ } +/*N*/ +/*N*/ if (!rData.bError) +/*N*/ { +/*N*/ switch (rData.eFunc) +/*N*/ { +/*?*/ case SUBTOTAL_FUNC_SUM: +/*?*/ case SUBTOTAL_FUNC_AVE: +/*?*/ if (bVal) +/*?*/ { +/*?*/ ++rData.nCount; +/*?*/ if (!SubTotal::SafePlus( rData.nVal, nValue )) +/*?*/ rData.bError = TRUE; +/*?*/ } +/*?*/ break; +/*?*/ case SUBTOTAL_FUNC_CNT: // nur Werte +/*?*/ if (bVal) +/*?*/ ++rData.nCount; +/*?*/ break; +/*N*/ case SUBTOTAL_FUNC_CNT2: // alle +/*N*/ if (bCell) +/*N*/ ++rData.nCount; +/*N*/ break; +/*?*/ case SUBTOTAL_FUNC_MAX: +/*?*/ if (bVal) +/*?*/ if (++rData.nCount == 1 || nValue > rData.nVal ) +/*?*/ rData.nVal = nValue; +/*?*/ break; +/*?*/ case SUBTOTAL_FUNC_MIN: +/*?*/ if (bVal) +/*?*/ if (++rData.nCount == 1 || nValue < rData.nVal ) +/*?*/ rData.nVal = nValue; +/*?*/ break; +/*N*/ } +/*N*/ } +/*N*/ } + +// Mehrfachselektion: +/*N*/ void ScColumn::UpdateSelectionFunction( const ScMarkData& rMark, +/*N*/ ScFunctionData& rData, const BYTE* pRowFlags, +/*N*/ BOOL bDoExclude, USHORT nExStartRow, USHORT nExEndRow ) +/*N*/ { +/*N*/ USHORT nIndex; +/*N*/ ScMarkedDataIter aDataIter(this, &rMark, FALSE); +/*N*/ while (aDataIter.Next( nIndex )) +/*N*/ { +/*N*/ USHORT nRow = pItems[nIndex].nRow; +/*N*/ if ( !pRowFlags || !( pRowFlags[nRow] & CR_HIDDEN ) ) +/*N*/ if ( !bDoExclude || nRow < nExStartRow || nRow > nExEndRow ) +/*N*/ lcl_UpdateSubTotal( rData, pItems[nIndex].pCell ); +/*N*/ } +/*N*/ } + +// bei bNoMarked die Mehrfachselektion weglassen +/*N*/ void ScColumn::UpdateAreaFunction( ScFunctionData& rData, BYTE* pRowFlags, +/*N*/ USHORT nStartRow, USHORT nEndRow ) +/*N*/ { +/*N*/ USHORT nIndex; +/*N*/ Search( nStartRow, nIndex ); +/*N*/ while ( nIndex<nCount && pItems[nIndex].nRow<=nEndRow ) +/*N*/ { +/*N*/ USHORT nRow = pItems[nIndex].nRow; +/*N*/ if ( !pRowFlags || !( pRowFlags[nRow] & CR_HIDDEN ) ) +/*N*/ lcl_UpdateSubTotal( rData, pItems[nIndex].pCell ); +/*N*/ ++nIndex; +/*N*/ } +/*N*/ } + +/*N*/ long ScColumn::GetWeightedCount() const +/*N*/ { +/*N*/ long nTotal = 0; +/*N*/ +/*N*/ // Notizen werden nicht gezaehlt +/*N*/ +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ { +/*N*/ ScBaseCell* pCell = pItems[i].pCell; +/*N*/ switch ( pCell->GetCellType() ) +/*N*/ { +/*N*/ case CELLTYPE_VALUE: +/*N*/ case CELLTYPE_STRING: +/*N*/ ++nTotal; +/*N*/ break; +/*N*/ case CELLTYPE_FORMULA: +/*N*/ nTotal += 5 + ((ScFormulaCell*)pCell)->GetCode()->GetCodeLen(); +/*N*/ break; +/*N*/ case CELLTYPE_EDIT: +/*N*/ nTotal += 50; +/*N*/ break; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ return nTotal; +/*N*/ } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_column3.cxx b/binfilter/bf_sc/source/core/data/sc_column3.cxx new file mode 100644 index 000000000000..f84eba85b1b0 --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_column3.cxx @@ -0,0 +1,1060 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <bf_sfx2/objsh.hxx> +#include <bf_svtools/zforlist.hxx> + +#include "scitems.hxx" +#include "cell.hxx" +#include "document.hxx" +#include "attarray.hxx" +#include "cellform.hxx" +#include "detfunc.hxx" // fuer Notizen bei DeleteRange +namespace binfilter { + +// Err527 Workaround +extern const ScFormulaCell* pLastFormulaTreeTop; // in cellform.cxx + +// STATIC DATA ----------------------------------------------------------- + +/*N*/ BOOL ScColumn::bDoubleAlloc = FALSE; // fuer Import: Groesse beim Allozieren verdoppeln +/*N*/ +/*N*/ +/*N*/ void ScColumn::Insert( USHORT nRow, ScBaseCell* pNewCell ) +/*N*/ { +/*N*/ BOOL bIsAppended = FALSE; +/*N*/ if (pItems && nCount) +/*N*/ { +/*N*/ if (pItems[nCount-1].nRow < nRow) +/*N*/ { +/*N*/ Append(nRow, pNewCell ); +/*N*/ bIsAppended = TRUE; +/*N*/ } +/*N*/ } +/*N*/ if ( !bIsAppended ) +/*N*/ { +/*N*/ USHORT nIndex; +/*N*/ if (Search(nRow, nIndex)) +/*N*/ { +/*N*/ ScBaseCell* pOldCell = pItems[nIndex].pCell; +/*N*/ ScBroadcasterList* pBC = pOldCell->GetBroadcaster(); +/*N*/ if (pBC && !pNewCell->GetBroadcaster()) +/*N*/ { +/*N*/ pNewCell->SetBroadcaster( pBC ); +/*N*/ pOldCell->ForgetBroadcaster(); +/*N*/ } +/*N*/ if (pOldCell->GetNotePtr() && !pNewCell->GetNotePtr()) +/*?*/ pNewCell->SetNote( *pOldCell->GetNotePtr() ); +/*N*/ if ( pOldCell->GetCellType() == CELLTYPE_FORMULA && !pDocument->IsClipOrUndo() ) +/*N*/ { +/*?*/ pOldCell->EndListeningTo( pDocument ); +/*?*/ // falls in EndListening NoteCell in gleicher Col zerstoert +/*?*/ if ( nIndex >= nCount || pItems[nIndex].nRow != nRow ) +/*?*/ Search(nRow, nIndex); +/*N*/ } +/*N*/ pOldCell->Delete(); +/*N*/ pItems[nIndex].pCell = pNewCell; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ if (nCount + 1 > nLimit) +/*N*/ { +/*N*/ if (bDoubleAlloc) +/*N*/ { +/*N*/ if (nLimit < COLUMN_DELTA) +/*N*/ nLimit = COLUMN_DELTA; +/*N*/ else +/*N*/ { +/*N*/ nLimit *= 2; +/*N*/ if ( nLimit > MAXROW+1 ) +/*N*/ nLimit = MAXROW+1; +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ nLimit += COLUMN_DELTA; +/*N*/ +/*N*/ ColEntry* pNewItems = new ColEntry[nLimit]; +/*N*/ if (pItems) +/*N*/ { +/*N*/ memmove( pNewItems, pItems, nCount * sizeof(ColEntry) ); +/*N*/ delete[] pItems; +/*N*/ } +/*N*/ pItems = pNewItems; +/*N*/ } +/*N*/ memmove( &pItems[nIndex + 1], &pItems[nIndex], (nCount - nIndex) * sizeof(ColEntry) ); +/*N*/ pItems[nIndex].pCell = pNewCell; +/*N*/ pItems[nIndex].nRow = nRow; +/*N*/ ++nCount; +/*N*/ } +/*N*/ } +/*N*/ // Bei aus Clipboard sind hier noch falsche (alte) Referenzen! +/*N*/ // Werden in CopyBlockFromClip per UpdateReference umgesetzt, +/*N*/ // danach StartListeningFromClip und BroadcastFromClip gerufen. +/*N*/ // Wird ins Clipboard/UndoDoc gestellt, wird kein Broadcast gebraucht. +/*N*/ // Nach Import wird CalcAfterLoad gerufen, dort Listening. +/*N*/ if ( !(pDocument->IsClipOrUndo() || pDocument->IsInsertingFromOtherDoc()) ) +/*N*/ { +/*N*/ pNewCell->StartListeningTo( pDocument ); +/*N*/ CellType eCellType = pNewCell->GetCellType(); +/*N*/ // Notizzelle entsteht beim Laden nur durch StartListeningCell, +/*N*/ // ausloesende Formelzelle muss sowieso dirty sein. +/*N*/ if ( !(pDocument->IsCalcingAfterLoad() && eCellType == CELLTYPE_NOTE) ) +/*N*/ { +/*N*/ if ( eCellType == CELLTYPE_FORMULA ) +/*N*/ ((ScFormulaCell*)pNewCell)->SetDirty(); +/*N*/ else +/*N*/ pDocument->Broadcast( ScHint( SC_HINT_DATACHANGED, +/*N*/ ScAddress( nCol, nRow, nTab ), pNewCell ) ); +/*N*/ } +/*N*/ } +/*N*/ } + + +/*N*/ void ScColumn::Insert( USHORT nRow, ULONG nNumberFormat, ScBaseCell* pCell ) +/*N*/ { +/*N*/ Insert(nRow, pCell); +/*N*/ short eOldType = pDocument->GetFormatTable()-> +/*N*/ GetType( (ULONG) +/*N*/ ((SfxUInt32Item*)GetAttr( nRow, ATTR_VALUE_FORMAT ))-> +/*N*/ GetValue() ); +/*N*/ short eNewType = pDocument->GetFormatTable()->GetType(nNumberFormat); +/*N*/ if (!pDocument->GetFormatTable()->IsCompatible(eOldType, eNewType)) +/*N*/ ApplyAttr( nRow, SfxUInt32Item( ATTR_VALUE_FORMAT, (UINT32) nNumberFormat) ); +/*N*/ } + + +/*N*/ void ScColumn::Append( USHORT nRow, ScBaseCell* pCell ) +/*N*/ { +/*N*/ if (nCount + 1 > nLimit) +/*N*/ { +/*N*/ if (bDoubleAlloc) +/*N*/ { +/*N*/ if (nLimit < COLUMN_DELTA) +/*N*/ nLimit = COLUMN_DELTA; +/*N*/ else +/*N*/ { +/*N*/ nLimit *= 2; +/*N*/ if ( nLimit > MAXROW+1 ) +/*N*/ nLimit = MAXROW+1; +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ nLimit += COLUMN_DELTA; +/*N*/ +/*N*/ ColEntry* pNewItems = new ColEntry[nLimit]; +/*N*/ if (pItems) +/*N*/ { +/*N*/ memmove( pNewItems, pItems, nCount * sizeof(ColEntry) ); +/*N*/ delete[] pItems; +/*N*/ } +/*N*/ pItems = pNewItems; +/*N*/ } +/*N*/ pItems[nCount].pCell = pCell; +/*N*/ pItems[nCount].nRow = nRow; +/*N*/ ++nCount; +/*N*/ } + + +/*N*/ void ScColumn::DeleteAtIndex( USHORT nIndex ) +/*N*/ { +/*N*/ ScBaseCell* pCell = pItems[nIndex].pCell; +/*N*/ ScNoteCell* pNoteCell = new ScNoteCell; +/*N*/ pItems[nIndex].pCell = pNoteCell; // Dummy fuer Interpret +/*N*/ pDocument->Broadcast( ScHint( SC_HINT_DYING, +/*N*/ ScAddress( nCol, pItems[nIndex].nRow, nTab ), pCell ) ); +/*N*/ delete pNoteCell; +/*N*/ --nCount; +/*N*/ memmove( &pItems[nIndex], &pItems[nIndex + 1], (nCount - nIndex) * sizeof(ColEntry) ); +/*N*/ pItems[nCount].nRow = 0; +/*N*/ pItems[nCount].pCell = NULL; +/*N*/ pCell->EndListeningTo( pDocument ); +/*N*/ pCell->Delete(); +/*N*/ } + + +/*N*/ void ScColumn::FreeAll() +/*N*/ { +/*N*/ if (pItems) +/*N*/ { +/*N*/ for (USHORT i = 0; i < nCount; i++) +/*N*/ pItems[i].pCell->Delete(); +/*N*/ delete[] pItems; +/*N*/ pItems = NULL; +/*N*/ } +/*N*/ nCount = 0; +/*N*/ nLimit = 0; +/*N*/ } + + +/*N*/ void ScColumn::DeleteRow( USHORT nStartRow, USHORT nSize ) +/*N*/ { +/*N*/ pAttrArray->DeleteRow( nStartRow, nSize ); +/*N*/ +/*N*/ if ( !pItems || !nCount ) +/*N*/ return ; +/*N*/ +/*N*/ USHORT nFirstIndex; +/*N*/ Search( nStartRow, nFirstIndex ); +/*N*/ if ( nFirstIndex >= nCount ) +/*N*/ return ; +/*N*/ +/*N*/ BOOL bOldAutoCalc = pDocument->GetAutoCalc(); +/*N*/ pDocument->SetAutoCalc( FALSE ); // Mehrfachberechnungen vermeiden +/*N*/ +/*N*/ BOOL bFound=FALSE; +/*N*/ USHORT nEndRow = nStartRow + nSize - 1; +/*N*/ USHORT nStartIndex; +/*N*/ USHORT nEndIndex; +/*N*/ USHORT i; +/*N*/ +/*N*/ for ( i = nFirstIndex; i < nCount && pItems[i].nRow <= nEndRow; i++ ) +/*N*/ { +/*N*/ if (!bFound) +/*N*/ { +/*N*/ nStartIndex = i; +/*N*/ bFound = TRUE; +/*N*/ } +/*N*/ nEndIndex = i; +/*N*/ +/*N*/ ScBaseCell* pCell = pItems[i].pCell; +/*N*/ ScBroadcasterList* pBC = pCell->GetBroadcaster(); +/*N*/ if (pBC) +/*N*/ { +/*N*/ // gibt jetzt invalid reference, kein Aufruecken der direkten Referenzen +/*N*/ // MoveListeners( *pBC, nRow+nSize ); +/*N*/ pCell->SetBroadcaster(NULL); +/*N*/ // in DeleteRange werden leere Broadcaster geloescht +/*N*/ } +/*N*/ } +/*N*/ if (bFound) +/*N*/ { +/*N*/ DeleteRange( nStartIndex, nEndIndex, IDF_CONTENTS ); +/*N*/ Search( nStartRow, i ); +/*N*/ if ( i >= nCount ) +/*N*/ { +/*N*/ pDocument->SetAutoCalc( bOldAutoCalc ); +/*N*/ return ; +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ i = nFirstIndex; +/*N*/ +/*N*/ ScAddress aAdr( nCol, 0, nTab ); +/*N*/ ScHint aHint( SC_HINT_DATACHANGED, aAdr, NULL ); // only areas (ScBaseCell* == NULL) +/*N*/ ScAddress& rAddress = aHint.GetAddress(); +/*N*/ // for sparse occupation use single broadcasts, not ranges +/*N*/ BOOL bSingleBroadcasts = (((pItems[nCount-1].nRow - pItems[i].nRow) / +/*N*/ (nCount - i)) > 1); +/*N*/ if ( bSingleBroadcasts ) +/*N*/ { +/*N*/ USHORT nLastBroadcast = MAXROW+1; +/*N*/ for ( ; i < nCount; i++ ) +/*N*/ { +/*N*/ USHORT nOldRow = pItems[i].nRow; +/*N*/ // #43940# Aenderung Quelle broadcasten +/*N*/ rAddress.SetRow( nOldRow ); +/*N*/ pDocument->AreaBroadcast( aHint ); +/*N*/ USHORT nNewRow = (pItems[i].nRow -= nSize); +/*N*/ // #43940# Aenderung Ziel broadcasten +/*N*/ if ( nLastBroadcast != nNewRow ) +/*N*/ { // direkt aufeinanderfolgende nicht doppelt broadcasten +/*N*/ rAddress.SetRow( nNewRow ); +/*N*/ pDocument->AreaBroadcast( aHint ); +/*N*/ } +/*N*/ nLastBroadcast = nOldRow; +/*N*/ ScBaseCell* pCell = pItems[i].pCell; +/*N*/ if ( pCell->GetCellType() == CELLTYPE_FORMULA ) +/*N*/ ((ScFormulaCell*)pCell)->aPos.SetRow( nNewRow ); +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ rAddress.SetRow( pItems[i].nRow ); +/*N*/ ScRange aRange( rAddress ); +/*N*/ aRange.aEnd.SetRow( pItems[nCount-1].nRow ); +/*N*/ for ( ; i < nCount; i++ ) +/*N*/ { +/*N*/ USHORT nNewRow = (pItems[i].nRow -= nSize); +/*N*/ ScBaseCell* pCell = pItems[i].pCell; +/*N*/ if ( pCell->GetCellType() == CELLTYPE_FORMULA ) +/*N*/ ((ScFormulaCell*)pCell)->aPos.SetRow( nNewRow ); +/*N*/ } +/*N*/ pDocument->AreaBroadcastInRange( aRange, aHint ); +/*N*/ } +/*N*/ +/*N*/ pDocument->SetAutoCalc( bOldAutoCalc ); +/*N*/ } + + +/*N*/ void ScColumn::DeleteRange( USHORT nStartIndex, USHORT nEndIndex, USHORT nDelFlag ) +/*N*/ { +/*N*/ USHORT nDelCount = 0; +/*N*/ ScBaseCell** ppDelCells = new ScBaseCell*[nEndIndex-nStartIndex+1]; +/*N*/ +/*N*/ BOOL bSimple = ((nDelFlag & IDF_CONTENTS) == IDF_CONTENTS); +/*N*/ USHORT i; +/*N*/ +/*N*/ // Notiz-Zeichenobjekte +/*N*/ if (nDelFlag & IDF_NOTE) +/*N*/ { +/*N*/ for ( i = nStartIndex; i <= nEndIndex; i++ ) +/*N*/ { +/*N*/ const ScPostIt* pNote = pItems[i].pCell->GetNotePtr(); +/*N*/ if ( pNote && pNote->IsShown() ) +/*N*/ { +/*?*/ ScDetectiveFunc( pDocument, nTab ).HideComment( nCol, pItems[i].nRow ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // Broadcaster stehenlassen +/*N*/ if (bSimple) +/*N*/ { +/*N*/ for (i = nStartIndex; i <= nEndIndex && bSimple; i++) +/*N*/ if (pItems[i].pCell->GetBroadcaster()) +/*N*/ bSimple = FALSE; +/*N*/ } +/*N*/ +/*N*/ ScHint aHint( SC_HINT_DYING, ScAddress( nCol, 0, nTab ), NULL ); +/*N*/ +/*N*/ if (bSimple) // Bereich komplett loeschen +/*N*/ { +/*N*/ ScBaseCell* pOldCell; +/*N*/ ScNoteCell* pNoteCell = new ScNoteCell; // Dummy +/*N*/ for (i = nStartIndex; i <= nEndIndex; i++) +/*N*/ { +/*N*/ pOldCell = pItems[i].pCell; +/*N*/ if (pOldCell->GetCellType() == CELLTYPE_FORMULA) // Formeln spaeter loeschen +/*N*/ ppDelCells[nDelCount++] = pOldCell; +/*N*/ else +/*N*/ { +/*N*/ // Interpret in Broadcast darf kein Value finden +/*N*/ pItems[i].pCell = pNoteCell; +/*N*/ aHint.GetAddress().SetRow( pItems[i].nRow ); +/*N*/ aHint.SetCell( pOldCell ); +/*N*/ pDocument->Broadcast( aHint ); +/*N*/ pOldCell->Delete(); +/*N*/ } +/*N*/ } +/*N*/ delete pNoteCell; +/*N*/ memmove( &pItems[nStartIndex], &pItems[nEndIndex + 1], (nCount - nEndIndex - 1) * sizeof(ColEntry) ); +/*N*/ nCount -= nEndIndex-nStartIndex+1; +/*N*/ } +/*N*/ else // Zellen einzeln durchgehen +/*N*/ { +/*N*/ USHORT j = nStartIndex; +/*N*/ for (USHORT i = nStartIndex; i <= nEndIndex; i++) +/*N*/ { +/*N*/ BOOL bDelete = FALSE; +/*N*/ ScBaseCell* pOldCell = pItems[j].pCell; +/*N*/ CellType eCellType = pOldCell->GetCellType(); +/*N*/ switch ( eCellType ) +/*N*/ { +/*N*/ case CELLTYPE_VALUE: +/*N*/ if ( ( nDelFlag & (IDF_DATETIME|IDF_VALUE) ) == (IDF_DATETIME|IDF_VALUE) ) +/*N*/ bDelete = TRUE; +/*N*/ else +/*N*/ { +/*?*/ ULONG nIndex = (ULONG)((SfxUInt32Item*)GetAttr( pItems[j].nRow, ATTR_VALUE_FORMAT ))->GetValue(); +/*?*/ short nTyp = pDocument->GetFormatTable()->GetType(nIndex); +/*?*/ if ((nTyp == NUMBERFORMAT_DATE) || (nTyp == NUMBERFORMAT_TIME) || (nTyp == NUMBERFORMAT_DATETIME)) +/*?*/ bDelete = ((nDelFlag & IDF_DATETIME) != 0); +/*?*/ else +/*?*/ bDelete = ((nDelFlag & IDF_VALUE) != 0); +/*N*/ } +/*N*/ break; +/*?*/ case CELLTYPE_STRING: +/*N*/ case CELLTYPE_EDIT: bDelete = ((nDelFlag & IDF_STRING) != 0); break; +/*?*/ case CELLTYPE_FORMULA: bDelete = ((nDelFlag & IDF_FORMULA) != 0); break; +/*?*/ case CELLTYPE_NOTE: +/*?*/ bDelete = ((nDelFlag & IDF_NOTE) != 0) && +/*?*/ (pOldCell->GetBroadcaster() == NULL); +/*?*/ break; +/*N*/ } +/*N*/ +/*N*/ if (bDelete) +/*N*/ { +/*N*/ ScNoteCell* pNoteCell = NULL; +/*N*/ if (eCellType != CELLTYPE_NOTE) +/*N*/ { +/*N*/ if ((nDelFlag & IDF_NOTE) == 0) +/*N*/ { +/*?*/ const ScPostIt* pNote = pOldCell->GetNotePtr(); +/*?*/ if (pNote) +/*?*/ pNoteCell = new ScNoteCell(*pNote); +/*N*/ } +/*N*/ ScBroadcasterList* pBC = pOldCell->GetBroadcaster(); +/*N*/ if (pBC) +/*N*/ { +/*N*/ if (!pNoteCell) +/*N*/ pNoteCell = new ScNoteCell; +/*N*/ pNoteCell->SetBroadcaster(pBC); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ USHORT nOldRow = pItems[j].nRow; +/*N*/ if (pNoteCell) +/*N*/ { +/*N*/ pItems[j].pCell = pNoteCell; +/*N*/ ++j; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ --nCount; +/*N*/ memmove( &pItems[j], &pItems[j + 1], (nCount - j) * sizeof(ColEntry) ); +/*N*/ pItems[nCount].nRow = 0; +/*N*/ pItems[nCount].pCell = NULL; +/*N*/ } +/*N*/ // ACHTUNG! pItems bereits verschoben! +/*N*/ // Interpret in Broadcast muss neue/keine Zelle finden +/*N*/ if (eCellType == CELLTYPE_FORMULA) // Formeln spaeter loeschen +/*N*/ { +/*N*/ ppDelCells[nDelCount++] = pOldCell; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ aHint.GetAddress().SetRow( nOldRow ); +/*N*/ aHint.SetCell( pOldCell ); +/*N*/ pDocument->Broadcast( aHint ); +/*N*/ if (eCellType != CELLTYPE_NOTE) +/*N*/ pOldCell->ForgetBroadcaster(); +/*N*/ pOldCell->Delete(); +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*?*/ if (nDelFlag & IDF_NOTE) +/*?*/ if (pItems[j].pCell->GetNotePtr()) +/*?*/ pItems[j].pCell->DeleteNote(); +/*?*/ ++j; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // erst Listener abhaengen kann Neuberechnungen sparen +/*N*/ // eventuell werden dabei vorher entstandene NoteCell mitsamt +/*N*/ // ihren Broadcaster deleted! +/*N*/ for (i=0; i<nDelCount; i++) +/*N*/ { +/*?*/ ((ScFormulaCell*) ppDelCells[i])->EndListeningTo( pDocument ); +/*N*/ } +/*N*/ // gibts die NoteCell und damit den Broadcaster noch? +/*N*/ // If not, discard them all before broadcasting takes place! +/*N*/ for (i=0; i<nDelCount; i++) +/*N*/ { +/*?*/ ScFormulaCell* pOldCell = (ScFormulaCell*) ppDelCells[i]; +/*?*/ USHORT nIndex; +/*?*/ if ( !Search( pOldCell->aPos.Row(), nIndex ) ) +/*?*/ pOldCell->ForgetBroadcaster(); +/*N*/ } +/*N*/ for (i=0; i<nDelCount; i++) +/*N*/ { +/*?*/ ScFormulaCell* pOldCell = (ScFormulaCell*) ppDelCells[i]; +/*?*/ aHint.SetAddress( pOldCell->aPos ); +/*?*/ aHint.SetCell( pOldCell ); +/*?*/ pDocument->Broadcast( aHint ); +/*?*/ pOldCell->ForgetBroadcaster(); +/*?*/ pOldCell->Delete(); +/*N*/ } +/*N*/ +/*N*/ delete[] ppDelCells; +/*N*/ } + + +/*N*/ void ScColumn::DeleteArea(USHORT nStartRow, USHORT nEndRow, USHORT nDelFlag) +/*N*/ { +/*N*/ // FreeAll darf hier nicht gerufen werden wegen Broadcastern +/*N*/ +/*N*/ // Attribute erst am Ende, damit vorher noch zwischen Zahlen und Datum +/*N*/ // unterschieden werden kann (#47901#) +/*N*/ +/*N*/ USHORT nContFlag = nDelFlag & IDF_CONTENTS; +/*N*/ if (pItems && nCount && nContFlag) +/*N*/ { +/*N*/ if (nStartRow==0 && nEndRow==MAXROW) +/*N*/ DeleteRange( 0, nCount-1, nContFlag ); +/*N*/ else +/*N*/ { +/*?*/ BOOL bFound=FALSE; +/*?*/ USHORT nStartIndex; +/*?*/ USHORT nEndIndex; +/*?*/ for (USHORT i = 0; i < nCount; i++) +/*?*/ if ((pItems[i].nRow >= nStartRow) && (pItems[i].nRow <= nEndRow)) +/*?*/ { +/*?*/ if (!bFound) +/*?*/ { +/*?*/ nStartIndex = i; +/*?*/ bFound = TRUE; +/*?*/ } +/*?*/ nEndIndex = i; +/*?*/ } +/*?*/ if (bFound) +/*?*/ DeleteRange( nStartIndex, nEndIndex, nContFlag ); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if ( nDelFlag & IDF_EDITATTR ) +/*N*/ { +/*?*/ DBG_ASSERT( nContFlag == 0, "DeleteArea: falsche Flags" ); +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 /*?*/ RemoveEditAttribs( nStartRow, nEndRow ); +/*N*/ } +/*N*/ +/*N*/ // Attribute erst hier +/*N*/ if ((nDelFlag & IDF_ATTRIB) == IDF_ATTRIB) pAttrArray->DeleteArea( nStartRow, nEndRow ); +/*N*/ else if ((nDelFlag & IDF_ATTRIB) != 0) pAttrArray->DeleteHardAttr( nStartRow, nEndRow ); +/*N*/ } + + + + +// rColumn = Quelle +// nRow1, nRow2 = Zielposition + + + + // Formelzellen werden jetzt schon hier kopiert, + // Notizen muessen aber evtl. noch geloescht werden + +/*N*/ ScBaseCell* ScColumn::CloneCell(USHORT nIndex, USHORT nFlags, +/*N*/ ScDocument* pDestDoc, const ScAddress& rDestPos) +/*N*/ { +/*N*/ ScBaseCell* pNew = 0; +/*N*/ ScBaseCell* pSource = pItems[nIndex].pCell; +/*N*/ switch (pSource->GetCellType()) +/*N*/ { +/*?*/ case CELLTYPE_NOTE: +/*?*/ if (nFlags & IDF_NOTE) +/*?*/ pNew = new ScNoteCell(*(ScNoteCell*)pSource); +/*?*/ break; +/*?*/ case CELLTYPE_EDIT: +/*?*/ if (nFlags & IDF_STRING) +/*?*/ pNew = new ScEditCell( *(ScEditCell*)pSource, pDestDoc ); +/*?*/ break; +/*N*/ case CELLTYPE_STRING: +/*N*/ if (nFlags & IDF_STRING) +/*N*/ pNew = new ScStringCell(*(ScStringCell*)pSource); +/*N*/ break; +/*N*/ case CELLTYPE_VALUE: +/*N*/ { +/*N*/ BOOL bDoIns = FALSE; +/*N*/ USHORT nMask = nFlags & ( IDF_DATETIME | IDF_VALUE ); +/*N*/ if ( nMask == (IDF_DATETIME | IDF_VALUE) ) +/*N*/ bDoIns = TRUE; +/*N*/ else if ( nMask ) +/*N*/ { +/*?*/ ULONG nNumIndex = (ULONG)((SfxUInt32Item*) GetAttr( +/*?*/ pItems[nIndex].nRow, ATTR_VALUE_FORMAT ))->GetValue(); +/*?*/ short nTyp = pDocument->GetFormatTable()->GetType(nNumIndex); +/*?*/ if (nTyp == NUMBERFORMAT_DATE || nTyp == NUMBERFORMAT_TIME || nTyp == NUMBERFORMAT_DATETIME) +/*?*/ bDoIns = (nFlags & IDF_DATETIME)!=0; +/*?*/ else +/*?*/ bDoIns = (nFlags & IDF_VALUE)!=0; +/*N*/ } +/*N*/ if (bDoIns) +/*N*/ pNew = new ScValueCell(*(ScValueCell*)pSource); +/*N*/ } +/*N*/ break; +/*?*/ case CELLTYPE_FORMULA: +/*?*/ { +/*?*/ ScFormulaCell* pForm = (ScFormulaCell*)pSource; +/*?*/ if (nFlags & IDF_FORMULA) +/*?*/ { +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 /*?*/ pNew = pForm->Clone( pDestDoc, rDestPos, TRUE ); +/*?*/ } +/*?*/ else if ( (nFlags & (IDF_VALUE | IDF_DATETIME | IDF_STRING)) && +/*?*/ !pDestDoc->IsUndo() ) +/*?*/ { +/*?*/ // #48491# ins Undo-Dokument immer nur die Original-Zelle kopieren, +/*?*/ // aus Formeln keine Value/String-Zellen erzeugen +/*?*/ +/*?*/ USHORT nErr = pForm->GetErrCode(); +/*?*/ if ( nErr ) +/*?*/ { +/*?*/ // Fehler werden immer mit "Zahlen" kopiert +/*?*/ // (Das ist hiermit willkuerlich so festgelegt) +/*?*/ +/*?*/ if ( nFlags & IDF_VALUE ) +/*?*/ { +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 /*?*/ ScFormulaCell* pErrCell = new ScFormulaCell( pDestDoc, rDestPos ); +/*?*/ } +/*?*/ } +/*?*/ else if ( pForm->IsValue() ) +/*?*/ { +/*?*/ BOOL bDoIns = FALSE; +/*?*/ USHORT nMask = nFlags & ( IDF_DATETIME | IDF_VALUE ); +/*?*/ if ( nMask == (IDF_DATETIME | IDF_VALUE) ) +/*?*/ bDoIns = TRUE; +/*?*/ else if ( nMask ) +/*?*/ { +/*?*/ ULONG nNumIndex = (ULONG)((SfxUInt32Item*) GetAttr( +/*?*/ pItems[nIndex].nRow, ATTR_VALUE_FORMAT ))->GetValue(); +/*?*/ short nTyp = pDocument->GetFormatTable()->GetType(nNumIndex); +/*?*/ if (nTyp == NUMBERFORMAT_DATE || nTyp == NUMBERFORMAT_TIME || nTyp == NUMBERFORMAT_DATETIME) +/*?*/ bDoIns = (nFlags & IDF_DATETIME)!=0; +/*?*/ else +/*?*/ bDoIns = (nFlags & IDF_VALUE)!=0; +/*?*/ } +/*?*/ +/*?*/ if (bDoIns) +/*?*/ { +/*?*/ double nVal = pForm->GetValue(); +/*?*/ pNew = new ScValueCell(nVal); +/*?*/ } +/*?*/ } +/*?*/ else +/*?*/ { +/*?*/ if (nFlags & IDF_STRING) +/*?*/ { +/*?*/ String aString; +/*?*/ pForm->GetString(aString); +/*?*/ if ( aString.Len() ) +/*?*/ pNew = new ScStringCell(aString); +/*?*/ // #33224# LeerStrings nicht kopieren +/*?*/ } +/*?*/ } +/*?*/ if ( pNew && pSource->GetNotePtr() && ( nFlags & IDF_NOTE ) ) +/*?*/ pNew->SetNote(*pSource->GetNotePtr()); +/*?*/ } +/*?*/ } +/*?*/ break; +/*N*/ } +/*N*/ +/*N*/ if ( !pNew && pSource->GetNotePtr() && ( nFlags & IDF_NOTE ) ) +/*?*/ pNew = new ScNoteCell(*pSource->GetNotePtr()); +/*N*/ +/*N*/ return pNew; +/*N*/ } + + + + +// Ergebnis in rVal1 + + + + + + + +/*N*/ ScAttrIterator* ScColumn::CreateAttrIterator( USHORT nStartRow, USHORT nEndRow ) const +/*N*/ { +/*N*/ return new ScAttrIterator( pAttrArray, nStartRow, nEndRow ); +/*N*/ } + + +/*N*/ void ScColumn::StartAllListeners() +/*N*/ { +/*N*/ if (pItems) +/*N*/ for (USHORT i = 0; i < nCount; i++) +/*N*/ { +/*N*/ ScBaseCell* pCell = pItems[i].pCell; +/*N*/ if ( pCell->GetCellType() == CELLTYPE_FORMULA ) +/*N*/ { +/*N*/ USHORT nRow = pItems[i].nRow; +/*N*/ ((ScFormulaCell*)pCell)->StartListeningTo( pDocument ); +/*N*/ if ( nRow != pItems[i].nRow ) +/*N*/ Search( nRow, i ); // Listener eingefuegt? +/*N*/ } +/*N*/ } +/*N*/ } + + +/*N*/ void ScColumn::StartNameListeners( BOOL bOnlyRelNames ) +/*N*/ { +/*N*/ if (pItems) +/*N*/ { +/*N*/ USHORT nNameListening = (bOnlyRelNames ? SC_LISTENING_NAMES_REL : +/*N*/ SC_LISTENING_NAMES_REL | SC_LISTENING_NAMES_ABS); +/*N*/ for (USHORT i = 0; i < nCount; i++) +/*N*/ { +/*N*/ ScBaseCell* pCell = pItems[i].pCell; +/*N*/ if ( pCell->GetCellType() == CELLTYPE_FORMULA ) +/*N*/ { +/*N*/ USHORT nRow = pItems[i].nRow; +/*N*/ ((ScFormulaCell*)pCell)->StartListeningTo( pDocument, nNameListening ); +/*N*/ if ( nRow != pItems[i].nRow ) +/*N*/ Search( nRow, i ); // Listener eingefuegt? +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } + + + + + + +// TRUE = Zahlformat gesetzt +/*N*/ BOOL ScColumn::SetString( USHORT nRow, USHORT nTab, const String& rString ) +/*N*/ { +/*N*/ BOOL bNumFmtSet = FALSE; +/*N*/ if (VALIDROW(nRow)) +/*N*/ { +/*N*/ ScBaseCell* pNewCell = NULL; +/*N*/ BOOL bIsLoading = FALSE; +/*N*/ if (rString.Len() > 0) +/*N*/ { +/*N*/ double nVal; +/*N*/ sal_uInt32 nIndex, nOldIndex; +/*N*/ sal_Unicode cFirstChar; +/*N*/ SvNumberFormatter* pFormatter = pDocument->GetFormatTable(); +/*N*/ SfxObjectShell* pDocSh = pDocument->GetDocumentShell(); +/*N*/ if ( pDocSh ) +/*N*/ bIsLoading = pDocSh->IsLoading(); +/*N*/ // IsLoading bei ConvertFrom Import +/*N*/ if ( !bIsLoading ) +/*N*/ { +/*N*/ nIndex = nOldIndex = GetNumberFormat( nRow ); +/*N*/ if ( rString.Len() > 1 +/*N*/ && pFormatter->GetType(nIndex) != NUMBERFORMAT_TEXT ) +/*N*/ cFirstChar = rString.GetChar(0); +/*N*/ else +/*N*/ cFirstChar = 0; // Text +/*N*/ } +/*N*/ else +/*N*/ { // waehrend ConvertFrom Import gibt es keine gesetzten Formate +/*N*/ cFirstChar = rString.GetChar(0); +/*N*/ } +/*N*/ +/*N*/ if ( cFirstChar == '=' ) +/*N*/ { +/*?*/ if ( rString.Len() == 1 ) // = Text +/*?*/ pNewCell = new ScStringCell( rString ); +/*?*/ else // =Formel +/*?*/ pNewCell = new ScFormulaCell( pDocument, +/*?*/ ScAddress( nCol, nRow, nTab ), rString, 0 ); +/*N*/ } +/*N*/ else if ( cFirstChar == '\'') // 'Text +/*?*/ pNewCell = new ScStringCell( rString.Copy(1) ); +/*N*/ else +/*N*/ { +/*N*/ BOOL bIsText = FALSE; +/*N*/ if ( bIsLoading ) +/*N*/ { +/*N*/ if ( pItems && nCount ) +/*N*/ { +/*?*/ String aStr; +/*?*/ USHORT i = nCount; +/*?*/ USHORT nStop = (i >= 3 ? i - 3 : 0); +/*?*/ // die letzten Zellen vergleichen, ob gleicher String +/*?*/ // und IsNumberFormat eingespart werden kann +/*?*/ do +/*?*/ { +/*?*/ i--; +/*?*/ ScBaseCell* pCell = pItems[i].pCell; +/*?*/ switch ( pCell->GetCellType() ) +/*?*/ { +/*?*/ case CELLTYPE_STRING : +/*?*/ ((ScStringCell*)pCell)->GetString( aStr ); +/*?*/ if ( rString == aStr ) +/*?*/ bIsText = TRUE; +/*?*/ break; +/*?*/ case CELLTYPE_NOTE : // durch =Formel referenziert +/*?*/ break; +/*?*/ default: +/*?*/ if ( i == nCount - 1 ) +/*?*/ i = 0; +/*?*/ // wahrscheinlich ganze Spalte kein String +/*?*/ } +/*?*/ } while ( i && i > nStop && !bIsText ); +/*N*/ } +/*N*/ // nIndex fuer IsNumberFormat vorbelegen +/*N*/ if ( !bIsText ) +/*N*/ nIndex = nOldIndex = pFormatter->GetStandardIndex(); +/*N*/ } +/*N*/ if ( !bIsText && +/*N*/ pFormatter->IsNumberFormat(rString, nIndex, nVal) ) +/*N*/ { // Zahl +/*?*/ pNewCell = new ScValueCell( nVal ); +/*?*/ if ( nIndex != nOldIndex) +/*?*/ { +/*?*/ ApplyAttr( nRow, SfxUInt32Item( ATTR_VALUE_FORMAT, +/*?*/ (UINT32) nIndex) ); +/*?*/ bNumFmtSet = TRUE; +/*?*/ } +/*N*/ } +/*N*/ else // Text +/*N*/ pNewCell = new ScStringCell( rString ); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if ( bIsLoading && (!nCount || nRow > pItems[nCount-1].nRow) ) +/*N*/ { // Search einsparen und ohne Umweg ueber Insert, Listener aufbauen +/*N*/ // und Broadcast kommt eh erst nach dem Laden +/*N*/ if ( pNewCell ) +/*N*/ Append( nRow, pNewCell ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ USHORT i; +/*N*/ if (Search(nRow, i)) +/*N*/ { +/*?*/ ScBaseCell* pOldCell = pItems[i].pCell; +/*?*/ const ScPostIt* pNote = pOldCell->GetNotePtr(); +/*?*/ ScBroadcasterList* pBC = pOldCell->GetBroadcaster(); +/*?*/ if (pNewCell || pNote || pBC) +/*?*/ { +/*?*/ if (!pNewCell) +/*?*/ pNewCell = new ScNoteCell(); +/*?*/ if (pNote) +/*?*/ pNewCell->SetNote(*pNote); +/*?*/ if (pBC) +/*?*/ { +/*?*/ pNewCell->SetBroadcaster(pBC); +/*?*/ pOldCell->ForgetBroadcaster(); +/*?*/ pLastFormulaTreeTop = 0; // Err527 Workaround +/*?*/ } +/*?*/ +/*?*/ if ( pOldCell->GetCellType() == CELLTYPE_FORMULA ) +/*?*/ { +/*?*/ pOldCell->EndListeningTo( pDocument ); +/*?*/ // falls in EndListening NoteCell in gleicher Col zerstoert +/*?*/ if ( i >= nCount || pItems[i].nRow != nRow ) +/*?*/ Search(nRow, i); +/*?*/ } +/*?*/ pOldCell->Delete(); +/*?*/ pItems[i].pCell = pNewCell; // ersetzen +/*?*/ if ( pNewCell->GetCellType() == CELLTYPE_FORMULA ) +/*?*/ { +/*?*/ pNewCell->StartListeningTo( pDocument ); +/*?*/ ((ScFormulaCell*)pNewCell)->SetDirty(); +/*?*/ } +/*?*/ else +/*?*/ pDocument->Broadcast( ScHint( SC_HINT_DATACHANGED, +/*?*/ ScAddress( nCol, nRow, nTab ), pNewCell ) ); +/*?*/ } +/*?*/ else +/*?*/ { +/*?*/ DeleteAtIndex(i); // loeschen und Broadcast +/*?*/ } +/*N*/ } +/*N*/ else if (pNewCell) +/*N*/ { +/*N*/ Insert(nRow, pNewCell); // neu eintragen und Broadcast +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // hier keine Formate mehr fuer Formeln setzen! +/*N*/ // (werden bei der Ausgabe abgefragt) +/*N*/ +/*N*/ } +/*N*/ return bNumFmtSet; +/*N*/ } + + + +// +// GetDataEntries - Strings aus zusammenhaengendem Bereich um nRow +// + +// DATENT_MAX - max. Anzahl Eintrage in Liste fuer Auto-Eingabe +// DATENT_SEARCH - max. Anzahl Zellen, die durchsucht werden - neu: nur Strings zaehlen +#define DATENT_MAX 200 +#define DATENT_SEARCH 2000 + + + +#undef DATENT_MAX +#undef DATENT_SEARCH + + + + +/*N*/ void ScColumn::SetError( USHORT nRow, const USHORT nError) +/*N*/ { +/*N*/ if (VALIDROW(nRow)) +/*N*/ { +/*N*/ ScFormulaCell* pCell = new ScFormulaCell +/*N*/ ( pDocument, ScAddress( nCol, nRow, nTab ) ); +/*N*/ pCell->SetErrCode( nError ); +/*N*/ Insert( nRow, pCell ); +/*N*/ } +/*N*/ } + + +/*N*/ void ScColumn::SetValue( USHORT nRow, const double& rVal) +/*N*/ { +/*N*/ if (VALIDROW(nRow)) +/*N*/ { +/*N*/ ScBaseCell* pCell = new ScValueCell(rVal); +/*N*/ Insert( nRow, pCell ); +/*N*/ } +/*N*/ } + + +/*N*/ void ScColumn::SetNote( USHORT nRow, const ScPostIt& rNote) +/*N*/ { +/*N*/ BOOL bEmpty = !rNote.GetText().Len(); +/*N*/ +/*N*/ USHORT nIndex; +/*N*/ if (Search(nRow, nIndex)) +/*N*/ { +/*N*/ ScBaseCell* pCell = pItems[nIndex].pCell; +/*N*/ if (bEmpty && pCell->GetCellType() == CELLTYPE_NOTE && !pCell->GetBroadcaster()) +/*?*/ DeleteAtIndex(nIndex); +/*N*/ else +/*N*/ pCell->SetNote(rNote); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ if (!bEmpty) +/*N*/ Insert(nRow, new ScNoteCell(rNote)); +/*N*/ } +/*N*/ } + + +/*N*/ void ScColumn::GetString( USHORT nRow, String& rString ) const +/*N*/ { +/*N*/ USHORT nIndex; +/*N*/ Color* pColor; +/*N*/ if (Search(nRow, nIndex)) +/*N*/ { +/*N*/ ScBaseCell* pCell = pItems[nIndex].pCell; +/*N*/ if (pCell->GetCellType() != CELLTYPE_NOTE) +/*N*/ { +/*N*/ ULONG nFormat = GetNumberFormat( nRow ); +/*N*/ ScCellFormat::GetString( pCell, nFormat, rString, &pColor, *(pDocument->GetFormatTable()) ); +/*N*/ } +/*N*/ else +/*N*/ rString.Erase(); +/*N*/ } +/*N*/ else +/*N*/ rString.Erase(); +/*N*/ } + + +/*N*/ void ScColumn::GetInputString( USHORT nRow, String& rString ) const +/*N*/ { +/*N*/ USHORT nIndex; +/*N*/ if (Search(nRow, nIndex)) +/*N*/ { +/*?*/ ScBaseCell* pCell = pItems[nIndex].pCell; +/*?*/ if (pCell->GetCellType() != CELLTYPE_NOTE) +/*?*/ { +/*?*/ ULONG nFormat = GetNumberFormat( nRow ); +/*?*/ ScCellFormat::GetInputString( pCell, nFormat, rString, *(pDocument->GetFormatTable()) ); +/*?*/ } +/*?*/ else +/*?*/ rString.Erase(); +/*N*/ } +/*N*/ else +/*N*/ rString.Erase(); +/*N*/ } + + +/*N*/ double ScColumn::GetValue( USHORT nRow ) const +/*N*/ { +/*N*/ USHORT nIndex; +/*N*/ if (Search(nRow, nIndex)) +/*N*/ { +/*N*/ ScBaseCell* pCell = pItems[nIndex].pCell; +/*N*/ switch (pCell->GetCellType()) +/*N*/ { +/*N*/ case CELLTYPE_VALUE: +/*N*/ return ((ScValueCell*)pCell)->GetValue(); +/*N*/ break; +/*N*/ case CELLTYPE_FORMULA: +/*N*/ { +/*N*/ if (((ScFormulaCell*)pCell)->IsValue()) +/*N*/ return ((ScFormulaCell*)pCell)->GetValue(); +/*N*/ else +/*N*/ return 0.0; +/*N*/ } +/*N*/ break; +/*N*/ default: +/*N*/ return 0.0; +/*N*/ break; +/*N*/ } +/*N*/ } +/*N*/ return 0.0; +/*N*/ } + +/*N*/ BOOL ScColumn::GetNote( USHORT nRow, ScPostIt& rNote) const +/*N*/ { +/*N*/ BOOL bHasNote = FALSE; +/*N*/ USHORT nIndex; +/*N*/ if (Search(nRow, nIndex)) +/*N*/ bHasNote = pItems[nIndex].pCell->GetNote(rNote); +/*N*/ else +/*?*/ rNote.Clear(); +/*N*/ +/*N*/ return bHasNote; +/*N*/ } + + +/*N*/ CellType ScColumn::GetCellType( USHORT nRow ) const +/*N*/ { +/*N*/ USHORT nIndex; +/*N*/ if (Search(nRow, nIndex)) +/*N*/ return pItems[nIndex].pCell->GetCellType(); +/*N*/ return CELLTYPE_NONE; +/*N*/ } + + +/*N*/ USHORT ScColumn::GetErrCode( USHORT nRow ) const +/*N*/ { +/*N*/ USHORT nIndex; +/*N*/ if (Search(nRow, nIndex)) +/*N*/ { +/*N*/ ScBaseCell* pCell = pItems[nIndex].pCell; +/*N*/ if (pCell->GetCellType() == CELLTYPE_FORMULA) +/*N*/ return ((ScFormulaCell*)pCell)->GetErrCode(); +/*N*/ } +/*N*/ return 0; +/*N*/ } + + +/*N*/ BOOL ScColumn::HasStringData( USHORT nRow ) const +/*N*/ { +/*N*/ USHORT nIndex; +/*N*/ if (Search(nRow, nIndex)) +/*N*/ return (pItems[nIndex].pCell)->HasStringData(); +/*N*/ return FALSE; +/*N*/ } + + +/*N*/ BOOL ScColumn::HasValueData( USHORT nRow ) const +/*N*/ { +/*N*/ USHORT nIndex; +/*N*/ if (Search(nRow, nIndex)) +/*N*/ return (pItems[nIndex].pCell)->HasValueData(); +/*N*/ return FALSE; +/*N*/ } + + + + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_conditio.cxx b/binfilter/bf_sc/source/core/data/sc_conditio.cxx new file mode 100644 index 000000000000..033290704ade --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_conditio.cxx @@ -0,0 +1,1370 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +//------------------------------------------------------------------ + +#include "scitems.hxx" +#include <bf_sfx2/objsh.hxx> +#include <bf_svtools/itemset.hxx> +#include <bf_svtools/zforlist.hxx> +#include <rtl/math.hxx> + + +#include "conditio.hxx" +#include "cell.hxx" +#include "document.hxx" +#include "hints.hxx" +#include "rechead.hxx" +#include "stlpool.hxx" +#include "rangenam.hxx" +namespace binfilter { + +//------------------------------------------------------------------------ + +/*N*/ SV_IMPL_OP_PTRARR_SORT( ScConditionalFormats_Impl, ScConditionalFormatPtr ); + +//------------------------------------------------------------------------ + +/*N*/ BOOL lcl_HasRelRef( ScDocument* pDoc, ScTokenArray* pFormula, USHORT nRecursion = 0 ) +/*N*/ { +/*N*/ if (pFormula) +/*N*/ { +/*N*/ pFormula->Reset(); +/*N*/ ScToken* t; +/*N*/ for( t = pFormula->GetNextReferenceOrName(); t; t = pFormula->GetNextReferenceOrName() ) +/*N*/ { +/*N*/ if( t->GetType() == svIndex ) +/*N*/ { +/*?*/ ScRangeData* pRangeData = pDoc->GetRangeName()->FindIndex( t->GetIndex() ); +/*?*/ if( (t->GetOpCode() == ocName) && (nRecursion < 42) && pRangeData && +/*?*/ lcl_HasRelRef( pDoc, pRangeData->GetCode(), nRecursion + 1 ) ) +/*?*/ return TRUE; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ SingleRefData& rRef1 = t->GetSingleRef(); +/*N*/ if ( rRef1.IsColRel() || rRef1.IsRowRel() || rRef1.IsTabRel() ) +/*N*/ return TRUE; +/*?*/ if ( t->GetType() == svDoubleRef ) +/*?*/ { +/*?*/ SingleRefData& rRef2 = t->GetDoubleRef().Ref2; +/*?*/ if ( rRef2.IsColRel() || rRef2.IsRowRel() || rRef2.IsTabRel() ) +/*?*/ return TRUE; +/*?*/ } +/*N*/ } +/*N*/ +/*N*/ } +/*N*/ } +/*N*/ return FALSE; +/*N*/ } + +/*N*/ ScConditionEntry::ScConditionEntry( const ScConditionEntry& r ) : +/*N*/ eOp(r.eOp), +/*N*/ nOptions(r.nOptions), +/*N*/ nVal1(r.nVal1), +/*N*/ nVal2(r.nVal2), +/*N*/ aStrVal1(r.aStrVal1), +/*N*/ aStrVal2(r.aStrVal2), +/*N*/ bIsStr1(r.bIsStr1), +/*N*/ bIsStr2(r.bIsStr2), +/*N*/ bRelRef1(r.bRelRef1), +/*N*/ bRelRef2(r.bRelRef2), +/*N*/ pFormula1(NULL), +/*N*/ pFormula2(NULL), +/*N*/ pFCell1(NULL), +/*N*/ pFCell2(NULL), +/*N*/ pDoc(r.pDoc), +/*N*/ aSrcPos(r.aSrcPos), +/*N*/ bFirstRun(TRUE) +/*N*/ { +/*N*/ // ScTokenArray copy ctor erzeugt flache Kopie +/*N*/ +/*N*/ if (r.pFormula1) +/*N*/ pFormula1 = new ScTokenArray( *r.pFormula1 ); +/*N*/ if (r.pFormula2) +/*N*/ pFormula2 = new ScTokenArray( *r.pFormula2 ); +/*N*/ +/*N*/ // Formelzellen werden erst bei IsValid angelegt +/*N*/ } + +/*N*/ ScConditionEntry::ScConditionEntry( ScDocument* pDocument, const ScConditionEntry& r ) : +/*N*/ eOp(r.eOp), +/*N*/ nOptions(r.nOptions), +/*N*/ nVal1(r.nVal1), +/*N*/ nVal2(r.nVal2), +/*N*/ aStrVal1(r.aStrVal1), +/*N*/ aStrVal2(r.aStrVal2), +/*N*/ bIsStr1(r.bIsStr1), +/*N*/ bIsStr2(r.bIsStr2), +/*N*/ bRelRef1(r.bRelRef1), +/*N*/ bRelRef2(r.bRelRef2), +/*N*/ pFormula1(NULL), +/*N*/ pFormula2(NULL), +/*N*/ pFCell1(NULL), +/*N*/ pFCell2(NULL), +/*N*/ pDoc(pDocument), +/*N*/ aSrcPos(r.aSrcPos), +/*N*/ bFirstRun(TRUE) +/*N*/ { +/*N*/ // echte Kopie der Formeln (fuer Ref-Undo) +/*N*/ +/*N*/ if (r.pFormula1) +/*N*/ pFormula1 = r.pFormula1->Clone(); +/*N*/ if (r.pFormula2) +/*N*/ pFormula2 = r.pFormula2->Clone(); +/*N*/ +/*N*/ // Formelzellen werden erst bei IsValid angelegt +/*N*/ //! im Clipboard nicht - dann vorher interpretieren !!! +/*N*/ } + +/*N*/ ScConditionEntry::ScConditionEntry( ScConditionMode eOper, +/*N*/ const String& rExpr1, const String& rExpr2, +/*N*/ ScDocument* pDocument, const ScAddress& rPos, +/*N*/ BOOL bCompileEnglish, BOOL bCompileXML ) : +/*N*/ eOp(eOper), +/*N*/ nOptions(0), // spaeter... +/*N*/ nVal1(0.0), +/*N*/ nVal2(0.0), +/*N*/ bIsStr1(FALSE), +/*N*/ bIsStr2(FALSE), +/*N*/ bRelRef1(FALSE), +/*N*/ bRelRef2(FALSE), +/*N*/ pFormula1(NULL), +/*N*/ pFormula2(NULL), +/*N*/ pFCell1(NULL), +/*N*/ pFCell2(NULL), +/*N*/ pDoc(pDocument), +/*N*/ aSrcPos(rPos), +/*N*/ bFirstRun(TRUE) +/*N*/ { +/*N*/ Compile( rExpr1, rExpr2, bCompileEnglish, bCompileXML, FALSE ); +/*N*/ +/*N*/ // Formelzellen werden erst bei IsValid angelegt +/*N*/ } + +/*N*/ ScConditionEntry::~ScConditionEntry() +/*N*/ { +/*N*/ delete pFCell1; +/*N*/ delete pFCell2; +/*N*/ +/*N*/ delete pFormula1; +/*N*/ delete pFormula2; +/*N*/ } + +/*N*/ ScConditionEntry::ScConditionEntry( SvStream& rStream, ScMultipleReadHeader& rHdr, +/*N*/ ScDocument* pDocument ) : +/*N*/ nVal1(0.0), +/*N*/ nVal2(0.0), +/*N*/ bIsStr1(FALSE), +/*N*/ bIsStr2(FALSE), +/*N*/ bRelRef1(FALSE), +/*N*/ bRelRef2(FALSE), +/*N*/ pFormula1(NULL), +/*N*/ pFormula2(NULL), +/*N*/ pFCell1(NULL), +/*N*/ pFCell2(NULL), +/*N*/ pDoc(pDocument), +/*N*/ bFirstRun(TRUE) +/*N*/ { +/*N*/ USHORT nVer = (USHORT) pDoc->GetSrcVersion(); +/*N*/ +/*N*/ rHdr.StartEntry(); +/*N*/ +/*N*/ BYTE nOpByte; +/*N*/ rStream >> nOpByte; +/*N*/ eOp = (ScConditionMode) nOpByte; +/*N*/ +/*N*/ rStream >> nOptions; +/*N*/ +/*N*/ ScAddress aPos; +/*N*/ BYTE nTypeByte; +/*N*/ rStream >> nTypeByte; +/*N*/ ScConditionValType eType = (ScConditionValType) nTypeByte; +/*N*/ if ( eType == SC_VAL_FORMULA ) +/*N*/ { +/*N*/ rStream >> aPos; +/*N*/ pFormula1 = new ScTokenArray; +/*N*/ pFormula1->Load( rStream, nVer, aPos ); +/*N*/ bRelRef1 = lcl_HasRelRef( pDoc, pFormula1 ); +/*N*/ } +/*N*/ else if ( eType == SC_VAL_VALUE ) +/*N*/ rStream >> nVal1; +/*N*/ else +/*N*/ { +/*?*/ bIsStr1 = TRUE; +/*?*/ rStream.ReadByteString( aStrVal1, rStream.GetStreamCharSet() ); +/*N*/ } +/*N*/ +/*N*/ if ( eOp == SC_COND_BETWEEN || eOp == SC_COND_NOTBETWEEN ) +/*N*/ { +/*?*/ rStream >> nTypeByte; +/*?*/ eType = (ScConditionValType) nTypeByte; +/*?*/ if ( eType == SC_VAL_FORMULA ) +/*?*/ { +/*?*/ rStream >> aPos; +/*?*/ pFormula2 = new ScTokenArray; +/*?*/ pFormula2->Load( rStream, nVer, aPos ); +/*?*/ bRelRef2 = lcl_HasRelRef( pDoc, pFormula2 ); +/*?*/ } +/*?*/ else if ( eType == SC_VAL_VALUE ) +/*?*/ rStream >> nVal2; +/*?*/ else +/*?*/ { +/*?*/ bIsStr2 = TRUE; +/*?*/ rStream.ReadByteString( aStrVal2, rStream.GetStreamCharSet() ); +/*?*/ } +/*N*/ } +/*N*/ +/*N*/ rHdr.EndEntry(); +/*N*/ +/*N*/ aSrcPos = aPos; +/*N*/ +/*N*/ // Formelzellen werden erst bei IsValid angelegt +/*N*/ } + +/*N*/ void ScConditionEntry::StoreCondition(SvStream& rStream, ScMultipleWriteHeader& rHdr) const +/*N*/ { +/*N*/ rHdr.StartEntry(); +/*N*/ +/*N*/ // 1) Byte fuer die Operation +/*N*/ // 2) USHORT fuer Optionen +/*N*/ // 3) Byte, ob Wert, String oder Formel folgt +/*N*/ // 4) double, String oder TokenArray +/*N*/ // 5) je nach Operation 3 und 4 nochmal +/*N*/ // vor jedem TokenArray noch die Position als ScAddress +/*N*/ +/*N*/ rStream << (BYTE) eOp; +/*N*/ rStream << nOptions; +/*N*/ +/*N*/ ScConditionValType eType = +/*N*/ pFormula1 ? SC_VAL_FORMULA : ( bIsStr1 ? SC_VAL_STRING : SC_VAL_VALUE ); +/*N*/ rStream << (BYTE) eType; +/*N*/ if ( eType == SC_VAL_FORMULA ) +/*N*/ { +/*N*/ rStream << aSrcPos; +/*N*/ pFormula1->Store( rStream, aSrcPos ); +/*N*/ } +/*N*/ else if ( eType == SC_VAL_VALUE ) +/*N*/ rStream << nVal1; +/*N*/ else +/*?*/ rStream.WriteByteString( aStrVal1, rStream.GetStreamCharSet() ); +/*N*/ +/*N*/ if ( eOp == SC_COND_BETWEEN || eOp == SC_COND_NOTBETWEEN ) +/*N*/ { +/*?*/ eType = pFormula2 ? SC_VAL_FORMULA : ( bIsStr2 ? SC_VAL_STRING : SC_VAL_VALUE ); +/*?*/ rStream << (BYTE) eType; +/*?*/ if ( eType == SC_VAL_FORMULA ) +/*?*/ { +/*?*/ rStream << aSrcPos; +/*?*/ pFormula2->Store( rStream, aSrcPos ); +/*?*/ } +/*?*/ else if ( eType == SC_VAL_VALUE ) +/*?*/ rStream << nVal2; +/*?*/ else +/*?*/ rStream.WriteByteString( aStrVal2, rStream.GetStreamCharSet() ); +/*N*/ } +/*N*/ +/*N*/ rHdr.EndEntry(); +/*N*/ } + +/*N*/ void ScConditionEntry::Compile( const String& rExpr1, const String& rExpr2, +/*N*/ BOOL bEnglish, BOOL bCompileXML, BOOL bTextToReal ) +/*N*/ { +/*N*/ if ( rExpr1.Len() || rExpr2.Len() ) +/*N*/ { +/*N*/ ScCompiler aComp( pDoc, aSrcPos ); +/*N*/ aComp.SetCompileEnglish( bEnglish ); +/*N*/ aComp.SetCompileXML( bCompileXML ); +/*N*/ +/*N*/ if ( rExpr1.Len() ) +/*N*/ { +/*N*/ if ( pDoc->IsImportingXML() && !bTextToReal ) +/*N*/ { +/*?*/ // temporary formula string as string tokens +/*?*/ //! merge with lcl_ScDocFunc_CreateTokenArrayXML +/*?*/ pFormula1 = new ScTokenArray; +/*?*/ pFormula1->AddString( rExpr1 ); +/*?*/ // bRelRef1 is set when the formula is compiled again (CompileXML) +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ pFormula1 = aComp.CompileString( rExpr1 ); +/*N*/ if ( pFormula1->GetLen() == 1 ) +/*N*/ { +/*?*/ // einzelne (konstante Zahl) ? +/*?*/ ScToken* pToken = pFormula1->First(); +/*?*/ if ( pToken->GetOpCode() == ocPush ) +/*?*/ { +/*?*/ if ( pToken->GetType() == svDouble ) +/*?*/ { +/*?*/ nVal1 = pToken->GetDouble(); +/*?*/ DELETEZ(pFormula1); // nicht als Formel merken +/*?*/ } +/*?*/ else if ( pToken->GetType() == svString ) +/*?*/ { +/*?*/ bIsStr1 = TRUE; +/*?*/ aStrVal1 = pToken->GetString(); +/*?*/ DELETEZ(pFormula1); // nicht als Formel merken +/*?*/ } +/*?*/ } +/*N*/ } +/*N*/ bRelRef1 = lcl_HasRelRef( pDoc, pFormula1 ); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if ( rExpr2.Len() ) +/*N*/ { +/*N*/ if ( pDoc->IsImportingXML() && !bTextToReal ) +/*N*/ { +/*?*/ // temporary formula string as string tokens +/*?*/ //! merge with lcl_ScDocFunc_CreateTokenArrayXML +/*?*/ pFormula2 = new ScTokenArray; +/*?*/ pFormula2->AddString( rExpr2 ); +/*?*/ // bRelRef2 is set when the formula is compiled again (CompileXML) +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ pFormula2 = aComp.CompileString( rExpr2 ); +/*N*/ if ( pFormula2->GetLen() == 1 ) +/*N*/ { +/*N*/ // einzelne (konstante Zahl) ? +/*N*/ ScToken* pToken = pFormula2->First(); +/*N*/ if ( pToken->GetOpCode() == ocPush ) +/*N*/ { +/*N*/ if ( pToken->GetType() == svDouble ) +/*N*/ { +/*N*/ nVal2 = pToken->GetDouble(); +/*N*/ DELETEZ(pFormula2); // nicht als Formel merken +/*N*/ } +/*N*/ else if ( pToken->GetType() == svString ) +/*N*/ { +/*?*/ bIsStr2 = TRUE; +/*?*/ aStrVal2 = pToken->GetString(); +/*?*/ DELETEZ(pFormula2); // nicht als Formel merken +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ bRelRef2 = lcl_HasRelRef( pDoc, pFormula2 ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ void ScConditionEntry::MakeCells( const ScAddress& rPos ) // Formelzellen anlegen +/*N*/ { +/*N*/ if ( !pDoc->IsClipOrUndo() ) // nie im Clipboard rechnen! +/*N*/ { +/*N*/ if ( pFormula1 && !pFCell1 && !bRelRef1 ) +/*N*/ { +/*?*/ pFCell1 = new ScFormulaCell( pDoc, rPos, pFormula1 ); +/*?*/ pFCell1->StartListeningTo( pDoc ); +/*N*/ } +/*N*/ +/*N*/ if ( pFormula2 && !pFCell2 && !bRelRef2 ) +/*N*/ { +/*?*/ pFCell2 = new ScFormulaCell( pDoc, rPos, pFormula2 ); +/*?*/ pFCell2->StartListeningTo( pDoc ); +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ void ScConditionEntry::SetIgnoreBlank(BOOL bSet) +/*N*/ { +/*N*/ // Das Bit SC_COND_NOBLANKS wird gesetzt, wenn Blanks nicht ignoriert werden +/*N*/ // (nur bei Gueltigkeit) +/*N*/ +/*N*/ if (bSet) +/*N*/ nOptions &= ~SC_COND_NOBLANKS; +/*N*/ else +/*N*/ nOptions |= SC_COND_NOBLANKS; +/*N*/ } + + +/*N*/ void ScConditionEntry::CompileXML() +/*N*/ { +/*N*/ // Convert the text tokens that were created during XML import into real tokens: +/*N*/ // The stored string tokens contain english function names, but no XML-style references +/*N*/ +/*N*/ Compile( GetExpression(aSrcPos, 0, 0, TRUE, FALSE, TRUE), +/*N*/ GetExpression(aSrcPos, 1, 0, TRUE, FALSE, TRUE), +/*N*/ TRUE, FALSE, TRUE ); +/*N*/ } + +/*N*/ void lcl_CondUpdateInsertTab( ScTokenArray& rCode, USHORT nInsTab, USHORT nPosTab, BOOL& rChanged ) +/*N*/ { +/*N*/ // Insert table: only update absolute table references. +/*N*/ // (Similar to ScCompiler::UpdateInsertTab with bIsName=TRUE, result is the same as for named ranges) +/*N*/ // For deleting, ScCompiler::UpdateDeleteTab is used because of the handling of invalid references. +/*N*/ +/*N*/ rCode.Reset(); +/*N*/ ScToken* p = rCode.GetNextReference(); +/*N*/ while( p ) +/*N*/ { +/*N*/ SingleRefData& rRef1 = p->GetSingleRef(); +/*N*/ if ( !rRef1.IsTabRel() && nInsTab <= rRef1.nTab ) +/*N*/ { +/*?*/ rRef1.nTab += 1; +/*?*/ rRef1.nRelTab = rRef1.nTab - nPosTab; +/*?*/ rChanged = TRUE; +/*N*/ } +/*N*/ if( p->GetType() == svDoubleRef ) +/*N*/ { +/*?*/ SingleRefData& rRef2 = p->GetDoubleRef().Ref2; +/*?*/ if ( !rRef2.IsTabRel() && nInsTab <= rRef2.nTab ) +/*?*/ { +/*?*/ rRef2.nTab += 1; +/*?*/ rRef2.nRelTab = rRef2.nTab - nPosTab; +/*?*/ rChanged = TRUE; +/*N*/ } +/*N*/ } +/*N*/ p = rCode.GetNextReference(); +/*N*/ } +/*N*/ } + +/*N*/ void ScConditionEntry::UpdateReference( UpdateRefMode eUpdateRefMode, +/*N*/ const ScRange& rRange, short nDx, short nDy, short nDz ) +/*N*/ { +/*N*/ BOOL bInsertTab = ( eUpdateRefMode == URM_INSDEL && nDz == 1 ); +/*N*/ BOOL bDeleteTab = ( eUpdateRefMode == URM_INSDEL && nDz == -1 ); +/*N*/ +/*N*/ BOOL bChanged1 = FALSE; +/*N*/ BOOL bChanged2 = FALSE; +/*N*/ +/*N*/ if (pFormula1) +/*N*/ { +/*N*/ if ( bInsertTab ) +/*N*/ lcl_CondUpdateInsertTab( *pFormula1, rRange.aStart.Tab(), aSrcPos.Tab(), bChanged1 ); +/*N*/ else +/*N*/ { +/*?*/ ScCompiler aComp( pDoc, aSrcPos, *pFormula1 ); +/*?*/ if ( bDeleteTab ) +/*?*/ aComp.UpdateDeleteTab( rRange.aStart.Tab(), FALSE, TRUE, bChanged1 ); +/*?*/ else +/*?*/ aComp.UpdateNameReference( eUpdateRefMode, rRange, nDx, nDy, nDz, bChanged1 ); +/*N*/ } +/*N*/ +/*N*/ if (bChanged1) +/*?*/ DELETEZ(pFCell1); // is created again in IsValid +/*N*/ } +/*N*/ if (pFormula2) +/*N*/ { +/*?*/ if ( bInsertTab ) +/*?*/ lcl_CondUpdateInsertTab( *pFormula2, rRange.aStart.Tab(), aSrcPos.Tab(), bChanged2 ); +/*?*/ else +/*?*/ { +/*?*/ ScCompiler aComp( pDoc, aSrcPos, *pFormula2 ); +/*?*/ if ( bDeleteTab ) +/*?*/ aComp.UpdateDeleteTab( rRange.aStart.Tab(), FALSE, TRUE, bChanged2 ); +/*?*/ else +/*?*/ aComp.UpdateNameReference( eUpdateRefMode, rRange, nDx, nDy, nDz, bChanged2 ); +/*?*/ } +/*?*/ +/*?*/ if (bChanged2) +/*?*/ DELETEZ(pFCell2); // is created again in IsValid +/*N*/ } +/*N*/ } + + +//! als Vergleichsoperator ans TokenArray ??? + +/*N*/ BOOL lcl_IsEqual( const ScTokenArray* pArr1, const ScTokenArray* pArr2 ) +/*N*/ { +/*N*/ // verglichen wird nur das nicht-UPN Array +/*N*/ +/*N*/ if ( pArr1 && pArr2 ) +/*N*/ { +/*N*/ USHORT nLen = pArr1->GetLen(); +/*N*/ if ( pArr2->GetLen() != nLen ) +/*N*/ return FALSE; +/*N*/ +/*N*/ ScToken** ppToken1 = pArr1->GetArray(); +/*N*/ ScToken** ppToken2 = pArr2->GetArray(); +/*N*/ for (USHORT i=0; i<nLen; i++) +/*N*/ { +/*N*/ if ( ppToken1[i] != ppToken2[i] && +/*N*/ !(*ppToken1[i] == *ppToken2[i]) ) +/*N*/ return FALSE; // Unterschied +/*N*/ } +/*N*/ return TRUE; // alle Eintraege gleich +/*N*/ } +/*N*/ else +/*N*/ return !pArr1 && !pArr2; // beide 0 -> gleich +/*N*/ } + +/*N*/ int ScConditionEntry::operator== ( const ScConditionEntry& r ) const +/*N*/ { +/*N*/ BOOL bEq = (eOp == r.eOp && nOptions == r.nOptions && +/*N*/ lcl_IsEqual( pFormula1, r.pFormula1 ) && +/*N*/ lcl_IsEqual( pFormula2, r.pFormula2 )); +/*N*/ if (bEq) +/*N*/ { +/*N*/ // bei Formeln auch die Referenz-Tabelle vergleichen +/*N*/ if ( ( pFormula1 || pFormula2 ) && aSrcPos != r.aSrcPos ) +/*N*/ bEq = FALSE; +/*N*/ +/*N*/ // wenn keine Formeln, Werte vergleichen +/*N*/ if ( !pFormula1 && ( nVal1 != r.nVal1 || aStrVal1 != r.aStrVal1 || bIsStr1 != r.bIsStr1 ) ) +/*N*/ bEq = FALSE; +/*N*/ if ( !pFormula2 && ( nVal2 != r.nVal2 || aStrVal2 != r.aStrVal2 || bIsStr2 != r.bIsStr2 ) ) +/*N*/ bEq = FALSE; +/*N*/ } +/*N*/ +/*N*/ return bEq; +/*N*/ } + +/*N*/ void ScConditionEntry::Interpret( const ScAddress& rPos ) +/*N*/ { +/*N*/ // Formelzellen anlegen +/*N*/ // dabei koennen neue Broadcaster (Note-Zellen) ins Dokument eingefuegt werden !!!! +/*N*/ +/*N*/ if ( ( pFormula1 && !pFCell1 ) || ( pFormula2 && !pFCell2 ) ) +/*N*/ MakeCells( rPos ); +/*N*/ +/*N*/ // Formeln auswerten +/*N*/ +/*N*/ BOOL bDirty = FALSE; //! 1 und 2 getrennt ??? +/*N*/ +/*N*/ ScFormulaCell* pTemp1 = NULL; +/*N*/ ScFormulaCell* pEff1 = pFCell1; +/*N*/ if ( bRelRef1 ) +/*N*/ { +/*N*/ pTemp1 = new ScFormulaCell( pDoc, rPos, pFormula1 ); // ohne Listening +/*N*/ pEff1 = pTemp1; +/*N*/ } +/*N*/ if ( pEff1 ) +/*N*/ { +/*N*/ if (!pEff1->IsRunning()) // keine 522 erzeugen +/*N*/ { +/*N*/ //! Changed statt Dirty abfragen !!! +/*N*/ if (pEff1->GetDirty() && !bRelRef1) +/*N*/ bDirty = TRUE; +/*N*/ if (pEff1->IsValue()) +/*N*/ { +/*N*/ bIsStr1 = FALSE; +/*N*/ nVal1 = pEff1->GetValue(); +/*N*/ aStrVal1.Erase(); +/*N*/ } +/*N*/ else +/*N*/ { +/*?*/ bIsStr1 = TRUE; +/*?*/ pEff1->GetString( aStrVal1 ); +/*?*/ nVal1 = 0.0; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ delete pTemp1; +/*N*/ +/*N*/ ScFormulaCell* pTemp2 = NULL; +/*N*/ ScFormulaCell* pEff2 = pFCell2; //@ 1!=2 +/*N*/ if ( bRelRef2 ) +/*N*/ { +/*N*/ pTemp2 = new ScFormulaCell( pDoc, rPos, pFormula2 ); // ohne Listening +/*N*/ pEff2 = pTemp2; +/*N*/ } +/*N*/ if ( pEff2 ) +/*N*/ { +/*N*/ if (!pEff2->IsRunning()) // keine 522 erzeugen +/*N*/ { +/*N*/ if (pEff2->GetDirty() && !bRelRef2) +/*N*/ bDirty = TRUE; +/*N*/ if (pEff2->IsValue()) +/*N*/ { +/*N*/ bIsStr2 = FALSE; +/*N*/ nVal2 = pEff2->GetValue(); +/*N*/ aStrVal2.Erase(); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ bIsStr2 = TRUE; +/*N*/ pEff2->GetString( aStrVal2 ); +/*N*/ nVal2 = 0.0; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ delete pTemp2; +/*N*/ +/*N*/ // wenn IsRunning, bleiben die letzten Werte erhalten +/*N*/ +/*N*/ if (bDirty && !bFirstRun) +/*N*/ { +/*N*/ // bei bedingten Formaten neu painten +/*N*/ +/*N*/ DataChanged( NULL ); // alles +/*N*/ } +/*N*/ +/*N*/ bFirstRun = FALSE; +/*N*/ } + +/*N*/ BOOL ScConditionEntry::IsValid( double nArg ) const +/*N*/ { +/*N*/ // Interpret muss schon gerufen sein +/*N*/ +/*N*/ if ( bIsStr1 ) +/*N*/ { +/*N*/ // wenn auf String getestet wird, bei Zahlen immer FALSE, ausser bei "ungleich" +/*N*/ +/*N*/ return ( eOp == SC_COND_NOTEQUAL ); +/*N*/ } +/*N*/ +/*N*/ if ( eOp == SC_COND_BETWEEN || eOp == SC_COND_NOTBETWEEN ) +/*N*/ if ( bIsStr2 ) +/*N*/ return FALSE; +/*N*/ +/*N*/ double nComp1 = nVal1; // Kopie, damit vertauscht werden kann +/*N*/ double nComp2 = nVal2; +/*N*/ +/*N*/ if ( eOp == SC_COND_BETWEEN || eOp == SC_COND_NOTBETWEEN ) +/*N*/ if ( nComp1 > nComp2 ) +/*N*/ { +/*N*/ // richtige Reihenfolge fuer Wertebereich +/*N*/ double nTemp = nComp1; nComp1 = nComp2; nComp2 = nTemp; +/*N*/ } +/*N*/ +/*N*/ // Alle Grenzfaelle muessen per ::rtl::math::approxEqual getestet werden! +/*N*/ +/*N*/ BOOL bValid = FALSE; +/*N*/ switch (eOp) +/*N*/ { +/*?*/ case SC_COND_NONE: +/*?*/ break; // immer FALSE; +/*?*/ case SC_COND_EQUAL: +/*?*/ bValid = ::rtl::math::approxEqual( nArg, nComp1 ); +/*?*/ break; +/*?*/ case SC_COND_NOTEQUAL: +/*?*/ bValid = !::rtl::math::approxEqual( nArg, nComp1 ); +/*?*/ break; +/*?*/ case SC_COND_GREATER: +/*?*/ bValid = ( nArg > nComp1 ) && !::rtl::math::approxEqual( nArg, nComp1 ); +/*?*/ break; +/*?*/ case SC_COND_EQGREATER: +/*?*/ bValid = ( nArg >= nComp1 ) || ::rtl::math::approxEqual( nArg, nComp1 ); +/*?*/ break; +/*?*/ case SC_COND_LESS: +/*?*/ bValid = ( nArg < nComp1 ) && !::rtl::math::approxEqual( nArg, nComp1 ); +/*?*/ break; +/*?*/ case SC_COND_EQLESS: +/*?*/ bValid = ( nArg <= nComp1 ) || ::rtl::math::approxEqual( nArg, nComp1 ); +/*?*/ break; +/*?*/ case SC_COND_BETWEEN: +/*?*/ bValid = ( nArg >= nComp1 && nArg <= nComp2 ) || +/*?*/ ::rtl::math::approxEqual( nArg, nComp1 ) || ::rtl::math::approxEqual( nArg, nComp2 ); +/*?*/ break; +/*?*/ case SC_COND_NOTBETWEEN: +/*?*/ bValid = ( nArg < nComp1 || nArg > nComp2 ) && +/*?*/ !::rtl::math::approxEqual( nArg, nComp1 ) && !::rtl::math::approxEqual( nArg, nComp2 ); +/*?*/ break; +/*N*/ case SC_COND_DIRECT: +/*N*/ bValid = !::rtl::math::approxEqual( nComp1, 0.0 ); +/*N*/ break; +/*N*/ default: +/*N*/ DBG_ERROR("unbekannte Operation bei ScConditionEntry"); +/*N*/ break; +/*N*/ } +/*N*/ return bValid; +/*N*/ } + + +/*N*/ BOOL ScConditionEntry::IsCellValid( ScBaseCell* pCell, const ScAddress& rPos ) const +/*N*/ { +/*N*/ ((ScConditionEntry*)this)->Interpret(rPos); // Formeln auswerten +/*N*/ +/*N*/ double nArg = 0.0; +/*N*/ String aArgStr; +/*N*/ BOOL bVal = TRUE; +/*N*/ +/*N*/ if ( pCell ) +/*N*/ { +/*N*/ CellType eType = pCell->GetCellType(); +/*N*/ switch (eType) +/*N*/ { +/*?*/ case CELLTYPE_VALUE: +/*?*/ nArg = ((ScValueCell*)pCell)->GetValue(); +/*?*/ break; +/*N*/ case CELLTYPE_FORMULA: +/*N*/ { +/*N*/ ScFormulaCell* pFCell = (ScFormulaCell*)pCell; +/*N*/ bVal = pFCell->IsValue(); +/*N*/ if (bVal) +/*N*/ nArg = pFCell->GetValue(); +/*N*/ else +/*?*/ pFCell->GetString(aArgStr); +/*N*/ } +/*N*/ break; +/*?*/ case CELLTYPE_STRING: +/*?*/ case CELLTYPE_EDIT: +/*?*/ bVal = FALSE; +/*?*/ if ( eType == CELLTYPE_STRING ) +/*?*/ ((ScStringCell*)pCell)->GetString(aArgStr); +/*?*/ else +/*?*/ ((ScEditCell*)pCell)->GetString(aArgStr); +/*?*/ break; +/*N*/ +/*N*/ default: +/*N*/ pCell = NULL; // Note-Zellen wie leere +/*N*/ break; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if (!pCell) +/*N*/ if (bIsStr1) +/*N*/ bVal = FALSE; // leere Zellen je nach Bedingung +/*N*/ +/*N*/ if (bVal) +/*N*/ return IsValid( nArg ); +/*N*/ else +/*?*/ {DBG_BF_ASSERT(0, "STRIP"); return FALSE;} //STRIP001 return IsValidStr( aArgStr ); +/*N*/ } + +/*N*/ String ScConditionEntry::GetExpression( const ScAddress& rCursor, USHORT nIndex, +/*N*/ ULONG nNumFmt, BOOL bEnglish, +/*N*/ BOOL bCompileXML, BOOL bTextToReal ) const +/*N*/ { +/*N*/ String aRet; +/*N*/ +/*N*/ if ( bEnglish && nNumFmt == 0 ) +/*N*/ nNumFmt = pDoc->GetFormatTable()->GetStandardIndex( LANGUAGE_ENGLISH_US ); +/*N*/ +/*N*/ if ( nIndex==0 ) +/*N*/ { +/*N*/ if ( pFormula1 ) +/*N*/ { +/*N*/ ScCompiler aComp(pDoc, rCursor, *pFormula1); +/*N*/ aComp.SetCompileEnglish( bEnglish ); +/*N*/ aComp.SetCompileXML( bCompileXML ); +/*N*/ aComp.SetImportXML( bTextToReal ); // set only from CompileXML method +/*N*/ aComp.CreateStringFromTokenArray( aRet ); +/*N*/ } +/*N*/ else if (bIsStr1) +/*N*/ { +/*N*/ aRet = '"'; +/*N*/ aRet += aStrVal1; +/*N*/ aRet += '"'; +/*N*/ } +/*N*/ else +/*?*/ pDoc->GetFormatTable()->GetInputLineString(nVal1, nNumFmt, aRet); +/*N*/ } +/*N*/ else if ( nIndex==1 ) +/*N*/ { +/*N*/ if ( pFormula2 ) +/*N*/ { +/*?*/ ScCompiler aComp(pDoc, rCursor, *pFormula2); +/*?*/ aComp.SetCompileEnglish( bEnglish ); +/*?*/ aComp.SetCompileXML( bCompileXML ); +/*M*/ aComp.SetImportXML( bTextToReal ); // set only from CompileXML method +/*?*/ aComp.CreateStringFromTokenArray( aRet ); +/*N*/ } +/*N*/ else if (bIsStr2) +/*N*/ { +/*N*/ aRet = '"'; +/*N*/ aRet += aStrVal2; +/*N*/ aRet += '"'; +/*N*/ } +/*N*/ else +/*N*/ pDoc->GetFormatTable()->GetInputLineString(nVal2, nNumFmt, aRet); +/*N*/ } +/*N*/ else +/*N*/ DBG_ERROR("GetExpression: falscher Index"); +/*N*/ +/*N*/ return aRet; +/*N*/ } + + +/*N*/ void ScConditionEntry::SourceChanged( const ScAddress& rChanged ) +/*N*/ { +/*N*/ for (USHORT nPass = 0; nPass < 2; nPass++) +/*N*/ { +/*N*/ ScTokenArray* pFormula = nPass ? pFormula2 : pFormula1; +/*N*/ if (pFormula) +/*N*/ { +/*N*/ pFormula->Reset(); +/*N*/ ScToken* t; +/*N*/ for( t = pFormula->GetNextReference(); t; t = pFormula->GetNextReference() ) +/*N*/ { +/*N*/ SingleDoubleRefProvider aProv( *t ); +/*N*/ if ( aProv.Ref1.IsColRel() || aProv.Ref1.IsRowRel() || aProv.Ref1.IsTabRel() || +/*N*/ aProv.Ref2.IsColRel() || aProv.Ref2.IsRowRel() || aProv.Ref2.IsTabRel() ) +/*N*/ { +/*N*/ // absolut muss getroffen sein, relativ bestimmt Bereich +/*N*/ +/*N*/ BOOL bHit = TRUE; +/*N*/ INT16 nCol1, nRow1, nTab1, nCol2, nRow2, nTab2; +/*N*/ +/*N*/ if ( aProv.Ref1.IsColRel() ) +/*N*/ nCol2 = rChanged.Col() - aProv.Ref1.nRelCol; +/*N*/ else +/*N*/ { +/*N*/ bHit &= ( rChanged.Col() >= aProv.Ref1.nCol ); +/*N*/ nCol2 = MAXCOL; +/*N*/ } +/*N*/ if ( aProv.Ref1.IsRowRel() ) +/*N*/ nRow2 = rChanged.Row() - aProv.Ref1.nRelRow; +/*N*/ else +/*N*/ { +/*N*/ bHit &= ( rChanged.Row() >= aProv.Ref1.nRow ); +/*N*/ nRow2 = MAXROW; +/*N*/ } +/*N*/ if ( aProv.Ref1.IsTabRel() ) +/*N*/ nTab2 = rChanged.Tab() - aProv.Ref1.nRelTab; +/*N*/ else +/*N*/ { +/*N*/ bHit &= ( rChanged.Tab() >= aProv.Ref1.nTab ); +/*N*/ nTab2 = MAXTAB; +/*N*/ } +/*N*/ +/*N*/ if ( aProv.Ref2.IsColRel() ) +/*N*/ nCol1 = rChanged.Col() - aProv.Ref2.nRelCol; +/*N*/ else +/*N*/ { +/*N*/ bHit &= ( rChanged.Col() <= aProv.Ref2.nCol ); +/*N*/ nCol1 = 0; +/*N*/ } +/*N*/ if ( aProv.Ref2.IsRowRel() ) +/*N*/ nRow1 = rChanged.Row() - aProv.Ref2.nRelRow; +/*N*/ else +/*N*/ { +/*N*/ bHit &= ( rChanged.Row() <= aProv.Ref2.nRow ); +/*N*/ nRow1 = 0; +/*N*/ } +/*N*/ if ( aProv.Ref2.IsTabRel() ) +/*N*/ nTab1 = rChanged.Tab() - aProv.Ref2.nRelTab; +/*N*/ else +/*N*/ { +/*N*/ bHit &= ( rChanged.Tab() <= aProv.Ref2.nTab ); +/*N*/ nTab1 = 0; +/*N*/ } +/*N*/ +/*N*/ if ( bHit ) +/*N*/ { +/*N*/ //! begrenzen +/*N*/ +/*N*/ ScRange aPaint( nCol1,nRow1,nTab1, nCol2,nRow2,nTab2 ); +/*N*/ +/*N*/ // kein Paint, wenn es nur die Zelle selber ist +/*N*/ if ( aPaint.aStart != rChanged || aPaint.aEnd != rChanged ) +/*N*/ DataChanged( &aPaint ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ void ScConditionEntry::DataChanged( const ScRange* pModified ) const +/*N*/ { +/*N*/ // nix +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ ScCondFormatEntry::ScCondFormatEntry( ScConditionMode eOper, +/*N*/ const String& rExpr1, const String& rExpr2, +/*N*/ ScDocument* pDocument, const ScAddress& rPos, +/*N*/ const String& rStyle, +/*N*/ BOOL bCompileEnglish, BOOL bCompileXML ) : +/*N*/ ScConditionEntry( eOper, rExpr1, rExpr2, pDocument, rPos, bCompileEnglish, bCompileXML ), +/*N*/ aStyleName( rStyle ), +/*N*/ pParent( NULL ) +/*N*/ { +/*N*/ } + +/*N*/ ScCondFormatEntry::ScCondFormatEntry( const ScCondFormatEntry& r ) : +/*N*/ ScConditionEntry( r ), +/*N*/ aStyleName( r.aStyleName ), +/*N*/ pParent( NULL ) +/*N*/ { +/*N*/ } + +/*N*/ ScCondFormatEntry::ScCondFormatEntry( ScDocument* pDocument, const ScCondFormatEntry& r ) : +/*N*/ ScConditionEntry( pDocument, r ), +/*N*/ aStyleName( r.aStyleName ), +/*N*/ pParent( NULL ) +/*N*/ { +/*N*/ } + +/*N*/ ScCondFormatEntry::ScCondFormatEntry( SvStream& rStream, ScMultipleReadHeader& rHdr, +/*N*/ ScDocument* pDocument ) : +/*N*/ ScConditionEntry( rStream, rHdr, pDocument ), +/*N*/ pParent( NULL ) +/*N*/ { +/*N*/ // im Datei-Header sind getrennte Eintraege fuer ScConditionEntry und ScCondFormatEntry +/*N*/ +/*N*/ rHdr.StartEntry(); +/*N*/ rStream.ReadByteString( aStyleName, rStream.GetStreamCharSet() ); +/*N*/ rHdr.EndEntry(); +/*N*/ } + +/*N*/ void ScCondFormatEntry::Store(SvStream& rStream, ScMultipleWriteHeader& rHdr) const +/*N*/ { +/*N*/ // im Datei-Header sind getrennte Eintraege fuer ScConditionEntry und ScCondFormatEntry +/*N*/ +/*N*/ StoreCondition( rStream, rHdr ); +/*N*/ +/*N*/ rHdr.StartEntry(); +/*N*/ rStream.WriteByteString( aStyleName, rStream.GetStreamCharSet() ); +/*N*/ rHdr.EndEntry(); +/*N*/ } + + +/*N*/ int ScCondFormatEntry::operator== ( const ScCondFormatEntry& r ) const +/*N*/ { +/*N*/ return ScConditionEntry::operator==( r ) && +/*N*/ aStyleName == r.aStyleName; +/*N*/ +/*N*/ // Range wird nicht verglichen +/*N*/ } + +/*N*/ ScCondFormatEntry::~ScCondFormatEntry() +/*N*/ { +/*N*/ } + +/*N*/ void ScCondFormatEntry::DataChanged( const ScRange* pModified ) const +/*N*/ { +/*N*/ if ( pParent ) +/*N*/ pParent->DoRepaint( pModified ); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ ScConditionalFormat::ScConditionalFormat(sal_uInt32 nNewKey, ScDocument* pDocument) : +/*N*/ pDoc( pDocument ), +/*N*/ pAreas( NULL ), +/*N*/ nKey( nNewKey ), +/*N*/ ppEntries( NULL ), +/*N*/ nEntryCount( 0 ) +/*N*/ { +/*N*/ } + +/*N*/ ScConditionalFormat::ScConditionalFormat(const ScConditionalFormat& r) : +/*N*/ pDoc( r.pDoc ), +/*N*/ pAreas( NULL ), +/*N*/ nKey( r.nKey ), +/*N*/ ppEntries( NULL ), +/*N*/ nEntryCount( r.nEntryCount ) +/*N*/ { +/*N*/ if (nEntryCount) +/*N*/ { +/*N*/ ppEntries = new ScCondFormatEntry*[nEntryCount]; +/*N*/ for (USHORT i=0; i<nEntryCount; i++) +/*N*/ { +/*N*/ ppEntries[i] = new ScCondFormatEntry(*r.ppEntries[i]); +/*N*/ ppEntries[i]->SetParent(this); +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ ScConditionalFormat* ScConditionalFormat::Clone(ScDocument* pNewDoc) const +/*N*/ { +/*N*/ // echte Kopie der Formeln (fuer Ref-Undo / zwischen Dokumenten) +/*N*/ +/*N*/ if (!pNewDoc) +/*N*/ pNewDoc = pDoc; +/*N*/ +/*N*/ ScConditionalFormat* pNew = new ScConditionalFormat(nKey, pNewDoc); +/*N*/ DBG_ASSERT(!pNew->ppEntries, "wo kommen die Eintraege her?"); +/*N*/ +/*N*/ if (nEntryCount) +/*N*/ { +/*N*/ pNew->ppEntries = new ScCondFormatEntry*[nEntryCount]; +/*N*/ for (USHORT i=0; i<nEntryCount; i++) +/*N*/ { +/*N*/ pNew->ppEntries[i] = new ScCondFormatEntry( pNewDoc, *ppEntries[i] ); +/*N*/ pNew->ppEntries[i]->SetParent(pNew); +/*N*/ } +/*N*/ pNew->nEntryCount = nEntryCount; +/*N*/ } +/*N*/ +/*N*/ return pNew; +/*N*/ } + +/*N*/ ScConditionalFormat::ScConditionalFormat(SvStream& rStream, ScMultipleReadHeader& rHdr, +/*N*/ ScDocument* pDocument) : +/*N*/ pDoc( pDocument ), +/*N*/ pAreas( NULL ), +/*N*/ ppEntries( NULL ), +/*N*/ nEntryCount( 0 ) +/*N*/ { +/*N*/ // ein Eintrag im Header fuer die ScConditionalFormat-Daten, +/*N*/ // je zwei Eintraege fuer jede Bedingung (ScConditionEntry und ScCondFormatEntry) +/*N*/ +/*N*/ rHdr.StartEntry(); +/*N*/ +/*N*/ rStream >> nKey; +/*N*/ rStream >> nEntryCount; +/*N*/ +/*N*/ rHdr.EndEntry(); +/*N*/ +/*N*/ // Eintraege laden +/*N*/ +/*N*/ if (nEntryCount) +/*N*/ { +/*N*/ ppEntries = new ScCondFormatEntry*[nEntryCount]; +/*N*/ for (USHORT i=0; i<nEntryCount; i++) +/*N*/ { +/*N*/ ppEntries[i] = new ScCondFormatEntry(rStream, rHdr, pDocument); +/*N*/ ppEntries[i]->SetParent(this); +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ void ScConditionalFormat::Store(SvStream& rStream, ScMultipleWriteHeader& rHdr) const +/*N*/ { +/*N*/ // ein Eintrag im Header fuer die ScConditionalFormat-Daten, +/*N*/ // je zwei Eintraege fuer jede Bedingung (ScConditionEntry und ScCondFormatEntry) +/*N*/ +/*N*/ rHdr.StartEntry(); +/*N*/ +/*N*/ rStream << nKey; +/*N*/ rStream << nEntryCount; +/*N*/ +/*N*/ rHdr.EndEntry(); +/*N*/ +/*N*/ // Eintraege speichern +/*N*/ +/*N*/ for (USHORT i=0; i<nEntryCount; i++) +/*N*/ ppEntries[i]->Store(rStream, rHdr); +/*N*/ } + +/*N*/ BOOL ScConditionalFormat::EqualEntries( const ScConditionalFormat& r ) const +/*N*/ { +/*N*/ if ( nEntryCount != r.nEntryCount ) +/*N*/ return FALSE; +/*N*/ +/*N*/ //! auf gleiche Eintraege in anderer Reihenfolge testen ??? +/*N*/ +/*N*/ for (USHORT i=0; i<nEntryCount; i++) +/*N*/ if ( ! (*ppEntries[i] == *r.ppEntries[i]) ) +/*N*/ return FALSE; +/*N*/ +/*N*/ return TRUE; +/*N*/ } + +/*N*/ void ScConditionalFormat::AddEntry( const ScCondFormatEntry& rNew ) +/*N*/ { +/*N*/ ScCondFormatEntry** ppNew = new ScCondFormatEntry*[nEntryCount+1]; +/*N*/ for (USHORT i=0; i<nEntryCount; i++) +/*N*/ ppNew[i] = ppEntries[i]; +/*N*/ ppNew[nEntryCount] = new ScCondFormatEntry(rNew); +/*N*/ ppNew[nEntryCount]->SetParent(this); +/*N*/ ++nEntryCount; +/*N*/ delete[] ppEntries; +/*N*/ ppEntries = ppNew; +/*N*/ } + +/*N*/ ScConditionalFormat::~ScConditionalFormat() +/*N*/ { +/*N*/ for (USHORT i=0; i<nEntryCount; i++) +/*N*/ delete ppEntries[i]; +/*N*/ delete[] ppEntries; +/*N*/ +/*N*/ delete pAreas; +/*N*/ } + +/*N*/ const ScCondFormatEntry* ScConditionalFormat::GetEntry( USHORT nPos ) const +/*N*/ { +/*N*/ if ( nPos < nEntryCount ) +/*N*/ return ppEntries[nPos]; +/*N*/ else +/*N*/ return NULL; +/*N*/ } + +/*N*/ const String& ScConditionalFormat::GetCellStyle( ScBaseCell* pCell, const ScAddress& rPos ) const +/*N*/ { +/*N*/ for (USHORT i=0; i<nEntryCount; i++) +/*N*/ if ( ppEntries[i]->IsCellValid( pCell, rPos ) ) +/*N*/ return ppEntries[i]->GetStyle(); +/*N*/ +/*N*/ return EMPTY_STRING; +/*N*/ } + +/*N*/ void lcl_Extend( ScRange& rRange, ScDocument* pDoc, BOOL bLines ) +/*N*/ { +/*N*/ USHORT nTab = rRange.aStart.Tab(); +/*N*/ DBG_ASSERT(rRange.aEnd.Tab() == nTab, "lcl_Extend - mehrere Tabellen?"); +/*N*/ +/*N*/ USHORT nStartCol = rRange.aStart.Col(); +/*N*/ USHORT nStartRow = rRange.aStart.Row(); +/*N*/ USHORT nEndCol = rRange.aEnd.Col(); +/*N*/ USHORT nEndRow = rRange.aEnd.Row(); +/*N*/ +/*N*/ BOOL bEx = pDoc->ExtendMerge( nStartCol, nStartRow, nEndCol, nEndRow, nTab ); +/*N*/ +/*N*/ if (bLines) +/*N*/ { +/*N*/ if (nStartCol > 0) --nStartCol; +/*N*/ if (nStartRow > 0) --nStartRow; +/*N*/ if (nEndCol < MAXCOL) ++nEndCol; +/*N*/ if (nEndRow < MAXROW) ++nEndRow; +/*N*/ } +/*N*/ +/*N*/ if ( bEx || bLines ) +/*N*/ { +/*N*/ rRange.aStart.Set( nStartCol, nStartRow, nTab ); +/*N*/ rRange.aEnd.Set( nEndCol, nEndRow, nTab ); +/*N*/ } +/*N*/ } + +/*N*/ BOOL lcl_CutRange( ScRange& rRange, const ScRange& rOther ) +/*N*/ { +/*N*/ rRange.Justify(); +/*N*/ ScRange aCmpRange = rOther; +/*N*/ aCmpRange.Justify(); +/*N*/ +/*N*/ if ( rRange.aStart.Col() <= aCmpRange.aEnd.Col() && +/*N*/ rRange.aEnd.Col() >= aCmpRange.aStart.Col() && +/*N*/ rRange.aStart.Row() <= aCmpRange.aEnd.Row() && +/*N*/ rRange.aEnd.Row() >= aCmpRange.aStart.Row() && +/*N*/ rRange.aStart.Tab() <= aCmpRange.aEnd.Tab() && +/*N*/ rRange.aEnd.Tab() >= aCmpRange.aStart.Tab() ) +/*N*/ { +/*N*/ if ( rRange.aStart.Col() < aCmpRange.aStart.Col() ) +/*N*/ rRange.aStart.SetCol( aCmpRange.aStart.Col() ); +/*N*/ if ( rRange.aStart.Row() < aCmpRange.aStart.Row() ) +/*N*/ rRange.aStart.SetRow( aCmpRange.aStart.Row() ); +/*N*/ if ( rRange.aStart.Tab() < aCmpRange.aStart.Tab() ) +/*N*/ rRange.aStart.SetTab( aCmpRange.aStart.Tab() ); +/*N*/ if ( rRange.aEnd.Col() > aCmpRange.aEnd.Col() ) +/*N*/ rRange.aEnd.SetCol( aCmpRange.aEnd.Col() ); +/*N*/ if ( rRange.aEnd.Row() > aCmpRange.aEnd.Row() ) +/*N*/ rRange.aEnd.SetRow( aCmpRange.aEnd.Row() ); +/*N*/ if ( rRange.aEnd.Tab() > aCmpRange.aEnd.Tab() ) +/*N*/ rRange.aEnd.SetTab( aCmpRange.aEnd.Tab() ); +/*N*/ +/*N*/ return TRUE; +/*N*/ } +/*N*/ +/*N*/ return FALSE; // ausserhalb +/*N*/ } + +/*N*/ void ScConditionalFormat::DoRepaint( const ScRange* pModified ) +/*N*/ { +/*N*/ USHORT i; +/*N*/ SfxObjectShell* pSh = pDoc->GetDocumentShell(); +/*N*/ if (pSh) +/*N*/ { +/*N*/ // Rahmen/Schatten enthalten? +/*N*/ // (alle Bedingungen testen) +/*N*/ BOOL bExtend = FALSE; +/*N*/ BOOL bRotate = FALSE; +/*N*/ for (i=0; i<nEntryCount; i++) +/*N*/ { +/*N*/ String aStyle = ppEntries[i]->GetStyle(); +/*N*/ if (aStyle.Len()) +/*N*/ { +/*N*/ SfxStyleSheetBase* pStyleSheet = +/*N*/ pDoc->GetStyleSheetPool()->Find( aStyle, SFX_STYLE_FAMILY_PARA ); +/*N*/ if ( pStyleSheet ) +/*N*/ { +/*N*/ const SfxItemSet& rSet = pStyleSheet->GetItemSet(); +/*N*/ if (rSet.GetItemState( ATTR_BORDER, TRUE ) == SFX_ITEM_SET || +/*N*/ rSet.GetItemState( ATTR_SHADOW, TRUE ) == SFX_ITEM_SET) +/*N*/ { +/*N*/ bExtend = TRUE; +/*N*/ } +/*N*/ if (rSet.GetItemState( ATTR_ROTATE_VALUE, TRUE ) == SFX_ITEM_SET || +/*N*/ rSet.GetItemState( ATTR_ROTATE_MODE, TRUE ) == SFX_ITEM_SET) +/*N*/ { +/*N*/ bRotate = TRUE; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if (!pAreas) // RangeList ggf. holen +/*N*/ { +/*N*/ pAreas = new ScRangeList; +/*N*/ pDoc->FindConditionalFormat( nKey, *pAreas ); +/*N*/ } +/*N*/ USHORT nCount = (USHORT) pAreas->Count(); +/*N*/ for (i=0; i<nCount; i++) +/*N*/ { +/*N*/ ScRange aRange = *pAreas->GetObject(i); +/*N*/ BOOL bDo = TRUE; +/*N*/ if ( pModified ) +/*N*/ { +/*N*/ if ( !lcl_CutRange( aRange, *pModified ) ) +/*N*/ bDo = FALSE; +/*N*/ } +/*N*/ if (bDo) +/*N*/ { +/*N*/ lcl_Extend( aRange, pDoc, bExtend ); // zusammengefasste und bExtend +/*N*/ if ( bRotate ) +/*N*/ { +/*?*/ aRange.aStart.SetCol(0); +/*?*/ aRange.aEnd.SetCol(MAXCOL); // gedreht: ganze Zeilen +/*N*/ } +/*N*/ +/*N*/ // gedreht -> ganze Zeilen +/*N*/ if ( aRange.aStart.Col() != 0 || aRange.aEnd.Col() != MAXCOL ) +/*N*/ { +/*N*/ if ( pDoc->HasAttrib( 0,aRange.aStart.Row(),aRange.aStart.Tab(), +/*N*/ MAXCOL,aRange.aEnd.Row(),aRange.aEnd.Tab(), +/*N*/ HASATTR_ROTATE ) ) +/*N*/ { +/*?*/ aRange.aStart.SetCol(0); +/*?*/ aRange.aEnd.SetCol(MAXCOL); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ pSh->Broadcast( ScPaintHint( aRange, PAINT_GRID ) ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ void ScConditionalFormat::InvalidateArea() +/*N*/ { +/*N*/ delete pAreas; +/*N*/ pAreas = NULL; +/*N*/ } + + +/*N*/ void ScConditionalFormat::CompileXML() +/*N*/ { +/*N*/ for (USHORT i=0; i<nEntryCount; i++) +/*N*/ ppEntries[i]->CompileXML(); +/*N*/ } + +/*N*/ void ScConditionalFormat::UpdateReference( UpdateRefMode eUpdateRefMode, +/*N*/ const ScRange& rRange, short nDx, short nDy, short nDz ) +/*N*/ { +/*N*/ for (USHORT i=0; i<nEntryCount; i++) +/*N*/ ppEntries[i]->UpdateReference(eUpdateRefMode, rRange, nDx, nDy, nDz); +/*N*/ +/*N*/ delete pAreas; // aus dem AttrArray kommt beim Einfuegen/Loeschen kein Aufruf +/*N*/ pAreas = NULL; +/*N*/ } + + +/*N*/ void ScConditionalFormat::SourceChanged( const ScAddress& rAddr ) +/*N*/ { +/*N*/ for (USHORT i=0; i<nEntryCount; i++) +/*N*/ ppEntries[i]->SourceChanged( rAddr ); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ ScConditionalFormatList::ScConditionalFormatList(const ScConditionalFormatList& rList) +/*N*/ { +/*N*/ // fuer Ref-Undo - echte Kopie mit neuen Tokens! +/*N*/ +/*N*/ USHORT nCount = rList.Count(); +/*N*/ +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ InsertNew( rList[i]->Clone() ); +/*N*/ +/*N*/ //! sortierte Eintraege aus rList schneller einfuegen ??? +/*N*/ } + +/*N*/ void ScConditionalFormatList::Load( SvStream& rStream, ScDocument* pDocument ) +/*N*/ { +/*N*/ ScMultipleReadHeader aHdr( rStream ); +/*N*/ +/*N*/ USHORT nNewCount; +/*N*/ rStream >> nNewCount; +/*N*/ +/*N*/ for (USHORT i=0; i<nNewCount; i++) +/*N*/ { +/*N*/ ScConditionalFormat* pNew = new ScConditionalFormat( rStream, aHdr, pDocument ); +/*N*/ InsertNew( pNew ); +/*N*/ } +/*N*/ } + +/*N*/ void ScConditionalFormatList::Store( SvStream& rStream ) const +/*N*/ { +/*N*/ USHORT i; +/*N*/ ScMultipleWriteHeader aHdr( rStream ); +/*N*/ +/*N*/ USHORT nCount = Count(); +/*N*/ USHORT nUsed = 0; +/*N*/ for (i=0; i<nCount; i++) +/*N*/ if ((*this)[i]->IsUsed()) +/*N*/ ++nUsed; +/*N*/ +/*N*/ rStream << nUsed; // Anzahl der gespeicherten +/*N*/ +/*N*/ for (i=0; i<nCount; i++) +/*N*/ { +/*N*/ const ScConditionalFormat* pForm = (*this)[i]; +/*N*/ if (pForm->IsUsed()) +/*N*/ pForm->Store( rStream, aHdr ); +/*N*/ } +/*N*/ } + +/*N*/ ScConditionalFormat* ScConditionalFormatList::GetFormat( sal_uInt32 nKey ) +/*N*/ { +/*N*/ //! binaer suchen +/*N*/ +/*N*/ USHORT nCount = Count(); +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ if ((*this)[i]->GetKey() == nKey) +/*N*/ return (*this)[i]; +/*N*/ +/*N*/ DBG_ERROR("ScConditionalFormatList: Eintrag nicht gefunden"); +/*N*/ return NULL; +/*N*/ } + +/*N*/ void ScConditionalFormatList::ResetUsed() +/*N*/ { +/*N*/ USHORT nCount = Count(); +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ (*this)[i]->SetUsed(FALSE); +/*N*/ } + + +/*N*/ void ScConditionalFormatList::CompileXML() +/*N*/ { +/*N*/ USHORT nCount = Count(); +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ (*this)[i]->CompileXML(); +/*N*/ } + +/*N*/ void ScConditionalFormatList::UpdateReference( UpdateRefMode eUpdateRefMode, +/*N*/ const ScRange& rRange, short nDx, short nDy, short nDz ) +/*N*/ { +/*N*/ USHORT nCount = Count(); +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ (*this)[i]->UpdateReference( eUpdateRefMode, rRange, nDx, nDy, nDz ); +/*N*/ } + + +/*N*/ void ScConditionalFormatList::SourceChanged( const ScAddress& rAddr ) +/*N*/ { +/*N*/ USHORT nCount = Count(); +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ (*this)[i]->SourceChanged( rAddr ); +/*N*/ } + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_dbdocutl.cxx b/binfilter/bf_sc/source/core/data/sc_dbdocutl.cxx new file mode 100644 index 000000000000..35b9bcc4e5f0 --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_dbdocutl.cxx @@ -0,0 +1,195 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// INCLUDE --------------------------------------------------------------- + +#include <com/sun/star/sdbc/DataType.hpp> +#include <com/sun/star/sdbc/XRow.hpp> + +#include <bf_svtools/zforlist.hxx> + +#include "dbdocutl.hxx" +#include "document.hxx" +#include "cell.hxx" +namespace binfilter { + +using namespace ::com::sun::star; + +#define D_TIMEFACTOR 86400.0 + +// ----------------------------------------------------------------------- + +// static +/*N*/ void ScDatabaseDocUtil::PutData( ScDocument* pDoc, USHORT nCol, USHORT nRow, USHORT nTab, +/*N*/ const uno::Reference<sdbc::XRow>& xRow, long nRowPos, +/*N*/ long nType, BOOL bCurrency, BOOL* pSimpleFlag ) +/*N*/ { +/*N*/ String aString; +/*N*/ double nVal = 0.0; +/*N*/ BOOL bValue = FALSE; +/*N*/ BOOL bEmptyFlag = FALSE; +/*N*/ BOOL bError = FALSE; +/*N*/ ULONG nFormatIndex = 0; +/*N*/ +/*N*/ //! wasNull calls only if null value was found? +/*N*/ +/*N*/ try +/*N*/ { +/*N*/ switch ( nType ) +/*N*/ { +/*N*/ case sdbc::DataType::BIT: +/*N*/ //! use language from doc (here, date/time and currency)? +/*N*/ nFormatIndex = pDoc->GetFormatTable()->GetStandardFormat( +/*N*/ NUMBERFORMAT_LOGICAL, ScGlobal::eLnge ); +/*N*/ nVal = (xRow->getBoolean(nRowPos) ? 1 : 0); +/*N*/ bEmptyFlag = ( nVal == 0.0 ) && xRow->wasNull(); +/*N*/ bValue = TRUE; +/*N*/ break; +/*N*/ +/*N*/ case sdbc::DataType::TINYINT: +/*N*/ case sdbc::DataType::SMALLINT: +/*N*/ case sdbc::DataType::INTEGER: +/*N*/ case sdbc::DataType::BIGINT: +/*N*/ case sdbc::DataType::FLOAT: +/*N*/ case sdbc::DataType::REAL: +/*N*/ case sdbc::DataType::DOUBLE: +/*N*/ case sdbc::DataType::NUMERIC: +/*N*/ case sdbc::DataType::DECIMAL: +/*N*/ //! do the conversion here? +/*N*/ nVal = xRow->getDouble(nRowPos); +/*N*/ bEmptyFlag = ( nVal == 0.0 ) && xRow->wasNull(); +/*N*/ bValue = TRUE; +/*N*/ break; +/*N*/ +/*N*/ case sdbc::DataType::CHAR: +/*N*/ case sdbc::DataType::VARCHAR: +/*N*/ case sdbc::DataType::LONGVARCHAR: +/*N*/ aString = xRow->getString(nRowPos); +/*N*/ bEmptyFlag = ( aString.Len() == 0 ) && xRow->wasNull(); +/*N*/ break; +/*N*/ +/*N*/ case sdbc::DataType::DATE: +/*N*/ { +/*N*/ SvNumberFormatter* pFormTable = pDoc->GetFormatTable(); +/*N*/ nFormatIndex = pFormTable->GetStandardFormat( +/*N*/ NUMBERFORMAT_DATE, ScGlobal::eLnge ); +/*N*/ +/*N*/ util::Date aDate = xRow->getDate(nRowPos); +/*N*/ nVal = Date( aDate.Day, aDate.Month, aDate.Year ) - +/*N*/ *pFormTable->GetNullDate(); +/*N*/ bEmptyFlag = xRow->wasNull(); +/*N*/ bValue = TRUE; +/*N*/ } +/*N*/ break; +/*N*/ +/*N*/ case sdbc::DataType::TIME: +/*N*/ { +/*N*/ SvNumberFormatter* pFormTable = pDoc->GetFormatTable(); +/*N*/ nFormatIndex = pFormTable->GetStandardFormat( +/*N*/ NUMBERFORMAT_TIME, ScGlobal::eLnge ); +/*N*/ +/*N*/ util::Time aTime = xRow->getTime(nRowPos); +/*N*/ nVal = ( aTime.Hours * 3600 + aTime.Minutes * 60 + +/*N*/ aTime.Seconds + aTime.HundredthSeconds / 100.0 ) / D_TIMEFACTOR; +/*N*/ bEmptyFlag = xRow->wasNull(); +/*N*/ bValue = TRUE; +/*N*/ } +/*N*/ break; +/*N*/ +/*N*/ case sdbc::DataType::TIMESTAMP: +/*N*/ { +/*N*/ SvNumberFormatter* pFormTable = pDoc->GetFormatTable(); +/*N*/ nFormatIndex = pFormTable->GetStandardFormat( +/*N*/ NUMBERFORMAT_DATETIME, ScGlobal::eLnge ); +/*N*/ +/*N*/ util::DateTime aStamp = xRow->getTimestamp(nRowPos); +/*N*/ nVal = ( Date( aStamp.Day, aStamp.Month, aStamp.Year ) - +/*N*/ *pFormTable->GetNullDate() ) + +/*N*/ ( aStamp.Hours * 3600 + aStamp.Minutes * 60 + +/*N*/ aStamp.Seconds + aStamp.HundredthSeconds / 100.0 ) / D_TIMEFACTOR; +/*N*/ bEmptyFlag = xRow->wasNull(); +/*N*/ bValue = TRUE; +/*N*/ } +/*N*/ break; +/*N*/ +/*N*/ case sdbc::DataType::SQLNULL: +/*N*/ bEmptyFlag = TRUE; +/*N*/ break; +/*N*/ +/*N*/ case sdbc::DataType::BINARY: +/*N*/ case sdbc::DataType::VARBINARY: +/*N*/ case sdbc::DataType::LONGVARBINARY: +/*N*/ default: +/*N*/ bError = TRUE; // unknown type +/*N*/ } +/*N*/ } +/*N*/ catch ( uno::Exception& ) +/*N*/ { +/*N*/ bError = TRUE; +/*N*/ } +/*N*/ +/*N*/ if ( bValue && bCurrency ) +/*N*/ nFormatIndex = pDoc->GetFormatTable()->GetStandardFormat( +/*N*/ NUMBERFORMAT_CURRENCY, ScGlobal::eLnge ); +/*N*/ +/*N*/ ScBaseCell* pCell; +/*N*/ if (bEmptyFlag) +/*N*/ { +/*N*/ pCell = NULL; +/*N*/ pDoc->PutCell( nCol, nRow, nTab, pCell ); +/*N*/ } +/*N*/ else if (bError) +/*N*/ { +/*N*/ pDoc->SetError( nCol, nRow, nTab, NOVALUE ); +/*N*/ } +/*N*/ else if (bValue) +/*N*/ { +/*?*/ pCell = new ScValueCell( nVal ); +/*N*/ if (nFormatIndex == 0) +/*N*/ pDoc->PutCell( nCol, nRow, nTab, pCell ); +/*N*/ else +/*N*/ pDoc->PutCell( nCol, nRow, nTab, pCell, nFormatIndex ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ if (aString.Len()) +/*N*/ { +/*N*/ pCell = ScBaseCell::CreateTextCell( aString, pDoc ); +/*N*/ if ( pSimpleFlag && pCell->GetCellType() == CELLTYPE_EDIT ) +/*N*/ *pSimpleFlag = FALSE; +/*N*/ } +/*N*/ else +/*N*/ pCell = NULL; +/*N*/ pDoc->PutCell( nCol, nRow, nTab, pCell ); +/*N*/ } +/*N*/ } + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_dociter.cxx b/binfilter/bf_sc/source/core/data/sc_dociter.cxx new file mode 100644 index 000000000000..abcf5a17368f --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_dociter.cxx @@ -0,0 +1,997 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include <bf_svtools/zforlist.hxx> + +#include "dociter.hxx" +#include "document.hxx" +#include "cell.hxx" +#include "attarray.hxx" +#include "docoptio.hxx" +namespace binfilter { + +//------------------------------------------------------------------------ +//------------------------------------------------------------------------ +void lcl_IterGetNumberFormat( ULONG& nFormat, const ScAttrArray*& rpArr, + USHORT& nAttrEndRow, const ScAttrArray* pNewArr, USHORT nRow, + ScDocument* pDoc ) +{ + DBG_BF_ASSERT(0, "STRIP"); //STRIP001 if ( rpArr != pNewArr || nAttrEndRow < nRow ) +} + +/*N*/ ScValueIterator::ScValueIterator( ScDocument* pDocument, const ScRange& rRange, +/*N*/ BOOL bSTotal, BOOL bTextZero ) : +/*N*/ pDoc( pDocument ), +/*N*/ nStartCol( rRange.aStart.Col() ), +/*N*/ nStartRow( rRange.aStart.Row() ), +/*N*/ nStartTab( rRange.aStart.Tab() ), +/*N*/ nEndCol( rRange.aEnd.Col() ), +/*N*/ nEndRow( rRange.aEnd.Row() ), +/*N*/ nEndTab( rRange.aEnd.Tab() ), +/*N*/ bSubTotal(bSTotal), +/*N*/ nNumFmtType( NUMBERFORMAT_UNDEFINED ), +/*N*/ nNumFmtIndex(0), +/*N*/ bNumValid( FALSE ), +/*N*/ bNextValid( FALSE ), +/*N*/ bCalcAsShown( pDocument->GetDocOptions().IsCalcAsShown() ), +/*N*/ bTextAsZero( bTextZero ) +/*N*/ { +/*N*/ PutInOrder( nStartCol, nEndCol); +/*N*/ PutInOrder( nStartRow, nEndRow); +/*N*/ PutInOrder( nStartTab, nEndTab ); +/*N*/ +/*N*/ if (nStartCol > MAXCOL) nStartCol = MAXCOL; +/*N*/ if (nEndCol > MAXCOL) nEndCol = MAXCOL; +/*N*/ if (nStartRow > MAXROW) nStartRow = MAXROW; +/*N*/ if (nEndRow > MAXROW) nEndRow = MAXROW; +/*N*/ if (nStartTab > MAXTAB) nStartTab = MAXTAB; +/*N*/ if (nEndTab > MAXTAB) nEndTab = MAXTAB; +/*N*/ +/*N*/ nCol = nStartCol; +/*N*/ nRow = nStartRow; +/*N*/ nTab = nStartTab; +/*N*/ +/*N*/ nColRow = 0; // wird bei GetFirst initialisiert +/*N*/ +/*N*/ nNumFormat = 0; // werden bei GetNumberFormat initialisiert +/*N*/ pAttrArray = 0; +/*N*/ nAttrEndRow = 0; +/*N*/ } + +/*N*/ BOOL ScValueIterator::GetThis(double& rValue, USHORT& rErr) +/*N*/ { +/*N*/ ScColumn* pCol = &(pDoc->pTab[nTab])->aCol[nCol]; +/*N*/ for (;;) +/*N*/ { +/*N*/ if ( nRow > nEndRow ) +/*N*/ { +/*N*/ nRow = nStartRow; +/*N*/ do +/*N*/ { +/*N*/ nCol++; +/*N*/ if ( nCol > nEndCol ) +/*N*/ { +/*N*/ nCol = nStartCol; +/*N*/ nTab++; +/*N*/ if ( nTab > nEndTab ) +/*N*/ { +/*N*/ rValue = 0.0; +/*N*/ rErr = 0; +/*N*/ return FALSE; // Ende und Aus +/*N*/ } +/*N*/ } +/*N*/ pCol = &(pDoc->pTab[nTab])->aCol[nCol]; +/*N*/ } while ( pCol->nCount == 0 ); +/*N*/ pCol->Search( nRow, nColRow ); +/*N*/ } +/*N*/ +/*N*/ while (( nColRow < pCol->nCount ) && ( pCol->pItems[nColRow].nRow < nRow )) +/*N*/ nColRow++; +/*N*/ +/*N*/ if ( nColRow < pCol->nCount && pCol->pItems[nColRow].nRow <= nEndRow ) +/*N*/ { +/*N*/ nRow = pCol->pItems[nColRow].nRow + 1; +/*N*/ if ( !bSubTotal || !pDoc->pTab[nTab]->IsFiltered( nRow-1 ) ) +/*N*/ { +/*N*/ ScBaseCell* pCell = pCol->pItems[nColRow].pCell; +/*N*/ ++nColRow; +/*N*/ switch (pCell->GetCellType()) +/*N*/ { +/*N*/ case CELLTYPE_VALUE: +/*N*/ { +/*N*/ bNumValid = FALSE; +/*N*/ rValue = ((ScValueCell*)pCell)->GetValue(); +/*N*/ rErr = 0; +/*N*/ --nRow; +/*N*/ if ( bCalcAsShown ) +/*N*/ { +/*?*/ #ifndef WTC +/*?*/ lcl_IterGetNumberFormat( nNumFormat,pAttrArray, +/*?*/ #else +/*?*/ lcl_IterGetNumberFormat( nNumFormat, +/*?*/ (ScAttrArray const *&)pAttrArray, +/*?*/ #endif +/*?*/ nAttrEndRow, pCol->pAttrArray, nRow, pDoc ); +/*?*/ rValue = pDoc->RoundValueAsShown( rValue, nNumFormat ); +/*N*/ } +/*N*/ // +/*N*/ // wenn in der selben Spalte gleich noch eine Value-Cell folgt, die +/*N*/ // auch noch im Block liegt, den Wert jetzt schon holen +/*N*/ // +/*N*/ if ( nColRow < pCol->nCount && +/*N*/ pCol->pItems[nColRow].nRow <= nEndRow && +/*N*/ pCol->pItems[nColRow].pCell->GetCellType() == CELLTYPE_VALUE && +/*N*/ !bSubTotal ) +/*N*/ { +/*N*/ fNextValue = ((ScValueCell*)pCol->pItems[nColRow].pCell)->GetValue(); +/*N*/ nNextRow = pCol->pItems[nColRow].nRow; +/*N*/ bNextValid = TRUE; +/*N*/ if ( bCalcAsShown ) +/*N*/ { +/*?*/ #ifndef WTC +/*?*/ lcl_IterGetNumberFormat( nNumFormat, pAttrArray, +/*?*/ #else +/*?*/ lcl_IterGetNumberFormat( nNumFormat, +/*?*/ (ScAttrArray const *&)pAttrArray, +/*?*/ #endif +/*?*/ nAttrEndRow, pCol->pAttrArray, nNextRow, pDoc ); +/*?*/ fNextValue = pDoc->RoundValueAsShown( fNextValue, nNumFormat ); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ return TRUE; // gefunden +/*N*/ } +/*N*/ break; +/*N*/ case CELLTYPE_FORMULA: +/*N*/ { +/*N*/ if (!bSubTotal || !((ScFormulaCell*)pCell)->IsSubTotal()) +/*N*/ { +/*N*/ rErr = ((ScFormulaCell*)pCell)->GetErrCode(); +/*N*/ if ( rErr || ((ScFormulaCell*)pCell)->IsValue() ) +/*N*/ { +/*N*/ rValue = ((ScFormulaCell*)pCell)->GetValue(); +/*N*/ nRow--; +/*N*/ bNumValid = FALSE; +/*N*/ return TRUE; // gefunden +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ break; +/*N*/ case CELLTYPE_STRING : +/*N*/ case CELLTYPE_EDIT : +/*N*/ { +/*N*/ if ( bTextAsZero ) +/*N*/ { +/*N*/ rErr = 0; +/*N*/ rValue = 0.0; +/*N*/ nNumFmtType = NUMBERFORMAT_NUMBER; +/*N*/ nNumFmtIndex = 0; +/*N*/ bNumValid = TRUE; +/*N*/ --nRow; +/*N*/ return TRUE; +/*N*/ } +/*N*/ } +/*N*/ break; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ nRow = nEndRow + 1; // naechste Spalte +/*N*/ } +/*N*/ } + +/*N*/ void ScValueIterator::GetCurNumFmtInfo( short& nType, ULONG& nIndex ) +/*N*/ { +/*N*/ if (!bNumValid) +/*N*/ { +/*N*/ const ScColumn* pCol = &(pDoc->pTab[nTab])->aCol[nCol]; +/*N*/ nNumFmtIndex = pCol->GetNumberFormat( nRow ); +/*N*/ if ( (nNumFmtIndex % SV_COUNTRY_LANGUAGE_OFFSET) == 0 ) +/*N*/ { +/*N*/ const ScBaseCell* pCell; +/*N*/ USHORT nIdx = nColRow - 1; +/*N*/ // there might be rearranged something, so be on the safe side +/*N*/ if ( nIdx < pCol->nCount && pCol->pItems[nIdx].nRow == nRow ) +/*N*/ pCell = pCol->pItems[nIdx].pCell; +/*N*/ else +/*N*/ { +/*?*/ if ( pCol->Search( nRow, nIdx ) ) +/*?*/ pCell = pCol->pItems[nIdx].pCell; +/*?*/ else +/*?*/ pCell = NULL; +/*N*/ } +/*N*/ if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA ) +/*N*/ ((const ScFormulaCell*)pCell)->GetFormatInfo( nNumFmtType, nNumFmtIndex ); +/*N*/ else +/*N*/ nNumFmtType = pDoc->GetFormatTable()->GetType( nNumFmtIndex ); +/*N*/ } +/*N*/ else +/*N*/ nNumFmtType = pDoc->GetFormatTable()->GetType( nNumFmtIndex ); +/*N*/ bNumValid = TRUE; +/*N*/ } +/*N*/ nType = nNumFmtType; +/*N*/ nIndex = nNumFmtIndex; +/*N*/ } + +/*N*/ BOOL ScValueIterator::GetFirst(double& rValue, USHORT& rErr) +/*N*/ { +/*N*/ nCol = nStartCol; +/*N*/ nRow = nStartRow; +/*N*/ nTab = nStartTab; +/*N*/ +/*N*/ // nColRow = 0; +/*N*/ ScColumn* pCol = &(pDoc->pTab[nTab])->aCol[nCol]; +/*N*/ pCol->Search( nRow, nColRow ); +/*N*/ +/*N*/ nNumFormat = 0; // werden bei GetNumberFormat initialisiert +/*N*/ pAttrArray = 0; +/*N*/ nAttrEndRow = 0; +/*N*/ +/*N*/ return GetThis(rValue, rErr); +/*N*/ } + +/* ist inline: +BOOL ScValueIterator::GetNext(double& rValue, USHORT& rErr) +{ + ++nRow; + return GetThis(rValue, rErr); +} +*/ + +//------------------------------------------------------------------------ +//------------------------------------------------------------------------ + +/*N*/ ScQueryValueIterator::ScQueryValueIterator(ScDocument* pDocument, USHORT nTable, const ScQueryParam& rParam) : +/*N*/ pDoc( pDocument ), +/*N*/ nTab( nTable), +/*N*/ aParam (rParam), +/*N*/ nNumFmtType( NUMBERFORMAT_UNDEFINED ), +/*N*/ nNumFmtIndex(0), +/*N*/ bCalcAsShown( pDocument->GetDocOptions().IsCalcAsShown() ) +/*N*/ { +/*N*/ nCol = aParam.nCol1; +/*N*/ nRow = aParam.nRow1; +/*N*/ nColRow = 0; // wird bei GetFirst initialisiert +/*N*/ USHORT i; +/*N*/ USHORT nCount = aParam.GetEntryCount(); +/*N*/ for (i=0; (i<nCount) && (aParam.GetEntry(i).bDoQuery); i++) +/*N*/ { +/*N*/ ScQueryEntry& rEntry = aParam.GetEntry(i); +/*N*/ sal_uInt32 nIndex = 0; +/*N*/ rEntry.bQueryByString = +/*N*/ !(pDoc->GetFormatTable()->IsNumberFormat(*rEntry.pStr, nIndex, rEntry.nVal)); +/*N*/ } +/*N*/ nNumFormat = 0; // werden bei GetNumberFormat initialisiert +/*N*/ pAttrArray = 0; +/*N*/ nAttrEndRow = 0; +/*N*/ } +/*N*/ +/*N*/ BOOL ScQueryValueIterator::GetThis(double& rValue, USHORT& rErr) +/*N*/ { +/*N*/ ScColumn* pCol = &(pDoc->pTab[nTab])->aCol[nCol]; +/*N*/ USHORT nFirstQueryField = aParam.GetEntry(0).nField; +/*N*/ for ( ;; ) +/*N*/ { +/*N*/ if ( nRow > aParam.nRow2 ) +/*N*/ { +/*N*/ nRow = aParam.nRow1; +/*N*/ if (aParam.bHasHeader) +/*N*/ nRow++; +/*N*/ do +/*N*/ { +/*N*/ nCol++; +/*N*/ if ( nCol > aParam.nCol2 ) +/*N*/ { +/*N*/ rValue = 0.0; +/*N*/ rErr = 0; +/*N*/ return FALSE; // Ende und Aus +/*N*/ } +/*N*/ pCol = &(pDoc->pTab[nTab])->aCol[nCol]; +/*N*/ } while ( pCol->nCount == 0 ); +/*N*/ pCol->Search( nRow, nColRow ); +/*N*/ } +/*N*/ +/*N*/ while ( (nColRow < pCol->nCount) && (pCol->pItems[nColRow].nRow < nRow) ) +/*N*/ nColRow++; +/*N*/ +/*N*/ if ( nColRow < pCol->nCount && pCol->pItems[nColRow].nRow <= aParam.nRow2 ) +/*N*/ { +/*N*/ nRow = pCol->pItems[nColRow].nRow; +/*N*/ ScBaseCell* pCell = pCol->pItems[nColRow].pCell; +/*N*/ if ( (pDoc->pTab[nTab])->ValidQuery( nRow, aParam, NULL, +/*N*/ (nCol == nFirstQueryField ? pCell : NULL) ) ) +/*N*/ { +/*N*/ switch (pCell->GetCellType()) +/*N*/ { +/*N*/ case CELLTYPE_VALUE: +/*N*/ { +/*N*/ rValue = ((ScValueCell*)pCell)->GetValue(); +/*N*/ if ( bCalcAsShown ) +/*N*/ { +/*N*/ #if ! ( defined WTC || defined ICC || defined HPUX || defined C50 || defined C52 || ( defined GCC && __GNUC__ >= 3 ) || ( defined WNT && _MSC_VER >= 1400 ) ) +/*N*/ lcl_IterGetNumberFormat( nNumFormat, pAttrArray, +/*N*/ #else +/*N*/ lcl_IterGetNumberFormat( nNumFormat, +/*N*/ (ScAttrArray const *&)pAttrArray, +/*N*/ #endif +/*N*/ nAttrEndRow, pCol->pAttrArray, nRow, pDoc ); +/*N*/ rValue = pDoc->RoundValueAsShown( rValue, nNumFormat ); +/*N*/ } +/*N*/ nNumFmtType = NUMBERFORMAT_NUMBER; +/*N*/ nNumFmtIndex = 0; +/*N*/ rErr = 0; +/*N*/ return TRUE; // gefunden +/*N*/ } +/*N*/ break; +/*N*/ case CELLTYPE_FORMULA: +/*N*/ { +/*N*/ if (((ScFormulaCell*)pCell)->IsValue()) +/*N*/ { +/*N*/ rValue = ((ScFormulaCell*)pCell)->GetValue(); +/*N*/ pDoc->GetNumberFormatInfo( nNumFmtType, +/*N*/ nNumFmtIndex, ScAddress( nCol, nRow, nTab ), +/*N*/ *((ScFormulaCell*)pCell) ); +/*N*/ rErr = ((ScFormulaCell*)pCell)->GetErrCode(); +/*N*/ return TRUE; // gefunden +/*N*/ } +/*N*/ else +/*N*/ nRow++; +/*N*/ } +/*N*/ break; +/*N*/ default: +/*N*/ nRow++; +/*N*/ break; +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ nRow++; +/*N*/ } +/*N*/ else +/*N*/ nRow = aParam.nRow2 + 1; // Naechste Spalte +/*N*/ } +/*N*/ return FALSE; +/*N*/ } +/*N*/ +/*N*/ BOOL ScQueryValueIterator::GetFirst(double& rValue, USHORT& rErr) +/*N*/ { +/*N*/ nCol = aParam.nCol1; +/*N*/ nRow = aParam.nRow1; +/*N*/ if (aParam.bHasHeader) +/*N*/ nRow++; +/*N*/ // nColRow = 0; +/*N*/ ScColumn* pCol = &(pDoc->pTab[nTab])->aCol[nCol]; +/*N*/ pCol->Search( nRow, nColRow ); +/*N*/ return GetThis(rValue, rErr); +/*N*/ } +/*N*/ +/*N*/ BOOL ScQueryValueIterator::GetNext(double& rValue, USHORT& rErr) +/*N*/ { +/*N*/ ++nRow; +/*N*/ return GetThis(rValue, rErr); +/*N*/ } + +//------------------------------------------------------------------------------- + +/*N*/ ScCellIterator::ScCellIterator( ScDocument* pDocument, +/*N*/ USHORT nSCol, USHORT nSRow, USHORT nSTab, +/*N*/ USHORT nECol, USHORT nERow, USHORT nETab, BOOL bSTotal ) : +/*N*/ pDoc( pDocument ), +/*N*/ nStartCol( nSCol), +/*N*/ nStartRow( nSRow), +/*N*/ nStartTab( nSTab ), +/*N*/ nEndCol( nECol ), +/*N*/ nEndRow( nERow), +/*N*/ nEndTab( nETab ), +/*N*/ bSubTotal(bSTotal) +/*N*/ +/*N*/ { +/*N*/ PutInOrder( nStartCol, nEndCol); +/*N*/ PutInOrder( nStartRow, nEndRow); +/*N*/ PutInOrder( nStartTab, nEndTab ); +/*N*/ +/*N*/ if (nStartCol > MAXCOL) nStartCol = MAXCOL; +/*N*/ if (nEndCol > MAXCOL) nEndCol = MAXCOL; +/*N*/ if (nStartRow > MAXROW) nStartRow = MAXROW; +/*N*/ if (nEndRow > MAXROW) nEndRow = MAXROW; +/*N*/ if (nStartTab > MAXTAB) nStartTab = MAXTAB; +/*N*/ if (nEndTab > MAXTAB) nEndTab = MAXTAB; +/*N*/ +/*N*/ while (nEndTab>0 && !pDoc->pTab[nEndTab]) +/*N*/ --nEndTab; // nur benutzte Tabellen +/*N*/ if (nStartTab>nEndTab) +/*N*/ nStartTab = nEndTab; +/*N*/ +/*N*/ nCol = nStartCol; +/*N*/ nRow = nStartRow; +/*N*/ nTab = nStartTab; +/*N*/ nColRow = 0; // wird bei GetFirst initialisiert +/*N*/ +/*N*/ if (!pDoc->pTab[nTab]) +/*N*/ { +/*N*/ DBG_ERROR("Tabelle nicht gefunden"); +/*N*/ nStartCol = nCol = MAXCOL+1; +/*N*/ nStartRow = nRow = MAXROW+1; +/*N*/ nStartTab = nTab = MAXTAB+1; // -> Abbruch bei GetFirst +/*N*/ } +/*N*/ } + +/*N*/ ScCellIterator::ScCellIterator +/*N*/ ( ScDocument* pDocument, const ScRange& rRange, BOOL bSTotal ) : +/*N*/ pDoc( pDocument ), +/*N*/ nStartCol( rRange.aStart.Col() ), +/*N*/ nStartRow( rRange.aStart.Row() ), +/*N*/ nStartTab( rRange.aStart.Tab() ), +/*N*/ nEndCol( rRange.aEnd.Col() ), +/*N*/ nEndRow( rRange.aEnd.Row() ), +/*N*/ nEndTab( rRange.aEnd.Tab() ), +/*N*/ bSubTotal(bSTotal) +/*N*/ +/*N*/ { +/*N*/ PutInOrder( nStartCol, nEndCol); +/*N*/ PutInOrder( nStartRow, nEndRow); +/*N*/ PutInOrder( nStartTab, nEndTab ); +/*N*/ +/*N*/ if (nStartCol > MAXCOL) nStartCol = MAXCOL; +/*N*/ if (nEndCol > MAXCOL) nEndCol = MAXCOL; +/*N*/ if (nStartRow > MAXROW) nStartRow = MAXROW; +/*N*/ if (nEndRow > MAXROW) nEndRow = MAXROW; +/*N*/ if (nStartTab > MAXTAB) nStartTab = MAXTAB; +/*N*/ if (nEndTab > MAXTAB) nEndTab = MAXTAB; +/*N*/ +/*N*/ while (nEndTab>0 && !pDoc->pTab[nEndTab]) +/*N*/ --nEndTab; // nur benutzte Tabellen +/*N*/ if (nStartTab>nEndTab) +/*N*/ nStartTab = nEndTab; +/*N*/ +/*N*/ nCol = nStartCol; +/*N*/ nRow = nStartRow; +/*N*/ nTab = nStartTab; +/*N*/ nColRow = 0; // wird bei GetFirst initialisiert +/*N*/ +/*N*/ if (!pDoc->pTab[nTab]) +/*N*/ { +/*N*/ DBG_ERROR("Tabelle nicht gefunden"); +/*N*/ nStartCol = nCol = MAXCOL+1; +/*N*/ nStartRow = nRow = MAXROW+1; +/*N*/ nStartTab = nTab = MAXTAB+1; // -> Abbruch bei GetFirst +/*N*/ } +/*N*/ } + +/*N*/ ScBaseCell* ScCellIterator::GetThis() +/*N*/ { +/*N*/ ScColumn* pCol = &(pDoc->pTab[nTab])->aCol[nCol]; +/*N*/ for ( ;; ) +/*N*/ { +/*N*/ if ( nRow > nEndRow ) +/*N*/ { +/*N*/ nRow = nStartRow; +/*N*/ do +/*N*/ { +/*N*/ nCol++; +/*N*/ if ( nCol > nEndCol ) +/*N*/ { +/*N*/ nCol = nStartCol; +/*N*/ nTab++; +/*N*/ if ( nTab > nEndTab ) +/*N*/ return NULL; // Ende und Aus +/*N*/ } +/*N*/ pCol = &(pDoc->pTab[nTab])->aCol[nCol]; +/*N*/ } while ( pCol->nCount == 0 ); +/*N*/ pCol->Search( nRow, nColRow ); +/*N*/ } +/*N*/ +/*N*/ while ( (nColRow < pCol->nCount) && (pCol->pItems[nColRow].nRow < nRow) ) +/*N*/ nColRow++; +/*N*/ +/*N*/ if ( nColRow < pCol->nCount && pCol->pItems[nColRow].nRow <= nEndRow ) +/*N*/ { +/*N*/ nRow = pCol->pItems[nColRow].nRow; +/*N*/ if ( !bSubTotal || !pDoc->pTab[nTab]->IsFiltered( nRow ) ) +/*N*/ { +/*N*/ ScBaseCell* pCell = pCol->pItems[nColRow].pCell; +/*N*/ +/*N*/ if ( bSubTotal && pCell->GetCellType() == CELLTYPE_FORMULA +/*N*/ && ((ScFormulaCell*)pCell)->IsSubTotal() ) +/*N*/ nRow++; // Sub-Total-Zeilen nicht +/*N*/ else +/*N*/ return pCell; // gefunden +/*N*/ } +/*N*/ else +/*N*/ nRow++; +/*N*/ } +/*N*/ else +/*N*/ nRow = nEndRow + 1; // Naechste Spalte +/*N*/ } +/*N*/ } + +/*N*/ ScBaseCell* ScCellIterator::GetFirst() +/*N*/ { +/*N*/ if ( nTab > MAXTAB ) +/*N*/ return NULL; +/*N*/ nCol = nStartCol; +/*N*/ nRow = nStartRow; +/*N*/ nTab = nStartTab; +/*N*/ // nColRow = 0; +/*N*/ ScColumn* pCol = &(pDoc->pTab[nTab])->aCol[nCol]; +/*N*/ pCol->Search( nRow, nColRow ); +/*N*/ return GetThis(); +/*N*/ } + +/*N*/ ScBaseCell* ScCellIterator::GetNext() +/*N*/ { +/*N*/ ++nRow; +/*N*/ return GetThis(); +/*N*/ } + +//------------------------------------------------------------------------------- + +/*N*/ ScQueryCellIterator::ScQueryCellIterator(ScDocument* pDocument, USHORT nTable, +/*N*/ const ScQueryParam& rParam, BOOL bMod ) : +/*N*/ pDoc( pDocument ), +/*N*/ nTab( nTable), +/*N*/ aParam (rParam), +/*N*/ nStopOnMismatch( nStopOnMismatchDisabled ), +/*N*/ nTestEqualCondition( nTestEqualConditionDisabled ), +/*N*/ bAdvanceQuery( FALSE ) +/*N*/ { +/*N*/ nCol = aParam.nCol1; +/*N*/ nRow = aParam.nRow1; +/*N*/ nColRow = 0; // wird bei GetFirst initialisiert +/*N*/ USHORT i; +/*N*/ if (bMod) // sonst schon eingetragen +/*N*/ { +/*N*/ for (i=0; (i<MAXQUERY) && (aParam.GetEntry(i).bDoQuery); i++) +/*N*/ { +/*?*/ ScQueryEntry& rEntry = aParam.GetEntry(i); +/*?*/ sal_uInt32 nIndex = 0; +/*?*/ rEntry.bQueryByString = +/*?*/ !(pDoc->GetFormatTable()->IsNumberFormat(*rEntry.pStr, +/*?*/ nIndex, rEntry.nVal)); +/*N*/ } +/*N*/ } +/*N*/ nNumFormat = 0; // werden bei GetNumberFormat initialisiert +/*N*/ pAttrArray = 0; +/*N*/ nAttrEndRow = 0; +/*N*/ } +/*N*/ +/*N*/ ScBaseCell* ScQueryCellIterator::GetThis() +/*N*/ { +/*N*/ ScColumn* pCol = &(pDoc->pTab[nTab])->aCol[nCol]; +/*N*/ USHORT nFirstQueryField = aParam.GetEntry(0).nField; +/*N*/ for ( ;; ) +/*N*/ { +/*N*/ if ( nRow > aParam.nRow2 ) +/*N*/ { +/*N*/ nRow = aParam.nRow1; +/*N*/ if (aParam.bHasHeader) +/*?*/ nRow++; +/*N*/ do +/*M*/ { +/*M*/ if ( ++nCol > aParam.nCol2 ) +/*M*/ return NULL; // Ende und Aus +/*M*/ if ( bAdvanceQuery ) +/*M*/ { +/*M*/ AdvanceQueryParamEntryField(); +/*M*/ nFirstQueryField = aParam.GetEntry(0).nField; +/*M*/ } +/*M*/ pCol = &(pDoc->pTab[nTab])->aCol[nCol]; +/*M*/ } while ( pCol->nCount == 0 ); +/*N*/ pCol->Search( nRow, nColRow ); +/*N*/ } +/*N*/ +/*N*/ while ( nColRow < pCol->nCount && pCol->pItems[nColRow].nRow < nRow ) +/*N*/ nColRow++; +/*N*/ +/*N*/ if ( nColRow < pCol->nCount && pCol->pItems[nColRow].nRow <= aParam.nRow2 ) +/*N*/ { +/*N*/ if ( pCol->pItems[nColRow].pCell->GetCellType() == CELLTYPE_NOTE ) +/*?*/ nRow++; +/*N*/ else +/*N*/ { +/*N*/ BOOL bTestEqualCondition; +/*N*/ nRow = pCol->pItems[nColRow].nRow; +/*N*/ ScBaseCell* pCell = pCol->pItems[nColRow].pCell; +/*N*/ if ( (pDoc->pTab[nTab])->ValidQuery( nRow, aParam, NULL, +/*N*/ (nCol == nFirstQueryField ? pCell : NULL), +/*N*/ (nTestEqualCondition ? &bTestEqualCondition : NULL) ) ) +/*N*/ { +/*N*/ if ( nTestEqualCondition && bTestEqualCondition ) +/*N*/ nTestEqualCondition |= nTestEqualConditionMatched; +/*N*/ return pCell; // found +/*N*/ } +/*N*/ else if ( nStopOnMismatch ) +/*N*/ { +/*N*/ nStopOnMismatch |= nStopOnMismatchOccured; +/*N*/ // Yes, even a mismatch may have a fulfilled equal +/*N*/ // condition if regular expressions were involved and +/*N*/ // SC_LESS_EQUAL or SC_GREATER_EQUAL were queried. +/*N*/ if ( nTestEqualCondition && bTestEqualCondition ) +/*?*/ nTestEqualCondition |= nTestEqualConditionMatched; +/*N*/ return NULL; +/*N*/ } +/*N*/ else +/*N*/ nRow++; +/*N*/ } +/*N*/ } +/*N*/ else +/*?*/ nRow = aParam.nRow2 + 1; // Naechste Spalte +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ ScBaseCell* ScQueryCellIterator::GetFirst() +/*N*/ { +/*N*/ nCol = aParam.nCol1; +/*N*/ nRow = aParam.nRow1; +/*N*/ if (aParam.bHasHeader) +/*?*/ nRow++; +/*N*/ // nColRow = 0; +/*N*/ ScColumn* pCol = &(pDoc->pTab[nTab])->aCol[nCol]; +/*N*/ pCol->Search( nRow, nColRow ); +/*N*/ return GetThis(); +/*N*/ } +/*N*/ +/*N*/ ScBaseCell* ScQueryCellIterator::GetNext() +/*N*/ { +/*N*/ ++nRow; +/*N*/ if ( nStopOnMismatch ) +/*N*/ nStopOnMismatch = nStopOnMismatchEnabled; +/*N*/ if ( nTestEqualCondition ) +/*N*/ nTestEqualCondition = nTestEqualConditionEnabled; +/*N*/ return GetThis(); +/*N*/ } +/*N*/ +/*N*/ ULONG ScQueryCellIterator::GetNumberFormat() +/*N*/ { +/*N*/ ScColumn* pCol = &(pDoc->pTab[nTab])->aCol[nCol]; +/*N*/ #if ! ( defined WTC || defined ICC || defined HPUX || defined C50 || defined C52 || ( defined GCC && __GNUC__ >= 3 ) || ( defined WNT && _MSC_VER >= 1400 ) ) +/*N*/ lcl_IterGetNumberFormat( nNumFormat, pAttrArray, +/*N*/ #else +/*N*/ lcl_IterGetNumberFormat( nNumFormat, +/*N*/ (ScAttrArray const *&)pAttrArray, +/*N*/ #endif +/*N*/ nAttrEndRow, pCol->pAttrArray, nRow, pDoc ); +/*N*/ return nNumFormat; +/*N*/ } + +/*N*/ void ScQueryCellIterator::AdvanceQueryParamEntryField() +/*N*/ { +/*N*/ USHORT nEntries = aParam.GetEntryCount(); +/*N*/ for ( USHORT j = 0; j < nEntries; j++ ) +/*N*/ { +/*N*/ ScQueryEntry& rEntry = aParam.GetEntry( j ); +/*N*/ if ( rEntry.bDoQuery ) +/*N*/ { +/*N*/ if ( rEntry.nField < MAXCOL ) +/*N*/ rEntry.nField++; +/*N*/ else +/*N*/ { +/*N*/ DBG_ERRORFILE( "AdvanceQueryParamEntryField: ++rEntry.nField > MAXCOL" ); +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ break; // for +/*N*/ } +/*N*/ } + + +/*N*/ BOOL ScQueryCellIterator::FindEqualOrSortedLastInRange( USHORT& nFoundCol, USHORT& nFoundRow ) +/*N*/ { +/*N*/ nFoundCol = MAXCOL+1; +/*N*/ nFoundRow = MAXROW+1; +/*N*/ SetStopOnMismatch( TRUE ); // assume sorted keys +/*N*/ SetTestEqualCondition( TRUE ); +/*N*/ if ( GetFirst() ) +/*N*/ { +/*N*/ do +/*N*/ { +/*N*/ nFoundCol = GetCol(); +/*N*/ nFoundRow = GetRow(); +/*N*/ } while ( !IsEqualConditionFulfilled() && GetNext() ); +/*N*/ } +/*N*/ if ( IsEqualConditionFulfilled() ) +/*N*/ { +/*N*/ nFoundCol = GetCol(); +/*N*/ nFoundRow = GetRow(); +/*N*/ return TRUE; +/*N*/ } +/*N*/ if ( StoppedOnMismatch() ) +/*N*/ { // Assume found entry to be the last value less than or equal to query. +/*N*/ // But keep on searching for an equal match. +/*N*/ SetStopOnMismatch( FALSE ); +/*N*/ SetTestEqualCondition( FALSE ); +/*N*/ USHORT nEntries = aParam.GetEntryCount(); +/*N*/ for ( USHORT j = 0; j < nEntries; j++ ) +/*N*/ { +/*N*/ ScQueryEntry& rEntry = aParam.GetEntry( j ); +/*N*/ if ( rEntry.bDoQuery ) +/*N*/ { +/*N*/ switch ( rEntry.eOp ) +/*N*/ { +/*N*/ case SC_LESS_EQUAL : +/*N*/ case SC_GREATER_EQUAL : +/*N*/ rEntry.eOp = SC_EQUAL; +/*N*/ break; +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ break; // for +/*N*/ } +/*N*/ if ( GetNext() ) +/*N*/ { +/*?*/ nFoundCol = GetCol(); +/*?*/ nFoundRow = GetRow(); +/*N*/ } +/*N*/ } +/*N*/ return (nFoundCol <= MAXCOL) && (nFoundRow <= MAXROW); +/*N*/ } + + +//------------------------------------------------------------------------------- + +/*N*/ ScHorizontalCellIterator::ScHorizontalCellIterator(ScDocument* pDocument, USHORT nTable, +/*N*/ USHORT nCol1, USHORT nRow1, USHORT nCol2, USHORT nRow2 ) : +/*N*/ pDoc( pDocument ), +/*N*/ nTab( nTable ), +/*N*/ nStartCol( nCol1 ), +/*N*/ nEndCol( nCol2 ), +/*N*/ nEndRow( nRow2 ), +/*N*/ nCol( nCol1 ), +/*N*/ nRow( nRow1 ), +/*N*/ bMore( TRUE ) +/*N*/ { +/*N*/ USHORT i; +/*N*/ USHORT nIndex; +/*N*/ +/*N*/ pNextRows = new USHORT[ nCol2-nCol1+1 ]; +/*N*/ pNextIndices = new USHORT[ nCol2-nCol1+1 ]; +/*N*/ +/*N*/ for (i=nStartCol; i<=nEndCol; i++) +/*N*/ { +/*N*/ ScColumn* pCol = &pDoc->pTab[nTab]->aCol[i]; +/*N*/ +/*N*/ pCol->Search( nRow1, nIndex ); +/*N*/ if ( nIndex < pCol->nCount ) +/*N*/ { +/*N*/ pNextRows[i-nStartCol] = pCol->pItems[nIndex].nRow; +/*N*/ pNextIndices[i-nStartCol] = nIndex; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ pNextRows[i-nStartCol] = MAXROW+1; // nichts gefunden +/*N*/ pNextIndices[i-nStartCol] = MAXROW+1; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if (pNextRows[0] != nRow1) +/*N*/ Advance(); +/*N*/ } + +/*N*/ ScHorizontalCellIterator::~ScHorizontalCellIterator() +/*N*/ { +/*N*/ delete [] pNextRows; +/*N*/ delete [] pNextIndices; +/*N*/ } + +/*N*/ ScBaseCell* ScHorizontalCellIterator::GetNext( USHORT& rCol, USHORT& rRow ) +/*N*/ { +/*N*/ if ( bMore ) +/*N*/ { +/*N*/ rCol = nCol; +/*N*/ rRow = nRow; +/*N*/ +/*N*/ ScColumn* pCol = &pDoc->pTab[nTab]->aCol[nCol]; +/*N*/ USHORT nIndex = pNextIndices[nCol-nStartCol]; +/*N*/ DBG_ASSERT( nIndex < pCol->nCount, "ScHorizontalCellIterator::GetNext: nIndex out of range" ); +/*N*/ ScBaseCell* pCell = pCol->pItems[nIndex].pCell; +/*N*/ if ( ++nIndex < pCol->nCount ) +/*N*/ { +/*N*/ pNextRows[nCol-nStartCol] = pCol->pItems[nIndex].nRow; +/*N*/ pNextIndices[nCol-nStartCol] = nIndex; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ pNextRows[nCol-nStartCol] = MAXROW+1; // nichts gefunden +/*N*/ pNextIndices[nCol-nStartCol] = MAXROW+1; +/*N*/ } +/*N*/ +/*N*/ Advance(); +/*N*/ return pCell; +/*N*/ } +/*N*/ else +/*N*/ return NULL; +/*N*/ } + +/*N*/ BOOL ScHorizontalCellIterator::ReturnNext( USHORT& rCol, USHORT& rRow ) +/*N*/ { +/*N*/ rCol = nCol; +/*N*/ rRow = nRow; +/*N*/ return bMore; +/*N*/ } + +/*N*/ void ScHorizontalCellIterator::Advance() +/*N*/ { +/*N*/ BOOL bFound = FALSE; +/*N*/ USHORT i; +/*N*/ +/*N*/ for (i=nCol+1; i<=nEndCol && !bFound; i++) +/*N*/ if (pNextRows[i-nStartCol] == nRow) +/*N*/ { +/*N*/ nCol = i; +/*N*/ bFound = TRUE; +/*N*/ } +/*N*/ +/*N*/ if (!bFound) +/*N*/ { +/*N*/ USHORT nMinRow = MAXROW+1; +/*N*/ for (i=nStartCol; i<=nEndCol; i++) +/*N*/ if (pNextRows[i-nStartCol] < nMinRow) +/*N*/ { +/*N*/ nCol = i; +/*N*/ nMinRow = pNextRows[i-nStartCol]; +/*N*/ } +/*N*/ +/*N*/ if (nMinRow <= nEndRow) +/*N*/ { +/*N*/ nRow = nMinRow; +/*N*/ bFound = TRUE; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if ( !bFound ) +/*N*/ bMore = FALSE; +/*N*/ } + +//------------------------------------------------------------------------------- + + +//------------------------------------------------------------------------------- + + +//------------------------------------------------------------------------------- + +/*N*/ ScDocAttrIterator::ScDocAttrIterator(ScDocument* pDocument, USHORT nTable, +/*N*/ USHORT nCol1, USHORT nRow1, +/*N*/ USHORT nCol2, USHORT nRow2) : +/*N*/ pDoc( pDocument ), +/*N*/ nTab( nTable ), +/*N*/ nCol( nCol1 ), +/*N*/ nEndCol( nCol2 ), +/*N*/ nStartRow( nRow1 ), +/*N*/ nEndRow( nRow2 ) +/*N*/ { +/*N*/ if ( nTab<=MAXTAB && pDoc->pTab[nTab] ) +/*N*/ pColIter = pDoc->pTab[nTab]->aCol[nCol].CreateAttrIterator( nStartRow, nEndRow ); +/*N*/ else +/*N*/ pColIter = NULL; +/*N*/ } + +/*N*/ ScDocAttrIterator::~ScDocAttrIterator() +/*N*/ { +/*N*/ delete pColIter; +/*N*/ } + +/*N*/ const ScPatternAttr* ScDocAttrIterator::GetNext( USHORT& rCol, USHORT& rRow1, USHORT& rRow2 ) +/*N*/ { +/*N*/ while ( pColIter ) +/*N*/ { +/*N*/ const ScPatternAttr* pPattern = pColIter->Next( rRow1, rRow2 ); +/*N*/ if ( pPattern ) +/*N*/ { +/*N*/ rCol = nCol; +/*N*/ return pPattern; +/*N*/ } +/*N*/ +/*N*/ delete pColIter; +/*N*/ ++nCol; +/*N*/ if ( nCol <= nEndCol ) +/*N*/ pColIter = pDoc->pTab[nTab]->aCol[nCol].CreateAttrIterator( nStartRow, nEndRow ); +/*N*/ else +/*N*/ pColIter = NULL; +/*N*/ } +/*N*/ return NULL; // is nix mehr +/*N*/ } + +//------------------------------------------------------------------------------- + +/*N*/ ScAttrRectIterator::ScAttrRectIterator(ScDocument* pDocument, USHORT nTable, +/*N*/ USHORT nCol1, USHORT nRow1, +/*N*/ USHORT nCol2, USHORT nRow2) : +/*N*/ pDoc( pDocument ), +/*N*/ nTab( nTable ), +/*N*/ nEndCol( nCol2 ), +/*N*/ nStartRow( nRow1 ), +/*N*/ nEndRow( nRow2 ), +/*N*/ nIterStartCol( nCol1 ), +/*N*/ nIterEndCol( nCol1 ) +/*N*/ { +/*N*/ if ( nTab<=MAXTAB && pDoc->pTab[nTab] ) +/*N*/ { +/*N*/ pColIter = pDoc->pTab[nTab]->aCol[nIterStartCol].CreateAttrIterator( nStartRow, nEndRow ); +/*N*/ while ( nIterEndCol < nEndCol && +/*N*/ pDoc->pTab[nTab]->aCol[nIterEndCol].IsAllAttrEqual( +/*N*/ pDoc->pTab[nTab]->aCol[nIterEndCol+1], nStartRow, nEndRow ) ) +/*N*/ ++nIterEndCol; +/*N*/ } +/*N*/ else +/*N*/ pColIter = NULL; +/*N*/ } + +/*N*/ ScAttrRectIterator::~ScAttrRectIterator() +/*N*/ { +/*N*/ delete pColIter; +/*N*/ } + +/*N*/ void ScAttrRectIterator::DataChanged() +/*N*/ { +/*N*/ if (pColIter) +/*N*/ { +/*N*/ USHORT nNextRow = pColIter->GetNextRow(); +/*N*/ delete pColIter; +/*N*/ pColIter = pDoc->pTab[nTab]->aCol[nIterStartCol].CreateAttrIterator( nNextRow, nEndRow ); +/*N*/ } +/*N*/ } + +/*N*/ const ScPatternAttr* ScAttrRectIterator::GetNext( USHORT& rCol1, USHORT& rCol2, +/*N*/ USHORT& rRow1, USHORT& rRow2 ) +/*N*/ { +/*N*/ while ( pColIter ) +/*N*/ { +/*N*/ const ScPatternAttr* pPattern = pColIter->Next( rRow1, rRow2 ); +/*N*/ if ( pPattern ) +/*N*/ { +/*N*/ rCol1 = nIterStartCol; +/*N*/ rCol2 = nIterEndCol; +/*N*/ return pPattern; +/*N*/ } +/*N*/ +/*N*/ delete pColIter; +/*N*/ nIterStartCol = nIterEndCol+1; +/*N*/ if ( nIterStartCol <= nEndCol ) +/*N*/ { +/*N*/ nIterEndCol = nIterStartCol; +/*N*/ pColIter = pDoc->pTab[nTab]->aCol[nIterStartCol].CreateAttrIterator( nStartRow, nEndRow ); +/*N*/ while ( nIterEndCol < nEndCol && +/*N*/ pDoc->pTab[nTab]->aCol[nIterEndCol].IsAllAttrEqual( +/*N*/ pDoc->pTab[nTab]->aCol[nIterEndCol+1], nStartRow, nEndRow ) ) +/*N*/ ++nIterEndCol; +/*N*/ } +/*N*/ else +/*N*/ pColIter = NULL; +/*N*/ } +/*N*/ return NULL; // is nix mehr +/*N*/ } + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_docpool.cxx b/binfilter/bf_sc/source/core/data/sc_docpool.cxx new file mode 100644 index 000000000000..888137d11c18 --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_docpool.cxx @@ -0,0 +1,607 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include "scitems.hxx" +#include <vcl/outdev.hxx> +#include <bf_svtools/aeitem.hxx> +#include <bf_svx/algitem.hxx> +#include <bf_svx/boxitem.hxx> +#include <bf_svx/brshitem.hxx> +#include <bf_svx/charreliefitem.hxx> +#include <bf_svx/cntritem.hxx> +#include <bf_svx/colritem.hxx> +#include <bf_svx/crsditem.hxx> +#include <bf_svx/emphitem.hxx> +#include <bf_svx/fhgtitem.hxx> +#include <bf_svx/fontitem.hxx> +#include <bf_svx/forbiddenruleitem.hxx> +#include <bf_svx/frmdiritem.hxx> +#include <bf_svx/hngpnctitem.hxx> +#include <bf_svx/langitem.hxx> +#include <bf_svx/lrspitem.hxx> +#include <bf_svx/pageitem.hxx> +#include <bf_svx/pbinitem.hxx> +#include <bf_svx/postitem.hxx> +#include <bf_svx/rotmodit.hxx> +#include <bf_svx/scriptspaceitem.hxx> +#include <bf_svx/shaditem.hxx> +#include <bf_svx/shdditem.hxx> +#include <bf_svx/sizeitem.hxx> +#include <bf_svx/svxitems.hrc> +#include <bf_svx/udlnitem.hxx> +#include <bf_svx/ulspitem.hxx> +#include <bf_svx/wghtitem.hxx> +#include <bf_svx/wrlmitem.hxx> +#include <bf_svx/xmlcnitm.hxx> + +#include "docpool.hxx" +#include "attrib.hxx" +#include "patattr.hxx" +#include "globstr.hrc" +#include "bf_sc.hrc" // Slot-IDs +namespace binfilter { + + +#define SC_MAX_POOLREF (SFX_ITEMS_OLD_MAXREF - 39) +#define SC_SAFE_POOLREF (SC_MAX_POOLREF + 20) + +// STATIC DATA ----------------------------------------------------------- + +/*N*/ USHORT* ScDocumentPool::pVersionMap1 = 0; +/*N*/ USHORT* ScDocumentPool::pVersionMap2 = 0; +/*N*/ USHORT* ScDocumentPool::pVersionMap3 = 0; +/*N*/ USHORT* ScDocumentPool::pVersionMap4 = 0; +/*N*/ USHORT* ScDocumentPool::pVersionMap5 = 0; +/*N*/ USHORT* ScDocumentPool::pVersionMap6 = 0; +/*N*/ USHORT* ScDocumentPool::pVersionMap7 = 0; +/*N*/ USHORT* ScDocumentPool::pVersionMap8 = 0; +/*N*/ USHORT* ScDocumentPool::pVersionMap9 = 0; + +// ATTR_FONT_TWOLINES (not used) was changed to ATTR_USERDEF (not saved in binary format) in 641c + +/*N*/ static SfxItemInfo __READONLY_DATA aItemInfos[] = +/*N*/ { +/*N*/ { SID_ATTR_CHAR_FONT, SFX_ITEM_POOLABLE }, // ATTR_FONT +/*N*/ { SID_ATTR_CHAR_FONTHEIGHT, SFX_ITEM_POOLABLE }, // ATTR_FONT_HEIGHT +/*N*/ { SID_ATTR_CHAR_WEIGHT, SFX_ITEM_POOLABLE }, // ATTR_FONT_WEIGHT +/*N*/ { SID_ATTR_CHAR_POSTURE, SFX_ITEM_POOLABLE }, // ATTR_FONT_POSTURE +/*N*/ { SID_ATTR_CHAR_UNDERLINE, SFX_ITEM_POOLABLE }, // ATTR_FONT_UNDERLINE +/*N*/ { SID_ATTR_CHAR_STRIKEOUT, SFX_ITEM_POOLABLE }, // ATTR_FONT_CROSSEDOUT +/*N*/ { SID_ATTR_CHAR_CONTOUR, SFX_ITEM_POOLABLE }, // ATTR_FONT_CONTOUR +/*N*/ { SID_ATTR_CHAR_SHADOWED, SFX_ITEM_POOLABLE }, // ATTR_FONT_SHADOWED +/*N*/ { SID_ATTR_CHAR_COLOR, SFX_ITEM_POOLABLE }, // ATTR_FONT_COLOR +/*N*/ { SID_ATTR_CHAR_LANGUAGE, SFX_ITEM_POOLABLE }, // ATTR_FONT_LANGUAGE +/*N*/ { SID_ATTR_CHAR_CJK_FONT, SFX_ITEM_POOLABLE }, // ATTR_CJK_FONT from 614 +/*N*/ { SID_ATTR_CHAR_CJK_FONTHEIGHT, SFX_ITEM_POOLABLE }, // ATTR_CJK_FONT_HEIGHT from 614 +/*N*/ { SID_ATTR_CHAR_CJK_WEIGHT, SFX_ITEM_POOLABLE }, // ATTR_CJK_FONT_WEIGHT from 614 +/*N*/ { SID_ATTR_CHAR_CJK_POSTURE, SFX_ITEM_POOLABLE }, // ATTR_CJK_FONT_POSTURE from 614 +/*N*/ { SID_ATTR_CHAR_CJK_LANGUAGE, SFX_ITEM_POOLABLE }, // ATTR_CJK_FONT_LANGUAGE from 614 +/*N*/ { SID_ATTR_CHAR_CTL_FONT, SFX_ITEM_POOLABLE }, // ATTR_CTL_FONT from 614 +/*N*/ { SID_ATTR_CHAR_CTL_FONTHEIGHT, SFX_ITEM_POOLABLE }, // ATTR_CTL_FONT_HEIGHT from 614 +/*N*/ { SID_ATTR_CHAR_CTL_WEIGHT, SFX_ITEM_POOLABLE }, // ATTR_CTL_FONT_WEIGHT from 614 +/*N*/ { SID_ATTR_CHAR_CTL_POSTURE, SFX_ITEM_POOLABLE }, // ATTR_CTL_FONT_POSTURE from 614 +/*N*/ { SID_ATTR_CHAR_CTL_LANGUAGE, SFX_ITEM_POOLABLE }, // ATTR_CTL_FONT_LANGUAGE from 614 +/*N*/ { SID_ATTR_CHAR_EMPHASISMARK, SFX_ITEM_POOLABLE }, // ATTR_FONT_EMPHASISMARK from 614 +/*N*/ { 0, SFX_ITEM_POOLABLE }, // ATTR_USERDEF from 614 / 641c +/*N*/ { SID_ATTR_CHAR_WORDLINEMODE, SFX_ITEM_POOLABLE }, // ATTR_FONT_WORDLINE from 632b +/*N*/ { SID_ATTR_CHAR_RELIEF, SFX_ITEM_POOLABLE }, // ATTR_FONT_RELIEF from 632b +/*N*/ { SID_ATTR_ALIGN_HYPHENATION, SFX_ITEM_POOLABLE }, // ATTR_HYPHENATE from 632b +/*N*/ { 0, SFX_ITEM_POOLABLE }, // ATTR_SCRIPTSPACE from 614d +/*N*/ { 0, SFX_ITEM_POOLABLE }, // ATTR_HANGPUNCTUATION from 614d +/*N*/ { SID_ATTR_PARA_FORBIDDEN_RULES,SFX_ITEM_POOLABLE }, // ATTR_FORBIDDEN_RULES from 614d +/*N*/ { SID_ATTR_ALIGN_HOR_JUSTIFY, SFX_ITEM_POOLABLE }, // ATTR_HOR_JUSTIFY +/*N*/ { SID_ATTR_ALIGN_INDENT, SFX_ITEM_POOLABLE }, // ATTR_INDENT ab 350 +/*N*/ { SID_ATTR_ALIGN_VER_JUSTIFY, SFX_ITEM_POOLABLE }, // ATTR_VER_JUSTIFY +/*N*/ { SID_ATTR_ALIGN_ORIENTATION, SFX_ITEM_POOLABLE }, // ATTR_ORIENTATION +/*N*/ { SID_ATTR_ALIGN_DEGREES, SFX_ITEM_POOLABLE }, // ATTR_ROTATE_VALUE ab 367 +/*N*/ { SID_ATTR_ALIGN_LOCKPOS, SFX_ITEM_POOLABLE }, // ATTR_ROTATE_MODE ab 367 +/*N*/ { SID_ATTR_ALIGN_ASIANVERTICAL, SFX_ITEM_POOLABLE }, // ATTR_VERTICAL_ASIAN from 642 +/*N*/ { SID_ATTR_FRAMEDIRECTION, SFX_ITEM_POOLABLE }, // ATTR_WRITINGDIR from 643 +/*N*/ { SID_ATTR_ALIGN_LINEBREAK, SFX_ITEM_POOLABLE }, // ATTR_LINEBREAK +/*N*/ { SID_ATTR_ALIGN_MARGIN, SFX_ITEM_POOLABLE }, // ATTR_MARGIN +/*N*/ { 0, SFX_ITEM_POOLABLE }, // ATTR_MERGE +/*N*/ { 0, SFX_ITEM_POOLABLE }, // ATTR_MERGE_FLAG +/*N*/ { SID_ATTR_NUMBERFORMAT_VALUE, SFX_ITEM_POOLABLE }, // ATTR_VALUE_FORMAT +/*N*/ { ATTR_LANGUAGE_FORMAT, SFX_ITEM_POOLABLE }, // ATTR_LANGUAGE_FORMAT ab 329, wird im Dialog mit SID_ATTR_NUMBERFORMAT_VALUE kombiniert +/*N*/ { SID_ATTR_BRUSH, SFX_ITEM_POOLABLE }, // ATTR_BACKGROUND +/*N*/ { SID_SCATTR_PROTECTION, SFX_ITEM_POOLABLE }, // ATTR_PROTECTION +/*N*/ { SID_ATTR_BORDER_OUTER, SFX_ITEM_POOLABLE }, // ATTR_BORDER +/*N*/ { SID_ATTR_BORDER_INNER, SFX_ITEM_POOLABLE }, // ATTR_BORDER_INNER +/*N*/ { SID_ATTR_BORDER_SHADOW, SFX_ITEM_POOLABLE }, // ATTR_SHADOW +/*N*/ { 0, SFX_ITEM_POOLABLE }, // ATTR_VALIDDATA +/*N*/ { 0, SFX_ITEM_POOLABLE }, // ATTR_CONDITIONAL +/*N*/ { 0, SFX_ITEM_POOLABLE }, // ATTR_PATTERN +/*N*/ { SID_ATTR_LRSPACE, SFX_ITEM_POOLABLE }, // ATTR_LRSPACE +/*N*/ { SID_ATTR_ULSPACE, SFX_ITEM_POOLABLE }, // ATTR_ULSPACE +/*N*/ { SID_ATTR_PAGE, SFX_ITEM_POOLABLE }, // ATTR_PAGE +/*N*/ { 0, SFX_ITEM_POOLABLE }, // ATTR_PAGE_PAPERTRAY, seit 303 nur noch dummy +/*N*/ { SID_ATTR_PAGE_PAPERBIN, SFX_ITEM_POOLABLE }, // ATTR_PAGE_PAPERBIN +/*N*/ { SID_ATTR_PAGE_SIZE, SFX_ITEM_POOLABLE }, // ATTR_PAGE_SIZE +/*N*/ { SID_ATTR_PAGE_MAXSIZE, SFX_ITEM_POOLABLE }, // ATTR_PAGE_MAXSIZE +/*N*/ { SID_ATTR_PAGE_EXT1, SFX_ITEM_POOLABLE }, // ATTR_PAGE_HORCENTER +/*N*/ { SID_ATTR_PAGE_EXT2, SFX_ITEM_POOLABLE }, // ATTR_PAGE_VERCENTER +/*N*/ { SID_ATTR_PAGE_ON, SFX_ITEM_POOLABLE }, // ATTR_PAGE_ON +/*N*/ { SID_ATTR_PAGE_DYNAMIC, SFX_ITEM_POOLABLE }, // ATTR_PAGE_DYNAMIC +/*N*/ { SID_ATTR_PAGE_SHARED, SFX_ITEM_POOLABLE }, // ATTR_PAGE_SHARED +/*N*/ { SID_SCATTR_PAGE_NOTES, SFX_ITEM_POOLABLE }, // ATTR_PAGE_NOTES +/*N*/ { SID_SCATTR_PAGE_GRID, SFX_ITEM_POOLABLE }, // ATTR_PAGE_GRID +/*N*/ { SID_SCATTR_PAGE_HEADERS, SFX_ITEM_POOLABLE }, // ATTR_PAGE_HEADERS +/*N*/ { SID_SCATTR_PAGE_CHARTS, SFX_ITEM_POOLABLE }, // ATTR_PAGE_CHARTS +/*N*/ { SID_SCATTR_PAGE_OBJECTS, SFX_ITEM_POOLABLE }, // ATTR_PAGE_OBJECTS +/*N*/ { SID_SCATTR_PAGE_DRAWINGS, SFX_ITEM_POOLABLE }, // ATTR_PAGE_DRAWINGS +/*N*/ { SID_SCATTR_PAGE_TOPDOWN, SFX_ITEM_POOLABLE }, // ATTR_PAGE_TOPDOWN +/*N*/ { SID_SCATTR_PAGE_SCALE, SFX_ITEM_POOLABLE }, // ATTR_PAGE_SCALE +/*N*/ { SID_SCATTR_PAGE_SCALETOPAGES, SFX_ITEM_POOLABLE }, // ATTR_PAGE_SCALETOPAGES +/*N*/ { SID_SCATTR_PAGE_FIRSTPAGENO, SFX_ITEM_POOLABLE }, // ATTR_PAGE_FIRSTPAGENO +/*N*/ { SID_SCATTR_PAGE_PRINTAREA, SFX_ITEM_POOLABLE }, // ATTR_PAGE_PRINTAREA +/*N*/ { SID_SCATTR_PAGE_REPEATROW, SFX_ITEM_POOLABLE }, // ATTR_PAGE_REPEATROW +/*N*/ { SID_SCATTR_PAGE_REPEATCOL, SFX_ITEM_POOLABLE }, // ATTR_PAGE_REPEATCOL +/*N*/ { SID_SCATTR_PAGE_PRINTTABLES, SFX_ITEM_POOLABLE }, // ATTR_PAGE_PRINTTABLES +/*N*/ { SID_SCATTR_PAGE_HEADERLEFT, SFX_ITEM_POOLABLE }, // ATTR_PAGE_HEADERLEFT +/*N*/ { SID_SCATTR_PAGE_FOOTERLEFT, SFX_ITEM_POOLABLE }, // ATTR_PAGE_FOOTERLEFT +/*N*/ { SID_SCATTR_PAGE_HEADERRIGHT, SFX_ITEM_POOLABLE }, // ATTR_PAGE_HEADERRIGHT +/*N*/ { SID_SCATTR_PAGE_FOOTERRIGHT, SFX_ITEM_POOLABLE }, // ATTR_PAGE_FOOTERRIGHT +/*N*/ { SID_ATTR_PAGE_HEADERSET, SFX_ITEM_POOLABLE }, // ATTR_PAGE_HEADERSET +/*N*/ { SID_ATTR_PAGE_FOOTERSET, SFX_ITEM_POOLABLE }, // ATTR_PAGE_FOOTERSET +/*N*/ { SID_SCATTR_PAGE_FORMULAS, SFX_ITEM_POOLABLE }, // ATTR_PAGE_FORMULAS +/*N*/ { SID_SCATTR_PAGE_NULLVALS, SFX_ITEM_POOLABLE } // ATTR_PAGE_NULLVALS +/*N*/ }; + +// ----------------------------------------------------------------------- + +/*N*/ ScDocumentPool::ScDocumentPool( SfxItemPool* pSecPool, BOOL bLoadRefCounts ) +/*N*/ +/*N*/ : SfxItemPool ( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ScDocumentPool")), +/*N*/ ATTR_STARTINDEX, ATTR_ENDINDEX, +/*N*/ aItemInfos, NULL, bLoadRefCounts ), +/*N*/ pSecondary ( pSecPool ) +/*N*/ { +/*N*/ // latin font from GetDefaultFonts is not used, DEFAULTFONT_LATIN_SPREADSHEET instead +/*N*/ Font aStdFont = OutputDevice::GetDefaultFont( DEFAULTFONT_LATIN_SPREADSHEET, LANGUAGE_ENGLISH_US, +/*N*/ DEFAULTFONT_FLAGS_ONLYONE ); +/*N*/ SvxFontItem* pStdFont = new SvxFontItem( aStdFont.GetFamily(), +/*N*/ aStdFont.GetName(), aStdFont.GetStyleName(), +/*N*/ aStdFont.GetPitch(), aStdFont.GetCharSet(), +/*N*/ ATTR_FONT ); +/*N*/ +/*N*/ SvxFontItem* pCjkFont = new SvxFontItem( ATTR_CJK_FONT ); +/*N*/ SvxFontItem* pCtlFont = new SvxFontItem( ATTR_CTL_FONT ); +/*N*/ SvxFontItem aDummy; +/*N*/ GetDefaultFonts( aDummy, *pCjkFont, *pCtlFont ); +/*N*/ +/*N*/ SvxBoxInfoItem* pGlobalBorderInnerAttr = new SvxBoxInfoItem( ATTR_BORDER_INNER ); +/*N*/ SfxItemSet* pSet = new SfxItemSet( *this, ATTR_PATTERN_START, ATTR_PATTERN_END ); +/*N*/ SfxItemSet aSetItemItemSet( *this, +/*N*/ ATTR_BACKGROUND, ATTR_BACKGROUND, +/*N*/ ATTR_BORDER, ATTR_SHADOW, +/*N*/ ATTR_LRSPACE, ATTR_ULSPACE, +/*N*/ ATTR_PAGE_SIZE, ATTR_PAGE_SIZE, +/*N*/ ATTR_PAGE_ON, ATTR_PAGE_SHARED, +/*N*/ 0 ); +/*N*/ +/*N*/ pGlobalBorderInnerAttr->SetLine(NULL, BOXINFO_LINE_HORI); +/*N*/ pGlobalBorderInnerAttr->SetLine(NULL, BOXINFO_LINE_VERT); +/*N*/ pGlobalBorderInnerAttr->SetTable(TRUE); +/*N*/ pGlobalBorderInnerAttr->SetDist((BOOL)FALSE); +/*N*/ pGlobalBorderInnerAttr->SetMinDist(FALSE); +/*N*/ +/*N*/ ppPoolDefaults = new SfxPoolItem*[ATTR_ENDINDEX-ATTR_STARTINDEX+1]; +/*N*/ +/*N*/ ppPoolDefaults[ ATTR_FONT - ATTR_STARTINDEX ] = pStdFont; +/*N*/ ppPoolDefaults[ ATTR_FONT_HEIGHT - ATTR_STARTINDEX ] = new SvxFontHeightItem( 200 ); // 10 pt; +/*N*/ ppPoolDefaults[ ATTR_FONT_WEIGHT - ATTR_STARTINDEX ] = new SvxWeightItem; +/*N*/ ppPoolDefaults[ ATTR_FONT_POSTURE - ATTR_STARTINDEX ] = new SvxPostureItem; +/*N*/ ppPoolDefaults[ ATTR_FONT_UNDERLINE - ATTR_STARTINDEX ] = new SvxUnderlineItem; +/*N*/ ppPoolDefaults[ ATTR_FONT_CROSSEDOUT - ATTR_STARTINDEX ] = new SvxCrossedOutItem; +/*N*/ ppPoolDefaults[ ATTR_FONT_CONTOUR - ATTR_STARTINDEX ] = new SvxContourItem; +/*N*/ ppPoolDefaults[ ATTR_FONT_SHADOWED - ATTR_STARTINDEX ] = new SvxShadowedItem; +/*N*/ ppPoolDefaults[ ATTR_FONT_COLOR - ATTR_STARTINDEX ] = new SvxColorItem( Color(COL_AUTO) ); +/*N*/ ppPoolDefaults[ ATTR_FONT_LANGUAGE - ATTR_STARTINDEX ] = new SvxLanguageItem( LanguageType(LANGUAGE_DONTKNOW), ATTR_FONT_LANGUAGE ); +/*N*/ ppPoolDefaults[ ATTR_CJK_FONT - ATTR_STARTINDEX ] = pCjkFont; +/*N*/ ppPoolDefaults[ ATTR_CJK_FONT_HEIGHT - ATTR_STARTINDEX ] = new SvxFontHeightItem( 200, 100, ATTR_CJK_FONT_HEIGHT ); +/*N*/ ppPoolDefaults[ ATTR_CJK_FONT_WEIGHT - ATTR_STARTINDEX ] = new SvxWeightItem( WEIGHT_NORMAL, ATTR_CJK_FONT_WEIGHT ); +/*N*/ ppPoolDefaults[ ATTR_CJK_FONT_POSTURE- ATTR_STARTINDEX ] = new SvxPostureItem( ITALIC_NONE, ATTR_CJK_FONT_POSTURE ); +/*N*/ ppPoolDefaults[ ATTR_CJK_FONT_LANGUAGE-ATTR_STARTINDEX ] = new SvxLanguageItem( LanguageType(LANGUAGE_DONTKNOW), +/*N*/ ATTR_CJK_FONT_LANGUAGE ); +/*N*/ ppPoolDefaults[ ATTR_CTL_FONT - ATTR_STARTINDEX ] = pCtlFont; +/*N*/ ppPoolDefaults[ ATTR_CTL_FONT_HEIGHT - ATTR_STARTINDEX ] = new SvxFontHeightItem( 200, 100, ATTR_CTL_FONT_HEIGHT ); +/*N*/ ppPoolDefaults[ ATTR_CTL_FONT_WEIGHT - ATTR_STARTINDEX ] = new SvxWeightItem( WEIGHT_NORMAL, ATTR_CTL_FONT_WEIGHT ); +/*N*/ ppPoolDefaults[ ATTR_CTL_FONT_POSTURE- ATTR_STARTINDEX ] = new SvxPostureItem( ITALIC_NONE, ATTR_CTL_FONT_POSTURE ); +/*N*/ ppPoolDefaults[ ATTR_CTL_FONT_LANGUAGE-ATTR_STARTINDEX ] = new SvxLanguageItem( LanguageType(LANGUAGE_DONTKNOW), +/*N*/ ATTR_CTL_FONT_LANGUAGE ); +/*N*/ ppPoolDefaults[ ATTR_FONT_EMPHASISMARK-ATTR_STARTINDEX ] = new SvxEmphasisMarkItem; +/*N*/ ppPoolDefaults[ ATTR_USERDEF - ATTR_STARTINDEX ] = new SvXMLAttrContainerItem( ATTR_USERDEF ); +/*N*/ ppPoolDefaults[ ATTR_FONT_WORDLINE - ATTR_STARTINDEX ] = new SvxWordLineModeItem; +/*N*/ ppPoolDefaults[ ATTR_FONT_RELIEF - ATTR_STARTINDEX ] = new SvxCharReliefItem; +/*N*/ ppPoolDefaults[ ATTR_HYPHENATE - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_HYPHENATE ); +/*N*/ ppPoolDefaults[ ATTR_SCRIPTSPACE - ATTR_STARTINDEX ] = new SvxScriptSpaceItem; +/*N*/ ppPoolDefaults[ ATTR_HANGPUNCTUATION - ATTR_STARTINDEX ] = new SvxHangingPunctuationItem; +/*N*/ ppPoolDefaults[ ATTR_FORBIDDEN_RULES - ATTR_STARTINDEX ] = new SvxForbiddenRuleItem; +/*N*/ ppPoolDefaults[ ATTR_HOR_JUSTIFY - ATTR_STARTINDEX ] = new SvxHorJustifyItem; +/*N*/ ppPoolDefaults[ ATTR_INDENT - ATTR_STARTINDEX ] = new SfxUInt16Item( ATTR_INDENT, 0 ); +/*N*/ ppPoolDefaults[ ATTR_VER_JUSTIFY - ATTR_STARTINDEX ] = new SvxVerJustifyItem; +/*N*/ ppPoolDefaults[ ATTR_ORIENTATION - ATTR_STARTINDEX ] = new SvxOrientationItem; +/*N*/ ppPoolDefaults[ ATTR_ROTATE_VALUE - ATTR_STARTINDEX ] = new SfxInt32Item( ATTR_ROTATE_VALUE, 0 ); +/*N*/ ppPoolDefaults[ ATTR_ROTATE_MODE - ATTR_STARTINDEX ] = new SvxRotateModeItem( SVX_ROTATE_MODE_BOTTOM, ATTR_ROTATE_MODE ); +/*N*/ ppPoolDefaults[ ATTR_VERTICAL_ASIAN - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_VERTICAL_ASIAN ); + // The default for the ATTR_WRITINGDIR cell attribute must by FRMDIR_ENVIRONMENT, + // so that value is returned when asking for a default cell's attributes. + // The value from the page style is set as DefaultHorizontalTextDirection for the EditEngine. +/*N*/ ppPoolDefaults[ ATTR_WRITINGDIR - ATTR_STARTINDEX ] = new SvxFrameDirectionItem( FRMDIR_ENVIRONMENT, ATTR_WRITINGDIR ); +/*N*/ ppPoolDefaults[ ATTR_LINEBREAK - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_LINEBREAK ); +/*N*/ ppPoolDefaults[ ATTR_MARGIN - ATTR_STARTINDEX ] = new SvxMarginItem; +/*N*/ ppPoolDefaults[ ATTR_MERGE - ATTR_STARTINDEX ] = new ScMergeAttr; +/*N*/ ppPoolDefaults[ ATTR_MERGE_FLAG - ATTR_STARTINDEX ] = new ScMergeFlagAttr; +/*N*/ ppPoolDefaults[ ATTR_VALUE_FORMAT - ATTR_STARTINDEX ] = new SfxUInt32Item( ATTR_VALUE_FORMAT, 0 ); +/*N*/ ppPoolDefaults[ ATTR_LANGUAGE_FORMAT - ATTR_STARTINDEX ] = new SvxLanguageItem( ScGlobal::eLnge, ATTR_LANGUAGE_FORMAT ); +/*N*/ ppPoolDefaults[ ATTR_BACKGROUND - ATTR_STARTINDEX ] = new SvxBrushItem( Color(COL_TRANSPARENT), ATTR_BACKGROUND ); +/*N*/ ppPoolDefaults[ ATTR_PROTECTION - ATTR_STARTINDEX ] = new ScProtectionAttr; +/*N*/ ppPoolDefaults[ ATTR_BORDER - ATTR_STARTINDEX ] = new SvxBoxItem( ATTR_BORDER ); +/*N*/ ppPoolDefaults[ ATTR_BORDER_INNER - ATTR_STARTINDEX ] = pGlobalBorderInnerAttr; +/*N*/ ppPoolDefaults[ ATTR_SHADOW - ATTR_STARTINDEX ] = new SvxShadowItem( ATTR_SHADOW ); +/*N*/ ppPoolDefaults[ ATTR_VALIDDATA - ATTR_STARTINDEX ] = new SfxUInt32Item( ATTR_VALIDDATA, 0 ); +/*N*/ ppPoolDefaults[ ATTR_CONDITIONAL - ATTR_STARTINDEX ] = new SfxUInt32Item( ATTR_CONDITIONAL, 0 ); +/*N*/ +/*N*/ // GetRscString funktioniert erst nach ScGlobal::Init, zu erkennen am EmptyBrushItem +/*N*/ //! zusaetzliche Methode ScGlobal::IsInit() oder so... +/*N*/ //! oder erkennen, ob dies der Secondary-Pool fuer einen MessagePool ist +/*N*/ if ( ScGlobal::GetEmptyBrushItem() ) +/*N*/ ppPoolDefaults[ ATTR_PATTERN - ATTR_STARTINDEX ] = new ScPatternAttr( pSet, ScGlobal::GetRscString(STR_STYLENAME_STANDARD) ); +/*N*/ else +/*N*/ ppPoolDefaults[ ATTR_PATTERN - ATTR_STARTINDEX ] = new ScPatternAttr( pSet, +/*N*/ String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(STRING_STANDARD)) ); //! without name? +/*N*/ +/*N*/ ppPoolDefaults[ ATTR_LRSPACE - ATTR_STARTINDEX ] = new SvxLRSpaceItem( ATTR_LRSPACE ); +/*N*/ ppPoolDefaults[ ATTR_ULSPACE - ATTR_STARTINDEX ] = new SvxULSpaceItem( ATTR_ULSPACE ); +/*N*/ ppPoolDefaults[ ATTR_PAGE - ATTR_STARTINDEX ] = new SvxPageItem( ATTR_PAGE ); +/*N*/ ppPoolDefaults[ ATTR_PAGE_PAPERTRAY - ATTR_STARTINDEX ] = new SfxAllEnumItem( ATTR_PAGE_PAPERTRAY ); +/*N*/ ppPoolDefaults[ ATTR_PAGE_PAPERBIN - ATTR_STARTINDEX ] = new SvxPaperBinItem( ATTR_PAGE_PAPERBIN ); +/*N*/ ppPoolDefaults[ ATTR_PAGE_SIZE - ATTR_STARTINDEX ] = new SvxSizeItem( ATTR_PAGE_SIZE ); +/*N*/ ppPoolDefaults[ ATTR_PAGE_MAXSIZE - ATTR_STARTINDEX ] = new SvxSizeItem( ATTR_PAGE_MAXSIZE ); +/*N*/ ppPoolDefaults[ ATTR_PAGE_HORCENTER - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_PAGE_HORCENTER ); +/*N*/ ppPoolDefaults[ ATTR_PAGE_VERCENTER - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_PAGE_VERCENTER ); +/*N*/ ppPoolDefaults[ ATTR_PAGE_ON - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_PAGE_ON, TRUE ); +/*N*/ ppPoolDefaults[ ATTR_PAGE_DYNAMIC - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_PAGE_DYNAMIC, TRUE ); +/*N*/ ppPoolDefaults[ ATTR_PAGE_SHARED - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_PAGE_SHARED, TRUE ); +/*N*/ ppPoolDefaults[ ATTR_PAGE_NOTES - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_PAGE_NOTES, FALSE ); +/*N*/ ppPoolDefaults[ ATTR_PAGE_GRID - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_PAGE_GRID, FALSE ); +/*N*/ ppPoolDefaults[ ATTR_PAGE_HEADERS - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_PAGE_HEADERS, FALSE ); +/*N*/ ppPoolDefaults[ ATTR_PAGE_CHARTS - ATTR_STARTINDEX ] = new ScViewObjectModeItem( ATTR_PAGE_CHARTS ); +/*N*/ ppPoolDefaults[ ATTR_PAGE_OBJECTS - ATTR_STARTINDEX ] = new ScViewObjectModeItem( ATTR_PAGE_OBJECTS ); +/*N*/ ppPoolDefaults[ ATTR_PAGE_DRAWINGS - ATTR_STARTINDEX ] = new ScViewObjectModeItem( ATTR_PAGE_DRAWINGS ); +/*N*/ ppPoolDefaults[ ATTR_PAGE_TOPDOWN - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_PAGE_TOPDOWN, TRUE ); +/*N*/ ppPoolDefaults[ ATTR_PAGE_SCALE - ATTR_STARTINDEX ] = new SfxUInt16Item( ATTR_PAGE_SCALE, 100 ); +/*N*/ ppPoolDefaults[ ATTR_PAGE_SCALETOPAGES-ATTR_STARTINDEX ] = new SfxUInt16Item( ATTR_PAGE_SCALETOPAGES, 1 ); +/*N*/ ppPoolDefaults[ ATTR_PAGE_FIRSTPAGENO- ATTR_STARTINDEX ] = new SfxUInt16Item( ATTR_PAGE_FIRSTPAGENO, 1 ); +/*N*/ ppPoolDefaults[ ATTR_PAGE_PRINTAREA - ATTR_STARTINDEX ] = new ScRangeItem( ATTR_PAGE_PRINTAREA ); +/*N*/ ppPoolDefaults[ ATTR_PAGE_REPEATROW - ATTR_STARTINDEX ] = new ScRangeItem( ATTR_PAGE_REPEATROW ); +/*N*/ ppPoolDefaults[ ATTR_PAGE_REPEATCOL - ATTR_STARTINDEX ] = new ScRangeItem( ATTR_PAGE_REPEATCOL ); +/*N*/ ppPoolDefaults[ ATTR_PAGE_PRINTTABLES- ATTR_STARTINDEX ] = new ScTableListItem( ATTR_PAGE_PRINTTABLES ); +/*N*/ ppPoolDefaults[ ATTR_PAGE_HEADERLEFT - ATTR_STARTINDEX ] = new ScPageHFItem( ATTR_PAGE_HEADERLEFT ); +/*N*/ ppPoolDefaults[ ATTR_PAGE_FOOTERLEFT - ATTR_STARTINDEX ] = new ScPageHFItem( ATTR_PAGE_FOOTERLEFT ); +/*N*/ ppPoolDefaults[ ATTR_PAGE_HEADERRIGHT- ATTR_STARTINDEX ] = new ScPageHFItem( ATTR_PAGE_HEADERRIGHT ); +/*N*/ ppPoolDefaults[ ATTR_PAGE_FOOTERRIGHT- ATTR_STARTINDEX ] = new ScPageHFItem( ATTR_PAGE_FOOTERRIGHT ); +/*N*/ ppPoolDefaults[ ATTR_PAGE_HEADERSET - ATTR_STARTINDEX ] = new SvxSetItem( ATTR_PAGE_HEADERSET, aSetItemItemSet ); +/*N*/ ppPoolDefaults[ ATTR_PAGE_FOOTERSET - ATTR_STARTINDEX ] = new SvxSetItem( ATTR_PAGE_FOOTERSET, aSetItemItemSet ); +/*N*/ ppPoolDefaults[ ATTR_PAGE_FORMULAS - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_PAGE_FORMULAS, FALSE ); +/*N*/ ppPoolDefaults[ ATTR_PAGE_NULLVALS - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_PAGE_NULLVALS, TRUE ); +/*N*/ // ppPoolDefaults[ ATTR_ITEM_DOUBLE - ATTR_STARTINDEX ] = new ScDoubleItem( ATTR_ITEM_DOUBLE, 0 ); +/*N*/ +/*N*/ SetDefaults( ppPoolDefaults ); +/*N*/ +/*N*/ if ( pSecondary ) +/*?*/ SetSecondaryPool( pSecondary ); +/*N*/ +/*N*/ // ATTR_LANGUAGE_FORMAT ab sv329 eingefuegt, VersionMap in _ScGlobal__Init +/*N*/ SetVersionMap( 1, 100, 157, pVersionMap1 ); +/*N*/ +/*N*/ // ATTR_VALIDDATA, ATTR_CONDITIONAL ab 341 +/*N*/ SetVersionMap( 2, 100, 158, pVersionMap2 ); +/*N*/ +/*N*/ // ATTR_INDENT ab 350 +/*N*/ SetVersionMap( 3, 100, 160, pVersionMap3 ); +/*N*/ +/*N*/ // ATTR_ROTATE_VALUE, ATTR_ROTATE_MODE ab 367 +/*N*/ SetVersionMap( 4, 100, 161, pVersionMap4 ); +/*N*/ +/*N*/ // CJK, CTL, EMPHASISMARK, TWOLINES from 614 +/*N*/ SetVersionMap( 5, 100, 163, pVersionMap5 ); +/*N*/ +/*N*/ // ATTR_SCRIPTSPACE, ATTR_HANGPUNCTUATION, ATTR_FORBIDDEN_RULES from 614d +/*N*/ SetVersionMap( 6, 100, 175, pVersionMap6 ); +/*N*/ +/*N*/ // ATTR_FONT_WORDLINE, ATTR_FONT_RELIEF, ATTR_HYPHENATE from 632b +/*N*/ SetVersionMap( 7, 100, 178, pVersionMap7 ); +/*N*/ +/*N*/ // ATTR_VERTICAL_ASIAN from 642q +/*N*/ SetVersionMap( 8, 100, 181, pVersionMap8 ); + + // ATTR_WRITINGDIR from 643y +/*N*/ SetVersionMap( 9, 100, 182, pVersionMap9 ); +/*N*/ } + +/*N*/ __EXPORT ScDocumentPool::~ScDocumentPool() +/*N*/ { +/*N*/ Delete(); +/*N*/ +/*N*/ for ( USHORT i=0; i < ATTR_ENDINDEX-ATTR_STARTINDEX+1; i++ ) +/*N*/ { +/*N*/ SetRefCount( *ppPoolDefaults[i], 0 ); +/*N*/ delete ppPoolDefaults[i]; +/*N*/ } +/*N*/ +/*N*/ delete[] ppPoolDefaults; +/*N*/ delete pSecondary; +/*N*/ } + +/*N*/ void ScDocumentPool::InitVersionMaps() +/*N*/ { +/*N*/ DBG_ASSERT( !pVersionMap1 && !pVersionMap2 && +/*N*/ !pVersionMap3 && !pVersionMap4 && +/*N*/ !pVersionMap5 && !pVersionMap6 && +/*N*/ !pVersionMap7 && !pVersionMap8 && +/*N*/ !pVersionMap9, "InitVersionMaps call multiple times" ); +/*N*/ +/*N*/ // alte WhichId's mappen +/*N*/ // nicht mit ATTR_* zaehlen, falls die sich nochmal aendern +/*N*/ +/*N*/ // erste Map: ATTR_LANGUAGE_FORMAT ab sv329 eingefuegt +/*N*/ +/*N*/ const USHORT nMap1Start = 100; // alter ATTR_STARTINDEX +/*N*/ const USHORT nMap1End = 157; // alter ATTR_ENDINDEX +/*N*/ const USHORT nMap1Count = nMap1End - nMap1Start + 1; +/*N*/ const USHORT nMap1New = 18; // ATTR_LANGUAGE_FORMAT - ATTR_STARTINDEX +/*N*/ pVersionMap1 = new USHORT [ nMap1Count ]; +/*N*/ USHORT i, j; +/*N*/ for ( i=0, j=nMap1Start; i < nMap1New; i++, j++ ) +/*N*/ pVersionMap1[i] = j; +/*N*/ // ein Eintrag eingefuegt... +/*N*/ for ( i=nMap1New, j=nMap1Start+nMap1New+1; i < nMap1Count; i++, j++ ) +/*N*/ pVersionMap1[i] = j; +/*N*/ +/*N*/ // zweite Map: ATTR_VALIDDATA und ATTR_CONDITIONAL ab 341 eingefuegt +/*N*/ +/*N*/ const USHORT nMap2Start = 100; // ATTR_STARTINDEX +/*N*/ const USHORT nMap2End = 158; // ATTR_ENDINDEX +/*N*/ const USHORT nMap2Count = nMap2End - nMap2Start + 1; +/*N*/ const USHORT nMap2New = 24; // ATTR_VALIDDATA - ATTR_STARTINDEX +/*N*/ pVersionMap2 = new USHORT [ nMap2Count ]; +/*N*/ for ( i=0, j=nMap2Start; i < nMap2New; i++, j++ ) +/*N*/ pVersionMap2[i] = j; +/*N*/ // zwei Eintraege eingefuegt... +/*N*/ for ( i=nMap2New, j=nMap2Start+nMap2New+2; i < nMap2Count; i++, j++ ) +/*N*/ pVersionMap2[i] = j; +/*N*/ +/*N*/ // dritte Map: ATTR_INDENT ab 350 eingefuegt +/*N*/ +/*N*/ const USHORT nMap3Start = 100; // ATTR_STARTINDEX +/*N*/ const USHORT nMap3End = 160; // ATTR_ENDINDEX +/*N*/ const USHORT nMap3Count = nMap3End - nMap3Start + 1; +/*N*/ const USHORT nMap3New = 11; // ATTR_INDENT - ATTR_STARTINDEX +/*N*/ pVersionMap3 = new USHORT [ nMap3Count ]; +/*N*/ for ( i=0, j=nMap3Start; i < nMap3New; i++, j++ ) +/*N*/ pVersionMap3[i] = j; +/*N*/ // ein Eintrag eingefuegt... +/*N*/ for ( i=nMap3New, j=nMap3Start+nMap3New+1; i < nMap3Count; i++, j++ ) +/*N*/ pVersionMap3[i] = j; +/*N*/ +/*N*/ // vierte Map: ATTR_ROTATE_VALUE und ATTR_ROTATE_MODE ab 367 eingefuegt +/*N*/ +/*N*/ const USHORT nMap4Start = 100; // ATTR_STARTINDEX +/*N*/ const USHORT nMap4End = 161; // ATTR_ENDINDEX +/*N*/ const USHORT nMap4Count = nMap4End - nMap4Start + 1; +/*N*/ const USHORT nMap4New = 14; // ATTR_ROTATE_VALUE - ATTR_STARTINDEX +/*N*/ pVersionMap4 = new USHORT [ nMap4Count ]; +/*N*/ for ( i=0, j=nMap4Start; i < nMap4New; i++, j++ ) +/*N*/ pVersionMap4[i] = j; +/*N*/ // zwei Eintraege eingefuegt... +/*N*/ for ( i=nMap4New, j=nMap4Start+nMap4New+2; i < nMap4Count; i++, j++ ) +/*N*/ pVersionMap4[i] = j; +/*N*/ +/*N*/ // fifth map: CJK..., CTL..., EMPHASISMARK, TWOLINES (12 items) added in 614 +/*N*/ +/*N*/ const USHORT nMap5Start = 100; // ATTR_STARTINDEX +/*N*/ const USHORT nMap5End = 163; // ATTR_ENDINDEX +/*N*/ const USHORT nMap5Count = nMap5End - nMap5Start + 1; +/*N*/ const USHORT nMap5New = 10; // ATTR_CJK_FONT - ATTR_STARTINDEX +/*N*/ pVersionMap5 = new USHORT [ nMap5Count ]; +/*N*/ for ( i=0, j=nMap5Start; i < nMap5New; i++, j++ ) +/*N*/ pVersionMap5[i] = j; +/*N*/ // 12 entries inserted +/*N*/ for ( i=nMap5New, j=nMap5Start+nMap5New+12; i < nMap5Count; i++, j++ ) +/*N*/ pVersionMap5[i] = j; +/*N*/ +/*N*/ // sixth map: ATTR_SCRIPTSPACE, ATTR_HANGPUNCTUATION, ATTR_FORBIDDEN_RULES added in 614d +/*N*/ +/*N*/ const USHORT nMap6Start = 100; // ATTR_STARTINDEX +/*N*/ const USHORT nMap6End = 175; // ATTR_ENDINDEX +/*N*/ const USHORT nMap6Count = nMap6End - nMap6Start + 1; +/*N*/ const USHORT nMap6New = 22; // ATTR_SCRIPTSPACE - ATTR_STARTINDEX +/*N*/ pVersionMap6 = new USHORT [ nMap6Count ]; +/*N*/ for ( i=0, j=nMap6Start; i < nMap6New; i++, j++ ) +/*N*/ pVersionMap6[i] = j; +/*N*/ // 3 entries inserted +/*N*/ for ( i=nMap6New, j=nMap6Start+nMap6New+3; i < nMap6Count; i++, j++ ) +/*N*/ pVersionMap6[i] = j; +/*N*/ +/*N*/ // seventh map: ATTR_FONT_WORDLINE, ATTR_FONT_RELIEF, ATTR_HYPHENATE added in 632b +/*N*/ +/*N*/ const USHORT nMap7Start = 100; // ATTR_STARTINDEX +/*N*/ const USHORT nMap7End = 178; // ATTR_ENDINDEX +/*N*/ const USHORT nMap7Count = nMap7End - nMap7Start + 1; +/*N*/ const USHORT nMap7New = 22; // ATTR_FONT_WORDLINE - ATTR_STARTINDEX +/*N*/ pVersionMap7 = new USHORT [ nMap7Count ]; +/*N*/ for ( i=0, j=nMap7Start; i < nMap7New; i++, j++ ) +/*N*/ pVersionMap7[i] = j; +/*N*/ // 3 entries inserted +/*N*/ for ( i=nMap7New, j=nMap7Start+nMap7New+3; i < nMap7Count; i++, j++ ) +/*N*/ pVersionMap7[i] = j; +/*N*/ +/*N*/ // eighth map: ATTR_VERTICAL_ASIAN added in 642q +/*N*/ +/*N*/ const USHORT nMap8Start = 100; // ATTR_STARTINDEX +/*N*/ const USHORT nMap8End = 181; // ATTR_ENDINDEX +/*N*/ const USHORT nMap8Count = nMap8End - nMap8Start + 1; +/*N*/ const USHORT nMap8New = 34; // ATTR_VERTICAL_ASIAN - ATTR_STARTINDEX +/*N*/ pVersionMap8 = new USHORT [ nMap8Count ]; +/*N*/ for ( i=0, j=nMap8Start; i < nMap8New; i++, j++ ) +/*N*/ pVersionMap8[i] = j; +/*N*/ // 1 entry inserted +/*N*/ for ( i=nMap8New, j=nMap8Start+nMap8New+1; i < nMap8Count; i++, j++ ) +/*N*/ pVersionMap8[i] = j; + +/*M*/ // 9th map: ATTR_WRITINGDIR added in 643y +/*M*/ +/*M*/ const USHORT nMap9Start = 100; // ATTR_STARTINDEX +/*M*/ const USHORT nMap9End = 182; // ATTR_ENDINDEX +/*M*/ const USHORT nMap9Count = nMap9End - nMap9Start + 1; +/*M*/ const USHORT nMap9New = 35; // ATTR_WRITINGDIR - ATTR_STARTINDEX +/*M*/ pVersionMap9 = new USHORT [ nMap9Count ]; +/*M*/ for ( i=0, j=nMap9Start; i < nMap9New; i++, j++ ) +/*M*/ pVersionMap9[i] = j; +/*M*/ // 1 entry inserted +/*M*/ for ( i=nMap9New, j=nMap9Start+nMap9New+1; i < nMap9Count; i++, j++ ) +/*M*/ pVersionMap9[i] = j; +/*N*/ } + +/*N*/ void ScDocumentPool::DeleteVersionMaps() +/*N*/ { +/*N*/ DBG_ASSERT( pVersionMap1 && pVersionMap2 && +/*N*/ pVersionMap3 && pVersionMap4 && +/*N*/ pVersionMap5 && pVersionMap6 && +/*M*/ pVersionMap7 && pVersionMap8 && +/*M*/ pVersionMap9, "DeleteVersionMaps without maps" ); +/*M*/ +/*M*/ delete[] pVersionMap9; +/*M*/ pVersionMap9 = 0; +/*N*/ delete[] pVersionMap8; +/*N*/ pVersionMap8 = 0; +/*N*/ delete[] pVersionMap7; +/*N*/ pVersionMap7 = 0; +/*N*/ delete[] pVersionMap6; +/*N*/ pVersionMap6 = 0; +/*N*/ delete[] pVersionMap5; +/*N*/ pVersionMap5 = 0; +/*N*/ delete[] pVersionMap4; +/*N*/ pVersionMap4 = 0; +/*N*/ delete[] pVersionMap3; +/*N*/ pVersionMap3 = 0; +/*N*/ delete[] pVersionMap2; +/*N*/ pVersionMap2 = 0; +/*N*/ delete[] pVersionMap1; +/*N*/ pVersionMap1 = 0; +/*N*/ } + +// ---------------------------------------------------------------------------------------- +// +// Fuer die Pattern-Attribute (SetItems) kann der USHORT RefCount leicht ueberlaufen +// (z.B. 600 ganze Zeilen abwechselnd formatieren). +// Darum wird der RefCount bei SC_MAX_POOLREF festgehalten und nicht mehr hoch- oder +// heruntergezaehlt. Dieser RefCount wird dann erst beim naechsten Laden neu gezaehlt. +// Die Differenz zwischen SC_MAX_POOLREF und SC_SAFE_POOLREF ist ein wenig groesser +// als noetig, um zu erkennen, wenn der RefCount aus Versehen doch "normal" veraendert +// wird (Assertions). +// + +/*N*/ const SfxPoolItem& __EXPORT ScDocumentPool::Put( const SfxPoolItem& rItem, USHORT nWhich ) +/*N*/ { +/*N*/ if ( rItem.Which() != ATTR_PATTERN ) // nur Pattern ist special +/*N*/ return SfxItemPool::Put( rItem, nWhich ); +/*N*/ +/*N*/ // das Default-Pattern dieses Pools nicht kopieren +/*N*/ if (&rItem == ppPoolDefaults[ ATTR_PATTERN - ATTR_STARTINDEX ]) +/*N*/ return rItem; +/*N*/ +/*N*/ // ansonsten muss Put immer passieren, weil es ein anderer Pool sein kann +/*N*/ const SfxPoolItem& rNew = SfxItemPool::Put( rItem, nWhich ); +/*N*/ CheckRef( rNew ); +/*N*/ return rNew; +/*N*/ } + +/*N*/ void __EXPORT ScDocumentPool::Remove( const SfxPoolItem& rItem ) +/*N*/ { +/*N*/ if ( rItem.Which() == ATTR_PATTERN ) // nur Pattern ist special +/*N*/ { +/*N*/ ULONG nRef = rItem.GetRefCount(); +/*N*/ if ( nRef >= (ULONG) SC_MAX_POOLREF && nRef <= (ULONG) SFX_ITEMS_OLD_MAXREF ) +/*N*/ { +/*?*/ if ( nRef != (ULONG) SC_SAFE_POOLREF ) +/*?*/ { +/*?*/ DBG_ERROR("Wer fummelt da an meinen Ref-Counts herum"); +/*?*/ SetRefCount( (SfxPoolItem&)rItem, (ULONG) SC_SAFE_POOLREF ); +/*?*/ } +/*?*/ return; // nicht herunterzaehlen +/*N*/ } +/*N*/ } +/*N*/ SfxItemPool::Remove( rItem ); +/*N*/ } + +/*N*/ void ScDocumentPool::CheckRef( const SfxPoolItem& rItem ) // static +/*N*/ { +/*N*/ ULONG nRef = rItem.GetRefCount(); +/*N*/ if ( nRef >= (ULONG) SC_MAX_POOLREF && nRef <= (ULONG) SFX_ITEMS_OLD_MAXREF ) +/*N*/ { +/*?*/ // beim Apply vom Cache wird evtl. um 2 hochgezaehlt (auf MAX+1 oder SAFE+2), +/*?*/ // heruntergezaehlt wird nur einzeln (in LoadCompleted) +/*?*/ DBG_ASSERT( nRef<=(ULONG)SC_MAX_POOLREF+1 || (nRef>=(ULONG)SC_SAFE_POOLREF-1 && nRef<=(ULONG)SC_SAFE_POOLREF+2), +/*?*/ "ScDocumentPool::CheckRef" ); +/*?*/ SetRefCount( (SfxPoolItem&)rItem, (ULONG) SC_SAFE_POOLREF ); +/*N*/ } +/*N*/ } + +/*N*/ void ScDocumentPool::MyLoadCompleted() +/*N*/ { +/*N*/ LoadCompleted(); +/*N*/ +/*N*/ USHORT nCount = GetItemCount(ATTR_PATTERN); +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ { +/*N*/ const SfxPoolItem* pItem = GetItem(ATTR_PATTERN, i); +/*N*/ if (pItem) +/*N*/ CheckRef(*pItem); +/*N*/ } +/*N*/ } + +// ---------------------------------------------------------------------------------------- + + + + + + + + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_documen2.cxx b/binfilter/bf_sc/source/core/data/sc_documen2.cxx new file mode 100644 index 000000000000..a1f5d4a5429f --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_documen2.cxx @@ -0,0 +1,1411 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#define _BIGINT_HXX +#define _SFXMULTISEL_HXX +//#define _STACK_HXX +//#define _QUEUE_HXX +#define _DYNARR_HXX +#define _TREELIST_HXX +#define _CACHESTR_HXX +#define _NEW_HXX +//#define _SHL_HXX *** +//#define _LINK_HXX *** +//#define _ERRCODE_HXX *** +//#define _GEN_HXX *** +//#define _FRACT_HXX *** +//#define _STRING_HXX *** +//#define _MTF_HXX *** +//#define _CONTNR_HXX *** +//#define _LIST_HXX *** +//#define _TABLE_HXX *** +#define _DYNARY_HXX +//#define _UNQIDX_HXX *** +//#define _SVMEMPOOL_HXX *** +//#define _UNQID_HXX *** +//#define _DEBUG_HXX *** +//#define _DATE_HXX *** +//#define _TIME_HXX *** +//#define _DATETIME_HXX *** +//#define _INTN_HXX *** +//#define _WLDCRD_HXX *** +//#define _FSYS_HXX *** +//#define _STREAM_HXX *** +#define _CACHESTR_HXX +//#define _SV_MULTISEL_HXX + + + +#define _SV_NOXSOUND + +#define _BASDLG_HXX +#define _CACHESTR_HXX +#define _CTRLTOOL_HXX +#define _DLGCFG_HXX +#define _EXTATTR_HXX +#define _FILDLG_HXX +#define _FRM3D_HXX +#define _INTRO_HXX +#define _ISETBWR_HXX +#define _NO_SVRTF_PARSER_HXX +#define _MACRODLG_HXX +#define _MODALDLG_HXX +#define _MOREBUTTON_HXX +#define _OUTLINER_HXX +#define _PASSWD_HXX +//#define _QUEUE_HXX +#define _RULER_HXX +#define _SCRWIN_HXX +#define _SETBRW_HXX +#define _STATUS_HXX +#define _STDMENU_HXX +#define _TABBAR_HXX +#define _RULER_HXX +#define _SCRWIN_HXX +#define _SELENG_HXX +#define _SETBRW_HXX +#define _SOUND_HXX +#define _STATUS_HXX +#define _STDMENU_HXX + + +//#define _PRNDLG_HXX *** +//#define _POLY_HXX ** +// TOOLS +#define _BIGINT_HXX +#define _SFXMULTISEL_HXX +//#define _STACK_HXX +//#define _QUEUE_HXX +#define _DYNARR_HXX +#define _TREELIST_HXX +#define _CACHESTR_HXX + +//SV +//#define _CLIP_HXX +#define _CONFIG_HXX +#define _CURSOR_HXX +#define _FONTDLG_HXX +#define _PRVWIN_HXX + +#ifndef OS2 +#define _MENUBTN_HXX +#endif + +//#define _SOBASE_HXX +//#define _SOSTOR_HXX +//#define _SOCORE_HXX +//#define _SOINPL_HXX + +#define _SFX_DOCFILE_HXX +#define _SFX_DOCFILT_HXX +#define _SFX_DOCINF_HXX +#define _SFX_DOCSH_HXX +#define _SFX_INTERNO_HXX +#define _SFX_PRNMON_HXX +#define _SFX_RESMGR_HXX +#define _SFX_TEMPLDLG_HXX +#define _SFXAPPWIN_HXX +#define _SFXBASIC_HXX +#define _SFXCTRLITEM +#define _SFXDLGCFG_HXX +#define _SFXDISPATCH_HXX +#define _SFXDOCFILE_HXX +#define _SFXDOCMAN_HXX +#define _SFXDOCMGR_HXX +#define _SFXDOCTDLG_HXX +#define _SFXFILEDLG_HXX +#define _SFXIMGMGR_HXX +#define _SFXIPFRM_HXX +#define _SFX_MACRO_HXX +#define _SFXMNUITEM_HXX +#define _SFXMNUMGR_HXX +#define _SFXMULTISEL_HXX +//#define _SFXMSG_HXX +#define _SFXMSGDESCR_HXX +#define _SFXMSGPOOL_HXX +#define _SFX_MINFITEM_HXX +#define _SFXOBJFACE_HXX +#define _SFXOBJFAC_HXX +#define _SFX_SAVEOPT_HXX +#define _SFXSTBITEM_HXX +#define _SFXSTBMGR_HXX +#define _SFXTBXCTRL_HXX +#define _SFXTBXMGR_HXX + +//#define _SI_HXX +//#define SI_NODRW +#define _SI_DLL_HXX +#define _SIDLL_HXX +#define _SI_NOITEMS +#define _SI_NOOTHERFORMS +#define _SI_NOSBXCONTROLS +#define _SINOSBXCONTROLS +#define _SI_NODRW // +#define _SI_NOCONTROL +#define _VCBRW_HXX +#define _VCTRLS_HXX +//#define _VCSBX_HXX +#define _VCONT_HXX +#define _VDRWOBJ_HXX +#define _VCATTR_HXX + + +#define _SVBOXITM_HXX +#define _SVCONTNR_HXX +#define _SVDIALDLL_HXX +//#define _SVDATTR_HXX +#define _SVDRAG_HXX +#define _SVDXOUT_HXX +#define _SVDEC_HXX +#define _SVDIO_HXX +//#define _SVDLAYER_HXX +#define _SVINCVW_HXX +#define _SVRTV_HXX +#define _SVTABBX_HXX +#define _SVTREEBOX_HXX +#define _SVTREELIST_HXX + +#define _SVX_DAILDLL_HXX +#define _SVX_HYPHEN_HXX +#define _SVX_IMPGRF_HXX +#define _SVX_OPTITEMS_HXX +#define _SVX_OPTGERL_HXX +#define _SVX_OPTSAVE_HXX +#define _SVX_OPTSPELL_HXX +#define _SVX_OPTPATH_HXX +#define _SVX_OPTLINGU_HXX +#define _SVX_RULER_HXX +#define _SVX_RULRITEM_HXX +#define _SVX_SPLWRAP_HXX +#define _SVX_SPLDLG_HXX +#define _SVX_THESDLG_HXX + + +// INCLUDE --------------------------------------------------------------- + +#define _ZFORLIST_DECLARE_TABLE +#include "scitems.hxx" +#define ITEMID_FIELD EE_FEATURE_FIELD + +#include <bf_svx/forbiddencharacterstable.hxx> +#include <bf_svx/linkmgr.hxx> +#include <bf_sfx2/objsh.hxx> +#include <bf_sfx2/printer.hxx> +#include <bf_svtools/zformat.hxx> +#include <bf_svtools/PasswordHelper.hxx> +#include <tools/tenccvt.hxx> +#include <rtl/crc.h> + +#include "attrib.hxx" +#include "patattr.hxx" +#include "rangenam.hxx" +#include "dbcolect.hxx" +#include "pivot.hxx" +#include "docpool.hxx" +#include "stlpool.hxx" +#include "stlsheet.hxx" +#include "globstr.hrc" +#include "chartarr.hxx" +#include "rechead.hxx" +#include "bcaslot.hxx" +#include "addinlis.hxx" +#include "chartlis.hxx" +#include "validat.hxx" +#include "detdata.hxx" +#include "bf_sc.hrc" // FID_DATACHANGED +#include "chgtrack.hxx" +#include "chgviset.hxx" +#include "editutil.hxx" +#include "dpobject.hxx" +#include "indexmap.hxx" +#include "scrdata.hxx" +#include "poolhelp.hxx" +#include <legacysmgr/legacy_binfilters_smgr.hxx> //STRIP002 +namespace binfilter { +// STATIC DATA ----------------------------------------------------------- + +/*N*/ ScDocument::ScDocument( ScDocumentMode eMode, +/*N*/ SfxObjectShell* pDocShell ) : +/*N*/ xServiceManager( ::legacy_binfilters::getLegacyProcessServiceFactory() ), +/*N*/ pDrawLayer( NULL ), +/*N*/ pColorTable( NULL ), +/*N*/ pShell( pDocShell ), +/*N*/ pPrinter( NULL ), +/*N*/ bAutoCalc( eMode == SCDOCMODE_DOCUMENT ), +/*N*/ bAutoCalcShellDisabled( FALSE ), +/*N*/ bForcedFormulaPending( FALSE ), +/*N*/ bCalculatingFormulaTree( FALSE ), +/*N*/ bIsUndo( eMode == SCDOCMODE_UNDO ), +/*N*/ bIsClip( eMode == SCDOCMODE_CLIP ), +/*N*/ bCutMode( FALSE ), +/*N*/ nMaxTableNumber( 0 ), +/*N*/ pCondFormList( NULL ), +/*N*/ pValidationList( NULL ), +/*N*/ pFormatExchangeList( NULL ), +/*N*/ bIsEmbedded( FALSE ), +/*N*/ bProtected( FALSE ), +/*N*/ pLinkManager( NULL ), +/*N*/ pDocOptions( NULL ), +/*N*/ pViewOptions( NULL ), +/*N*/ pExtDocOptions( NULL ), +/*N*/ pConsolidateDlgData( NULL ), +/*N*/ pFormulaTree( NULL ), +/*N*/ pEOFormulaTree( NULL ), +/*N*/ aCurTextWidthCalcPos(MAXCOL,0,0), +/*N*/ // bNoSetDirty( TRUE ), +/*N*/ bNoSetDirty( FALSE ), +/*N*/ pFormulaTrack( NULL ), +/*N*/ pEOFormulaTrack( NULL ), +/*N*/ nFormulaTrackCount(0), +/*N*/ bInsertingFromOtherDoc( FALSE ), + bImportingXML( FALSE ), // #i41083# this has to be set in ScXMLImport::startDocument +/*N*/ nHardRecalcState(0), +/*N*/ bCalcingAfterLoad( FALSE ), +/*N*/ bNoListening( FALSE ), +/*N*/ bLoadingDone( TRUE ), +/*N*/ nVisibleTab( 0 ), +/*N*/ bIdleDisabled( FALSE ), +/*N*/ bInLinkUpdate( FALSE ), +/*N*/ bDetectiveDirty( FALSE ), +/*N*/ nMacroCallMode( SC_MACROCALL_ALLOWED ), +/*N*/ bHasMacroFunc( FALSE ), +/*N*/ bChartListenerCollectionNeedsUpdate( FALSE ), +/*N*/ bHasForcedFormulas( FALSE ), +/*N*/ nVisSpellState( 0 ), +/*N*/ pOtherObjects( NULL ), +/*N*/ pClipData( NULL ), +/*N*/ nFormulaCodeInTree(0), +/*N*/ nInterpretLevel(0), +/*N*/ nMacroInterpretLevel(0), +/*N*/ nInterpreterTableOpLevel(0), +/*N*/ bLostData(FALSE), +/*N*/ pDetOpList(NULL), +/*N*/ bInDtorClear( FALSE ), +/*N*/ bExpandRefs( FALSE ), +/*N*/ pUnoBroadcaster( NULL ), +/*N*/ pChangeTrack( NULL ), +/*N*/ pChangeViewSettings( NULL ), +/*N*/ pEditEngine( NULL ), +/*N*/ eLinkMode(LM_UNKNOWN), +/*N*/ pDPCollection( NULL ), +/*N*/ pScriptTypeData( NULL ), +/*N*/ nAsianCompression(SC_ASIANCOMPRESSION_INVALID), +/*N*/ nAsianKerning(SC_ASIANKERNING_INVALID), +/*N*/ pLoadedSymbolStringCellList( NULL ), +/*N*/ bPastingDrawFromOtherDoc( FALSE ), +/*N*/ pCacheFieldEditEngine( NULL ), +/*N*/ nInDdeLinkUpdate( 0 ), +/*N*/ nXMLImportedFormulaCount( 0 ), +/*N*/ bInUnoBroadcast( FALSE ), +/*N*/ bStyleSheetUsageInvalid( TRUE ) +/*N*/ { +/*N*/ eSrcSet = gsl_getSystemTextEncoding(); +/*N*/ nSrcVer = SC_CURRENT_VERSION; +/*N*/ nSrcMaxRow = MAXROW; +/*N*/ +/*N*/ if ( eMode == SCDOCMODE_DOCUMENT ) +/*N*/ { +/*N*/ if ( pDocShell ) +/*N*/ pLinkManager = new SvxLinkManager( pDocShell ); +/*N*/ +/*N*/ xPoolHelper = new ScPoolHelper( this ); +/*N*/ +/*N*/ pTab[0] = NULL; +/*N*/ pBASM = new ScBroadcastAreaSlotMachine( this ); +/*N*/ pChartListenerCollection = new ScChartListenerCollection( this ); +/*N*/ pRefreshTimerControl = new ScRefreshTimerControl; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ pTab[0] = NULL; +/*N*/ pBASM = NULL; +/*N*/ pChartListenerCollection = NULL; +/*N*/ pRefreshTimerControl = NULL; +/*N*/ } +/*N*/ +/*N*/ for (USHORT i=1; i<=MAXTAB; i++) +/*N*/ pTab[i] = NULL; +/*N*/ +/*N*/ pRangeName = new ScRangeName( 4, 4, FALSE, this ); +/*N*/ pDBCollection = new ScDBCollection( 4, 4, FALSE, this ); +/*N*/ pPivotCollection = new ScPivotCollection(4, 4, this ); +/*N*/ pSelectionAttr = NULL; +/*N*/ pChartCollection = new ScChartCollection; +/*N*/ xColNameRanges = new ScRangePairList; +/*N*/ xRowNameRanges = new ScRangePairList; +/*N*/ ImplCreateOptions(); +/*N*/ // languages for a visible document are set by docshell later (from options) +/*N*/ SetLanguage( ScGlobal::eLnge, ScGlobal::eLnge, ScGlobal::eLnge ); +/*N*/ +/*N*/ aTrackTimer.SetTimeoutHdl( LINK( this, ScDocument, TrackTimeHdl ) ); +/*N*/ aTrackTimer.SetTimeout( 100 ); +/*N*/ } + + + + +/*N*/ void ScDocument::StartChangeTracking() // Changetracking.sdc +/*N*/ { +/*N*/ if (!pChangeTrack) +/*N*/ pChangeTrack = new ScChangeTrack( this ); +/*N*/ } + +/*N*/ void ScDocument::EndChangeTracking() // Changetracking.sdc +/*N*/ { +/*N*/ delete pChangeTrack; +/*N*/ pChangeTrack = NULL; +/*N*/ } + +/*N*/ void ScDocument::SetChangeTrack( ScChangeTrack* pTrack ) +/*N*/ { + // #i49161# this is needed to save documents with change tracking + DBG_ASSERT( pTrack->GetDocument() == this, "SetChangeTrack: different documents" ); + if ( !pTrack || pTrack == pChangeTrack || pTrack->GetDocument() != this ) + return ; + EndChangeTracking(); + pChangeTrack = pTrack; +/*N*/ } + + +/*N*/ IMPL_LINK( ScDocument, TrackTimeHdl, Timer*, pTimer ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 if ( ScDdeLink::IsInUpdate() ) // nicht verschachteln +/*N*/ return 0; +/*N*/ } + + +/*N*/ ScDocument::~ScDocument() +/*N*/ { +/*N*/ DBG_ASSERT( !bInLinkUpdate, "bInLinkUpdate in dtor" ); +/*N*/ +/*N*/ bInDtorClear = TRUE; +/*N*/ +/*N*/ // first of all disable all refresh timers by deleting the control +/*N*/ if ( pRefreshTimerControl ) +/*N*/ { // To be sure there isn't anything running do it with a protector, +/*N*/ // this ensures also that nothing needs the control anymore. +/*N*/ ScRefreshTimerProtector aProt( GetRefreshTimerControlAddress() ); +/*N*/ delete pRefreshTimerControl, pRefreshTimerControl = NULL; +/*N*/ } +/*N*/ +/*N*/ // Links aufrauemen +/*N*/ +/*N*/ if ( pLinkManager ) +/*N*/ { +/*N*/ // BaseLinks freigeben +/*N*/ for ( USHORT n = pLinkManager->GetServers().Count(); n; ) +/*?*/ pLinkManager->GetServers()[ --n ]->Closed(); +/*N*/ +/*N*/ if ( pLinkManager->GetLinks().Count() ) +/*N*/ pLinkManager->Remove( 0, pLinkManager->GetLinks().Count() ); +/*N*/ } +/*N*/ +/*N*/ ScAddInAsync::RemoveDocument( this ); +/*N*/ ScAddInListener::RemoveDocument( this ); +/*N*/ delete pChartListenerCollection; // vor pBASM wg. evtl. Listener! +/*N*/ pChartListenerCollection = NULL; +/*N*/ // BroadcastAreas vor allen Zellen zerstoeren um unnoetige +/*N*/ // Einzel-EndListenings der Formelzellen zu vermeiden +/*N*/ delete pBASM; // BroadcastAreaSlotMachine +/*N*/ pBASM = NULL; +/*N*/ +/*N*/ if (pUnoBroadcaster) +/*N*/ { +/*N*/ delete pUnoBroadcaster; // broadcasted nochmal SFX_HINT_DYING +/*N*/ pUnoBroadcaster = NULL; +/*N*/ } +/*N*/ +/*N*/ Clear(); +/*N*/ +/*N*/ if (pCondFormList) +/*N*/ { +/*N*/ pCondFormList->DeleteAndDestroy( 0, pCondFormList->Count() ); +/*N*/ DELETEZ(pCondFormList); +/*N*/ } +/*N*/ if (pValidationList) +/*N*/ { +/*N*/ pValidationList->DeleteAndDestroy( 0, pValidationList->Count() ); +/*N*/ DELETEZ(pValidationList); +/*N*/ } +/*N*/ delete pRangeName; +/*N*/ delete pDBCollection; +/*N*/ delete pPivotCollection; +/*N*/ delete pSelectionAttr; +/*N*/ delete pChartCollection; +/*N*/ DeleteDrawLayer(); +/*N*/ delete pFormatExchangeList; +/*N*/ delete pPrinter; +/*N*/ ImplDeleteOptions(); +/*N*/ delete pConsolidateDlgData; +/*N*/ delete pLinkManager; +/*N*/ delete pClipData; +/*N*/ delete pDetOpList; // loescht auch die Eintraege +/*N*/ delete pChangeTrack; +/*N*/ delete pEditEngine; +/*N*/ delete pChangeViewSettings; // und weg damit +/*N*/ +/*N*/ delete pDPCollection; +/*N*/ +/*N*/ // delete the EditEngine before destroying the xPoolHelper +/*N*/ delete pCacheFieldEditEngine; +/*N*/ +/*N*/ if ( xPoolHelper.is() && !bIsClip ) +/*N*/ xPoolHelper->SourceDocumentGone(); +/*N*/ xPoolHelper.clear(); +/*N*/ +/*N*/ DeleteColorTable(); +/*N*/ delete pScriptTypeData; +/*N*/ delete pOtherObjects; +/*N*/ +/*N*/ } + + +/*N*/ SvNumberFormatter* ScDocument::GetFormatTable() const +/*N*/ { +/*N*/ return xPoolHelper->GetFormTable(); +/*N*/ } + +/*N*/ SfxItemPool* ScDocument::GetEditPool() const +/*N*/ { +/*N*/ return xPoolHelper->GetEditPool(); +/*N*/ } + +/*N*/ SfxItemPool* ScDocument::GetEnginePool() const +/*N*/ { +/*N*/ return xPoolHelper->GetEnginePool(); +/*N*/ } + +/*N*/ ScFieldEditEngine& ScDocument::GetEditEngine() +/*N*/ { +/*N*/ if ( !pEditEngine ) +/*N*/ { +/*N*/ pEditEngine = new ScFieldEditEngine( GetEnginePool(), GetEditPool() ); +/*N*/ pEditEngine->SetUpdateMode( FALSE ); +/*N*/ pEditEngine->EnableUndo( FALSE ); +/*N*/ pEditEngine->SetRefMapMode( MAP_100TH_MM ); +/*N*/ pEditEngine->SetForbiddenCharsTable( xForbiddenCharacters ); +/*N*/ } +/*N*/ return *pEditEngine; +/*N*/ } + +/*N*/ void ScDocument::ResetClip( ScDocument* pSourceDoc, const ScMarkData* pMarks ) +/*N*/ { +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 //STRIP001 if (bIsClip) +/*N*/ } + +/*N*/ void lcl_RefreshPivotData( ScPivotCollection* pColl ) +/*N*/ { +/*N*/ USHORT nCount = pColl->GetCount(); +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ { +/*N*/ ScPivot* pPivot = (*pColl)[i]; +/*N*/ if (pPivot->CreateData(TRUE)) +/*N*/ pPivot->ReleaseData(); +/*N*/ } +/*N*/ } + + +/*N*/ BOOL ScDocument::SymbolStringCellsPending() const +/*N*/ { +/*N*/ return pLoadedSymbolStringCellList && pLoadedSymbolStringCellList->Count(); +/*N*/ } + + +/*N*/ List& ScDocument::GetLoadedSymbolStringCellsList() +/*N*/ { +/*N*/ if ( !pLoadedSymbolStringCellList ) +/*N*/ pLoadedSymbolStringCellList = new List; +/*N*/ return *pLoadedSymbolStringCellList; +/*N*/ } + + +/*N*/ BOOL ScDocument::Load( SvStream& rStream, ScProgress* pProgress ) +/*N*/ { +/*N*/ bLoadingDone = FALSE; +/*N*/ +/*N*/ //---------------------------------------------------- +/*N*/ +/*N*/ Clear(); +/*N*/ USHORT nOldBufSize = rStream.GetBufferSize(); +/*N*/ rStream.SetBufferSize( 32768 ); +/*N*/ +/*N*/ // Progress-Bar +/*N*/ +/*N*/ // ULONG nCurPos = rStream.Tell(); +/*N*/ // ULONG nEndPos = rStream.Seek( STREAM_SEEK_TO_END ); +/*N*/ // rStream.Seek( nCurPos ); +/*N*/ // ScProgress aProgress( NULL, ScGlobal::GetRscString(STR_LOAD_DOC), nEndPos - nCurPos ); +/*N*/ +/*N*/ BOOL bError = FALSE; +/*N*/ USHORT nVersion = 0; +/*N*/ USHORT nVerMaxRow = MAXROW_30; // 8191, wenn in der Datei nichts steht +/*N*/ USHORT nTab = 0; +/*N*/ USHORT nEnumDummy; +/*N*/ String aEmptyName; +/*N*/ String aPageStyle; +/*N*/ CharSet eOldSet = rStream.GetStreamCharSet(); +/*N*/ +/*N*/ USHORT nID; +/*N*/ rStream >> nID; +/*N*/ if (nID == SCID_DOCUMENT || nID == SCID_NEWDOCUMENT ) +/*N*/ { +/*N*/ ScReadHeader aHdr( rStream ); +/*N*/ while (aHdr.BytesLeft() && !bError ) +/*N*/ { +/*N*/ USHORT nSubID; +/*N*/ rStream >> nSubID; +/*N*/ switch (nSubID) +/*N*/ { +/*N*/ case SCID_DOCFLAGS: +/*N*/ { +/*N*/ ScReadHeader aFlagsHdr( rStream ); +/*N*/ +/*N*/ rStream >> nVersion; // 312 abwaerts +/*N*/ rStream.ReadByteString( aPageStyle, rStream.GetStreamCharSet() ); +/*N*/ rStream >> bProtected; // Dokument geschuetzt +/*N*/ String aPass; +/*N*/ rStream.ReadByteString( aPass, rStream.GetStreamCharSet() ); +/*N*/ if (aPass.Len()) +/*?*/ SvPasswordHelper::GetHashPassword(aProtectPass, aPass); +/*N*/ if ( aFlagsHdr.BytesLeft() ) +/*N*/ { +/*N*/ rStream >> nEnumDummy; +/*N*/ eLanguage = LanguageType( nEnumDummy ); +/*N*/ } +/*N*/ if ( aFlagsHdr.BytesLeft() ) +/*N*/ rStream >> bAutoCalc; +/*N*/ if ( aFlagsHdr.BytesLeft() ) +/*N*/ rStream >> nVisibleTab; +/*N*/ if ( aFlagsHdr.BytesLeft() ) +/*N*/ rStream >> nVersion; // echte Version +/*N*/ if ( aFlagsHdr.BytesLeft() ) +/*N*/ rStream >> nVerMaxRow; // sonst auf 8191 lassen +/*N*/ +/*N*/ nSrcVer = nVersion; // Member +/*N*/ nSrcMaxRow = nVerMaxRow; // Member +/*N*/ +/*N*/ // Fuer Debugging bis hin zur SC 3.0a: +/*N*/ if( nVersion > 0x0002 && nVersion < SC_NUMFMT ) +/*N*/ { +/*N*/ bError = TRUE; +/*N*/ rStream.SetError( SVSTREAM_WRONGVERSION ); +/*N*/ } +/*N*/ +/*N*/ // Das obere Byte muss kleiner oder gleich sein +/*N*/ // (3.1 Dateien mit 8192 Zeilen koennen noch gelesen werden) +/*N*/ +/*N*/ if( ( nSrcVer & 0xFF00 ) > ( SC_CURRENT_VERSION & 0xFF00 ) ) +/*N*/ { +/*N*/ bError = TRUE; +/*N*/ rStream.SetError( SVSTREAM_WRONGVERSION ); +/*N*/ } +/*N*/ } +/*N*/ break; +/*N*/ case SCID_CHARSET: +/*N*/ { +/*N*/ ScReadHeader aSetHdr( rStream ); +/*N*/ BYTE cSet, cGUI; // cGUI is dummy, old GUIType +/*N*/ rStream >> cGUI >> cSet; +/*N*/ eSrcSet = (CharSet) cSet; +/*N*/ rStream.SetStreamCharSet( ::GetSOLoadTextEncoding( +/*N*/ eSrcSet, (USHORT)rStream.GetVersion() ) ); +/*N*/ } +/*N*/ break; +/*?*/ case SCID_LINKUPMODE: // Link Update Mode +/*?*/ { +/*?*/ ScReadHeader aSetHdr( rStream ); +/*?*/ BYTE cSet; +/*?*/ rStream >> cSet; +/*?*/ eLinkMode=(ScLkUpdMode) cSet; +/*?*/ } +/*?*/ break; +/*N*/ case SCID_TABLE: +/*N*/ pTab[nTab] = new ScTable(this, nTab, aEmptyName); +/*N*/ pTab[nTab]->SetPageStyle( aPageStyle ); +/*N*/ pTab[nTab]->Load(rStream,nVersion,pProgress); +/*N*/ ++nTab; +/*N*/ break; +/*N*/ case SCID_DRAWING: +/*N*/ LoadDrawLayer(rStream); +/*N*/ break; +/*N*/ case SCID_DDELINKS: +/*N*/ LoadDdeLinks(rStream); +/*N*/ break; +/*N*/ case SCID_AREALINKS: +/*N*/ LoadAreaLinks(rStream); +/*N*/ break; +/*N*/ case SCID_RANGENAME: +/*N*/ pRangeName->Load(rStream, nVersion ); +/*N*/ break; +/*N*/ case SCID_DBAREAS: +/*N*/ pDBCollection->Load( rStream ); +/*N*/ break; +/*?*/ case SCID_DATAPILOT: +/*?*/ GetDPCollection()->LoadNew( rStream ); +/*?*/ break; +/*N*/ case SCID_PIVOT: +/*N*/ pPivotCollection->Load( rStream ); +/*N*/ break; +/*N*/ case SCID_CHARTS: +/*N*/ pChartCollection->Load( this, rStream ); +/*N*/ break; +/*N*/ case SCID_COLNAMERANGES: +/*N*/ xColNameRanges->Load( rStream, nVersion ); +/*N*/ break; +/*N*/ case SCID_ROWNAMERANGES: +/*N*/ xRowNameRanges->Load( rStream, nVersion ); +/*N*/ break; +/*N*/ case SCID_CONDFORMATS: +/*N*/ if (!pCondFormList) +/*N*/ pCondFormList = new ScConditionalFormatList; +/*N*/ pCondFormList->Load( rStream, this ); +/*N*/ break; +/*N*/ case SCID_VALIDATION: +/*N*/ if (!pValidationList) +/*N*/ pValidationList = new ScValidationDataList; +/*N*/ pValidationList->Load( rStream, this ); +/*N*/ break; +/*N*/ case SCID_DETOPLIST: +/*N*/ if (!pDetOpList) +/*N*/ pDetOpList = new ScDetOpList; +/*N*/ pDetOpList->Load( rStream ); +/*N*/ break; +/*N*/ case SCID_NUMFORMAT: +/*N*/ { +/*N*/ ScReadHeader aNumHeader(rStream); +/*N*/ xPoolHelper->GetFormTable()->Load(rStream); +/*N*/ } +/*N*/ break; +/*N*/ case SCID_DOCOPTIONS: +/*N*/ ImplLoadDocOptions(rStream); +/*N*/ break; +/*N*/ case SCID_VIEWOPTIONS: +/*N*/ ImplLoadViewOptions(rStream); +/*N*/ break; +/*N*/ case SCID_PRINTSETUP: +/*N*/ { +/*N*/ ScReadHeader aJobHeader(rStream); +/*N*/ SfxItemSet* pSet = new SfxItemSet( *xPoolHelper->GetDocPool(), +/*N*/ SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN, +/*N*/ SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC, +/*N*/ SID_SCPRINTOPTIONS, SID_SCPRINTOPTIONS, +/*N*/ NULL ); +/*N*/ SetPrinter( SfxPrinter::Create( rStream, pSet ) ); +/*N*/ } +/*N*/ break; +/*?*/ case SCID_CONSOLIDATA: +/*?*/ if (!pConsolidateDlgData) +/*?*/ pConsolidateDlgData = new ScConsolidateParam; +/*?*/ pConsolidateDlgData->Load( rStream ); +/*?*/ break; +/*?*/ case SCID_CHANGETRACK: +/*N*/ if ( pChangeTrack ) // Changetracking.sdc +/*N*/ /*?*/ pChangeTrack->Clear(); // es kann nur einen geben +/*N*/ /*?*/ else +/*N*/ /*?*/ StartChangeTracking(); +/*N*/ /*?*/ pChangeTrack->Load( rStream, nVersion ); +/*?*/ break; +/*N*/ case SCID_CHGVIEWSET: +/*N*/ if (!pChangeViewSettings) +/*N*/ pChangeViewSettings = new ScChangeViewSettings; +/*N*/ pChangeViewSettings->Load( rStream, nVersion ); +/*N*/ break; +/*N*/ default: +/*N*/ { +/*N*/ DBG_ERROR("unbekannter Sub-Record in ScDocument::Load"); +/*N*/ ScReadHeader aDummyHdr( rStream ); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if (rStream.GetError() != SVSTREAM_OK) +/*N*/ bError = TRUE; +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ // Assertion nur, wenn kein Passwort gesetzt ist +/*N*/ DBG_ASSERT( rStream.GetKey().Len(), "Load: SCID_DOCUMENT nicht gefunden" ); +/*N*/ bError = TRUE; +/*N*/ } +/*N*/ +/*N*/ rStream.SetStreamCharSet( eOldSet ); +/*N*/ rStream.SetBufferSize( nOldBufSize ); +/*N*/ +/*N*/ if (!bError) // Neuberechnungen +/*N*/ { +/*N*/ xPoolHelper->GetStylePool()->UpdateStdNames(); // falls mit Version in anderer Sprache gespeichert +/*N*/ +/*N*/ // Zahlformat-Sprache +/*N*/ // (kann nicht in LoadPool passieren, weil der Numberformatter geladen sein muss) +/*N*/ +/*N*/ ScDocumentPool* pPool = xPoolHelper->GetDocPool(); +/*N*/ if ( pPool->GetLoadingVersion() == 0 ) // 0 = Pool-Version bis 3.1 +/*N*/ { +/*N*/ // in 3.1-Dokumenten gibt es ATTR_LANGUAGE_FORMAT noch nicht +/*N*/ // darum bei Bedarf zu ATTR_VALUE_FORMAT noch die Sprache dazutun +/*N*/ // (Bug #37441#) +/*N*/ +/*N*/ // harte Attribute: +/*N*/ +/*N*/ SvNumberFormatter* pFormatter = xPoolHelper->GetFormTable(); +/*N*/ USHORT nCount = pPool->GetItemCount(ATTR_PATTERN); +/*N*/ ScPatternAttr* pPattern; +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ { +/*N*/ pPattern = (ScPatternAttr*)pPool->GetItem(ATTR_PATTERN, i); +/*N*/ if (pPattern) +/*N*/ ScGlobal::AddLanguage( pPattern->GetItemSet(), *pFormatter ); +/*N*/ } +/*N*/ +/*N*/ // Vorlagen: +/*N*/ +/*N*/ SfxStyleSheetIterator aIter( xPoolHelper->GetStylePool(), SFX_STYLE_FAMILY_PARA ); +/*N*/ for ( SfxStyleSheetBase* pStyle = aIter.First(); pStyle; pStyle = aIter.Next() ) +/*N*/ ScGlobal::AddLanguage( pStyle->GetItemSet(), *pFormatter ); +/*N*/ } +/*N*/ +/*N*/ // change FontItems in styles +/*N*/ xPoolHelper->GetStylePool()->ConvertFontsAfterLoad(); +/*N*/ +/*N*/ // Druckbereiche etc. +/*N*/ +/*N*/ SfxStyleSheetIterator aIter( xPoolHelper->GetStylePool(), SFX_STYLE_FAMILY_PAGE ); +/*N*/ ScStyleSheet* pStyleSheet = NULL; +/*N*/ +/*N*/ nMaxTableNumber = 0; +/*N*/ for (USHORT i=0; i<=MAXTAB; i++) +/*N*/ if (pTab[i]) +/*N*/ { +/*N*/ // MaxTableNumber ermitteln +/*N*/ +/*N*/ nMaxTableNumber = i+1; +/*N*/ +/*N*/ // Druckbereiche aus <= 3.00.2 Dokumenten +/*N*/ // aus den PageStyles holen und jetzt an +/*N*/ // der Tabelle speichern. +/*N*/ +/*N*/ pStyleSheet = (ScStyleSheet*)aIter.Find( pTab[i]->GetPageStyle() ); +/*N*/ +/*N*/ if ( pStyleSheet ) +/*N*/ { +/*N*/ SfxItemSet& rSet = pStyleSheet->GetItemSet(); +/*N*/ const ScRangeItem* pPrintAreaItem = NULL; +/*N*/ const ScRangeItem* pRepeatColItem = NULL; +/*N*/ const ScRangeItem* pRepeatRowItem = NULL; +/*N*/ +/*N*/ rSet.GetItemState( ATTR_PAGE_PRINTAREA, TRUE, +/*N*/ (const SfxPoolItem**)&pPrintAreaItem ); +/*N*/ rSet.GetItemState( ATTR_PAGE_REPEATCOL, TRUE, +/*N*/ (const SfxPoolItem**)&pRepeatColItem ); +/*N*/ rSet.GetItemState( ATTR_PAGE_REPEATROW, TRUE, +/*N*/ (const SfxPoolItem**)&pRepeatRowItem ); +/*N*/ +/*N*/ if ( pPrintAreaItem ) // Druckbereiche +/*N*/ { +/*N*/ if ( !pPrintAreaItem->GetFlags() ) +/*N*/ { +/*N*/ SetPrintRangeCount( i, 1 ); +/*N*/ SetPrintRange( i, 0, pPrintAreaItem->GetRange() ); +/*N*/ } +/*N*/ rSet.ClearItem( ATTR_PAGE_PRINTAREA ); +/*N*/ } +/*N*/ +/*N*/ if ( pRepeatColItem ) // Wiederholungsspalte +/*N*/ { +/*?*/ SetRepeatColRange( i, !pRepeatColItem->GetFlags() +/*?*/ ? &pRepeatColItem->GetRange() +/*?*/ : (const ScRange *)NULL ); +/*?*/ rSet.ClearItem( ATTR_PAGE_REPEATCOL ); +/*N*/ } +/*N*/ +/*N*/ if ( pRepeatRowItem ) // Wiederholungszeile +/*N*/ { +/*?*/ SetRepeatRowRange( i, !pRepeatRowItem->GetFlags() +/*?*/ ? &pRepeatRowItem->GetRange() +/*?*/ : (const ScRange *)NULL ); +/*?*/ rSet.ClearItem( ATTR_PAGE_REPEATROW ); +/*?*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ +/*N*/ if ( pDPCollection && pDPCollection->GetCount() ) +/*?*/ pPivotCollection->FreeAll(); +/*N*/ else +/*N*/ { +/*N*/ lcl_RefreshPivotData( pPivotCollection ); +/*N*/ GetDPCollection()->ConvertOldTables( *pPivotCollection ); +/*N*/ } +/*N*/ if ( pDPCollection ) +/*N*/ pDPCollection->EnsureNames(); // make sure every table has a name +/*N*/ +/*N*/ SetAutoFilterFlags(); +/*N*/ if (pDrawLayer) +/*N*/ UpdateAllCharts(); +/*N*/ #ifdef DBG_UTIL +/*N*/ //2do: wg. #62107 +/*N*/ // ChartListenerCollection speichern/laden, damit nach dem Laden das Update +/*N*/ // hier einmal eingespart werden kann und somit nicht mehr alle Charts +/*N*/ // angefasst werden muessen. Die ChartListenerCollection muss dann zum Master +/*N*/ // der Referenzen werden. +/*N*/ // static BOOL bShown = 0; +/*N*/ // if ( !bShown && SOFFICE_FILEFORMAT_NOW > SOFFICE_FILEFORMAT_50 ) +/*N*/ // { +/*N*/ // bShown = 1; +/*N*/ // DBG_ERRORFILE( "bei inkompatiblem FileFormat ChartListenerCollection speichern!" ); +/*N*/ // } +/*N*/ #endif +/*N*/ UpdateChartListenerCollection(); +/*N*/ if (pDrawLayer) +/*N*/ RefreshNoteFlags(); +/*N*/ CalcAfterLoad(); +/*N*/ } +/*N*/ +/*N*/ if ( pLoadedSymbolStringCellList ) +/*N*/ { // we had symbol string cells, list was cleared by columns, delete it +/*N*/ delete pLoadedSymbolStringCellList; +/*N*/ pLoadedSymbolStringCellList = NULL; +/*N*/ } +/*N*/ +/*N*/ //---------------------------------------------------- +/*N*/ +/*N*/ bLoadingDone = TRUE; +/*N*/ +/*N*/ return !bError; +/*N*/ } + +/*N*/ BOOL ScDocument::Save( SvStream& rStream, ScProgress* pProgress ) const +/*N*/ { +/*N*/ ((ScDocument*)this)->bLoadingDone = FALSE; // nicht zwischendrin reinpfuschen lassen +/*N*/ +/*N*/ ((ScDocument*)this)->bLostData = FALSE; // wird beim Speichern gesetzt +/*N*/ +/*N*/ ((ScDocument*)this)->nSrcVer = SC_CURRENT_VERSION; +/*N*/ ((ScDocument*)this)->nSrcMaxRow = MAXROW; +/*N*/ if ( rStream.GetVersion() <= SOFFICE_FILEFORMAT_31 ) +/*N*/ { +/*N*/ // 3.1 Export -> nur 8192 Zeilen schreiben, und kompatible Versionsnummer +/*N*/ +/*N*/ ((ScDocument*)this)->nSrcVer = SC_31_EXPORT_VER; +/*N*/ ((ScDocument*)this)->nSrcMaxRow = MAXROW_30; +/*N*/ } +/*N*/ else if ( rStream.GetVersion() <= SOFFICE_FILEFORMAT_40 ) +/*N*/ { // 4.0 Export -> kompatible Versionsnummer +/*N*/ ((ScDocument*)this)->nSrcVer = SC_40_EXPORT_VER; +/*N*/ } +/*N*/ +/*N*/ USHORT i; +/*N*/ USHORT nOldBufSize = rStream.GetBufferSize(); +/*N*/ rStream.SetBufferSize( 32768 ); +/*N*/ +/*N*/ CharSet eOldSet = rStream.GetStreamCharSet(); +/*N*/ CharSet eStoreCharSet = ::GetSOStoreTextEncoding( +/*N*/ gsl_getSystemTextEncoding(), (USHORT)rStream.GetVersion() ); +/*N*/ rStream.SetStreamCharSet( eStoreCharSet ); +/*N*/ +/*N*/ +/*N*/ // Progress-Bar +/*N*/ +/*N*/ long nSavedDocCells = 0; +/*N*/ // ScProgress aProgress( NULL, ScGlobal::GetRscString( STR_SAVE_DOC ), GetWeightedCount() + 1 ); +/*N*/ +/*N*/ { +/*N*/ rStream << (USHORT) SCID_NEWDOCUMENT; +/*N*/ ScWriteHeader aHdr( rStream ); +/*N*/ +/*N*/ // Flags +/*N*/ +/*N*/ { +/*N*/ rStream << (USHORT) SCID_DOCFLAGS; +/*N*/ ScWriteHeader aFlagsHdr( rStream, 18 ); //! ausprobieren +/*N*/ +/*N*/ // wg. Bug in 312 ScToken::RelToRelAbs mit DoubleRefs bekommt +/*N*/ // die 312er immer vorgegaukelt, dass es keine RelRefs gaebe, +/*N*/ // was auch ok ist, da immer absolut gespeichert wird und +/*N*/ // SR_RELATIVE nie zur Verwendung kam und nicht kommen darf. +/*N*/ if ( nSrcVer & 0xFF00 ) +/*N*/ rStream << (USHORT) nSrcVer; +/*N*/ // hoehere Major-Version darf von 312 nicht geladen werden +/*N*/ else +/*N*/ rStream << (USHORT) (SC_RELATIVE_REFS - 1); +/*N*/ +/*N*/ // dummy page style (for compatibility) +/*N*/ rStream.WriteByteString( +/*N*/ String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(STRING_STANDARD)), +/*N*/ rStream.GetStreamCharSet() ); +/*N*/ rStream << bProtected; // Dokument geschuetzt +/*N*/ String aPass; +/*N*/ //rStream.WriteByteString( aProtectPass, rStream.GetStreamCharSet() ); +/*N*/ rStream.WriteByteString( aPass, rStream.GetStreamCharSet() ); +/*N*/ rStream << (USHORT) eLanguage; +/*N*/ rStream << bAutoCalc; +/*N*/ +/*N*/ rStream << nVisibleTab; +/*N*/ +/*N*/ // und hier jetzt die echte Versionsnummer +/*N*/ rStream << (USHORT) nSrcVer; +/*N*/ +/*N*/ rStream << nSrcMaxRow; // Zeilenanzahl +/*N*/ } +/*N*/ +/*N*/ // Zeichensatz +/*N*/ +/*N*/ { +/*N*/ rStream << (USHORT) SCID_CHARSET; +/*N*/ ScWriteHeader aSetHdr( rStream, 2 ); +/*N*/ rStream << (BYTE) 0 // dummy, old System::GetGUIType() +/*N*/ << (BYTE) eStoreCharSet; +/*N*/ } +/*N*/ +/*N*/ // Link Update Mode +/*N*/ +/*N*/ if(eLinkMode!=LM_UNKNOWN) +/*N*/ { +/*?*/ rStream << (USHORT) SCID_LINKUPMODE; +/*?*/ ScWriteHeader aSetHdr( rStream, 1 ); +/*?*/ rStream << (BYTE) eLinkMode; +/*N*/ } +/*N*/ +/*N*/ rStream << (USHORT) SCID_RANGENAME; +/*N*/ pRangeName->Store( rStream ); +/*N*/ +/*N*/ rStream << (USHORT) SCID_DBAREAS; +/*N*/ pDBCollection->Store( rStream ); +/*N*/ +/*N*/ rStream << (USHORT) SCID_DDELINKS; +/*N*/ SaveDdeLinks( rStream ); +/*N*/ +/*N*/ rStream << (USHORT) SCID_AREALINKS; +/*N*/ SaveAreaLinks( rStream ); +/*N*/ +/*N*/ { +/*N*/ rStream << (USHORT) SCID_NUMFORMAT; +/*N*/ ScWriteHeader aNumHeader(rStream); +/*N*/ xPoolHelper->GetFormTable()->Save(rStream); +/*N*/ } +/*N*/ +/*N*/ if ( xColNameRanges->Count() ) +/*N*/ { +/*N*/ rStream << (USHORT) SCID_COLNAMERANGES; +/*N*/ xColNameRanges->Store( rStream ); +/*N*/ } +/*N*/ if ( xRowNameRanges->Count() ) +/*N*/ { +/*N*/ rStream << (USHORT) SCID_ROWNAMERANGES; +/*N*/ xRowNameRanges->Store( rStream ); +/*N*/ } +/*N*/ +/*N*/ if (pCondFormList) +/*N*/ pCondFormList->ResetUsed(); // wird beim Speichern der Tabellen gesetzt +/*N*/ if (pValidationList) +/*N*/ pValidationList->ResetUsed(); // wird beim Speichern der Tabellen gesetzt +/*N*/ +/*N*/ // Tabellen (Daten) +/*N*/ +/*N*/ for (i=0; i<=MAXTAB; i++) +/*N*/ { +/*N*/ if (pTab[i]) +/*N*/ { +/*N*/ rStream << (USHORT) SCID_TABLE; +/*N*/ pTab[i]->Save(rStream, nSavedDocCells, pProgress); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // bedingte Formate / Gueltigkeit +/*N*/ // beim Speichern der Tabellen ist eingetragen worden, +/*N*/ // welche Eintraege benutzt werden +/*N*/ +/*N*/ if (pCondFormList) +/*N*/ { +/*N*/ rStream << (USHORT) SCID_CONDFORMATS; +/*N*/ pCondFormList->Store(rStream); +/*N*/ } +/*N*/ if (pValidationList) +/*N*/ { +/*N*/ rStream << (USHORT) SCID_VALIDATION; +/*N*/ pValidationList->Store(rStream); +/*N*/ } +/*N*/ +/*N*/ // Liste der Detektiv-Operationen (zum Aktualisieren) +/*N*/ if (pDetOpList) +/*N*/ { +/*N*/ rStream << (USHORT) SCID_DETOPLIST; +/*N*/ pDetOpList->Store(rStream); +/*N*/ } +/*N*/ +/*N*/ // Drawing +/*N*/ +/*N*/ // if (pDrawLayer && pDrawLayer->HasObjects()) +/*N*/ // auch ohne Objekte - wegen ColorTable etc. +/*N*/ +/*N*/ if (pDrawLayer) +/*N*/ { +/*N*/ rStream << (USHORT) SCID_DRAWING; +/*N*/ StoreDrawLayer(rStream); +/*N*/ } +/*N*/ +/*N*/ // Collections +/*N*/ +/*N*/ // (new) DataPilot collection must be saved before old Pivot collection +/*N*/ // so old data can be skipped by new office +/*N*/ // not in 3.0 or 4.0 export to avoid warning messages +/*N*/ +/*N*/ if ( nSrcVer > SC_40_EXPORT_VER && pDPCollection && pDPCollection->GetCount() ) +/*N*/ { +/*?*/ rStream << (USHORT) SCID_DATAPILOT; // new data +/*?*/ pDPCollection->StoreNew( rStream ); +/*N*/ } +/*N*/ +/*N*/ rStream << (USHORT) SCID_PIVOT; // old data +/*N*/ if ( pDPCollection && pDPCollection->GetCount() ) +/*N*/ pDPCollection->StoreOld( rStream ); +/*N*/ else +/*N*/ pPivotCollection->Store( rStream ); // not converted or all empty +/*N*/ +/*N*/ // Charts werden hier nicht mehr gespeichert, weil +/*N*/ // jedes Chart seine Daten selber speichert +/*N*/ +/*N*/ DBG_ASSERT(!pChartCollection || !pChartCollection->GetCount(), +/*N*/ "wer hat da ein Chart eingetragen?"); +/*N*/ +/*N*/ rStream << (USHORT) SCID_DOCOPTIONS; +/*N*/ ImplSaveDocOptions(rStream); +/*N*/ +/*N*/ rStream << (USHORT) SCID_VIEWOPTIONS; +/*N*/ ImplSaveViewOptions(rStream); +/*N*/ +/*N*/ // Job-Setup vom Printer +/*N*/ +/*N*/ if (pPrinter) +/*N*/ { +/*N*/ rStream << (USHORT) SCID_PRINTSETUP; +/*N*/ ScWriteHeader aJobHeader(rStream); +/*N*/ +/*N*/ ((ScDocument*)this)->GetPrinter()->Store( rStream ); +/*N*/ } +/*N*/ +/*N*/ if ( nSrcVer > SC_40_EXPORT_VER ) // Das folgende nicht bei 3.0 oder 4.0 Export... +/*N*/ { +/*N*/ if (pConsolidateDlgData) // Einstellungen fuer den Konsolidieren-Dialog +/*N*/ { +/*?*/ rStream << (USHORT) SCID_CONSOLIDATA; +/*?*/ pConsolidateDlgData->Store( rStream ); +/*N*/ } +/*N*/ if ( pChangeTrack ) +/*N*/ { +/*N*/ rStream << (USHORT) SCID_CHANGETRACK; +/*N*/ pChangeTrack->Store( rStream ); +/*N*/ } +/*N*/ if ( pChangeViewSettings ) +/*N*/ { +/*N*/ rStream << (USHORT) SCID_CHGVIEWSET; +/*N*/ pChangeViewSettings->Store( rStream ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ rStream.SetStreamCharSet( eOldSet ); +/*N*/ rStream.SetBufferSize( nOldBufSize ); +/*N*/ +/*N*/ ((ScDocument*)this)->bLoadingDone = TRUE; +/*N*/ +/*N*/ return ( rStream.GetError() == SVSTREAM_OK ); +/*N*/ } + +/*N*/ void ScDocument::SetLostData() +/*N*/ { +/*N*/ bLostData = TRUE; +/*N*/ } + + +/*N*/ void ScDocument::PutCell( USHORT nCol, USHORT nRow, USHORT nTab, +/*N*/ ScBaseCell* pCell, ULONG nFormatIndex, BOOL bForceTab ) +/*N*/ { +/*N*/ if (VALIDTAB(nTab)) +/*N*/ { +/*N*/ if ( bForceTab && !pTab[nTab] ) +/*N*/ { +/*?*/ BOOL bExtras = !bIsUndo; // Spaltenbreiten, Zeilenhoehen, Flags +/*?*/ +/*?*/ pTab[nTab] = new ScTable(this, nTab, +/*?*/ String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("temp")), +/*?*/ bExtras, bExtras); +/*N*/ } +/*N*/ +/*N*/ if (pTab[nTab]) +/*N*/ pTab[nTab]->PutCell( nCol, nRow, nFormatIndex, pCell ); +/*N*/ } +/*N*/ } + + +/*N*/ BOOL ScDocument::GetPrintArea( USHORT nTab, USHORT& rEndCol, USHORT& rEndRow, +/*N*/ BOOL bNotes ) const +/*N*/ { +/*N*/ if (nTab<=MAXTAB && pTab[nTab]) +/*N*/ { +/*N*/ BOOL bAny = pTab[nTab]->GetPrintArea( rEndCol, rEndRow, bNotes ); +/*N*/ if (pDrawLayer) +/*N*/ { +/*N*/ ScRange aDrawRange(0,0,nTab, MAXCOL,MAXROW,nTab); +/*N*/ if (DrawGetPrintArea( aDrawRange, TRUE, TRUE )) +/*N*/ { +/*N*/ if (aDrawRange.aEnd.Col()>rEndCol) rEndCol=aDrawRange.aEnd.Col(); +/*N*/ if (aDrawRange.aEnd.Row()>rEndRow) rEndRow=aDrawRange.aEnd.Row(); +/*N*/ bAny = TRUE; +/*N*/ } +/*N*/ } +/*N*/ return bAny; +/*N*/ } +/*N*/ +/*N*/ rEndCol = 0; +/*N*/ rEndRow = 0; +/*N*/ return FALSE; +/*N*/ } + + + +/*N*/ BOOL ScDocument::GetDataStart( USHORT nTab, USHORT& rStartCol, USHORT& rStartRow ) const +/*N*/ { +/*N*/ if (nTab<=MAXTAB && pTab[nTab]) +/*N*/ { +/*N*/ BOOL bAny = pTab[nTab]->GetDataStart( rStartCol, rStartRow ); +/*N*/ if (pDrawLayer) +/*N*/ { +/*N*/ ScRange aDrawRange(0,0,nTab, MAXCOL,MAXROW,nTab); +/*N*/ if (DrawGetPrintArea( aDrawRange, TRUE, TRUE )) +/*N*/ { +/*N*/ if (aDrawRange.aStart.Col()<rStartCol) rStartCol=aDrawRange.aStart.Col(); +/*N*/ if (aDrawRange.aStart.Row()<rStartRow) rStartRow=aDrawRange.aStart.Row(); +/*N*/ bAny = TRUE; +/*N*/ } +/*N*/ } +/*N*/ return bAny; +/*N*/ } +/*N*/ +/*N*/ rStartCol = 0; +/*N*/ rStartRow = 0; +/*N*/ return FALSE; +/*N*/ } + + + +/*N*/ ULONG ScDocument::TransferTab( ScDocument* pSrcDoc, USHORT nSrcPos, +/*N*/ USHORT nDestPos, BOOL bInsertNew, +/*N*/ BOOL bResultsOnly ) +/*N*/ { +/*N*/ ULONG nRetVal = 1; // 0 => Fehler 1 = ok +/*N*/ // 2 => RefBox, 3 => NameBox +/*N*/ // 4 => beides +/*N*/ BOOL bValid = TRUE; +/*N*/ if (bInsertNew) // neu einfuegen +/*N*/ { +/*?*/ String aName; +/*?*/ pSrcDoc->GetName(nSrcPos, aName); +/*?*/ CreateValidTabName(aName); +/*?*/ bValid = InsertTab(nDestPos, aName); +/*N*/ } +/*N*/ else // bestehende Tabelle ersetzen +/*N*/ { +/*N*/ if (VALIDTAB(nDestPos) && pTab[nDestPos]) +/*N*/ { +/*N*/ pTab[nDestPos]->DeleteArea( 0,0, MAXCOL,MAXROW, IDF_ALL ); +/*N*/ // ClearDrawPage(nDestPos); +/*N*/ } +/*N*/ else +/*N*/ bValid = FALSE; +/*N*/ } +/*N*/ +/*N*/ if (bValid) +/*N*/ { +/*N*/ BOOL bOldAutoCalcSrc; +/*N*/ BOOL bOldAutoCalc = GetAutoCalc(); +/*N*/ SetAutoCalc( FALSE ); // Mehrfachberechnungen vermeiden +/*N*/ SetNoListening( TRUE ); +/*N*/ if ( bResultsOnly ) +/*N*/ { +/*N*/ bOldAutoCalcSrc = pSrcDoc->GetAutoCalc(); +/*N*/ pSrcDoc->SetAutoCalc( TRUE ); // falls was berechnet werden muss +/*N*/ } +/*N*/ SvNumberFormatter* pThisFormatter = xPoolHelper->GetFormTable(); +/*N*/ SvNumberFormatter* pOtherFormatter = pSrcDoc->xPoolHelper->GetFormTable(); +/*N*/ if (pOtherFormatter && pOtherFormatter != pThisFormatter) +/*N*/ { +/*N*/ SvNumberFormatterIndexTable* pExchangeList = +/*N*/ pThisFormatter->MergeFormatter(*(pOtherFormatter)); +/*N*/ if (pExchangeList->Count() > 0) +/*N*/ pFormatExchangeList = pExchangeList; +/*N*/ } +/*N*/ nDestPos = Min(nDestPos, (USHORT)(GetTableCount() - 1)); +/*N*/ pSrcDoc->pTab[nSrcPos]->CopyToTable(0, 0, MAXCOL, MAXROW, +/*N*/ ( bResultsOnly ? IDF_ALL & ~IDF_FORMULA : IDF_ALL), +/*N*/ FALSE, pTab[nDestPos] ); +/*N*/ pFormatExchangeList = NULL; +/*N*/ pTab[nDestPos]->SetTabNo(nDestPos); +/*N*/ +/*N*/ if ( !bResultsOnly ) +/*N*/ { +/*N*/ USHORT nSrcRangeNames = pSrcDoc->pRangeName->GetCount(); +/*N*/ // array containing range names which might need update of indices +/*N*/ ScRangeData** pSrcRangeNames = nSrcRangeNames ? new ScRangeData* [nSrcRangeNames] : NULL; +/*N*/ // the index mapping thereof +/*N*/ ScIndexMap aSrcRangeMap( nSrcRangeNames ); +/*N*/ BOOL bRangeNameReplace = FALSE; +/*N*/ +/*N*/ for (USHORT i = 0; i < nSrcRangeNames; i++) //! DB-Bereiche Pivot-Bereiche auch !!! +/*N*/ { +/*?*/ ScRangeData* pSrcData = (*pSrcDoc->pRangeName)[i]; +/*?*/ USHORT nOldIndex = pSrcData->GetIndex(); +/*?*/ BOOL bInUse = FALSE; +/*?*/ for (USHORT j = 0; !bInUse && (j <= MAXTAB); j++) +/*?*/ { +/*?*/ if (pSrcDoc->pTab[j]) +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 /*?*/ bInUse = pSrcDoc->pTab[j]->IsRangeNameInUse(0, 0, MAXCOL, MAXROW, +/*?*/ } +/*?*/ if (bInUse) +/*?*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 ScRangeData* pData = new ScRangeData( *pSrcData ); +/*?*/ } +/*?*/ else +/*?*/ { +/*?*/ pSrcRangeNames[i] = NULL; +/*?*/ //aSrcRangeMap.SetPair( i, 0, 0 ); // not needed, defaulted +/*?*/ } +/*N*/ } +/*N*/ if ( bRangeNameReplace ) +/*N*/ { +/*?*/ // first update all inserted named formulas if they contain other +/*?*/ // range names and used indices changed +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 /*?*/ for (USHORT i = 0; i < nSrcRangeNames; i++) //! DB-Bereiche Pivot-Bereiche auch +/*N*/ } +/*N*/ if ( pSrcRangeNames ) +/*?*/ delete [] pSrcRangeNames; +/*N*/ +/*N*/ short nDz = ((short)nDestPos) - (short)nSrcPos; +/*N*/ pTab[nDestPos]->UpdateReference(URM_COPY, 0, 0, nDestPos, +/*N*/ MAXCOL, MAXROW, nDestPos, +/*N*/ 0, 0, nDz, NULL); +/*N*/ // Test for outside absolute references for info box +/*N*/ BOOL bIsAbsRef = pSrcDoc->pTab[nSrcPos]->TestTabRefAbs(nSrcPos); +/*N*/ // Readjust self-contained absolute references to this sheet +/*N*/ pTab[nDestPos]->TestTabRefAbs(nSrcPos); +/*N*/ if (bIsAbsRef) +/*N*/ { +/*N*/ nRetVal += 1; +/*N*/ // InfoBox AbsoluteRefs sind möglicherweise nicht mehr korrekt!! +/*N*/ } +/*N*/ pTab[nDestPos]->CompileAll(); +/*N*/ } +/*N*/ +/*N*/ SetNoListening( FALSE ); +/*N*/ if ( !bResultsOnly ) +/*N*/ pTab[nDestPos]->StartAllListeners(); +/*N*/ SetDirty(); // ist das wirklich dokumentweit noetig?!? +/*N*/ if ( bResultsOnly ) +/*N*/ pSrcDoc->SetAutoCalc( bOldAutoCalcSrc ); +/*N*/ SetAutoCalc( bOldAutoCalc ); +/*N*/ +/*N*/ // Drawing kopieren +/*N*/ +/*N*/ if (bInsertNew) +/*?*/ TransferDrawPage( pSrcDoc, nSrcPos, nDestPos ); +/*N*/ } +/*N*/ if (!bValid) +/*N*/ nRetVal = 0; +/*N*/ return nRetVal; +/*N*/ } + +// ---------------------------------------------------------------------------- + +/*N*/ void ScDocument::SetError( USHORT nCol, USHORT nRow, USHORT nTab, const USHORT nError) +/*N*/ { +/*N*/ if (VALIDTAB(nTab)) +/*N*/ if (pTab[nTab]) +/*N*/ pTab[nTab]->SetError( nCol, nRow, nError ); +/*N*/ } + + +// ---------------------------------------------------------------------------- + +/*N*/ void ScDocument::SetConsolidateDlgData( const ScConsolidateParam* pData ) +/*N*/ { +/*N*/ delete pConsolidateDlgData; +/*N*/ +/*N*/ if ( pData ) +/*N*/ pConsolidateDlgData = new ScConsolidateParam( *pData ); +/*N*/ else +/*N*/ pConsolidateDlgData = NULL; +/*N*/ } + +/*N*/ void ScDocument::SetChangeViewSettings(const ScChangeViewSettings& rNew) +/*N*/ { + // #i49161# this is needed to save documents with change tracking + if (pChangeViewSettings==NULL) + pChangeViewSettings = new ScChangeViewSettings; + + DBG_ASSERT( pChangeViewSettings, "Oops. No ChangeViewSettings :-( by!" ); + + *pChangeViewSettings=rNew; +/*N*/ } + +// ---------------------------------------------------------------------------- + +/*N*/ ScFieldEditEngine* ScDocument::CreateFieldEditEngine() +/*N*/ { +/*N*/ ScFieldEditEngine* pEditEngine = NULL; +/*N*/ if (!pCacheFieldEditEngine) +/*N*/ { +/*N*/ pEditEngine = new ScFieldEditEngine( GetEnginePool(), +/*N*/ GetEditPool(), FALSE ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ pEditEngine = pCacheFieldEditEngine; +/*N*/ pCacheFieldEditEngine = NULL; +/*N*/ } +/*N*/ return pEditEngine; +/*N*/ } + +/*N*/ void ScDocument::DisposeFieldEditEngine(ScFieldEditEngine*& rpEditEngine) +/*N*/ { +/*N*/ if (!pCacheFieldEditEngine && rpEditEngine) +/*N*/ { +/*N*/ pCacheFieldEditEngine = rpEditEngine; +/*N*/ pCacheFieldEditEngine->Clear(); +/*N*/ } +/*N*/ else +/*N*/ delete rpEditEngine; +/*N*/ rpEditEngine = NULL; +/*N*/ } + +} //namespace binfilter + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_documen3.cxx b/binfilter/bf_sc/source/core/data/sc_documen3.cxx new file mode 100644 index 000000000000..09dfd5b9f0d5 --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_documen3.cxx @@ -0,0 +1,917 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#ifdef WIN +// SFX +#define _SFXAPPWIN_HXX +#define _SFX_SAVEOPT_HXX +//#define _SFX_CHILDWIN_HXX *** +#define _SFXCTRLITEM_HXX +#define _SFXPRNMON_HXX +#define _INTRO_HXX +#define _SFXMSGDESCR_HXX +#define _SFXMSGPOOL_HXX +#define _SFXFILEDLG_HXX +#define _PASSWD_HXX +#define _SFXTBXCTRL_HXX +#define _SFXSTBITEM_HXX +#define _SFXMNUITEM_HXX +#define _SFXIMGMGR_HXX +#define _SFXTBXMGR_HXX +#define _SFXSTBMGR_HXX +#define _SFX_MINFITEM_HXX +#define _SFXEVENT_HXX + +//sfxdlg.hxx +//#define _SFXTABDLG_HXX +#define _BASEDLGS_HXX +#define _SFX_DINFDLG_HXX +#define _SFXDINFEDT_HXX +#define _SFX_MGETEMPL_HXX +#define _SFX_TPLPITEM_HXX +#define _SFX_STYLEDLG_HXX +#define _NEWSTYLE_HXX +#define _SFXDOCTEMPL_HXX +#define _SFXDOCTDLG_HXX +#define _SFX_TEMPLDLG_HXX +#define _SFXNEW_HXX +#define _SFXDOCMAN_HXX +//#define _SFXDOCKWIN_HXX *** + +//sfxdoc.hxx +//#define _SFX_OBJSH_HXX +//#define _SFX_CLIENTSH_HXX *** +//#define _SFXDOCINF_HXX +#define _SFX_OBJFAC_HXX +#define _SFX_DOCFILT_HXX +#define _SFXDOCFILE_HXX +#define _VIEWFAC_HXX +#define _SFXVIEWFRM_HXX +//#define _SFXVIEWSH_HXX *** +#define _MDIFRM_HXX +#define _SFX_IPFRM_HXX +#define _SFX_INTERNO_HXX + +#endif //WIN + +// INCLUDE --------------------------------------------------------------- + +#include "scitems.hxx" +#include <bf_svx/langitem.hxx> +#include <bf_svx/linkmgr.hxx> +#include <bf_svtools/zforlist.hxx> +#include <vcl/svapp.hxx> +#include "document.hxx" +#include "attrib.hxx" +#include "rangenam.hxx" +#include "dbcolect.hxx" +#include "pivot.hxx" +#include "docpool.hxx" +#include "poolhelp.hxx" +#include "refupdat.hxx" +#include "docoptio.hxx" +#include "viewopti.hxx" +#include "scextopt.hxx" +#include "tablink.hxx" +#include "conditio.hxx" +#include "detdata.hxx" +#include "scmod.hxx" // SC_MOD +#include "inputopt.hxx" // GetExpandRefs +#include "bf_sc.hrc" // SID_LINK +#include "hints.hxx" +#include "dpobject.hxx" + +namespace binfilter { +using namespace ::com::sun::star; + +//------------------------------------------------------------------------ + +/*N*/ ScRangeName* ScDocument::GetRangeName() +/*N*/ { +/*N*/ return pRangeName; +/*N*/ } + +/*N*/ void ScDocument::SetRangeName( ScRangeName* pNewRangeName ) +/*N*/ { +/*N*/ if (pRangeName) +/*N*/ delete pRangeName; +/*N*/ pRangeName = pNewRangeName; +/*N*/ } + + + +/*N*/ ScDBCollection* ScDocument::GetDBCollection() const +/*N*/ { +/*N*/ return pDBCollection; +/*N*/ } + + +/*N*/ ScDBData* ScDocument::GetDBAtCursor(USHORT nCol, USHORT nRow, USHORT nTab, BOOL bStartOnly) const +/*N*/ { +/*N*/ if (pDBCollection) +/*N*/ return pDBCollection->GetDBAtCursor(nCol, nRow, nTab, bStartOnly); +/*N*/ else +/*N*/ return NULL; +/*N*/ } + +/*N*/ ScDBData* ScDocument::GetDBAtArea(USHORT nTab, USHORT nCol1, USHORT nRow1, USHORT nCol2, USHORT nRow2) const +/*N*/ { +/*N*/ if (pDBCollection) +/*N*/ return pDBCollection->GetDBAtArea(nTab, nCol1, nRow1, nCol2, nRow2); +/*N*/ else +/*N*/ return NULL; +/*N*/ } + +/*N*/ ScDPCollection* ScDocument::GetDPCollection() +/*N*/ { +/*N*/ if (!pDPCollection) +/*N*/ pDPCollection = new ScDPCollection(this); +/*N*/ return pDPCollection; +/*N*/ } + + + + + + + + +/*N*/ void ScDocument::SetScenario( USHORT nTab, BOOL bFlag ) +/*N*/ { +/*N*/ if (nTab<=MAXTAB && pTab[nTab]) +/*N*/ pTab[nTab]->SetScenario(bFlag); +/*N*/ } + +/*N*/ BOOL ScDocument::IsScenario( USHORT nTab ) const +/*N*/ { +/*N*/ if (nTab<=MAXTAB && pTab[nTab]) +/*N*/ return pTab[nTab]->IsScenario(); +/*N*/ +/*N*/ return FALSE; +/*N*/ } + +/*N*/ void ScDocument::SetScenarioData( USHORT nTab, const String& rComment, +/*N*/ const Color& rColor, USHORT nFlags ) +/*N*/ { +/*N*/ if (nTab<=MAXTAB && pTab[nTab] && pTab[nTab]->IsScenario()) +/*N*/ { +/*N*/ pTab[nTab]->SetScenarioComment( rComment ); +/*N*/ pTab[nTab]->SetScenarioColor( rColor ); +/*N*/ pTab[nTab]->SetScenarioFlags( nFlags ); +/*N*/ } +/*N*/ } + +/*N*/ void ScDocument::GetScenarioData( USHORT nTab, String& rComment, +/*N*/ Color& rColor, USHORT& rFlags ) const +/*N*/ { +/*N*/ if (nTab<=MAXTAB && pTab[nTab] && pTab[nTab]->IsScenario()) +/*N*/ { +/*N*/ pTab[nTab]->GetScenarioComment( rComment ); +/*N*/ rColor = pTab[nTab]->GetScenarioColor(); +/*N*/ rFlags = pTab[nTab]->GetScenarioFlags(); +/*N*/ } +/*N*/ } + +/*N*/ BOOL ScDocument::IsLinked( USHORT nTab ) const +/*N*/ { +/*N*/ if (nTab<=MAXTAB && pTab[nTab]) +/*N*/ return pTab[nTab]->IsLinked(); +/*N*/ return FALSE; +/*N*/ } + +/*N*/ BOOL ScDocument::GetLinkMode( USHORT nTab ) const +/*N*/ { +/*N*/ if (nTab<=MAXTAB && pTab[nTab]) +/*N*/ return pTab[nTab]->GetLinkMode(); +/*N*/ return SC_LINK_NONE; +/*N*/ } + +/*N*/ const String& ScDocument::GetLinkDoc( USHORT nTab ) const +/*N*/ { +/*N*/ if (nTab<=MAXTAB && pTab[nTab]) +/*N*/ return pTab[nTab]->GetLinkDoc(); +/*N*/ return EMPTY_STRING; +/*N*/ } + +/*N*/ const String& ScDocument::GetLinkFlt( USHORT nTab ) const +/*N*/ { +/*N*/ if (nTab<=MAXTAB && pTab[nTab]) +/*N*/ return pTab[nTab]->GetLinkFlt(); +/*N*/ return EMPTY_STRING; +/*N*/ } + +/*N*/ const String& ScDocument::GetLinkOpt( USHORT nTab ) const +/*N*/ { +/*N*/ if (nTab<=MAXTAB && pTab[nTab]) +/*N*/ return pTab[nTab]->GetLinkOpt(); +/*N*/ return EMPTY_STRING; +/*N*/ } + +/*N*/ const String& ScDocument::GetLinkTab( USHORT nTab ) const +/*N*/ { +/*N*/ if (nTab<=MAXTAB && pTab[nTab]) +/*N*/ return pTab[nTab]->GetLinkTab(); +/*N*/ return EMPTY_STRING; +/*N*/ } + +/*N*/ ULONG ScDocument::GetLinkRefreshDelay( USHORT nTab ) const +/*N*/ { +/*N*/ if (nTab<=MAXTAB && pTab[nTab]) +/*N*/ return pTab[nTab]->GetLinkRefreshDelay(); +/*N*/ return 0; +/*N*/ } + +/*N*/ void ScDocument::SetLink( USHORT nTab, BYTE nMode, const String& rDoc, +/*N*/ const String& rFilter, const String& rOptions, +/*N*/ const String& rTabName, ULONG nRefreshDelay ) +/*N*/ { +/*N*/ if (nTab<=MAXTAB && pTab[nTab]) +/*N*/ pTab[nTab]->SetLink( nMode, rDoc, rFilter, rOptions, rTabName, nRefreshDelay ); +/*N*/ } + +/*N*/ BOOL ScDocument::HasLink( const String& rDoc, +/*N*/ const String& rFilter, const String& rOptions ) const +/*N*/ { +/*N*/ USHORT nCount = GetTableCount(); +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ if (pTab[i]->IsLinked() +/*N*/ && pTab[i]->GetLinkDoc() == rDoc +/*N*/ && pTab[i]->GetLinkFlt() == rFilter +/*N*/ && pTab[i]->GetLinkOpt() == rOptions) +/*N*/ return TRUE; +/*N*/ +/*N*/ return FALSE; +/*N*/ } + + +/*N*/ BOOL ScDocument::LinkExternalTab( USHORT& rTab, const String& aDocTab, +/*N*/ const String& aFileName, const String& aTabName ) +/*N*/ { +/*N*/ if ( IsClipboard() ) +/*N*/ { +/*N*/ DBG_ERRORFILE( "LinkExternalTab in Clipboard" ); +/*N*/ return FALSE; +/*N*/ } +/*N*/ rTab = 0; +/*N*/ String aFilterName; // wird vom Loader gefuellt +/*N*/ String aOptions; // Filter-Optionen +/*N*/ ScDocumentLoader aLoader( aFileName, aFilterName, aOptions, +/*N*/ pExtDocOptions ? pExtDocOptions->nLinkCnt + 1 : 1 ); +/*N*/ if ( aLoader.IsError() ) +/*N*/ return FALSE; +/*N*/ ScDocument* pSrcDoc = aLoader.GetDocument(); +/*N*/ +/*N*/ // Tabelle kopieren +/*N*/ USHORT nSrcTab; +/*N*/ if ( pSrcDoc->GetTable( aTabName, nSrcTab ) ) +/*N*/ { +/*N*/ if ( !InsertTab( SC_TAB_APPEND, aDocTab, TRUE ) ) +/*N*/ { +/*N*/ DBG_ERRORFILE("can't insert external document table"); +/*N*/ return FALSE; +/*N*/ } +/*N*/ rTab = GetTableCount() - 1; +/*N*/ // nicht neu einfuegen, nur Ergebnisse +/*N*/ TransferTab( pSrcDoc, nSrcTab, rTab, FALSE, TRUE ); +/*N*/ } +/*N*/ else +/*N*/ return FALSE; +/*N*/ +/*N*/ ULONG nRefreshDelay = 0; +/*N*/ +/*N*/ BOOL bWasThere = HasLink( aFileName, aFilterName, aOptions ); +/*N*/ SetLink( rTab, SC_LINK_VALUE, aFileName, aFilterName, aOptions, aTabName, nRefreshDelay ); +/*N*/ if ( !bWasThere ) // Link pro Quelldokument nur einmal eintragen +/*N*/ { +/*N*/ ScTableLink* pLink = new ScTableLink( pShell, aFileName, aFilterName, aOptions, nRefreshDelay ); +/*N*/ pLink->SetInCreate( TRUE ); +/*N*/ pLinkManager->InsertFileLink( *pLink, OBJECT_CLIENT_FILE, aFileName, +/*N*/ &aFilterName ); +/*N*/ pLink->Update(); +/*N*/ pLink->SetInCreate( FALSE ); +/*N*/ } +/*N*/ return TRUE; +/*N*/ } + +/*N*/ ScOutlineTable* ScDocument::GetOutlineTable( USHORT nTab, BOOL bCreate ) +/*N*/ { +/*N*/ ScOutlineTable* pVal = NULL; +/*N*/ +/*N*/ if (VALIDTAB(nTab)) +/*N*/ if (pTab[nTab]) +/*N*/ { +/*N*/ pVal = pTab[nTab]->GetOutlineTable(); +/*N*/ if (!pVal) +/*N*/ if (bCreate) +/*N*/ { +/*N*/ pTab[nTab]->StartOutlineTable(); +/*N*/ pVal = pTab[nTab]->GetOutlineTable(); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ return pVal; +/*N*/ } + + + + + + + +// kopiert aus diesem Dokument die Zellen von Positionen, an denen in pPosDoc +// auch Zellen stehen, nach pDestDoc + + + + + +/*N*/ const ScRangeList* ScDocument::GetScenarioRanges( USHORT nTab ) const +/*N*/ { +/*N*/ if (nTab<=MAXTAB && pTab[nTab]) +/*N*/ return pTab[nTab]->GetScenarioRanges(); +/*N*/ +/*N*/ return NULL; +/*N*/ } + +/*N*/ BOOL ScDocument::IsActiveScenario( USHORT nTab ) const +/*N*/ { +/*N*/ if (nTab<=MAXTAB && pTab[nTab]) +/*N*/ return pTab[nTab]->IsActiveScenario(); +/*N*/ +/*N*/ return FALSE; +/*N*/ } + +/*N*/ void ScDocument::SetActiveScenario( USHORT nTab, BOOL bActive ) +/*N*/ { +/*N*/ if (nTab<=MAXTAB && pTab[nTab]) +/*N*/ pTab[nTab]->SetActiveScenario( bActive ); +/*N*/ } + + +/*N*/ void ScDocument::AddUnoObject( SfxListener& rObject ) +/*N*/ { +/*N*/ if (!pUnoBroadcaster) +/*N*/ pUnoBroadcaster = new SfxBroadcaster; +/*N*/ +/*N*/ rObject.StartListening( *pUnoBroadcaster ); +/*N*/ } + +/*N*/ void ScDocument::RemoveUnoObject( SfxListener& rObject ) +/*N*/ { +/*N*/ if (pUnoBroadcaster) +/*N*/ { +/*N*/ rObject.EndListening( *pUnoBroadcaster ); +/*N*/ +/*N*/ if ( bInUnoBroadcast ) +/*N*/ { +/*?*/ // #107294# Broadcasts from ScDocument::BroadcastUno are the only way that +/*?*/ // uno object methods are called without holding a reference. +/*?*/ // +/*?*/ // If RemoveUnoObject is called from an object dtor in the finalizer thread +/*?*/ // while the main thread is calling BroadcastUno, the dtor thread must wait +/*?*/ // (or the object's Notify might try to access a deleted object). +/*?*/ // The SolarMutex can't be locked here because if a component is called from +/*?*/ // a VCL event, the main thread has the SolarMutex locked all the time. +/*?*/ // +/*?*/ // This check is done after calling EndListening, so a later BroadcastUno call +/*?*/ // won't touch this object. +/*?*/ +/*?*/ osl::SolarMutex& rSolarMutex = Application::GetSolarMutex(); +/*?*/ if ( rSolarMutex.tryToAcquire() ) +/*?*/ { +/*?*/ // BroadcastUno is always called with the SolarMutex locked, so if it +/*?*/ // can be acquired, this is within the same thread (should not happen) +/*?*/ DBG_ERRORFILE( "RemoveUnoObject called from BroadcastUno" ); +/*?*/ rSolarMutex.release(); +/*?*/ } +/*?*/ else +/*?*/ { +/*?*/ // let the thread that called BroadcastUno continue +/*?*/ while ( bInUnoBroadcast ) +/*?*/ { +/*?*/ osl::Thread::yield(); +/*?*/ } +/*?*/ } +/*N*/ } +/*N*/ } +/*N*/ else +/*?*/ DBG_ERROR("No Uno broadcaster"); +/*N*/ } + +/*N*/ void ScDocument::BroadcastUno( const SfxHint &rHint ) +/*N*/ { +/*N*/ if (pUnoBroadcaster) +/*N*/ { +/*N*/ bInUnoBroadcast = TRUE; +/*N*/ pUnoBroadcaster->Broadcast( rHint ); +/*N*/ bInUnoBroadcast = FALSE; +/*N*/ } +/*N*/ } + +/*N*/ void ScDocument::UpdateReference( UpdateRefMode eUpdateRefMode, +/*N*/ USHORT nCol1, USHORT nRow1, USHORT nTab1, +/*N*/ USHORT nCol2, USHORT nRow2, USHORT nTab2, +/*N*/ short nDx, short nDy, short nDz, +/*N*/ ScDocument* pUndoDoc, BOOL bIncludeDraw ) +/*N*/ { +/*N*/ PutInOrder( nCol1, nCol2 ); +/*N*/ PutInOrder( nRow1, nRow2 ); +/*N*/ PutInOrder( nTab1, nTab2 ); +/*N*/ if (VALIDTAB(nTab1) && VALIDTAB(nTab2)) +/*N*/ { +/*N*/ BOOL bExpandRefsOld = IsExpandRefs(); +/*N*/ if ( eUpdateRefMode == URM_INSDEL && (nDx > 0 || nDy > 0 || nDz > 0) ) +/*N*/ SetExpandRefs( SC_MOD()->GetInputOptions().GetExpandRefs() ); +/*N*/ USHORT i; +/*N*/ USHORT iMax; +/*N*/ if ( eUpdateRefMode == URM_COPY ) +/*N*/ { +/*N*/ i = nTab1; +/*N*/ iMax = nTab2; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ ScRange aRange( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 ); +/*N*/ xColNameRanges->UpdateReference( eUpdateRefMode, this, aRange, nDx, nDy, nDz ); +/*N*/ xRowNameRanges->UpdateReference( eUpdateRefMode, this, aRange, nDx, nDy, nDz ); +/*N*/ pDBCollection->UpdateReference( eUpdateRefMode, nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, nDx, nDy, nDz ); +/*N*/ pRangeName->UpdateReference( eUpdateRefMode, aRange, nDx, nDy, nDz ); +/*N*/ if (pPivotCollection) +/*N*/ pPivotCollection->UpdateReference( eUpdateRefMode, nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, nDx, nDy, nDz ); +/*N*/ if ( pDPCollection ) +/*N*/ pDPCollection->UpdateReference( eUpdateRefMode, aRange, nDx, nDy, nDz ); +/*N*/ UpdateChartRef( eUpdateRefMode, nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, nDx, nDy, nDz ); +/*N*/ UpdateRefAreaLinks( eUpdateRefMode, aRange, nDx, nDy, nDz ); +/*N*/ if ( pCondFormList ) +/*N*/ pCondFormList->UpdateReference( eUpdateRefMode, aRange, nDx, nDy, nDz ); +/*N*/ if ( pDetOpList ) +/*N*/ pDetOpList->UpdateReference( this, eUpdateRefMode, aRange, nDx, nDy, nDz ); +/*N*/ if ( pUnoBroadcaster ) +/*N*/ pUnoBroadcaster->Broadcast( ScUpdateRefHint( +/*N*/ eUpdateRefMode, aRange, nDx, nDy, nDz ) ); +/*N*/ i = 0; +/*N*/ iMax = MAXTAB; +/*N*/ } +/*N*/ for ( ; i<=iMax; i++) +/*N*/ if (pTab[i]) +/*N*/ pTab[i]->UpdateReference( +/*N*/ eUpdateRefMode, nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, +/*N*/ nDx, nDy, nDz, pUndoDoc, bIncludeDraw ); +/*N*/ +/*N*/ if ( bIsEmbedded ) +/*N*/ { +/*N*/ USHORT theCol1, theRow1, theTab1, theCol2, theRow2, theTab2; +/*N*/ theCol1 = aEmbedRange.aStart.Col(); +/*N*/ theRow1 = aEmbedRange.aStart.Row(); +/*N*/ theTab1 = aEmbedRange.aStart.Tab(); +/*N*/ theCol2 = aEmbedRange.aEnd.Col(); +/*N*/ theRow2 = aEmbedRange.aEnd.Row(); +/*N*/ theTab2 = aEmbedRange.aEnd.Tab(); +/*N*/ if ( ScRefUpdate::Update( this, eUpdateRefMode, nCol1,nRow1,nTab1, nCol2,nRow2,nTab2, +/*N*/ nDx,nDy,nDz, theCol1,theRow1,theTab1, theCol2,theRow2,theTab2 ) ) +/*N*/ { +/*N*/ aEmbedRange = ScRange( theCol1,theRow1,theTab1, theCol2,theRow2,theTab2 ); +/*N*/ } +/*N*/ } +/*N*/ SetExpandRefs( bExpandRefsOld ); + } +/*N*/ } + + + +/*N*/ void ScDocument::Fill(USHORT nCol1, USHORT nRow1, USHORT nCol2, USHORT nRow2, const ScMarkData& rMark, +/*N*/ USHORT nFillCount, FillDir eFillDir, FillCmd eFillCmd, FillDateCmd eFillDateCmd, +/*N*/ double nStepValue, double nMaxValue) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 PutInOrder( nCol1, nCol2 ); +/*N*/ } + + +/*N*/ void ScDocument::AutoFormat( USHORT nStartCol, USHORT nStartRow, USHORT nEndCol, USHORT nEndRow, +/*N*/ USHORT nFormatNo, const ScMarkData& rMark ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 PutInOrder( nStartCol, nEndCol ); +/*N*/ } + + +// Outline anpassen + +/*N*/ BOOL ScDocument::UpdateOutlineCol( USHORT nStartCol, USHORT nEndCol, USHORT nTab, BOOL bShow ) +/*N*/ { +/*N*/ if ( nTab<=MAXTAB && pTab[nTab] ) +/*N*/ return pTab[nTab]->UpdateOutlineCol( nStartCol, nEndCol, bShow ); +/*N*/ +/*N*/ DBG_ERROR("missing tab"); +/*N*/ return FALSE; +/*N*/ } + +/*N*/ BOOL ScDocument::UpdateOutlineRow( USHORT nStartRow, USHORT nEndRow, USHORT nTab, BOOL bShow ) +/*N*/ { +/*N*/ if ( nTab<=MAXTAB && pTab[nTab] ) +/*N*/ return pTab[nTab]->UpdateOutlineRow( nStartRow, nEndRow, bShow ); +/*N*/ +/*N*/ DBG_ERROR("missing tab"); +/*N*/ return FALSE; +/*N*/ } + +/*N*/ void ScDocument::Sort(USHORT nTab, const ScSortParam& rSortParam, BOOL bKeepQuery) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 if ( nTab<=MAXTAB && pTab[nTab] ) +/*N*/ } + +/*N*/ USHORT ScDocument::Query(USHORT nTab, const ScQueryParam& rQueryParam, BOOL bKeepSub) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 if ( nTab<=MAXTAB && pTab[nTab] ) +/*N*/ return 0; +/*N*/ } + + + + + +/*N*/ BOOL ScDocument::CreateQueryParam(USHORT nCol1, USHORT nRow1, USHORT nCol2, USHORT nRow2, USHORT nTab, ScQueryParam& rQueryParam) +/*N*/ { +/*N*/ if ( nTab<=MAXTAB && pTab[nTab] ) +/*N*/ return pTab[nTab]->CreateQueryParam(nCol1, nRow1, nCol2, nRow2, rQueryParam); +/*N*/ +/*N*/ DBG_ERROR("missing tab"); +/*N*/ return FALSE; +/*N*/ } + +/*N*/ BOOL ScDocument::HasColHeader( USHORT nStartCol, USHORT nStartRow, USHORT nEndCol, USHORT nEndRow, +/*N*/ USHORT nTab ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 if (VALIDTAB(nTab)) +/*N*/ return FALSE; +/*N*/ } + +// Funktionen werden als 1 schon vom InputHandler eingefuegt +#define SC_STRTYPE_NAMES 2 +#define SC_STRTYPE_DBNAMES 3 +#define SC_STRTYPE_HEADERS 4 + + + +/*N*/ BOOL ScDocument::IsEmbedded() const +/*N*/ { +/*N*/ return bIsEmbedded; +/*N*/ } + + + + + +/*N*/ ScRange ScDocument::GetRange( USHORT nTab, const Rectangle& rMMRect ) +/*N*/ { +/*N*/ ScTable* pTable = pTab[nTab]; +/*N*/ if (!pTable) +/*N*/ { +/*N*/ DBG_ERROR("GetRange ohne Tabelle"); +/*N*/ return ScRange(); +/*N*/ } +/*N*/ +/*N*/ long nSize; +/*N*/ long nTwips; +/*N*/ long nAdd; +/*N*/ BOOL bEnd; +/*N*/ +/*N*/ nSize = 0; +/*N*/ nTwips = (long) (rMMRect.Left() / HMM_PER_TWIPS); +/*N*/ +/*N*/ USHORT nX1 = 0; +/*N*/ bEnd = FALSE; +/*N*/ while (!bEnd) +/*N*/ { +/*N*/ nAdd = (long) pTable->GetColWidth(nX1); +/*N*/ if (nSize+nAdd <= nTwips+1 && nX1<MAXCOL) +/*N*/ { +/*N*/ nSize += nAdd; +/*N*/ ++nX1; +/*N*/ } +/*N*/ else +/*N*/ bEnd = TRUE; +/*N*/ } +/*N*/ +/*N*/ nTwips = (long) (rMMRect.Right() / HMM_PER_TWIPS); +/*N*/ +/*N*/ USHORT nX2 = nX1; +/*N*/ bEnd = FALSE; +/*N*/ while (!bEnd) +/*N*/ { +/*N*/ nAdd = (long) pTable->GetColWidth(nX2); +/*N*/ if (nSize+nAdd < nTwips && nX2<MAXCOL) +/*N*/ { +/*N*/ nSize += nAdd; +/*N*/ ++nX2; +/*N*/ } +/*N*/ else +/*N*/ bEnd = TRUE; +/*N*/ } +/*N*/ +/*N*/ +/*N*/ nSize = 0; +/*N*/ nTwips = (long) (rMMRect.Top() / HMM_PER_TWIPS); +/*N*/ +/*N*/ USHORT nY1 = 0; +/*N*/ bEnd = FALSE; +/*N*/ while (!bEnd) +/*N*/ { +/*N*/ nAdd = (long) pTable->GetRowHeight(nY1); +/*N*/ if (nSize+nAdd <= nTwips+1 && nY1<MAXROW) +/*N*/ { +/*N*/ nSize += nAdd; +/*N*/ ++nY1; +/*N*/ } +/*N*/ else +/*N*/ bEnd = TRUE; +/*N*/ } +/*N*/ +/*N*/ nTwips = (long) (rMMRect.Bottom() / HMM_PER_TWIPS); +/*N*/ +/*N*/ USHORT nY2 = nY1; +/*N*/ bEnd = FALSE; +/*N*/ while (!bEnd) +/*N*/ { +/*N*/ nAdd = (long) pTable->GetRowHeight(nY2); +/*N*/ if (nSize+nAdd < nTwips && nY2<MAXROW) +/*N*/ { +/*N*/ nSize += nAdd; +/*N*/ ++nY2; +/*N*/ } +/*N*/ else +/*N*/ bEnd = TRUE; +/*N*/ } +/*N*/ +/*N*/ return ScRange( nX1,nY1,nTab, nX2,nY2,nTab ); +/*N*/ } + + +// VisArea auf Zellgrenzen anpassen + +/*N*/ void lcl_SnapHor( ScTable* pTable, long& rVal, USHORT& rStartCol ) +/*N*/ { +/*N*/ USHORT nCol = 0; +/*N*/ long nTwips = (long) (rVal / HMM_PER_TWIPS); +/*N*/ long nSnap = 0; +/*N*/ while ( nCol<MAXCOL ) +/*N*/ { +/*N*/ long nAdd = pTable->GetColWidth(nCol); +/*N*/ if ( nSnap + nAdd/2 < nTwips || nCol < rStartCol ) +/*N*/ { +/*N*/ nSnap += nAdd; +/*N*/ ++nCol; +/*N*/ } +/*N*/ else +/*N*/ break; +/*N*/ } +/*N*/ rVal = (long) ( nSnap * HMM_PER_TWIPS ); +/*N*/ rStartCol = nCol; +/*N*/ } + +/*N*/ void lcl_SnapVer( ScTable* pTable, long& rVal, USHORT& rStartRow ) +/*N*/ { +/*N*/ USHORT nRow = 0; +/*N*/ long nTwips = (long) (rVal / HMM_PER_TWIPS); +/*N*/ long nSnap = 0; +/*N*/ while ( nRow<MAXROW ) +/*N*/ { +/*N*/ long nAdd = pTable->GetRowHeight(nRow); +/*N*/ if ( nSnap + nAdd/2 < nTwips || nRow < rStartRow ) +/*N*/ { +/*N*/ nSnap += nAdd; +/*N*/ ++nRow; +/*N*/ } +/*N*/ else +/*N*/ break; +/*N*/ } +/*N*/ rVal = (long) ( nSnap * HMM_PER_TWIPS ); +/*N*/ rStartRow = nRow; +/*N*/ } + +/*N*/ void ScDocument::SnapVisArea( Rectangle& rRect ) const +/*N*/ { +/*N*/ ScTable* pTable = pTab[nVisibleTab]; +/*N*/ if (!pTable) +/*N*/ { +/*N*/ DBG_ERROR("SetEmbedded ohne Tabelle"); +/*N*/ return; +/*N*/ } +/*N*/ +/*N*/ USHORT nCol = 0; +/*N*/ lcl_SnapHor( pTable, rRect.Left(), nCol ); +/*N*/ ++nCol; // mindestens eine Spalte +/*N*/ lcl_SnapHor( pTable, rRect.Right(), nCol ); +/*N*/ +/*N*/ USHORT nRow = 0; +/*N*/ lcl_SnapVer( pTable, rRect.Top(), nRow ); +/*N*/ ++nRow; // mindestens eine Zeile +/*N*/ lcl_SnapVer( pTable, rRect.Bottom(), nRow ); +/*N*/ } + +/*N*/ void ScDocument::SetDocProtection( BOOL bProtect, const uno::Sequence<sal_Int8>& rPasswd ) +/*N*/ { +/*N*/ bProtected = bProtect; +/*N*/ aProtectPass = rPasswd; +/*N*/ } + +/*N*/ void ScDocument::SetTabProtection( USHORT nTab, BOOL bProtect, const uno::Sequence<sal_Int8>& rPasswd ) +/*N*/ { +/*N*/ if (VALIDTAB(nTab)) +/*N*/ if (pTab[nTab]) +/*N*/ pTab[nTab]->SetProtection( bProtect, rPasswd ); +/*N*/ } + +/*N*/ BOOL ScDocument::IsDocProtected() const +/*N*/ { +/*N*/ return bProtected; +/*N*/ } + +/*N*/ BOOL ScDocument::IsDocEditable() const +/*N*/ { +/*N*/ // import into read-only document is possible - must be extended if other filters use api +/*N*/ +/*N*/ return !bProtected && ( !pShell || !pShell->IsReadOnly() || bImportingXML ); +/*N*/ } + +/*N*/ BOOL ScDocument::IsTabProtected( USHORT nTab ) const +/*N*/ { +/*N*/ if (VALIDTAB(nTab)) +/*N*/ if (pTab[nTab]) +/*N*/ return pTab[nTab]->IsProtected(); +/*N*/ +/*N*/ DBG_ERROR("Falsche Tabellennummer"); +/*N*/ return FALSE; +/*N*/ } + +/*N*/ const uno::Sequence<sal_Int8>& ScDocument::GetDocPassword() const +/*N*/ { +/*N*/ return aProtectPass; +/*N*/ } + +/*N*/ const uno::Sequence<sal_Int8>& ScDocument::GetTabPassword( USHORT nTab ) const +/*N*/ { +/*N*/ if (VALIDTAB(nTab)) +/*N*/ if (pTab[nTab]) +/*N*/ return pTab[nTab]->GetPassword(); +/*N*/ +/*N*/ DBG_ERROR("Falsche Tabellennummer"); +/*N*/ return aProtectPass; +/*N*/ } + +/*N*/ const ScDocOptions& ScDocument::GetDocOptions() const +/*N*/ { +/*N*/ DBG_ASSERT( pDocOptions, "No DocOptions! :-(" ); +/*N*/ return *pDocOptions; +/*N*/ } + +/*N*/ void ScDocument::SetDocOptions( const ScDocOptions& rOpt ) +/*N*/ { +/*N*/ USHORT d,m,y; +/*N*/ +/*N*/ DBG_ASSERT( pDocOptions, "No DocOptions! :-(" ); +/*N*/ *pDocOptions = rOpt; +/*N*/ rOpt.GetDate( d,m,y ); +/*N*/ +/*N*/ SvNumberFormatter* pFormatter = xPoolHelper->GetFormTable(); +/*N*/ pFormatter->ChangeNullDate( d,m,y ); +/*N*/ pFormatter->ChangeStandardPrec( (USHORT)rOpt.GetStdPrecision() ); +/*N*/ pFormatter->SetYear2000( rOpt.GetYear2000() ); +/*N*/ } + +/*N*/ const ScViewOptions& ScDocument::GetViewOptions() const +/*N*/ { +/*N*/ DBG_ASSERT( pViewOptions, "No ViewOptions! :-(" ); +/*N*/ return *pViewOptions; +/*N*/ } + +/*N*/ void ScDocument::SetViewOptions( const ScViewOptions& rOpt ) +/*N*/ { +/*N*/ DBG_ASSERT( pViewOptions, "No ViewOptions! :-(" ); +/*N*/ *pViewOptions = rOpt; +/*N*/ } + +/*N*/ void ScDocument::GetLanguage( LanguageType& rLatin, LanguageType& rCjk, LanguageType& rCtl ) const +/*N*/ { +/*N*/ rLatin = eLanguage; +/*N*/ rCjk = eCjkLanguage; +/*N*/ rCtl = eCtlLanguage; +/*N*/ } + +/*N*/ void ScDocument::SetLanguage( LanguageType eLatin, LanguageType eCjk, LanguageType eCtl ) +/*N*/ { +/*N*/ eLanguage = eLatin; +/*N*/ eCjkLanguage = eCjk; +/*N*/ eCtlLanguage = eCtl; +/*N*/ if ( xPoolHelper.is() ) +/*N*/ { +/*N*/ ScDocumentPool* pPool = xPoolHelper->GetDocPool(); +/*N*/ pPool->SetPoolDefaultItem( SvxLanguageItem( eLanguage, ATTR_FONT_LANGUAGE ) ); +/*N*/ pPool->SetPoolDefaultItem( SvxLanguageItem( eCjkLanguage, ATTR_CJK_FONT_LANGUAGE ) ); +/*N*/ pPool->SetPoolDefaultItem( SvxLanguageItem( eCtlLanguage, ATTR_CTL_FONT_LANGUAGE ) ); +/*N*/ } +/*N*/ +/*N*/ UpdateDrawLanguages(); // set edit engine defaults in drawing layer pool +/*N*/ } + +/*N*/ Rectangle ScDocument::GetMMRect( USHORT nStartCol, USHORT nStartRow, +/*N*/ USHORT nEndCol, USHORT nEndRow, USHORT nTab ) +/*N*/ { +/*N*/ if (nTab > MAXTAB || !pTab[nTab]) +/*N*/ { +/*N*/ DBG_ERROR("GetMMRect: falsche Tabelle"); +/*N*/ return Rectangle(0,0,0,0); +/*N*/ } +/*N*/ +/*N*/ USHORT i; +/*N*/ Rectangle aRect; +/*N*/ +/*N*/ for (i=0; i<nStartCol; i++) +/*N*/ aRect.Left() += GetColWidth(i,nTab); +/*N*/ for (i=0; i<nStartRow; i++) +/*N*/ aRect.Top() += FastGetRowHeight(i,nTab); +/*N*/ +/*N*/ aRect.Right() = aRect.Left(); +/*N*/ aRect.Bottom() = aRect.Top(); +/*N*/ +/*N*/ for (i=nStartCol; i<=nEndCol; i++) +/*N*/ aRect.Right() += GetColWidth(i,nTab); +/*N*/ for (i=nStartRow; i<=nEndRow; i++) +/*N*/ aRect.Bottom() += FastGetRowHeight(i,nTab); +/*N*/ +/*N*/ aRect.Left() = (long)(aRect.Left() * HMM_PER_TWIPS); +/*N*/ aRect.Right() = (long)(aRect.Right() * HMM_PER_TWIPS); +/*N*/ aRect.Top() = (long)(aRect.Top() * HMM_PER_TWIPS); +/*N*/ aRect.Bottom() = (long)(aRect.Bottom() * HMM_PER_TWIPS); +/*N*/ +/*N*/ return aRect; +/*N*/ } + +/*N*/ void ScDocument::DoMerge( USHORT nTab, USHORT nStartCol, USHORT nStartRow, +/*N*/ USHORT nEndCol, USHORT nEndRow ) +/*N*/ { +/*N*/ ScMergeAttr aAttr( nEndCol-nStartCol+1, nEndRow-nStartRow+1 ); +/*N*/ ApplyAttr( nStartCol, nStartRow, nTab, aAttr ); +/*N*/ +/*N*/ if ( nEndCol > nStartCol ) +/*N*/ ApplyFlagsTab( nStartCol+1, nStartRow, nEndCol, nStartRow, nTab, SC_MF_HOR ); +/*N*/ if ( nEndRow > nStartRow ) +/*N*/ ApplyFlagsTab( nStartCol, nStartRow+1, nStartCol, nEndRow, nTab, SC_MF_VER ); +/*N*/ if ( nEndCol > nStartCol && nEndRow > nStartRow ) +/*N*/ ApplyFlagsTab( nStartCol+1, nStartRow+1, nEndCol, nEndRow, nTab, SC_MF_HOR | SC_MF_VER ); +/*N*/ } + + +/*N*/ void ScDocument::ExtendPrintArea( OutputDevice* pDev, USHORT nTab, +/*N*/ USHORT nStartCol, USHORT nStartRow, USHORT& rEndCol, USHORT nEndRow ) +/*N*/ { +/*N*/ if ( nTab <= MAXTAB && pTab[nTab] ) +/*N*/ pTab[nTab]->ExtendPrintArea( pDev, nStartCol, nStartRow, rEndCol, nEndRow ); +/*N*/ } + +/*N*/ void ScDocument::IncSizeRecalcLevel( USHORT nTab ) +/*N*/ { +/*N*/ if ( nTab <= MAXTAB && pTab[nTab] ) +/*N*/ pTab[nTab]->IncRecalcLevel(); +/*N*/ } + +/*N*/ void ScDocument::DecSizeRecalcLevel( USHORT nTab ) +/*N*/ { +/*N*/ if ( nTab <= MAXTAB && pTab[nTab] ) +/*N*/ pTab[nTab]->DecRecalcLevel(); +/*N*/ } + + + + +} //namespace binfilter + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_documen4.cxx b/binfilter/bf_sc/source/core/data/sc_documen4.cxx new file mode 100644 index 000000000000..08a69c308879 --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_documen4.cxx @@ -0,0 +1,501 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include <bf_svtools/intitem.hxx> +#include <vcl/sound.hxx> + +#include "globstr.hrc" +#include "subtotal.hxx" +#include "interpre.hxx" +#include "markdata.hxx" +#include "validat.hxx" +#include "scitems.hxx" +#include "stlpool.hxx" +#include "poolhelp.hxx" +#include "detdata.hxx" +namespace binfilter { + +// ----------------------------------------------------------------------- + +// Nach der Regula Falsi Methode +/*N*/ BOOL ScDocument::Solver(USHORT nFCol, USHORT nFRow, USHORT nFTab, +/*N*/ USHORT nVCol, USHORT nVRow, USHORT nVTab, +/*N*/ const String& sValStr, double& nX) +/*N*/ { +/*N*/ BOOL bRet = FALSE; +/*N*/ nX = 0.0; +/*N*/ if (ValidColRow(nFCol, nFRow) && ValidColRow(nVCol, nVRow) && +/*N*/ VALIDTAB(nFTab) && VALIDTAB(nVTab) && pTab[nFTab] && pTab[nVTab]) +/*N*/ { +/*N*/ CellType eFType, eVType; +/*N*/ GetCellType(nFCol, nFRow, nFTab, eFType); +/*N*/ GetCellType(nVCol, nVRow, nVTab, eVType); +/*N*/ // CELLTYPE_NOTE: kein Value aber von Formel referiert +/*N*/ if (eFType == CELLTYPE_FORMULA && (eVType == CELLTYPE_VALUE +/*N*/ || eVType == CELLTYPE_NOTE) ) +/*N*/ { +/*N*/ SingleRefData aRefData; +/*N*/ aRefData.InitFlags(); +/*N*/ aRefData.nCol = nVCol; +/*N*/ aRefData.nRow = nVRow; +/*N*/ aRefData.nTab = nVTab; +/*N*/ +/*N*/ ScTokenArray aArr; +/*N*/ aArr.AddOpCode( ocBackSolver ); +/*N*/ aArr.AddOpCode( ocOpen ); +/*N*/ aArr.AddSingleReference( aRefData ); +/*N*/ aArr.AddOpCode( ocSep ); +/*N*/ +/*N*/ aRefData.nCol = nFCol; +/*N*/ aRefData.nRow = nFRow; +/*N*/ aRefData.nTab = nFTab; +/*N*/ +/*N*/ aArr.AddSingleReference( aRefData ); +/*N*/ aArr.AddOpCode( ocSep ); +/*N*/ aArr.AddString( sValStr.GetBuffer() ); +/*N*/ aArr.AddOpCode( ocClose ); +/*N*/ aArr.AddOpCode( ocStop ); +/*N*/ +/*N*/ ScFormulaCell* pCell = new ScFormulaCell( this, ScAddress(), &aArr ); +/*N*/ +/*N*/ if (pCell) +/*N*/ { +/*N*/ pCell->Interpret(); +/*N*/ USHORT nErrCode = pCell->GetErrCode(); +/*N*/ nX = pCell->GetValueAlways(); +/*N*/ if (nErrCode == 0) // kein fehler beim Rechnen +/*N*/ bRet = TRUE; +/*N*/ delete pCell; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ return bRet; +/*N*/ } + +/*N*/ void ScDocument::InsertMatrixFormula(USHORT nCol1, USHORT nRow1, +/*N*/ USHORT nCol2, USHORT nRow2, +/*N*/ const ScMarkData& rMark, +/*N*/ const String& rFormula, +/*N*/ const ScTokenArray* pArr ) +/*N*/ { +/*N*/ PutInOrder(nCol1, nCol2); +/*N*/ PutInOrder(nRow1, nRow2); +/*N*/ USHORT i, j, k, nTab1; +/*N*/ i = 0; +/*N*/ BOOL bStop = FALSE; +/*N*/ while (i <= MAXTAB && !bStop) // erste markierte Tabelle finden +/*N*/ { +/*N*/ if (pTab[i] && rMark.GetTableSelect(i)) +/*N*/ bStop = TRUE; +/*N*/ else +/*N*/ i++; +/*N*/ } +/*N*/ nTab1 = i; +/*N*/ if (i == MAXTAB + 1) +/*N*/ { +/*N*/ Sound::Beep(); +/*N*/ DBG_ERROR("ScDocument::InsertMatrixFormula Keine Tabelle markiert"); +/*N*/ return; +/*N*/ } +/*N*/ +/*N*/ ScFormulaCell* pCell; +/*N*/ ScAddress aPos( nCol1, nRow1, nTab1 ); +/*N*/ if (pArr) +/*N*/ pCell = new ScFormulaCell( this, aPos, pArr, MM_FORMULA ); +/*N*/ else +/*N*/ pCell = new ScFormulaCell( this, aPos, rFormula, MM_FORMULA ); +/*N*/ pCell->SetMatColsRows( nCol2 - nCol1 + 1, nRow2 - nRow1 + 1 ); +/*N*/ for (i = 0; i <= MAXTAB; i++) +/*N*/ { +/*N*/ if (pTab[i] && rMark.GetTableSelect(i)) +/*N*/ { +/*N*/ if (i == nTab1) +/*N*/ pTab[i]->PutCell(nCol1, nRow1, pCell); +/*N*/ else +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 /*?*/ pTab[i]->PutCell(nCol1, nRow1, pCell->Clone(this, ScAddress( nCol1, nRow1, i))); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ SingleRefData aRefData; +/*N*/ aRefData.InitFlags(); +/*N*/ aRefData.nCol = nCol1; +/*N*/ aRefData.nRow = nRow1; +/*N*/ aRefData.nTab = nTab1; +/*N*/ aRefData.SetColRel( TRUE ); +/*N*/ aRefData.SetRowRel( TRUE ); +/*N*/ aRefData.SetTabRel( TRUE ); +/*N*/ aRefData.CalcRelFromAbs( ScAddress( nCol1, nRow1, nTab1 ) ); +/*N*/ +/*N*/ ScTokenArray aArr; +/*N*/ ScToken* t = aArr.AddSingleReference(aRefData); +/*N*/ t->NewOpCode( ocMatRef ); +/*N*/ +/*N*/ for (i = 0; i <= MAXTAB; i++) +/*N*/ { +/*N*/ if (pTab[i] && rMark.GetTableSelect(i)) +/*N*/ { +/*N*/ pTab[i]->DoColResize( nCol1, nCol2, nRow2 - nRow1 + 1 ); +/*N*/ if (i != nTab1) +/*N*/ { +/*?*/ aRefData.nTab = i; +/*?*/ aRefData.nRelTab = i - nTab1; +/*?*/ t->GetSingleRef() = aRefData; +/*N*/ } +/*N*/ for (j = nCol1; j <= nCol2; j++) +/*N*/ { +/*N*/ for (k = nRow1; k <= nRow2; k++) +/*N*/ { +/*N*/ if (j != nCol1 || k != nRow1) // nicht in der ersten Zelle +/*N*/ { +/*N*/ // Array muss geklont werden, damit jede +/*N*/ // Zelle ein eigenes Array erhaelt! +/*N*/ aPos = ScAddress( j, k, i ); +/*N*/ t->CalcRelFromAbs( aPos ); +/*N*/ pCell = new ScFormulaCell( this, aPos, aArr.Clone(), MM_REFERENCE ); +/*N*/ pTab[i]->PutCell(j, k, (ScBaseCell*) pCell); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } + + + + +/*N*/ BOOL ScDocument::GetNextMarkedCell( USHORT& rCol, USHORT& rRow, USHORT nTab, +/*N*/ const ScMarkData& rMark ) +/*N*/ { +/*N*/ if (nTab<=MAXTAB && pTab[nTab]) +/*N*/ return pTab[nTab]->GetNextMarkedCell( rCol, rRow, rMark ); +/*N*/ else +/*N*/ return FALSE; +/*N*/ } + + +/*N*/ void ScDocument::CompileDBFormula() +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 for (USHORT i=0; i<=MAXTAB; i++) +/*N*/ } + +/*N*/ void ScDocument::CompileDBFormula( BOOL bCreateFormulaString ) +/*N*/ { +/*N*/ for (USHORT i=0; i<=MAXTAB; i++) +/*N*/ { +/*N*/ if (pTab[i]) pTab[i]->CompileDBFormula( bCreateFormulaString ); +/*N*/ } +/*N*/ } + +/*N*/ void ScDocument::CompileNameFormula( BOOL bCreateFormulaString ) +/*N*/ { +/*N*/ if ( pCondFormList ) +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 /*?*/ pCondFormList->CompileAll(); // nach ScNameDlg noetig +/*N*/ +/*N*/ for (USHORT i=0; i<=MAXTAB; i++) +/*N*/ { +/*N*/ if (pTab[i]) pTab[i]->CompileNameFormula( bCreateFormulaString ); +/*N*/ } +/*N*/ } + +/*N*/ void ScDocument::CompileColRowNameFormula() +/*N*/ { +/*N*/ for (USHORT i=0; i<=MAXTAB; i++) +/*N*/ { +/*N*/ if (pTab[i]) pTab[i]->CompileColRowNameFormula(); +/*N*/ } +/*N*/ } + +/*N*/ void ScDocument::DoColResize( USHORT nTab, USHORT nCol1, USHORT nCol2, USHORT nAdd ) +/*N*/ { +/*N*/ if (nTab<=MAXTAB && pTab[nTab]) +/*N*/ pTab[nTab]->DoColResize( nCol1, nCol2, nAdd ); +/*N*/ else +/*N*/ DBG_ERROR("DoColResize: falsche Tabelle"); +/*N*/ } + +/*N*/ void ScDocument::InvalidateTableArea() +/*N*/ { +/*N*/ for (USHORT nTab=0; nTab<=MAXTAB && pTab[nTab]; nTab++) +/*N*/ { +/*N*/ pTab[nTab]->InvalidateTableArea(); +/*N*/ if ( pTab[nTab]->IsScenario() ) +/*N*/ pTab[nTab]->InvalidateScenarioRanges(); +/*N*/ } +/*N*/ } + + + +/*N*/ BOOL ScDocument::GetSelectionFunction( ScSubTotalFunc eFunc, +/*N*/ const ScAddress& rCursor, const ScMarkData& rMark, +/*N*/ double& rResult ) +/*N*/ { +/*N*/ ScFunctionData aData(eFunc); +/*N*/ +/*N*/ ScRange aSingle( rCursor ); +/*N*/ if ( rMark.IsMarked() ) +/*N*/ rMark.GetMarkArea(aSingle); +/*N*/ +/*N*/ USHORT nStartCol = aSingle.aStart.Col(); +/*N*/ USHORT nStartRow = aSingle.aStart.Row(); +/*N*/ USHORT nEndCol = aSingle.aEnd.Col(); +/*N*/ USHORT nEndRow = aSingle.aEnd.Row(); +/*N*/ +/*N*/ for (USHORT nTab=0; nTab<=MAXTAB && !aData.bError; nTab++) +/*N*/ if (pTab[nTab] && rMark.GetTableSelect(nTab)) +/*N*/ pTab[nTab]->UpdateSelectionFunction( aData, +/*N*/ nStartCol, nStartRow, nEndCol, nEndRow, rMark ); +/*N*/ +/*N*/ //! rMark an UpdateSelectionFunction uebergeben !!!!! +/*N*/ +/*N*/ if (!aData.bError) +/*N*/ switch (eFunc) +/*N*/ { +/*N*/ case SUBTOTAL_FUNC_SUM: +/*N*/ rResult = aData.nVal; +/*N*/ break; +/*N*/ case SUBTOTAL_FUNC_CNT: +/*N*/ case SUBTOTAL_FUNC_CNT2: +/*N*/ rResult = aData.nCount; +/*N*/ break; +/*N*/ case SUBTOTAL_FUNC_AVE: +/*N*/ if (aData.nCount) +/*N*/ rResult = aData.nVal / (double) aData.nCount; +/*N*/ else +/*N*/ aData.bError = TRUE; +/*N*/ break; +/*N*/ case SUBTOTAL_FUNC_MAX: +/*N*/ case SUBTOTAL_FUNC_MIN: +/*N*/ if (aData.nCount) +/*N*/ rResult = aData.nVal; +/*N*/ else +/*N*/ aData.bError = TRUE; +/*N*/ break; +/*N*/ } +/*N*/ +/*N*/ if (aData.bError) +/*N*/ rResult = 0.0; +/*N*/ +/*N*/ return !aData.bError; +/*N*/ } + +/*N*/ double ScDocument::RoundValueAsShown( double fVal, ULONG nFormat ) +/*N*/ { +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 short nType; + return 0;//STRIP001 return fVal; +} + +// +// bedingte Formate und Gueltigkeitsbereiche +// + +/*N*/ ULONG ScDocument::AddCondFormat( const ScConditionalFormat& rNew ) +/*N*/ { +/*N*/ if (rNew.IsEmpty()) +/*N*/ return 0; // leer ist immer 0 +/*N*/ +/*N*/ if (!pCondFormList) +/*N*/ pCondFormList = new ScConditionalFormatList; +/*N*/ +/*N*/ ULONG nMax = 0; +/*N*/ USHORT nCount = pCondFormList->Count(); +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ { +/*N*/ const ScConditionalFormat* pForm = (*pCondFormList)[i]; +/*N*/ ULONG nKey = pForm->GetKey(); +/*N*/ if ( pForm->EqualEntries( rNew ) ) +/*N*/ return nKey; +/*N*/ if ( nKey > nMax ) +/*N*/ nMax = nKey; +/*N*/ } +/*N*/ +/*N*/ // Der Aufruf kann aus ScPatternAttr::PutInPool kommen, darum Clone (echte Kopie) +/*N*/ +/*N*/ ULONG nNewKey = nMax + 1; +/*N*/ ScConditionalFormat* pInsert = rNew.Clone(this); +/*N*/ pInsert->SetKey( nNewKey ); +/*N*/ pCondFormList->InsertNew( pInsert ); +/*N*/ return nNewKey; +/*N*/ } + +/*N*/ ULONG ScDocument::AddValidationEntry( const ScValidationData& rNew ) +/*N*/ { +/*N*/ if (rNew.IsEmpty()) +/*N*/ return 0; // leer ist immer 0 +/*N*/ +/*N*/ if (!pValidationList) +/*N*/ pValidationList = new ScValidationDataList; +/*N*/ +/*N*/ ULONG nMax = 0; +/*N*/ USHORT nCount = pValidationList->Count(); +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ { +/*N*/ const ScValidationData* pData = (*pValidationList)[i]; +/*N*/ ULONG nKey = pData->GetKey(); +/*N*/ if ( pData->EqualEntries( rNew ) ) +/*N*/ return nKey; +/*N*/ if ( nKey > nMax ) +/*N*/ nMax = nKey; +/*N*/ } +/*N*/ +/*N*/ // Der Aufruf kann aus ScPatternAttr::PutInPool kommen, darum Clone (echte Kopie) +/*N*/ +/*N*/ ULONG nNewKey = nMax + 1; +/*N*/ ScValidationData* pInsert = rNew.Clone(this); +/*N*/ pInsert->SetKey( nNewKey ); +/*N*/ pValidationList->InsertNew( pInsert ); +/*N*/ return nNewKey; +/*N*/ } + + +/*N*/ const SfxItemSet* ScDocument::GetCondResult( USHORT nCol, USHORT nRow, USHORT nTab ) const +/*N*/ { +/*N*/ const ScConditionalFormat* pForm = GetCondFormat( nCol, nRow, nTab ); +/*N*/ if ( pForm ) +/*N*/ { +/*N*/ ScBaseCell* pCell = ((ScDocument*)this)->GetCell(ScAddress(nCol,nRow,nTab)); +/*N*/ String aStyle = pForm->GetCellStyle( pCell, ScAddress(nCol, nRow, nTab) ); +/*N*/ if (aStyle.Len()) +/*N*/ { +/*N*/ SfxStyleSheetBase* pStyleSheet = xPoolHelper->GetStylePool()->Find( aStyle, SFX_STYLE_FAMILY_PARA ); +/*N*/ if ( pStyleSheet ) +/*N*/ return &pStyleSheet->GetItemSet(); +/*N*/ // if style is not there, treat like no condition +/*N*/ } +/*N*/ } +/*N*/ return NULL; +/*N*/ } + +/*N*/ const ScConditionalFormat* ScDocument::GetCondFormat( +/*N*/ USHORT nCol, USHORT nRow, USHORT nTab ) const +/*N*/ { +/*N*/ ULONG nIndex = ((const SfxUInt32Item*)GetAttr(nCol,nRow,nTab,ATTR_CONDITIONAL))->GetValue(); +/*N*/ if (nIndex) +/*N*/ { +/*N*/ if (pCondFormList) +/*N*/ return pCondFormList->GetFormat( nIndex ); +/*N*/ else +/*N*/ DBG_ERROR("pCondFormList ist 0"); +/*N*/ } +/*N*/ +/*N*/ return NULL; +/*N*/ } + +/*N*/ const ScValidationData* ScDocument::GetValidationEntry( ULONG nIndex ) const +/*N*/ { +/*N*/ if ( pValidationList ) +/*N*/ return pValidationList->GetData( nIndex ); +/*N*/ else +/*N*/ return NULL; +/*N*/ } + +/*N*/ void ScDocument::FindConditionalFormat( ULONG nKey, ScRangeList& rRanges ) +/*N*/ { +/*N*/ for (USHORT i=0; i<=MAXTAB && pTab[i]; i++) +/*N*/ pTab[i]->FindConditionalFormat( nKey, rRanges ); +/*N*/ } + + +/*N*/ void ScDocument::ConditionalChanged( ULONG nKey ) +/*N*/ { +/*N*/ if ( nKey && pCondFormList && !bIsClip && !bIsUndo ) // nKey==0 -> noop +/*N*/ { +/*N*/ ScConditionalFormat* pForm = pCondFormList->GetFormat( nKey ); +/*N*/ if (pForm) +/*N*/ pForm->InvalidateArea(); +/*N*/ } +/*N*/ } + +/*N*/ void ScDocument::SetConditionalUsed( ULONG nKey ) // aus dem Speichern der Tabellen +/*N*/ { +/*N*/ if ( nKey && pCondFormList ) // nKey==0 -> noop +/*N*/ { +/*N*/ ScConditionalFormat* pForm = pCondFormList->GetFormat( nKey ); +/*N*/ if (pForm) +/*N*/ pForm->SetUsed(TRUE); +/*N*/ } +/*N*/ } + +/*N*/ void ScDocument::SetValidationUsed( ULONG nKey ) // aus dem Speichern der Tabellen +/*N*/ { +/*N*/ if ( nKey && pValidationList ) // nKey==0 -> noop +/*N*/ { +/*N*/ ScValidationData* pData = pValidationList->GetData( nKey ); +/*N*/ if (pData) +/*N*/ pData->SetUsed(TRUE); +/*N*/ } +/*N*/ } + + +//------------------------------------------------------------------------ + + +/*N*/ void ScDocument::AddDetectiveOperation( const ScDetOpData& rData ) +/*N*/ { +/*N*/ if (!pDetOpList) +/*N*/ pDetOpList = new ScDetOpList; +/*N*/ +/*N*/ pDetOpList->Append( new ScDetOpData( rData ) ); +/*N*/ } + +/*N*/ void ScDocument::ClearDetectiveOperations() +/*N*/ { +/*N*/ delete pDetOpList; // loescht auch die Eintraege +/*N*/ pDetOpList = NULL; +/*N*/ } + + +//------------------------------------------------------------------------ +// +// Vergleich von Dokumenten +// +//------------------------------------------------------------------------ + +// Pfriemel-Faktoren +#define SC_DOCCOMP_MAXDIFF 256 +#define SC_DOCCOMP_MINGOOD 128 +#define SC_DOCCOMP_COLUMNS 10 +#define SC_DOCCOMP_ROWS 100 + + + + + + + + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_documen5.cxx b/binfilter/bf_sc/source/core/data/sc_documen5.cxx new file mode 100644 index 000000000000..b5bfdb0acd9a --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_documen5.cxx @@ -0,0 +1,541 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#ifdef _MSC_VER +#pragma optimize("",off) +#endif +#ifdef _MSC_VER +#pragma optimize("q",off) // p-code off +#endif + +// INCLUDE --------------------------------------------------------------- + +#include <bf_sfx2/objsh.hxx> +#include <bf_svx/svditer.hxx> +#include <bf_svx/svdoole2.hxx> +#include <bf_svx/svdpage.hxx> +#include <bf_sch/schdll.hxx> +#include <bf_sch/memchrt.hxx> +#include <bf_sch/schdll0.hxx> + +#include "document.hxx" +#include "drwlayer.hxx" +#include "chartarr.hxx" +#include "chartlis.hxx" +#include "refupdat.hxx" +namespace binfilter { + +#ifndef SO2_DECL_SVINPLACEOBJECT_DEFINED +#define SO2_DECL_SVINPLACEOBJECT_DEFINED +SO2_DECL_REF(SvInPlaceObject) +#endif + +// ----------------------------------------------------------------------- + + // Charts aus altem Dokument updaten + +/*N*/ void ScDocument::UpdateAllCharts(BOOL bDoUpdate) +/*N*/ { +/*N*/ if (!pDrawLayer) +/*N*/ return; +/*N*/ +/*N*/ USHORT nDataCount = pChartCollection->GetCount(); +/*N*/ if ( !nDataCount ) +/*N*/ return ; // nothing to do +/*?*/ +/*?*/ USHORT nPos; +/*?*/ +/*?*/ for (USHORT nTab=0; nTab<=MAXTAB; nTab++) +/*?*/ { +/*?*/ if (pTab[nTab]) +/*?*/ { +/*?*/ SdrPage* pPage = pDrawLayer->GetPage(nTab); +/*?*/ DBG_ASSERT(pPage,"Page ?"); +/*?*/ +/*?*/ ScRange aRange; +/*?*/ SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS ); +/*?*/ SdrObject* pObject = aIter.Next(); +/*?*/ while (pObject) +/*?*/ { +/*?*/ if ( pObject->GetObjIdentifier() == OBJ_OLE2 ) +/*?*/ { +/*?*/ SvInPlaceObjectRef aIPObj = ((SdrOle2Obj*)pObject)->GetObjRef(); +/*?*/ if (aIPObj.Is()) +/*?*/ { +/*?*/ // String aIPName = aIPObj->GetName()->GetName(); +/*?*/ +/*?*/ SvInfoObject* pInfoObj = pShell->Find( aIPObj ); +/*?*/ String aIPName; +/*?*/ +/*?*/ if ( pInfoObj ) +/*?*/ aIPName = pInfoObj->GetObjName(); +/*?*/ +/*?*/ for (nPos=0; nPos<nDataCount; nPos++) +/*?*/ { +/*?*/ ScChartArray* pChartObj = (*pChartCollection)[nPos]; +/*?*/ if (pChartObj->GetName() == aIPName) +/*?*/ { +/*?*/ if (bDoUpdate) +/*?*/ { +/*?*/ SchMemChart* pMemChart = pChartObj->CreateMemChart(); +/*?*/ SchDLL::Update( aIPObj, pMemChart ); +/*?*/ delete pMemChart; +/*?*/ } +/*?*/ else // nur Position uebernehmen +/*?*/ { +/*?*/ SchMemChart* pChartData = SchDLL::GetChartData(aIPObj); +/*?*/ if (pChartData) +/*?*/ { +/*?*/ pChartObj->SetExtraStrings(*pChartData); +/*?*/ // aIPObj->SetModified( TRUE ); +/*?*/ } +/*?*/ } +/*?*/ ScChartListener* pCL = new ScChartListener( +/*?*/ aIPName, this, pChartObj->GetRangeList() ); +/*?*/ pChartListenerCollection->Insert( pCL ); +/*?*/ pCL->StartListeningTo(); +/*?*/ } +/*?*/ } +/*?*/ } +/*?*/ } +/*?*/ pObject = aIter.Next(); +/*?*/ } +/*?*/ } +/*?*/ } +/*?*/ +/*?*/ pChartCollection->FreeAll(); +/*N*/ } + + +/*N*/ void ScDocument::UpdateChartArea( const String& rChartName, +/*N*/ const ScRangeListRef& rNewList, BOOL bColHeaders, BOOL bRowHeaders, +/*N*/ BOOL bAdd, Window* pWindow ) +/*N*/ { +/*N*/ if (!pDrawLayer) +/*N*/ return; +/*N*/ +/*N*/ for (USHORT nTab=0; nTab<=MAXTAB && pTab[nTab]; nTab++) +/*N*/ { +/*N*/ SdrPage* pPage = pDrawLayer->GetPage(nTab); +/*N*/ DBG_ASSERT(pPage,"Page ?"); +/*N*/ +/*N*/ SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS ); +/*N*/ SdrObject* pObject = aIter.Next(); +/*N*/ while (pObject) +/*N*/ { +/*N*/ if ( pObject->GetObjIdentifier() == OBJ_OLE2 && +/*N*/ ((SdrOle2Obj*)pObject)->GetPersistName() == rChartName ) +/*N*/ { +/*N*/ SvInPlaceObjectRef aIPObj = ((SdrOle2Obj*)pObject)->GetObjRef(); +/*N*/ if (aIPObj.Is()) +/*N*/ { +/*N*/ const SchMemChart* pChartData = SchDLL::GetChartData(aIPObj); +/*N*/ if ( pChartData ) +/*N*/ { +/*N*/ ScChartArray aArray( this, *pChartData ); +/*N*/ if ( bAdd ) +/*N*/ { +/*N*/ // bei bAdd werden Header-Angaben ignoriert +/*N*/ aArray.AddToRangeList( rNewList ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ aArray.SetRangeList( rNewList ); +/*N*/ aArray.SetHeaders( bColHeaders, bRowHeaders ); +/*N*/ } +/*N*/ pChartListenerCollection->ChangeListening( +/*N*/ rChartName, aArray.GetRangeList() ); +/*N*/ +/*N*/ +/*N*/ SchMemChart* pMemChart = aArray.CreateMemChart(); +/*N*/ ScChartArray::CopySettings( *pMemChart, *pChartData ); +/*N*/ +/*N*/ SchDLL::Update( aIPObj, pMemChart, pWindow ); +/*N*/ delete pMemChart; +/*N*/ +/*N*/ // Dies veranlaesst Chart zum sofortigen Update +/*N*/ //SvData aEmpty; +/*N*/ //aIPObj->SendDataChanged( aEmpty ); +/*N*/ aIPObj->SendViewChanged(); +/*N*/ pObject->SendRepaintBroadcast(); +/*N*/ +/*N*/ return; // nicht weitersuchen +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ pObject = aIter.Next(); +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ void ScDocument::UpdateChart( const String& rChartName, Window* pWindow ) +/*N*/ { +/*N*/ if (!pDrawLayer || bInDtorClear) +/*N*/ return; +/*N*/ +/*N*/ for (USHORT nTab=0; nTab<=MAXTAB && pTab[nTab]; nTab++) +/*N*/ { +/*N*/ SdrPage* pPage = pDrawLayer->GetPage(nTab); +/*N*/ DBG_ASSERT(pPage,"Page ?"); +/*N*/ +/*N*/ SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS ); +/*N*/ SdrObject* pObject = aIter.Next(); +/*N*/ while (pObject) +/*N*/ { +/*N*/ if ( pObject->GetObjIdentifier() == OBJ_OLE2 && +/*N*/ ((SdrOle2Obj*)pObject)->GetPersistName() == rChartName ) +/*N*/ { +/*N*/ SvInPlaceObjectRef aIPObj = ((SdrOle2Obj*)pObject)->GetObjRef(); +/*N*/ if (aIPObj.Is()) +/*N*/ { +/*N*/ const SchMemChart* pChartData = SchDLL::GetChartData(aIPObj); +/*N*/ if ( pChartData ) +/*N*/ { +/*N*/ ScChartArray aArray( this, *pChartData ); +/*N*/ +/*N*/ SchMemChart* pMemChart = aArray.CreateMemChart(); +/*N*/ ScChartArray::CopySettings( *pMemChart, *pChartData ); +/*N*/ +/*N*/ // #57655# Chart-Update ohne geaenderte Einstellungen (MemChart) +/*N*/ // soll das Dokument nicht auf modified setzen (z.B. in frisch +/*N*/ // geladenem Dokument durch initiales Recalc) +/*N*/ +/*N*/ // #72576# disable SetModified for readonly documents only +/*N*/ +/*N*/ BOOL bEnabled = ( ((pShell && pShell->IsReadOnly()) || +/*N*/ IsImportingXML()) && +/*N*/ aIPObj->IsEnableSetModified() ); +/*N*/ if (bEnabled) +/*N*/ aIPObj->EnableSetModified(FALSE); +/*N*/ +/*N*/ SchDLL::Update( aIPObj, pMemChart, pWindow ); +/*N*/ delete pMemChart; +/*N*/ +/*N*/ // Dies veranlaesst Chart zum sofortigen Update +/*N*/ //SvData aEmpty; +/*N*/ //aIPObj->SendDataChanged( aEmpty ); +/*N*/ aIPObj->SendViewChanged(); +/*N*/ pObject->SendRepaintBroadcast(); +/*N*/ +/*N*/ if (bEnabled) +/*N*/ aIPObj->EnableSetModified(TRUE); +/*N*/ +/*N*/ return; // nicht weitersuchen +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ pObject = aIter.Next(); +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ void ScDocument::UpdateChartRef( UpdateRefMode eUpdateRefMode, +/*N*/ USHORT nCol1, USHORT nRow1, USHORT nTab1, +/*N*/ USHORT nCol2, USHORT nRow2, USHORT nTab2, +/*N*/ short nDx, short nDy, short nDz ) +/*N*/ { +/*N*/ if (!pDrawLayer) +/*N*/ return; +/*N*/ +/*N*/ USHORT nChartCount = pChartListenerCollection->GetCount(); +/*N*/ for ( USHORT nIndex = 0; nIndex < nChartCount; nIndex++ ) +/*N*/ { +/*?*/ ScChartListener* pChartListener = +/*?*/ (ScChartListener*) (pChartListenerCollection->At(nIndex)); +/*?*/ ScRangeListRef aRLR( pChartListener->GetRangeList() ); +/*?*/ ScRangeListRef aNewRLR( new ScRangeList ); +/*?*/ BOOL bChanged = FALSE; +/*?*/ BOOL bDataChanged = FALSE; +/*?*/ for ( ScRangePtr pR = aRLR->First(); pR; pR = aRLR->Next() ) +/*?*/ { +/*?*/ USHORT theCol1 = pR->aStart.Col(); +/*?*/ USHORT theRow1 = pR->aStart.Row(); +/*?*/ USHORT theTab1 = pR->aStart.Tab(); +/*?*/ USHORT theCol2 = pR->aEnd.Col(); +/*?*/ USHORT theRow2 = pR->aEnd.Row(); +/*?*/ USHORT theTab2 = pR->aEnd.Tab(); +/*?*/ ScRefUpdateRes eRes = ScRefUpdate::Update( +/*?*/ this, eUpdateRefMode, +/*?*/ nCol1,nRow1,nTab1, nCol2,nRow2,nTab2, +/*?*/ nDx,nDy,nDz, +/*?*/ theCol1,theRow1,theTab1, +/*?*/ theCol2,theRow2,theTab2 ); +/*?*/ if ( eRes != UR_NOTHING ) +/*?*/ { +/*?*/ bChanged = TRUE; +/*?*/ aNewRLR->Append( ScRange( +/*?*/ theCol1, theRow1, theTab1, +/*?*/ theCol2, theRow2, theTab2 )); +/*?*/ if ( eUpdateRefMode == URM_INSDEL +/*?*/ && !bDataChanged +/*?*/ && (eRes == UR_INVALID || +/*?*/ ((pR->aEnd.Col() - pR->aStart.Col() +/*?*/ != theCol2 - theCol1) +/*?*/ || (pR->aEnd.Row() - pR->aStart.Row() +/*?*/ != theRow2 - theRow1) +/*?*/ || (pR->aEnd.Tab() - pR->aStart.Tab() +/*?*/ != theTab2 - theTab1))) ) +/*?*/ { +/*?*/ bDataChanged = TRUE; +/*?*/ } +/*?*/ } +/*?*/ else +/*?*/ aNewRLR->Append( *pR ); +/*?*/ } +/*?*/ if ( bChanged ) +/*?*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 if ( nDz != 0 ) +/*?*/ } +/*N*/ } +/*N*/ } + + + + +/*N*/ BOOL ScDocument::HasData( USHORT nCol, USHORT nRow, USHORT nTab ) +/*N*/ { +/*N*/ if (pTab[nTab]) +/*N*/ return pTab[nTab]->HasData( nCol, nRow ); +/*N*/ else +/*N*/ return FALSE; +/*N*/ } + +/*N*/ SchMemChart* ScDocument::FindChartData(const String& rName, BOOL bForModify) +/*N*/ { +/*N*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 if (!pDrawLayer) +/*N*/ return NULL; // nix +/*N*/ } + + +/*N*/ BOOL lcl_StringInCollection( const StrCollection* pColl, const String& rStr ) +/*N*/ { +/*N*/ if ( !pColl ) +/*N*/ return FALSE; +/*N*/ +/*N*/ StrData aData( rStr ); +/*N*/ USHORT nDummy; +/*N*/ return pColl->Search( &aData, nDummy ); +/*N*/ } + +/*N*/ void ScDocument::UpdateChartListenerCollection() +/*N*/ { +/*N*/ bChartListenerCollectionNeedsUpdate = FALSE; +/*N*/ if (!pDrawLayer) +/*N*/ return; +/*N*/ else +/*N*/ { +/*N*/ ScRange aRange; +/*N*/ // Range fuer Suche unwichtig +/*N*/ ScChartListener aCLSearcher( EMPTY_STRING, this, aRange ); +/*N*/ for (USHORT nTab=0; nTab<=MAXTAB; nTab++) +/*N*/ { +/*N*/ if (pTab[nTab]) +/*N*/ { +/*N*/ SdrPage* pPage = pDrawLayer->GetPage(nTab); +/*N*/ DBG_ASSERT(pPage,"Page ?"); +/*N*/ +/*N*/ SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS ); +/*N*/ SdrObject* pObject = aIter.Next(); +/*N*/ while (pObject) +/*N*/ { +/*N*/ if ( pObject->GetObjIdentifier() == OBJ_OLE2 ) +/*N*/ { +/*N*/ String aObjName = ((SdrOle2Obj*)pObject)->GetPersistName(); +/*N*/ aCLSearcher.SetString( aObjName ); +/*N*/ USHORT nIndex; +/*N*/ if ( pChartListenerCollection->Search( &aCLSearcher, nIndex ) ) +/*N*/ { +/*N*/ ((ScChartListener*) (pChartListenerCollection-> +/*N*/ At( nIndex )))->SetUsed( TRUE ); +/*N*/ } +/*N*/ else if ( lcl_StringInCollection( pOtherObjects, aObjName ) ) +/*N*/ { +/*N*/ // non-chart OLE object -> don't touch +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ // SchDLL::GetChartData always loads the chart dll, +/*N*/ // so SchModuleDummy::HasID must be tested before +/*N*/ +/*N*/ BOOL bIsChart = FALSE; +/*N*/ USHORT nId; +/*N*/ +/*N*/ // Ask the SvPersist for the InfoObject to find out +/*N*/ // whether it is a Chart. The old way with GetObjRef +/*N*/ // loads the object which takes too much unnecessary +/*N*/ // time +/*N*/ SvInfoObject* pInfoObj = pShell->Find(aObjName); +/*N*/ DBG_ASSERT(pInfoObj, "Why isn't here a SvInfoObject?"); +/*N*/ if ( pInfoObj && +/*N*/ ((nId = SchModuleDummy::HasID(pInfoObj->GetClassName()) ) != 0) ) +/*N*/ { +/*N*/ SvInPlaceObjectRef aIPObj = ((SdrOle2Obj*)pObject)->GetObjRef(); +/*N*/ DBG_ASSERT(aIPObj.Is(), "no SvInPlaceObject given"); +/*N*/ if (aIPObj.Is()) +/*N*/ { +/*N*/ BOOL bSO6 = (nId >= SOFFICE_FILEFORMAT_60); +/*N*/ SchMemChart* pChartData = SchDLL::GetChartData(aIPObj); +/*N*/ // #84359# manually inserted OLE object +/*N*/ // => no listener at ScAddress(0,0,0) +/*N*/ // >=SO6: if no series set +/*N*/ // < SO6: if no SomeData set +/*N*/ if ( pChartData && +/*N*/ ((!bSO6 && pChartData->SomeData1().Len()) || +/*N*/ (bSO6 && pChartData->GetChartRange().maRanges.size())) ) +/*N*/ { +/*N*/ if ( PastingDrawFromOtherDoc() ) +/*N*/ { +/*?*/ // #89247# Remove series ranges from +/*?*/ // charts not originating from the +/*?*/ // same document, they become true OLE +/*?*/ // objects. +/*?*/ pChartData->SomeData1().Erase(); +/*?*/ pChartData->SomeData2().Erase(); +/*?*/ pChartData->SomeData3().Erase(); +/*?*/ pChartData->SomeData4().Erase(); +/*?*/ SchChartRange aChartRange; +/*?*/ pChartData->SetChartRange( aChartRange ); +/*?*/ pChartData->SetReadOnly( FALSE ); +/*?*/ SchDLL::Update( aIPObj, pChartData ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ bIsChart = TRUE; +/*N*/ +/*N*/ ScChartArray aArray( this, *pChartData ); +/*N*/ ScChartListener* pCL = new ScChartListener( +/*N*/ aObjName, +/*N*/ this, aArray.GetRangeList() ); +/*N*/ pChartListenerCollection->Insert( pCL ); +/*N*/ pCL->StartListeningTo(); +/*N*/ pCL->SetUsed( TRUE ); +/*N*/ +/*N*/ BOOL bForceSave = FALSE; +/*N*/ +/*N*/ // Set ReadOnly flag at MemChart, so Chart knows +/*N*/ // about the external data in a freshly loaded document. +/*N*/ // #73642# only if the chart really has external data +/*N*/ if ( aArray.IsValid() ) +/*N*/ { +/*N*/ pChartData->SetReadOnly( TRUE ); +/*N*/ +/*N*/ // #81525# re-create series ranges from old extra string +/*N*/ // if not set (after loading) +/*N*/ if ( !bSO6 ) +/*N*/ { +/*N*/ String aOldData3 = pChartData->SomeData3(); +/*N*/ aArray.SetExtraStrings( *pChartData ); +/*N*/ if ( aOldData3 != pChartData->SomeData3() ) +/*N*/ { +/*N*/ // #96148# ChartRange isn't saved in binary format anyway, +/*N*/ // but SomeData3 (sheet names) has to survive swapping out, +/*N*/ // or the chart can't be saved to 6.0 format. +/*N*/ +/*N*/ bForceSave = TRUE; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ #if 1 +/*N*/ // #74046# initially loaded charts need the number formatter standard precision +/*N*/ BOOL bEnabled = aIPObj->IsEnableSetModified(); +/*N*/ if (bEnabled) +/*N*/ aIPObj->EnableSetModified(FALSE); +/*N*/ pChartData->SetNumberFormatter( GetFormatTable() ); +/*N*/ SchDLL::Update( aIPObj, pChartData ); +/*N*/ //! pChartData got deleted, don't use it anymore +/*N*/ if (bEnabled) +/*N*/ aIPObj->EnableSetModified(TRUE); +/*N*/ #ifdef DBG_UTIL +/*N*/ // static BOOL bShown74046 = 0; +/*N*/ // if ( !bShown74046 && SOFFICE_FILEFORMAT_NOW > SOFFICE_FILEFORMAT_50 ) +/*N*/ // { +/*N*/ // bShown74046 = 1; +/*N*/ // DBG_ERRORFILE( "on incompatible file format save number formatter standard precision in chart" ); +/*N*/ // } +/*N*/ #endif +/*N*/ #endif +/*N*/ if ( bForceSave ) +/*N*/ { +/*N*/ // #96148# after adjusting the data that wasn't in the MemChart +/*N*/ // in a binary file (ChartRange etc.), the chart object has to be +/*N*/ // saved (within the open document, in transacted mode, so the +/*N*/ // original file isn't changed yet), so the changes are still +/*N*/ // there after the chart is swapped out and loaded again. +/*N*/ // The chart can't get the modified flag set, because then it +/*N*/ // wouldn't be swapped out at all. So it has to be saved manually +/*N*/ // here (which is unnecessary if the chart is modified before it +/*N*/ // it swapped out). At this point, we don't have to care about +/*N*/ // contents being lost when saving in old binary format, because +/*N*/ // the chart was just loaded from that format. +/*N*/ +/*N*/ aIPObj->DoSave(); +/*N*/ aIPObj->DoSaveCompleted(); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ if (!bIsChart) +/*N*/ { +/*N*/ // put into list of other ole objects, so the object doesn't have to +/*N*/ // be swapped in the next time UpdateChartListenerCollection is called +/*N*/ //! remove names when objects are no longer there? +/*N*/ // (object names aren't used again before reloading the document) +/*N*/ +/*N*/ if (!pOtherObjects) +/*N*/ pOtherObjects = new StrCollection; +/*N*/ pOtherObjects->Insert( new StrData( aObjName ) ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ pObject = aIter.Next(); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ // alle nicht auf SetUsed gesetzten loeschen +/*N*/ pChartListenerCollection->FreeUnused(); +/*N*/ } +/*N*/ } + +/*N*/ void ScDocument::AddOLEObjectToCollection(const String& rName) +/*N*/ { +/*N*/ if (!pOtherObjects) +/*N*/ pOtherObjects = new StrCollection; +/*N*/ pOtherObjects->Insert( new StrData( rName ) ); +/*N*/ } + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_documen6.cxx b/binfilter/bf_sc/source/core/data/sc_documen6.cxx new file mode 100644 index 000000000000..898b72fe8963 --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_documen6.cxx @@ -0,0 +1,167 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef PCH +#include "core_pch.hxx" +#endif + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include "scitems.hxx" +#include <bf_svx/scripttypeitem.hxx> + +#include <com/sun/star/i18n/XBreakIterator.hpp> +#include <com/sun/star/i18n/ScriptType.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> + +#include "document.hxx" +#include "cell.hxx" +#include "cellform.hxx" +#include "patattr.hxx" +#include "scrdata.hxx" +#include "poolhelp.hxx" +namespace binfilter { + +using namespace ::com::sun::star; + +#define SC_BREAKITER_SERVICE "com.sun.star.i18n.BreakIterator" + +// +// this file is compiled with exceptions enabled +// put functions here that need exceptions! +// + +// ----------------------------------------------------------------------- + +/*N*/ const uno::Reference< i18n::XBreakIterator >& ScDocument::GetBreakIterator() +/*N*/ { +/*N*/ if ( !pScriptTypeData ) +/*N*/ pScriptTypeData = new ScScriptTypeData; +/*N*/ if ( !pScriptTypeData->xBreakIter.is() ) +/*N*/ { +/*N*/ uno::Reference< uno::XInterface > xInterface = xServiceManager->createInstance( +/*N*/ ::rtl::OUString::createFromAscii( SC_BREAKITER_SERVICE ) ); +/*N*/ pScriptTypeData->xBreakIter = uno::Reference< i18n::XBreakIterator >( xInterface, uno::UNO_QUERY ); +/*N*/ DBG_ASSERT( pScriptTypeData->xBreakIter.is(), "can't get BreakIterator" ); +/*N*/ } +/*N*/ return pScriptTypeData->xBreakIter; +/*N*/ } + + +/*N*/ BYTE ScDocument::GetStringScriptType( const String& rString ) +/*N*/ { +/*N*/ +/*N*/ BYTE nRet = 0; +/*N*/ if (rString.Len()) +/*N*/ { +/*N*/ uno::Reference<i18n::XBreakIterator> xBreakIter = GetBreakIterator(); +/*N*/ if ( xBreakIter.is() ) +/*N*/ { +/*N*/ ::rtl::OUString aText = rString; +/*N*/ sal_Int32 nLen = aText.getLength(); +/*N*/ +/*N*/ sal_Int32 nPos = 0; +/*N*/ do +/*N*/ { +/*N*/ sal_Int16 nType = xBreakIter->getScriptType( aText, nPos ); +/*N*/ switch ( nType ) +/*N*/ { +/*N*/ case i18n::ScriptType::LATIN: +/*N*/ nRet |= SCRIPTTYPE_LATIN; +/*N*/ break; +/*N*/ case i18n::ScriptType::ASIAN: +/*N*/ nRet |= SCRIPTTYPE_ASIAN; +/*N*/ break; +/*N*/ case i18n::ScriptType::COMPLEX: +/*N*/ nRet |= SCRIPTTYPE_COMPLEX; +/*N*/ break; +/*N*/ // WEAK is ignored +/*N*/ } +/*N*/ nPos = xBreakIter->endOfScript( aText, nPos, nType ); +/*N*/ } +/*N*/ while ( nPos >= 0 && nPos < nLen ); +/*N*/ } +/*N*/ } +/*N*/ return nRet; +/*N*/ } + +/*N*/ BYTE ScDocument::GetCellScriptType( ScBaseCell* pCell, ULONG nNumberFormat ) +/*N*/ { +/*N*/ if ( !pCell ) +/*N*/ return 0; // empty +/*N*/ +/*N*/ BYTE nStored = pCell->GetScriptType(); +/*N*/ if ( nStored != SC_SCRIPTTYPE_UNKNOWN ) // stored value valid? +/*N*/ return nStored; // use stored value +/*N*/ +/*N*/ String aStr; +/*N*/ Color* pColor; +/*N*/ ScCellFormat::GetString( pCell, nNumberFormat, aStr, &pColor, *xPoolHelper->GetFormTable() ); +/*N*/ +/*N*/ BYTE nRet = GetStringScriptType( aStr ); +/*N*/ +/*N*/ pCell->SetScriptType( nRet ); // store for later calls +/*N*/ +/*N*/ return nRet; +/*N*/ } + +/*N*/ BYTE ScDocument::GetScriptType( USHORT nCol, USHORT nRow, USHORT nTab, ScBaseCell* pCell ) +/*N*/ { +/*N*/ // if cell is not passed, take from document +/*N*/ +/*N*/ if (!pCell) +/*N*/ { +/*N*/ pCell = GetCell( ScAddress( nCol, nRow, nTab ) ); +/*N*/ if ( !pCell ) +/*N*/ return 0; // empty +/*N*/ } +/*N*/ +/*N*/ // if script type is set, don't have to get number formats +/*N*/ +/*N*/ BYTE nStored = pCell->GetScriptType(); +/*N*/ if ( nStored != SC_SCRIPTTYPE_UNKNOWN ) // stored value valid? +/*N*/ return nStored; // use stored value +/*N*/ +/*N*/ // include number formats from conditional formatting +/*N*/ +/*N*/ const ScPatternAttr* pPattern = GetPattern( nCol, nRow, nTab ); +/*N*/ if (!pPattern) return 0; +/*N*/ const SfxItemSet* pCondSet = NULL; +/*N*/ if ( ((const SfxUInt32Item&)pPattern->GetItem(ATTR_CONDITIONAL)).GetValue() ) +/*N*/ pCondSet = GetCondResult( nCol, nRow, nTab ); +/*N*/ +/*N*/ ULONG nFormat = pPattern->GetNumberFormat( xPoolHelper->GetFormTable(), pCondSet ); +/*N*/ return GetCellScriptType( pCell, nFormat ); +/*N*/ } + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_documen7.cxx b/binfilter/bf_sc/source/core/data/sc_documen7.cxx new file mode 100644 index 000000000000..58973eae7725 --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_documen7.cxx @@ -0,0 +1,409 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + + +#if defined( WNT ) && defined( erBEEP ) +#include <svwin.h> +#define erBEEPER() Beep( 666, 66 ) +#else +#define erBEEPER() +#endif + +#include "document.hxx" +#include "bcaslot.hxx" +#include "cell.hxx" +#include "scmod.hxx" // SC_MOD +#include "inputopt.hxx" // GetExpandRefs +#include "conditio.hxx" +#include "bclist.hxx" + + + +#include "globstr.hrc" +namespace binfilter { + +extern const ScFormulaCell* pLastFormulaTreeTop; // cellform.cxx Err527 WorkAround + +// STATIC DATA ----------------------------------------------------------- + +#ifdef erDEBUG +ULONG erCountBCAInserts = 0; +ULONG erCountBCAFinds = 0; +#endif + +// ----------------------------------------------------------------------- + +/*N*/ void ScDocument::StartListeningArea( const ScRange& rRange, +/*N*/ SfxListener* pListener +/*N*/ ) +/*N*/ { +/*N*/ if ( pBASM ) +/*N*/ pBASM->StartListeningArea( rRange, pListener ); +/*N*/ } + + +/*N*/ void ScDocument::EndListeningArea( const ScRange& rRange, +/*N*/ SfxListener* pListener +/*N*/ ) +/*N*/ { +/*N*/ if ( pBASM ) +/*N*/ pBASM->EndListeningArea( rRange, pListener ); +/*N*/ } + + +/*N*/ void ScDocument::Broadcast( ULONG nHint, const ScAddress& rAddr, +/*N*/ ScBaseCell* pCell +/*N*/ ) +/*N*/ { +/*N*/ if ( !pBASM ) +/*N*/ return ; // Clipboard or Undo +/*N*/ ScHint aHint( nHint, rAddr, pCell ); +/*N*/ Broadcast( aHint ); +/*N*/ } + + +/*N*/ void ScDocument::Broadcast( const ScHint& rHint ) +/*N*/ { +/*N*/ if ( !pBASM ) +/*N*/ return ; // Clipboard or Undo +/*N*/ if ( !nHardRecalcState ) +/*N*/ { +/*N*/ BOOL bIsBroadcasted = FALSE; +/*N*/ ScBaseCell* pCell = rHint.GetCell(); +/*N*/ if ( pCell ) +/*N*/ { +/*N*/ ScBroadcasterList* pBC = pCell->GetBroadcaster(); +/*N*/ if ( pBC ) +/*N*/ { +/*N*/ pBC->Broadcast( rHint ); +/*N*/ bIsBroadcasted = TRUE; +/*N*/ } +/*N*/ } +/*N*/ if ( pBASM->AreaBroadcast( rHint ) || bIsBroadcasted ) +/*N*/ TrackFormulas( rHint.GetId() ); +/*N*/ } +/*N*/ +/*N*/ // Repaint fuer bedingte Formate mit relativen Referenzen: +/*N*/ if ( pCondFormList && rHint.GetAddress() != BCA_BRDCST_ALWAYS ) +/*?*/ pCondFormList->SourceChanged( rHint.GetAddress() ); +/*N*/ } + + +/*N*/ void ScDocument::AreaBroadcast( const ScHint& rHint ) +/*N*/ { +/*N*/ if ( !pBASM ) +/*N*/ return ; // Clipboard or Undo +/*N*/ if ( !nHardRecalcState ) +/*N*/ { +/*N*/ if ( pBASM->AreaBroadcast( rHint ) ) +/*N*/ TrackFormulas( rHint.GetId() ); +/*N*/ } +/*N*/ +/*N*/ // Repaint fuer bedingte Formate mit relativen Referenzen: +/*N*/ if ( pCondFormList && rHint.GetAddress() != BCA_BRDCST_ALWAYS ) +/*N*/ pCondFormList->SourceChanged( rHint.GetAddress() ); +/*N*/ } + + +/*N*/ void ScDocument::AreaBroadcastInRange( const ScRange& rRange, const ScHint& rHint ) +/*N*/ { +/*N*/ if ( !pBASM ) +/*N*/ return ; // Clipboard or Undo +/*N*/ if ( !nHardRecalcState ) +/*N*/ { +/*N*/ if ( pBASM->AreaBroadcastInRange( rRange, rHint ) ) +/*N*/ TrackFormulas( rHint.GetId() ); +/*N*/ } +/*N*/ +/*N*/ // Repaint for conditional formats containing relative references. +/*N*/ //! This is _THE_ bottle neck! +/*N*/ if ( pCondFormList ) +/*N*/ { +/*N*/ USHORT nCol, nRow, nTab, nCol1, nRow1, nTab1, nCol2, nRow2, nTab2; +/*N*/ rRange.GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 ); +/*N*/ ScAddress aAddress( rRange.aStart ); +/*N*/ for ( nTab = nTab1; nTab <= nTab2; ++nTab ) +/*N*/ { +/*N*/ aAddress.SetTab( nTab ); +/*N*/ for ( nCol = nCol1; nCol <= nCol2; ++nCol ) +/*N*/ { +/*N*/ aAddress.SetCol( nCol ); +/*N*/ for ( nRow = nRow1; nRow <= nRow2; ++nRow ) +/*N*/ { +/*N*/ aAddress.SetRow( nRow ); +/*N*/ pCondFormList->SourceChanged( aAddress ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } + + +/*N*/ void ScDocument::DelBroadcastAreasInRange( const ScRange& rRange ) +/*N*/ { +/*N*/ if ( pBASM ) +/*N*/ pBASM->DelBroadcastAreasInRange( rRange ); +/*N*/ } + +/*N*/ void ScDocument::StartListeningCell( const ScAddress& rAddress, +/*N*/ SfxListener* pListener ) +/*N*/ { +/*N*/ DBG_ASSERT(pListener, "StartListeningCell: pListener Null"); +/*N*/ USHORT nTab = rAddress.Tab(); +/*N*/ if (pTab[nTab]) +/*N*/ pTab[nTab]->StartListening( rAddress, pListener ); +/*N*/ } + +/*N*/ void ScDocument::EndListeningCell( const ScAddress& rAddress, +/*N*/ SfxListener* pListener ) +/*N*/ { +/*N*/ DBG_ASSERT(pListener, "EndListeningCell: pListener Null"); +/*N*/ USHORT nTab = rAddress.Tab(); +/*N*/ if (pTab[nTab]) +/*N*/ pTab[nTab]->EndListening( rAddress, pListener ); +/*N*/ } + + +/*N*/ void ScDocument::PutInFormulaTree( ScFormulaCell* pCell ) +/*N*/ { +/*N*/ DBG_ASSERT( pCell, "PutInFormulaTree: pCell Null" ); +/*N*/ RemoveFromFormulaTree( pCell ); +/*N*/ // anhaengen +/*N*/ if ( pEOFormulaTree ) +/*N*/ pEOFormulaTree->SetNext( pCell ); +/*N*/ else +/*N*/ pFormulaTree = pCell; // kein Ende, kein Anfang.. +/*N*/ pCell->SetPrevious( pEOFormulaTree ); +/*N*/ pCell->SetNext( 0 ); +/*N*/ pEOFormulaTree = pCell; +/*N*/ nFormulaCodeInTree += pCell->GetCode()->GetCodeLen(); +/*N*/ } + + +/*N*/ void ScDocument::RemoveFromFormulaTree( ScFormulaCell* pCell ) +/*N*/ { +/*N*/ DBG_ASSERT( pCell, "RemoveFromFormulaTree: pCell Null" ); +/*N*/ ScFormulaCell* pPrev = pCell->GetPrevious(); +/*N*/ // wenn die Zelle die erste oder sonstwo ist +/*N*/ if ( pPrev || pFormulaTree == pCell ) +/*N*/ { +/*N*/ ScFormulaCell* pNext = pCell->GetNext(); +/*N*/ if ( pPrev ) +/*N*/ pPrev->SetNext( pNext ); // gibt Vorlaeufer +/*N*/ else +/*N*/ pFormulaTree = pNext; // ist erste Zelle +/*N*/ if ( pNext ) +/*N*/ pNext->SetPrevious( pPrev ); // gibt Nachfolger +/*N*/ else +/*N*/ pEOFormulaTree = pPrev; // ist letzte Zelle +/*N*/ pCell->SetPrevious( 0 ); +/*N*/ pCell->SetNext( 0 ); +/*N*/ USHORT nRPN = pCell->GetCode()->GetCodeLen(); +/*N*/ if ( nFormulaCodeInTree >= nRPN ) +/*N*/ nFormulaCodeInTree -= nRPN; +/*N*/ else +/*N*/ { +/*N*/ DBG_ERRORFILE( "RemoveFromFormulaTree: nFormulaCodeInTree < nRPN" ); +/*N*/ nFormulaCodeInTree = 0; +/*N*/ } +/*N*/ } +/*N*/ else if ( !pFormulaTree && nFormulaCodeInTree ) +/*N*/ { +/*?*/ DBG_ERRORFILE( "!pFormulaTree && nFormulaCodeInTree != 0" ); +/*?*/ nFormulaCodeInTree = 0; +/*N*/ } +/*N*/ } + + +/*N*/ BOOL ScDocument::IsInFormulaTree( ScFormulaCell* pCell ) const +/*N*/ { +/*N*/ return pCell->GetPrevious() || pFormulaTree == pCell; +/*N*/ } + + + + +/*N*/ void ScDocument::ClearFormulaTree() +/*N*/ { +/*N*/ ScFormulaCell* pCell; +/*N*/ ScFormulaCell* pTree = pFormulaTree; +/*N*/ while ( pTree ) +/*N*/ { +/*N*/ pCell = pTree; +/*N*/ pTree = pCell->GetNext(); +/*N*/ if ( !pCell->GetCode()->IsRecalcModeAlways() ) +/*N*/ RemoveFromFormulaTree( pCell ); +/*N*/ } +/*N*/ } + + +/*N*/ void ScDocument::AppendToFormulaTrack( ScFormulaCell* pCell ) +/*N*/ { +/*N*/ DBG_ASSERT( pCell, "AppendToFormulaTrack: pCell Null" ); +/*N*/ // Zelle kann nicht in beiden Listen gleichzeitig sein +/*N*/ RemoveFromFormulaTrack( pCell ); +/*N*/ RemoveFromFormulaTree( pCell ); +/*N*/ if ( pEOFormulaTrack ) +/*N*/ pEOFormulaTrack->SetNextTrack( pCell ); +/*N*/ else +/*N*/ pFormulaTrack = pCell; // kein Ende, kein Anfang.. +/*N*/ pCell->SetPreviousTrack( pEOFormulaTrack ); +/*N*/ pCell->SetNextTrack( 0 ); +/*N*/ pEOFormulaTrack = pCell; +/*N*/ ++nFormulaTrackCount; +/*N*/ } + + +/*N*/ void ScDocument::RemoveFromFormulaTrack( ScFormulaCell* pCell ) +/*N*/ { +/*N*/ DBG_ASSERT( pCell, "RemoveFromFormulaTrack: pCell Null" ); +/*N*/ ScFormulaCell* pPrev = pCell->GetPreviousTrack(); +/*N*/ // wenn die Zelle die erste oder sonstwo ist +/*N*/ if ( pPrev || pFormulaTrack == pCell ) +/*N*/ { +/*N*/ ScFormulaCell* pNext = pCell->GetNextTrack(); +/*N*/ if ( pPrev ) +/*?*/ pPrev->SetNextTrack( pNext ); // gibt Vorlaeufer +/*N*/ else +/*N*/ pFormulaTrack = pNext; // ist erste Zelle +/*N*/ if ( pNext ) +/*N*/ pNext->SetPreviousTrack( pPrev ); // gibt Nachfolger +/*N*/ else +/*N*/ pEOFormulaTrack = pPrev; // ist letzte Zelle +/*N*/ pCell->SetPreviousTrack( 0 ); +/*N*/ pCell->SetNextTrack( 0 ); +/*N*/ --nFormulaTrackCount; +/*N*/ } +/*N*/ } + + +/*N*/ BOOL ScDocument::IsInFormulaTrack( ScFormulaCell* pCell ) const +/*N*/ { +/*N*/ return pCell->GetPreviousTrack() || pFormulaTrack == pCell; +/*N*/ } + + +/* + Der erste wird gebroadcastet, + die dadurch entstehenden werden durch das Notify an den Track gehaengt. + Der nachfolgende broadcastet wieder usw. + View stoesst Interpret an. + */ +/*N*/ void ScDocument::TrackFormulas( ULONG nHintId ) +/*N*/ { +/*N*/ +/*N*/ if ( pFormulaTrack ) +/*N*/ { +///*N*/ BOOL bWasWaiting = Application::IsWait(); +///*N*/ if ( !bWasWaiting ) +///*N*/ Application::EnterWait(); +/*N*/ erBEEPER(); +/*N*/ ScBroadcasterList* pBC; +/*N*/ ScFormulaCell* pTrack; +/*N*/ ScFormulaCell* pNext; +/*N*/ BOOL bIsChanged = TRUE; +/*N*/ pTrack = pFormulaTrack; +/*N*/ do +/*N*/ { +/*N*/ ScHint aHint( nHintId, pTrack->aPos, pTrack ); +/*N*/ if ( pBC = pTrack->GetBroadcaster() ) +/*N*/ pBC->Broadcast( aHint ); +/*N*/ pBASM->AreaBroadcast( aHint ); +/*N*/ // Repaint fuer bedingte Formate mit relativen Referenzen: +/*N*/ if ( pCondFormList ) +/*N*/ pCondFormList->SourceChanged( pTrack->aPos ); +/*N*/ pTrack = pTrack->GetNextTrack(); +/*N*/ } while ( pTrack ); +/*N*/ pTrack = pFormulaTrack; +/*N*/ BOOL bHaveForced = FALSE; +/*N*/ do +/*N*/ { +/*N*/ pNext = pTrack->GetNextTrack(); +/*N*/ RemoveFromFormulaTrack( pTrack ); +/*N*/ PutInFormulaTree( pTrack ); +/*N*/ if ( pTrack->GetCode()->IsRecalcModeForced() ) +/*N*/ bHaveForced = TRUE; +/*N*/ pTrack = pNext; +/*N*/ } while ( pTrack ); +/*N*/ if ( bHaveForced ) +/*N*/ { +/*?*/ SetForcedFormulas( TRUE ); +/*?*/ if ( bAutoCalc && !IsAutoCalcShellDisabled() && !IsInInterpreter() +/*?*/ && !IsCalculatingFormulaTree() ) +{DBG_BF_ASSERT(0, "STRIP"); }//STRIP001 /*?*/ CalcFormulaTree( TRUE ); +/*?*/ else +/*?*/ SetForcedFormulaPending( TRUE ); +/*N*/ } +///*N*/ if ( !bWasWaiting ) +///*N*/ Application::LeaveWait(); +/*N*/ } +/*N*/ DBG_ASSERT( nFormulaTrackCount==0, "TrackFormulas: nFormulaTrackCount!=0" ); +/*N*/ } + + +/*N*/ void ScDocument::StartAllListeners() +/*N*/ { +/*N*/ for ( USHORT i = 0; i <= MAXTAB; ++i ) +/*N*/ if ( pTab[i] ) +/*N*/ pTab[i]->StartAllListeners(); +/*N*/ } + +/*N*/ void ScDocument::UpdateBroadcastAreas( UpdateRefMode eUpdateRefMode, +/*N*/ const ScRange& rRange, short nDx, short nDy, short nDz +/*N*/ ) +/*N*/ { +/*N*/ BOOL bExpandRefsOld = IsExpandRefs(); +/*N*/ if ( eUpdateRefMode == URM_INSDEL && (nDx > 0 || nDy > 0 || nDz > 0) ) +/*N*/ SetExpandRefs( SC_MOD()->GetInputOptions().GetExpandRefs() ); +/*N*/ SetExpandRefs( bExpandRefsOld ); +/*N*/ } + +/*N*/ void ScDocument::SetAutoCalc( BOOL bNewAutoCalc ) +/*N*/ { +/*N*/ BOOL bOld = bAutoCalc; +/*N*/ bAutoCalc = bNewAutoCalc; +/*N*/ if ( !bOld && bNewAutoCalc && bHasForcedFormulas ) +/*N*/ { +/*?*/ if ( IsAutoCalcShellDisabled() ) +/*?*/ SetForcedFormulaPending( TRUE ); +/*?*/ else if ( !IsInInterpreter() ) +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 /*?*/ CalcFormulaTree( TRUE ); +/*N*/ } +/*N*/ } + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_documen8.cxx b/binfilter/bf_sc/source/core/data/sc_documen8.cxx new file mode 100644 index 000000000000..918fea3fd13b --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_documen8.cxx @@ -0,0 +1,648 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include "scitems.hxx" +#define ITEMID_FIELD EE_FEATURE_FIELD + +#include <bf_svx/frmdiritem.hxx> +#include <bf_svx/langitem.hxx> +#include <bf_svx/linkmgr.hxx> +#include <bf_sfx2/printer.hxx> +#include <bf_svtools/flagitem.hxx> +#define _SVSTDARR_USHORTS +#include <bf_svtools/zformat.hxx> +#include <bf_sfx2/misccfg.hxx> +#include <bf_sfx2/app.hxx> + + +#include "poolhelp.hxx" +#include "docpool.hxx" +#include "stlpool.hxx" +#include "docoptio.hxx" +#include "viewopti.hxx" +#include "rechead.hxx" +#include "ddelink.hxx" +#include "scmatrix.hxx" +#include "arealink.hxx" +#include "patattr.hxx" +#include "editutil.hxx" +#include "document.hxx" +#include "refupdat.hxx" +#include "scmod.hxx" +#include "globstr.hrc" +#include "bf_sc.hrc" +namespace binfilter { + +#define GET_SCALEVALUE(set,id) ((const SfxUInt16Item&)(set.Get( id ))).GetValue() + +// states for online spelling in the visible range (0 is set initially) +#define VSPL_START 0 +#define VSPL_DONE 1 + + +// STATIC DATA ----------------------------------------------------------- + + + +//------------------------------------------------------------------------ + +/*N*/ void ScDocument::ImplLoadDocOptions( SvStream& rStream ) +/*N*/ { +/*N*/ USHORT d,m,y; +/*N*/ +/*N*/ DBG_ASSERT( pDocOptions, "No DocOptions to load! :-(" ); +/*N*/ +/*N*/ pDocOptions->Load( rStream ); +/*N*/ +/*N*/ if ( pDocOptions->GetStdPrecision() > 20 ) //!!! ist 20 als Maximum konstant ??? +/*N*/ { +/*?*/ DBG_ERROR( "Document options corrupted. Setting to defaults." ); +/*?*/ pDocOptions->ResetDocOptions(); +/*N*/ } +/*N*/ +/*N*/ pDocOptions->GetDate( d,m,y ); +/*N*/ SvNumberFormatter* pFormatter = xPoolHelper->GetFormTable(); +/*N*/ pFormatter->ChangeNullDate( d,m,y ); +/*N*/ pFormatter->ChangeStandardPrec( pDocOptions->GetStdPrecision() ); +/*N*/ pFormatter->SetYear2000( pDocOptions->GetYear2000() ); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ void ScDocument::ImplLoadViewOptions( SvStream& rStream ) +/*N*/ { +/*N*/ DBG_ASSERT( pViewOptions, "No ViewOptions to load! :-(" ); +/*N*/ rStream >> *pViewOptions; +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ void ScDocument::ImplSaveDocOptions( SvStream& rStream ) const +/*N*/ { +/*N*/ DBG_ASSERT( pDocOptions, "No DocOptions to save! :-(" ); +/*N*/ pDocOptions->Save( rStream ); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ void ScDocument::ImplSaveViewOptions( SvStream& rStream ) const +/*N*/ { +/*N*/ DBG_ASSERT( pViewOptions, "No ViewOptions to save! :-(" ); +/*N*/ rStream << *pViewOptions; +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ void ScDocument::ImplCreateOptions() +/*N*/ { +/*N*/ pDocOptions = new ScDocOptions(); +/*N*/ pViewOptions = new ScViewOptions(); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ void ScDocument::ImplDeleteOptions() +/*N*/ { +/*N*/ delete pDocOptions; +/*N*/ delete pViewOptions; +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ SfxPrinter* ScDocument::GetPrinter() +/*N*/ { +/*N*/ if ( !pPrinter ) +/*N*/ { +/*N*/ SfxItemSet* pSet = +/*N*/ new SfxItemSet( *xPoolHelper->GetDocPool(), +/*N*/ SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN, +/*N*/ SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC, +/*N*/ SID_SCPRINTOPTIONS, SID_SCPRINTOPTIONS, +/*N*/ NULL ); +/*N*/ +/*N*/ SfxMiscCfg* pOffCfg = SFX_APP()->GetMiscConfig(); +/*N*/ if ( pOffCfg ) +/*N*/ { +/*N*/ USHORT nFlags = 0; +/*N*/ if ( pOffCfg->IsPaperOrientationWarning() ) +/*N*/ nFlags |= SFX_PRINTER_CHG_ORIENTATION; +/*N*/ if ( pOffCfg->IsPaperSizeWarning() ) +/*N*/ nFlags |= SFX_PRINTER_CHG_SIZE; +/*N*/ pSet->Put( SfxFlagItem( SID_PRINTER_CHANGESTODOC, nFlags ) ); +/*N*/ pSet->Put( SfxBoolItem( SID_PRINTER_NOTFOUND_WARN, pOffCfg->IsNotFoundWarning() ) ); +/*N*/ } +/*N*/ +/*N*/ pPrinter = new SfxPrinter( pSet ); +/*N*/ UpdateDrawPrinter(); +/*N*/ pPrinter->SetDigitLanguage( SC_MOD()->GetOptDigitLanguage() ); +/*N*/ } +/*N*/ +/*N*/ return pPrinter; +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ void ScDocument::SetPrinter( SfxPrinter* pNewPrinter ) +/*N*/ { +/*N*/ if ( pNewPrinter == pPrinter ) +/*N*/ { +/*N*/ // #i6706# SetPrinter is called with the same printer again if +/*N*/ // the JobSetup has changed. In that case just call UpdateDrawPrinter +/*N*/ // (SetRefDevice for drawing layer) because of changed text sizes. +/*N*/ UpdateDrawPrinter(); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ SfxPrinter* pOld = pPrinter; +/*N*/ pPrinter = pNewPrinter; +/*N*/ UpdateDrawPrinter(); +/*N*/ pPrinter->SetDigitLanguage( SC_MOD()->GetOptDigitLanguage() ); +/*N*/ delete pOld; +/*N*/ } +/*N*/ InvalidateTextWidth(); // in both cases +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ void ScDocument::SetPrintOptions() +/*N*/ { +/*N*/ if ( !pPrinter ) GetPrinter(); // setzt pPrinter +/*N*/ DBG_ASSERT( pPrinter, "Error in printer creation :-/" ); +/*N*/ +/*N*/ if ( pPrinter ) +/*N*/ { +/*N*/ SfxMiscCfg* pOffCfg = SFX_APP()->GetMiscConfig(); +/*N*/ if ( pOffCfg ) +/*N*/ { +/*N*/ SfxItemSet aOptSet( pPrinter->GetOptions() ); +/*N*/ +/*N*/ USHORT nFlags = 0; +/*N*/ if ( pOffCfg->IsPaperOrientationWarning() ) +/*N*/ nFlags |= SFX_PRINTER_CHG_ORIENTATION; +/*N*/ if ( pOffCfg->IsPaperSizeWarning() ) +/*N*/ nFlags |= SFX_PRINTER_CHG_SIZE; +/*N*/ aOptSet.Put( SfxFlagItem( SID_PRINTER_CHANGESTODOC, nFlags ) ); +/*N*/ aOptSet.Put( SfxBoolItem( SID_PRINTER_NOTFOUND_WARN, pOffCfg->IsNotFoundWarning() ) ); +/*N*/ +/*N*/ pPrinter->SetOptions( aOptSet ); +/*N*/ } +/*N*/ } +/*N*/ } + +//------------------------------------------------------------------------ + + +//------------------------------------------------------------------------ + + +//------------------------------------------------------------------------ + + +//------------------------------------------------------------------------ + + +//------------------------------------------------------------------------ + + +//------------------------------------------------------------------------ + +/*N*/ BOOL ScDocument::RemovePageStyleInUse( const String& rStyle ) +/*N*/ { +/*N*/ BOOL bWasInUse = FALSE; +/*N*/ const USHORT nCount = GetTableCount(); +/*N*/ +/*N*/ for ( USHORT i=0; i<nCount && pTab[i]; i++ ) +/*N*/ if ( pTab[i]->GetPageStyle() == rStyle ) +/*N*/ { +/*N*/ bWasInUse = TRUE; +/*N*/ pTab[i]->SetPageStyle( ScGlobal::GetRscString(STR_STYLENAME_STANDARD) ); +/*N*/ } +/*N*/ +/*N*/ return bWasInUse; +/*N*/ } + + +//------------------------------------------------------------------------ + +/*M*/ BYTE ScDocument::GetEditTextDirection(USHORT nTab) const +/*M*/ { +/*M*/ EEHorizontalTextDirection eRet = EE_HTEXTDIR_DEFAULT; +/*M*/ +/*M*/ String aStyleName = GetPageStyle( nTab ); +/*M*/ SfxStyleSheetBase* pStyle = xPoolHelper->GetStylePool()->Find( aStyleName, SFX_STYLE_FAMILY_PAGE ); +/*M*/ if ( pStyle ) +/*M*/ { +/*M*/ SfxItemSet& rStyleSet = pStyle->GetItemSet(); +/*M*/ SvxFrameDirection eDirection = (SvxFrameDirection) +/*M*/ ((const SvxFrameDirectionItem&)rStyleSet.Get( ATTR_WRITINGDIR )).GetValue(); +/*M*/ +/*M*/ if ( eDirection == FRMDIR_HORI_LEFT_TOP ) +/*M*/ eRet = EE_HTEXTDIR_L2R; +/*M*/ else if ( eDirection == FRMDIR_HORI_RIGHT_TOP ) +/*M*/ eRet = EE_HTEXTDIR_R2L; +/*M*/ // else (invalid for EditEngine): keep "default" +/*M*/ } +/*M*/ +/*M*/ return eRet; +/*M*/ } + +//------------------------------------------------------------------------ + +/*N*/ void ScDocument::InvalidateTextWidth( const ScAddress* pAdrFrom, +/*N*/ const ScAddress* pAdrTo, +/*N*/ BOOL bBroadcast ) +/*N*/ { +/*N*/ bBroadcast = (bBroadcast && GetDocOptions().IsCalcAsShown() && !IsImportingXML()); +/*N*/ if ( pAdrFrom && !pAdrTo ) +/*N*/ { +/*?*/ const USHORT nTab = pAdrFrom->Tab(); +/*?*/ +/*?*/ if ( pTab[nTab] ) +/*?*/ pTab[nTab]->InvalidateTextWidth( pAdrFrom, NULL, bBroadcast ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ const USHORT nTabStart = pAdrFrom ? pAdrFrom->Tab() : 0; +/*N*/ const USHORT nTabEnd = pAdrTo ? pAdrTo->Tab() : MAXTAB; +/*N*/ +/*N*/ for ( USHORT nTab=nTabStart; nTab<=nTabEnd; nTab++ ) +/*N*/ if ( pTab[nTab] ) +/*N*/ pTab[nTab]->InvalidateTextWidth( pAdrFrom, pAdrTo, bBroadcast ); +/*N*/ } +/*N*/ } + +//------------------------------------------------------------------------ + +#define CALCMAX 1000 // Berechnungen +#define ABORT_EVENTS (INPUT_ANY & ~INPUT_TIMER & ~INPUT_OTHER) + +//------------------------------------------------------------------------ + + +// SPELL_MAXCELLS muss mindestens 256 sein, solange am Iterator keine +// Start-Spalte gesetzt werden kann + +//! SPELL_MAXTEST fuer Timer und Idle unterschiedlich ??? + +// SPELL_MAXTEST now divided between visible and rest of document + +#define SPELL_MAXTEST_VIS 1 +#define SPELL_MAXTEST_ALL 3 +#define SPELL_MAXCELLS 256 + +//------------------------------------------------------------------------ + +/*N*/ void ScDocument::SaveDdeLinks(SvStream& rStream) const +/*N*/ { +/*N*/ // bei 4.0-Export alle mit Modus != DEFAULT weglassen +/*N*/ BOOL bExport40 = ( rStream.GetVersion() <= SOFFICE_FILEFORMAT_40 ); +/*N*/ +/*N*/ const ::binfilter::SvBaseLinks& rLinks = pLinkManager->GetLinks(); +/*N*/ USHORT nCount = rLinks.Count(); +/*N*/ +/*N*/ // erstmal zaehlen... +/*N*/ +/*N*/ USHORT nDdeCount = 0; +/*N*/ USHORT i; +/*N*/ for (i=0; i<nCount; i++) +/*N*/ { +/*N*/ ::binfilter::SvBaseLink* pBase = *rLinks[i]; +/*N*/ if (pBase->ISA(ScDdeLink)) +/*?*/ if ( !bExport40 || ((ScDdeLink*)pBase)->GetMode() == SC_DDE_DEFAULT ) +/*?*/ ++nDdeCount; +/*N*/ } +/*N*/ +/*N*/ // Header +/*N*/ +/*N*/ ScMultipleWriteHeader aHdr( rStream ); +/*N*/ rStream << nDdeCount; +/*N*/ +/*N*/ // Links speichern +/*N*/ +/*N*/ for (i=0; i<nCount; i++) +/*N*/ { +/*N*/ ::binfilter::SvBaseLink* pBase = *rLinks[i]; +/*N*/ if (pBase->ISA(ScDdeLink)) +/*N*/ { +/*?*/ ScDdeLink* pLink = (ScDdeLink*)pBase; +/*?*/ if ( !bExport40 || pLink->GetMode() == SC_DDE_DEFAULT ) +/*?*/ pLink->Store( rStream, aHdr ); +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ void ScDocument::LoadDdeLinks(SvStream& rStream) +/*N*/ { +/*N*/ ScMultipleReadHeader aHdr( rStream ); +/*N*/ +/*N*/ USHORT nCount; +/*N*/ rStream >> nCount; +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ { +/*?*/ ScDdeLink* pLink = new ScDdeLink( this, rStream, aHdr ); +/*?*/ pLinkManager->InsertDDELink( pLink, +/*?*/ pLink->GetAppl(), pLink->GetTopic(), pLink->GetItem() ); +/*N*/ } +/*N*/ } + +/*N*/ void ScDocument::SetInLinkUpdate(BOOL bSet) +/*N*/ { +/*N*/ // called from TableLink and AreaLink +/*N*/ +/*N*/ DBG_ASSERT( bInLinkUpdate != bSet, "SetInLinkUpdate twice" ); +/*N*/ bInLinkUpdate = bSet; +/*N*/ } + + +/*N*/ BOOL ScDocument::UpdateDdeLink( const String& rAppl, const String& rTopic, const String& rItem ) +/*N*/ { +/*N*/ // fuer refresh() per StarOne Api +/*N*/ // ResetValue() fuer einzelnen Link nicht noetig +/*N*/ //! wenn's mal alles asynchron wird, aber auch hier +/*N*/ +/*N*/ BOOL bFound = FALSE; +/*N*/ if (pLinkManager) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 const ::binfilter::SvBaseLinks& rLinks = pLinkManager->GetLinks(); +/*N*/ } +/*N*/ return bFound; +/*N*/ } + + + +/*N*/ USHORT ScDocument::GetDdeLinkCount() const +/*N*/ { +/*N*/ USHORT nDdeCount = 0; +/*N*/ if (pLinkManager) +/*N*/ { +/*N*/ const ::binfilter::SvBaseLinks& rLinks = pLinkManager->GetLinks(); +/*N*/ USHORT nCount = rLinks.Count(); +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ if ((*rLinks[i])->ISA(ScDdeLink)) +/*N*/ ++nDdeCount; +/*N*/ } +/*N*/ return nDdeCount; +/*N*/ } + +/*N*/ BOOL ScDocument::GetDdeLinkData( USHORT nPos, String& rAppl, String& rTopic, String& rItem ) const +/*N*/ { +/*N*/ USHORT nDdeCount = 0; +/*N*/ if (pLinkManager) +/*N*/ { +/*N*/ const ::binfilter::SvBaseLinks& rLinks = pLinkManager->GetLinks(); +/*N*/ USHORT nCount = rLinks.Count(); +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ { +/*N*/ ::binfilter::SvBaseLink* pBase = *rLinks[i]; +/*N*/ if (pBase->ISA(ScDdeLink)) +/*N*/ { +/*N*/ if ( nDdeCount == nPos ) +/*N*/ { +/*N*/ ScDdeLink* pDde = (ScDdeLink*)pBase; +/*N*/ rAppl = pDde->GetAppl(); +/*N*/ rTopic = pDde->GetTopic(); +/*N*/ rItem = pDde->GetItem(); +/*N*/ return TRUE; +/*N*/ } +/*N*/ ++nDdeCount; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ return FALSE; +/*N*/ } + +/*N*/ BOOL ScDocument::GetDdeLinkMode(USHORT nPos, USHORT& nMode) +/*N*/ { +/*N*/ USHORT nDdeCount = 0; +/*N*/ if (pLinkManager) +/*N*/ { +/*N*/ const ::binfilter::SvBaseLinks& rLinks = pLinkManager->GetLinks(); +/*N*/ USHORT nCount = rLinks.Count(); +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ { +/*N*/ ::binfilter::SvBaseLink* pBase = *rLinks[i]; +/*N*/ if (pBase->ISA(ScDdeLink)) +/*N*/ { +/*N*/ if ( nDdeCount == nPos ) +/*N*/ { +/*N*/ ScDdeLink* pDde = (ScDdeLink*)pBase; +/*N*/ nMode = pDde->GetMode(); +/*N*/ return TRUE; +/*N*/ } +/*N*/ ++nDdeCount; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ return FALSE; +/*N*/ } + +/*N*/ BOOL ScDocument::GetDdeLinkResultDimension( USHORT nPos, USHORT& nCol, USHORT& nRow, ScMatrix*& pMatrix) +/*N*/ { +/*N*/ USHORT nDdeCount = 0; +/*N*/ if (pLinkManager) +/*N*/ { +/*N*/ const ::binfilter::SvBaseLinks& rLinks = pLinkManager->GetLinks(); +/*N*/ USHORT nCount = rLinks.Count(); +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ { +/*N*/ ::binfilter::SvBaseLink* pBase = *rLinks[i]; +/*N*/ if (pBase->ISA(ScDdeLink)) +/*N*/ { +/*N*/ if ( nDdeCount == nPos ) +/*N*/ { +/*N*/ ScDdeLink* pDde = (ScDdeLink*)pBase; +/*N*/ pMatrix = pDde->GetResult(); +/*N*/ if (pMatrix) +/*N*/ { +/*N*/ pMatrix->GetDimensions(nCol, nRow); +/*N*/ return TRUE; +/*N*/ } +/*N*/ } +/*N*/ ++nDdeCount; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ return FALSE; +/*N*/ } + +/*N*/ BOOL ScDocument::GetDdeLinkResult(const ScMatrix* pMatrix, USHORT nCol, USHORT nRow, String& rStrValue, double& rDoubValue, BOOL& bIsString) +/*N*/ { +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 if (pMatrix) +/*N*/ return TRUE; +/*N*/ } + +/*N*/ void ScDocument::CreateDdeLink(const String& rAppl, const String& rTopic, const String& rItem, const BYTE nMode ) +/*N*/ { + // DDE-Link anlegen und nicht updaten (z.B. fuer Excel-Import, +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 //STRIP001 // damit nicht ohne Nachfrage Verbindungen aufgebaut werden) +/*N*/ } + +/*N*/ BOOL ScDocument::FindDdeLink(const String& rAppl, const String& rTopic, const String& rItem, const BYTE nMode, USHORT& nPos ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 if (pLinkManager) +/*N*/ return FALSE; +/*N*/ } + +/*N*/ BOOL ScDocument::CreateDdeLinkResultDimension(USHORT nPos, USHORT nCols, USHORT nRows, ScMatrix*& pMatrix) +/*N*/ { +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 USHORT nDdeCount = 0; +/*N*/ return FALSE; +/*N*/ } + +void ScDocument::SetDdeLinkResult(ScMatrix* pMatrix, const USHORT nCol, const USHORT nRow, const String& rStrValue, const double& rDoubValue, BOOL bString, BOOL bEmpty) +{ +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 DBG_ASSERT(pMatrix, "there is no matrix"); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ void ScDocument::UpdateRefAreaLinks( UpdateRefMode eUpdateRefMode, +/*N*/ const ScRange& rRange, short nDx, short nDy, short nDz ) +/*N*/ { +/*N*/ if (pLinkManager) +/*N*/ { +/*N*/ const ::binfilter::SvBaseLinks& rLinks = pLinkManager->GetLinks(); +/*N*/ USHORT nCount = rLinks.Count(); +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ { +/*?*/ ::binfilter::SvBaseLink* pBase = *rLinks[i]; +/*?*/ if (pBase->ISA(ScAreaLink)) +/*?*/ { +/*?*/ ScAreaLink* pLink = (ScAreaLink*) pBase; +/*?*/ ScRange aOutRange = pLink->GetDestArea(); +/*?*/ +/*?*/ USHORT nCol1 = aOutRange.aStart.Col(); +/*?*/ USHORT nRow1 = aOutRange.aStart.Row(); +/*?*/ USHORT nTab1 = aOutRange.aStart.Tab(); +/*?*/ USHORT nCol2 = aOutRange.aEnd.Col(); +/*?*/ USHORT nRow2 = aOutRange.aEnd.Row(); +/*?*/ USHORT nTab2 = aOutRange.aEnd.Tab(); +/*?*/ +/*?*/ ScRefUpdateRes eRes = +/*?*/ ScRefUpdate::Update( this, eUpdateRefMode, +/*?*/ rRange.aStart.Col(), rRange.aStart.Row(), rRange.aStart.Tab(), +/*?*/ rRange.aEnd.Col(), rRange.aEnd.Row(), rRange.aEnd.Tab(), nDx, nDy, nDz, +/*?*/ nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 ); +/*?*/ if ( eRes != UR_NOTHING ) +/*?*/ pLink->SetDestArea( ScRange( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 ) ); +/*?*/ } +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ void ScDocument::SaveAreaLinks(SvStream& rStream) const +/*N*/ { +/*N*/ const ::binfilter::SvBaseLinks& rLinks = pLinkManager->GetLinks(); +/*N*/ USHORT nCount = rLinks.Count(); +/*N*/ +/*N*/ // erstmal zaehlen... +/*N*/ +/*N*/ USHORT nAreaCount = 0; +/*N*/ USHORT i; +/*N*/ for (i=0; i<nCount; i++) +/*N*/ if ((*rLinks[i])->ISA(ScAreaLink)) // rLinks[i] = Pointer auf Ref +/*N*/ ++nAreaCount; +/*N*/ +/*N*/ // Header +/*N*/ +/*N*/ ScMultipleWriteHeader aHdr( rStream ); +/*N*/ rStream << nAreaCount; +/*N*/ +/*N*/ // Links speichern +/*N*/ +/*N*/ for (i=0; i<nCount; i++) +/*N*/ { +/*N*/ ::binfilter::SvBaseLink* pBase = *rLinks[i]; +/*N*/ if (pBase->ISA(ScAreaLink)) +/*N*/ { +/*?*/ ScAreaLink* pLink = (ScAreaLink*)pBase; +/*?*/ +/*?*/ aHdr.StartEntry(); +/*?*/ +/*?*/ rStream.WriteByteString( pLink->GetFile(), rStream.GetStreamCharSet() ); +/*?*/ rStream.WriteByteString( pLink->GetFilter(), rStream.GetStreamCharSet() ); +/*?*/ rStream.WriteByteString( pLink->GetSource(), rStream.GetStreamCharSet() ); +/*?*/ rStream << pLink->GetDestArea(); // ScRange +/*?*/ rStream.WriteByteString( pLink->GetOptions(), rStream.GetStreamCharSet() ); +/*?*/ // filter options starting from 336 +/*?*/ +/*?*/ aHdr.EndEntry(); +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ void ScDocument::LoadAreaLinks(SvStream& rStream) +/*N*/ { +/*N*/ ScMultipleReadHeader aHdr( rStream ); +/*N*/ +/*N*/ if (!pShell) +/*N*/ { +/*N*/ DBG_ERROR("AreaLinks koennen nicht ohne Shell geladen werden"); +/*N*/ return; +/*N*/ } +/*N*/ +/*N*/ String aFile, aFilter, aOptions, aSource; +/*N*/ ScRange aDestArea; +/*N*/ +/*N*/ USHORT nCount; +/*N*/ rStream >> nCount; +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 aHdr.StartEntry(); +/*?*/ +/*N*/ } +/*N*/ } + + +//------------------------------------------------------------------------ + +// TimerDelays etc. + +// ---------------------------------------------------------------------------- + +/*N*/ BOOL ScDocument::CheckMacroWarn() +/*N*/ { +/*N*/ // The check for macro configuration, macro warning and disabling is now handled +/*N*/ // in SfxObjectShell::AdjustMacroMode, called by SfxObjectShell::CallBasic. +/*N*/ +/*N*/ return TRUE; +/*N*/ } + + + +//------------------------------------------------------------------------ + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_documen9.cxx b/binfilter/bf_sc/source/core/data/sc_documen9.cxx new file mode 100644 index 000000000000..0a2bdfffaf95 --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_documen9.cxx @@ -0,0 +1,531 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "scitems.hxx" +#include <bf_svx/eeitem.hxx> +#define ITEMID_FIELD EE_FEATURE_FIELD + +#include <bf_svx/fontitem.hxx> +#include <bf_svx/forbiddencharacterstable.hxx> +#include <bf_svx/langitem.hxx> +#include <bf_svx/svditer.hxx> +#include <bf_svx/svdocapt.hxx> +#include <bf_svx/svdoole2.hxx> +#include <bf_svx/svdouno.hxx> +#include <bf_svx/svdpage.hxx> +#include <bf_svx/xtable.hxx> +#include <bf_sfx2/objsh.hxx> +#include <bf_sfx2/printer.hxx> +#include <bf_svtools/saveopt.hxx> +#include <bf_svtools/pathoptions.hxx> +#include <bf_sch/schdll.hxx> +#include <bf_sch/schdll0.hxx> + +#include "document.hxx" +#include "docoptio.hxx" +#include "drwlayer.hxx" +#include "userdat.hxx" +#include "patattr.hxx" +#include "rechead.hxx" +#include "poolhelp.hxx" +#include "docpool.hxx" +#include "detfunc.hxx" // for UpdateAllComments +#include "editutil.hxx" +namespace binfilter { + + +// ----------------------------------------------------------------------- + +/*N*/ XColorTable* ScDocument::GetColorTable() +/*N*/ { +/*N*/ if (pDrawLayer) +/*N*/ return pDrawLayer->GetColorTable(); +/*N*/ else +/*N*/ { +/*N*/ if (!pColorTable) +/*N*/ { +/*N*/ SvtPathOptions aPathOpt; +/*N*/ pColorTable = new XColorTable( aPathOpt.GetPalettePath() ); +/*N*/ } +/*N*/ +/*N*/ return pColorTable; +/*N*/ } +/*N*/ } + +/*N*/ void ScDocument::TransferDrawPage(ScDocument* pSrcDoc, USHORT nSrcPos, USHORT nDestPos) +/*N*/ { +/*N*/ if (pDrawLayer && pSrcDoc->pDrawLayer) +/*N*/ { +/*?*/ SdrPage* pOldPage = pSrcDoc->pDrawLayer->GetPage(nSrcPos); +/*?*/ SdrPage* pNewPage = pDrawLayer->GetPage(nDestPos); +/*?*/ +/*?*/ if (pOldPage && pNewPage) +/*?*/ { +/*?*/ SdrObjListIter aIter( *pOldPage, IM_FLAT ); +/*?*/ SdrObject* pOldObject = aIter.Next(); +/*?*/ while (pOldObject) +/*?*/ {DBG_BF_ASSERT(0, "STRIP"); //STRIP001 +/*?*/ } +/*?*/ } +/*N*/ } +/*N*/ } + + +/*N*/ void ScDocument::InitDrawLayer( SfxObjectShell* pDocShell ) +/*N*/ { +/*N*/ if (pDocShell && !pShell) +/*N*/ pShell = pDocShell; +/*N*/ +/*N*/ // DBG_ASSERT(pShell,"InitDrawLayer ohne Shell"); +/*N*/ +/*N*/ if (!pDrawLayer) +/*N*/ { +/*N*/ String aName; +/*N*/ if ( pShell && !pShell->IsLoading() ) // #88438# don't call GetTitle while loading +/*N*/ aName = pShell->GetTitle(); +/*N*/ pDrawLayer = new ScDrawLayer( this, aName ); +/*N*/ if (pLinkManager) +/*N*/ pDrawLayer->SetLinkManager( pLinkManager ); +/*N*/ +/*N*/ // Drawing pages are accessed by table number, so they must also be present +/*N*/ // for preceding table numbers, even if the tables aren't allocated +/*N*/ // (important for clipboard documents). +/*N*/ +/*N*/ USHORT nDrawPages = 0; +/*N*/ USHORT nTab; +/*N*/ for (nTab=0; nTab<=MAXTAB; nTab++) +/*N*/ if (pTab[nTab]) +/*N*/ nDrawPages = nTab + 1; // needed number of pages +/*N*/ +/*N*/ for (nTab=0; nTab<nDrawPages; nTab++) +/*N*/ { +/*N*/ pDrawLayer->ScAddPage( nTab ); // always add page, with or without the table +/*N*/ if (pTab[nTab]) +/*N*/ { +/*N*/ String aName; +/*N*/ pTab[nTab]->GetName(aName); +/*N*/ pDrawLayer->ScRenamePage( nTab, aName ); +/*N*/ +/*N*/ pTab[nTab]->SetDrawPageSize(); // #54782# sofort die richtige Groesse +/*N*/ #if 0 +/*N*/ ULONG nx = (ULONG) ((double) (MAXCOL+1) * STD_COL_WIDTH * HMM_PER_TWIPS ); +/*N*/ ULONG ny = (ULONG) ((double) (MAXROW+1) * ScGlobal::nStdRowHeight * HMM_PER_TWIPS ); +/*N*/ pDrawLayer->SetPageSize( nTab, Size( nx, ny ) ); +/*N*/ #endif +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ pDrawLayer->SetDefaultTabulator( GetDocOptions().GetTabDistance() ); +/*N*/ +/*N*/ UpdateDrawPrinter(); +/*N*/ UpdateDrawLanguages(); +/*N*/ if (bImportingXML) +/*?*/ pDrawLayer->EnableAdjust(FALSE); +/*N*/ +/*N*/ pDrawLayer->SetForbiddenCharsTable( xForbiddenCharacters ); +/*N*/ pDrawLayer->SetCharCompressType( GetAsianCompression() ); +/*N*/ pDrawLayer->SetKernAsianPunctuation( GetAsianKerning() ); +/*N*/ } +/*N*/ } + +/*N*/ void ScDocument::UpdateDrawLanguages() +/*N*/ { +/*N*/ if (pDrawLayer) +/*N*/ { +/*N*/ SfxItemPool& rDrawPool = pDrawLayer->GetItemPool(); +/*N*/ rDrawPool.SetPoolDefaultItem( SvxLanguageItem( eLanguage, EE_CHAR_LANGUAGE ) ); +/*N*/ rDrawPool.SetPoolDefaultItem( SvxLanguageItem( eCjkLanguage, EE_CHAR_LANGUAGE_CJK ) ); +/*N*/ rDrawPool.SetPoolDefaultItem( SvxLanguageItem( eCtlLanguage, EE_CHAR_LANGUAGE_CTL ) ); +/*N*/ } +/*N*/ } + +/*N*/ void ScDocument::UpdateDrawPrinter() +/*N*/ { +/*N*/ if (pDrawLayer) +/*N*/ { +/*N*/ // use the printer even if IsValid is false +/*N*/ // Application::GetDefaultDevice causes trouble with changing MapModes +/*N*/ +/*N*/ OutputDevice* pRefDev = GetPrinter(); +/*N*/ pRefDev->SetMapMode( MAP_100TH_MM ); +/*N*/ pDrawLayer->SetRefDevice(pRefDev); +/*N*/ } +/*N*/ } + +/*N*/ BOOL ScDocument::IsChart( SdrObject* pObject ) +/*N*/ { +/*N*/ if ( pObject->GetObjIdentifier() == OBJ_OLE2 ) +/*N*/ { +/*N*/ SvInPlaceObjectRef aIPObj = ((SdrOle2Obj*)pObject)->GetObjRef(); +/*N*/ if (aIPObj.Is()) +/*N*/ { +/*N*/ SvGlobalName aObjClsId = *aIPObj->GetSvFactory(); +/*N*/ if (SchModuleDummy::HasID( aObjClsId )) +/*N*/ return TRUE; +/*N*/ } +/*N*/ } +/*N*/ return FALSE; +/*N*/ } + +/*N*/ IMPL_LINK_INLINE_START( ScDocument, GetUserDefinedColor, USHORT *, pColorIndex ) +/*N*/ { +/*N*/ return (long) &((GetColorTable()->Get(*pColorIndex))->GetColor()); +/*N*/ } +/*N*/ IMPL_LINK_INLINE_END( ScDocument, GetUserDefinedColor, USHORT *, pColorIndex ) + +/*N*/ void ScDocument::DeleteDrawLayer() +/*N*/ { +/*N*/ delete pDrawLayer; +/*N*/ } + +/*N*/ void ScDocument::DeleteColorTable() +/*N*/ { +/*N*/ delete pColorTable; +/*N*/ } + +/*N*/ void ScDocument::LoadDrawLayer(SvStream& rStream) +/*N*/ { +/*N*/ InitDrawLayer(); // anlegen +/*N*/ pDrawLayer->Load(rStream); +/*N*/ +/*N*/ // nMaxTableNumber ist noch nicht initialisiert +/*N*/ +/*N*/ USHORT nTableCount = 0; +/*N*/ while ( nTableCount <= MAXTAB && pTab[nTableCount] ) +/*N*/ ++nTableCount; +/*N*/ +/*N*/ USHORT nPageCount = pDrawLayer->GetPageCount(); +/*N*/ if ( nPageCount > nTableCount && nTableCount != 0 ) +/*N*/ { +/*?*/ // Manchmal sind beim Kopieren/Verschieben/Undo von Tabellen zuviele +/*?*/ // (leere) Pages in der Tabelle stehengeblieben. Weg damit! +/*?*/ +/*?*/ DBG_ERROR("zuviele Draw-Pages in der Datei"); +/*?*/ +/*?*/ for (USHORT i=nTableCount; i<nPageCount; i++) +/*?*/ pDrawLayer->DeletePage(nTableCount); +/*N*/ } +/*N*/ +/*N*/ // Controls auf richtigen Layer setzen +/*N*/ // (zumindest in Dateien aus der 502 koennen sie falsch sein, +/*N*/ // wegen des fehlenden Layers in alten Dateien) +/*N*/ +/*N*/ nPageCount = pDrawLayer->GetPageCount(); +/*N*/ for (USHORT i=0; i<nPageCount; i++) +/*N*/ { +/*N*/ SdrPage* pPage = pDrawLayer->GetPage(i); +/*N*/ SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS ); +/*N*/ SdrObject* pObject = aIter.Next(); +/*N*/ while (pObject) +/*N*/ { +/*N*/ if ( pObject->ISA(SdrUnoObj) && pObject->GetLayer() != SC_LAYER_CONTROLS ) +/*N*/ { +/*?*/ pObject->NbcSetLayer(SC_LAYER_CONTROLS); +/*?*/ DBG_ERROR("Control war auf falschem Layer"); +/*N*/ } +/*N*/ pObject = aIter.Next(); +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ void ScDocument::StoreDrawLayer(SvStream& rStream) const +/*N*/ { +/*N*/ if (pDrawLayer) +/*N*/ { +/*N*/ // SetSavePortable wird mit VCL nicht mehr gebraucht +/*N*/ //BOOL bIndep = SFX_APP()->GetOptions().IsIndepGrfFmt(); +/*N*/ //pDrawLayer->SetSavePortable( bIndep ); +/*N*/ +/*N*/ pDrawLayer->SetSaveCompressed( FALSE ); +/*N*/ pDrawLayer->SetSaveNative( FALSE ); +/*N*/ +/*N*/ pDrawLayer->GetItemPool().SetFileFormatVersion( (USHORT)rStream.GetVersion() ); +/*N*/ pDrawLayer->Store(rStream); +/*N*/ } +/*N*/ } + +/*N*/ BOOL ScDocument::DrawGetPrintArea( ScRange& rRange, BOOL bSetHor, BOOL bSetVer ) const +/*N*/ { +/*N*/ return pDrawLayer->GetPrintArea( rRange, bSetHor, bSetVer ); +/*N*/ } + + + + + + + + + + +/*N*/ BOOL ScDocument::HasNoteObject( USHORT nCol, USHORT nRow, USHORT nTab ) const +/*N*/ { +/*N*/ if (!pDrawLayer) +/*N*/ return FALSE; +/*N*/ SdrPage* pPage = pDrawLayer->GetPage(nTab); +/*N*/ DBG_ASSERT(pPage,"Page ?"); +/*N*/ if (!pPage) +/*N*/ return FALSE; +/*N*/ +/*N*/ BOOL bFound = FALSE; +/*N*/ +/*N*/ SdrObjListIter aIter( *pPage, IM_FLAT ); +/*N*/ SdrObject* pObject = aIter.Next(); +/*N*/ while (pObject && !bFound) +/*N*/ { +/*N*/ if ( pObject->GetLayer() == SC_LAYER_INTERN && pObject->ISA( SdrCaptionObj ) ) +/*N*/ { +/*N*/ ScDrawObjData* pData = ScDrawLayer::GetObjData( pObject ); +/*N*/ if ( pData && nCol == pData->aStt.nCol && nRow == pData->aStt.nRow ) +/*N*/ bFound = TRUE; +/*N*/ } +/*N*/ pObject = aIter.Next(); +/*N*/ } +/*N*/ +/*N*/ return bFound; +/*N*/ } + +/*N*/ void ScDocument::RefreshNoteFlags() +/*N*/ { +/*N*/ if (!pDrawLayer) +/*N*/ return; +/*N*/ +/*N*/ BOOL bAnyIntObj = FALSE; +/*N*/ USHORT nTab; +/*N*/ ScPostIt aNote; +/*N*/ for (nTab=0; nTab<=MAXTAB && pTab[nTab]; nTab++) +/*N*/ { +/*N*/ SdrPage* pPage = pDrawLayer->GetPage(nTab); +/*N*/ DBG_ASSERT(pPage,"Page ?"); +/*N*/ if (pPage) +/*N*/ { +/*N*/ SdrObjListIter aIter( *pPage, IM_FLAT ); +/*N*/ SdrObject* pObject = aIter.Next(); +/*N*/ while (pObject) +/*N*/ { +/*N*/ if ( pObject->GetLayer() == SC_LAYER_INTERN ) +/*N*/ { +/*?*/ bAnyIntObj = TRUE; // for all internal objects, including detective +/*?*/ +/*?*/ if ( pObject->ISA( SdrCaptionObj ) ) +/*?*/ { +/*?*/ ScDrawObjData* pData = ScDrawLayer::GetObjData( pObject ); +/*?*/ if ( pData ) +/*?*/ { +/*?*/ if ( GetNote( pData->aStt.nCol, pData->aStt.nRow, nTab, aNote ) ) +/*?*/ if ( !aNote.IsShown() ) +/*?*/ { +/*?*/ aNote.SetShown(TRUE); +/*?*/ SetNote( pData->aStt.nCol, pData->aStt.nRow, nTab, aNote ); +/*?*/ } +/*?*/ } +/*?*/ } +/*N*/ } +/*N*/ pObject = aIter.Next(); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if (bAnyIntObj) +/*N*/ { +/*?*/ // update attributes for all note objects and the colors of detective objects +/*?*/ // (we don't know with which settings the file was created) +/*?*/ +/*N*/ ScDetectiveFunc aFunc( this, 0 ); // detective.sdc +/*N*/ /*?*/ aFunc.UpdateAllComments(); +/*N*/ /*?*/ aFunc.UpdateAllArrowColors(); +/*N*/ } +/*N*/ } + +/*N*/ BOOL ScDocument::IsPrintEmpty( USHORT nTab, USHORT nStartCol, USHORT nStartRow, +/*N*/ USHORT nEndCol, USHORT nEndRow, BOOL bLeftIsEmpty, +/*N*/ ScRange* pLastRange, Rectangle* pLastMM ) const +/*N*/ { + DBG_BF_ASSERT(0, "STRIP"); //STRIP001 if (!IsBlockEmpty( nTab, nStartCol, nStartRow, nEndCol, nEndRow )) +/*N*/ return TRUE; +/*N*/ } + +/*N*/ void ScDocument::Clear() +/*N*/ { +/*N*/ for (USHORT i=0; i<=MAXTAB; i++) +/*N*/ if (pTab[i]) +/*N*/ { +/*N*/ delete pTab[i]; +/*N*/ pTab[i]=NULL; +/*N*/ } +/*N*/ delete pSelectionAttr; +/*N*/ pSelectionAttr = NULL; +/*N*/ +/*N*/ if (pDrawLayer) +/*N*/ pDrawLayer->Clear(); +/*N*/ } + +/*N*/ BOOL ScDocument::HasDetectiveObjects(USHORT nTab) const +/*N*/ { +/*N*/ // looks for detective objects, annotations don't count +/*N*/ // (used to adjust scale so detective objects hit their cells better) +/*N*/ +/*N*/ BOOL bFound = FALSE; +/*N*/ +/*N*/ if (pDrawLayer) +/*N*/ { +/*N*/ SdrPage* pPage = pDrawLayer->GetPage(nTab); +/*N*/ DBG_ASSERT(pPage,"Page ?"); +/*N*/ if (pPage) +/*N*/ { +/*N*/ SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS ); +/*N*/ SdrObject* pObject = aIter.Next(); +/*N*/ while (pObject && !bFound) +/*N*/ { +/*N*/ // anything on the internal layer except captions (annotations) +/*N*/ if ( pObject->GetLayer() == SC_LAYER_INTERN && !pObject->ISA( SdrCaptionObj ) ) +/*N*/ bFound = TRUE; +/*N*/ +/*N*/ pObject = aIter.Next(); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ return bFound; +/*N*/ } + +/*N*/ void ScDocument::UpdateFontCharSet() +/*N*/ { +/*N*/ // In alten Versionen (bis incl. 4.0 ohne SP) wurden beim Austausch zwischen +/*N*/ // Systemen die CharSets in den Font-Attributen nicht angepasst. +/*N*/ // Das muss fuer Dokumente bis incl SP2 nun nachgeholt werden: +/*N*/ // Alles, was nicht SYMBOL ist, wird auf den System-CharSet umgesetzt. +/*N*/ // Bei neuen Dokumenten (Version SC_FONTCHARSET) sollte der CharSet stimmen. +/*N*/ +/*N*/ BOOL bUpdateOld = ( nSrcVer < SC_FONTCHARSET ); +/*N*/ +/*N*/ CharSet eSysSet = gsl_getSystemTextEncoding(); +/*N*/ if ( eSrcSet != eSysSet || bUpdateOld ) +/*N*/ { +/*N*/ USHORT nCount,i; +/*N*/ SvxFontItem* pItem; +/*N*/ +/*N*/ ScDocumentPool* pPool = xPoolHelper->GetDocPool(); +/*N*/ nCount = pPool->GetItemCount(ATTR_FONT); +/*N*/ for (i=0; i<nCount; i++) +/*N*/ { +/*N*/ pItem = (SvxFontItem*)pPool->GetItem(ATTR_FONT, i); +/*N*/ if ( pItem && ( pItem->GetCharSet() == eSrcSet || +/*N*/ ( bUpdateOld && pItem->GetCharSet() != RTL_TEXTENCODING_SYMBOL ) ) ) +/*N*/ pItem->GetCharSet() = eSysSet; +/*N*/ } +/*N*/ +/*N*/ if ( pDrawLayer ) +/*N*/ { +/*N*/ SfxItemPool& rDrawPool = pDrawLayer->GetItemPool(); +/*N*/ nCount = rDrawPool.GetItemCount(EE_CHAR_FONTINFO); +/*N*/ for (i=0; i<nCount; i++) +/*N*/ { +/*N*/ pItem = (SvxFontItem*)rDrawPool.GetItem(EE_CHAR_FONTINFO, i); +/*N*/ if ( pItem && ( pItem->GetCharSet() == eSrcSet || +/*N*/ ( bUpdateOld && pItem->GetCharSet() != RTL_TEXTENCODING_SYMBOL ) ) ) +/*?*/ pItem->GetCharSet() = eSysSet; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ void ScDocument::SetImportingXML( BOOL bVal ) +/*N*/ { +/*N*/ bImportingXML = bVal; +/*N*/ if (pDrawLayer) +/*N*/ pDrawLayer->EnableAdjust(!bImportingXML); +/*N*/ } + +/*N*/ rtl::Reference<SvxForbiddenCharactersTable> ScDocument::GetForbiddenCharacters() +/*N*/ { +/*N*/ return xForbiddenCharacters; +/*N*/ } + +/*N*/ void ScDocument::SetForbiddenCharacters( const rtl::Reference<SvxForbiddenCharactersTable> xNew ) +/*N*/ { +/*N*/ xForbiddenCharacters = xNew; +/*N*/ if ( pEditEngine ) +/*?*/ pEditEngine->SetForbiddenCharsTable( xForbiddenCharacters ); +/*N*/ if ( pDrawLayer ) +/*N*/ pDrawLayer->SetForbiddenCharsTable( xForbiddenCharacters ); +/*N*/ } + +/*N*/ BOOL ScDocument::IsValidAsianCompression() const +/*N*/ { +/*N*/ return ( nAsianCompression != SC_ASIANCOMPRESSION_INVALID ); +/*N*/ } + +/*N*/ BYTE ScDocument::GetAsianCompression() const +/*N*/ { +/*N*/ if ( nAsianCompression == SC_ASIANCOMPRESSION_INVALID ) +/*N*/ return 0; +/*N*/ else +/*N*/ return nAsianCompression; +/*N*/ } + +/*N*/ void ScDocument::SetAsianCompression(BYTE nNew) +/*N*/ { +/*N*/ nAsianCompression = nNew; +/*N*/ if ( pEditEngine ) +/*?*/ pEditEngine->SetAsianCompressionMode( nAsianCompression ); +/*N*/ if ( pDrawLayer ) +/*N*/ pDrawLayer->SetCharCompressType( nAsianCompression ); +/*N*/ } + +/*N*/ BOOL ScDocument::IsValidAsianKerning() const +/*N*/ { +/*N*/ return ( nAsianKerning != SC_ASIANKERNING_INVALID ); +/*N*/ } + +/*N*/ BOOL ScDocument::GetAsianKerning() const +/*N*/ { +/*N*/ if ( nAsianKerning == SC_ASIANKERNING_INVALID ) +/*N*/ return FALSE; +/*N*/ else +/*N*/ return (BOOL)nAsianKerning; +/*N*/ } + +/*N*/ void ScDocument::SetAsianKerning(BOOL bNew) +/*N*/ { +/*N*/ nAsianKerning = (BYTE)bNew; +/*N*/ if ( pEditEngine ) +/*?*/ pEditEngine->SetKernAsianPunctuation( (BOOL)nAsianKerning ); +/*N*/ if ( pDrawLayer ) +/*N*/ pDrawLayer->SetKernAsianPunctuation( (BOOL)nAsianKerning ); +/*N*/ } + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_document.cxx b/binfilter/bf_sc/source/core/data/sc_document.cxx new file mode 100644 index 000000000000..abed98c378de --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_document.cxx @@ -0,0 +1,3028 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#define _ZFORLIST_DECLARE_TABLE +#include "scitems.hxx" +#define ITEMID_FIELD EE_FEATURE_FIELD + +#include <bf_svx/boxitem.hxx> +#include <bf_svx/frmdiritem.hxx> +#include <bf_svx/editeng.hxx> +#include <bf_svtools/poolcach.hxx> +#include <bf_svtools/saveopt.hxx> +#include <bf_svtools/zforlist.hxx> +#include <tools/tenccvt.hxx> + +#include "attarray.hxx" +#include "patattr.hxx" +#include "rangenam.hxx" +#include "poolhelp.hxx" +#include "docpool.hxx" +#include "stlpool.hxx" +#include "globstr.hrc" +#include "rechead.hxx" +#include "dbcolect.hxx" +#include "pivot.hxx" +#include "chartlis.hxx" +#include "drwlayer.hxx" +#include "validat.hxx" +#include "prnsave.hxx" +#include "chgtrack.hxx" +#include "bf_sc.hrc" +#include "scresid.hxx" +#include "hints.hxx" +#include "detdata.hxx" +#include "cell.hxx" +#include "dpobject.hxx" +#include "indexmap.hxx" +#include "detfunc.hxx" // for UpdateAllComments +#include "scmod.hxx" +#include "dociter.hxx" +#include "progress.hxx" +#ifndef __SGI_STL_SET +#include <set> +#endif +namespace binfilter { + +/*N*/ struct ScDefaultAttr +/*N*/ { +/*N*/ const ScPatternAttr* pAttr; +/*N*/ USHORT nFirst; +/*N*/ USHORT nCount; +/*N*/ ScDefaultAttr(const ScPatternAttr* pPatAttr) : pAttr(pPatAttr), nFirst(0), nCount(0) {} +/*N*/ }; + +/*N*/ struct ScLessDefaultAttr +/*N*/ { +/*N*/ sal_Bool operator() (const ScDefaultAttr& rValue1, const ScDefaultAttr& rValue2) const +/*N*/ { +/*N*/ return rValue1.pAttr < rValue2.pAttr; +/*N*/ } +/*N*/ }; + +/*N*/ typedef std::set<ScDefaultAttr, ScLessDefaultAttr> ScDefaultAttrSet; + +/*N*/ void ScDocument::MakeTable( USHORT nTab ) +/*N*/ { +/*N*/ if ( nTab<=MAXTAB && !pTab[nTab] ) +/*N*/ { +/*N*/ String aString = ScGlobal::GetRscString(STR_TABLE_DEF); //"Tabelle" +/*N*/ aString += String::CreateFromInt32(nTab+1); +/*N*/ CreateValidTabName( aString ); // keine doppelten +/*N*/ +/*N*/ pTab[nTab] = new ScTable(this, nTab, aString); +/*N*/ ++nMaxTableNumber; +/*N*/ } +/*N*/ } + + +/*N*/ BOOL ScDocument::HasTable( USHORT nTab ) const +/*N*/ { +/*N*/ if (VALIDTAB(nTab)) +/*N*/ if (pTab[nTab]) +/*N*/ return TRUE; +/*N*/ +/*N*/ return FALSE; +/*N*/ } + + +/*N*/ BOOL ScDocument::GetName( USHORT nTab, String& rName ) const +/*N*/ { +/*N*/ if (VALIDTAB(nTab)) +/*N*/ if (pTab[nTab]) +/*N*/ { +/*N*/ pTab[nTab]->GetName( rName ); +/*N*/ return TRUE; +/*N*/ } +/*N*/ rName.Erase(); +/*N*/ return FALSE; +/*N*/ } + + +/*N*/ BOOL ScDocument::GetTable( const String& rName, USHORT& rTab ) const +/*N*/ { +/*N*/ String aUpperName = rName; +/*N*/ ScGlobal::pCharClass->toUpper(aUpperName); +/*N*/ String aCompName; +/*N*/ +/*N*/ for (USHORT i=0; i<=MAXTAB; i++) +/*N*/ if (pTab[i]) +/*N*/ { +/*N*/ pTab[i]->GetName( aCompName ); +/*N*/ ScGlobal::pCharClass->toUpper(aCompName); +/*N*/ if (aUpperName == aCompName) +/*N*/ { +/*N*/ rTab = i; +/*N*/ return TRUE; +/*N*/ } +/*N*/ } +/*N*/ rTab = 0; +/*N*/ return FALSE; +/*N*/ } + + +/*N*/ BOOL ScDocument::ValidTabName( const String& rName ) const +/*N*/ { + /* If changed, ScfTools::ConvertToScSheetName (sc/source/filter/ftools/ftools.cxx) + needs to be changed too. */ +/*N*/ using namespace ::com::sun::star::i18n; +/*N*/ sal_Int32 nStartFlags = KParseTokens::ANY_LETTER_OR_NUMBER | +/*N*/ KParseTokens::ASC_UNDERSCORE; +/*N*/ sal_Int32 nContFlags = nStartFlags; +/*N*/ String aContChars( RTL_CONSTASCII_USTRINGPARAM(" ") ); +/*N*/ ParseResult rRes = ScGlobal::pCharClass->parsePredefinedToken( KParseType::IDENTNAME, rName, 0, +/*N*/ nStartFlags, EMPTY_STRING, nContFlags, aContChars ); +/*N*/ return (rRes.TokenType & KParseType::IDENTNAME) && rRes.EndPos == rName.Len(); +/*N*/ } + + +/*N*/ BOOL ScDocument::ValidNewTabName( const String& rName ) const +/*N*/ { +/*N*/ BOOL bValid = ValidTabName(rName); +/*N*/ for (USHORT i=0; (i<=MAXTAB) && bValid; i++) +/*N*/ if (pTab[i]) +/*N*/ { +/*N*/ String aOldName; +/*N*/ pTab[i]->GetName(aOldName); +/*N*/ bValid = !ScGlobal::pTransliteration->isEqual( rName, aOldName ); +/*N*/ } +/*N*/ return bValid; +/*N*/ } + + +/*N*/ void ScDocument::CreateValidTabName(String& rName) const +/*N*/ { +/*N*/ if ( !ValidTabName(rName) ) +/*N*/ { +/*?*/ // neu erzeugen +/*?*/ +/*?*/ const String aStrTable( ScResId(SCSTR_TABLE) ); +/*?*/ BOOL bOk = FALSE; +/*?*/ +/*?*/ // vorneweg testen, ob der Prefix als gueltig erkannt wird +/*?*/ // wenn nicht, nur doppelte vermeiden +/*?*/ BOOL bPrefix = ValidTabName( aStrTable ); +/*?*/ DBG_ASSERT(bPrefix, "ungueltiger Tabellenname"); +/*?*/ USHORT nDummy; +/*?*/ +/*?*/ USHORT nLoops = 0; // "zur Sicherheit" +/*?*/ for ( USHORT i = nMaxTableNumber+1; !bOk && nLoops <= MAXTAB; i++ ) +/*?*/ { +/*?*/ rName = aStrTable; +/*?*/ rName += String::CreateFromInt32(i); +/*?*/ if (bPrefix) +/*?*/ bOk = ValidNewTabName( rName ); +/*?*/ else +/*?*/ bOk = !GetTable( rName, nDummy ); +/*?*/ ++nLoops; +/*?*/ } +/*?*/ +/*?*/ DBG_ASSERT(bOk, "kein gueltiger Tabellenname gefunden"); +/*?*/ if ( !bOk ) +/*?*/ rName = aStrTable; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ // uebergebenen Namen ueberpruefen +/*N*/ +/*N*/ if ( !ValidNewTabName(rName) ) +/*N*/ { +/*N*/ USHORT i = 1; +/*N*/ String aName; +/*N*/ do +/*N*/ { +/*N*/ i++; +/*N*/ aName = rName; +/*N*/ aName += '_'; +/*N*/ aName += String::CreateFromInt32(i); +/*N*/ } +/*N*/ while (!ValidNewTabName(aName) && (i < MAXTAB+1)); +/*N*/ rName = aName; +/*N*/ } +/*N*/ } +/*N*/ } + + +/*N*/ BOOL ScDocument::InsertTab( USHORT nPos, const String& rName, +/*N*/ BOOL bExternalDocument ) +/*N*/ { +/*N*/ USHORT nTabCount = GetTableCount(); +/*N*/ BOOL bValid = (nTabCount <= MAXTAB); +/*N*/ if ( !bExternalDocument ) // sonst rName == "'Doc'!Tab", vorher pruefen +/*N*/ bValid = (bValid && ValidNewTabName(rName)); +/*N*/ if (bValid) +/*N*/ { +/*N*/ if (nPos == SC_TAB_APPEND || nPos == nTabCount) +/*N*/ { +/*?*/ pTab[nTabCount] = new ScTable(this, nTabCount, rName); +/*?*/ ++nMaxTableNumber; +/*?*/ if ( bExternalDocument ) +/*?*/ pTab[nTabCount]->SetVisible( FALSE ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ if (VALIDTAB(nPos) && (nPos < nTabCount)) +/*N*/ { +/*N*/ ScRange aRange( 0,0,nPos, MAXCOL,MAXROW,MAXTAB ); +/*N*/ xColNameRanges->UpdateReference( URM_INSDEL, this, aRange, 0,0,1 ); +/*N*/ xRowNameRanges->UpdateReference( URM_INSDEL, this, aRange, 0,0,1 ); +/*N*/ pRangeName->UpdateTabRef( nPos, 1 ); +/*N*/ pDBCollection->UpdateReference( +/*N*/ URM_INSDEL, 0,0,nPos, MAXCOL,MAXROW,MAXTAB, 0,0,1 ); +/*N*/ if (pPivotCollection) +/*N*/ pPivotCollection->UpdateReference( +/*N*/ URM_INSDEL, 0,0,nPos, MAXCOL,MAXROW,MAXTAB, 0,0,1 ); +/*N*/ if (pDPCollection) +/*?*/ pDPCollection->UpdateReference( URM_INSDEL, aRange, 0,0,1 ); +/*N*/ if (pDetOpList) +/*?*/ {DBG_BF_ASSERT(0, "STRIP");} //STRIP001 pDetOpList->UpdateReference( this, URM_INSDEL, aRange, 0,0,1 ); +/*N*/ UpdateChartRef( URM_INSDEL, 0,0,nPos, MAXCOL,MAXROW,MAXTAB, 0,0,1 ); +/*N*/ UpdateRefAreaLinks( URM_INSDEL, aRange, 0,0,1 ); +/*N*/ if ( pUnoBroadcaster ) +/*N*/ pUnoBroadcaster->Broadcast( ScUpdateRefHint( URM_INSDEL, aRange, 0,0,1 ) ); +/*N*/ +/*N*/ USHORT i; +/*N*/ for (i = 0; i <= MAXTAB; i++) +/*N*/ if (pTab[i]) +/*N*/ pTab[i]->UpdateInsertTab(nPos); +/*N*/ for (i = nTabCount; i > nPos; i--) +/*N*/ pTab[i] = pTab[i - 1]; +/*N*/ pTab[nPos] = new ScTable(this, nPos, rName); +/*N*/ ++nMaxTableNumber; +/*N*/ for (i = 0; i <= MAXTAB; i++) +/*N*/ if (pTab[i]) +/*N*/ pTab[i]->UpdateCompile(); +/*N*/ for (i = 0; i <= MAXTAB; i++) +/*N*/ if (pTab[i]) +/*N*/ pTab[i]->StartAllListeners(); +/*N*/ +/*N*/ // update conditional formats after table is inserted +/*N*/ if ( pCondFormList ) +/*N*/ pCondFormList->UpdateReference( URM_INSDEL, aRange, 0,0,1 ); +/*N*/ // #81844# sheet names of references are not valid until sheet is inserted +/*N*/ if ( pChartListenerCollection ) +/*N*/ pChartListenerCollection->UpdateScheduledSeriesRanges(); +/*N*/ +/*N*/ SetDirty(); +/*N*/ bValid = TRUE; +/*N*/ } +/*N*/ else +/*N*/ bValid = FALSE; +/*N*/ } +/*N*/ } +/*N*/ return bValid; +/*N*/ } + + +/*N*/ BOOL ScDocument::DeleteTab( USHORT nTab, ScDocument* pRefUndoDoc ) +/*N*/ { +/*N*/ BOOL bValid = FALSE; +/*N*/ if (VALIDTAB(nTab)) +/*N*/ { +/*N*/ if (pTab[nTab]) +/*N*/ { +/*N*/ USHORT nTabCount = GetTableCount(); +/*N*/ if (nTabCount > 1) +/*N*/ { +/*N*/ BOOL bOldAutoCalc = GetAutoCalc(); +/*N*/ SetAutoCalc( FALSE ); // Mehrfachberechnungen vermeiden +/*N*/ ScRange aRange( 0, 0, nTab, MAXCOL, MAXROW, nTab ); +/*N*/ DelBroadcastAreasInRange( aRange ); +/*N*/ +/*N*/ aRange.aEnd.SetTab( MAXTAB ); +/*N*/ xColNameRanges->UpdateReference( URM_INSDEL, this, aRange, 0,0,-1 ); +/*N*/ xRowNameRanges->UpdateReference( URM_INSDEL, this, aRange, 0,0,-1 ); +/*N*/ pRangeName->UpdateTabRef( nTab, 2 ); +/*N*/ pDBCollection->UpdateReference( +/*N*/ URM_INSDEL, 0,0,nTab, MAXCOL,MAXROW,MAXTAB, 0,0,-1 ); +/*N*/ if (pPivotCollection) +/*N*/ pPivotCollection->UpdateReference( +/*N*/ URM_INSDEL, 0,0,nTab, MAXCOL,MAXROW,MAXTAB, 0,0,-1 ); +/*N*/ if (pDPCollection) +/*N*/ pDPCollection->UpdateReference( URM_INSDEL, aRange, 0,0,-1 ); +/*N*/ if (pDetOpList) +/*N*/ pDetOpList->UpdateReference( this, URM_INSDEL, aRange, 0,0,-1 ); +/*N*/ UpdateChartRef( URM_INSDEL, 0,0,nTab, MAXCOL,MAXROW,MAXTAB, 0,0,-1 ); +/*N*/ UpdateRefAreaLinks( URM_INSDEL, aRange, 0,0,-1 ); +/*N*/ if ( pCondFormList ) +/*N*/ pCondFormList->UpdateReference( URM_INSDEL, aRange, 0,0,-1 ); +/*N*/ if ( pUnoBroadcaster ) +/*N*/ pUnoBroadcaster->Broadcast( ScUpdateRefHint( URM_INSDEL, aRange, 0,0,-1 ) ); +/*N*/ +/*N*/ USHORT i; +/*N*/ for (i=0; i<=MAXTAB; i++) +/*N*/ if (pTab[i]) +/*N*/ pTab[i]->UpdateDeleteTab(nTab,FALSE, +/*N*/ pRefUndoDoc ? pRefUndoDoc->pTab[i] : 0); +/*N*/ delete pTab[nTab]; +/*N*/ for (i=nTab + 1; i < nTabCount; i++) +/*N*/ pTab[i - 1] = pTab[i]; +/*N*/ pTab[nTabCount - 1] = NULL; +/*N*/ --nMaxTableNumber; +/*N*/ for (i = 0; i <= MAXTAB; i++) +/*N*/ if (pTab[i]) +/*N*/ pTab[i]->UpdateCompile(); +/*N*/ // Excel-Filter loescht einige Tables waehrend des Ladens, +/*N*/ // Listener werden erst nach dem Laden aufgesetzt +/*N*/ if ( !bInsertingFromOtherDoc ) +/*N*/ { +/*N*/ for (i = 0; i <= MAXTAB; i++) +/*N*/ if (pTab[i]) +/*N*/ pTab[i]->StartAllListeners(); +/*N*/ SetDirty(); +/*N*/ } +/*N*/ // #81844# sheet names of references are not valid until sheet is deleted +/*N*/ pChartListenerCollection->UpdateScheduledSeriesRanges(); +/*N*/ SetAutoCalc( bOldAutoCalc ); +/*N*/ bValid = TRUE; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ return bValid; +/*N*/ } + + +/*N*/ BOOL ScDocument::RenameTab( USHORT nTab, const String& rName, BOOL bUpdateRef, +/*N*/ BOOL bExternalDocument ) +/*N*/ { +/*N*/ BOOL bValid = FALSE; +/*N*/ USHORT i; +/*N*/ if VALIDTAB(nTab) +/*N*/ if (pTab[nTab]) +/*N*/ { +/*N*/ if ( bExternalDocument ) +/*N*/ bValid = TRUE; // zusammengesetzter Name +/*N*/ else +/*N*/ bValid = ValidTabName(rName); +/*N*/ for (i=0; (i<=MAXTAB) && bValid; i++) +/*N*/ if (pTab[i] && (i != nTab)) +/*N*/ { +/*N*/ String aOldName; +/*N*/ pTab[i]->GetName(aOldName); +/*N*/ bValid = !ScGlobal::pTransliteration->isEqual( rName, aOldName ); +/*N*/ } +/*N*/ if (bValid) +/*N*/ { +/*N*/ pTab[nTab]->SetName(rName); +/*N*/ if ( pChartListenerCollection ) +/*N*/ pChartListenerCollection->UpdateSeriesRangesContainingTab( nTab ); +/*N*/ } +/*N*/ } +/*N*/ return bValid; +/*N*/ } + + +/*N*/ void ScDocument::SetVisible( USHORT nTab, BOOL bVisible ) +/*N*/ { +/*N*/ if (VALIDTAB(nTab)) +/*N*/ if (pTab[nTab]) +/*N*/ pTab[nTab]->SetVisible(bVisible); +/*N*/ } + + +/*N*/ BOOL ScDocument::IsVisible( USHORT nTab ) const +/*N*/ { +/*N*/ if (VALIDTAB(nTab)) +/*N*/ if (pTab[nTab]) +/*N*/ return pTab[nTab]->IsVisible(); +/*N*/ +/*N*/ return FALSE; +/*N*/ } + +/* ---------------------------------------------------------------------------- + benutzten Bereich suchen: + + GetCellArea - nur Daten + GetTableArea - Daten / Attribute + GetPrintArea - beruecksichtigt auch Zeichenobjekte, + streicht Attribute bis ganz rechts / unten +---------------------------------------------------------------------------- */ + + +/*N*/ BOOL ScDocument::GetCellArea( USHORT nTab, USHORT& rEndCol, USHORT& rEndRow ) const +/*N*/ { +/*N*/ if (VALIDTAB(nTab)) +/*N*/ if (pTab[nTab]) +/*N*/ return pTab[nTab]->GetCellArea( rEndCol, rEndRow ); +/*N*/ +/*N*/ rEndCol = 0; +/*N*/ rEndRow = 0; +/*N*/ return FALSE; +/*N*/ } + + +/*N*/ BOOL ScDocument::GetTableArea( USHORT nTab, USHORT& rEndCol, USHORT& rEndRow ) const +/*N*/ { +/*N*/ if (VALIDTAB(nTab)) +/*N*/ if (pTab[nTab]) +/*N*/ return pTab[nTab]->GetTableArea( rEndCol, rEndRow ); +/*N*/ +/*N*/ rEndCol = 0; +/*N*/ rEndRow = 0; +/*N*/ return FALSE; +/*N*/ } + + +// zusammenhaengender Bereich + +/*N*/ void ScDocument::GetDataArea( USHORT nTab, USHORT& rStartCol, USHORT& rStartRow, +/*N*/ USHORT& rEndCol, USHORT& rEndRow, BOOL bIncludeOld ) +/*N*/ { +/*N*/ if (VALIDTAB(nTab)) +/*N*/ if (pTab[nTab]) +/*N*/ pTab[nTab]->GetDataArea( rStartCol, rStartRow, rEndCol, rEndRow, bIncludeOld ); +/*N*/ } + + + + + + +/*N*/ BOOL ScDocument::CanInsertRow( const ScRange& rRange ) const +/*N*/ { +/*N*/ USHORT nStartCol = rRange.aStart.Col(); +/*N*/ USHORT nStartRow = rRange.aStart.Row(); +/*N*/ USHORT nStartTab = rRange.aStart.Tab(); +/*N*/ USHORT nEndCol = rRange.aEnd.Col(); +/*N*/ USHORT nEndRow = rRange.aEnd.Row(); +/*N*/ USHORT nEndTab = rRange.aEnd.Tab(); +/*N*/ PutInOrder( nStartCol, nEndCol ); +/*N*/ PutInOrder( nStartRow, nEndRow ); +/*N*/ PutInOrder( nStartTab, nEndTab ); +/*N*/ USHORT nSize = nEndRow - nStartRow + 1; +/*N*/ +/*N*/ BOOL bTest = TRUE; +/*N*/ for (USHORT i=nStartTab; i<=nEndTab && bTest; i++) +/*N*/ if (pTab[i]) +/*N*/ bTest &= pTab[i]->TestInsertRow( nStartCol, nEndCol, nSize ); +/*N*/ +/*N*/ return bTest; +/*N*/ } + + +/*N*/ BOOL ScDocument::InsertRow( USHORT nStartCol, USHORT nStartTab, +/*N*/ USHORT nEndCol, USHORT nEndTab, +/*N*/ USHORT nStartRow, USHORT nSize, ScDocument* pRefUndoDoc ) +/*N*/ { +/*N*/ PutInOrder( nStartCol, nEndCol ); +/*N*/ PutInOrder( nStartTab, nEndTab ); +/*N*/ +/*N*/ BOOL bTest = TRUE; +/*N*/ BOOL bRet = FALSE; +/*N*/ BOOL bOldAutoCalc = GetAutoCalc(); +/*N*/ SetAutoCalc( FALSE ); // Mehrfachberechnungen vermeiden +/*N*/ USHORT i = 0; +/*N*/ for (i=nStartTab; i<=nEndTab && bTest; i++) +/*N*/ if (pTab[i]) +/*N*/ bTest &= pTab[i]->TestInsertRow( nStartCol, nEndCol, nSize ); +/*N*/ if (bTest) +/*N*/ { +/*N*/ // UpdateBroadcastAreas muss vor UpdateReference gerufen werden, damit nicht +/*N*/ // Eintraege verschoben werden, die erst bei UpdateReference neu erzeugt werden +/*N*/ +/*N*/ UpdateBroadcastAreas( URM_INSDEL, ScRange( +/*N*/ ScAddress( nStartCol, nStartRow, nStartTab ), +/*N*/ ScAddress( nEndCol, MAXROW, nEndTab )), 0, nSize, 0 ); +/*N*/ UpdateReference( URM_INSDEL, nStartCol, nStartRow, nStartTab, +/*N*/ nEndCol, MAXROW, nEndTab, +/*N*/ 0, nSize, 0, pRefUndoDoc, FALSE ); // without drawing objects +/*N*/ for (i=nStartTab; i<=nEndTab; i++) +/*N*/ if (pTab[i]) +/*N*/ pTab[i]->InsertRow( nStartCol, nEndCol, nStartRow, nSize ); +/*N*/ +/*N*/ // #82991# UpdateRef for drawing layer must be after inserting, +/*N*/ // when the new row heights are known. +/*N*/ for (i=nStartTab; i<=nEndTab; i++) +/*N*/ if (pTab[i]) +/*N*/ pTab[i]->UpdateDrawRef( URM_INSDEL, +/*N*/ nStartCol, nStartRow, nStartTab, nEndCol, MAXROW, nEndTab, +/*N*/ 0, nSize, 0 ); +/*N*/ +/*N*/ if ( pChangeTrack && pChangeTrack->IsInDeleteUndo() ) +/*N*/ { // durch Restaurierung von Referenzen auf geloeschte Bereiche ist +/*N*/ // ein neues Listening faellig, bisherige Listener wurden in +/*N*/ // FormulaCell UpdateReference abgehaengt +/*N*/ StartAllListeners(); +/*N*/ } +/*N*/ else +/*N*/ { // RelName listeners have been removed in UpdateReference +/*N*/ for (i=0; i<=MAXTAB; i++) +/*N*/ if (pTab[i]) +/*N*/ pTab[i]->StartNameListeners( TRUE ); +/*N*/ // #69592# at least all cells using range names pointing relative +/*N*/ // to the moved range must recalculate +/*N*/ for (i=0; i<=MAXTAB; i++) +/*N*/ if (pTab[i]) +/*N*/ pTab[i]->SetRelNameDirty(); +/*N*/ } +/*N*/ bRet = TRUE; +/*N*/ } +/*N*/ SetAutoCalc( bOldAutoCalc ); +/*N*/ if ( bRet ) +/*N*/ pChartListenerCollection->UpdateDirtyCharts(); +/*N*/ return bRet; +/*N*/ } + + +/*N*/ BOOL ScDocument::InsertRow( const ScRange& rRange, ScDocument* pRefUndoDoc ) +/*N*/ { +/*N*/ return InsertRow( rRange.aStart.Col(), rRange.aStart.Tab(), +/*N*/ rRange.aEnd.Col(), rRange.aEnd.Tab(), +/*N*/ rRange.aStart.Row(), rRange.aEnd.Row()-rRange.aStart.Row()+1, +/*N*/ pRefUndoDoc ); +/*N*/ } + + +/*N*/ void ScDocument::DeleteRow( USHORT nStartCol, USHORT nStartTab, +/*N*/ USHORT nEndCol, USHORT nEndTab, +/*N*/ USHORT nStartRow, USHORT nSize, +/*N*/ ScDocument* pRefUndoDoc, BOOL* pUndoOutline ) +/*N*/ { +/*N*/ PutInOrder( nStartCol, nEndCol ); +/*N*/ PutInOrder( nStartTab, nEndTab ); +/*N*/ +/*N*/ BOOL bOldAutoCalc = GetAutoCalc(); +/*N*/ SetAutoCalc( FALSE ); // Mehrfachberechnungen vermeiden +/*N*/ +/*N*/ if ( nStartRow+nSize <= MAXROW ) +/*N*/ { +/*N*/ DelBroadcastAreasInRange( ScRange( +/*N*/ ScAddress( nStartCol, nStartRow, nStartTab ), +/*N*/ ScAddress( nEndCol, nStartRow+nSize-1, nEndTab ) ) ); +/*N*/ UpdateBroadcastAreas( URM_INSDEL, ScRange( +/*N*/ ScAddress( nStartCol, nStartRow+nSize, nStartTab ), +/*N*/ ScAddress( nEndCol, MAXROW, nEndTab )), 0, -(short) nSize, 0 ); +/*N*/ } +/*N*/ else +/*N*/ DelBroadcastAreasInRange( ScRange( +/*N*/ ScAddress( nStartCol, nStartRow, nStartTab ), +/*N*/ ScAddress( nEndCol, MAXROW, nEndTab ) ) ); +/*N*/ +/*N*/ if ( nStartRow+nSize <= MAXROW ) +/*N*/ { +/*N*/ UpdateReference( URM_INSDEL, nStartCol, nStartRow+nSize, nStartTab, +/*N*/ nEndCol, MAXROW, nEndTab, +/*N*/ 0, -(short) nSize, 0, pRefUndoDoc ); +/*N*/ } +/*N*/ +/*N*/ if (pUndoOutline) +/*N*/ *pUndoOutline = FALSE; +/*N*/ +/*N*/ USHORT i=0; +/*N*/ for (i=nStartTab; i<=nEndTab; i++) +/*N*/ if (pTab[i]) +/*N*/ pTab[i]->DeleteRow( nStartCol, nEndCol, nStartRow, nSize, pUndoOutline ); +/*N*/ +/*N*/ if ( nStartRow+nSize <= MAXROW ) +/*N*/ { // Name listeners have been removed in UpdateReference +/*N*/ for (i=0; i<=MAXTAB; i++) +/*N*/ if (pTab[i]) +/*N*/ pTab[i]->StartNameListeners( FALSE ); +/*N*/ // #69592# at least all cells using range names pointing relative to +/*N*/ // the moved range must recalculate +/*N*/ for (i=0; i<=MAXTAB; i++) +/*N*/ if (pTab[i]) +/*N*/ pTab[i]->SetRelNameDirty(); +/*N*/ } +/*N*/ +/*N*/ SetAutoCalc( bOldAutoCalc ); +/*N*/ pChartListenerCollection->UpdateDirtyCharts(); +/*N*/ } + + +/*N*/ void ScDocument::DeleteRow( const ScRange& rRange, ScDocument* pRefUndoDoc, BOOL* pUndoOutline ) +/*N*/ { +/*N*/ DeleteRow( rRange.aStart.Col(), rRange.aStart.Tab(), +/*N*/ rRange.aEnd.Col(), rRange.aEnd.Tab(), +/*N*/ rRange.aStart.Row(), rRange.aEnd.Row()-rRange.aStart.Row()+1, +/*N*/ pRefUndoDoc, pUndoOutline ); +/*N*/ } + + +/*N*/ BOOL ScDocument::CanInsertCol( const ScRange& rRange ) const +/*N*/ { +/*N*/ USHORT nStartCol = rRange.aStart.Col(); +/*N*/ USHORT nStartRow = rRange.aStart.Row(); +/*N*/ USHORT nStartTab = rRange.aStart.Tab(); +/*N*/ USHORT nEndCol = rRange.aEnd.Col(); +/*N*/ USHORT nEndRow = rRange.aEnd.Row(); +/*N*/ USHORT nEndTab = rRange.aEnd.Tab(); +/*N*/ PutInOrder( nStartCol, nEndCol ); +/*N*/ PutInOrder( nStartRow, nEndRow ); +/*N*/ PutInOrder( nStartTab, nEndTab ); +/*N*/ USHORT nSize = nEndCol - nStartCol + 1; +/*N*/ +/*N*/ BOOL bTest = TRUE; +/*N*/ for (USHORT i=nStartTab; i<=nEndTab && bTest; i++) +/*N*/ if (pTab[i]) +/*N*/ bTest &= pTab[i]->TestInsertCol( nStartRow, nEndRow, nSize ); +/*N*/ +/*N*/ return bTest; +/*N*/ } + + +/*N*/ BOOL ScDocument::InsertCol( USHORT nStartRow, USHORT nStartTab, +/*N*/ USHORT nEndRow, USHORT nEndTab, +/*N*/ USHORT nStartCol, USHORT nSize, ScDocument* pRefUndoDoc ) +/*N*/ { +/*N*/ PutInOrder( nStartRow, nEndRow ); +/*N*/ PutInOrder( nStartTab, nEndTab ); +/*N*/ +/*N*/ BOOL bTest = TRUE; +/*N*/ BOOL bRet = FALSE; +/*N*/ BOOL bOldAutoCalc = GetAutoCalc(); +/*N*/ SetAutoCalc( FALSE ); // Mehrfachberechnungen vermeiden +/*N*/ USHORT i=0; +/*N*/ for (i=nStartTab; i<=nEndTab && bTest; i++) +/*N*/ if (pTab[i]) +/*N*/ bTest &= pTab[i]->TestInsertCol( nStartRow, nEndRow, nSize ); +/*N*/ if (bTest) +/*N*/ { +/*N*/ UpdateBroadcastAreas( URM_INSDEL, ScRange( +/*N*/ ScAddress( nStartCol, nStartRow, nStartTab ), +/*N*/ ScAddress( MAXCOL, nEndRow, nEndTab )), nSize, 0, 0 ); +/*N*/ UpdateReference( URM_INSDEL, nStartCol, nStartRow, nStartTab, +/*N*/ MAXCOL, nEndRow, nEndTab, +/*N*/ nSize, 0, 0, pRefUndoDoc ); +/*N*/ for (i=nStartTab; i<=nEndTab; i++) +/*N*/ if (pTab[i]) +/*N*/ pTab[i]->InsertCol( nStartCol, nStartRow, nEndRow, nSize ); +/*N*/ +/*N*/ if ( pChangeTrack && pChangeTrack->IsInDeleteUndo() ) +/*N*/ { // durch Restaurierung von Referenzen auf geloeschte Bereiche ist +/*N*/ // ein neues Listening faellig, bisherige Listener wurden in +/*N*/ // FormulaCell UpdateReference abgehaengt +/*N*/ StartAllListeners(); +/*N*/ } +/*N*/ else +/*N*/ { // RelName listeners have been removed in UpdateReference +/*N*/ for (i=0; i<=MAXTAB; i++) +/*N*/ if (pTab[i]) +/*N*/ pTab[i]->StartNameListeners( TRUE ); +/*N*/ // #69592# at least all cells using range names pointing relative +/*N*/ // to the moved range must recalculate +/*N*/ for (i=0; i<=MAXTAB; i++) +/*N*/ if (pTab[i]) +/*N*/ pTab[i]->SetRelNameDirty(); +/*N*/ } +/*N*/ bRet = TRUE; +/*N*/ } +/*N*/ SetAutoCalc( bOldAutoCalc ); +/*N*/ if ( bRet ) +/*N*/ pChartListenerCollection->UpdateDirtyCharts(); +/*N*/ return bRet; +/*N*/ } + + +/*N*/ BOOL ScDocument::InsertCol( const ScRange& rRange, ScDocument* pRefUndoDoc ) +/*N*/ { +/*N*/ return InsertCol( rRange.aStart.Row(), rRange.aStart.Tab(), +/*N*/ rRange.aEnd.Row(), rRange.aEnd.Tab(), +/*N*/ rRange.aStart.Col(), rRange.aEnd.Col()-rRange.aStart.Col()+1, +/*N*/ pRefUndoDoc ); +/*N*/ } + + +/*N*/ void ScDocument::DeleteCol(USHORT nStartRow, USHORT nStartTab, USHORT nEndRow, USHORT nEndTab, +/*N*/ USHORT nStartCol, USHORT nSize, ScDocument* pRefUndoDoc, +/*N*/ BOOL* pUndoOutline ) +/*N*/ { +/*N*/ PutInOrder( nStartRow, nEndRow ); +/*N*/ PutInOrder( nStartTab, nEndTab ); +/*N*/ +/*N*/ BOOL bOldAutoCalc = GetAutoCalc(); +/*N*/ SetAutoCalc( FALSE ); // Mehrfachberechnungen vermeiden +/*N*/ +/*N*/ if ( nStartCol+nSize <= MAXCOL ) +/*N*/ { +/*N*/ DelBroadcastAreasInRange( ScRange( +/*N*/ ScAddress( nStartCol, nStartRow, nStartTab ), +/*N*/ ScAddress( nStartCol+nSize-1, nEndRow, nEndTab ) ) ); +/*N*/ UpdateBroadcastAreas( URM_INSDEL, ScRange( +/*N*/ ScAddress( nStartCol+nSize, nStartRow, nStartTab ), +/*N*/ ScAddress( MAXCOL, nEndRow, nEndTab )), -(short) nSize, 0, 0 ); +/*N*/ } +/*N*/ else +/*N*/ DelBroadcastAreasInRange( ScRange( +/*N*/ ScAddress( nStartCol, nStartRow, nStartTab ), +/*N*/ ScAddress( MAXCOL, nEndRow, nEndTab ) ) ); +/*N*/ +/*N*/ if ( nStartCol+nSize <= MAXCOL ) +/*N*/ { +/*N*/ UpdateReference( URM_INSDEL, nStartCol+nSize, nStartRow, nStartTab, +/*N*/ MAXCOL, nEndRow, nEndTab, +/*N*/ -(short) nSize, 0, 0, pRefUndoDoc ); +/*N*/ } +/*N*/ +/*N*/ if (pUndoOutline) +/*N*/ *pUndoOutline = FALSE; +/*N*/ +/*N*/ USHORT i=0; +/*N*/ for (i=nStartTab; i<=nEndTab; i++) +/*N*/ if (pTab[i]) +/*N*/ pTab[i]->DeleteCol( nStartCol, nStartRow, nEndRow, nSize, pUndoOutline ); +/*N*/ +/*N*/ if ( nStartCol+nSize <= MAXCOL ) +/*N*/ { // Name listeners have been removed in UpdateReference +/*N*/ for (i=0; i<=MAXTAB; i++) +/*N*/ if (pTab[i]) +/*N*/ pTab[i]->StartNameListeners( FALSE ); +/*N*/ // #69592# at least all cells using range names pointing relative to +/*N*/ // the moved range must recalculate +/*N*/ for (i=0; i<=MAXTAB; i++) +/*N*/ if (pTab[i]) +/*N*/ pTab[i]->SetRelNameDirty(); +/*N*/ } +/*N*/ +/*N*/ SetAutoCalc( bOldAutoCalc ); +/*N*/ pChartListenerCollection->UpdateDirtyCharts(); +/*N*/ } + + +/*N*/ void ScDocument::DeleteCol( const ScRange& rRange, ScDocument* pRefUndoDoc, BOOL* pUndoOutline ) +/*N*/ { +/*N*/ DeleteCol( rRange.aStart.Row(), rRange.aStart.Tab(), +/*N*/ rRange.aEnd.Row(), rRange.aEnd.Tab(), +/*N*/ rRange.aStart.Col(), rRange.aEnd.Col()-rRange.aStart.Col()+1, +/*N*/ pRefUndoDoc, pUndoOutline ); +/*N*/ } + + +// fuer Area-Links: Zellen einuegen/loeschen, wenn sich der Bereich veraendert +// (ohne Paint) + + + + + + +/*N*/ BOOL ScDocument::CanFitBlock( const ScRange& rOld, const ScRange& rNew ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); return FALSE; //STRIP001 if ( rOld == rNew ) +/*N*/ } + + +/*N*/ void ScDocument::FitBlock( const ScRange& rOld, const ScRange& rNew, BOOL bClear ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 if (bClear) +/*N*/ } + + +/*N*/ void ScDocument::DeleteArea(USHORT nCol1, USHORT nRow1, +/*N*/ USHORT nCol2, USHORT nRow2, +/*N*/ const ScMarkData& rMark, USHORT nDelFlag) +/*N*/ { +/*N*/ PutInOrder( nCol1, nCol2 ); +/*N*/ PutInOrder( nRow1, nRow2 ); +/*N*/ BOOL bOldAutoCalc = GetAutoCalc(); +/*N*/ SetAutoCalc( FALSE ); // Mehrfachberechnungen vermeiden +/*N*/ for (USHORT i = 0; i <= MAXTAB; i++) +/*N*/ if (pTab[i]) +/*N*/ if ( rMark.GetTableSelect(i) || bIsUndo ) +/*N*/ pTab[i]->DeleteArea(nCol1, nRow1, nCol2, nRow2, nDelFlag); +/*N*/ SetAutoCalc( bOldAutoCalc ); +/*N*/ } + + +/*N*/ void ScDocument::DeleteAreaTab(USHORT nCol1, USHORT nRow1, +/*N*/ USHORT nCol2, USHORT nRow2, +/*N*/ USHORT nTab, USHORT nDelFlag) +/*N*/ { +/*N*/ PutInOrder( nCol1, nCol2 ); +/*N*/ PutInOrder( nRow1, nRow2 ); +/*N*/ if ( VALIDTAB(nTab) && pTab[nTab] ) +/*N*/ { +/*N*/ BOOL bOldAutoCalc = GetAutoCalc(); +/*N*/ SetAutoCalc( FALSE ); // Mehrfachberechnungen vermeiden +/*N*/ pTab[nTab]->DeleteArea(nCol1, nRow1, nCol2, nRow2, nDelFlag); +/*N*/ SetAutoCalc( bOldAutoCalc ); +/*N*/ } +/*N*/ } + + +/*N*/ void ScDocument::DeleteAreaTab( const ScRange& rRange, USHORT nDelFlag ) +/*N*/ { +/*N*/ for ( USHORT nTab = rRange.aStart.Tab(); nTab <= rRange.aEnd.Tab(); nTab++ ) +/*N*/ DeleteAreaTab( rRange.aStart.Col(), rRange.aStart.Row(), +/*N*/ rRange.aEnd.Col(), rRange.aEnd.Row(), +/*N*/ nTab, nDelFlag ); +/*N*/ } + + +/*N*/ void ScDocument::InitUndo( ScDocument* pSrcDoc, USHORT nTab1, USHORT nTab2, +/*N*/ BOOL bColInfo, BOOL bRowInfo ) +/*N*/ { +/*N*/ if (bIsUndo) +/*N*/ { +/*N*/ Clear(); +/*N*/ +/*N*/ xPoolHelper = pSrcDoc->xPoolHelper; +/*N*/ +/*N*/ String aString; +/*N*/ for (USHORT nTab = nTab1; nTab <= nTab2; nTab++) +/*N*/ pTab[nTab] = new ScTable(this, nTab, aString, bColInfo, bRowInfo); +/*N*/ +/*N*/ nMaxTableNumber = nTab2 + 1; +/*N*/ } +/*N*/ else +/*N*/ DBG_ERROR("InitUndo"); +/*N*/ } + +/*N*/ void ScDocument::CopyToDocument(USHORT nCol1, USHORT nRow1, USHORT nTab1, +/*N*/ USHORT nCol2, USHORT nRow2, USHORT nTab2, +/*N*/ USHORT nFlags, BOOL bOnlyMarked, ScDocument* pDestDoc, +/*N*/ const ScMarkData* pMarks, BOOL bColRowFlags ) +/*N*/ { +/*N*/ PutInOrder( nCol1, nCol2 ); +/*N*/ PutInOrder( nRow1, nRow2 ); +/*N*/ PutInOrder( nTab1, nTab2 ); +/*N*/ if( !pDestDoc->aDocName.Len() ) +/*N*/ pDestDoc->aDocName = aDocName; +/*N*/ if (VALIDTAB(nTab1) && VALIDTAB(nTab2)) +/*N*/ { +/*N*/ BOOL bOldAutoCalc = pDestDoc->GetAutoCalc(); +/*N*/ pDestDoc->SetAutoCalc( FALSE ); // Mehrfachberechnungen vermeiden +/*N*/ for (USHORT i = nTab1; i <= nTab2; i++) +/*N*/ { +/*N*/ if (pTab[i] && pDestDoc->pTab[i]) +/*N*/ pTab[i]->CopyToTable( nCol1, nRow1, nCol2, nRow2, nFlags, +/*N*/ bOnlyMarked, pDestDoc->pTab[i], pMarks, +/*N*/ FALSE, bColRowFlags ); +/*N*/ } +/*N*/ pDestDoc->SetAutoCalc( bOldAutoCalc ); +/*N*/ } +/*N*/ } + + + + +/*N*/ void ScDocument::CopyToDocument(const ScRange& rRange, +/*N*/ USHORT nFlags, BOOL bOnlyMarked, ScDocument* pDestDoc, +/*N*/ const ScMarkData* pMarks, BOOL bColRowFlags) +/*N*/ { +/*N*/ ScRange aNewRange = rRange; +/*N*/ aNewRange.Justify(); +/*N*/ +/*N*/ if( !pDestDoc->aDocName.Len() ) +/*N*/ pDestDoc->aDocName = aDocName; +/*N*/ BOOL bOldAutoCalc = pDestDoc->GetAutoCalc(); +/*N*/ pDestDoc->SetAutoCalc( FALSE ); // Mehrfachberechnungen vermeiden +/*N*/ for (USHORT i = aNewRange.aStart.Tab(); i <= aNewRange.aEnd.Tab(); i++) +/*N*/ if (pTab[i] && pDestDoc->pTab[i]) +/*N*/ pTab[i]->CopyToTable(aNewRange.aStart.Col(), aNewRange.aStart.Row(), +/*N*/ aNewRange.aEnd.Col(), aNewRange.aEnd.Row(), +/*N*/ nFlags, bOnlyMarked, pDestDoc->pTab[i], +/*N*/ pMarks, FALSE, bColRowFlags); +/*N*/ pDestDoc->SetAutoCalc( bOldAutoCalc ); +/*N*/ } + + + + +/*N*/ void ScDocument::CopyToClip(USHORT nCol1, USHORT nRow1, +/*N*/ USHORT nCol2, USHORT nRow2, +/*N*/ BOOL bCut, ScDocument* pClipDoc, +/*N*/ BOOL bAllTabs, const ScMarkData* pMarks, +/*N*/ BOOL bKeepScenarioFlags, BOOL bIncludeObjects) +/*N*/ { +/*N*/ DBG_ASSERT( bAllTabs || pMarks, "CopyToClip: ScMarkData fehlt" ); +/*N*/ +/*N*/ if (!bIsClip) +/*N*/ { +/*N*/ PutInOrder( nCol1, nCol2 ); +/*N*/ PutInOrder( nRow1, nRow2 ); +/*N*/ if (!pClipDoc) +/*N*/ { +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 /*?*/ DBG_ERROR("CopyToClip: no ClipDoc"); +/*N*/ } +/*N*/ +/*N*/ pClipDoc->aDocName = aDocName; +/*N*/ pClipDoc->aClipRange = ScRange( nCol1,nRow1,0, nCol2,nRow2,0 ); +/*N*/ pClipDoc->ResetClip( this, pMarks ); +/*N*/ USHORT i, j; +/*N*/ pClipDoc->pRangeName->FreeAll(); +/*N*/ for (i = 0; i < pRangeName->GetCount(); i++) //! DB-Bereiche Pivot-Bereiche auch !!! +/*N*/ { +/*N*/ USHORT nIndex = ((ScRangeData*)((*pRangeName)[i]))->GetIndex(); +/*N*/ BOOL bInUse = FALSE; +/*N*/ for (j = 0; !bInUse && (j <= MAXTAB); j++) +/*N*/ { +/*N*/ if (pTab[j]) +/*N*/ bInUse = pTab[j]->IsRangeNameInUse(nCol1, nRow1, nCol2, nRow2, +/*N*/ nIndex); +/*N*/ } +/*N*/ if (bInUse) +/*N*/ { +/*N*/ ScRangeData* pData = new ScRangeData(*((*pRangeName)[i])); +/*N*/ if (!pClipDoc->pRangeName->Insert(pData)) +/*N*/ delete pData; +/*N*/ else +/*N*/ pData->SetIndex(nIndex); +/*N*/ } +/*N*/ } +/*N*/ for (i = 0; i <= MAXTAB; i++) +/*N*/ if (pTab[i] && pClipDoc->pTab[i]) +/*N*/ if ( bAllTabs || !pMarks || pMarks->GetTableSelect(i) ) +/*N*/ { +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 /*?*/ pTab[i]->CopyToClip(nCol1, nRow1, nCol2, nRow2, pClipDoc->pTab[i], bKeepScenarioFlags); +/*N*/ +/*N*/ if ( pDrawLayer && bIncludeObjects ) +/*N*/ { +/*N*/ // also copy drawing objects +/*N*/ +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 /*?*/ Rectangle aObjRect = GetMMRect( nCol1, nRow1, nCol2, nRow2, i ); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ pClipDoc->bCutMode = bCut; +/*N*/ } +/*N*/ } + +void ScDocument::StartListeningFromClip( USHORT nCol1, USHORT nRow1, USHORT nCol2, USHORT nRow2, const ScMarkData& rMark, USHORT nInsFlag ) +{ +} + + +/*N*/ void ScDocument::BroadcastFromClip( USHORT nCol1, USHORT nRow1, +/*N*/ USHORT nCol2, USHORT nRow2, +/*N*/ const ScMarkData& rMark, USHORT nInsFlag ) +/*N*/ { +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 //STRIP001 if (nInsFlag & IDF_CONTENTS) +/*N*/ } + + +/*N*/ void ScDocument::CopyBlockFromClip( USHORT nCol1, USHORT nRow1, +/*N*/ USHORT nCol2, USHORT nRow2, +/*N*/ const ScMarkData& rMark, +/*N*/ short nDx, short nDy, +/*N*/ const ScCopyBlockFromClipParams* pCBFCP ) +/*N*/ { +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 //STRIP001 ScTable** ppClipTab = pCBFCP->pClipDoc->pTab; +/*N*/ } + + +/*N*/ void ScDocument::CopyNonFilteredFromClip( USHORT nCol1, USHORT nRow1, +/*N*/ USHORT nCol2, USHORT nRow2, +/*N*/ const ScMarkData& rMark, +/*N*/ short nDx, short nDy, +/*N*/ const ScCopyBlockFromClipParams* pCBFCP ) +/*N*/ { +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 //STRIP001 // call CopyBlockFromClip for ranges of consecutive non-filtered rows +/*N*/ } + + +/*N*/ void ScDocument::CopyFromClip( const ScRange& rDestRange, const ScMarkData& rMark, +/*N*/ USHORT nInsFlag, +/*N*/ ScDocument* pRefUndoDoc, ScDocument* pClipDoc, BOOL bResetCut, +/*N*/ BOOL bAsLink, BOOL bIncludeFiltered, BOOL bSkipAttrForEmpty ) +/*N*/ { +/*N*/ if (!bIsClip && pClipDoc) +/*N*/ { +/*N*/ if (pClipDoc->bIsClip && pClipDoc->GetTableCount()) +/*N*/ { +/*N*/ BOOL bOldAutoCalc = GetAutoCalc(); +/*N*/ SetAutoCalc( FALSE ); // avoid multiple recalculations +/*N*/ +/*N*/ SvNumberFormatter* pThisFormatter = xPoolHelper->GetFormTable(); +/*N*/ SvNumberFormatter* pOtherFormatter = pClipDoc->xPoolHelper->GetFormTable(); +/*N*/ if (pOtherFormatter && pOtherFormatter != pThisFormatter) +/*N*/ { +/*N*/ SvNumberFormatterIndexTable* pExchangeList = +/*N*/ pThisFormatter->MergeFormatter(*(pOtherFormatter)); +/*N*/ if (pExchangeList->Count() > 0) +/*N*/ pFormatExchangeList = pExchangeList; +/*N*/ } +/*N*/ +/*N*/ USHORT nClipRangeNames = pClipDoc->pRangeName->GetCount(); +/*N*/ // array containing range names which might need update of indices +/*N*/ ScRangeData** pClipRangeNames = nClipRangeNames ? new ScRangeData* [nClipRangeNames] : NULL; +/*N*/ // the index mapping thereof +/*N*/ ScIndexMap aClipRangeMap( nClipRangeNames ); +/*N*/ BOOL bRangeNameReplace = FALSE; +/*N*/ +/*N*/ USHORT i, k; +/*N*/ for (i = 0; i < nClipRangeNames; i++) //! DB-Bereiche Pivot-Bereiche auch +/*N*/ { + /* Copy only if the name doesn't exist in this document. + If it exists we use the already existing name instead, + another possibility could be to create new names if + documents differ. + A proper solution would ask the user how to proceed. + The adjustment of the indices in the formulas is done later. + */ +/*N*/ ScRangeData* pClipData = (*pClipDoc->pRangeName)[i]; +/*N*/ if ( pRangeName->SearchName( pClipData->GetName(), k ) ) +/*N*/ { +/*N*/ pClipRangeNames[i] = NULL; // range name not inserted +/*N*/ USHORT nOldIndex = pClipData->GetIndex(); +/*N*/ USHORT nNewIndex = ((*pRangeName)[k])->GetIndex(); +/*N*/ aClipRangeMap.SetPair( i, nOldIndex, nNewIndex ); +/*N*/ if ( !bRangeNameReplace ) +/*N*/ bRangeNameReplace = ( nOldIndex != nNewIndex ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ ScRangeData* pData = new ScRangeData( *pClipData ); +/*N*/ pData->SetDocument(this); +/*N*/ if ( pRangeName->FindIndex( pData->GetIndex() ) ) +/*N*/ pData->SetIndex(0); // need new index, done in Insert +/*N*/ if ( pRangeName->Insert( pData ) ) +/*N*/ { +/*N*/ pClipRangeNames[i] = pData; +/*N*/ USHORT nOldIndex = pClipData->GetIndex(); +/*N*/ USHORT nNewIndex = pData->GetIndex(); +/*N*/ aClipRangeMap.SetPair( i, nOldIndex, nNewIndex ); +/*N*/ if ( !bRangeNameReplace ) +/*N*/ bRangeNameReplace = ( nOldIndex != nNewIndex ); +/*N*/ } +/*N*/ else +/*N*/ { // must be an overflow +/*N*/ delete pData; +/*N*/ pClipRangeNames[i] = NULL; +/*N*/ aClipRangeMap.SetPair( i, pClipData->GetIndex(), 0 ); +/*N*/ bRangeNameReplace = TRUE; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ USHORT nCol1 = rDestRange.aStart.Col(); +/*N*/ USHORT nRow1 = rDestRange.aStart.Row(); +/*N*/ USHORT nCol2 = rDestRange.aEnd.Col(); +/*N*/ USHORT nRow2 = rDestRange.aEnd.Row(); +/*N*/ +/*N*/ USHORT nXw = pClipDoc->aClipRange.aEnd.Col(); +/*N*/ USHORT nYw = pClipDoc->aClipRange.aEnd.Row(); +/*N*/ pClipDoc->ExtendMerge( pClipDoc->aClipRange.aStart.Col(), +/*N*/ pClipDoc->aClipRange.aStart.Row(), +/*N*/ nXw, nYw, 0 ); +/*N*/ nXw -= pClipDoc->aClipRange.aEnd.Col(); +/*N*/ nYw -= pClipDoc->aClipRange.aEnd.Row(); // only extra value from ExtendMerge +/*N*/ USHORT nDestAddX, nDestAddY; +/*N*/ pClipDoc->GetClipArea( nDestAddX, nDestAddY, bIncludeFiltered ); +/*N*/ nXw += nDestAddX; +/*N*/ nYw += nDestAddY; // ClipArea, plus ExtendMerge value +/*N*/ +/*N*/ // Inhalte entweder komplett oder gar nicht loeschen: +/*N*/ USHORT nDelFlag = IDF_NONE; +/*N*/ if ( nInsFlag & IDF_CONTENTS ) +/*N*/ nDelFlag |= IDF_CONTENTS; +/*N*/ // With bSkipAttrForEmpty, don't remove attributes, copy +/*N*/ // on top of existing attributes instead. +/*N*/ if ( ( nInsFlag & IDF_ATTRIB ) && !bSkipAttrForEmpty ) +/*N*/ nDelFlag |= IDF_ATTRIB; +/*N*/ DeleteArea(nCol1, nRow1, nCol2, nRow2, rMark, nDelFlag); +/*N*/ +/*N*/ bInsertingFromOtherDoc = TRUE; // kein Broadcast/Listener aufbauen bei Insert +/*N*/ USHORT nC1 = nCol1; +/*N*/ USHORT nR1 = nRow1; +/*N*/ USHORT nC2 = nC1 + nXw; +/*N*/ USHORT nR2 = nR1 + nYw; +/*N*/ USHORT nClipStartCol = pClipDoc->aClipRange.aStart.Col(); +/*N*/ USHORT nClipStartRow = pClipDoc->aClipRange.aStart.Row(); +/*N*/ +/*N*/ ScCopyBlockFromClipParams aCBFCP; +/*N*/ aCBFCP.pRefUndoDoc = pRefUndoDoc; +/*N*/ aCBFCP.pClipDoc = pClipDoc; +/*N*/ aCBFCP.nInsFlag = nInsFlag; +/*N*/ aCBFCP.bAsLink = bAsLink; +/*N*/ aCBFCP.bSkipAttrForEmpty = bSkipAttrForEmpty; +/*N*/ aCBFCP.nTabStart = MAXTAB; // wird in der Schleife angepasst +/*N*/ aCBFCP.nTabEnd = 0; // wird in der Schleife angepasst +/*N*/ +/*N*/ // Inc/DecRecalcLevel einmal aussen, damit nicht fuer jeden Block +/*N*/ // die Draw-Seitengroesse neu berechnet werden muss +/*N*/ //! nur wenn ganze Zeilen/Spalten kopiert werden? +/*N*/ +/*N*/ for (i = 0; i <= MAXTAB; i++) +/*N*/ if (pTab[i] && rMark.GetTableSelect(i)) +/*N*/ { +/*N*/ if ( i < aCBFCP.nTabStart ) +/*N*/ aCBFCP.nTabStart = i; +/*N*/ aCBFCP.nTabEnd = i; +/*N*/ pTab[i]->IncRecalcLevel(); +/*N*/ } +/*N*/ +/*N*/ // bei mindestens 64 Zeilen wird in ScColumn::CopyFromClip voralloziert +/*N*/ BOOL bDoDouble = ( nYw < 64 && nRow2 - nRow1 > 64); +/*N*/ BOOL bOldDouble = ScColumn::bDoubleAlloc; +/*N*/ if (bDoDouble) +/*N*/ ScColumn::bDoubleAlloc = TRUE; +/*N*/ +/*N*/ do +/*N*/ { +/*N*/ do +/*N*/ { +/*N*/ short nDx = ((short)nC1) - nClipStartCol; +/*N*/ short nDy = ((short)nR1) - nClipStartRow; +/*N*/ if ( bIncludeFiltered ) +/*N*/ CopyBlockFromClip( nC1, nR1, nC2, nR2, rMark, nDx, nDy, &aCBFCP ); +/*N*/ else +/*N*/ CopyNonFilteredFromClip( nC1, nR1, nC2, nR2, rMark, nDx, nDy, &aCBFCP ); +/*N*/ nC1 = nC2 + 1; +/*N*/ nC2 = Min((USHORT)(nC1 + nXw), nCol2); +/*N*/ } +/*N*/ while (nC1 <= nCol2); +/*N*/ nC1 = nCol1; +/*N*/ nC2 = nC1 + nXw; +/*N*/ nR1 = nR2 + 1; +/*N*/ nR2 = Min((USHORT)(nR1 + nYw), nRow2); +/*N*/ } +/*N*/ while (nR1 <= nRow2); +/*N*/ +/*N*/ ScColumn::bDoubleAlloc = bOldDouble; +/*N*/ +/*N*/ for (i = 0; i <= MAXTAB; i++) +/*N*/ if (pTab[i] && rMark.GetTableSelect(i)) +/*N*/ pTab[i]->DecRecalcLevel(); +/*N*/ +/*N*/ bInsertingFromOtherDoc = FALSE; +/*N*/ pFormatExchangeList = NULL; +/*N*/ if ( bRangeNameReplace ) +/*N*/ { +/*N*/ // first update all inserted named formulas if they contain other +/*N*/ // range names and used indices changed +/*N*/ for (i = 0; i < nClipRangeNames; i++) //! DB-Bereiche Pivot-Bereiche auch +/*N*/ { +/*N*/ if ( pClipRangeNames[i] ) +/*N*/ pClipRangeNames[i]->ReplaceRangeNamesInUse( aClipRangeMap ); +/*N*/ } +/*N*/ // then update the formulas, they might need the just updated range names +/*N*/ USHORT nC1 = nCol1; +/*N*/ USHORT nR1 = nRow1; +/*N*/ USHORT nC2 = nC1 + nXw; +/*N*/ USHORT nR2 = nR1 + nYw; +/*N*/ do +/*N*/ { +/*N*/ do +/*N*/ { +/*N*/ for (k = 0; k <= MAXTAB; k++) +/*N*/ { +/*N*/ if ( pTab[k] && rMark.GetTableSelect(k) ) +/*N*/ pTab[k]->ReplaceRangeNamesInUse(nC1, nR1, +/*N*/ nC2, nR2, aClipRangeMap ); +/*N*/ } +/*N*/ nC1 = nC2 + 1; +/*N*/ nC2 = Min((USHORT)(nC1 + nXw), nCol2); +/*N*/ } while (nC1 <= nCol2); +/*N*/ nC1 = nCol1; +/*N*/ nC2 = nC1 + nXw; +/*N*/ nR1 = nR2 + 1; +/*N*/ nR2 = Min((USHORT)(nR1 + nYw), nRow2); +/*N*/ } while (nR1 <= nRow2); +/*N*/ } +/*N*/ if ( pClipRangeNames ) +/*N*/ delete [] pClipRangeNames; +/*N*/ // Listener aufbauen nachdem alles inserted wurde +/*N*/ StartListeningFromClip( nCol1, nRow1, nCol2, nRow2, rMark, nInsFlag ); +/*N*/ // nachdem alle Listener aufgebaut wurden, kann gebroadcastet werden +/*N*/ BroadcastFromClip( nCol1, nRow1, nCol2, nRow2, rMark, nInsFlag ); +/*N*/ if (bResetCut) +/*N*/ pClipDoc->bCutMode = FALSE; +/*N*/ SetAutoCalc( bOldAutoCalc ); +/*N*/ } +/*N*/ } +/*N*/ } + + + + +/*N*/ void ScDocument::GetClipArea(USHORT& nClipX, USHORT& nClipY, BOOL bIncludeFiltered) +/*N*/ { +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 //STRIP001 if (bIsClip) +/*N*/ } + + + + + + + + + + + + +/*N*/ void ScDocument::PutCell( USHORT nCol, USHORT nRow, USHORT nTab, ScBaseCell* pCell, BOOL bForceTab ) +/*N*/ { +/*N*/ if (VALIDTAB(nTab)) +/*N*/ { +/*N*/ if ( bForceTab && !pTab[nTab] ) +/*N*/ { +/*N*/ BOOL bExtras = !bIsUndo; // Spaltenbreiten, Zeilenhoehen, Flags +/*N*/ +/*N*/ pTab[nTab] = new ScTable(this, nTab, +/*N*/ String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("temp")), +/*N*/ bExtras, bExtras); +/*N*/ ++nMaxTableNumber; +/*N*/ } +/*N*/ +/*N*/ if (pTab[nTab]) +/*N*/ pTab[nTab]->PutCell( nCol, nRow, pCell ); +/*N*/ } +/*N*/ } + + +/*N*/ void ScDocument::PutCell( const ScAddress& rPos, ScBaseCell* pCell, BOOL bForceTab ) +/*N*/ { +/*N*/ USHORT nTab = rPos.Tab(); +/*N*/ if ( bForceTab && !pTab[nTab] ) +/*N*/ { +/*?*/ BOOL bExtras = !bIsUndo; // Spaltenbreiten, Zeilenhoehen, Flags +/*?*/ +/*?*/ pTab[nTab] = new ScTable(this, nTab, +/*?*/ String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("temp")), +/*?*/ bExtras, bExtras); +/*?*/ ++nMaxTableNumber; +/*N*/ } +/*N*/ +/*N*/ if (pTab[nTab]) +/*N*/ pTab[nTab]->PutCell( rPos, pCell ); +/*N*/ } + + +/*N*/ BOOL ScDocument::SetString( USHORT nCol, USHORT nRow, USHORT nTab, const String& rString ) +/*N*/ { +/*N*/ if ( nTab<=MAXTAB && pTab[nTab] ) +/*N*/ return pTab[nTab]->SetString( nCol, nRow, nTab, rString ); +/*N*/ else +/*N*/ return FALSE; +/*N*/ } + + +/*N*/ void ScDocument::SetValue( USHORT nCol, USHORT nRow, USHORT nTab, const double& rVal ) +/*N*/ { +/*N*/ if (VALIDTAB(nTab)) +/*N*/ if (pTab[nTab]) +/*N*/ pTab[nTab]->SetValue( nCol, nRow, rVal ); +/*N*/ } + + +/*N*/ void ScDocument::SetNote( USHORT nCol, USHORT nRow, USHORT nTab, const ScPostIt& rNote ) +/*N*/ { +/*N*/ if (VALIDTAB(nTab)) +/*N*/ if (pTab[nTab]) +/*N*/ pTab[nTab]->SetNote( nCol, nRow, rNote ); +/*N*/ } + + +/*N*/ void ScDocument::GetString( USHORT nCol, USHORT nRow, USHORT nTab, String& rString ) +/*N*/ { +/*N*/ if ( VALIDTAB(nTab) && pTab[nTab] ) +/*N*/ pTab[nTab]->GetString( nCol, nRow, rString ); +/*N*/ else +/*N*/ rString.Erase(); +/*N*/ } + + +/*N*/ void ScDocument::GetInputString( USHORT nCol, USHORT nRow, USHORT nTab, String& rString ) +/*N*/ { +/*N*/ if ( VALIDTAB(nTab) && pTab[nTab] ) +/*N*/ pTab[nTab]->GetInputString( nCol, nRow, rString ); +/*N*/ else +/*N*/ rString.Erase(); +/*N*/ } + + +/*N*/ void ScDocument::GetValue( USHORT nCol, USHORT nRow, USHORT nTab, double& rValue ) +/*N*/ { +/*N*/ if ( VALIDTAB(nTab) && pTab[nTab] ) +/*N*/ rValue = pTab[nTab]->GetValue( nCol, nRow ); +/*N*/ else +/*N*/ rValue = 0.0; +/*N*/ } + + +/*N*/ double ScDocument::GetValue( const ScAddress& rPos ) +/*N*/ { +/*N*/ USHORT nTab = rPos.Tab(); +/*N*/ if ( pTab[nTab] ) +/*N*/ return pTab[nTab]->GetValue( rPos ); +/*N*/ return 0.0; +/*N*/ } + + +/*N*/ void ScDocument::GetNumberFormat( USHORT nCol, USHORT nRow, USHORT nTab, +/*N*/ sal_uInt32& rFormat ) +/*N*/ { +/*N*/ if (VALIDTAB(nTab)) +/*N*/ if (pTab[nTab]) +/*N*/ { +/*N*/ rFormat = pTab[nTab]->GetNumberFormat( nCol, nRow ); +/*N*/ return ; +/*N*/ } +/*N*/ rFormat = 0; +/*N*/ } + + +/*N*/ ULONG ScDocument::GetNumberFormat( const ScAddress& rPos ) const +/*N*/ { +/*N*/ USHORT nTab = rPos.Tab(); +/*N*/ if ( pTab[nTab] ) +/*N*/ return pTab[nTab]->GetNumberFormat( rPos ); +/*N*/ return 0; +/*N*/ } + + +/*N*/ void ScDocument::GetNumberFormatInfo( short& nType, ULONG& nIndex, +/*N*/ const ScAddress& rPos, const ScFormulaCell& rFCell ) const +/*N*/ { +/*N*/ USHORT nTab = rPos.Tab(); +/*N*/ if ( pTab[nTab] ) +/*N*/ { +/*N*/ nIndex = pTab[nTab]->GetNumberFormat( rPos ); +/*N*/ if ( (nIndex % SV_COUNTRY_LANGUAGE_OFFSET) == 0 ) +/*N*/ rFCell.GetFormatInfo( nType, nIndex ); +/*N*/ else +/*N*/ nType = GetFormatTable()->GetType( nIndex ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ nType = NUMBERFORMAT_UNDEFINED; +/*N*/ nIndex = 0; +/*N*/ } +/*N*/ } + + +/*N*/ BOOL ScDocument::GetNote( USHORT nCol, USHORT nRow, USHORT nTab, ScPostIt& rNote ) +/*N*/ { +/*N*/ BOOL bHasNote = FALSE; +/*N*/ +/*N*/ if ( VALIDTAB(nTab) && pTab[nTab] ) +/*N*/ bHasNote = pTab[nTab]->GetNote( nCol, nRow, rNote ); +/*N*/ else +/*?*/ rNote.Clear(); +/*N*/ +/*N*/ return bHasNote; +/*N*/ } + + +/*N*/ CellType ScDocument::GetCellType( const ScAddress& rPos ) const +/*N*/ { +/*N*/ USHORT nTab = rPos.Tab(); +/*N*/ if ( pTab[nTab] ) +/*N*/ return pTab[nTab]->GetCellType( rPos ); +/*N*/ return CELLTYPE_NONE; +/*N*/ } + + +/*N*/ void ScDocument::GetCellType( USHORT nCol, USHORT nRow, USHORT nTab, +/*N*/ CellType& rCellType ) const +/*N*/ { +/*N*/ if (nTab<=MAXTAB && pTab[nTab]) +/*N*/ rCellType = pTab[nTab]->GetCellType( nCol, nRow ); +/*N*/ else +/*N*/ rCellType = CELLTYPE_NONE; +/*N*/ } + + +/*N*/ void ScDocument::GetCell( USHORT nCol, USHORT nRow, USHORT nTab, +/*N*/ ScBaseCell*& rpCell ) const +/*N*/ { +/*N*/ if (nTab<=MAXTAB && pTab[nTab]) +/*N*/ rpCell = pTab[nTab]->GetCell( nCol, nRow ); +/*N*/ else +/*N*/ { +/*N*/ DBG_ERROR("GetCell ohne Tabelle"); +/*N*/ rpCell = NULL; +/*N*/ } +/*N*/ } + + +/*N*/ ScBaseCell* ScDocument::GetCell( const ScAddress& rPos ) const +/*N*/ { +/*N*/ USHORT nTab = rPos.Tab(); +/*N*/ if ( pTab[nTab] ) +/*N*/ return pTab[nTab]->GetCell( rPos ); +/*N*/ +/*N*/ DBG_ERROR("GetCell ohne Tabelle"); +/*N*/ return NULL; +/*N*/ } + + +/*N*/ BOOL ScDocument::HasStringData( USHORT nCol, USHORT nRow, USHORT nTab ) const +/*N*/ { +/*N*/ if ( VALIDTAB(nTab) && pTab[nTab] ) +/*N*/ return pTab[nTab]->HasStringData( nCol, nRow ); +/*N*/ else +/*N*/ return FALSE; +/*N*/ } + + +/*N*/ BOOL ScDocument::HasValueData( USHORT nCol, USHORT nRow, USHORT nTab ) const +/*N*/ { +/*N*/ if ( VALIDTAB(nTab) && pTab[nTab] ) +/*N*/ return pTab[nTab]->HasValueData( nCol, nRow ); +/*N*/ else +/*N*/ return FALSE; +/*N*/ } + + + + + + +/*N*/ void ScDocument::SetDirty() +/*N*/ { +/*N*/ BOOL bOldAutoCalc = GetAutoCalc(); +/*N*/ bAutoCalc = FALSE; // keine Mehrfachberechnung +/*N*/ for (USHORT i=0; i<=MAXTAB; i++) +/*N*/ if (pTab[i]) pTab[i]->SetDirty(); +/*N*/ +/*N*/ // Charts werden zwar auch ohne AutoCalc im Tracking auf Dirty gesetzt, +/*N*/ // wenn alle Formeln dirty sind, werden die Charts aber nicht mehr erwischt +/*N*/ // (#45205#) - darum alle Charts nochmal explizit +/*N*/ if (pChartListenerCollection) +/*N*/ pChartListenerCollection->SetDirty(); +/*N*/ +/*N*/ SetAutoCalc( bOldAutoCalc ); +/*N*/ } + + +/*N*/ void ScDocument::SetDirty( const ScRange& rRange ) +/*N*/ { +/*N*/ BOOL bOldAutoCalc = GetAutoCalc(); +/*N*/ bAutoCalc = FALSE; // keine Mehrfachberechnung +/*N*/ USHORT nTab2 = rRange.aEnd.Tab(); +/*N*/ for (USHORT i=rRange.aStart.Tab(); i<=nTab2; i++) +/*N*/ if (pTab[i]) pTab[i]->SetDirty( rRange ); +/*N*/ SetAutoCalc( bOldAutoCalc ); +/*N*/ } + + +/*N*/ void ScDocument::SetTableOpDirty( const ScRange& rRange ) +/*N*/ { +/*N*/ BOOL bOldAutoCalc = GetAutoCalc(); +/*N*/ bAutoCalc = FALSE; // no multiple recalculation +/*N*/ USHORT nTab2 = rRange.aEnd.Tab(); +/*N*/ for (USHORT i=rRange.aStart.Tab(); i<=nTab2; i++) +/*N*/ if (pTab[i]) pTab[i]->SetTableOpDirty( rRange ); +/*N*/ SetAutoCalc( bOldAutoCalc ); +/*N*/ } + + +/*N*/ void ScDocument::AddTableOpFormulaCell( ScFormulaCell* pCell ) +/*N*/ { +/*N*/ ScInterpreterTableOpParams* p = aTableOpList.Last(); +/*N*/ if ( p && p->bCollectNotifications ) +/*N*/ { +/*N*/ if ( p->bRefresh ) +/*N*/ { // refresh pointers only +/*N*/ p->aNotifiedFormulaCells.push_back( pCell ); +/*N*/ } +/*N*/ else +/*N*/ { // init both, address and pointer +/*N*/ p->aNotifiedFormulaCells.push_back( pCell ); +/*N*/ p->aNotifiedFormulaPos.push_back( pCell->aPos ); +/*N*/ } +/*N*/ } +/*N*/ } + + +/*N*/ void ScDocument::CalcAll() +/*N*/ { +/*N*/ BOOL bOldAutoCalc = GetAutoCalc(); +/*N*/ SetAutoCalc( TRUE ); +/*N*/ USHORT i; +/*N*/ for (i=0; i<=MAXTAB; i++) +/*N*/ if (pTab[i]) pTab[i]->SetDirtyVar(); +/*N*/ for (i=0; i<=MAXTAB; i++) +/*N*/ if (pTab[i]) pTab[i]->CalcAll(); +/*N*/ ClearFormulaTree(); +/*N*/ SetAutoCalc( bOldAutoCalc ); +/*N*/ } + + + + +/*N*/ void ScDocument::CompileXML() +/*N*/ { +/*N*/ BOOL bOldAutoCalc = GetAutoCalc(); +/*N*/ SetAutoCalc( FALSE ); +/*N*/ ScProgress aProgress( GetDocumentShell(), ScGlobal::GetRscString( +/*N*/ STR_PROGRESS_CALCULATING ), GetXMLImportedFormulaCount() ); +/*N*/ +/*N*/ for (USHORT i=0; i<=MAXTAB; i++) +/*N*/ if (pTab[i]) pTab[i]->CompileXML( aProgress ); +/*N*/ +/*N*/ if ( pCondFormList ) +/*N*/ pCondFormList->CompileXML(); +/*N*/ if ( pValidationList ) +/*N*/ pValidationList->CompileXML(); +/*N*/ +/*N*/ SetDirty(); +/*N*/ SetAutoCalc( bOldAutoCalc ); +/*N*/ } + + +/*N*/ void ScDocument::CalcAfterLoad() +/*N*/ { +/*N*/ if (bIsClip) // Excel-Dateien werden aus dem Clipboard in ein Clip-Doc geladen +/*N*/ return; // dann wird erst beim Einfuegen in das richtige Doc berechnet +/*N*/ +/*N*/ bCalcingAfterLoad = TRUE; +/*N*/ USHORT i=0; +/*N*/ for (i=0; i<=MAXTAB; i++) +/*N*/ if (pTab[i]) pTab[i]->CalcAfterLoad(); +/*N*/ for (i=0; i<=MAXTAB; i++) +/*N*/ if (pTab[i]) pTab[i]->SetDirtyAfterLoad(); +/*N*/ bCalcingAfterLoad = FALSE; +/*N*/ +/*N*/ SetDetectiveDirty(FALSE); // noch keine wirklichen Aenderungen +/*N*/ } + + +/*N*/ USHORT ScDocument::GetErrCode( const ScAddress& rPos ) const +/*N*/ { +/*N*/ USHORT nTab = rPos.Tab(); +/*N*/ if ( pTab[nTab] ) +/*N*/ return pTab[nTab]->GetErrCode( rPos ); +/*N*/ return 0; +/*N*/ } + + +/*N*/ void ScDocument::ResetChanged( const ScRange& rRange ) +/*N*/ { +/*N*/ USHORT nStartTab = rRange.aStart.Tab(); +/*N*/ USHORT nEndTab = rRange.aEnd.Tab(); +/*N*/ for (USHORT nTab=nStartTab; nTab<=nEndTab; nTab++) +/*N*/ if (pTab[nTab]) +/*N*/ pTab[nTab]->ResetChanged( rRange ); +/*N*/ } + +// +// Spaltenbreiten / Zeilenhoehen -------------------------------------- +// + + +/*N*/ void ScDocument::SetColWidth( USHORT nCol, USHORT nTab, USHORT nNewWidth ) +/*N*/ { +/*N*/ if ( nTab<=MAXTAB && pTab[nTab] ) +/*N*/ pTab[nTab]->SetColWidth( nCol, nNewWidth ); +/*N*/ } + + + + +/*N*/ void ScDocument::SetRowHeightRange( USHORT nStartRow, USHORT nEndRow, USHORT nTab, USHORT nNewHeight ) +/*N*/ { +/*N*/ if ( nTab<=MAXTAB && pTab[nTab] ) +/*N*/ pTab[nTab]->SetRowHeightRange +/*N*/ ( nStartRow, nEndRow, nNewHeight, 1.0, 1.0 ); +/*N*/ } + + +/*N*/ void ScDocument::SetManualHeight( USHORT nStartRow, USHORT nEndRow, USHORT nTab, BOOL bManual ) +/*N*/ { +/*N*/ if ( nTab<=MAXTAB && pTab[nTab] ) +/*N*/ pTab[nTab]->SetManualHeight( nStartRow, nEndRow, bManual ); +/*N*/ } + + +/*N*/ USHORT ScDocument::GetColWidth( USHORT nCol, USHORT nTab ) const +/*N*/ { +/*N*/ if ( nTab<=MAXTAB && pTab[nTab] ) +/*N*/ return pTab[nTab]->GetColWidth( nCol ); +/*N*/ DBG_ERROR("Falsche Tabellennummer"); +/*N*/ return 0; +/*N*/ } + + +/*N*/ USHORT ScDocument::GetOriginalWidth( USHORT nCol, USHORT nTab ) const +/*N*/ { +/*N*/ if ( nTab<=MAXTAB && pTab[nTab] ) +/*N*/ return pTab[nTab]->GetOriginalWidth( nCol ); +/*N*/ DBG_ERROR("Falsche Tabellennummer"); +/*N*/ return 0; +/*N*/ } + + + + +/*N*/ USHORT ScDocument::GetOriginalHeight( USHORT nRow, USHORT nTab ) const +/*N*/ { +/*N*/ if ( nTab<=MAXTAB && pTab[nTab] ) +/*N*/ return pTab[nTab]->GetOriginalHeight( nRow ); +/*N*/ DBG_ERROR("Wrong table number"); +/*N*/ return 0; +/*N*/ } + + +/*N*/ USHORT ScDocument::GetRowHeight( USHORT nRow, USHORT nTab ) const +/*N*/ { +/*N*/ if ( nTab<=MAXTAB && pTab[nTab] ) +/*N*/ return pTab[nTab]->GetRowHeight( nRow ); +/*N*/ DBG_ERROR("Falsche Tabellennummer"); +/*N*/ return 0; +/*N*/ } + + +/*N*/ USHORT ScDocument::GetHiddenRowCount( USHORT nRow, USHORT nTab ) const +/*N*/ { +/*N*/ if ( nTab<=MAXTAB && pTab[nTab] ) +/*N*/ return pTab[nTab]->GetHiddenRowCount( nRow ); +/*N*/ DBG_ERROR("Falsche Tabellennummer"); +/*N*/ return 0; +/*N*/ } + + + + + + +/*N*/ USHORT ScDocument::GetOptimalColWidth( USHORT nCol, USHORT nTab, OutputDevice* pDev, +/*N*/ double nPPTX, double nPPTY, +/*N*/ const Fraction& rZoomX, const Fraction& rZoomY, +/*N*/ BOOL bFormula, const ScMarkData* pMarkData, +/*N*/ BOOL bSimpleTextImport ) +/*N*/ { +/*N*/ if ( nTab<=MAXTAB && pTab[nTab] ) +/*N*/ return pTab[nTab]->GetOptimalColWidth( nCol, pDev, nPPTX, nPPTY, +/*N*/ rZoomX, rZoomY, bFormula, pMarkData, bSimpleTextImport ); +/*N*/ DBG_ERROR("Falsche Tabellennummer"); +/*N*/ return 0; +/*N*/ } + + + + +/*N*/ BOOL ScDocument::SetOptimalHeight( USHORT nStartRow, USHORT nEndRow, USHORT nTab, USHORT nExtra, +/*N*/ OutputDevice* pDev, +/*N*/ double nPPTX, double nPPTY, +/*N*/ const Fraction& rZoomX, const Fraction& rZoomY, +/*N*/ BOOL bShrink ) +/*N*/ { +/*N*/ //! MarkToMulti(); +/*N*/ if ( nTab<=MAXTAB && pTab[nTab] ) +/*N*/ return pTab[nTab]->SetOptimalHeight( nStartRow, nEndRow, nExtra, +/*N*/ pDev, nPPTX, nPPTY, rZoomX, rZoomY, bShrink ); +/*N*/ DBG_ERROR("Falsche Tabellennummer"); +/*N*/ return FALSE; +/*N*/ } + + +// +// Spalten-/Zeilen-Flags ---------------------------------------------- +// + +/*N*/ void ScDocument::ShowCol(USHORT nCol, USHORT nTab, BOOL bShow) +/*N*/ { +/*N*/ if ( nTab<=MAXTAB && pTab[nTab] ) +/*N*/ pTab[nTab]->ShowCol( nCol, bShow ); +/*N*/ } + + +/*N*/ void ScDocument::ShowRows(USHORT nRow1, USHORT nRow2, USHORT nTab, BOOL bShow) +/*N*/ { +/*N*/ if ( nTab<=MAXTAB && pTab[nTab] ) +/*N*/ pTab[nTab]->ShowRows( nRow1, nRow2, bShow ); +/*N*/ } + + + + +/*N*/ void ScDocument::SetRowFlags( USHORT nRow, USHORT nTab, BYTE nNewFlags ) +/*N*/ { +/*N*/ if ( nTab<=MAXTAB && pTab[nTab] ) +/*N*/ pTab[nTab]->SetRowFlags( nRow, nNewFlags ); +/*N*/ } + + +/*N*/ BYTE ScDocument::GetColFlags( USHORT nCol, USHORT nTab ) const +/*N*/ { +/*N*/ if ( nTab<=MAXTAB && pTab[nTab] ) +/*N*/ return pTab[nTab]->GetColFlags( nCol ); +/*N*/ DBG_ERROR("Falsche Tabellennummer"); +/*N*/ return 0; +/*N*/ } + +/*N*/ BYTE ScDocument::GetRowFlags( USHORT nRow, USHORT nTab ) const +/*N*/ { +/*N*/ if ( nTab<=MAXTAB && pTab[nTab] ) +/*N*/ return pTab[nTab]->GetRowFlags( nRow ); +/*N*/ DBG_ERROR("Falsche Tabellennummer"); +/*N*/ return 0; +/*N*/ } + + + + + +/*N*/ USHORT ScDocument::GetLastChangedCol( USHORT nTab ) const +/*N*/ { +/*N*/ if ( nTab<=MAXTAB && pTab[nTab] ) +/*N*/ return pTab[nTab]->GetLastChangedCol(); +/*N*/ return 0; +/*N*/ } + +/*N*/ USHORT ScDocument::GetLastChangedRow( USHORT nTab ) const +/*N*/ { +/*N*/ if ( nTab<=MAXTAB && pTab[nTab] ) +/*N*/ return pTab[nTab]->GetLastChangedRow(); +/*N*/ return 0; +/*N*/ } + + +/*N*/ USHORT ScDocument::GetNextDifferentChangedCol( USHORT nTab, USHORT nStart) const +/*N*/ { +/*N*/ if ( nTab<=MAXTAB && pTab[nTab] ) +/*N*/ { +/*N*/ BYTE nStartFlags = pTab[nTab]->GetColFlags(nStart); +/*N*/ USHORT nStartWidth = pTab[nTab]->GetOriginalWidth(nStart); +/*N*/ for (USHORT nCol = nStart + 1; nCol <= MAXCOL; nCol++) +/*N*/ { +/*N*/ if (((nStartFlags & CR_MANUALBREAK) != (pTab[nTab]->GetColFlags(nCol) & CR_MANUALBREAK)) || +/*N*/ (nStartWidth != pTab[nTab]->GetOriginalWidth(nCol)) || +/*N*/ ((nStartFlags & CR_HIDDEN) != (pTab[nTab]->GetColFlags(nCol) & CR_HIDDEN)) ) +/*N*/ return nCol; +/*N*/ } +/*N*/ return MAXCOL; +/*N*/ } +/*N*/ return 0; +/*N*/ } + +/*N*/ USHORT ScDocument::GetNextDifferentChangedRow( USHORT nTab, USHORT nStart, bool bCareManualSize) const +/*N*/ { +/*N*/ if ( nTab<=MAXTAB && pTab[nTab] ) +/*N*/ { +/*N*/ BYTE nStartFlags = pTab[nTab]->GetRowFlags(nStart); +/*N*/ USHORT nStartHeight = pTab[nTab]->GetOriginalHeight(nStart); +/*N*/ for (USHORT nRow = nStart + 1; nRow <= MAXROW; nRow++) +/*N*/ { +/*N*/ if (((nStartFlags & CR_MANUALBREAK) != (pTab[nTab]->GetRowFlags(nRow) & CR_MANUALBREAK)) || +/*N*/ ((nStartFlags & CR_MANUALSIZE) != (pTab[nTab]->GetRowFlags(nRow) & CR_MANUALSIZE)) || +/*N*/ (bCareManualSize && (nStartFlags & CR_MANUALSIZE) && (nStartHeight != pTab[nTab]->GetOriginalHeight(nRow))) || +/*N*/ (!bCareManualSize && ((nStartHeight != pTab[nTab]->GetOriginalHeight(nRow))))) +/*N*/ return nRow; +/*N*/ } +/*N*/ return MAXROW; +/*N*/ } +/*N*/ return 0; +/*N*/ } + +/*N*/ BOOL ScDocument::GetColDefault( USHORT nTab, USHORT nCol, USHORT nLastRow, USHORT& nDefault) +/*N*/ { +/*N*/ BOOL bRet(FALSE); +/*N*/ nDefault = 0; +/*N*/ ScDocAttrIterator aDocAttrItr(this, nTab, nCol, 0, nCol, nLastRow); +/*N*/ USHORT nColumn, nStartRow, nEndRow; +/*N*/ const ScPatternAttr* pAttr = aDocAttrItr.GetNext(nColumn, nStartRow, nEndRow); +/*N*/ if (nEndRow < nLastRow) +/*N*/ { +/*N*/ ScDefaultAttrSet aSet; +/*N*/ ScDefaultAttrSet::iterator aItr = aSet.end(); +/*N*/ while (pAttr) +/*N*/ { +/*N*/ ScDefaultAttr aAttr(pAttr); +/*N*/ aItr = aSet.find(aAttr); +/*N*/ if (aItr == aSet.end()) +/*N*/ { +/*N*/ aAttr.nCount = nEndRow - nStartRow + 1; +/*N*/ aAttr.nFirst = nStartRow; +/*N*/ aSet.insert(aAttr); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ aAttr.nCount = aItr->nCount + nEndRow - nStartRow + 1; +/*N*/ aAttr.nFirst = aItr->nFirst; +/*N*/ aSet.erase(aItr); +/*N*/ aSet.insert(aAttr); +/*N*/ } +/*N*/ pAttr = aDocAttrItr.GetNext(nColumn, nStartRow, nEndRow); +/*N*/ } +/*N*/ ScDefaultAttrSet::iterator aDefaultItr = aSet.begin(); +/*N*/ aItr = aDefaultItr; +/*N*/ aItr++; +/*N*/ while (aItr != aSet.end()) +/*N*/ { +/*N*/ if (aItr->nCount > aDefaultItr->nCount) +/*N*/ aDefaultItr = aItr; +/*N*/ aItr++; +/*N*/ } +/*N*/ nDefault = aDefaultItr->nFirst; +/*N*/ bRet = TRUE; +/*N*/ } +/*N*/ else +/*N*/ bRet = TRUE; +/*N*/ return bRet; +/*N*/ } + +/*N*/ BOOL ScDocument::GetRowDefault( USHORT nTab, USHORT nRow, USHORT nLastCol, USHORT& nDefault) +/*N*/ { +/*N*/ BOOL bRet(FALSE); +/*N*/ return bRet; +/*N*/ } + +// +// Attribute ---------------------------------------------------------- +// + +/*N*/ const SfxPoolItem* ScDocument::GetAttr( USHORT nCol, USHORT nRow, USHORT nTab, USHORT nWhich ) const +/*N*/ { +/*N*/ if ( nTab <= MAXTAB && pTab[nTab] ) +/*N*/ { +/*N*/ const SfxPoolItem* pTemp = pTab[nTab]->GetAttr( nCol, nRow, nWhich ); +/*N*/ if (pTemp) +/*N*/ return pTemp; +/*N*/ else +/*N*/ DBG_ERROR( "Attribut Null" ); +/*N*/ } +/*N*/ return &xPoolHelper->GetDocPool()->GetDefaultItem( nWhich ); +/*N*/ } + + +/*N*/ const ScPatternAttr* ScDocument::GetPattern( USHORT nCol, USHORT nRow, USHORT nTab ) const +/*N*/ { +/*N*/ if ( nTab <= MAXTAB && pTab[nTab] ) +/*N*/ return pTab[nTab]->GetPattern( nCol, nRow ); +/*N*/ return NULL; +/*N*/ } + + +/*N*/ void ScDocument::ApplyAttr( USHORT nCol, USHORT nRow, USHORT nTab, const SfxPoolItem& rAttr ) +/*N*/ { +/*N*/ if ( nTab <= MAXTAB && pTab[nTab] ) +/*N*/ pTab[nTab]->ApplyAttr( nCol, nRow, rAttr ); +/*N*/ } + + + + +/*N*/ void ScDocument::ApplyPatternArea( USHORT nStartCol, USHORT nStartRow, +/*N*/ USHORT nEndCol, USHORT nEndRow, +/*N*/ const ScMarkData& rMark, +/*N*/ const ScPatternAttr& rAttr ) +/*N*/ { +/*N*/ for (USHORT i=0; i <= MAXTAB; i++) +/*N*/ if (pTab[i]) +/*N*/ if (rMark.GetTableSelect(i)) +/*N*/ pTab[i]->ApplyPatternArea( nStartCol, nStartRow, nEndCol, nEndRow, rAttr ); +/*N*/ } + + +/*N*/ void ScDocument::ApplyPatternAreaTab( USHORT nStartCol, USHORT nStartRow, +/*N*/ USHORT nEndCol, USHORT nEndRow, USHORT nTab, const ScPatternAttr& rAttr ) +/*N*/ { +/*N*/ if (VALIDTAB(nTab)) +/*N*/ if (pTab[nTab]) +/*N*/ pTab[nTab]->ApplyPatternArea( nStartCol, nStartRow, nEndCol, nEndRow, rAttr ); +/*N*/ } + + + + + +/*N*/ void ScDocument::ApplyStyleArea( USHORT nStartCol, USHORT nStartRow, +/*N*/ USHORT nEndCol, USHORT nEndRow, +/*N*/ const ScMarkData& rMark, +/*N*/ const ScStyleSheet& rStyle) +/*N*/ { +/*N*/ for (USHORT i=0; i <= MAXTAB; i++) +/*N*/ if (pTab[i]) +/*N*/ if (rMark.GetTableSelect(i)) +/*N*/ pTab[i]->ApplyStyleArea( nStartCol, nStartRow, nEndCol, nEndRow, rStyle ); +/*N*/ } + + +/*N*/ void ScDocument::ApplyStyleAreaTab( USHORT nStartCol, USHORT nStartRow, +/*N*/ USHORT nEndCol, USHORT nEndRow, USHORT nTab, const ScStyleSheet& rStyle) +/*N*/ { +/*N*/ if (VALIDTAB(nTab)) +/*N*/ if (pTab[nTab]) +/*N*/ pTab[nTab]->ApplyStyleArea( nStartCol, nStartRow, nEndCol, nEndRow, rStyle ); +/*N*/ } + + +/*N*/ void ScDocument::ApplySelectionStyle(const ScStyleSheet& rStyle, const ScMarkData& rMark) +/*N*/ { +/*N*/ // ApplySelectionStyle needs multi mark +/*N*/ if ( rMark.IsMarked() && !rMark.IsMultiMarked() ) +/*N*/ { +/*N*/ ScRange aRange; +/*N*/ rMark.GetMarkArea( aRange ); +/*N*/ ApplyStyleArea( aRange.aStart.Col(), aRange.aStart.Row(), +/*N*/ aRange.aEnd.Col(), aRange.aEnd.Row(), rMark, rStyle ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ for (USHORT i=0; i<=MAXTAB; i++) +/*N*/ if ( pTab[i] && rMark.GetTableSelect(i) ) +/*N*/ pTab[i]->ApplySelectionStyle( rStyle, rMark ); +/*N*/ } +/*N*/ } + +/*N*/ const ScStyleSheet* ScDocument::GetSelectionStyle( const ScMarkData& rMark ) const +/*N*/ { +/*N*/ BOOL bEqual = TRUE; +/*N*/ BOOL bFound; +/*N*/ USHORT i; +/*N*/ +/*N*/ const ScStyleSheet* pStyle = NULL; +/*N*/ const ScStyleSheet* pNewStyle; +/*N*/ +/*N*/ if ( rMark.IsMultiMarked() ) +/*N*/ for (i=0; i<=MAXTAB && bEqual; i++) +/*N*/ if (pTab[i] && rMark.GetTableSelect(i)) +/*N*/ { +/*N*/ pNewStyle = pTab[i]->GetSelectionStyle( rMark, bFound ); +/*N*/ if (bFound) +/*N*/ { +/*N*/ if ( !pNewStyle || ( pStyle && pNewStyle != pStyle ) ) +/*N*/ bEqual = FALSE; // unterschiedliche +/*N*/ pStyle = pNewStyle; +/*N*/ } +/*N*/ } +/*N*/ if ( rMark.IsMarked() ) +/*N*/ { +/*N*/ ScRange aRange; +/*N*/ rMark.GetMarkArea( aRange ); +/*N*/ for (i=aRange.aStart.Tab(); i<=aRange.aEnd.Tab() && bEqual; i++) +/*N*/ if (pTab[i] && rMark.GetTableSelect(i)) +/*N*/ { +/*N*/ pNewStyle = pTab[i]->GetAreaStyle( bFound, +/*N*/ aRange.aStart.Col(), aRange.aStart.Row(), +/*N*/ aRange.aEnd.Col(), aRange.aEnd.Row() ); +/*N*/ if (bFound) +/*N*/ { +/*N*/ if ( !pNewStyle || ( pStyle && pNewStyle != pStyle ) ) +/*N*/ bEqual = FALSE; // unterschiedliche +/*N*/ pStyle = pNewStyle; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ return bEqual ? pStyle : NULL; +/*N*/ } + + +/*N*/ void ScDocument::StyleSheetChanged( const SfxStyleSheetBase* pStyleSheet, BOOL bRemoved, +/*N*/ OutputDevice* pDev, +/*N*/ double nPPTX, double nPPTY, +/*N*/ const Fraction& rZoomX, const Fraction& rZoomY ) +/*N*/ { +/*N*/ for (USHORT i=0; i <= MAXTAB; i++) +/*N*/ if (pTab[i]) +/*N*/ pTab[i]->StyleSheetChanged +/*N*/ ( pStyleSheet, bRemoved, pDev, nPPTX, nPPTY, rZoomX, rZoomY ); +/*N*/ +/*N*/ if ( pStyleSheet && pStyleSheet->GetName() == ScGlobal::GetRscString(STR_STYLENAME_STANDARD) ) +/*N*/ { +/*N*/ // update attributes for all note objects +/*N*/ +/*N*/ ScDetectiveFunc aFunc( this, 0 ); +/*N*/ aFunc.UpdateAllComments(); +/*N*/ } +/*N*/ } + + +/*N*/ BOOL ScDocument::IsStyleSheetUsed( const ScStyleSheet& rStyle, BOOL bGatherAllStyles ) const +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); return FALSE; //STRIP001 +/*N*/ } + + + + + +/*N*/ BOOL ScDocument::ApplyFlagsTab( USHORT nStartCol, USHORT nStartRow, +/*N*/ USHORT nEndCol, USHORT nEndRow, USHORT nTab, INT16 nFlags ) +/*N*/ { +/*N*/ if (VALIDTAB(nTab)) +/*N*/ if (pTab[nTab]) +/*N*/ return pTab[nTab]->ApplyFlags( nStartCol, nStartRow, nEndCol, nEndRow, nFlags ); +/*N*/ +/*N*/ DBG_ERROR("ApplyFlags: falsche Tabelle"); +/*N*/ return FALSE; +/*N*/ } + + + + +/*N*/ BOOL ScDocument::RemoveFlagsTab( USHORT nStartCol, USHORT nStartRow, +/*N*/ USHORT nEndCol, USHORT nEndRow, USHORT nTab, INT16 nFlags ) +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); //STRIP001 +/*N*/ return FALSE; +/*N*/ } + + + + + + +/*N*/ ScPatternAttr* ScDocument::CreateSelectionPattern( const ScMarkData& rMark, BOOL bDeep ) +/*N*/ { +/*N*/ SfxItemSet* pSet = NULL; +/*N*/ USHORT i; +/*N*/ +/*N*/ if ( rMark.IsMultiMarked() ) // multi selection +/*N*/ { +/*N*/ for (i=0; i<=MAXTAB; i++) +/*N*/ if (pTab[i] && rMark.GetTableSelect(i)) +/*N*/ pTab[i]->MergeSelectionPattern( &pSet, rMark, bDeep ); +/*N*/ } +/*N*/ if ( rMark.IsMarked() ) // simle selection +/*N*/ { +/*N*/ ScRange aRange; +/*N*/ rMark.GetMarkArea(aRange); +/*N*/ for (i=0; i<=MAXTAB; i++) +/*N*/ if (pTab[i] && rMark.GetTableSelect(i)) +/*N*/ pTab[i]->MergePatternArea( &pSet, +/*N*/ aRange.aStart.Col(), aRange.aStart.Row(), +/*N*/ aRange.aEnd.Col(), aRange.aEnd.Row(), bDeep ); +/*N*/ } +/*N*/ +/*N*/ DBG_ASSERT( pSet, "SelectionPattern Null" ); +/*N*/ if (pSet) +/*N*/ return new ScPatternAttr( pSet ); +/*N*/ else +/*?*/ return new ScPatternAttr( GetPool() ); // empty +/*N*/ } + + +/*N*/ void ScDocument::GetSelectionFrame( const ScMarkData& rMark, +/*N*/ SvxBoxItem& rLineOuter, +/*N*/ SvxBoxInfoItem& rLineInner ) +/*N*/ { +/*N*/ rLineOuter.SetLine(NULL, BOX_LINE_TOP); +/*N*/ rLineOuter.SetLine(NULL, BOX_LINE_BOTTOM); +/*N*/ rLineOuter.SetLine(NULL, BOX_LINE_LEFT); +/*N*/ rLineOuter.SetLine(NULL, BOX_LINE_RIGHT); +/*N*/ rLineOuter.SetDistance(0); +/*N*/ +/*N*/ rLineInner.SetLine(NULL, BOXINFO_LINE_HORI); +/*N*/ rLineInner.SetLine(NULL, BOXINFO_LINE_VERT); +/*N*/ rLineInner.SetTable(TRUE); +/*N*/ rLineInner.SetDist((BOOL)FALSE); +/*N*/ rLineInner.SetMinDist(FALSE); +/*N*/ +/*N*/ ScLineFlags aFlags; +/*N*/ +/*N*/ if (rMark.IsMarked()) +/*N*/ { +/*N*/ ScRange aRange; +/*N*/ rMark.GetMarkArea(aRange); +/*N*/ rLineInner.SetTable(aRange.aStart!=aRange.aEnd); +/*N*/ for (USHORT i=0; i<=MAXTAB; i++) +/*N*/ if (pTab[i] && rMark.GetTableSelect(i)) +/*N*/ pTab[i]->MergeBlockFrame( &rLineOuter, &rLineInner, aFlags, +/*N*/ aRange.aStart.Col(), aRange.aStart.Row(), +/*N*/ aRange.aEnd.Col(), aRange.aEnd.Row() ); +/*N*/ } +/*N*/ +/*N*/ // Don't care Status auswerten +/*N*/ +/*N*/ rLineInner.SetValid( VALID_LEFT, ( aFlags.nLeft != SC_LINE_DONTCARE ) ); +/*N*/ rLineInner.SetValid( VALID_RIGHT, ( aFlags.nRight != SC_LINE_DONTCARE ) ); +/*N*/ rLineInner.SetValid( VALID_TOP, ( aFlags.nTop != SC_LINE_DONTCARE ) ); +/*N*/ rLineInner.SetValid( VALID_BOTTOM, ( aFlags.nBottom != SC_LINE_DONTCARE ) ); +/*N*/ rLineInner.SetValid( VALID_HORI, ( aFlags.nHori != SC_LINE_DONTCARE ) ); +/*N*/ rLineInner.SetValid( VALID_VERT, ( aFlags.nVert != SC_LINE_DONTCARE ) ); +/*N*/ } + + +/*N*/ BOOL ScDocument::HasAttrib( USHORT nCol1, USHORT nRow1, USHORT nTab1, +/*N*/ USHORT nCol2, USHORT nRow2, USHORT nTab2, USHORT nMask ) +/*N*/ { +/*N*/ if ( nMask & HASATTR_ROTATE ) +/*N*/ { +/*N*/ // Attribut im Dokument ueberhaupt verwendet? +/*N*/ // (wie in fillinfo) +/*N*/ +/*N*/ ScDocumentPool* pPool = xPoolHelper->GetDocPool(); +/*N*/ +/*N*/ BOOL bAnyItem = FALSE; +/*N*/ USHORT nRotCount = pPool->GetItemCount( ATTR_ROTATE_VALUE ); +/*N*/ for (USHORT nItem=0; nItem<nRotCount; nItem++) +/*N*/ if (pPool->GetItem( ATTR_ROTATE_VALUE, nItem )) +/*N*/ { +/*N*/ bAnyItem = TRUE; +/*N*/ break; +/*N*/ } +/*N*/ if (!bAnyItem) +/*N*/ nMask &= ~HASATTR_ROTATE; +/*N*/ } +/*N*/ +/*N*/ if ( nMask & HASATTR_RTL ) +/*N*/ { +/*?*/ // first check if right-to left is in the pool at all +/*?*/ // (the same item is used in cell and page format) +/*?*/ +/*?*/ ScDocumentPool* pPool = xPoolHelper->GetDocPool(); +/*?*/ +/*?*/ BOOL bHasRtl = FALSE; +/*?*/ USHORT nDirCount = pPool->GetItemCount( ATTR_WRITINGDIR ); +/*?*/ for (USHORT nItem=0; nItem<nDirCount; nItem++) +/*?*/ { +/*?*/ const SfxPoolItem* pItem = pPool->GetItem( ATTR_WRITINGDIR, nItem ); +/*?*/ if ( pItem && ((const SvxFrameDirectionItem*)pItem)->GetValue() == FRMDIR_HORI_RIGHT_TOP ) +/*?*/ { +/*?*/ bHasRtl = TRUE; +/*?*/ break; +/*?*/ } +/*?*/ } +/*?*/ if (!bHasRtl) +/*?*/ nMask &= ~HASATTR_RTL; +/*N*/ } +/*N*/ +/*N*/ if (!nMask) +/*N*/ return FALSE; +/*N*/ +/*N*/ BOOL bFound = FALSE; +/*N*/ for (USHORT i=nTab1; i<=nTab2 && !bFound; i++) +/*N*/ if (pTab[i]) +/*N*/ { +/*N*/ if ( nMask & HASATTR_RTL ) +/*N*/ { +/*?*/ if ( GetEditTextDirection(i) == EE_HTEXTDIR_R2L ) // sheet default +/*?*/ bFound = TRUE; +/*N*/ } +/*N*/ +/*N*/ bFound |= pTab[i]->HasAttrib( nCol1, nRow1, nCol2, nRow2, nMask ); +/*N*/ } +/*N*/ +/*N*/ return bFound; +/*N*/ } + +/*N*/ BOOL ScDocument::HasAttrib( const ScRange& rRange, USHORT nMask ) +/*N*/ { +/*N*/ return HasAttrib( rRange.aStart.Col(), rRange.aStart.Row(), rRange.aStart.Tab(), +/*N*/ rRange.aEnd.Col(), rRange.aEnd.Row(), rRange.aEnd.Tab(), +/*N*/ nMask ); +/*N*/ } + +/*N*/ BOOL ScDocument::IsBlockEmpty( USHORT nTab, USHORT nStartCol, USHORT nStartRow, +/*N*/ USHORT nEndCol, USHORT nEndRow ) const +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 if (VALIDTAB(nTab)) +/*N*/ return FALSE; +/*N*/ } + + +/*N*/ void ScDocument::LockTable(USHORT nTab) +/*N*/ { +/*N*/ if ( nTab <= MAXTAB && pTab[nTab] ) +/*N*/ pTab[nTab]->LockTable(); +/*N*/ else +/*N*/ DBG_ERROR("Falsche Tabellennummer"); +/*N*/ } + + +/*N*/ void ScDocument::UnlockTable(USHORT nTab) +/*N*/ { +/*N*/ if ( nTab <= MAXTAB && pTab[nTab] ) +/*N*/ pTab[nTab]->UnlockTable(); +/*N*/ else +/*N*/ DBG_ERROR("Falsche Tabellennummer"); +/*N*/ } + + +/*N*/ BOOL ScDocument::IsBlockEditable( USHORT nTab, USHORT nStartCol, USHORT nStartRow, +/*N*/ USHORT nEndCol, USHORT nEndRow, +/*N*/ BOOL* pOnlyNotBecauseOfMatrix /* = NULL */ ) const +/*N*/ { +/*N*/ // import into read-only document is possible - must be extended if other filters use api +/*N*/ if ( pShell && pShell->IsReadOnly() && !bImportingXML ) +/*N*/ { +/*N*/ if ( pOnlyNotBecauseOfMatrix ) +/*N*/ *pOnlyNotBecauseOfMatrix = FALSE; +/*N*/ return FALSE; +/*N*/ } +/*N*/ +/*N*/ if (VALIDTAB(nTab)) +/*N*/ if (pTab[nTab]) +/*N*/ return pTab[nTab]->IsBlockEditable( nStartCol, nStartRow, nEndCol, +/*N*/ nEndRow, pOnlyNotBecauseOfMatrix ); +/*N*/ +/*N*/ DBG_ERROR("Falsche Tabellennummer"); +/*N*/ if ( pOnlyNotBecauseOfMatrix ) +/*N*/ *pOnlyNotBecauseOfMatrix = FALSE; +/*N*/ return FALSE; +/*N*/ } + + +/*N*/ BOOL ScDocument::IsSelectionEditable( const ScMarkData& rMark, +/*N*/ BOOL* pOnlyNotBecauseOfMatrix /* = NULL */ ) const +/*N*/ { +/*N*/ // import into read-only document is possible - must be extended if other filters use api +/*N*/ if ( pShell && pShell->IsReadOnly() && !bImportingXML ) +/*N*/ { +/*N*/ if ( pOnlyNotBecauseOfMatrix ) +/*N*/ *pOnlyNotBecauseOfMatrix = FALSE; +/*N*/ return FALSE; +/*N*/ } +/*N*/ +/*N*/ ScRange aRange; +/*N*/ rMark.GetMarkArea(aRange); +/*N*/ +/*N*/ BOOL bOk = TRUE; +/*N*/ BOOL bMatrix = ( pOnlyNotBecauseOfMatrix != NULL ); +/*N*/ for ( USHORT i=0; i<=MAXTAB && (bOk || bMatrix); i++ ) +/*N*/ { +/*N*/ if ( pTab[i] && rMark.GetTableSelect(i) ) +/*N*/ { +/*N*/ if (rMark.IsMarked()) +/*N*/ { +/*N*/ if ( !pTab[i]->IsBlockEditable( aRange.aStart.Col(), +/*N*/ aRange.aStart.Row(), aRange.aEnd.Col(), +/*N*/ aRange.aEnd.Row(), pOnlyNotBecauseOfMatrix ) ) +/*N*/ { +/*N*/ bOk = FALSE; +/*N*/ if ( pOnlyNotBecauseOfMatrix ) +/*N*/ bMatrix = *pOnlyNotBecauseOfMatrix; +/*N*/ } +/*N*/ } +/*N*/ if (rMark.IsMultiMarked()) +/*N*/ { +/*N*/ if ( !pTab[i]->IsSelectionEditable( rMark, pOnlyNotBecauseOfMatrix ) ) +/*N*/ { +/*N*/ bOk = FALSE; +/*N*/ if ( pOnlyNotBecauseOfMatrix ) +/*N*/ bMatrix = *pOnlyNotBecauseOfMatrix; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if ( pOnlyNotBecauseOfMatrix ) +/*N*/ *pOnlyNotBecauseOfMatrix = ( !bOk && bMatrix ); +/*N*/ +/*N*/ return bOk; +/*N*/ } + + + + + + + + +/*N*/ BOOL ScDocument::GetMatrixFormulaRange( const ScAddress& rCellPos, ScRange& rMatrix ) +/*N*/ { +/*N*/ // if rCell is part of a matrix formula, return its complete range +/*N*/ +/*N*/ BOOL bRet = FALSE; +/*N*/ ScBaseCell* pCell = GetCell( rCellPos ); +/*N*/ if (pCell && pCell->GetCellType() == CELLTYPE_FORMULA) +/*N*/ { +/*N*/ ScAddress aOrigin = rCellPos; +/*N*/ if ( ((ScFormulaCell*)pCell)->GetMatrixOrigin( aOrigin ) ) +/*N*/ { +/*N*/ if ( aOrigin != rCellPos ) +/*N*/ pCell = GetCell( aOrigin ); +/*N*/ if (pCell && pCell->GetCellType() == CELLTYPE_FORMULA) +/*N*/ { +/*N*/ USHORT nSizeX, nSizeY; +/*N*/ ((ScFormulaCell*)pCell)->GetMatColsRows(nSizeX,nSizeY); +/*N*/ if ( !(nSizeX && nSizeY) ) +/*N*/ { +/*?*/ // GetMatrixEdge computes also dimensions of the matrix +/*?*/ // if not already done (may occur if document is loaded +/*?*/ // from old file format). +/*?*/ // Needs an "invalid" initialized address. +/*?*/ aOrigin = UINT32(0xffffffff); +/*?*/ ((ScFormulaCell*)pCell)->GetMatrixEdge(aOrigin); +/*?*/ ((ScFormulaCell*)pCell)->GetMatColsRows(nSizeX,nSizeY); +/*N*/ } +/*N*/ if ( nSizeX && nSizeY ) +/*N*/ { +/*N*/ ScAddress aEnd( aOrigin.Col() + nSizeX - 1, +/*N*/ aOrigin.Row() + nSizeY - 1, +/*N*/ aOrigin.Tab() ); +/*N*/ +/*N*/ rMatrix.aStart = aOrigin; +/*N*/ rMatrix.aEnd = aEnd; +/*N*/ bRet = TRUE; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ return bRet; +/*N*/ } + + +/*N*/ BOOL ScDocument::ExtendOverlapped( USHORT& rStartCol, USHORT& rStartRow, +/*N*/ USHORT nEndCol, USHORT nEndRow, USHORT nTab ) +/*N*/ { +/*N*/ BOOL bFound = FALSE; +/*N*/ if ( ValidColRow(rStartCol,rStartRow) && ValidColRow(nEndCol,nEndRow) && nTab<=MAXTAB ) +/*N*/ { +/*N*/ if (pTab[nTab]) +/*N*/ { +/*N*/ USHORT nCol; +/*N*/ USHORT nOldCol = rStartCol; +/*N*/ USHORT nOldRow = rStartRow; +/*N*/ for (nCol=nOldCol; nCol<=nEndCol; nCol++) +/*N*/ while (((ScMergeFlagAttr*)GetAttr(nCol,rStartRow,nTab,ATTR_MERGE_FLAG))-> +/*N*/ IsVerOverlapped()) +/*N*/ --rStartRow; +/*N*/ +/*N*/ //! weiterreichen ? +/*N*/ +/*N*/ ScAttrArray* pAttrArray = pTab[nTab]->aCol[nOldCol].pAttrArray; +/*N*/ short nIndex; +/*N*/ pAttrArray->Search( nOldRow, nIndex ); +/*N*/ USHORT nAttrPos = nOldRow; +/*N*/ while (nAttrPos<=nEndRow) +/*N*/ { +/*N*/ DBG_ASSERT( nIndex < (short) pAttrArray->nCount, "Falscher Index im AttrArray" ); +/*N*/ +/*N*/ if (((ScMergeFlagAttr&)pAttrArray->pData[nIndex].pPattern-> +/*N*/ GetItem(ATTR_MERGE_FLAG)).IsHorOverlapped()) +/*N*/ { +/*N*/ USHORT nLoopEndRow = Min( nEndRow, pAttrArray->pData[nIndex].nRow ); +/*N*/ for (USHORT nAttrRow = nAttrPos; nAttrRow <= nLoopEndRow; nAttrRow++) +/*N*/ { +/*N*/ USHORT nTempCol = nOldCol; +/*N*/ do +/*N*/ --nTempCol; +/*N*/ while (((ScMergeFlagAttr*)GetAttr(nTempCol,nAttrRow,nTab,ATTR_MERGE_FLAG)) +/*N*/ ->IsHorOverlapped()); +/*N*/ if (nTempCol < rStartCol) +/*N*/ rStartCol = nTempCol; +/*N*/ } +/*N*/ } +/*N*/ nAttrPos = pAttrArray->pData[nIndex].nRow + 1; +/*N*/ ++nIndex; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ DBG_ERROR("ExtendOverlapped: falscher Bereich"); +/*N*/ +/*N*/ return bFound; +/*N*/ } + + +/*N*/ BOOL ScDocument::ExtendMerge( USHORT nStartCol, USHORT nStartRow, +/*N*/ USHORT& rEndCol, USHORT& rEndRow, +/*N*/ USHORT nTab, BOOL bRefresh, BOOL bAttrs ) +/*N*/ { +/*N*/ BOOL bFound = FALSE; +/*N*/ if ( ValidColRow(nStartCol,nStartRow) && ValidColRow(rEndCol,rEndRow) && nTab<=MAXTAB ) +/*N*/ { +/*N*/ if (pTab[nTab]) +/*N*/ bFound = pTab[nTab]->ExtendMerge( nStartCol, nStartRow, rEndCol, rEndRow, bRefresh, bAttrs ); +/*N*/ +/*N*/ if (bRefresh) +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 /*?*/ RefreshAutoFilter( nStartCol, nStartRow, rEndCol, rEndRow, nTab ); +/*N*/ } +/*N*/ else +/*N*/ DBG_ERROR("ExtendMerge: falscher Bereich"); +/*N*/ +/*N*/ return bFound; +/*N*/ } + + +/*N*/ BOOL ScDocument::ExtendMerge( ScRange& rRange, BOOL bRefresh, BOOL bAttrs ) +/*N*/ { +/*N*/ BOOL bFound = FALSE; +/*N*/ USHORT nStartTab = rRange.aStart.Tab(); +/*N*/ USHORT nEndTab = rRange.aEnd.Tab(); +/*N*/ USHORT nEndCol = rRange.aEnd.Col(); +/*N*/ USHORT nEndRow = rRange.aEnd.Row(); +/*N*/ +/*N*/ PutInOrder( nStartTab, nEndTab ); +/*N*/ for (USHORT nTab = nStartTab; nTab <= nEndTab; nTab++ ) +/*N*/ { +/*N*/ USHORT nExtendCol = rRange.aEnd.Col(); +/*N*/ USHORT nExtendRow = rRange.aEnd.Row(); +/*N*/ if (ExtendMerge( rRange.aStart.Col(), rRange.aStart.Row(), +/*N*/ nExtendCol, nExtendRow, +/*N*/ nTab, bRefresh, bAttrs ) ) +/*N*/ { +/*N*/ bFound = TRUE; +/*N*/ if (nExtendCol > nEndCol) nEndCol = nExtendCol; +/*N*/ if (nExtendRow > nEndRow) nEndRow = nExtendRow; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ rRange.aEnd.SetCol(nEndCol); +/*N*/ rRange.aEnd.SetRow(nEndRow); +/*N*/ +/*N*/ return bFound; +/*N*/ } + + +/*N*/ BOOL ScDocument::ExtendOverlapped( ScRange& rRange ) +/*N*/ { +/*N*/ BOOL bFound = FALSE; +/*N*/ USHORT nStartTab = rRange.aStart.Tab(); +/*N*/ USHORT nEndTab = rRange.aEnd.Tab(); +/*N*/ USHORT nStartCol = rRange.aStart.Col(); +/*N*/ USHORT nStartRow = rRange.aStart.Row(); +/*N*/ +/*N*/ PutInOrder( nStartTab, nEndTab ); +/*N*/ for (USHORT nTab = nStartTab; nTab <= nEndTab; nTab++ ) +/*N*/ { +/*N*/ USHORT nExtendCol = rRange.aStart.Col(); +/*N*/ USHORT nExtendRow = rRange.aStart.Row(); +/*N*/ ExtendOverlapped( nExtendCol, nExtendRow, +/*N*/ rRange.aEnd.Col(), rRange.aEnd.Row(), nTab ); +/*N*/ if (nExtendCol < nStartCol) +/*N*/ { +/*N*/ nStartCol = nExtendCol; +/*N*/ bFound = TRUE; +/*N*/ } +/*N*/ if (nExtendRow < nStartRow) +/*N*/ { +/*N*/ nStartRow = nExtendRow; +/*N*/ bFound = TRUE; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ rRange.aStart.SetCol(nStartCol); +/*N*/ rRange.aStart.SetRow(nStartRow); +/*N*/ +/*N*/ return bFound; +/*N*/ } + + + +/*N*/ void ScDocument::SetAutoFilterFlags() +/*N*/ { +/*N*/ USHORT nCount = pDBCollection->GetCount(); +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ { +/*N*/ ScDBData* pData = (*pDBCollection)[i]; +/*N*/ USHORT nDBTab; +/*N*/ USHORT nDBStartCol; +/*N*/ USHORT nDBStartRow; +/*N*/ USHORT nDBEndCol; +/*N*/ USHORT nDBEndRow; +/*N*/ pData->GetArea( nDBTab, nDBStartCol,nDBStartRow, nDBEndCol,nDBEndRow ); +/*N*/ pData->SetAutoFilter( HasAttrib( nDBStartCol,nDBStartRow,nDBTab, +/*N*/ nDBEndCol,nDBStartRow,nDBTab, HASATTR_AUTOFILTER ) ); +/*N*/ } +/*N*/ } + + + + + + + + +/*N*/ void ScDocument::ApplySelectionFrame( const ScMarkData& rMark, +/*N*/ const SvxBoxItem* pLineOuter, +/*N*/ const SvxBoxInfoItem* pLineInner ) +/*N*/ { +/*N*/ if (rMark.IsMarked()) +/*N*/ { +/*N*/ ScRange aRange; +/*N*/ rMark.GetMarkArea(aRange); +/*N*/ for (USHORT i=0; i<=MAXTAB; i++) +/*N*/ if (pTab[i]) +/*N*/ if (rMark.GetTableSelect(i)) +/*N*/ pTab[i]->ApplyBlockFrame( pLineOuter, pLineInner, +/*N*/ aRange.aStart.Col(), aRange.aStart.Row(), +/*N*/ aRange.aEnd.Col(), aRange.aEnd.Row() ); +/*N*/ } +/*N*/ } + + + + +/*N*/ void ScDocument::ApplySelectionPattern( const ScPatternAttr& rAttr, const ScMarkData& rMark ) +/*N*/ { +/*N*/ const SfxItemSet* pSet = &rAttr.GetItemSet(); +/*N*/ BOOL bSet = FALSE; +/*N*/ USHORT i; +/*N*/ for (i=ATTR_PATTERN_START; i<=ATTR_PATTERN_END && !bSet; i++) +/*N*/ if (pSet->GetItemState(i) == SFX_ITEM_SET) +/*N*/ bSet = TRUE; +/*N*/ +/*N*/ if (bSet) +/*N*/ { +/*N*/ // ApplySelectionCache needs multi mark +/*N*/ if ( rMark.IsMarked() && !rMark.IsMultiMarked() ) +/*N*/ { +/*N*/ ScRange aRange; +/*N*/ rMark.GetMarkArea( aRange ); +/*N*/ ApplyPatternArea( aRange.aStart.Col(), aRange.aStart.Row(), +/*N*/ aRange.aEnd.Col(), aRange.aEnd.Row(), rMark, rAttr ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ SfxItemPoolCache aCache( xPoolHelper->GetDocPool(), pSet ); +/*N*/ for (USHORT i=0; i<=MAXTAB; i++) +/*N*/ if (pTab[i]) +/*N*/ if (rMark.GetTableSelect(i)) +/*N*/ pTab[i]->ApplySelectionCache( &aCache, rMark ); +/*N*/ } +/*N*/ } +/*N*/ } + + +/*N*/ void ScDocument::ChangeSelectionIndent( BOOL bIncrement, const ScMarkData& rMark ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 for (USHORT i=0; i<=MAXTAB; i++) +/*N*/ } + + +/*N*/ void ScDocument::ClearSelectionItems( const USHORT* pWhich, const ScMarkData& rMark ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 for (USHORT i=0; i<=MAXTAB; i++) +/*N*/ } + + + + + + +/*N*/ ScPatternAttr* ScDocument::GetDefPattern() const +/*N*/ { +/*N*/ return (ScPatternAttr*) &xPoolHelper->GetDocPool()->GetDefaultItem(ATTR_PATTERN); +/*N*/ } + + +/*N*/ ScDocumentPool* ScDocument::GetPool() +/*N*/ { +/*N*/ return xPoolHelper->GetDocPool(); +/*N*/ } + + + +/*N*/ ScStyleSheetPool* ScDocument::GetStyleSheetPool() const +/*N*/ { +/*N*/ return xPoolHelper->GetStylePool(); +/*N*/ } + + + + + + +/*N*/ void ScDocument::GetNextPos( USHORT& rCol, USHORT& rRow, USHORT nTab, short nMovX, short nMovY, +/*N*/ BOOL bMarked, BOOL bUnprotected, const ScMarkData& rMark ) +/*N*/ { +/*N*/ DBG_ASSERT( !nMovX || !nMovY, "GetNextPos: nur X oder Y" ); +/*N*/ +/*N*/ ScMarkData aCopyMark = rMark; +/*N*/ aCopyMark.SetMarking(FALSE); +/*N*/ aCopyMark.MarkToMulti(); +/*N*/ +/*N*/ if (nTab<=MAXTAB && pTab[nTab]) +/*N*/ pTab[nTab]->GetNextPos( rCol, rRow, nMovX, nMovY, bMarked, bUnprotected, aCopyMark ); +/*N*/ } + +// +// Datei-Operationen +// + + +/*N*/ void ScDocument::UpdStlShtPtrsFrmNms() +/*N*/ { +/*N*/ ScPatternAttr::pDoc = this; +/*N*/ +/*N*/ ScDocumentPool* pPool = xPoolHelper->GetDocPool(); +/*N*/ +/*N*/ USHORT nCount = pPool->GetItemCount(ATTR_PATTERN); +/*N*/ ScPatternAttr* pPattern; +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ { +/*N*/ pPattern = (ScPatternAttr*)pPool->GetItem(ATTR_PATTERN, i); +/*N*/ if (pPattern) +/*N*/ pPattern->UpdateStyleSheet(); +/*N*/ } +/*N*/ ((ScPatternAttr&)pPool->GetDefaultItem(ATTR_PATTERN)).UpdateStyleSheet(); +/*N*/ } + + + + +/*N*/ void lcl_RemoveMergeFromStyles( ScStyleSheetPool* pStylePool ) +/*N*/ { +/*N*/ pStylePool->SetSearchMask( SFX_STYLE_FAMILY_ALL ); +/*N*/ +/*N*/ USHORT nCount = pStylePool->Count(); +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ { +/*N*/ // in alten Versionen wurden statt SFXSTYLEBIT_USERDEF alle Bits gesetzt +/*N*/ SfxStyleSheetBase* pStyle = (*pStylePool)[i]; +/*N*/ if ( pStyle->GetMask() & SFXSTYLEBIT_READONLY ) +/*N*/ pStyle->SetMask( pStyle->GetMask() & ~SFXSTYLEBIT_READONLY ); +/*N*/ +/*N*/ SfxItemSet& rSet = pStyle->GetItemSet(); +/*N*/ rSet.ClearItem( ATTR_MERGE ); +/*N*/ rSet.ClearItem( ATTR_MERGE_FLAG ); +/*N*/ +/*N*/ // Das SvxBoxInfoItem wurde bis zur 358 falsch geladen, so dass +/*N*/ // Seitenvorlagen falsche Items mit bDist = FALSE enthalten koennen +/*N*/ if ( pStyle->GetFamily() == SFX_STYLE_FAMILY_PAGE ) +/*N*/ { +/*N*/ const SvxBoxInfoItem& rPageInfo = (const SvxBoxInfoItem&)rSet.Get(ATTR_BORDER_INNER); +/*N*/ if ( !rPageInfo.IsDist() ) +/*N*/ { +/*N*/ DBG_WARNING("altes SvxBoxInfoItem muss korrigiert werden"); +/*N*/ SvxBoxInfoItem aNew( rPageInfo ); +/*N*/ aNew.SetDist( TRUE ); +/*N*/ rSet.Put( aNew ); +/*N*/ } +/*N*/ // Das gilt fuer alle Hdr/Ftr-SetItems, darum kann das SetItem auch +/*N*/ // direkt im Pool geaendert werden (const weggecastet): +/*N*/ SfxItemSet& rHdrSet = ((SvxSetItem&)rSet.Get(ATTR_PAGE_HEADERSET)).GetItemSet(); +/*N*/ const SvxBoxInfoItem& rHdrInfo = (const SvxBoxInfoItem&)rHdrSet.Get(ATTR_BORDER_INNER); +/*N*/ if ( !rHdrInfo.IsDist() ) +/*N*/ { +/*N*/ DBG_WARNING("altes SvxBoxInfoItem muss korrigiert werden"); +/*N*/ SvxBoxInfoItem aNew( rHdrInfo ); +/*N*/ aNew.SetDist( TRUE ); +/*N*/ rHdrSet.Put( aNew ); +/*N*/ } +/*N*/ SfxItemSet& rFtrSet = ((SvxSetItem&)rSet.Get(ATTR_PAGE_FOOTERSET)).GetItemSet(); +/*N*/ const SvxBoxInfoItem& rFtrInfo = (const SvxBoxInfoItem&)rFtrSet.Get(ATTR_BORDER_INNER); +/*N*/ if ( !rFtrInfo.IsDist() ) +/*N*/ { +/*N*/ DBG_WARNING("altes SvxBoxInfoItem muss korrigiert werden"); +/*N*/ SvxBoxInfoItem aNew( rFtrInfo ); +/*N*/ aNew.SetDist( TRUE ); +/*N*/ rFtrSet.Put( aNew ); +/*N*/ } +/*N*/ const SfxUInt16Item& rScaleItem = (const SfxUInt16Item&)rSet.Get(ATTR_PAGE_SCALE); +/*N*/ USHORT nScale = rScaleItem.GetValue(); +/*N*/ //! Extra-Konstanten fuer Seitenformat? +/*N*/ // 0 ist erlaubt (wird gesetzt bei Scale To Pages) +/*N*/ if ( nScale != 0 && ( nScale < MINZOOM || nScale > MAXZOOM ) ) +/*N*/ { +/*?*/ // konnte anscheinend mal irgendwie kaputtgehen (#34508#) +/*?*/ DBG_WARNING("kaputter Zoom im Seitenformat muss korrigiert werden"); +/*?*/ rSet.Put( SfxUInt16Item( ATTR_PAGE_SCALE, 100 ) ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } + + +/*N*/ BOOL ScDocument::LoadPool( SvStream& rStream, BOOL bLoadRefCounts ) +/*N*/ { +/*N*/ // bLoadingDone wird beim Laden des StylePools (ScStyleSheet::GetItemSet) gebraucht +/*N*/ bLoadingDone = FALSE; +/*N*/ +/*N*/ USHORT nOldBufSize = rStream.GetBufferSize(); +/*N*/ rStream.SetBufferSize( 32768 ); +/*N*/ CharSet eOldSet = rStream.GetStreamCharSet(); +/*N*/ +/*N*/ SetPrinter( NULL ); +/*N*/ +/*N*/ ScPatternAttr::pDoc = this; +/*N*/ +/*N*/ if ( xPoolHelper.is() && !bIsClip ) +/*N*/ xPoolHelper->SourceDocumentGone(); +/*N*/ +/*N*/ xPoolHelper = new ScPoolHelper( this ); +/*N*/ +/*N*/ xPoolHelper->GetDocPool()->SetFileFormatVersion( (USHORT)rStream.GetVersion() ); +/*N*/ BOOL bStylesFound = FALSE; +/*N*/ +/*N*/ BOOL bRet = FALSE; +/*N*/ USHORT nID; +/*N*/ rStream >> nID; +/*N*/ if (nID == SCID_POOLS || nID == SCID_NEWPOOLS) +/*N*/ { +/*N*/ ScReadHeader aHdr( rStream ); +/*N*/ while (aHdr.BytesLeft()) +/*N*/ { +/*N*/ USHORT nSubID; +/*N*/ rStream >> nSubID; +/*N*/ ScReadHeader aSubHdr( rStream ); +/*N*/ switch (nSubID) +/*N*/ { +/*N*/ case SCID_CHARSET: +/*N*/ { +/*N*/ BYTE cSet, cGUI; // cGUI is dummy, old GUIType +/*N*/ rStream >> cGUI >> cSet; +/*N*/ eSrcSet = (CharSet) cSet; +/*N*/ rStream.SetStreamCharSet( ::GetSOLoadTextEncoding( +/*N*/ eSrcSet, (USHORT)rStream.GetVersion() ) ); +/*N*/ } +/*N*/ break; +/*N*/ case SCID_DOCPOOL: +/*N*/ xPoolHelper->GetDocPool()->Load( rStream ); +/*N*/ break; +/*N*/ case SCID_STYLEPOOL: +/*N*/ { +/*N*/ // StylePool konvertiert beim Laden selber +/*N*/ CharSet eOld = rStream.GetStreamCharSet(); +/*N*/ rStream.SetStreamCharSet( gsl_getSystemTextEncoding() ); //! ??? +/*N*/ xPoolHelper->GetStylePool()->Load( rStream ); +/*N*/ rStream.SetStreamCharSet( eOld ); +/*N*/ lcl_RemoveMergeFromStyles( xPoolHelper->GetStylePool() ); // setzt auch ReadOnly zurueck +/*N*/ bStylesFound = TRUE; +/*N*/ } +/*N*/ break; +/*N*/ case SCID_EDITPOOL : +/*N*/ xPoolHelper->GetEditPool()->Load( rStream ); +/*N*/ break; +/*?*/ default: +/*?*/ DBG_ERROR("unbekannter Sub-Record in ScDocument::LoadPool"); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ UpdStlShtPtrsFrmNms(); +/*N*/ bRet = TRUE; +/*N*/ } +/*N*/ else +/*?*/ DBG_ERROR("LoadPool: SCID_POOLS nicht gefunden"); +/*N*/ +/*N*/ if (!bStylesFound) +/*?*/ xPoolHelper->GetStylePool()->CreateStandardStyles(); +/*N*/ +/*N*/ rStream.SetStreamCharSet( eOldSet ); +/*N*/ rStream.SetBufferSize( nOldBufSize ); +/*N*/ +/*N*/ bLoadingDone = TRUE; +/*N*/ +/*N*/ // Das Uno-Objekt merkt sich einen Pointer auf den NumberFormatter +/*N*/ // -> mitteilen, dass der alte Pointer ungueltig geworden ist +/*N*/ BroadcastUno( ScPointerChangedHint(SC_POINTERCHANGED_NUMFMT) ); +/*N*/ +/*N*/ return bRet; +/*N*/ } + + +/*N*/ BOOL ScDocument::SavePool( SvStream& rStream ) const +/*N*/ { +/*N*/ xPoolHelper->GetDocPool()->SetFileFormatVersion( (USHORT)rStream.GetVersion() ); +/*N*/ +/*N*/ USHORT nOldBufSize = rStream.GetBufferSize(); +/*N*/ rStream.SetBufferSize( 32768 ); +/*N*/ CharSet eOldSet = rStream.GetStreamCharSet(); +/*N*/ CharSet eStoreCharSet = ::GetSOStoreTextEncoding( +/*N*/ gsl_getSystemTextEncoding(), (USHORT)rStream.GetVersion() ); +/*N*/ rStream.SetStreamCharSet( eStoreCharSet ); +/*N*/ +/*N*/ // ::com::press-Mode fuer Grafiken in Brush-Items (Hintergrund im Seitenformat) +/*N*/ +/*N*/ USHORT nComprMode = rStream.GetCompressMode() & ~(COMPRESSMODE_ZBITMAP | COMPRESSMODE_NATIVE); +/*N*/ BOOL bNative = FALSE; +/*N*/ BOOL bCompr = FALSE; +/*N*/ +/*N*/ if ( rStream.GetVersion() >= SOFFICE_FILEFORMAT_40 && bCompr ) +/*N*/ nComprMode |= COMPRESSMODE_ZBITMAP; // komprimiert ab 4.0 +/*N*/ if ( rStream.GetVersion() > SOFFICE_FILEFORMAT_40 && bNative ) +/*N*/ nComprMode |= COMPRESSMODE_NATIVE; // Originalformat ab 5.0 +/*N*/ rStream.SetCompressMode( nComprMode ); +/*N*/ +/*N*/ { +/*N*/ rStream << (USHORT) SCID_NEWPOOLS; +/*N*/ ScWriteHeader aHdr( rStream ); +/*N*/ +/*N*/ { +/*N*/ rStream << (USHORT) SCID_CHARSET; +/*N*/ ScWriteHeader aSetHdr( rStream, 2 ); +/*N*/ rStream << (BYTE) 0 // dummy, old System::GetGUIType() +/*N*/ << (BYTE) eStoreCharSet; +/*N*/ } +/*N*/ +/*N*/ // Force the default style's name to be "Standard" for all languages in the file. +/*N*/ // This is needed for versions up to 5.1, to find the default pattern's style in +/*N*/ // the UpdateStyleSheet call. +/*N*/ // #89078# this has to be set for the DocPool save, too, so the default style name +/*N*/ // is adjusted for the patterns, or a wrong style would be used if other styles +/*N*/ // match the default style's name after CharacterSet conversion. +/*N*/ +/*N*/ String aFileStdName = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(STRING_STANDARD)); +/*N*/ if ( aFileStdName != ScGlobal::GetRscString(STR_STYLENAME_STANDARD) ) +/*N*/ xPoolHelper->GetStylePool()->SetForceStdName( &aFileStdName ); +/*N*/ +/*N*/ { +/*N*/ rStream << (USHORT) SCID_DOCPOOL; +/*N*/ ScWriteHeader aDocPoolHdr( rStream ); +/*N*/ xPoolHelper->GetDocPool()->Store( rStream ); +/*N*/ } +/*N*/ +/*N*/ { +/*N*/ rStream << (USHORT) SCID_STYLEPOOL; +/*N*/ ScWriteHeader aStylePoolHdr( rStream ); +/*N*/ xPoolHelper->GetStylePool()->SetSearchMask( SFX_STYLE_FAMILY_ALL ); +/*N*/ +/*N*/ xPoolHelper->GetStylePool()->Store( rStream, FALSE ); +/*N*/ } +/*N*/ +/*N*/ xPoolHelper->GetStylePool()->SetForceStdName( NULL ); +/*N*/ +/*N*/ if ( rStream.GetVersion() >= SOFFICE_FILEFORMAT_50 ) +/*N*/ { +/*N*/ rStream << (USHORT) SCID_EDITPOOL; +/*N*/ ScWriteHeader aEditPoolHdr( rStream ); +/*N*/ xPoolHelper->GetEditPool()->SetFileFormatVersion( (USHORT)rStream.GetVersion() ); +/*N*/ xPoolHelper->GetEditPool()->Store( rStream ); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ rStream.SetStreamCharSet( eOldSet ); +/*N*/ rStream.SetBufferSize( nOldBufSize ); +/*N*/ return TRUE; +/*N*/ } + + +/*N*/ long ScDocument::GetCellCount() const +/*N*/ { +/*N*/ long nCellCount = 0L; +/*N*/ +/*N*/ for ( USHORT nTab=0; nTab<=MAXTAB; nTab++ ) +/*N*/ if ( pTab[nTab] ) +/*N*/ nCellCount += pTab[nTab]->GetCellCount(); +/*N*/ +/*N*/ return nCellCount; +/*N*/ } + + +/*N*/ long ScDocument::GetWeightedCount() const +/*N*/ { +/*N*/ long nCellCount = 0L; +/*N*/ +/*N*/ for ( USHORT nTab=0; nTab<=MAXTAB; nTab++ ) +/*N*/ if ( pTab[nTab] ) +/*N*/ nCellCount += pTab[nTab]->GetWeightedCount(); +/*N*/ +/*N*/ return nCellCount; +/*N*/ } + + + + +/*N*/ void ScDocument::SetPageStyle( USHORT nTab, const String& rName ) +/*N*/ { +/*N*/ if ( nTab <= MAXTAB && pTab[nTab] ) +/*N*/ pTab[nTab]->SetPageStyle( rName ); +/*N*/ } + + +/*N*/ const String& ScDocument::GetPageStyle( USHORT nTab ) const +/*N*/ { +/*N*/ if ( nTab <= MAXTAB && pTab[nTab] ) +/*N*/ return pTab[nTab]->GetPageStyle(); +/*N*/ +/*N*/ return EMPTY_STRING; +/*N*/ } + + +/*N*/ void ScDocument::SetPageSize( USHORT nTab, const Size& rSize ) +/*N*/ { +/*N*/ if ( nTab <= MAXTAB && pTab[nTab] ) +/*N*/ pTab[nTab]->SetPageSize( rSize ); +/*N*/ } + +/*N*/ Size ScDocument::GetPageSize( USHORT nTab ) const +/*N*/ { +/*N*/ if ( nTab <= MAXTAB && pTab[nTab] ) +/*N*/ return pTab[nTab]->GetPageSize(); +/*N*/ +/*N*/ DBG_ERROR("falsche Tab"); +/*N*/ return Size(); +/*N*/ } + + +/*N*/ void ScDocument::SetRepeatArea( USHORT nTab, USHORT nStartCol, USHORT nEndCol, USHORT nStartRow, USHORT nEndRow ) +/*N*/ { +/*N*/ if ( nTab <= MAXTAB && pTab[nTab] ) +/*N*/ pTab[nTab]->SetRepeatArea( nStartCol, nEndCol, nStartRow, nEndRow ); +/*N*/ } + +/*N*/ void ScDocument::UpdatePageBreaks( USHORT nTab, const ScRange* pUserArea ) +/*N*/ { +/*N*/ if ( nTab <= MAXTAB && pTab[nTab] ) +/*N*/ pTab[nTab]->UpdatePageBreaks( pUserArea ); +/*N*/ } + +/*N*/ void ScDocument::RemoveManualBreaks( USHORT nTab ) +/*N*/ { +/*N*/ if ( nTab <= MAXTAB && pTab[nTab] ) +/*N*/ pTab[nTab]->RemoveManualBreaks(); +/*N*/ } + + + + + +/*N*/ BOOL ScDocument::HasPrintRange() +/*N*/ { +/*N*/ BOOL bResult = FALSE; +/*N*/ +/*N*/ for ( USHORT i=0; !bResult && i<nMaxTableNumber; i++ ) +/*N*/ if ( pTab[i] ) +/*N*/ bResult = ( pTab[i]->GetPrintRangeCount() > 0 ); +/*N*/ +/*N*/ return bResult; +/*N*/ } + + +/*N*/ USHORT ScDocument::GetPrintRangeCount( USHORT nTab ) +/*N*/ { +/*N*/ if (nTab<=MAXTAB && pTab[nTab]) +/*N*/ return pTab[nTab]->GetPrintRangeCount(); +/*N*/ +/*N*/ return 0; +/*N*/ } + + +/*N*/ const ScRange* ScDocument::GetPrintRange( USHORT nTab, USHORT nPos ) +/*N*/ { +/*N*/ if (nTab<=MAXTAB && pTab[nTab]) +/*N*/ return pTab[nTab]->GetPrintRange(nPos); +/*N*/ +/*N*/ return NULL; +/*N*/ } + + +/*N*/ const ScRange* ScDocument::GetRepeatColRange( USHORT nTab ) +/*N*/ { +/*N*/ if (nTab<=MAXTAB && pTab[nTab]) +/*N*/ return pTab[nTab]->GetRepeatColRange(); +/*N*/ +/*N*/ return NULL; +/*N*/ } + + +/*N*/ const ScRange* ScDocument::GetRepeatRowRange( USHORT nTab ) +/*N*/ { +/*N*/ if (nTab<=MAXTAB && pTab[nTab]) +/*N*/ return pTab[nTab]->GetRepeatRowRange(); +/*N*/ +/*N*/ return NULL; +/*N*/ } + + +// #42845# zeroptimiert +/*N*/ #if defined(WIN) && defined(MSC) +/*N*/ #pragma optimize("",off) +/*N*/ #endif +/*N*/ void ScDocument::SetPrintRangeCount( USHORT nTab, USHORT nNew ) +/*N*/ { +/*N*/ if (nTab<=MAXTAB && pTab[nTab]) +/*N*/ pTab[nTab]->SetPrintRangeCount( nNew ); +/*N*/ } +/*N*/ #if defined(WIN) && defined(MSC) +/*N*/ #pragma optimize("",on) +/*N*/ #endif + + +/*N*/ void ScDocument::SetPrintRange( USHORT nTab, USHORT nPos, const ScRange& rNew ) +/*N*/ { +/*N*/ if (nTab<=MAXTAB && pTab[nTab]) +/*N*/ pTab[nTab]->SetPrintRange( nPos, rNew ); +/*N*/ } + + +/*N*/ void ScDocument::SetRepeatColRange( USHORT nTab, const ScRange* pNew ) +/*N*/ { +/*N*/ if (nTab<=MAXTAB && pTab[nTab]) +/*N*/ pTab[nTab]->SetRepeatColRange( pNew ); +/*N*/ } + + +/*N*/ void ScDocument::SetRepeatRowRange( USHORT nTab, const ScRange* pNew ) +/*N*/ { +/*N*/ if (nTab<=MAXTAB && pTab[nTab]) +/*N*/ pTab[nTab]->SetRepeatRowRange( pNew ); +/*N*/ } + + +/*N*/ ScPrintRangeSaver* ScDocument::CreatePrintRangeSaver() const +/*N*/ { +/*N*/ USHORT nCount = GetTableCount(); +/*N*/ ScPrintRangeSaver* pNew = new ScPrintRangeSaver( nCount ); +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ if (pTab[i]) +/*N*/ pTab[i]->FillPrintSaver( pNew->GetTabData(i) ); +/*N*/ return pNew; +/*N*/ } + + + + + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_dpobject.cxx b/binfilter/bf_sc/source/core/data/sc_dpobject.cxx new file mode 100644 index 000000000000..77554d3b3b44 --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_dpobject.cxx @@ -0,0 +1,1090 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// INCLUDE --------------------------------------------------------------- + +#include "dpobject.hxx" +#include "dptabsrc.hxx" +#include "dpsave.hxx" +#include "dpoutput.hxx" +#include "dpshttab.hxx" +#include "dpsdbtab.hxx" +#include "document.hxx" +#include "rechead.hxx" +#include "pivot.hxx" // PIVOT_DATA_FIELD +#include "dapiuno.hxx" // ScDataPilotConversion +#include "miscuno.hxx" +#include "scerrors.hxx" +#include "refupdat.hxx" + +#include <com/sun/star/sheet/GeneralFunction.hpp> +#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/XSingleServiceFactory.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/container/XContentEnumerationAccess.hpp> + +#include <comphelper/processfactory.hxx> +#include <tools/debug.hxx> +#include <bf_svtools/zforlist.hxx> // IsNumberFormat +#include <legacysmgr/legacy_binfilters_smgr.hxx> //STRIP002 +namespace binfilter { +using namespace ::com::sun::star; + +// ----------------------------------------------------------------------- + +#define MAX_LABELS 256 //!!! from fieldwnd.hxx, must be moved to global.hxx + +// ----------------------------------------------------------------------- + +#define SCDPSOURCE_SERVICE "com.sun.star.sheet.DataPilotSource" + +// ----------------------------------------------------------------------- + +// incompatible versions of data pilot files +#define SC_DP_VERSION_CURRENT 6 + +// type of source data +#define SC_DP_SOURCE_SHEET 0 +#define SC_DP_SOURCE_DATABASE 1 +#define SC_DP_SOURCE_SERVICE 2 + +// ----------------------------------------------------------------------- + +//! move to a header file +#define DP_PROP_COLUMNGRAND "ColumnGrand" +#define DP_PROP_FUNCTION "Function" +#define DP_PROP_IGNOREEMPTY "IgnoreEmptyRows" +#define DP_PROP_ISDATALAYOUT "IsDataLayoutDimension" +//#define DP_PROP_ISVISIBLE "IsVisible" +#define DP_PROP_ORIENTATION "Orientation" +#define DP_PROP_ORIGINAL "Original" +#define DP_PROP_POSITION "Position" +#define DP_PROP_REPEATIFEMPTY "RepeatIfEmpty" +#define DP_PROP_ROWGRAND "RowGrand" +#define DP_PROP_SHOWDETAILS "ShowDetails" +#define DP_PROP_SHOWEMPTY "ShowEmpty" +#define DP_PROP_SUBTOTALS "SubTotals" +#define DP_PROP_USEDHIERARCHY "UsedHierarchy" + +// ----------------------------------------------------------------------- + +/*N*/ USHORT lcl_GetDataGetOrientation( const uno::Reference<sheet::XDimensionsSupplier>& xSource ) +/*N*/ { +/*N*/ long nRet = sheet::DataPilotFieldOrientation_HIDDEN; +/*N*/ if ( xSource.is() ) +/*N*/ { +/*N*/ uno::Reference<container::XNameAccess> xDimsName = xSource->getDimensions(); +/*N*/ uno::Reference<container::XIndexAccess> xIntDims = new ScNameToIndexAccess( xDimsName ); +/*N*/ long nIntCount = xIntDims->getCount(); +/*N*/ BOOL bFound = FALSE; +/*N*/ for (long nIntDim=0; nIntDim<nIntCount && !bFound; nIntDim++) +/*N*/ { +/*N*/ uno::Reference<uno::XInterface> xIntDim = +/*N*/ ScUnoHelpFunctions::AnyToInterface( xIntDims->getByIndex(nIntDim) ); +/*N*/ uno::Reference<beans::XPropertySet> xDimProp( xIntDim, uno::UNO_QUERY ); +/*N*/ if ( xDimProp.is() ) +/*N*/ { +/*N*/ bFound = ScUnoHelpFunctions::GetBoolProperty( xDimProp, +/*N*/ ::rtl::OUString::createFromAscii(DP_PROP_ISDATALAYOUT) ); +/*N*/ //! error checking -- is "IsDataLayoutDimension" property required?? +/*N*/ if (bFound) +/*N*/ nRet = ScUnoHelpFunctions::GetEnumProperty( +/*N*/ xDimProp, ::rtl::OUString::createFromAscii(DP_PROP_ORIENTATION), +/*N*/ sheet::DataPilotFieldOrientation_HIDDEN ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ return nRet; +/*N*/ } + +// ----------------------------------------------------------------------- + +/*N*/ ScDPObject::ScDPObject( ScDocument* pD ) : +/*N*/ pDoc( pD ), +/*N*/ bAlive( FALSE ), +/*N*/ pSaveData( NULL ), +/*N*/ pSheetDesc( NULL ), +/*N*/ pImpDesc( NULL ), +/*N*/ pServDesc( NULL ), +/*N*/ pOutput( NULL ), +/*N*/ bSettingsChanged( FALSE ) +/*N*/ { +/*N*/ } + +/*N*/ ScDPObject::ScDPObject(const ScDPObject& r) : +/*N*/ pDoc( r.pDoc ), +/*N*/ bAlive( FALSE ), +/*N*/ pSaveData( NULL ), +/*N*/ aTableName( r.aTableName ), +/*N*/ aTableTag( r.aTableTag ), +/*N*/ aOutRange( r.aOutRange ), +/*N*/ pSheetDesc( NULL ), +/*N*/ pImpDesc( NULL ), +/*N*/ pServDesc( NULL ), +/*N*/ pOutput( NULL ), +/*N*/ bSettingsChanged( FALSE ) +/*N*/ { +/*N*/ if (r.pSaveData) +/*N*/ pSaveData = new ScDPSaveData(*r.pSaveData); +/*N*/ if (r.pSheetDesc) +/*N*/ pSheetDesc = new ScSheetSourceDesc(*r.pSheetDesc); +/*N*/ if (r.pImpDesc) +/*N*/ pImpDesc = new ScImportSourceDesc(*r.pImpDesc); +/*N*/ if (r.pServDesc) +/*N*/ pServDesc = new ScDPServiceDesc(*r.pServDesc); +/*N*/ // xSource (and pOutput) is not copied +/*N*/ } + +/*N*/ ScDPObject::~ScDPObject() +/*N*/ { +/*N*/ delete pOutput; +/*N*/ delete pSaveData; +/*N*/ delete pSheetDesc; +/*N*/ delete pImpDesc; +/*N*/ delete pServDesc; +/*N*/ } + +/*N*/ DataObject* ScDPObject::Clone() const +/*N*/ { +DBG_BF_ASSERT(0, "STRIP"); return NULL;//STRIP001 return new ScDPObject(*this); +/*N*/ } + +/*N*/ void ScDPObject::SetAlive(BOOL bSet) +/*N*/ { +/*N*/ bAlive = bSet; +/*N*/ } + +/*N*/ void ScDPObject::SetSaveData(const ScDPSaveData& rData) +/*N*/ { +/*N*/ delete pSaveData; +/*N*/ pSaveData = new ScDPSaveData( rData ); +/*N*/ +/*N*/ InvalidateData(); // re-init source from SaveData +/*N*/ } + +/*N*/ void ScDPObject::SetOutRange(const ScRange& rRange) +/*N*/ { +/*N*/ aOutRange = rRange; +/*N*/ +/*N*/ if ( pOutput ) +/*N*/ pOutput->SetPosition( rRange.aStart ); +/*N*/ } + +/*N*/ void ScDPObject::SetSheetDesc(const ScSheetSourceDesc& rDesc) +/*N*/ { +/*N*/ if ( pSheetDesc && rDesc == *pSheetDesc ) +/*N*/ return; // nothing to do +/*N*/ +/*N*/ DELETEZ( pImpDesc ); +/*N*/ DELETEZ( pServDesc ); +/*N*/ +/*N*/ delete pImpDesc; +/*N*/ pSheetDesc = new ScSheetSourceDesc(rDesc); +/*N*/ +/*N*/ // make valid QueryParam +/*N*/ +/*N*/ pSheetDesc->aQueryParam.nCol1 = pSheetDesc->aSourceRange.aStart.Col(); +/*N*/ pSheetDesc->aQueryParam.nRow1 = pSheetDesc->aSourceRange.aStart.Row(); +/*N*/ pSheetDesc->aQueryParam.nCol2 = pSheetDesc->aSourceRange.aEnd.Col(); +/*N*/ pSheetDesc->aQueryParam.nRow2 = pSheetDesc->aSourceRange.aEnd.Row();; +/*N*/ pSheetDesc->aQueryParam.bHasHeader = TRUE; +/*N*/ USHORT nCount = pSheetDesc->aQueryParam.GetEntryCount(); +/*N*/ +/*N*/ InvalidateSource(); // new source must be created +/*N*/ } + +/*N*/ void ScDPObject::SetImportDesc(const ScImportSourceDesc& rDesc) +/*N*/ { +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 if ( pImpDesc && rDesc == *pImpDesc ) +/*N*/ } + +/*N*/ void ScDPObject::SetServiceData(const ScDPServiceDesc& rDesc) +/*N*/ { +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 if ( pServDesc && rDesc == *pServDesc ) +/*N*/ } + + +/*N*/ BOOL ScDPObject::IsSheetData() const +/*N*/ { +/*N*/ return ( pSheetDesc != NULL ); +/*N*/ } + +/*N*/ void ScDPObject::SetName(const String& rNew) +/*N*/ { +/*N*/ aTableName = rNew; +/*N*/ } + +/*N*/ void ScDPObject::SetTag(const String& rNew) +/*N*/ { +/*N*/ aTableTag = rNew; +/*N*/ } + + + +/*N*/ void ScDPObject::CreateObjects() +/*N*/ { +/*N*/ if (!xSource.is()) +/*N*/ { +/*N*/ //! cache DPSource and/or Output? +/*N*/ +/*N*/ DBG_ASSERT( bAlive, "CreateObjects on non-inserted DPObject" ); +/*N*/ +/*N*/ DELETEZ( pOutput ); // not valid when xSource is changed +/*N*/ +/*N*/ if ( pImpDesc ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 ScDatabaseDPData* pData = new ScDatabaseDPData( pDoc->GetServiceManager(), *pImpDesc ); +/*N*/ } +/*N*/ else if ( pServDesc ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 xSource = CreateSource( *pServDesc ); +/*N*/ } +/*N*/ +/*N*/ if ( !xSource.is() ) // sheet data or error in above cases +/*N*/ { +/*N*/ DBG_ASSERT( !pImpDesc && !pServDesc, "DPSource could not be created" ); +/*N*/ if (!pSheetDesc) +/*N*/ { +/*?*/ DBG_ERROR("no source descriptor"); +/*?*/ pSheetDesc = new ScSheetSourceDesc; // dummy defaults +/*N*/ } +/*N*/ ScSheetDPData* pData = new ScSheetDPData( pDoc, *pSheetDesc ); +/*N*/ xSource = new ScDPSource( pData ); +/*N*/ } +/*N*/ +/*N*/ if (pSaveData) +/*N*/ pSaveData->WriteToSource( xSource ); +/*N*/ } +/*N*/ else if (bSettingsChanged) +/*N*/ { +/*?*/ DELETEZ( pOutput ); // not valid when xSource is changed +/*?*/ +/*?*/ uno::Reference<util::XRefreshable> xRef( xSource, uno::UNO_QUERY ); +/*?*/ if (xRef.is()) +/*?*/ { +/*?*/ try +/*?*/ { +/*?*/ xRef->refresh(); +/*?*/ } +/*?*/ catch(uno::Exception&) +/*?*/ { +/*?*/ DBG_ERROR("exception in refresh"); +/*?*/ } +/*?*/ } +/*?*/ +/*?*/ if (pSaveData) +/*?*/ pSaveData->WriteToSource( xSource ); +/*N*/ } +/*N*/ bSettingsChanged = FALSE; +/*N*/ } + +/*N*/ void ScDPObject::InvalidateData() +/*N*/ { +/*N*/ bSettingsChanged = TRUE; +/*N*/ } + +/*N*/ void ScDPObject::InvalidateSource() +/*N*/ { +/*N*/ xSource = NULL; +/*N*/ } + + + +/*N*/ void ScDPObject::UpdateReference( UpdateRefMode eUpdateRefMode, +/*N*/ const ScRange& rRange, short nDx, short nDy, short nDz ) +/*N*/ { + DBG_BF_ASSERT(0, "STRIP"); //STRIP001 // Output area +} + +/*N*/ USHORT lcl_FirstSubTotal( const uno::Reference<beans::XPropertySet>& xDimProp ) // PIVOT_FUNC mask +/*N*/ { +/*N*/ uno::Reference<sheet::XHierarchiesSupplier> xDimSupp( xDimProp, uno::UNO_QUERY ); +/*N*/ if ( xDimProp.is() && xDimSupp.is() ) +/*N*/ { +/*N*/ uno::Reference<container::XIndexAccess> xHiers = new ScNameToIndexAccess( xDimSupp->getHierarchies() ); +/*N*/ long nHierarchy = ScUnoHelpFunctions::GetLongProperty( xDimProp, +/*N*/ ::rtl::OUString::createFromAscii(DP_PROP_USEDHIERARCHY) ); +/*N*/ if ( nHierarchy >= xHiers->getCount() ) +/*N*/ nHierarchy = 0; +/*N*/ +/*N*/ uno::Reference<uno::XInterface> xHier = ScUnoHelpFunctions::AnyToInterface( +/*N*/ xHiers->getByIndex(nHierarchy) ); +/*N*/ uno::Reference<sheet::XLevelsSupplier> xHierSupp( xHier, uno::UNO_QUERY ); +/*N*/ if ( xHierSupp.is() ) +/*N*/ { +/*N*/ uno::Reference<container::XIndexAccess> xLevels = new ScNameToIndexAccess( xHierSupp->getLevels() ); +/*N*/ uno::Reference<uno::XInterface> xLevel = +/*N*/ ScUnoHelpFunctions::AnyToInterface( xLevels->getByIndex( 0 ) ); +/*N*/ uno::Reference<beans::XPropertySet> xLevProp( xLevel, uno::UNO_QUERY ); +/*N*/ if ( xLevProp.is() ) +/*N*/ { +/*N*/ uno::Any aSubAny; +/*N*/ try +/*N*/ { +/*N*/ aSubAny = xLevProp->getPropertyValue( +/*N*/ ::rtl::OUString::createFromAscii(DP_PROP_SUBTOTALS) ); +/*N*/ } +/*N*/ catch(uno::Exception&) +/*N*/ { +/*N*/ } +/*N*/ uno::Sequence<sheet::GeneralFunction> aSeq; +/*N*/ if ( aSubAny >>= aSeq ) +/*N*/ { +/*N*/ USHORT nMask = 0; +/*N*/ const sheet::GeneralFunction* pArray = aSeq.getConstArray(); +/*N*/ long nCount = aSeq.getLength(); +/*N*/ for (long i=0; i<nCount; i++) +/*?*/ nMask |= ScDataPilotConversion::FunctionBit(pArray[i]); +/*N*/ return nMask; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*?*/ DBG_ERROR("FirstSubTotal: NULL"); +/*?*/ return 0; +/*N*/ } + +/*N*/ USHORT lcl_CountBits( USHORT nBits ) +/*N*/ { +/*N*/ if (!nBits) return 0; +/*N*/ +/*N*/ USHORT nCount = 0; +/*N*/ USHORT nMask = 1; +/*N*/ for (USHORT i=0; i<16; i++) +/*N*/ { +/*N*/ if ( nBits & nMask ) +/*N*/ ++nCount; +/*N*/ nMask <<= 1; +/*N*/ } +/*N*/ return nCount; +/*N*/ } + +/*N*/ USHORT lcl_FillOldFields( PivotField* pFields, +/*N*/ const uno::Reference<sheet::XDimensionsSupplier>& xSource, +/*N*/ USHORT nOrient, USHORT nColAdd, BOOL bAddData ) +/*N*/ { +/*N*/ USHORT nOutCount = 0; +/*N*/ BOOL bDataFound = FALSE; +/*N*/ +/*N*/ //! merge multiple occurences (data field with different functions) +/*N*/ //! force data field in one dimension +/*N*/ +/*N*/ long nPos[PIVOT_MAXFIELD]; +/*N*/ +/*N*/ uno::Reference<container::XNameAccess> xDimsName = xSource->getDimensions(); +/*N*/ uno::Reference<container::XIndexAccess> xDims = new ScNameToIndexAccess( xDimsName ); +/*N*/ long nDimCount = xDims->getCount(); +/*N*/ for (long nDim=0; nDim < nDimCount && nOutCount < PIVOT_MAXFIELD; nDim++) +/*N*/ { +/*N*/ uno::Reference<uno::XInterface> xIntDim = +/*N*/ ScUnoHelpFunctions::AnyToInterface( xDims->getByIndex(nDim) ); +/*N*/ uno::Reference<beans::XPropertySet> xDimProp( xIntDim, uno::UNO_QUERY ); +/*N*/ long nDimOrient = ScUnoHelpFunctions::GetEnumProperty( +/*N*/ xDimProp, ::rtl::OUString::createFromAscii(DP_PROP_ORIENTATION), +/*N*/ sheet::DataPilotFieldOrientation_HIDDEN ); +/*N*/ if ( xDimProp.is() && nDimOrient == nOrient ) +/*N*/ { +/*N*/ USHORT nMask = 0; +/*N*/ if ( nOrient == sheet::DataPilotFieldOrientation_DATA ) +/*N*/ { +/*N*/ sheet::GeneralFunction eFunc = (sheet::GeneralFunction)ScUnoHelpFunctions::GetEnumProperty( +/*N*/ xDimProp, ::rtl::OUString::createFromAscii(DP_PROP_FUNCTION), +/*N*/ sheet::GeneralFunction_NONE ); +/*N*/ if ( eFunc == sheet::GeneralFunction_AUTO ) +/*N*/ { +/*N*/ //! test for numeric data +/*?*/ eFunc = sheet::GeneralFunction_SUM; +/*N*/ } +/*N*/ nMask = ScDataPilotConversion::FunctionBit(eFunc); +/*N*/ } +/*N*/ else +/*N*/ nMask = lcl_FirstSubTotal( xDimProp ); // from first hierarchy +/*N*/ +/*N*/ BOOL bDataLayout = ScUnoHelpFunctions::GetBoolProperty( xDimProp, +/*N*/ ::rtl::OUString::createFromAscii(DP_PROP_ISDATALAYOUT) ); +/*N*/ uno::Any aOrigAny; +/*N*/ try +/*N*/ { +/*N*/ aOrigAny = xDimProp->getPropertyValue( +/*N*/ ::rtl::OUString::createFromAscii(DP_PROP_ORIGINAL) ); +/*N*/ } +/*N*/ catch(uno::Exception&) +/*N*/ { +/*N*/ } +/*N*/ +/*N*/ long nDupSource = -1; +/*N*/ uno::Reference<uno::XInterface> xIntOrig = ScUnoHelpFunctions::AnyToInterface( aOrigAny ); +/*N*/ if ( xIntOrig.is() ) +/*N*/ { +/*?*/ uno::Reference<container::XNamed> xNameOrig( xIntOrig, uno::UNO_QUERY ); +/*?*/ if ( xNameOrig.is() ) +/*?*/ {DBG_BF_ASSERT(0, "STRIP");} //STRIP001 nDupSource = lcl_FindName( xNameOrig->getName(), xDimsName ); +/*N*/ } +/*N*/ +/*N*/ BOOL bDupUsed = FALSE; +/*N*/ if ( nDupSource >= 0 ) +/*N*/ { +/*?*/ // add function bit to previous entry +/*?*/ +/*?*/ short nCompCol; +/*?*/ if ( bDataLayout ) +/*?*/ nCompCol = PIVOT_DATA_FIELD; +/*?*/ else +/*?*/ nCompCol = (short)(nDupSource+nColAdd); //! seek source column from name +/*?*/ +/*?*/ for (USHORT nOld=0; nOld<nOutCount && !bDupUsed; nOld++) +/*?*/ if ( pFields[nOld].nCol == nCompCol ) +/*?*/ { +/*?*/ // add to previous column only if new bits aren't already set there +/*?*/ if ( ( pFields[nOld].nFuncMask & nMask ) == 0 ) +/*?*/ { +/*?*/ pFields[nOld].nFuncMask |= nMask; +/*?*/ pFields[nOld].nFuncCount = lcl_CountBits( pFields[nOld].nFuncMask ); +/*?*/ bDupUsed = TRUE; +/*?*/ } +/*?*/ } +/*N*/ } +/*N*/ +/*N*/ if ( !bDupUsed ) // also for duplicated dim if original has different orientation +/*N*/ { +/*N*/ if ( bDataLayout ) +/*N*/ { +/*N*/ pFields[nOutCount].nCol = PIVOT_DATA_FIELD; +/*N*/ bDataFound = TRUE; +/*N*/ } +/*N*/ else if ( nDupSource >= 0 ) // if source was not found (different orientation) +/*?*/ pFields[nOutCount].nCol = (short)(nDupSource+nColAdd); //! seek from name +/*N*/ else +/*N*/ pFields[nOutCount].nCol = (short)(nDim+nColAdd); //! seek source column from name +/*N*/ +/*N*/ pFields[nOutCount].nFuncMask = nMask; +/*N*/ pFields[nOutCount].nFuncCount = lcl_CountBits( nMask ); +/*N*/ nPos[nOutCount] = ScUnoHelpFunctions::GetLongProperty( xDimProp, +/*N*/ ::rtl::OUString::createFromAscii(DP_PROP_POSITION) ); +/*N*/ ++nOutCount; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // sort by getPosition() value +/*N*/ +/*N*/ for (long i=0; i+1<nOutCount; i++) +/*N*/ { +/*N*/ for (long j=0; j+i+1<nOutCount; j++) +/*N*/ if ( nPos[j+1] < nPos[j] ) +/*N*/ { +/*?*/ long nTemp = nPos[j+1]; +/*?*/ nPos[j+1] = nPos[j]; +/*?*/ nPos[j] = nTemp; +/*?*/ PivotField aField = pFields[j+1]; +/*?*/ pFields[j+1] = pFields[j]; +/*?*/ pFields[j] = aField; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if ( bAddData && !bDataFound ) +/*N*/ { +/*?*/ if ( nOutCount >= PIVOT_MAXFIELD ) // space for data field? +/*?*/ --nOutCount; //! error? +/*?*/ pFields[nOutCount].nCol = PIVOT_DATA_FIELD; +/*?*/ pFields[nOutCount].nFuncMask = 0; +/*?*/ pFields[nOutCount].nFuncCount = 0; +/*?*/ ++nOutCount; +/*N*/ } +/*N*/ +/*N*/ return nOutCount; +/*N*/ } + +/*N*/ void lcl_SaveOldFieldArr( SvStream& rStream, +/*N*/ const uno::Reference<sheet::XDimensionsSupplier>& xSource, +/*N*/ USHORT nOrient, USHORT nColAdd, BOOL bAddData ) +/*N*/ { +/*N*/ // PIVOT_MAXFIELD = max. number in old files +/*N*/ PivotField aFields[PIVOT_MAXFIELD]; +/*N*/ USHORT nOutCount = lcl_FillOldFields( aFields, xSource, nOrient, nColAdd, bAddData ); +/*N*/ +/*N*/ rStream << nOutCount; +/*N*/ for (USHORT i=0; i<nOutCount; i++) +/*N*/ { +/*N*/ rStream << (BYTE) 0x00 +/*N*/ << aFields[i].nCol +/*N*/ << aFields[i].nFuncMask +/*N*/ << aFields[i].nFuncCount; +/*N*/ } +/*N*/ } + +/*N*/ BOOL ScDPObject::StoreNew( SvStream& rStream, ScMultipleWriteHeader& rHdr ) const +/*N*/ { +/*N*/ // save all data +/*N*/ +/*N*/ rHdr.StartEntry(); +/*N*/ +/*N*/ if ( pImpDesc ) +/*N*/ { +/*N*/ rStream << (BYTE) SC_DP_SOURCE_DATABASE; +/*N*/ rStream.WriteByteString( pImpDesc->aDBName, rStream.GetStreamCharSet() ); +/*N*/ rStream.WriteByteString( pImpDesc->aObject, rStream.GetStreamCharSet() ); +/*N*/ rStream << pImpDesc->nType; // USHORT +/*N*/ rStream << pImpDesc->bNative; +/*N*/ } +/*N*/ else if ( pServDesc ) +/*N*/ { +/*N*/ rStream << (BYTE) SC_DP_SOURCE_SERVICE; +/*N*/ rStream.WriteByteString( pServDesc->aServiceName, rStream.GetStreamCharSet() ); +/*N*/ rStream.WriteByteString( pServDesc->aParSource, rStream.GetStreamCharSet() ); +/*N*/ rStream.WriteByteString( pServDesc->aParName, rStream.GetStreamCharSet() ); +/*N*/ rStream.WriteByteString( pServDesc->aParUser, rStream.GetStreamCharSet() ); +/*N*/ rStream.WriteByteString( pServDesc->aParPass, rStream.GetStreamCharSet() ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ if (!pSheetDesc) +/*N*/ { +/*N*/ DBG_ERROR("no source descriptor"); +/*N*/ ((ScDPObject*)this)->pSheetDesc = new ScSheetSourceDesc; // dummy defaults +/*N*/ } +/*N*/ +/*N*/ rStream << (BYTE) SC_DP_SOURCE_SHEET; +/*N*/ rStream << pSheetDesc->aSourceRange; +/*N*/ pSheetDesc->aQueryParam.Store( rStream ); +/*N*/ } +/*N*/ +/*N*/ rStream << aOutRange; +/*N*/ +/*N*/ DBG_ASSERT(pSaveData, "ScDPObject::StoreNew no SaveData"); +/*N*/ pSaveData->Store( rStream ); +/*N*/ +/*N*/ // additional data starting from 561b +/*N*/ rStream.WriteByteString( aTableName, rStream.GetStreamCharSet() ); +/*N*/ rStream.WriteByteString( aTableTag, rStream.GetStreamCharSet() ); +/*N*/ +/*N*/ rHdr.EndEntry(); +/*N*/ return TRUE; +/*N*/ } +/*N*/ +/*N*/ BOOL ScDPObject::LoadNew(SvStream& rStream, ScMultipleReadHeader& rHdr ) +/*N*/ { +/*N*/ rHdr.StartEntry(); +/*N*/ +/*N*/ DELETEZ( pImpDesc ); +/*N*/ DELETEZ( pSheetDesc ); +/*N*/ DELETEZ( pServDesc ); +/*N*/ +/*N*/ BYTE nType; +/*N*/ rStream >> nType; +/*N*/ switch (nType) +/*N*/ { +/*N*/ case SC_DP_SOURCE_DATABASE: +/*N*/ pImpDesc = new ScImportSourceDesc; +/*N*/ rStream.ReadByteString( pImpDesc->aDBName, rStream.GetStreamCharSet() ); +/*N*/ rStream.ReadByteString( pImpDesc->aObject, rStream.GetStreamCharSet() ); +/*N*/ rStream >> pImpDesc->nType; // USHORT +/*N*/ rStream >> pImpDesc->bNative; +/*N*/ break; +/*N*/ +/*N*/ case SC_DP_SOURCE_SHEET: +/*N*/ pSheetDesc = new ScSheetSourceDesc; +/*N*/ rStream >> pSheetDesc->aSourceRange; +/*N*/ pSheetDesc->aQueryParam.Load( rStream ); +/*N*/ break; +/*N*/ +/*N*/ case SC_DP_SOURCE_SERVICE: +/*N*/ { +/*N*/ String aServiceName, aParSource, aParName, aParUser, aParPass; +/*N*/ rStream.ReadByteString( aServiceName, rStream.GetStreamCharSet() ); +/*N*/ rStream.ReadByteString( aParSource, rStream.GetStreamCharSet() ); +/*N*/ rStream.ReadByteString( aParName, rStream.GetStreamCharSet() ); +/*N*/ rStream.ReadByteString( aParUser, rStream.GetStreamCharSet() ); +/*N*/ rStream.ReadByteString( aParPass, rStream.GetStreamCharSet() ); +/*N*/ pServDesc = new ScDPServiceDesc( aServiceName, +/*N*/ aParSource, aParName, aParUser, aParPass ); +/*N*/ } +/*N*/ break; +/*N*/ +/*N*/ default: +/*N*/ DBG_ERROR("unknown source type"); +/*N*/ } +/*N*/ +/*N*/ rStream >> aOutRange; +/*N*/ +/*N*/ SetSaveData(ScDPSaveData()); +/*N*/ pSaveData->Load( rStream ); +/*N*/ +/*N*/ if (rHdr.BytesLeft()) // additional data starting from 561b +/*N*/ { +/*N*/ rStream.ReadByteString( aTableName, rStream.GetStreamCharSet() ); +/*N*/ rStream.ReadByteString( aTableTag, rStream.GetStreamCharSet() ); +/*N*/ } +/*N*/ +/*N*/ rHdr.EndEntry(); +/*N*/ return TRUE; +/*N*/ } + +/*N*/ BOOL ScDPObject::StoreOld( SvStream& rStream, ScMultipleWriteHeader& rHdr ) const +/*N*/ { +/*N*/ // write compatible data for office 5.1 and below +/*N*/ +/*N*/ DBG_ASSERT( pSheetDesc, "StoreOld: !pSheetDesc" ); +/*N*/ ScRange aStoreRange; +/*N*/ ScQueryParam aStoreQuery; +/*N*/ if (pSheetDesc) +/*N*/ { +/*N*/ aStoreRange = pSheetDesc->aSourceRange; +/*N*/ aStoreQuery = pSheetDesc->aQueryParam; +/*N*/ } +/*N*/ +/*N*/ ((ScDPObject*)this)->CreateObjects(); // xSource is needed for field numbers +/*N*/ +/*N*/ rHdr.StartEntry(); +/*N*/ +/*N*/ rStream << (BOOL) TRUE; // bHasHeader +/*N*/ +/*N*/ rStream << aStoreRange.aStart.Col(); +/*N*/ rStream << aStoreRange.aStart.Row(); +/*N*/ rStream << aStoreRange.aEnd.Col(); +/*N*/ rStream << aStoreRange.aEnd.Row(); +/*N*/ rStream << aStoreRange.aStart.Tab(); +/*N*/ +/*N*/ //! make sure aOutRange is initialized +/*N*/ +/*N*/ rStream << aOutRange.aStart.Col(); +/*N*/ rStream << aOutRange.aStart.Row(); +/*N*/ rStream << aOutRange.aEnd.Col(); +/*N*/ rStream << aOutRange.aEnd.Row(); +/*N*/ rStream << aOutRange.aStart.Tab(); +/*N*/ +/*N*/ BOOL bAddData = ( lcl_GetDataGetOrientation( xSource ) == sheet::DataPilotFieldOrientation_HIDDEN ); +/*N*/ +/*N*/ lcl_SaveOldFieldArr( rStream, xSource, sheet::DataPilotFieldOrientation_ROW, aStoreRange.aStart.Col(), bAddData ); +/*N*/ lcl_SaveOldFieldArr( rStream, xSource, sheet::DataPilotFieldOrientation_COLUMN, aStoreRange.aStart.Col(), FALSE ); +/*N*/ lcl_SaveOldFieldArr( rStream, xSource, sheet::DataPilotFieldOrientation_DATA, aStoreRange.aStart.Col(), FALSE ); +/*N*/ +/*N*/ aStoreQuery.Store( rStream ); +/*N*/ +/*N*/ BOOL bColumnGrand = TRUE; +/*N*/ BOOL bRowGrand = TRUE; +/*N*/ BOOL bIgnoreEmpty = FALSE; +/*N*/ BOOL bRepeatIfEmpty = FALSE; +/*N*/ +/*N*/ uno::Reference<beans::XPropertySet> xProp( xSource, uno::UNO_QUERY ); +/*N*/ if (xProp.is()) +/*N*/ { +/*N*/ bColumnGrand = ScUnoHelpFunctions::GetBoolProperty( xProp, +/*N*/ ::rtl::OUString::createFromAscii(DP_PROP_COLUMNGRAND), TRUE ); +/*N*/ bRowGrand = ScUnoHelpFunctions::GetBoolProperty( xProp, +/*N*/ ::rtl::OUString::createFromAscii(DP_PROP_ROWGRAND), TRUE ); +/*N*/ +/*N*/ // following properties may be missing for external sources +/*N*/ bIgnoreEmpty = ScUnoHelpFunctions::GetBoolProperty( xProp, +/*N*/ ::rtl::OUString::createFromAscii(DP_PROP_IGNOREEMPTY) ); +/*N*/ bRepeatIfEmpty = ScUnoHelpFunctions::GetBoolProperty( xProp, +/*N*/ ::rtl::OUString::createFromAscii(DP_PROP_REPEATIFEMPTY) ); +/*N*/ } +/*N*/ +/*N*/ rStream << bIgnoreEmpty; // bIgnoreEmpty +/*N*/ rStream << bRepeatIfEmpty; // bDetectCat +/*N*/ +/*N*/ rStream << bColumnGrand; // bMakeTotalCol +/*N*/ rStream << bRowGrand; // bMakeTotalRow +/*N*/ +/*N*/ if( rStream.GetVersion() > SOFFICE_FILEFORMAT_40 ) +/*N*/ { +/*N*/ rStream.WriteByteString( aTableName, rStream.GetStreamCharSet() ); +/*N*/ rStream.WriteByteString( aTableTag, rStream.GetStreamCharSet() ); +/*N*/ rStream << (USHORT)0; // nColNameCount +/*N*/ } +/*N*/ +/*N*/ rHdr.EndEntry(); +/*N*/ return TRUE; +/*N*/ } + +/*N*/ BOOL ScDPObject::FillOldParam(ScPivotParam& rParam, BOOL bForFile) const +/*N*/ { +/*N*/ ((ScDPObject*)this)->CreateObjects(); // xSource is needed for field numbers +/*N*/ +/*N*/ rParam.nCol = aOutRange.aStart.Col(); +/*N*/ rParam.nRow = aOutRange.aStart.Row(); +/*N*/ rParam.nTab = aOutRange.aStart.Tab(); +/*N*/ // ppLabelArr / nLabels is not changed +/*N*/ +/*N*/ USHORT nColAdd = 0; +/*N*/ if ( bForFile ) +/*N*/ { +/*N*/ // in old file format, columns are within document, not within source range +/*N*/ +/*N*/ DBG_ASSERT( pSheetDesc, "FillOldParam: bForFile, !pSheetDesc" ); +/*N*/ nColAdd = pSheetDesc->aSourceRange.aStart.Col(); +/*N*/ } +/*N*/ +/*N*/ BOOL bAddData = ( lcl_GetDataGetOrientation( xSource ) == sheet::DataPilotFieldOrientation_HIDDEN ); +/*N*/ rParam.nColCount = lcl_FillOldFields( rParam.aColArr, +/*N*/ xSource, sheet::DataPilotFieldOrientation_COLUMN, nColAdd, bAddData ); +/*N*/ rParam.nRowCount = lcl_FillOldFields( rParam.aRowArr, +/*N*/ xSource, sheet::DataPilotFieldOrientation_ROW, nColAdd, FALSE ); +/*N*/ rParam.nDataCount = lcl_FillOldFields( rParam.aDataArr, +/*N*/ xSource, sheet::DataPilotFieldOrientation_DATA, nColAdd, FALSE ); +/*N*/ +/*N*/ uno::Reference<beans::XPropertySet> xProp( xSource, uno::UNO_QUERY ); +/*N*/ if (xProp.is()) +/*N*/ { +/*N*/ try +/*N*/ { +/*N*/ rParam.bMakeTotalCol = ScUnoHelpFunctions::GetBoolProperty( xProp, +/*N*/ ::rtl::OUString::createFromAscii(DP_PROP_COLUMNGRAND), TRUE ); +/*N*/ rParam.bMakeTotalRow = ScUnoHelpFunctions::GetBoolProperty( xProp, +/*N*/ ::rtl::OUString::createFromAscii(DP_PROP_ROWGRAND), TRUE ); +/*N*/ +/*N*/ // following properties may be missing for external sources +/*N*/ rParam.bIgnoreEmptyRows = ScUnoHelpFunctions::GetBoolProperty( xProp, +/*N*/ ::rtl::OUString::createFromAscii(DP_PROP_IGNOREEMPTY) ); +/*N*/ rParam.bDetectCategories = ScUnoHelpFunctions::GetBoolProperty( xProp, +/*N*/ ::rtl::OUString::createFromAscii(DP_PROP_REPEATIFEMPTY) ); +/*N*/ } +/*N*/ catch(uno::Exception&) +/*N*/ { +/*N*/ // no error +/*N*/ } +/*N*/ } +/*N*/ return TRUE; +/*N*/ } + + + + +//------------------------------------------------------------------------ +// convert old pivot tables into new datapilot tables + + +// static +/*N*/ void ScDPObject::ConvertOrientation( ScDPSaveData& rSaveData, +/*N*/ PivotField* pFields, USHORT nCount, USHORT nOrient, +/*N*/ ScDocument* pDoc, USHORT nRow, USHORT nTab, +/*N*/ const uno::Reference<sheet::XDimensionsSupplier>& xSource, +/*N*/ BOOL bOldDefaults, +/*N*/ PivotField* pRefColFields, USHORT nRefColCount, +/*N*/ PivotField* pRefRowFields, USHORT nRefRowCount ) +/*N*/ { +/*N*/ // pDoc or xSource must be set +/*N*/ DBG_ASSERT( pDoc || xSource.is(), "missing string source" ); +/*N*/ +/*N*/ String aDocStr; +/*N*/ ScDPSaveDimension* pDim; +/*N*/ +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ { +/*N*/ USHORT nCol = pFields[i].nCol; +/*N*/ USHORT nFuncs = pFields[i].nFuncMask; +/*N*/ if ( nCol == PIVOT_DATA_FIELD ) +/*N*/ pDim = rSaveData.GetDataLayoutDimension(); +/*N*/ else +/*N*/ { +/*N*/ if ( pDoc ) +/*N*/ pDoc->GetString( nCol, nRow, nTab, aDocStr ); +/*N*/ else +/*?*/ {DBG_BF_ASSERT(0, "STRIP");} //STRIP001 aDocStr = lcl_GetDimName( xSource, nCol ); // cols must start at 0 +/*N*/ +/*N*/ if ( aDocStr.Len() ) +/*N*/ pDim = rSaveData.GetDimensionByName(aDocStr); +/*N*/ else +/*?*/ pDim = NULL; +/*N*/ } +/*N*/ +/*N*/ if ( pDim ) +/*N*/ { +/*N*/ if ( nOrient == sheet::DataPilotFieldOrientation_DATA ) // set summary function +/*N*/ { +/*N*/ // generate an individual entry for each function +/*N*/ BOOL bFirst = TRUE; +/*N*/ +/*N*/ // if a dimension is used for column or row and data, +/*N*/ // use duplicated dimensions for all data occurrences +/*N*/ if (pRefColFields) +/*N*/ for (USHORT nRefCol=0; nRefCol<nRefColCount; nRefCol++) +/*N*/ if (pRefColFields[nRefCol].nCol == nCol) +/*?*/ bFirst = FALSE; +/*N*/ if (pRefRowFields) +/*N*/ for (USHORT nRefRow=0; nRefRow<nRefRowCount; nRefRow++) +/*N*/ if (pRefRowFields[nRefRow].nCol == nCol) +/*?*/ bFirst = FALSE; +/*N*/ +/*N*/ // if set via api, a data column may occur several times +/*N*/ // (if the function hasn't been changed yet) -> also look for duplicate data column +/*N*/ for (USHORT nPrevData=0; nPrevData<i; nPrevData++) +/*?*/ if (pFields[nPrevData].nCol == nCol) +/*?*/ bFirst = FALSE; +/*N*/ +/*N*/ USHORT nMask = 1; +/*N*/ for (USHORT nBit=0; nBit<16; nBit++) +/*N*/ { +/*N*/ if ( nFuncs & nMask ) +/*N*/ { +/*N*/ sheet::GeneralFunction eFunc = ScDataPilotConversion::FirstFunc( nMask ); +/*N*/ if (bFirst) +/*N*/ { +/*N*/ pDim->SetOrientation( nOrient ); +/*N*/ pDim->SetFunction( eFunc ); +/*N*/ bFirst = FALSE; +/*N*/ } +/*N*/ else +/*N*/ { +/*?*/ ScDPSaveDimension* pDup = rSaveData.DuplicateDimension(pDim->GetName()); +/*?*/ pDup->SetOrientation( nOrient ); +/*?*/ pDup->SetFunction( eFunc ); +/*N*/ } +/*N*/ } +/*N*/ nMask *= 2; +/*N*/ } +/*N*/ } +/*N*/ else // set SubTotals +/*N*/ { +/*N*/ pDim->SetOrientation( nOrient ); +/*N*/ +/*N*/ USHORT nFuncArray[16]; +/*N*/ USHORT nFuncCount = 0; +/*N*/ USHORT nMask = 1; +/*N*/ for (USHORT nBit=0; nBit<16; nBit++) +/*N*/ { +/*N*/ if ( nFuncs & nMask ) +/*?*/ nFuncArray[nFuncCount++] = ScDataPilotConversion::FirstFunc( nMask ); +/*N*/ nMask *= 2; +/*N*/ } +/*N*/ pDim->SetSubTotals( nFuncCount, nFuncArray ); +/*N*/ +/*N*/ // ShowEmpty was implicit in old tables, +/*N*/ // must be set for data layout dimension (not accessible in dialog) +/*N*/ if ( bOldDefaults || nCol == PIVOT_DATA_FIELD ) +/*N*/ pDim->SetShowEmpty( TRUE ); +/*N*/ } +/*N*/ } +/*N*/ } +} + +/*N*/ void ScDPObject::InitFromOldPivot( const ScPivot& rOld, ScDocument* pDoc, BOOL bSetSource ) +/*N*/ { +/*N*/ ScDPSaveData aSaveData; +/*N*/ +/*N*/ ScPivotParam aParam; +/*N*/ ScQueryParam aQuery; +/*N*/ ScArea aArea; +/*N*/ rOld.GetParam( aParam, aQuery, aArea ); +/*N*/ +/*N*/ ConvertOrientation( aSaveData, aParam.aColArr, aParam.nColCount, +/*N*/ sheet::DataPilotFieldOrientation_COLUMN, pDoc, aArea.nRowStart, aArea.nTab, +/*N*/ uno::Reference<sheet::XDimensionsSupplier>(), TRUE ); +/*N*/ ConvertOrientation( aSaveData, aParam.aRowArr, aParam.nRowCount, +/*N*/ sheet::DataPilotFieldOrientation_ROW, pDoc, aArea.nRowStart, aArea.nTab, +/*N*/ uno::Reference<sheet::XDimensionsSupplier>(), TRUE ); +/*N*/ ConvertOrientation( aSaveData, aParam.aDataArr, aParam.nDataCount, +/*N*/ sheet::DataPilotFieldOrientation_DATA, pDoc, aArea.nRowStart, aArea.nTab, +/*N*/ uno::Reference<sheet::XDimensionsSupplier>(), TRUE, +/*N*/ aParam.aColArr, aParam.nColCount, aParam.aRowArr, aParam.nRowCount ); +/*N*/ +/*N*/ aSaveData.SetIgnoreEmptyRows( rOld.GetIgnoreEmpty() ); +/*N*/ aSaveData.SetRepeatIfEmpty( rOld.GetDetectCat() ); +/*N*/ aSaveData.SetColumnGrand( rOld.GetMakeTotalCol() ); +/*N*/ aSaveData.SetRowGrand( rOld.GetMakeTotalRow() ); +/*N*/ +/*N*/ SetSaveData( aSaveData ); +/*N*/ if (bSetSource) +/*N*/ { +/*N*/ ScSheetSourceDesc aDesc; +/*N*/ aDesc.aSourceRange = rOld.GetSrcArea(); +/*N*/ rOld.GetQuery( aDesc.aQueryParam ); +/*N*/ SetSheetDesc( aDesc ); +/*N*/ } +/*N*/ SetOutRange( rOld.GetDestArea() ); +/*N*/ +/*N*/ aTableName = rOld.GetName(); +/*N*/ aTableTag = rOld.GetTag(); +/*N*/ } + +// ----------------------------------------------------------------------- + +// static + +// static + +// static + +// ----------------------------------------------------------------------- + +/*N*/ ScDPCollection::ScDPCollection(ScDocument* pDocument) : +/*N*/ pDoc( pDocument ) +/*N*/ { +/*N*/ } + +/*N*/ ScDPCollection::ScDPCollection(const ScDPCollection& r) : +/*N*/ Collection(r), +/*N*/ pDoc(r.pDoc) +/*N*/ { +/*N*/ } + +/*N*/ ScDPCollection::~ScDPCollection() +/*N*/ { +/*N*/ } + +/*N*/ DataObject* ScDPCollection::Clone() const +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); return NULL;//STRIP001 return new ScDPCollection(*this); +/*N*/ } + +/*N*/ BOOL ScDPCollection::StoreOld( SvStream& rStream ) const +/*N*/ { +/*N*/ BOOL bSuccess = TRUE; +/*N*/ +/*N*/ USHORT nSheetCount = 0; +/*N*/ USHORT i; +/*N*/ for (i=0; i<nCount; i++) +/*N*/ if ( ((const ScDPObject*)At(i))->IsSheetData() ) +/*N*/ ++nSheetCount; +/*N*/ +/*N*/ ScMultipleWriteHeader aHdr( rStream ); +/*N*/ +/*N*/ rStream << nSheetCount; // only tables from sheet data +/*N*/ +/*N*/ for (i=0; i<nCount && bSuccess; i++) +/*N*/ { +/*N*/ const ScDPObject* pObj = (const ScDPObject*)At(i); +/*N*/ if ( pObj->IsSheetData() ) +/*N*/ bSuccess = pObj->StoreOld( rStream, aHdr ); +/*N*/ } +/*N*/ +/*N*/ return bSuccess; +/*N*/ } + +/*N*/ BOOL ScDPCollection::StoreNew( SvStream& rStream ) const +/*N*/ { +/*N*/ BOOL bSuccess = TRUE; +/*N*/ +/*N*/ ScMultipleWriteHeader aHdr( rStream ); +/*N*/ +/*N*/ rStream << (long)SC_DP_VERSION_CURRENT; +/*N*/ rStream << (long)nCount; +/*N*/ +/*N*/ for (USHORT i=0; i<nCount && bSuccess; i++) +/*N*/ bSuccess = ((const ScDPObject*)At(i))->StoreNew( rStream, aHdr ); +/*N*/ +/*N*/ return bSuccess; +/*N*/ } +/*N*/ +/*N*/ BOOL ScDPCollection::LoadNew( SvStream& rStream ) +/*N*/ { +/*N*/ BOOL bSuccess = TRUE; +/*N*/ +/*N*/ FreeAll(); +/*N*/ ScMultipleReadHeader aHdr( rStream ); +/*N*/ +/*N*/ long nVer; +/*N*/ rStream >> nVer; +/*N*/ +/*N*/ // check for all supported versions here.. +/*N*/ +/*N*/ if ( nVer != SC_DP_VERSION_CURRENT ) +/*N*/ { +/*N*/ DBG_ERROR("skipping unknown version of data pilot obejct"); +/*N*/ if ( rStream.GetError() == SVSTREAM_OK ) +/*N*/ rStream.SetError( SCWARN_IMPORT_INFOLOST ); +/*N*/ return FALSE; +/*N*/ } +/*N*/ +/*N*/ long nNewCount; +/*N*/ rStream >> nNewCount; +/*N*/ for (long i=0; i<nNewCount; i++) +/*N*/ { +/*N*/ ScDPObject* pObj = new ScDPObject( pDoc ); +/*N*/ if ( pObj->LoadNew(rStream, aHdr) ) +/*N*/ { +/*N*/ pObj->SetAlive( TRUE ); +/*N*/ Insert( pObj ); +/*N*/ } +/*N*/ else +/*N*/ delete pObj; +/*N*/ } +/*N*/ +/*N*/ return bSuccess; +/*N*/ } + +/*N*/ void ScDPCollection::UpdateReference( UpdateRefMode eUpdateRefMode, +/*N*/ const ScRange& r, short nDx, short nDy, short nDz ) +/*N*/ { +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ ((ScDPObject*)At(i))->UpdateReference( eUpdateRefMode, r, nDx, nDy, nDz ); +/*N*/ } + +/*N*/ String ScDPCollection::CreateNewName( USHORT nMin ) const +/*N*/ { +/*N*/ String aBase = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("DataPilot")); +/*N*/ //! from Resource? +/*N*/ +/*N*/ for (USHORT nAdd=0; nAdd<=nCount; nAdd++) // nCount+1 tries +/*N*/ { +/*N*/ String aNewName = aBase; +/*N*/ aNewName += String::CreateFromInt32( nMin + nAdd ); +/*N*/ BOOL bFound = FALSE; +/*N*/ for (USHORT i=0; i<nCount && !bFound; i++) +/*N*/ if (((const ScDPObject*)pItems[i])->GetName() == aNewName) +/*N*/ bFound = TRUE; +/*N*/ if (!bFound) +/*N*/ return aNewName; // found unused Name +/*N*/ } +/*N*/ return String(); // should not happen +/*N*/ } + +/*N*/ void ScDPCollection::EnsureNames() +/*N*/ { +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ if (!((const ScDPObject*)At(i))->GetName().Len()) +/*?*/ ((ScDPObject*)At(i))->SetName( CreateNewName() ); +/*N*/ } + +//------------------------------------------------------------------------ +// convert old pivot tables into new datapilot tables + +/*N*/ void ScDPCollection::ConvertOldTables( ScPivotCollection& rOldColl ) +/*N*/ { +/*N*/ // convert old pivot tables into new datapilot tables +/*N*/ +/*N*/ USHORT nOldCount = rOldColl.GetCount(); +/*N*/ for (USHORT i=0; i<nOldCount; i++) +/*N*/ { +/*N*/ ScDPObject* pNewObj = new ScDPObject(pDoc); +/*N*/ pNewObj->InitFromOldPivot( *(rOldColl)[i], pDoc, TRUE ); +/*N*/ pNewObj->SetAlive( TRUE ); +/*N*/ Insert( pNewObj ); +/*N*/ } +/*N*/ rOldColl.FreeAll(); +/*N*/ } + + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_dpoutput.cxx b/binfilter/bf_sc/source/core/data/sc_dpoutput.cxx new file mode 100644 index 000000000000..982250007ab1 --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_dpoutput.cxx @@ -0,0 +1,117 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// INCLUDE --------------------------------------------------------------- + +#include "scitems.hxx" +#include <bf_svx/algitem.hxx> +#include <bf_svx/boxitem.hxx> +#include <bf_svx/brshitem.hxx> +#include <bf_svx/wghtitem.hxx> + +#include "dpoutput.hxx" +#include "document.hxx" +#include "patattr.hxx" +#include "docpool.hxx" +#include "markdata.hxx" +#include "attrib.hxx" +#include "compiler.hxx" // errNoValue +#include "miscuno.hxx" +#include "globstr.hrc" +#include "stlpool.hxx" +#include "stlsheet.hxx" + +#include <com/sun/star/sheet/XLevelsSupplier.hpp> +#include <com/sun/star/sheet/XHierarchiesSupplier.hpp> +#include <com/sun/star/sheet/XDataPilotResults.hpp> +#include <com/sun/star/sheet/XDataPilotMemberResults.hpp> +#include <com/sun/star/sheet/DataResultFlags.hpp> +#include <com/sun/star/sheet/MemberResultFlags.hpp> +#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp> +#include <com/sun/star/container/XNamed.hpp> +namespace binfilter { + +using namespace ::com::sun::star; + +// ----------------------------------------------------------------------- + +//! move to a header file +#define DP_PROP_ORIENTATION "Orientation" +#define DP_PROP_POSITION "Position" +#define DP_PROP_USEDHIERARCHY "UsedHierarchy" +#define DP_PROP_DATADESCR "DataDescription" +#define DP_PROP_ISDATALAYOUT "IsDataLayoutDimension" +#define DP_PROP_NUMBERFORMAT "NumberFormat" + +// ----------------------------------------------------------------------- + +//! dynamic!!! +#define SC_DPOUT_MAXLEVELS 256 + + +struct ScDPOutLevelData +{ + long nDim; + long nHier; + long nLevel; + long nDimPos; + uno::Sequence<sheet::MemberResult> aResult; + String aCaption; + + ScDPOutLevelData() { nDim = nHier = nLevel = nDimPos = -1; } + + BOOL operator<(const ScDPOutLevelData& r) const + { return nDimPos<r.nDimPos || ( nDimPos==r.nDimPos && nHier<r.nHier ) || + ( nDimPos==r.nDimPos && nHier==r.nHier && nLevel<r.nLevel ); } + + void Swap(ScDPOutLevelData& r) +//! { ScDPOutLevelData aTemp = r; r = *this; *this = aTemp; } + { ScDPOutLevelData aTemp; aTemp = r; r = *this; *this = aTemp; } + + //! bug (73840) in uno::Sequence - copy and then assign doesn't work! +}; + +ScDPOutput::~ScDPOutput() +{ + delete[] pColFields; + delete[] pRowFields; + delete[] pPageFields; + + delete[] pColNumFmt; + delete[] pRowNumFmt; +} + +/*N*/ void ScDPOutput::SetPosition( const ScAddress& rPos ) +/*N*/ { +/*N*/ aStartPos = rPos; +/*N*/ bSizesValid = bSizeOverflow = FALSE; +/*N*/ } + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_dpsave.cxx b/binfilter/bf_sc/source/core/data/sc_dpsave.cxx new file mode 100644 index 000000000000..e7f80ea7066e --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_dpsave.cxx @@ -0,0 +1,845 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// INCLUDE --------------------------------------------------------------- + +#include "dpsave.hxx" +#include "miscuno.hxx" +#include "scerrors.hxx" + +#include <tools/debug.hxx> +#include <tools/stream.hxx> + +#include <com/sun/star/sheet/GeneralFunction.hpp> +#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp> +#include <com/sun/star/sheet/XHierarchiesSupplier.hpp> +#include <com/sun/star/sheet/XLevelsSupplier.hpp> +#include <com/sun/star/sheet/XMembersSupplier.hpp> +#include <com/sun/star/container/XNamed.hpp> +#include <com/sun/star/util/XCloneable.hpp> +namespace binfilter { + +using namespace ::com::sun::star; + +// ----------------------------------------------------------------------- + +#define SC_DPSAVEMODE_NO 0 +#define SC_DPSAVEMODE_YES 1 +#define SC_DPSAVEMODE_DONTKNOW 2 + +// ----------------------------------------------------------------------- + +//! move to a header file +#define DP_PROP_COLUMNGRAND "ColumnGrand" +#define DP_PROP_FUNCTION "Function" +#define DP_PROP_IGNOREEMPTY "IgnoreEmptyRows" +#define DP_PROP_ISDATALAYOUT "IsDataLayoutDimension" +#define DP_PROP_ISVISIBLE "IsVisible" +#define DP_PROP_ORIENTATION "Orientation" +#define DP_PROP_REPEATIFEMPTY "RepeatIfEmpty" +#define DP_PROP_ROWGRAND "RowGrand" +#define DP_PROP_SHOWDETAILS "ShowDetails" +#define DP_PROP_SHOWEMPTY "ShowEmpty" +#define DP_PROP_SUBTOTALS "SubTotals" +#define DP_PROP_USEDHIERARCHY "UsedHierarchy" + +// ----------------------------------------------------------------------- + +/*N*/ void lcl_SetBoolProperty( const uno::Reference<beans::XPropertySet>& xProp, +/*N*/ const ::rtl::OUString& rName, sal_Bool bValue ) +/*N*/ { +/*N*/ //! move to ScUnoHelpFunctions? +/*N*/ +/*N*/ xProp->setPropertyValue( rName, uno::Any( &bValue, getBooleanCppuType() ) ); +/*N*/ } +/*N*/ +/*N*/ // ----------------------------------------------------------------------- +/*N*/ +/*N*/ void lcl_SkipExtra( SvStream& rStream ) +/*N*/ { +/*N*/ USHORT nExtra; +/*N*/ rStream >> nExtra; +/*N*/ if ( nExtra ) +/*N*/ { +/*N*/ rStream.SeekRel( nExtra ); +/*N*/ if ( rStream.GetError() == SVSTREAM_OK ) +/*N*/ rStream.SetError( SCWARN_IMPORT_INFOLOST ); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // ----------------------------------------------------------------------- +/*N*/ +/*N*/ ScDPSaveMember::ScDPSaveMember(const String& rName) : +/*N*/ aName( rName ), +/*N*/ nVisibleMode( SC_DPSAVEMODE_DONTKNOW ), +/*N*/ nShowDetailsMode( SC_DPSAVEMODE_DONTKNOW ) +/*N*/ { +/*N*/ } +/*N*/ +/*N*/ ScDPSaveMember::ScDPSaveMember(const ScDPSaveMember& r) : +/*N*/ aName( r.aName ), +/*N*/ nVisibleMode( r.nVisibleMode ), +/*N*/ nShowDetailsMode( r.nShowDetailsMode ) +/*N*/ { +/*N*/ } +/*N*/ +/*N*/ ScDPSaveMember::ScDPSaveMember(SvStream& rStream) +/*N*/ { +/*N*/ rStream.ReadByteString( aName, rStream.GetStreamCharSet() ); +/*N*/ rStream >> nVisibleMode; +/*N*/ rStream >> nShowDetailsMode; +/*N*/ +/*N*/ lcl_SkipExtra( rStream ); // reads at least 1 USHORT +/*N*/ } +/*N*/ +/*N*/ void ScDPSaveMember::Store( SvStream& rStream ) const +/*N*/ { +/*N*/ rStream.WriteByteString( aName, rStream.GetStreamCharSet() ); +/*N*/ rStream << nVisibleMode; +/*N*/ rStream << nShowDetailsMode; +/*N*/ +/*N*/ rStream << (USHORT) 0; // nExtra +/*N*/ } +/*N*/ +/*N*/ ScDPSaveMember::~ScDPSaveMember() +/*N*/ { +/*N*/ } +/*N*/ +/*N*/ BOOL ScDPSaveMember::operator== ( const ScDPSaveMember& r ) const +/*N*/ { +/*N*/ if ( aName != r.aName || +/*N*/ nVisibleMode != r.nVisibleMode || +/*N*/ nShowDetailsMode != r.nShowDetailsMode ) +/*N*/ return FALSE; +/*N*/ +/*N*/ return TRUE; +/*N*/ } +/*N*/ +/*N*/ void ScDPSaveMember::SetIsVisible(BOOL bSet) +/*N*/ { +/*N*/ nVisibleMode = bSet; +/*N*/ } +/*N*/ +/*N*/ void ScDPSaveMember::SetShowDetails(BOOL bSet) +/*N*/ { +/*N*/ nShowDetailsMode = bSet; +/*N*/ } +/*N*/ +/*N*/ void ScDPSaveMember::WriteToSource( const uno::Reference<uno::XInterface>& xMember ) +/*N*/ { +/*N*/ // nothing to do? +/*N*/ if ( nVisibleMode == SC_DPSAVEMODE_DONTKNOW && nShowDetailsMode == SC_DPSAVEMODE_DONTKNOW ) +/*N*/ return; +/*N*/ +/*N*/ uno::Reference<beans::XPropertySet> xMembProp( xMember, uno::UNO_QUERY ); +/*N*/ DBG_ASSERT( xMembProp.is(), "no properties at member" ); +/*N*/ if ( xMembProp.is() ) +/*N*/ { +/*N*/ // exceptions are caught at ScDPSaveData::WriteToSource +/*N*/ +/*N*/ if ( nVisibleMode != SC_DPSAVEMODE_DONTKNOW ) +/*N*/ lcl_SetBoolProperty( xMembProp, +/*N*/ ::rtl::OUString::createFromAscii(DP_PROP_ISVISIBLE), (BOOL)nVisibleMode ); +/*N*/ +/*N*/ if ( nShowDetailsMode != SC_DPSAVEMODE_DONTKNOW ) +/*N*/ lcl_SetBoolProperty( xMembProp, +/*N*/ ::rtl::OUString::createFromAscii(DP_PROP_SHOWDETAILS), (BOOL)nShowDetailsMode ); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // ----------------------------------------------------------------------- +/*N*/ +/*N*/ ScDPSaveDimension::ScDPSaveDimension(const String& rName, BOOL bDataLayout) : +/*N*/ aName( rName ), +/*N*/ bIsDataLayout( bDataLayout ), +/*N*/ bDupFlag( FALSE ), +/*N*/ nOrientation( sheet::DataPilotFieldOrientation_HIDDEN ), +/*N*/ bSubTotalDefault( TRUE ), +/*N*/ nSubTotalCount( 0 ), +/*N*/ pSubTotalFuncs( NULL ), +/*N*/ nShowEmptyMode( SC_DPSAVEMODE_DONTKNOW ), +/*N*/ nFunction( sheet::GeneralFunction_AUTO ), +/*N*/ nUsedHierarchy( -1 ), +/*N*/ pLayoutName( NULL ) +/*N*/ { +/*N*/ } +/*N*/ +/*N*/ ScDPSaveDimension::ScDPSaveDimension(const ScDPSaveDimension& r) : +/*N*/ aName( r.aName ), +/*N*/ bIsDataLayout( r.bIsDataLayout ), +/*N*/ bDupFlag( r.bDupFlag ), +/*N*/ nOrientation( r.nOrientation ), +/*N*/ bSubTotalDefault( r.bSubTotalDefault ), +/*N*/ nSubTotalCount( r.nSubTotalCount ), +/*N*/ pSubTotalFuncs( NULL ), +/*N*/ nShowEmptyMode( r.nShowEmptyMode ), +/*N*/ nFunction( r.nFunction ), +/*N*/ nUsedHierarchy( r.nUsedHierarchy ) +/*N*/ { +/*N*/ if ( nSubTotalCount && r.pSubTotalFuncs ) +/*N*/ { +/*N*/ pSubTotalFuncs = new USHORT[nSubTotalCount]; +/*N*/ for (long nSub=0; nSub<nSubTotalCount; nSub++) +/*N*/ pSubTotalFuncs[nSub] = r.pSubTotalFuncs[nSub]; +/*N*/ } +/*N*/ +/*N*/ long nCount = r.aMemberList.Count(); +/*N*/ for (long i=0; i<nCount; i++) +/*N*/ { +/*N*/ ScDPSaveMember* pNew = new ScDPSaveMember( *(ScDPSaveMember*)r.aMemberList.GetObject(i) ); +/*N*/ aMemberList.Insert( pNew, LIST_APPEND ); +/*N*/ } +/*N*/ if (r.pLayoutName) +/*N*/ pLayoutName = new String( *(r.pLayoutName) ); +/*N*/ else +/*N*/ pLayoutName = NULL; +/*N*/ } +/*N*/ +/*N*/ ScDPSaveDimension::ScDPSaveDimension(SvStream& rStream) +/*N*/ { +/*N*/ long i; +/*N*/ +/*N*/ rStream.ReadByteString( aName, rStream.GetStreamCharSet() ); +/*N*/ rStream >> bIsDataLayout; +/*N*/ +/*N*/ rStream >> bDupFlag; +/*N*/ +/*N*/ rStream >> nOrientation; +/*N*/ rStream >> nFunction; // enum GeneralFunction +/*N*/ rStream >> nUsedHierarchy; +/*N*/ +/*N*/ rStream >> nShowEmptyMode; //! at level +/*N*/ +/*N*/ rStream >> bSubTotalDefault; //! at level +/*N*/ rStream >> nSubTotalCount; +/*N*/ if (nSubTotalCount) +/*N*/ { +/*N*/ pSubTotalFuncs = new USHORT[nSubTotalCount]; +/*N*/ for (i=0; i<nSubTotalCount; i++) +/*N*/ rStream >> pSubTotalFuncs[i]; +/*N*/ } +/*N*/ else +/*N*/ pSubTotalFuncs = NULL; +/*N*/ +/*N*/ lcl_SkipExtra( rStream ); // reads at least 1 USHORT +/*N*/ +/*N*/ long nNewCount; +/*N*/ rStream >> nNewCount; +/*N*/ for (i=0; i<nNewCount; i++) +/*N*/ { +/*N*/ ScDPSaveMember* pNew = new ScDPSaveMember( rStream ); +/*N*/ aMemberList.Insert( pNew, LIST_APPEND ); +/*N*/ } +/*N*/ pLayoutName = NULL; +/*N*/ } +/*N*/ +/*N*/ void ScDPSaveDimension::Store( SvStream& rStream ) const +/*N*/ { +/*N*/ long i; +/*N*/ +/*N*/ rStream.WriteByteString( aName, rStream.GetStreamCharSet() ); +/*N*/ rStream << bIsDataLayout; +/*N*/ +/*N*/ rStream << bDupFlag; +/*N*/ +/*N*/ rStream << nOrientation; +/*N*/ rStream << nFunction; // enum GeneralFunction +/*N*/ rStream << nUsedHierarchy; +/*N*/ +/*N*/ rStream << nShowEmptyMode; //! at level +/*N*/ +/*N*/ //! subtotals at level +/*N*/ rStream << bSubTotalDefault; +/*N*/ long nSubCnt = pSubTotalFuncs ? nSubTotalCount : 0; +/*N*/ rStream << nSubCnt; +/*N*/ for (i=0; i<nSubCnt; i++) +/*N*/ rStream << pSubTotalFuncs[i]; +/*N*/ +/*N*/ rStream << (USHORT) 0; // nExtra +/*N*/ +/*N*/ long nCount = aMemberList.Count(); +/*N*/ rStream << nCount; +/*N*/ for (i=0; i<nCount; i++) +/*N*/ { +/*N*/ const ScDPSaveMember* pMember = (const ScDPSaveMember*)aMemberList.GetObject(i); +/*N*/ pMember->Store( rStream ); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ ScDPSaveDimension::~ScDPSaveDimension() +/*N*/ { +/*N*/ long nCount = aMemberList.Count(); +/*N*/ for (long i=0; i<nCount; i++) +/*N*/ delete (ScDPSaveMember*)aMemberList.GetObject(i); +/*N*/ aMemberList.Clear(); +/*N*/ if (pLayoutName) +/*N*/ delete pLayoutName; +/*N*/ delete [] pSubTotalFuncs; +/*N*/ } +/*N*/ +/*N*/ BOOL ScDPSaveDimension::operator== ( const ScDPSaveDimension& r ) const +/*N*/ { +/*N*/ if ( aName != r.aName || +/*N*/ bIsDataLayout != r.bIsDataLayout || +/*N*/ bDupFlag != r.bDupFlag || +/*N*/ nOrientation != r.nOrientation || +/*N*/ nFunction != r.nFunction || +/*N*/ nUsedHierarchy != r.nUsedHierarchy || +/*N*/ nShowEmptyMode != r.nShowEmptyMode || +/*N*/ bSubTotalDefault != r.bSubTotalDefault || +/*N*/ nSubTotalCount != r.nSubTotalCount ) +/*N*/ return FALSE; +/*N*/ +/*N*/ if ( nSubTotalCount && ( !pSubTotalFuncs || !r.pSubTotalFuncs ) ) // should not happen +/*N*/ return FALSE; +/*N*/ +/*N*/ long i; +/*N*/ for (i=0; i<nSubTotalCount; i++) +/*N*/ if ( pSubTotalFuncs[i] != r.pSubTotalFuncs[i] ) +/*N*/ return FALSE; +/*N*/ +/*N*/ long nCount = aMemberList.Count(); +/*N*/ if ( nCount != r.aMemberList.Count() ) +/*N*/ return FALSE; +/*N*/ +/*N*/ for (i=0; i<nCount; i++) +/*N*/ if ( !( *(ScDPSaveMember*)aMemberList.GetObject(i) == +/*N*/ *(ScDPSaveMember*)r.aMemberList.GetObject(i) ) ) +/*N*/ return FALSE; +/*N*/ +/*N*/ return TRUE; +/*N*/ } +/*N*/ +/*N*/ +/*N*/ void ScDPSaveDimension::SetOrientation(USHORT nNew) +/*N*/ { +/*N*/ nOrientation = nNew; +/*N*/ } +/*N*/ +/*N*/ void ScDPSaveDimension::SetSubTotals(long nCount, const USHORT* pFuncs) +/*N*/ { +/*N*/ if (pSubTotalFuncs) +/*N*/ delete pSubTotalFuncs; +/*N*/ nSubTotalCount = nCount; +/*N*/ if ( nCount && pFuncs ) +/*N*/ { +/*N*/ pSubTotalFuncs = new USHORT[nCount]; +/*N*/ for (long i=0; i<nCount; i++) +/*N*/ pSubTotalFuncs[i] = pFuncs[i]; +/*N*/ } +/*N*/ else +/*N*/ pSubTotalFuncs = NULL; +/*N*/ +/*N*/ bSubTotalDefault = FALSE; +/*N*/ } +/*N*/ +/*N*/ void ScDPSaveDimension::SetShowEmpty(BOOL bSet) +/*N*/ { +/*N*/ nShowEmptyMode = bSet; +/*N*/ } +/*N*/ +/*N*/ void ScDPSaveDimension::SetFunction(USHORT nNew) +/*N*/ { +/*N*/ nFunction = nNew; +/*N*/ } +/*N*/ +/*N*/ void ScDPSaveDimension::SetUsedHierarchy(long nNew) +/*N*/ { +/*N*/ nUsedHierarchy = nNew; +/*N*/ } + +/*N*/ BOOL ScDPSaveDimension::HasLayoutName() const +/*N*/ { +/*N*/ return ( pLayoutName != NULL ); +/*N*/ } + +/*N*/ void ScDPSaveDimension::ResetLayoutName() +/*N*/ { +/*N*/ delete pLayoutName; +/*N*/ pLayoutName = NULL; +/*N*/ } + +/*N*/ void ScDPSaveDimension::SetLayoutName(const String* pName) +/*N*/ { +/*N*/ if (pName) +/*N*/ { +/*N*/ if (pLayoutName) +/*N*/ delete pLayoutName; +/*N*/ pLayoutName = new String( *pName ); +/*N*/ } +/*N*/ } + +/*N*/ const String& ScDPSaveDimension::GetLayoutName() const +/*N*/ { +/*N*/ if (pLayoutName) +/*N*/ return *pLayoutName; +/*N*/ return aName; +/*N*/ } + +/*N*/ void ScDPSaveDimension::WriteToSource( const uno::Reference<uno::XInterface>& xDim ) +/*N*/ { +/*N*/ uno::Reference<beans::XPropertySet> xDimProp( xDim, uno::UNO_QUERY ); +/*N*/ DBG_ASSERT( xDimProp.is(), "no properties at dimension" ); +/*N*/ if ( xDimProp.is() ) +/*N*/ { +/*N*/ // exceptions are caught at ScDPSaveData::WriteToSource +/*N*/ uno::Any aAny; +/*N*/ +/*N*/ sheet::DataPilotFieldOrientation eOrient = (sheet::DataPilotFieldOrientation)nOrientation; +/*N*/ aAny <<= eOrient; +/*N*/ xDimProp->setPropertyValue( ::rtl::OUString::createFromAscii(DP_PROP_ORIENTATION), aAny ); +/*N*/ +/*N*/ sheet::GeneralFunction eFunc = (sheet::GeneralFunction)nFunction; +/*N*/ aAny <<= eFunc; +/*N*/ xDimProp->setPropertyValue( ::rtl::OUString::createFromAscii(DP_PROP_FUNCTION), aAny ); +/*N*/ +/*N*/ if ( nUsedHierarchy >= 0 ) +/*N*/ { +/*N*/ aAny <<= (INT32)nUsedHierarchy; +/*N*/ xDimProp->setPropertyValue( ::rtl::OUString::createFromAscii(DP_PROP_USEDHIERARCHY), aAny ); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // Level loop outside of aMemberList loop +/*N*/ // because SubTotals have to be set independently of known members +/*N*/ +/*N*/ long nCount = aMemberList.Count(); +/*N*/ +/*N*/ long nHierCount = 0; +/*N*/ uno::Reference<container::XIndexAccess> xHiers; +/*N*/ uno::Reference<sheet::XHierarchiesSupplier> xHierSupp( xDim, uno::UNO_QUERY ); +/*N*/ if ( xHierSupp.is() ) +/*N*/ { +/*N*/ uno::Reference<container::XNameAccess> xHiersName = xHierSupp->getHierarchies(); +/*N*/ xHiers = new ScNameToIndexAccess( xHiersName ); +/*N*/ nHierCount = xHiers->getCount(); +/*N*/ } +/*N*/ +/*N*/ for (long nHier=0; nHier<nHierCount; nHier++) +/*N*/ { +/*N*/ uno::Reference<uno::XInterface> xHierarchy = ScUnoHelpFunctions::AnyToInterface( xHiers->getByIndex(nHier) ); +/*N*/ +/*N*/ long nLevCount = 0; +/*N*/ uno::Reference<container::XIndexAccess> xLevels; +/*N*/ uno::Reference<sheet::XLevelsSupplier> xLevSupp( xHierarchy, uno::UNO_QUERY ); +/*N*/ if ( xLevSupp.is() ) +/*N*/ { +/*N*/ uno::Reference<container::XNameAccess> xLevelsName = xLevSupp->getLevels(); +/*N*/ xLevels = new ScNameToIndexAccess( xLevelsName ); +/*N*/ nLevCount = xLevels->getCount(); +/*N*/ } +/*N*/ +/*N*/ for (long nLev=0; nLev<nLevCount; nLev++) +/*N*/ { +/*N*/ uno::Reference<uno::XInterface> xLevel = ScUnoHelpFunctions::AnyToInterface( xLevels->getByIndex(nLev) ); +/*N*/ uno::Reference<beans::XPropertySet> xLevProp( xLevel, uno::UNO_QUERY ); +/*N*/ DBG_ASSERT( xLevProp.is(), "no properties at level" ); +/*N*/ if ( xLevProp.is() ) +/*N*/ { +/*N*/ if ( !bSubTotalDefault ) +/*N*/ { +/*N*/ if ( !pSubTotalFuncs ) +/*N*/ nSubTotalCount = 0; +/*N*/ +/*N*/ uno::Sequence<sheet::GeneralFunction> aSeq(nSubTotalCount); +/*N*/ sheet::GeneralFunction* pArray = aSeq.getArray(); +/*N*/ for (long i=0; i<nSubTotalCount; i++) +/*N*/ pArray[i] = (sheet::GeneralFunction)pSubTotalFuncs[i]; +/*N*/ uno::Any aAny; +/*N*/ aAny <<= aSeq; +/*N*/ xLevProp->setPropertyValue( ::rtl::OUString::createFromAscii(DP_PROP_SUBTOTALS), aAny ); +/*N*/ } +/*N*/ if ( nShowEmptyMode != SC_DPSAVEMODE_DONTKNOW ) +/*N*/ lcl_SetBoolProperty( xLevProp, +/*N*/ ::rtl::OUString::createFromAscii(DP_PROP_SHOWEMPTY), (BOOL)nShowEmptyMode ); +/*N*/ +/*N*/ // exceptions are caught at ScDPSaveData::WriteToSource +/*N*/ } +/*N*/ +/*N*/ if ( nCount > 0 ) +/*N*/ { +/*N*/ uno::Reference<sheet::XMembersSupplier> xMembSupp( xLevel, uno::UNO_QUERY ); +/*N*/ if ( xMembSupp.is() ) +/*N*/ { +/*N*/ uno::Reference<container::XNameAccess> xMembers = xMembSupp->getMembers(); +/*N*/ if ( xMembers.is() ) +/*N*/ { +/*N*/ for (long i=0; i<nCount; i++) +/*N*/ { +/*N*/ ScDPSaveMember* pMember = (ScDPSaveMember*)aMemberList.GetObject(i); +/*N*/ ::rtl::OUString aName = pMember->GetName(); +/*N*/ if ( xMembers->hasByName( aName ) ) +/*N*/ { +/*N*/ uno::Reference<uno::XInterface> xMemberInt = ScUnoHelpFunctions::AnyToInterface( +/*N*/ xMembers->getByName( aName ) ); +/*N*/ pMember->WriteToSource( xMemberInt ); +/*N*/ } +/*N*/ // missing member is no error +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +// ----------------------------------------------------------------------- + +/*N*/ ScDPSaveData::ScDPSaveData() : +/*N*/ nColumnGrandMode( SC_DPSAVEMODE_DONTKNOW ), +/*N*/ nRowGrandMode( SC_DPSAVEMODE_DONTKNOW ), +/*N*/ nIgnoreEmptyMode( SC_DPSAVEMODE_DONTKNOW ), +/*N*/ nRepeatEmptyMode( SC_DPSAVEMODE_DONTKNOW ) +/*N*/ { +/*N*/ } + +/*N*/ ScDPSaveData::ScDPSaveData(const ScDPSaveData& r) : +/*N*/ nColumnGrandMode( r.nColumnGrandMode ), +/*N*/ nRowGrandMode( r.nRowGrandMode ), +/*N*/ nIgnoreEmptyMode( r.nIgnoreEmptyMode ), +/*N*/ nRepeatEmptyMode( r.nRepeatEmptyMode ) +/*N*/ { +/*N*/ long nCount = r.aDimList.Count(); +/*N*/ for (long i=0; i<nCount; i++) +/*N*/ { +/*N*/ ScDPSaveDimension* pNew = new ScDPSaveDimension( *(ScDPSaveDimension*)r.aDimList.GetObject(i) ); +/*N*/ aDimList.Insert( pNew, LIST_APPEND ); +/*N*/ } +/*N*/ } + +/*N*/ ScDPSaveData& ScDPSaveData::operator= ( const ScDPSaveData& r ) +/*N*/ { +/*N*/ if ( &r != this ) +/*N*/ { +/*N*/ nColumnGrandMode = r.nColumnGrandMode; +/*N*/ nRowGrandMode = r.nRowGrandMode; +/*N*/ nIgnoreEmptyMode = r.nIgnoreEmptyMode; +/*N*/ nRepeatEmptyMode = r.nRepeatEmptyMode; +/*N*/ +/*N*/ // remove old dimensions +/*N*/ +/*N*/ long nCount = aDimList.Count(); +/*N*/ long i; +/*N*/ for (i=0; i<nCount; i++) +/*N*/ delete (ScDPSaveDimension*)aDimList.GetObject(i); +/*N*/ aDimList.Clear(); +/*N*/ +/*N*/ // copy new dimensions +/*N*/ +/*N*/ nCount = r.aDimList.Count(); +/*N*/ for (i=0; i<nCount; i++) +/*N*/ { +/*N*/ ScDPSaveDimension* pNew = +/*N*/ new ScDPSaveDimension( *(ScDPSaveDimension*)r.aDimList.GetObject(i) ); +/*N*/ aDimList.Insert( pNew, LIST_APPEND ); +/*N*/ } +/*N*/ } +/*N*/ return *this; +/*N*/ } +/*N*/ +/*N*/ BOOL ScDPSaveData::operator== ( const ScDPSaveData& r ) const +/*N*/ { +/*N*/ if ( nColumnGrandMode != r.nColumnGrandMode || +/*N*/ nRowGrandMode != r.nRowGrandMode || +/*N*/ nIgnoreEmptyMode != r.nIgnoreEmptyMode || +/*N*/ nRepeatEmptyMode != r.nRepeatEmptyMode ) +/*N*/ return FALSE; +/*N*/ +/*N*/ long nCount = aDimList.Count(); +/*N*/ if ( nCount != r.aDimList.Count() ) +/*N*/ return FALSE; +/*N*/ +/*N*/ for (long i=0; i<nCount; i++) +/*N*/ if ( !( *(ScDPSaveDimension*)aDimList.GetObject(i) == +/*N*/ *(ScDPSaveDimension*)r.aDimList.GetObject(i) ) ) +/*N*/ return FALSE; +/*N*/ +/*N*/ return TRUE; +/*N*/ } + +/*N*/ ScDPSaveData::~ScDPSaveData() +/*N*/ { +/*N*/ long nCount = aDimList.Count(); +/*N*/ for (long i=0; i<nCount; i++) +/*N*/ delete (ScDPSaveDimension*)aDimList.GetObject(i); +/*N*/ aDimList.Clear(); +/*N*/ } + +/*N*/ ScDPSaveDimension* ScDPSaveData::GetDimensionByName(const String& rName) +/*N*/ { +/*N*/ long nCount = aDimList.Count(); +/*N*/ for (long i=0; i<nCount; i++) +/*N*/ { +/*N*/ ScDPSaveDimension* pDim = (ScDPSaveDimension*)aDimList.GetObject(i); +/*N*/ if ( pDim->GetName() == rName && !pDim->IsDataLayout() ) +/*N*/ return pDim; +/*N*/ } +/*N*/ ScDPSaveDimension* pNew = new ScDPSaveDimension( rName, FALSE ); +/*N*/ aDimList.Insert( pNew, LIST_APPEND ); +/*N*/ return pNew; +/*N*/ } + +/*N*/ ScDPSaveDimension* ScDPSaveData::GetExistingDimensionByName(const String& rName) +/*N*/ { +/*N*/ long nCount = aDimList.Count(); +/*N*/ for (long i=0; i<nCount; i++) +/*N*/ { +/*N*/ ScDPSaveDimension* pDim = (ScDPSaveDimension*)aDimList.GetObject(i); +/*N*/ if ( pDim->GetName() == rName && !pDim->IsDataLayout() ) +/*N*/ return pDim; +/*N*/ } +/*N*/ return NULL; // don't create new +/*N*/ } + +/*N*/ ScDPSaveDimension* ScDPSaveData::GetDataLayoutDimension() +/*N*/ { +/*N*/ long nCount = aDimList.Count(); +/*N*/ for (long i=0; i<nCount; i++) +/*N*/ { +/*N*/ ScDPSaveDimension* pDim = (ScDPSaveDimension*)aDimList.GetObject(i); +/*N*/ if ( pDim->IsDataLayout() ) +/*N*/ return pDim; +/*N*/ } +/*N*/ ScDPSaveDimension* pNew = new ScDPSaveDimension( String(), TRUE ); +/*N*/ aDimList.Insert( pNew, LIST_APPEND ); +/*N*/ return pNew; +/*N*/ } +/*N*/ +/*N*/ ScDPSaveDimension* ScDPSaveData::DuplicateDimension(const String& rName) +/*N*/ { +/*N*/ // always insert new +/*N*/ //! check if dimension is there? +/*N*/ +/*N*/ ScDPSaveDimension* pOld = GetDimensionByName( rName ); +/*N*/ ScDPSaveDimension* pNew = new ScDPSaveDimension( *pOld ); +/*N*/ pNew->SetDupFlag( TRUE ); +/*N*/ aDimList.Insert( pNew, LIST_APPEND ); +/*N*/ return pNew; +/*N*/ } +/*N*/ +/*N*/ void ScDPSaveData::SetColumnGrand(BOOL bSet) +/*N*/ { +/*N*/ nColumnGrandMode = bSet; +/*N*/ } +/*N*/ +/*N*/ void ScDPSaveData::SetRowGrand(BOOL bSet) +/*N*/ { +/*N*/ nRowGrandMode = bSet; +/*N*/ } +/*N*/ +/*N*/ void ScDPSaveData::SetIgnoreEmptyRows(BOOL bSet) +/*N*/ { +/*N*/ nIgnoreEmptyMode = bSet; +/*N*/ } +/*N*/ +/*N*/ void ScDPSaveData::SetRepeatIfEmpty(BOOL bSet) +/*N*/ { +/*N*/ nRepeatEmptyMode = bSet; +/*N*/ } +/*N*/ +/*N*/ void lcl_ResetOrient( const uno::Reference<sheet::XDimensionsSupplier>& xSource ) +/*N*/ { +/*N*/ sheet::DataPilotFieldOrientation eOrient = sheet::DataPilotFieldOrientation_HIDDEN; +/*N*/ +/*N*/ uno::Reference<container::XNameAccess> xDimsName = xSource->getDimensions(); +/*N*/ uno::Reference<container::XIndexAccess> xIntDims = new ScNameToIndexAccess( xDimsName ); +/*N*/ long nIntCount = xIntDims->getCount(); +/*N*/ for (long nIntDim=0; nIntDim<nIntCount; nIntDim++) +/*N*/ { +/*N*/ uno::Reference<uno::XInterface> xIntDim = ScUnoHelpFunctions::AnyToInterface( xIntDims->getByIndex(nIntDim) ); +/*N*/ uno::Reference<beans::XPropertySet> xDimProp( xIntDim, uno::UNO_QUERY ); +/*N*/ if (xDimProp.is()) +/*N*/ { +/*N*/ uno::Any aAny; +/*N*/ aAny <<= eOrient; +/*N*/ xDimProp->setPropertyValue( ::rtl::OUString::createFromAscii(DP_PROP_ORIENTATION), aAny ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ void ScDPSaveData::WriteToSource( const uno::Reference<sheet::XDimensionsSupplier>& xSource ) +/*N*/ { +/*N*/ if (!xSource.is()) +/*N*/ return; +/*N*/ +/*N*/ // source options must be first! +/*N*/ +/*N*/ uno::Reference<beans::XPropertySet> xSourceProp( xSource, uno::UNO_QUERY ); +/*N*/ DBG_ASSERT( xSourceProp.is(), "no properties at source" ); +/*N*/ if ( xSourceProp.is() ) +/*N*/ { +/*N*/ // source options are not available for external sources +/*N*/ //! use XPropertySetInfo to test for availability? +/*N*/ +/*N*/ try +/*N*/ { +/*N*/ if ( nIgnoreEmptyMode != SC_DPSAVEMODE_DONTKNOW ) +/*N*/ lcl_SetBoolProperty( xSourceProp, +/*N*/ ::rtl::OUString::createFromAscii(DP_PROP_IGNOREEMPTY), (BOOL)nIgnoreEmptyMode ); +/*N*/ if ( nRepeatEmptyMode != SC_DPSAVEMODE_DONTKNOW ) +/*N*/ lcl_SetBoolProperty( xSourceProp, +/*N*/ ::rtl::OUString::createFromAscii(DP_PROP_REPEATIFEMPTY), (BOOL)nRepeatEmptyMode ); +/*N*/ } +/*N*/ catch(uno::Exception&) +/*N*/ { +/*N*/ // no error +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // exceptions in the other calls are errors +/*N*/ try +/*N*/ { +/*N*/ // reset all orientations +/*N*/ //! "forgetSettings" or similar at source ????? +/*N*/ //! reset all duplicated dimensions, or reuse them below !!! +/*N*/ +/*N*/ lcl_ResetOrient( xSource ); +/*N*/ +/*N*/ long nCount = aDimList.Count(); +/*N*/ for (long i=0; i<nCount; i++) +/*N*/ { +/*N*/ ScDPSaveDimension* pDim = (ScDPSaveDimension*)aDimList.GetObject(i); +/*N*/ ::rtl::OUString aName = pDim->GetName(); +/*N*/ BOOL bData = pDim->IsDataLayout(); +/*N*/ +/*N*/ //! getByName for ScDPSource, including DataLayoutDimension !!!!!!!! +/*N*/ +/*N*/ uno::Reference<container::XNameAccess> xDimsName = xSource->getDimensions(); +/*N*/ uno::Reference<container::XIndexAccess> xIntDims = new ScNameToIndexAccess( xDimsName ); +/*N*/ long nIntCount = xIntDims->getCount(); +/*N*/ BOOL bFound = FALSE; +/*N*/ for (long nIntDim=0; nIntDim<nIntCount && !bFound; nIntDim++) +/*N*/ { +/*N*/ uno::Reference<uno::XInterface> xIntDim = ScUnoHelpFunctions::AnyToInterface( xIntDims->getByIndex(nIntDim) ); +/*N*/ if ( bData ) +/*N*/ { +/*N*/ uno::Reference<beans::XPropertySet> xDimProp( xIntDim, uno::UNO_QUERY ); +/*N*/ if ( xDimProp.is() ) +/*N*/ { +/*N*/ bFound = ScUnoHelpFunctions::GetBoolProperty( xDimProp, +/*N*/ ::rtl::OUString::createFromAscii(DP_PROP_ISDATALAYOUT) ); +/*N*/ //! error checking -- is "IsDataLayoutDimension" property required?? +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ uno::Reference<container::XNamed> xDimName( xIntDim, uno::UNO_QUERY ); +/*N*/ if ( xDimName.is() && xDimName->getName() == aName ) +/*N*/ bFound = TRUE; +/*N*/ } +/*N*/ +/*N*/ if ( bFound ) +/*N*/ { +/*N*/ if ( pDim->GetDupFlag() ) +/*N*/ { +/*N*/ String aNewName = pDim->GetName(); +/*N*/ +/*N*/ // different name for each duplication of a (real) dimension... +/*N*/ for (long j=0; j<=i; j++) //! Test !!!!!! +/*N*/ aNewName += '*'; //! modify name at creation of SaveDimension +/*N*/ +/*N*/ uno::Reference<util::XCloneable> xCloneable( xIntDim, uno::UNO_QUERY ); +/*N*/ DBG_ASSERT( xCloneable.is(), "cannot clone dimension" ); +/*N*/ if (xCloneable.is()) +/*N*/ { +/*N*/ uno::Reference<util::XCloneable> xNew = xCloneable->createClone(); +/*N*/ uno::Reference<container::XNamed> xNewName( xNew, uno::UNO_QUERY ); +/*N*/ if (xNewName.is()) +/*N*/ { +/*N*/ xNewName->setName( aNewName ); +/*N*/ pDim->WriteToSource( xNew ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ pDim->WriteToSource( xIntDim ); +/*N*/ } +/*N*/ } +/*N*/ DBG_ASSERT(bFound, "WriteToSource: Dimension not found"); +/*N*/ } +/*N*/ +/*N*/ if ( xSourceProp.is() ) +/*N*/ { +/*N*/ if ( nColumnGrandMode != SC_DPSAVEMODE_DONTKNOW ) +/*N*/ lcl_SetBoolProperty( xSourceProp, +/*N*/ ::rtl::OUString::createFromAscii(DP_PROP_COLUMNGRAND), (BOOL)nColumnGrandMode ); +/*N*/ if ( nRowGrandMode != SC_DPSAVEMODE_DONTKNOW ) +/*N*/ lcl_SetBoolProperty( xSourceProp, +/*N*/ ::rtl::OUString::createFromAscii(DP_PROP_ROWGRAND), (BOOL)nRowGrandMode ); +/*N*/ } +/*N*/ } +/*N*/ catch(uno::Exception&) +/*N*/ { +/*N*/ DBG_ERROR("exception in WriteToSource"); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ void ScDPSaveData::Store( SvStream& rStream ) const +/*N*/ { +/*N*/ //! multi-header for individual entries +/*N*/ +/*N*/ long nCount = aDimList.Count(); +/*N*/ rStream << nCount; +/*N*/ for (long i=0; i<nCount; i++) +/*N*/ { +/*N*/ const ScDPSaveDimension* pDim = (const ScDPSaveDimension*)aDimList.GetObject(i); +/*N*/ pDim->Store( rStream ); +/*N*/ } +/*N*/ +/*N*/ rStream << nColumnGrandMode; +/*N*/ rStream << nRowGrandMode; +/*N*/ rStream << nIgnoreEmptyMode; +/*N*/ rStream << nRepeatEmptyMode; +/*N*/ +/*N*/ rStream << (USHORT) 0; // nExtra +/*N*/ } +/*N*/ +/*N*/ void ScDPSaveData::Load( SvStream& rStream ) +/*N*/ { +/*N*/ //! multi-header for individual entries +/*N*/ +/*N*/ DBG_ASSERT( aDimList.Count()==0, "ScDPSaveData::Load not empty" ); +/*N*/ +/*N*/ long nNewCount; +/*N*/ rStream >> nNewCount; +/*N*/ for (long i=0; i<nNewCount; i++) +/*N*/ { +/*N*/ ScDPSaveDimension* pNew = new ScDPSaveDimension( rStream ); +/*N*/ aDimList.Insert( pNew, LIST_APPEND ); +/*N*/ } +/*N*/ +/*N*/ rStream >> nColumnGrandMode; +/*N*/ rStream >> nRowGrandMode; +/*N*/ rStream >> nIgnoreEmptyMode; +/*N*/ rStream >> nRepeatEmptyMode; +/*N*/ +/*N*/ lcl_SkipExtra( rStream ); // reads at least 1 USHORT +/*N*/ } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_dpshttab.cxx b/binfilter/bf_sc/source/core/data/sc_dpshttab.cxx new file mode 100644 index 000000000000..52864e35cdf1 --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_dpshttab.cxx @@ -0,0 +1,230 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE -------------------------------------------------------------- + +#include <tools/debug.hxx> +#include <bf_svtools/zforlist.hxx> + +#include "dpshttab.hxx" +#include "document.hxx" +#include "collect.hxx" +#include "globstr.hrc" +namespace binfilter { + +// ----------------------------------------------------------------------- + +/*N*/ class ScSheetDPData_Impl +/*N*/ { +/*N*/ public: +/*N*/ ScDocument* pDoc; +/*N*/ ScRange aRange; +/*N*/ ScQueryParam aQuery; +/*N*/ long nColCount; +/*N*/ BOOL bIgnoreEmptyRows; +/*N*/ BOOL bRepeatIfEmpty; +/*N*/ TypedStrCollection** ppStrings; +/*N*/ BOOL* pDateDim; +/*N*/ USHORT nNextRow; // for iterator, within range +/*N*/ +/*N*/ ScSheetDPData_Impl() {} +/*N*/ }; + +// ----------------------------------------------------------------------- + +/*M*/ ScSheetDPData::ScSheetDPData( ScDocument* pD, const ScSheetSourceDesc& rDesc ) +/*M*/ : pSpecial(NULL) +/*M*/ { +/*M*/ long nCount = rDesc.aSourceRange.aEnd.Col() - rDesc.aSourceRange.aStart.Col() + 1; +/*M*/ pImpl = new ScSheetDPData_Impl; +/*M*/ pImpl->pDoc = pD; +/*M*/ pImpl->aRange = rDesc.aSourceRange; +/*M*/ pImpl->aQuery = rDesc.aQueryParam; +/*M*/ pImpl->bIgnoreEmptyRows = FALSE; +/*M*/ pImpl->bRepeatIfEmpty = FALSE; +/*M*/ pImpl->nColCount = nCount; +/*M*/ pImpl->ppStrings = new TypedStrCollection*[nCount]; +/*M*/ pImpl->pDateDim = NULL; +/*M*/ for (long i=0; i<nCount; i++) +/*M*/ pImpl->ppStrings[i] = NULL; +/*M*/ +/*M*/ pImpl->nNextRow = pImpl->aRange.aStart.Row() + 1; +/*M*/ +/*M*/ long nEntryCount(pImpl->aQuery.GetEntryCount()); +/*M*/ pSpecial = new BOOL[nEntryCount]; +/*M*/ for (long j = 0; j < nEntryCount; ++j ) +/*M*/ { +/*M*/ ScQueryEntry& rEntry = pImpl->aQuery.GetEntry(j); +/*M*/ if (rEntry.bDoQuery) +/*M*/ { +/*M*/ pSpecial[j] = false; +/*M*/ if (!rEntry.bQueryByString) +/*M*/ { +/*M*/ if (*rEntry.pStr == EMPTY_STRING && +/*M*/ ((rEntry.nVal == SC_EMPTYFIELDS) || (rEntry.nVal == SC_NONEMPTYFIELDS))) +/*M*/ pSpecial[j] = true; +/*M*/ } +/*M*/ else +/*M*/ { +/*M*/ sal_uInt32 nIndex = 0; +/*M*/ rEntry.bQueryByString = +/*M*/ !(pD->GetFormatTable()-> +/*M*/ IsNumberFormat(*rEntry.pStr, nIndex, rEntry.nVal)); +/*M*/ } +/*M*/ } +/*M*/ } +/*M*/ } + +/*N*/ ScSheetDPData::~ScSheetDPData() +/*N*/ { +/*N*/ for (long i=0; i<pImpl->nColCount; i++) +/*N*/ delete pImpl->ppStrings[i]; +/*N*/ delete[] pImpl->ppStrings; +/*N*/ delete[] pImpl->pDateDim; +/*N*/ delete pImpl; +/*M*/ delete[] pSpecial; +/*N*/ } + +/*N*/ void ScSheetDPData::DisposeData() +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); //STRIP001 +/*N*/ } + +/*N*/ long ScSheetDPData::GetColumnCount() +/*N*/ { +/*N*/ return pImpl->nColCount; +/*N*/ } + + +/*N*/ const TypedStrCollection& ScSheetDPData::GetColumnEntries(long nColumn) +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); return NULL;//STRIP001 +/*N*/ } + +/*N*/ String ScSheetDPData::getDimensionName(long nColumn) +/*N*/ { +/*N*/ if (getIsDataLayoutDimension(nColumn)) +/*N*/ { +/*N*/ //! different internal and display names? +/*N*/ //return "Data"; +/*N*/ return ScGlobal::GetRscString(STR_PIVOT_DATA); +/*N*/ } +/*N*/ else if ( nColumn >= pImpl->nColCount ) +/*N*/ { +/*?*/ DBG_ERROR("getDimensionName: invalid dimension"); +/*?*/ return String(); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ USHORT nDocCol = (USHORT)(pImpl->aRange.aStart.Col() + nColumn); +/*N*/ USHORT nDocRow = pImpl->aRange.aStart.Row(); +/*N*/ USHORT nDocTab = pImpl->aRange.aStart.Tab(); +/*N*/ String aDocStr; +/*N*/ pImpl->pDoc->GetString( nDocCol, nDocRow, nDocTab, aDocStr ); +/*N*/ return aDocStr; +/*N*/ } +/*N*/ } + +/*N*/ BOOL lcl_HasDateFormat( ScDocument* pDoc, const ScRange& rRange ) +/*N*/ { +/*N*/ //! iterate formats in range? +/*N*/ +/*N*/ ScAddress aPos = rRange.aStart; +/*N*/ aPos.SetRow( aPos.Row() + 1 ); // below title +/*N*/ ULONG nFormat = pDoc->GetNumberFormat( aPos ); +/*N*/ SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); +/*N*/ return ( pFormatter->GetType(nFormat) & NUMBERFORMAT_DATE ) != 0; +/*N*/ } + +/*N*/ BOOL ScSheetDPData::IsDateDimension(long nDim) +/*N*/ { +/*N*/ if (getIsDataLayoutDimension(nDim)) +/*N*/ { +/*N*/ return FALSE; +/*N*/ } +/*N*/ else if ( nDim >= pImpl->nColCount ) +/*N*/ { +/*?*/ DBG_ERROR("IsDateDimension: invalid dimension"); +/*?*/ return FALSE; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ if (!pImpl->pDateDim) +/*N*/ { +/*N*/ pImpl->pDateDim = new BOOL[pImpl->nColCount]; +/*N*/ ScRange aTestRange = pImpl->aRange; +/*N*/ for (long i=0; i<pImpl->nColCount; i++) +/*N*/ { +/*N*/ USHORT nCol = (USHORT)( pImpl->aRange.aStart.Col() + i ); +/*N*/ aTestRange.aStart.SetCol(nCol); +/*N*/ aTestRange.aEnd.SetCol(nCol); +/*N*/ pImpl->pDateDim[i] = lcl_HasDateFormat( pImpl->pDoc, aTestRange ); +/*N*/ } +/*N*/ } +/*N*/ return pImpl->pDateDim[nDim]; +/*N*/ } +/*N*/ } + +/*N*/ UINT32 ScSheetDPData::GetNumberFormat(long nDim) +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); return 0; //STRIP001 +/*N*/ } + +/*N*/ BOOL ScSheetDPData::getIsDataLayoutDimension(long nColumn) +/*N*/ { +/*N*/ return ( nColumn == pImpl->nColCount ); +/*N*/ } + +/*N*/ void ScSheetDPData::SetEmptyFlags( BOOL bIgnoreEmptyRows, BOOL bRepeatIfEmpty ) +/*N*/ { +/*N*/ pImpl->bIgnoreEmptyRows = bIgnoreEmptyRows; +/*N*/ pImpl->bRepeatIfEmpty = bRepeatIfEmpty; +/*N*/ } + +/*N*/ void ScSheetDPData::ResetIterator() +/*N*/ { +/*N*/ pImpl->nNextRow = pImpl->aRange.aStart.Row() + 1; +/*N*/ } + + +/*N*/ BOOL ScSheetDPData::GetNextRow( const ScDPTableIteratorParam& rParam ) +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); return FALSE; //STRIP001 +/*N*/ } + +// ----------------------------------------------------------------------- + + + + + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_dptabdat.cxx b/binfilter/bf_sc/source/core/data/sc_dptabdat.cxx new file mode 100644 index 000000000000..97f599589dc2 --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_dptabdat.cxx @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + + +#include "dptabdat.hxx" +namespace binfilter { + +// ----------------------------------------------------------------------- + + +// ----------------------------------------------------------------------- + + +// ----------------------------------------------------------------------- + +/*N*/ ScDPTableData::ScDPTableData() +/*N*/ { +/*N*/ nLastDateVal = nLastHier = nLastLevel = nLastRet = -1; // invalid +/*N*/ +/*N*/ //! reset before new calculation (in case the base date is changed) +/*N*/ } + +/*N*/ ScDPTableData::~ScDPTableData() +/*N*/ { +/*N*/ } + + + +// ----------------------------------------------------------------------- + + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_dptabsrc.cxx b/binfilter/bf_sc/source/core/data/sc_dptabsrc.cxx new file mode 100644 index 000000000000..20b0178bb76f --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_dptabsrc.cxx @@ -0,0 +1,1151 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#include <tools/debug.hxx> +#include <rtl/math.hxx> +#include <bf_svtools/itemprop.hxx> +#include <vcl/svapp.hxx> + +#include "dptabsrc.hxx" +#include "dptabdat.hxx" +#include "global.hxx" +#include "collect.hxx" +#include "datauno.hxx" // ScDataUnoConversion +#include "miscuno.hxx" +#include "unonames.hxx" +#include "dptabres.hxx" + +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp> + +#include <unotools/calendarwrapper.hxx> +#include <com/sun/star/i18n/CalendarDisplayIndex.hpp> +namespace binfilter { + +using namespace ::com::sun::star; + +// ----------------------------------------------------------------------- + +#define SC_MINCOUNT_LIMIT 1000000 + +// ----------------------------------------------------------------------- + +/*N*/ SC_SIMPLE_SERVICE_INFO( ScDPSource, "ScDPSource", "com.sun.star.sheet.DataPilotSource" ) +/*N*/ SC_SIMPLE_SERVICE_INFO( ScDPDimensions, "ScDPDimensions", "com.sun.star.sheet.DataPilotSourceDimensions" ) +/*N*/ SC_SIMPLE_SERVICE_INFO( ScDPDimension, "ScDPDimension", "com.sun.star.sheet.DataPilotSourceDimension" ) +/*N*/ SC_SIMPLE_SERVICE_INFO( ScDPHierarchies, "ScDPHierarchies", "com.sun.star.sheet.DataPilotSourceHierarcies" ) +/*N*/ SC_SIMPLE_SERVICE_INFO( ScDPHierarchy, "ScDPHierarchy", "com.sun.star.sheet.DataPilotSourceHierarcy" ) +/*N*/ SC_SIMPLE_SERVICE_INFO( ScDPLevels, "ScDPLevels", "com.sun.star.sheet.DataPilotSourceLevels" ) +/*N*/ SC_SIMPLE_SERVICE_INFO( ScDPLevel, "ScDPLevel", "com.sun.star.sheet.DataPilotSourceLevel" ) + +// ----------------------------------------------------------------------- + +// property maps for PropertySetInfo +// DataDescription / NumberFormat are internal + +// ----------------------------------------------------------------------- + +//! move to a header? +/*N*/ BOOL lcl_GetBoolFromAny( const uno::Any& aAny ) +/*N*/ { +/*N*/ if ( aAny.getValueTypeClass() == uno::TypeClass_BOOLEAN ) +/*N*/ return *(sal_Bool*)aAny.getValue(); +/*N*/ return FALSE; +/*N*/ } + +/*N*/ void lcl_SetBoolInAny( uno::Any& rAny, BOOL bValue ) +/*N*/ { +/*N*/ rAny.setValue( &bValue, getBooleanCppuType() ); +/*N*/ } + +// ----------------------------------------------------------------------- + +/*N*/ ScDPSource::ScDPSource( ScDPTableData* pD ) : +/*N*/ pData( pD ), +/*N*/ pDimensions( NULL ), +/*N*/ nColDimCount( 0 ), +/*N*/ nRowDimCount( 0 ), +/*N*/ nDataDimCount( 0 ), +/*N*/ nPageDimCount( 0 ), +/*N*/ nDupCount( 0 ), +/*N*/ bResultOverflow( FALSE ), +/*N*/ pResData( NULL ), +/*N*/ pColResRoot( NULL ), +/*N*/ pRowResRoot( NULL ), +/*N*/ pColResults( NULL ), +/*N*/ pRowResults( NULL ), +/*N*/ bColumnGrand( TRUE ), // default is true +/*N*/ bRowGrand( TRUE ), +/*N*/ bIgnoreEmptyRows( FALSE ), +/*N*/ bRepeatIfEmpty( FALSE ) +/*N*/ { +/*N*/ pData->SetEmptyFlags( bIgnoreEmptyRows, bRepeatIfEmpty ); +/*N*/ } + +/*N*/ ScDPSource::~ScDPSource() +/*N*/ { +/*N*/ delete pData; // ScDPTableData is not ref-counted +/*N*/ +/*N*/ if (pDimensions) +/*N*/ pDimensions->release(); // ref-counted +/*N*/ +/*N*/ //! free lists +/*N*/ +/*N*/ delete[] pColResults; +/*N*/ delete[] pRowResults; +/*N*/ +/*N*/ delete pColResRoot; +/*N*/ delete pRowResRoot; +/*N*/ delete pResData; +/*N*/ } + +/*N*/ USHORT ScDPSource::GetOrientation(long nColumn) +/*N*/ { +/*N*/ long i; +/*N*/ for (i=0; i<nColDimCount; i++) +/*N*/ if (nColDims[i] == nColumn) +/*N*/ return sheet::DataPilotFieldOrientation_COLUMN; +/*N*/ for (i=0; i<nRowDimCount; i++) +/*N*/ if (nRowDims[i] == nColumn) +/*N*/ return sheet::DataPilotFieldOrientation_ROW; +/*N*/ for (i=0; i<nDataDimCount; i++) +/*N*/ if (nDataDims[i] == nColumn) +/*N*/ return sheet::DataPilotFieldOrientation_DATA; +/*N*/ for (i=0; i<nPageDimCount; i++) +/*?*/ if (nPageDims[i] == nColumn) +/*?*/ return sheet::DataPilotFieldOrientation_PAGE; +/*N*/ return sheet::DataPilotFieldOrientation_HIDDEN; +/*N*/ } + + + +/*N*/ long ScDPSource::GetPosition(long nColumn) +/*N*/ { +/*N*/ long i; +/*N*/ for (i=0; i<nColDimCount; i++) +/*N*/ if (nColDims[i] == nColumn) +/*N*/ return i; +/*N*/ for (i=0; i<nRowDimCount; i++) +/*N*/ if (nRowDims[i] == nColumn) +/*N*/ return i; +/*N*/ for (i=0; i<nDataDimCount; i++) +/*N*/ if (nDataDims[i] == nColumn) +/*N*/ return i; +/*N*/ for (i=0; i<nPageDimCount; i++) +/*?*/ if (nPageDims[i] == nColumn) +/*?*/ return i; +/*N*/ return 0; +/*N*/ } + +/*N*/ BOOL lcl_TestSubTotal( BOOL& rAllowed, long nColumn, long* pArray, long nCount, ScDPSource* pSource ) +/*N*/ { +/*N*/ for (long i=0; i<nCount; i++) +/*N*/ if (pArray[i] == nColumn) +/*N*/ { +/*N*/ // no subtotals for data layout dim, no matter where +/*N*/ if ( pSource->IsDataLayoutDimension(nColumn) ) +/*N*/ rAllowed = FALSE; +/*N*/ else +/*N*/ { +/*N*/ // no subtotals if no other dim but data layout follows +/*N*/ long nNextIndex = i+1; +/*N*/ if ( nNextIndex < nCount && pSource->IsDataLayoutDimension(pArray[nNextIndex]) ) +/*N*/ ++nNextIndex; +/*N*/ if ( nNextIndex >= nCount ) +/*N*/ rAllowed = FALSE; +/*N*/ } +/*N*/ +/*N*/ return TRUE; // found +/*N*/ } +/*N*/ return FALSE; +/*N*/ } + +/*N*/ BOOL ScDPSource::SubTotalAllowed(long nColumn) +/*N*/ { +/*N*/ //! cache this at ScDPResultData +/*N*/ BOOL bAllowed = TRUE; +/*N*/ if ( lcl_TestSubTotal( bAllowed, nColumn, nColDims, nColDimCount, this ) ) +/*N*/ return bAllowed; +/*N*/ if ( lcl_TestSubTotal( bAllowed, nColumn, nRowDims, nRowDimCount, this ) ) +/*N*/ return bAllowed; +/*N*/ return bAllowed; +/*N*/ } + +/*N*/ void lcl_RemoveDim( long nRemove, long* pDims, long& rCount ) +/*N*/ { +/*N*/ for (long i=0; i<rCount; i++) +/*N*/ if ( pDims[i] == nRemove ) +/*N*/ { +/*?*/ for (long j=i; j+1<rCount; j++) +/*?*/ pDims[j] = pDims[j+1]; +/*?*/ --rCount; +/*?*/ return; +/*N*/ } +/*N*/ } + +/*N*/ void ScDPSource::SetOrientation(long nColumn, USHORT nNew) +/*N*/ { +/*N*/ //! change to no-op if new orientation is equal to old? +/*N*/ +/*N*/ // remove from old list +/*N*/ lcl_RemoveDim( nColumn, nColDims, nColDimCount ); +/*N*/ lcl_RemoveDim( nColumn, nRowDims, nRowDimCount ); +/*N*/ lcl_RemoveDim( nColumn, nDataDims, nDataDimCount ); +/*N*/ lcl_RemoveDim( nColumn, nPageDims, nPageDimCount ); +/*N*/ +/*N*/ // add to new list +/*N*/ switch (nNew) +/*N*/ { +/*N*/ case sheet::DataPilotFieldOrientation_COLUMN: +/*N*/ nColDims[nColDimCount++] = nColumn; +/*N*/ break; +/*N*/ case sheet::DataPilotFieldOrientation_ROW: +/*N*/ nRowDims[nRowDimCount++] = nColumn; +/*N*/ break; +/*N*/ case sheet::DataPilotFieldOrientation_DATA: +/*N*/ nDataDims[nDataDimCount++] = nColumn; +/*N*/ break; +/*N*/ case sheet::DataPilotFieldOrientation_PAGE: +/*?*/ nPageDims[nPageDimCount++] = nColumn; +/*N*/ break; +/*N*/ } +/*N*/ } + +/*N*/ BOOL ScDPSource::IsDataLayoutDimension(long nDim) +/*N*/ { +/*N*/ return nDim == pData->GetColumnCount(); +/*N*/ } + + +/*N*/ BOOL ScDPSource::IsDateDimension(long nDim) +/*N*/ { +/*N*/ return pData->IsDateDimension(nDim); +/*N*/ } + +/*N*/ ScDPDimensions* ScDPSource::GetDimensionsObject() +/*N*/ { +/*N*/ if (!pDimensions) +/*N*/ { +/*N*/ pDimensions = new ScDPDimensions(this); +/*N*/ pDimensions->acquire(); // ref-counted +/*N*/ } +/*N*/ return pDimensions; +/*N*/ } + +/*N*/ uno::Reference<container::XNameAccess> SAL_CALL ScDPSource::getDimensions() throw(uno::RuntimeException) +/*N*/ { +/*N*/ return GetDimensionsObject(); +/*N*/ } + + + +/*N*/ long ScDPSource::GetSourceDim(long nDim) +/*N*/ { +/*N*/ // original source dimension or data layout dimension? +/*N*/ if ( nDim <= pData->GetColumnCount() ) +/*N*/ return nDim; +/*N*/ +/*?*/ if ( nDim < pDimensions->getCount() ) +/*?*/ { +/*?*/ ScDPDimension* pDimObj = pDimensions->getByIndex( nDim ); +/*?*/ if ( pDimObj ) +/*?*/ { +/*?*/ long nSource = pDimObj->GetSourceDim(); +/*?*/ if ( nSource >= 0 ) +/*?*/ return nSource; +/*?*/ } +/*?*/ } +/*?*/ +/*?*/ DBG_ERROR("GetSourceDim: wrong dim"); +/*?*/ return nDim; +/*N*/ } + +/*?*/ uno::Sequence< uno::Sequence<sheet::DataResult> > SAL_CALL ScDPSource::getResults() +/*?*/ throw(uno::RuntimeException) +/*?*/ {DBG_BF_ASSERT(0, "STRIP"); return uno::Sequence< uno::Sequence<sheet::DataResult> >(0); //STRIP001 +/*?*/ } + +/*?*/ void SAL_CALL ScDPSource::refresh() throw(uno::RuntimeException) +/*?*/ {DBG_BF_ASSERT(0, "STRIP"); //STRIP001 +/*?*/ } + +/*?*/ void SAL_CALL ScDPSource::addRefreshListener( const uno::Reference<util::XRefreshListener >& l ) +/*?*/ throw(uno::RuntimeException) +/*?*/ { +/*?*/ DBG_ERROR("not implemented"); //! exception? +/*?*/ } + +/*?*/ void SAL_CALL ScDPSource::removeRefreshListener( const uno::Reference<util::XRefreshListener >& l ) +/*?*/ throw(uno::RuntimeException) +/*?*/ { +/*?*/ DBG_ERROR("not implemented"); //! exception? +/*?*/ } + + +/*N*/ BOOL ScDPSource::getColumnGrand() const +/*N*/ { +/*N*/ return bColumnGrand; +/*N*/ } + +/*N*/ void ScDPSource::setColumnGrand(BOOL bSet) +/*N*/ { +/*N*/ bColumnGrand = bSet; +/*N*/ } + +/*N*/ BOOL ScDPSource::getRowGrand() const +/*N*/ { +/*N*/ return bRowGrand; +/*N*/ } + +/*N*/ void ScDPSource::setRowGrand(BOOL bSet) +/*N*/ { +/*N*/ bRowGrand = bSet; +/*N*/ } + +/*N*/ BOOL ScDPSource::getIgnoreEmptyRows() const +/*N*/ { +/*N*/ return bIgnoreEmptyRows; +/*N*/ } + +/*N*/ void ScDPSource::setIgnoreEmptyRows(BOOL bSet) +/*N*/ { +/*N*/ bIgnoreEmptyRows = bSet; +/*N*/ pData->SetEmptyFlags( bIgnoreEmptyRows, bRepeatIfEmpty ); +/*N*/ } + +/*N*/ BOOL ScDPSource::getRepeatIfEmpty() const +/*N*/ { +/*N*/ return bRepeatIfEmpty; +/*N*/ } + +/*N*/ void ScDPSource::setRepeatIfEmpty(BOOL bSet) +/*N*/ { +/*N*/ bRepeatIfEmpty = bSet; +/*N*/ pData->SetEmptyFlags( bIgnoreEmptyRows, bRepeatIfEmpty ); +/*N*/ } + + + + + + + + +// XPropertySet + +/*?*/ uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDPSource::getPropertySetInfo() +/*?*/ throw(uno::RuntimeException) +/*?*/ {DBG_BF_ASSERT(0, "STRIP"); return uno::Reference<beans::XPropertySetInfo>(0); //STRIP001 +/*?*/ } + +/*N*/ void SAL_CALL ScDPSource::setPropertyValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue ) +/*N*/ throw(beans::UnknownPropertyException, beans::PropertyVetoException, +/*N*/ lang::IllegalArgumentException, lang::WrappedTargetException, +/*N*/ uno::RuntimeException) +/*N*/ { +/*N*/ String aNameStr = aPropertyName; +/*N*/ if ( aNameStr.EqualsAscii( SC_UNO_COLGRAND ) ) +/*N*/ setColumnGrand( lcl_GetBoolFromAny( aValue ) ); +/*N*/ else if ( aNameStr.EqualsAscii( SC_UNO_ROWGRAND ) ) +/*N*/ setRowGrand( lcl_GetBoolFromAny( aValue ) ); +/*N*/ else if ( aNameStr.EqualsAscii( SC_UNO_IGNOREEM ) ) +/*N*/ setIgnoreEmptyRows( lcl_GetBoolFromAny( aValue ) ); +/*N*/ else if ( aNameStr.EqualsAscii( SC_UNO_REPEATIF ) ) +/*N*/ setRepeatIfEmpty( lcl_GetBoolFromAny( aValue ) ); +/*N*/ else +/*N*/ { +/*N*/ DBG_ERROR("unknown property"); +/*N*/ //! THROW( UnknownPropertyException() ); +/*N*/ } +/*N*/ } + +/*N*/ uno::Any SAL_CALL ScDPSource::getPropertyValue( const ::rtl::OUString& aPropertyName ) +/*N*/ throw(beans::UnknownPropertyException, lang::WrappedTargetException, +/*N*/ uno::RuntimeException) +/*N*/ { +/*N*/ uno::Any aRet; +/*N*/ String aNameStr = aPropertyName; +/*N*/ if ( aNameStr.EqualsAscii( SC_UNO_COLGRAND ) ) +/*N*/ lcl_SetBoolInAny( aRet, getColumnGrand() ); +/*N*/ else if ( aNameStr.EqualsAscii( SC_UNO_ROWGRAND ) ) +/*N*/ lcl_SetBoolInAny( aRet, getRowGrand() ); +/*N*/ else if ( aNameStr.EqualsAscii( SC_UNO_IGNOREEM ) ) +/*N*/ lcl_SetBoolInAny( aRet, getIgnoreEmptyRows() ); +/*N*/ else if ( aNameStr.EqualsAscii( SC_UNO_REPEATIF ) ) +/*N*/ lcl_SetBoolInAny( aRet, getRepeatIfEmpty() ); +/*N*/ else if ( aNameStr.EqualsAscii( SC_UNO_DATADESC ) ) // read-only +/*?*/ {DBG_BF_ASSERT(0, "STRIP");} //STRIP001 aRet <<= ::rtl::OUString( getDataDescription() ); +/*N*/ else +/*N*/ { +/*N*/ DBG_ERROR("unknown property"); +/*N*/ //! THROW( UnknownPropertyException() ); +/*N*/ } +/*N*/ return aRet; +/*N*/ } + +/*N*/ SC_IMPL_DUMMY_PROPERTY_LISTENER( ScDPSource ) + +// ----------------------------------------------------------------------- + +/*N*/ ScDPDimensions::ScDPDimensions( ScDPSource* pSrc ) : +/*N*/ pSource( pSrc ), +/*N*/ ppDims( NULL ) +/*N*/ { +/*N*/ //! hold pSource +/*N*/ +/*N*/ // include data layout dimension and duplicated dimensions +/*N*/ nDimCount = pSource->GetData()->GetColumnCount() + 1 + pSource->GetDupCount(); +/*N*/ } + +/*N*/ ScDPDimensions::~ScDPDimensions() +/*N*/ { +/*N*/ //! release pSource +/*N*/ +/*N*/ if (ppDims) +/*N*/ { +/*N*/ for (long i=0; i<nDimCount; i++) +/*N*/ if ( ppDims[i] ) +/*N*/ ppDims[i]->release(); // ref-counted +/*N*/ delete[] ppDims; +/*N*/ } +/*N*/ } + + +// very simple XNameAccess implementation using getCount/getByIndex + +/*N*/ uno::Any SAL_CALL ScDPDimensions::getByName( const ::rtl::OUString& aName ) +/*N*/ throw(container::NoSuchElementException, +/*N*/ lang::WrappedTargetException, uno::RuntimeException) +/*N*/ { +/*N*/ long nCount = getCount(); +/*N*/ for (long i=0; i<nCount; i++) +/*N*/ if ( getByIndex(i)->getName() == aName ) +/*N*/ { +/*N*/ uno::Reference<container::XNamed> xNamed = getByIndex(i); +/*N*/ uno::Any aRet; +/*N*/ aRet <<= xNamed; +/*N*/ return aRet; +/*N*/ } +/*N*/ +/*N*/ throw container::NoSuchElementException(); +/*N*/ return uno::Any(); +/*N*/ } + +/*N*/ uno::Sequence<rtl::OUString> SAL_CALL ScDPDimensions::getElementNames() throw(uno::RuntimeException) +/*N*/ { +/*N*/ long nCount = getCount(); +/*N*/ uno::Sequence<rtl::OUString> aSeq(nCount); +/*N*/ ::rtl::OUString* pArr = aSeq.getArray(); +/*N*/ for (long i=0; i<nCount; i++) +/*N*/ pArr[i] = getByIndex(i)->getName(); +/*N*/ return aSeq; +/*N*/ } + +/*?*/ sal_Bool SAL_CALL ScDPDimensions::hasByName( const ::rtl::OUString& aName ) throw(uno::RuntimeException) +/*?*/ { +/*?*/ long nCount = getCount(); +/*?*/ for (long i=0; i<nCount; i++) +/*?*/ if ( getByIndex(i)->getName() == aName ) +/*?*/ return TRUE; +/*?*/ return FALSE; +/*?*/ } + +/*?*/ uno::Type SAL_CALL ScDPDimensions::getElementType() throw(uno::RuntimeException) +/*?*/ { +/*?*/ return getCppuType((uno::Reference<container::XNamed>*)0); +/*?*/ } + +/*?*/ sal_Bool SAL_CALL ScDPDimensions::hasElements() throw(uno::RuntimeException) +/*?*/ { +/*?*/ return ( getCount() > 0 ); +/*?*/ } + +// end of XNameAccess implementation + +/*N*/ long ScDPDimensions::getCount() const +/*N*/ { +/*N*/ // in tabular data, every column of source data is a dimension +/*N*/ +/*N*/ return nDimCount; +/*N*/ } + +/*N*/ ScDPDimension* ScDPDimensions::getByIndex(long nIndex) const +/*N*/ { +/*N*/ if ( nIndex >= 0 && nIndex < nDimCount ) +/*N*/ { +/*N*/ if ( !ppDims ) +/*N*/ { +/*N*/ ((ScDPDimensions*)this)->ppDims = new ScDPDimension*[nDimCount]; +/*N*/ for (long i=0; i<nDimCount; i++) +/*N*/ ppDims[i] = NULL; +/*N*/ } +/*N*/ if ( !ppDims[nIndex] ) +/*N*/ { +/*N*/ ppDims[nIndex] = new ScDPDimension( pSource, nIndex ); +/*N*/ ppDims[nIndex]->acquire(); // ref-counted +/*N*/ } +/*N*/ +/*N*/ return ppDims[nIndex]; +/*N*/ } +/*N*/ +/*N*/ return NULL; //! exception? +/*N*/ } + +// ----------------------------------------------------------------------- + +/*N*/ ScDPDimension::ScDPDimension( ScDPSource* pSrc, long nD ) : +/*N*/ pSource( pSrc ), +/*N*/ nDim( nD ), +/*N*/ pHierarchies( NULL ), +/*N*/ nUsedHier( 0 ), +/*N*/ nFunction( SUBTOTAL_FUNC_SUM ), // sum is default +/*N*/ nSourceDim( -1 ) +/*N*/ { +/*N*/ //! hold pSource +/*N*/ } + +/*N*/ ScDPDimension::~ScDPDimension() +/*N*/ { +/*N*/ //! release pSource +/*N*/ +/*N*/ if ( pHierarchies ) +/*N*/ pHierarchies->release(); // ref-counted +/*N*/ } + +/*N*/ ScDPHierarchies* ScDPDimension::GetHierarchiesObject() +/*N*/ { +/*N*/ if (!pHierarchies) +/*N*/ { +/*N*/ pHierarchies = new ScDPHierarchies( pSource, nDim ); +/*N*/ pHierarchies->acquire(); // ref-counted +/*N*/ } +/*N*/ return pHierarchies; +/*N*/ } + +/*N*/ uno::Reference<container::XNameAccess> SAL_CALL ScDPDimension::getHierarchies() +/*N*/ throw(uno::RuntimeException) +/*N*/ { +/*N*/ return GetHierarchiesObject(); +/*N*/ } + +/*N*/ ::rtl::OUString SAL_CALL ScDPDimension::getName() throw(uno::RuntimeException) +/*N*/ { +/*N*/ if (aName.Len()) +/*N*/ return aName; +/*N*/ else +/*N*/ return pSource->GetData()->getDimensionName( nDim ); +/*N*/ } + +/*?*/ void SAL_CALL ScDPDimension::setName( const ::rtl::OUString& rNewName ) throw(uno::RuntimeException) +/*?*/ { +/*?*/ // used after cloning +/*?*/ aName = String( rNewName ); +/*?*/ } + +/*N*/ USHORT ScDPDimension::getOrientation() const +/*N*/ { +/*N*/ return pSource->GetOrientation( nDim ); +/*N*/ } + +/*N*/ void ScDPDimension::setOrientation(USHORT nNew) +/*N*/ { +/*N*/ pSource->SetOrientation( nDim, nNew ); +/*N*/ } + +/*N*/ long ScDPDimension::getPosition() const +/*N*/ { +/*N*/ return pSource->GetPosition( nDim ); +/*N*/ } + + +/*N*/ BOOL ScDPDimension::getIsDataLayoutDimension() const +/*N*/ { +/*N*/ return pSource->GetData()->getIsDataLayoutDimension( nDim ); +/*N*/ } + +/*N*/ USHORT ScDPDimension::getFunction() const +/*N*/ { +/*N*/ return nFunction; +/*N*/ } + +/*N*/ void ScDPDimension::setFunction(USHORT nNew) +/*N*/ { +/*N*/ nFunction = nNew; +/*N*/ } + +/*N*/ long ScDPDimension::getUsedHierarchy() const +/*N*/ { +/*N*/ return nUsedHier; +/*N*/ } + + + +/*?*/ uno::Reference<util::XCloneable> SAL_CALL ScDPDimension::createClone() throw(uno::RuntimeException) +/*?*/ {DBG_BF_ASSERT(0, "STRIP"); return uno::Reference<util::XCloneable>(0); //STRIP001 +/*?*/ } + + +// XPropertySet + +/*?*/ uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDPDimension::getPropertySetInfo() +/*?*/ throw(uno::RuntimeException) +/*?*/ {DBG_BF_ASSERT(0, "STRIP"); return uno::Reference<beans::XPropertySetInfo>(0); //STRIP001 +/*?*/ } + +/*N*/ void SAL_CALL ScDPDimension::setPropertyValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue ) +/*N*/ throw(beans::UnknownPropertyException, beans::PropertyVetoException, +/*N*/ lang::IllegalArgumentException, lang::WrappedTargetException, +/*N*/ uno::RuntimeException) +/*N*/ { +/*N*/ String aNameStr = aPropertyName; +/*N*/ if ( aNameStr.EqualsAscii( SC_UNO_POSITION ) ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 INT32 nInt; +/*N*/ } +/*N*/ else if ( aNameStr.EqualsAscii( SC_UNO_USEDHIER ) ) +/*N*/ { +/*?*/ INT32 nInt; +/*?*/ if (aValue >>= nInt) +/*?*/ {DBG_BF_ASSERT(0, "STRIP");} //STRIP001 setUsedHierarchy( nInt ); +/*N*/ } +/*N*/ else if ( aNameStr.EqualsAscii( SC_UNO_ORIENTAT ) ) +/*N*/ { +/*N*/ sheet::DataPilotFieldOrientation eEnum; +/*N*/ if (aValue >>= eEnum) +/*N*/ setOrientation( eEnum ); +/*N*/ } +/*N*/ else if ( aNameStr.EqualsAscii( SC_UNO_FUNCTION ) ) +/*N*/ { +/*N*/ sheet::GeneralFunction eEnum; +/*N*/ if (aValue >>= eEnum) +/*N*/ setFunction( eEnum ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ DBG_ERROR("unknown property"); +/*N*/ //! THROW( UnknownPropertyException() ); +/*N*/ } +/*N*/ } + +/*N*/ uno::Any SAL_CALL ScDPDimension::getPropertyValue( const ::rtl::OUString& aPropertyName ) +/*N*/ throw(beans::UnknownPropertyException, lang::WrappedTargetException, +/*N*/ uno::RuntimeException) +/*N*/ { +/*N*/ uno::Any aRet; +/*N*/ String aNameStr = aPropertyName; +/*N*/ if ( aNameStr.EqualsAscii( SC_UNO_POSITION ) ) +/*N*/ aRet <<= (sal_Int32) getPosition(); +/*N*/ else if ( aNameStr.EqualsAscii( SC_UNO_USEDHIER ) ) +/*N*/ aRet <<= (sal_Int32) getUsedHierarchy(); +/*N*/ else if ( aNameStr.EqualsAscii( SC_UNO_ORIENTAT ) ) +/*N*/ { +/*N*/ sheet::DataPilotFieldOrientation eVal = (sheet::DataPilotFieldOrientation)getOrientation(); +/*N*/ aRet <<= eVal; +/*N*/ } +/*N*/ else if ( aNameStr.EqualsAscii( SC_UNO_FUNCTION ) ) +/*N*/ { +/*N*/ sheet::GeneralFunction eVal = (sheet::GeneralFunction)getFunction(); +/*N*/ aRet <<= eVal; +/*N*/ } +/*N*/ else if ( aNameStr.EqualsAscii( SC_UNO_ISDATALA ) ) // read-only properties +/*N*/ lcl_SetBoolInAny( aRet, getIsDataLayoutDimension() ); +/*N*/ else if ( aNameStr.EqualsAscii( SC_UNO_NUMBERFO ) ) +/*?*/ {DBG_BF_ASSERT(0, "STRIP");} //STRIP001 aRet <<= (sal_Int32) pSource->GetData()->GetNumberFormat( +/*N*/ else if ( aNameStr.EqualsAscii( SC_UNO_ORIGINAL ) ) +/*N*/ { +/*N*/ uno::Reference<container::XNamed> xOriginal; +/*N*/ if (nSourceDim >= 0) +/*?*/ xOriginal = pSource->GetDimensionsObject()->getByIndex(nSourceDim); +/*N*/ aRet <<= xOriginal; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ DBG_ERROR("unknown property"); +/*N*/ //! THROW( UnknownPropertyException() ); +/*N*/ } +/*N*/ return aRet; +/*N*/ } + +/*N*/ SC_IMPL_DUMMY_PROPERTY_LISTENER( ScDPDimension ) + +// ----------------------------------------------------------------------- + +/*N*/ ScDPHierarchies::ScDPHierarchies( ScDPSource* pSrc, long nD ) : +/*N*/ pSource( pSrc ), +/*N*/ nDim( nD ), +/*N*/ ppHiers( NULL ) +/*N*/ { +/*N*/ //! hold pSource +/*N*/ +/*N*/ // date columns have 3 hierarchies (flat/quarter/week), other columns only one +/*N*/ long nSrcDim = pSource->GetSourceDim( nDim ); +/*N*/ if ( pSource->IsDateDimension( nSrcDim ) ) +/*?*/ nHierCount = SC_DAPI_DATE_HIERARCHIES; +/*N*/ else +/*N*/ nHierCount = 1; +/*N*/ } + +/*N*/ ScDPHierarchies::~ScDPHierarchies() +/*N*/ { +/*N*/ //! release pSource +/*N*/ +/*N*/ if (ppHiers) +/*N*/ { +/*N*/ for (long i=0; i<nHierCount; i++) +/*N*/ if ( ppHiers[i] ) +/*N*/ ppHiers[i]->release(); // ref-counted +/*N*/ delete[] ppHiers; +/*N*/ } +/*N*/ } + +// very simple XNameAccess implementation using getCount/getByIndex + +/*N*/ uno::Any SAL_CALL ScDPHierarchies::getByName( const ::rtl::OUString& aName ) +/*N*/ throw(container::NoSuchElementException, +/*N*/ lang::WrappedTargetException, uno::RuntimeException) +/*N*/ { +/*N*/ long nCount = getCount(); +/*N*/ for (long i=0; i<nCount; i++) +/*N*/ if ( getByIndex(i)->getName() == aName ) +/*N*/ { +/*N*/ uno::Reference<container::XNamed> xNamed = getByIndex(i); +/*N*/ uno::Any aRet; +/*N*/ aRet <<= xNamed; +/*N*/ return aRet; +/*N*/ } +/*N*/ +/*?*/ throw container::NoSuchElementException(); +/*N*/ return uno::Any(); +/*N*/ } + +/*N*/ uno::Sequence<rtl::OUString> SAL_CALL ScDPHierarchies::getElementNames() throw(uno::RuntimeException) +/*N*/ { +/*N*/ long nCount = getCount(); +/*N*/ uno::Sequence<rtl::OUString> aSeq(nCount); +/*N*/ ::rtl::OUString* pArr = aSeq.getArray(); +/*N*/ for (long i=0; i<nCount; i++) +/*N*/ pArr[i] = getByIndex(i)->getName(); +/*N*/ return aSeq; +/*N*/ } + +/*?*/ sal_Bool SAL_CALL ScDPHierarchies::hasByName( const ::rtl::OUString& aName ) throw(uno::RuntimeException) +/*?*/ { +/*?*/ long nCount = getCount(); +/*?*/ for (long i=0; i<nCount; i++) +/*?*/ if ( getByIndex(i)->getName() == aName ) +/*?*/ return TRUE; +/*?*/ return FALSE; +/*?*/ } + +/*?*/ uno::Type SAL_CALL ScDPHierarchies::getElementType() throw(uno::RuntimeException) +/*?*/ { +/*?*/ return getCppuType((uno::Reference<container::XNamed>*)0); +/*?*/ } + +/*?*/ sal_Bool SAL_CALL ScDPHierarchies::hasElements() throw(uno::RuntimeException) +/*?*/ { +/*?*/ return ( getCount() > 0 ); +/*?*/ } + +// end of XNameAccess implementation + +/*N*/ long ScDPHierarchies::getCount() const +/*N*/ { +/*N*/ return nHierCount; +/*N*/ } + +/*N*/ ScDPHierarchy* ScDPHierarchies::getByIndex(long nIndex) const +/*N*/ { +/*N*/ // pass hierarchy index to new object in case the implementation +/*N*/ // will be extended to more than one hierarchy +/*N*/ +/*N*/ if ( nIndex >= 0 && nIndex < nHierCount ) +/*N*/ { +/*N*/ if ( !ppHiers ) +/*N*/ { +/*N*/ ((ScDPHierarchies*)this)->ppHiers = new ScDPHierarchy*[nHierCount]; +/*N*/ for (long i=0; i<nHierCount; i++) +/*N*/ ppHiers[i] = NULL; +/*N*/ } +/*N*/ if ( !ppHiers[nIndex] ) +/*N*/ { +/*N*/ ppHiers[nIndex] = new ScDPHierarchy( pSource, nDim, nIndex ); +/*N*/ ppHiers[nIndex]->acquire(); // ref-counted +/*N*/ } +/*N*/ +/*N*/ return ppHiers[nIndex]; +/*N*/ } +/*N*/ +/*N*/ return NULL; //! exception? +/*N*/ } + +// ----------------------------------------------------------------------- + +/*N*/ ScDPHierarchy::ScDPHierarchy( ScDPSource* pSrc, long nD, long nH ) : +/*N*/ pSource( pSrc ), +/*N*/ nDim( nD ), +/*N*/ nHier( nH ), +/*N*/ pLevels( NULL ) +/*N*/ { +/*N*/ //! hold pSource +/*N*/ } + +/*N*/ ScDPHierarchy::~ScDPHierarchy() +/*N*/ { +/*N*/ //! release pSource +/*N*/ +/*N*/ if (pLevels) +/*N*/ pLevels->release(); // ref-counted +/*N*/ } + +/*N*/ ScDPLevels* ScDPHierarchy::GetLevelsObject() +/*N*/ { +/*N*/ if (!pLevels) +/*N*/ { +/*N*/ pLevels = new ScDPLevels( pSource, nDim, nHier ); +/*N*/ pLevels->acquire(); // ref-counted +/*N*/ } +/*N*/ return pLevels; +/*N*/ } + +/*N*/ uno::Reference<container::XNameAccess> SAL_CALL ScDPHierarchy::getLevels() +/*N*/ throw(uno::RuntimeException) +/*N*/ { +/*N*/ return GetLevelsObject(); +/*N*/ } + +/*N*/ ::rtl::OUString SAL_CALL ScDPHierarchy::getName() throw(uno::RuntimeException) +/*N*/ { +/*N*/ String aRet; //! globstr-ID !!!! +/*N*/ switch (nHier) +/*N*/ { +/*N*/ case SC_DAPI_HIERARCHY_FLAT: +/*N*/ aRet = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("flat")); +/*N*/ break; //! name ??????? +/*N*/ case SC_DAPI_HIERARCHY_QUARTER: +/*?*/ aRet = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Quarter")); +/*?*/ break; //! name ??????? +/*N*/ case SC_DAPI_HIERARCHY_WEEK: +/*?*/ aRet = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Week")); +/*?*/ break; //! name ??????? +/*N*/ } +/*N*/ return aRet; +/*N*/ } + +/*?*/ void SAL_CALL ScDPHierarchy::setName( const ::rtl::OUString& rNewName ) throw(uno::RuntimeException) +/*?*/ { +/*?*/ DBG_ERROR("not implemented"); //! exception? +/*?*/ } + +// ----------------------------------------------------------------------- + +/*N*/ ScDPLevels::ScDPLevels( ScDPSource* pSrc, long nD, long nH ) : +/*N*/ pSource( pSrc ), +/*N*/ nDim( nD ), +/*N*/ nHier( nH ), +/*N*/ ppLevs( NULL ) +/*N*/ { +/*N*/ //! hold pSource +/*N*/ +/*N*/ // text columns have only one level +/*N*/ +/*N*/ long nSrcDim = pSource->GetSourceDim( nDim ); +/*N*/ if ( pSource->IsDateDimension( nSrcDim ) ) +/*N*/ { +/*?*/ switch ( nHier ) +/*?*/ { +/*?*/ case SC_DAPI_HIERARCHY_FLAT: nLevCount = SC_DAPI_FLAT_LEVELS; break; +/*?*/ case SC_DAPI_HIERARCHY_QUARTER: nLevCount = SC_DAPI_QUARTER_LEVELS; break; +/*?*/ case SC_DAPI_HIERARCHY_WEEK: nLevCount = SC_DAPI_WEEK_LEVELS; break; +/*?*/ default: +/*?*/ DBG_ERROR("wrong hierarchy"); +/*?*/ nLevCount = 0; +/*?*/ } +/*N*/ } +/*N*/ else +/*N*/ nLevCount = 1; +/*N*/ } + +/*N*/ ScDPLevels::~ScDPLevels() +/*N*/ { +/*N*/ //! release pSource +/*N*/ +/*N*/ if (ppLevs) +/*N*/ { +/*N*/ for (long i=0; i<nLevCount; i++) +/*N*/ if ( ppLevs[i] ) +/*N*/ ppLevs[i]->release(); // ref-counted +/*N*/ delete[] ppLevs; +/*N*/ } +/*N*/ } + +// very simple XNameAccess implementation using getCount/getByIndex + +/*N*/ uno::Any SAL_CALL ScDPLevels::getByName( const ::rtl::OUString& aName ) +/*N*/ throw(container::NoSuchElementException, +/*N*/ lang::WrappedTargetException, uno::RuntimeException) +/*N*/ { +/*N*/ long nCount = getCount(); +/*N*/ for (long i=0; i<nCount; i++) +/*N*/ if ( getByIndex(i)->getName() == aName ) +/*N*/ { +/*N*/ uno::Reference<container::XNamed> xNamed = getByIndex(i); +/*N*/ uno::Any aRet; +/*N*/ aRet <<= xNamed; +/*N*/ return aRet; +/*N*/ } +/*N*/ +/*?*/ throw container::NoSuchElementException(); +/*N*/ return uno::Any(); +/*N*/ } + +/*N*/ uno::Sequence<rtl::OUString> SAL_CALL ScDPLevels::getElementNames() throw(uno::RuntimeException) +/*N*/ { +/*N*/ long nCount = getCount(); +/*N*/ uno::Sequence<rtl::OUString> aSeq(nCount); +/*N*/ ::rtl::OUString* pArr = aSeq.getArray(); +/*N*/ for (long i=0; i<nCount; i++) +/*N*/ pArr[i] = getByIndex(i)->getName(); +/*N*/ return aSeq; +/*N*/ } + +/*N*/ sal_Bool SAL_CALL ScDPLevels::hasByName( const ::rtl::OUString& aName ) throw(uno::RuntimeException) +/*N*/ { +/*N*/ long nCount = getCount(); +/*N*/ for (long i=0; i<nCount; i++) +/*N*/ if ( getByIndex(i)->getName() == aName ) +/*N*/ return TRUE; +/*N*/ return FALSE; +/*N*/ } + +/*N*/ uno::Type SAL_CALL ScDPLevels::getElementType() throw(uno::RuntimeException) +/*N*/ { +/*N*/ return getCppuType((uno::Reference<container::XNamed>*)0); +/*N*/ } + +/*N*/ sal_Bool SAL_CALL ScDPLevels::hasElements() throw(uno::RuntimeException) +/*N*/ { +/*N*/ return ( getCount() > 0 ); +/*N*/ } + +// end of XNameAccess implementation + +/*N*/ long ScDPLevels::getCount() const +/*N*/ { +/*N*/ return nLevCount; +/*N*/ } + +/*N*/ ScDPLevel* ScDPLevels::getByIndex(long nIndex) const +/*N*/ { +/*N*/ if ( nIndex >= 0 && nIndex < nLevCount ) +/*N*/ { +/*N*/ if ( !ppLevs ) +/*N*/ { +/*N*/ ((ScDPLevels*)this)->ppLevs = new ScDPLevel*[nLevCount]; +/*N*/ for (long i=0; i<nLevCount; i++) +/*N*/ ppLevs[i] = NULL; +/*N*/ } +/*N*/ if ( !ppLevs[nIndex] ) +/*N*/ { +/*N*/ ppLevs[nIndex] = new ScDPLevel( pSource, nDim, nHier, nIndex ); +/*N*/ ppLevs[nIndex]->acquire(); // ref-counted +/*N*/ } +/*N*/ +/*N*/ return ppLevs[nIndex]; +/*N*/ } +/*N*/ +/*N*/ return NULL; //! exception? +/*N*/ } + +// ----------------------------------------------------------------------- + +/*N*/ ScDPLevel::ScDPLevel( ScDPSource* pSrc, long nD, long nH, long nL ) : +/*N*/ pSource( pSrc ), +/*N*/ nDim( nD ), +/*N*/ nHier( nH ), +/*N*/ nLev( nL ), +/*N*/ pMembers( NULL ), +/*N*/ bShowEmpty( FALSE ) +/*N*/ { +/*N*/ //! hold pSource +/*N*/ // aSubTotals is empty +/*N*/ } + +/*N*/ ScDPLevel::~ScDPLevel() +/*N*/ { +/*N*/ //! release pSource +/*N*/ +/*N*/ if ( pMembers ) +/*?*/ {DBG_BF_ASSERT(0, "STRIP");} //STRIP001 pMembers->release(); // ref-counted +/*N*/ } + + +/*?*/ uno::Reference<container::XNameAccess> SAL_CALL ScDPLevel::getMembers() throw(uno::RuntimeException) +/*?*/ {DBG_BF_ASSERT(0, "STRIP"); return uno::Reference<container::XNameAccess>(0); //STRIP001 +/*?*/ } + +/*?*/ uno::Sequence<sheet::MemberResult> SAL_CALL ScDPLevel::getResults() throw(uno::RuntimeException) +/*?*/ {DBG_BF_ASSERT(0, "STRIP"); //STRIP001 +/*?*/ return uno::Sequence<sheet::MemberResult>(0); //! Error? +/*?*/ } + +/*N*/ ::rtl::OUString SAL_CALL ScDPLevel::getName() throw(uno::RuntimeException) +/*N*/ { +/*N*/ long nSrcDim = pSource->GetSourceDim( nDim ); +/*N*/ if ( pSource->IsDateDimension( nSrcDim ) ) +/*?*/ { +/*?*/ String aRet; //! globstr-ID !!!! +/*?*/ +/*?*/ if ( nHier == SC_DAPI_HIERARCHY_QUARTER ) +/*?*/ { +/*?*/ switch ( nLev ) +/*?*/ { +/*?*/ case SC_DAPI_LEVEL_YEAR: +/*?*/ aRet = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Year")); +/*?*/ break; +/*?*/ case SC_DAPI_LEVEL_QUARTER: +/*?*/ aRet = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Quarter")); +/*?*/ break; +/*?*/ case SC_DAPI_LEVEL_MONTH: +/*?*/ aRet = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Month")); +/*?*/ break; +/*?*/ case SC_DAPI_LEVEL_DAY: +/*?*/ aRet = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Day")); +/*?*/ break; +/*?*/ } +/*?*/ } +/*?*/ else if ( nHier == SC_DAPI_HIERARCHY_WEEK ) +/*?*/ { +/*?*/ switch ( nLev ) +/*?*/ { +/*?*/ case SC_DAPI_LEVEL_YEAR: +/*?*/ aRet = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Year")); +/*?*/ break; +/*?*/ case SC_DAPI_LEVEL_WEEK: +/*?*/ aRet = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Week")); +/*?*/ break; +/*?*/ case SC_DAPI_LEVEL_WEEKDAY: +/*?*/ aRet = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Weekday")); +/*?*/ break; +/*?*/ } +/*?*/ } +/*?*/ if (aRet.Len()) +/*?*/ return aRet; +/*N*/ } +/*N*/ +/*N*/ return pSource->GetData()->getDimensionName( nSrcDim ); // (original) dimension name +/*N*/ } + +/*?*/ void SAL_CALL ScDPLevel::setName( const ::rtl::OUString& rNewName ) throw(uno::RuntimeException) +/*?*/ { +/*?*/ DBG_ERROR("not implemented"); //! exception? +/*?*/ } + +/*N*/ uno::Sequence<sheet::GeneralFunction> ScDPLevel::getSubTotals() const +/*N*/ { +/*N*/ //! separate functions for settings and evaluation? +/*N*/ +/*N*/ long nSrcDim = pSource->GetSourceDim( nDim ); +/*N*/ if ( !pSource->SubTotalAllowed( nSrcDim ) ) +/*N*/ return uno::Sequence<sheet::GeneralFunction>(0); +/*N*/ +/*N*/ return aSubTotals; +/*N*/ } + + + +/*N*/ void ScDPLevel::setShowEmpty(BOOL bSet) +/*N*/ { +/*N*/ bShowEmpty = bSet; +/*N*/ } + +// XPropertySet + +/*N*/ uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDPLevel::getPropertySetInfo() +/*N*/ throw(uno::RuntimeException) +/*N*/ { +/*N*/ SolarMutexGuard aGuard; +/*N*/ +/*N*/ static SfxItemPropertyMap aDPLevelMap_Impl[] = +/*N*/ { +/*N*/ {MAP_CHAR_LEN(SC_UNO_SHOWEMPT), 0, &getBooleanCppuType(), 0, 0 }, +/*N*/ {MAP_CHAR_LEN(SC_UNO_SUBTOTAL), 0, &getCppuType((uno::Sequence<sheet::GeneralFunction>*)0), 0, 0 }, +/*N*/ {0,0,0,0} +/*N*/ }; +/*N*/ static uno::Reference<beans::XPropertySetInfo> aRef = +/*N*/ new SfxItemPropertySetInfo( aDPLevelMap_Impl ); +/*N*/ return aRef; +/*N*/ } + +/*N*/ void SAL_CALL ScDPLevel::setPropertyValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue ) +/*N*/ throw(beans::UnknownPropertyException, beans::PropertyVetoException, +/*N*/ lang::IllegalArgumentException, lang::WrappedTargetException, +/*N*/ uno::RuntimeException) +/*N*/ { +/*N*/ String aNameStr = aPropertyName; +/*N*/ if ( aNameStr.EqualsAscii( SC_UNO_SHOWEMPT ) ) +/*N*/ setShowEmpty( lcl_GetBoolFromAny( aValue ) ); +/*N*/ else if ( aNameStr.EqualsAscii( SC_UNO_SUBTOTAL ) ) +/*N*/ { +/*?*/ uno::Sequence<sheet::GeneralFunction> aSeq; +/*?*/ if ( aValue >>= aSeq ) +/*?*/ {DBG_BF_ASSERT(0, "STRIP");} //STRIP001 setSubTotals( aSeq ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ DBG_ERROR("unknown property"); +/*N*/ //! THROW( UnknownPropertyException() ); +/*N*/ } +/*N*/ } + +/*N*/ uno::Any SAL_CALL ScDPLevel::getPropertyValue( const ::rtl::OUString& aPropertyName ) +/*N*/ throw(beans::UnknownPropertyException, lang::WrappedTargetException, +/*N*/ uno::RuntimeException) +/*N*/ { +/*N*/ uno::Any aRet; +/*N*/ String aNameStr = aPropertyName; +/*N*/ if ( aNameStr.EqualsAscii( SC_UNO_SHOWEMPT ) ) +/*?*/ {DBG_BF_ASSERT(0, "STRIP");} //STRIP001 lcl_SetBoolInAny( aRet, getShowEmpty() ); +/*N*/ else if ( aNameStr.EqualsAscii( SC_UNO_SUBTOTAL ) ) +/*N*/ { +/*N*/ uno::Sequence<sheet::GeneralFunction> aSeq = getSubTotals(); //! avoid extra copy? +/*N*/ aRet <<= aSeq; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ DBG_ERROR("unknown property"); +/*N*/ //! THROW( UnknownPropertyException() ); +/*N*/ } +/*N*/ return aRet; +/*N*/ } + +/*N*/ SC_IMPL_DUMMY_PROPERTY_LISTENER( ScDPLevel ) + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_drawpage.cxx b/binfilter/bf_sc/source/core/data/sc_drawpage.cxx new file mode 100644 index 000000000000..43559bfb9ddf --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_drawpage.cxx @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + + +#include "drawpage.hxx" +#include "drwlayer.hxx" +#include "pageuno.hxx" +namespace binfilter { + +// STATIC DATA ----------------------------------------------------------- + +// ----------------------------------------------------------------------- + +/*N*/ ScDrawPage::ScDrawPage(ScDrawLayer& rNewModel, StarBASIC* pBasic, BOOL bMasterPage) : +/*N*/ FmFormPage(rNewModel, pBasic, bMasterPage) +/*N*/ { +/*N*/ SetSize( Size( LONG_MAX, LONG_MAX ) ); +/*N*/ } + +// ----------------------------------------------------------------------- + +/*N*/ __EXPORT ScDrawPage::~ScDrawPage() +/*N*/ { +/*N*/ } + +// ----------------------------------------------------------------------- + + +// ----------------------------------------------------------------------- + +/*N*/ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > ScDrawPage::createUnoPage() +/*N*/ { +/*N*/ return static_cast<cppu::OWeakObject*>( new ScPageObj( this ) ); +/*N*/ } + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_drwlayer.cxx b/binfilter/bf_sc/source/core/data/sc_drwlayer.cxx new file mode 100644 index 000000000000..0f09ef768ba3 --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_drwlayer.cxx @@ -0,0 +1,928 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + + +#include "scitems.hxx" +#include <bf_svx/eeitem.hxx> +#define ITEMID_FIELD EE_FEATURE_FIELD + +#include <bf_svx/frmdiritem.hxx> +#include <bf_svx/objfac3d.hxx> +#include <bf_svx/svdoutl.hxx> +#include <bf_svx/svditer.hxx> +#include <bf_svx/svdoedge.hxx> +#include <bf_svx/svdoole2.hxx> +#include <bf_svx/svdundo.hxx> +#include <bf_svx/drawitem.hxx> +#include <bf_svx/fhgtitem.hxx> +#include <bf_sfx2/docfile.hxx> +#include <bf_svtools/pathoptions.hxx> +#include <bf_svtools/itempool.hxx> +#include <bf_offmgr/app.hxx> + +#include "drwlayer.hxx" +#include "drawpage.hxx" +#include "document.hxx" +#include "rechead.hxx" +#include "userdat.hxx" +#include "globstr.hrc" +#include "scmod.hxx" +namespace binfilter { + +#define DET_ARROW_OFFSET 1000 + +// Abstand zur naechsten Zelle beim Loeschen (bShrink), damit der Anker +// immer an der richtigen Zelle angezeigt wird +//#define SHRINK_DIST 3 +// und noch etwas mehr, damit das Objekt auch sichtbar in der Zelle liegt +#define SHRINK_DIST 25 + +#define SHRINK_DIST_TWIPS 15 + +// ----------------------------------------------------------------------- +// +// Das Anpassen der Detektiv-UserData muss zusammen mit den Draw-Undo's +// in der SdrUndoGroup liegen, darum von SdrUndoAction abgeleitet: + + +// ----------------------------------------------------------------------- + +// STATIC DATA ----------------------------------------------------------- + +/*N*/ TYPEINIT1(ScTabDeletedHint, SfxHint); +/*N*/ TYPEINIT1(ScTabSizeChangedHint, SfxHint); + +static ScDrawObjFactory* pFac = NULL; +static E3dObjFactory* pF3d = NULL; +static USHORT nInst = 0; + +SvPersist* ScDrawLayer::pGlobalDrawPersist = NULL; + +BOOL bDrawIsInUndo = FALSE; //! Member + +// ----------------------------------------------------------------------- + +/*N*/ __EXPORT ScTabDeletedHint::~ScTabDeletedHint() +/*N*/ { +/*N*/ } + +/*N*/ ScTabSizeChangedHint::ScTabSizeChangedHint( USHORT nTabNo ) : +/*N*/ nTab( nTabNo ) +/*N*/ { +/*N*/ } + +/*N*/ __EXPORT ScTabSizeChangedHint::~ScTabSizeChangedHint() +/*N*/ { +/*N*/ } + +// ----------------------------------------------------------------------- + +#define MAXMM 10000000 + +/*N*/ inline void TwipsToMM( long& nVal ) +/*N*/ { +/*N*/ nVal = (long) ( nVal * HMM_PER_TWIPS ); +/*N*/ } + +/*N*/ inline void ReverseTwipsToMM( long& nVal ) +/*N*/ { +/*N*/ // reverse the effect of TwipsToMM - round up here (add 1) +/*N*/ +/*N*/ nVal = ((long) ( nVal / HMM_PER_TWIPS )) + 1; +/*N*/ } + +/*N*/ void lcl_TwipsToMM( Point& rPoint ) +/*N*/ { +/*N*/ TwipsToMM( rPoint.X() ); +/*N*/ TwipsToMM( rPoint.Y() ); +/*N*/ } + +/*N*/ void lcl_ReverseTwipsToMM( Point& rPoint ) +/*N*/ { +/*N*/ ReverseTwipsToMM( rPoint.X() ); +/*N*/ ReverseTwipsToMM( rPoint.Y() ); +/*N*/ } + +/*N*/ void lcl_ReverseTwipsToMM( Rectangle& rRect ) +/*N*/ { +/*N*/ ReverseTwipsToMM( rRect.Left() ); +/*N*/ ReverseTwipsToMM( rRect.Right() ); +/*N*/ ReverseTwipsToMM( rRect.Top() ); +/*N*/ ReverseTwipsToMM( rRect.Bottom() ); +/*N*/ } + +// ----------------------------------------------------------------------- + + +/*N*/ ScDrawLayer::ScDrawLayer( ScDocument* pDocument, const String& rName ) : +/*N*/ FmFormModel( SvtPathOptions().GetPalettePath(), +/*N*/ NULL, // SfxItemPool* Pool +/*N*/ pGlobalDrawPersist ? +/*N*/ pGlobalDrawPersist : +/*N*/ ( pDocument ? pDocument->GetDocumentShell() : NULL ), +/*N*/ TRUE ), // bUseExtColorTable (is set below) +/*N*/ aName( rName ), +/*N*/ pDoc( pDocument ), +/*N*/ pUndoGroup( NULL ), +/*N*/ bRecording( FALSE ), +/*N*/ bAdjustEnabled( TRUE ), +/*N*/ bHyphenatorSet( FALSE ) +/*N*/ { +/*N*/ pGlobalDrawPersist = NULL; // nur einmal benutzen +/*N*/ +/*N*/ SfxObjectShell* pObjSh = pDocument ? pDocument->GetDocumentShell() : NULL; +/*N*/ if ( pObjSh ) +/*N*/ { +/*N*/ SetObjectShell( pObjSh ); +/*N*/ +/*N*/ // set color table +/*N*/ SvxColorTableItem* pColItem = (SvxColorTableItem*) pObjSh->GetItem( ITEMID_COLOR_TABLE ); +/*N*/ XColorTable* pXCol = pColItem ? pColItem->GetColorTable() : OFF_APP()->GetStdColorTable(); +/*N*/ SetColorTable( pXCol ); +/*N*/ } +/*N*/ else +/*?*/ SetColorTable( OFF_APP()->GetStdColorTable() ); +/*N*/ +/*N*/ SetSwapGraphics(TRUE); +/*N*/ // SetSwapAsynchron(TRUE); // an der View +/*N*/ +/*N*/ SetScaleUnit(MAP_100TH_MM); +/*N*/ SfxItemPool& rPool = GetItemPool(); +/*N*/ rPool.SetDefaultMetric(SFX_MAPUNIT_100TH_MM); +/*N*/ SvxFrameDirectionItem aModeItem( FRMDIR_ENVIRONMENT, EE_PARA_WRITINGDIR ); +/*N*/ rPool.SetPoolDefaultItem( aModeItem ); +/*N*/ rPool.FreezeIdRanges(); // der Pool wird auch direkt verwendet +/*N*/ +/*N*/ SdrLayerAdmin& rAdmin = GetLayerAdmin(); +/*N*/ rAdmin.NewLayer(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("vorne")), SC_LAYER_FRONT); +/*N*/ rAdmin.NewLayer(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("hinten")), SC_LAYER_BACK); +/*N*/ rAdmin.NewLayer(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("intern")), SC_LAYER_INTERN); +/*N*/ rAdmin.NewLayer(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Controls")), SC_LAYER_CONTROLS); +/*N*/ // "Controls" is new - must also be created when loading +/*N*/ +/*N*/ // Link fuer URL-Fields setzen +/*N*/ ScModule* pScMod = SC_MOD(); +/*N*/ Outliner& rOutliner = GetDrawOutliner(); +/*N*/ rOutliner.SetCalcFieldValueHdl( LINK( pScMod, ScModule, CalcFieldValueHdl ) ); +/*N*/ +/*N*/ Outliner& rHitOutliner = GetHitTestOutliner(); +/*N*/ rHitOutliner.SetCalcFieldValueHdl( LINK( pScMod, ScModule, CalcFieldValueHdl ) ); +/*N*/ +/*N*/ // #95129# SJ: set FontHeight pool defaults without changing static SdrEngineDefaults +/*N*/ SfxItemPool* pOutlinerPool = rOutliner.GetEditTextObjectPool(); +/*N*/ if ( pOutlinerPool ) +/*N*/ pItemPool->SetPoolDefaultItem(SvxFontHeightItem( 423, 100, EE_CHAR_FONTHEIGHT )); // 12Pt +/*N*/ SfxItemPool* pHitOutlinerPool = rHitOutliner.GetEditTextObjectPool(); +/*N*/ if ( pHitOutlinerPool ) +/*N*/ pHitOutlinerPool->SetPoolDefaultItem(SvxFontHeightItem( 423, 100, EE_CHAR_FONTHEIGHT )); // 12Pt +/*N*/ +/*N*/ // URL-Buttons haben keinen Handler mehr, machen alles selber +/*N*/ +/*N*/ if( !nInst++ ) +/*N*/ { +/*N*/ pFac = new ScDrawObjFactory; +/*N*/ pF3d = new E3dObjFactory; +/*N*/ } +/*N*/ } + +/*N*/ __EXPORT ScDrawLayer::~ScDrawLayer() +/*N*/ { +/*N*/ Broadcast(SdrHint(HINT_MODELCLEARED)); +/*N*/ +/*N*/ Clear(); +/*N*/ +/*N*/ delete pUndoGroup; +/*N*/ if( !--nInst ) +/*N*/ { +/*N*/ delete pFac, pFac = NULL; +/*N*/ delete pF3d, pF3d = NULL; +/*N*/ } +/*N*/ } + + +/*N*/ SdrPage* __EXPORT ScDrawLayer::AllocPage(FASTBOOL bMasterPage) +/*N*/ { +/*N*/ // don't create basic until it is needed +/*N*/ StarBASIC* pBasic = NULL; +/*N*/ ScDrawPage* pPage = new ScDrawPage( *this, pBasic, bMasterPage ); +/*N*/ return pPage; +/*N*/ } + + +/*N*/ void ScDrawLayer::UpdateBasic() +/*N*/ { +/*N*/ // don't create basic until it is needed +/*N*/ //! remove this method? +/*N*/ } + + + +/*N*/ void ScDrawLayer::ScAddPage( USHORT nTab ) +/*N*/ { +/*N*/ if (bDrawIsInUndo) +/*N*/ return; +/*N*/ +/*N*/ ScDrawPage* pPage = (ScDrawPage*)AllocPage( FALSE ); +/*N*/ InsertPage(pPage, nTab); +/*N*/ if (bRecording) +/*N*/ AddCalcUndo(new SdrUndoNewPage(*pPage)); +/*N*/ } + + +/*N*/ void ScDrawLayer::ScRenamePage( USHORT nTab, const String& rNewName ) +/*N*/ { +/*N*/ ScDrawPage* pPage = (ScDrawPage*) GetPage(nTab); +/*N*/ if (pPage) +/*N*/ pPage->SetName(rNewName); +/*N*/ } + + + + + +/*N*/ void ScDrawLayer::SetPageSize( USHORT nPageNo, const Size& rSize ) +/*N*/ { +/*N*/ SdrPage* pPage = GetPage(nPageNo); +/*N*/ if (pPage) +/*N*/ { +/*N*/ if ( rSize != pPage->GetSize() ) +/*N*/ { +/*N*/ pPage->SetSize( rSize ); +/*N*/ Broadcast( ScTabSizeChangedHint( nPageNo ) ); // SetWorkArea() an den Views +/*N*/ } +/*N*/ +/*N*/ // Detektivlinien umsetzen (an neue Hoehen/Breiten anpassen) +/*N*/ // auch wenn Groesse gleich geblieben ist +/*N*/ // (einzelne Zeilen/Spalten koennen geaendert sein) +/*N*/ +/*N*/ ULONG nCount = pPage->GetObjCount(); +/*N*/ for ( ULONG i = 0; i < nCount; i++ ) +/*N*/ { +/*N*/ SdrObject* pObj = pPage->GetObj( i ); +/*N*/ ScDrawObjData* pData = GetObjData( pObj ); +/*N*/ if( pData ) +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 /*?*/ RecalcPos( pObj, pData ); +/*N*/ } +/*N*/ } +/*N*/ } + + +/*N*/ void ScDrawLayer::Load( SvStream& rStream ) +/*N*/ { +/*N*/ bRecording = FALSE; +/*N*/ DELETEZ(pUndoGroup); +/*N*/ +/*N*/ ScReadHeader aHdr( rStream ); +/*N*/ while (aHdr.BytesLeft()) +/*N*/ { +/*N*/ USHORT nID; +/*N*/ rStream >> nID; +/*N*/ switch (nID) +/*N*/ { +/*N*/ case SCID_DRAWPOOL: +/*N*/ { +/*N*/ ScReadHeader aPoolHdr( rStream ); +/*N*/ GetItemPool().Load( rStream ); //! in Pool-Stream ? +/*N*/ } +/*N*/ break; +/*N*/ case SCID_DRAWMODEL: +/*N*/ { +/*N*/ ScReadHeader aDrawHdr( rStream ); +/*N*/ rStream >> *this; +/*N*/ +/*N*/ // Control-Layer ist nicht in alten Dateien +/*N*/ SdrLayerAdmin& rAdmin = GetLayerAdmin(); +/*N*/ const SdrLayer* pLayer = rAdmin.GetLayerPerID(SC_LAYER_CONTROLS); +/*N*/ if (!pLayer) +/*N*/ rAdmin.NewLayer( +/*N*/ String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Controls")), +/*N*/ SC_LAYER_CONTROLS); +/*N*/ } +/*N*/ break; +/*N*/ default: +/*N*/ { +/*N*/ DBG_ERROR("unbekannter Sub-Record in ScDrawLayer::Load"); +/*N*/ ScReadHeader aDummyHdr( rStream ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ GetItemPool().LoadCompleted(); +/*N*/ } + +/*N*/ void ScDrawLayer::Store( SvStream& rStream ) const +/*N*/ { +/*N*/ ScWriteHeader aHdr( rStream ); +/*N*/ +/*N*/ //-/ const_cast<ScDrawLayer*>(this)->PrepareStore(); // non-const +/*N*/ const_cast<ScDrawLayer*>(this)->PreSave(); // non-const +/*N*/ +/*N*/ { +/*N*/ rStream << (USHORT) SCID_DRAWPOOL; +/*N*/ ScWriteHeader aPoolHdr( rStream ); +/*N*/ GetItemPool().Store( rStream ); //! in Pool-Stream ? +/*N*/ } +/*N*/ +/*N*/ { +/*N*/ rStream << (USHORT) SCID_DRAWMODEL; +/*N*/ ScWriteHeader aDrawHdr( rStream ); +/*N*/ rStream << *this; +/*N*/ } +/*N*/ +/*N*/ const_cast<ScDrawLayer*>(this)->PostSave(); // non-const +/*N*/ } + +/*N*/ BOOL ScDrawLayer::GetPrintArea( ScRange& rRange, BOOL bSetHor, BOOL bSetVer ) const +/*N*/ { +/*N*/ DBG_ASSERT( pDoc, "ScDrawLayer::GetPrintArea without document" ); +/*N*/ if ( !pDoc ) +/*N*/ return FALSE; +/*N*/ +/*N*/ USHORT nTab = rRange.aStart.Tab(); +/*N*/ DBG_ASSERT( rRange.aEnd.Tab() == nTab, "GetPrintArea: Tab unterschiedlich" ); +/*N*/ +/*N*/ BOOL bAny = FALSE; +/*N*/ long nEndX = 0; +/*N*/ long nEndY = 0; +/*N*/ long nStartX = LONG_MAX; +/*N*/ long nStartY = LONG_MAX; +/*N*/ USHORT i; +/*N*/ +/*N*/ // Grenzen ausrechnen +/*N*/ +/*N*/ if (!bSetHor) +/*N*/ { +/*?*/ nStartX = 0; +/*?*/ USHORT nStartCol = rRange.aStart.Col(); +/*?*/ for (i=0; i<nStartCol; i++) +/*?*/ nStartX +=pDoc->GetColWidth(i,nTab); +/*?*/ nEndX = nStartX; +/*?*/ USHORT nEndCol = rRange.aEnd.Col(); +/*?*/ for (i=nStartCol; i<=nEndCol; i++) +/*?*/ nEndX += pDoc->GetColWidth(i,nTab); +/*?*/ nStartX = (long)(nStartX * HMM_PER_TWIPS); +/*?*/ nEndX = (long)(nEndX * HMM_PER_TWIPS); +/*N*/ } +/*N*/ if (!bSetVer) +/*N*/ { +/*?*/ nStartY = 0; +/*?*/ USHORT nStartRow = rRange.aStart.Row(); +/*?*/ for (i=0; i<nStartRow; i++) +/*?*/ nStartY +=pDoc->FastGetRowHeight(i,nTab); +/*?*/ nEndY = nStartY; +/*?*/ USHORT nEndRow = rRange.aEnd.Row(); +/*?*/ for (i=nStartRow; i<=nEndRow; i++) +/*?*/ nEndY += pDoc->FastGetRowHeight(i,nTab); +/*?*/ nStartY = (long)(nStartY * HMM_PER_TWIPS); +/*?*/ nEndY = (long)(nEndY * HMM_PER_TWIPS); +/*N*/ } +/*N*/ +/*N*/ const SdrPage* pPage = GetPage(nTab); +/*N*/ DBG_ASSERT(pPage,"Page nicht gefunden"); +/*N*/ if (pPage) +/*N*/ { +/*N*/ SdrObjListIter aIter( *pPage, IM_FLAT ); +/*N*/ SdrObject* pObject = aIter.Next(); +/*N*/ while (pObject) +/*N*/ { +/*N*/ //! Flags (ausgeblendet?) testen +/*N*/ +/*N*/ Rectangle aObjRect = pObject->GetBoundRect(); +/*N*/ BOOL bFit = TRUE; +/*N*/ if ( !bSetHor && ( aObjRect.Right() < nStartX || aObjRect.Left() > nEndX ) ) +/*N*/ bFit = FALSE; +/*N*/ if ( !bSetVer && ( aObjRect.Bottom() < nStartY || aObjRect.Top() > nEndY ) ) +/*N*/ bFit = FALSE; +/*N*/ if ( bFit ) +/*N*/ { +/*N*/ if (bSetHor) +/*N*/ { +/*N*/ if (aObjRect.Left() < nStartX) nStartX = aObjRect.Left(); +/*N*/ if (aObjRect.Right() > nEndX) nEndX = aObjRect.Right(); +/*N*/ } +/*N*/ if (bSetVer) +/*N*/ { +/*N*/ if (aObjRect.Top() < nStartY) nStartY = aObjRect.Top(); +/*N*/ if (aObjRect.Bottom() > nEndY) nEndY = aObjRect.Bottom(); +/*N*/ } +/*N*/ bAny = TRUE; +/*N*/ } +/*N*/ +/*N*/ pObject = aIter.Next(); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if (bAny) +/*N*/ { +/*N*/ DBG_ASSERT( nStartX<=nEndX && nStartY<=nEndY, "Start/End falsch in ScDrawLayer::GetPrintArea" ); +/*N*/ +/*N*/ if (bSetHor) +/*N*/ { +/*N*/ nStartX = (long) (nStartX / HMM_PER_TWIPS); +/*N*/ nEndX = (long) (nEndX / HMM_PER_TWIPS); +/*N*/ long nWidth; +/*N*/ +/*N*/ nWidth = 0; +/*N*/ for (i=0; i<MAXCOL && nWidth<=nStartX; i++) +/*N*/ nWidth += pDoc->GetColWidth(i,nTab); +/*N*/ rRange.aStart.SetCol( i ? (i-1) : 0 ); +/*N*/ +/*N*/ nWidth = 0; +/*N*/ for (i=0; i<MAXCOL && nWidth<=nEndX; i++) //! bei Start anfangen +/*N*/ nWidth += pDoc->GetColWidth(i,nTab); +/*N*/ rRange.aEnd.SetCol( i ? (i-1) : 0 ); +/*N*/ } +/*N*/ +/*N*/ if (bSetVer) +/*N*/ { +/*N*/ nStartY = (long) (nStartY / HMM_PER_TWIPS); +/*N*/ nEndY = (long) (nEndY / HMM_PER_TWIPS); +/*N*/ long nHeight; +/*N*/ +/*N*/ nHeight = 0; +/*N*/ for (i=0; i<MAXROW && nHeight<=nStartY; i++) +/*N*/ nHeight += pDoc->FastGetRowHeight(i,nTab); +/*N*/ rRange.aStart.SetRow( i ? (i-1) : 0 ); +/*N*/ +/*N*/ nHeight = 0; +/*N*/ for (i=0; i<MAXROW && nHeight<=nEndY; i++) +/*N*/ nHeight += pDoc->FastGetRowHeight(i,nTab); +/*N*/ rRange.aEnd.SetRow( i ? (i-1) : 0 ); +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ if (bSetHor) +/*N*/ { +/*N*/ rRange.aStart.SetCol(0); +/*N*/ rRange.aEnd.SetCol(0); +/*N*/ } +/*N*/ if (bSetVer) +/*N*/ { +/*N*/ rRange.aStart.SetRow(0); +/*N*/ rRange.aEnd.SetRow(0); +/*N*/ } +/*N*/ } +/*N*/ return bAny; +/*N*/ } + +/*N*/ void ScDrawLayer::AddCalcUndo( SdrUndoAction* pUndo ) +/*N*/ { +/*N*/ if (bRecording) +/*N*/ { +/*N*/ if (!pUndoGroup) +/*N*/ pUndoGroup = new SdrUndoGroup(*this); +/*N*/ +/*N*/ pUndoGroup->AddAction( pUndo ); +/*N*/ } +/*N*/ else +/*N*/ delete pUndo; +/*N*/ } + +// MoveAreaTwips: all measures are kept in twips +/*N*/ void ScDrawLayer::MoveAreaTwips( USHORT nTab, const Rectangle& rArea, +/*N*/ const Point& rMove, const Point& rTopLeft ) +/*N*/ { +/*N*/ if (!rMove.X() && !rMove.Y()) +/*N*/ return; // nix +/*N*/ +/*N*/ SdrPage* pPage = GetPage(nTab); +/*N*/ DBG_ASSERT(pPage,"Page nicht gefunden"); +/*N*/ if (!pPage) +/*N*/ return; +/*N*/ +/*N*/ // fuer Shrinking! +/*N*/ Rectangle aNew( rArea ); +/*N*/ BOOL bShrink = FALSE; +/*N*/ if ( rMove.X() < 0 || rMove.Y() < 0 ) // verkleinern +/*N*/ { +/*N*/ if ( rTopLeft != rArea.TopLeft() ) // sind gleich beim Verschieben von Zellen +/*N*/ { +/*N*/ bShrink = TRUE; +/*N*/ aNew.Left() = rTopLeft.X(); +/*N*/ aNew.Top() = rTopLeft.Y(); +/*N*/ } +/*N*/ } +/*N*/ SdrObjListIter aIter( *pPage, IM_FLAT ); +/*N*/ SdrObject* pObject = aIter.Next(); +/*N*/ while (pObject) +/*N*/ { +/*N*/ if( GetAnchor( pObject ) == SCA_CELL ) +/*N*/ { +/*N*/ if ( GetObjData( pObject ) ) // Detektiv-Pfeil ? +/*N*/ { +/*N*/ // hier nichts +/*N*/ } +/*N*/ else if ( pObject->ISA( SdrEdgeObj ) ) // Verbinder? +/*N*/ { +/*N*/ // hier auch nichts +/*N*/ //! nicht verbundene Enden wie bei Linien (s.u.) behandeln? +/*N*/ } +/*N*/ else if ( pObject->IsPolyObj() && pObject->GetPointCount()==2 ) +/*N*/ { +/*N*/ for (USHORT i=0; i<2; i++) +/*N*/ { +/*N*/ BOOL bMoved = FALSE; +/*N*/ Point aPoint = pObject->GetPoint(i); +/*N*/ lcl_ReverseTwipsToMM( aPoint ); +/*N*/ if (rArea.IsInside(aPoint)) +/*N*/ { +/*N*/ aPoint += rMove; bMoved = TRUE; +/*N*/ } +/*N*/ else if (bShrink && aNew.IsInside(aPoint)) +/*N*/ { +/*?*/ // Punkt ist in betroffener Zelle - Test auf geloeschten Bereich +/*?*/ if ( rMove.X() && aPoint.X() >= rArea.Left() + rMove.X() ) +/*?*/ { +/*?*/ aPoint.X() = rArea.Left() + rMove.X() - SHRINK_DIST_TWIPS; +/*?*/ if ( aPoint.X() < 0 ) aPoint.X() = 0; +/*?*/ bMoved = TRUE; +/*?*/ } +/*?*/ if ( rMove.Y() && aPoint.Y() >= rArea.Top() + rMove.Y() ) +/*?*/ { +/*?*/ aPoint.Y() = rArea.Top() + rMove.Y() - SHRINK_DIST_TWIPS; +/*?*/ if ( aPoint.Y() < 0 ) aPoint.Y() = 0; +/*?*/ bMoved = TRUE; +/*?*/ } +/*N*/ } +/*N*/ if( bMoved ) +/*N*/ { +/*N*/ AddCalcUndo( new SdrUndoGeoObj( *pObject ) ); +/*N*/ lcl_TwipsToMM( aPoint ); +/*N*/ pObject->SetPoint( aPoint, i ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ Rectangle aObjRect = pObject->GetLogicRect(); +/*N*/ Point aOldMMPos = aObjRect.TopLeft(); // not converted, millimeters +/*N*/ lcl_ReverseTwipsToMM( aObjRect ); +/*N*/ Point aTopLeft = aObjRect.TopLeft(); +/*N*/ Size aMoveSize; +/*N*/ BOOL bDoMove = FALSE; +/*N*/ if (rArea.IsInside(aTopLeft)) +/*N*/ { +/*N*/ aMoveSize = Size(rMove.X(),rMove.Y()); +/*N*/ bDoMove = TRUE; +/*N*/ } +/*N*/ else if (bShrink && aNew.IsInside(aTopLeft)) +/*N*/ { +/*?*/ // Position ist in betroffener Zelle - Test auf geloeschten Bereich +/*?*/ if ( rMove.X() && aTopLeft.X() >= rArea.Left() + rMove.X() ) +/*?*/ { +/*?*/ aMoveSize.Width() = rArea.Left() + rMove.X() - SHRINK_DIST - aTopLeft.X(); +/*?*/ bDoMove = TRUE; +/*?*/ } +/*?*/ if ( rMove.Y() && aTopLeft.Y() >= rArea.Top() + rMove.Y() ) +/*?*/ { +/*?*/ aMoveSize.Height() = rArea.Top() + rMove.Y() - SHRINK_DIST - aTopLeft.Y(); +/*?*/ bDoMove = TRUE; +/*?*/ } +/*N*/ } +/*N*/ if ( bDoMove ) +/*N*/ { +/*N*/ if ( aTopLeft.X() + aMoveSize.Width() < 0 ) +/*?*/ aMoveSize.Width() = -aTopLeft.X(); +/*N*/ if ( aTopLeft.Y() + aMoveSize.Height() < 0 ) +/*?*/ aMoveSize.Height() = -aTopLeft.Y(); +/*N*/ +/*N*/ // get corresponding move size in millimeters: +/*N*/ Point aNewPos( aTopLeft.X() + aMoveSize.Width(), aTopLeft.Y() + aMoveSize.Height() ); +/*N*/ lcl_TwipsToMM( aNewPos ); +/*N*/ aMoveSize = Size( aNewPos.X() - aOldMMPos.X(), aNewPos.Y() - aOldMMPos.Y() ); // millimeters +/*N*/ +/*N*/ AddCalcUndo( new SdrUndoMoveObj( *pObject, aMoveSize ) ); +/*N*/ pObject->Move( aMoveSize ); +/*N*/ } +/*N*/ else if ( rArea.IsInside(aObjRect.BottomRight()) && +/*N*/ !pObject->IsResizeProtect() ) +/*N*/ { +/*N*/ // geschuetzte Groessen werden nicht veraendert +/*N*/ // (Positionen schon, weil sie ja an der Zelle "verankert" sind) +/*N*/ AddCalcUndo( new SdrUndoGeoObj( *pObject ) ); +/*N*/ long nOldSizeX = aObjRect.Right() - aObjRect.Left() + 1; +/*N*/ long nOldSizeY = aObjRect.Bottom() - aObjRect.Top() + 1; +/*N*/ pObject->Resize( aOldMMPos, Fraction( nOldSizeX+rMove.X(), nOldSizeX ), +/*N*/ Fraction( nOldSizeY+rMove.Y(), nOldSizeY ) ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ pObject = aIter.Next(); +/*N*/ } +/*N*/ } + + +/*N*/ void ScDrawLayer::WidthChanged( USHORT nTab, USHORT nCol, long nDifTwips ) +/*N*/ { +/*N*/ DBG_ASSERT( pDoc, "ScDrawLayer::WidthChanged without document" ); +/*N*/ if ( !pDoc ) +/*N*/ return; +/*N*/ +/*N*/ if (!bAdjustEnabled) +/*N*/ return; +/*N*/ +/*N*/ USHORT i; +/*N*/ Rectangle aRect; +/*N*/ Point aTopLeft; +/*N*/ +/*N*/ for (i=0; i<nCol; i++) +/*N*/ aRect.Left() += pDoc->GetColWidth(i,nTab); +/*N*/ aTopLeft.X() = aRect.Left(); +/*N*/ aRect.Left() += pDoc->GetColWidth(nCol,nTab); +/*N*/ +/*N*/ aRect.Right() = MAXMM; +/*N*/ aRect.Top() = 0; +/*N*/ aRect.Bottom() = MAXMM; +/*N*/ +/*N*/ //! aTopLeft ist falsch, wenn mehrere Spalten auf einmal ausgeblendet werden +/*N*/ +/*N*/ MoveAreaTwips( nTab, aRect, Point( nDifTwips,0 ), aTopLeft ); +/*N*/ } + +/*N*/ void ScDrawLayer::HeightChanged( USHORT nTab, USHORT nRow, long nDifTwips ) +/*N*/ { +/*N*/ DBG_ASSERT( pDoc, "ScDrawLayer::HeightChanged without document" ); +/*N*/ if ( !pDoc ) +/*N*/ return; +/*N*/ +/*N*/ if (!bAdjustEnabled) +/*N*/ return; +/*N*/ +/*N*/ USHORT i; +/*N*/ Rectangle aRect; +/*N*/ Point aTopLeft; +/*N*/ +/*N*/ for (i=0; i<nRow; i++) +/*N*/ aRect.Top() += pDoc->FastGetRowHeight(i,nTab); +/*N*/ aTopLeft.Y() = aRect.Top(); +/*N*/ aRect.Top() += pDoc->FastGetRowHeight(nRow,nTab); +/*N*/ +/*N*/ aRect.Bottom() = MAXMM; +/*N*/ aRect.Left() = 0; +/*N*/ aRect.Right() = MAXMM; +/*N*/ +/*N*/ //! aTopLeft ist falsch, wenn mehrere Zeilen auf einmal ausgeblendet werden +/*N*/ +/*N*/ MoveAreaTwips( nTab, aRect, Point( 0,nDifTwips ), aTopLeft ); +/*N*/ } + +/*N*/ BOOL ScDrawLayer::HasObjectsInRows( USHORT nTab, USHORT nStartRow, USHORT nEndRow ) +/*N*/ { +/*N*/ DBG_ASSERT( pDoc, "ScDrawLayer::HasObjectsInRows without document" ); +/*N*/ if ( !pDoc ) +/*N*/ return FALSE; +/*N*/ +/*N*/ Rectangle aTestRect; +/*N*/ +/*N*/ USHORT i; +/*N*/ for (i=0; i<nStartRow; i++) +/*N*/ aTestRect.Top() += pDoc->FastGetRowHeight(i,nTab); +/*N*/ +/*N*/ if (nEndRow==MAXROW) +/*N*/ aTestRect.Bottom() = MAXMM; +/*N*/ else +/*N*/ { +/*N*/ aTestRect.Bottom() = aTestRect.Top(); +/*N*/ for (i=nStartRow; i<=nEndRow; i++) +/*N*/ { +/*N*/ aTestRect.Bottom() += pDoc->FastGetRowHeight(i,nTab); +/*N*/ } +/*N*/ TwipsToMM( aTestRect.Bottom() ); +/*N*/ } +/*N*/ +/*N*/ TwipsToMM( aTestRect.Top() ); +/*N*/ +/*N*/ aTestRect.Left() = 0; +/*N*/ aTestRect.Right() = MAXMM; +/*N*/ +/*N*/ SdrPage* pPage = GetPage(nTab); +/*N*/ DBG_ASSERT(pPage,"Page nicht gefunden"); +/*N*/ if (!pPage) +/*N*/ return FALSE; +/*N*/ +/*N*/ BOOL bFound = FALSE; +/*N*/ +/*N*/ Rectangle aObjRect; +/*N*/ SdrObjListIter aIter( *pPage ); +/*N*/ SdrObject* pObject = aIter.Next(); +/*N*/ while ( pObject && !bFound ) +/*N*/ { +/*N*/ aObjRect = pObject->GetSnapRect(); //! GetLogicRect ? +/*N*/ if (aTestRect.IsInside(aObjRect.TopLeft()) || aTestRect.IsInside(aObjRect.BottomLeft())) +/*N*/ bFound = TRUE; +/*N*/ +/*N*/ pObject = aIter.Next(); +/*N*/ } +/*N*/ +/*N*/ return bFound; +/*N*/ } + + + + + + + + +// static + +/*N*/ inline BOOL IsNamedObject( SdrObject* pObj, const String& rName ) +/*N*/ { +/*N*/ // TRUE if rName is the object's Name or PersistName +/*N*/ // (used to find a named object) +/*N*/ +/*N*/ return ( pObj->GetName() == rName || +/*N*/ ( pObj->GetObjIdentifier() == OBJ_OLE2 && +/*N*/ static_cast<SdrOle2Obj*>(pObj)->GetPersistName() == rName ) ); +/*N*/ } + +/*N*/ SdrObject* ScDrawLayer::GetNamedObject( const String& rName, USHORT nId, USHORT& rFoundTab ) const +/*N*/ { +/*N*/ USHORT nTabCount = GetPageCount(); +/*N*/ for (USHORT nTab=0; nTab<nTabCount; nTab++) +/*N*/ { +/*N*/ const SdrPage* pPage = GetPage(nTab); +/*N*/ DBG_ASSERT(pPage,"Page ?"); +/*N*/ if (pPage) +/*N*/ { +/*N*/ SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS ); +/*N*/ SdrObject* pObject = aIter.Next(); +/*N*/ while (pObject) +/*N*/ { +/*N*/ if ( nId == 0 || pObject->GetObjIdentifier() == nId ) +/*N*/ if ( IsNamedObject( pObject, rName ) ) +/*N*/ { +/*N*/ rFoundTab = nTab; +/*N*/ return pObject; +/*N*/ } +/*N*/ +/*N*/ pObject = aIter.Next(); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ return NULL; +/*N*/ } + + + + +/*N*/ void ScDrawLayer::SetAnchor( SdrObject* pObj, ScAnchorType eType ) +/*N*/ { +/*N*/ // Ein an der Seite verankertes Objekt zeichnet sich durch eine Anker-Pos +/*N*/ // von (0,1) aus. Das ist ein shabby Trick, der aber funktioniert! +/*N*/ Point aAnchor( 0, eType == SCA_PAGE ? 1 : 0 ); +/*N*/ pObj->SetAnchorPos( aAnchor ); +/*N*/ } + +/*N*/ ScAnchorType ScDrawLayer::GetAnchor( const SdrObject* pObj ) +/*N*/ { +/*N*/ Point aAnchor( pObj->GetAnchorPos() ); +/*N*/ return ( aAnchor.Y() != 0 ) ? SCA_PAGE : SCA_CELL; +/*N*/ } + +/*N*/ ScDrawObjData* ScDrawLayer::GetObjData( SdrObject* pObj, BOOL bCreate ) // static +/*N*/ { +/*N*/ USHORT nCount = pObj->GetUserDataCount(); +/*N*/ for( USHORT i = 0; i < nCount; i++ ) +/*N*/ { +/*?*/ SdrObjUserData* pData = pObj->GetUserData( i ); +/*?*/ if( pData && pData->GetInventor() == SC_DRAWLAYER +/*?*/ && pData->GetId() == SC_UD_OBJDATA ) +/*?*/ return (ScDrawObjData*) pData; +/*N*/ } +/*N*/ if( bCreate ) +/*N*/ { +/*N*/ ScDrawObjData* pData = new ScDrawObjData; +/*N*/ pObj->InsertUserData( pData, 0 ); +/*N*/ return pData; +/*N*/ } +/*N*/ return NULL; +/*N*/ } + +/*N*/ ScIMapInfo* ScDrawLayer::GetIMapInfo( SdrObject* pObj ) // static +/*N*/ { +/*N*/ USHORT nCount = pObj->GetUserDataCount(); +/*N*/ for( USHORT i = 0; i < nCount; i++ ) +/*N*/ { +/*?*/ SdrObjUserData* pData = pObj->GetUserData( i ); +/*?*/ if( pData && pData->GetInventor() == SC_DRAWLAYER +/*?*/ && pData->GetId() == SC_UD_IMAPDATA ) +/*?*/ return (ScIMapInfo*) pData; +/*N*/ } +/*N*/ return NULL; +/*N*/ } + + +// static: + + +/*N*/ void __EXPORT ScDrawLayer::SetChanged( FASTBOOL bFlg /* =TRUE */ ) +/*N*/ { +/*N*/ if ( bFlg && pDoc ) +/*N*/ pDoc->SetChartListenerCollectionNeedsUpdate( TRUE ); +/*N*/ FmFormModel::SetChanged( bFlg ); +/*N*/ } + +/*N*/ SvStream* __EXPORT ScDrawLayer::GetDocumentStream(SdrDocumentStreamInfo& rStreamInfo) const +/*N*/ { +/*N*/ DBG_ASSERT( pDoc, "ScDrawLayer::GetDocumentStream without document" ); +/*N*/ if ( !pDoc ) +/*N*/ return NULL; +/*N*/ +/*N*/ SvStorage* pStor = pDoc->GetDocumentShell() ? pDoc->GetDocumentShell()->GetMedium()->GetStorage() : NULL; +/*N*/ SvStream* pRet = NULL; +/*N*/ +/*N*/ if( pStor ) +/*N*/ { +/*N*/ if( rStreamInfo.maUserData.Len() && +/*N*/ ( rStreamInfo.maUserData.GetToken( 0, ':' ) == +/*N*/ String( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.Package" ) ) ) ) +/*N*/ { +/*?*/ const String aPicturePath( rStreamInfo.maUserData.GetToken( 1, ':' ) ); +/*?*/ +/*?*/ // graphic from picture stream in picture storage in XML package +/*?*/ if( aPicturePath.GetTokenCount( '/' ) == 2 ) +/*?*/ { +/*?*/ const String aPictureStreamName( aPicturePath.GetToken( 1, '/' ) ); +/*?*/ +/*?*/ if( !xPictureStorage.Is() ) +/*?*/ { +/*?*/ const String aPictureStorageName( aPicturePath.GetToken( 0, '/' ) ); +/*?*/ +/*?*/ if( pStor->IsContained( aPictureStorageName ) && +/*?*/ pStor->IsStorage( aPictureStorageName ) ) +/*?*/ { +/*?*/ ( (ScDrawLayer*) this )->xPictureStorage = pStor->OpenUCBStorage( aPictureStorageName, STREAM_READ | STREAM_WRITE ); +/*?*/ } +/*?*/ } +/*?*/ +/*?*/ if( xPictureStorage.Is() && +/*?*/ xPictureStorage->IsContained( aPictureStreamName ) && +/*?*/ xPictureStorage->IsStream( aPictureStreamName ) ) +/*?*/ { +/*?*/ pRet = xPictureStorage->OpenStream( aPictureStreamName ); +/*?*/ } +/*?*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ pRet = pStor->OpenStream( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(STRING_SCSTREAM)), +/*N*/ STREAM_READ | STREAM_WRITE | STREAM_TRUNC ); +/*N*/ +/*N*/ if( pRet ) +/*N*/ { +/*N*/ pRet->SetVersion( pStor->GetVersion() ); +/*N*/ pRet->SetKey( pStor->GetKey() ); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ rStreamInfo.mbDeleteAfterUse = ( pRet != NULL ); +/*N*/ } +/*N*/ +/*N*/ return pRet; +/*N*/ } + +/*N*/ void ScDrawLayer::ReleasePictureStorage() +/*N*/ { +/*N*/ xPictureStorage.Clear(); +/*N*/ } + + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_fillinfo.cxx b/binfilter/bf_sc/source/core/data/sc_fillinfo.cxx new file mode 100644 index 000000000000..cf5c1802ed1e --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_fillinfo.cxx @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "scitems.hxx" +#include <bf_svx/boxitem.hxx> +#include <bf_svx/shaditem.hxx> + +#include "document.hxx" +#include "cell.hxx" +#include "attarray.hxx" +#include "markdata.hxx" +#include "patattr.hxx" +#include "poolhelp.hxx" +#include "docpool.hxx" +#include "conditio.hxx" +#include "stlpool.hxx" +namespace binfilter { + + +// ----------------------------------------------------------------------- + +enum FillInfoLinePos + { + FILP_TOP, + FILP_BOTTOM, + FILP_LEFT, + FILP_RIGHT + }; + + +/*N*/ inline const SvxBorderLine* GetNullOrLine( const SvxBoxItem* pBox, FillInfoLinePos eWhich ) +/*N*/ { +/*N*/ if (pBox) +/*N*/ { +/*N*/ if (eWhich==FILP_TOP) +/*N*/ return pBox->GetTop(); +/*N*/ else if (eWhich==FILP_BOTTOM) +/*N*/ return pBox->GetBottom(); +/*N*/ else if (eWhich==FILP_LEFT) +/*N*/ return pBox->GetLeft(); +/*N*/ else +/*N*/ return pBox->GetRight(); +/*N*/ } +/*N*/ else +/*N*/ return NULL; +/*N*/ } + +/*N*/ inline BOOL ScDocument::RowHidden( USHORT nRow, USHORT nTab ) +/*N*/ { +/*N*/ return ( pTab[nTab]->pRowFlags[nRow] & CR_HIDDEN ) != 0; +/*N*/ } + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_global.cxx b/binfilter/bf_sc/source/core/data/sc_global.cxx new file mode 100644 index 000000000000..7dd2a41d36ea --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_global.cxx @@ -0,0 +1,787 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "scitems.hxx" +#include <bf_svx/editobj.hxx> +#include <bf_svx/scripttypeitem.hxx> +#include <bf_svx/langitem.hxx> +#include <bf_sfx2/app.hxx> +#include <bf_svtools/zformat.hxx> +#include <vcl/image.hxx> +#include <tools/rcid.h> +#include <vcl/virdev.hxx> +#include <stdlib.h> +#include <time.h> +#include <ctype.h> + + +#include <i18npool/mslangid.hxx> +#include <unotools/intlwrapper.hxx> + +#include "autoform.hxx" +#include "patattr.hxx" +#include "addincol.hxx" +#include "adiasync.hxx" +#include "userlist.hxx" +#include "interpre.hxx" +#include "strload.hxx" +#include "docpool.hxx" +#include "unitconv.hxx" +#include "globstr.hrc" +#include "bf_sc.hrc" +#include <legacysmgr/legacy_binfilters_smgr.hxx> //STRIP002 + +namespace binfilter { +// ----------------------------------------------------------------------- + +#define CLIPST_AVAILABLE 0 +#define CLIPST_CAPTURED 1 +#define CLIPST_DELETE 2 +#define CLIPST_DRAW 3 + +ScDocShellRef* ScGlobal::pDrawClipDocShellRef = NULL; +ScAutoFormat* ScGlobal::pAutoFormat = NULL; +FuncCollection* ScGlobal::pFuncCollection = NULL; +ScUnoAddInCollection* ScGlobal::pAddInCollection = NULL; +ScUserList* ScGlobal::pUserList = NULL; +String** ScGlobal::ppRscString = NULL; +LanguageType ScGlobal::eLnge = LANGUAGE_SYSTEM; +::com::sun::star::lang::Locale* ScGlobal::pLocale = NULL; +SvtSysLocale* ScGlobal::pSysLocale = NULL; +const CharClass* ScGlobal::pCharClass = NULL; +const LocaleDataWrapper* ScGlobal::pLocaleData = NULL; +CalendarWrapper* ScGlobal::pCalendar = NULL; +CollatorWrapper* ScGlobal::pCollator = NULL; +CollatorWrapper* ScGlobal::pCaseCollator = NULL; +::utl::TransliterationWrapper* ScGlobal::pTransliteration = NULL; +::utl::TransliterationWrapper* ScGlobal::pCaseTransliteration = NULL; +IntlWrapper* ScGlobal::pScIntlWrapper = NULL; +sal_Unicode ScGlobal::cListDelimiter = ','; +String* ScGlobal::pEmptyString = NULL; +String* ScGlobal::pStrClipDocName = NULL; + +SvxBrushItem* ScGlobal::pEmptyBrushItem = NULL; +SvxBrushItem* ScGlobal::pButtonBrushItem = NULL; +SvxBrushItem* ScGlobal::pEmbeddedBrushItem = NULL; +SvxBrushItem* ScGlobal::pProtectedBrushItem = NULL; + +ImageList* ScGlobal::pOutlineBitmaps = NULL; +ImageList* ScGlobal::pOutlineBitmapsHC = NULL; + +ScFunctionList* ScGlobal::pStarCalcFunctionList = NULL; +ScFunctionMgr* ScGlobal::pStarCalcFunctionMgr = NULL; + +ScUnitConverter* ScGlobal::pUnitConverter = NULL; +SvNumberFormatter* ScGlobal::pEnglishFormatter = NULL; + +double ScGlobal::nScreenPPTX = 96.0; +double ScGlobal::nScreenPPTY = 96.0; + +USHORT ScGlobal::nDefFontHeight = 240; +USHORT ScGlobal::nStdRowHeight = 257; + +long ScGlobal::nLastRowHeightExtra = 0; +long ScGlobal::nLastColWidthExtra = STD_EXTRA_WIDTH; + +static USHORT nPPTZoom = 0; // ScreenZoom used to determine nScreenPPTX/Y + + +// ... oder so? + +BOOL bOderSo; + +class SfxViewShell; +SfxViewShell* pScActiveViewShell = NULL; //! als Member !!!!! +USHORT nScClickMouseModifier = 0; //! dito +USHORT nScFillModeMouseModifier = 0; //! dito + +// Hack: ScGlobal::GetUserList() muss InitAppOptions in der UI aufrufen, +// damit UserList aus Cfg geladen wird + +void global_InitAppOptions(); + +// ----------------------------------------------------------------------- + +/*N*/ String ScTripel::GetColRowString( BOOL bAbsolute ) const +/*N*/ { +/*N*/ String aString; +/*N*/ if (bAbsolute) +/*N*/ aString.Append( '$' ); +/*N*/ +/*N*/ if ( nCol < 26 ) +/*N*/ aString.Append( (sal_Unicode) ( 'A' + nCol ) ); +/*N*/ else +/*N*/ { +/*N*/ aString.Append( (sal_Unicode) ( 'A' + ( nCol / 26 ) - 1 ) ); +/*N*/ aString.Append( (sal_Unicode) ( 'A' + ( nCol % 26 ) ) ); +/*N*/ } +/*N*/ +/*N*/ if ( bAbsolute ) +/*N*/ aString.Append( '$' ); +/*N*/ +/*N*/ aString += String::CreateFromInt32(nRow+1); +/*N*/ +/*N*/ return aString; +/*N*/ } + +/*N*/ String ScRefTripel::GetRefString(ScDocument* pDoc, USHORT nActTab) const +/*N*/ { +/*N*/ if ( !pDoc ) +/*N*/ return EMPTY_STRING; +/*N*/ if ( nTab+1 > pDoc->GetTableCount() ) +/*N*/ return ScGlobal::GetRscString( STR_NOREF_STR ); +/*N*/ +/*N*/ String aString; +/*N*/ USHORT nFlags = SCA_VALID; +/*N*/ if ( nActTab != nTab ) +/*N*/ { +/*N*/ nFlags |= SCA_TAB_3D; +/*N*/ if ( !bRelTab ) +/*N*/ nFlags |= SCA_TAB_ABSOLUTE; +/*N*/ } +/*N*/ if ( !bRelCol ) +/*N*/ nFlags |= SCA_COL_ABSOLUTE; +/*N*/ if ( !bRelRow ) +/*N*/ nFlags |= SCA_ROW_ABSOLUTE; +/*N*/ +/*N*/ ScAddress( nCol, nRow, nTab ).Format( aString, nFlags, pDoc ); +/*N*/ +/*N*/ return aString; +/*N*/ } + + +//======================================================================== +// +// statische Funktionen +// +//======================================================================== + +/*N*/ BOOL ScGlobal::HasAttrChanged( const SfxItemSet& rNewAttrs, +/*N*/ const SfxItemSet& rOldAttrs, +/*N*/ const USHORT nWhich ) +/*N*/ { +/*N*/ BOOL bInvalidate = FALSE; +/*N*/ const SfxItemState eNewState = rNewAttrs.GetItemState( nWhich ); +/*N*/ const SfxItemState eOldState = rOldAttrs.GetItemState( nWhich ); +/*N*/ +/*N*/ //---------------------------------------------------------- +/*N*/ +/*N*/ if ( eNewState == eOldState ) +/*N*/ { +/*N*/ // beide Items gesetzt +/*N*/ // PoolItems, d.h. Pointer-Vergleich zulaessig +/*N*/ if ( SFX_ITEM_SET == eOldState ) +/*N*/ bInvalidate = (&rNewAttrs.Get( nWhich ) != &rOldAttrs.Get( nWhich )); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ // ein Default-Item dabei +/*N*/ // PoolItems, d.h. Item-Vergleich noetig +/*N*/ +/*N*/ const SfxPoolItem& rOldItem = ( SFX_ITEM_SET == eOldState ) +/*N*/ ? rOldAttrs.Get( nWhich ) +/*N*/ : rOldAttrs.GetPool()->GetDefaultItem( nWhich ); +/*N*/ +/*N*/ const SfxPoolItem& rNewItem = ( SFX_ITEM_SET == eNewState ) +/*N*/ ? rNewAttrs.Get( nWhich ) +/*N*/ : rNewAttrs.GetPool()->GetDefaultItem( nWhich ); +/*N*/ +/*N*/ bInvalidate = (rNewItem != rOldItem); +/*N*/ } +/*N*/ +/*N*/ return bInvalidate; +/*N*/ } + +/*N*/ ULONG ScGlobal::GetStandardFormat( SvNumberFormatter& rFormatter, +/*N*/ ULONG nFormat, short nType ) +/*N*/ { +/*N*/ const SvNumberformat* pFormat = rFormatter.GetEntry( nFormat ); +/*N*/ if ( pFormat ) +/*N*/ return rFormatter.GetStandardFormat( nFormat, nType, pFormat->GetLanguage() ); +/*N*/ return rFormatter.GetStandardFormat( nType, eLnge ); +/*N*/ } + +/*N*/ ULONG ScGlobal::GetStandardFormat( double fNumber, SvNumberFormatter& rFormatter, +/*N*/ ULONG nFormat, short nType ) +/*N*/ { +/*N*/ const SvNumberformat* pFormat = rFormatter.GetEntry( nFormat ); +/*N*/ if ( pFormat ) +/*N*/ return rFormatter.GetStandardFormat( fNumber, nFormat, nType, +/*N*/ pFormat->GetLanguage() ); +/*?*/ return rFormatter.GetStandardFormat( nType, eLnge ); +/*N*/ } + + +// static +/*N*/ SvNumberFormatter* ScGlobal::GetEnglishFormatter() +/*N*/ { +/*N*/ if ( !pEnglishFormatter ) +/*N*/ { +/*N*/ pEnglishFormatter = new SvNumberFormatter( +/*N*/ ::legacy_binfilters::getLegacyProcessServiceFactory(), LANGUAGE_ENGLISH_US ); +/*N*/ pEnglishFormatter->SetEvalDateFormat( NF_EVALDATEFORMAT_INTL_FORMAT ); +/*N*/ } +/*N*/ return pEnglishFormatter; +/*N*/ } + + +//------------------------------------------------------------------------ + +/*N*/ BOOL ScGlobal::CheckWidthInvalidate( BOOL& bNumFormatChanged, +/*N*/ const SfxItemSet& rNewAttrs, +/*N*/ const SfxItemSet& rOldAttrs ) +/*N*/ { +/*N*/ // Ueberpruefen, ob Attributaenderungen in rNewAttrs gegnueber +/*N*/ // rOldAttrs die Textbreite an einer Zelle ungueltig machen +/*N*/ +/*N*/ bNumFormatChanged = +/*N*/ HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_VALUE_FORMAT ); +/*N*/ return ( bNumFormatChanged +/*N*/ || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_LANGUAGE_FORMAT ) +/*N*/ || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_FONT ) +/*N*/ || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_CJK_FONT ) +/*N*/ || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_CTL_FONT ) +/*N*/ || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_FONT_HEIGHT ) +/*N*/ || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_CJK_FONT_HEIGHT ) +/*N*/ || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_CTL_FONT_HEIGHT ) +/*N*/ || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_FONT_WEIGHT ) +/*N*/ || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_CJK_FONT_WEIGHT ) +/*N*/ || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_CTL_FONT_WEIGHT ) +/*N*/ || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_FONT_POSTURE ) +/*N*/ || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_CJK_FONT_POSTURE ) +/*N*/ || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_CTL_FONT_POSTURE ) +/*N*/ || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_FONT_UNDERLINE ) +/*N*/ || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_FONT_CROSSEDOUT ) +/*N*/ || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_FONT_CONTOUR ) +/*N*/ || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_FONT_SHADOWED ) +/*N*/ || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_ORIENTATION ) +/*N*/ || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_ROTATE_VALUE ) +/*N*/ || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_ROTATE_MODE ) +/*N*/ || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_LINEBREAK ) +/*N*/ || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_MARGIN ) +/*N*/ ); +/*N*/ } + + + + +/*N*/ ScAutoFormat* ScGlobal::GetAutoFormat() +/*N*/ { +/*N*/ if ( !pAutoFormat ) +/*N*/ { +/*N*/ pAutoFormat = new ScAutoFormat; +/*N*/ pAutoFormat->Load(); +/*N*/ } +/*N*/ +/*N*/ return pAutoFormat; +/*N*/ } + +/*N*/ FuncCollection* ScGlobal::GetFuncCollection() +/*N*/ { +/*N*/ if (!pFuncCollection) +/*N*/ pFuncCollection = new FuncCollection(); +/*N*/ return pFuncCollection; +/*N*/ } + +/*N*/ ScUnoAddInCollection* ScGlobal::GetAddInCollection() +/*N*/ { +/*N*/ if (!pAddInCollection) +/*N*/ pAddInCollection = new ScUnoAddInCollection(); +/*N*/ return pAddInCollection; +/*N*/ } + +/*N*/ ScUserList* ScGlobal::GetUserList() +/*N*/ { +/*N*/ // Hack: Cfg-Item an der App ggF. laden +/*N*/ +/*N*/ global_InitAppOptions(); +/*N*/ +/*N*/ if (!pUserList) +/*N*/ pUserList = new ScUserList(); +/*N*/ return pUserList; +/*N*/ } + +/*N*/ void ScGlobal::SetUserList( const ScUserList* pNewList ) +/*N*/ { +/*N*/ if ( pNewList ) +/*N*/ { +/*N*/ if ( !pUserList ) +/*N*/ pUserList = new ScUserList( *pNewList ); +/*N*/ else +/*?*/ *pUserList = *pNewList; +/*N*/ } +/*N*/ else +/*N*/ { +/*?*/ delete pUserList; +/*?*/ pUserList = NULL; +/*N*/ } +/*N*/ } + +/*N*/ const String& ScGlobal::GetRscString( USHORT nIndex ) +/*N*/ { +/*N*/ DBG_ASSERT( nIndex <= STR_COUNT, +/*N*/ "-ScGlobal::GetRscString(): Index zu gross!"); +/*N*/ if( !ppRscString[ nIndex ] ) +/*N*/ { +/*N*/ ppRscString[ nIndex ] = +/*N*/ new String( ScRscStrLoader( RID_GLOBSTR, nIndex ).GetString() ); +/*N*/ } +/*N*/ return *ppRscString[ nIndex ]; +/*N*/ } + +/*N*/ String ScGlobal::GetErrorString(USHORT nErrNumber) +/*N*/ { +/*N*/ String sResStr; +/*N*/ switch (nErrNumber) +/*N*/ { +/*N*/ case NOVALUE : nErrNumber = STR_NV_STR; break; +/*N*/ case errNoRef : nErrNumber = STR_NO_REF_TABLE; break; +/*N*/ case errNoName : nErrNumber = STR_NO_NAME_REF; break; +/*N*/ case errNoAddin : nErrNumber = STR_NO_ADDIN; break; +/*N*/ case errNoMacro : nErrNumber = STR_NO_MACRO; break; +/*N*/ case errDoubleRef: +/*N*/ case errNoValue : nErrNumber = STR_NO_VALUE; break; +/*N*/ +/*N*/ default : sResStr = GetRscString(STR_ERROR_STR); +/*N*/ sResStr += String::CreateFromInt32( nErrNumber ); +/*N*/ nErrNumber = 0; +/*N*/ break; +/*N*/ } +/*N*/ if( nErrNumber ) +/*N*/ sResStr = GetRscString( nErrNumber ); +/*N*/ return sResStr; +/*N*/ } + +/*N*/ const String& ScGlobal::GetEmptyString() +/*N*/ { +/*N*/ return *pEmptyString; +/*N*/ } + + +/*N*/ void ScGlobal::Init() +/*N*/ { +/*N*/ pEmptyString = new String; +/*N*/ +/*N*/ // Die Default-Sprache fuer Zahlenformate (ScGlobal::eLnge) +/*N*/ // muss immer LANGUAGE_SYSTEM sein +/*N*/ //! Dann kann auch die Variable raus +/*N*/ eLnge = LANGUAGE_SYSTEM; +/*N*/ +/*N*/ //! Wenn Sortierung etc. von der Sprache der installierten Offfice-Version +/*N*/ //! abhaengen sollen, hier "Application::GetSettings().GetUILanguage()" +/*N*/ String aLanguage, aCountry; +/*N*/ LanguageType eOfficeLanguage = Application::GetSettings().GetLanguage(); +/*N*/ pLocale = new ::com::sun::star::lang::Locale( MsLangId::convertLanguageToLocale( eOfficeLanguage )); +/*N*/ pSysLocale = new SvtSysLocale; +/*N*/ pCharClass = pSysLocale->GetCharClassPtr(); +/*N*/ pLocaleData = pSysLocale->GetLocaleDataPtr(); +/*N*/ pCalendar = new CalendarWrapper( ::legacy_binfilters::getLegacyProcessServiceFactory() ); +/*N*/ pCalendar->loadDefaultCalendar( *pLocale ); +/*N*/ pCollator = new CollatorWrapper( ::legacy_binfilters::getLegacyProcessServiceFactory() ); +/*N*/ pCollator->loadDefaultCollator( *pLocale, SC_COLLATOR_IGNORES ); +/*N*/ pCaseCollator = new CollatorWrapper( ::legacy_binfilters::getLegacyProcessServiceFactory() ); +/*N*/ pCaseCollator->loadDefaultCollator( *pLocale, 0 ); +/*N*/ pTransliteration = new ::utl::TransliterationWrapper( +/*N*/ ::legacy_binfilters::getLegacyProcessServiceFactory(), SC_TRANSLITERATION_IGNORECASE ); +/*N*/ pTransliteration->loadModuleIfNeeded( eOfficeLanguage ); +/*N*/ pCaseTransliteration = new ::utl::TransliterationWrapper( +/*N*/ ::legacy_binfilters::getLegacyProcessServiceFactory(), SC_TRANSLITERATION_CASESENSE ); +/*N*/ pCaseTransliteration->loadModuleIfNeeded( eOfficeLanguage ); +/*N*/ pScIntlWrapper = new IntlWrapper( ::legacy_binfilters::getLegacyProcessServiceFactory(), *pLocale ); +/*N*/ +/*N*/ ppRscString = new String *[ STR_COUNT+1 ]; +/*N*/ for( USHORT nC = 0 ; nC <= STR_COUNT ; nC++ ) ppRscString[ nC ] = NULL; +/*N*/ +/*N*/ pEmptyBrushItem = new SvxBrushItem( Color( COL_TRANSPARENT ) ); +/*N*/ pButtonBrushItem = new SvxBrushItem( Color() ); +/*N*/ pEmbeddedBrushItem = new SvxBrushItem( Color( COL_LIGHTCYAN ) ); +/*N*/ pProtectedBrushItem = new SvxBrushItem( Color( COL_LIGHTGRAY ) ); +/*N*/ +/*N*/ UpdatePPT(NULL); +/*N*/ ScCompiler::Init(); +/*N*/ srand( (unsigned) time( NULL ) ); // Random Seed Init fuer Interpreter +/*N*/ +/*N*/ InitAddIns(); +/*N*/ +/*N*/ pStrClipDocName = new String( ScResId( SCSTR_NONAME ) ); +/*N*/ *pStrClipDocName += '1'; +/*N*/ +/*N*/ // ScDocumentPool::InitVersionMaps() ist schon vorher gerufen worden +/*N*/ } + +/*N*/ void ScGlobal::UpdatePPT( OutputDevice* pDev ) +/*N*/ { +/*N*/ USHORT nCurrentZoom = Application::GetSettings().GetStyleSettings().GetScreenZoom(); +/*N*/ if ( nCurrentZoom != nPPTZoom ) +/*N*/ { +/*N*/ // Screen PPT values must be updated when ScreenZoom has changed. +/*N*/ // If called from Window::DataChanged, the window is passed as pDev, +/*N*/ // to make sure LogicToPixel uses a device which already uses the new zoom. +/*N*/ // For the initial settings, NULL is passed and GetDefaultDevice used. +/*N*/ +/*N*/ if ( !pDev ) +/*N*/ pDev = Application::GetDefaultDevice(); +/*N*/ Point aPix1000 = pDev->LogicToPixel( Point(1000,1000), MAP_TWIP ); +/*N*/ nScreenPPTX = aPix1000.X() / 1000.0; +/*N*/ nScreenPPTY = aPix1000.Y() / 1000.0; +/*N*/ nPPTZoom = nCurrentZoom; +/*N*/ } +/*N*/ } + + + + +/*N*/ void ScGlobal::InitTextHeight(SfxItemPool* pPool) +/*N*/ { +/*N*/ if (!pPool) +/*N*/ { +/*?*/ DBG_ERROR("kein Pool bei ScGlobal::InitTextHeight"); +/*?*/ return; +/*N*/ } +/*N*/ +/*N*/ const ScPatternAttr* pPattern = (const ScPatternAttr*)&pPool->GetDefaultItem(ATTR_PATTERN); +/*N*/ if (!pPattern) +/*N*/ { +/*?*/ DBG_ERROR("kein Default-Pattern bei ScGlobal::InitTextHeight"); +/*?*/ return; +/*N*/ } +/*N*/ +/*N*/ // String aTestString('X'); +/*N*/ OutputDevice* pDefaultDev = Application::GetDefaultDevice(); +/*N*/ VirtualDevice aVirtWindow( *pDefaultDev ); +/*N*/ aVirtWindow.SetMapMode(MAP_PIXEL); +/*N*/ Font aDefFont; +/*N*/ pPattern->GetFont(aDefFont, SC_AUTOCOL_BLACK, &aVirtWindow); // font color doesn't matter here +/*N*/ aVirtWindow.SetFont(aDefFont); +/*N*/ nDefFontHeight = (USHORT) aVirtWindow.PixelToLogic(Size(0, aVirtWindow.GetTextHeight()), +/*N*/ MAP_TWIP).Height(); +/*N*/ +/*N*/ const SvxMarginItem* pMargin = (const SvxMarginItem*)&pPattern->GetItem(ATTR_MARGIN); +/*N*/ +/*N*/ nStdRowHeight = (USHORT) ( nDefFontHeight + +/*N*/ pMargin->GetTopMargin() + pMargin->GetBottomMargin() +/*N*/ - STD_ROWHEIGHT_DIFF ); +/*N*/ } + +/*N*/ void ScGlobal::Clear() +/*N*/ { +/*N*/ // asyncs _vor_ ExitExternalFunc zerstoeren! +/*N*/ theAddInAsyncTbl.DeleteAndDestroy( 0, theAddInAsyncTbl.Count() ); +/*N*/ ExitExternalFunc(); +/*N*/ DELETEZ(pAutoFormat); +/*N*/ DELETEZ(pFuncCollection); +/*N*/ DELETEZ(pAddInCollection); +/*N*/ DELETEZ(pUserList); +/*N*/ +/*N*/ for( USHORT nC = 0 ; nC < STR_COUNT ; nC++ ) +/*N*/ if( ppRscString ) delete ppRscString[ nC ]; +/*N*/ delete[] ppRscString; +/*N*/ ppRscString = NULL; +/*N*/ +/*N*/ DELETEZ(pStarCalcFunctionList); // vor ResMgr zerstoeren! +/*N*/ DELETEZ(pStarCalcFunctionMgr); +/*N*/ ScCompiler::DeInit(); +/*N*/ ScInterpreter::GlobalExit(); // statischen Stack loeschen +/*N*/ +/*N*/ DELETEZ(pEmptyBrushItem); +/*N*/ DELETEZ(pButtonBrushItem); +/*N*/ DELETEZ(pEmbeddedBrushItem); +/*N*/ DELETEZ(pProtectedBrushItem); +/*N*/ DELETEZ(pOutlineBitmaps); +/*N*/ DELETEZ(pOutlineBitmapsHC); +/*N*/ // DELETEZ(pAnchorBitmap); +/*N*/ // DELETEZ(pGrayAnchorBitmap); +/*N*/ DELETEZ(pEnglishFormatter); +/*N*/ DELETEZ(pCaseTransliteration); +/*N*/ DELETEZ(pTransliteration); +/*N*/ DELETEZ(pCaseCollator); +/*N*/ DELETEZ(pCollator); +/*N*/ DELETEZ(pCalendar); +/*N*/ //! do NOT delete pCharClass since it is a pointer to the single SvtSysLocale instance +/*N*/ pCharClass = NULL; +/*N*/ //! do NOT delete pLocaleData since it is a pointer to the single SvtSysLocale instance +/*N*/ pLocaleData = NULL; +/*N*/ DELETEZ(pSysLocale); +/*N*/ DELETEZ(pLocale); +/*N*/ DELETEZ(pScIntlWrapper); +/*N*/ DELETEZ(pStrClipDocName); +/*N*/ +/*N*/ DELETEZ(pUnitConverter); +/*N*/ +/*N*/ ScDocumentPool::DeleteVersionMaps(); +/*N*/ +/*N*/ DELETEZ(pEmptyString); +/*N*/ } + +//------------------------------------------------------------------------ + +// static +/*N*/ CharSet ScGlobal::GetCharsetValue( const String& rCharSet ) +/*N*/ { +/*N*/ // new TextEncoding values +/*N*/ if ( CharClass::isAsciiNumeric( rCharSet ) ) +/*N*/ { +/*?*/ sal_Int32 nVal = rCharSet.ToInt32(); +/*?*/ if ( !nVal || nVal == RTL_TEXTENCODING_DONTKNOW ) +/*?*/ return gsl_getSystemTextEncoding(); +/*?*/ return (CharSet) nVal; +/*N*/ } +/*N*/ // old CharSet values for compatibility +/*N*/ else if (rCharSet.EqualsIgnoreCaseAscii("ANSI") ) return RTL_TEXTENCODING_MS_1252; +/*N*/ else if (rCharSet.EqualsIgnoreCaseAscii("MAC") ) return RTL_TEXTENCODING_APPLE_ROMAN; +/*N*/ else if (rCharSet.EqualsIgnoreCaseAscii("IBMPC") ) return RTL_TEXTENCODING_IBM_850; +/*N*/ else if (rCharSet.EqualsIgnoreCaseAscii("IBMPC_437")) return RTL_TEXTENCODING_IBM_437; +/*N*/ else if (rCharSet.EqualsIgnoreCaseAscii("IBMPC_850")) return RTL_TEXTENCODING_IBM_850; +/*N*/ else if (rCharSet.EqualsIgnoreCaseAscii("IBMPC_860")) return RTL_TEXTENCODING_IBM_860; +/*N*/ else if (rCharSet.EqualsIgnoreCaseAscii("IBMPC_861")) return RTL_TEXTENCODING_IBM_861; +/*N*/ else if (rCharSet.EqualsIgnoreCaseAscii("IBMPC_863")) return RTL_TEXTENCODING_IBM_863; +/*N*/ else if (rCharSet.EqualsIgnoreCaseAscii("IBMPC_865")) return RTL_TEXTENCODING_IBM_865; +/*N*/ // else if (rCharSet.EqualsIgnoreCaseAscii("SYSTEM") ) return gsl_getSystemTextEncoding(); +/*N*/ else return gsl_getSystemTextEncoding(); +/*N*/ } + +//------------------------------------------------------------------------ + +// static +/*N*/ String ScGlobal::GetCharsetString( CharSet eVal ) +/*N*/ { +/*N*/ const sal_Char* pChar; +/*N*/ switch ( eVal ) +/*N*/ { +/*N*/ // old CharSet strings for compatibility +/*N*/ case RTL_TEXTENCODING_MS_1252: pChar = "ANSI"; break; +/*N*/ case RTL_TEXTENCODING_APPLE_ROMAN: pChar = "MAC"; break; +/*N*/ // IBMPC == IBMPC_850 +/*N*/ case RTL_TEXTENCODING_IBM_437: pChar = "IBMPC_437"; break; +/*N*/ case RTL_TEXTENCODING_IBM_850: pChar = "IBMPC_850"; break; +/*N*/ case RTL_TEXTENCODING_IBM_860: pChar = "IBMPC_860"; break; +/*N*/ case RTL_TEXTENCODING_IBM_861: pChar = "IBMPC_861"; break; +/*N*/ case RTL_TEXTENCODING_IBM_863: pChar = "IBMPC_863"; break; +/*N*/ case RTL_TEXTENCODING_IBM_865: pChar = "IBMPC_865"; break; +/*N*/ case RTL_TEXTENCODING_DONTKNOW: pChar = "SYSTEM"; break; +/*N*/ // new string of TextEncoding value +/*N*/ default: +/*N*/ return String::CreateFromInt32( eVal ); +/*N*/ } +/*N*/ return String::CreateFromAscii(pChar); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ ScFunctionList* ScGlobal::GetStarCalcFunctionList() +/*N*/ { +/*N*/ if ( !pStarCalcFunctionList ) +/*N*/ pStarCalcFunctionList = new ScFunctionList; +/*N*/ +/*N*/ return pStarCalcFunctionList; +/*N*/ } + +// static +/*N*/ ScUnitConverter* ScGlobal::GetUnitConverter() +/*N*/ { +/*N*/ if ( !pUnitConverter ) +/*N*/ pUnitConverter = new ScUnitConverter; +/*N*/ +/*N*/ return pUnitConverter; +/*N*/ } + + +//------------------------------------------------------------------------ + +// static +/*N*/ const sal_Unicode* ScGlobal::UnicodeStrChr( const sal_Unicode* pStr, +/*N*/ sal_Unicode c ) +/*N*/ { +/*N*/ if ( !pStr ) +/*N*/ return NULL; +/*N*/ while ( *pStr ) +/*N*/ { +/*N*/ if ( *pStr == c ) +/*N*/ return pStr; +/*N*/ pStr++; +/*N*/ } +/*N*/ return NULL; +/*N*/ } + + +//------------------------------------------------------------------------ + +/*N*/ BOOL ScGlobal::EETextObjEqual( const EditTextObject* pObj1, +/*N*/ const EditTextObject* pObj2 ) +/*N*/ { +/*N*/ if ( pObj1 == pObj2 ) // both empty or the same object +/*N*/ return TRUE; +/*N*/ +/*N*/ if ( pObj1 && pObj2 ) +/*N*/ { +/*N*/ // first test for equal text content +/*N*/ USHORT nParCount = pObj1->GetParagraphCount(); +/*N*/ if ( nParCount != pObj2->GetParagraphCount() ) +/*N*/ return FALSE; +/*N*/ for (USHORT nPar=0; nPar<nParCount; nPar++) +/*N*/ if ( pObj1->GetText(nPar) != pObj2->GetText(nPar) ) +/*N*/ return FALSE; +/*N*/ +/*N*/ SvMemoryStream aStream1; +/*N*/ SvMemoryStream aStream2; +/*N*/ pObj1->Store( aStream1 ); +/*N*/ pObj2->Store( aStream2 ); +/*N*/ ULONG nSize = aStream1.Tell(); +/*N*/ if ( aStream2.Tell() == nSize ) +/*N*/ if ( !memcmp( aStream1.GetData(), aStream2.GetData(), (USHORT) nSize ) ) +/*N*/ return TRUE; +/*N*/ } +/*N*/ +/*N*/ return FALSE; +/*N*/ } + + +//------------------------------------------------------------------------ + +/*N*/ BYTE ScGlobal::GetDefaultScriptType() +/*N*/ { +/*N*/ // Used when text contains only WEAK characters. +/*N*/ // Script type of office language is used then (same as GetEditDefaultLanguage, +/*N*/ // to get consistent behavior of text in simple cells and EditEngine, +/*N*/ // also same as GetAppLanguage() in Writer) +/*N*/ +/*N*/ return (BYTE) SvtLanguageOptions::GetScriptTypeOfLanguage( Application::GetSettings().GetLanguage() ); +/*N*/ } + +/*N*/ LanguageType ScGlobal::GetEditDefaultLanguage() +/*N*/ { +/*N*/ // used for EditEngine::SetDefaultLanguage +/*N*/ +/*N*/ return Application::GetSettings().GetLanguage(); +/*N*/ } + + +//------------------------------------------------------------------------ + +/*N*/ void ScGlobal::AddLanguage( SfxItemSet& rSet, SvNumberFormatter& rFormatter ) +/*N*/ { +/*N*/ DBG_ASSERT( rSet.GetItemState( ATTR_LANGUAGE_FORMAT, FALSE ) == SFX_ITEM_DEFAULT, +/*N*/ "ScGlobal::AddLanguage - language already added"); +/*N*/ +/*N*/ const SfxPoolItem* pHardItem; +/*N*/ if ( rSet.GetItemState( ATTR_VALUE_FORMAT, FALSE, &pHardItem ) == SFX_ITEM_SET ) +/*N*/ { +/*N*/ const SvNumberformat* pHardFormat = rFormatter.GetEntry( +/*N*/ ((const SfxUInt32Item*)pHardItem)->GetValue() ); +/*N*/ +/*N*/ ULONG nParentFmt = 0; // pool default +/*N*/ const SfxItemSet* pParent = rSet.GetParent(); +/*N*/ if ( pParent ) +/*N*/ nParentFmt = ((const SfxUInt32Item&)pParent->Get( ATTR_VALUE_FORMAT )).GetValue(); +/*N*/ const SvNumberformat* pParFormat = rFormatter.GetEntry( nParentFmt ); +/*N*/ +/*N*/ if ( pHardFormat && pParFormat && +/*N*/ (pHardFormat->GetLanguage() != pParFormat->GetLanguage()) ) +/*N*/ rSet.Put( SvxLanguageItem( pHardFormat->GetLanguage(), ATTR_LANGUAGE_FORMAT ) ); +/*N*/ } +/*N*/ } + + +/*N*/ ScFunctionList::ScFunctionList() : +/*N*/ nMaxFuncNameLen ( 0 ) +/*N*/ { +/*N*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 ScFuncDesc* pDesc = NULL; +} + +//------------------------------------------------------------------------ + +/*N*/ ScFunctionList::~ScFunctionList() +/*N*/ { +/*N*/ ScFuncDesc* pDesc = (ScFuncDesc*)aFunctionList.First(); +/*N*/ while (pDesc) +/*N*/ { +/*N*/ delete pDesc; +/*N*/ pDesc = (ScFuncDesc*)aFunctionList.Next(); +/*N*/ } +/*N*/ } + + +//======================================================================== +// class ScFuncDesc: + +/*N*/ ScFuncDesc::~ScFuncDesc() +/*N*/ { +/*N*/ USHORT nArgs; +/*N*/ +/*N*/ nArgs = nArgCount; +/*N*/ if (nArgs >= VAR_ARGS) nArgs -= VAR_ARGS-1; +/*N*/ if (nArgs) +/*N*/ { +/*?*/ for (USHORT i=0; i<nArgs; i++ ) +/*?*/ { +/*?*/ delete aDefArgNames[i]; +/*?*/ delete aDefArgDescs[i]; +/*?*/ } +/*?*/ delete [] aDefArgNames; +/*?*/ delete [] aDefArgDescs; +/*?*/ delete [] aDefArgOpt; +/*N*/ } +/*N*/ if(pFuncName) +/*?*/ delete pFuncName; +/*N*/ +/*N*/ if(pFuncDesc) +/*?*/ delete pFuncDesc; +/*N*/ } + +//======================================================================== +// class ScFunctionMgr: + +/*N*/ ScFunctionMgr::~ScFunctionMgr() +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 for (USHORT i = 0; i < MAX_FUNCCAT; i++) +/*N*/ } + +/*N*/ String ColToAlpha( const USHORT nCol ) +/*N*/ { +/*N*/ String aStr; +/*N*/ +/*N*/ if ( nCol < 26 ) +/*N*/ aStr = (sal_Unicode) ( 'A' + nCol ); +/*N*/ else +/*N*/ { +/*N*/ aStr = (sal_Unicode) ( 'A' + ( nCol / 26 ) - 1 ); +/*N*/ aStr += (sal_Unicode) ( 'A' + ( nCol % 26 ) ); +/*N*/ } +/*N*/ +/*N*/ return aStr; +/*N*/ } + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_global2.cxx b/binfilter/bf_sc/source/core/data/sc_global2.cxx new file mode 100644 index 000000000000..00ac5ccf003f --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_global2.cxx @@ -0,0 +1,1393 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include <bf_sfx2/docfile.hxx> +#include <bf_sfx2/objsh.hxx> +#include <unotools/textsearch.hxx> +#include <bf_svtools/pathoptions.hxx> +#include <bf_svtools/useroptions.hxx> +#include <tools/urlobj.hxx> +#include <stdlib.h> +#include <ctype.h> + +#include <bf_svtools/syslocale.hxx> + +#include "document.hxx" +#include "rangeutl.hxx" +#include "pivot.hxx" +#include "rechead.hxx" +#include "compiler.hxx" + +#include "bf_sc.hrc" +#include "globstr.hrc" +namespace binfilter { + + +// ----------------------------------------------------------------------- + + + +#define MAX_LABELS 256 //!!! aus fieldwnd.hxx, muss noch nach global.hxx ??? + +//------------------------------------------------------------------------ +// struct ScImportParam: + +/*N*/ ScImportParam::ScImportParam() : +/*N*/ nCol1(0), +/*N*/ nRow1(0), +/*N*/ nCol2(0), +/*N*/ nRow2(0), +/*N*/ bImport(FALSE), +/*N*/ bNative(FALSE), +/*N*/ bSql(TRUE), +/*N*/ nType(ScDbTable) +/*N*/ { +/*N*/ } + +/*N*/ ScImportParam::ScImportParam( const ScImportParam& r ) : +/*N*/ nCol1 (r.nCol1), +/*N*/ nRow1 (r.nRow1), +/*N*/ nCol2 (r.nCol2), +/*N*/ nRow2 (r.nRow2), +/*N*/ bImport (r.bImport), +/*N*/ aDBName (r.aDBName), +/*N*/ aStatement (r.aStatement), +/*N*/ bNative (r.bNative), +/*N*/ bSql (r.bSql), +/*N*/ nType (r.nType) +/*N*/ { +/*N*/ } + +/*N*/ ScImportParam::~ScImportParam() +/*N*/ { +/*N*/ } + + +/*N*/ ScImportParam& ScImportParam::operator=( const ScImportParam& r ) +/*N*/ { +/*N*/ nCol1 = r.nCol1; +/*N*/ nRow1 = r.nRow1; +/*N*/ nCol2 = r.nCol2; +/*N*/ nRow2 = r.nRow2; +/*N*/ bImport = r.bImport; +/*N*/ aDBName = r.aDBName; +/*N*/ aStatement = r.aStatement; +/*N*/ bNative = r.bNative; +/*N*/ bSql = r.bSql; +/*N*/ nType = r.nType; +/*N*/ +/*N*/ return *this; +/*N*/ } + + + +//------------------------------------------------------------------------ +// struct ScQueryParam: + +/*N*/ ScQueryEntry::ScQueryEntry() +/*N*/ { +/*N*/ bDoQuery = FALSE; +/*N*/ bQueryByString = FALSE; +/*N*/ eOp = SC_EQUAL; +/*N*/ eConnect = SC_AND; +/*N*/ nField = 0; +/*N*/ nVal = 0.0; +/*N*/ pStr = new String; +/*N*/ pSearchParam = NULL; +/*N*/ pSearchText = NULL; +/*N*/ } + +/*N*/ ScQueryEntry::ScQueryEntry(const ScQueryEntry& r) +/*N*/ { +/*N*/ bDoQuery = r.bDoQuery; +/*N*/ bQueryByString = r.bQueryByString; +/*N*/ eOp = r.eOp; +/*N*/ eConnect = r.eConnect; +/*N*/ nField = r.nField; +/*N*/ nVal = r.nVal; +/*N*/ pStr = new String(*r.pStr); +/*N*/ pSearchParam = NULL; +/*N*/ pSearchText = NULL; +/*N*/ } + +/*N*/ ScQueryEntry::~ScQueryEntry() +/*N*/ { +/*N*/ delete pStr; +/*N*/ if ( pSearchParam ) +/*N*/ { +/*N*/ delete pSearchParam; +/*N*/ delete pSearchText; +/*N*/ } +/*N*/ } + +/*N*/ ScQueryEntry& ScQueryEntry::operator=( const ScQueryEntry& r ) +/*N*/ { +/*N*/ bDoQuery = r.bDoQuery; +/*N*/ bQueryByString = r.bQueryByString; +/*N*/ eOp = r.eOp; +/*N*/ eConnect = r.eConnect; +/*N*/ nField = r.nField; +/*N*/ nVal = r.nVal; +/*N*/ *pStr = *r.pStr; +/*N*/ if ( pSearchParam ) +/*N*/ { +/*?*/ delete pSearchParam; +/*?*/ delete pSearchText; +/*N*/ } +/*N*/ pSearchParam = NULL; +/*N*/ pSearchText = NULL; +/*N*/ +/*N*/ return *this; +/*N*/ } + +/*N*/ void ScQueryEntry::Clear() +/*N*/ { +/*N*/ bDoQuery = FALSE; +/*N*/ bQueryByString = FALSE; +/*N*/ eOp = SC_EQUAL; +/*N*/ eConnect = SC_AND; +/*N*/ nField = 0; +/*N*/ nVal = 0.0; +/*N*/ pStr->Erase(); +/*N*/ if ( pSearchParam ) +/*N*/ { +/*?*/ delete pSearchParam; +/*?*/ delete pSearchText; +/*N*/ } +/*N*/ pSearchParam = NULL; +/*N*/ pSearchText = NULL; +/*N*/ } + +/*N*/ BOOL ScQueryEntry::operator==( const ScQueryEntry& r ) const +/*N*/ { +/*N*/ return bDoQuery == r.bDoQuery +/*N*/ && bQueryByString == r.bQueryByString +/*N*/ && eOp == r.eOp +/*N*/ && eConnect == r.eConnect +/*N*/ && nField == r.nField +/*N*/ && nVal == r.nVal +/*N*/ && *pStr == *r.pStr; +/*N*/ //! pSearchParam und pSearchText nicht vergleichen +/*N*/ } +/*N*/ +/*N*/ void ScQueryEntry::Load( SvStream& rStream ) +/*N*/ { +/*N*/ BYTE cOp, cConnect; +/*N*/ rStream >> bDoQuery +/*N*/ >> bQueryByString +/*N*/ >> cOp +/*N*/ >> cConnect +/*N*/ >> nField +/*N*/ >> nVal; +/*N*/ rStream.ReadByteString( *pStr, rStream.GetStreamCharSet() ); +/*N*/ eOp = (ScQueryOp) cOp; +/*N*/ eConnect = (ScQueryConnect) cConnect; +/*N*/ } +/*N*/ +/*N*/ void ScQueryEntry::Store( SvStream& rStream ) const +/*N*/ { +/*N*/ rStream << bDoQuery +/*N*/ << bQueryByString +/*N*/ << (BYTE) eOp +/*N*/ << (BYTE) eConnect +/*N*/ << nField +/*N*/ << nVal; +/*N*/ rStream.WriteByteString( *pStr, rStream.GetStreamCharSet() ); +/*N*/ } + +/*N*/ ::utl::TextSearch* ScQueryEntry::GetSearchTextPtr( BOOL bCaseSens ) +/*N*/ { +/*N*/ if ( !pSearchParam ) +/*N*/ { +/*N*/ pSearchParam = new ::utl::SearchParam( *pStr, utl::SearchParam::SRCH_REGEXP, +/*N*/ bCaseSens, FALSE, FALSE ); +/*N*/ pSearchText = new ::utl::TextSearch( *pSearchParam, *ScGlobal::pCharClass ); +/*N*/ } +/*N*/ return pSearchText; +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ ScQueryParam::ScQueryParam() +/*N*/ { +/*N*/ nEntryCount = 0; +/*N*/ Clear(); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ ScQueryParam::ScQueryParam( const ScQueryParam& r ) : +/*N*/ nCol1(r.nCol1),nRow1(r.nRow1),nCol2(r.nCol2),nRow2(r.nRow2),nTab(r.nTab), +/*N*/ nDestTab(r.nDestTab),nDestCol(r.nDestCol),nDestRow(r.nDestRow), +/*N*/ bHasHeader(r.bHasHeader),bInplace(r.bInplace),bCaseSens(r.bCaseSens), +/*N*/ bRegExp(r.bRegExp),bDuplicate(r.bDuplicate),bByRow(r.bByRow), +/*N*/ bDestPers(r.bDestPers) +/*N*/ { +/*N*/ nEntryCount = 0; +/*N*/ +/*N*/ Resize( r.nEntryCount ); +/*N*/ for (USHORT i=0; i<nEntryCount; i++) +/*N*/ pEntries[i] = r.pEntries[i]; +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ ScQueryParam::~ScQueryParam() +/*N*/ { +/*N*/ delete[] pEntries; +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ void ScQueryParam::Clear() +/*N*/ { +/*N*/ nCol1=nRow1=nCol2=nRow2= +/*N*/ nDestTab=nDestCol=nDestRow = 0; +/*N*/ nTab = USHRT_MAX; +/*N*/ bHasHeader=bCaseSens=bRegExp = FALSE; +/*N*/ bInplace=bByRow=bDuplicate=bDestPers = TRUE; +/*N*/ +/*N*/ Resize( MAXQUERY ); +/*N*/ for (USHORT i=0; i<MAXQUERY; i++) +/*N*/ pEntries[i].Clear(); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ ScQueryParam& ScQueryParam::operator=( const ScQueryParam& r ) +/*N*/ { +/*N*/ nCol1 = r.nCol1; +/*N*/ nRow1 = r.nRow1; +/*N*/ nCol2 = r.nCol2; +/*N*/ nRow2 = r.nRow2; +/*N*/ nTab = r.nTab; +/*N*/ nDestTab = r.nDestTab; +/*N*/ nDestCol = r.nDestCol; +/*N*/ nDestRow = r.nDestRow; +/*N*/ bHasHeader = r.bHasHeader; +/*N*/ bInplace = r.bInplace; +/*N*/ bCaseSens = r.bCaseSens; +/*N*/ bRegExp = r.bRegExp; +/*N*/ bDuplicate = r.bDuplicate; +/*N*/ bByRow = r.bByRow; +/*N*/ bDestPers = r.bDestPers; +/*N*/ +/*N*/ Resize( r.nEntryCount ); +/*N*/ for (USHORT i=0; i<nEntryCount; i++) +/*N*/ pEntries[i] = r.pEntries[i]; +/*N*/ +/*N*/ return *this; +/*N*/ } + +//------------------------------------------------------------------------ + +BOOL ScQueryParam::operator==( const ScQueryParam& rOther ) const +{ + BOOL bEqual = FALSE; + + // Anzahl der Queries gleich? + DBG_BF_ASSERT(0, "STRIP"); //STRIP001 USHORT nUsed = 0; + return bEqual; +} + +//------------------------------------------------------------------------ + + +//------------------------------------------------------------------------ + +/*N*/ void ScQueryParam::Resize(USHORT nNew) +/*N*/ { +/*N*/ if ( nNew < MAXQUERY ) +/*N*/ nNew = MAXQUERY; // nie weniger als MAXQUERY +/*N*/ +/*N*/ ScQueryEntry* pNewEntries = NULL; +/*N*/ if ( nNew ) +/*N*/ pNewEntries = new ScQueryEntry[nNew]; +/*N*/ +/*N*/ USHORT nCopy = Min( nEntryCount, nNew ); +/*N*/ for (USHORT i=0; i<nCopy; i++) +/*N*/ pNewEntries[i] = pEntries[i]; +/*N*/ +/*N*/ if ( nEntryCount ) +/*N*/ delete[] pEntries; +/*N*/ nEntryCount = nNew; +/*N*/ pEntries = pNewEntries; +/*N*/ } + +//------------------------------------------------------------------------ + + +//------------------------------------------------------------------------ + +/*N*/ void ScQueryParam::FillInExcelSyntax(String& aCellStr, USHORT nIndex) +/*N*/ { +/*N*/ if (aCellStr.Len() > 0) +/*N*/ { +/*N*/ if ( nIndex >= nEntryCount ) +/*N*/ Resize( nIndex+1 ); +/*N*/ +/*N*/ ScQueryEntry& rEntry = pEntries[nIndex]; +/*N*/ +/*N*/ rEntry.bDoQuery = TRUE; +/*N*/ // Operatoren herausfiltern +/*N*/ if (aCellStr.GetChar(0) == '<') +/*N*/ { +/*N*/ if (aCellStr.GetChar(1) == '>') +/*N*/ { +/*N*/ *rEntry.pStr = aCellStr.Copy(2); +/*N*/ rEntry.eOp = SC_NOT_EQUAL; +/*N*/ } +/*N*/ else if (aCellStr.GetChar(1) == '=') +/*N*/ { +/*N*/ *rEntry.pStr = aCellStr.Copy(2); +/*N*/ rEntry.eOp = SC_LESS_EQUAL; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ *rEntry.pStr = aCellStr.Copy(1); +/*N*/ rEntry.eOp = SC_LESS; +/*N*/ } +/*N*/ } +/*N*/ else if (aCellStr.GetChar(0) == '>') +/*N*/ { +/*N*/ if (aCellStr.GetChar(1) == '=') +/*N*/ { +/*N*/ *rEntry.pStr = aCellStr.Copy(2); +/*N*/ rEntry.eOp = SC_GREATER_EQUAL; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ *rEntry.pStr = aCellStr.Copy(1); +/*N*/ rEntry.eOp = SC_GREATER; +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ if (aCellStr.GetChar(0) == '=') +/*N*/ *rEntry.pStr = aCellStr.Copy(1); +/*N*/ else +/*N*/ *rEntry.pStr = aCellStr; +/*N*/ rEntry.eOp = SC_EQUAL; +/*N*/ } +/*N*/ } +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ void ScQueryParam::Load( SvStream& rStream ) // z.B. fuer Pivot-Tabelle +/*N*/ { +/*N*/ // bDestPers wird nicht geladen/gespeichert +/*N*/ +/*N*/ ScReadHeader aHdr( rStream ); +/*N*/ +/*N*/ rStream >> nCol1 +/*N*/ >> nRow1 +/*N*/ >> nCol2 +/*N*/ >> nRow2 +/*N*/ >> nDestTab +/*N*/ >> nDestCol +/*N*/ >> nDestRow +/*N*/ >> bHasHeader +/*N*/ >> bInplace +/*N*/ >> bCaseSens +/*N*/ >> bRegExp +/*N*/ >> bDuplicate +/*N*/ >> bByRow; +/*N*/ +/*N*/ Resize( MAXQUERY ); +/*N*/ +/*N*/ for (USHORT i=0; i<MAXQUERY; i++) +/*N*/ pEntries[i].Load(rStream); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ void ScQueryParam::Store( SvStream& rStream ) const // z.B. fuer Pivot-Tabelle +/*N*/ { +/*N*/ // bDestPers wird nicht geladen/gespeichert +/*N*/ +/*N*/ ScWriteHeader aHdr( rStream ); +/*N*/ +/*N*/ DBG_ASSERT( nEntryCount <= MAXQUERY || !pEntries[MAXQUERY].bDoQuery, +/*N*/ "zuviele Eintraege bei ScQueryParam::Store" ); +/*N*/ +/*N*/ +/*N*/ if ( nEntryCount < MAXQUERY ) +/*N*/ { +/*N*/ DBG_ERROR("ScQueryParam::Store - zuwenig Eintraege"); +/*N*/ ((ScQueryParam*)this)->Resize( MAXQUERY ); +/*N*/ } +/*N*/ +/*N*/ rStream << nCol1 +/*N*/ << nRow1 +/*N*/ << nCol2 +/*N*/ << nRow2 +/*N*/ << nDestTab +/*N*/ << nDestCol +/*N*/ << nDestRow +/*N*/ << bHasHeader +/*N*/ << bInplace +/*N*/ << bCaseSens +/*N*/ << bRegExp +/*N*/ << bDuplicate +/*N*/ << bByRow; +/*N*/ +/*N*/ for (USHORT i=0; i<MAXQUERY; i++) +/*N*/ pEntries[i].Store(rStream); +/*N*/ } + +//------------------------------------------------------------------------ +// struct ScSubTotalParam: + +/*N*/ ScSubTotalParam::ScSubTotalParam() +/*N*/ { +/*N*/ for ( USHORT i=0; i<MAXSUBTOTAL; i++ ) +/*N*/ { +/*N*/ nSubTotals[i] = 0; +/*N*/ pSubTotals[i] = NULL; +/*N*/ pFunctions[i] = NULL; +/*N*/ } +/*N*/ +/*N*/ Clear(); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ ScSubTotalParam::ScSubTotalParam( const ScSubTotalParam& r ) : +/*N*/ nCol1(r.nCol1),nRow1(r.nRow1),nCol2(r.nCol2),nRow2(r.nRow2), +/*N*/ bReplace(r.bReplace),bPagebreak(r.bPagebreak),bCaseSens(r.bCaseSens), +/*N*/ bDoSort(r.bDoSort),bAscending(r.bAscending),bUserDef(r.bUserDef),nUserIndex(r.nUserIndex), +/*N*/ bIncludePattern(r.bIncludePattern),bRemoveOnly(r.bRemoveOnly) +/*N*/ { +/*N*/ for (USHORT i=0; i<MAXSUBTOTAL; i++) +/*N*/ { +/*N*/ bGroupActive[i] = r.bGroupActive[i]; +/*N*/ nField[i] = r.nField[i]; +/*N*/ +/*N*/ if ( (r.nSubTotals[i] > 0) && r.pSubTotals[i] && r.pFunctions[i] ) +/*N*/ { +/*N*/ nSubTotals[i] = r.nSubTotals[i]; +/*N*/ pSubTotals[i] = new USHORT [r.nSubTotals[i]]; +/*N*/ pFunctions[i] = new ScSubTotalFunc [r.nSubTotals[i]]; +/*N*/ +/*N*/ for (USHORT j=0; j<r.nSubTotals[i]; j++) +/*N*/ { +/*N*/ pSubTotals[i][j] = r.pSubTotals[i][j]; +/*N*/ pFunctions[i][j] = r.pFunctions[i][j]; +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ nSubTotals[i] = 0; +/*N*/ pSubTotals[i] = NULL; +/*N*/ pFunctions[i] = NULL; +/*N*/ } +/*N*/ } +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ void ScSubTotalParam::Clear() +/*N*/ { +/*N*/ nCol1=nRow1=nCol2=nRow2=nUserIndex = 0; +/*N*/ bPagebreak=bCaseSens=bUserDef=bIncludePattern=bRemoveOnly = FALSE; +/*N*/ bAscending=bReplace=bDoSort = TRUE; +/*N*/ +/*N*/ USHORT i=0; +/*N*/ for ( i=0; i<MAXSUBTOTAL; i++) +/*N*/ { +/*N*/ bGroupActive[i] = FALSE; +/*N*/ nField[i] = 0; +/*N*/ +/*N*/ if ( (nSubTotals[i] > 0) && pSubTotals[i] && pFunctions[i] ) +/*N*/ { +/*?*/ USHORT j=0; +/*?*/ for ( j=0; j<nSubTotals[i]; j++ ) +/*?*/ pSubTotals[i][j] = 0; +/*?*/ pFunctions[i][j] = SUBTOTAL_FUNC_NONE; +/*N*/ } +/*N*/ } +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ ScSubTotalParam& ScSubTotalParam::operator=( const ScSubTotalParam& r ) +/*N*/ { +/*N*/ nCol1 = r.nCol1; +/*N*/ nRow1 = r.nRow1; +/*N*/ nCol2 = r.nCol2; +/*N*/ nRow2 = r.nRow2; +/*N*/ bRemoveOnly = r.bRemoveOnly; +/*N*/ bReplace = r.bReplace; +/*N*/ bPagebreak = r.bPagebreak; +/*N*/ bCaseSens = r.bCaseSens; +/*N*/ bDoSort = r.bDoSort; +/*N*/ bAscending = r.bAscending; +/*N*/ bUserDef = r.bUserDef; +/*N*/ nUserIndex = r.nUserIndex; +/*N*/ bIncludePattern = r.bIncludePattern; +/*N*/ +/*N*/ for (USHORT i=0; i<MAXSUBTOTAL; i++) +/*N*/ { +/*N*/ bGroupActive[i] = r.bGroupActive[i]; +/*N*/ nField[i] = r.nField[i]; +/*N*/ nSubTotals[i] = r.nSubTotals[i]; +/*N*/ +/*N*/ if ( pSubTotals[i] ) delete [] pSubTotals[i]; +/*N*/ if ( pFunctions[i] ) delete [] pFunctions[i]; +/*N*/ +/*N*/ if ( r.nSubTotals[i] > 0 ) +/*N*/ { +/*N*/ pSubTotals[i] = new USHORT [r.nSubTotals[i]]; +/*N*/ pFunctions[i] = new ScSubTotalFunc [r.nSubTotals[i]]; +/*N*/ +/*N*/ for (USHORT j=0; j<r.nSubTotals[i]; j++) +/*N*/ { +/*N*/ pSubTotals[i][j] = r.pSubTotals[i][j]; +/*N*/ pFunctions[i][j] = r.pFunctions[i][j]; +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ nSubTotals[i] = 0; +/*N*/ pSubTotals[i] = NULL; +/*N*/ pFunctions[i] = NULL; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ return *this; +/*N*/ } + +//------------------------------------------------------------------------ + + +//------------------------------------------------------------------------ + + +//------------------------------------------------------------------------ +// struct ScConsolidateParam: + +/*N*/ ScConsolidateParam::ScConsolidateParam() : +/*N*/ ppDataAreas( NULL ) +/*N*/ { +/*N*/ Clear(); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ ScConsolidateParam::ScConsolidateParam( const ScConsolidateParam& r ) : +/*N*/ ppDataAreas( NULL ), +/*N*/ nCol(r.nCol),nRow(r.nRow),nTab(r.nTab), +/*N*/ bByCol(r.bByCol),bByRow(r.bByRow),bReferenceData(r.bReferenceData), +/*N*/ nDataAreaCount(0),eFunction(r.eFunction) +/*N*/ { +/*N*/ if ( r.nDataAreaCount > 0 ) +/*N*/ { +/*N*/ nDataAreaCount = r.nDataAreaCount; +/*N*/ ppDataAreas = new ScArea*[nDataAreaCount]; +/*N*/ for ( USHORT i=0; i<nDataAreaCount; i++ ) +/*N*/ ppDataAreas[i] = new ScArea( *(r.ppDataAreas[i]) ); +/*N*/ } +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ __EXPORT ScConsolidateParam::~ScConsolidateParam() +/*N*/ { +/*N*/ ClearDataAreas(); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ void __EXPORT ScConsolidateParam::ClearDataAreas() +/*N*/ { +/*N*/ if ( ppDataAreas ) +/*N*/ { +/*?*/ for ( USHORT i=0; i<nDataAreaCount; i++ ) +/*?*/ delete ppDataAreas[i]; +/*?*/ delete [] ppDataAreas; +/*?*/ ppDataAreas = NULL; +/*N*/ } +/*N*/ nDataAreaCount = 0; +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ void __EXPORT ScConsolidateParam::Clear() +/*N*/ { +/*N*/ ClearDataAreas(); +/*N*/ +/*N*/ nCol = nRow = nTab = 0; +/*N*/ bByCol = bByRow = bReferenceData = FALSE; +/*N*/ eFunction = SUBTOTAL_FUNC_SUM; +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ ScConsolidateParam& __EXPORT ScConsolidateParam::operator=( const ScConsolidateParam& r ) +/*N*/ { +/*N*/ nCol = r.nCol; +/*N*/ nRow = r.nRow; +/*N*/ nTab = r.nTab; +/*N*/ bByCol = r.bByCol; +/*N*/ bByRow = r.bByRow; +/*N*/ bReferenceData = r.bReferenceData; +/*N*/ eFunction = r.eFunction; +/*N*/ SetAreas( r.ppDataAreas, r.nDataAreaCount ); +/*N*/ +/*N*/ return *this; +/*N*/ } + +//------------------------------------------------------------------------ + + +//------------------------------------------------------------------------ + +/*N*/ void __EXPORT ScConsolidateParam::SetAreas( ScArea* const* ppAreas, USHORT nCount ) +/*N*/ { +/*N*/ ClearDataAreas(); +/*N*/ if ( ppAreas && nCount > 0 ) +/*N*/ { +/*N*/ ppDataAreas = new ScArea*[nCount]; +/*N*/ for ( USHORT i=0; i<nCount; i++ ) +/*N*/ ppDataAreas[i] = new ScArea( *(ppAreas[i]) ); +/*N*/ nDataAreaCount = nCount; +/*N*/ } +/*N*/ } + +/*N*/ void ScConsolidateParam::Load( SvStream& rStream ) +/*N*/ { +/*N#116571#*/ ClearDataAreas(); +/*N#116571#*/ +/*N#116571#*/ ScReadHeader aHdr( rStream ); +/*N#116571#*/ +/*N#116571#*/ BYTE nByte; +/*N#116571#*/ rStream >> nCol >> nRow >> nTab +/*N#116571#*/ >> bByCol >> bByRow >> bReferenceData >> nByte; +/*N#116571#*/ eFunction = (ScSubTotalFunc) nByte; +/*N#116571#*/ +/*N#116571#*/ rStream >> nDataAreaCount; +/*N#116571#*/ if ( nDataAreaCount ) +/*N#116571#*/ { +/*N#116571#*/ ppDataAreas = new ScArea*[nDataAreaCount]; +/*N#116571#*/ for ( USHORT i=0; i<nDataAreaCount; i++ ) +/*N#116571#*/ { +/*N#116571#*/ ppDataAreas[i] = new ScArea(); +/*N#116571#*/ rStream >> *ppDataAreas[i]; +/*N#116571#*/ } +/*N#116571#*/ } +/*N*/ } + +/*N*/ void ScConsolidateParam::Store( SvStream& rStream ) const +/*N*/ { +/*N#116571#*/ ScWriteHeader aHdr( rStream, 12+10*nDataAreaCount ); +/*N#116571#*/ +/*N#116571#*/ rStream << nCol << nRow << nTab +/*N#116571#*/ << bByCol << bByRow << bReferenceData << (BYTE) eFunction; +/*N#116571#*/ +/*N#116571#*/ rStream << nDataAreaCount; +/*N#116571#*/ for (USHORT i=0; i<nDataAreaCount; i++) +/*N#116571#*/ rStream << *ppDataAreas[i]; +/*N*/ } + +//------------------------------------------------------------------------ +// struct ScPivotParam: + +/*N*/ ScPivotParam::ScPivotParam() +/*N*/ : nCol(0), nRow(0), nTab(0), +/*N*/ ppLabelArr( NULL ), nLabels(0), +/*N*/ nColCount(0), nRowCount(0), nDataCount(0), +/*N*/ bIgnoreEmptyRows(FALSE), bDetectCategories(FALSE), +/*N*/ bMakeTotalCol(TRUE), bMakeTotalRow(TRUE) +/*N*/ { +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ ScPivotParam::ScPivotParam( const ScPivotParam& r ) +/*N*/ : nCol( r.nCol ), nRow( r.nRow ), nTab( r.nTab ), +/*N*/ bIgnoreEmptyRows(r.bIgnoreEmptyRows), +/*N*/ bDetectCategories(r.bDetectCategories), +/*N*/ bMakeTotalCol(r.bMakeTotalCol), +/*N*/ bMakeTotalRow(r.bMakeTotalRow), +/*N*/ ppLabelArr( NULL ), nLabels(0), +/*N*/ nColCount(0), nRowCount(0), nDataCount(0) +/*N*/ { +/*N*/ SetLabelData ( r.ppLabelArr, r.nLabels ); +/*N*/ SetPivotArrays ( r.aColArr, r.aRowArr, r.aDataArr, +/*N*/ r.nColCount, r.nRowCount, r.nDataCount ); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ __EXPORT ScPivotParam::~ScPivotParam() +/*N*/ { +/*N*/ ClearLabelData(); +/*N*/ } + +//------------------------------------------------------------------------ + + +//------------------------------------------------------------------------ + +/*N*/ void __EXPORT ScPivotParam::ClearLabelData() +/*N*/ { +/*N*/ if ( (nLabels > 0) && ppLabelArr ) +/*N*/ { +/*N*/ for ( USHORT i=0; i<nLabels; i++ ) +/*N*/ delete ppLabelArr[i]; +/*N*/ delete [] ppLabelArr; +/*N*/ ppLabelArr = NULL; +/*N*/ nLabels = 0; +/*N*/ } +/*N*/ } + +//------------------------------------------------------------------------ + + +//------------------------------------------------------------------------ + +/*N*/ void __EXPORT ScPivotParam::SetLabelData( LabelData** pLabArr, +/*N*/ USHORT nLab ) +/*N*/ { +/*N*/ ClearLabelData(); +/*N*/ +/*N*/ if ( (nLab > 0) && pLabArr ) +/*N*/ { +/*N*/ nLabels = (nLab>MAX_LABELS) ? MAX_LABELS : nLab; +/*N*/ ppLabelArr = new LabelData*[nLabels]; +/*N*/ for ( USHORT i=0; i<nLabels; i++ ) +/*N*/ ppLabelArr[i] = new LabelData( *(pLabArr[i]) ); +/*N*/ } +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ void __EXPORT ScPivotParam::SetPivotArrays ( const PivotField* pColArr, +/*N*/ const PivotField* pRowArr, +/*N*/ const PivotField* pDataArr, +/*N*/ USHORT nColCnt, +/*N*/ USHORT nRowCnt, +/*N*/ USHORT nDataCnt ) +/*N*/ { +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 ClearPivotArrays(); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ ScPivotParam& __EXPORT ScPivotParam::operator=( const ScPivotParam& r ) +/*N*/ { +/*N*/ nCol = r.nCol; +/*N*/ nRow = r.nRow; +/*N*/ nTab = r.nTab; +/*N*/ bIgnoreEmptyRows = r.bIgnoreEmptyRows; +/*N*/ bDetectCategories = r.bDetectCategories; +/*N*/ bMakeTotalCol = r.bMakeTotalCol; +/*N*/ bMakeTotalRow = r.bMakeTotalRow; +/*N*/ +/*N*/ SetLabelData ( r.ppLabelArr, r.nLabels ); +/*N*/ SetPivotArrays ( r.aColArr, r.aRowArr, r.aDataArr, +/*N*/ r.nColCount, r.nRowCount, r.nDataCount ); +/*N*/ +/*N*/ return *this; +/*N*/ } + +//------------------------------------------------------------------------ + + +//------------------------------------------------------------------------ +// struct ScSolveParam + +/*N*/ ScSolveParam::ScSolveParam() +/*N*/ : pStrTargetVal( NULL ) +/*N*/ { +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ ScSolveParam::ScSolveParam( const ScSolveParam& r ) +/*N*/ : aRefFormulaCell ( r.aRefFormulaCell ), +/*N*/ aRefVariableCell( r.aRefVariableCell ), +/*N*/ pStrTargetVal ( r.pStrTargetVal +/*N*/ ? new String(*r.pStrTargetVal) +/*N*/ : NULL ) +/*N*/ { +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ ScSolveParam::~ScSolveParam() +/*N*/ { +/*N*/ delete pStrTargetVal; +/*N*/ } + +//------------------------------------------------------------------------ + + +//------------------------------------------------------------------------ + + + +//------------------------------------------------------------------------ +// struct ScTabOpParam + +/*N*/ ScTabOpParam::ScTabOpParam( const ScTabOpParam& r ) +/*N*/ : aRefFormulaCell ( r.aRefFormulaCell ), +/*N*/ aRefFormulaEnd ( r.aRefFormulaEnd ), +/*N*/ aRefRowCell ( r.aRefRowCell ), +/*N*/ aRefColCell ( r.aRefColCell ), +/*N*/ nMode ( r.nMode ) +/*N*/ { +/*N*/ } + +//------------------------------------------------------------------------ + +//======================================================================== +// class ScPostIt +//======================================================================== + +/*N*/ ScPostIt::ScPostIt() +/*N*/ { +/*N*/ bShown = FALSE; +/*N*/ } + +/*N*/ ScPostIt::ScPostIt( const String& rText, const String& rDate, const String& rAuthor ) +/*N*/ : aStrText ( rText ), +/*N*/ aStrDate ( rDate ), +/*N*/ aStrAuthor ( rAuthor ) +/*N*/ { +/*N*/ bShown = FALSE; +/*N*/ } + +/*N*/ ScPostIt::ScPostIt( const ScPostIt& rCpy ) +/*N*/ : aStrText ( rCpy.aStrText ), +/*N*/ aStrDate ( rCpy.aStrDate ), +/*N*/ aStrAuthor ( rCpy.aStrAuthor ) +/*N*/ { +/*N*/ bShown = rCpy.bShown; +/*N*/ } + +/*N*/ __EXPORT ScPostIt::~ScPostIt() +/*N*/ { +/*N*/ } + +/*N*/ void ScPostIt::AutoSetText( const String& rNewText ) +/*N*/ { +/*N*/ aStrText = rNewText; +/*N*/ aStrDate = ScGlobal::pLocaleData->getDate( Date() ); +/*N*/ +/*N*/ // Der Einheitlichkeit halber das Datum immer ohne Uhrzeit (wie im Writer) +/*N*/ // aStrDate += ", "; +/*N*/ // aStrDate += ScGlobal::pLocaleData->getTime( Time() ); +/*N*/ +/*N*/ SvtUserOptions aUserOpt; +/*N*/ aStrAuthor = aUserOpt.GetID(); +/*N*/ } + +//======================================================================== + +/*N*/ String ScGlobal::GetAbsDocName( const String& rFileName, +/*N*/ SfxObjectShell* pShell ) +/*N*/ { +/*N*/ String aAbsName; +/*N*/ if ( !pShell->HasName() ) +/*N*/ { // maybe relative to document path working directory +/*N*/ INetURLObject aObj; +/*N*/ SvtPathOptions aPathOpt; +/*N*/ aObj.SetSmartURL( aPathOpt.GetWorkPath() ); +/*N*/ aObj.setFinalSlash(); // it IS a path +/*N*/ bool bWasAbs = true; +/*N*/ aAbsName = aObj.smartRel2Abs( rFileName, bWasAbs ).GetMainURL(INetURLObject::NO_DECODE); +/*N*/ // returned string must be encoded because it's used directly to create SfxMedium +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ const SfxMedium* pMedium = pShell->GetMedium(); +/*N*/ if ( pMedium ) +/*N*/ { +/*N*/ bool bWasAbs = true; +/*N*/ aAbsName = pMedium->GetURLObject().smartRel2Abs( rFileName, bWasAbs ).GetMainURL(INetURLObject::NO_DECODE); +/*N*/ } +/*N*/ else +/*N*/ { // This can't happen, but ... +/*?*/ // just to be sure to have the same encoding +/*?*/ INetURLObject aObj; +/*?*/ aObj.SetSmartURL( aAbsName ); +/*?*/ aAbsName = aObj.GetMainURL(INetURLObject::NO_DECODE); +/*N*/ } +/*N*/ } +/*N*/ return aAbsName; +/*N*/ } + + +/*N*/ String ScGlobal::GetDocTabName( const String& rFileName, +/*N*/ const String& rTabName ) +/*N*/ { +/*N*/ String aDocTab( '\'' ); +/*N*/ aDocTab += rFileName; +/*N*/ xub_StrLen nPos = 1; +/*N*/ while( (nPos = aDocTab.Search( '\'', nPos )) +/*N*/ != STRING_NOTFOUND ) +/*N*/ { // escape Quotes +/*N*/ aDocTab.Insert( '\\', nPos ); +/*N*/ nPos += 2; +/*N*/ } +/*N*/ aDocTab += '\''; +/*N*/ aDocTab += SC_COMPILER_FILE_TAB_SEP; +/*N*/ aDocTab += rTabName; // "'Doc'#Tab" +/*N*/ return aDocTab; +/*N*/ } + + +/*N*/ USHORT lcl_ConvertSingleRef( BOOL& bExternal, const sal_Unicode* p, +/*N*/ ScDocument* pDoc, ScAddress& rAddr ) +/*N*/ { +/*N*/ if ( !*p ) +/*N*/ return 0; +/*N*/ USHORT nRes = 0; +/*N*/ String aDocName; // der pure Dokumentenname +/*N*/ String aDocTab; // zusammengesetzt fuer Table +/*N*/ String aTab; +/*N*/ BOOL bExtDoc = FALSE; +/*N*/ BOOL bNeedExtTab = FALSE; +/*N*/ +/*N*/ if ( *p == '\'' && ScGlobal::UnicodeStrChr( p, SC_COMPILER_FILE_TAB_SEP ) ) +/*N*/ { +/*?*/ BOOL bQuote = TRUE; // Dokumentenname ist immer quoted +/*?*/ aDocTab += *p++; +/*?*/ while ( bQuote && *p ) +/*?*/ { +/*?*/ if ( *p == '\'' && *(p-1) != '\\' ) +/*?*/ bQuote = FALSE; +/*?*/ else if( !(*p == '\\' && *(p+1) == '\'') ) +/*?*/ aDocName += *p; // falls escaped Quote: nur Quote in den Namen +/*?*/ aDocTab += *p++; +/*?*/ } +/*?*/ aDocTab += *p; // den SC_COMPILER_FILE_TAB_SEP mitnehmen +/*?*/ if( *p++ == SC_COMPILER_FILE_TAB_SEP ) +/*?*/ bExtDoc = TRUE; +/*?*/ else +/*?*/ return nRes; +/*N*/ } +/*N*/ +/*N*/ USHORT nCol = 0; +/*N*/ USHORT nRow = 0; +/*N*/ USHORT nTab = 0; +/*N*/ USHORT nBits = SCA_VALID_TAB; +/*N*/ const sal_Unicode* q; +/*N*/ if ( ScGlobal::UnicodeStrChr( p, '.') ) +/*N*/ { +/*N*/ nRes |= SCA_TAB_3D; +/*N*/ if ( bExtDoc ) +/*N*/ nRes |= SCA_TAB_ABSOLUTE; +/*N*/ if (*p == '$') +/*N*/ nRes |= SCA_TAB_ABSOLUTE, p++; +/*N*/ BOOL bQuote = FALSE; +/*N*/ if( *p == '\'' ) +/*N*/ p++, bQuote = TRUE; +/*N*/ while (*p && (*p != '.')) +/*N*/ { +/*N*/ if( bQuote && *p == '\'' ) +/*N*/ { +/*N*/ p++; break; +/*N*/ } +/*N*/ aTab += *p++; +/*N*/ } +/*N*/ if( *p++ != '.' ) +/*N*/ nBits = 0; +/*N*/ if ( pDoc ) +/*N*/ { +/*N*/ if ( bExtDoc ) +/*N*/ { +/*N*/ bExternal = TRUE; +/*N*/ aDocTab += aTab; // "'Doc'#Tab" +/*N*/ if ( !pDoc->GetTable( aDocTab, nTab ) ) +/*N*/ { +/*N*/ if ( pDoc->ValidTabName( aTab ) ) +/*N*/ { +/*N*/ aDocName = ScGlobal::GetAbsDocName( aDocName, +/*N*/ pDoc->GetDocumentShell() ); +/*N*/ aDocTab = ScGlobal::GetDocTabName( aDocName, aTab ); +/*N*/ if ( !pDoc->GetTable( aDocTab, nTab ) ) +/*N*/ { +/*N*/ // erst einfuegen, wenn Rest der Ref ok +/*N*/ bNeedExtTab = TRUE; +/*N*/ nBits = 0; +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ nBits = 0; +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ if ( !pDoc->GetTable( aTab, nTab ) ) +/*N*/ nBits = 0; +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ nBits = 0; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ if ( bExtDoc ) +/*N*/ return nRes; // nach Dokument muss Tabelle folgen +/*N*/ nTab = rAddr.Tab(); +/*N*/ } +/*N*/ nRes |= nBits; +/*N*/ +/*N*/ q = p; +/*N*/ if (*p) +/*N*/ { +/*N*/ nBits = SCA_VALID_COL; +/*N*/ if (*p == '$') +/*N*/ nBits |= SCA_COL_ABSOLUTE, p++; +/*N*/ if( CharClass::isAsciiAlpha( *p ) ) +/*N*/ nCol = toupper( char(*p++) ) - 'A'; +/*N*/ else +/*N*/ nBits = 0; +/*N*/ if( CharClass::isAsciiAlpha( *p ) ) +/*N*/ nCol = ((nCol + 1) * 26) + (toupper( char(*p++) ) - 'A'); +/*N*/ if( nCol > MAXCOL ) +/*N*/ nBits = 0; +/*N*/ while( CharClass::isAsciiAlpha( *p ) ) +/*N*/ p++, nBits = 0; +/*N*/ nRes |= nBits; +/*N*/ if( !nBits ) +/*N*/ p = q; +/*N*/ } +/*N*/ +/*N*/ q = p; +/*N*/ if (*p) +/*N*/ { +/*N*/ nBits = SCA_VALID_ROW; +/*N*/ if (*p == '$') +/*N*/ nBits |= SCA_ROW_ABSOLUTE, p++; +/*N*/ if( !CharClass::isAsciiDigit( *p ) ) +/*N*/ { +/*N*/ nBits = 0; +/*N*/ nRow = USHORT(-1); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ String aTmp( p ); +/*N*/ long n = aTmp.ToInt32() - 1; +/*N*/ while (CharClass::isAsciiDigit( *p )) +/*N*/ p++; +/*N*/ if( n < 0 || n > MAXROW ) +/*N*/ nBits = 0; +/*N*/ nRow = (USHORT) n; +/*N*/ } +/*N*/ nRes |= nBits; +/*N*/ if( !nBits ) +/*N*/ p = q; +/*N*/ } +/*N*/ if ( bNeedExtTab ) +/*N*/ { +/*N*/ if ( (nRes & SCA_VALID_ROW) && (nRes & SCA_VALID_COL) +/*N*/ && pDoc->LinkExternalTab( nTab, aDocTab, aDocName, aTab ) ) +/*N*/ { +/*N*/ nRes |= SCA_VALID_TAB; +/*N*/ } +/*N*/ else +/*N*/ nRes = 0; // #NAME? statt #REF!, Dateiname bleibt erhalten +/*N*/ } +/*N*/ if ( !(nRes & SCA_VALID_ROW) && (nRes & SCA_VALID_COL) +/*N*/ && !( (nRes & SCA_TAB_3D) && (nRes & SCA_VALID_TAB)) ) +/*N*/ { // keine Row, keine Tab, aber Col => DM (...), B (...) o.ae. +/*N*/ nRes = 0; +/*N*/ } +/*N*/ if( !*p ) +/*N*/ { +/*N*/ USHORT nMask = nRes & ( SCA_VALID_ROW | SCA_VALID_COL | SCA_VALID_TAB ); +/*N*/ if( nMask == ( SCA_VALID_ROW | SCA_VALID_COL | SCA_VALID_TAB ) ) +/*N*/ nRes |= SCA_VALID; +/*N*/ } +/*N*/ else +/*N*/ nRes = 0; +/*N*/ rAddr.Set( nCol, nRow, nTab ); +/*N*/ return nRes; +/*N*/ } + + +// ConvertSingleRef mit sal_Unicode* muss vorher stehen!!! + +/*N*/ BOOL ConvertSingleRef( ScDocument* pDoc, const String& rRefString, +/*N*/ USHORT nDefTab, ScRefTripel& rRefTripel ) +/*N*/ { +/*N*/ BOOL bExternal = FALSE; +/*N*/ ScAddress aAddr( 0, 0, nDefTab ); +/*N*/ USHORT nRes = lcl_ConvertSingleRef( bExternal, rRefString.GetBuffer(), pDoc, aAddr ); +/*N*/ if( nRes & SCA_VALID ) +/*N*/ { +/*N*/ rRefTripel.Put( aAddr.Col(), aAddr.Row(), aAddr.Tab(), +/*N*/ BOOL( ( nRes & SCA_COL_ABSOLUTE ) == 0 ), +/*N*/ BOOL( ( nRes & SCA_ROW_ABSOLUTE ) == 0 ), +/*N*/ BOOL( ( nRes & SCA_TAB_ABSOLUTE ) == 0 ) ); +/*N*/ return TRUE; +/*N*/ } +/*N*/ else +/*N*/ return FALSE; +/*N*/ } + + +/*N*/ BOOL ConvertDoubleRef( ScDocument* pDoc, const String& rRefString, USHORT nDefTab, +/*N*/ ScRefTripel& rStartRefTripel, ScRefTripel& rEndRefTripel ) +/*N*/ { +/*N*/ BOOL bRet = FALSE; +/*N*/ xub_StrLen nPos = rRefString.Search(':'); +/*N*/ if (nPos != STRING_NOTFOUND) +/*N*/ { +/*N*/ String aTmp( rRefString ); +/*N*/ sal_Unicode* p = aTmp.GetBufferAccess(); +/*N*/ p[ nPos ] = 0; +/*N*/ if ( ConvertSingleRef( pDoc, p, nDefTab, rStartRefTripel ) ) +/*N*/ { +/*N*/ nDefTab = rStartRefTripel.GetTab(); +/*N*/ bRet = ConvertSingleRef( pDoc, p + nPos + 1, nDefTab, rEndRefTripel ); +/*N*/ } +/*N*/ } +/*N*/ return bRet; +/*N*/ } + + +/*N*/ USHORT ScAddress::Parse( const String& r, ScDocument* pDoc ) +/*N*/ { +/*N*/ BOOL bExternal = FALSE; +/*N*/ return lcl_ConvertSingleRef( bExternal, r.GetBuffer(), pDoc, *this ); +/*N*/ } + +/*N*/ BOOL ScRange::Intersects( const ScRange& r ) const +/*N*/ { +/*N*/ return !( +/*N*/ Min( aEnd.Col(), r.aEnd.Col() ) < Max( aStart.Col(), r.aStart.Col() ) +/*N*/ || Min( aEnd.Row(), r.aEnd.Row() ) < Max( aStart.Row(), r.aStart.Row() ) +/*N*/ || Min( aEnd.Tab(), r.aEnd.Tab() ) < Max( aStart.Tab(), r.aStart.Tab() ) +/*N*/ ); +/*N*/ } + +/*N*/ void ScRange::Justify() +/*N*/ { +/*N*/ USHORT nTemp; +/*N*/ if ( aEnd.Col() < (nTemp = aStart.Col()) ) +/*N*/ { +/*?*/ aStart.SetCol(aEnd.Col()); aEnd.SetCol(nTemp); +/*N*/ } +/*N*/ if ( aEnd.Row() < (nTemp = aStart.Row()) ) +/*N*/ { +/*?*/ aStart.SetRow(aEnd.Row()); aEnd.SetRow(nTemp); +/*N*/ } +/*N*/ if ( aEnd.Tab() < (nTemp = aStart.Tab()) ) +/*N*/ { +/*?*/ aStart.SetTab(aEnd.Tab()); aEnd.SetTab(nTemp); +/*N*/ } +/*N*/ } + + +/*N*/ USHORT ScRange::Parse( const String& r, ScDocument* pDoc ) +/*N*/ { +/*N*/ USHORT nRes1 = 0, nRes2 = 0; +/*N*/ xub_StrLen nTmp = 0; +/*N*/ xub_StrLen nPos = STRING_NOTFOUND; +/*N*/ while ( (nTmp = r.Search( ':', nTmp )) != STRING_NOTFOUND ) +/*N*/ nPos = nTmp++; // der letzte zaehlt, koennte 'd:\...'!a1:a2 sein +/*N*/ if (nPos != STRING_NOTFOUND) +/*N*/ { +/*N*/ String aTmp( r ); +/*N*/ sal_Unicode* p = aTmp.GetBufferAccess(); +/*N*/ p[ nPos ] = 0; +/*N*/ BOOL bExternal = FALSE; +/*N*/ if( nRes1 = lcl_ConvertSingleRef( bExternal, p, pDoc, aStart ) ) +/*N*/ { +/*N*/ aEnd = aStart; // die Tab _muss_ gleich sein, so ist`s weniger Code +/*N*/ if ( nRes2 = lcl_ConvertSingleRef( bExternal, p + nPos+ 1, pDoc, aEnd ) ) +/*N*/ { +/*N*/ if ( bExternal && aStart.Tab() != aEnd.Tab() ) +/*N*/ nRes2 &= ~SCA_VALID_TAB; // #REF! +/*N*/ else +/*N*/ { +/*N*/ // PutInOrder / Justify +/*N*/ USHORT nTemp, nMask, nBits1, nBits2; +/*N*/ if ( aEnd.Col() < (nTemp = aStart.Col()) ) +/*N*/ { +/*?*/ aStart.SetCol(aEnd.Col()); aEnd.SetCol(nTemp); +/*?*/ nMask = (SCA_VALID_COL | SCA_COL_ABSOLUTE); +/*?*/ nBits1 = nRes1 & nMask; +/*?*/ nBits2 = nRes2 & nMask; +/*?*/ nRes1 = (nRes1 & ~nMask) | nBits2; +/*?*/ nRes2 = (nRes2 & ~nMask) | nBits1; +/*N*/ } +/*N*/ if ( aEnd.Row() < (nTemp = aStart.Row()) ) +/*N*/ { +/*?*/ aStart.SetRow(aEnd.Row()); aEnd.SetRow(nTemp); +/*?*/ nMask = (SCA_VALID_ROW | SCA_ROW_ABSOLUTE); +/*?*/ nBits1 = nRes1 & nMask; +/*?*/ nBits2 = nRes2 & nMask; +/*?*/ nRes1 = (nRes1 & ~nMask) | nBits2; +/*?*/ nRes2 = (nRes2 & ~nMask) | nBits1; +/*N*/ } +/*N*/ if ( aEnd.Tab() < (nTemp = aStart.Tab()) ) +/*N*/ { +/*?*/ aStart.SetTab(aEnd.Tab()); aEnd.SetTab(nTemp); +/*?*/ nMask = (SCA_VALID_TAB | SCA_TAB_ABSOLUTE | SCA_TAB_3D); +/*?*/ nBits1 = nRes1 & nMask; +/*?*/ nBits2 = nRes2 & nMask; +/*?*/ nRes1 = (nRes1 & ~nMask) | nBits2; +/*?*/ nRes2 = (nRes2 & ~nMask) | nBits1; +/*N*/ } +/*N*/ if ( ((nRes1 & ( SCA_TAB_ABSOLUTE | SCA_TAB_3D )) +/*N*/ == ( SCA_TAB_ABSOLUTE | SCA_TAB_3D )) +/*N*/ && !(nRes2 & SCA_TAB_3D) ) +/*N*/ nRes2 |= SCA_TAB_ABSOLUTE; +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ nRes1 = 0; // #38840# keine Tokens aus halben Sachen +/*N*/ } +/*N*/ } +/*N*/ nRes1 = ( ( nRes1 | nRes2 ) & SCA_VALID ) +/*N*/ | nRes1 +/*N*/ | ( ( nRes2 & 0x070F ) << 4 ); +/*N*/ return nRes1; +/*N*/ } + +/*N*/ USHORT ScRange::ParseAny( const String& r, ScDocument* pDoc ) +/*N*/ { +/*N*/ USHORT nRet = Parse( r, pDoc ); +/*N*/ const USHORT nValid = SCA_VALID | SCA_VALID_COL2 | SCA_VALID_ROW2 | SCA_VALID_TAB2; +/*N*/ if ( (nRet & nValid) != nValid ) +/*N*/ { +/*N*/ ScAddress aAdr; +/*N*/ nRet = aAdr.Parse( r, pDoc ); +/*N*/ if ( nRet & SCA_VALID ) +/*N*/ aStart = aEnd = aAdr; +/*N*/ } +/*N*/ return nRet; +/*N*/ } + +/*N*/ void ScAddress::Format( String& r, USHORT nFlags, ScDocument* pDoc ) const +/*N*/ { +/*N*/ USHORT nTab = Tab(); +/*N*/ USHORT nCol = Col(); +/*N*/ r.Erase(); +/*N*/ if( nFlags & SCA_VALID ) +/*N*/ nFlags |= ( SCA_VALID_ROW | SCA_VALID_COL | SCA_VALID_TAB ); +/*N*/ if( pDoc && (nFlags & SCA_VALID_TAB ) ) +/*N*/ { +/*N*/ if ( nTab >= pDoc->GetTableCount() ) +/*N*/ { +/*?*/ r = ScGlobal::GetRscString( STR_NOREF_STR ); +/*?*/ return; +/*N*/ } +/*N*/ // if( nFlags & ( SCA_TAB_ABSOLUTE | SCA_TAB_3D ) ) +/*N*/ if( nFlags & SCA_TAB_3D ) +/*N*/ { +/*N*/ String aTabName; +/*N*/ pDoc->GetName( nTab, aTabName ); +/*N*/ +/*N*/ // externe Referenzen (wie in ScCompiler::MakeTabStr) +/*N*/ String aDoc; +/*N*/ if ( aTabName.GetChar(0) == '\'' ) +/*N*/ { // "'Doc'#Tab" +/*?*/ xub_StrLen nPos, nLen = 1; +/*?*/ while( (nPos = aTabName.Search( '\'', nLen )) +/*?*/ != STRING_NOTFOUND ) +/*?*/ nLen = nPos + 1; +/*?*/ if ( aTabName.GetChar(nLen) == SC_COMPILER_FILE_TAB_SEP ) +/*?*/ { +/*?*/ aDoc = aTabName.Copy( 0, nLen + 1 ); +/*?*/ aTabName.Erase( 0, nLen + 1 ); +/*?*/ } +/*N*/ } +/*N*/ r += aDoc; +/*N*/ +/*N*/ if( nFlags & SCA_TAB_ABSOLUTE ) +/*N*/ r += '$'; +/*N*/ ScCompiler::CheckTabQuotes( aTabName ); +/*N*/ r += aTabName; +/*N*/ r += '.'; +/*N*/ } +/*N*/ } +/*N*/ if( nFlags & SCA_VALID_COL ) +/*N*/ { +/*N*/ if( nFlags & SCA_COL_ABSOLUTE ) +/*N*/ r += '$'; +/*N*/ if ( nCol < 26 ) +/*N*/ r += (sal_Unicode) ( 'A' + nCol ); +/*N*/ else +/*N*/ { +/*N*/ r += (sal_Unicode) ( 'A' + ( nCol / 26 ) - 1 ); +/*N*/ r += (sal_Unicode) ( 'A' + ( nCol % 26 ) ); +/*N*/ } +/*N*/ } +/*N*/ if( nFlags & SCA_VALID_ROW ) +/*N*/ { +/*N*/ if ( nFlags & SCA_ROW_ABSOLUTE ) +/*N*/ r += '$'; +/*N*/ r += String::CreateFromInt32( Row()+1 ); +/*N*/ } +/*N*/ } + + +/*N*/ void ScRange::Format( String& r, USHORT nFlags, ScDocument* pDoc ) const +/*N*/ { +/*N*/ if( !( nFlags & SCA_VALID ) ) +/*N*/ r = ScGlobal::GetRscString( STR_NOREF_STR ); +/*N*/ else +/*N*/ { +/*N*/ BOOL bOneTab = (aStart.Tab() == aEnd.Tab()); +/*N*/ if ( !bOneTab ) +/*N*/ nFlags |= SCA_TAB_3D; +/*N*/ aStart.Format( r, nFlags, pDoc ); +/*N*/ if( aStart != aEnd ) +/*N*/ { +/*N*/ String aName; +/*N*/ nFlags = ( nFlags & SCA_VALID ) | ( ( nFlags >> 4 ) & 0x070F ); +/*N*/ if ( bOneTab ) +/*N*/ pDoc = NULL; +/*N*/ else +/*N*/ nFlags |= SCA_TAB_3D; +/*N*/ aEnd.Format( aName, nFlags, pDoc ); +/*N*/ r += ':'; +/*N*/ r += aName; +/*N*/ } +/*N*/ } +/*N*/ } + + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_globalx.cxx b/binfilter/bf_sc/source/core/data/sc_globalx.cxx new file mode 100644 index 000000000000..ee3598e86e8f --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_globalx.cxx @@ -0,0 +1,138 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + + +#include "callform.hxx" +#include "global.hxx" + +#include <tools/urlobj.hxx> +#include <ucbhelper/contentbroker.hxx> +#include <ucbhelper/content.hxx> +#include <unotools/localfilehelper.hxx> + +#include <tools/debug.hxx> +#include <bf_svtools/pathoptions.hxx> + +#include <com/sun/star/sdbc/XResultSet.hpp> +#include <com/sun/star/sdbc/XRow.hpp> +#include <com/sun/star/ucb/XCommandEnvironment.hpp> +#include <com/sun/star/ucb/XContentAccess.hpp> + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::ucb; +namespace binfilter { + + +// static +/*N*/ void ScGlobal::InitAddIns() +/*N*/ { +/*N*/ // multi paths separated by semicolons +/*N*/ SvtPathOptions aPathOpt; +/*N*/ String aMultiPath = aPathOpt.GetAddinPath(); +/*N*/ if ( aMultiPath.Len() > 0 ) +/*N*/ { +/*N*/ xub_StrLen nTokens = aMultiPath.GetTokenCount( ';' ); +/*N*/ xub_StrLen nIndex = 0; +/*N*/ for ( xub_StrLen j=0; j<nTokens; j++ ) +/*N*/ { +/*N*/ String aPath( aMultiPath.GetToken( 0, ';', nIndex ) ); +/*N*/ if ( aPath.Len() > 0 ) +/*N*/ { +/*N*/ // use LocalFileHelper to convert the path to a URL that always points +/*N*/ // to the file on the server +/*N*/ String aUrl; +/*N*/ if ( ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPath, aUrl ) ) +/*N*/ aPath = aUrl; +/*N*/ +/*N*/ INetURLObject aObj; +/*N*/ aObj.SetSmartURL( aPath ); +/*N*/ aObj.setFinalSlash(); +/*N*/ try +/*N*/ { +/*N*/ ::ucbhelper::Content aCnt( aObj.GetMainURL(INetURLObject::NO_DECODE), +/*N*/ Reference< XCommandEnvironment > () ); +/*N*/ Reference< sdbc::XResultSet > xResultSet; +/*N*/ Sequence< ::rtl::OUString > aProps; +/*N*/ try +/*N*/ { +/*N*/ xResultSet = aCnt.createCursor( +/*N*/ aProps, ::ucbhelper::INCLUDE_DOCUMENTS_ONLY ); +/*N*/ } +/*N*/ catch ( Exception& ) +/*N*/ { +/*N*/ // ucb may throw different exceptions on failure now +/*N*/ // no assertion if AddIn directory doesn't exist +/*N*/ } +/*N*/ +/*N*/ if ( xResultSet.is() ) +/*N*/ { +/*N*/ Reference< sdbc::XRow > xRow( xResultSet, UNO_QUERY ); +/*N*/ Reference< XContentAccess > +/*N*/ xContentAccess( xResultSet, UNO_QUERY ); +/*N*/ try +/*N*/ { +/*N*/ if ( xResultSet->first() ) +/*N*/ { +/*N*/ do +/*?*/ { +/*?*/ ::rtl::OUString aId( xContentAccess->queryContentIdentifierString() ); +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 InitExternalFunc( aId ); +/*?*/ } +/*?*/ while ( xResultSet->next() ); +/*?*/ } +/*N*/ } +/*N*/ catch ( Exception& ) +/*N*/ { +/*N*/ DBG_ERRORFILE( "ResultSetException catched!" ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ catch ( Exception& ) +/*N*/ { +/*N*/ DBG_ERRORFILE( "Exception catched!" ); +/*N*/ } +/*N*/ catch ( ... ) +/*N*/ { +/*N*/ +/*N*/ DBG_ERRORFILE( "unexpected exception caught!" ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_markarr.cxx b/binfilter/bf_sc/source/core/data/sc_markarr.cxx new file mode 100644 index 000000000000..5912868d8a8e --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_markarr.cxx @@ -0,0 +1,412 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include <tools/debug.hxx> + +#include "markarr.hxx" +#include "global.hxx" +namespace binfilter { + +// STATIC DATA ----------------------------------------------------------- + +//------------------------------------------------------------------------ + +/*N*/ ScMarkArray::ScMarkArray() +/*N*/ { +/*N*/ nCount = nLimit = 1; +/*N*/ pData = new ScMarkEntry[1]; +/*N*/ if (pData) +/*N*/ { +/*N*/ pData[0].nRow = MAXROW; +/*N*/ pData[0].bMarked = FALSE; +/*N*/ } +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ ScMarkArray::~ScMarkArray() +/*N*/ { +/*N*/ if (pData) +/*N*/ delete[] pData; +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ void ScMarkArray::Reset( BOOL bMarked ) +/*N*/ { +/*N*/ if (pData) +/*N*/ { +/*N*/ delete[] pData; +/*N*/ +/*N*/ nCount = nLimit = 1; +/*N*/ pData = new ScMarkEntry[1]; +/*N*/ if (pData) +/*N*/ { +/*N*/ pData[0].nRow = MAXROW; +/*N*/ pData[0].bMarked = bMarked; +/*N*/ } +/*N*/ } +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ BOOL ScMarkArray::Search( USHORT nRow, short& nIndex ) const +/*N*/ { +/*N*/ short nLo = 0; +/*N*/ short nHi = ((short) nCount) - 1; +/*N*/ short nStartRow = 0; +/*N*/ short nEndRow = 0; +/*N*/ short i = 0; +/*N*/ BOOL bFound = (nCount == 1); +/*N*/ if (pData) +/*N*/ { +/*N*/ while ( !bFound && nLo <= nHi ) +/*N*/ { +/*N*/ i = (nLo + nHi) / 2; +/*N*/ if (i > 0) +/*N*/ nStartRow = (short) pData[i - 1].nRow; +/*N*/ else +/*N*/ nStartRow = -1; +/*N*/ nEndRow = (short) pData[i].nRow; +/*N*/ if (nEndRow < (short) nRow) +/*N*/ nLo = ++i; +/*N*/ else +/*N*/ if (nStartRow >= (short) nRow) +/*N*/ nHi = --i; +/*N*/ else +/*N*/ bFound = TRUE; +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ bFound = FALSE; +/*N*/ +/*N*/ if (bFound) +/*N*/ nIndex=i; +/*N*/ else +/*N*/ nIndex=0; +/*N*/ return bFound; +/*N*/ } + +/*N*/ BOOL ScMarkArray::GetMark( USHORT nRow ) const +/*N*/ { +/*N*/ short i; +/*N*/ if (Search( nRow, i )) +/*N*/ return pData[i].bMarked; +/*N*/ else +/*N*/ return FALSE; +/*N*/ +/*N*/ } + +//------------------------------------------------------------------------ + + +/*N*/ void ScMarkArray::SetMarkArea( USHORT nStartRow, USHORT nEndRow, BOOL bMarked ) +/*N*/ { +/*N*/ if ((nStartRow >= 0 && nStartRow <= MAXROW) && (nEndRow >= 0 && nEndRow <= MAXROW)) +/*N*/ { +/*N*/ if ((nStartRow == 0) && (nEndRow == MAXROW)) +/*N*/ { +/*N*/ Reset(bMarked); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ USHORT nNeeded = nCount + 2; +/*N*/ if ( nLimit < nNeeded ) +/*N*/ { +/*N*/ nLimit += SC_MARKARRAY_DELTA; +/*N*/ if ( nLimit < nNeeded ) +/*N*/ nLimit = nNeeded; +/*N*/ ScMarkEntry* pNewData = new ScMarkEntry[nLimit]; +/*N*/ memcpy( pNewData, pData, nCount*sizeof(ScMarkEntry) ); +/*N*/ delete[] pData; +/*N*/ pData = pNewData; +/*N*/ } +/*N*/ +/*N*/ USHORT ni; // number of entries in beginning +/*N*/ USHORT nInsert; // insert position (MAXROW+1 := no insert) +/*N*/ BOOL bCombined = FALSE; +/*N*/ BOOL bSplit = FALSE; +/*N*/ if ( nStartRow > 0 ) +/*N*/ { +/*N*/ // skip beginning +/*N*/ short nIndex; +/*N*/ Search( nStartRow, nIndex ); +/*N*/ ni = nIndex; +/*N*/ +/*N*/ nInsert = MAXROW+1; +/*N*/ if ( pData[ni].bMarked != bMarked ) +/*N*/ { +/*N*/ if ( ni == 0 || (pData[ni-1].nRow < nStartRow - 1) ) +/*N*/ { // may be a split or a simple insert or just a shrink, +/*N*/ // row adjustment is done further down +/*N*/ if ( pData[ni].nRow > nEndRow ) +/*N*/ bSplit = TRUE; +/*N*/ ni++; +/*N*/ nInsert = ni; +/*N*/ } +/*N*/ else if ( ni > 0 && pData[ni-1].nRow == nStartRow - 1 ) +/*N*/ nInsert = ni; +/*N*/ } +/*N*/ if ( ni > 0 && pData[ni-1].bMarked == bMarked ) +/*N*/ { // combine +/*N*/ pData[ni-1].nRow = nEndRow; +/*N*/ nInsert = MAXROW+1; +/*N*/ bCombined = TRUE; +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ nInsert = ni = 0; +/*N*/ +/*N*/ USHORT nj = ni; // stop position of range to replace +/*N*/ while ( nj < nCount && pData[nj].nRow <= nEndRow ) +/*N*/ nj++; +/*N*/ if ( !bSplit ) +/*N*/ { +/*N*/ if ( nj < nCount && pData[nj].bMarked == bMarked ) +/*N*/ { // combine +/*N*/ if ( ni > 0 ) +/*N*/ { +/*N*/ if ( pData[ni-1].bMarked == bMarked ) +/*N*/ { // adjacent entries +/*N*/ pData[ni-1].nRow = pData[nj].nRow; +/*N*/ nj++; +/*N*/ } +/*N*/ else if ( ni == nInsert ) +/*N*/ pData[ni-1].nRow = nStartRow - 1; // shrink +/*N*/ } +/*N*/ nInsert = MAXROW+1; +/*N*/ bCombined = TRUE; +/*N*/ } +/*N*/ else if ( ni > 0 && ni == nInsert ) +/*N*/ pData[ni-1].nRow = nStartRow - 1; // shrink +/*N*/ } +/*N*/ if ( ni < nj ) +/*N*/ { // remove middle entries +/*N*/ if ( !bCombined ) +/*N*/ { // replace one entry +/*N*/ pData[ni].nRow = nEndRow; +/*N*/ pData[ni].bMarked = bMarked; +/*N*/ ni++; +/*N*/ nInsert = MAXROW+1; +/*N*/ } +/*N*/ if ( ni < nj ) +/*N*/ { // remove entries +/*N*/ memmove( pData + ni, pData + nj, (nCount - nj) * sizeof(ScMarkEntry) ); +/*N*/ nCount -= nj - ni; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if ( nInsert <= MAXROW ) +/*N*/ { // insert or append new entry +/*N*/ if ( nInsert <= nCount ) +/*N*/ { +/*N*/ if ( !bSplit ) +/*N*/ memmove( pData + nInsert + 1, pData + nInsert, +/*N*/ (nCount - nInsert) * sizeof(ScMarkEntry) ); +/*N*/ else +/*N*/ { +/*N*/ memmove( pData + nInsert + 2, pData + nInsert, +/*N*/ (nCount - nInsert) * sizeof(ScMarkEntry) ); +/*N*/ pData[nInsert+1] = pData[nInsert-1]; +/*N*/ nCount++; +/*N*/ } +/*N*/ } +/*N*/ if ( nInsert ) +/*N*/ pData[nInsert-1].nRow = nStartRow - 1; +/*N*/ pData[nInsert].nRow = nEndRow; +/*N*/ pData[nInsert].bMarked = bMarked; +/*N*/ nCount++; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ // InfoBox(0, String(nCount) + String(" Eintraege") ).Execute(); +/*N*/ } + + +/*N*/ BOOL ScMarkArray::IsAllMarked( USHORT nStartRow, USHORT nEndRow ) const +/*N*/ { +/*N*/ short nStartIndex; +/*N*/ short nEndIndex; +/*N*/ +/*N*/ if (Search( nStartRow, nStartIndex )) +/*N*/ if (pData[nStartIndex].bMarked) +/*N*/ if (Search( nEndRow, nEndIndex )) +/*N*/ if (nEndIndex==nStartIndex) +/*N*/ return TRUE; +/*N*/ +/*N*/ return FALSE; +/*N*/ } + +/*N*/ BOOL ScMarkArray::HasOneMark( USHORT& rStartRow, USHORT& rEndRow ) const +/*N*/ { +/*N*/ BOOL bRet = FALSE; +/*N*/ if ( nCount == 1 ) +/*N*/ { +/*N*/ if ( pData[0].bMarked ) +/*N*/ { +/*N*/ rStartRow = 0; +/*N*/ rEndRow = MAXROW; +/*N*/ bRet = TRUE; +/*N*/ } +/*N*/ } +/*N*/ else if ( nCount == 2 ) +/*N*/ { +/*N*/ if ( pData[0].bMarked ) +/*N*/ { +/*N*/ rStartRow = 0; +/*N*/ rEndRow = pData[0].nRow; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ rStartRow = pData[0].nRow + 1; +/*N*/ rEndRow = MAXROW; +/*N*/ } +/*N*/ bRet = TRUE; +/*N*/ } +/*N*/ else if ( nCount == 3 ) +/*N*/ { +/*N*/ if ( pData[1].bMarked ) +/*N*/ { +/*N*/ rStartRow = pData[0].nRow + 1; +/*N*/ rEndRow = pData[1].nRow; +/*N*/ bRet = TRUE; +/*N*/ } +/*N*/ } +/*N*/ return bRet; +/*N*/ } + +/*N*/ BOOL ScMarkArray::HasMarks() const +/*N*/ { +/*N*/ return ( nCount > 1 || pData[0].bMarked ); +/*N*/ } + + + +/*N*/ void ScMarkArray::CopyMarksTo( ScMarkArray& rDestMarkArray ) const +/*N*/ { +/*N*/ delete[] rDestMarkArray.pData; +/*N*/ +/*N*/ if (pData) +/*N*/ { +/*N*/ rDestMarkArray.pData = new ScMarkEntry[nCount]; +/*N*/ memmove( rDestMarkArray.pData, pData, nCount * sizeof(ScMarkEntry) ); +/*N*/ } +/*N*/ else +/*N*/ rDestMarkArray.pData = NULL; +/*N*/ +/*N*/ rDestMarkArray.nCount = rDestMarkArray.nLimit = nCount; +/*N*/ } + +/*N*/ short ScMarkArray::GetNextMarked( short nRow, BOOL bUp ) const +/*N*/ { +/*N*/ short nRet = nRow; +/*N*/ if (VALIDROW(nRow)) +/*N*/ { +/*N*/ short nIndex; +/*N*/ Search(nRow, nIndex); +/*N*/ if (!pData[nIndex].bMarked) +/*N*/ { +/*N*/ if (bUp) +/*N*/ { +/*N*/ if (nIndex>0) +/*N*/ nRet = pData[nIndex-1].nRow; +/*N*/ else +/*N*/ nRet = -1; +/*N*/ } +/*N*/ else +/*N*/ nRet = pData[nIndex].nRow + 1; +/*N*/ } +/*N*/ } +/*N*/ return nRet; +/*N*/ } + +/*N*/ USHORT ScMarkArray::GetMarkEnd( USHORT nRow, BOOL bUp ) const +/*N*/ { +/*N*/ USHORT nRet; +/*N*/ short nIndex; +/*N*/ Search(nRow, nIndex); +/*N*/ DBG_ASSERT( pData[nIndex].bMarked, "GetMarkEnd ohne bMarked" ); +/*N*/ if (bUp) +/*N*/ { +/*N*/ if (nIndex>0) +/*N*/ nRet = pData[nIndex-1].nRow + 1; +/*N*/ else +/*N*/ nRet = 0; +/*N*/ } +/*N*/ else +/*N*/ nRet = pData[nIndex].nRow; +/*N*/ +/*N*/ return nRet; +/*N*/ } + +// +// -------------- Iterator ---------------------------------------------- +// + +/*N*/ ScMarkArrayIter::ScMarkArrayIter( const ScMarkArray* pNewArray ) : +/*N*/ pArray( pNewArray ), +/*N*/ nPos( 0 ) +/*N*/ { +/*N*/ } + +/*N*/ ScMarkArrayIter::~ScMarkArrayIter() +/*N*/ { +/*N*/ } + +/*N*/ BOOL ScMarkArrayIter::Next( USHORT& rTop, USHORT& rBottom ) +/*N*/ { +/*N*/ if ( nPos >= pArray->nCount ) +/*N*/ return FALSE; +/*N*/ while (!pArray->pData[nPos].bMarked) +/*N*/ { +/*N*/ ++nPos; +/*N*/ if ( nPos >= pArray->nCount ) +/*N*/ return FALSE; +/*N*/ } +/*N*/ rBottom = pArray->pData[nPos].nRow; +/*N*/ if (nPos==0) +/*N*/ rTop = 0; +/*N*/ else +/*N*/ rTop = pArray->pData[nPos-1].nRow + 1; +/*N*/ ++nPos; +/*N*/ return TRUE; +/*N*/ } + + + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_markdata.cxx b/binfilter/bf_sc/source/core/data/sc_markdata.cxx new file mode 100644 index 000000000000..3792f8eb3ed2 --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_markdata.cxx @@ -0,0 +1,369 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include <tools/debug.hxx> + +#include "markdata.hxx" +#include "markarr.hxx" +#include "rangelst.hxx" +namespace binfilter { + +// STATIC DATA ----------------------------------------------------------- + +//------------------------------------------------------------------------ + +/*N*/ ScMarkData::ScMarkData() : +/*N*/ pMultiSel( NULL ) +/*N*/ { +/*N*/ for (USHORT i=0; i<=MAXTAB; i++) +/*N*/ bTabMarked[i] = FALSE; +/*N*/ +/*N*/ ResetMark(); +/*N*/ } + +/*N*/ ScMarkData::ScMarkData(const ScMarkData& rData) : +/*N*/ pMultiSel( NULL ), +/*N*/ aMarkRange( rData.aMarkRange ), +/*N*/ aMultiRange( rData.aMultiRange ) +/*N*/ { +/*N*/ bMarked = rData.bMarked; +/*N*/ bMultiMarked = rData.bMultiMarked; +/*N*/ bMarking = rData.bMarking; +/*N*/ bMarkIsNeg = rData.bMarkIsNeg; +/*N*/ +/*N*/ USHORT i; +/*N*/ for (i=0; i<=MAXTAB; i++) +/*N*/ bTabMarked[i] = rData.bTabMarked[i]; +/*N*/ +/*N*/ if (rData.pMultiSel) +/*N*/ { +/*N*/ pMultiSel = new ScMarkArray[MAXCOL+1]; +/*N*/ for (i=0; i<=MAXCOL; i++) +/*N*/ rData.pMultiSel[i].CopyMarksTo( pMultiSel[i] ); +/*N*/ } +/*N*/ } + + +/*N*/ ScMarkData::~ScMarkData() +/*N*/ { +/*N*/ delete[] pMultiSel; +/*N*/ } + +/*N*/ void ScMarkData::ResetMark() +/*N*/ { +/*N*/ delete[] pMultiSel; +/*N*/ pMultiSel = NULL; +/*N*/ +/*N*/ bMarked = bMultiMarked = FALSE; +/*N*/ bMarking = bMarkIsNeg = FALSE; +/*N*/ } + +/*N*/ void ScMarkData::SetMarkArea( const ScRange& rRange ) +/*N*/ { +/*N*/ aMarkRange = rRange; +/*N*/ aMarkRange.Justify(); +/*N*/ if ( !bMarked ) +/*N*/ { +/*N*/ // #77987# Upon creation of a document ScFormatShell GetTextAttrState +/*N*/ // may query (default) attributes although no sheet is marked yet. +/*N*/ // => mark that one. +/*N*/ if ( !GetSelectCount() ) +/*N*/ bTabMarked[ aMarkRange.aStart.Tab() ] = TRUE; +/*N*/ bMarked = TRUE; +/*N*/ } +/*N*/ } + +/*N*/ void ScMarkData::GetMarkArea( ScRange& rRange ) const +/*N*/ { +/*N*/ rRange = aMarkRange; //! inline ? +/*N*/ } + +/*N*/ void ScMarkData::GetMultiMarkArea( ScRange& rRange ) const +/*N*/ { +/*N*/ rRange = aMultiRange; +/*N*/ } + +/*N*/ void ScMarkData::SetMultiMarkArea( const ScRange& rRange, BOOL bMark ) +/*N*/ { +/*N*/ if (!pMultiSel) +/*N*/ { +/*N*/ pMultiSel = new ScMarkArray[MAXCOL+1]; +/*N*/ +/*N*/ // if simple mark range is set, copy to multi marks +/*N*/ if ( bMarked && !bMarkIsNeg ) +/*N*/ { +/*N*/ bMarked = FALSE; +/*N*/ SetMultiMarkArea( aMarkRange, TRUE ); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ USHORT nStartCol = rRange.aStart.Col(); +/*N*/ USHORT nStartRow = rRange.aStart.Row(); +/*N*/ USHORT nEndCol = rRange.aEnd.Col(); +/*N*/ USHORT nEndRow = rRange.aEnd.Row(); +/*N*/ PutInOrder( nStartRow, nEndRow ); +/*N*/ PutInOrder( nStartCol, nEndCol ); +/*N*/ +/*N*/ USHORT nCol; +/*N*/ for (nCol=nStartCol; nCol<=nEndCol; nCol++) +/*N*/ pMultiSel[nCol].SetMarkArea( nStartRow, nEndRow, bMark ); +/*N*/ +/*N*/ if ( bMultiMarked ) // aMultiRange updaten +/*N*/ { +/*N*/ if ( nStartCol < aMultiRange.aStart.Col() ) +/*N*/ aMultiRange.aStart.SetCol( nStartCol ); +/*N*/ if ( nStartRow < aMultiRange.aStart.Row() ) +/*N*/ aMultiRange.aStart.SetRow( nStartRow ); +/*N*/ if ( nEndCol > aMultiRange.aEnd.Col() ) +/*N*/ aMultiRange.aEnd.SetCol( nEndCol ); +/*N*/ if ( nEndRow > aMultiRange.aEnd.Row() ) +/*N*/ aMultiRange.aEnd.SetRow( nEndRow ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ aMultiRange = rRange; // neu +/*N*/ bMultiMarked = TRUE; +/*N*/ } +/*N*/ } + + +/*N*/ void ScMarkData::SelectOneTable( USHORT nTab ) +/*N*/ { +/*N*/ for (USHORT i=0; i<=MAXTAB; i++) +/*N*/ bTabMarked[i] = ( nTab == i ); +/*N*/ } + +/*N*/ USHORT ScMarkData::GetSelectCount() const +/*N*/ { +/*N*/ USHORT nCount = 0; +/*N*/ for (USHORT i=0; i<=MAXTAB; i++) +/*N*/ if (bTabMarked[i]) +/*N*/ ++nCount; +/*N*/ +/*N*/ return nCount; +/*N*/ } + +/*N*/ void ScMarkData::MarkToMulti() +/*N*/ { +/*N*/ if ( bMarked && !bMarking ) +/*N*/ { +/*N*/ SetMultiMarkArea( aMarkRange, !bMarkIsNeg ); +/*N*/ bMarked = FALSE; +/*N*/ +/*N*/ // check if all multi mark ranges have been removed +/*N*/ if ( bMarkIsNeg && !HasAnyMultiMarks() ) +/*?*/ ResetMark(); +/*N*/ } +/*N*/ } + +/*N*/ void ScMarkData::MarkToSimple() +/*N*/ { +/*N*/ if ( bMarking ) +/*N*/ return; +/*N*/ +/*N*/ if ( bMultiMarked && bMarked ) +/*?*/ MarkToMulti(); // may result in bMarked and bMultiMarked reset +/*N*/ +/*N*/ if ( bMultiMarked ) +/*N*/ { +/*N*/ DBG_ASSERT(pMultiSel, "bMultiMarked, aber pMultiSel == 0"); +/*N*/ +/*N*/ ScRange aNew = aMultiRange; +/*N*/ +/*N*/ BOOL bOk = FALSE; +/*N*/ USHORT nStartCol = aNew.aStart.Col(); +/*N*/ USHORT nEndCol = aNew.aEnd.Col(); +/*N*/ +/*N*/ while ( nStartCol < nEndCol && !pMultiSel[nStartCol].HasMarks() ) +/*N*/ ++nStartCol; +/*N*/ while ( nStartCol < nEndCol && !pMultiSel[nEndCol].HasMarks() ) +/*N*/ --nEndCol; +/*N*/ +/*N*/ // Zeilen werden nur aus MarkArray genommen +/*N*/ USHORT nStartRow, nEndRow; +/*N*/ if ( pMultiSel[nStartCol].HasOneMark( nStartRow, nEndRow ) ) +/*N*/ { +/*N*/ bOk = TRUE; +/*N*/ USHORT nCmpStart, nCmpEnd; +/*N*/ for (USHORT nCol=nStartCol+1; nCol<=nEndCol && bOk; nCol++) +/*N*/ if ( !pMultiSel[nCol].HasOneMark( nCmpStart, nCmpEnd ) +/*N*/ || nCmpStart != nStartRow || nCmpEnd != nEndRow ) +/*N*/ bOk = FALSE; +/*N*/ } +/*N*/ +/*N*/ if (bOk) +/*N*/ { +/*?*/ aNew.aStart.SetCol(nStartCol); +/*?*/ aNew.aStart.SetRow(nStartRow); +/*?*/ aNew.aEnd.SetCol(nEndCol); +/*?*/ aNew.aEnd.SetRow(nEndRow); +/*?*/ +/*?*/ ResetMark(); +/*?*/ aMarkRange = aNew; +/*?*/ bMarked = TRUE; +/*?*/ bMarkIsNeg = FALSE; +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ BOOL ScMarkData::IsCellMarked( USHORT nCol, USHORT nRow, BOOL bNoSimple ) const +/*N*/ { +/*N*/ if ( bMarked && !bNoSimple && !bMarkIsNeg ) +/*?*/ if ( aMarkRange.aStart.Col() <= nCol && aMarkRange.aEnd.Col() >= nCol && +/*?*/ aMarkRange.aStart.Row() <= nRow && aMarkRange.aEnd.Row() >= nRow ) +/*?*/ return TRUE; +/*N*/ +/*N*/ if (bMultiMarked) +/*N*/ { +/*N*/ //! hier auf negative Markierung testen ? +/*N*/ +/*N*/ DBG_ASSERT(pMultiSel, "bMultiMarked, aber pMultiSel == 0"); +/*N*/ return pMultiSel[nCol].GetMark( nRow ); +/*N*/ } +/*N*/ +/*N*/ return FALSE; +/*N*/ } + + + +/*N*/ void ScMarkData::MarkFromRangeList( const ScRangeList& rList, BOOL bReset ) +/*N*/ { +/*N*/ if (bReset) +/*N*/ { +/*?*/ for (USHORT i=0; i<=MAXTAB; i++) +/*?*/ bTabMarked[i] = FALSE; // Tabellen sind nicht in ResetMark +/*?*/ ResetMark(); +/*N*/ } +/*N*/ +/*N*/ ULONG nCount = rList.Count(); +/*N*/ if ( nCount == 1 && !bMarked && !bMultiMarked ) +/*N*/ { +/*N*/ ScRange aRange = *rList.GetObject(0); +/*N*/ SetMarkArea( aRange ); +/*N*/ SelectTable( aRange.aStart.Tab(), TRUE ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ for (ULONG i=0; i<nCount; i++) +/*N*/ { +/*N*/ ScRange aRange = *rList.GetObject(i); +/*N*/ SetMultiMarkArea( aRange, TRUE ); +/*N*/ SelectTable( aRange.aStart.Tab(), TRUE ); +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ void ScMarkData::FillRangeListWithMarks( ScRangeList* pList, BOOL bClear ) const +/*N*/ { +/*N*/ if (!pList) +/*N*/ return; +/*N*/ +/*N*/ if (bClear) +/*?*/ pList->RemoveAll(); +/*N*/ +/*N*/ //! bei mehreren selektierten Tabellen mehrere Ranges eintragen !!! +/*N*/ +/*N*/ if ( bMultiMarked ) +/*N*/ { +/*N*/ DBG_ASSERT(pMultiSel, "bMultiMarked, aber pMultiSel == 0"); +/*N*/ +/*N*/ USHORT nTab = aMultiRange.aStart.Tab(); +/*N*/ +/*N*/ USHORT nStartCol = aMultiRange.aStart.Col(); +/*N*/ USHORT nEndCol = aMultiRange.aEnd.Col(); +/*N*/ for (USHORT nCol=nStartCol; nCol<=nEndCol; nCol++) +/*N*/ if (pMultiSel[nCol].HasMarks()) +/*N*/ { +/*N*/ USHORT nTop, nBottom; +/*N*/ ScRange aRange( nCol, 0, nTab ); +/*N*/ ScMarkArrayIter aMarkIter( &pMultiSel[nCol] ); +/*N*/ while ( aMarkIter.Next( nTop, nBottom ) ) +/*N*/ { +/*N*/ aRange.aStart.SetRow( nTop ); +/*N*/ aRange.aEnd.SetRow( nBottom ); +/*N*/ pList->Join( aRange ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if ( bMarked ) +/*?*/ pList->Append( aMarkRange ); +/*N*/ } + +/*N*/ BOOL ScMarkData::IsAllMarked( const ScRange& rRange ) const +/*N*/ { +/*N*/ if ( !bMultiMarked ) +/*N*/ return FALSE; +/*N*/ +/*N*/ DBG_ASSERT(pMultiSel, "bMultiMarked, aber pMultiSel == 0"); +/*N*/ +/*N*/ USHORT nStartCol = rRange.aStart.Col(); +/*N*/ USHORT nStartRow = rRange.aStart.Row(); +/*N*/ USHORT nEndCol = rRange.aEnd.Col(); +/*N*/ USHORT nEndRow = rRange.aEnd.Row(); +/*N*/ BOOL bOk = TRUE; +/*N*/ for (USHORT nCol=nStartCol; nCol<=nEndCol && bOk; nCol++) +/*N*/ if ( !pMultiSel[nCol].IsAllMarked( nStartRow, nEndRow ) ) +/*N*/ bOk = FALSE; +/*N*/ +/*N*/ return bOk; +/*N*/ } + + +/*N*/ BOOL ScMarkData::HasMultiMarks( USHORT nCol ) const +/*N*/ { +/*N*/ if ( !bMultiMarked ) +/*N*/ return FALSE; +/*N*/ +/*N*/ DBG_ASSERT(pMultiSel, "bMultiMarked, aber pMultiSel == 0"); +/*N*/ +/*N*/ return pMultiSel[nCol].HasMarks(); +/*N*/ } + +/*N*/ BOOL ScMarkData::HasAnyMultiMarks() const +/*N*/ { +/*N*/ if ( !bMultiMarked ) +/*N*/ return FALSE; +/*N*/ +/*N*/ DBG_ASSERT(pMultiSel, "bMultiMarked, aber pMultiSel == 0"); +/*N*/ +/*N*/ for (USHORT nCol=0; nCol<=MAXCOL; nCol++) +/*N*/ if ( pMultiSel[nCol].HasMarks() ) +/*N*/ return TRUE; +/*N*/ +/*N*/ return FALSE; // nix +/*N*/ } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_olinetab.cxx b/binfilter/bf_sc/source/core/data/sc_olinetab.cxx new file mode 100644 index 000000000000..31d4fc3305a4 --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_olinetab.cxx @@ -0,0 +1,637 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <tools/debug.hxx> +#include <limits.h> + +// INCLUDE --------------------------------------------------------------- + +#include "olinetab.hxx" +#include "global.hxx" +#include "rechead.hxx" +namespace binfilter { + +//------------------------------------------------------------------------ + +/*N*/ ScOutlineEntry::ScOutlineEntry( USHORT nNewStart, USHORT nNewSize, BOOL bNewHidden ) : +/*N*/ nStart ( nNewStart ), +/*N*/ nSize ( nNewSize ), +/*N*/ bHidden ( bNewHidden ), +/*N*/ bVisible( TRUE ) +/*N*/ { +/*N*/ } + +/*N*/ ScOutlineEntry::ScOutlineEntry( const ScOutlineEntry& rEntry ) : +/*N*/ nStart ( rEntry.nStart ), +/*N*/ nSize ( rEntry.nSize ), +/*N*/ bHidden ( rEntry.bHidden ), +/*N*/ bVisible( rEntry.bVisible ) +/*N*/ { +/*N*/ } + +/*N*/ ScOutlineEntry::ScOutlineEntry( SvStream& rStream, ScMultipleReadHeader& rHdr ) +/*N*/ { +/*N*/ rHdr.StartEntry(); +/*N*/ +/*N*/ rStream >> nStart; +/*N*/ rStream >> nSize; +/*N*/ rStream >> bHidden; +/*N*/ rStream >> bVisible; +/*N*/ +/*N*/ rHdr.EndEntry(); +/*N*/ } + +/*N*/ void ScOutlineEntry::Store( SvStream& rStream, ScMultipleWriteHeader& rHdr ) +/*N*/ { +/*N*/ rHdr.StartEntry(); +/*N*/ +/*N*/ rStream << nStart; +/*N*/ rStream << nSize; +/*N*/ rStream << bHidden; +/*N*/ rStream << bVisible; +/*N*/ +/*N*/ rHdr.EndEntry(); +/*N*/ } + +/*N*/ DataObject* ScOutlineEntry::Clone() const +/*N*/ { +/*N*/ return new ScOutlineEntry( *this ); +/*N*/ } + +/*N*/ void ScOutlineEntry::Move( short nDelta ) +/*N*/ { +/*N*/ short nNewPos = ((short) nStart) + nDelta; +/*N*/ if (nNewPos<0) +/*N*/ { +/*N*/ DBG_ERROR("OutlineEntry < 0"); +/*N*/ nNewPos = 0; +/*N*/ } +/*N*/ nStart = (USHORT) nNewPos; +/*N*/ } + +/*N*/ void ScOutlineEntry::SetSize( USHORT nNewSize ) +/*N*/ { +/*N*/ if (nNewSize) +/*N*/ nSize = nNewSize; +/*N*/ else +/*N*/ DBG_ERROR("ScOutlineEntry Size == 0"); +/*N*/ } + +/*N*/ void ScOutlineEntry::SetPosSize( USHORT nNewPos, USHORT nNewSize ) +/*N*/ { +/*N*/ nStart = nNewPos; +/*N*/ SetSize( nNewSize ); +/*N*/ } + +/*N*/ void ScOutlineEntry::SetVisible( BOOL bNewVisible ) +/*N*/ { +/*N*/ bVisible = bNewVisible; +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ ScOutlineCollection::ScOutlineCollection() : +/*N*/ SortedCollection( 4,4,FALSE ) +/*N*/ { +/*N*/ } + +/*N*/ inline short IntCompare( USHORT nX, USHORT nY ) +/*N*/ { +/*N*/ if ( nX==nY ) return 0; +/*N*/ else if ( nX<nY ) return -1; +/*N*/ else return 1; +/*N*/ } + +/*N*/ short ScOutlineCollection::Compare(DataObject* pKey1, DataObject* pKey2) const +/*N*/ { +/*N*/ return IntCompare( ((ScOutlineEntry*)pKey1)->GetStart(), +/*N*/ ((ScOutlineEntry*)pKey2)->GetStart() ); +/*N*/ } +/*N*/ + +//------------------------------------------------------------------------ + +/*N*/ ScOutlineArray::ScOutlineArray() : +/*N*/ nDepth( 0 ) +/*N*/ { +/*N*/ } + +/*N*/ ScOutlineArray::ScOutlineArray( const ScOutlineArray& rArray ) : +/*N*/ nDepth( rArray.nDepth ) +/*N*/ { +/*N*/ for (USHORT nLevel=0; nLevel<nDepth; nLevel++) +/*N*/ { +/*N*/ USHORT nCount = rArray.aCollections[nLevel].GetCount(); +/*N*/ for (USHORT nEntry=0; nEntry<nCount; nEntry++) +/*N*/ { +/*N*/ ScOutlineEntry* pEntry = (ScOutlineEntry*) rArray.aCollections[nLevel].At(nEntry); +/*N*/ aCollections[nLevel].Insert( new ScOutlineEntry( *pEntry ) ); +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ void ScOutlineArray::FindEntry( USHORT nSearchPos, USHORT& rFindLevel, USHORT& rFindIndex, +/*N*/ USHORT nMaxLevel ) +/*N*/ { +/*N*/ rFindLevel = rFindIndex = 0; +/*N*/ +/*N*/ if (nMaxLevel > nDepth) +/*N*/ nMaxLevel = nDepth; +/*N*/ +/*N*/ for (USHORT nLevel=0; nLevel<nMaxLevel; nLevel++) //! rueckwaerts suchen ? +/*N*/ { +/*N*/ ScOutlineCollection* pCollect = &aCollections[nLevel]; +/*N*/ USHORT nCount = pCollect->GetCount(); +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ { +/*N*/ ScOutlineEntry* pEntry = (ScOutlineEntry*) pCollect->At(i); +/*N*/ if ( pEntry->GetStart() <= nSearchPos && pEntry->GetEnd() >= nSearchPos ) +/*N*/ { +/*N*/ rFindLevel = nLevel + 1; // naechster Level (zum Einfuegen) +/*N*/ rFindIndex = i; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ BOOL ScOutlineArray::Insert( USHORT nStartCol, USHORT nEndCol, BOOL& rSizeChanged, +/*N*/ BOOL bHidden, BOOL bVisible ) +/*N*/ { +/*N*/ rSizeChanged = FALSE; +/*N*/ +/*N*/ USHORT nStartLevel; +/*N*/ USHORT nStartIndex; +/*N*/ USHORT nEndLevel; +/*N*/ USHORT nEndIndex; +/*N*/ BOOL bFound = FALSE; +/*N*/ +/*N*/ BOOL bCont; +/*N*/ USHORT nFindMax; +/*N*/ FindEntry( nStartCol, nStartLevel, nStartIndex ); // nLevel = neuer Level (alter+1) !!! +/*N*/ FindEntry( nEndCol, nEndLevel, nEndIndex ); +/*N*/ nFindMax = Max(nStartLevel,nEndLevel); +/*N*/ do +/*N*/ { +/*N*/ bCont = FALSE; +/*N*/ +/*N*/ if ( nStartLevel == nEndLevel && nStartIndex == nEndIndex && nStartLevel < SC_OL_MAXDEPTH ) +/*N*/ bFound = TRUE; +/*N*/ +/*N*/ if (!bFound) +/*N*/ { +/*N*/ if (nFindMax>0) +/*N*/ { +/*N*/ --nFindMax; +/*N*/ if (nStartLevel) +/*N*/ if ( ((ScOutlineEntry*)aCollections[nStartLevel-1].At(nStartIndex))-> +/*N*/ GetStart() == nStartCol ) +/*N*/ FindEntry( nStartCol, nStartLevel, nStartIndex, nFindMax ); +/*N*/ if (nEndLevel) +/*?*/ if ( ((ScOutlineEntry*)aCollections[nEndLevel-1].At(nEndIndex))-> +/*?*/ GetEnd() == nEndCol ) +/*N*/ FindEntry( nEndCol, nEndLevel, nEndIndex, nFindMax ); +/*N*/ bCont = TRUE; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ while ( !bFound && bCont ); +/*N*/ +/*N*/ if (!bFound) +/*N*/ return FALSE; +/*N*/ +/*N*/ USHORT nLevel = nStartLevel; +/*N*/ +/*N*/ // untere verschieben +/*N*/ +/*N*/ BOOL bNeedSize = FALSE; +/*N*/ for ( short nMoveLevel = nDepth-1; nMoveLevel >= (short) nLevel; nMoveLevel-- ) +/*N*/ { +/*N*/ USHORT nCount = aCollections[nMoveLevel].GetCount(); +/*N*/ BOOL bMoved = FALSE; +/*N*/ for ( USHORT i=0; i<nCount; i += bMoved ? 0 : 1 ) +/*N*/ { +/*N*/ ScOutlineEntry* pEntry = (ScOutlineEntry*) aCollections[nMoveLevel].At(i); +/*N*/ USHORT nEntryStart = pEntry->GetStart(); +/*N*/ if ( nEntryStart >= nStartCol && nEntryStart <= nEndCol ) +/*N*/ { +/*N*/ if (nMoveLevel >= SC_OL_MAXDEPTH - 1) +/*N*/ { +/*?*/ rSizeChanged = FALSE; // kein Platz +/*?*/ return FALSE; +/*N*/ } +/*N*/ aCollections[nMoveLevel+1].Insert( new ScOutlineEntry( *pEntry ) ); +/*N*/ aCollections[nMoveLevel].AtFree( i ); +/*N*/ nCount = aCollections[nMoveLevel].GetCount(); +/*N*/ bMoved = TRUE; +/*N*/ if (nMoveLevel == (short) nDepth - 1) +/*N*/ bNeedSize = TRUE; +/*N*/ } +/*N*/ else +/*N*/ bMoved = FALSE; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if (bNeedSize) +/*N*/ { +/*N*/ ++nDepth; +/*N*/ rSizeChanged = TRUE; +/*N*/ } +/*N*/ +/*N*/ if (nDepth <= nLevel) +/*N*/ { +/*N*/ nDepth = nLevel+1; +/*N*/ rSizeChanged = TRUE; +/*N*/ } +/*N*/ +/* nicht zusammenfassen! + + // zusammenfassen + + USHORT nCount = aCollections[nLevel].GetCount(); + USHORT nIndex; + bFound = FALSE; + for ( nIndex=0; nIndex<nCount && !bFound; nIndex++ ) + { + if ( ((ScOutlineEntry*) aCollections[nLevel].At(nIndex))->GetEnd() + 1 == nStartCol ) + { + nStartCol = ((ScOutlineEntry*) aCollections[nLevel].At(nIndex))->GetStart(); + aCollections[nLevel].AtFree(nIndex); + nCount = aCollections[nLevel].GetCount(); // Daten geaendert + bFound = TRUE; + } + } + + bFound = FALSE; + for ( nIndex=0; nIndex<nCount && !bFound; nIndex++ ) + { + if ( ((ScOutlineEntry*) aCollections[nLevel].At(nIndex))->GetStart() == nEndCol + 1 ) + { + nEndCol = ((ScOutlineEntry*) aCollections[nLevel].At(nIndex))->GetEnd(); + aCollections[nLevel].AtFree(nIndex); + bFound = TRUE; + } + } +*/ +/*N*/ ScOutlineEntry* pNewEntry = new ScOutlineEntry( nStartCol, nEndCol+1-nStartCol, bHidden ); +/*N*/ pNewEntry->SetVisible( bVisible ); +/*N*/ aCollections[nLevel].Insert( pNewEntry ); +/*N*/ +/*N*/ return TRUE; +/*N*/ } + + + + +/*N*/ BOOL ScOutlineArray::DecDepth() // nDepth auf leere Levels anpassen +/*N*/ { +/*N*/ BOOL bChanged = FALSE; +/*N*/ BOOL bCont; +/*N*/ do +/*N*/ { +/*N*/ bCont = FALSE; +/*N*/ if (nDepth) +/*N*/ if (aCollections[nDepth-1].GetCount() == 0) +/*N*/ { +/*N*/ --nDepth; +/*N*/ bChanged = TRUE; +/*N*/ bCont = TRUE; +/*N*/ } +/*N*/ } +/*N*/ while (bCont); +/*N*/ return bChanged; +/*N*/ } + + +/*M*/ ScOutlineEntry* ScOutlineArray::GetEntry( USHORT nLevel, USHORT nIndex ) const +/*M*/ { +/*M*/ return (ScOutlineEntry*)((nLevel < nDepth) ? aCollections[nLevel].At(nIndex) : NULL); +/*M*/ } + +/*M*/ USHORT ScOutlineArray::GetCount( USHORT nLevel ) const +/*M*/ { +/*M*/ return (nLevel < nDepth) ? aCollections[nLevel].GetCount() : 0; +/*M*/ } + + +/*M*/ void ScOutlineArray::SetVisibleBelow( USHORT nLevel, USHORT nEntry, BOOL bValue, BOOL bSkipHidden ) +/*M*/ { +/*M*/ ScOutlineEntry* pEntry = GetEntry( nLevel, nEntry ); +/*M*/ if( pEntry ) +/*M*/ { +/*M*/ USHORT nStart = pEntry->GetStart(); +/*M*/ USHORT nEnd = pEntry->GetEnd(); +/*M*/ +/*M*/ for (USHORT nSubLevel=nLevel+1; nSubLevel<nDepth; nSubLevel++) +/*M*/ { +/*M*/ USHORT i = 0; +/*M*/ pEntry = (ScOutlineEntry*) aCollections[nSubLevel].At(i); +/*M*/ while (pEntry) +/*M*/ { +/*M*/ if (pEntry->GetStart() >= nStart && pEntry->GetEnd() <= nEnd) +/*M*/ { +/*M*/ pEntry->SetVisible(bValue); +/*M*/ +/*M*/ if (bSkipHidden) +/*M*/ if (!pEntry->IsHidden()) +/*M*/ SetVisibleBelow( nSubLevel, i, bValue, TRUE ); +/*M*/ } +/*M*/ +/*M*/ ++i; +/*M*/ pEntry = (ScOutlineEntry*) aCollections[nSubLevel].At(i); +/*M*/ } +/*M*/ +/*M*/ if (bSkipHidden) +/*M*/ nSubLevel = nDepth; // Abbruch +/*M*/ } +/*M*/ } +/*M*/ } + + + +/*N*/ BOOL ScOutlineArray::TestInsertSpace( USHORT nSize, USHORT nMaxVal ) const +/*N*/ { +/*N*/ USHORT nCount = aCollections[0].GetCount(); +/*N*/ if (nCount) +/*N*/ { +/*N*/ USHORT nEnd = ((ScOutlineEntry*) aCollections[0].At(nCount-1))->GetEnd(); +/*N*/ return ( nEnd+nSize <= nMaxVal ); +/*N*/ } +/*N*/ +/*N*/ return TRUE; +/*N*/ } + +/*N*/ void ScOutlineArray::InsertSpace( USHORT nStartPos, USHORT nSize ) +/*N*/ { +/*N*/ ScSubOutlineIterator aIter( this ); +/*N*/ ScOutlineEntry* pEntry; +/*N*/ while((pEntry=aIter.GetNext())!=NULL) +/*N*/ { +/*N*/ if ( pEntry->GetStart() >= nStartPos ) +/*N*/ pEntry->Move(nSize); +/*N*/ else +/*N*/ { +/*N*/ USHORT nEnd = pEntry->GetEnd(); +/*N*/ // immer erweitern, wenn innerhalb der Gruppe eingefuegt +/*N*/ // beim Einfuegen am Ende nur, wenn die Gruppe nicht ausgeblendet ist +/*N*/ if ( nEnd >= nStartPos || ( nEnd+1 >= nStartPos && !pEntry->IsHidden() ) ) +/*N*/ { +/*N*/ USHORT nEntrySize = pEntry->GetSize(); +/*N*/ nEntrySize += nSize; +/*N*/ pEntry->SetSize( nEntrySize ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ BOOL ScOutlineArray::DeleteSpace( USHORT nStartPos, USHORT nSize ) +/*N*/ { +/*N*/ USHORT nEndPos = nStartPos + nSize - 1; +/*N*/ BOOL bNeedSave = FALSE; // Original fuer Undo benoetigt? +/*N*/ BOOL bChanged = FALSE; // fuer Test auf Level +/*N*/ +/*N*/ ScSubOutlineIterator aIter( this ); +/*N*/ ScOutlineEntry* pEntry; +/*N*/ while((pEntry=aIter.GetNext())!=NULL) +/*N*/ { +/*N*/ USHORT nEntryStart = pEntry->GetStart(); +/*N*/ USHORT nEntryEnd = pEntry->GetEnd(); +/*N*/ USHORT nEntrySize = pEntry->GetSize(); +/*N*/ +/*N*/ if ( nEntryEnd >= nStartPos ) +/*N*/ { +/*N*/ if ( nEntryStart > nEndPos ) // rechts +/*N*/ pEntry->Move(-(short)nSize); +/*N*/ else if ( nEntryStart < nStartPos && nEntryEnd >= nEndPos ) // aussen +/*N*/ pEntry->SetSize( nEntrySize-nSize ); +/*N*/ else +/*N*/ { +/*N*/ bNeedSave = TRUE; +/*N*/ if ( nEntryStart >= nStartPos && nEntryEnd <= nEndPos ) // innen +/*N*/ { +/*N*/ aIter.DeleteLast(); +/*N*/ bChanged = TRUE; +/*N*/ } +/*N*/ else if ( nEntryStart >= nStartPos ) // rechts ueber +/*N*/ pEntry->SetPosSize( nStartPos, nEntryEnd-nEndPos ); +/*N*/ else // links ueber +/*N*/ pEntry->SetSize( nStartPos-nEntryStart ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if (bChanged) +/*N*/ DecDepth(); +/*N*/ +/*N*/ return bNeedSave; +/*N*/ } + +/*N*/ BOOL ScOutlineArray::ManualAction( USHORT nStartPos, USHORT nEndPos, BOOL bShow, BYTE* pHiddenFlags ) +/*N*/ { +/*N*/ BOOL bModified = FALSE; +/*N*/ ScSubOutlineIterator aIter( this ); +/*N*/ ScOutlineEntry* pEntry; +/*N*/ while((pEntry=aIter.GetNext())!=NULL) +/*N*/ { +/*N*/ USHORT nEntryStart = pEntry->GetStart(); +/*N*/ USHORT nEntryEnd = pEntry->GetEnd(); +/*N*/ +/*N*/ if (nEntryEnd>=nStartPos && nEntryStart<=nEndPos) +/*N*/ { +/*?*/ if ( pEntry->IsHidden() == bShow ) +/*?*/ { +/*?*/ // #i12341# hide if all columns/rows are hidden, show if at least one +/*?*/ // is visible +/*?*/ +/*?*/ BOOL bAllHidden = TRUE; +/*?*/ for ( USHORT i=nEntryStart; i<=nEntryEnd && bAllHidden; i++ ) +/*?*/ if ( ( pHiddenFlags[i] & CR_HIDDEN ) == 0 ) +/*?*/ bAllHidden = FALSE; +/*?*/ +/*?*/ BOOL bToggle = ( bShow != bAllHidden ); +/*?*/ if ( bToggle ) +/*?*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 pEntry->SetHidden( !bShow ); +/*?*/ } +/*?*/ } +/*N*/ } +/*N*/ } +/*N*/ return bModified; +/*N*/ } + + +/*N*/ void ScOutlineArray::Load( SvStream& rStream ) +/*N*/ { +/*N*/ ScMultipleReadHeader aHdr( rStream ); +/*N*/ +/*N*/ rStream >> nDepth; +/*N*/ for (USHORT nLevel=0; nLevel<nDepth; nLevel++) +/*N*/ { +/*N*/ USHORT nCount; +/*N*/ rStream >> nCount; +/*N*/ for (USHORT nIndex=0; nIndex<nCount; nIndex++) +/*N*/ { +/*N*/ ScOutlineEntry* pEntry = new ScOutlineEntry( rStream, aHdr ); +/*N*/ aCollections[nLevel].Insert( pEntry ); +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ void ScOutlineArray::Store( SvStream& rStream ) +/*N*/ { +/*N*/ ScMultipleWriteHeader aHdr( rStream ); +/*N*/ +/*N*/ rStream << nDepth; +/*N*/ for (USHORT nLevel=0; nLevel<nDepth; nLevel++) +/*N*/ { +/*N*/ USHORT nCount = aCollections[nLevel].GetCount(); +/*N*/ rStream << nCount; +/*N*/ for (USHORT nIndex=0; nIndex<nCount; nIndex++) +/*N*/ ((ScOutlineEntry*) aCollections[nLevel].At(nIndex))->Store( rStream, aHdr ); +/*N*/ } +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ ScOutlineTable::ScOutlineTable() +/*N*/ { +/*N*/ } + +/*N*/ ScOutlineTable::ScOutlineTable( const ScOutlineTable& rOutline ) : +/*N*/ aColOutline( rOutline.aColOutline ), +/*N*/ aRowOutline( rOutline.aRowOutline ) +/*N*/ { +/*N*/ } + +/*N*/ BOOL ScOutlineTable::TestInsertCol( USHORT nSize ) +/*N*/ { +/*N*/ return aColOutline.TestInsertSpace( nSize, MAXCOL ); +/*N*/ } + +/*N*/ void ScOutlineTable::InsertCol( USHORT nStartCol, USHORT nSize ) +/*N*/ { +/*N*/ aColOutline.InsertSpace( nStartCol, nSize ); +/*N*/ } + +/*N*/ BOOL ScOutlineTable::DeleteCol( USHORT nStartCol, USHORT nSize ) +/*N*/ { +/*N*/ return aColOutline.DeleteSpace( nStartCol, nSize ); +/*N*/ } + +/*N*/ BOOL ScOutlineTable::TestInsertRow( USHORT nSize ) +/*N*/ { +/*N*/ return aRowOutline.TestInsertSpace( nSize, MAXROW ); +/*N*/ } + +/*N*/ void ScOutlineTable::InsertRow( USHORT nStartRow, USHORT nSize ) +/*N*/ { +/*N*/ aRowOutline.InsertSpace( nStartRow, nSize ); +/*N*/ } + +/*N*/ BOOL ScOutlineTable::DeleteRow( USHORT nStartRow, USHORT nSize ) +/*N*/ { +/*N*/ return aRowOutline.DeleteSpace( nStartRow, nSize ); +/*N*/ } + +/*N*/ void ScOutlineTable::Load( SvStream& rStream ) +/*N*/ { +/*N*/ DBG_ASSERT( aColOutline.GetDepth()==0 && aRowOutline.GetDepth()==0, +/*N*/ "Load auf nicht leere ScOutlineTable" ); +/*N*/ aColOutline.Load( rStream ); +/*N*/ aRowOutline.Load( rStream ); +/*N*/ } + +/*N*/ void ScOutlineTable::Store( SvStream& rStream ) +/*N*/ { +/*N*/ aColOutline.Store( rStream ); +/*N*/ aRowOutline.Store( rStream ); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ ScSubOutlineIterator::ScSubOutlineIterator( ScOutlineArray* pOutlineArray ) : +/*N*/ pArray( pOutlineArray ), +/*N*/ nStart( 0 ), +/*N*/ nEnd( USHRT_MAX ), // alle durchgehen +/*N*/ nSubLevel( 0 ), +/*N*/ nSubEntry( 0 ) +/*N*/ { +/*N*/ nDepth = pArray->nDepth; +/*N*/ } + +/*N*/ +/*N*/ ScOutlineEntry* ScSubOutlineIterator::GetNext() +/*N*/ { +/*N*/ ScOutlineEntry* pEntry; +/*N*/ BOOL bFound = FALSE; +/*N*/ do +/*N*/ { +/*N*/ if (nSubLevel >= nDepth) +/*N*/ return NULL; +/*N*/ +/*N*/ pEntry = (ScOutlineEntry*) pArray->aCollections[nSubLevel].At(nSubEntry); +/*N*/ if (!pEntry) +/*N*/ { +/*N*/ nSubEntry = 0; +/*N*/ ++nSubLevel; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ if ( pEntry->GetStart() >= nStart && pEntry->GetEnd() <= nEnd ) +/*N*/ bFound = TRUE; +/*N*/ ++nSubEntry; +/*N*/ } +/*N*/ } +/*N*/ while (!bFound); +/*N*/ return pEntry; // nSubLevel gueltig, wenn pEntry != 0 +/*N*/ } +/*N*/ +/*N*/ void ScSubOutlineIterator::DeleteLast() +/*N*/ { +/*N*/ if (nSubLevel >= nDepth) +/*N*/ { +/*N*/ DBG_ERROR("ScSubOutlineIterator::DeleteLast nach Ende"); +/*N*/ return; +/*N*/ } +/*N*/ if (nSubEntry == 0) +/*N*/ { +/*N*/ DBG_ERROR("ScSubOutlineIterator::DeleteLast vor GetNext"); +/*N*/ return; +/*N*/ } +/*N*/ +/*N*/ --nSubEntry; +/*N*/ pArray->aCollections[nSubLevel].AtFree(nSubEntry); +/*N*/ } + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_pagepar.cxx b/binfilter/bf_sc/source/core/data/sc_pagepar.cxx new file mode 100644 index 000000000000..5e8999b749ea --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_pagepar.cxx @@ -0,0 +1,114 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#include <string.h> + +#include "pagepar.hxx" +namespace binfilter { + + +//======================================================================== +// struct ScPageTableParam: + +/*N*/ ScPageTableParam::ScPageTableParam() +/*N*/ { +/*N*/ Reset(); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ ScPageTableParam::ScPageTableParam( const ScPageTableParam& r ) +/*N*/ { +/*N*/ *this = r; +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ __EXPORT ScPageTableParam::~ScPageTableParam() +/*N*/ { +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ void __EXPORT ScPageTableParam::Reset() +/*N*/ { +/*N*/ bNotes=bGrid=bHeaders=bDrawings= +/*N*/ bLeftRight=bScaleAll=bScalePageNum= +/*N*/ bFormulas=bNullVals=bSkipEmpty = FALSE; +/*N*/ bTopDown=bScaleNone=bCharts=bObjects = TRUE; +/*N*/ nScaleAll = 100; +/*N*/ nScalePageNum = 0; +/*N*/ nFirstPageNo = 1; +/*N*/ } + +//------------------------------------------------------------------------ + + +//------------------------------------------------------------------------ + + +//======================================================================== +// struct ScPageAreaParam: + +/*N*/ ScPageAreaParam::ScPageAreaParam() +/*N*/ { +/*N*/ Reset(); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ ScPageAreaParam::ScPageAreaParam( const ScPageAreaParam& r ) +/*N*/ { +/*N*/ *this = r; +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ __EXPORT ScPageAreaParam::~ScPageAreaParam() +/*N*/ { +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ void __EXPORT ScPageAreaParam::Reset() +/*N*/ { +/*N*/ bPrintArea = bRepeatRow = bRepeatCol = FALSE; +/*N*/ +/*N*/ memset( &aPrintArea, 0, sizeof(ScRange) ); +/*N*/ memset( &aRepeatRow, 0, sizeof(ScRange) ); +/*N*/ memset( &aRepeatCol, 0, sizeof(ScRange) ); +/*N*/ } + +//------------------------------------------------------------------------ + + +//------------------------------------------------------------------------ + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_patattr.cxx b/binfilter/bf_sc/source/core/data/sc_patattr.cxx new file mode 100644 index 000000000000..62e729549694 --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_patattr.cxx @@ -0,0 +1,1175 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "scitems.hxx" +#include <bf_svx/adjitem.hxx> +#include <bf_svx/algitem.hxx> +#include <bf_svx/boxitem.hxx> +#include <bf_svx/brshitem.hxx> +#include <bf_svx/charreliefitem.hxx> +#include <bf_svx/cntritem.hxx> +#include <bf_svtools/colorcfg.hxx> +#include <bf_svx/colritem.hxx> +#include <bf_svx/crsditem.hxx> +#include <bf_svx/emphitem.hxx> +#include <bf_svx/fhgtitem.hxx> +#include <bf_svx/fontitem.hxx> +#include <bf_svx/forbiddenruleitem.hxx> +#include <bf_svx/frmdiritem.hxx> +#include <bf_svx/langitem.hxx> +#include <bf_svx/postitem.hxx> +#include <bf_svx/rotmodit.hxx> +#include <bf_svx/scripttypeitem.hxx> +#include <bf_svx/shaditem.hxx> +#include <bf_svx/shdditem.hxx> +#include <bf_svx/udlnitem.hxx> +#include <bf_svx/wghtitem.hxx> +#include <bf_svx/wrlmitem.hxx> +#include <bf_svtools/zforlist.hxx> +#include <vcl/outdev.hxx> + +#include "patattr.hxx" +#include "docpool.hxx" +#include "stlsheet.hxx" +#include "stlpool.hxx" +#include "document.hxx" +#include "globstr.hrc" +#include "validat.hxx" +#include "scmod.hxx" +namespace binfilter { + +// STATIC DATA ----------------------------------------------------------- + +ScDocument* ScPatternAttr::pDoc = NULL; + +// ----------------------------------------------------------------------- + +//! move to some header file +inline long TwipsToHMM(long nTwips) { return (nTwips * 127 + 36) / 72; } +inline long HMMToTwips(long nHMM) { return (nHMM * 72 + 63) / 127; } + +// ----------------------------------------------------------------------- + +/*N*/ ScPatternAttr::ScPatternAttr( SfxItemSet* pItemSet, const String& rStyleName ) +/*N*/ : SfxSetItem ( ATTR_PATTERN, pItemSet ), +/*N*/ pName ( new String( rStyleName ) ), +/*N*/ pStyle ( NULL ) +/*N*/ { +/*N*/ } + +/*N*/ ScPatternAttr::ScPatternAttr( SfxItemSet* pItemSet, ScStyleSheet* pStyleSheet ) +/*N*/ : SfxSetItem ( ATTR_PATTERN, pItemSet ), +/*N*/ pName ( NULL ), +/*N*/ pStyle ( pStyleSheet ) +/*N*/ { +/*N*/ if ( pStyleSheet ) +/*?*/ GetItemSet().SetParent( &pStyleSheet->GetItemSet() ); +/*N*/ } + +/*N*/ ScPatternAttr::ScPatternAttr( SfxItemPool* pItemPool ) +/*N*/ : SfxSetItem ( ATTR_PATTERN, new SfxItemSet( *pItemPool, ATTR_PATTERN_START, ATTR_PATTERN_END ) ), +/*N*/ pName ( NULL ), +/*N*/ pStyle ( NULL ) +/*N*/ { +/*N*/ } + +/*N*/ ScPatternAttr::ScPatternAttr( const ScPatternAttr& rPatternAttr ) +/*N*/ : SfxSetItem ( rPatternAttr ), +/*N*/ pStyle ( rPatternAttr.pStyle ) +/*N*/ { +/*N*/ if (rPatternAttr.pName) +/*N*/ pName = new String(*rPatternAttr.pName); +/*N*/ else +/*N*/ pName = NULL; +/*N*/ } + +/*N*/ __EXPORT ScPatternAttr::~ScPatternAttr() +/*N*/ { +/*N*/ delete pName; +/*N*/ } + +/*N*/ SfxPoolItem* __EXPORT ScPatternAttr::Clone( SfxItemPool *pPool ) const +/*N*/ { +/*N*/ ScPatternAttr* pPattern = new ScPatternAttr( GetItemSet().Clone(TRUE, pPool) ); +/*N*/ +/*N*/ pPattern->pStyle = pStyle; +/*N*/ pPattern->pName = pName ? new String(*pName) : NULL; +/*N*/ +/*N*/ return pPattern; +/*N*/ } + +/*N*/ inline int StrCmp( const String* pStr1, const String* pStr2 ) +/*N*/ { +/*N*/ return ( pStr1 ? ( pStr2 ? ( *pStr1 == *pStr2 ) : FALSE ) : ( pStr2 ? FALSE : TRUE ) ); +/*N*/ } + +/*N*/ int __EXPORT ScPatternAttr::operator==( const SfxPoolItem& rCmp ) const +/*N*/ { +/*N*/ return ( SfxSetItem::operator==(rCmp) && +/*N*/ StrCmp( GetStyleName(), ((const ScPatternAttr&)rCmp).GetStyleName() ) ); +/*N*/ } + +/*N*/ SfxPoolItem* __EXPORT ScPatternAttr::Create( SvStream& rStream, USHORT nVersion ) const +/*N*/ { +/*N*/ String* pStr; +/*N*/ BOOL bHasStyle; +/*N*/ short eFamDummy; +/*N*/ +/*N*/ rStream >> bHasStyle; +/*N*/ +/*N*/ if ( bHasStyle ) +/*N*/ { +/*N*/ pStr = new String; +/*N*/ rStream.ReadByteString( *pStr, rStream.GetStreamCharSet() ); +/*N*/ rStream >> eFamDummy; // wg. altem Dateiformat +/*N*/ } +/*N*/ else +/*N*/ pStr = new String( ScGlobal::GetRscString(STR_STYLENAME_STANDARD) ); +/*N*/ +/*N*/ SfxItemSet *pSet = new SfxItemSet( *GetItemSet().GetPool(), +/*N*/ ATTR_PATTERN_START, ATTR_PATTERN_END ); +/*N*/ pSet->Load( rStream ); +/*N*/ +/*N*/ ScPatternAttr* pPattern = new ScPatternAttr( pSet ); +/*N*/ +/*N*/ pPattern->pName = pStr; +/*N*/ +/*N*/ return pPattern; +/*N*/ } + +/*N*/ SvStream& __EXPORT ScPatternAttr::Store(SvStream& rStream, USHORT nItemVersion) const +/*N*/ { +/*N*/ rStream << (BOOL)TRUE; +/*N*/ +/*N*/ if ( pStyle ) +/*N*/ rStream.WriteByteString( pStyle->GetName(), rStream.GetStreamCharSet() ); +/*N*/ else if ( pName ) // wenn Style geloescht ist/war +/*?*/ rStream.WriteByteString( *pName, rStream.GetStreamCharSet() ); +/*N*/ else +/*N*/ rStream.WriteByteString( ScGlobal::GetRscString(STR_STYLENAME_STANDARD), +/*N*/ rStream.GetStreamCharSet() ); +/*N*/ +/*N*/ rStream << (short)SFX_STYLE_FAMILY_PARA; // wg. altem Dateiformat +/*N*/ +/*N*/ GetItemSet().Store( rStream ); +/*N*/ +/*N*/ return rStream; +/*N*/ } + +/*N*/ void ScPatternAttr::GetFont( +/*N*/ Font& rFont, const SfxItemSet& rItemSet, ScAutoFontColorMode eAutoMode, +/*N*/ OutputDevice* pOutDev, const Fraction* pScale, +/*N*/ const SfxItemSet* pCondSet, BYTE nScript, +/*N*/ const Color* pBackConfigColor, const Color* pTextConfigColor ) +/*N*/ { +/*N*/ // Items auslesen +/*N*/ +/*N*/ const SvxFontItem* pFontAttr; +/*N*/ UINT32 nFontHeight; +/*N*/ FontWeight eWeight; +/*N*/ FontItalic eItalic; +/*N*/ FontUnderline eUnder; +/*N*/ BOOL bWordLine; +/*N*/ FontStrikeout eStrike; +/*N*/ BOOL bOutline; +/*N*/ BOOL bShadow; +/*N*/ FontEmphasisMark eEmphasis; +/*N*/ FontRelief eRelief; +/*N*/ Color aColor; +/*N*/ +/*N*/ USHORT nFontId, nHeightId, nWeightId, nPostureId; +/*N*/ if ( nScript == SCRIPTTYPE_ASIAN ) +/*N*/ { +/*?*/ nFontId = ATTR_CJK_FONT; +/*?*/ nHeightId = ATTR_CJK_FONT_HEIGHT; +/*?*/ nWeightId = ATTR_CJK_FONT_WEIGHT; +/*?*/ nPostureId = ATTR_CJK_FONT_POSTURE; +/*N*/ } +/*N*/ else if ( nScript == SCRIPTTYPE_COMPLEX ) +/*N*/ { +/*?*/ nFontId = ATTR_CTL_FONT; +/*?*/ nHeightId = ATTR_CTL_FONT_HEIGHT; +/*?*/ nWeightId = ATTR_CTL_FONT_WEIGHT; +/*?*/ nPostureId = ATTR_CTL_FONT_POSTURE; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ nFontId = ATTR_FONT; +/*N*/ nHeightId = ATTR_FONT_HEIGHT; +/*N*/ nWeightId = ATTR_FONT_WEIGHT; +/*N*/ nPostureId = ATTR_FONT_POSTURE; +/*N*/ } +/*N*/ +/*N*/ if ( pCondSet ) +/*N*/ { +/*N*/ const SfxPoolItem* pItem; +/*N*/ +/*N*/ if ( pCondSet->GetItemState( nFontId, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rItemSet.Get( nFontId ); +/*N*/ pFontAttr = (const SvxFontItem*) pItem; +/*N*/ +/*N*/ if ( pCondSet->GetItemState( nHeightId, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rItemSet.Get( nHeightId ); +/*N*/ nFontHeight = ((const SvxFontHeightItem*)pItem)->GetHeight(); +/*N*/ +/*N*/ if ( pCondSet->GetItemState( nWeightId, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rItemSet.Get( nWeightId ); +/*N*/ eWeight = (FontWeight)((const SvxWeightItem*)pItem)->GetValue(); +/*N*/ +/*N*/ if ( pCondSet->GetItemState( nPostureId, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rItemSet.Get( nPostureId ); +/*N*/ eItalic = (FontItalic)((const SvxPostureItem*)pItem)->GetValue(); +/*N*/ +/*N*/ if ( pCondSet->GetItemState( ATTR_FONT_UNDERLINE, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rItemSet.Get( ATTR_FONT_UNDERLINE ); +/*N*/ eUnder = (FontUnderline)((const SvxUnderlineItem*)pItem)->GetValue(); +/*N*/ +/*N*/ if ( pCondSet->GetItemState( ATTR_FONT_WORDLINE, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rItemSet.Get( ATTR_FONT_WORDLINE ); +/*N*/ bWordLine = ((const SvxWordLineModeItem*)pItem)->GetValue(); +/*N*/ +/*N*/ if ( pCondSet->GetItemState( ATTR_FONT_CROSSEDOUT, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rItemSet.Get( ATTR_FONT_CROSSEDOUT ); +/*N*/ eStrike = (FontStrikeout)((const SvxCrossedOutItem*)pItem)->GetValue(); +/*N*/ +/*N*/ if ( pCondSet->GetItemState( ATTR_FONT_CONTOUR, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rItemSet.Get( ATTR_FONT_CONTOUR ); +/*N*/ bOutline = ((const SvxContourItem*)pItem)->GetValue(); +/*N*/ +/*N*/ if ( pCondSet->GetItemState( ATTR_FONT_SHADOWED, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rItemSet.Get( ATTR_FONT_SHADOWED ); +/*N*/ bShadow = ((const SvxShadowedItem*)pItem)->GetValue(); +/*N*/ +/*N*/ if ( pCondSet->GetItemState( ATTR_FONT_EMPHASISMARK, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rItemSet.Get( ATTR_FONT_EMPHASISMARK ); +/*N*/ eEmphasis = ((const SvxEmphasisMarkItem*)pItem)->GetEmphasisMark(); +/*N*/ +/*N*/ if ( pCondSet->GetItemState( ATTR_FONT_RELIEF, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rItemSet.Get( ATTR_FONT_RELIEF ); +/*N*/ eRelief = (FontRelief)((const SvxCharReliefItem*)pItem)->GetValue(); +/*N*/ +/*N*/ if ( pCondSet->GetItemState( ATTR_FONT_COLOR, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rItemSet.Get( ATTR_FONT_COLOR ); +/*N*/ aColor = ((const SvxColorItem*)pItem)->GetValue(); +/*N*/ } +/*N*/ else // alles aus rItemSet +/*N*/ { +/*N*/ pFontAttr = &(const SvxFontItem&)rItemSet.Get( nFontId ); +/*N*/ nFontHeight = ((const SvxFontHeightItem&) +/*N*/ rItemSet.Get( nHeightId )).GetHeight(); +/*N*/ eWeight = (FontWeight)((const SvxWeightItem&) +/*N*/ rItemSet.Get( nWeightId )).GetValue(); +/*N*/ eItalic = (FontItalic)((const SvxPostureItem&) +/*N*/ rItemSet.Get( nPostureId )).GetValue(); +/*N*/ eUnder = (FontUnderline)((const SvxUnderlineItem&) +/*N*/ rItemSet.Get( ATTR_FONT_UNDERLINE )).GetValue(); +/*N*/ bWordLine = ((const SvxWordLineModeItem&) +/*N*/ rItemSet.Get( ATTR_FONT_WORDLINE )).GetValue(); +/*N*/ eStrike = (FontStrikeout)((const SvxCrossedOutItem&) +/*N*/ rItemSet.Get( ATTR_FONT_CROSSEDOUT )).GetValue(); +/*N*/ bOutline = ((const SvxContourItem&) +/*N*/ rItemSet.Get( ATTR_FONT_CONTOUR )).GetValue(); +/*N*/ bShadow = ((const SvxShadowedItem&) +/*N*/ rItemSet.Get( ATTR_FONT_SHADOWED )).GetValue(); +/*N*/ eEmphasis = ((const SvxEmphasisMarkItem&) +/*N*/ rItemSet.Get( ATTR_FONT_EMPHASISMARK )).GetEmphasisMark(); +/*N*/ eRelief = (FontRelief)((const SvxCharReliefItem&) +/*N*/ rItemSet.Get( ATTR_FONT_RELIEF )).GetValue(); +/*N*/ aColor = ((const SvxColorItem&) +/*N*/ rItemSet.Get( ATTR_FONT_COLOR )).GetValue(); +/*N*/ } +/*N*/ DBG_ASSERT(pFontAttr,"nanu?"); +/*N*/ +/*N*/ // auswerten +/*N*/ +/*N*/ // FontItem: +/*N*/ +/*N*/ if (rFont.GetName() != pFontAttr->GetFamilyName()) +/*N*/ rFont.SetName( pFontAttr->GetFamilyName() ); +/*N*/ if (rFont.GetStyleName() != pFontAttr->GetStyleName()) +/*?*/ rFont.SetStyleName( pFontAttr->GetStyleName() ); +/*N*/ if (rFont.GetFamily() != pFontAttr->GetFamily()) +/*N*/ rFont.SetFamily( pFontAttr->GetFamily() ); +/*N*/ if (rFont.GetCharSet() != pFontAttr->GetCharSet()) +/*N*/ rFont.SetCharSet( pFontAttr->GetCharSet() ); +/*N*/ if (rFont.GetPitch() != pFontAttr->GetPitch()) +/*N*/ rFont.SetPitch( pFontAttr->GetPitch() ); +/*N*/ +/*N*/ // Groesse +/*N*/ +/*N*/ if ( pOutDev != NULL ) +/*N*/ { +/*N*/ Size aEffSize; +/*N*/ Fraction aFraction( 1,1 ); +/*N*/ if (pScale) +/*N*/ aFraction = *pScale; +/*N*/ Size aSize( 0, (long) nFontHeight ); +/*N*/ MapMode aDestMode = pOutDev->GetMapMode(); +/*N*/ MapMode aSrcMode( MAP_TWIP, Point(), aFraction, aFraction ); +/*N*/ if (aDestMode.GetMapUnit() == MAP_PIXEL) +/*N*/ aEffSize = pOutDev->LogicToPixel( aSize, aSrcMode ); +/*N*/ else +/*N*/ { +/*?*/ Fraction aFractOne(1,1); +/*?*/ aDestMode.SetScaleX( aFractOne ); +/*?*/ aDestMode.SetScaleY( aFractOne ); +/*?*/ aEffSize = OutputDevice::LogicToLogic( aSize, aSrcMode, aDestMode ); +/*N*/ } +/*N*/ rFont.SetSize( aEffSize ); +/*N*/ } +/*N*/ else /* if pOutDev != NULL */ +/*N*/ { +/*?*/ rFont.SetSize( Size( 0, (long) nFontHeight ) ); +/*N*/ } +/*N*/ + // determine effective font color + +/*M*/ if ( ( aColor.GetColor() == COL_AUTO && eAutoMode != SC_AUTOCOL_RAW ) || +/*M*/ eAutoMode == SC_AUTOCOL_IGNOREFONT || eAutoMode == SC_AUTOCOL_IGNOREALL ) +/*M*/ { +/*M*/ if ( eAutoMode == SC_AUTOCOL_BLACK ) +/*M*/ aColor.SetColor( COL_BLACK ); +/*M*/ else +/*M*/ { +/*M*/ // get background color from conditional or own set +/*M*/ Color aBackColor; +/*M*/ if ( pCondSet ) +/*M*/ { +/*M*/ const SfxPoolItem* pItem; +/*M*/ if ( pCondSet->GetItemState( ATTR_BACKGROUND, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rItemSet.Get( ATTR_BACKGROUND ); +/*M*/ aBackColor = ((const SvxBrushItem*)pItem)->GetColor(); +/*M*/ } +/*M*/ else +/*N*/ aBackColor = ((const SvxBrushItem&)rItemSet.Get( ATTR_BACKGROUND )).GetColor(); +/*M*/ +/*M*/ // if background color attribute is transparent, use window color for brightness comparisons +/*M*/ if ( aBackColor == COL_TRANSPARENT || +/*M*/ eAutoMode == SC_AUTOCOL_IGNOREBACK || eAutoMode == SC_AUTOCOL_IGNOREALL ) +/*M*/ { +/*M*/ if ( eAutoMode == SC_AUTOCOL_PRINT ) +/*M*/ aBackColor.SetColor( COL_WHITE ); +/*M*/ else if ( pBackConfigColor ) +/*M*/ { +/*M*/ // pBackConfigColor can be used to avoid repeated lookup of the configured color +/*M*/ aBackColor = *pBackConfigColor; +/*M*/ } +/*M*/ else +/*N*/ aBackColor.SetColor( SC_MOD()->GetColorConfig().GetColorValue(DOCCOLOR).nColor ); +/*M*/ } +/*M*/ +/*M*/ // get system text color for comparison +/*M*/ Color aSysTextColor; +/*M*/ if ( eAutoMode == SC_AUTOCOL_PRINT ) +/*M*/ aSysTextColor.SetColor( COL_BLACK ); +/*N*/ else if ( pTextConfigColor ) +/*N*/ { +/*N*/ // pTextConfigColor can be used to avoid repeated lookup of the configured color +/*N*/ aSysTextColor = *pTextConfigColor; +/*N*/ } +/*N*/ else +/*N*/ aSysTextColor.SetColor( SC_MOD()->GetColorConfig().GetColorValue(FONTCOLOR).nColor ); +/*M*/ +/*M*/ // select the resulting color +/*M*/ if ( aBackColor.IsDark() && aSysTextColor.IsDark() ) +/*M*/ { +/*M*/ // use white instead of dark on dark +/*M*/ aColor.SetColor( COL_WHITE ); +/*M*/ } +/*M*/ else if ( aBackColor.IsBright() && aSysTextColor.IsBright() ) +/*M*/ { +/*M*/ // use black instead of bright on bright +/*M*/ aColor.SetColor( COL_BLACK ); +/*M*/ } +/*M*/ else +/*M*/ { +/*M*/ // use aSysTextColor (black for SC_AUTOCOL_PRINT, from style settings otherwise) +/*M*/ aColor = aSysTextColor; +/*M*/ } +/*M*/ } +/*M*/ } + + // set font effects + +/*N*/ if (rFont.GetWeight() != eWeight) +/*N*/ rFont.SetWeight( eWeight ); +/*N*/ if (rFont.GetItalic() != eItalic) +/*N*/ rFont.SetItalic( eItalic ); +/*N*/ if (rFont.GetUnderline() != eUnder) +/*N*/ rFont.SetUnderline( eUnder ); +/*N*/ if (rFont.IsWordLineMode() != bWordLine) +/*N*/ rFont.SetWordLineMode( bWordLine ); +/*N*/ if (rFont.GetStrikeout() != eStrike) +/*N*/ rFont.SetStrikeout( eStrike ); +/*N*/ if (rFont.IsOutline() != bOutline) +/*N*/ rFont.SetOutline( bOutline ); +/*N*/ if (rFont.IsShadow() != bShadow) +/*N*/ rFont.SetShadow( bShadow ); +/*N*/ if (rFont.GetEmphasisMark() != eEmphasis) +/*N*/ rFont.SetEmphasisMark( eEmphasis ); +/*N*/ if (rFont.GetRelief() != eRelief) +/*N*/ rFont.SetRelief( eRelief ); +/*N*/ if (rFont.GetColor() != aColor) +/*N*/ rFont.SetColor( aColor ); +/*N*/ if (!rFont.IsTransparent()) +/*N*/ rFont.SetTransparent( TRUE ); +/*N*/ } + +/*N*/ void ScPatternAttr::GetFont( +/*N*/ Font& rFont, ScAutoFontColorMode eAutoMode, +/*N*/ OutputDevice* pOutDev, const Fraction* pScale, +/*N*/ const SfxItemSet* pCondSet, BYTE nScript, +/*N*/ const Color* pBackConfigColor, const Color* pTextConfigColor ) const +/*N*/ { +/*N*/ GetFont( rFont, GetItemSet(), eAutoMode, pOutDev, pScale, pCondSet, nScript, pBackConfigColor, pTextConfigColor ); +/*N*/ } + + +/*N*/ void ScPatternAttr::FillToEditItemSet( SfxItemSet& rEditSet, const SfxItemSet& rSrcSet, const SfxItemSet* pCondSet ) +/*N*/ { +/*N*/ // Items auslesen +/*N*/ +/*N*/ SvxColorItem aColorItem(EE_CHAR_COLOR); // use item as-is +/*N*/ SvxFontItem aFontItem(EE_CHAR_FONTINFO); // use item as-is +/*N*/ SvxFontItem aCjkFontItem(EE_CHAR_FONTINFO_CJK); +/*N*/ SvxFontItem aCtlFontItem(EE_CHAR_FONTINFO_CTL); +/*N*/ long nTHeight, nCjkTHeight, nCtlTHeight; // Twips +/*N*/ FontWeight eWeight, eCjkWeight, eCtlWeight; +/*N*/ SvxUnderlineItem aUnderlineItem(UNDERLINE_NONE, EE_CHAR_UNDERLINE); +/*N*/ BOOL bWordLine; +/*N*/ FontStrikeout eStrike; +/*N*/ FontItalic eItalic, eCjkItalic, eCtlItalic; +/*N*/ BOOL bOutline; +/*N*/ BOOL bShadow; +/*N*/ BOOL bForbidden; +/*N*/ FontEmphasisMark eEmphasis; +/*N*/ FontRelief eRelief; +/*N*/ LanguageType eLang, eCjkLang, eCtlLang; +/*N*/ BOOL bHyphenate; +/*N*/ SvxFrameDirection eDirection; +/*N*/ +/*N*/ //! additional parameter to control if language is needed? +/*N*/ +/*N*/ if ( pCondSet ) +/*N*/ { +/*N*/ const SfxPoolItem* pItem; +/*N*/ +/*N*/ if ( pCondSet->GetItemState( ATTR_FONT_COLOR, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rSrcSet.Get( ATTR_FONT_COLOR ); +/*N*/ aColorItem = *(const SvxColorItem*)pItem; +/*N*/ +/*N*/ if ( pCondSet->GetItemState( ATTR_FONT, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rSrcSet.Get( ATTR_FONT ); +/*N*/ aFontItem = *(const SvxFontItem*)pItem; +/*N*/ if ( pCondSet->GetItemState( ATTR_CJK_FONT, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rSrcSet.Get( ATTR_CJK_FONT ); +/*N*/ aCjkFontItem = *(const SvxFontItem*)pItem; +/*N*/ if ( pCondSet->GetItemState( ATTR_CTL_FONT, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rSrcSet.Get( ATTR_CTL_FONT ); +/*N*/ aCtlFontItem = *(const SvxFontItem*)pItem; +/*N*/ +/*N*/ if ( pCondSet->GetItemState( ATTR_FONT_HEIGHT, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rSrcSet.Get( ATTR_FONT_HEIGHT ); +/*N*/ nTHeight = ((const SvxFontHeightItem*)pItem)->GetHeight(); +/*N*/ if ( pCondSet->GetItemState( ATTR_CJK_FONT_HEIGHT, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rSrcSet.Get( ATTR_CJK_FONT_HEIGHT ); +/*N*/ nCjkTHeight = ((const SvxFontHeightItem*)pItem)->GetHeight(); +/*N*/ if ( pCondSet->GetItemState( ATTR_CTL_FONT_HEIGHT, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rSrcSet.Get( ATTR_CTL_FONT_HEIGHT ); +/*N*/ nCtlTHeight = ((const SvxFontHeightItem*)pItem)->GetHeight(); +/*N*/ +/*N*/ if ( pCondSet->GetItemState( ATTR_FONT_WEIGHT, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rSrcSet.Get( ATTR_FONT_WEIGHT ); +/*N*/ eWeight = (FontWeight)((const SvxWeightItem*)pItem)->GetValue(); +/*N*/ if ( pCondSet->GetItemState( ATTR_CJK_FONT_WEIGHT, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rSrcSet.Get( ATTR_CJK_FONT_WEIGHT ); +/*N*/ eCjkWeight = (FontWeight)((const SvxWeightItem*)pItem)->GetValue(); +/*N*/ if ( pCondSet->GetItemState( ATTR_CTL_FONT_WEIGHT, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rSrcSet.Get( ATTR_CTL_FONT_WEIGHT ); +/*N*/ eCtlWeight = (FontWeight)((const SvxWeightItem*)pItem)->GetValue(); +/*N*/ +/*N*/ if ( pCondSet->GetItemState( ATTR_FONT_POSTURE, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rSrcSet.Get( ATTR_FONT_POSTURE ); +/*N*/ eItalic = (FontItalic)((const SvxPostureItem*)pItem)->GetValue(); +/*N*/ if ( pCondSet->GetItemState( ATTR_CJK_FONT_POSTURE, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rSrcSet.Get( ATTR_CJK_FONT_POSTURE ); +/*N*/ eCjkItalic = (FontItalic)((const SvxPostureItem*)pItem)->GetValue(); +/*N*/ if ( pCondSet->GetItemState( ATTR_CTL_FONT_POSTURE, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rSrcSet.Get( ATTR_CTL_FONT_POSTURE ); +/*N*/ eCtlItalic = (FontItalic)((const SvxPostureItem*)pItem)->GetValue(); +/*N*/ +/*N*/ if ( pCondSet->GetItemState( ATTR_FONT_UNDERLINE, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rSrcSet.Get( ATTR_FONT_UNDERLINE ); +/*N*/ aUnderlineItem = *(const SvxUnderlineItem*)pItem; +/*N*/ +/*N*/ if ( pCondSet->GetItemState( ATTR_FONT_WORDLINE, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rSrcSet.Get( ATTR_FONT_WORDLINE ); +/*N*/ bWordLine = ((const SvxWordLineModeItem*)pItem)->GetValue(); +/*N*/ +/*N*/ if ( pCondSet->GetItemState( ATTR_FONT_CROSSEDOUT, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rSrcSet.Get( ATTR_FONT_CROSSEDOUT ); +/*N*/ eStrike = (FontStrikeout)((const SvxCrossedOutItem*)pItem)->GetValue(); +/*N*/ +/*N*/ if ( pCondSet->GetItemState( ATTR_FONT_CONTOUR, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rSrcSet.Get( ATTR_FONT_CONTOUR ); +/*N*/ bOutline = ((const SvxContourItem*)pItem)->GetValue(); +/*N*/ +/*N*/ if ( pCondSet->GetItemState( ATTR_FONT_SHADOWED, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rSrcSet.Get( ATTR_FONT_SHADOWED ); +/*N*/ bShadow = ((const SvxShadowedItem*)pItem)->GetValue(); +/*N*/ +/*N*/ if ( pCondSet->GetItemState( ATTR_FORBIDDEN_RULES, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rSrcSet.Get( ATTR_FORBIDDEN_RULES ); +/*N*/ bForbidden = ((const SvxForbiddenRuleItem*)pItem)->GetValue(); +/*N*/ +/*N*/ if ( pCondSet->GetItemState( ATTR_FONT_EMPHASISMARK, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rSrcSet.Get( ATTR_FONT_EMPHASISMARK ); +/*N*/ eEmphasis = ((const SvxEmphasisMarkItem*)pItem)->GetEmphasisMark(); +/*N*/ if ( pCondSet->GetItemState( ATTR_FONT_RELIEF, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rSrcSet.Get( ATTR_FONT_RELIEF ); +/*N*/ eRelief = (FontRelief)((const SvxCharReliefItem*)pItem)->GetValue(); +/*N*/ +/*N*/ if ( pCondSet->GetItemState( ATTR_FONT_LANGUAGE, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rSrcSet.Get( ATTR_FONT_LANGUAGE ); +/*N*/ eLang = ((const SvxLanguageItem*)pItem)->GetLanguage(); +/*N*/ if ( pCondSet->GetItemState( ATTR_CJK_FONT_LANGUAGE, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rSrcSet.Get( ATTR_CJK_FONT_LANGUAGE ); +/*N*/ eCjkLang = ((const SvxLanguageItem*)pItem)->GetLanguage(); +/*N*/ if ( pCondSet->GetItemState( ATTR_CTL_FONT_LANGUAGE, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rSrcSet.Get( ATTR_CTL_FONT_LANGUAGE ); +/*N*/ eCtlLang = ((const SvxLanguageItem*)pItem)->GetLanguage(); +/*N*/ +/*N*/ if ( pCondSet->GetItemState( ATTR_HYPHENATE, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rSrcSet.Get( ATTR_HYPHENATE ); +/*N*/ bHyphenate = ((const SfxBoolItem*)pItem)->GetValue(); +/*N*/ +/*N*/ if ( pCondSet->GetItemState( ATTR_WRITINGDIR, TRUE, &pItem ) != SFX_ITEM_SET ) +/*N*/ pItem = &rSrcSet.Get( ATTR_WRITINGDIR ); +/*N*/ eDirection = (SvxFrameDirection)((const SvxFrameDirectionItem*)pItem)->GetValue(); +/*N*/ } +/*N*/ else // alles direkt aus Pattern +/*N*/ { +/*N*/ aColorItem = (const SvxColorItem&) rSrcSet.Get( ATTR_FONT_COLOR ); +/*N*/ aFontItem = (const SvxFontItem&) rSrcSet.Get( ATTR_FONT ); +/*N*/ aCjkFontItem = (const SvxFontItem&) rSrcSet.Get( ATTR_CJK_FONT ); +/*N*/ aCtlFontItem = (const SvxFontItem&) rSrcSet.Get( ATTR_CTL_FONT ); +/*N*/ nTHeight = ((const SvxFontHeightItem&) +/*N*/ rSrcSet.Get( ATTR_FONT_HEIGHT )).GetHeight(); +/*N*/ nCjkTHeight = ((const SvxFontHeightItem&) +/*N*/ rSrcSet.Get( ATTR_CJK_FONT_HEIGHT )).GetHeight(); +/*N*/ nCtlTHeight = ((const SvxFontHeightItem&) +/*N*/ rSrcSet.Get( ATTR_CTL_FONT_HEIGHT )).GetHeight(); +/*N*/ eWeight = (FontWeight)((const SvxWeightItem&) +/*N*/ rSrcSet.Get( ATTR_FONT_WEIGHT )).GetValue(); +/*N*/ eCjkWeight = (FontWeight)((const SvxWeightItem&) +/*N*/ rSrcSet.Get( ATTR_CJK_FONT_WEIGHT )).GetValue(); +/*N*/ eCtlWeight = (FontWeight)((const SvxWeightItem&) +/*N*/ rSrcSet.Get( ATTR_CTL_FONT_WEIGHT )).GetValue(); +/*N*/ eItalic = (FontItalic)((const SvxPostureItem&) +/*N*/ rSrcSet.Get( ATTR_FONT_POSTURE )).GetValue(); +/*N*/ eCjkItalic = (FontItalic)((const SvxPostureItem&) +/*N*/ rSrcSet.Get( ATTR_CJK_FONT_POSTURE )).GetValue(); +/*N*/ eCtlItalic = (FontItalic)((const SvxPostureItem&) +/*N*/ rSrcSet.Get( ATTR_CTL_FONT_POSTURE )).GetValue(); +/*N*/ aUnderlineItem = (const SvxUnderlineItem&) rSrcSet.Get( ATTR_FONT_UNDERLINE ); +/*N*/ bWordLine = ((const SvxWordLineModeItem&) +/*N*/ rSrcSet.Get( ATTR_FONT_WORDLINE )).GetValue(); +/*N*/ eStrike = (FontStrikeout)((const SvxCrossedOutItem&) +/*N*/ rSrcSet.Get( ATTR_FONT_CROSSEDOUT )).GetValue(); +/*N*/ bOutline = ((const SvxContourItem&) +/*N*/ rSrcSet.Get( ATTR_FONT_CONTOUR )).GetValue(); +/*N*/ bShadow = ((const SvxShadowedItem&) +/*N*/ rSrcSet.Get( ATTR_FONT_SHADOWED )).GetValue(); +/*N*/ bForbidden = ((const SvxForbiddenRuleItem&) +/*N*/ rSrcSet.Get( ATTR_FORBIDDEN_RULES )).GetValue(); +/*N*/ eEmphasis = ((const SvxEmphasisMarkItem&) +/*N*/ rSrcSet.Get( ATTR_FONT_EMPHASISMARK )).GetEmphasisMark(); +/*N*/ eRelief = (FontRelief)((const SvxCharReliefItem&) +/*N*/ rSrcSet.Get( ATTR_FONT_RELIEF )).GetValue(); +/*N*/ eLang = ((const SvxLanguageItem&) +/*N*/ rSrcSet.Get( ATTR_FONT_LANGUAGE )).GetLanguage(); +/*N*/ eCjkLang = ((const SvxLanguageItem&) +/*N*/ rSrcSet.Get( ATTR_CJK_FONT_LANGUAGE )).GetLanguage(); +/*N*/ eCtlLang = ((const SvxLanguageItem&) +/*N*/ rSrcSet.Get( ATTR_CTL_FONT_LANGUAGE )).GetLanguage(); +/*N*/ bHyphenate = ((const SfxBoolItem&) +/*N*/ rSrcSet.Get( ATTR_HYPHENATE )).GetValue(); +/*N*/ eDirection = (SvxFrameDirection)((const SvxFrameDirectionItem&) +/*N*/ rSrcSet.Get( ATTR_WRITINGDIR )).GetValue(); +/*N*/ } +/*N*/ +/*N*/ // kompatibel zu LogicToLogic rechnen, also 2540/1440 = 127/72, und runden +/*N*/ +/*N*/ long nHeight = TwipsToHMM(nTHeight); +/*N*/ long nCjkHeight = TwipsToHMM(nCjkTHeight); +/*N*/ long nCtlHeight = TwipsToHMM(nCtlTHeight); +/*N*/ +/*N*/ // put items into EditEngine ItemSet +/*N*/ +/*N*/ if ( aColorItem.GetValue().GetColor() == COL_AUTO ) +/*N*/ { +/*N*/ // #108979# When cell attributes are converted to EditEngine paragraph attributes, +/*N*/ // don't create a hard item for automatic color, because that would be converted +/*N*/ // to black when the item's Store method is used in CreateTransferable/WriteBin. +/*N*/ // COL_AUTO is the EditEngine's pool default, so ClearItem will result in automatic +/*N*/ // color, too, without having to store the item. +/*N*/ rEditSet.ClearItem( EE_CHAR_COLOR ); +/*N*/ } +/*N*/ else +/*N*/ rEditSet.Put( aColorItem ); +/*N*/ rEditSet.Put( aFontItem ); +/*N*/ rEditSet.Put( aCjkFontItem ); +/*N*/ rEditSet.Put( aCtlFontItem ); +/*N*/ rEditSet.Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT ) ); +/*N*/ rEditSet.Put( SvxFontHeightItem( nCjkHeight, 100, EE_CHAR_FONTHEIGHT_CJK ) ); +/*N*/ rEditSet.Put( SvxFontHeightItem( nCtlHeight, 100, EE_CHAR_FONTHEIGHT_CTL ) ); +/*N*/ rEditSet.Put( SvxWeightItem ( eWeight, EE_CHAR_WEIGHT ) ); +/*N*/ rEditSet.Put( SvxWeightItem ( eCjkWeight, EE_CHAR_WEIGHT_CJK ) ); +/*N*/ rEditSet.Put( SvxWeightItem ( eCtlWeight, EE_CHAR_WEIGHT_CTL ) ); +/*N*/ rEditSet.Put( aUnderlineItem ); +/*N*/ rEditSet.Put( SvxWordLineModeItem( bWordLine, EE_CHAR_WLM ) ); +/*N*/ rEditSet.Put( SvxCrossedOutItem( eStrike, EE_CHAR_STRIKEOUT ) ); +/*N*/ rEditSet.Put( SvxPostureItem ( eItalic, EE_CHAR_ITALIC ) ); +/*N*/ rEditSet.Put( SvxPostureItem ( eCjkItalic, EE_CHAR_ITALIC_CJK ) ); +/*N*/ rEditSet.Put( SvxPostureItem ( eCtlItalic, EE_CHAR_ITALIC_CTL ) ); +/*N*/ rEditSet.Put( SvxContourItem ( bOutline, EE_CHAR_OUTLINE ) ); +/*N*/ rEditSet.Put( SvxShadowedItem ( bShadow, EE_CHAR_SHADOW ) ); +/*N*/ rEditSet.Put( SfxBoolItem ( EE_PARA_FORBIDDENRULES, bForbidden ) ); +/*N*/ rEditSet.Put( SvxEmphasisMarkItem( eEmphasis, EE_CHAR_EMPHASISMARK ) ); +/*N*/ rEditSet.Put( SvxCharReliefItem( eRelief, EE_CHAR_RELIEF ) ); +/*N*/ rEditSet.Put( SvxLanguageItem ( eLang, EE_CHAR_LANGUAGE ) ); +/*N*/ rEditSet.Put( SvxLanguageItem ( eCjkLang, EE_CHAR_LANGUAGE_CJK ) ); +/*N*/ rEditSet.Put( SvxLanguageItem ( eCtlLang, EE_CHAR_LANGUAGE_CTL ) ); +/*N*/ rEditSet.Put( SfxBoolItem ( EE_PARA_HYPHENATE, bHyphenate ) ); +/*N*/ rEditSet.Put( SvxFrameDirectionItem( eDirection, EE_PARA_WRITINGDIR ) ); +/*N*/ } + +/*N*/ void ScPatternAttr::FillEditItemSet( SfxItemSet* pEditSet, const SfxItemSet* pCondSet ) const +/*N*/ { +/*N*/ if( pEditSet ) +/*N*/ FillToEditItemSet( *pEditSet, GetItemSet(), pCondSet ); +/*N*/ } + + +/*N*/ void ScPatternAttr::GetFromEditItemSet( SfxItemSet& rDestSet, const SfxItemSet& rEditSet ) +/*N*/ { +/*N*/ const SfxPoolItem* pItem; +/*N*/ +/*N*/ if (rEditSet.GetItemState(EE_CHAR_COLOR,TRUE,&pItem) == SFX_ITEM_SET) +/*N*/ rDestSet.Put( SvxColorItem(ATTR_FONT_COLOR) = *(const SvxColorItem*)pItem ); +/*N*/ +/*N*/ if (rEditSet.GetItemState(EE_CHAR_FONTINFO,TRUE,&pItem) == SFX_ITEM_SET) +/*N*/ rDestSet.Put( SvxFontItem(ATTR_FONT) = *(const SvxFontItem*)pItem ); +/*N*/ if (rEditSet.GetItemState(EE_CHAR_FONTINFO_CJK,TRUE,&pItem) == SFX_ITEM_SET) +/*N*/ rDestSet.Put( SvxFontItem(ATTR_CJK_FONT) = *(const SvxFontItem*)pItem ); +/*N*/ if (rEditSet.GetItemState(EE_CHAR_FONTINFO_CTL,TRUE,&pItem) == SFX_ITEM_SET) +/*N*/ rDestSet.Put( SvxFontItem(ATTR_CTL_FONT) = *(const SvxFontItem*)pItem ); +/*N*/ +/*N*/ if (rEditSet.GetItemState(EE_CHAR_FONTHEIGHT,TRUE,&pItem) == SFX_ITEM_SET) +/*N*/ rDestSet.Put( SvxFontHeightItem( HMMToTwips( ((const SvxFontHeightItem*)pItem)->GetHeight() ), +/*N*/ 100, ATTR_FONT_HEIGHT ) ); +/*N*/ if (rEditSet.GetItemState(EE_CHAR_FONTHEIGHT_CJK,TRUE,&pItem) == SFX_ITEM_SET) +/*N*/ rDestSet.Put( SvxFontHeightItem( HMMToTwips( ((const SvxFontHeightItem*)pItem)->GetHeight() ), +/*N*/ 100, ATTR_CJK_FONT_HEIGHT ) ); +/*N*/ if (rEditSet.GetItemState(EE_CHAR_FONTHEIGHT_CTL,TRUE,&pItem) == SFX_ITEM_SET) +/*N*/ rDestSet.Put( SvxFontHeightItem( HMMToTwips( ((const SvxFontHeightItem*)pItem)->GetHeight() ), +/*N*/ 100, ATTR_CTL_FONT_HEIGHT ) ); +/*N*/ +/*N*/ if (rEditSet.GetItemState(EE_CHAR_WEIGHT,TRUE,&pItem) == SFX_ITEM_SET) +/*N*/ rDestSet.Put( SvxWeightItem( (FontWeight)((const SvxWeightItem*)pItem)->GetValue(), +/*N*/ ATTR_FONT_WEIGHT) ); +/*N*/ if (rEditSet.GetItemState(EE_CHAR_WEIGHT_CJK,TRUE,&pItem) == SFX_ITEM_SET) +/*N*/ rDestSet.Put( SvxWeightItem( (FontWeight)((const SvxWeightItem*)pItem)->GetValue(), +/*N*/ ATTR_CJK_FONT_WEIGHT) ); +/*N*/ if (rEditSet.GetItemState(EE_CHAR_WEIGHT_CTL,TRUE,&pItem) == SFX_ITEM_SET) +/*N*/ rDestSet.Put( SvxWeightItem( (FontWeight)((const SvxWeightItem*)pItem)->GetValue(), +/*N*/ ATTR_CTL_FONT_WEIGHT) ); +/*N*/ +/*N*/ // SvxUnderlineItem contains enum and color +/*N*/ if (rEditSet.GetItemState(EE_CHAR_UNDERLINE,TRUE,&pItem) == SFX_ITEM_SET) +/*N*/ rDestSet.Put( SvxUnderlineItem(UNDERLINE_NONE,ATTR_FONT_UNDERLINE) = *(const SvxUnderlineItem*)pItem ); +/*N*/ if (rEditSet.GetItemState(EE_CHAR_WLM,TRUE,&pItem) == SFX_ITEM_SET) +/*N*/ rDestSet.Put( SvxWordLineModeItem( ((const SvxWordLineModeItem*)pItem)->GetValue(), +/*N*/ ATTR_FONT_WORDLINE) ); +/*N*/ +/*N*/ if (rEditSet.GetItemState(EE_CHAR_STRIKEOUT,TRUE,&pItem) == SFX_ITEM_SET) +/*N*/ rDestSet.Put( SvxCrossedOutItem( (FontStrikeout)((const SvxCrossedOutItem*)pItem)->GetValue(), +/*N*/ ATTR_FONT_CROSSEDOUT) ); +/*N*/ +/*N*/ if (rEditSet.GetItemState(EE_CHAR_ITALIC,TRUE,&pItem) == SFX_ITEM_SET) +/*N*/ rDestSet.Put( SvxPostureItem( (FontItalic)((const SvxPostureItem*)pItem)->GetValue(), +/*N*/ ATTR_FONT_POSTURE) ); +/*N*/ if (rEditSet.GetItemState(EE_CHAR_ITALIC_CJK,TRUE,&pItem) == SFX_ITEM_SET) +/*N*/ rDestSet.Put( SvxPostureItem( (FontItalic)((const SvxPostureItem*)pItem)->GetValue(), +/*N*/ ATTR_CJK_FONT_POSTURE) ); +/*N*/ if (rEditSet.GetItemState(EE_CHAR_ITALIC_CTL,TRUE,&pItem) == SFX_ITEM_SET) +/*N*/ rDestSet.Put( SvxPostureItem( (FontItalic)((const SvxPostureItem*)pItem)->GetValue(), +/*N*/ ATTR_CTL_FONT_POSTURE) ); +/*N*/ +/*N*/ if (rEditSet.GetItemState(EE_CHAR_OUTLINE,TRUE,&pItem) == SFX_ITEM_SET) +/*N*/ rDestSet.Put( SvxContourItem( ((const SvxContourItem*)pItem)->GetValue(), +/*N*/ ATTR_FONT_CONTOUR) ); +/*N*/ if (rEditSet.GetItemState(EE_CHAR_SHADOW,TRUE,&pItem) == SFX_ITEM_SET) +/*N*/ rDestSet.Put( SvxShadowedItem( ((const SvxShadowedItem*)pItem)->GetValue(), +/*N*/ ATTR_FONT_SHADOWED) ); +/*N*/ if (rEditSet.GetItemState(EE_CHAR_EMPHASISMARK,TRUE,&pItem) == SFX_ITEM_SET) +/*N*/ rDestSet.Put( SvxEmphasisMarkItem( ((const SvxEmphasisMarkItem*)pItem)->GetEmphasisMark(), +/*N*/ ATTR_FONT_EMPHASISMARK) ); +/*N*/ if (rEditSet.GetItemState(EE_CHAR_RELIEF,TRUE,&pItem) == SFX_ITEM_SET) +/*N*/ rDestSet.Put( SvxCharReliefItem( (FontRelief)((const SvxCharReliefItem*)pItem)->GetValue(), +/*N*/ ATTR_FONT_RELIEF) ); +/*N*/ +/*N*/ if (rEditSet.GetItemState(EE_PARA_JUST,TRUE,&pItem) == SFX_ITEM_SET) +/*N*/ { +/*N*/ SvxCellHorJustify eVal; +/*N*/ switch ( ((const SvxAdjustItem*)pItem)->GetAdjust() ) +/*N*/ { +/*N*/ case SVX_ADJUST_LEFT: +/*N*/ // #30154# EditEngine Default ist bei dem GetAttribs() ItemSet +/*N*/ // immer gesetzt! +/*N*/ // ob links oder rechts entscheiden wir selbst bei Text/Zahl +/*N*/ eVal = SVX_HOR_JUSTIFY_STANDARD; +/*N*/ break; +/*N*/ case SVX_ADJUST_RIGHT: +/*N*/ eVal = SVX_HOR_JUSTIFY_RIGHT; +/*N*/ break; +/*N*/ case SVX_ADJUST_BLOCK: +/*N*/ eVal = SVX_HOR_JUSTIFY_BLOCK; +/*N*/ break; +/*N*/ case SVX_ADJUST_CENTER: +/*N*/ eVal = SVX_HOR_JUSTIFY_CENTER; +/*N*/ break; +/*N*/ case SVX_ADJUST_BLOCKLINE: +/*N*/ eVal = SVX_HOR_JUSTIFY_BLOCK; +/*N*/ break; +/*N*/ case SVX_ADJUST_END: +/*N*/ eVal = SVX_HOR_JUSTIFY_RIGHT; +/*N*/ break; +/*N*/ default: +/*N*/ eVal = SVX_HOR_JUSTIFY_STANDARD; +/*N*/ } +/*N*/ if ( eVal != SVX_HOR_JUSTIFY_STANDARD ) +/*N*/ rDestSet.Put( SvxHorJustifyItem( eVal, ATTR_HOR_JUSTIFY) ); +/*N*/ } +/*N*/ } + +/*N*/ void ScPatternAttr::GetFromEditItemSet( const SfxItemSet* pEditSet ) +/*N*/ { +/*N*/ if( pEditSet ) +/*N*/ GetFromEditItemSet( GetItemSet(), *pEditSet ); +/*N*/ } + +/*N*/ void ScPatternAttr::FillEditParaItems( SfxItemSet* pEditSet ) const +/*N*/ { +/*N*/ // in GetFromEditItemSet schon dabei, in FillEditItemSet aber nicht +/*N*/ // Hor. Ausrichtung Standard wird immer als "links" umgesetzt +/*N*/ +/*N*/ const SfxItemSet& rMySet = GetItemSet(); +/*N*/ +/*N*/ SvxCellHorJustify eHorJust = (SvxCellHorJustify) +/*N*/ ((const SvxHorJustifyItem&)rMySet.Get(ATTR_HOR_JUSTIFY)).GetValue(); +/*N*/ +/*N*/ SvxAdjust eSvxAdjust; +/*N*/ switch (eHorJust) +/*N*/ { +/*N*/ case SVX_HOR_JUSTIFY_RIGHT: eSvxAdjust = SVX_ADJUST_RIGHT; break; +/*N*/ case SVX_HOR_JUSTIFY_CENTER: eSvxAdjust = SVX_ADJUST_CENTER; break; +/*N*/ case SVX_HOR_JUSTIFY_BLOCK: eSvxAdjust = SVX_ADJUST_BLOCK; break; +/*N*/ default: eSvxAdjust = SVX_ADJUST_LEFT; break; +/*N*/ } +/*N*/ pEditSet->Put( SvxAdjustItem( eSvxAdjust, EE_PARA_JUST ) ); +/*N*/ } + +/*N*/ void ScPatternAttr::DeleteUnchanged( const ScPatternAttr* pOldAttrs ) +/*N*/ { +/*N*/ SfxItemSet& rThisSet = GetItemSet(); +/*N*/ const SfxItemSet& rOldSet = pOldAttrs->GetItemSet(); +/*N*/ +/*N*/ const SfxPoolItem* pThisItem; +/*N*/ const SfxPoolItem* pOldItem; +/*N*/ +/*N*/ for ( USHORT nWhich=ATTR_PATTERN_START; nWhich<=ATTR_PATTERN_END; nWhich++ ) +/*N*/ { +/*N*/ // only items that are set are interesting +/*N*/ if ( rThisSet.GetItemState( nWhich, FALSE, &pThisItem ) == SFX_ITEM_SET ) +/*N*/ { +/*N*/ SfxItemState eOldState = rOldSet.GetItemState( nWhich, TRUE, &pOldItem ); +/*N*/ if ( eOldState == SFX_ITEM_SET ) +/*N*/ { +/*?*/ // item is set in OldAttrs (or its parent) -> compare pointers +/*?*/ if ( pThisItem == pOldItem ) +/*?*/ rThisSet.ClearItem( nWhich ); +/*N*/ } +/*N*/ else if ( eOldState != SFX_ITEM_DONTCARE ) +/*N*/ { +/*N*/ // not set in OldAttrs -> compare item value to default item +/*N*/ if ( *pThisItem == rThisSet.GetPool()->GetDefaultItem( nWhich ) ) +/*N*/ rThisSet.ClearItem( nWhich ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ BOOL ScPatternAttr::HasItemsSet( const USHORT* pWhich ) const +/*N*/ { +/*N*/ const SfxItemSet& rSet = GetItemSet(); +/*N*/ for (USHORT i=0; pWhich[i]; i++) +/*N*/ if ( rSet.GetItemState( pWhich[i], FALSE ) == SFX_ITEM_SET ) +/*N*/ return TRUE; +/*N*/ return FALSE; +/*N*/ } + +/*N*/ void ScPatternAttr::ClearItems( const USHORT* pWhich ) +/*N*/ { +/*N*/ SfxItemSet& rSet = GetItemSet(); +/*N*/ for (USHORT i=0; pWhich[i]; i++) +/*N*/ rSet.ClearItem(pWhich[i]); +/*N*/ } + +/*N*/ SfxStyleSheetBase* lcl_CopyStyleToPool +/*N*/ ( +/*N*/ SfxStyleSheetBase* pSrcStyle, +/*N*/ SfxStyleSheetBasePool* pSrcPool, +/*N*/ SfxStyleSheetBasePool* pDestPool +/*N*/ ) +/*N*/ { +/*N*/ if ( !pSrcStyle || !pDestPool || !pSrcPool ) +/*N*/ { +/*N*/ DBG_ERROR( "CopyStyleToPool: Invalid Arguments :-/" ); +/*N*/ return NULL; +/*N*/ } +/*N*/ +/*N*/ //-------------------------------------------------------- +/*N*/ +/*N*/ const String aStrSrcStyle = pSrcStyle->GetName(); +/*N*/ const SfxStyleFamily eFamily = pSrcStyle->GetFamily(); +/*N*/ SfxStyleSheetBase* pDestStyle = pDestPool->Find( aStrSrcStyle, eFamily ); +/*N*/ +/*N*/ if ( !pDestStyle ) +/*N*/ { +/*?*/ const String aStrParent = pSrcStyle->GetParent(); +/*?*/ +/*?*/ pDestStyle = &pDestPool->Make( aStrSrcStyle, eFamily, SFXSTYLEBIT_USERDEF ); +/*?*/ pDestStyle->GetItemSet().Put( pSrcStyle->GetItemSet() ); +/*?*/ +/*?*/ // ggF. abgeleitete Styles erzeugen, wenn nicht vorhanden: +/*?*/ +/*?*/ if ( ScGlobal::GetRscString(STR_STYLENAME_STANDARD) != aStrParent && +/*?*/ aStrSrcStyle != aStrParent && +/*?*/ !pDestPool->Find( aStrParent, eFamily ) ) +/*?*/ { +/*?*/ lcl_CopyStyleToPool( pSrcPool->Find( aStrParent, eFamily ), +/*?*/ pSrcPool, pDestPool ); +/*?*/ } +/*?*/ +/*?*/ pDestStyle->SetParent( aStrParent ); +/*N*/ } +/*N*/ +/*N*/ return pDestStyle; +/*N*/ } + +/*N*/ ScPatternAttr* ScPatternAttr::PutInPool( ScDocument* pDestDoc, ScDocument* pSrcDoc ) const +/*N*/ { +/*N*/ const SfxItemSet* pSrcSet = &GetItemSet(); +/*N*/ +/*N*/ ScPatternAttr* pDestPattern = new ScPatternAttr(pDestDoc->GetPool()); +/*N*/ SfxItemSet* pDestSet = &pDestPattern->GetItemSet(); +/*N*/ +/*N*/ // Zellformatvorlage in anderes Dokument kopieren: +/*N*/ +/*N*/ if ( pDestDoc != pSrcDoc ) +/*N*/ { +/*N*/ DBG_ASSERT( pStyle, "Missing Pattern-Style! :-/" ); +/*N*/ +/*N*/ // wenn Vorlage im DestDoc vorhanden, dieses benutzen, sonst Style +/*N*/ // mit Parent-Vorlagen kopieren/ggF. erzeugen und dem DestDoc hinzufuegen +/*N*/ +/*N*/ SfxStyleSheetBase* pStyleCpy = lcl_CopyStyleToPool( pStyle, +/*N*/ pSrcDoc->GetStyleSheetPool(), +/*N*/ pDestDoc->GetStyleSheetPool() ); +/*N*/ +/*N*/ pDestPattern->SetStyleSheet( (ScStyleSheet*)pStyleCpy ); +/*N*/ } +/*N*/ +/*N*/ for ( USHORT nAttrId = ATTR_PATTERN_START; nAttrId <= ATTR_PATTERN_END; nAttrId++ ) +/*N*/ { +/*N*/ const SfxPoolItem* pSrcItem; +/*N*/ SfxItemState eItemState = pSrcSet->GetItemState( nAttrId, FALSE, &pSrcItem ); +/*N*/ if (eItemState==SFX_ITEM_ON) +/*N*/ { +/*N*/ SfxPoolItem* pNewItem = NULL; +/*N*/ +/*N*/ if ( nAttrId == ATTR_CONDITIONAL ) +/*N*/ { +/*?*/ // Bedingte Formate ins neue Dokument kopieren +/*?*/ +/*?*/ ULONG nNewIndex = 0; +/*?*/ ScConditionalFormatList* pSrcList = pSrcDoc->GetCondFormList(); +/*?*/ if ( pSrcList ) +/*?*/ { +/*?*/ ULONG nOldIndex = ((const SfxUInt32Item*)pSrcItem)->GetValue(); +/*?*/ const ScConditionalFormat* pOldData = pSrcList->GetFormat( nOldIndex ); +/*?*/ if ( pOldData ) +/*?*/ { +/*?*/ nNewIndex = pDestDoc->AddCondFormat( *pOldData ); +/*?*/ +/*?*/ // zugehoerige Styles auch mitkopieren +/*?*/ //! nur wenn Format bei Add neu angelegt +/*?*/ +/*?*/ ScStyleSheetPool* pSrcSPool = pSrcDoc->GetStyleSheetPool(); +/*?*/ ScStyleSheetPool* pDestSPool = pDestDoc->GetStyleSheetPool(); +/*?*/ USHORT nStlCnt = pOldData->Count(); +/*?*/ for (USHORT i=0; i<nStlCnt; i++) +/*?*/ { +/*?*/ String aName = pOldData->GetEntry(i)->GetStyle(); +/*?*/ SfxStyleSheetBase* pSrcStl = +/*?*/ pSrcDoc->GetStyleSheetPool()->Find(aName, SFX_STYLE_FAMILY_PARA); +/*?*/ lcl_CopyStyleToPool( pSrcStl, pSrcSPool, pDestSPool ); +/*?*/ } +/*?*/ } +/*?*/ } +/*?*/ pNewItem = new SfxUInt32Item( ATTR_CONDITIONAL, nNewIndex ); +/*N*/ } +/*N*/ else if ( nAttrId == ATTR_VALIDDATA ) +/*N*/ { +/*?*/ // Gueltigkeit ins neue Dokument kopieren +/*?*/ +/*?*/ ULONG nNewIndex = 0; +/*?*/ ScValidationDataList* pSrcList = pSrcDoc->GetValidationList(); +/*?*/ if ( pSrcList ) +/*?*/ { +/*?*/ ULONG nOldIndex = ((const SfxUInt32Item*)pSrcItem)->GetValue(); +/*?*/ const ScValidationData* pOldData = pSrcList->GetData( nOldIndex ); +/*?*/ if ( pOldData ) +/*?*/ nNewIndex = pDestDoc->AddValidationEntry( *pOldData ); +/*?*/ } +/*?*/ pNewItem = new SfxUInt32Item( ATTR_VALIDDATA, nNewIndex ); +/*N*/ } +/*N*/ else if ( nAttrId == ATTR_VALUE_FORMAT && pDestDoc->GetFormatExchangeList() ) +/*N*/ { +/*N*/ // Zahlformate nach Exchange-Liste +/*N*/ +/*N*/ ULONG nOldFormat = ((const SfxUInt32Item*)pSrcItem)->GetValue(); +/*N*/ ULONG* pNewFormat = (ULONG*)pDestDoc->GetFormatExchangeList()->Get(nOldFormat); +/*N*/ if (pNewFormat) +/*?*/ pNewItem = new SfxUInt32Item( ATTR_VALUE_FORMAT, (UINT32) (*pNewFormat) ); +/*N*/ } +/*N*/ +/*N*/ if ( pNewItem ) +/*N*/ { +/*?*/ pDestSet->Put(*pNewItem); +/*?*/ delete pNewItem; +/*N*/ } +/*N*/ else +/*N*/ pDestSet->Put(*pSrcItem); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ ScPatternAttr* pPatternAttr = +/*N*/ (ScPatternAttr*) &pDestDoc->GetPool()->Put(*pDestPattern); +/*N*/ delete pDestPattern; +/*N*/ return pPatternAttr; +/*N*/ } + +/*N*/ BOOL ScPatternAttr::IsVisible() const +/*N*/ { +/*N*/ const SfxItemSet& rSet = GetItemSet(); +/*N*/ const SfxItemPool* pPool = rSet.GetPool(); +/*N*/ +/*N*/ const SfxPoolItem* pItem; +/*N*/ SfxItemState eState; +/*N*/ +/*N*/ eState = rSet.GetItemState( ATTR_BACKGROUND, TRUE, &pItem ); +/*N*/ if ( eState == SFX_ITEM_SET ) +/*N*/ if ( ((SvxBrushItem*)pItem)->GetColor().GetColor() != COL_TRANSPARENT ) +/*N*/ return TRUE; +/*N*/ +/*N*/ eState = rSet.GetItemState( ATTR_BORDER, TRUE, &pItem ); +/*N*/ if ( eState == SFX_ITEM_SET ) +/*N*/ { +/*N*/ SvxBoxItem* pBoxItem = (SvxBoxItem*) pItem; +/*N*/ if ( pBoxItem->GetTop() || pBoxItem->GetBottom() || +/*N*/ pBoxItem->GetLeft() || pBoxItem->GetRight() ) +/*N*/ return TRUE; +/*N*/ } +/*N*/ +/*N*/ eState = rSet.GetItemState( ATTR_SHADOW, TRUE, &pItem ); +/*N*/ if ( eState == SFX_ITEM_SET ) +/*?*/ if ( ((SvxShadowItem*)pItem)->GetLocation() != SVX_SHADOW_NONE ) +/*?*/ return TRUE; +/*N*/ +/*N*/ return FALSE; +/*N*/ } + +/*N*/ inline BOOL OneEqual( const SfxItemSet& rSet1, const SfxItemSet& rSet2, USHORT nId ) +/*N*/ { +/*N*/ const SfxPoolItem* pItem1 = &rSet1.Get(nId); +/*N*/ const SfxPoolItem* pItem2 = &rSet2.Get(nId); +/*N*/ return ( pItem1 == pItem2 || *pItem1 == *pItem2 ); +/*N*/ } + +/*N*/ BOOL ScPatternAttr::IsVisibleEqual( const ScPatternAttr& rOther ) const +/*N*/ { +/*N*/ const SfxItemSet& rThisSet = GetItemSet(); +/*N*/ const SfxItemSet& rOtherSet = rOther.GetItemSet(); +/*N*/ +/*N*/ return OneEqual( rThisSet, rOtherSet, ATTR_BACKGROUND ) && +/*N*/ OneEqual( rThisSet, rOtherSet, ATTR_BORDER ) && +/*N*/ OneEqual( rThisSet, rOtherSet, ATTR_SHADOW ); +/*N*/ +/*N*/ //! auch hier nur wirklich sichtbare Werte testen !!! +/*N*/ } + +/*N*/ const String* ScPatternAttr::GetStyleName() const +/*N*/ { +/*N*/ return pName ? pName : ( pStyle ? &pStyle->GetName() : NULL ); +/*N*/ } + + +/*N*/ void ScPatternAttr::SetStyleSheet( ScStyleSheet* pNewStyle ) +/*N*/ { +/*N*/ if (pNewStyle) +/*N*/ { +/*N*/ SfxItemSet& rPatternSet = GetItemSet(); +/*N*/ const SfxItemSet& rStyleSet = pNewStyle->GetItemSet(); +/*N*/ +/*N*/ for (USHORT i=ATTR_PATTERN_START; i<=ATTR_PATTERN_END; i++) +/*N*/ { +/*N*/ if (rStyleSet.GetItemState(i, TRUE) == SFX_ITEM_SET) +/*N*/ rPatternSet.ClearItem(i); +/*N*/ } +/*N*/ rPatternSet.SetParent(&pNewStyle->GetItemSet()); +/*N*/ pStyle = pNewStyle; +/*N*/ DELETEZ( pName ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ DBG_ERROR( "ScPatternAttr::SetStyleSheet( NULL ) :-|" ); +/*N*/ GetItemSet().SetParent(NULL); +/*N*/ pStyle = NULL; +/*N*/ } +/*N*/ } + +/*N*/ void ScPatternAttr::UpdateStyleSheet() +/*N*/ { +/*N*/ if (pName) +/*N*/ { +/*N*/ pStyle = (ScStyleSheet*)pDoc->GetStyleSheetPool()->Find(*pName, SFX_STYLE_FAMILY_PARA); +/*N*/ +/*N*/ // wenn Style nicht gefunden, Standard nehmen, +/*N*/ // damit keine leere Anzeige im Toolbox-Controller +/*N*/ //! es wird vorausgesetzt, dass "Standard" immer der erste Eintrag ist! +/*N*/ if (!pStyle) +/*N*/ { +/*N*/ SfxStyleSheetIterator* pIter = pDoc->GetStyleSheetPool()->CreateIterator( +/*N*/ SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_ALL ); +/*N*/ pStyle = (ScStyleSheet*)pIter->First(); +/*N*/ } +/*N*/ +/*N*/ if (pStyle) +/*N*/ { +/*N*/ GetItemSet().SetParent(&pStyle->GetItemSet()); +/*N*/ DELETEZ( pName ); +/*N*/ } +/*N*/ } +/*N*/ else +/*?*/ pStyle = NULL; +/*N*/ } + + +/*N*/ BOOL ScPatternAttr::IsSymbolFont() const +/*N*/ { +/*N*/ const SfxPoolItem* pItem; +/*N*/ if( GetItemSet().GetItemState( ATTR_FONT, TRUE, &pItem ) == SFX_ITEM_SET ) +/*N*/ return BOOL( ((const SvxFontItem*) pItem)->GetCharSet() +/*N*/ == RTL_TEXTENCODING_SYMBOL ); +/*N*/ else +/*N*/ return FALSE; +/*N*/ } + +/*N*/ FontToSubsFontConverter ScPatternAttr::GetSubsFontConverter( ULONG nFlags ) const +/*N*/ { +/*N*/ const SfxPoolItem* pItem; +/*N*/ if( GetItemSet().GetItemState( ATTR_FONT, TRUE, &pItem ) == SFX_ITEM_SET ) +/*N*/ return CreateFontToSubsFontConverter( +/*N*/ ((const SvxFontItem*) pItem)->GetFamilyName(), nFlags ); +/*N*/ else +/*N*/ return 0; +/*N*/ } + + +/*N*/ ULONG ScPatternAttr::GetNumberFormat( SvNumberFormatter* pFormatter ) const +/*N*/ { +/*N*/ ULONG nFormat = +/*N*/ ((SfxUInt32Item*)&GetItemSet().Get( ATTR_VALUE_FORMAT ))->GetValue(); +/*N*/ LanguageType eLang = +/*N*/ ((SvxLanguageItem*)&GetItemSet().Get( ATTR_LANGUAGE_FORMAT ))->GetLanguage(); +/*N*/ if ( nFormat < SV_COUNTRY_LANGUAGE_OFFSET && eLang == LANGUAGE_SYSTEM ) +/*N*/ ; // es bleibt wie es ist +/*N*/ else if ( pFormatter ) +/*N*/ nFormat = pFormatter->GetFormatForLanguageIfBuiltIn( nFormat, eLang ); +/*N*/ return nFormat; +/*N*/ } + +// dasselbe, wenn bedingte Formatierung im Spiel ist: + +/*N*/ ULONG ScPatternAttr::GetNumberFormat( SvNumberFormatter* pFormatter, +/*N*/ const SfxItemSet* pCondSet ) const +/*N*/ { +/*N*/ DBG_ASSERT(pFormatter,"GetNumberFormat ohne Formatter"); +/*N*/ +/*N*/ const SfxPoolItem* pFormItem; +/*N*/ if ( !pCondSet || pCondSet->GetItemState(ATTR_VALUE_FORMAT,TRUE,&pFormItem) != SFX_ITEM_SET ) +/*N*/ pFormItem = &GetItemSet().Get(ATTR_VALUE_FORMAT); +/*N*/ +/*N*/ const SfxPoolItem* pLangItem; +/*N*/ if ( !pCondSet || pCondSet->GetItemState(ATTR_LANGUAGE_FORMAT,TRUE,&pLangItem) != SFX_ITEM_SET ) +/*N*/ pLangItem = &GetItemSet().Get(ATTR_LANGUAGE_FORMAT); +/*N*/ +/*N*/ return pFormatter->GetFormatForLanguageIfBuiltIn( +/*N*/ ((SfxUInt32Item*)pFormItem)->GetValue(), +/*N*/ ((SvxLanguageItem*)pLangItem)->GetLanguage() ); +/*N*/ } + +/*N*/ const SfxPoolItem& ScPatternAttr::GetItem( USHORT nWhich, const SfxItemSet* pCondSet ) const +/*N*/ { +/*N*/ const SfxPoolItem* pCondItem; +/*N*/ if ( pCondSet && pCondSet->GetItemState( nWhich, TRUE, &pCondItem ) == SFX_ITEM_SET ) +/*?*/ return *pCondItem; +/*N*/ +/*N*/ return GetItemSet().Get(nWhich); +/*N*/ } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_pivot.cxx b/binfilter/bf_sc/source/core/data/sc_pivot.cxx new file mode 100644 index 000000000000..b77191660776 --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_pivot.cxx @@ -0,0 +1,1313 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// ----------------------------------------------------------------------- + +#ifdef _MSC_VER +#pragma optimize("",off) +#endif +#ifdef _MSC_VER +#pragma optimize("q",off) // p-code off +#endif + + +// INCLUDE --------------------------------------------------------------- + +#include <tools/solar.h> +#include <string.h> +#include <math.h> + + +#include "globstr.hrc" +#include "subtotal.hxx" +#include "docpool.hxx" +#include "document.hxx" +#include "userlist.hxx" +#include "pivot.hxx" +#include "cell.hxx" +#include "rechead.hxx" +namespace binfilter { + + +// STATIC DATA ----------------------------------------------------------- + +//! bei Gelegenheit... + +static short nStaticStrRefCount = 0; +static String* pLabel[PIVOT_MAXFUNC+1]; // incl. "auto" +static String* pLabelTotal; +static String* pLabelData; + +static USHORT nDataMult = 1; + +#define nFirstLine 2 + +static const USHORT nFuncMaskArr[PIVOT_MAXFUNC+1] = + { PIVOT_FUNC_SUM, + PIVOT_FUNC_COUNT, + PIVOT_FUNC_AVERAGE, + PIVOT_FUNC_MAX, + PIVOT_FUNC_MIN, + PIVOT_FUNC_PRODUCT, + PIVOT_FUNC_COUNT_NUM, + PIVOT_FUNC_STD_DEV, + PIVOT_FUNC_STD_DEVP, + PIVOT_FUNC_STD_VAR, + PIVOT_FUNC_STD_VARP, + PIVOT_FUNC_AUTO }; // automatisch + +// ----------------------------------------------------------------------- + +// 1 Filter-Knopf +// 2 Feldnamen links +// 3 "Daten" links +// 4 Feldnamen oben +// 5 "Daten" oben +// 6 einzelne "Gesamt" oben rechts +// 7 "Gesamt" oben rechts +// 8 einzelne "Gesamt" unten links +// 9 "Gesamt" unten links +// 10 innere Kategorie links +// 11 Teilergebnis Label einzeln links +// 12 Teilergebnis Label gesamt links +// 13 letzte Kategorie links +// 14 innere Kategorie oben +// 15 Teilergebnis Label einzeln oben +// 16 Teilergebnis Label gesamt oben +// 17 letzte Kategorie oben +// 18 Werte innen +// 19 Werte in Teilergebnisspalte +// 20 Werte in Gesamt-Spalte +// 21 Werte in einzelnen Gesamt-Spalten +// 22 Werte in Ergebnis-Zeile Teilergebnis oder Gesamt +// 23 Kreuzung von Spalte/Zeile (Teilergebnis-Spalte) +// 24 Kreuzung von Spalte/Zeile (Gesamt-Spalte) +// 25 wie 24 bei einzelnen "Gesamt" + + + +/*N*/ ScPivot::ScPivot(ScDocument* pDocument) : +/*N*/ pDoc (pDocument), +/*N*/ aQuery (), +/*N*/ bHasHeader (FALSE), +/*N*/ bIgnoreEmpty (FALSE), +/*N*/ bDetectCat (FALSE), +/*N*/ bMakeTotalCol (TRUE), +/*N*/ bMakeTotalRow (TRUE), +/*N*/ nColNameCount (0), +/*N*/ pColNames (NULL), +/*N*/ nSrcCol1 (0), +/*N*/ nSrcRow1 (0), +/*N*/ nSrcCol2 (0), +/*N*/ nSrcRow2 (0), +/*N*/ nSrcTab (0), +/*N*/ nDestCol1 (0), +/*N*/ nDestRow1 (0), +/*N*/ nDestCol2 (0), +/*N*/ nDestRow2 (0), +/*N*/ nDestTab (0), +/*N*/ nDataStartCol (0), +/*N*/ nDataStartRow (0), +/*N*/ nColCount (0), +/*N*/ nRowCount (0), +/*N*/ nDataCount (0), +/*N*/ bValidArea (FALSE), +/*N*/ bDataAtCol (FALSE) +/*N*/ { +/*N*/ short i; +/*N*/ for (i=0; i<PIVOT_MAXFIELD; i++) +/*N*/ { +/*N*/ pColList[i] = new PivotStrCollection(); +/*N*/ pRowList[i] = new PivotStrCollection(); +/*N*/ } +/*N*/ pDataList = pColList[0]; +/*N*/ ppDataArr = NULL; +/*N*/ nDataColCount = 0; +/*N*/ nDataRowCount = 0; +/*N*/ nRecCount = 0; +/*N*/ pColRef = NULL; +/*N*/ +/*N*/ // Initialisierung der statischen Strings, wenn noetig +/*N*/ nStaticStrRefCount += 1; +/*N*/ if ( nStaticStrRefCount < 2 ) +/*N*/ { +/*N*/ pLabelTotal = new String( ScGlobal::GetRscString(STR_PIVOT_TOTAL) ); +/*N*/ pLabelData = new String( ScGlobal::GetRscString(STR_PIVOT_DATA) ); +/*N*/ +/*N*/ for ( i=0; i<=PIVOT_MAXFUNC; i++ ) // incl. "auto" +/*N*/ pLabel[i] = new String; // kein Leerzeichen +/*N*/ +/*N*/ *pLabel[ 0] = ScGlobal::GetRscString(STR_FUN_TEXT_SUM); +/*N*/ *pLabel[ 1] = ScGlobal::GetRscString(STR_FUN_TEXT_COUNT); +/*N*/ *pLabel[ 2] = ScGlobal::GetRscString(STR_FUN_TEXT_AVG); +/*N*/ *pLabel[ 3] = ScGlobal::GetRscString(STR_FUN_TEXT_MAX); +/*N*/ *pLabel[ 4] = ScGlobal::GetRscString(STR_FUN_TEXT_MIN); +/*N*/ *pLabel[ 5] = ScGlobal::GetRscString(STR_FUN_TEXT_PRODUCT); +/*N*/ *pLabel[ 6] = ScGlobal::GetRscString(STR_FUN_TEXT_COUNT); // Count2 +/*N*/ *pLabel[ 7] = ScGlobal::GetRscString(STR_FUN_TEXT_STDDEV); +/*N*/ *pLabel[ 8] = ScGlobal::GetRscString(STR_FUN_TEXT_STDDEV); // Stddev2 +/*N*/ *pLabel[ 9] = ScGlobal::GetRscString(STR_FUN_TEXT_VAR); +/*N*/ *pLabel[10] = ScGlobal::GetRscString(STR_FUN_TEXT_VAR); // Var2 +/*N*/ *pLabel[11] = ScGlobal::GetRscString(STR_TABLE_ERGEBNIS); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ ScPivot::ScPivot(const ScPivot& rPivot): +/*N*/ pDoc (rPivot.pDoc), +/*N*/ aQuery (rPivot.aQuery), +/*N*/ bHasHeader (rPivot.bHasHeader), +/*N*/ bIgnoreEmpty (rPivot.bIgnoreEmpty), +/*N*/ bDetectCat (rPivot.bDetectCat), +/*N*/ bMakeTotalCol (rPivot.bMakeTotalCol), +/*N*/ bMakeTotalRow (rPivot.bMakeTotalRow), +/*N*/ nColNameCount (0), +/*N*/ pColNames (NULL), +/*N*/ aName (rPivot.aName), +/*N*/ aTag (rPivot.aTag), +/*N*/ nSrcCol1 (rPivot.nSrcCol1), +/*N*/ nSrcRow1 (rPivot.nSrcRow1), +/*N*/ nSrcCol2 (rPivot.nSrcCol2), +/*N*/ nSrcRow2 (rPivot.nSrcRow2), +/*N*/ nSrcTab (rPivot.nSrcTab), +/*N*/ nDestCol1 (rPivot.nDestCol1), +/*N*/ nDestRow1 (rPivot.nDestRow1), +/*N*/ nDestCol2 (rPivot.nDestCol2), +/*N*/ nDestRow2 (rPivot.nDestRow2), +/*N*/ nDestTab (rPivot.nDestTab), +/*N*/ nDataStartCol (0), +/*N*/ nDataStartRow (0), +/*N*/ nColCount (0), +/*N*/ nRowCount (0), +/*N*/ nDataCount (0), +/*N*/ bValidArea (FALSE), +/*N*/ bDataAtCol (FALSE) +/*N*/ { +/*N*/ if (rPivot.nColNameCount && rPivot.pColNames) +/*N*/ { +/*N*/ nColNameCount = rPivot.nColNameCount; +/*N*/ pColNames = new String[nColNameCount]; +/*N*/ for (USHORT nCol=0; nCol<nColNameCount; nCol++) +/*N*/ pColNames[nCol] = rPivot.pColNames[nCol]; +/*N*/ } +/*N*/ +/*N*/ short i; +/*N*/ for (i=0; i<PIVOT_MAXFIELD; i++) +/*N*/ { +/*N*/ pColList[i] = new PivotStrCollection(); +/*N*/ pRowList[i] = new PivotStrCollection(); +/*N*/ } +/*N*/ pDataList = pColList[0]; +/*N*/ ppDataArr = NULL; +/*N*/ nRecCount = 0; +/*N*/ pColRef = NULL; +/*N*/ +/*N*/ SetColFields( rPivot.aColArr, rPivot.nColCount ); +/*N*/ SetRowFields( rPivot.aRowArr, rPivot.nRowCount ); +/*N*/ SetDataFields( rPivot.aDataArr, rPivot.nDataCount ); +/*N*/ +/*N*/ nStaticStrRefCount += 1; +/*N*/ } + +/*N*/ ScPivot::~ScPivot() +/*N*/ { +/*N*/ short i; +/*N*/ for (i=0; i<PIVOT_MAXFIELD; i++) +/*N*/ { +/*N*/ delete pColList[i]; +/*N*/ delete pRowList[i]; +/*N*/ } +/*N*/ if (ppDataArr) +/*N*/ { +/*N*/ for (i=0; i<nDataRowCount; i++) +/*N*/ delete[] ppDataArr[i]; +/*N*/ delete[] ppDataArr; +/*N*/ ppDataArr = NULL; +/*N*/ } +/*N*/ delete[] pColRef; +/*N*/ +/*N*/ delete[] pColNames; +/*N*/ +/*N*/ // statische Strings ggF. wieder abraeumen +/*N*/ nStaticStrRefCount -= 1; +/*N*/ if ( nStaticStrRefCount == 0 ) +/*N*/ { +/*N*/ delete pLabelTotal; +/*N*/ delete pLabelData; +/*N*/ +/*N*/ for ( i=0; i<=PIVOT_MAXFUNC; i++ ) // incl. "auto" +/*N*/ delete pLabel[i]; +/*N*/ } +/*N*/ } + + +/*N*/ void lcl_LoadFieldArr30( SvStream& rStream, PivotField* pField, USHORT nCount ) +/*N*/ { +/*N*/ USHORT i; +/*N*/ +/*N*/ for (i=0; i<nCount; i++) +/*N*/ { +/*N*/ rStream >> pField[i].nCol +/*N*/ >> pField[i].nFuncMask +/*N*/ >> pField[i].nFuncCount; +/*N*/ } +/*N*/ } + +/*N*/ void lcl_LoadFieldArr( SvStream& rStream, PivotField* pField, USHORT nCount ) +/*N*/ { +/*N*/ USHORT i; +/*N*/ +/*N*/ for (i=0; i<nCount; i++) +/*N*/ { +/*N*/ BYTE cData; +/*N*/ rStream >> cData; +/*N*/ if( cData & 0x0F ) +/*N*/ rStream.SeekRel( cData & 0x0F ); +/*N*/ rStream >> pField[i].nCol +/*N*/ >> pField[i].nFuncMask +/*N*/ >> pField[i].nFuncCount; +/*N*/ } +/*N*/ } + +/*N*/ void lcl_SaveFieldArr( SvStream& rStream, const PivotField* pField, USHORT nCount ) +/*N*/ { +/*N*/ USHORT i; +/*N*/ +/*N*/ for (i=0; i<nCount; i++) +/*N*/ { +/*N*/ rStream << (BYTE) 0x00 +/*N*/ << pField[i].nCol +/*N*/ << pField[i].nFuncMask +/*N*/ << pField[i].nFuncCount; +/*N*/ } +/*N*/ } + +// nach Load muessen Daten neu berechnet werden ! + +/*N*/ BOOL ScPivot::Load( SvStream& rStream, ScMultipleReadHeader& rHdr ) +/*N*/ { +/*N*/ rHdr.StartEntry(); +/*N*/ +/*N*/ rStream >> bHasHeader +/*N*/ +/*N*/ >> nSrcCol1 +/*N*/ >> nSrcRow1 +/*N*/ >> nSrcCol2 +/*N*/ >> nSrcRow2 +/*N*/ >> nSrcTab +/*N*/ +/*N*/ >> nDestCol1 +/*N*/ >> nDestRow1 +/*N*/ >> nDestCol2 +/*N*/ >> nDestRow2 +/*N*/ >> nDestTab; +/*N*/ +/*N*/ // Arrays immer ueber Set...Fields initalisieren! +/*N*/ +/*N*/ short nCount; +/*N*/ PivotFieldArr aFieldArr; +/*N*/ +/*N*/ if( pDoc->GetSrcVersion() >= SC_DATABYTES2 ) +/*N*/ { +/*N*/ rStream >> nCount; +/*N*/ lcl_LoadFieldArr( rStream, aFieldArr, nCount ); +/*N*/ SetColFields(aFieldArr, nCount); +/*N*/ +/*N*/ rStream >> nCount; +/*N*/ lcl_LoadFieldArr( rStream, aFieldArr, nCount ); +/*N*/ SetRowFields(aFieldArr, nCount); +/*N*/ +/*N*/ rStream >> nCount; +/*N*/ lcl_LoadFieldArr( rStream, aFieldArr, nCount ); +/*N*/ SetDataFields(aFieldArr, nCount); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ rStream >> nCount; +/*N*/ lcl_LoadFieldArr30( rStream, aFieldArr, nCount ); +/*N*/ SetColFields(aFieldArr, nCount); +/*N*/ +/*N*/ rStream >> nCount; +/*N*/ lcl_LoadFieldArr30( rStream, aFieldArr, nCount ); +/*N*/ SetRowFields(aFieldArr, nCount); +/*N*/ +/*N*/ rStream >> nCount; +/*N*/ lcl_LoadFieldArr30( rStream, aFieldArr, nCount ); +/*N*/ SetDataFields(aFieldArr, nCount); +/*N*/ } +/*N*/ +/*N*/ aQuery.Load( rStream ); +/*N*/ +/*N*/ rStream >> bIgnoreEmpty; +/*N*/ rStream >> bDetectCat; +/*N*/ +/*N*/ if (rHdr.BytesLeft()) +/*N*/ { +/*N*/ rStream >> bMakeTotalCol; // ab 355i +/*N*/ rStream >> bMakeTotalRow; +/*N*/ } +/*N*/ +/*N*/ if (rHdr.BytesLeft()) // ab 500a +/*N*/ { +/*N*/ rStream.ReadByteString( aName, rStream.GetStreamCharSet() ); +/*N*/ rStream.ReadByteString( aTag, rStream.GetStreamCharSet() ); +/*N*/ +/*N*/ DBG_ASSERT(!pColNames, "Spaltennamen schon gesetzt?"); +/*N*/ rStream >> nColNameCount; +/*N*/ if (nColNameCount) +/*N*/ { +/*N*/ pColNames = new String[nColNameCount]; +/*N*/ for (USHORT nCol=0; nCol<nColNameCount; nCol++) +/*N*/ rStream.ReadByteString( pColNames[nCol], rStream.GetStreamCharSet() ); +/*N*/ } +/*N*/ } +/*N*/ // sonst wird hinterher aus ScPivotCollection::Load ein Name vergeben +/*N*/ +/*N*/ rHdr.EndEntry(); +/*N*/ return TRUE; +/*N*/ } + +/*N*/ BOOL ScPivot::Store( SvStream& rStream, ScMultipleWriteHeader& rHdr ) const +/*N*/ { +/*N*/ rHdr.StartEntry(); +/*N*/ +/*N*/ rStream << bHasHeader +/*N*/ +/*N*/ << nSrcCol1 +/*N*/ << nSrcRow1 +/*N*/ << nSrcCol2 +/*N*/ << nSrcRow2 +/*N*/ << nSrcTab +/*N*/ +/*N*/ << nDestCol1 +/*N*/ << nDestRow1 +/*N*/ << nDestCol2 +/*N*/ << nDestRow2 +/*N*/ << nDestTab +/*N*/ +/*N*/ << nColCount; +/*N*/ lcl_SaveFieldArr( rStream, aColArr, nColCount ); +/*N*/ rStream << nRowCount; +/*N*/ lcl_SaveFieldArr( rStream, aRowArr, nRowCount ); +/*N*/ rStream << nDataCount; +/*N*/ lcl_SaveFieldArr( rStream, aDataArr, nDataCount ); +/*N*/ +/*N*/ aQuery.Store( rStream ); +/*N*/ +/*N*/ rStream << bIgnoreEmpty; +/*N*/ rStream << bDetectCat; +/*N*/ +/*N*/ rStream << bMakeTotalCol; // ab 355i +/*N*/ rStream << bMakeTotalRow; +/*N*/ +/*N*/ if( rStream.GetVersion() > SOFFICE_FILEFORMAT_40 ) // Name/Tag/Spalten ab 5.0 +/*N*/ { +/*N*/ rStream.WriteByteString( aName, rStream.GetStreamCharSet() ); +/*N*/ rStream.WriteByteString( aTag, rStream.GetStreamCharSet() ); +/*N*/ +/*N*/ if (!pColNames) ((ScPivot*)this)->nColNameCount = 0; // soll nicht sein +/*N*/ rStream << nColNameCount; +/*N*/ for (USHORT nCol=0; nCol<nColNameCount; nCol++) +/*N*/ rStream.WriteByteString( pColNames[nCol], rStream.GetStreamCharSet() ); +/*N*/ } +/*N*/ +/*N*/ rHdr.EndEntry(); +/*N*/ return TRUE; +/*N*/ } + +/*N*/ void ScPivot::SetQuery(const ScQueryParam& rQuery) +/*N*/ { +/*N*/ aQuery = rQuery; +/*N*/ +/*N*/ bValidArea = FALSE; +/*N*/ } + +/*N*/ void ScPivot::GetQuery(ScQueryParam& rQuery) const +/*N*/ { +/*N*/ rQuery = aQuery; +/*N*/ } + +/*N*/ void ScPivot::SetHeader(BOOL bHeader) +/*N*/ { +/*N*/ bHasHeader = bHeader; +/*N*/ bValidArea = FALSE; +/*N*/ } + + +/*N*/ void ScPivot::SetIgnoreEmpty(BOOL bIgnore) +/*N*/ { +/*N*/ bIgnoreEmpty = bIgnore; +/*N*/ bValidArea = FALSE; +/*N*/ } + +/*N*/ BOOL ScPivot::GetIgnoreEmpty() const +/*N*/ { +/*N*/ return bIgnoreEmpty; +/*N*/ } + +/*N*/ void ScPivot::SetDetectCat(BOOL bDetect) +/*N*/ { +/*N*/ bDetectCat = bDetect; +/*N*/ bValidArea = FALSE; +/*N*/ } + +/*N*/ BOOL ScPivot::GetDetectCat() const +/*N*/ { +/*N*/ return bDetectCat; +/*N*/ } + +/*N*/ void ScPivot::SetMakeTotalCol(BOOL bSet) +/*N*/ { +/*N*/ bMakeTotalCol = bSet; +/*N*/ bValidArea = FALSE; +/*N*/ } + +/*N*/ BOOL ScPivot::GetMakeTotalCol() const +/*N*/ { +/*N*/ return bMakeTotalCol; +/*N*/ } + +/*N*/ void ScPivot::SetMakeTotalRow(BOOL bSet) +/*N*/ { +/*N*/ bMakeTotalRow = bSet; +/*N*/ bValidArea = FALSE; +/*N*/ } + +/*N*/ BOOL ScPivot::GetMakeTotalRow() const +/*N*/ { +/*N*/ return bMakeTotalRow; +/*N*/ } + +/*N*/ void ScPivot::SetName(const String& rNew) +/*N*/ { +/*N*/ aName = rNew; +/*N*/ } + +/*N*/ const String& ScPivot::GetName() const +/*N*/ { +/*N*/ return aName; +/*N*/ } + +/*N*/ void ScPivot::SetTag(const String& rNew) +/*N*/ { +/*N*/ aTag = rNew; +/*N*/ } + +/*N*/ const String& ScPivot::GetTag() const +/*N*/ { +/*N*/ return aTag; +/*N*/ } + +/*N*/ void ScPivot::SetSrcArea(USHORT nCol1, USHORT nRow1, USHORT nCol2, USHORT nRow2, USHORT nTab) +/*N*/ { +/*N*/ nSrcCol1 = Min(nCol1, (USHORT)MAXCOL); +/*N*/ nSrcRow1 = Min(nRow1, (USHORT)MAXROW); +/*N*/ nSrcCol2 = Min(nCol2, (USHORT)MAXCOL); +/*N*/ nSrcRow2 = Min(nRow2, (USHORT)MAXROW); +/*N*/ nSrcTab = nTab; +/*N*/ bValidArea = FALSE; +/*N*/ } + +/*N*/ void ScPivot::GetSrcArea(USHORT& rCol1, USHORT& rRow1, USHORT& rCol2, USHORT& rRow2, USHORT& rTab) const +/*N*/ { +/*N*/ rCol1 = nSrcCol1; +/*N*/ rRow1 = nSrcRow1; +/*N*/ rCol2 = nSrcCol2; +/*N*/ rRow2 = nSrcRow2; +/*N*/ rTab = nSrcTab; +/*N*/ } + +/*N*/ ScRange ScPivot::GetSrcArea() const +/*N*/ { +/*N*/ return ScRange( nSrcCol1,nSrcRow1,nSrcTab, nSrcCol2,nSrcRow2,nSrcTab ); +/*N*/ } + +/*N*/ void ScPivot::SetDestPos(USHORT nCol, USHORT nRow, USHORT nTab) +/*N*/ { +/*N*/ nDestCol1 = nCol; +/*N*/ nDestRow1 = nRow; +/*N*/ nDestTab = nTab; +/*N*/ bValidArea = FALSE; +/*N*/ } + +/*N*/ void ScPivot::GetDestArea(USHORT& rCol1, USHORT& rRow1, USHORT& rCol2, USHORT& rRow2, USHORT& rTab) const +/*N*/ { +/*N*/ rCol1 = nDestCol1; +/*N*/ rRow1 = nDestRow1; +/*N*/ rTab = nDestTab; +/*N*/ if (bValidArea) +/*N*/ { +/*N*/ rCol2 = nDestCol2; +/*N*/ rRow2 = nDestRow2; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ rCol2 = nDestCol1; +/*N*/ rRow2 = nDestRow1; +/*N*/ } +/*N*/ } + +/*N*/ ScRange ScPivot::GetDestArea() const +/*N*/ { +/*N*/ ScAddress aStart( nDestCol1, nDestRow1, nDestTab ); +/*N*/ ScAddress aEnd = aStart; +/*N*/ if ( bValidArea ) +/*N*/ aEnd = ScAddress( nDestCol2, nDestRow2, nDestTab ); +/*N*/ return ScRange( aStart, aEnd ); +/*N*/ } + +/*N*/ void ScPivot::MoveSrcArea( USHORT nNewCol, USHORT nNewRow, USHORT nNewTab ) +/*N*/ { +/*N*/ if ( nNewCol != nSrcCol1 || nNewRow != nSrcRow1 || nNewTab != nSrcTab ) +/*N*/ { +/*N*/ USHORT i; +/*N*/ short nDiffX = nNewCol - (short) nSrcCol1; +/*N*/ short nDiffY = nNewRow - (short) nSrcRow1; +/*N*/ +/*N*/ nSrcTab = nNewTab; +/*N*/ nSrcCol1 += nDiffX; +/*N*/ nSrcCol2 += nDiffX; +/*N*/ nSrcRow1 += nDiffY; +/*N*/ nSrcRow2 += nDiffY; +/*N*/ +/*N*/ aQuery.nCol1 += nDiffX; +/*N*/ aQuery.nCol2 += nDiffX; +/*N*/ aQuery.nRow1 += nDiffY; +/*N*/ aQuery.nRow2 += nDiffY; +/*N*/ +/*N*/ USHORT nEC = aQuery.GetEntryCount(); +/*N*/ for (i=0; i<nEC; i++) +/*N*/ if (aQuery.GetEntry(i).bDoQuery) +/*N*/ aQuery.GetEntry(i).nField += nDiffX; +/*N*/ +/*N*/ if (bValidArea) +/*N*/ { +/*N*/ short nC; +/*N*/ for (nC=0; nC<nColCount; nC++) +/*N*/ if (aColArr[nC].nCol != PIVOT_DATA_FIELD) +/*N*/ aColArr[nC].nCol += nDiffX; +/*N*/ for (nC=0; nC<nRowCount; nC++) +/*N*/ if (aRowArr[nC].nCol != PIVOT_DATA_FIELD) +/*N*/ aRowArr[nC].nCol += nDiffX; +/*N*/ for (nC=0; nC<nDataCount; nC++) +/*N*/ if (aDataArr[nC].nCol != PIVOT_DATA_FIELD) +/*N*/ aDataArr[nC].nCol += nDiffX; +/*N*/ } +/*N*/ } +/*N*/ } + + +/*N*/ void ScPivot::MoveDestArea( USHORT nNewCol, USHORT nNewRow, USHORT nNewTab ) +/*N*/ { +/*N*/ if ( nNewCol != nDestCol1 || nNewRow != nDestRow1 || nNewTab != nDestTab ) +/*N*/ { +/*N*/ short nDiffX = nNewCol - (short) nDestCol1; +/*N*/ short nDiffY = nNewRow - (short) nDestRow1; +/*N*/ +/*N*/ nDestTab = nNewTab; +/*N*/ nDestCol1 += nDiffX; +/*N*/ nDestRow1 += nDiffY; +/*N*/ +/*N*/ if (bValidArea) +/*N*/ { +/*N*/ nDestCol2 += nDiffX; +/*N*/ nDestRow2 += nDiffY; +/*N*/ +/*N*/ nDataStartCol += nDiffX; +/*N*/ nDataStartRow += nDiffY; +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ void ScPivot::SetColFields(const PivotField* pFieldArr, short nCount) +/*N*/ { +/*N*/ nColCount = Max((short)0, Min(nCount, (short)PIVOT_MAXFIELD)); +/*N*/ for (short i = 0; i < nColCount; i++) +/*N*/ { +/*N*/ aColArr[i] = pFieldArr[i]; +/*N*/ aColArr[i].nFuncCount = 0; +/*N*/ if (aColArr[i].nCol == PIVOT_DATA_FIELD) +/*N*/ { +/*N*/ aColArr[i].nFuncMask = PIVOT_FUNC_NONE; +/*N*/ pDataList = pColList[i]; +/*N*/ bDataAtCol = TRUE; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ for (short j=0; j<=PIVOT_MAXFUNC; j++) // incl. "auto" +/*N*/ if (aColArr[i].nFuncMask & nFuncMaskArr[j]) +/*N*/ aColArr[i].nFuncCount++; +/*N*/ } +/*N*/ } +/*N*/ bValidArea = FALSE; +/*N*/ } + +/*N*/ void ScPivot::GetColFields(PivotField* pFieldArr, short& rCount) const +/*N*/ { +/*N*/ for (short i=0; i<nColCount; i++) +/*N*/ pFieldArr[i] = aColArr[i]; +/*N*/ rCount = nColCount; +/*N*/ } + +/*N*/ void ScPivot::SetRowFields(const PivotField* pFieldArr, short nCount) +/*N*/ { +/*N*/ nRowCount = Max((short)0, Min(nCount, (short)PIVOT_MAXFIELD)); +/*N*/ for (short i = 0; i < nRowCount; i++) +/*N*/ { +/*N*/ aRowArr[i] = pFieldArr[i]; +/*N*/ aRowArr[i].nFuncCount = 0; +/*N*/ if (aRowArr[i].nCol == PIVOT_DATA_FIELD) +/*N*/ { +/*N*/ aRowArr[i].nFuncMask = PIVOT_FUNC_NONE; +/*N*/ pDataList = pRowList[i]; +/*N*/ bDataAtCol = FALSE; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ for (short j=0; j<=PIVOT_MAXFUNC; j++) // incl. "auto" +/*N*/ if (aRowArr[i].nFuncMask & nFuncMaskArr[j]) +/*N*/ aRowArr[i].nFuncCount++; +/*N*/ } +/*N*/ } +/*N*/ bValidArea = FALSE; +/*N*/ } + +/*N*/ void ScPivot::GetRowFields(PivotField* pFieldArr, short& rCount) const +/*N*/ { +/*N*/ for (short i=0; i<nRowCount; i++) +/*N*/ pFieldArr[i] = aRowArr[i]; +/*N*/ rCount = nRowCount; +/*N*/ } + +/*N*/ void ScPivot::SetDataFields(const PivotField* pFieldArr, short nCount) +/*N*/ { +/*N*/ USHORT nFuncNo; +/*N*/ short i; +/*N*/ +/*N*/ // +/*N*/ // nDataCount vorausberechnen (wie unten) +/*N*/ // +/*N*/ +/*N*/ nDataCount = 0; +/*N*/ for (i = 0; i < nCount; i++) +/*N*/ for (nFuncNo=0; nFuncNo<PIVOT_MAXFUNC; nFuncNo++) +/*N*/ if (pFieldArr[i].nFuncMask & nFuncMaskArr[nFuncNo]) +/*N*/ if (nDataCount+1 < PIVOT_MAXFIELD) +/*N*/ ++nDataCount; +/*N*/ +/*N*/ // +/*N*/ // Eintraege anpassen +/*N*/ // +/*N*/ +/*N*/ if ((nRowCount == 1) && (aRowArr[0].nCol == PIVOT_DATA_FIELD) && (nDataCount == 1)) +/*N*/ { +/*?*/ aColArr[nColCount] = aRowArr[0]; +/*?*/ pDataList = pColList[nColCount]; +/*?*/ nColCount++; +/*?*/ nRowCount--; +/*?*/ bDataAtCol = TRUE; +/*N*/ } +/*N*/ if ((nColCount == 1) && (aColArr[0].nCol == PIVOT_DATA_FIELD) && (nDataCount == 1)) +/*N*/ { +/*?*/ aRowArr[nRowCount] = aColArr[0]; +/*?*/ pDataList = pRowList[nRowCount]; +/*?*/ nRowCount++; +/*?*/ nColCount--; +/*?*/ bDataAtCol = FALSE; +/*N*/ } +/*N*/ +/*N*/ if ((nDataCount == 1) +/*N*/ && (aColArr[nColCount-1].nCol != PIVOT_DATA_FIELD) +/*N*/ && (aColArr[nRowCount-1].nCol != PIVOT_DATA_FIELD)) +/*N*/ { +/*?*/ if (bDataAtCol) +/*?*/ { +/*?*/ PivotField aField; +/*?*/ short nIndex = PIVOT_MAXFIELD; +/*?*/ for (i=0; i<nColCount; i++) +/*?*/ { +/*?*/ if (aColArr[i].nCol == PIVOT_DATA_FIELD) +/*?*/ { +/*?*/ aField = aColArr[i]; +/*?*/ nIndex = i; +/*?*/ } +/*?*/ } +/*?*/ DBG_ASSERT(nIndex < PIVOT_MAXFIELD, "no data field (GPF in old versions!)"); +/*?*/ if ( nIndex < PIVOT_MAXFIELD ) +/*?*/ { +/*?*/ memcpy(&aColArr[nIndex], &aColArr[nIndex+1], (PIVOT_MAXFIELD - nIndex - 1) * sizeof(PivotField)); +/*?*/ aColArr[nColCount-1] = aField; +/*?*/ pDataList = pColList[nColCount-1]; +/*?*/ } +/*?*/ } +/*?*/ else +/*?*/ { +/*?*/ PivotField aField; +/*?*/ short nIndex = PIVOT_MAXFIELD; +/*?*/ for (i=0; i<nRowCount; i++) +/*?*/ { +/*?*/ if (aRowArr[i].nCol == PIVOT_DATA_FIELD) +/*?*/ { +/*?*/ aField = aRowArr[i]; +/*?*/ nIndex = i; +/*?*/ } +/*?*/ } +/*?*/ DBG_ASSERT(nIndex < PIVOT_MAXFIELD, "no data field (GPF in old versions!)"); +/*?*/ if ( nIndex < PIVOT_MAXFIELD ) +/*?*/ { +/*?*/ memcpy(&aRowArr[nIndex], &aRowArr[nIndex+1], (PIVOT_MAXFIELD - nIndex - 1) * sizeof(PivotField)); +/*?*/ aRowArr[nRowCount-1] = aField; +/*?*/ pDataList = pRowList[nRowCount-1]; +/*?*/ } +/*?*/ } +/*N*/ } +/*N*/ +/*N*/ // +/*N*/ // Datenfelder in Eintraege mit nur einer Funktion aufteilen +/*N*/ // +/*N*/ +/*N*/ pDataList->FreeAll(); +/*N*/ nDataCount = 0; +/*N*/ for (i = 0; i < nCount; i++) +/*N*/ { +/*N*/ for (nFuncNo=0; nFuncNo<PIVOT_MAXFUNC; nFuncNo++) +/*N*/ if (pFieldArr[i].nFuncMask & nFuncMaskArr[nFuncNo]) +/*N*/ if (nDataCount+1 < PIVOT_MAXFIELD) +/*N*/ { +/*N*/ aDataArr[nDataCount] = pFieldArr[i]; +/*N*/ aDataArr[nDataCount].nFuncCount = 0; +/*N*/ aDataArr[nDataCount].nFuncMask = nFuncMaskArr[nFuncNo]; +/*N*/ +/*N*/ String aStr; +/*N*/ pDoc->GetString(aDataArr[nDataCount].nCol, nSrcRow1, nSrcTab, aStr); +/*N*/ if (aStr.Len() == 0) +/*?*/ aStr = ColToAlpha( aDataArr[nDataCount].nCol ); +/*N*/ TypedStrData* pStrData = new TypedStrData(aStr); +/*N*/ if (!(pDataList->AtInsert(pDataList->GetCount(), pStrData))) +/*N*/ { +/*?*/ delete pStrData; +/*?*/ DBG_ERROR("Fehler bei pDataList->AtInsert"); +/*N*/ } +/*N*/ +/*N*/ ++nDataCount; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // +/*N*/ // +/*N*/ // +/*N*/ +/*N*/ bValidArea = FALSE; +/*N*/ } + +/*N*/ void ScPivot::GetDataFields(PivotField* pFieldArr, short& rCount) const +/*N*/ { +/* for (short i=0; i<nDataCount; i++) + pFieldArr[i] = aDataArr[i]; + rCount = nDataCount; +*/ +/*N*/ +/*N*/ rCount = 0; +/*N*/ for (short i=0; i<nDataCount; i++) +/*N*/ { +/*N*/ BOOL bFound = FALSE; +/*N*/ for (short j=0; j<rCount && !bFound; j++) +/*?*/ if (pFieldArr[j].nCol == aDataArr[i].nCol) +/*?*/ { +/*?*/ // add to previous column only if new bits aren't already set there +/*?*/ if ( ( pFieldArr[j].nFuncMask & aDataArr[i].nFuncMask ) == 0 ) +/*?*/ { +/*?*/ pFieldArr[j].nFuncMask |= aDataArr[i].nFuncMask; +/*?*/ pFieldArr[j].nFuncCount++; +/*?*/ bFound = TRUE; +/*?*/ } +/*?*/ } +/*N*/ if (!bFound) +/*N*/ { +/*N*/ pFieldArr[rCount] = aDataArr[i]; +/*N*/ ++rCount; +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ BOOL ScPivot::CreateData(BOOL bKeepDest) +/*N*/ { +/*N*/ // +/*N*/ // +/*N*/ // +/*N*/ +/*N*/ USHORT nOldCol2 = nDestCol2; +/*N*/ USHORT nOldRow2 = nDestRow2; +/*N*/ +/*N*/ pColRef = new PivotColRef[MAXCOL]; +/*N*/ aQuery.nCol1 = nSrcCol1; +/*N*/ aQuery.nRow1 = nSrcRow1; +/*N*/ aQuery.nCol2 = nSrcCol2; +/*N*/ aQuery.nRow2 = nSrcRow2; +/*N*/ aQuery.bHasHeader = bHasHeader; +/*N*/ BOOL bRet = CreateFields(); +/*N*/ if (bRet) +/*N*/ { +/*N*/ short i=0; // nDataMult berechnen - nach CreateFields, vor CreateFieldData !!! +/*N*/ nDataMult = 1; +/*N*/ if (nDataCount > 1) +/*N*/ { +/*?*/ if (bDataAtCol) +/*?*/ { +/*?*/ while (i<nColCount && aColArr[i].nCol != PIVOT_DATA_FIELD) i++; +/*?*/ i++; +/*?*/ while (i<nColCount) +/*?*/ nDataMult *= pColList[i++]->GetCount(); +/*?*/ } +/*?*/ else +/*?*/ { +/*?*/ while (i<nRowCount && aRowArr[i].nCol != PIVOT_DATA_FIELD) i++; +/*?*/ i++; +/*?*/ while (i<nRowCount) +/*?*/ nDataMult *= pRowList[i++]->GetCount(); +/*?*/ } +/*N*/ } +/*N*/ DBG_ASSERT(nDataMult,"nDataMult==0"); +/*N*/ +/*N*/ CalcArea(); +/*N*/ if ((nDestCol2 <= MAXCOL) && (nDestRow2 <= MAXROW)) +/*N*/ { +/*N*/ CreateFieldData(); +/*N*/ bValidArea = TRUE; +/*N*/ } +/*N*/ else +/*N*/ bRet = FALSE; +/*N*/ } +/*N*/ +/*N*/ if ( bKeepDest ) +/*N*/ { +/*N*/ bValidArea = TRUE; //! ??? +/*N*/ nDestCol2 = nOldCol2; +/*N*/ nDestRow2 = nOldRow2; +/*N*/ } +/*N*/ +/*N*/ return bRet; +/*N*/ } + + +/*N*/ void ScPivot::ReleaseData() +/*N*/ { +/*N*/ short i; +/*N*/ for (i = 0; i < PIVOT_MAXFIELD; i++) +/*N*/ { +/*N*/ pColList[i]->FreeAll(); +/*N*/ pRowList[i]->FreeAll(); +/*N*/ } +/*N*/ if (ppDataArr) +/*N*/ { +/*N*/ for (i=0; i<nDataRowCount; i++) +/*N*/ delete[] ppDataArr[i]; +/*N*/ delete[] ppDataArr; +/*N*/ ppDataArr = NULL; +/*N*/ } +/*N*/ nDataColCount = 0; +/*N*/ nDataRowCount = 0; +/*N*/ delete[] pColRef; +/*N*/ pColRef = NULL; +/*N*/ } + + + + + + +//-------------------------------------------------------------------------------------------------- +// Private Methoden +//-------------------------------------------------------------------------------------------------- + +/*N*/ BOOL ScPivot::CreateFields() +/*N*/ { +/*N*/ short i; +/*N*/ USHORT nRow; +/*N*/ USHORT nHeader; +/*N*/ String aStr; +/*N*/ TypedStrData* pStrData; +/*N*/ if (bHasHeader) +/*N*/ nHeader = 1; +/*N*/ else +/*N*/ nHeader = 0; +/*N*/ +/*N*/ // Sortieren nach Benutzerdefinierte Listen ?? +/*N*/ for (i = 0; i < nColCount; i++) +/*N*/ { +/*N*/ if (aColArr[i].nCol != PIVOT_DATA_FIELD) +/*N*/ { +/*N*/ pDoc->GetString(aColArr[i].nCol, nSrcRow1 + nHeader, nSrcTab, aStr); +/*N*/ pColList[i]->SetUserData(ScGlobal::GetUserList()->GetData(aStr)); +/*N*/ } +/*N*/ else +/*N*/ pColList[i]->SetUserData(NULL); +/*N*/ } +/*N*/ for (i = 0; i < nRowCount; i++) +/*N*/ { +/*N*/ if (aRowArr[i].nCol != PIVOT_DATA_FIELD) +/*N*/ { +/*N*/ pDoc->GetString(aRowArr[i].nCol, nSrcRow1 + nHeader, nSrcTab, aStr); +/*N*/ pRowList[i]->SetUserData(ScGlobal::GetUserList()->GetData(aStr)); +/*N*/ } +/*N*/ else +/*?*/ pRowList[i]->SetUserData(NULL); +/*N*/ } +/*N*/ +/*N*/ ScAddress aSrcAdr( nSrcCol1, 0, nSrcTab ); +/*N*/ for (nRow = nSrcRow1 + nHeader; nRow <= nSrcRow2; nRow++) +/*N*/ { +/*N*/ BOOL bValidLine = TRUE; +/*N*/ if (bIgnoreEmpty) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 aSrcAdr.SetRow( nRow ); +/*N*/ } +/*N*/ if (bValidLine) +/*N*/ bValidLine = pDoc->pTab[nSrcTab]->ValidQuery(nRow, aQuery); +/*N*/ if (bValidLine) +/*N*/ { +/*N*/ // Sortierte Liste der Felder erzeugen +/*N*/ //! statt GetCategoryString leere weglassen ! +/*N*/ +/*N*/ for (i = 0; i < nColCount; i++) +/*N*/ { +/*N*/ if (aColArr[i].nCol != PIVOT_DATA_FIELD) +/*N*/ { +/*N*/ USHORT nCatRow = bDetectCat ? GetCategoryRow( aColArr[i].nCol, nRow ) : nRow; +/*N*/ pStrData = new TypedStrData( pDoc, aColArr[i].nCol, nCatRow, nSrcTab, TRUE ); +/*N*/ if (!(pColList[i]->Insert(pStrData))) +/*N*/ delete pStrData; +/*N*/ } +/*N*/ } +/*N*/ for (i = 0; i < nRowCount; i++) +/*N*/ { +/*N*/ if (aRowArr[i].nCol != PIVOT_DATA_FIELD) +/*N*/ { +/*N*/ USHORT nCatRow = bDetectCat ? GetCategoryRow( aRowArr[i].nCol, nRow ) : nRow; +/*N*/ pStrData = new TypedStrData( pDoc, aRowArr[i].nCol, nCatRow, nSrcTab, TRUE ); +/*N*/ if (!(pRowList[i]->Insert(pStrData))) +/*N*/ delete pStrData; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ return TRUE; +/*N*/ } + +/*N*/ void ScPivot::CreateFieldData() +/*N*/ { +/*N*/ USHORT* pRowListIndex = nRowCount ? new USHORT[nRowCount] : NULL; +/*N*/ USHORT* pColListIndex = nColCount ? new USHORT[nColCount] : NULL; +/*N*/ +/*N*/ short i,j,k; +/*N*/ +/*N*/ ppDataArr = new SubTotal*[nDataRowCount]; +/*N*/ for (i=0; i<nDataRowCount; i++) +/*N*/ ppDataArr[i] = new SubTotal[nDataColCount]; +/*N*/ +/*N*/ if (bDataAtCol) +/*N*/ for (j=0; j<nDataRowCount; j++) +/*N*/ for (i=0; i<nDataColCount; i++) +/*N*/ ppDataArr[j][i].nIndex = j/nDataMult%nDataCount; +/*N*/ else +/*?*/ for (j=0; j<nDataRowCount; j++) +/*?*/ for (i=0; i<nDataColCount; i++) +/*?*/ ppDataArr[j][i].nIndex = i/nDataMult%nDataCount; +/*N*/ +/*N*/ short nHeader; +/*N*/ if (bHasHeader) +/*N*/ nHeader = 1; +/*N*/ else +/*N*/ nHeader = 0; +/*N*/ ScAddress aSrcAdr( nSrcCol1, 0, nSrcTab ); +/*N*/ for (USHORT nRow = nSrcRow1 + nHeader; nRow <= nSrcRow2; nRow++) +/*N*/ { +/*N*/ BOOL bValidLine = TRUE; +/*N*/ if (bIgnoreEmpty) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 aSrcAdr.SetRow( nRow ); +/*N*/ } +/*N*/ if (bValidLine) +/*N*/ bValidLine = pDoc->pTab[nSrcTab]->ValidQuery(nRow, aQuery); +/*N*/ if (bValidLine) +/*N*/ { +/*N*/ // Indizes der Kategorien nur einmal ausserhalb nDataCount +/*N*/ for (j=0; j<nRowCount; j++) +/*N*/ if (aRowArr[j].nCol != PIVOT_DATA_FIELD) +/*N*/ { +/*N*/ USHORT nCatRow = bDetectCat ? GetCategoryRow( aRowArr[j].nCol, nRow ) : nRow; +/*N*/ TypedStrData aStrData( pDoc, aRowArr[j].nCol, nCatRow, nSrcTab, TRUE ); +/*N*/ pRowListIndex[j] = pRowList[j]->GetIndex(&aStrData); +/*N*/ } +/*N*/ for (j=0; j<nColCount; j++) +/*N*/ if (aColArr[j].nCol != PIVOT_DATA_FIELD) +/*N*/ { +/*N*/ USHORT nCatRow = bDetectCat ? GetCategoryRow( aColArr[j].nCol, nRow ) : nRow; +/*N*/ TypedStrData aStrData( pDoc, aColArr[j].nCol, nCatRow, nSrcTab, TRUE ); +/*N*/ pColListIndex[j] = pColList[j]->GetIndex(&aStrData); +/*N*/ } +/*N*/ +/*N*/ String aStr; +/*N*/ short nCIndex; +/*N*/ short nRIndex; +/*N*/ short nIndex; +/*N*/ ScAddress aAdr( 0, nRow, nSrcTab ); +/*N*/ +/*N*/ for (i=0; i<nDataCount; i++) +/*N*/ { +/*N*/ // ColIndex Berechnen +/*N*/ nCIndex = 0; +/*N*/ for (j=0; j<nRowCount; j++) +/*N*/ { +/*N*/ if (aRowArr[j].nCol == PIVOT_DATA_FIELD) +/*N*/ nIndex = i; +/*N*/ else +/*N*/ nIndex = pRowListIndex[j]; +/*N*/ if (nIndex) +/*N*/ { +/*N*/ for (k=j+1; k<nRowCount; k++) +/*?*/ nIndex *= pRowList[k]->GetCount(); +/*N*/ nCIndex += nIndex; +/*N*/ } +/*N*/ } +/*N*/ // RowIndex Berechnen +/*N*/ nRIndex = 0; +/*N*/ for (j=0; j<nColCount; j++) +/*N*/ { +/*N*/ if (aColArr[j].nCol == PIVOT_DATA_FIELD) +/*N*/ nIndex = i; +/*N*/ else +/*N*/ nIndex = pColListIndex[j]; +/*N*/ if (nIndex) +/*N*/ { +/*N*/ for (k=j+1; k<nColCount; k++) +/*N*/ nIndex *= pColList[k]->GetCount(); +/*N*/ nRIndex += nIndex; +/*N*/ } +/*N*/ } +/*N*/ // Daten eintragen +/*N*/ if ((nCIndex < nDataColCount) && (nRIndex < nDataRowCount)) +/*N*/ { +/*N*/ DBG_ASSERT((short)ppDataArr[nRIndex][nCIndex].nIndex == i, "falsch init."); +/*N*/ +/*N*/ ppDataArr[nRIndex][nCIndex].nIndex = i; +/*N*/ aAdr.SetCol( aDataArr[i].nCol ); +/*N*/ CellType eCellType = pDoc->GetCellType( aAdr ); +/*N*/ if ((eCellType != CELLTYPE_NONE) && (eCellType != CELLTYPE_NOTE)) +/*N*/ { +/*N*/ BOOL bValue = (eCellType == CELLTYPE_VALUE); +/*N*/ if (eCellType == CELLTYPE_FORMULA) +/*N*/ { +/*N*/ ScBaseCell* pCell = pDoc->GetCell( aAdr ); +/*N*/ bValue = ((ScFormulaCell*)pCell)->IsValue(); +/*N*/ } +/*N*/ +/*N*/ if (bValue) +/*N*/ { +/*N*/ double nVal = pDoc->GetValue( aAdr ); +/*N*/ ppDataArr[nRIndex][nCIndex].Update(nVal); +/*N*/ } +/*N*/ else +/*?*/ {DBG_BF_ASSERT(0, "STRIP");} //STRIP001 ppDataArr[nRIndex][nCIndex].UpdateNoVal(); // nur nCount +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ delete pColListIndex; +/*N*/ delete pRowListIndex; +/*N*/ } + +/*N*/ void ScPivot::CalcArea() +/*N*/ { +/*N*/ BOOL bNoRows = (nRowCount == 0) || ( nRowCount == 1 && aRowArr[0].nCol == PIVOT_DATA_FIELD ); +/*N*/ BOOL bNoCols = (nColCount == 0) || ( nColCount == 1 && aColArr[0].nCol == PIVOT_DATA_FIELD ); +/*N*/ if (!bMakeTotalCol) bNoRows = TRUE; +/*N*/ if (!bMakeTotalRow) bNoCols = TRUE; +/*N*/ +/*N*/ short i; +/*N*/ short nDx; +/*N*/ // StartSpalte/StartZeile des Datenbereichs berechnen +/*N*/ if (bDataAtCol) +/*N*/ { +/*N*/ if (nDataCount > 1) +/*?*/ nDataStartCol = nDestCol1 + nColCount; +/*N*/ else +/*N*/ nDataStartCol = nDestCol1 + Max(0, nColCount - 1); +/*N*/ } +/*N*/ else +/*?*/ nDataStartCol = nDestCol1 + nColCount; +/*N*/ if (!bDataAtCol) +/*N*/ { +/*?*/ if (nDataCount > 1) +/*?*/ nDataStartRow = nDestRow1 + nRowCount + nFirstLine + 1; +/*?*/ else +/*?*/ nDataStartRow = nDestRow1 + Max(0, nRowCount - 1) + nFirstLine + 1; +/*N*/ } +/*N*/ else +/*N*/ nDataStartRow = nDestRow1 + nRowCount + nFirstLine + 1; +/*N*/ +/*N*/ // +/*N*/ // Groesse der PivotTabelle berechnen +/*N*/ // +/*N*/ +/*N*/ if (nRowCount == 0 || (nRowCount==1 && aRowArr[0].nCol==PIVOT_DATA_FIELD && nDataCount==1)) +/*N*/ { +/*?*/ nDataColCount = 1; +/*?*/ if (nDataCount == 1) +/*?*/ nDestCol2 = nDestCol1 + nColCount - 1; +/*?*/ else +/*?*/ nDestCol2 = nDestCol1 + nColCount; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ // Anzahl Spalten +/*N*/ if ((aRowArr[nRowCount-1].nCol == PIVOT_DATA_FIELD) && (nDataCount == 1)) +/*N*/ nDx = 2; +/*N*/ else +/*N*/ nDx = 1; +/*N*/ long nColLines = pRowList[nRowCount-nDx]->GetCount(); // long um Ueberlauf zu erkennen +/*N*/ nDataColCount = pRowList[nRowCount-nDx]->GetCount(); +/*N*/ for (i=nRowCount-nDx-1; i >= 0; i--) +/*N*/ { +/*?*/ nColLines *= pRowList[i]->GetCount(); +/*?*/ nDataColCount *= pRowList[i]->GetCount(); +/*?*/ if (!bDataAtCol) +/*?*/ nColLines += (pRowList[i]->GetCount() * aRowArr[i].nFuncCount * nDataCount); +/*?*/ else +/*?*/ nColLines += (pRowList[i]->GetCount() * aRowArr[i].nFuncCount); +/*N*/ } +/*N*/ /* + // Ergebnisspalten des letzten Elements + if (aRowArr[nRowCount-1].nCol != PIVOT_DATA_FIELD) + nColLines += (pRowList[nRowCount-1]->GetCount() * aRowArr[nRowCount-1].nFuncCount); + */ +/*N*/ if (nColLines > MAXCOL) +/*?*/ nDestCol2 = MAXCOL+2; // ungueltig, 1 wird unten abgezogen +/*N*/ else if (bDataAtCol) +/*N*/ { +/*N*/ if (nDataCount > 1) +/*?*/ nDestCol2 = nDestCol1 + nColCount + nColLines; +/*N*/ else +/*N*/ nDestCol2 = nDestCol1 + (nColCount - 1) + nColLines; +/*N*/ if (!bMakeTotalCol) +/*?*/ --nDestCol2; +/*N*/ } +/*N*/ else +/*?*/ nDestCol2 = nDestCol1 + nColCount + nColLines; +/*N*/ } +/*N*/ +/*N*/ if (nColCount == 0 || (nColCount==1 && aColArr[0].nCol==PIVOT_DATA_FIELD && nDataCount==1)) +/*N*/ { +/*?*/ nDataRowCount = 1; +/*?*/ if (nDataCount == 1) +/*?*/ nDestRow2 = nDestRow1 + (nRowCount - 1) + nFirstLine + 1; +/*?*/ else +/*?*/ nDestRow2 = nDestRow1 + nRowCount + nFirstLine + 1; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ // Anzahl Zeilen +/*N*/ if ((aColArr[nColCount-1].nCol == PIVOT_DATA_FIELD) && (nDataCount == 1)) +/*N*/ nDx = 2; +/*N*/ else +/*N*/ nDx = 1; +/*N*/ long nRowLines = pColList[nColCount-nDx]->GetCount(); // long um Ueberlauf zu erkennen +/*N*/ nDataRowCount = pColList[nColCount-nDx]->GetCount(); +/*N*/ for (i=nColCount-nDx-1; i >= 0; i--) +/*N*/ { +/*?*/ nRowLines *= pColList[i]->GetCount(); +/*?*/ nDataRowCount *= pColList[i]->GetCount(); +/*?*/ if (bDataAtCol) +/*?*/ nRowLines += (pColList[i]->GetCount() * aColArr[i].nFuncCount * nDataCount); +/*?*/ else +/*?*/ nRowLines += (pColList[i]->GetCount() * aColArr[i].nFuncCount); +/*N*/ } + /* + // Ergebniszeilen des letzten Elements + if (aColArr[nColCount-1].nCol != PIVOT_DATA_FIELD) + nRowLines += (pColList[nColCount-1]->GetCount() * aColArr[nColCount-1].nFuncCount); + */ +/*N*/ if (nRowLines > MAXROW) +/*?*/ nDestRow2 = MAXROW+2; // ungueltig, 1 wird unten abgezogen +/*N*/ else if (!bDataAtCol) +/*N*/ { +/*?*/ if (nDataCount > 1) +/*?*/ nDestRow2 = nDestRow1 + nRowCount + nRowLines + nFirstLine + 1; +/*?*/ else +/*?*/ nDestRow2 = nDestRow1 + (nRowCount - 1) + nRowLines + nFirstLine + 1; +/*?*/ if (!bMakeTotalRow) +/*?*/ --nDestRow2; +/*N*/ } +/*N*/ else +/*N*/ nDestRow2 = nDestRow1 + nRowCount + nRowLines + nFirstLine + 1; +/*N*/ } +/*N*/ +/*N*/ if (bDataAtCol) +/*N*/ { +/*N*/ if (!bNoCols) +/*N*/ nDestRow2 += nDataCount; +/*N*/ nDestRow2 --; +/*N*/ } +/*N*/ else +/*N*/ { +/*?*/ if (!bNoRows) +/*?*/ nDestCol2 += nDataCount; +/*?*/ nDestCol2 --; +/*N*/ } +/*N*/ } + + + + + +/*N*/ USHORT ScPivot::GetCategoryRow( USHORT nCol, USHORT nRow ) +/*N*/ { +/*N*/ USHORT nMinRow = nSrcRow1; +/*N*/ if (bHasHeader) ++nMinRow; +/*N*/ BOOL bFound = FALSE; +/*N*/ do +/*N*/ { +/*N*/ if ( !pDoc->HasData( nCol, nRow, nSrcTab ) && nRow>nMinRow ) +/*N*/ --nRow; +/*N*/ else +/*N*/ bFound = TRUE; +/*N*/ } +/*N*/ while (!bFound); +/*N*/ return nRow; +/*N*/ } + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_pivot2.cxx b/binfilter/bf_sc/source/core/data/sc_pivot2.cxx new file mode 100644 index 000000000000..f70ee20c2a24 --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_pivot2.cxx @@ -0,0 +1,291 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#ifdef _MSC_VER +#pragma optimize("",off) +#endif +#ifdef _MSC_VER +#pragma optimize("q",off) // p-code off +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "scitems.hxx" +#include <unotools/transliterationwrapper.hxx> + +#include "globstr.hrc" +#include "rangeutl.hxx" +#include "pivot.hxx" +#include "rechead.hxx" +#include "refupdat.hxx" +#include "stlsheet.hxx" +namespace binfilter { + + +// STATIC DATA ----------------------------------------------------------- + +//-------------------------------------------------------------------------------------------------- +// Hilfsmethoden von ScPivot +//-------------------------------------------------------------------------------------------------- + + + + + + + + + + +//-------------------------------------------------------------------------------------------------- + +/*N*/ void ScPivot::GetParam( ScPivotParam& rParam, ScQueryParam& rQuery, ScArea& rSrcArea ) const +/*N*/ { +/*N*/ short nCount; +/*N*/ USHORT nDummy; +/*N*/ GetDestArea( rParam.nCol,rParam.nRow, nDummy,nDummy, rParam.nTab ); +/*N*/ +/*N*/ // Row und Col in der Bedeutung vertauscht: +/*N*/ GetRowFields( rParam.aColArr, nCount ); +/*N*/ rParam.nColCount = (USHORT) nCount; +/*N*/ GetColFields( rParam.aRowArr, nCount ); +/*N*/ rParam.nRowCount = (USHORT) nCount; +/*N*/ GetDataFields( rParam.aDataArr, nCount ); +/*N*/ rParam.nDataCount = (USHORT) nCount; +/*N*/ +/*N*/ rParam.bIgnoreEmptyRows = GetIgnoreEmpty(); +/*N*/ rParam.bDetectCategories = GetDetectCat(); +/*N*/ rParam.bMakeTotalCol = GetMakeTotalCol(); +/*N*/ rParam.bMakeTotalRow = GetMakeTotalRow(); +/*N*/ +/*N*/ GetQuery(rQuery); +/*N*/ GetSrcArea( rSrcArea.nColStart, rSrcArea.nRowStart, +/*N*/ rSrcArea.nColEnd, rSrcArea.nRowEnd, rSrcArea.nTab ); +/*N*/ } + +/*N*/ void ScPivot::SetParam( const ScPivotParam& rParam, const ScQueryParam& rQuery, +/*N*/ const ScArea& rSrcArea ) +/*N*/ { +/*N*/ SetQuery( rQuery ); +/*N*/ SetHeader( TRUE ); +/*N*/ SetSrcArea( rSrcArea.nColStart, rSrcArea.nRowStart, +/*N*/ rSrcArea.nColEnd, rSrcArea.nRowEnd, rSrcArea.nTab ); +/*N*/ SetDestPos( rParam.nCol, rParam.nRow, rParam.nTab ); +/*N*/ SetIgnoreEmpty( rParam.bIgnoreEmptyRows ); +/*N*/ SetDetectCat( rParam.bDetectCategories ); +/*N*/ SetMakeTotalCol( rParam.bMakeTotalCol ); +/*N*/ SetMakeTotalRow( rParam.bMakeTotalRow ); +/*N*/ +/*N*/ // Row und Col in der Bedeutung vertauscht: +/*N*/ SetRowFields( rParam.aColArr, rParam.nColCount ); +/*N*/ SetColFields( rParam.aRowArr, rParam.nRowCount ); +/*N*/ SetDataFields( rParam.aDataArr, rParam.nDataCount ); +/*N*/ } + +/*N*/ DataObject* ScPivot::Clone() const +/*N*/ { +/*N*/ return new ScPivot(*this); +/*N*/ } + +//-------------------------------------------------------------------------------------------------- +// PivotStrCollection +//-------------------------------------------------------------------------------------------------- + + +/*N*/ short PivotStrCollection::Compare(DataObject* pKey1, DataObject* pKey2) const +/*N*/ { +/*N*/ DBG_ASSERT(pKey1&&pKey2,"0-Zeiger bei PivotStrCollection::Compare"); +/*N*/ +/*N*/ short nResult = 0; +/*N*/ +/*N*/ TypedStrData& rData1 = (TypedStrData&)*pKey1; +/*N*/ TypedStrData& rData2 = (TypedStrData&)*pKey2; +/*N*/ +/*N*/ if ( rData1.nStrType > rData2.nStrType ) +/*N*/ nResult = 1; +/*N*/ else if ( rData1.nStrType < rData2.nStrType ) +/*N*/ nResult = -1; +/*N*/ else if ( !rData1.nStrType /* && !rData2.nStrType */ ) +/*N*/ { +/*?*/ // Zahlen vergleichen: +/*?*/ +/*?*/ if ( rData1.nValue == rData2.nValue ) +/*?*/ nResult = 0; +/*?*/ else if ( rData1.nValue < rData2.nValue ) +/*?*/ nResult = -1; +/*?*/ else +/*?*/ nResult = 1; +/*N*/ } +/*N*/ else /* if ( rData1.nStrType && rData2.nStrType ) */ +/*N*/ { +/*N*/ // Strings vergleichen: +/*N*/ +/*N*/ if (pUserData) +/*?*/ {DBG_BF_ASSERT(0, "STRIP");} //STRIP001 nResult = pUserData->ICompare(rData1.aStrValue, rData2.aStrValue); +/*N*/ else +/*N*/ { +/*N*/ nResult = (short) ScGlobal::pTransliteration->compareString( +/*N*/ rData1.aStrValue, rData2.aStrValue ); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ return nResult; +/*N*/ } + +/*N*/ short PivotStrCollection::GetIndex(TypedStrData* pData) const +/*N*/ { +/*N*/ USHORT nIndex = 0; +/*N*/ if (!Search(pData, nIndex)) +/*N*/ nIndex = 0; +/*N*/ return (short)nIndex; +/*N*/ } + +//-------------------------------------------------------------------------------------------------- +// PivotCollection +//-------------------------------------------------------------------------------------------------- + +/*N*/ String ScPivotCollection::CreateNewName( USHORT nMin ) const +/*N*/ { +/*N*/ String aBase( RTL_CONSTASCII_USTRINGPARAM("DataPilot") ); +/*N*/ //! from Resource? +/*N*/ +/*N*/ for (USHORT nAdd=0; nAdd<=nCount; nAdd++) // nCount+1 Versuche +/*N*/ { +/*N*/ String aNewName = aBase; +/*N*/ aNewName += String::CreateFromInt32( nMin + nAdd ); +/*N*/ BOOL bFound = FALSE; +/*N*/ for (USHORT i=0; i<nCount && !bFound; i++) +/*N*/ if (((ScPivot*)pItems[i])->GetName() == aNewName) +/*N*/ bFound = TRUE; +/*N*/ if (!bFound) +/*N*/ return aNewName; // freien Namen gefunden +/*N*/ } +/*N*/ return String(); // sollte nicht vorkommen +/*N*/ } + + +/*N*/ BOOL ScPivotCollection::Load(SvStream& rStream) +/*N*/ { +/*N*/ BOOL bSuccess = TRUE; +/*N*/ USHORT nNewCount, i; +/*N*/ FreeAll(); +/*N*/ +/*N*/ ScMultipleReadHeader aHdr( rStream ); +/*N*/ +/*N*/ rStream >> nNewCount; +/*N*/ for (i=0; i<nNewCount && bSuccess; i++) +/*N*/ { +/*N*/ ScPivot* pPivot = new ScPivot( pDoc ); +/*N*/ if (pPivot) +/*N*/ { +/*N*/ bSuccess = pPivot->Load(rStream, aHdr); +/*N*/ Insert( pPivot ); +/*N*/ } +/*N*/ else +/*N*/ bSuccess = FALSE; +/*N*/ } +/*N*/ +/*N*/ // fuer alte Dateien: eindeutige Namen vergeben +/*N*/ +/*N*/ if (bSuccess) +/*N*/ for (i=0; i<nCount; i++) +/*N*/ if (!((const ScPivot*)At(i))->GetName().Len()) +/*N*/ ((ScPivot*)At(i))->SetName( CreateNewName() ); +/*N*/ +/*N*/ return bSuccess; +/*N*/ } + +/*N*/ BOOL ScPivotCollection::Store(SvStream& rStream) const +/*N*/ { +/*N*/ BOOL bSuccess = TRUE; +/*N*/ +/*N*/ ScMultipleWriteHeader aHdr( rStream ); +/*N*/ +/*N*/ rStream << nCount; +/*N*/ +/*N*/ for (USHORT i=0; i<nCount && bSuccess; i++) +/*?*/ bSuccess = ((const ScPivot*)At(i))->Store( rStream, aHdr ); +/*N*/ +/*N*/ return bSuccess; +/*N*/ } + +/*N*/ void ScPivotCollection::UpdateReference(UpdateRefMode eUpdateRefMode, +/*N*/ USHORT nCol1, USHORT nRow1, USHORT nTab1, +/*N*/ USHORT nCol2, USHORT nRow2, USHORT nTab2, +/*N*/ short nDx, short nDy, short nDz ) +/*N*/ { +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ { +/*?*/ USHORT theCol1; +/*?*/ USHORT theRow1; +/*?*/ USHORT theTab1; +/*?*/ USHORT theCol2; +/*?*/ USHORT theRow2; +/*?*/ USHORT theTab2; +/*?*/ ScRefUpdateRes eRes; +/*?*/ ScPivot* pPivot = (ScPivot*)pItems[i]; +/*?*/ +/*?*/ // Source +/*?*/ +/*?*/ pPivot->GetSrcArea( theCol1, theRow1, theCol2, theRow2, theTab1 ); +/*?*/ theTab2 = theTab1; +/*?*/ +/*?*/ eRes = ScRefUpdate::Update( pDoc, eUpdateRefMode, +/*?*/ nCol1,nRow1,nTab1, nCol2,nRow2,nTab2, nDx,nDy,nDz, +/*?*/ theCol1,theRow1,theTab1, theCol2,theRow2,theTab2 ); +/*?*/ +/*?*/ if (eRes != UR_NOTHING) +/*?*/ pPivot->MoveSrcArea( theCol1, theRow1, theTab1 ); +/*?*/ +/*?*/ // Dest +/*?*/ +/*?*/ pPivot->GetDestArea( theCol1, theRow1, theCol2, theRow2, theTab1 ); +/*?*/ theTab2 = theTab1; +/*?*/ +/*?*/ eRes = ScRefUpdate::Update( pDoc, eUpdateRefMode, +/*?*/ nCol1,nRow1,nTab1, nCol2,nRow2,nTab2, nDx,nDy,nDz, +/*?*/ theCol1,theRow1,theTab1, theCol2,theRow2,theTab2 ); +/*?*/ +/*?*/ if (eRes != UR_NOTHING) +/*?*/ pPivot->MoveDestArea( theCol1, theRow1, theTab1 ); +/*N*/ } +/*N*/ } + + + + + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_poolhelp.cxx b/binfilter/bf_sc/source/core/data/sc_poolhelp.cxx new file mode 100644 index 000000000000..5988251cacf4 --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_poolhelp.cxx @@ -0,0 +1,91 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include <bf_svtools/zforlist.hxx> +#include <bf_svx/editeng.hxx> + +#include "poolhelp.hxx" +#include "document.hxx" +#include "docpool.hxx" +#include "stlpool.hxx" + +namespace binfilter { + +// ----------------------------------------------------------------------- + +/*N*/ ScPoolHelper::ScPoolHelper( ScDocument* pSourceDoc ) +/*N*/ { +/*N*/ DBG_ASSERT( pSourceDoc, "ScPoolHelper: no document" ); +/*N*/ +/*N*/ pDocPool = new ScDocumentPool; +/*N*/ pDocPool->FreezeIdRanges(); +/*N*/ +/*N*/ pStylePool = new ScStyleSheetPool( *pDocPool, pSourceDoc ); +/*N*/ +/*N*/ pFormTable = new SvNumberFormatter( pSourceDoc->GetServiceManager(), ScGlobal::eLnge ); +/*N*/ pFormTable->SetColorLink( LINK( pSourceDoc, ScDocument, GetUserDefinedColor ) ); +/*N*/ pFormTable->SetEvalDateFormat( NF_EVALDATEFORMAT_INTL_FORMAT ); +/*N*/ +/*N*/ pEditPool = EditEngine::CreatePool(); +/*N*/ pEditPool->SetDefaultMetric( SFX_MAPUNIT_100TH_MM ); +/*N*/ pEditPool->FreezeIdRanges(); +/*N*/ pEditPool->SetFileFormatVersion( SOFFICE_FILEFORMAT_50 ); // used in ScGlobal::EETextObjEqual +/*N*/ +/*N*/ pEnginePool = EditEngine::CreatePool(); +/*N*/ pEnginePool->SetDefaultMetric( SFX_MAPUNIT_100TH_MM ); +/*N*/ pEnginePool->FreezeIdRanges(); +/*N*/ } + +/*N*/ ScPoolHelper::~ScPoolHelper() +/*N*/ { +/*N*/ delete pEnginePool; +/*N*/ delete pEditPool; +/*N*/ delete pFormTable; +/*N*/ delete pStylePool; +/*N*/ delete pDocPool; +/*N*/ } + +/*N*/ void ScPoolHelper::SourceDocumentGone() +/*N*/ { +/*N*/ // reset all pointers to the source document +/*N*/ pStylePool->SetDocument( NULL ); +/*N*/ pFormTable->SetColorLink( Link() ); +/*N*/ } + +// ----------------------------------------------------------------------- + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_sortparam.cxx b/binfilter/bf_sc/source/core/data/sc_sortparam.cxx new file mode 100644 index 000000000000..10ec7a97c5b1 --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_sortparam.cxx @@ -0,0 +1,98 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include "sortparam.hxx" + +namespace binfilter { + + +//------------------------------------------------------------------------ + +/*N*/ ScSortParam::ScSortParam() +/*N*/ { +/*N*/ Clear(); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ ScSortParam::ScSortParam( const ScSortParam& r ) : +/*N*/ nCol1(r.nCol1),nRow1(r.nRow1),nCol2(r.nCol2),nRow2(r.nRow2), +/*N*/ bHasHeader(r.bHasHeader),bCaseSens(r.bCaseSens), +/*N*/ bByRow(r.bByRow),bUserDef(r.bUserDef),nUserIndex(r.nUserIndex),bIncludePattern(r.bIncludePattern), +/*N*/ bInplace(r.bInplace), +/*N*/ nDestTab(r.nDestTab),nDestCol(r.nDestCol),nDestRow(r.nDestRow), +/*N*/ aCollatorLocale( r.aCollatorLocale ), aCollatorAlgorithm( r.aCollatorAlgorithm ) +/*N*/ { +/*N*/ for (USHORT i=0; i<MAXSORT; i++) +/*N*/ { +/*N*/ bDoSort[i] = r.bDoSort[i]; +/*N*/ nField[i] = r.nField[i]; +/*N*/ bAscending[i] = r.bAscending[i]; +/*N*/ } +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ void ScSortParam::Clear() +/*N*/ { +/*N*/ nCol1=nRow1=nCol2=nRow2=nDestTab=nDestCol=nDestRow=nUserIndex = 0; +/*N*/ bHasHeader=bCaseSens=bUserDef = FALSE; +/*N*/ bByRow=bIncludePattern=bInplace = TRUE; +/*N*/ aCollatorLocale = ::com::sun::star::lang::Locale(); +/*N*/ aCollatorAlgorithm.Erase(); +/*N*/ +/*N*/ for (USHORT i=0; i<MAXSORT; i++) +/*N*/ { +/*N*/ bDoSort[i] = FALSE; +/*N*/ nField[i] = 0; +/*N*/ bAscending[i] = TRUE; +/*N*/ } +/*N*/ } + +//------------------------------------------------------------------------ + + +//------------------------------------------------------------------------ + + +//------------------------------------------------------------------------ + + +//------------------------------------------------------------------------ + + +//------------------------------------------------------------------------ + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_stlpool.cxx b/binfilter/bf_sc/source/core/data/sc_stlpool.cxx new file mode 100644 index 000000000000..d1cf7627da44 --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_stlpool.cxx @@ -0,0 +1,576 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +//------------------------------------------------------------------------ + +#include "scitems.hxx" +#define ITEMID_FIELD EE_FEATURE_FIELD + +#include <bf_svx/algitem.hxx> +#include <bf_svx/boxitem.hxx> +#include <bf_svx/brshitem.hxx> +#include <bf_svx/editobj.hxx> +#include <bf_svx/fhgtitem.hxx> + + + +#include <bf_svx/itemdata.hxx> + +#include <tools/date.hxx> + +#include <tools/time.hxx> + +#include <bf_svx/flditem.hxx> +#include <bf_svx/fontitem.hxx> +#include <bf_svx/postitem.hxx> +#include <bf_svx/udlnitem.hxx> +#include <bf_svx/wghtitem.hxx> +#include <bf_svtools/zforlist.hxx> +#include <vcl/outdev.hxx> +#include <vcl/svapp.hxx> + +#include "bf_sc.hrc" +#include "attrib.hxx" +#include "globstr.hrc" +#include "document.hxx" +#include "stlpool.hxx" +#include "stlsheet.hxx" +#include "rechead.hxx" +#include "editutil.hxx" +#include "patattr.hxx" +namespace binfilter { + + +//======================================================================== + +/*N*/ ScStyleSheetPool::ScStyleSheetPool( SfxItemPool& rPool, +/*N*/ ScDocument* pDocument ) +/*N*/ : SfxStyleSheetPool( rPool ), +/*N*/ pActualStyleSheet( NULL ), +/*N*/ pDoc( pDocument ), +/*N*/ pForceStdName( NULL ) +/*N*/ { +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ __EXPORT ScStyleSheetPool::~ScStyleSheetPool() +/*N*/ { +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ void ScStyleSheetPool::SetDocument( ScDocument* pDocument ) +/*N*/ { +/*N*/ pDoc = pDocument; +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ void ScStyleSheetPool::SetForceStdName( const String* pSet ) +/*N*/ { +/*N*/ pForceStdName = pSet; +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ SfxStyleSheetBase& ScStyleSheetPool::Make( const String& rName, +/*N*/ SfxStyleFamily eFam, USHORT mask, USHORT nPos ) +/*N*/ { +/*N*/ // When updating styles from a template, Office 5.1 sometimes created +/*N*/ // files with multiple default styles. +/*N*/ // Create new styles in that case: +/*N*/ +/*N*/ //! only when loading? +/*N*/ +/*N*/ if ( rName.EqualsAscii(STRING_STANDARD) && Find( rName, eFam ) != NULL ) +/*N*/ { +/*?*/ DBG_ERROR("renaming additional default style"); +/*?*/ long nCount = aStyles.Count(); +/*?*/ for ( long nAdd = 1; nAdd <= nCount; nAdd++ ) +/*?*/ { +/*?*/ String aNewName = ScGlobal::GetRscString(STR_STYLENAME_STANDARD); +/*?*/ aNewName += String::CreateFromInt32( nAdd ); +/*?*/ if ( Find( aNewName, eFam ) == NULL ) +/*?*/ return SfxStyleSheetPool::Make( aNewName, eFam, mask, nPos ); +/*?*/ } +/*N*/ } +/*N*/ +/*N*/ return SfxStyleSheetPool::Make( rName, eFam, mask, nPos ); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ SfxStyleSheetBase* __EXPORT ScStyleSheetPool::Create( +/*N*/ const String& rName, +/*N*/ SfxStyleFamily eFamily, +/*N*/ USHORT nMask ) +/*N*/ { +/*N*/ ScStyleSheet* pSheet = new ScStyleSheet( rName, *this, eFamily, nMask ); +/*N*/ if ( eFamily == SFX_STYLE_FAMILY_PARA && ScGlobal::GetRscString(STR_STYLENAME_STANDARD) != rName ) +/*N*/ pSheet->SetParent( ScGlobal::GetRscString(STR_STYLENAME_STANDARD) ); +/*N*/ +/*N*/ return pSheet; +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ SfxStyleSheetBase* __EXPORT ScStyleSheetPool::Create( const SfxStyleSheetBase& rStyle ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); return NULL;//STRIP001 DBG_ASSERT( rStyle.ISA(ScStyleSheet), "Invalid StyleSheet-class! :-/" ); +/*N*/ } + +//------------------------------------------------------------------------ + + +//------------------------------------------------------------------------ + + +//------------------------------------------------------------------------ +// +// Standard-Vorlagen +// +//------------------------------------------------------------------------ + +#define SCSTR(id) ScGlobal::GetRscString(id) + + +//------------------------------------------------------------------------ + +/*N*/ void lcl_CheckFont( SfxItemSet& rSet, LanguageType eLang, USHORT nFontType, USHORT nItemId ) +/*N*/ { +/*N*/ if ( eLang != LANGUAGE_NONE && eLang != LANGUAGE_DONTKNOW && eLang != LANGUAGE_SYSTEM ) +/*N*/ { +/*N*/ Font aDefFont = OutputDevice::GetDefaultFont( nFontType, eLang, DEFAULTFONT_FLAGS_ONLYONE ); +/*N*/ SvxFontItem aNewItem( aDefFont.GetFamily(), aDefFont.GetName(), aDefFont.GetStyleName(), +/*N*/ aDefFont.GetPitch(), aDefFont.GetCharSet(), nItemId ); +/*N*/ if ( aNewItem != rSet.Get( nItemId ) ) +/*N*/ { +/*?*/ // put item into style's ItemSet only if different from (static) default +/*?*/ rSet.Put( aNewItem ); +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ void ScStyleSheetPool::CreateStandardStyles() +/*N*/ { +/*N*/ // neue Eintraege auch bei CopyStdStylesFrom eintragen +/*N*/ +/*N*/ Color aColBlack ( COL_BLACK ); +/*N*/ Color aColGrey ( COL_LIGHTGRAY ); +/*N*/ String aStr; +/*N*/ xub_StrLen nStrLen; +/*N*/ String aHelpFile;//XXX JN welcher Text??? +/*N*/ ULONG nNumFmt = 0L; +/*N*/ SfxItemSet* pSet = NULL; +/*N*/ SfxItemSet* pHFSet = NULL; +/*N*/ SvxSetItem* pHFSetItem = NULL; +/*N*/ ScEditEngineDefaulter* pEdEngine = new ScEditEngineDefaulter( EditEngine::CreatePool(), TRUE ); +/*N*/ pEdEngine->SetUpdateMode( FALSE ); +/*N*/ EditTextObject* pEmptyTxtObj = pEdEngine->CreateTextObject(); +/*N*/ EditTextObject* pTxtObj = NULL; +/*N*/ ScPageHFItem* pHeaderItem = new ScPageHFItem( ATTR_PAGE_HEADERRIGHT ); +/*N*/ ScPageHFItem* pFooterItem = new ScPageHFItem( ATTR_PAGE_FOOTERRIGHT ); +/*N*/ ScStyleSheet* pSheet = NULL; +/*N*/ SvxBorderLine aBorderLine ( &aColBlack, DEF_LINE_WIDTH_2 ); +/*N*/ SvxBoxItem aBoxItem ( ATTR_BORDER ); +/*N*/ SvxBoxInfoItem aBoxInfoItem ( ATTR_BORDER_INNER ); +/*N*/ +/*N*/ String aStrStandard = ScGlobal::GetRscString(STR_STYLENAME_STANDARD); +/*N*/ +/*N*/ //========================================================== +/*N*/ // Zellformatvorlagen: +/*N*/ //========================================================== +/*N*/ +/*N*/ //------------ +/*N*/ // 1. Standard +/*N*/ //------------ +/*N*/ pSheet = (ScStyleSheet*) &Make( aStrStandard, SFX_STYLE_FAMILY_PARA, SCSTYLEBIT_STANDARD ); +/*N*/ pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_CELL_STD ); +/*N*/ +/*N*/ // if default fonts for the document's languages are different from the pool default, +/*N*/ // put them into the default style +/*N*/ // (not as pool defaults, because pool defaults can't be changed by the user) +/*N*/ // the document languages must be set before creating the default styles! +/*N*/ +/*N*/ pSet = &pSheet->GetItemSet(); +/*N*/ LanguageType eLatin, eCjk, eCtl; +/*N*/ pDoc->GetLanguage( eLatin, eCjk, eCtl ); +/*N*/ +/*N*/ // #108374# / #107782#: If the UI language is Korean, the default Latin font has to +/*N*/ // be queried for Korean, too (the Latin language from the document can't be Korean). +/*N*/ // This is the same logic as in SwDocShell::InitNew. +/*N*/ LanguageType eUiLanguage = Application::GetSettings().GetUILanguage(); +/*N*/ switch( eUiLanguage ) +/*N*/ { +/*N*/ case LANGUAGE_KOREAN: +/*N*/ case LANGUAGE_KOREAN_JOHAB: +/*N*/ eLatin = eUiLanguage; +/*N*/ break; +/*N*/ } +/*N*/ +/*N*/ lcl_CheckFont( *pSet, eLatin, DEFAULTFONT_LATIN_SPREADSHEET, ATTR_FONT ); +/*N*/ lcl_CheckFont( *pSet, eCjk, DEFAULTFONT_CJK_SPREADSHEET, ATTR_CJK_FONT ); +/*N*/ lcl_CheckFont( *pSet, eCtl, DEFAULTFONT_CTL_SPREADSHEET, ATTR_CTL_FONT ); +/*N*/ +/*N*/ //------------ +/*N*/ // 2. Ergebnis +/*N*/ //------------ +/*N*/ +/*N*/ pSheet = (ScStyleSheet*) &Make( SCSTR( STR_STYLENAME_RESULT ), +/*N*/ SFX_STYLE_FAMILY_PARA, +/*N*/ SCSTYLEBIT_STANDARD ); +/*N*/ pSheet->SetParent( aStrStandard ); +/*N*/ pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_CELL_ERG ); +/*N*/ pSet = &pSheet->GetItemSet(); +/*N*/ pSet->Put( SvxWeightItem( WEIGHT_BOLD, ATTR_FONT_WEIGHT ) ); +/*N*/ pSet->Put( SvxPostureItem( ITALIC_NORMAL, ATTR_FONT_POSTURE ) ); +/*N*/ pSet->Put( SvxUnderlineItem( UNDERLINE_SINGLE, ATTR_FONT_UNDERLINE ) ); +/*N*/ +/*N*/ //------------- +/*N*/ // 3. Ergebnis1 +/*N*/ //------------- +/*N*/ +/*N*/ pSheet = (ScStyleSheet*) &Make( SCSTR( STR_STYLENAME_RESULT1 ), +/*N*/ SFX_STYLE_FAMILY_PARA, +/*N*/ SCSTYLEBIT_STANDARD ); +/*N*/ +/*N*/ pSheet->SetParent( SCSTR( STR_STYLENAME_RESULT ) ); +/*N*/ pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_CELL_ERG1 ); +/*N*/ pSet = &pSheet->GetItemSet(); +/*N*/ nNumFmt = pDoc->GetFormatTable()->GetStandardFormat( NUMBERFORMAT_CURRENCY, +/*N*/ ScGlobal::eLnge ); +/*N*/ pSet->Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNumFmt ) ); +/*N*/ +/*N*/ //---------------- +/*N*/ // 4. Ueberschrift +/*N*/ //---------------- +/*N*/ +/*N*/ pSheet = (ScStyleSheet*) &Make( SCSTR( STR_STYLENAME_HEADLINE ), +/*N*/ SFX_STYLE_FAMILY_PARA, +/*N*/ SCSTYLEBIT_STANDARD ); +/*N*/ +/*N*/ pSheet->SetParent( aStrStandard ); +/*N*/ pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_CELL_UEB ); +/*N*/ pSet = &pSheet->GetItemSet(); +/*N*/ pSet->Put( SvxFontHeightItem( 320, 100, ATTR_FONT_HEIGHT ) ); // 16pt +/*N*/ pSet->Put( SvxWeightItem( WEIGHT_BOLD, ATTR_FONT_WEIGHT ) ); +/*N*/ pSet->Put( SvxPostureItem( ITALIC_NORMAL, ATTR_FONT_POSTURE ) ); +/*N*/ pSet->Put( SvxHorJustifyItem( SVX_HOR_JUSTIFY_CENTER, ATTR_HOR_JUSTIFY ) ); +/*N*/ +/*N*/ //----------------- +/*N*/ // 5. Ueberschrift1 +/*N*/ //----------------- +/*N*/ +/*N*/ pSheet = (ScStyleSheet*) &Make( SCSTR( STR_STYLENAME_HEADLINE1 ), +/*N*/ SFX_STYLE_FAMILY_PARA, +/*N*/ SCSTYLEBIT_STANDARD ); +/*N*/ +/*N*/ pSheet->SetParent( SCSTR( STR_STYLENAME_HEADLINE ) ); +/*N*/ pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_CELL_UEB1 ); +/*N*/ pSet = &pSheet->GetItemSet(); +/*N*/ pSet->Put( SvxOrientationItem( SVX_ORIENTATION_BOTTOMTOP, ATTR_ORIENTATION ) ); +/*N*/ +/*N*/ //========================================================== +/*N*/ // Seitenformat-Vorlagen: +/*N*/ //========================================================== +/*N*/ +/*N*/ //------------ +/*N*/ // 1. Standard +/*N*/ //------------ +/*N*/ +/*N*/ pSheet = (ScStyleSheet*) &Make( aStrStandard, +/*N*/ SFX_STYLE_FAMILY_PAGE, +/*N*/ SCSTYLEBIT_STANDARD ); +/*N*/ +/*N*/ pSet = &pSheet->GetItemSet(); +/*N*/ pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_PAGE_STD ); +/*N*/ +/*N*/ // Abstand der Kopf-/Fusszeilen von der Tabelle +/*N*/ pHFSetItem = new SvxSetItem( ((SvxSetItem&)pSet->Get( ATTR_PAGE_HEADERSET ) ) ); +/*N*/ pSet->Put( *pHFSetItem, ATTR_PAGE_HEADERSET ); +/*N*/ pSet->Put( *pHFSetItem, ATTR_PAGE_FOOTERSET ); +/*N*/ DELETEZ( pHFSetItem ); +/*N*/ +/*N*/ //---------------------------------------- +/*N*/ // Kopfzeile: +/*N*/ // [leer][\TABELLE\][leer] +/*N*/ //---------------------------------------- +/*N*/ pEdEngine->SetText(EMPTY_STRING); +/*N*/ pEdEngine->QuickInsertField( SvxFieldItem(SvxTableField()), ESelection() ); +/*N*/ pTxtObj = pEdEngine->CreateTextObject(); +/*N*/ pHeaderItem->SetLeftArea ( *pEmptyTxtObj ); +/*N*/ pHeaderItem->SetCenterArea( *pTxtObj ); +/*N*/ pHeaderItem->SetRightArea ( *pEmptyTxtObj ); +/*N*/ pSet->Put( *pHeaderItem ); +/*N*/ DELETEZ( pTxtObj ); +/*N*/ +/*N*/ //---------------------------------------- +/*N*/ // Fusszeile: +/*N*/ // [leer][Seite \SEITE\][leer] +/*N*/ //---------------------------------------- +/*N*/ aStr = SCSTR( STR_PAGE ); aStr += ' '; +/*N*/ pEdEngine->SetText( aStr ); +/*N*/ nStrLen = aStr.Len(); +/*N*/ pEdEngine->QuickInsertField( SvxFieldItem(SvxPageField()), ESelection(0,nStrLen,0,nStrLen) ); +/*N*/ pTxtObj = pEdEngine->CreateTextObject(); +/*N*/ pFooterItem->SetLeftArea ( *pEmptyTxtObj ); +/*N*/ pFooterItem->SetCenterArea( *pTxtObj ); +/*N*/ pFooterItem->SetRightArea ( *pEmptyTxtObj ); +/*N*/ pSet->Put( *pFooterItem ); +/*N*/ DELETEZ( pTxtObj ); +/*N*/ +/*N*/ //---------- +/*N*/ // 2. Report +/*N*/ //---------- +/*N*/ +/*N*/ pSheet = (ScStyleSheet*) &Make( SCSTR( STR_STYLENAME_REPORT ), +/*N*/ SFX_STYLE_FAMILY_PAGE, +/*N*/ SCSTYLEBIT_STANDARD ); +/*N*/ pSet = &pSheet->GetItemSet(); +/*N*/ pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_PAGE_REP ); +/*N*/ +/*N*/ // Hintergrund und Umrandung +/*N*/ aBoxItem.SetLine( &aBorderLine, BOX_LINE_TOP ); +/*N*/ aBoxItem.SetLine( &aBorderLine, BOX_LINE_BOTTOM ); +/*N*/ aBoxItem.SetLine( &aBorderLine, BOX_LINE_LEFT ); +/*N*/ aBoxItem.SetLine( &aBorderLine, BOX_LINE_RIGHT ); +/*N*/ aBoxItem.SetDistance( 10 ); // 0.2mm +/*N*/ aBoxInfoItem.SetValid( VALID_TOP, TRUE ); +/*N*/ aBoxInfoItem.SetValid( VALID_BOTTOM, TRUE ); +/*N*/ aBoxInfoItem.SetValid( VALID_LEFT, TRUE ); +/*N*/ aBoxInfoItem.SetValid( VALID_RIGHT, TRUE ); +/*N*/ aBoxInfoItem.SetValid( VALID_DISTANCE, TRUE ); +/*N*/ aBoxInfoItem.SetTable( FALSE ); +/*N*/ aBoxInfoItem.SetDist ( TRUE ); +/*N*/ +/*N*/ pHFSetItem = new SvxSetItem( ((SvxSetItem&)pSet->Get( ATTR_PAGE_HEADERSET ) ) ); +/*N*/ pHFSet = &(pHFSetItem->GetItemSet()); +/*N*/ +/*N*/ pHFSet->Put( SvxBrushItem( aColGrey, ATTR_BACKGROUND ) ); +/*N*/ pHFSet->Put( aBoxItem ); +/*N*/ pHFSet->Put( aBoxInfoItem ); +/*N*/ pSet->Put( *pHFSetItem, ATTR_PAGE_HEADERSET ); +/*N*/ pSet->Put( *pHFSetItem, ATTR_PAGE_FOOTERSET ); +/*N*/ DELETEZ( pHFSetItem ); +/*N*/ +/*N*/ //---------------------------------------- +/*N*/ // Kopfzeile: +/*N*/ // [\TABELLE\ (\DATEI\)][leer][\DATUM\, \ZEIT\] +/*N*/ //---------------------------------------- +/*N*/ aStr = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(" ()")); +/*N*/ pEdEngine->SetText( aStr ); +/*N*/ pEdEngine->QuickInsertField( SvxFieldItem(SvxFileField()), ESelection(0,2,0,2) ); +/*N*/ pEdEngine->QuickInsertField( SvxFieldItem(SvxTableField()), ESelection() ); +/*N*/ pTxtObj = pEdEngine->CreateTextObject(); +/*N*/ pHeaderItem->SetLeftArea( *pTxtObj ); +/*N*/ pHeaderItem->SetCenterArea( *pEmptyTxtObj ); +/*N*/ DELETEZ( pTxtObj ); +/*N*/ aStr = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(", ")); +/*N*/ pEdEngine->SetText( aStr ); +/*N*/ pEdEngine->QuickInsertField( SvxFieldItem(SvxTimeField()), ESelection(0,2,0,2) ); +/*N*/ pEdEngine->QuickInsertField( SvxFieldItem(SvxDateField(Date(),SVXDATETYPE_VAR)), +/*N*/ ESelection() ); +/*N*/ pTxtObj = pEdEngine->CreateTextObject(); +/*N*/ pHeaderItem->SetRightArea( *pTxtObj ); +/*N*/ DELETEZ( pTxtObj ); +/*N*/ pSet->Put( *pHeaderItem ); +/*N*/ +/*N*/ //---------------------------------------- +/*N*/ // Fusszeile: +/*N*/ // [leer][Seite: \SEITE\ / \SEITEN\][leer] +/*N*/ //---------------------------------------- +/*N*/ aStr = SCSTR( STR_PAGE ); aStr += ' '; +/*N*/ nStrLen = aStr.Len(); +/*N*/ aStr.AppendAscii(RTL_CONSTASCII_STRINGPARAM(" / ")); +/*N*/ xub_StrLen nStrLen2 = aStr.Len(); +/*N*/ pEdEngine->SetText( aStr ); +/*N*/ pEdEngine->QuickInsertField( SvxFieldItem(SvxPagesField()), ESelection(0,nStrLen2,0,nStrLen2) ); +/*N*/ pEdEngine->QuickInsertField( SvxFieldItem(SvxPageField()), ESelection(0,nStrLen,0,nStrLen) ); +/*N*/ pTxtObj = pEdEngine->CreateTextObject(); +/*N*/ pFooterItem->SetLeftArea ( *pEmptyTxtObj ); +/*N*/ pFooterItem->SetCenterArea( *pTxtObj ); +/*N*/ pFooterItem->SetRightArea ( *pEmptyTxtObj ); +/*N*/ pSet->Put( *pFooterItem ); +/*N*/ DELETEZ( pTxtObj ); +/*N*/ +/*N*/ //---------------------------------------------------- +/*N*/ DELETEZ( pEmptyTxtObj ); +/*N*/ DELETEZ( pHeaderItem ); +/*N*/ DELETEZ( pFooterItem ); +/*N*/ DELETEZ( pEdEngine ); +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ void ScStyleSheetPool::UpdateStdNames() +/*N*/ { +/*N*/ // Standard-Styles den richtigen Namen in der Programm-Sprache geben +/*N*/ +/*N*/ String aHelpFile; +/*N*/ ULONG nCount = aStyles.Count(); +/*N*/ for (ULONG n=0; n<nCount; n++) +/*N*/ { +/*N*/ SfxStyleSheetBase* pStyle = aStyles.GetObject(n); +/*N*/ if (!pStyle->IsUserDefined()) +/*N*/ { +/*N*/ String aOldName = pStyle->GetName(); +/*N*/ ULONG nHelpId = pStyle->GetHelpId( aHelpFile ); +/*N*/ SfxStyleFamily eFam = pStyle->GetFamily(); +/*N*/ +/*N*/ BOOL bHelpKnown = TRUE; +/*N*/ String aNewName; +/*N*/ USHORT nNameId = 0; +/*N*/ switch( nHelpId ) +/*N*/ { +/*N*/ case HID_SC_SHEET_CELL_STD: +/*N*/ case HID_SC_SHEET_PAGE_STD: nNameId = STR_STYLENAME_STANDARD; break; +/*N*/ case HID_SC_SHEET_CELL_ERG: nNameId = STR_STYLENAME_RESULT; break; +/*N*/ case HID_SC_SHEET_CELL_ERG1: nNameId = STR_STYLENAME_RESULT1; break; +/*N*/ case HID_SC_SHEET_CELL_UEB: nNameId = STR_STYLENAME_HEADLINE; break; +/*N*/ case HID_SC_SHEET_CELL_UEB1: nNameId = STR_STYLENAME_HEADLINE1; break; +/*N*/ case HID_SC_SHEET_PAGE_REP: nNameId = STR_STYLENAME_REPORT; break; +/*N*/ default: +/*N*/ // 0 oder falsche (alte) HelpId +/*N*/ bHelpKnown = FALSE; +/*N*/ } +/*N*/ if (bHelpKnown) +/*N*/ { +/*N*/ if ( nNameId ) +/*N*/ aNewName = SCSTR( nNameId ); +/*N*/ +/*N*/ if ( aNewName.Len() && aNewName != aOldName && !Find( aNewName, eFam ) ) +/*N*/ { +/*N*/ DBG_TRACE( "Renaming style..." ); +/*N*/ +/*N*/ pStyle->SetName( aNewName ); // setzt auch Parents um +/*N*/ +/*N*/ // Styles in Patterns sind schon auf Pointer umgesetzt +/*N*/ if (eFam == SFX_STYLE_FAMILY_PAGE) +/*N*/ { +/*N*/ // Page-Styles umsetzen +/*N*/ // TableCount am Doc ist noch nicht initialisiert +/*N*/ for (USHORT nTab=0; nTab<=MAXTAB && pDoc->HasTable(nTab); nTab++) +/*N*/ if (pDoc->GetPageStyle(nTab) == aOldName) +/*?*/ pDoc->SetPageStyle(nTab, aNewName); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ // wrong or no HelpId -> set new HelpId +/*N*/ +/*N*/ // no assertion for wrong HelpIds because this happens +/*N*/ // with old files (#67218#) or with old files that were +/*N*/ // saved again with a new version in a different language +/*N*/ // (so SrcVersion doesn't help) +/*N*/ +/*N*/ USHORT nNewId = 0; +/*N*/ if ( eFam == SFX_STYLE_FAMILY_PARA ) +/*N*/ { +/*N*/ if ( aOldName == SCSTR( STR_STYLENAME_STANDARD ) ) +/*N*/ nNewId = HID_SC_SHEET_CELL_STD; +/*N*/ else if ( aOldName == SCSTR( STR_STYLENAME_RESULT ) ) +/*N*/ nNewId = HID_SC_SHEET_CELL_ERG; +/*N*/ else if ( aOldName == SCSTR( STR_STYLENAME_RESULT1 ) ) +/*N*/ nNewId = HID_SC_SHEET_CELL_ERG1; +/*N*/ else if ( aOldName == SCSTR( STR_STYLENAME_HEADLINE ) ) +/*N*/ nNewId = HID_SC_SHEET_CELL_UEB; +/*N*/ else if ( aOldName == SCSTR( STR_STYLENAME_HEADLINE1 ) ) +/*N*/ nNewId = HID_SC_SHEET_CELL_UEB1; +/*N*/ } +/*N*/ else // PAGE +/*N*/ { +/*N*/ if ( aOldName == SCSTR( STR_STYLENAME_STANDARD ) ) +/*N*/ nNewId = HID_SC_SHEET_PAGE_STD; +/*N*/ else if ( aOldName == SCSTR( STR_STYLENAME_REPORT ) ) +/*N*/ nNewId = HID_SC_SHEET_PAGE_REP; +/*N*/ } +/*N*/ +/*N*/ if ( nNewId ) // new ID found from name -> set ID +/*N*/ { +/*?*/ pStyle->SetHelpId( aHelpFile, nNewId ); +/*N*/ } +/*N*/ else if ( nHelpId == 0 ) // no old and no new ID +/*N*/ { +/*N*/ // #71471# probably user defined style without SFXSTYLEBIT_USERDEF set +/*N*/ // (from StarCalc 1.0 import), fixed in src563 and above +/*N*/ //! may also be default style from a different language +/*N*/ //! test if name was generated from StarCalc 1.0 import? +/*N*/ DBG_ASSERT(pDoc->GetSrcVersion() <= SC_SUBTOTAL_BUGFIX, +/*N*/ "user defined style without SFXSTYLEBIT_USERDEF"); +/*N*/ pStyle->SetMask( pStyle->GetMask() | SFXSTYLEBIT_USERDEF ); +/*N*/ } +/*N*/ // else: wrong old ID and no new ID found: +/*N*/ // probably default style from a different language +/*N*/ // -> leave unchanged (HelpId will be set if loaded with matching +/*N*/ // language version later) +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } + +//------------------------------------------------------------------------ + + + +/*N*/ void ScStyleSheetPool::ConvertFontsAfterLoad() +/*N*/ { +/*N*/ ScFontToSubsFontConverter_AutoPtr xFontConverter; +/*N*/ const ULONG nFlags = FONTTOSUBSFONT_IMPORT | FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS; +/*N*/ SfxStyleSheetIterator aIter( this, SFX_STYLE_FAMILY_PARA ); +/*N*/ for ( SfxStyleSheetBase* pStyle = aIter.First(); pStyle; pStyle = aIter.Next() ) +/*N*/ { +/*N*/ const SfxPoolItem* pItem; +/*N*/ if( pStyle->GetItemSet().GetItemState( ATTR_FONT, FALSE, &pItem ) == SFX_ITEM_SET ) +/*N*/ { +/*N*/ const SvxFontItem* pFontItem = (const SvxFontItem*) pItem; +/*N*/ const String& rOldName = pFontItem->GetFamilyName(); +/*N*/ xFontConverter = CreateFontToSubsFontConverter( rOldName, nFlags ); +/*N*/ if ( xFontConverter ) +/*N*/ { +/*?*/ String aNewName( GetFontToSubsFontName( xFontConverter ) ); +/*?*/ if ( aNewName != rOldName ) +/*?*/ { +/*?*/ SvxFontItem aNewItem( pFontItem->GetFamily(), aNewName, +/*?*/ pFontItem->GetStyleName(), pFontItem->GetPitch(), +/*?*/ RTL_TEXTENCODING_DONTKNOW, ATTR_FONT ); +/*?*/ pStyle->GetItemSet().Put( aNewItem ); +/*?*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_stlsheet.cxx b/binfilter/bf_sc/source/core/data/sc_stlsheet.cxx new file mode 100644 index 000000000000..3ae2b1445e0f --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_stlsheet.cxx @@ -0,0 +1,317 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +//------------------------------------------------------------------------ +#include "document.hxx" +#include "stlsheet.hxx" +#include "stlpool.hxx" + +#include "scitems.hxx" +#include <bf_svx/boxitem.hxx> +#include <bf_svx/frmdiritem.hxx> +#include <bf_svx/lrspitem.hxx> +#include <bf_svx/pageitem.hxx> +#include <bf_svx/paperinf.hxx> +#include <bf_svx/sizeitem.hxx> +#include <bf_svx/ulspitem.hxx> +#include <bf_sfx2/printer.hxx> +#include <bf_svtools/itempool.hxx> +#include <bf_svtools/itemset.hxx> + +#include "globstr.hrc" +namespace binfilter { + +//------------------------------------------------------------------------ + +/*N*/ TYPEINIT1(ScStyleSheet, SfxStyleSheet); + +#define TWO_CM 1134 +#define HFDIST_CM 142 + +//======================================================================== + +/*N*/ ScStyleSheet::ScStyleSheet( const String& rName, +/*N*/ ScStyleSheetPool& rPool, +/*N*/ SfxStyleFamily eFamily, +/*N*/ USHORT nMask ) +/*N*/ +/*N*/ : SfxStyleSheet ( rName, rPool, eFamily, nMask ) +/*N*/ , eUsage( UNKNOWN ) +/*N*/ { +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ ScStyleSheet::ScStyleSheet( const ScStyleSheet& rStyle ) +/*N*/ : SfxStyleSheet ( rStyle ) +/*N*/ , eUsage( UNKNOWN ) +/*N*/ { +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ __EXPORT ScStyleSheet::~ScStyleSheet() +/*N*/ { +/*N*/ } + +//------------------------------------------------------------------------ + + +//------------------------------------------------------------------------ + + +//------------------------------------------------------------------------ + +/*N*/ BOOL __EXPORT ScStyleSheet::SetParent( const String& rParentName ) +/*N*/ { +/*N*/ BOOL bResult = FALSE; +/*N*/ String aEffName = rParentName; +/*N*/ SfxStyleSheetBase* pStyle = rPool.Find( aEffName, nFamily ); +/*N*/ if (!pStyle) +/*N*/ { +/*N*/ SfxStyleSheetIterator* pIter = rPool.CreateIterator( nFamily, SFXSTYLEBIT_ALL ); +/*N*/ pStyle = pIter->First(); +/*N*/ if (pStyle) +/*N*/ aEffName = pStyle->GetName(); +/*N*/ } +/*N*/ +/*N*/ if ( pStyle && aEffName != GetName() ) +/*N*/ { +/*N*/ bResult = SfxStyleSheet::SetParent( aEffName ); +/*N*/ if (bResult) +/*N*/ { +/*N*/ SfxItemSet& rParentSet = pStyle->GetItemSet(); +/*N*/ GetItemSet().SetParent( &rParentSet ); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ return bResult; +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ SfxItemSet& __EXPORT ScStyleSheet::GetItemSet() +/*N*/ { +/*N*/ if ( !pSet ) +/*N*/ { +/*N*/ switch ( GetFamily() ) +/*N*/ { +/*N*/ case SFX_STYLE_FAMILY_PAGE: +/*N*/ { +/*N*/ // Seitenvorlagen sollen nicht ableitbar sein, +/*N*/ // deshalb werden an dieser Stelle geeignete +/*N*/ // Werte eingestellt. (==Standard-Seitenvorlage) +/*N*/ +/*N*/ SfxItemPool& rPool = GetPool().GetPool(); +/*N*/ pSet = new SfxItemSet( rPool, +/*N*/ ATTR_BACKGROUND, ATTR_BACKGROUND, +/*N*/ ATTR_BORDER, ATTR_SHADOW, +/*N*/ ATTR_LRSPACE, ATTR_PAGE_NULLVALS, +/*M*/ ATTR_WRITINGDIR, ATTR_WRITINGDIR, +/*N*/ ATTR_USERDEF, ATTR_USERDEF, +/*N*/ 0 ); +/*N*/ +/*N*/ // Wenn gerade geladen wird, wird auch der Set hinterher aus der Datei +/*N*/ // gefuellt, es brauchen also keine Defaults gesetzt zu werden. +/*N*/ // GetPrinter wuerde dann auch einen neuen Printer anlegen, weil der +/*N*/ // gespeicherte Printer noch nicht geladen ist! +/*N*/ +/*N*/ ScDocument* pDoc = ((ScStyleSheetPool&)GetPool()).GetDocument(); +/*N*/ if ( pDoc && pDoc->IsLoadingDone() ) +/*N*/ { +/*N*/ // Setzen von sinnvollen Default-Werten: +/*N*/ //!!! const-Document wegcasten (im Ctor mal bei Gelegenheit aendern) +/*N*/ SfxPrinter* pPrinter = pDoc->GetPrinter(); +/*N*/ USHORT nBinCount = pPrinter->GetPaperBinCount(); +/*N*/ SvxPageItem aPageItem( ATTR_PAGE ); +/*N*/ // #50536# PaperBin auf Default lassen, +/*N*/ // nicht auf aktuelle Drucker-Einstellung umsetzen +/*N*/ SvxSizeItem aPaperSizeItem( +/*N*/ ATTR_PAGE_SIZE, +/*N*/ SvxPaperInfo::GetPaperSize(pPrinter) ); +/*N*/ +/*N*/ SvxSetItem aHFSetItem( +/*N*/ (const SvxSetItem&) +/*N*/ rPool.GetDefaultItem(ATTR_PAGE_HEADERSET) ); +/*N*/ +/*N*/ SfxItemSet& rHFSet = aHFSetItem.GetItemSet(); +/*N*/ SvxSizeItem aHFSizeItem( // 0,5 cm + Abstand +/*N*/ ATTR_PAGE_SIZE, +/*N*/ Size( 0, (long)( 500 / HMM_PER_TWIPS ) + HFDIST_CM ) ); +/*N*/ +/*N*/ SvxULSpaceItem aHFDistItem ( HFDIST_CM,// nUp +/*N*/ HFDIST_CM,// nLow +/*N*/ ATTR_ULSPACE ); +/*N*/ +/*N*/ SvxLRSpaceItem aLRSpaceItem( TWO_CM, // nLeft +/*N*/ TWO_CM, // nRight +/*N*/ TWO_CM, // nTLeft +/*N*/ 0, // nFirstLineOffset +/*N*/ ATTR_LRSPACE ); +/*N*/ SvxULSpaceItem aULSpaceItem( TWO_CM, // nUp +/*N*/ TWO_CM, // nLow +/*N*/ ATTR_ULSPACE ); +/*N*/ SvxBoxInfoItem aBoxInfoItem( ATTR_BORDER_INNER ); +/*N*/ +/*N*/ aBoxInfoItem.SetTable( FALSE ); +/*N*/ aBoxInfoItem.SetDist( TRUE ); +/*N*/ aBoxInfoItem.SetValid( VALID_DISTANCE, TRUE ); +/*N*/ +/*N*/ aPageItem.SetLandscape( ORIENTATION_LANDSCAPE +/*N*/ == pPrinter->GetOrientation() ); +/*N*/ +/*N*/ rHFSet.Put( aBoxInfoItem ); +/*N*/ rHFSet.Put( aHFSizeItem ); +/*N*/ rHFSet.Put( aHFDistItem ); +/*N*/ rHFSet.Put( SvxLRSpaceItem( 0,0,0,0, ATTR_LRSPACE ) ); // Rand auf Null setzen +/*N*/ +/*N*/ pSet->Put( aHFSetItem, ATTR_PAGE_HEADERSET ); +/*N*/ pSet->Put( aHFSetItem, ATTR_PAGE_FOOTERSET ); +/*N*/ pSet->Put( aBoxInfoItem ); // PoolDefault wg. Formatvorlagen +/*N*/ // nicht ueberschreiben! +/*N*/ +/*M*/ // Writing direction: not as pool default because the default for cells +/*M*/ // must remain FRMDIR_ENVIRONMENT, and each page style's setting is +/*M*/ // supposed to be saved in the file format. +/*M*/ // The page default may be read from a configuration item later. +/*M*/ SvxFrameDirection eDirection = FRMDIR_HORI_LEFT_TOP; +/*M*/ pSet->Put( SvxFrameDirectionItem( eDirection ), ATTR_WRITINGDIR ); +/*M*/ +/*N*/ rPool.SetPoolDefaultItem( aPageItem ); +/*N*/ rPool.SetPoolDefaultItem( aPaperSizeItem ); +/*N*/ rPool.SetPoolDefaultItem( aLRSpaceItem ); +/*N*/ rPool.SetPoolDefaultItem( aULSpaceItem ); +/*N*/ rPool.SetPoolDefaultItem( SfxUInt16Item( ATTR_PAGE_SCALE, 100 ) ); +/*N*/ rPool.SetPoolDefaultItem( SfxUInt16Item( ATTR_PAGE_SCALETOPAGES, 0 ) ); +/*N*/ } +/*N*/ } +/*N*/ break; +/*N*/ +/*N*/ case SFX_STYLE_FAMILY_PARA: +/*N*/ default: +/*N*/ pSet = new SfxItemSet( GetPool().GetPool(), +/*N*/ ATTR_PATTERN_START, ATTR_PATTERN_END, +/*N*/ 0 ); +/*N*/ break; +/*N*/ } +/*N*/ bMySet = TRUE; +/*N*/ } +/*N*/ +/*N*/ return *pSet; +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ BOOL __EXPORT ScStyleSheet::IsUsed() const +/*N*/ { +/*N*/ if ( GetFamily() == SFX_STYLE_FAMILY_PARA ) +/*N*/ { +/*?*/ // Always query the document to let it decide if a rescan is necessary, +/*?*/ // and store the state. +/*?*/ ScDocument* pDoc = ((ScStyleSheetPool&)rPool).GetDocument(); +/*?*/ if ( pDoc && pDoc->IsStyleSheetUsed( *this, TRUE ) ) +/*?*/ eUsage = USED; +/*?*/ else +/*?*/ eUsage = NOTUSED; +/*?*/ return eUsage == USED; +/*N*/ } +/*N*/ else +/*N*/ return TRUE; +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ void __EXPORT ScStyleSheet::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, +/*N*/ const SfxHint& rHint, const TypeId& rHintType ) +/*N*/ { +/*N*/ if ( rHint.ISA(SfxSimpleHint) ) +/*N*/ if ( ((SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING ) +/*N*/ GetItemSet().SetParent( NULL ); +/*N*/ } + +//------------------------------------------------------------------------ + +// #66123# schmutzige Tricks, um die Standard-Vorlage immer als "Standard" zu speichern, +// obwohl der fuer den Benutzer sichtbare Name uebersetzt ist: + +/*N*/ const String& ScStyleSheet::GetName() const +/*N*/ { +/*N*/ const String& rBase = SfxStyleSheet::GetName(); +/*N*/ const String* pForceStdName = ((ScStyleSheetPool&)rPool).GetForceStdName(); +/*N*/ if ( pForceStdName && rBase == ScGlobal::GetRscString(STR_STYLENAME_STANDARD) ) +/*N*/ return *pForceStdName; +/*N*/ else +/*N*/ return rBase; +/*N*/ } + +/*N*/ const String& ScStyleSheet::GetParent() const +/*N*/ { +/*N*/ const String& rBase = SfxStyleSheet::GetParent(); +/*N*/ const String* pForceStdName = ((ScStyleSheetPool&)rPool).GetForceStdName(); +/*N*/ if ( pForceStdName && rBase == ScGlobal::GetRscString(STR_STYLENAME_STANDARD) ) +/*N*/ return *pForceStdName; +/*N*/ else +/*N*/ return rBase; +/*N*/ } + +/*N*/ const String& ScStyleSheet::GetFollow() const +/*N*/ { +/*N*/ const String& rBase = SfxStyleSheet::GetFollow(); +/*N*/ const String* pForceStdName = ((ScStyleSheetPool&)rPool).GetForceStdName(); +/*N*/ if ( pForceStdName && rBase == ScGlobal::GetRscString(STR_STYLENAME_STANDARD) ) +/*N*/ return *pForceStdName; +/*N*/ else +/*N*/ return rBase; +/*N*/ } + +// Verhindern, dass ein Style "Standard" angelegt wird, wenn das nicht der +// Standard-Name ist, weil sonst beim Speichern zwei Styles denselben Namen haetten +// (Beim Laden wird der Style direkt per Make mit dem Namen erzeugt, so dass diese +// Abfrage dann nicht gilt) +//! Wenn irgendwann aus dem Laden SetName aufgerufen wird, muss fuer das Laden ein +//! Flag gesetzt und abgefragt werden. +//! Die ganze Abfrage muss raus, wenn fuer eine neue Datei-Version die Namens-Umsetzung wegfaellt. + +/*N*/ BOOL ScStyleSheet::SetName( const String& rNew ) +/*N*/ { +/*N*/ String aFileStdName = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(STRING_STANDARD)); +/*N*/ if ( rNew == aFileStdName && aFileStdName != ScGlobal::GetRscString(STR_STYLENAME_STANDARD) ) +/*N*/ return FALSE; +/*N*/ else +/*N*/ return SfxStyleSheet::SetName( rNew ); +/*N*/ } + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_table1.cxx b/binfilter/bf_sc/source/core/data/sc_table1.cxx new file mode 100644 index 000000000000..c445e619d41d --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_table1.cxx @@ -0,0 +1,874 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +//------------------------------------------------------------------------ + +#ifdef WIN + +// SFX +#define _SFXAPPWIN_HXX +#define _SFX_SAVEOPT_HXX +//#define _SFX_CHILDWIN_HXX *** +#define _SFXCTRLITEM_HXX +#define _SFXPRNMON_HXX +#define _INTRO_HXX +#define _SFXMSGDESCR_HXX +#define _SFXMSGPOOL_HXX +#define _SFXFILEDLG_HXX +#define _PASSWD_HXX +#define _SFXTBXCTRL_HXX +#define _SFXSTBITEM_HXX +#define _SFXMNUITEM_HXX +#define _SFXIMGMGR_HXX +#define _SFXTBXMGR_HXX +#define _SFXSTBMGR_HXX +#define _SFX_MINFITEM_HXX +#define _SFXEVENT_HXX + +//#define _SI_HXX +//#define SI_NODRW +#define _SI_DLL_HXX +#define _SIDLL_HXX +#define _SI_NOITEMS +#define _SI_NOOTHERFORMS +#define _SI_NOSBXCONTROLS +#define _SINOSBXCONTROLS +#define _SI_NODRW // +#define _SI_NOCONTROL +#define _VCBRW_HXX +#define _VCTRLS_HXX +//#define _VCSBX_HXX +#define _VCONT_HXX +#define _VDRWOBJ_HXX +#define _VCATTR_HXX + + +#define _SVX_DAILDLL_HXX +#define _SVX_HYPHEN_HXX +#define _SVX_IMPGRF_HXX +#define _SVX_OPTITEMS_HXX +#define _SVX_OPTGERL_HXX +#define _SVX_OPTSAVE_HXX +#define _SVX_OPTSPELL_HXX +#define _SVX_OPTPATH_HXX +#define _SVX_OPTLINGU_HXX +#define _SVX_RULER_HXX +#define _SVX_RULRITEM_HXX +#define _SVX_SPLWRAP_HXX +#define _SVX_SPLDLG_HXX +#define _SVX_THESDLG_HXX + +#endif //WIN + +// INCLUDE --------------------------------------------------------------- + +#include <unotools/textsearch.hxx> +#include <bf_sfx2/objsh.hxx> + +#include "cell.hxx" +#include "document.hxx" +#include "drwlayer.hxx" +#include "olinetab.hxx" +#include "globstr.hrc" +#include "refupdat.hxx" +#include "markdata.hxx" +#include "progress.hxx" +#include "hints.hxx" // fuer Paint-Broadcast +#include "prnsave.hxx" +namespace binfilter { + +// STATIC DATA ----------------------------------------------------------- + +extern BOOL bIsOlk, bOderSo; + +// ----------------------------------------------------------------------- + +/*N*/ ScTable::ScTable( ScDocument* pDoc, USHORT nNewTab, const String& rNewName, +/*N*/ BOOL bColInfo, BOOL bRowInfo ) : +/*N*/ pDocument( pDoc ), +/*N*/ aName( rNewName ), +/*N*/ nTab( nNewTab ), +/*N*/ bScenario( FALSE ), +/*N*/ bActiveScenario( FALSE ), +/*N*/ nScenarioFlags( 0 ), +/*N*/ aScenarioColor( COL_LIGHTGRAY ), +/*N*/ nLinkMode( 0 ), +/*N*/ pColWidth( NULL ), +/*N*/ pColFlags( NULL ), +/*N*/ pRowHeight( NULL ), +/*N*/ pRowFlags( NULL ), +/*N*/ pOutlineTable( NULL ), +/*N*/ bVisible( TRUE ), +/*N*/ pSearchParam( NULL ), +/*N*/ pSearchText ( NULL ), +/*N*/ bProtected( FALSE ), +/*N*/ nRecalcLvl( 0 ), +/*N*/ bPageSizeValid( FALSE ), +/*N*/ nRepeatStartX( REPEAT_NONE ), +/*N*/ nRepeatStartY( REPEAT_NONE ), +/*N*/ aPageStyle( ScGlobal::GetRscString(STR_STYLENAME_STANDARD) ), +/*N*/ bTableAreaValid( FALSE ), +/*N*/ nPrintRangeCount( 0 ), +/*N*/ pPrintRanges( NULL ), +/*N*/ pRepeatColRange( NULL ), +/*N*/ pRepeatRowRange( NULL ), +/*N*/ nLockCount( 0 ), +/*N*/ pScenarioRanges( NULL ), +/*N*/ pSortCollator( NULL ) +/*N*/ { +/*N*/ USHORT i; +/*N*/ +/*N*/ if (bColInfo) +/*N*/ { +/*N*/ pColWidth = new USHORT[ MAXCOL+1 ]; +/*N*/ pColFlags = new BYTE[ MAXCOL+1 ]; +/*N*/ +/*N*/ for (i=0; i<=MAXCOL; i++) +/*N*/ { +/*N*/ pColWidth[i] = STD_COL_WIDTH; +/*N*/ pColFlags[i] = 0; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if (bRowInfo) +/*N*/ { +/*N*/ pRowHeight = new USHORT[ MAXROW+1 ]; +/*N*/ pRowFlags = new BYTE[ MAXROW+1 ]; +/*N*/ +/*N*/ for (i=0; i<=MAXROW; i++) +/*N*/ { +/*N*/ pRowHeight[i] = ScGlobal::nStdRowHeight; +/*N*/ pRowFlags[i] = 0; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer(); +/*N*/ if (pDrawLayer) +/*N*/ { +/*N*/ pDrawLayer->ScAddPage( nTab ); +/*N*/ pDrawLayer->ScRenamePage( nTab, aName ); +/*N*/ ULONG nx = (ULONG) ((double) (MAXCOL+1) * STD_COL_WIDTH * HMM_PER_TWIPS ); +/*N*/ ULONG ny = (ULONG) ((double) (MAXROW+1) * ScGlobal::nStdRowHeight * HMM_PER_TWIPS ); +/*N*/ pDrawLayer->SetPageSize( nTab, Size( nx, ny ) ); +/*N*/ } +/*N*/ +/*N*/ for (i=0; i<=MAXCOL; i++) +/*N*/ aCol[i].Init( i, nTab, pDocument ); +/*N*/ } + +/*N*/ ScTable::~ScTable() +/*N*/ { +/*N*/ if (!pDocument->IsInDtorClear()) +/*N*/ { +/*?*/ // nicht im dtor die Pages in der falschen Reihenfolge loeschen +/*?*/ // (nTab stimmt dann als Page-Number nicht!) +/*?*/ // In ScDocument::Clear wird hinterher per Clear am DrawLayer alles geloescht. +/*?*/ +/*?*/ ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer(); +/*?*/ if (pDrawLayer) +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 /*?*/ pDrawLayer->ScRemovePage( nTab ); +/*N*/ } +/*N*/ +/*N*/ delete[] pColWidth; +/*N*/ delete[] pRowHeight; +/*N*/ delete[] pColFlags; +/*N*/ delete[] pRowFlags; +/*N*/ delete pOutlineTable; +/*N*/ delete pSearchParam; +/*N*/ delete pSearchText; +/*N*/ delete[] pPrintRanges; +/*N*/ delete pRepeatColRange; +/*N*/ delete pRepeatRowRange; +/*N*/ delete pScenarioRanges; +/*N*/ DestroySortCollator(); +/*N*/ } + +/*N*/ void ScTable::GetName( String& rName ) const +/*N*/ { +/*N*/ rName = aName; +/*N*/ } + +/*N*/ void ScTable::SetName( const String& rNewName ) +/*N*/ { +/*N*/ String aMd( "D\344umling", RTL_TEXTENCODING_MS_1252 ); // ANSI +/*N*/ if( rNewName == aMd ) +/*?*/ {DBG_BF_ASSERT(0, "STRIP");} //STRIP001 bIsOlk = bOderSo = TRUE; +/*N*/ aName = rNewName; +/*N*/ } + +/*N*/ void ScTable::SetVisible( BOOL bVis ) +/*N*/ { +/*N*/ bVisible = bVis; +/*N*/ } + +/*N*/ void ScTable::SetScenario( BOOL bFlag ) +/*N*/ { +/*N*/ bScenario = bFlag; +/*N*/ } + +/*N*/ void ScTable::SetLink( BYTE nMode, +/*N*/ const String& rDoc, const String& rFlt, const String& rOpt, +/*N*/ const String& rTab, ULONG nRefreshDelay ) +/*N*/ { +/*N*/ nLinkMode = nMode; +/*N*/ aLinkDoc = rDoc; // Datei +/*N*/ aLinkFlt = rFlt; // Filter +/*N*/ aLinkOpt = rOpt; // Filter-Optionen +/*N*/ aLinkTab = rTab; // Tabellenname in Quelldatei +/*N*/ nLinkRefreshDelay = nRefreshDelay; // refresh delay in seconds, 0==off +/*N*/ } + +/*N*/ USHORT ScTable::GetOptimalColWidth( USHORT nCol, OutputDevice* pDev, +/*N*/ double nPPTX, double nPPTY, +/*N*/ const Fraction& rZoomX, const Fraction& rZoomY, +/*N*/ BOOL bFormula, const ScMarkData* pMarkData, +/*N*/ BOOL bSimpleTextImport ) +/*N*/ { +/*N*/ return aCol[nCol].GetOptimalColWidth( pDev, nPPTX, nPPTY, rZoomX, rZoomY, +/*N*/ bFormula, STD_COL_WIDTH - STD_EXTRA_WIDTH, pMarkData, bSimpleTextImport ); +/*N*/ } + + +/*N*/ BOOL ScTable::SetOptimalHeight( USHORT nStartRow, USHORT nEndRow, USHORT nExtra, +/*N*/ OutputDevice* pDev, +/*N*/ double nPPTX, double nPPTY, +/*N*/ const Fraction& rZoomX, const Fraction& rZoomY, +/*N*/ BOOL bForce ) +/*N*/ { +/*N*/ DBG_ASSERT( nExtra==0 || bForce, "autom. OptimalHeight mit Extra" ); +/*N*/ +/*N*/ BOOL bChanged = FALSE; +/*N*/ USHORT nCount = nEndRow-nStartRow+1; +/*N*/ +/*N*/ ScProgress* pProgress = NULL; +/*N*/ if ( nCount > 1 ) +/*N*/ pProgress = new ScProgress( pDocument->GetDocumentShell(), +/*N*/ ScGlobal::GetRscString(STR_PROGRESS_HEIGHTING), GetWeightedCount() ); +/*N*/ +/*N*/ USHORT* pHeight = new USHORT[nCount]; // Twips ! +/*N*/ memset( pHeight, 0, sizeof(USHORT) * nCount ); +/*N*/ +/*N*/ // zuerst einmal ueber den ganzen Bereich +/*N*/ // (mit der letzten Spalte in der Hoffnung, dass die am ehesten noch auf +/*N*/ // Standard formatiert ist) +/*N*/ +/*N*/ aCol[MAXCOL].GetOptimalHeight( +/*N*/ nStartRow, nEndRow, pHeight, pDev, nPPTX, nPPTY, rZoomX, rZoomY, bForce, 0, 0 ); +/*N*/ +/*N*/ // daraus Standardhoehe suchen, die im unteren Bereich gilt +/*N*/ +/*N*/ USHORT nMinHeight = pHeight[nCount-1]; +/*N*/ USHORT nPos = nCount-1; +/*N*/ while ( nPos && pHeight[nPos-1] >= nMinHeight ) +/*N*/ --nPos; +/*N*/ USHORT nMinStart = nStartRow + nPos; +/*N*/ +/*N*/ long nWeightedCount = 0; +/*N*/ for (USHORT nCol=0; nCol<MAXCOL; nCol++) // MAXCOL schon oben +/*N*/ { +/*N*/ aCol[nCol].GetOptimalHeight( +/*N*/ nStartRow, nEndRow, pHeight, pDev, nPPTX, nPPTY, rZoomX, rZoomY, bForce, +/*N*/ nMinHeight, nMinStart ); +/*N*/ +/*N*/ if (pProgress) +/*N*/ { +/*N*/ long nWeight = aCol[nCol].GetWeightedCount(); +/*N*/ if (nWeight) // nochmal denselben Status muss auch nicht sein +/*N*/ { +/*N*/ nWeightedCount += nWeight; +/*N*/ pProgress->SetState( nWeightedCount ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ USHORT nRngStart; +/*N*/ USHORT nRngEnd; +/*N*/ USHORT nLast = 0; +/*N*/ USHORT i; +/*N*/ for (i=0; i<nCount; i++) +/*N*/ { +/*N*/ if ( (pRowFlags[nStartRow+i] & CR_MANUALSIZE) == 0 || bForce ) +/*N*/ { +/*N*/ if (nExtra) +/*N*/ pRowFlags[nStartRow+i] |= CR_MANUALSIZE; +/*N*/ else +/*N*/ pRowFlags[nStartRow+i] &= ~CR_MANUALSIZE; +/*N*/ +/*N*/ if (nLast) +/*N*/ { +/*N*/ if (pHeight[i]+nExtra == nLast) +/*N*/ nRngEnd = nStartRow+i; +/*N*/ else +/*N*/ { +/*N*/ bChanged |= SetRowHeightRange( nRngStart, nRngEnd, nLast, nPPTX, nPPTY ); +/*N*/ nLast = 0; +/*N*/ } +/*N*/ } +/*N*/ if (!nLast) +/*N*/ { +/*N*/ nLast = pHeight[i]+nExtra; +/*N*/ nRngStart = nStartRow+i; +/*N*/ nRngEnd = nStartRow+i; +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ if (nLast) +/*N*/ bChanged |= SetRowHeightRange( nRngStart, nRngEnd, nLast, nPPTX, nPPTY ); +/*N*/ nLast = 0; +/*N*/ } +/*N*/ } +/*N*/ if (nLast) +/*N*/ bChanged |= SetRowHeightRange( nRngStart, nRngEnd, nLast, nPPTX, nPPTY ); +/*N*/ +/*N*/ delete[] pHeight; +/*N*/ delete pProgress; +/*N*/ +/*N*/ return bChanged; +/*N*/ } + +/*N*/ BOOL ScTable::GetCellArea( USHORT& rEndCol, USHORT& rEndRow ) const +/*N*/ { +/*N*/ BOOL bFound = FALSE; +/*N*/ USHORT nMaxX = 0; +/*N*/ USHORT nMaxY = 0; +/*N*/ for (USHORT i=0; i<=MAXCOL; i++) +/*N*/ if (!aCol[i].IsEmptyVisData(TRUE)) // TRUE = Notizen zaehlen auch +/*N*/ { +/*N*/ bFound = TRUE; +/*N*/ nMaxX = i; +/*N*/ USHORT nColY = aCol[i].GetLastVisDataPos(TRUE); +/*N*/ if (nColY > nMaxY) +/*N*/ nMaxY = nColY; +/*N*/ } +/*N*/ +/*N*/ rEndCol = nMaxX; +/*N*/ rEndRow = nMaxY; +/*N*/ return bFound; +/*N*/ } + +/*N*/ BOOL ScTable::GetTableArea( USHORT& rEndCol, USHORT& rEndRow ) const +/*N*/ { +/*N*/ BOOL bRet = TRUE; //! merken? +/*N*/ if (!bTableAreaValid) +/*N*/ { +/*N*/ bRet = GetPrintArea( ((ScTable*)this)->nTableAreaX, +/*N*/ ((ScTable*)this)->nTableAreaY, TRUE ); +/*N*/ ((ScTable*)this)->bTableAreaValid = TRUE; +/*N*/ } +/*N*/ rEndCol = nTableAreaX; +/*N*/ rEndRow = nTableAreaY; +/*N*/ return bRet; +/*N*/ } + +/* vorher: + + BOOL bFound = FALSE; + USHORT nMaxX = 0; + USHORT nMaxY = 0; + for (USHORT i=0; i<=MAXCOL; i++) + if (!aCol[i].IsEmpty()) + { + bFound = TRUE; + nMaxX = i; + USHORT nColY = aCol[i].GetLastEntryPos(); + if (nColY > nMaxY) + nMaxY = nColY; + } + + rEndCol = nMaxX; + rEndRow = nMaxY; + return bFound; +*/ + +/*N*/ BOOL ScTable::GetPrintArea( USHORT& rEndCol, USHORT& rEndRow, BOOL bNotes ) const +/*N*/ { +/*N*/ BOOL bFound = FALSE; +/*N*/ USHORT nMaxX = 0; +/*N*/ USHORT nMaxY = 0; +/*N*/ USHORT i; +/*N*/ +/*N*/ for (i=0; i<=MAXCOL; i++) // Attribute testen +/*N*/ { +/*N*/ USHORT nFirstRow,nLastRow; +/*N*/ if (aCol[i].HasVisibleAttr( nFirstRow,nLastRow, FALSE )) +/*N*/ { +/*N*/ bFound = TRUE; +/*N*/ nMaxX = i; +/*N*/ if (nLastRow > nMaxY) +/*N*/ nMaxY = nLastRow; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if (nMaxX == MAXCOL) // Attribute rechts weglassen +/*N*/ { +/*N*/ --nMaxX; +/*N*/ while ( nMaxX>0 && aCol[nMaxX].IsVisibleAttrEqual(aCol[nMaxX+1]) ) +/*N*/ --nMaxX; +/*N*/ } +/*N*/ +/*N*/ for (i=0; i<=MAXCOL; i++) // Daten testen +/*N*/ if (!aCol[i].IsEmptyVisData(bNotes)) +/*N*/ { +/*N*/ bFound = TRUE; +/*N*/ if (i>nMaxX) +/*N*/ nMaxX = i; +/*N*/ USHORT nColY = aCol[i].GetLastVisDataPos(bNotes); +/*N*/ if (nColY > nMaxY) +/*N*/ nMaxY = nColY; +/*N*/ } +/*N*/ +/*N*/ rEndCol = nMaxX; +/*N*/ rEndRow = nMaxY; +/*N*/ return bFound; +/*N*/ } + + + +/*N*/ BOOL ScTable::GetDataStart( USHORT& rStartCol, USHORT& rStartRow ) const +/*N*/ { +/*N*/ BOOL bFound = FALSE; +/*N*/ USHORT nMinX = MAXCOL; +/*N*/ USHORT nMinY = MAXROW; +/*N*/ USHORT i; +/*N*/ +/*N*/ for (i=0; i<=MAXCOL; i++) // Attribute testen +/*N*/ { +/*N*/ USHORT nFirstRow,nLastRow; +/*N*/ if (aCol[i].HasVisibleAttr( nFirstRow,nLastRow, TRUE )) +/*N*/ { +/*N*/ if (!bFound) +/*N*/ nMinX = i; +/*N*/ bFound = TRUE; +/*N*/ if (nFirstRow < nMinY) +/*N*/ nMinY = nFirstRow; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if (nMinX == 0) // Attribute links weglassen +/*N*/ { +/*N*/ if ( aCol[0].IsVisibleAttrEqual(aCol[1]) ) // keine einzelnen +/*N*/ { +/*?*/ ++nMinX; +/*?*/ while ( nMinX<MAXCOL && aCol[nMinX].IsVisibleAttrEqual(aCol[nMinX-1]) ) +/*?*/ ++nMinX; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ BOOL bDatFound = FALSE; +/*N*/ for (i=0; i<=MAXCOL; i++) // Daten testen +/*N*/ if (!aCol[i].IsEmptyVisData(TRUE)) +/*N*/ { +/*N*/ if (!bDatFound && i<nMinX) +/*N*/ nMinX = i; +/*N*/ bFound = bDatFound = TRUE; +/*N*/ USHORT nColY = aCol[i].GetFirstVisDataPos(TRUE); +/*N*/ if (nColY < nMinY) +/*N*/ nMinY = nColY; +/*N*/ } +/*N*/ +/*N*/ rStartCol = nMinX; +/*N*/ rStartRow = nMinY; +/*N*/ return bFound; +/*N*/ } + +/*N*/ void ScTable::GetDataArea( USHORT& rStartCol, USHORT& rStartRow, USHORT& rEndCol, USHORT& rEndRow, +/*N*/ BOOL bIncludeOld ) +/*N*/ { +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 //STRIP001 BOOL bLeft = FALSE; +/*N*/ } + + + + + + +/*N*/ void ScTable::GetNextPos( USHORT& rCol, USHORT& rRow, short nMovX, short nMovY, +/*N*/ BOOL bMarked, BOOL bUnprotected, const ScMarkData& rMark ) +/*N*/ { +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 //STRIP001 if (bUnprotected && !IsProtected()) // Tabelle ueberhaupt geschuetzt? +/*N*/ } + +/*N*/ BOOL ScTable::GetNextMarkedCell( USHORT& rCol, USHORT& rRow, const ScMarkData& rMark ) +/*N*/ { +/*N*/ const ScMarkArray* pMarkArray = rMark.GetArray(); +/*N*/ DBG_ASSERT(pMarkArray,"GetNextMarkedCell ohne MarkArray"); +/*N*/ if ( !pMarkArray ) +/*N*/ return FALSE; +/*N*/ +/*N*/ ++rRow; // naechste Zelle ist gesucht +/*N*/ +/*N*/ while ( rCol <= MAXCOL ) +/*N*/ { +/*N*/ const ScMarkArray& rArray = pMarkArray[rCol]; +/*N*/ while ( rRow <= MAXROW ) +/*N*/ { +/*N*/ USHORT nStart = (USHORT) rArray.GetNextMarked( (short) rRow, FALSE ); +/*N*/ if ( nStart <= MAXROW ) +/*N*/ { +/*N*/ USHORT nEnd = rArray.GetMarkEnd( nStart, FALSE ); +/*N*/ ScColumnIterator aColIter( &aCol[rCol], nStart, nEnd ); +/*N*/ USHORT nCellRow; +/*N*/ ScBaseCell* pCell = NULL; +/*N*/ while ( aColIter.Next( nCellRow, pCell ) ) +/*N*/ { +/*N*/ if ( pCell && pCell->GetCellType() != CELLTYPE_NOTE ) +/*N*/ { +/*N*/ rRow = nCellRow; +/*N*/ return TRUE; // Zelle gefunden +/*N*/ } +/*N*/ } +/*N*/ rRow = nEnd + 1; // naechsten markierten Bereich suchen +/*N*/ } +/*N*/ else +/*N*/ rRow = MAXROW + 1; // Ende der Spalte +/*N*/ } +/*N*/ rRow = 0; +/*N*/ ++rCol; // naechste Spalte testen +/*N*/ } +/*N*/ +/*N*/ return FALSE; // alle Spalten durch +/*N*/ } + +/*N*/ void ScTable::UpdateDrawRef( UpdateRefMode eUpdateRefMode, USHORT nCol1, USHORT nRow1, USHORT nTab1, +/*N*/ USHORT nCol2, USHORT nRow2, USHORT nTab2, +/*N*/ short nDx, short nDy, short nDz ) +/*N*/ { +/*N*/ if ( nTab >= nTab1 && nTab <= nTab2 && nDz == 0 ) // only within the table +/*N*/ { +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 /*?*/ ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer(); +/*N*/ } +/*N*/ } + +/*N*/ void ScTable::UpdateReference( UpdateRefMode eUpdateRefMode, USHORT nCol1, USHORT nRow1, USHORT nTab1, +/*N*/ USHORT nCol2, USHORT nRow2, USHORT nTab2, short nDx, short nDy, short nDz, +/*N*/ ScDocument* pUndoDoc, BOOL bIncludeDraw ) +/*N*/ { +/*N*/ USHORT i; +/*N*/ USHORT iMax; +/*N*/ if ( eUpdateRefMode == URM_COPY ) +/*N*/ { +/*N*/ i = nCol1; +/*N*/ iMax = nCol2; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ i = 0; +/*N*/ iMax = MAXCOL; +/*N*/ } +/*N*/ for ( ; i<=iMax; i++) +/*N*/ aCol[i].UpdateReference( eUpdateRefMode, nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, +/*N*/ nDx, nDy, nDz, pUndoDoc ); +/*N*/ +/*N*/ if ( bIncludeDraw ) +/*N*/ UpdateDrawRef( eUpdateRefMode, nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, nDx, nDy, nDz ); +/*N*/ +/*N*/ if ( nTab >= nTab1 && nTab <= nTab2 && nDz == 0 ) // print ranges: only within the table +/*N*/ { +/*?*/ USHORT nSTab,nETab,nSCol,nSRow,nECol,nERow; +/*?*/ BOOL bRecalcPages = FALSE; +/*?*/ +/*?*/ if ( pPrintRanges && nPrintRangeCount ) +/*?*/ for ( i=0; i<nPrintRangeCount; i++ ) +/*?*/ { +/*?*/ nSTab = nETab = pPrintRanges[i].aStart.Tab(); +/*?*/ nSCol = pPrintRanges[i].aStart.Col(); +/*?*/ nSRow = pPrintRanges[i].aStart.Row(); +/*?*/ nECol = pPrintRanges[i].aEnd.Col(); +/*?*/ nERow = pPrintRanges[i].aEnd.Row(); +/*?*/ +/*?*/ if ( ScRefUpdate::Update( pDocument, eUpdateRefMode, +/*?*/ nCol1,nRow1,nTab1, nCol2,nRow2,nTab2, +/*?*/ nDx,nDy,nDz, +/*?*/ nSCol,nSRow,nSTab, nECol,nERow,nETab ) ) +/*?*/ { +/*?*/ pPrintRanges[i] = ScRange( nSCol, nSRow, nSTab, nECol, nERow, nSTab ); +/*?*/ bRecalcPages = TRUE; +/*?*/ } +/*?*/ } +/*?*/ +/*?*/ if ( pRepeatColRange ) +/*?*/ { +/*?*/ nSTab = nETab = pRepeatColRange->aStart.Tab(); +/*?*/ nSCol = pRepeatColRange->aStart.Col(); +/*?*/ nSRow = pRepeatColRange->aStart.Row(); +/*?*/ nECol = pRepeatColRange->aEnd.Col(); +/*?*/ nERow = pRepeatColRange->aEnd.Row(); +/*?*/ +/*?*/ if ( ScRefUpdate::Update( pDocument, eUpdateRefMode, +/*?*/ nCol1,nRow1,nTab1, nCol2,nRow2,nTab2, +/*?*/ nDx,nDy,nDz, +/*?*/ nSCol,nSRow,nSTab, nECol,nERow,nETab ) ) +/*?*/ { +/*?*/ *pRepeatColRange = ScRange( nSCol, nSRow, nSTab, nECol, nERow, nSTab ); +/*?*/ bRecalcPages = TRUE; +/*?*/ nRepeatStartX = nSCol; // fuer UpdatePageBreaks +/*?*/ nRepeatEndX = nECol; +/*?*/ } +/*?*/ } +/*?*/ +/*?*/ if ( pRepeatRowRange ) +/*?*/ { +/*?*/ nSTab = nETab = pRepeatRowRange->aStart.Tab(); +/*?*/ nSCol = pRepeatRowRange->aStart.Col(); +/*?*/ nSRow = pRepeatRowRange->aStart.Row(); +/*?*/ nECol = pRepeatRowRange->aEnd.Col(); +/*?*/ nERow = pRepeatRowRange->aEnd.Row(); +/*?*/ +/*?*/ if ( ScRefUpdate::Update( pDocument, eUpdateRefMode, +/*?*/ nCol1,nRow1,nTab1, nCol2,nRow2,nTab2, +/*?*/ nDx,nDy,nDz, +/*?*/ nSCol,nSRow,nSTab, nECol,nERow,nETab ) ) +/*?*/ { +/*?*/ *pRepeatRowRange = ScRange( nSCol, nSRow, nSTab, nECol, nERow, nSTab ); +/*?*/ bRecalcPages = TRUE; +/*?*/ nRepeatStartY = nSRow; // fuer UpdatePageBreaks +/*?*/ nRepeatEndY = nERow; +/*?*/ } +/*?*/ } +/*?*/ +/*?*/ // updating print ranges is not necessary with multiple print ranges +/*?*/ if ( bRecalcPages && GetPrintRangeCount() <= 1 ) +/*?*/ { +/*?*/ UpdatePageBreaks(NULL); +/*?*/ +/*?*/ SfxObjectShell* pDocSh = pDocument->GetDocumentShell(); +/*?*/ if (pDocSh) +/*?*/ pDocSh->Broadcast( ScPaintHint( +/*?*/ ScRange(0,0,nTab,MAXCOL,MAXROW,nTab), +/*?*/ PAINT_GRID ) ); +/*?*/ } +/*N*/ } +/*N*/ } + + + +/*N*/ void ScTable::UpdateInsertTab(USHORT nTable) +/*N*/ { +/*N*/ if (nTab >= nTable) nTab++; +/*N*/ for (USHORT i=0; i <= MAXCOL; i++) aCol[i].UpdateInsertTab(nTable); +/*N*/ } + + +/*N*/ void ScTable::UpdateDeleteTab( USHORT nTable, BOOL bIsMove, ScTable* pRefUndo ) +/*N*/ { +/*N*/ if (nTab > nTable) nTab--; +/*N*/ +/*N*/ USHORT i; +/*N*/ if (pRefUndo) +/*N*/ for (i=0; i <= MAXCOL; i++) aCol[i].UpdateDeleteTab(nTable, bIsMove, &pRefUndo->aCol[i]); +/*N*/ else +/*N*/ for (i=0; i <= MAXCOL; i++) aCol[i].UpdateDeleteTab(nTable, bIsMove, NULL); +/*N*/ } + +/*N*/ void ScTable::UpdateCompile( BOOL bForceIfNameInUse ) +/*N*/ { +/*N*/ for (USHORT i=0; i <= MAXCOL; i++) +/*N*/ { +/*N*/ aCol[i].UpdateCompile( bForceIfNameInUse ); +/*N*/ } +/*N*/ } + +/*N*/ void ScTable::SetTabNo(USHORT nNewTab) +/*N*/ { +/*N*/ nTab = nNewTab; +/*N*/ for (USHORT i=0; i <= MAXCOL; i++) aCol[i].SetTabNo(nNewTab); +/*N*/ } + +/*N*/ BOOL ScTable::IsRangeNameInUse(USHORT nCol1, USHORT nRow1, USHORT nCol2, USHORT nRow2, + USHORT nIndex) const +/*N*/ { +/*N*/ BOOL bInUse = FALSE; +/*N*/ for (USHORT i = nCol1; !bInUse && (i <= nCol2) && (i <= MAXCOL); i++) +/*N*/ bInUse = aCol[i].IsRangeNameInUse(nRow1, nRow2, nIndex); +/*N*/ return bInUse; +/*N*/ } + +/*N*/ void ScTable::ReplaceRangeNamesInUse(USHORT nCol1, USHORT nRow1, +/*N*/ USHORT nCol2, USHORT nRow2, +/*N*/ const ScIndexMap& rMap ) +/*N*/ { +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 //STRIP001 for (USHORT i = nCol1; i <= nCol2 && (i <= MAXCOL); i++) +/*N*/ } + +/*N*/ void ScTable::ExtendPrintArea( OutputDevice* pDev, +/*N*/ USHORT nStartCol, USHORT nStartRow, USHORT& rEndCol, USHORT nEndRow ) +/*N*/ { +/*N*/ if ( !pColFlags || !pRowFlags ) +/*N*/ { +/*N*/ DBG_ERROR("keine ColInfo oder RowInfo in ExtendPrintArea"); +/*N*/ return; +/*N*/ } +/*N*/ +/*N*/ Point aPix1000 = pDev->LogicToPixel( Point(1000,1000), MAP_TWIP ); +/*N*/ double nPPTX = aPix1000.X() / 1000.0; +/*N*/ double nPPTY = aPix1000.Y() / 1000.0; +/*N*/ +/*N*/ BOOL bEmpty[MAXCOL+1]; +/*N*/ for (USHORT i=0; i<=MAXCOL; i++) +/*N*/ bEmpty[i] = ( aCol[i].GetCellCount() == 0 ); +/*N*/ +/*N*/ USHORT nIndex; +/*N*/ USHORT nPrintCol = rEndCol; +/*N*/ for (USHORT nRow = nStartRow; nRow<=nEndRow; nRow++) +/*N*/ { +/*N*/ if ( ( pRowFlags[nRow] & CR_HIDDEN ) == 0 ) +/*N*/ { +/*N*/ USHORT nDataCol = rEndCol; +/*N*/ while (nDataCol > 0 && ( bEmpty[nDataCol] || !aCol[nDataCol].Search(nRow,nIndex) ) ) +/*N*/ --nDataCol; +/*N*/ if ( ( pColFlags[nDataCol] & CR_HIDDEN ) == 0 ) +/*N*/ { +/*N*/ ScBaseCell* pCell = aCol[nDataCol].GetCell(nRow); +/*N*/ if (pCell) +/*N*/ { +/*N*/ CellType eType = pCell->GetCellType(); +/*N*/ if (eType == CELLTYPE_STRING || eType == CELLTYPE_EDIT +/*N*/ || (eType == CELLTYPE_FORMULA && !((ScFormulaCell*)pCell)->IsValue()) ) +/*N*/ { +/*N*/ BOOL bFormula = FALSE; //! uebergeben +/*N*/ long nPixel = pCell->GetTextWidth(); +/*N*/ +/*N*/ // Breite bereits im Idle-Handler berechnet? +/*N*/ if ( TEXTWIDTH_DIRTY == nPixel ) +/*N*/ { +/*N*/ ScNeededSizeOptions aOptions; +/*N*/ aOptions.bTotalSize = TRUE; +/*N*/ aOptions.bFormula = bFormula; +/*N*/ aOptions.bSkipMerged = FALSE; +/*N*/ +/*N*/ Fraction aZoom(1,1); +/*N*/ nPixel = aCol[nDataCol].GetNeededSize( nRow, +/*N*/ pDev,nPPTX,nPPTY,aZoom,aZoom, +/*N*/ TRUE, aOptions ); +/*N*/ pCell->SetTextWidth( (USHORT)nPixel ); +/*N*/ } +/*N*/ +/*N*/ long nTwips = (long) (nPixel / nPPTX); +/*N*/ long nDocW = GetColWidth( nDataCol ); +/*N*/ USHORT nCol = nDataCol; +/*N*/ while (nTwips > nDocW && nCol < MAXCOL) +/*N*/ { +/*N*/ ++nCol; +/*N*/ nDocW += GetColWidth( nCol ); +/*N*/ } +/*N*/ if (nCol>nPrintCol) +/*N*/ nPrintCol = nCol; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ rEndCol = nPrintCol; +/*N*/ } + +/*N*/ void ScTable::DoColResize( USHORT nCol1, USHORT nCol2, USHORT nAdd ) +/*N*/ { +/*N*/ for (USHORT nCol=nCol1; nCol<=nCol2; nCol++) +/*N*/ aCol[nCol].Resize(aCol[nCol].GetCellCount() + nAdd); +/*N*/ } + +/*N*/ #define SET_PRINTRANGE( p1, p2 ) \ +/*N*/ if ( (p2) ) \ +/*N*/ { \ +/*N*/ if ( (p1) ) \ +/*N*/ *(p1) = *(p2); \ +/*N*/ else \ +/*N*/ (p1) = new ScRange( *(p2) ); \ +/*N*/ } \ +/*N*/ else \ +/*N*/ DELETEZ( (p1) ) + +/*N*/ void ScTable::SetRepeatColRange( const ScRange* pNew ) +/*N*/ { +/*N*/ SET_PRINTRANGE( pRepeatColRange, pNew ); +/*N*/ } + +/*N*/ void ScTable::SetRepeatRowRange( const ScRange* pNew ) +/*N*/ { +/*N*/ SET_PRINTRANGE( pRepeatRowRange, pNew ); +/*N*/ } + +// #42845# zeroptimiert +#if defined(WIN) && defined(MSC) +#pragma optimize("",off) +#endif +/*N*/ void ScTable::SetPrintRangeCount( USHORT nNew ) +/*N*/ { +/*N*/ ScRange* pNewRanges; +/*N*/ if (nNew) +/*N*/ pNewRanges = new ScRange[nNew]; +/*N*/ else +/*N*/ pNewRanges = NULL; +/*N*/ +/*N*/ if ( pPrintRanges && nNew >= nPrintRangeCount ) // Anzahl vergroessert? +/*?*/ for ( USHORT i=0; i<nPrintRangeCount; i++ ) // (fuer "Hinzufuegen") +/*?*/ pNewRanges[i] = pPrintRanges[i]; // alte Ranges kopieren +/*N*/ +/*N*/ delete[] pPrintRanges; +/*N*/ pPrintRanges = pNewRanges; +/*N*/ nPrintRangeCount = nNew; +/*N*/ } +#if defined(WIN) && defined(MSC) +#pragma optimize("",on) +#endif + +/*N*/ void ScTable::SetPrintRange( USHORT nPos, const ScRange& rNew ) +/*N*/ { +/*N*/ if (nPos < nPrintRangeCount && pPrintRanges) +/*N*/ pPrintRanges[nPos] = rNew; +/*N*/ else +/*N*/ DBG_ERROR("SetPrintRange falsch"); +/*N*/ } + +/*N*/ const ScRange* ScTable::GetPrintRange(USHORT nPos) const +/*N*/ { +/*N*/ if (nPos < nPrintRangeCount && pPrintRanges) +/*N*/ return pPrintRanges+nPos; +/*N*/ else +/*N*/ return NULL; +/*N*/ } + +/*N*/ void ScTable::FillPrintSaver( ScPrintSaverTab& rSaveTab ) const +/*N*/ { +/*N*/ rSaveTab.SetAreas( nPrintRangeCount, pPrintRanges ); +/*N*/ rSaveTab.SetRepeat( pRepeatColRange, pRepeatRowRange ); +/*N*/ } + + + + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_table2.cxx b/binfilter/bf_sc/source/core/data/sc_table2.cxx new file mode 100644 index 000000000000..4c81443b010d --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_table2.cxx @@ -0,0 +1,1974 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "scitems.hxx" +#include <tools/urlobj.hxx> +#include <math.h> +#include <bf_svtools/PasswordHelper.hxx> +#include <unotools/transliterationwrapper.hxx> + +#include "patattr.hxx" +#include "docpool.hxx" +#include "document.hxx" +#include "drwlayer.hxx" +#include "olinetab.hxx" +#include "rechead.hxx" +#include "stlpool.hxx" +#include "attarray.hxx" // Iterator +#include "markdata.hxx" +#include "progress.hxx" +#include "dociter.hxx" +#include "conditio.hxx" +#include "chartlis.hxx" +#include "globstr.hrc" +#include "bf_so3/staticbaseurl.hxx" +namespace binfilter { + +// STATIC DATA ----------------------------------------------------------- + +void lcl_LoadRange( SvStream& rStream, ScRange** ppRange ); +void lcl_SaveRange( SvStream& rStream, ScRange* pRange ); + + + +/*N*/ BOOL ScTable::SetOutlineTable( const ScOutlineTable* pNewOutline ) +/*N*/ { +/*N*/ USHORT nOldSizeX = 0; +/*N*/ USHORT nOldSizeY = 0; +/*N*/ USHORT nNewSizeX = 0; +/*N*/ USHORT nNewSizeY = 0; +/*N*/ +/*N*/ if (pOutlineTable) +/*N*/ { +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 /*?*/ nOldSizeX = pOutlineTable->GetColArray()->GetDepth(); +/*N*/ } +/*N*/ +/*N*/ if (pNewOutline) +/*N*/ { +/*N*/ pOutlineTable = new ScOutlineTable( *pNewOutline ); +/*N*/ nNewSizeX = pOutlineTable->GetColArray()->GetDepth(); +/*N*/ nNewSizeY = pOutlineTable->GetRowArray()->GetDepth(); +/*N*/ } +/*N*/ else +/*N*/ pOutlineTable = NULL; +/*N*/ +/*N*/ return ( nNewSizeX != nOldSizeX || nNewSizeY != nOldSizeY ); // Groesse geaendert ? +/*N*/ } + + +/*N*/ void ScTable::StartOutlineTable() +/*N*/ { +/*N*/ if (!pOutlineTable) +/*N*/ pOutlineTable = new ScOutlineTable; +/*N*/ } + + +/*N*/ BOOL ScTable::TestInsertRow( USHORT nStartCol, USHORT nEndCol, USHORT nSize ) +/*N*/ { +/*N*/ BOOL bTest = TRUE; +/*N*/ +/*N*/ if ( nStartCol==0 && nEndCol==MAXCOL && pOutlineTable ) +/*N*/ bTest = pOutlineTable->TestInsertRow(nSize); +/*N*/ +/*N*/ for (USHORT i=nStartCol; (i<=nEndCol) && bTest; i++) +/*N*/ bTest = aCol[i].TestInsertRow( nSize ); +/*N*/ +/*N*/ return bTest; +/*N*/ } + + +/*N*/ void ScTable::InsertRow( USHORT nStartCol, USHORT nEndCol, USHORT nStartRow, USHORT nSize ) +/*N*/ { +/*N*/ USHORT i; +/*N*/ nRecalcLvl++; +/*N*/ if (nStartCol==0 && nEndCol==MAXCOL) +/*N*/ { +/*N*/ if (pRowHeight && pRowFlags) +/*N*/ { +/*N*/ memmove( &pRowHeight[nStartRow+nSize], &pRowHeight[nStartRow], +/*N*/ (MAXROW - nStartRow + 1 - nSize) * sizeof(pRowHeight[0]) ); +/*N*/ memmove( &pRowFlags[nStartRow+nSize], &pRowFlags[nStartRow], +/*N*/ (MAXROW - nStartRow + 1 - nSize) * sizeof(pRowFlags[0]) ); +/*N*/ +/*N*/ // #67451# copy row height from row above +/*N*/ USHORT nSourceRow = ( nStartRow > 0 ) ? ( nStartRow - 1 ) : 0; +/*N*/ BYTE nNewFlags = pRowFlags[nSourceRow] & CR_MANUALSIZE; +/*N*/ USHORT nNewHeight = pRowHeight[nSourceRow]; +/*N*/ for (i=nStartRow; i<nStartRow+nSize; i++) +/*N*/ { +/*N*/ pRowHeight[i] = nNewHeight; +/*N*/ pRowFlags[i] = nNewFlags; +/*N*/ } +/*N*/ } +/*N*/ if (pOutlineTable) +/*N*/ pOutlineTable->InsertRow( nStartRow, nSize ); +/*N*/ } +/*N*/ +/*N*/ for (i=nStartCol; i<=nEndCol; i++) +/*N*/ aCol[i].InsertRow( nStartRow, nSize ); +/*N*/ if( !--nRecalcLvl ) +/*N*/ SetDrawPageSize(); +/*N*/ } + + +/*N*/ void ScTable::DeleteRow( USHORT nStartCol, USHORT nEndCol, USHORT nStartRow, USHORT nSize, +/*N*/ BOOL* pUndoOutline ) +/*N*/ { +/*N*/ USHORT i; +/*N*/ nRecalcLvl++; +/*N*/ if (nStartCol==0 && nEndCol==MAXCOL) +/*N*/ { +/*N*/ if (pRowHeight && pRowFlags) +/*N*/ { +/*N*/ memmove( &pRowHeight[nStartRow], &pRowHeight[nStartRow+nSize], +/*N*/ (MAXROW - nStartRow + 1 - nSize) * sizeof(pRowHeight[0]) ); +/*N*/ memmove( &pRowFlags[nStartRow], &pRowFlags[nStartRow+nSize], +/*N*/ (MAXROW - nStartRow + 1 - nSize) * sizeof(pRowFlags[0]) ); +/*N*/ } +/*N*/ if (pOutlineTable) +/*N*/ if (pOutlineTable->DeleteRow( nStartRow, nSize )) +/*N*/ if (pUndoOutline) +/*N*/ *pUndoOutline = TRUE; +/*N*/ } +/*N*/ +/*N*/ for (i=nStartCol; i<=nEndCol; i++) +/*N*/ aCol[i].DeleteRow( nStartRow, nSize ); +/*N*/ if( !--nRecalcLvl ) +/*N*/ SetDrawPageSize(); +/*N*/ } + + +/*N*/ BOOL ScTable::TestInsertCol( USHORT nStartRow, USHORT nEndRow, USHORT nSize ) +/*N*/ { +/*N*/ BOOL bTest = TRUE; +/*N*/ +/*N*/ if ( nStartRow==0 && nEndRow==MAXROW && pOutlineTable ) +/*N*/ bTest = pOutlineTable->TestInsertCol(nSize); +/*N*/ +/*N*/ if ( nSize > MAXCOL ) +/*N*/ bTest = FALSE; +/*N*/ +/*N*/ for (USHORT i=MAXCOL; (i+nSize>MAXCOL) && bTest; i--) +/*N*/ bTest = aCol[i].TestInsertCol(nStartRow, nEndRow); +/*N*/ +/*N*/ return bTest; +/*N*/ } + + +/*N*/ void ScTable::InsertCol( USHORT nStartCol, USHORT nStartRow, USHORT nEndRow, USHORT nSize ) +/*N*/ { +/*N*/ USHORT i; +/*N*/ nRecalcLvl++; +/*N*/ if (nStartRow==0 && nEndRow==MAXROW) +/*N*/ { +/*N*/ if (pColWidth && pColFlags) +/*N*/ { +/*N*/ memmove( &pColWidth[nStartCol+nSize], &pColWidth[nStartCol], +/*N*/ (MAXCOL - nStartCol + 1 - nSize) * sizeof(pColWidth[0]) ); +/*N*/ memmove( &pColFlags[nStartCol+nSize], &pColFlags[nStartCol], +/*N*/ (MAXCOL - nStartCol + 1 - nSize) * sizeof(pColFlags[0]) ); +/*N*/ } +/*N*/ if (pOutlineTable) +/*N*/ pOutlineTable->InsertCol( nStartCol, nSize ); +/*N*/ } +/*N*/ +/*N*/ +/*N*/ if ((nStartRow == 0) && (nEndRow == MAXROW)) +/*N*/ { +/*N*/ for (i=0; i < nSize; i++) +/*N*/ for (USHORT nCol = MAXCOL; nCol > nStartCol; nCol--) +/*N*/ aCol[nCol].SwapCol(aCol[nCol-1]); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ for (i=0; i+nSize+nStartCol <= MAXCOL; i++) +/*N*/ aCol[MAXCOL - nSize - i].MoveTo(nStartRow, nEndRow, aCol[MAXCOL - i]); +/*N*/ } +/*N*/ +/*N*/ if (nStartCol>0) // copy old attributes +/*N*/ { +/*N*/ USHORT nWhichArray[2]; +/*N*/ nWhichArray[0] = ATTR_MERGE; +/*N*/ nWhichArray[1] = 0; +/*N*/ +/*N*/ for (i=0; i<nSize; i++) +/*N*/ { +/*N*/ aCol[nStartCol-1].CopyToColumn( nStartRow, nEndRow, IDF_ATTRIB, +/*N*/ FALSE, aCol[nStartCol+i] ); +/*N*/ aCol[nStartCol+i].RemoveFlags( nStartRow, nEndRow, +/*N*/ SC_MF_HOR | SC_MF_VER | SC_MF_AUTO ); +/*N*/ aCol[nStartCol+i].ClearItems( nStartRow, nEndRow, nWhichArray ); +/*N*/ } +/*N*/ } +/*N*/ if( !--nRecalcLvl ) +/*N*/ SetDrawPageSize(); +/*N*/ } + + +/*N*/ void ScTable::DeleteCol( USHORT nStartCol, USHORT nStartRow, USHORT nEndRow, USHORT nSize, +/*N*/ BOOL* pUndoOutline ) +/*N*/ { +/*N*/ USHORT i; +/*N*/ nRecalcLvl++; +/*N*/ if (nStartRow==0 && nEndRow==MAXROW) +/*N*/ { +/*N*/ if (pColWidth && pColFlags) +/*N*/ { +/*N*/ memmove( &pColWidth[nStartCol], &pColWidth[nStartCol+nSize], +/*N*/ (MAXCOL - nStartCol + 1 - nSize) * sizeof(pColWidth[0]) ); +/*N*/ memmove( &pColFlags[nStartCol], &pColFlags[nStartCol+nSize], +/*N*/ (MAXCOL - nStartCol + 1 - nSize) * sizeof(pColFlags[0]) ); +/*N*/ } +/*N*/ if (pOutlineTable) +/*N*/ if (pOutlineTable->DeleteCol( nStartCol, nSize )) +/*N*/ if (pUndoOutline) +/*N*/ *pUndoOutline = TRUE; +/*N*/ } +/*N*/ +/*N*/ +/*N*/ for (i = 0; i < nSize; i++) +/*N*/ aCol[nStartCol + i].DeleteArea(nStartRow, nEndRow, IDF_ALL); +/*N*/ +/*N*/ if ((nStartRow == 0) && (nEndRow == MAXROW)) +/*N*/ { +/*N*/ for (i=0; i < nSize; i++) +/*N*/ for (USHORT nCol = nStartCol; nCol < MAXCOL; nCol++) +/*N*/ aCol[nCol].SwapCol(aCol[nCol+1]); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ for (i=0; i+nSize+nStartCol <= MAXCOL; i++) +/*N*/ aCol[nStartCol + nSize + i].MoveTo(nStartRow, nEndRow, aCol[nStartCol + i]); +/*N*/ } +/*N*/ if( !--nRecalcLvl ) +/*N*/ SetDrawPageSize(); +/*N*/ } + + +/*N*/ void ScTable::DeleteArea(USHORT nCol1, USHORT nRow1, USHORT nCol2, USHORT nRow2, USHORT nDelFlag) +/*N*/ { +/*N*/ if (nCol2 > MAXCOL) nCol2 = MAXCOL; +/*N*/ if (nRow2 > MAXROW) nRow2 = MAXROW; +/*N*/ if (ValidColRow(nCol1, nRow1) && ValidColRow(nCol2, nRow2)) +/*N*/ { +/*N*/ // nRecalcLvl++; +/*N*/ +/*N*/ for (USHORT i = nCol1; i <= nCol2; i++) +/*N*/ aCol[i].DeleteArea(nRow1, nRow2, nDelFlag); +/*N*/ +/*N*/ // +/*N*/ // Zellschutz auf geschuetzter Tabelle nicht setzen +/*N*/ // +/*N*/ +/*N*/ if ( bProtected && (nDelFlag & IDF_ATTRIB) ) +/*N*/ { +/*N*/ ScPatternAttr aPattern(pDocument->GetPool()); +/*N*/ aPattern.GetItemSet().Put( ScProtectionAttr( FALSE ) ); +/*N*/ ApplyPatternArea( nCol1, nRow1, nCol2, nRow2, aPattern ); +/*N*/ } +/*N*/ +/* if( !--nRecalcLvl ) + SetDrawPageSize(); +*/ +/*N*/ } +/*N*/ } + + + + +// pTable = Clipboard + + + + + + +// Markierung von diesem Dokument + + + + +/*N*/ void ScTable::StartAllListeners() +/*N*/ { +/*N*/ for (USHORT i=0; i<=MAXCOL; i++) +/*N*/ aCol[i].StartAllListeners(); +/*N*/ } + + +/*N*/ void ScTable::StartNameListeners( BOOL bOnlyRelNames ) +/*N*/ { +/*N*/ for (USHORT i=0; i<=MAXCOL; i++) +/*N*/ aCol[i].StartNameListeners( bOnlyRelNames ); +/*N*/ } + + + + + + +/*N*/ void ScTable::CopyToTable(USHORT nCol1, USHORT nRow1, USHORT nCol2, USHORT nRow2, +/*N*/ USHORT nFlags, BOOL bMarked, ScTable* pDestTab, +/*N*/ const ScMarkData* pMarkData, +/*N*/ BOOL bAsLink, BOOL bColRowFlags) +/*N*/ { +/*N*/ if (ValidColRow(nCol1, nRow1) && ValidColRow(nCol2, nRow2)) +/*N*/ { +/*N*/ USHORT i; +/*N*/ +/*N*/ if (nFlags) +/*N*/ for (i = nCol1; i <= nCol2; i++) +/*N*/ aCol[i].CopyToColumn(nRow1, nRow2, nFlags, bMarked, +/*N*/ pDestTab->aCol[i], pMarkData, bAsLink); +/*N*/ +/*N*/ if (bColRowFlags) // Spaltenbreiten/Zeilenhoehen/Flags +/*N*/ { +/*N*/ // Charts muessen beim Ein-/Ausblenden angepasst werden +/*N*/ ScChartListenerCollection* pCharts = pDestTab->pDocument->GetChartListenerCollection(); +/*N*/ if ( pCharts && !pCharts->GetCount() ) +/*N*/ pCharts = NULL; +/*N*/ +/*N*/ if (nRow1==0 && nRow2==MAXROW && pColWidth && pDestTab->pColWidth) +/*N*/ for (i=nCol1; i<=nCol2; i++) +/*N*/ { +/*N*/ BOOL bChange = pCharts && +/*N*/ ( pDestTab->pColFlags[i] & CR_HIDDEN ) != ( pColFlags[i] & CR_HIDDEN ); +/*N*/ pDestTab->pColWidth[i] = pColWidth[i]; +/*N*/ pDestTab->pColFlags[i] = pColFlags[i]; +/*N*/ //! Aenderungen zusammenfassen? +/*N*/ if (bChange) +/*?*/ { DBG_BF_ASSERT(0, "STRIP");} //STRIP001 pCharts->SetRangeDirty(ScRange( i, 0, nTab, i, MAXROW, nTab )); +/*N*/ } +/*N*/ +/*N*/ if (nCol1==0 && nCol2==MAXCOL && pRowHeight && pDestTab->pRowHeight) +/*N*/ for (i=nRow1; i<=nRow2; i++) +/*N*/ { +/*N*/ BOOL bChange = pCharts && +/*N*/ ( pDestTab->pRowFlags[i] & CR_HIDDEN ) != ( pRowFlags[i] & CR_HIDDEN ); +/*N*/ pDestTab->pRowHeight[i] = pRowHeight[i]; +/*N*/ pDestTab->pRowFlags[i] = pRowFlags[i]; +/*N*/ //! Aenderungen zusammenfassen? +/*N*/ if (bChange) +/*?*/ { DBG_BF_ASSERT(0, "STRIP");} //STRIP001 pCharts->SetRangeDirty(ScRange( 0, i, nTab, MAXCOL, i, nTab )); +/*N*/ } +/*N*/ +/*N*/ pDestTab->SetOutlineTable( pOutlineTable ); // auch nur wenn bColRowFlags +/*N*/ } +/*N*/ } +/*N*/ } + + + + + + + +/*N*/ void ScTable::MarkScenarioIn( ScMarkData& rDestMark, USHORT nNeededBits ) const +/*N*/ { +/*N*/ DBG_ASSERT( bScenario, "bScenario == FALSE" ); +/*N*/ +/*N*/ if ( ( nScenarioFlags & nNeededBits ) != nNeededBits ) // alle Bits gesetzt? +/*N*/ return; +/*N*/ +/*N*/ for (USHORT i=0; i<=MAXCOL; i++) +/*N*/ aCol[i].MarkScenarioIn( rDestMark ); +/*N*/ } + + +/*N*/ void ScTable::InvalidateScenarioRanges() +/*N*/ { +/*N*/ delete pScenarioRanges; +/*N*/ pScenarioRanges = NULL; +/*N*/ } + +/*N*/ const ScRangeList* ScTable::GetScenarioRanges() const +/*N*/ { +/*N*/ DBG_ASSERT( bScenario, "bScenario == FALSE" ); +/*N*/ +/*N*/ if (!pScenarioRanges) +/*N*/ { +/*N*/ ((ScTable*)this)->pScenarioRanges = new ScRangeList; +/*N*/ ScMarkData aMark; +/*N*/ MarkScenarioIn( aMark, 0 ); // immer +/*N*/ aMark.FillRangeListWithMarks( pScenarioRanges, FALSE ); +/*N*/ } +/*N*/ return pScenarioRanges; +/*N*/ } + + +/*N*/ void ScTable::PutCell( USHORT nCol, USHORT nRow, ScBaseCell* pCell ) +/*N*/ { +/*N*/ if (ValidColRow(nCol,nRow)) +/*N*/ { +/*N*/ if (pCell) +/*N*/ aCol[nCol].Insert( nRow, pCell ); +/*N*/ else +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 /*?*/ aCol[nCol].Delete( nRow ); +/*N*/ } +/*N*/ } + + +/*N*/ void ScTable::PutCell( USHORT nCol, USHORT nRow, ULONG nFormatIndex, ScBaseCell* pCell ) +/*N*/ { +/*N*/ if (ValidColRow(nCol,nRow)) +/*N*/ { +/*N*/ if (pCell) +/*N*/ aCol[nCol].Insert( nRow, nFormatIndex, pCell ); +/*N*/ else +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 /*?*/ aCol[nCol].Delete( nRow ); +/*N*/ } +/*N*/ } + + +/*N*/ void ScTable::PutCell( const ScAddress& rPos, ScBaseCell* pCell ) +/*N*/ { +/*N*/ if (pCell) +/*N*/ aCol[rPos.Col()].Insert( rPos.Row(), pCell ); +/*N*/ else +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 /*?*/ aCol[rPos.Col()].Delete( rPos.Row() ); +/*N*/ } + + +/*N*/ BOOL ScTable::SetString( USHORT nCol, USHORT nRow, USHORT nTab, const String& rString ) +/*N*/ { +/*N*/ if (ValidColRow(nCol,nRow)) +/*N*/ return aCol[nCol].SetString( nRow, nTab, rString ); +/*N*/ else +/*N*/ return FALSE; +/*N*/ } + + +/*N*/ void ScTable::SetValue( USHORT nCol, USHORT nRow, const double& rVal ) +/*N*/ { +/*N*/ if (ValidColRow(nCol, nRow)) +/*N*/ aCol[nCol].SetValue( nRow, rVal ); +/*N*/ } + + +/*N*/ void ScTable::SetNote( USHORT nCol, USHORT nRow, const ScPostIt& rNote) +/*N*/ { +/*N*/ if (ValidColRow(nCol, nRow)) +/*N*/ aCol[nCol].SetNote(nRow, rNote); +/*N*/ } + + +/*N*/ void ScTable::GetString( USHORT nCol, USHORT nRow, String& rString ) +/*N*/ { +/*N*/ if (ValidColRow(nCol,nRow)) +/*N*/ aCol[nCol].GetString( nRow, rString ); +/*N*/ else +/*N*/ rString.Erase(); +/*N*/ } + + +/*N*/ void ScTable::GetInputString( USHORT nCol, USHORT nRow, String& rString ) +/*N*/ { +/*N*/ if (ValidColRow(nCol,nRow)) +/*N*/ aCol[nCol].GetInputString( nRow, rString ); +/*N*/ else +/*N*/ rString.Erase(); +/*N*/ } + +/*N*/ double ScTable::GetValue( USHORT nCol, USHORT nRow ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); return 0.0;//STRIP001 if (ValidColRow( nCol, nRow )) +/*N*/ } + +/*N*/ BOOL ScTable::GetNote( USHORT nCol, USHORT nRow, ScPostIt& rNote) +/*N*/ { +/*N*/ BOOL bHasNote = FALSE; +/*N*/ +/*N*/ if (ValidColRow(nCol,nRow)) +/*N*/ bHasNote = aCol[nCol].GetNote( nRow, rNote ); +/*N*/ else +/*?*/ rNote.Clear(); +/*N*/ +/*N*/ return bHasNote; +/*N*/ } + + +/*N*/ CellType ScTable::GetCellType( USHORT nCol, USHORT nRow ) const +/*N*/ { +/*N*/ if (ValidColRow( nCol, nRow )) +/*N*/ return aCol[nCol].GetCellType( nRow ); +/*N*/ return CELLTYPE_NONE; +/*N*/ } + + +/*N*/ ScBaseCell* ScTable::GetCell( USHORT nCol, USHORT nRow ) const +/*N*/ { +/*N*/ if (ValidColRow( nCol, nRow )) +/*N*/ return aCol[nCol].GetCell( nRow ); +/*N*/ +/*N*/ DBG_ERROR("GetCell ausserhalb"); +/*N*/ return NULL; +/*N*/ } + + + + +/*N*/ BOOL ScTable::HasData( USHORT nCol, USHORT nRow ) +/*N*/ { +/*N*/ if (ValidColRow(nCol,nRow)) +/*N*/ return aCol[nCol].HasDataAt( nRow ); +/*N*/ else +/*N*/ return FALSE; +/*N*/ } + + +/*N*/ BOOL ScTable::HasStringData( USHORT nCol, USHORT nRow ) +/*N*/ { +/*N*/ if (ValidColRow(nCol,nRow)) +/*N*/ return aCol[nCol].HasStringData( nRow ); +/*N*/ else +/*N*/ return FALSE; +/*N*/ } + + +/*N*/ BOOL ScTable::HasValueData( USHORT nCol, USHORT nRow ) +/*N*/ { +/*N*/ if (ValidColRow(nCol,nRow)) +/*N*/ return aCol[nCol].HasValueData( nRow ); +/*N*/ else +/*N*/ return FALSE; +/*N*/ } + +/*N*/ void ScTable::SetDirtyVar() +/*N*/ { +/*N*/ for (USHORT i=0; i<=MAXCOL; i++) +/*N*/ aCol[i].SetDirtyVar(); +/*N*/ } + + +/*N*/ void ScTable::SetDirty() +/*N*/ { +/*N*/ BOOL bOldAutoCalc = pDocument->GetAutoCalc(); +/*N*/ pDocument->SetAutoCalc( FALSE ); // Mehrfachberechnungen vermeiden +/*N*/ for (USHORT i=0; i<=MAXCOL; i++) +/*N*/ aCol[i].SetDirty(); +/*N*/ pDocument->SetAutoCalc( bOldAutoCalc ); +/*N*/ } + + +/*N*/ void ScTable::SetDirty( const ScRange& rRange ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 BOOL bOldAutoCalc = pDocument->GetAutoCalc(); +/*N*/ } + + +/*N*/ void ScTable::SetTableOpDirty( const ScRange& rRange ) +/*N*/ { +/*N*/ BOOL bOldAutoCalc = pDocument->GetAutoCalc(); +/*N*/ pDocument->SetAutoCalc( FALSE ); // no multiple recalculation +/*N*/ USHORT nCol2 = rRange.aEnd.Col(); +/*N*/ for (USHORT i=rRange.aStart.Col(); i<=nCol2; i++) +/*N*/ aCol[i].SetTableOpDirty( rRange ); +/*N*/ pDocument->SetAutoCalc( bOldAutoCalc ); +/*N*/ } + + +/*N*/ void ScTable::SetDirtyAfterLoad() +/*N*/ { +/*N*/ BOOL bOldAutoCalc = pDocument->GetAutoCalc(); +/*N*/ pDocument->SetAutoCalc( FALSE ); // Mehrfachberechnungen vermeiden +/*N*/ for (USHORT i=0; i<=MAXCOL; i++) +/*N*/ aCol[i].SetDirtyAfterLoad(); +/*N*/ pDocument->SetAutoCalc( bOldAutoCalc ); +/*N*/ } + + +/*N*/ void ScTable::SetRelNameDirty() +/*N*/ { +/*N*/ BOOL bOldAutoCalc = pDocument->GetAutoCalc(); +/*N*/ pDocument->SetAutoCalc( FALSE ); // Mehrfachberechnungen vermeiden +/*N*/ for (USHORT i=0; i<=MAXCOL; i++) +/*N*/ aCol[i].SetRelNameDirty(); +/*N*/ pDocument->SetAutoCalc( bOldAutoCalc ); +/*N*/ } + + +/*N*/ void ScTable::CalcAll() +/*N*/ { +/*N*/ for (USHORT i=0; i<=MAXCOL; i++) aCol[i].CalcAll(); +/*N*/ } + + +/*N*/ void ScTable::CompileAll() +/*N*/ { +/*N*/ for (USHORT i=0; i <= MAXCOL; i++) aCol[i].CompileAll(); +/*N*/ } + + +/*N*/ void ScTable::CompileXML( ScProgress& rProgress ) +/*N*/ { +/*N*/ for (USHORT i=0; i <= MAXCOL; i++) +/*N*/ { +/*N*/ aCol[i].CompileXML( rProgress ); +/*N*/ } +/*N*/ } + + +/*N*/ void ScTable::CalcAfterLoad() +/*N*/ { +/*N*/ for (USHORT i=0; i <= MAXCOL; i++) aCol[i].CalcAfterLoad(); +/*N*/ } + + +/*N*/ void ScTable::ResetChanged( const ScRange& rRange ) +/*N*/ { +/*N*/ USHORT nStartCol = rRange.aStart.Col(); +/*N*/ USHORT nStartRow = rRange.aStart.Row(); +/*N*/ USHORT nEndCol = rRange.aEnd.Col(); +/*N*/ USHORT nEndRow = rRange.aEnd.Row(); +/*N*/ +/*N*/ for (USHORT nCol=nStartCol; nCol<=nEndCol; nCol++) +/*N*/ aCol[nCol].ResetChanged(nStartRow, nEndRow); +/*N*/ } + +// Attribute + +/*N*/ const SfxPoolItem* ScTable::GetAttr( USHORT nCol, USHORT nRow, USHORT nWhich ) const +/*N*/ { +/*N*/ if (ValidColRow(nCol,nRow)) +/*N*/ return aCol[nCol].GetAttr( nRow, nWhich ); +/*N*/ else +/*N*/ return NULL; +/*N*/ } + + +/*N*/ ULONG ScTable::GetNumberFormat( USHORT nCol, USHORT nRow ) const +/*N*/ { +/*N*/ if (ValidColRow(nCol,nRow)) +/*N*/ return aCol[nCol].GetNumberFormat( nRow ); +/*N*/ else +/*N*/ return 0; +/*N*/ } + + +/*N*/ const ScPatternAttr* ScTable::GetPattern( USHORT nCol, USHORT nRow ) const +/*N*/ { +/*N*/ if (ValidColRow(nCol,nRow)) +/*N*/ return aCol[nCol].GetPattern( nRow ); +/*N*/ else +/*N*/ return NULL; +/*N*/ } + + +/*N*/ BOOL ScTable::HasAttrib( USHORT nCol1, USHORT nRow1, USHORT nCol2, USHORT nRow2, USHORT nMask ) const +/*N*/ { +/*N*/ BOOL bFound=FALSE; +/*N*/ for (USHORT i=nCol1; i<=nCol2 && !bFound; i++) +/*N*/ bFound |= aCol[i].HasAttrib( nRow1, nRow2, nMask ); +/*N*/ return bFound; +/*N*/ } + + + + + + +/*N*/ BOOL ScTable::ExtendMerge( USHORT nStartCol, USHORT nStartRow, +/*N*/ USHORT& rEndCol, USHORT& rEndRow, +/*N*/ BOOL bRefresh, BOOL bAttrs ) +/*N*/ { +/*N*/ BOOL bFound=FALSE; +/*N*/ USHORT nOldEndX = rEndCol; +/*N*/ USHORT nOldEndY = rEndRow; +/*N*/ for (USHORT i=nStartCol; i<=nOldEndX; i++) +/*N*/ bFound |= aCol[i].ExtendMerge( i, nStartRow, nOldEndY, rEndCol, rEndRow, bRefresh, bAttrs ); +/*N*/ return bFound; +/*N*/ } + +/*N*/ BOOL ScTable::HasBlockMatrixFragment( USHORT nCol1, USHORT nRow1, USHORT nCol2, USHORT nRow2 ) const +/*N*/ { +/*N*/ // nix:0, mitte:1, unten:2, links:4, oben:8, rechts:16, offen:32 +/*N*/ USHORT nEdges; +/*N*/ +/*N*/ if ( nCol1 == nCol2 ) +/*N*/ { // linke und rechte Spalte +/*N*/ const USHORT n = 4 | 16; +/*N*/ nEdges = aCol[nCol1].GetBlockMatrixEdges( nRow1, nRow2, n ); +/*N*/ // nicht (4 und 16) oder 1 oder 32 +/*N*/ if ( nEdges && (((nEdges & n) != n) || (nEdges & 33)) ) +/*N*/ return TRUE; // linke oder rechte Kante fehlt oder offen +/*N*/ } +/*N*/ else +/*N*/ { // linke Spalte +/*N*/ nEdges = aCol[nCol1].GetBlockMatrixEdges( nRow1, nRow2, 4 ); +/*N*/ // nicht 4 oder 1 oder 32 +/*N*/ if ( nEdges && (((nEdges & 4) != 4) || (nEdges & 33)) ) +/*N*/ return TRUE; // linke Kante fehlt oder offen +/*N*/ // rechte Spalte +/*N*/ nEdges = aCol[nCol2].GetBlockMatrixEdges( nRow1, nRow2, 16 ); +/*N*/ // nicht 16 oder 1 oder 32 +/*N*/ if ( nEdges && (((nEdges & 16) != 16) || (nEdges & 33)) ) +/*N*/ return TRUE; // rechte Kante fehlt oder offen +/*N*/ } +/*N*/ +/*N*/ if ( nRow1 == nRow2 ) +/*N*/ { // obere und untere Zeile +/*N*/ USHORT i; +/*N*/ BOOL bOpen = FALSE; +/*N*/ const USHORT n = 2 | 8; +/*N*/ for ( i=nCol1; i<=nCol2; i++) +/*N*/ { +/*N*/ nEdges = aCol[i].GetBlockMatrixEdges( nRow1, nRow1, n ); +/*N*/ if ( nEdges ) +/*N*/ { +/*N*/ if ( (nEdges & n) != n ) +/*N*/ return TRUE; // obere oder untere Kante fehlt +/*N*/ if ( nEdges & 4 ) +/*N*/ bOpen = TRUE; // linke Kante oeffnet, weitersehen +/*N*/ else if ( !bOpen ) +/*N*/ return TRUE; // es gibt was, was nicht geoeffnet wurde +/*N*/ if ( nEdges & 16 ) +/*N*/ bOpen = FALSE; // rechte Kante schliesst +/*N*/ } +/*N*/ } +/*N*/ if ( bOpen ) +/*N*/ return TRUE; // es geht noch weiter +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ USHORT j, nR, n, i; +/*N*/ // erst obere Zeile, dann untere Zeile +/*N*/ for ( j=0, nR=nRow1, n=8; j<2; j++, nR=nRow2, n=2 ) +/*N*/ { +/*N*/ BOOL bOpen = FALSE; +/*N*/ for ( i=nCol1; i<=nCol2; i++) +/*N*/ { +/*N*/ nEdges = aCol[i].GetBlockMatrixEdges( nR, nR, n ); +/*N*/ if ( nEdges ) +/*N*/ { +/*N*/ // in oberere Zeile keine obere Kante bzw. +/*N*/ // in unterer Zeile keine untere Kante +/*N*/ if ( (nEdges & n) != n ) +/*N*/ return TRUE; +/*N*/ if ( nEdges & 4 ) +/*N*/ bOpen = TRUE; // linke Kante oeffnet, weitersehen +/*N*/ else if ( !bOpen ) +/*N*/ return TRUE; // es gibt was, was nicht geoeffnet wurde +/*N*/ if ( nEdges & 16 ) +/*N*/ bOpen = FALSE; // rechte Kante schliesst +/*N*/ } +/*N*/ } +/*N*/ if ( bOpen ) +/*N*/ return TRUE; // es geht noch weiter +/*N*/ } +/*N*/ } +/*N*/ return FALSE; +/*N*/ } + + +/*N*/ BOOL ScTable::HasSelectionMatrixFragment( const ScMarkData& rMark ) const +/*N*/ { +/*N*/ BOOL bFound=FALSE; +/*N*/ for (USHORT i=0; i<=MAXCOL && !bFound; i++) +/*N*/ bFound |= aCol[i].HasSelectionMatrixFragment(rMark); +/*N*/ return bFound; +/*N*/ } + + +/*N*/ BOOL ScTable::IsBlockEditable( USHORT nCol1, USHORT nRow1, USHORT nCol2, +/*N*/ USHORT nRow2, BOOL* pOnlyNotBecauseOfMatrix /* = NULL */ ) const +/*N*/ { +/*N*/ BOOL bIsEditable; +/*N*/ if ( nLockCount ) +/*N*/ bIsEditable = FALSE; +/*N*/ else if ( bProtected ) +/*N*/ bIsEditable = !HasAttrib( nCol1, nRow1, nCol2, nRow2, HASATTR_PROTECTED ); +/*N*/ else +/*N*/ bIsEditable = TRUE; +/*N*/ if ( bIsEditable ) +/*N*/ { +/*N*/ if ( HasBlockMatrixFragment( nCol1, nRow1, nCol2, nRow2 ) ) +/*N*/ { +/*N*/ bIsEditable = FALSE; +/*N*/ if ( pOnlyNotBecauseOfMatrix ) +/*N*/ *pOnlyNotBecauseOfMatrix = TRUE; +/*N*/ } +/*N*/ else if ( pOnlyNotBecauseOfMatrix ) +/*N*/ *pOnlyNotBecauseOfMatrix = FALSE; +/*N*/ } +/*N*/ else if ( pOnlyNotBecauseOfMatrix ) +/*N*/ *pOnlyNotBecauseOfMatrix = FALSE; +/*N*/ return bIsEditable; +/*N*/ } + + +/*N*/ BOOL ScTable::IsSelectionEditable( const ScMarkData& rMark, +/*N*/ BOOL* pOnlyNotBecauseOfMatrix /* = NULL */ ) const +/*N*/ { +/*N*/ BOOL bIsEditable; +/*N*/ if ( nLockCount ) +/*N*/ bIsEditable = FALSE; +/*N*/ else if ( bProtected ) + { +{DBG_BF_ASSERT(0, "STRIP");} //STRIP001 /*?*/ bIsEditable = !HasAttribSelection( rMark, HASATTR_PROTECTED ); + bIsEditable = FALSE; + } +/*N*/ else +/*N*/ bIsEditable = TRUE; +/*N*/ if ( bIsEditable ) +/*N*/ { +/*N*/ if ( HasSelectionMatrixFragment( rMark ) ) +/*N*/ { +/*N*/ bIsEditable = FALSE; +/*N*/ if ( pOnlyNotBecauseOfMatrix ) +/*N*/ *pOnlyNotBecauseOfMatrix = TRUE; +/*N*/ } +/*N*/ else if ( pOnlyNotBecauseOfMatrix ) +/*N*/ *pOnlyNotBecauseOfMatrix = FALSE; +/*N*/ } +/*N*/ else if ( pOnlyNotBecauseOfMatrix ) +/*N*/ *pOnlyNotBecauseOfMatrix = FALSE; +/*N*/ return bIsEditable; +/*N*/ } + + + +/*N*/ void ScTable::LockTable() +/*N*/ { +/*N*/ ++nLockCount; +/*N*/ } + + +/*N*/ void ScTable::UnlockTable() +/*N*/ { +/*N*/ if (nLockCount) +/*N*/ --nLockCount; +/*N*/ else +/*N*/ DBG_ERROR("UnlockTable ohne LockTable"); +/*N*/ } + + +/*N*/ void ScTable::MergeSelectionPattern( SfxItemSet** ppSet, const ScMarkData& rMark, BOOL bDeep ) const +/*N*/ { +/*N*/ for (USHORT i=0; i<=MAXCOL; i++) +/*N*/ aCol[i].MergeSelectionPattern( ppSet, rMark, bDeep ); +/*N*/ } + + +/*N*/ void ScTable::MergePatternArea( SfxItemSet** ppSet, USHORT nCol1, USHORT nRow1, +/*N*/ USHORT nCol2, USHORT nRow2, BOOL bDeep ) const +/*N*/ { +/*N*/ for (USHORT i=nCol1; i<=nCol2; i++) +/*N*/ aCol[i].MergePatternArea( ppSet, nRow1, nRow2, bDeep ); +/*N*/ } + + +/*N*/ void ScTable::MergeBlockFrame( SvxBoxItem* pLineOuter, SvxBoxInfoItem* pLineInner, ScLineFlags& rFlags, +/*N*/ USHORT nStartCol, USHORT nStartRow, USHORT nEndCol, USHORT nEndRow ) const +/*N*/ { +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 //STRIP001 if (ValidColRow(nStartCol, nStartRow) && ValidColRow(nEndCol, nEndRow)) +/*N*/ } + + +/*N*/ void ScTable::ApplyBlockFrame( const SvxBoxItem* pLineOuter, const SvxBoxInfoItem* pLineInner, +/*N*/ USHORT nStartCol, USHORT nStartRow, USHORT nEndCol, USHORT nEndRow ) +/*N*/ { +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 //STRIP001 if (ValidColRow(nStartCol, nStartRow) && ValidColRow(nEndCol, nEndRow)) +/*N*/ } + + + + +/*N*/ void ScTable::ApplyPatternArea( USHORT nStartCol, USHORT nStartRow, USHORT nEndCol, USHORT nEndRow, +/*N*/ const ScPatternAttr& rAttr ) +/*N*/ { +/*N*/ if (ValidColRow(nStartCol, nStartRow) && ValidColRow(nEndCol, nEndRow)) +/*N*/ { +/*N*/ PutInOrder(nStartCol, nEndCol); +/*N*/ PutInOrder(nStartRow, nEndRow); +/*N*/ for (USHORT i = nStartCol; i <= nEndCol; i++) +/*N*/ aCol[i].ApplyPatternArea(nStartRow, nEndRow, rAttr); +/*N*/ } +/*N*/ } + + + + + + +/*N*/ void ScTable::ApplyStyleArea( USHORT nStartCol, USHORT nStartRow, USHORT nEndCol, USHORT nEndRow, const ScStyleSheet& rStyle ) +/*N*/ { +/*N*/ if (ValidColRow(nStartCol, nStartRow) && ValidColRow(nEndCol, nEndRow)) +/*N*/ { +/*N*/ PutInOrder(nStartCol, nEndCol); +/*N*/ PutInOrder(nStartRow, nEndRow); +/*N*/ for (USHORT i = nStartCol; i <= nEndCol; i++) +/*N*/ aCol[i].ApplyStyleArea(nStartRow, nEndRow, rStyle); +/*N*/ } +/*N*/ } + +/*N*/ void ScTable::ApplySelectionStyle(const ScStyleSheet& rStyle, const ScMarkData& rMark) +/*N*/ { +/*N*/ for (USHORT i=0; i<=MAXCOL; i++) +/*N*/ aCol[i].ApplySelectionStyle( rStyle, rMark ); +/*N*/ } + +/*N*/ const ScStyleSheet* ScTable::GetSelectionStyle( const ScMarkData& rMark, BOOL& rFound ) const +/*N*/ { +/*N*/ rFound = FALSE; +/*N*/ +/*N*/ BOOL bEqual = TRUE; +/*N*/ BOOL bColFound; +/*N*/ USHORT i; +/*N*/ +/*N*/ const ScStyleSheet* pStyle = NULL; +/*N*/ const ScStyleSheet* pNewStyle; +/*N*/ +/*N*/ for (i=0; i<=MAXCOL && bEqual; i++) +/*N*/ if (rMark.HasMultiMarks(i)) +/*N*/ { +/*N*/ pNewStyle = aCol[i].GetSelectionStyle( rMark, bColFound ); +/*N*/ if (bColFound) +/*N*/ { +/*N*/ rFound = TRUE; +/*N*/ if ( !pNewStyle || ( pStyle && pNewStyle != pStyle ) ) +/*N*/ bEqual = FALSE; // unterschiedliche +/*N*/ pStyle = pNewStyle; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ return bEqual ? pStyle : NULL; +/*N*/ } + + +/*N*/ const ScStyleSheet* ScTable::GetAreaStyle( BOOL& rFound, USHORT nCol1, USHORT nRow1, +/*N*/ USHORT nCol2, USHORT nRow2 ) const +/*N*/ { +/*N*/ rFound = FALSE; +/*N*/ +/*N*/ BOOL bEqual = TRUE; +/*N*/ BOOL bColFound; +/*N*/ USHORT i; +/*N*/ +/*N*/ const ScStyleSheet* pStyle = NULL; +/*N*/ const ScStyleSheet* pNewStyle; +/*N*/ +/*N*/ for (i=nCol1; i<=nCol2 && bEqual; i++) +/*N*/ { +/*N*/ pNewStyle = aCol[i].GetAreaStyle(bColFound, nRow1, nRow2); +/*N*/ if (bColFound) +/*N*/ { +/*N*/ rFound = TRUE; +/*N*/ if ( !pNewStyle || ( pStyle && pNewStyle != pStyle ) ) +/*N*/ bEqual = FALSE; // unterschiedliche +/*N*/ pStyle = pNewStyle; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ return bEqual ? pStyle : NULL; +/*N*/ } + + +/*N*/ void ScTable::StyleSheetChanged( const SfxStyleSheetBase* pStyleSheet, BOOL bRemoved, +/*N*/ OutputDevice* pDev, +/*N*/ double nPPTX, double nPPTY, +/*N*/ const Fraction& rZoomX, const Fraction& rZoomY ) +/*N*/ { +/*N*/ BOOL* pUsed = new BOOL[MAXROW+1]; +/*N*/ memset( pUsed, 0, sizeof(BOOL) * (MAXROW+1) ); +/*N*/ +/*N*/ USHORT nCol; +/*N*/ for (nCol=0; nCol<=MAXCOL; nCol++) +/*N*/ aCol[nCol].FindStyleSheet( pStyleSheet, pUsed, bRemoved ); +/*N*/ +/*N*/ BOOL bFound = FALSE; +/*N*/ USHORT i; +/*N*/ USHORT nStart; +/*N*/ USHORT nEnd; +/*N*/ for (i=0; i<=MAXROW; i++) +/*N*/ { +/*N*/ if (pUsed[i]) +/*N*/ { +/*N*/ if (!bFound) +/*N*/ { +/*N*/ nStart = i; +/*N*/ bFound = TRUE; +/*N*/ } +/*N*/ nEnd = i; +/*N*/ } +/*N*/ else if (bFound) +/*N*/ { +/*?*/ SetOptimalHeight( nStart, nEnd, 0, pDev, nPPTX, nPPTY, rZoomX, rZoomY, FALSE ); +/*?*/ bFound = FALSE; +/*N*/ } +/*N*/ } +/*N*/ if (bFound) +/*N*/ SetOptimalHeight( nStart, nEnd, 0, pDev, nPPTX, nPPTY, rZoomX, rZoomY, FALSE ); +/*N*/ +/*N*/ delete[] pUsed; +/*N*/ } + + +/*N*/ BOOL ScTable::ApplyFlags( USHORT nStartCol, USHORT nStartRow, USHORT nEndCol, USHORT nEndRow, +/*N*/ INT16 nFlags ) +/*N*/ { +/*N*/ BOOL bChanged = FALSE; +/*N*/ if (ValidColRow(nStartCol, nStartRow) && ValidColRow(nEndCol, nEndRow)) +/*N*/ for (USHORT i = nStartCol; i <= nEndCol; i++) +/*N*/ bChanged |= aCol[i].ApplyFlags(nStartRow, nEndRow, nFlags); +/*N*/ return bChanged; +/*N*/ } + + + + + + +/*N*/ void ScTable::ApplyAttr( USHORT nCol, USHORT nRow, const SfxPoolItem& rAttr ) +/*N*/ { +/*N*/ if (ValidColRow(nCol,nRow)) +/*N*/ aCol[nCol].ApplyAttr( nRow, rAttr ); +/*N*/ } + + +/*N*/ void ScTable::ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark ) +/*N*/ { +/*N*/ for (USHORT i=0; i<=MAXCOL; i++) +/*N*/ aCol[i].ApplySelectionCache( pCache, rMark ); +/*N*/ } + + + + + + +// Spaltenbreiten / Zeilenhoehen + +/*N*/ void ScTable::SetColWidth( USHORT nCol, USHORT nNewWidth ) +/*N*/ { +/*N*/ if (VALIDCOL(nCol) && pColWidth) +/*N*/ { +/*N*/ if (!nNewWidth) +/*N*/ { +/*N*/ // DBG_ERROR("Spaltenbreite 0 in SetColWidth"); +/*N*/ nNewWidth = STD_COL_WIDTH; +/*N*/ } +/*N*/ +/*N*/ if ( nNewWidth != pColWidth[nCol] ) +/*N*/ { +/*N*/ nRecalcLvl++; +/*N*/ ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer(); +/*N*/ if (pDrawLayer) +/*N*/ pDrawLayer->WidthChanged( nTab, nCol, ((long) nNewWidth) - (long) pColWidth[nCol] ); +/*N*/ pColWidth[nCol] = nNewWidth; +/*N*/ if( !--nRecalcLvl ) +/*N*/ SetDrawPageSize(); +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ DBG_ERROR("Falsche Spaltennummer oder keine Breiten"); +/*N*/ } + + +/*N*/ void ScTable::SetRowHeight( USHORT nRow, USHORT nNewHeight ) +/*N*/ { +/*N*/ if (VALIDROW(nRow) && pRowHeight) +/*N*/ { +/*N*/ if (!nNewHeight) +/*N*/ { +/*?*/ DBG_ERROR("Zeilenhoehe 0 in SetRowHeight"); +/*?*/ nNewHeight = ScGlobal::nStdRowHeight; +/*N*/ } +/*N*/ +/*N*/ if ( nNewHeight != pRowHeight[nRow] ) +/*N*/ { +/*N*/ nRecalcLvl++; +/*N*/ ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer(); +/*N*/ if (pDrawLayer) +/*N*/ pDrawLayer->HeightChanged( nTab, nRow, ((long) nNewHeight) - (long) pRowHeight[nRow] ); +/*N*/ pRowHeight[nRow] = nNewHeight; +/*N*/ if( !--nRecalcLvl ) +/*?*/ SetDrawPageSize(); +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ DBG_ERROR("Falsche Zeilennummer oder keine Hoehen"); +/*N*/ } + + +/*N*/ BOOL ScTable::SetRowHeightRange( USHORT nStartRow, USHORT nEndRow, USHORT nNewHeight, +/*N*/ double nPPTX,double nPPTY ) +/*N*/ { +/*N*/ BOOL bChanged = FALSE; +/*N*/ if (VALIDROW(nStartRow) && VALIDROW(nEndRow) && pRowHeight) +/*N*/ { +/*N*/ nRecalcLvl++; +/*N*/ if (!nNewHeight) +/*N*/ { +/*?*/ DBG_ERROR("Zeilenhoehe 0 in SetRowHeight"); +/*?*/ nNewHeight = ScGlobal::nStdRowHeight; +/*N*/ } +/*N*/ +/*N*/ long nNewPix = (long) ( nNewHeight * nPPTY ); +/*N*/ +/*N*/ BOOL bSingle = FALSE; +/*N*/ ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer(); +/*N*/ if (pDrawLayer) +/*N*/ if (pDrawLayer->HasObjectsInRows( nTab, nStartRow, nEndRow )) +/*N*/ bSingle = TRUE; +/*N*/ +/*N*/ USHORT nRow; +/*N*/ if (bSingle) +/*N*/ { +/*N*/ BOOL bDiff = FALSE; +/*N*/ for (nRow=nStartRow; nRow<=nEndRow && !bDiff; nRow++) +/*N*/ bDiff = ( pRowHeight[nRow] != nNewHeight ); +/*N*/ if (!bDiff) +/*N*/ bSingle = FALSE; +/*N*/ } +/*N*/ if (bSingle) +/*N*/ { +/*N*/ if (nEndRow-nStartRow < 20) +/*N*/ for (nRow=nStartRow; nRow<=nEndRow; nRow++) +/*N*/ { +/*N*/ if (!bChanged) +/*N*/ if ( pRowHeight[nRow] != nNewHeight ) +/*N*/ bChanged = ( nNewPix != (long) ( pRowHeight[nRow] * nPPTY ) ); +/*N*/ SetRowHeight( nRow, nNewHeight ); +/*N*/ } +/*N*/ else +/*N*/ { +/*?*/ USHORT nMid = (nStartRow+nEndRow) / 2; +/*?*/ if (SetRowHeightRange( nStartRow, nMid, nNewHeight, 1.0, 1.0 )) +/*?*/ bChanged = TRUE; +/*?*/ if (SetRowHeightRange( nMid+1, nEndRow, nNewHeight, 1.0, 1.0 )) +/*?*/ bChanged = TRUE; +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ if (pDrawLayer) +/*N*/ { +/*N*/ long nHeightDif = 0; +/*N*/ for (nRow=nStartRow; nRow<=nEndRow; nRow++) +/*N*/ nHeightDif += ((long) nNewHeight) - (long) pRowHeight[nRow]; +/*N*/ pDrawLayer->HeightChanged( nTab, nEndRow, nHeightDif ); +/*N*/ } +/*N*/ for (nRow=nStartRow; nRow<=nEndRow; nRow++) +/*N*/ { +/*N*/ if (!bChanged) +/*N*/ if ( pRowHeight[nRow] != nNewHeight ) +/*N*/ bChanged = ( nNewPix != (long) ( pRowHeight[nRow] * nPPTY ) ); +/*N*/ pRowHeight[nRow] = nNewHeight; +/*N*/ } +/*N*/ } +/*N*/ if( !--nRecalcLvl ) +/*N*/ SetDrawPageSize(); +/*N*/ } +/*N*/ else +/*N*/ DBG_ERROR("Falsche Zeilennummer oder keine Hoehen"); +/*N*/ +/*N*/ return bChanged; +/*N*/ } + + +/*N*/ void ScTable::SetManualHeight( USHORT nStartRow, USHORT nEndRow, BOOL bManual ) +/*N*/ { +/*N*/ if (VALIDROW(nStartRow) && VALIDROW(nEndRow) && pRowFlags) +/*N*/ { +/*N*/ USHORT nRow; +/*N*/ if (bManual) +/*N*/ for (nRow=nStartRow; nRow<=nEndRow; nRow++) +/*N*/ pRowFlags[nRow] |= CR_MANUALSIZE; +/*N*/ else +/*N*/ for (nRow=nStartRow; nRow<=nEndRow; nRow++) +/*N*/ pRowFlags[nRow] &= ~CR_MANUALSIZE; +/*N*/ } +/*N*/ else +/*N*/ DBG_ERROR("Falsche Zeilennummer oder keine Zeilenflags"); +/*N*/ } + + +/*N*/ USHORT ScTable::GetColWidth( USHORT nCol ) const +/*N*/ { +/*N*/ DBG_ASSERT(VALIDCOL(nCol),"Falsche Spaltennummer"); +/*N*/ +/*N*/ if (VALIDCOL(nCol) && pColFlags && pColWidth) +/*N*/ { +/*N*/ if ( pColFlags[nCol] & CR_HIDDEN ) +/*N*/ return 0; +/*N*/ else +/*N*/ return pColWidth[nCol]; +/*N*/ } +/*N*/ else +/*N*/ return (USHORT) STD_COL_WIDTH; +/*N*/ } + + +/*N*/ USHORT ScTable::GetOriginalWidth( USHORT nCol ) const // immer die eingestellte +/*N*/ { +/*N*/ DBG_ASSERT(VALIDCOL(nCol),"Falsche Spaltennummer"); +/*N*/ +/*N*/ if (VALIDCOL(nCol) && pColWidth) +/*N*/ return pColWidth[nCol]; +/*N*/ else +/*N*/ return (USHORT) STD_COL_WIDTH; +/*N*/ } + + + + +/*N*/ USHORT ScTable::GetRowHeight( USHORT nRow ) const +/*N*/ { +/*N*/ DBG_ASSERT(VALIDROW(nRow),"Falsche Zeilennummer"); +/*N*/ +/*N*/ if (VALIDROW(nRow) && pRowFlags && pRowHeight) +/*N*/ { +/*N*/ if ( pRowFlags[nRow] & CR_HIDDEN ) +/*N*/ return 0; +/*N*/ else +/*N*/ return pRowHeight[nRow]; +/*N*/ } +/*N*/ else +/*N*/ return (USHORT) ScGlobal::nStdRowHeight; +/*N*/ } + + +/*N*/ USHORT ScTable::GetOriginalHeight( USHORT nRow ) const // non-0 even if hidden +/*N*/ { +/*N*/ DBG_ASSERT(VALIDROW(nRow),"wrong row number"); +/*N*/ +/*N*/ if (VALIDROW(nRow) && pRowHeight) +/*N*/ return pRowHeight[nRow]; +/*N*/ else +/*N*/ return (USHORT) ScGlobal::nStdRowHeight; +/*N*/ } + + +// Spalten-/Zeilen-Flags + + +/*N*/ USHORT ScTable::GetHiddenRowCount( USHORT nRow ) const +/*N*/ { +/*N*/ USHORT nEndRow = nRow; +/*N*/ if ( pRowFlags ) +/*N*/ { +/*N*/ while ( nEndRow <= MAXROW && ( pRowFlags[nEndRow] & CR_HIDDEN ) ) +/*N*/ ++nEndRow; +/*N*/ } +/*N*/ return nEndRow - nRow; +/*N*/ } + + +//! ShowRows / DBShowRows zusammenfassen + +/*N*/ void ScTable::ShowCol(USHORT nCol, BOOL bShow) +/*N*/ { +/*N*/ if (VALIDCOL(nCol) && pColFlags) +/*N*/ { +/*N*/ BOOL bWasVis = ( pColFlags[nCol] & CR_HIDDEN ) == 0; +/*N*/ if (bWasVis != bShow) +/*N*/ { +/*N*/ nRecalcLvl++; +/*N*/ ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer(); +/*N*/ if (pDrawLayer) +/*N*/ { +/*N*/ if (bShow) +/*N*/ pDrawLayer->WidthChanged( nTab, nCol, (long) pColWidth[nCol] ); +/*N*/ else +/*N*/ pDrawLayer->WidthChanged( nTab, nCol, -(long) pColWidth[nCol] ); +/*N*/ } +/*N*/ +/*N*/ if (bShow) +/*N*/ pColFlags[nCol] &= ~CR_HIDDEN; +/*N*/ else +/*N*/ pColFlags[nCol] |= CR_HIDDEN; +/*N*/ if( !--nRecalcLvl ) +/*?*/ SetDrawPageSize(); +/*N*/ +/*N*/ ScChartListenerCollection* pCharts = pDocument->GetChartListenerCollection(); +/*N*/ if ( pCharts && pCharts->GetCount() ) +/*?*/ {DBG_BF_ASSERT(0, "STRIP");} //STRIP001 pCharts->SetRangeDirty(ScRange( nCol, 0, nTab, nCol, MAXROW, nTab )); +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ DBG_ERROR("Falsche Spaltennummer oder keine Flags"); +/*N*/ } + + +/*N*/ void ScTable::ShowRows(USHORT nRow1, USHORT nRow2, BOOL bShow) +/*N*/ { +/*N*/ USHORT i; +/*N*/ USHORT nStartRow = nRow1; +/*N*/ nRecalcLvl++; +/*N*/ while (nStartRow <= nRow2) +/*N*/ { +/*N*/ USHORT nEndRow = nStartRow; +/*N*/ BYTE nOldFlag = pRowFlags[nStartRow] & CR_HIDDEN; +/*N*/ while ( nEndRow < nRow2 && (pRowFlags[nEndRow+1] & CR_HIDDEN) == nOldFlag ) +/*N*/ ++nEndRow; +/*N*/ +/*N*/ BOOL bWasVis = ( nOldFlag == 0 ); +/*N*/ BOOL bChanged = ( bWasVis != bShow ); +/*N*/ if ( bChanged ) +/*N*/ { +/*N*/ ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer(); +/*N*/ if (pDrawLayer) +/*N*/ { +/*N*/ long nHeight = 0; +/*N*/ for (i=nStartRow; i<=nEndRow; i++) +/*N*/ nHeight += pRowHeight[i]; +/*N*/ +/*N*/ if (bShow) +/*N*/ pDrawLayer->HeightChanged( nTab, nStartRow, nHeight ); +/*N*/ else +/*N*/ pDrawLayer->HeightChanged( nTab, nStartRow, -nHeight ); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if (bShow) +/*N*/ for (i=nStartRow; i<=nEndRow; i++) +/*N*/ pRowFlags[i] &= ~(CR_HIDDEN | CR_FILTERED); +/*N*/ else +/*N*/ for (i=nStartRow; i<=nEndRow; i++) +/*N*/ pRowFlags[i] |= CR_HIDDEN; +/*N*/ +/*N*/ if ( bChanged ) +/*N*/ { +/*N*/ ScChartListenerCollection* pCharts = pDocument->GetChartListenerCollection(); +/*N*/ if ( pCharts && pCharts->GetCount() ) +/*?*/ {DBG_BF_ASSERT(0, "STRIP");} //STRIP001 pCharts->SetRangeDirty(ScRange( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab )); +/*N*/ } +/*N*/ +/*N*/ nStartRow = nEndRow + 1; +/*N*/ } +/*N*/ if( !--nRecalcLvl ) +/*?*/ SetDrawPageSize(); +/*N*/ } + + +/*N*/ BOOL ScTable::IsFiltered(USHORT nRow) const +/*N*/ { +/*N*/ if (VALIDROW(nRow) && pRowFlags) +/*N*/ return ( pRowFlags[nRow] & CR_FILTERED ) != 0; +/*N*/ +/*N*/ DBG_ERROR("Falsche Zeilennummer oder keine Flags"); +/*N*/ return FALSE; +/*N*/ } + + + + +/*N*/ void ScTable::SetRowFlags( USHORT nRow, BYTE nNewFlags ) +/*N*/ { +/*N*/ if (VALIDROW(nRow) && pRowFlags) +/*N*/ pRowFlags[nRow] = nNewFlags; +/*N*/ else +/*N*/ DBG_ERROR("Falsche Zeilennummer oder keine Flags"); +/*N*/ } + + +/*N*/ BYTE ScTable::GetColFlags( USHORT nCol ) const +/*N*/ { +/*N*/ if (VALIDCOL(nCol) && pColFlags) +/*N*/ return pColFlags[nCol]; +/*N*/ else +/*N*/ return 0; +/*N*/ } + + +/*N*/ BYTE ScTable::GetRowFlags( USHORT nRow ) const +/*N*/ { +/*N*/ if (VALIDROW(nRow) && pRowFlags) +/*N*/ return pRowFlags[nRow]; +/*N*/ else +/*N*/ return 0; +/*N*/ } + + + + + + +/*N*/ USHORT ScTable::GetLastChangedCol() const +/*N*/ { +/*N*/ if ( !pColFlags ) +/*N*/ return 0; +/*N*/ +/*N*/ USHORT nLastFound = 0; +/*N*/ for (USHORT nCol = 1; nCol <= MAXCOL; nCol++) +/*N*/ if ((pColFlags[nCol] & ~CR_PAGEBREAK) || (pColWidth[nCol] != STD_COL_WIDTH)) +/*N*/ nLastFound = nCol; +/*N*/ +/*N*/ return nLastFound; +/*N*/ } + + +/*N*/ USHORT ScTable::GetLastChangedRow() const +/*N*/ { +/*N*/ if ( !pRowFlags ) +/*N*/ return 0; +/*N*/ +/*N*/ USHORT nLastFound = 0; +/*N*/ for (USHORT nRow = 1; nRow <= MAXROW; nRow++) +/*N*/ if ((pRowFlags[nRow] & ~CR_PAGEBREAK) || (pRowHeight[nRow] != ScGlobal::nStdRowHeight)) +/*N*/ nLastFound = nRow; +/*N*/ +/*N*/ return nLastFound; +/*N*/ } + + +/*N*/ BOOL ScTable::UpdateOutlineCol( USHORT nStartCol, USHORT nEndCol, BOOL bShow ) +/*N*/ { +/*N*/ if (pOutlineTable && pColFlags) +/*?*/ {DBG_BF_ASSERT(0, "STRIP"); return FALSE;} //STRIP001 return pOutlineTable->GetColArray()->ManualAction( nStartCol, nEndCol, bShow, pColFlags ); +/*N*/ else +/*N*/ return FALSE; +/*N*/ } + + +/*N*/ BOOL ScTable::UpdateOutlineRow( USHORT nStartRow, USHORT nEndRow, BOOL bShow ) +/*N*/ { +/*N*/ if (pOutlineTable && pRowFlags) +/*N*/ return pOutlineTable->GetRowArray()->ManualAction( nStartRow, nEndRow, bShow, pRowFlags ); +/*N*/ else +/*N*/ return FALSE; +/*N*/ } + + +// Auto-Outline + +/*N*/ inline short DiffSign( USHORT a, USHORT b ) +/*N*/ { +/*N*/ return (a<b) ? -1 : +/*N*/ (a>b) ? 1 : 0; +/*N*/ } + + + +// +// Datei-Operationen +// + +// Laden + +/*N*/ BOOL ScTable::Load( SvStream& rStream, USHORT nVersion, ScProgress* pProgress ) +/*N*/ { +/*N*/ ScReadHeader aHdr( rStream ); +/*N*/ USHORT i; +/*N*/ +/*N*/ while (aHdr.BytesLeft() && rStream.GetError() == SVSTREAM_OK) +/*N*/ { +/*N*/ USHORT nID; +/*N*/ rStream >> nID; +/*N*/ switch (nID) +/*N*/ { +/*N*/ case SCID_COLUMNS: // Spalten (Daten) +/*N*/ { +/*N*/ ScMultipleReadHeader aColHdr( rStream ); +/*N*/ if( nVersion >= SC_DATABYTES ) +/*N*/ while( aColHdr.BytesLeft() ) +/*N*/ { +/*N*/ BYTE nCol; +/*N*/ rStream >> nCol; +/*N*/ aCol[ nCol ].Load(rStream, aColHdr); +/*N*/ if (pProgress) +/*N*/ pProgress->SetState( rStream.Tell() ); +/*N*/ } +/*N*/ else +/*N*/ for (i=0; i<=MAXCOL; i++) +/*N*/ { +/*N*/ aCol[i].Load(rStream, aColHdr); +/*N*/ if (pProgress) +/*N*/ pProgress->SetState( rStream.Tell() ); +/*N*/ } +/*N*/ } +/*N*/ break; +/*N*/ case SCID_COLROWFLAGS: // Spalten-/Zeilenflags +/*N*/ { +/*N*/ ScReadHeader aFlagsHdr( rStream ); +/*N*/ +/*N*/ BYTE nFlags; +/*N*/ USHORT nVal; +/*N*/ short nRep; +/*N*/ +/*N*/ i=0; +/*N*/ while (i<=MAXCOL) +/*N*/ { +/*N*/ rStream >> nRep; +/*N*/ rStream >> nVal; +/*N*/ while (nRep-- && i<=MAXCOL) +/*N*/ pColWidth[i++] = nVal; +/*N*/ } +/*N*/ DBG_ASSERT(nRep==-1, "Fehler bei Spaltenbreiten"); +/*N*/ i=0; +/*N*/ while (i<=MAXCOL) +/*N*/ { +/*N*/ rStream >> nRep; +/*N*/ rStream >> nFlags; +/*N*/ while (nRep-- && i<=MAXCOL) +/*N*/ pColFlags[i++] = nFlags; +/*N*/ } +/*N*/ DBG_ASSERT(nRep==-1, "Fehler bei Spaltenflags"); +/*N*/ if (pProgress) +/*N*/ pProgress->SetState( rStream.Tell() ); +/*N*/ +/*N*/ // aus der Datei immer soviele Zeilen laden, wie gespeichert wurden +/*N*/ USHORT nSrcMaxRow = pDocument->GetSrcMaxRow(); +/*N*/ +/*N*/ i=0; +/*N*/ while (i<=nSrcMaxRow) // nSrcMaxRow und MAXROW evtl. unterschiedlich +/*N*/ { +/*N*/ rStream >> nRep; +/*N*/ rStream >> nVal; +/*N*/ while (nRep--) +/*N*/ { +/*N*/ if (i<=MAXROW) +/*N*/ pRowHeight[i] = nVal; +/*N*/ ++i; +/*N*/ } +/*N*/ } +/*N*/ DBG_ASSERT(i==nSrcMaxRow+1, "Fehler bei Zeilenhoehen"); +/*N*/ if (pProgress) +/*N*/ pProgress->SetState( rStream.Tell() ); +/*N*/ i=0; +/*N*/ while (i<=nSrcMaxRow) // nSrcMaxRow und MAXROW evtl. unterschiedlich +/*N*/ { +/*N*/ rStream >> nRep; +/*N*/ rStream >> nFlags; +/*N*/ while (nRep--) +/*N*/ { +/*N*/ if (i<=MAXROW) +/*N*/ pRowFlags[i] = nFlags; +/*N*/ ++i; +/*N*/ } +/*N*/ } +/*N*/ DBG_ASSERT(i==nSrcMaxRow+1, "Fehler bei Zeilenflags"); +/*N*/ if (pProgress) +/*N*/ pProgress->SetState( rStream.Tell() ); +/*N*/ } +/*N*/ break; +/*N*/ case SCID_TABOPTIONS: // einzelne Einstellungen +/*N*/ { +/*N*/ ScReadHeader aFlagsHdr( rStream ); +/*N*/ +/*N*/ rStream.ReadByteString( aName, rStream.GetStreamCharSet() ); +/*N*/ +/*N*/ rStream >> bScenario; +/*N*/ rStream.ReadByteString( aComment, rStream.GetStreamCharSet() ); +/*N*/ +/*N*/ rStream >> bProtected; +/*N*/ String aPass; +/*N*/ rStream.ReadByteString( aPass, rStream.GetStreamCharSet() ); +/*N*/ if (aPass.Len()) +/*N*/ SvPasswordHelper::GetHashPassword(aProtectPass, aPass); +/*N*/ +/*N*/ BOOL bOutline; +/*N*/ rStream >> bOutline; +/*N*/ if (bOutline) +/*N*/ { +/*N*/ StartOutlineTable(); +/*N*/ pOutlineTable->Load( rStream ); +/*N*/ } +/*N*/ +/*N*/ if ( aFlagsHdr.BytesLeft() ) +/*N*/ { +/*N*/ SfxStyleSheetBasePool* pStylePool = +/*N*/ pDocument->GetStyleSheetPool(); +/*N*/ +/*N*/ rStream.ReadByteString( aPageStyle, rStream.GetStreamCharSet() ); +/*N*/ +/*N*/ if ( !pStylePool->Find( aPageStyle, SFX_STYLE_FAMILY_PAGE ) ) +/*N*/ { +/*N*/ DBG_TRACE( "PageStyle not found. Using Standard." ); +/*N*/ aPageStyle = ScGlobal::GetRscString(STR_STYLENAME_STANDARD); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if ( aFlagsHdr.BytesLeft() ) +/*N*/ { +/*N*/ BOOL bOneRange; // einzelner Druckbereich ? +/*N*/ rStream >> bOneRange; +/*N*/ if ( bOneRange ) +/*N*/ { +/*N*/ ScRange aRange; +/*N*/ rStream >> aRange; +/*N*/ SetPrintRangeCount( 1 ); +/*N*/ SetPrintRange( 0, aRange ); +/*N*/ } +/*N*/ +/*N*/ lcl_LoadRange( rStream, &pRepeatColRange ); +/*N*/ lcl_LoadRange( rStream, &pRepeatRowRange ); +/*N*/ } +/*N*/ +/*N*/ if ( aFlagsHdr.BytesLeft() ) +/*N*/ rStream >> bVisible; +/*N*/ +/*N*/ if ( aFlagsHdr.BytesLeft() ) // Druckbereiche ab Version 314c +/*N*/ { +/*N*/ USHORT nNewCount; +/*N*/ rStream >> nNewCount; +/*N*/ if ( nNewCount ) +/*N*/ { +/*?*/ ScRange aTmp; +/*?*/ SetPrintRangeCount( nNewCount ); +/*?*/ for (i=0; i<nNewCount; i++) +/*?*/ { +/*?*/ rStream >> aTmp; +/*?*/ SetPrintRange( i, aTmp ); +/*?*/ } +/*?*/ } +/*N*/ } +/*N*/ +/*N*/ if ( aFlagsHdr.BytesLeft() ) // erweiterte Szenario-Flags ab 5.0 +/*N*/ { +/*N*/ rStream >> aScenarioColor; +/*N*/ rStream >> nScenarioFlags; +/*N*/ rStream >> bActiveScenario; +/*N*/ } +/*N*/ else if ( bScenario ) +/*N*/ { +/*?*/ // Default fuer Szenarien aus alten Dateien?? +/*?*/ // Wenn die alten Szenarien wirklich benutzt wurden, +/*?*/ // wuerde der Rahmen wahrscheinlich stoeren. +/*?*/ +/*?*/ nScenarioFlags = SC_SCENARIO_COPYALL; +/*N*/ } +/*N*/ +/*N*/ if (pProgress) +/*N*/ pProgress->SetState( rStream.Tell() ); +/*N*/ } +/*N*/ break; +/*N*/ case SCID_TABLINK: // Verknuepfung +/*N*/ { +/*N*/ ScReadHeader aLinkHdr( rStream ); +/*N*/ +/*N*/ rStream >> nLinkMode; +/*N*/ rStream.ReadByteString( aLinkDoc, rStream.GetStreamCharSet() ); +/*N*/ aLinkDoc = ::binfilter::StaticBaseUrl::RelToAbs( aLinkDoc ); +/*N*/ rStream.ReadByteString( aLinkFlt, rStream.GetStreamCharSet() ); +/*N*/ rStream.ReadByteString( aLinkTab, rStream.GetStreamCharSet() ); +/*N*/ +/*N*/ BOOL bRelURL; +/*N*/ if ( aLinkHdr.BytesLeft() ) +/*N*/ rStream >> bRelURL; +/*N*/ else +/*N*/ bRelURL = FALSE; +/*N*/ // externer Tabellenname relativ zu absolut +/*N*/ if ( nLinkMode == SC_LINK_VALUE && bRelURL ) +/*N*/ aName = ScGlobal::GetDocTabName( aLinkDoc, aLinkTab ); +/*N*/ +/*N*/ if ( aLinkHdr.BytesLeft() ) // ab 336 auch Filter-Optionen +/*N*/ rStream.ReadByteString( aLinkOpt, rStream.GetStreamCharSet() ); +/*N*/ } +/*N*/ break; +/*N*/ default: +/*N*/ { +/*N*/ DBG_ERROR("unbekannter Sub-Record in ScTable::Load"); +/*N*/ ScReadHeader aDummyHeader( rStream ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // Neuberechnungen +/*N*/ +/*N*/ ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer(); +/*N*/ if (pDrawLayer) +/*?*/ pDrawLayer->ScRenamePage( nTab, aName ); +/*N*/ +/*N*/ return TRUE; +/*N*/ } + +// Speichern + + +/*N*/ void lcl_SaveValue( SvStream& rStream, USHORT* pValue, USHORT nEnd ) +/*N*/ { +/*N*/ USHORT nPos = 0; +/*N*/ while (nPos<=nEnd) +/*N*/ { +/*N*/ USHORT nVal = pValue[nPos]; +/*N*/ USHORT nNextPos = nPos+1; +/*N*/ while (nNextPos<=nEnd && pValue[nNextPos]==nVal) +/*N*/ ++nNextPos; +/*N*/ rStream << (USHORT)( nNextPos - nPos ); +/*N*/ rStream << nVal; +/*N*/ nPos = nNextPos; +/*N*/ } +/*N*/ } + + +/*N*/ void lcl_SaveFlags( SvStream& rStream, BYTE* pValue, USHORT nEnd ) +/*N*/ { +/*N*/ USHORT nPos = 0; +/*N*/ while (nPos<=nEnd) +/*N*/ { +/*N*/ BYTE nVal = pValue[nPos] & CR_SAVEMASK; +/*N*/ USHORT nNextPos = nPos+1; +/*N*/ while (nNextPos<=nEnd && (pValue[nNextPos] & CR_SAVEMASK)==nVal) +/*N*/ ++nNextPos; +/*N*/ rStream << (USHORT)( nNextPos - nPos ); +/*N*/ rStream << nVal; +/*N*/ nPos = nNextPos; +/*N*/ } +/*N*/ } + + +/*N*/ void lcl_LoadRange( SvStream& rStream, ScRange** ppRange ) +/*N*/ { +/*N*/ BOOL bIsSet = FALSE; +/*N*/ +/*N*/ rStream >> bIsSet; +/*N*/ +/*N*/ if ( bIsSet ) +/*N*/ { +/*N*/ *ppRange = new ScRange; +/*N*/ rStream >> **ppRange; +/*N*/ } +/*N*/ else +/*N*/ *ppRange = NULL; +/*N*/ } + + +/*N*/ void lcl_SaveRange( SvStream& rStream, ScRange* pRange ) +/*N*/ { +/*N*/ if ( pRange ) +/*N*/ { +/*N*/ rStream << (BOOL)TRUE; +/*N*/ rStream << *pRange; +/*N*/ } +/*N*/ else +/*N*/ rStream << (BOOL)FALSE; +/*N*/ } + + +/*N*/ BOOL ScTable::Save( SvStream& rStream, long& rSavedDocCells, ScProgress* pProgress ) const +/*N*/ { +/*N*/ ScWriteHeader aHdr( rStream ); +/*N*/ USHORT i; +/*N*/ +/*N*/ // Spalten (Daten) +/*N*/ +/*N*/ { +/*N*/ rStream << (USHORT) SCID_COLUMNS; +/*N*/ ScMultipleWriteHeader aColHdr( rStream ); +/*N*/ +/*N*/ for (i=0; i<=MAXCOL; i++) +/*N*/ { +/*N*/ const ScColumn* pCol = &aCol[ i ]; +/*N*/ if( !pCol->IsEmptyData() || pCol->NoteCount() || !pCol->IsEmptyAttr()) +/*N*/ { +/*N*/ rStream << (BYTE) i; +/*N*/ aCol[i].Save(rStream, aColHdr); +/*N*/ rSavedDocCells += aCol[i].GetWeightedCount(); +/*N*/ if (pProgress) +/*N*/ pProgress->SetState( rSavedDocCells ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // Spalten-/Zeilenflags +/*N*/ +/*N*/ { +/*N*/ rStream << (USHORT) SCID_COLROWFLAGS; +/*N*/ ScWriteHeader aFlagsHdr( rStream ); +/*N*/ +/*N*/ USHORT nSaveMaxRow = pDocument->GetSrcMaxRow(); +/*N*/ +/*N*/ lcl_SaveValue( rStream, pColWidth, MAXCOL ); +/*N*/ lcl_SaveFlags( rStream, pColFlags, MAXCOL ); +/*N*/ lcl_SaveValue( rStream, pRowHeight,nSaveMaxRow ); +/*N*/ lcl_SaveFlags( rStream, pRowFlags, nSaveMaxRow ); +/*N*/ +/*N*/ // wenn dabei weniger Zeilenhoehen als vorhanden gespeichert wurden, +/*N*/ // gibt das noch keine Warnung wegen Datenverlust. +/*N*/ } +/*N*/ +/*N*/ BOOL bRelURL = FALSE; +/*N*/ String aLinkDocSaveName( aLinkDoc ); +/*N*/ String aSaveName( aName ); +/*N*/ if ( nLinkMode ) +/*N*/ { +/*N*/ aLinkDocSaveName = ::binfilter::StaticBaseUrl::AbsToRel( aLinkDocSaveName ); +/*N*/ aLinkDocSaveName = INetURLObject::decode( aLinkDocSaveName, +/*N*/ INET_HEX_ESCAPE, INetURLObject::DECODE_UNAMBIGUOUS ); +/*N*/ if ( ScGlobal::pTransliteration->isEqual( aLinkDocSaveName, +/*N*/ INetURLObject::decode( aLinkDoc, INET_HEX_ESCAPE, +/*N*/ INetURLObject::DECODE_UNAMBIGUOUS ) ) ) +/*N*/ { +/*N*/ aSaveName = INetURLObject::decode( aSaveName, +/*N*/ INET_HEX_ESCAPE, INetURLObject::DECODE_UNAMBIGUOUS ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ bRelURL = TRUE; +/*N*/ // Reference to external sheet, only the sheet name is stored +/*N*/ // instead of the absolute DocTabName, will be reconcatenated upon +/*N*/ // load time. +/*N*/ if ( nLinkMode == SC_LINK_VALUE ) +/*N*/ aSaveName = aLinkTab; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // einzelne Einstellungen +/*N*/ +/*N*/ { +/*N*/ rStream << (USHORT) SCID_TABOPTIONS; +/*N*/ ScWriteHeader aFlagsHdr( rStream ); +/*N*/ +/*N*/ rStream.WriteByteString( aSaveName, rStream.GetStreamCharSet() ); +/*N*/ +/*N*/ rStream << bScenario; +/*N*/ rStream.WriteByteString( aComment, rStream.GetStreamCharSet() ); +/*N*/ +/*N*/ rStream << bProtected; +/*N*/ String aPass; +/*N*/ //rStream.WriteByteString( aProtectPass, rStream.GetStreamCharSet() ); +/*N*/ rStream.WriteByteString( aPass, rStream.GetStreamCharSet() ); +/*N*/ +/*N*/ BOOL bOutline = ( pOutlineTable != NULL ); +/*N*/ rStream << bOutline; +/*N*/ if (bOutline) +/*N*/ pOutlineTable->Store( rStream ); +/*N*/ +/*N*/ rStream.WriteByteString( aPageStyle, rStream.GetStreamCharSet() ); +/*N*/ +/*N*/ if ( pPrintRanges && nPrintRangeCount == 1 ) // kompatibel zu alten Versionen +/*N*/ lcl_SaveRange( rStream, pPrintRanges ); // (nur wenn genau ein Bereich) +/*N*/ else +/*N*/ lcl_SaveRange( rStream, NULL ); +/*N*/ lcl_SaveRange( rStream, pRepeatColRange ); +/*N*/ lcl_SaveRange( rStream, pRepeatRowRange ); +/*N*/ +/*N*/ rStream << bVisible; +/*N*/ +/*N*/ if ( pPrintRanges && nPrintRangeCount>1 ) // einzelner Bereich schon oben +/*N*/ { +/*?*/ rStream << nPrintRangeCount; // ab Version 314c +/*?*/ if ( nPrintRangeCount > 1 ) +/*?*/ for ( i=0; i<nPrintRangeCount; i++) +/*?*/ rStream << pPrintRanges[i]; +/*N*/ } +/*N*/ else +/*N*/ rStream << (USHORT) 0; +/*N*/ +/*N*/ if( rStream.GetVersion() > SOFFICE_FILEFORMAT_40 ) // erweiterte Szenario-Flags ab 5.0 +/*N*/ { +/*N*/ rStream << aScenarioColor; +/*N*/ rStream << nScenarioFlags; +/*N*/ rStream << bActiveScenario; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // Verknuepfung +/*N*/ +/*N*/ if (nLinkMode) +/*N*/ { +/*N*/ rStream << (USHORT) SCID_TABLINK; +/*N*/ ScWriteHeader aLinkHdr( rStream ); +/*N*/ +/*N*/ // Hack, um verknuepfte Tabellen mit der 3.1 laden zu koennen (#35242#) +/*N*/ // bei 3.1 Export Filter von "StarCalc 4.0" auf "StarCalc 3.0" umsetzen +/*N*/ // (4.0 Dateien koennen vom Calc 3.1 gelesen werden) +/*N*/ String aSaveFlt = aLinkFlt; +/*N*/ if ( rStream.GetVersion() == SOFFICE_FILEFORMAT_31 && aSaveFlt.EqualsAscii("StarCalc 4.0") ) +/*?*/ aSaveFlt.AssignAscii(RTL_CONSTASCII_STRINGPARAM("StarCalc 3.0")); +/*N*/ +/*N*/ rStream << nLinkMode; +/*N*/ rStream.WriteByteString( aLinkDocSaveName, rStream.GetStreamCharSet() ); +/*N*/ rStream.WriteByteString( aSaveFlt, rStream.GetStreamCharSet() ); +/*N*/ rStream.WriteByteString( aLinkTab, rStream.GetStreamCharSet() ); +/*N*/ rStream << bRelURL; +/*N*/ rStream.WriteByteString( aLinkOpt, rStream.GetStreamCharSet() ); +/*N*/ } +/*N*/ +/*N*/ return TRUE; +/*N*/ } + + + // CopyData - fuer Query in anderen Bereich + + + + + + + +// Berechnen der Groesse der Tabelle und setzen der Groesse an der DrawPage + +/*N*/ void ScTable::SetDrawPageSize() +/*N*/ { +/*N*/ ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer(); +/*N*/ if( pDrawLayer ) +/*N*/ { +/*N*/ ULONG x = GetColOffset( MAXCOL + 1 ); +/*N*/ ULONG y = GetRowOffset( MAXROW + 1 ); +/*N*/ x = (ULONG) ((double) x * HMM_PER_TWIPS); +/*N*/ y = (ULONG) ((double) y * HMM_PER_TWIPS); +/*N*/ pDrawLayer->SetPageSize( nTab, Size( x, y ) ); +/*N*/ } +/*N*/ } + + +/*N*/ ULONG ScTable::GetRowOffset( USHORT nRow ) const +/*N*/ { +/*N*/ ULONG n = 0; +/*N*/ if ( pRowFlags && pRowHeight ) +/*N*/ { +/*N*/ USHORT i; +/*N*/ BYTE* pFlags = pRowFlags; +/*N*/ USHORT* pHeight = pRowHeight; +/*N*/ for( i = 0; i < nRow; i++, pFlags++, pHeight++ ) +/*N*/ if( !( *pFlags & CR_HIDDEN ) ) +/*N*/ n += *pHeight; +/*N*/ } +/*N*/ else +/*N*/ DBG_ERROR("GetRowOffset: Daten fehlen"); +/*N*/ return n; +/*N*/ } + + +/*N*/ ULONG ScTable::GetColOffset( USHORT nCol ) const +/*N*/ { +/*N*/ ULONG n = 0; +/*N*/ if ( pColFlags && pColWidth ) +/*N*/ { +/*N*/ USHORT i; +/*N*/ BYTE* pFlags = pColFlags; +/*N*/ USHORT* pWidth = pColWidth; +/*N*/ for( i = 0; i < nCol; i++, pFlags++, pWidth++ ) +/*N*/ if( !( *pFlags & CR_HIDDEN ) ) +/*N*/ n += *pWidth; +/*N*/ } +/*N*/ else +/*N*/ DBG_ERROR("GetColumnOffset: Daten fehlen"); +/*N*/ return n; +/*N*/ } + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_table3.cxx b/binfilter/bf_sc/source/core/data/sc_table3.cxx new file mode 100644 index 000000000000..f04f7fa2b480 --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_table3.cxx @@ -0,0 +1,412 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include <rtl/math.hxx> +#include <unotools/textsearch.hxx> +#include <unotools/collatorwrapper.hxx> +#include <stdlib.h> +#include <unotools/transliterationwrapper.hxx> + +#include "scitems.hxx" +#include "cell.hxx" +#include "document.hxx" +#include "globstr.hrc" +#include "patattr.hxx" +#include "subtotal.hxx" +#include "docoptio.hxx" +#include "markdata.hxx" +#include "attarray.hxx" +#include "cellform.hxx" + +#include <vector> +namespace binfilter { + +// STATIC DATA ----------------------------------------------------------- + +const USHORT nMaxSorts = 3; // maximale Anzahl Sortierkriterien in aSortParam + +struct ScSortInfo +{ + ScBaseCell* pCell; + USHORT nOrg; + DECL_FIXEDMEMPOOL_NEWDEL( ScSortInfo ); +}; +/*N*/ const USHORT nMemPoolSortInfo = (0x8000 - 64) / sizeof(ScSortInfo); +/*N*/ IMPL_FIXEDMEMPOOL_NEWDEL( ScSortInfo, nMemPoolSortInfo, nMemPoolSortInfo )//STRIP008 ; + +// END OF STATIC DATA ----------------------------------------------------- + + + + + + + + + +/*N*/ void ScTable::DestroySortCollator() +/*N*/ { +/*N*/ if ( pSortCollator ) +/*N*/ { +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 /*?*/ if ( !IsSortCollatorGlobal() ) +/*N*/ } +/*N*/ } + + + + + + + + + + + + + +// Testen, ob beim Loeschen von Zwischenergebnissen andere Daten mit geloescht werden +// (fuer Hinweis-Box) + + +// alte Ergebnisse loeschen +// rParam.nRow2 wird veraendert ! + + +// harte Zahlenformate loeschen (fuer Ergebnisformeln) + + + +// at least MSC needs this at linkage level to be able to use it in a template + +// neue Zwischenergebnisse +// rParam.nRow2 wird veraendert ! + + + +/*N*/ BOOL ScTable::ValidQuery(USHORT nRow, const ScQueryParam& rParam, +/*N*/ BOOL* pSpecial /* =NULL */ , ScBaseCell* pCell /* =NULL */ , +/*N*/ BOOL* pbTestEqualCondition /* = NULL */ ) +/*N*/ { +/*N*/ if (!rParam.GetEntry(0).bDoQuery) +/*N*/ return TRUE; +/*N*/ +/*N*/ //--------------------------------------------------------------- +/*N*/ +/*N*/ const USHORT nFixedBools = 32; +/*N*/ BOOL aBool[nFixedBools]; +/*N*/ BOOL aTest[nFixedBools]; +/*N*/ USHORT nEntryCount = rParam.GetEntryCount(); +/*N*/ BOOL* pPasst = ( nEntryCount <= nFixedBools ? &aBool[0] : new BOOL[nEntryCount] ); +/*N*/ BOOL* pTest = ( nEntryCount <= nFixedBools ? &aTest[0] : new BOOL[nEntryCount] ); +/*N*/ +/*N*/ short nPos = -1; +/*N*/ USHORT i = 0; +/*N*/ BOOL bMatchWholeCell = pDocument->GetDocOptions().IsMatchWholeCell(); +/*N*/ CollatorWrapper* pCollator = (rParam.bCaseSens ? ScGlobal::pCaseCollator : +/*N*/ ScGlobal::pCollator); +/*N*/ ::utl::TransliterationWrapper* pTransliteration = (rParam.bCaseSens ? +/*N*/ ScGlobal::pCaseTransliteration : ScGlobal::pTransliteration); +/*N*/ +/*N*/ while ( (i < nEntryCount) && rParam.GetEntry(i).bDoQuery ) +/*N*/ { +/*N*/ ScQueryEntry& rEntry = rParam.GetEntry(i); +/*N*/ // we can only handle one single direct query +/*N*/ if ( !pCell || i > 0 ) +/*?*/ pCell = GetCell( rEntry.nField, nRow ); +/*N*/ +/*N*/ BOOL bOk = FALSE; +/*N*/ BOOL bTestEqual = FALSE; +/*N*/ +/*N*/ if ( pSpecial && pSpecial[i] ) +/*N*/ { +/*?*/ if (rEntry.nVal == SC_EMPTYFIELDS) +/*?*/ bOk = !( aCol[rEntry.nField].HasDataAt( nRow ) ); +/*?*/ else // if (rEntry.nVal == SC_NONEMPTYFIELDS) +/*?*/ bOk = aCol[rEntry.nField].HasDataAt( nRow ); +/*N*/ } +/*N*/ else if ( !rEntry.bQueryByString && +/*N*/ (pCell ? pCell->HasValueData() : HasValueData(rEntry.nField, nRow)) ) +/*N*/ { // by Value +/*N*/ double nCellVal; +/*N*/ if ( pCell ) +/*N*/ { +/*N*/ switch ( pCell->GetCellType() ) +/*N*/ { +/*N*/ case CELLTYPE_VALUE : +/*N*/ nCellVal = ((ScValueCell*)pCell)->GetValue(); +/*N*/ break; +/*N*/ case CELLTYPE_FORMULA : +/*?*/ nCellVal = ((ScFormulaCell*)pCell)->GetValue(); +/*?*/ break; +/*?*/ default: +/*?*/ nCellVal = 0.0; +/*N*/ } +/*N*/ +/*N*/ } +/*N*/ else +/*?*/ nCellVal = GetValue( rEntry.nField, nRow ); +/*N*/ switch (rEntry.eOp) +/*N*/ { +/*N*/ case SC_EQUAL : +/*?*/ bOk = ::rtl::math::approxEqual( nCellVal, rEntry.nVal ); +/*?*/ break; +/*?*/ case SC_LESS : +/*?*/ bOk = (nCellVal < rEntry.nVal) && !::rtl::math::approxEqual( nCellVal, rEntry.nVal ); +/*?*/ break; +/*?*/ case SC_GREATER : +/*?*/ bOk = (nCellVal > rEntry.nVal) && !::rtl::math::approxEqual( nCellVal, rEntry.nVal ); +/*?*/ break; +/*?*/ case SC_LESS_EQUAL : +/*N*/ bOk = (nCellVal < rEntry.nVal) || ::rtl::math::approxEqual( nCellVal, rEntry.nVal ); +/*N*/ if ( bOk && pbTestEqualCondition ) +/*N*/ bTestEqual = ::rtl::math::approxEqual( nCellVal, rEntry.nVal ); +/*N*/ break; +/*?*/ case SC_GREATER_EQUAL : +/*?*/ bOk = (nCellVal > rEntry.nVal) || ::rtl::math::approxEqual( nCellVal, rEntry.nVal ); +/*?*/ if ( bOk && pbTestEqualCondition ) +/*?*/ bTestEqual = ::rtl::math::approxEqual( nCellVal, rEntry.nVal ); +/*?*/ break; +/*?*/ case SC_NOT_EQUAL : +/*?*/ bOk = !::rtl::math::approxEqual( nCellVal, rEntry.nVal ); +/*?*/ break; +/*N*/ } +/*N*/ } +/*N*/ else if ( (rEntry.eOp == SC_EQUAL || rEntry.eOp == SC_NOT_EQUAL) +/*N*/ || (rEntry.bQueryByString +/*N*/ && (pCell ? pCell->HasStringData() : HasStringData(rEntry.nField, nRow))) +/*N*/ ) +/*N*/ { // by String +/*N*/ String aCellStr; +/*N*/ if ( pCell ) +/*N*/ { +/*N*/ if (pCell->GetCellType() != CELLTYPE_NOTE) +/*N*/ { +/*N*/ ULONG nFormat = GetNumberFormat( rEntry.nField, nRow ); +/*N*/ ScCellFormat::GetInputString( pCell, nFormat, aCellStr, *(pDocument->GetFormatTable()) ); +/*N*/ } +/*N*/ } +/*N*/ else +/*?*/ GetInputString( rEntry.nField, nRow, aCellStr ); +/*N*/ +/*N*/ BOOL bRealRegExp = (rParam.bRegExp && ((rEntry.eOp == SC_EQUAL) +/*N*/ || (rEntry.eOp == SC_NOT_EQUAL))); +/*N*/ BOOL bTestRegExp = (pbTestEqualCondition && rParam.bRegExp +/*N*/ && ((rEntry.eOp == SC_LESS_EQUAL) +/*N*/ || (rEntry.eOp == SC_GREATER_EQUAL))); +/*N*/ if ( bRealRegExp || bTestRegExp ) +/*N*/ { +/*N*/ xub_StrLen nStart = 0; +/*N*/ xub_StrLen nEnd = aCellStr.Len(); +/*N*/ BOOL bMatch = (BOOL) rEntry.GetSearchTextPtr( rParam.bCaseSens ) +/*N*/ ->SearchFrwrd( aCellStr, &nStart, &nEnd ); +/*N*/ // from 614 on, nEnd is behind the found text +/*N*/ if ( bMatch && bMatchWholeCell +/*N*/ && (nStart != 0 || nEnd != aCellStr.Len()) ) +/*?*/ bMatch = FALSE; // RegExp must match entire cell string +/*N*/ if ( bRealRegExp ) +/*N*/ bOk = ((rEntry.eOp == SC_NOT_EQUAL) ? !bMatch : bMatch); +/*N*/ else +/*?*/ bTestEqual = bMatch; +/*N*/ } +/*N*/ if ( !bRealRegExp ) +/*N*/ { +/*N*/ if ( rEntry.eOp == SC_EQUAL || rEntry.eOp == SC_NOT_EQUAL ) +/*N*/ { +/*N*/ if ( bMatchWholeCell ) +/*N*/ bOk = pTransliteration->isEqual( aCellStr, *rEntry.pStr ); +/*N*/ else +/*N*/ { +/*N*/ ::com::sun::star::uno::Sequence< sal_Int32 > xOff; +/*N*/ String aCell( pTransliteration->transliterate( +/*N*/ aCellStr, ScGlobal::eLnge, 0, aCellStr.Len(), +/*N*/ &xOff ) ); +/*N*/ String aQuer( pTransliteration->transliterate( +/*N*/ *rEntry.pStr, ScGlobal::eLnge, 0, rEntry.pStr->Len(), +/*N*/ &xOff ) ); +/*N*/ bOk = (aCell.Search( aQuer ) != STRING_NOTFOUND); +/*N*/ } +/*N*/ if ( rEntry.eOp == SC_NOT_EQUAL ) +/*?*/ bOk = !bOk; +/*N*/ } +/*N*/ else +/*N*/ { // use collator here because data was probably sorted +/*?*/ sal_Int32 nCompare = pCollator->compareString( +/*?*/ aCellStr, *rEntry.pStr ); +/*?*/ switch (rEntry.eOp) +/*?*/ { +/*?*/ case SC_LESS : +/*?*/ bOk = (nCompare < 0); +/*?*/ break; +/*?*/ case SC_GREATER : +/*?*/ bOk = (nCompare > 0); +/*?*/ break; +/*?*/ case SC_LESS_EQUAL : +/*?*/ bOk = (nCompare <= 0); +/*?*/ if ( bOk && pbTestEqualCondition && !bTestEqual ) +/*?*/ bTestEqual = (nCompare == 0); +/*?*/ break; +/*?*/ case SC_GREATER_EQUAL : +/*?*/ bOk = (nCompare >= 0); +/*?*/ if ( bOk && pbTestEqualCondition && !bTestEqual ) +/*?*/ bTestEqual = (nCompare == 0); +/*?*/ break; +/*?*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if (nPos == -1) +/*N*/ { +/*N*/ nPos++; +/*N*/ pPasst[nPos] = bOk; +/*N*/ pTest[nPos] = bTestEqual; +/*N*/ } +/*N*/ else +/*N*/ { +/*?*/ if (rEntry.eConnect == SC_AND) +/*?*/ { +/*?*/ pPasst[nPos] = pPasst[nPos] && bOk; +/*?*/ pTest[nPos] = pTest[nPos] && bTestEqual; +/*?*/ } +/*?*/ else +/*?*/ { +/*?*/ nPos++; +/*?*/ pPasst[nPos] = bOk; +/*?*/ pTest[nPos] = bTestEqual; +/*?*/ } +/*N*/ } +/*N*/ i++; +/*N*/ } +/*N*/ +/*N*/ for ( i=1; (short)i <= nPos; i++ ) +/*N*/ { +/*?*/ pPasst[0] = pPasst[0] || pPasst[i]; +/*?*/ pTest[0] = pTest[0] || pTest[i]; +/*N*/ } +/*N*/ +/*N*/ BOOL bRet = pPasst[0]; +/*N*/ if ( pPasst != &aBool[0] ) +/*?*/ delete [] pPasst; +/*N*/ if ( pbTestEqualCondition ) +/*N*/ *pbTestEqualCondition = pTest[0]; +/*N*/ if ( pTest != &aTest[0] ) +/*?*/ delete [] pTest; +/*N*/ +/*N*/ return bRet; +/*N*/ } + + + + + +/*N*/ BOOL ScTable::CreateQueryParam(USHORT nCol1, USHORT nRow1, USHORT nCol2, USHORT nRow2, ScQueryParam& rQueryParam) +/*N*/ { +DBG_BF_ASSERT(0, "STRIP"); //STRIP001 //STRIP001 USHORT i, nCount; +return FALSE;//STRIP001 return bValid; +/*N*/ } + + + + + +/*N*/ long ScTable::GetCellCount() const +/*N*/ { +/*N*/ long nCellCount = 0; +/*N*/ +/*N*/ for ( USHORT nCol=0; nCol<=MAXCOL; nCol++ ) +/*N*/ nCellCount += aCol[nCol].GetCellCount(); +/*N*/ +/*N*/ return nCellCount; +/*N*/ } + +/*N*/ long ScTable::GetWeightedCount() const +/*N*/ { +/*N*/ long nCellCount = 0; +/*N*/ +/*N*/ for ( USHORT nCol=0; nCol<=MAXCOL; nCol++ ) +/*N*/ if ( aCol[nCol].GetCellCount() ) // GetCellCount ist inline +/*N*/ nCellCount += aCol[nCol].GetWeightedCount(); +/*N*/ +/*N*/ return nCellCount; +/*N*/ } + +/*N*/ void ScTable::UpdateSelectionFunction( ScFunctionData& rData, +/*N*/ USHORT nStartCol, USHORT nStartRow, USHORT nEndCol, USHORT nEndRow, +/*N*/ const ScMarkData& rMark ) +/*N*/ { +/*N*/ // Cursor neben einer Markierung nicht beruecksichtigen: +/*N*/ //! nur noch MarkData uebergeben, Cursorposition ggf. hineinselektieren!!! +/*N*/ BOOL bSingle = ( rMark.IsMarked() || !rMark.IsMultiMarked() ); +/*N*/ +/*N*/ // Mehrfachselektion: +/*N*/ +/*N*/ USHORT nCol; +/*N*/ if ( rMark.IsMultiMarked() ) +/*N*/ for (nCol=0; nCol<=MAXCOL && !rData.bError; nCol++) +/*N*/ if ( !pColFlags || !( pColFlags[nCol] & CR_HIDDEN ) ) +/*N*/ aCol[nCol].UpdateSelectionFunction( rMark, rData, pRowFlags, +/*N*/ bSingle && ( nCol >= nStartCol && nCol <= nEndCol ), +/*N*/ nStartRow, nEndRow ); +/*N*/ +/*N*/ // Einfachselektion (oder Cursor) nur wenn nicht negativ (und s.o.): +/*N*/ +/*N*/ if ( bSingle && !rMark.IsMarkNegative() ) +/*N*/ for (nCol=nStartCol; nCol<=nEndCol && !rData.bError; nCol++) +/*N*/ if ( !pColFlags || !( pColFlags[nCol] & CR_HIDDEN ) ) +/*N*/ aCol[nCol].UpdateAreaFunction( rData, pRowFlags, nStartRow, nEndRow ); +/*N*/ } + +/*N*/ void ScTable::FindConditionalFormat( ULONG nKey, ScRangeList& rList ) +/*N*/ { +/*N*/ USHORT nStartRow, nEndRow; +/*N*/ for (USHORT nCol=0; nCol<=MAXCOL; nCol++) +/*N*/ { +/*N*/ ScAttrIterator* pIter = aCol[nCol].CreateAttrIterator( 0, MAXCOL ); +/*N*/ const ScPatternAttr* pPattern = pIter->Next( nStartRow, nEndRow ); +/*N*/ while (pPattern) +/*N*/ { +/*N*/ if (((SfxUInt32Item&)pPattern->GetItem(ATTR_CONDITIONAL)).GetValue() == nKey) +/*N*/ rList.Join( ScRange(nCol,nStartRow,nTab, nCol,nEndRow,nTab) ); +/*N*/ pPattern = pIter->Next( nStartRow, nEndRow ); +/*N*/ } +/*N*/ delete pIter; +/*N*/ } +/*N*/ } + + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_table4.cxx b/binfilter/bf_sc/source/core/data/sc_table4.cxx new file mode 100644 index 000000000000..73b184ba5e4c --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_table4.cxx @@ -0,0 +1,116 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#ifdef _MSC_VER +#pragma optimize("",off) +#endif + // sonst Absturz Win beim Fuellen + +#include "scitems.hxx" + +#include "globstr.hrc" +#include "document.hxx" +#include "autoform.hxx" +namespace binfilter { + +// STATIC DATA ----------------------------------------------------------- + +#define _D_MAX_LONG_ (double) 0x7fffffff + +extern USHORT nScFillModeMouseModifier; // global.cxx + +// ----------------------------------------------------------------------- + + + + + + + + + + + + + + +#define LF_LEFT 1 +#define LF_TOP 2 +#define LF_RIGHT 4 +#define LF_BOTTOM 8 +#define LF_ALL (LF_LEFT | LF_TOP | LF_RIGHT | LF_BOTTOM) + + + +/*N*/ void ScTable::SetError( USHORT nCol, USHORT nRow, USHORT nError) +/*N*/ { +/*N*/ if (ValidColRow(nCol, nRow)) +/*N*/ aCol[nCol].SetError( nRow, nError ); +/*N*/ } + + + + + +/*N*/ BOOL ScTable::TestTabRefAbs(USHORT nTable) +/*N*/ { +/*N*/ BOOL bRet = FALSE; +/*N*/ for (USHORT i=0; i <= MAXCOL; i++) +/*N*/ if (aCol[i].TestTabRefAbs(nTable)) +/*N*/ bRet = TRUE; +/*N*/ return bRet; +/*N*/ } + + +/*N*/ void ScTable::CompileDBFormula( BOOL bCreateFormulaString ) +/*N*/ { +/*N*/ for (USHORT i=0; i<=MAXCOL; i++) aCol[i].CompileDBFormula( bCreateFormulaString ); +/*N*/ } + +/*N*/ void ScTable::CompileNameFormula( BOOL bCreateFormulaString ) +/*N*/ { +/*N*/ for (USHORT i=0; i<=MAXCOL; i++) aCol[i].CompileNameFormula( bCreateFormulaString ); +/*N*/ } + +/*N*/ void ScTable::CompileColRowNameFormula() +/*N*/ { +/*N*/ for (USHORT i=0; i<=MAXCOL; i++) aCol[i].CompileColRowNameFormula(); +/*N*/ } + + + + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_table5.cxx b/binfilter/bf_sc/source/core/data/sc_table5.cxx new file mode 100644 index 000000000000..44da94034ecb --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_table5.cxx @@ -0,0 +1,369 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "scitems.hxx" +#include "attrib.hxx" +#include "patattr.hxx" +#include "cell.hxx" +#include "document.hxx" +#include "stlpool.hxx" +#include "globstr.hrc" +namespace binfilter { + +// STATIC DATA ----------------------------------------------------------- + +#define GET_SCALEVALUE(set,id) ((const SfxUInt16Item&)(set.Get( id ))).GetValue() + + +/*N*/ void ScTable::UpdatePageBreaks( const ScRange* pUserArea ) +/*N*/ { +/*N*/ if ( pDocument->IsImportingXML() ) +/*N*/ return; +/*N*/ if ( !pUserArea && !bPageSizeValid ) +/*N*/ return; +/*N*/ +/*N*/ SfxStyleSheetBase* pStyle = pDocument->GetStyleSheetPool()-> +/*N*/ Find( aPageStyle, SFX_STYLE_FAMILY_PAGE ); +/*N*/ if ( !pStyle ) +/*N*/ { +/*N*/ DBG_ERROR("UpdatePageBreaks: Style nicht gefunden"); +/*N*/ return; +/*N*/ } +/*N*/ SfxItemSet* pStyleSet = &pStyle->GetItemSet(); +/*N*/ const SfxPoolItem* pItem; +/*N*/ +/*N*/ USHORT i; +/*N*/ USHORT nX; +/*N*/ USHORT nY; +/*N*/ USHORT nStartCol = 0; +/*N*/ USHORT nStartRow = 0; +/*N*/ USHORT nEndCol = MAXCOL; +/*N*/ USHORT nEndRow = MAXROW; +/*N*/ if (pUserArea) +/*N*/ { +/*N*/ nStartCol = pUserArea->aStart.Col(); +/*N*/ nStartRow = pUserArea->aStart.Row(); +/*N*/ nEndCol = pUserArea->aEnd.Col(); +/*N*/ nEndRow = pUserArea->aEnd.Row(); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ USHORT nAreaCount = GetPrintRangeCount(); +/*N*/ if ( nAreaCount > 1 ) +/*N*/ { +/*N*/ // bei mehreren Bereichen nichts anzeigen: +/*N*/ +/*N*/ for (nX=0; nX<MAXCOL; nX++) +/*N*/ pColFlags[nX] &= ~CR_PAGEBREAK; +/*N*/ for (nY=0; nY<MAXROW; nY++) +/*N*/ pRowFlags[nY] &= ~CR_PAGEBREAK; +/*N*/ +/*N*/ return; +/*N*/ } +/*N*/ else if ( nAreaCount == 1 ) +/*N*/ { +/*N*/ const ScRange* pArea = GetPrintRange( 0 ); +/*N*/ if (pArea) +/*N*/ { +/*N*/ nStartCol = pArea->aStart.Col(); +/*N*/ nStartRow = pArea->aStart.Row(); +/*N*/ nEndCol = pArea->aEnd.Col(); +/*N*/ nEndRow = pArea->aEnd.Row(); +/*N*/ } +/*N*/ } // sonst alles +/*N*/ } +/*N*/ +/*N*/ // bSkipBreaks holen: +/*N*/ +/*N*/ BOOL bSkipBreaks = FALSE; +/*N*/ +/*N*/ if ( pStyleSet->GetItemState( ATTR_PAGE_SCALETOPAGES, FALSE, &pItem ) == SFX_ITEM_SET ) +/*N*/ { +/*N*/ DBG_ASSERT( pItem->ISA(SfxUInt16Item), "falsches Item" ); +/*N*/ bSkipBreaks = ( ((const SfxUInt16Item*)pItem)->GetValue() > 0 ); +/*N*/ } +/*N*/ +/*N*/ //-------------------------------------------------------------------------- +/*N*/ +/*N*/ long nPageSizeX = aPageSizeTwips.Width(); +/*N*/ long nPageSizeY = aPageSizeTwips.Height(); +/*N*/ +/*N*/ // Anfang: Breaks loeschen +/*N*/ +/*N*/ for (nX=0; nX<nStartCol; nX++) +/*N*/ pColFlags[nX] &= ~CR_PAGEBREAK; +/*N*/ for (nY=0; nY<nStartRow; nY++) +/*N*/ pRowFlags[nY] &= ~CR_PAGEBREAK; +/*N*/ +/*N*/ if (nStartCol) +/*N*/ pColFlags[nStartCol] |= CR_PAGEBREAK; //! AREABREAK +/*N*/ if (nStartRow) +/*N*/ pRowFlags[nStartRow] |= CR_PAGEBREAK; //! AREABREAK +/*N*/ +/*N*/ // Mittelteil: Breaks verteilen +/*N*/ +/*N*/ BOOL bRepeatCol = ( nRepeatStartX != REPEAT_NONE ); +/*N*/ BOOL bColFound = FALSE; +/*N*/ long nSizeX = 0; +/*N*/ for (nX=nStartCol; nX<=nEndCol; nX++) +/*N*/ { +/*N*/ BOOL bStartOfPage = FALSE; +/*N*/ long nThisX = ( pColFlags[nX] & CR_HIDDEN ) ? 0 : pColWidth[nX]; +/*N*/ if ( (nSizeX+nThisX > nPageSizeX) || ((pColFlags[nX] & CR_MANUALBREAK) && !bSkipBreaks) ) +/*N*/ { +/*N*/ pColFlags[nX] |= CR_PAGEBREAK; +/*N*/ nSizeX = 0; +/*N*/ bStartOfPage = TRUE; +/*N*/ } +/*N*/ else if (nX != nStartCol) +/*N*/ pColFlags[nX] &= ~CR_PAGEBREAK; +/*N*/ else +/*N*/ bStartOfPage = TRUE; +/*N*/ +/*N*/ if ( bStartOfPage && bRepeatCol && nX>nRepeatStartX && !bColFound ) +/*N*/ { +/*N*/ // subtract size of repeat columns from page size +/*N*/ for (i=nRepeatStartX; i<=nRepeatEndX; i++) +/*N*/ nPageSizeX -= ( pColFlags[i] & CR_HIDDEN ) ? 0 : pColWidth[i]; +/*N*/ while (nX<=nRepeatEndX) +/*N*/ pColFlags[++nX] &= ~CR_PAGEBREAK; +/*N*/ bColFound = TRUE; +/*N*/ } +/*N*/ +/*N*/ nSizeX += nThisX; +/*N*/ } +/*N*/ +/*N*/ BOOL bRepeatRow = ( nRepeatStartY != REPEAT_NONE ); +/*N*/ BOOL bRowFound = FALSE; +/*N*/ long nSizeY = 0; +/*N*/ for (nY=nStartRow; nY<=nEndRow; nY++) +/*N*/ { +/*N*/ BOOL bStartOfPage = FALSE; +/*N*/ long nThisY = ( pRowFlags[nY] & CR_HIDDEN ) ? 0 : pRowHeight[nY]; +/*N*/ if ( (nSizeY+nThisY > nPageSizeY) || ((pRowFlags[nY] & CR_MANUALBREAK) && !bSkipBreaks) ) +/*N*/ { +/*N*/ pRowFlags[nY] |= CR_PAGEBREAK; +/*N*/ nSizeY = 0; +/*N*/ bStartOfPage = TRUE; +/*N*/ } +/*N*/ else if (nY != nStartRow) +/*N*/ pRowFlags[nY] &= ~CR_PAGEBREAK; +/*N*/ else +/*N*/ bStartOfPage = TRUE; +/*N*/ +/*N*/ if ( bStartOfPage && bRepeatRow && nY>nRepeatStartY && !bRowFound ) +/*N*/ { +/*?*/ // subtract size of repeat rows from page size +/*?*/ for (i=nRepeatStartY; i<=nRepeatEndY; i++) +/*?*/ nPageSizeY -= ( pRowFlags[i] & CR_HIDDEN ) ? 0 : pRowHeight[i]; +/*?*/ while (nY<=nRepeatEndY) +/*?*/ pRowFlags[++nY] &= ~CR_PAGEBREAK; +/*?*/ bRowFound = TRUE; +/*N*/ } +/*N*/ +/*N*/ nSizeY += nThisY; +/*N*/ } +/*N*/ +/*N*/ // Ende: Breaks loeschen +/*N*/ +/*N*/ if (nEndCol < MAXCOL) +/*N*/ { +/*N*/ pColFlags[nEndCol+1] |= CR_PAGEBREAK; //! AREABREAK +/*N*/ for (nX=nEndCol+2; nX<=MAXCOL; nX++) +/*N*/ pColFlags[nX] &= ~CR_PAGEBREAK; +/*N*/ } +/*N*/ if (nEndRow < MAXROW) +/*N*/ { +/*N*/ pRowFlags[nEndRow+1] |= CR_PAGEBREAK; //! AREABREAK +/*N*/ for (nY=nEndRow+2; nY<=MAXROW; nY++) +/*N*/ pRowFlags[nY] &= ~CR_PAGEBREAK; +/*N*/ } +/*N*/ } + +/*N*/ void ScTable::RemoveManualBreaks() +/*N*/ { +/*N*/ if (pColFlags) +/*N*/ for (USHORT nCol = 0; nCol <= MAXCOL; nCol++) +/*N*/ pColFlags[nCol] &= ~CR_MANUALBREAK; +/*N*/ +/*N*/ if (pRowFlags) +/*N*/ for (USHORT nRow = 0; nRow <= MAXROW; nRow++) +/*N*/ pRowFlags[nRow] &= ~CR_MANUALBREAK; +/*N*/ } + + +/*N*/ void ScTable::SetPageSize( const Size& rSize ) +/*N*/ { +/*N*/ if ( rSize.Width() != 0 && rSize.Height() != 0 ) +/*N*/ { +/*N*/ bPageSizeValid = TRUE; +/*N*/ aPageSizeTwips = rSize; +/*N*/ } +/*N*/ else +/*N*/ bPageSizeValid = FALSE; +/*N*/ } + +/*N*/ Size ScTable::GetPageSize() const +/*N*/ { +/*N*/ if ( bPageSizeValid ) +/*N*/ return aPageSizeTwips; +/*N*/ else +/*N*/ return Size(); // leer +/*N*/ } + +/*N*/ void ScTable::SetRepeatArea( USHORT nStartCol, USHORT nEndCol, USHORT nStartRow, USHORT nEndRow ) +/*N*/ { +/*N*/ nRepeatStartX = nStartCol; +/*N*/ nRepeatEndX = nEndCol; +/*N*/ nRepeatStartY = nStartRow; +/*N*/ nRepeatEndY = nEndRow; +/*N*/ } + +/*N*/ void ScTable::StartListening( const ScAddress& rAddress, SfxListener* pListener ) +/*N*/ { +/*N*/ aCol[rAddress.Col()].StartListening( *pListener, rAddress.Row() ); +/*N*/ } + +/*N*/ void ScTable::EndListening( const ScAddress& rAddress, SfxListener* pListener ) +/*N*/ { +/*N*/ aCol[rAddress.Col()].EndListening( *pListener, rAddress.Row() ); +/*N*/ } + +/*N*/ void ScTable::SetPageStyle( const String& rName ) +/*N*/ { +/*N*/ if ( aPageStyle != rName ) +/*N*/ { +/*N*/ String aStrNew = rName; +/*N*/ SfxStyleSheetBasePool* pStylePool = pDocument->GetStyleSheetPool(); +/*N*/ SfxStyleSheetBase* pNewStyle = pStylePool->Find( aStrNew, SFX_STYLE_FAMILY_PAGE ); +/*N*/ +/*N*/ if ( !pNewStyle ) +/*N*/ { +/*?*/ aStrNew = ScGlobal::GetRscString(STR_STYLENAME_STANDARD); +/*?*/ pNewStyle = pStylePool->Find( aStrNew, SFX_STYLE_FAMILY_PAGE ); +/*N*/ } +/*N*/ +/*N*/ if ( aPageStyle != aStrNew ) +/*N*/ { +/*N*/ SfxStyleSheetBase* pOldStyle = pStylePool->Find( aPageStyle, SFX_STYLE_FAMILY_PAGE ); +/*N*/ +/*N*/ if ( pOldStyle && pNewStyle ) +/*N*/ { +/*N*/ SfxItemSet& rOldSet = pOldStyle->GetItemSet(); +/*N*/ SfxItemSet& rNewSet = pNewStyle->GetItemSet(); +/*N*/ const USHORT nOldScale = GET_SCALEVALUE(rOldSet,ATTR_PAGE_SCALE); +/*N*/ const USHORT nOldScaleToPages = GET_SCALEVALUE(rOldSet,ATTR_PAGE_SCALETOPAGES); +/*N*/ const USHORT nNewScale = GET_SCALEVALUE(rNewSet,ATTR_PAGE_SCALE); +/*N*/ const USHORT nNewScaleToPages = GET_SCALEVALUE(rNewSet,ATTR_PAGE_SCALETOPAGES); +/*N*/ +/*N*/ if ( (nOldScale != nNewScale) || (nOldScaleToPages != nNewScaleToPages) ) +/*N*/ InvalidateTextWidth(); +/*N*/ } +/*N*/ +/*N*/ if ( pNewStyle ) // auch ohne den alten (fuer UpdateStdNames) +/*N*/ aPageStyle = aStrNew; +/*N*/ } +/*N*/ } +/*N*/ } + + +/*N*/ void ScTable::InvalidateTextWidth( const ScAddress* pAdrFrom, +/*N*/ const ScAddress* pAdrTo, +/*N*/ BOOL bBroadcast ) +/*N*/ { +/*N*/ if ( pAdrFrom && !pAdrTo ) +/*N*/ { +/*?*/ ScBaseCell* pCell = aCol[pAdrFrom->Col()].GetCell( pAdrFrom->Row() ); +/*?*/ if ( pCell ) +/*?*/ { +/*?*/ pCell->SetTextWidth( TEXTWIDTH_DIRTY ); +/*?*/ pCell->SetScriptType( SC_SCRIPTTYPE_UNKNOWN ); +/*?*/ if ( bBroadcast ) +/*?*/ { // nur bei CalcAsShown +/*?*/ switch ( pCell->GetCellType() ) +/*?*/ { +/*?*/ case CELLTYPE_VALUE : +/*?*/ pDocument->Broadcast( SC_HINT_DATACHANGED, +/*?*/ ScAddress( pAdrFrom->Col(), pAdrFrom->Row(), nTab ), +/*?*/ pCell ); +/*?*/ break; +/*?*/ case CELLTYPE_FORMULA : +/*?*/ ((ScFormulaCell*)pCell)->SetDirty(); +/*?*/ break; +/*?*/ } +/*?*/ } +/*?*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ const USHORT nColStart = pAdrFrom ? pAdrFrom->Col() : 0; +/*N*/ const USHORT nRowStart = pAdrFrom ? pAdrFrom->Row() : 0; +/*N*/ const USHORT nColEnd = pAdrTo ? pAdrTo->Col() : MAXCOL; +/*N*/ const USHORT nRowEnd = pAdrTo ? pAdrTo->Row() : MAXROW; +/*N*/ +/*N*/ for ( USHORT nCol=nColStart; nCol<=nColEnd; nCol++ ) +/*N*/ { +/*N*/ ScColumnIterator aIter( &aCol[nCol], nRowStart, nRowEnd ); +/*N*/ ScBaseCell* pCell = NULL; +/*N*/ USHORT nRow = nRowStart; +/*N*/ +/*N*/ while ( aIter.Next( nRow, pCell ) ) +/*N*/ { +/*N*/ pCell->SetTextWidth( TEXTWIDTH_DIRTY ); +/*N*/ pCell->SetScriptType( SC_SCRIPTTYPE_UNKNOWN ); +/*N*/ if ( bBroadcast ) +/*N*/ { // nur bei CalcAsShown +/*?*/ switch ( pCell->GetCellType() ) +/*?*/ { +/*?*/ case CELLTYPE_VALUE : +/*?*/ pDocument->Broadcast( SC_HINT_DATACHANGED, +/*?*/ ScAddress( nCol, nRow, nTab ), pCell ); +/*?*/ break; +/*?*/ case CELLTYPE_FORMULA : +/*?*/ ((ScFormulaCell*)pCell)->SetDirty(); +/*?*/ break; +/*?*/ } +/*?*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } + + + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_userdat.cxx b/binfilter/bf_sc/source/core/data/sc_userdat.cxx new file mode 100644 index 000000000000..a9fa6b06c9fd --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_userdat.cxx @@ -0,0 +1,723 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +//------------------------------------------------------------------------ + +// TOOLS +#define _BIGINT_HXX +#define _SFXMULTISEL_HXX +#define _STACK_HXX +#define _QUEUE_HXX +#define _DYNARR_HXX +#define _TREELIST_HXX +#define _CACHESTR_HXX +#define _NEW_HXX +//#define _SHL_HXX +//#define _LINK_HXX +//#define _ERRCODE_HXX +//#define _GEN_HXX +//#define _FRACT_HXX +//#define _STRING_HXX +//#define _MTF_HXX +//#define _CONTNR_HXX +//#define _LIST_HXX +//#define _TABLE_HXX +#define _DYNARY_HXX +//#define _UNQIDX_HXX +#define _SVMEMPOOL_HXX +//#define _UNQID_HXX +//#define _DEBUG_HXX +//#define _DATE_HXX +//#define _TIME_HXX +//#define _DATETIME_HXX +//#define _INTN_HXX +//#define _WLDCRD_HXX +//#define _FSYS_HXX +//#define _STREAM_HXX +#define _SV_MULTISEL_HXX + +//SV +//#define _CLIP_HXX *** +#define _CONFIG_HXX +#define _CURSOR_HXX +#define _FONTDLG_HXX +#define _PRVWIN_HXX +//#define _COLOR_HXX +//#define _PAL_HXX +//#define _BITMAP_HXX +//#define _GDIOBJ_HXX +//#define _POINTR_HXX +//#define _ICON_HXX +//#define _IMAGE_HXX +//#define _KEYCOD_HXX +//#define _EVENT_HXX +#define _HELP_HXX +//#define _APP_HXX +//#define _MDIAPP_HXX +//#define _TIMER_HXX +//#define _METRIC_HXX +//#define _REGION_HXX +//#define _OUTDEV_HXX +//#define _SYSTEM_HXX +//#define _VIRDEV_HXX +//#define _JOBSET_HXX +//#define _PRINT_HXX +//#define _WINDOW_HXX +//#define _SYSWIN_HXX +//#define _WRKWIN_HXX +#define _MDIWIN_HXX +//#define _FLOATWIN_HXX +//#define _DOCKWIN_HXX +//#define _CTRL_HXX +//#define _SCRBAR_HXX +//#define _BUTTON_HXX +//#define _IMAGEBTN_HXX +//#define _FIXED_HXX +//#define _GROUP_HXX +//#define _EDIT_HXX +//#define _COMBOBOX_HXX +//#define _LSTBOX_HXX +//#define _SELENG_HXX *** +//#define _SPLIT_HXX +#define _SPIN_HXX +//#define _FIELD_HXX +//#define _MOREBTN_HXX *** +//#define _TOOLBOX_HXX +//#define _STATUS_HXX *** +//#define _DIALOG_HXX +//#define _MSGBOX_HXX +//#define _SYSDLG_HXX +#define _FILDLG_HXX +//#define _PRNDLG_HXX +#define _COLDLG_HXX +//#define _TABDLG_HXX +//#define _MENU_HXX +//#define _GDIMTF_HXX +//#define _POLY_HXX +//#define _ACCEL_HXX +//#define _GRAPH_HXX +#define _SOUND_HXX + +#if defined WIN +#define _MENUBTN_HXX +#endif + +//svtools +#define _SCRWIN_HXX +#define _RULER_HXX +//#define _TABBAR_HXX +//#define _VALUESET_HXX +#define _STDMENU_HXX +//#define _STDCTRL_HXX +//#define _CTRLBOX_HXX +#define _CTRLTOOL_HXX +#define _EXTATTR_HXX +#define _FRM3D_HXX +#define _EXTATTR_HXX + +//SVTOOLS +//#define _SVTREELIST_HXX *** +#define _FILTER_HXX +//#define _SVLBOXITM_HXX *** +//#define _SVTREEBOX_HXX *** +#define _SVICNVW_HXX +#define _SVTABBX_HXX + +//sfxcore.hxx +//#define _SFXINIMGR_HXX *** +//#define _SFXCFGITEM_HXX +//#define _SFX_PRINTER_HXX +#define _SFXGENLINK_HXX +#define _SFXHINTPOST_HXX +#define _SFXDOCINF_HXX +#define _SFXLINKHDL_HXX +//#define _SFX_PROGRESS_HXX + +//sfxsh.hxx +//#define _SFX_SHELL_HXX +//#define _SFXAPP_HXX +//#define _SFXDISPATCH_HXX +//#define _SFXMSG_HXX *** +//#define _SFXOBJFACE_HXX *** +//#define _SFXREQUEST_HXX +#define _SFXMACRO_HXX + +// SFX +//#define _SFXAPPWIN_HXX *** +#define _SFX_SAVEOPT_HXX +//#define _SFX_CHILDWIN_HXX +//#define _SFXCTRLITEM_HXX +#define _SFXPRNMON_HXX +#define _INTRO_HXX +#define _SFXMSGDESCR_HXX +#define _SFXMSGPOOL_HXX +#define _SFXFILEDLG_HXX +#define _PASSWD_HXX +#define _SFXTBXCTRL_HXX +#define _SFXSTBITEM_HXX +#define _SFXMNUITEM_HXX +#define _SFXIMGMGR_HXX +#define _SFXTBXMGR_HXX +#define _SFXSTBMGR_HXX +#define _SFX_MINFITEM_HXX +#define _SFXEVENT_HXX + +//sfxdoc.hxx +//#define _SFX_OBJSH_HXX +//#define _SFX_CLIENTSH_HXX +//#define _SFXDOCINF_HXX +//#define _SFX_OBJFAC_HXX +#define _SFX_DOCFILT_HXX +//#define _SFXDOCFILE_HXX *** +//define _VIEWFAC_HXX +//#define _SFXVIEWFRM_HXX +//#define _SFXVIEWSH_HXX +//#define _MDIFRM_HXX *** +#define _SFX_IPFRM_HXX +//#define _SFX_INTERNO_HXX + +//sfxdlg.hxx +//#define _SFXTABDLG_HXX +//#define _BASEDLGS_HXX *** +#define _SFX_DINFDLG_HXX +#define _SFXDINFEDT_HXX +#define _SFX_MGETEMPL_HXX +#define _SFX_TPLPITEM_HXX +//#define _SFX_STYLEDLG_HXX +#define _NEWSTYLE_HXX +//#define _SFXDOCTEMPL_HXX *** +//#define _SFXDOCTDLG_HXX *** +//#define _SFX_TEMPLDLG_HXX *** +//#define _SFXNEW_HXX *** +#define _SFXDOCMAN_HXX +//#define _SFXDOCKWIN_HXX + +//sfxitems.hxx +#define _SFX_WHMAP_HXX +#define _ARGS_HXX +//#define _SFXPOOLITEM_HXX +//#define _SFXINTITEM_HXX +//#define _SFXENUMITEM_HXX +#define _SFXFLAGITEM_HXX +//#define _SFXSTRITEM_HXX +#define _SFXPTITEM_HXX +#define _SFXRECTITEM_HXX +//#define _SFXITEMPOOL_HXX +//#define _SFXITEMSET_HXX +#define _SFXITEMITER_HXX +#define _SFX_WHITER_HXX +#define _SFXPOOLCACH_HXX +//#define _AEITEM_HXX +#define _SFXRNGITEM_HXX +//#define _SFXSLSTITM_HXX +//#define _SFXSTYLE_HXX + +//xout.hxx +//#define _XENUM_HXX +//#define _XPOLY_HXX +//#define _XATTR_HXX +//#define _XOUTX_HXX +//#define _XPOOL_HXX +//#define _XTABLE_HXX + +//svdraw.hxx +#define _SDR_NOITEMS +#define _SDR_NOTOUCH +#define _SDR_NOTRANSFORM +//#define _SDR_NOOBJECTS +//#define _SDR_NOVIEWS + +//#define SI_NOITEMS +//#define SI_NODRW +#define _SI_NOSBXCONTROLS +//#define _VCATTR_HXX +#define _VCONT_HXX +//#define _VCSBX_HXX +#define _SI_NOOTHERFORMS +#define _VCTRLS_HXX +//#define _VCDRWOBJ_HXX +#define _SI_NOCONTROL +#define _SETBRW_HXX +#define _VCBRW_HXX +#define _SI_NOSBXCONTROLS +//#define _SIDLL_HXX *** + +#define _SVX_DAILDLL_HXX +#define _SVX_HYPHEN_HXX +#define _SVX_IMPGRF_HXX +#define _SVX_OPTITEMS_HXX +#define _SVX_OPTGERL_HXX +#define _SVX_OPTSAVE_HXX +#define _SVX_OPTSPELL_HXX +#define _SVX_OPTPATH_HXX +#define _SVX_OPTLINGU_HXX +#define _SVX_RULER_HXX +#define _SVX_RULRITEM_HXX +#define _SVX_SPLWRAP_HXX +#define _SVX_SPLDLG_HXX +#define _SVX_THESDLG_HXX + +// neu +#define _BIGINT_HXX +#define _SFXMULTISEL_HXX +#define _STACK_HXX +#define _QUEUE_HXX +#define _DYNARR_HXX +#define _TREELIST_HXX +#define _CACHESTR_HXX +#define _NEW_HXX +//#define _SHL_HXX +//#define _LINK_HXX +//#define _ERRCODE_HXX +//#define _GEN_HXX +//#define _FRACT_HXX +//#define _STRING_HXX +//#define _MTF_HXX +//#define _CONTNR_HXX +//#define _LIST_HXX +//#define _TABLE_HXX +#define _DYNARY_HXX +//#define _UNQIDX_HXX +#define _SVMEMPOOL_HXX +//#define _UNQID_HXX +//#define _DEBUG_HXX +//#define _DATE_HXX +//#define _TIME_HXX +//#define _DATETIME_HXX +//#define _INTN_HXX +//#define _WLDCRD_HXX +//#define _FSYS_HXX +//#define _STREAM_HXX +#define _CACHESTR_HXX +#define _SV_MULTISEL_HXX + +//SV +//#define _CLIP_HXX *** +#define _CONFIG_HXX +#define _CURSOR_HXX +#define _FONTDLG_HXX +#define _PRVWIN_HXX +//#define _COLOR_HXX +//#define _PAL_HXX +//#define _BITMAP_HXX +//#define _GDIOBJ_HXX +//#define _POINTR_HXX +//#define _ICON_HXX +//#define _IMAGE_HXX +//#define _KEYCOD_HXX +//#define _EVENT_HXX +#define _HELP_HXX +//#define _APP_HXX +//#define _MDIAPP_HXX +//#define _TIMER_HXX +//#define _METRIC_HXX +//#define _REGION_HXX +//#define _OUTDEV_HXX +//#define _SYSTEM_HXX +//#define _VIRDEV_HXX +//#define _JOBSET_HXX +//#define _PRINT_HXX +//#define _WINDOW_HXX +//#define _SYSWIN_HXX +//#define _WRKWIN_HXX +#define _MDIWIN_HXX +//#define _FLOATWIN_HXX +//#define _DOCKWIN_HXX +//#define _CTRL_HXX +//#define _SCRBAR_HXX +//#define _BUTTON_HXX +//#define _IMAGEBTN_HXX +//#define _FIXED_HXX +//#define _GROUP_HXX +//#define _EDIT_HXX +//#define _COMBOBOX_HXX +//#define _LSTBOX_HXX +//#define _SELENG_HXX *** +//#define _SPLIT_HXX +#define _SPIN_HXX +//#define _FIELD_HXX +//#define _MOREBTN_HXX *** +//#define _TOOLBOX_HXX +//#define _STATUS_HXX *** +//#define _DIALOG_HXX +//#define _MSGBOX_HXX +//#define _SYSDLG_HXX +#define _FILDLG_HXX +//#define _PRNDLG_HXX +#define _COLDLG_HXX +//#define _TABDLG_HXX +//#define _MENU_HXX *** +//#define _GDIMTF_HXX +//#define _POLY_HXX +//#define _ACCEL_HXX +//#define _GRAPH_HXX +#define _SOUND_HXX + + + + + +#define _BIGINT_HXX +#define _SFXMULTISEL_HXX +#define _STACK_HXX +#define _QUEUE_HXX +#define _DYNARR_HXX +#define _TREELIST_HXX +#define _CACHESTR_HXX +#define _NEW_HXX +//#define _SHL_HXX +//#define _LINK_HXX +//#define _ERRCODE_HXX +//#define _GEN_HXX +//#define _FRACT_HXX +//#define _STRING_HXX +//#define _MTF_HXX +//#define _CONTNR_HXX +//#define _LIST_HXX +//#define _TABLE_HXX +#define _DYNARY_HXX +//#define _UNQIDX_HXX +#define _SVMEMPOOL_HXX +//#define _UNQID_HXX +//#define _DEBUG_HXX +//#define _DATE_HXX +//#define _TIME_HXX +//#define _DATETIME_HXX +//#define _INTN_HXX +//#define _WLDCRD_HXX +//#define _FSYS_HXX +//#define _STREAM_HXX +#define _CACHESTR_HXX +#define _SV_MULTISEL_HXX + +//SV +//#define _CLIP_HXX *** +#define _CONFIG_HXX +#define _CURSOR_HXX +#define _FONTDLG_HXX +#define _PRVWIN_HXX +//#define _COLOR_HXX +//#define _PAL_HXX +//#define _BITMAP_HXX +//#define _GDIOBJ_HXX +//#define _POINTR_HXX +//#define _ICON_HXX +//#define _IMAGE_HXX +//#define _KEYCOD_HXX +//#define _EVENT_HXX +#define _HELP_HXX +//#define _APP_HXX +//#define _MDIAPP_HXX +//#define _TIMER_HXX +//#define _METRIC_HXX +//#define _REGION_HXX +//#define _OUTDEV_HXX +//#define _SYSTEM_HXX +//#define _VIRDEV_HXX +//#define _JOBSET_HXX +//#define _PRINT_HXX +//#define _WINDOW_HXX +//#define _SYSWIN_HXX +//#define _WRKWIN_HXX +#define _MDIWIN_HXX +//#define _FLOATWIN_HXX +//#define _DOCKWIN_HXX +//#define _CTRL_HXX +//#define _SCRBAR_HXX +//#define _BUTTON_HXX +//#define _IMAGEBTN_HXX +//#define _FIXED_HXX +//#define _GROUP_HXX +//#define _EDIT_HXX +//#define _COMBOBOX_HXX +//#define _LSTBOX_HXX +//#define _SELENG_HXX *** +//#define _SPLIT_HXX +#define _SPIN_HXX +//#define _FIELD_HXX +//#define _MOREBTN_HXX *** +//#define _TOOLBOX_HXX +//#define _STATUS_HXX *** +//#define _DIALOG_HXX +//#define _MSGBOX_HXX +//#define _SYSDLG_HXX +//#define _FILDLG_HXX +//#define _PRNDLG_HXX +#define _COLDLG_HXX +//#define _TABDLG_HXX +//#define _MENU_HXX +//#define _GDIMTF_HXX +//#define _POLY_HXX +//#define _ACCEL_HXX +//#define _GRAPH_HXX +#define _SOUND_HXX + +#if defined WIN +#define _MENUBTN_HXX +#endif + +//svtools +#define _SCRWIN_HXX +#define _RULER_HXX +//#define _TABBAR_HXX +//#define _VALUESET_HXX +#define _STDMENU_HXX +//#define _STDCTRL_HXX +//#define _CTRLBOX_HXX +#define _CTRLTOOL_HXX +#define _EXTATTR_HXX +#define _FRM3D_HXX +#define _EXTATTR_HXX + +//SVTOOLS +//#define _SVTREELIST_HXX *** +#define _FILTER_HXX +//#define _SVLBOXITM_HXX *** +//#define _SVTREEBOX_HXX *** +#define _SVICNVW_HXX +#define _SVTABBX_HXX + +//sfxcore.hxx +//#define _SFXINIMGR_HXX *** +//#define _SFXCFGITEM_HXX +//#define _SFX_PRINTER_HXX +#define _SFXGENLINK_HXX +#define _SFXHINTPOST_HXX +#define _SFXDOCINF_HXX +#define _SFXLINKHDL_HXX +//#define _SFX_PROGRESS_HXX + +//sfxsh.hxx +//#define _SFX_SHELL_HXX +//#define _SFXAPP_HXX +//#define _SFXDISPATCH_HXX +//#define _SFXMSG_HXX *** +//#define _SFXOBJFACE_HXX *** +//#define _SFXREQUEST_HXX +#define _SFXMACRO_HXX + +// SFX +//#define _SFXAPPWIN_HXX *** +#define _SFX_SAVEOPT_HXX +//#define _SFX_CHILDWIN_HXX +//#define _SFXCTRLITEM_HXX +#define _SFXPRNMON_HXX +#define _INTRO_HXX +#define _SFXMSGDESCR_HXX +#define _SFXMSGPOOL_HXX +#define _SFXFILEDLG_HXX +#define _PASSWD_HXX +#define _SFXTBXCTRL_HXX +#define _SFXSTBITEM_HXX +#define _SFXMNUITEM_HXX +#define _SFXIMGMGR_HXX +#define _SFXTBXMGR_HXX +#define _SFXSTBMGR_HXX +#define _SFX_MINFITEM_HXX +#define _SFXEVENT_HXX + + +#define _SFXFILEDLG_HXX +#define _SFXIMGMGR_HXX +#define _SFXIPFRM_HXX +#define _SFX_MACRO_HXX +#define _SFXMNUITEM_HXX +#define _SFXMNUMGR_HXX +#define _SFXMULTISEL_HXX +#define _SFXMSG_HXX +#define _SFXMSGDESCR_HXX +#define _SFXMSGPOOL_HXX +#define _SFX_MINFITEM_HXX +#define _SFXOBJFACE_HXX +#define _SFXOBJFAC_HXX +//#define _SFXREQUEST_HXX +#define _SFX_SAVEOPT_HXX +#define _SFXSTBITEM_HXX +#define _SFXSTBMGR_HXX +#define _SFXTBXCTRL_HXX +#define _SFXTBXMGR_HXX + +#define _SVX_DAILDLL_HXX +#define _SVX_HYPHEN_HXX +#define _SVX_IMPGRF_HXX +#define _SVX_OPTITEMS_HXX +#define _SVX_OPTGERL_HXX +#define _SVX_OPTSAVE_HXX +#define _SVX_OPTSPELL_HXX +#define _SVX_OPTPATH_HXX +#define _SVX_OPTLINGU_HXX +#define _SVX_RULER_HXX +#define _SVX_RULRITEM_HXX +#define _SVX_SPLWRAP_HXX +#define _SVX_SPLDLG_HXX +#define _SVX_THESDLG_HXX + + +// INCLUDE --------------------------------------------------------------- + + +#include "drwlayer.hxx" +#include "rechead.hxx" +#include "userdat.hxx" +#include "bf_so3/staticbaseurl.hxx" + +namespace binfilter { +// STATIC DATA ----------------------------------------------------------- + + +// ----------------------------------------------------------------------- + +/*N*/ ScDrawObjFactory::ScDrawObjFactory() +/*N*/ { +/*N*/ SdrObjFactory::InsertMakeUserDataHdl( LINK ( this, ScDrawObjFactory, MakeUserData ) ); +/*N*/ } + +/*N*/ ScDrawObjFactory::~ScDrawObjFactory() +/*N*/ { +/*N*/ SdrObjFactory::RemoveMakeUserDataHdl( LINK ( this, ScDrawObjFactory, MakeUserData ) ); +/*N*/ } + +/*N*/ IMPL_LINK_INLINE_START( ScDrawObjFactory, MakeUserData, SdrObjFactory *, pObjFactory ) +/*N*/ { +/*N*/ if ( pObjFactory->nInventor == SC_DRAWLAYER ) +/*N*/ { +/*N*/ if ( pObjFactory->nIdentifier == SC_UD_OBJDATA ) +/*N*/ pObjFactory->pNewData = new ScDrawObjData; +/*N*/ else if ( pObjFactory->nIdentifier == SC_UD_IMAPDATA ) +/*N*/ pObjFactory->pNewData = new ScIMapInfo; +/*N*/ else +/*N*/ DBG_ERROR("MakeUserData: falsche ID"); +/*N*/ } +/*N*/ return 0; +/*N*/ } +/*N*/ IMPL_LINK_INLINE_END( ScDrawObjFactory, MakeUserData, SdrObjFactory *, pObjFactory ) + +//------------------------------------------------------------------------ + +/*N*/ ScDrawObjData::ScDrawObjData() : SdrObjUserData( SC_DRAWLAYER, SC_UD_OBJDATA, 0 ) +/*N*/ { +/*N*/ bValidEnd = FALSE; +/*N*/ } +/*N*/ +/*N*/ ScDrawObjData::ScDrawObjData( const ScDrawObjData& r ) +/*N*/ : SdrObjUserData( r ), aStt( r.aStt ), aEnd( r.aEnd ), +/*N*/ bValidStart( r.bValidStart ), bValidEnd( r.bValidEnd ) +/*N*/ {} +/*N*/ +/*N*/ ScDrawObjData::~ScDrawObjData() +/*N*/ {} +/*N*/ +/*N*/ SdrObjUserData* ScDrawObjData::Clone(SdrObject* pObj) const +/*N*/ { +/*N*/ return new ScDrawObjData( *this ); +/*N*/ } +/*N*/ +/*N*/ void ScDrawObjData::ReadData( SvStream& r ) +/*N*/ { +/*N*/ SdrObjUserData::ReadData( r ); +/*N*/ +/*N*/ USHORT n; +/*N*/ r >> aStt.nCol >> aStt.nRow >> aStt.nTab +/*N*/ >> aEnd.nCol >> aEnd.nRow >> aEnd.nTab +/*N*/ >> n; +/*N*/ bValidEnd = BOOL( n & 0x0001 ); +/*N*/ bValidStart = !BOOL( n & 0x0002 ); // Default (0) = bValidStart fuer alte Dokumente +/*N*/ } +/*N*/ +/*N*/ void ScDrawObjData::WriteData( SvStream& r ) +/*N*/ { +/*N*/ SdrObjUserData::WriteData( r ); +/*N*/ +/*N*/ USHORT n = 0x0000; +/*N*/ if (bValidEnd) n |= 0x0001; +/*N*/ if (!bValidStart) n |= 0x0002; // Default (0) = bValidStart fuer alte Dokumente +/*N*/ +/*N*/ r << (UINT16) aStt.nCol << (UINT16) aStt.nRow << (UINT16) aStt.nTab +/*N*/ << (UINT16) aEnd.nCol << (UINT16) aEnd.nRow << (UINT16) aEnd.nTab +/*N*/ << n; +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ ScIMapInfo::ScIMapInfo() : +/*N*/ SdrObjUserData( SC_DRAWLAYER, SC_UD_IMAPDATA, 0 ) +/*N*/ { +/*N*/ } + +/*N*/ ScIMapInfo::ScIMapInfo( const ImageMap& rImageMap ) : +/*N*/ SdrObjUserData( SC_DRAWLAYER, SC_UD_IMAPDATA, 0 ), +/*N*/ aImageMap( rImageMap ) +/*N*/ { +/*N*/ } + +/*N*/ ScIMapInfo::ScIMapInfo( const ScIMapInfo& rIMapInfo ) : +/*N*/ SdrObjUserData( rIMapInfo ), +/*N*/ aImageMap( rIMapInfo.aImageMap ) +/*N*/ { +/*N*/ } + +/*N*/ __EXPORT ScIMapInfo::~ScIMapInfo() +/*N*/ { +/*N*/ } +/*N*/ +/*N*/ SdrObjUserData* __EXPORT ScIMapInfo::Clone( SdrObject* pObj ) const +/*N*/ { +/*N*/ return new ScIMapInfo( *this ); +/*N*/ } +/*N*/ +/*N*/ void __EXPORT ScIMapInfo::WriteData( SvStream& rOStm ) +/*N*/ { +/*N*/ SdrObjUserData::WriteData( rOStm ); +/*N*/ +/*N*/ ScWriteHeader aHdr( rOStm ); +/*N*/ +/*N*/ aImageMap.Write( + rOStm, ::binfilter::StaticBaseUrl::GetBaseURL(INetURLObject::NO_DECODE)); +/*N*/ } +/*N*/ +/*N*/ void __EXPORT ScIMapInfo::ReadData( SvStream& rIStm ) +/*N*/ { +/*N*/ SdrObjUserData::ReadData( rIStm ); +/*N*/ +/*N*/ ScReadHeader aHdr( rIStm ); +/*N*/ +/*N*/ aImageMap.Read( + rIStm, ::binfilter::StaticBaseUrl::GetBaseURL(INetURLObject::NO_DECODE)); +/*N*/ } + + + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/core/data/sc_validat.cxx b/binfilter/bf_sc/source/core/data/sc_validat.cxx new file mode 100644 index 000000000000..04800c8dd7f1 --- /dev/null +++ b/binfilter/bf_sc/source/core/data/sc_validat.cxx @@ -0,0 +1,312 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + + + +#include <math.h> + + +#include "validat.hxx" +#include "patattr.hxx" +#include "rechead.hxx" +#include "globstr.hrc" +namespace binfilter { + +//------------------------------------------------------------------------ + +/*N*/ SV_IMPL_OP_PTRARR_SORT( ScValidationEntries_Impl, ScValidationDataPtr ); + +//------------------------------------------------------------------------ + +// +// Eintrag fuer Gueltigkeit (es gibt nur eine Bedingung) +// + +/*N*/ ScValidationData::ScValidationData( ScValidationMode eMode, ScConditionMode eOper, +/*N*/ const String& rExpr1, const String& rExpr2, +/*N*/ ScDocument* pDocument, const ScAddress& rPos, +/*N*/ BOOL bCompileEnglish, BOOL bCompileXML ) : +/*N*/ ScConditionEntry( eOper, rExpr1, rExpr2, pDocument, rPos, bCompileEnglish, bCompileXML ), +/*N*/ nKey( 0 ), +/*N*/ eDataMode( eMode ) +/*N*/ { +/*N*/ bShowInput = bShowError = FALSE; +/*N*/ eErrorStyle = SC_VALERR_STOP; +/*N*/ } + +/*N*/ ScValidationData::ScValidationData( const ScValidationData& r ) : +/*N*/ ScConditionEntry( r ), +/*N*/ nKey( r.nKey ), +/*N*/ eDataMode( r.eDataMode ), +/*N*/ bShowInput( r.bShowInput ), +/*N*/ bShowError( r.bShowError ), +/*N*/ eErrorStyle( r.eErrorStyle ), +/*N*/ aInputTitle( r.aInputTitle ), +/*N*/ aInputMessage( r.aInputMessage ), +/*N*/ aErrorTitle( r.aErrorTitle ), +/*N*/ aErrorMessage( r.aErrorMessage ) +/*N*/ { +/*N*/ // Formeln per RefCount kopiert +/*N*/ } + +/*N*/ ScValidationData::ScValidationData( ScDocument* pDocument, const ScValidationData& r ) : +/*N*/ ScConditionEntry( pDocument, r ), +/*N*/ nKey( r.nKey ), +/*N*/ eDataMode( r.eDataMode ), +/*N*/ bShowInput( r.bShowInput ), +/*N*/ bShowError( r.bShowError ), +/*N*/ eErrorStyle( r.eErrorStyle ), +/*N*/ aInputTitle( r.aInputTitle ), +/*N*/ aInputMessage( r.aInputMessage ), +/*N*/ aErrorTitle( r.aErrorTitle ), +/*N*/ aErrorMessage( r.aErrorMessage ) +/*N*/ { +/*N*/ // Formeln wirklich kopiert +/*N*/ } + +/*N*/ ScValidationData::ScValidationData( SvStream& rStream, ScMultipleReadHeader& rHdr, +/*N*/ ScDocument* pDocument ) : +/*N*/ ScConditionEntry( rStream, rHdr, pDocument ) +/*N*/ { +/*N*/ // im Datei-Header sind getrennte Eintraege fuer ScConditionEntry und ScValidationData +/*N*/ +/*N*/ rHdr.StartEntry(); +/*N*/ +/*N*/ // 1) Key +/*N*/ // 2) eDataMode +/*N*/ // 3) bShowInput +/*N*/ // 4) aInputTitle +/*N*/ // 5) aInputMessage +/*N*/ // 6) bShowError +/*N*/ // 7) aErrorTitle +/*N*/ // 8) aErrorMessage +/*N*/ // 9) eErrorStyle +/*N*/ +/*N*/ USHORT nDummy; +/*N*/ rStream >> nKey; +/*N*/ rStream >> nDummy; +/*N*/ eDataMode = (ScValidationMode) nDummy; +/*N*/ rStream >> bShowInput; +/*N*/ rStream.ReadByteString( aInputTitle, rStream.GetStreamCharSet() ); +/*N*/ rStream.ReadByteString( aInputMessage, rStream.GetStreamCharSet() ); +/*N*/ rStream >> bShowError; +/*N*/ rStream.ReadByteString( aErrorTitle, rStream.GetStreamCharSet() ); +/*N*/ rStream.ReadByteString( aErrorMessage, rStream.GetStreamCharSet() ); +/*N*/ rStream >> nDummy; +/*N*/ eErrorStyle = (ScValidErrorStyle) nDummy; +/*N*/ +/*N*/ rHdr.EndEntry(); +/*N*/ } + +/*N*/ ScValidationData::~ScValidationData() +/*N*/ { +/*N*/ } + +/*N*/ void ScValidationData::Store(SvStream& rStream, ScMultipleWriteHeader& rHdr) const +/*N*/ { +/*N*/ // im Datei-Header sind getrennte Eintraege fuer ScConditionEntry und ScValidationData +/*N*/ +/*N*/ StoreCondition( rStream, rHdr ); +/*N*/ +/*N*/ rHdr.StartEntry(); +/*N*/ +/*N*/ // 1) Key +/*N*/ // 2) eDataMode +/*N*/ // 3) bShowInput +/*N*/ // 4) aInputTitle +/*N*/ // 5) aInputMessage +/*N*/ // 6) bShowError +/*N*/ // 7) aErrorTitle +/*N*/ // 8) aErrorMessage +/*N*/ // 9) eErrorStyle +/*N*/ +/*N*/ rStream << nKey; +/*N*/ rStream << (USHORT) eDataMode; +/*N*/ rStream << bShowInput; +/*N*/ rStream.WriteByteString( aInputTitle, rStream.GetStreamCharSet() ); +/*N*/ rStream.WriteByteString( aInputMessage, rStream.GetStreamCharSet() ); +/*N*/ rStream << bShowError; +/*N*/ rStream.WriteByteString( aErrorTitle, rStream.GetStreamCharSet() ); +/*N*/ rStream.WriteByteString( aErrorMessage, rStream.GetStreamCharSet() ); +/*N*/ rStream << (USHORT) eErrorStyle; +/*N*/ +/*N*/ rHdr.EndEntry(); +/*N*/ } + +/*N*/ BOOL ScValidationData::IsEmpty() const +/*N*/ { +/*N*/ String aEmpty; +/*N*/ ScValidationData aDefault( SC_VALID_ANY, SC_COND_EQUAL, aEmpty, aEmpty, GetDocument(), ScAddress() ); +/*N*/ return EqualEntries( aDefault ); +/*N*/ } + +/*N*/ BOOL ScValidationData::EqualEntries( const ScValidationData& r ) const +/*N*/ { +/*N*/ // gleiche Parameter eingestellt (ohne Key) +/*N*/ +/*N*/ return ScConditionEntry::operator==(r) && +/*N*/ eDataMode == r.eDataMode && +/*N*/ bShowInput == r.bShowInput && +/*N*/ bShowError == r.bShowError && +/*N*/ eErrorStyle == r.eErrorStyle && +/*N*/ aInputTitle == r.aInputTitle && +/*N*/ aInputMessage == r.aInputMessage && +/*N*/ aErrorTitle == r.aErrorTitle && +/*N*/ aErrorMessage == r.aErrorMessage; +/*N*/ } + +/*N*/ void ScValidationData::ResetInput() +/*N*/ { +/*N*/ bShowInput = FALSE; +/*N*/ } + +/*N*/ void ScValidationData::ResetError() +/*N*/ { +/*N*/ bShowError = FALSE; +/*N*/ } + +/*N*/ void ScValidationData::SetInput( const String& rTitle, const String& rMsg ) +/*N*/ { +/*N*/ bShowInput = TRUE; +/*N*/ aInputTitle = rTitle; +/*N*/ aInputMessage = rMsg; +/*N*/ } + +/*N*/ void ScValidationData::SetError( const String& rTitle, const String& rMsg, +/*N*/ ScValidErrorStyle eStyle ) +/*N*/ { +/*N*/ bShowError = TRUE; +/*N*/ eErrorStyle = eStyle; +/*N*/ aErrorTitle = rTitle; +/*N*/ aErrorMessage = rMsg; +/*N*/ } + +/*N*/ BOOL ScValidationData::GetErrMsg( String& rTitle, String& rMsg, +/*N*/ ScValidErrorStyle& rStyle ) const +/*N*/ { +/*N*/ rTitle = aErrorTitle; +/*N*/ rMsg = aErrorMessage; +/*N*/ rStyle = eErrorStyle; +/*N*/ return bShowError; +/*N*/ } + +/*N*/ BOOL ScValidationData::IsDataValid( ScBaseCell* pCell, const ScAddress& rPos ) const +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); return FALSE; //STRIP001 double nVal = 0.0; +/*N*/ } + +//------------------------------------------------------------------------ + +/*N*/ ScValidationDataList::ScValidationDataList(const ScValidationDataList& rList) +/*N*/ { +/*N*/ // fuer Ref-Undo - echte Kopie mit neuen Tokens! +/*N*/ +/*N*/ USHORT nCount = rList.Count(); +/*N*/ +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ InsertNew( rList[i]->Clone() ); +/*N*/ +/*N*/ //! sortierte Eintraege aus rList schneller einfuegen ??? +/*N*/ } + +/*N*/ ScValidationData* ScValidationDataList::GetData( sal_uInt32 nKey ) +/*N*/ { +/*N*/ //! binaer suchen +/*N*/ +/*N*/ USHORT nCount = Count(); +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ if ((*this)[i]->GetKey() == nKey) +/*N*/ return (*this)[i]; +/*N*/ +/*N*/ DBG_ERROR("ScValidationDataList: Eintrag nicht gefunden"); +/*N*/ return NULL; +/*N*/ } + +/*N*/ void ScValidationDataList::Load( SvStream& rStream, ScDocument* pDocument ) +/*N*/ { +/*N*/ ScMultipleReadHeader aHdr( rStream ); +/*N*/ +/*N*/ USHORT nNewCount; +/*N*/ rStream >> nNewCount; +/*N*/ +/*N*/ for (USHORT i=0; i<nNewCount; i++) +/*N*/ { +/*N*/ ScValidationData* pNew = new ScValidationData( rStream, aHdr, pDocument ); +/*N*/ InsertNew( pNew ); +/*N*/ } +/*N*/ } + +/*N*/ void ScValidationDataList::Store( SvStream& rStream ) const +/*N*/ { +/*N*/ USHORT i; +/*N*/ ScMultipleWriteHeader aHdr( rStream ); +/*N*/ +/*N*/ USHORT nCount = Count(); +/*N*/ USHORT nUsed = 0; +/*N*/ for (i=0; i<nCount; i++) +/*N*/ if ((*this)[i]->IsUsed()) +/*N*/ ++nUsed; +/*N*/ +/*N*/ rStream << nUsed; // Anzahl der gespeicherten +/*N*/ +/*N*/ for (i=0; i<nCount; i++) +/*N*/ { +/*N*/ const ScValidationData* pForm = (*this)[i]; +/*N*/ if (pForm->IsUsed()) +/*N*/ pForm->Store( rStream, aHdr ); +/*N*/ } +/*N*/ } + +/*N*/ void ScValidationDataList::ResetUsed() +/*N*/ { +/*N*/ USHORT nCount = Count(); +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ (*this)[i]->SetUsed(FALSE); +/*N*/ } + +/*N*/ void ScValidationDataList::CompileXML() +/*N*/ { +/*N*/ USHORT nCount = Count(); +/*N*/ for (USHORT i=0; i<nCount; i++) +/*N*/ (*this)[i]->CompileXML(); +/*N*/ } + + + + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |