summaryrefslogtreecommitdiff
path: root/sw/source/core/bastyp
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/core/bastyp')
-rw-r--r--sw/source/core/bastyp/SwSmartTagMgr.cxx95
-rw-r--r--sw/source/core/bastyp/bparr.cxx580
-rw-r--r--sw/source/core/bastyp/breakit.cxx186
-rw-r--r--sw/source/core/bastyp/calc.cxx1824
-rw-r--r--sw/source/core/bastyp/checkit.cxx51
-rw-r--r--sw/source/core/bastyp/index.cxx593
-rw-r--r--sw/source/core/bastyp/init.cxx918
-rw-r--r--sw/source/core/bastyp/makefile.mk79
-rw-r--r--sw/source/core/bastyp/ring.cxx125
-rw-r--r--sw/source/core/bastyp/swcache.cxx656
-rw-r--r--sw/source/core/bastyp/swrect.cxx336
-rw-r--r--sw/source/core/bastyp/swregion.cxx254
-rw-r--r--sw/source/core/bastyp/swtypes.cxx133
-rw-r--r--sw/source/core/bastyp/tabcol.cxx142
14 files changed, 5972 insertions, 0 deletions
diff --git a/sw/source/core/bastyp/SwSmartTagMgr.cxx b/sw/source/core/bastyp/SwSmartTagMgr.cxx
new file mode 100644
index 000000000000..ac661389ae6a
--- /dev/null
+++ b/sw/source/core/bastyp/SwSmartTagMgr.cxx
@@ -0,0 +1,95 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+#include "SwSmartTagMgr.hxx"
+
+#include <vos/mutex.hxx>
+#include <vcl/svapp.hxx>
+#include <swmodule.hxx>
+
+#ifndef _DOCSH_HXX
+#include <docsh.hxx>
+#endif
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+SwSmartTagMgr* SwSmartTagMgr::mpTheSwSmartTagMgr = 0;
+
+SwSmartTagMgr& SwSmartTagMgr::Get()
+{
+ if ( !mpTheSwSmartTagMgr )
+ {
+ mpTheSwSmartTagMgr = new SwSmartTagMgr( SwDocShell::Factory().GetModuleName() );
+ mpTheSwSmartTagMgr->Init( rtl::OUString::createFromAscii("Writer") );
+ }
+ return *mpTheSwSmartTagMgr;
+}
+
+SwSmartTagMgr::SwSmartTagMgr( const rtl::OUString& rModuleName ) :
+ SmartTagMgr( rModuleName )
+{
+}
+
+SwSmartTagMgr::~SwSmartTagMgr()
+{
+}
+
+// ::com::sun::star::util::XModifyListener
+void SwSmartTagMgr::modified( const lang::EventObject& rEO ) throw( RuntimeException )
+{
+ vos::OGuard aGuard(Application::GetSolarMutex());
+
+ // Installed recognizers have changed. We remove all existing smart tags:
+ SW_MOD()->CheckSpellChanges( sal_False, sal_True, sal_True, sal_True );
+
+ SmartTagMgr::modified( rEO );
+}
+
+// ::com::sun::star::util::XChangesListener
+void SwSmartTagMgr::changesOccurred( const util::ChangesEvent& rEvent ) throw( RuntimeException)
+{
+ vos::OGuard aGuard(Application::GetSolarMutex());
+
+ // Configuration has changed. We remove all existing smart tags:
+ SW_MOD()->CheckSpellChanges( sal_False, sal_True, sal_True, sal_True );
+
+ SmartTagMgr::changesOccurred( rEvent );
+}
+
+/*
+SmartTagMgr& SwSmartTagMgr::Get()
+{
+ if ( !pSmartTagMgr )
+ pSmartTagMgr = new SmartTagMgr( SwDocShell::Factory().GetModuleName() );
+
+ return *pSmartTagMgr;
+}
+*/
+
diff --git a/sw/source/core/bastyp/bparr.cxx b/sw/source/core/bastyp/bparr.cxx
new file mode 100644
index 000000000000..5dbb3dad6537
--- /dev/null
+++ b/sw/source/core/bastyp/bparr.cxx
@@ -0,0 +1,580 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+
+
+#include <string.h>
+#include <limits.h>
+#include "bparr.hxx"
+
+// die Blockverwaltung waechst/schrumpft immer um 20 Bloecke, das sind dann
+// immer ~ 20 * MAXENTRY == 20000 Eintraege
+const USHORT nBlockGrowSize = 20;
+
+#ifndef DBG_UTIL
+
+#define CHECKIDX( p, n, i, c )
+
+#else
+
+#define CHECKIDX( p, n, i, c ) CheckIdx( p, n, i, c );
+
+void CheckIdx( BlockInfo** ppInf, USHORT nBlock, ULONG nSize, USHORT nCur )
+{
+ DBG_ASSERT( !nSize || nCur < nBlock, "BigPtrArray: CurIndex steht falsch" );
+
+ ULONG nIdx = 0;
+ for( USHORT nCnt = 0; nCnt < nBlock; ++nCnt, ++ppInf )
+ {
+ nIdx += (*ppInf)->nElem;
+ // Array mit Luecken darf es nicht geben
+ DBG_ASSERT( !nCnt || (*(ppInf-1))->nEnd + 1 == (*ppInf)->nStart,
+ "BigPtrArray: Luecke in der Verwaltung!" );
+ }
+
+ DBG_ASSERT( nIdx == nSize, "BigPtrArray: Anzahl ungueltig" );
+}
+
+#endif
+
+
+BigPtrArray::BigPtrArray()
+{
+ nBlock = nCur = 0;
+ nSize = 0;
+ nMaxBlock = nBlockGrowSize; // == 20 * 1000 Eintraege
+ ppInf = new BlockInfo* [ nMaxBlock ];
+}
+
+
+
+BigPtrArray::~BigPtrArray()
+{
+ if( nBlock )
+ {
+ BlockInfo** pp = ppInf;
+ for( USHORT n = 0; n < nBlock; ++n, ++pp )
+ {
+ delete[] (*pp)->pData;
+ delete *pp;
+ }
+ }
+ delete[] ppInf;
+}
+
+// Auch der Move ist schlicht. Optimieren ist hier wg. der
+// Stueckelung des Feldes zwecklos!
+
+void BigPtrArray::Move( ULONG from, ULONG to )
+{
+ USHORT cur = Index2Block( from );
+ BlockInfo* p = ppInf[ cur ];
+ ElementPtr pElem = p->pData[ from - p->nStart ];
+ Insert( pElem, to ); // erst einfuegen, dann loeschen !!!!
+ Remove( ( to < from ) ? ( from + 1 ) : from );
+}
+
+// das Ende ist EXCLUSIV
+
+
+void BigPtrArray::ForEach( ULONG nStart, ULONG nEnd,
+ FnForEach fn, void* pArgs )
+{
+ if( nEnd > nSize )
+ nEnd = nSize;
+
+ if( nStart < nEnd )
+ {
+ USHORT cur = Index2Block( nStart );
+ BlockInfo** pp = ppInf + cur;
+ BlockInfo* p = *pp;
+ USHORT nElem = USHORT( nStart - p->nStart );
+ ElementPtr* pElem = p->pData + nElem;
+ nElem = p->nElem - nElem;
+ for(;;)
+ {
+ if( !(*fn)( *pElem++, pArgs ) || ++nStart >= nEnd )
+ break;
+
+ // naechstes Element
+ if( !--nElem )
+ {
+ // neuer Block
+ p = *++pp;
+ pElem = p->pData;
+ nElem = p->nElem;
+ }
+ }
+ }
+}
+
+
+ElementPtr BigPtrArray::operator[]( ULONG idx ) const
+{
+ // weil die Funktion eben doch nicht const ist:
+ DBG_ASSERT( idx < nSize, "operator[]: Index aussserhalb" );
+ BigPtrArray* pThis = (BigPtrArray*) this;
+ USHORT cur = Index2Block( idx );
+ BlockInfo* p = ppInf[ cur ];
+ pThis->nCur = cur;
+ return p->pData[ idx - p->nStart ];
+}
+
+///////////////////////////////////////////////////////////////////////////
+
+// private Methoden
+
+// Suchen des Blocks einer bestimmten Position
+// Algorithmus:
+// 1. Test, ob der letzte Block der gesuchte Block ist
+// 2. Sonderfall: Index = 0?
+// 3. Test der Nachbarbloecke
+
+// 4. Binaere Suche
+
+
+
+USHORT BigPtrArray::Index2Block( ULONG pos ) const
+{
+ // zuletzt verwendeter Block?
+ BlockInfo* p = ppInf[ nCur ];
+ if( p->nStart <= pos && p->nEnd >= pos )
+ return nCur;
+ // Index = 0?
+ if( !pos )
+ return 0;
+ // Folgeblock?
+ if( nCur < ( nBlock - 1 ) )
+ {
+ p = ppInf[ nCur+1 ];
+ if( p->nStart <= pos && p->nEnd >= pos )
+ return nCur+1;
+ }
+ // vorangehender Block?
+ else if( pos < p->nStart && nCur > 0 )
+ {
+ p = ppInf[ nCur-1 ];
+ if( p->nStart <= pos && p->nEnd >= pos )
+ return nCur-1;
+ }
+ // Binaere Suche:
+ // Diese fuehrt immer zum Erfolg
+ USHORT lower = 0, upper = nBlock - 1;
+ USHORT cur = 0;
+ for(;;)
+ {
+ USHORT n = lower + ( upper - lower ) / 2;
+ cur = ( n == cur ) ? n+1 : n;
+ p = ppInf[ cur ];
+ if( p->nStart <= pos && p->nEnd >= pos )
+ return cur;
+ if( p->nStart > pos )
+ upper = cur;
+ else
+ lower = cur;
+ }
+}
+
+
+// Update aller Indexbereiche ab einer bestimmten Position
+
+// pos bezeichnet den letzten korrekten Block
+
+void BigPtrArray::UpdIndex( USHORT pos )
+{
+ BlockInfo** pp = ppInf + pos;
+ ULONG idx = (*pp)->nEnd + 1;
+ BlockInfo* p;
+ while( ++pos < nBlock )
+ {
+ p = *++pp;
+ p->nStart = idx;
+ idx += p->nElem;
+ p->nEnd = idx - 1;
+ }
+}
+
+// Einrichten eines neuen Blocks an einer bestimmten Position
+
+// Vorhandene Blocks werden nach hinten verschoben
+
+
+
+BlockInfo* BigPtrArray::InsBlock( USHORT pos )
+{
+ if( nBlock == nMaxBlock )
+ {
+ // dann sollte wir mal das Array erweitern
+ BlockInfo** ppNew = new BlockInfo* [ nMaxBlock + nBlockGrowSize ];
+ memcpy( ppNew, ppInf, nMaxBlock * sizeof( BlockInfo* ));
+ delete[] ppInf;
+ nMaxBlock += nBlockGrowSize;
+ ppInf = ppNew;
+ }
+ if( pos != nBlock )
+ memmove( ppInf + pos+1, ppInf + pos ,
+ ( nBlock - pos ) * sizeof (BlockInfo*) );
+ ++nBlock;
+ BlockInfo* p = new BlockInfo;
+ ppInf[ pos ] = p;
+
+ if( pos )
+ p->nStart = p->nEnd = ppInf[ pos-1 ]->nEnd + 1;
+ else
+ p->nStart = p->nEnd = 0;
+ p->nEnd--; // keine Elemente
+ p->nElem = 0;
+ p->pData = new ElementPtr [ MAXENTRY ];
+ p->pBigArr = this;
+ return p;
+}
+
+void BigPtrArray::BlockDel( USHORT nDel )
+{
+ nBlock = nBlock - nDel;
+ if( nMaxBlock - nBlock > nBlockGrowSize )
+ {
+ // dann koennen wir wieder schrumpfen
+ nDel = (( nBlock / nBlockGrowSize ) + 1 ) * nBlockGrowSize;
+ BlockInfo** ppNew = new BlockInfo* [ nDel ];
+ memcpy( ppNew, ppInf, nBlock * sizeof( BlockInfo* ));
+ delete[] ppInf;
+ ppInf = ppNew;
+ nMaxBlock = nDel;
+ }
+}
+
+
+void BigPtrArray::Insert( const ElementPtr& rElem, ULONG pos )
+{
+ CHECKIDX( ppInf, nBlock, nSize, nCur );
+
+ BlockInfo* p;
+ USHORT cur;
+ if( !nSize )
+ // Sonderfall: erstes Element einfuegen
+ p = InsBlock( cur = 0 );
+ else if( pos == nSize )
+ {
+ // Sonderfall: Einfuegen am Ende
+ cur = nBlock - 1;
+ p = ppInf[ cur ];
+ if( p->nElem == MAXENTRY )
+ // Der letzte Block ist voll, neuen anlegen
+ p = InsBlock( ++cur );
+ }
+ else
+ {
+ // Standardfall:
+ cur = Index2Block( pos );
+ p = ppInf[ cur ];
+ }
+ if( p->nElem == MAXENTRY )
+ {
+ // passt der letzte Eintrag in den naechsten Block?
+ BlockInfo* q;
+ if( cur < ( nBlock - 1 ) && ppInf[ cur+1 ]->nElem < MAXENTRY )
+ {
+ q = ppInf[ cur+1 ];
+ if( q->nElem )
+ {
+ int nCount = q->nElem;
+ ElementPtr *pFrom = q->pData + nCount,
+ *pTo = pFrom+1;
+ while( nCount-- )
+ ++( *--pTo = *--pFrom )->nOffset;
+ }
+ q->nStart--;
+ q->nEnd--;
+ }
+ else
+ {
+ // Wenn er auch nicht in den Folgeblock passt, muss ein
+ // neuer Block eingefuegt werden
+ // erst mal bei Bedarf komprimieren
+
+ // wenn mehr als 50% "Luft" im Array ist, dann sollte man mal das
+ // Compress aufrufen
+ if( /*nBlock == nMaxBlock &&*/
+ nBlock > ( nSize / ( MAXENTRY / 2 ) ) &&
+ cur >= Compress() )
+ {
+ // es wurde vor der akt. Pos etwas verschoben und alle
+ // Pointer koennen ungueltig sein. Also das Insert
+ // nochmals aufsetzen
+ Insert( rElem, pos );
+ return ;
+ }
+
+ q = InsBlock( cur+1 );
+ }
+
+ // Eintrag passt nicht mehr. Dann muss Platz gemacht werden
+ ElementPtr pLast = p->pData[ MAXENTRY-1 ];
+ pLast->nOffset = 0;
+ pLast->pBlock = q;
+
+ q->pData[ 0 ] = pLast;
+ q->nElem++;
+ q->nEnd++;
+
+ p->nEnd--;
+ p->nElem--;
+ }
+ // Nun haben wir einen freien Block am Wickel: eintragen
+ pos -= p->nStart;
+ DBG_ASSERT( pos < MAXENTRY, "falsche Pos" );
+ if( pos != p->nElem )
+ {
+ int nCount = p->nElem - USHORT(pos);
+ ElementPtr *pFrom = p->pData + p->nElem,
+ *pTo = pFrom + 1;
+ while( nCount-- )
+ ++( *--pTo = *--pFrom )->nOffset;
+ }
+ // Element eintragen und Indexe updaten
+ ((ElementPtr&)rElem)->nOffset = USHORT(pos);
+ ((ElementPtr&)rElem)->pBlock = p;
+ p->pData[ pos ] = rElem;
+ p->nEnd++;
+ p->nElem++;
+ nSize++;
+ if( cur != ( nBlock - 1 ) ) UpdIndex( cur );
+ nCur = cur;
+
+ CHECKIDX( ppInf, nBlock, nSize, nCur );
+}
+
+void BigPtrArray::Remove( ULONG pos, ULONG n )
+{
+ CHECKIDX( ppInf, nBlock, nSize, nCur );
+
+ USHORT nBlkdel = 0; // entfernte Bloecke
+ USHORT cur = Index2Block( pos ); // aktuelle Blocknr
+ USHORT nBlk1 = cur; // 1. behandelter Block
+ USHORT nBlk1del = USHRT_MAX; // 1. entfernter Block
+ BlockInfo* p = ppInf[ cur ];
+ pos -= p->nStart;
+ ULONG nElem = n;
+ while( nElem )
+ {
+ USHORT nel = p->nElem - USHORT(pos);
+ if( ULONG(nel) > nElem )
+ nel = USHORT(nElem);
+ // Eventuell Elemente verschieben
+ if( ( pos + nel ) < ULONG(p->nElem) )
+ {
+ ElementPtr *pTo = p->pData + pos,
+ *pFrom = pTo + nel;
+ int nCount = p->nElem - nel - USHORT(pos);
+ while( nCount-- )
+ {
+ *pTo = *pFrom++;
+ (*pTo)->nOffset = (*pTo)->nOffset - nel;
+ ++pTo;
+ }
+ }
+ p->nEnd -= nel;
+ p->nElem = p->nElem - nel;
+ if( !p->nElem )
+ {
+ // eventuell Block ganz entfernen
+ delete[] p->pData;
+ nBlkdel++;
+ if( USHRT_MAX == nBlk1del )
+ nBlk1del = cur;
+ }
+ nElem -= nel;
+ if( !nElem )
+ break;
+ p = ppInf[ ++cur ];
+ pos = 0;
+ }
+ // Am Ende die Tabelle updaten, falls Bloecke geloescht waren
+ if( nBlkdel )
+ {
+ // loeschen sollte man immer !!
+ for( USHORT i = nBlk1del; i < ( nBlk1del + nBlkdel ); i++ )
+ delete ppInf[ i ];
+
+ if( ( nBlk1del + nBlkdel ) < nBlock )
+ {
+ memmove( ppInf + nBlk1del, ppInf + nBlk1del + nBlkdel,
+ ( nBlock - nBlkdel - nBlk1del ) * sizeof( BlockInfo* ) );
+
+ // JP 19.07.95: nicht den ersten behandelten, sondern den davor!!
+ // UpdateIdx updatet nur alle Nachfolgende!!
+ if( !nBlk1 )
+ {
+ p = ppInf[ 0 ];
+ p->nStart = 0;
+ p->nEnd = p->nElem-1;
+ }
+ else
+ --nBlk1;
+ }
+ BlockDel( nBlkdel ); // es wurden Bloecke geloescht
+ }
+
+ nSize -= n;
+ if( nBlk1 != ( nBlock - 1 ) && nSize )
+ UpdIndex( nBlk1 );
+ nCur = nBlk1;
+
+ // wenn mehr als 50% "Luft" im Array ist, dann sollte man mal das
+ // Compress aufrufen
+ if( nBlock > ( nSize / ( MAXENTRY / 2 ) ) )
+ Compress();
+
+ CHECKIDX( ppInf, nBlock, nSize, nCur );
+}
+
+
+void BigPtrArray::Replace( ULONG idx, const ElementPtr& rElem)
+{
+ // weil die Funktion eben doch nicht const ist:
+ DBG_ASSERT( idx < nSize, "Set: Index aussserhalb" );
+ BigPtrArray* pThis = (BigPtrArray*) this;
+ USHORT cur = Index2Block( idx );
+ BlockInfo* p = ppInf[ cur ];
+ pThis->nCur = cur;
+ ((ElementPtr&)rElem)->nOffset = USHORT(idx - p->nStart);
+ ((ElementPtr&)rElem)->pBlock = p;
+ p->pData[ idx - p->nStart ] = rElem;
+}
+
+
+// Array komprimieren
+
+USHORT BigPtrArray::Compress( short nMax )
+{
+ CHECKIDX( ppInf, nBlock, nSize, nCur );
+
+ // Es wird von vorne nach hinten ueber das InfoBlock Array iteriert.
+ // Wenn zwischen durch Block gel�scht werden, dann mussen alle
+ // nachfolgenden verschoben werden. Dazu werden die Pointer pp und qq
+ // benutzt; wobei pp das "alte" Array, qq das "neue" Array ist.
+ BlockInfo** pp = ppInf, **qq = pp;
+ BlockInfo* p;
+ BlockInfo* pLast(0); // letzter nicht voller Block
+ USHORT nLast = 0; // fehlende Elemente
+ USHORT nBlkdel = 0; // Anzahl der geloeschte Bloecke
+ USHORT nFirstChgPos = USHRT_MAX; // ab welcher Pos gab es die 1. Aenderung?
+
+ // von Fuell-Prozenten auf uebrige Eintrage umrechnen
+ nMax = MAXENTRY - (long) MAXENTRY * nMax / 100;
+
+ for( USHORT cur = 0; cur < nBlock; ++cur )
+ {
+ p = *pp++;
+ USHORT n = p->nElem;
+ // Testen, ob der noch nicht volle Block so gelassen wird
+ // dies ist der Fall, wenn der aktuelle Block gesplittet
+ // werden muesste, der noch nicht volle Block aber bereits
+ // ueber dem uebergebenen Break-Wert voll ist. In diesem
+ // Fall wird von einer weiteren Fuellung (die ja wegen dem
+ // zweifachen memmove() zeitaufwendig ist) abgesehen.
+ if( nLast && ( n > nLast ) && ( nLast < nMax ) )
+ nLast = 0;
+ if( nLast )
+ {
+ if( USHRT_MAX == nFirstChgPos )
+ nFirstChgPos = cur;
+
+ // ein nicht voller Block vorhanden: auffuellen
+ if( n > nLast )
+ n = nLast;
+
+ // Elemente uebertragen, vom akt. in den letzten
+ ElementPtr* pElem = pLast->pData + pLast->nElem;
+ ElementPtr* pFrom = p->pData;
+ for( USHORT nCount = n, nOff = pLast->nElem;
+ nCount; --nCount, ++pElem )
+ *pElem = *pFrom++,
+ (*pElem)->pBlock = pLast,
+ (*pElem)->nOffset = nOff++;
+
+ // korrigieren
+ pLast->nElem = pLast->nElem + n;
+ nLast = nLast - n;
+ p->nElem = p->nElem - n;
+
+ // Ist der aktuelle Block dadurch leer geworden?
+ if( !p->nElem )
+ {
+ // dann kann der entfernt werden
+ delete[] p->pData;
+ delete p, p = 0;
+ ++nBlkdel;
+ }
+ else
+ {
+ pElem = p->pData, pFrom = pElem + n;
+ int nCount = p->nElem;
+ while( nCount-- )
+ {
+ *pElem = *pFrom++;
+ (*pElem)->nOffset = (*pElem)->nOffset - n;
+ ++pElem;
+ }
+ }
+ }
+
+ if( p ) // die Blockinfo wurde nicht geloescht
+ {
+ *qq++ = p; // dann setze sie an die richtige neue Position
+
+ // eventuell den letzten halbvollen Block festhalten
+ if( !nLast && p->nElem < MAXENTRY )
+ {
+ pLast = p;
+ nLast = MAXENTRY - p->nElem;
+ }
+ }
+ }
+
+ // Bloecke geloescht wurden, ggfs. das BlockInfo Array verkuerzen
+ if( nBlkdel )
+ BlockDel( nBlkdel );
+
+ // Und neu durchindizieren
+ p = ppInf[ 0 ];
+ p->nEnd = p->nElem - 1;
+ UpdIndex( 0 );
+
+ if( nCur >= nFirstChgPos )
+ nCur = 0;
+
+ CHECKIDX( ppInf, nBlock, nSize, nCur );
+
+ return nFirstChgPos;
+}
+
+
diff --git a/sw/source/core/bastyp/breakit.cxx b/sw/source/core/bastyp/breakit.cxx
new file mode 100644
index 000000000000..4253507b11b5
--- /dev/null
+++ b/sw/source/core/bastyp/breakit.cxx
@@ -0,0 +1,186 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+#include "breakit.hxx"
+#include <unicode/uchar.h>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_
+#include <com/sun/star/i18n/ScriptType.hdl>
+#endif
+#include <unotools/localedatawrapper.hxx>
+
+#ifndef _SVX_LINGU_HXX
+#include <editeng/unolingu.hxx>
+#endif
+#include <editeng/scripttypeitem.hxx>
+#include "swtypes.hxx"
+
+using namespace com::sun::star;
+
+SwBreakIt * pBreakIt = 0;
+
+void SwBreakIt::_Create(
+ const uno::Reference< lang::XMultiServiceFactory > & rxMSF)
+{
+ delete pBreakIt, pBreakIt = new SwBreakIt( rxMSF );
+}
+
+void SwBreakIt::_Delete()
+{
+ delete pBreakIt, pBreakIt = 0;
+}
+
+SwBreakIt * SwBreakIt::Get()
+{
+ return pBreakIt;
+}
+
+SwBreakIt::SwBreakIt(
+ const uno::Reference< lang::XMultiServiceFactory > & rxMSF)
+ : m_xMSF( rxMSF ),
+ m_pLocale( NULL ),
+ m_pForbidden( NULL ),
+ aLast( LANGUAGE_DONTKNOW ),
+ aForbiddenLang( LANGUAGE_DONTKNOW)
+{
+ DBG_ASSERT( m_xMSF.is(), "SwBreakIt: no MultiServiceFactory" );
+ //if ( m_xMSF.is() )
+ //{
+ // xBreak = uno::Reference< i18n::XBreakIterator >(
+ // m_xMSF->createInstance(
+ // rtl::OUString::createFromAscii( "com.sun.star.i18n.BreakIterator" ) ),
+ // uno::UNO_QUERY);
+
+ // xCTLDetect = uno::Reference< i18n::XScriptTypeDetector >(
+ // m_xMSF->createInstance(
+ // rtl::OUString::createFromAscii( "com.sun.star.i18n.ScriptTypeDetector" ) ),
+ // uno::UNO_QUERY);
+ // }
+}
+
+SwBreakIt::~SwBreakIt()
+{
+ delete m_pLocale;
+ delete m_pForbidden;
+}
+void SwBreakIt::createBreakIterator() const
+{
+ if ( m_xMSF.is() && !xBreak.is() )
+ xBreak.set(m_xMSF->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.i18n.BreakIterator"))),uno::UNO_QUERY);
+}
+void SwBreakIt::createScriptTypeDetector()
+{
+ if ( m_xMSF.is() && !xCTLDetect.is() )
+ xCTLDetect.set(m_xMSF->createInstance(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.i18n.ScriptTypeDetector" ))),uno::UNO_QUERY);
+}
+void SwBreakIt::_GetLocale( const LanguageType aLang )
+{
+ aLast = aLang;
+ delete m_pLocale;
+ m_pLocale = new lang::Locale( SvxCreateLocale( aLast ) );
+}
+
+void SwBreakIt::_GetForbidden( const LanguageType aLang )
+{
+ LocaleDataWrapper aWrap( m_xMSF, GetLocale( aLang ) );
+
+ aForbiddenLang = aLang;
+ delete m_pForbidden;
+ m_pForbidden = new i18n::ForbiddenCharacters( aWrap.getForbiddenCharacters() );
+}
+
+USHORT SwBreakIt::GetRealScriptOfText( const String& rTxt,
+ xub_StrLen nPos ) const
+{
+ createBreakIterator();
+ USHORT nScript = i18n::ScriptType::WEAK;
+ if( xBreak.is() && rTxt.Len() )
+ {
+ if( nPos && nPos == rTxt.Len() )
+ --nPos;
+ nScript = xBreak->getScriptType( rTxt, nPos );
+ sal_Int32 nChgPos = 0;
+ if ( i18n::ScriptType::WEAK == nScript && nPos + 1 < rTxt.Len() )
+ {
+ // A weak character followed by a mark may be meant to combine with
+ // the mark, so prefer the following character's script
+ switch ( u_charType(rTxt.GetChar(nPos + 1) ) ) {
+ case U_NON_SPACING_MARK:
+ case U_ENCLOSING_MARK:
+ case U_COMBINING_SPACING_MARK:
+ nScript = xBreak->getScriptType( rTxt, nPos+1 );
+ break;
+ }
+ }
+ if( i18n::ScriptType::WEAK == nScript && nPos &&
+ 0 < (nChgPos = xBreak->beginOfScript( rTxt, nPos, nScript )) )
+ nScript = xBreak->getScriptType( rTxt, nChgPos-1 );
+
+ if( i18n::ScriptType::WEAK == nScript && rTxt.Len() >
+ ( nChgPos = xBreak->endOfScript( rTxt, nPos, nScript ) ) &&
+ 0 <= nChgPos )
+ nScript = xBreak->getScriptType( rTxt, nChgPos );
+ }
+ if( i18n::ScriptType::WEAK == nScript )
+ nScript = GetI18NScriptTypeOfLanguage( (USHORT)GetAppLanguage() );
+ return nScript;
+}
+
+USHORT SwBreakIt::GetAllScriptsOfText( const String& rTxt ) const
+{
+ const USHORT coAllScripts = ( SCRIPTTYPE_LATIN |
+ SCRIPTTYPE_ASIAN |
+ SCRIPTTYPE_COMPLEX );
+ createBreakIterator();
+ USHORT nRet = 0, nScript;
+ if( !xBreak.is() )
+ nRet = coAllScripts;
+ else if( rTxt.Len() )
+ {
+ for( xub_StrLen n = 0, nEnd = rTxt.Len(); n < nEnd;
+ n = static_cast<xub_StrLen>(xBreak->endOfScript( rTxt, n, nScript )) )
+ {
+ switch( nScript = xBreak->getScriptType( rTxt, n ) )
+ {
+ case i18n::ScriptType::LATIN: nRet |= SCRIPTTYPE_LATIN; break;
+ case i18n::ScriptType::ASIAN: nRet |= SCRIPTTYPE_ASIAN; break;
+ case i18n::ScriptType::COMPLEX: nRet |= SCRIPTTYPE_COMPLEX; break;
+ case i18n::ScriptType::WEAK:
+ if( !nRet )
+ nRet |= coAllScripts;
+ break;
+ }
+ if( coAllScripts == nRet )
+ break;
+ }
+ }
+ return nRet;
+}
+
diff --git a/sw/source/core/bastyp/calc.cxx b/sw/source/core/bastyp/calc.cxx
new file mode 100644
index 000000000000..f837fa7a108c
--- /dev/null
+++ b/sw/source/core/bastyp/calc.cxx
@@ -0,0 +1,1824 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+
+#include <cctype>
+#if defined(MACOSX)
+#include <stdlib.h>
+#endif
+#include <cstdlib>
+#include <climits>
+// #include <cmath>
+#include <cfloat>
+#include <hintids.hxx>
+#include <rtl/math.hxx>
+#include <editeng/langitem.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <comphelper/processfactory.hxx>
+#include <unotools/localedatawrapper.hxx>
+#include <unotools/charclass.hxx>
+#include <editeng/unolingu.hxx>
+#include <editeng/scripttypeitem.hxx>
+#include <unotools/useroptions.hxx>
+#include <tools/datetime.hxx>
+#include <svl/zforlist.hxx>
+#include <swmodule.hxx>
+#include <doc.hxx>
+#include <viewsh.hxx>
+#include <docstat.hxx>
+#include <calc.hxx>
+#include <shellres.hxx>
+#include <dbfld.hxx>
+#include <expfld.hxx>
+#include <usrfld.hxx>
+#ifndef _DBMGR_HXX
+#include <dbmgr.hxx>
+#endif
+#include <docfld.hxx>
+#include <swunodef.hxx>
+#include <swtypes.hxx>
+
+using namespace ::com::sun::star;
+
+// tippt sich schneller
+#define RESOURCE ViewShell::GetShellRes()
+
+const sal_Char __FAR_DATA sCalc_Add[] = "add";
+const sal_Char __FAR_DATA sCalc_Sub[] = "sub";
+const sal_Char __FAR_DATA sCalc_Mul[] = "mul";
+const sal_Char __FAR_DATA sCalc_Div[] = "div";
+const sal_Char __FAR_DATA sCalc_Phd[] = "phd";
+const sal_Char __FAR_DATA sCalc_Sqrt[] = "sqrt";
+const sal_Char __FAR_DATA sCalc_Pow[] = "pow";
+const sal_Char __FAR_DATA sCalc_Or[] = "or";
+const sal_Char __FAR_DATA sCalc_Xor[] = "xor";
+const sal_Char __FAR_DATA sCalc_And[] = "and";
+const sal_Char __FAR_DATA sCalc_Not[] = "not";
+const sal_Char __FAR_DATA sCalc_Eq[] = "eq";
+const sal_Char __FAR_DATA sCalc_Neq[] = "neq";
+const sal_Char __FAR_DATA sCalc_Leq[] = "leq";
+const sal_Char __FAR_DATA sCalc_Geq[] = "geq";
+const sal_Char __FAR_DATA sCalc_L[] = "l";
+const sal_Char __FAR_DATA sCalc_G[] = "g";
+const sal_Char __FAR_DATA sCalc_Sum[] = "sum";
+const sal_Char __FAR_DATA sCalc_Mean[] = "mean";
+const sal_Char __FAR_DATA sCalc_Min[] = "min";
+const sal_Char __FAR_DATA sCalc_Max[] = "max";
+const sal_Char __FAR_DATA sCalc_Sin[] = "sin";
+const sal_Char __FAR_DATA sCalc_Cos[] = "cos";
+const sal_Char __FAR_DATA sCalc_Tan[] = "tan";
+const sal_Char __FAR_DATA sCalc_Asin[] = "asin";
+const sal_Char __FAR_DATA sCalc_Acos[] = "acos";
+const sal_Char __FAR_DATA sCalc_Atan[] = "atan";
+const sal_Char __FAR_DATA sCalc_Round[] = "round";
+const sal_Char __FAR_DATA sCalc_Date[] = "date";
+
+
+
+//!!!!! ACHTUNG - Sortierte Liste aller Operatoren !!!!!
+struct _CalcOp
+{
+ union{
+ const sal_Char* pName;
+ const String* pUName;
+ };
+ SwCalcOper eOp;
+};
+
+_CalcOp __READONLY_DATA aOpTable[] = {
+/* ACOS */ {{sCalc_Acos}, CALC_ACOS}, // Arcuscosinus
+/* ADD */ {{sCalc_Add}, CALC_PLUS}, // Addition
+/* AND */ {{sCalc_And}, CALC_AND}, // log. und
+/* ASIN */ {{sCalc_Asin}, CALC_ASIN}, // Arcussinus
+/* ATAN */ {{sCalc_Atan}, CALC_ATAN}, // Arcustangens
+/* COS */ {{sCalc_Cos}, CALC_COS}, // Cosinus
+/* DATE */ {{sCalc_Date}, CALC_DATE}, // Date
+/* DIV */ {{sCalc_Div}, CALC_DIV}, // Dividieren
+/* EQ */ {{sCalc_Eq}, CALC_EQ}, // gleich
+/* G */ {{sCalc_G}, CALC_GRE}, // groesser
+/* GEQ */ {{sCalc_Geq}, CALC_GEQ}, // groesser gleich
+/* L */ {{sCalc_L}, CALC_LES}, // kleiner
+/* LEQ */ {{sCalc_Leq}, CALC_LEQ}, // kleiner gleich
+/* MAX */ {{sCalc_Max}, CALC_MAX}, // Maximalwert
+/* MEAN */ {{sCalc_Mean}, CALC_MEAN}, // Mittelwert
+/* MIN */ {{sCalc_Min}, CALC_MIN}, // Minimalwert
+/* MUL */ {{sCalc_Mul}, CALC_MUL}, // Multiplizieren
+/* NEQ */ {{sCalc_Neq}, CALC_NEQ}, // nicht gleich
+/* NOT */ {{sCalc_Not}, CALC_NOT}, // log. nicht
+/* OR */ {{sCalc_Or}, CALC_OR}, // log. oder
+/* PHD */ {{sCalc_Phd}, CALC_PHD}, // Prozent
+/* POW */ {{sCalc_Pow}, CALC_POW}, // Potenzieren
+/* ROUND */ {{sCalc_Round}, CALC_ROUND}, // Runden
+/* SIN */ {{sCalc_Sin}, CALC_SIN}, // Sinus
+/* SQRT */ {{sCalc_Sqrt}, CALC_SQRT}, // Wurzel
+/* SUB */ {{sCalc_Sub}, CALC_MINUS}, // Subtraktion
+/* SUM */ {{sCalc_Sum}, CALC_SUM}, // Summe
+/* TAN */ {{sCalc_Tan}, CALC_TAN}, // Tangens
+/* XOR */ {{sCalc_Xor}, CALC_XOR} // log. xoder
+};
+
+double __READONLY_DATA nRoundVal[] = {
+ 5.0e+0, 0.5e+0, 0.5e-1, 0.5e-2, 0.5e-3, 0.5e-4, 0.5e-5, 0.5e-6,
+ 0.5e-7, 0.5e-8, 0.5e-9, 0.5e-10,0.5e-11,0.5e-12,0.5e-13,0.5e-14,
+ 0.5e-15,0.5e-16
+};
+
+double __READONLY_DATA nKorrVal[] = {
+ 9, 9e-1, 9e-2, 9e-3, 9e-4, 9e-5, 9e-6, 9e-7, 9e-8,
+ 9e-9, 9e-10, 9e-11, 9e-12, 9e-13, 9e-14
+};
+
+ // First character may be any alphabetic or underscore.
+const sal_Int32 coStartFlags =
+ i18n::KParseTokens::ANY_LETTER_OR_NUMBER |
+ i18n::KParseTokens::ASC_UNDERSCORE |
+ i18n::KParseTokens::IGNORE_LEADING_WS;
+
+ // Continuing characters may be any alphanumeric or underscore or dot.
+const sal_Int32 coContFlags =
+ ( coStartFlags | i18n::KParseTokens::ASC_DOT )
+ & ~i18n::KParseTokens::IGNORE_LEADING_WS;
+
+
+extern "C" {
+static int
+#if defined( WNT )
+ __cdecl
+#endif
+#if defined( ICC )
+ _Optlink
+#endif
+ OperatorCompare( const void *pFirst, const void *pSecond)
+{
+ int nRet = 0;
+ if( CALC_NAME == ((_CalcOp*)pFirst)->eOp )
+ {
+ if( CALC_NAME == ((_CalcOp*)pSecond)->eOp )
+ nRet = ((_CalcOp*)pFirst)->pUName->CompareTo(
+ *((_CalcOp*)pSecond)->pUName );
+ else
+ nRet = ((_CalcOp*)pFirst)->pUName->CompareToAscii(
+ ((_CalcOp*)pSecond)->pName );
+ }
+ else
+ {
+ if( CALC_NAME == ((_CalcOp*)pSecond)->eOp )
+ nRet = -1 * ((_CalcOp*)pSecond)->pUName->CompareToAscii(
+ ((_CalcOp*)pFirst)->pName );
+ else
+ nRet = strcmp( ((_CalcOp*)pFirst)->pName,
+ ((_CalcOp*)pSecond)->pName );
+ }
+ return nRet;
+}
+
+}// extern "C"
+
+_CalcOp* FindOperator( const String& rSrch )
+{
+ _CalcOp aSrch;
+ aSrch.pUName = &rSrch;
+ aSrch.eOp = CALC_NAME;
+
+ return (_CalcOp*)bsearch( (void*) &aSrch,
+ (void*) aOpTable,
+ sizeof( aOpTable ) / sizeof( _CalcOp ),
+ sizeof( _CalcOp ),
+ OperatorCompare );
+}
+
+
+//-----------------------------------------------------------------------------
+
+SwHash* Find( const String& rStr, SwHash** ppTable, USHORT nTblSize,
+ USHORT* pPos )
+{
+ ULONG ii = 0;
+ for( xub_StrLen n = 0; n < rStr.Len(); ++n )
+ ii = ii << 1 ^ rStr.GetChar( n );
+ ii %= nTblSize;
+
+ if( pPos )
+ *pPos = (USHORT)ii;
+
+ for( SwHash* pEntry = *(ppTable+ii); pEntry; pEntry = pEntry->pNext )
+ if( rStr == pEntry->aStr )
+ return pEntry;
+ return 0;
+}
+
+inline LanguageType GetDocAppScriptLang( SwDoc& rDoc )
+{
+ return ((SvxLanguageItem&)rDoc.GetDefault(
+ GetWhichOfScript( RES_CHRATR_LANGUAGE,
+ GetI18NScriptTypeOfLanguage( (USHORT)GetAppLanguage() ))
+ )).GetLanguage();
+}
+
+double lcl_ConvertToDateValue( SwDoc& rDoc, sal_Int32 nDate )
+{
+ double nRet = 0;
+ SvNumberFormatter* pFormatter = rDoc.GetNumberFormatter();
+ if( pFormatter )
+ {
+ Date* pNull = pFormatter->GetNullDate();
+ Date aDate( nDate >> 24, (nDate & 0x00FF0000) >> 16, nDate & 0x0000FFFF );
+ nRet = aDate - *pNull;
+ }
+ return nRet;
+}
+
+//-----------------------------------------------------------------------------
+
+/******************************************************************************
+|*
+|* SwCalc::SwCalc( SwDoc* pD ) :
+|*
+|* Erstellung OK 12-02-93 11:04am
+|* Letzte Aenderung JP 03.11.95
+|*
+|******************************************************************************/
+
+SwCalc::SwCalc( SwDoc& rD )
+ :
+ aErrExpr( aEmptyStr, SwSbxValue(), 0 ),
+ rDoc( rD ),
+ pLclData( &SvtSysLocale().GetLocaleData() ),
+ pCharClass( &GetAppCharClass() ),
+ nListPor( 0 ),
+ eError( CALC_NOERR )
+{
+ aErrExpr.aStr.AssignAscii( "~C_ERR~" );
+ memset( VarTable, 0, sizeof(VarTable) );
+ LanguageType eLang = GetDocAppScriptLang( rDoc );
+
+ if( eLang != SvxLocaleToLanguage( pLclData->getLocale() ) ||
+ eLang != SvxLocaleToLanguage( pCharClass->getLocale() ) )
+ {
+ STAR_NMSPC::lang::Locale aLocale( SvxCreateLocale( eLang ));
+ STAR_REFERENCE( lang::XMultiServiceFactory ) xMSF(
+ ::comphelper::getProcessServiceFactory() );
+ pCharClass = new CharClass( xMSF, aLocale );
+ pLclData = new LocaleDataWrapper( xMSF, aLocale );
+ }
+
+ sCurrSym = pLclData->getCurrSymbol();
+ sCurrSym.EraseLeadingChars().EraseTrailingChars();
+ pCharClass->toLower( sCurrSym );
+
+static sal_Char __READONLY_DATA
+ sNType0[] = "false",
+ sNType1[] = "true",
+ sNType2[] = "pi",
+ sNType3[] = "e",
+ sNType4[] = "tables",
+ sNType5[] = "graf",
+ sNType6[] = "ole",
+ sNType7[] = "page",
+ sNType8[] = "para",
+ sNType9[] = "word",
+ sNType10[]= "char",
+
+ sNType11[] = "user_firstname" ,
+ sNType12[] = "user_lastname" ,
+ sNType13[] = "user_initials" ,
+ sNType14[] = "user_company" ,
+ sNType15[] = "user_street" ,
+ sNType16[] = "user_country" ,
+ sNType17[] = "user_zipcode" ,
+ sNType18[] = "user_city" ,
+ sNType19[] = "user_title" ,
+ sNType20[] = "user_position" ,
+ sNType21[] = "user_tel_work" ,
+ sNType22[] = "user_tel_home" ,
+ sNType23[] = "user_fax" ,
+ sNType24[] = "user_email" ,
+ sNType25[] = "user_state" ,
+ sNType26[] = "graph"
+ ;
+
+static const sal_Char* __READONLY_DATA sNTypeTab[ 27 ] =
+{
+ sNType0, sNType1, sNType2, sNType3, sNType4, sNType5,
+ sNType6, sNType7, sNType8, sNType9, sNType10, sNType11,
+ sNType12, sNType13, sNType14, sNType15, sNType16, sNType17,
+ sNType18, sNType19, sNType20, sNType21, sNType22, sNType23,
+ sNType24,
+
+ // diese sind mit doppelten HashIds
+ sNType25, sNType26
+};
+static USHORT __READONLY_DATA aHashValue[ 27 ] =
+{
+ 34, 38, 43, 7, 18, 32, 22, 29, 30, 33, 3,
+ 28, 24, 40, 9, 11, 26, 45, 4, 23, 36, 44, 19, 5, 1,
+ // diese sind mit doppelten HashIds
+ 11, 38
+};
+static USHORT __READONLY_DATA aAdrToken[ 12 ] =
+{
+ USER_OPT_COMPANY, USER_OPT_STREET, USER_OPT_COUNTRY, USER_OPT_ZIP,
+ USER_OPT_CITY, USER_OPT_TITLE, USER_OPT_POSITION, USER_OPT_TELEPHONEWORK,
+ USER_OPT_TELEPHONEHOME, USER_OPT_FAX, USER_OPT_EMAIL, USER_OPT_STATE
+};
+
+static USHORT SwDocStat::* __READONLY_DATA aDocStat1[ 3 ] =
+{
+ &SwDocStat::nTbl, &SwDocStat::nGrf, &SwDocStat::nOLE
+};
+static ULONG SwDocStat::* __READONLY_DATA aDocStat2[ 4 ] =
+{
+ &SwDocStat::nPage, &SwDocStat::nPara,
+ &SwDocStat::nWord, &SwDocStat::nChar
+};
+
+#if TBLSZ != 47
+#error Alle Hashwerte angepasst?
+#endif
+
+ const SwDocStat& rDocStat = rDoc.GetDocStat();
+
+ SwSbxValue nVal;
+ String sTmpStr;
+ USHORT n;
+
+ for( n = 0; n < 25; ++n )
+ {
+ sTmpStr.AssignAscii( sNTypeTab[ n ] );
+ VarTable[ aHashValue[ n ] ] = new SwCalcExp( sTmpStr, nVal, 0 );
+ }
+
+ ((SwCalcExp*)VarTable[ aHashValue[ 0 ] ])->nValue.PutBool( FALSE );
+ ((SwCalcExp*)VarTable[ aHashValue[ 1 ] ])->nValue.PutBool( TRUE );
+ ((SwCalcExp*)VarTable[ aHashValue[ 2 ] ])->nValue.PutDouble( F_PI );
+ ((SwCalcExp*)VarTable[ aHashValue[ 3 ] ])->nValue.PutDouble( 2.7182818284590452354 );
+
+ for( n = 0; n < 3; ++n )
+ ((SwCalcExp*)VarTable[ aHashValue[ n + 4 ] ])->nValue.PutLong( rDocStat.*aDocStat1[ n ] );
+ for( n = 0; n < 4; ++n )
+ ((SwCalcExp*)VarTable[ aHashValue[ n + 7 ] ])->nValue.PutLong( rDocStat.*aDocStat2[ n ] );
+
+ SvtUserOptions& rUserOptions = SW_MOD()->GetUserOptions();
+
+ ((SwCalcExp*)VarTable[ aHashValue[ 11 ] ])->nValue.PutString( (String)rUserOptions.GetFirstName() );
+ ((SwCalcExp*)VarTable[ aHashValue[ 12 ] ])->nValue.PutString( (String)rUserOptions.GetLastName() );
+ ((SwCalcExp*)VarTable[ aHashValue[ 13 ] ])->nValue.PutString( (String)rUserOptions.GetID() );
+
+ for( n = 0; n < 11; ++n )
+ ((SwCalcExp*)VarTable[ aHashValue[ n + 14 ] ])->nValue.PutString(
+ (String)rUserOptions.GetToken( aAdrToken[ n ] ));
+
+ nVal.PutString( (String)rUserOptions.GetToken( aAdrToken[ 11 ] ));
+ sTmpStr.AssignAscii( sNTypeTab[ 25 ] );
+ VarTable[ aHashValue[ 25 ] ]->pNext = new SwCalcExp( sTmpStr, nVal, 0 );
+
+// at time its better not to use "graph", because then the im-/export have
+// to change in all formulas this name.
+// nVal.PutLong( rDocStat.*aDocStat1[ 1 ] );
+// VarTable[ aHashValue[ 26 ] ]->pNext = new SwCalcExp(
+// sNTypeTab[ 26 ], nVal, 0 );
+}
+
+/******************************************************************************
+|*
+|* SwCalc::~SwCalc()
+|*
+|* Erstellung OK 12-02-93 11:04am
+|* Letzte Aenderung OK 12-02-93 11:04am
+|*
+|******************************************************************************/
+
+SwCalc::~SwCalc()
+{
+ for( USHORT n = 0; n < TBLSZ; ++n )
+ delete VarTable[n];
+ if( pLclData != &SvtSysLocale().GetLocaleData() )
+ delete pLclData;
+ if( pCharClass != &GetAppCharClass() )
+ delete pCharClass;
+}
+
+/******************************************************************************
+|*
+|* SwSbxValue SwCalc::Calculate( const String& rStr )
+|*
+|* Erstellung OK 12-02-93 11:04am
+|* Letzte Aenderung OK 12-02-93 11:04am
+|*
+|******************************************************************************/
+
+SwSbxValue SwCalc::Calculate( const String& rStr )
+{
+ eError = CALC_NOERR;
+ SwSbxValue nResult;
+
+ if( !rStr.Len() )
+ return nResult;
+
+ nListPor = 0;
+ eCurrListOper = CALC_PLUS; // defaulten auf Summe
+
+ sCommand = rStr;
+ nCommandPos = 0;
+
+ while( (eCurrOper = GetToken()) != CALC_ENDCALC && eError == CALC_NOERR )
+ nResult = Expr();
+
+ if( eError )
+ nResult.PutDouble( DBL_MAX );
+
+ return nResult;
+}
+
+/******************************************************************************
+|*
+|* String SwCalc::GetStrResult( SwSbxValue nValue, BOOL bRound = TRUE )
+|* Beschreibung Der Parameter bRound ist auf TRUE defaultet und darf
+|* nur beim errechnen von Tabellenzellen auf FALSE gesetzt
+|* werden, damit keine Rundungsfehler beim zusammenstellen
+|* der Formel entstehen.
+|* Erstellung OK 12-02-93 11:04am
+|* Letzte Aenderung JP 19.02.98
+|*
+|******************************************************************************/
+
+String SwCalc::GetStrResult( const SwSbxValue& rVal, BOOL bRound )
+{
+ if( !rVal.IsDouble() )
+ return rVal.GetString();
+
+ return GetStrResult( rVal.GetDouble(), bRound );
+}
+
+
+String SwCalc::GetStrResult( double nValue, BOOL )
+{
+ if( nValue >= DBL_MAX )
+ switch( eError )
+ {
+ case CALC_SYNTAX : return RESOURCE->aCalc_Syntax;
+ case CALC_ZERODIV : return RESOURCE->aCalc_ZeroDiv;
+ case CALC_BRACK : return RESOURCE->aCalc_Brack;
+ case CALC_POWERR : return RESOURCE->aCalc_Pow;
+ case CALC_VARNFND : return RESOURCE->aCalc_VarNFnd;
+ case CALC_OVERFLOW : return RESOURCE->aCalc_Overflow;
+ case CALC_WRONGTIME : return RESOURCE->aCalc_WrongTime;
+ default : return RESOURCE->aCalc_Default;
+ }
+
+ USHORT nDec = 15; //pLclData->getNumDigits();
+ String aRetStr( ::rtl::math::doubleToUString( nValue,
+ rtl_math_StringFormat_Automatic,
+ nDec,
+ pLclData->getNumDecimalSep().GetChar(0),
+ true ));
+
+ return aRetStr;
+}
+
+/******************************************************************************
+|*
+|* SwCalcExp* SwCalc::VarLook( const String& )
+|*
+|* Erstellung OK 12-02-93 11:04am
+|* Letzte Aenderung JP 15.11.99
+|*
+|******************************************************************************/
+
+SwCalcExp* SwCalc::VarInsert( const String &rStr )
+{
+ String aStr( rStr );
+ pCharClass->toLower( aStr );
+ return VarLook( aStr, 1 );
+}
+
+/******************************************************************************
+|*
+|* SwCalcExp* SwCalc::VarLook( const String& , USHORT ins )
+|*
+|* Erstellung OK 12-02-93 11:04am
+|* Letzte Aenderung JP 15.11.99
+|*
+|******************************************************************************/
+SwCalcExp* SwCalc::VarLook( const String& rStr, USHORT ins )
+{
+ aErrExpr.nValue.SetVoidValue(false);
+
+ USHORT ii = 0;
+ String aStr( rStr );
+ pCharClass->toLower( aStr );
+
+ SwHash* pFnd = Find( aStr, VarTable, TBLSZ, &ii );
+
+ if( !pFnd )
+ {
+ // dann sehen wir mal im Doc nach:
+ SwHash** ppDocTbl = rDoc.GetUpdtFlds().GetFldTypeTable();
+ for( SwHash* pEntry = *(ppDocTbl+ii); pEntry; pEntry = pEntry->pNext )
+ if( aStr == pEntry->aStr )
+ {
+ // dann hier zufuegen
+ pFnd = new SwCalcExp( aStr, SwSbxValue(),
+ ((SwCalcFldType*)pEntry)->pFldType );
+ pFnd->pNext = *(VarTable+ii);
+ *(VarTable+ii) = pFnd;
+ break;
+ }
+ }
+
+ if( pFnd )
+ {
+ SwCalcExp* pFndExp = (SwCalcExp*)pFnd;
+
+ if( pFndExp->pFldType && pFndExp->pFldType->Which() == RES_USERFLD )
+ {
+ SwUserFieldType* pUFld = (SwUserFieldType*)pFndExp->pFldType;
+ if( nsSwGetSetExpType::GSE_STRING & pUFld->GetType() )
+ pFndExp->nValue.PutString( pUFld->GetContent() );
+ else if( !pUFld->IsValid() )
+ {
+ // Die aktuellen Werte sichern . . .
+ USHORT nOld_ListPor = nListPor;
+ SwSbxValue nOld_LastLeft = nLastLeft;
+ SwSbxValue nOld_NumberValue = nNumberValue;
+ xub_StrLen nOld_CommandPos = nCommandPos;
+ SwCalcOper eOld_CurrOper = eCurrOper;
+ SwCalcOper eOld_CurrListOper = eCurrListOper;
+
+ pFndExp->nValue.PutDouble( pUFld->GetValue( *this ) );
+
+ // . . . und zurueck damit.
+ nListPor = nOld_ListPor;
+ nLastLeft = nOld_LastLeft;
+ nNumberValue = nOld_NumberValue;
+ nCommandPos = nOld_CommandPos;
+ eCurrOper = eOld_CurrOper;
+ eCurrListOper = eOld_CurrListOper;
+ }
+ else
+ pFndExp->nValue.PutDouble( pUFld->GetValue() );
+ }
+ return pFndExp;
+ }
+
+ // Name(p)=Adress.PLZ oder Adress.DATENSATZNUMMER
+ // DBSETNUMBERFLD = DatenSATZ-nummernfeld (NICHT "setze Datensatznummer!!!")
+ // #101436#: At this point the "real" case variable has to be used
+ String sTmpName( rStr );
+ ::ReplacePoint( sTmpName );
+
+ if( !ins )
+ {
+ SwNewDBMgr *pMgr = rDoc.GetNewDBMgr();
+
+ // Name(p)=Adress.PLZ oder Adress.DATENSATZNUMMER
+ // DBSETNUMBERFLD = DatenSATZ-nummernfeld (NICHT "setze Datensatznummer!!!")
+ String sDBName(GetDBName( sTmpName ));
+ String sSourceName(sDBName.GetToken(0, DB_DELIM));
+ String sTableName(sDBName.GetToken(0).GetToken(1, DB_DELIM));
+ if( pMgr && sSourceName.Len() && sTableName.Len() &&
+ pMgr->OpenDataSource(sSourceName, sTableName, -1, false))
+ {
+ String sColumnName( GetColumnName( sTmpName ));
+ ASSERT (sColumnName.Len(), "DB-Spaltenname fehlt!");
+
+ String sDBNum( SwFieldType::GetTypeStr(TYP_DBSETNUMBERFLD) );
+ pCharClass->toLower(sDBNum);
+
+ // Hier nochmal initialisieren, da das nicht mehr in docfld
+ // fuer Felder != RES_DBFLD geschieht. Z.B. wenn ein Expressionfield
+ // vor einem DB_Field in einem Dok vorkommt.
+ VarChange( sDBNum, pMgr->GetSelectedRecordId(sSourceName, sTableName));
+
+ if( sDBNum.EqualsIgnoreCaseAscii(sColumnName) )
+ {
+ aErrExpr.nValue.PutLong(long(pMgr->GetSelectedRecordId(sSourceName, sTableName)));
+ return &aErrExpr;
+ }
+
+ ULONG nTmpRec = 0;
+ if( 0 != ( pFnd = Find( sDBNum, VarTable, TBLSZ ) ) )
+ nTmpRec = ((SwCalcExp*)pFnd)->nValue.GetULong();
+
+ String sResult;
+ double nNumber = DBL_MAX;
+
+ long nLang = SvxLocaleToLanguage( pLclData->getLocale() );
+ if(pMgr->GetColumnCnt( sSourceName, sTableName, sColumnName,
+ nTmpRec, nLang, sResult, &nNumber ))
+ {
+ if (nNumber != DBL_MAX)
+ aErrExpr.nValue.PutDouble( nNumber );
+ else
+ aErrExpr.nValue.PutString( sResult );
+
+ return &aErrExpr;
+ }
+ }
+ else
+ {
+ //data source was not available - set return to "NoValue"
+ aErrExpr.nValue.SetVoidValue(true);
+ }
+ // auf keinen fall eintragen!!
+ return &aErrExpr;
+ }
+
+
+ SwCalcExp* pNewExp = new SwCalcExp( aStr, SwSbxValue(), 0 );
+ pNewExp->pNext = VarTable[ ii ];
+ VarTable[ ii ] = pNewExp;
+
+ String sColumnName( GetColumnName( sTmpName ));
+ ASSERT( sColumnName.Len(), "DB-Spaltenname fehlt!" );
+ if( sColumnName.EqualsIgnoreCaseAscii(
+ SwFieldType::GetTypeStr( TYP_DBSETNUMBERFLD ) ))
+ {
+ SwNewDBMgr *pMgr = rDoc.GetNewDBMgr();
+ String sDBName(GetDBName( sTmpName ));
+ String sSourceName(sDBName.GetToken(0, DB_DELIM));
+ String sTableName(sDBName.GetToken(0).GetToken(1, DB_DELIM));
+ if( pMgr && sSourceName.Len() && sTableName.Len() &&
+ pMgr->OpenDataSource(sSourceName, sTableName, -1, false) &&
+ !pMgr->IsInMerge())
+ pNewExp->nValue.PutULong( pMgr->GetSelectedRecordId(sSourceName, sTableName));
+ else
+ pNewExp->nValue.SetVoidValue(true);
+ }
+
+ return pNewExp;
+}
+
+/******************************************************************************
+|*
+|* BOOL SwCalc::VarChange( const String& rStr, const SwSbxValue nValue )
+|*
+|* Erstellung OK 12-02-93 11:04am
+|* Letzte Aenderung OK 12-02-93 11:04am
+|*
+|******************************************************************************/
+
+void SwCalc::VarChange( const String& rStr, double nValue )
+{
+ SwSbxValue aVal( nValue );
+ VarChange( rStr, aVal );
+}
+
+void SwCalc::VarChange( const String& rStr, const SwSbxValue& rValue )
+{
+ String aStr( rStr );
+ pCharClass->toLower( aStr );
+
+ USHORT nPos = 0;
+ SwCalcExp* pFnd = (SwCalcExp*)Find( aStr, VarTable, TBLSZ, &nPos );
+
+ if( !pFnd )
+ {
+ pFnd = new SwCalcExp( aStr, SwSbxValue( rValue ), 0 );
+ pFnd->pNext = VarTable[ nPos ];
+ VarTable[ nPos ] = pFnd;
+ }
+ else
+ pFnd->nValue = rValue;
+}
+
+/******************************************************************************
+|*
+|* BOOL SwCalc::Push( const void* pPtr )
+|*
+|* Erstellung OK 12-02-93 11:05am
+|* Letzte Aenderung OK 12-02-93 11:05am
+|*
+|******************************************************************************/
+
+BOOL SwCalc::Push( const VoidPtr pPtr )
+{
+ if( USHRT_MAX != aRekurStk.GetPos( pPtr ) )
+ return FALSE;
+
+ aRekurStk.Insert( pPtr, aRekurStk.Count() );
+ return TRUE;
+}
+
+/******************************************************************************
+|*
+|* void SwCalc::Pop( const void* pPtr )
+|*
+|* Erstellung OK 12-02-93 11:05am
+|* Letzte Aenderung OK 12-02-93 11:05am
+|*
+|******************************************************************************/
+
+void SwCalc::Pop( const VoidPtr )
+{
+ ASSERT( aRekurStk.Count(), "SwCalc: Pop auf ungueltigen Ptr" );
+
+ aRekurStk.Remove( aRekurStk.Count() - 1 );
+}
+
+
+/******************************************************************************
+|*
+|* SwCalcOper SwCalc::GetToken()
+|*
+|* Erstellung OK 12-02-93 11:05am
+|* Letzte Aenderung JP 03.11.95
+|*
+|******************************************************************************/
+
+SwCalcOper SwCalc::GetToken()
+{
+#if OSL_DEBUG_LEVEL > 1
+//JP 25.01.2001: static for switch back to the "old" implementation of the
+// calculator, which don't use the I18N routines.
+static int nUseOld = 0;
+if( !nUseOld )
+{
+#endif
+
+ if( nCommandPos >= sCommand.Len() )
+ return eCurrOper = CALC_ENDCALC;
+
+ using namespace ::com::sun::star::i18n;
+ {
+ // Parse any token.
+ ParseResult aRes = pCharClass->parseAnyToken( sCommand, nCommandPos,
+ coStartFlags, aEmptyStr,
+ coContFlags, aEmptyStr );
+
+ BOOL bSetError = TRUE;
+ xub_StrLen nRealStt = nCommandPos + (xub_StrLen)aRes.LeadingWhiteSpace;
+ if( aRes.TokenType & (KParseType::ASC_NUMBER | KParseType::UNI_NUMBER) )
+ {
+ nNumberValue.PutDouble( aRes.Value );
+ eCurrOper = CALC_NUMBER;
+ bSetError = FALSE;
+ }
+ else if( aRes.TokenType & KParseType::IDENTNAME )
+ {
+ String aName( sCommand.Copy( nRealStt, static_cast<xub_StrLen>(aRes.EndPos) - nRealStt ));
+ //#101436#: the variable may contain a database name it must not be converted to lower case
+ // instead all further comparisons must be done case-insensitive
+ //pCharClass->toLower( aName );
+ String sLowerCaseName(aName);
+ pCharClass->toLower( sLowerCaseName );
+ // Currency-Symbol abfangen
+ if( sLowerCaseName == sCurrSym )
+ {
+ nCommandPos = (xub_StrLen)aRes.EndPos;
+ return GetToken(); // also nochmal aufrufen
+ }
+
+ // Operations abfangen
+ _CalcOp* pFnd = ::FindOperator( sLowerCaseName );
+ if( pFnd )
+ {
+ switch( ( eCurrOper = ((_CalcOp*)pFnd)->eOp ) )
+ {
+ case CALC_SUM:
+ case CALC_MEAN:
+ eCurrListOper = CALC_PLUS;
+ break;
+ case CALC_MIN:
+ eCurrListOper = CALC_MIN_IN;
+ break;
+ case CALC_MAX:
+ eCurrListOper = CALC_MAX_IN;
+ break;
+ case CALC_DATE:
+ eCurrListOper = CALC_MONTH;
+ break;
+ default:
+ break;
+ }
+ nCommandPos = (xub_StrLen)aRes.EndPos;
+ return eCurrOper;
+ }
+ aVarName = aName;
+ eCurrOper = CALC_NAME;
+ bSetError = FALSE;
+ }
+ else if ( aRes.TokenType & KParseType::DOUBLE_QUOTE_STRING )
+ {
+ nNumberValue.PutString( String( aRes.DequotedNameOrString ));
+ eCurrOper = CALC_NUMBER;
+ bSetError = FALSE;
+ }
+ else if( aRes.TokenType & KParseType::ONE_SINGLE_CHAR )
+ {
+ String aName( sCommand.Copy( nRealStt, static_cast<xub_StrLen>(aRes.EndPos) - nRealStt ));
+ if( 1 == aName.Len() )
+ {
+ bSetError = FALSE;
+ sal_Unicode ch = aName.GetChar( 0 );
+ switch( ch )
+ {
+ case ';': if( CALC_MONTH == eCurrListOper ||
+ CALC_DAY == eCurrListOper )
+ {
+ eCurrOper = eCurrListOper;
+ break;
+ }
+ case '\n':
+ eCurrOper = CALC_PRINT;
+ break;
+ case '%':
+ case '^':
+ case '*':
+ case '/':
+ case '+':
+ case '-':
+ case '(':
+ case ')': eCurrOper = SwCalcOper(ch);
+ break;
+
+ case '=':
+ case '!':
+ {
+ SwCalcOper eTmp2;
+ if( '=' == ch )
+ eCurrOper = SwCalcOper('='), eTmp2 = CALC_EQ;
+ else
+ eCurrOper = CALC_NOT, eTmp2 = CALC_NEQ;
+
+ if( aRes.EndPos < sCommand.Len() &&
+ '=' == sCommand.GetChar( (xub_StrLen)aRes.EndPos ) )
+ {
+ eCurrOper = eTmp2;
+ ++aRes.EndPos;
+ }
+ }
+ break;
+
+ case cListDelim :
+ eCurrOper = eCurrListOper;
+ break;
+
+ case '[':
+ if( aRes.EndPos < sCommand.Len() )
+ {
+ aVarName.Erase();
+ xub_StrLen nFndPos = (xub_StrLen)aRes.EndPos,
+ nSttPos = nFndPos;
+
+ do{
+ if( STRING_NOTFOUND != ( nFndPos =
+ sCommand.Search( ']', nFndPos )) )
+ {
+ // ignore the ]
+ if( '\\' == sCommand.GetChar(nFndPos-1))
+ {
+ aVarName += sCommand.Copy( nSttPos,
+ nFndPos - nSttPos - 1 );
+ nSttPos = ++nFndPos;
+ }
+ else
+ break;
+ }
+ } while( STRING_NOTFOUND != nFndPos );
+
+ if( STRING_NOTFOUND != nFndPos )
+ {
+ if( nSttPos != nFndPos )
+ aVarName += sCommand.Copy( nSttPos,
+ nFndPos - nSttPos );
+ aRes.EndPos = nFndPos + 1;
+ eCurrOper = CALC_NAME;
+ }
+ else
+ bSetError = TRUE;
+ }
+ else
+ bSetError = TRUE;
+ break;
+
+ default:
+ bSetError = TRUE;
+ break;
+ }
+ }
+ }
+ else if( aRes.TokenType & KParseType::BOOLEAN )
+ {
+ String aName( sCommand.Copy( nRealStt, static_cast<xub_StrLen>(aRes.EndPos) - nRealStt ));
+ if( aName.Len() )
+ {
+ sal_Unicode ch = aName.GetChar(0);
+
+ bSetError = TRUE;
+ if ('<' == ch || '>' == ch)
+ {
+ bSetError = FALSE;
+
+ SwCalcOper eTmp2 = ('<' == ch) ? CALC_LEQ : CALC_GEQ;
+ eCurrOper = ('<' == ch) ? CALC_LES : CALC_GRE;
+
+ if( 2 == aName.Len() && '=' == aName.GetChar(1) )
+ eCurrOper = eTmp2;
+ else if( 1 != aName.Len() )
+ bSetError = TRUE;
+ }
+ }
+ }
+ else if( nRealStt == sCommand.Len() )
+ {
+ eCurrOper = CALC_ENDCALC;
+ bSetError = FALSE;
+ }
+
+ if( bSetError )
+ {
+ eError = CALC_SYNTAX;
+ eCurrOper = CALC_PRINT;
+ }
+ nCommandPos = (xub_StrLen)aRes.EndPos;
+ };
+
+#if OSL_DEBUG_LEVEL > 1
+
+#define NextCh( s, n ) (nCommandPos < sCommand.Len() ? sCommand.GetChar( nCommandPos++ ) : 0)
+
+}
+else
+{
+ sal_Unicode ch;
+ sal_Unicode cTSep = pLclData->getNumThousandSep().GetChar(0),
+ cDSep = pLclData->getNumDecimalSep().GetChar(0);
+
+ do {
+ if( 0 == ( ch = NextCh( sCommand, nCommandPos ) ) )
+ return eCurrOper = CALC_ENDCALC;
+ } while ( ch == '\t' || ch == ' ' || ch == cTSep );
+
+ if( ch == cDSep )
+ ch = '.';
+
+ switch( ch )
+ {
+ case ';': if( CALC_MONTH == eCurrListOper || CALC_DAY == eCurrListOper )
+ {
+ eCurrOper = eCurrListOper;
+ break;
+ } // else .. no break
+ case '\n':
+ {
+ sal_Unicode c;
+ while( nCommandPos < sCommand.Len() && ( ( c =
+ sCommand.GetChar( nCommandPos ) ) == ' ' ||
+ c == '\t' || c == '\x0a' || c == '\x0d' ))
+ ++nCommandPos;
+ eCurrOper = CALC_PRINT;
+ }
+ break;
+ case '%':
+ case '^':
+ case '*':
+ case '/':
+ case '+':
+ case '-':
+ case '(':
+ case ')': eCurrOper = SwCalcOper(ch);
+ break;
+
+ case '=': if( '=' == sCommand.GetChar( nCommandPos ) )
+ {
+ ++nCommandPos;
+ eCurrOper = CALC_EQ;
+ }
+ else
+ eCurrOper = SwCalcOper(ch);
+ break;
+
+ case '!': if( '=' == sCommand.GetChar( nCommandPos ) )
+ {
+ ++nCommandPos;
+ eCurrOper = CALC_NEQ;
+ }
+ else
+ eCurrOper = CALC_NOT;
+ break;
+
+ case '>':
+ case '<': eCurrOper = '>' == ch ? CALC_GRE : CALC_LES;
+ if( '=' == (ch = sCommand.GetChar( nCommandPos ) ) )
+ {
+ ++nCommandPos;
+ eCurrOper = CALC_GRE == eCurrOper ? CALC_GEQ : CALC_LEQ;
+ }
+ else if( ' ' != ch )
+ {
+ eError = CALC_SYNTAX;
+ eCurrOper = CALC_PRINT;
+ }
+ break;
+
+ case cListDelim :
+ eCurrOper = eCurrListOper;
+ break;
+
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ',':
+ case '.': {
+ double nVal;
+ --nCommandPos; // auf das 1. Zeichen zurueck
+ if( Str2Double( sCommand, nCommandPos, nVal, pLclData ))
+ {
+ nNumberValue.PutDouble( nVal );
+ eCurrOper = CALC_NUMBER;
+ }
+ else
+ {
+ // fehlerhafte Zahl
+ eError = CALC_SYNTAX;
+ eCurrOper = CALC_PRINT;
+ }
+ }
+ break;
+
+ case '[': {
+ String aStr;
+ BOOL bIgnore = FALSE;
+ do {
+ while( 0 != ( ch = NextCh( sCommand, nCommandPos ))
+ && ch != ']' )
+ {
+ if( !bIgnore && '\\' == ch )
+ bIgnore = TRUE;
+ else if( bIgnore )
+ bIgnore = FALSE;
+ aStr += ch;
+ }
+
+ if( !bIgnore )
+ break;
+
+ aStr.SetChar( aStr.Len() - 1, ch );
+ } while( ch );
+
+ aVarName = aStr;
+ eCurrOper = CALC_NAME;
+ }
+ break;
+
+ case '"': {
+ xub_StrLen nStt = nCommandPos;
+ while( 0 != ( ch = NextCh( sCommand, nCommandPos ) )
+ && '"' != ch )
+ ;
+
+ xub_StrLen nLen = nCommandPos - nStt;
+ if( '"' == ch )
+ --nLen;
+ nNumberValue.PutString( sCommand.Copy( nStt, nLen ));
+ eCurrOper = CALC_NUMBER;
+ }
+ break;
+
+ default: if( ch && pCharClass->isLetter( sCommand, nCommandPos - 1)
+ || '_' == ch )
+ {
+ xub_StrLen nStt = nCommandPos-1;
+ while( 0 != (ch = NextCh( sCommand, nCommandPos )) &&
+ (pCharClass->isLetterNumeric(
+ sCommand, nCommandPos - 1) ||
+ ch == '_' || ch == '.' ) )
+ ;
+
+ if( ch )
+ --nCommandPos;
+
+ String aStr( sCommand.Copy( nStt, nCommandPos-nStt ));
+ pCharClass->toLower( aStr );
+
+
+ // Currency-Symbol abfangen
+ if( aStr == sCurrSym )
+ return GetToken(); // also nochmal aufrufen
+
+ // Operations abfangen
+ _CalcOp* pFnd = ::FindOperator( aStr );
+ if( pFnd )
+ {
+ switch( ( eCurrOper = ((_CalcOp*)pFnd)->eOp ) )
+ {
+ case CALC_SUM :
+ case CALC_MEAN : eCurrListOper = CALC_PLUS;
+ break;
+ case CALC_MIN : eCurrListOper = CALC_MIN_IN;
+ break;
+ case CALC_MAX : eCurrListOper = CALC_MAX_IN;
+ break;
+ case CALC_DATE : eCurrListOper = CALC_MONTH;
+ break;
+ default :
+ break;
+ }
+ return eCurrOper;
+ }
+ aVarName = aStr;
+ eCurrOper = CALC_NAME;
+ }
+ else
+ {
+ eError = CALC_SYNTAX;
+ eCurrOper = CALC_PRINT;
+ }
+ break;
+ }
+
+}
+#endif
+ return eCurrOper;
+}
+
+/******************************************************************************
+|*
+|* SwSbxValue SwCalc::Term()
+|*
+|* Erstellung OK 12-02-93 11:05am
+|* Letzte Aenderung JP 16.01.96
+|*
+|******************************************************************************/
+
+SwSbxValue SwCalc::Term()
+{
+ SwSbxValue left( Prim() );
+ nLastLeft = left;
+ for(;;)
+ {
+ USHORT nSbxOper = USHRT_MAX;
+
+ switch( eCurrOper )
+ {
+// wir haben kein Bitweises verodern, oder ?
+// case CALC_AND: eSbxOper = SbxAND; break;
+// case CALC_OR: eSbxOper = SbxOR; break;
+// case CALC_XOR: eSbxOper = SbxXOR; break;
+ case CALC_AND: {
+ GetToken();
+ BOOL bB = Prim().GetBool();
+ left.PutBool( left.GetBool() && bB );
+ }
+ break;
+ case CALC_OR: {
+ GetToken();
+ BOOL bB = Prim().GetBool();
+ left.PutBool( left.GetBool() || bB );
+ }
+ break;
+ case CALC_XOR: {
+ GetToken();
+ BOOL bR = Prim().GetBool();
+ BOOL bL = left.GetBool();
+ left.PutBool( (bL && !bR) || (!bL && bR) );
+ }
+ break;
+
+ case CALC_EQ: nSbxOper = SbxEQ; break;
+ case CALC_NEQ: nSbxOper = SbxNE; break;
+ case CALC_LEQ: nSbxOper = SbxLE; break;
+ case CALC_GEQ: nSbxOper = SbxGE; break;
+ case CALC_GRE: nSbxOper = SbxGT; break;
+ case CALC_LES: nSbxOper = SbxLT; break;
+
+ case CALC_MUL: nSbxOper = SbxMUL; break;
+ case CALC_DIV: nSbxOper = SbxDIV; break;
+
+ case CALC_MIN_IN:
+ {
+ GetToken();
+ SwSbxValue e = Prim();
+ left = left.GetDouble() < e.GetDouble()
+ ? left : e;
+ }
+ break;
+ case CALC_MAX_IN:
+ {
+ GetToken();
+ SwSbxValue e = Prim();
+ left = left.GetDouble() > e.GetDouble()
+ ? left : e;
+ }
+ break;
+ case CALC_MONTH:
+ {
+ GetToken();
+ SwSbxValue e = Prim();
+ sal_Int32 nYear = (sal_Int32) floor( left.GetDouble() );
+ nYear = nYear & 0x0000FFFF;
+ sal_Int32 nMonth = (INT32) floor( e.GetDouble() );
+ nMonth = ( nMonth & 0x000000FF ) << 16;
+ left.PutLong( nMonth + nYear );
+ eCurrOper = CALC_DAY;
+ }
+ break;
+ case CALC_DAY:
+ {
+ GetToken();
+ SwSbxValue e = Prim();
+ sal_Int32 nYearMonth = (sal_Int32) floor( left.GetDouble() );
+ nYearMonth = nYearMonth & 0x00FFFFFF;
+ sal_Int32 nDay = (sal_Int32) floor( e.GetDouble() );
+ nDay = ( nDay & 0x000000FF ) << 24;
+ left = lcl_ConvertToDateValue( rDoc, nDay + nYearMonth );
+ }
+ break;
+ case CALC_ROUND:
+ {
+ GetToken();
+ SwSbxValue e = Prim();
+
+ double fVal = 0;
+ double fFac = 1;
+ INT32 nDec = (INT32) floor( e.GetDouble() );
+ if( nDec < -20 || nDec > 20 )
+ {
+ eError = CALC_OVERFLOW;
+ left.Clear();
+ return left;
+ }
+ fVal = left.GetDouble();
+ USHORT i;
+ if( nDec >= 0)
+ for (i = 0; i < (USHORT) nDec; ++i )
+ fFac *= 10.0;
+ else
+ for (i = 0; i < (USHORT) -nDec; ++i )
+ fFac /= 10.0;
+
+ fVal *= fFac;
+
+ BOOL bSign;
+ if (fVal < 0.0)
+ {
+ fVal *= -1.0;
+ bSign = TRUE;
+ }
+ else
+ bSign = FALSE;
+
+ // runden
+ double fNum = fVal; // find the exponent
+ int nExp = 0;
+ if( fNum > 0 )
+ {
+ while( fNum < 1.0 ) fNum *= 10.0, --nExp;
+ while( fNum >= 10.0 ) fNum /= 10.0, ++nExp;
+ }
+ nExp = 15 - nExp;
+ if( nExp > 15 )
+ nExp = 15;
+ else if( nExp <= 1 )
+ nExp = 0;
+ fVal = floor( fVal+ 0.5 + nRoundVal[ nExp ] );
+
+ if (bSign)
+ fVal *= -1.0;
+
+ fVal /= fFac;
+
+ left.PutDouble( fVal );
+ }
+ break;
+
+/*
+// removed here because of #77448# (=2*3^2 != 18)
+ case CALC_POW: {
+ GetToken();
+ double fraction, integer;
+ double right = Prim().GetDouble(),
+ dleft = left.GetDouble();
+
+ fraction = modf( right, &integer );
+ if( ( dleft < 0.0 && 0.0 != fraction ) ||
+ ( 0.0 == dleft && right < 0.0 ) )
+ {
+ eError = CALC_OVERFLOW;
+ left.Clear();
+ return left;
+ }
+ dleft = pow(dleft, right );
+ if( dleft == HUGE_VAL )
+ {
+ eError = CALC_POWERR;
+ left.Clear();
+ return left;
+ }
+ left.PutDouble( dleft );
+ }
+ break;
+*/
+ default: return left;
+ }
+
+ if( USHRT_MAX != nSbxOper )
+ {
+ // #i47706: cast to SbxOperator AFTER comparing to USHRT_MAX
+ SbxOperator eSbxOper = (SbxOperator)nSbxOper;
+
+ GetToken();
+ if( SbxEQ <= eSbxOper && eSbxOper <= SbxGE )
+ left.PutBool( left.Compare( eSbxOper, Prim() ));
+ else
+ {
+ SwSbxValue aRight( Prim() );
+ aRight.MakeDouble();
+ left.MakeDouble();
+
+ if( SbxDIV == eSbxOper && !aRight.GetDouble() )
+ eError = CALC_ZERODIV;
+ else
+ left.Compute( eSbxOper, aRight );
+ }
+ }
+ }
+}
+
+/******************************************************************************
+|*
+|* SwSbxValue SwCalc::Prim()
+|*
+|* Erstellung OK 12-02-93 11:05am
+|* Letzte Aenderung JP 03.11.95
+|*
+|******************************************************************************/
+
+extern "C" typedef double (*pfCalc)( double );
+
+SwSbxValue SwCalc::Prim()
+{
+ SwSbxValue nErg;
+
+ pfCalc pFnc = 0;
+
+ BOOL bChkTrig = FALSE, bChkPow = FALSE;
+
+ switch( eCurrOper )
+ {
+ case CALC_SIN: pFnc = &sin; break;
+ case CALC_COS: pFnc = &cos; break;
+ case CALC_TAN: pFnc = &tan; break;
+ case CALC_ATAN: pFnc = &atan; break;
+ case CALC_ASIN: pFnc = &asin; bChkTrig = TRUE; break;
+ case CALC_ACOS: pFnc = &acos; bChkTrig = TRUE; break;
+
+ case CALC_NOT: {
+ GetToken();
+ nErg = Prim();
+ if( SbxSTRING == nErg.GetType() )
+ nErg.PutBool( 0 == nErg.GetString().Len() );
+ else if(SbxBOOL == nErg.GetType() )
+ nErg.PutBool(!nErg.GetBool());
+ // evaluate arguments manually so that the binary NOT below
+ // does not get called.
+ // We want a BOOLEAN NOT.
+ else if (nErg.IsNumeric())
+ nErg.PutLong( nErg.GetDouble() == 0.0 ? 1 : 0 );
+ else
+ {
+ DBG_ERROR( "unexpected case. computing binary NOT" );
+ //!! computes a binary NOT
+ nErg.Compute( SbxNOT, nErg );
+ }
+ }
+ break;
+
+ case CALC_NUMBER: if( GetToken() == CALC_PHD )
+ {
+ double aTmp = nNumberValue.GetDouble();
+ aTmp *= 0.01;
+ nErg.PutDouble( aTmp );
+ GetToken();
+ }
+ else if( eCurrOper == CALC_NAME )
+ eError = CALC_SYNTAX;
+ else
+ {
+ nErg = nNumberValue;
+ bChkPow = TRUE;
+ }
+ break;
+
+ case CALC_NAME: if( GetToken() == CALC_ASSIGN )
+ {
+ SwCalcExp* n = VarInsert( aVarName );
+ GetToken();
+ nErg = n->nValue = Expr();
+ }
+ else
+ {
+ nErg = VarLook( aVarName )->nValue;
+ bChkPow = TRUE;
+ }
+ break;
+
+ case CALC_MINUS: GetToken();
+ nErg.PutDouble( -(Prim().GetDouble()) );
+ break;
+
+ case CALC_LP: {
+ GetToken();
+ nErg = Expr();
+ if( eCurrOper != CALC_RP )
+ eError = CALC_BRACK;
+ else
+ {
+ GetToken();
+ bChkPow = TRUE; // in order for =(7)^2 to work
+ }
+ }
+ break;
+
+ case CALC_MEAN: {
+ nListPor = 1;
+ GetToken();
+ nErg = Expr();
+ double aTmp = nErg.GetDouble();
+ aTmp /= nListPor;
+ nErg.PutDouble( aTmp );
+ }
+ break;
+
+ case CALC_SQRT: {
+ GetToken();
+ nErg = Prim();
+ if( nErg.GetDouble() < 0 )
+ eError = CALC_OVERFLOW;
+ else
+ nErg.PutDouble( sqrt( nErg.GetDouble() ));
+ }
+ break;
+
+ case CALC_SUM:
+ case CALC_DATE:
+ case CALC_MIN:
+ case CALC_MAX: GetToken();
+ nErg = Expr();
+ break;
+
+ case CALC_ENDCALC: nErg.Clear();
+ break;
+
+ default: eError = CALC_SYNTAX;
+ break;
+ }
+
+ if( pFnc )
+ {
+ GetToken();
+ double nVal = Prim().GetDouble();
+ if( !bChkTrig || ( nVal > -1 && nVal < 1 ) )
+ nErg.PutDouble( (*pFnc)( nVal ) );
+ else
+ eError = CALC_OVERFLOW;
+ }
+
+ // added here because of #77448# (=2*3^2 should be 18)
+ if( bChkPow && eCurrOper == CALC_POW )
+ {
+ double dleft = nErg.GetDouble();
+ GetToken();
+ double right = Prim().GetDouble();
+
+ double fraction, integer;
+ fraction = modf( right, &integer );
+ if( ( dleft < 0.0 && 0.0 != fraction ) ||
+ ( 0.0 == dleft && right < 0.0 ) )
+ {
+ eError = CALC_OVERFLOW;
+ nErg.Clear();
+ }
+ else
+ {
+ dleft = pow(dleft, right );
+ if( dleft == HUGE_VAL )
+ {
+ eError = CALC_POWERR;
+ nErg.Clear();
+ }
+ else
+ {
+ nErg.PutDouble( dleft );
+// GetToken();
+ }
+ }
+ }
+
+ return nErg;
+}
+
+/******************************************************************************
+|*
+|* SwSbxValue SwCalc::Expr()
+|*
+|* Erstellung OK 12-02-93 11:06am
+|* Letzte Aenderung JP 03.11.95
+|*
+|******************************************************************************/
+
+SwSbxValue SwCalc::Expr()
+{
+ SwSbxValue left = Term(), right;
+ nLastLeft = left;
+ for(;;)
+ switch(eCurrOper)
+ {
+ case CALC_PLUS: GetToken();
+ // erzeuge zum addieren auf jedenfall einen
+ // Double-Wert
+ left.MakeDouble();
+ ( right = Term() ).MakeDouble();
+ left.Compute( SbxPLUS, right );
+ nListPor++;
+ break;
+
+ case CALC_MINUS: GetToken();
+ // erzeuge zum addieren auf jedenfall einen
+ // Double-Wert
+ left.MakeDouble();
+ ( right = Term() ).MakeDouble();
+ left.Compute( SbxMINUS, right );
+ break;
+
+ default: return left;
+ }
+}
+
+//------------------------------------------------------------------------------
+
+String SwCalc::GetColumnName(const String& rName)
+{
+ xub_StrLen nPos = rName.Search(DB_DELIM);
+ if( STRING_NOTFOUND != nPos )
+ {
+ nPos = rName.Search(DB_DELIM, nPos + 1);
+
+ if( STRING_NOTFOUND != nPos )
+ return rName.Copy(nPos + 1);
+ }
+ return rName;
+}
+
+//------------------------------------------------------------------------------
+
+String SwCalc::GetDBName(const String& rName)
+{
+ xub_StrLen nPos = rName.Search(DB_DELIM);
+ if( STRING_NOTFOUND != nPos )
+ {
+ nPos = rName.Search(DB_DELIM, nPos + 1);
+
+ if( STRING_NOTFOUND != nPos )
+ return rName.Copy( 0, nPos );
+ }
+ SwDBData aData = rDoc.GetDBData();
+ String sRet = aData.sDataSource;
+ sRet += DB_DELIM;
+ sRet += String(aData.sCommand);
+ return sRet;
+}
+
+//------------------------------------------------------------------------------
+
+/******************************************************************************
+ * Methode : BOOL SwCalc::Str2Double( double& )
+ * Beschreibung:
+ * Erstellt : OK 07.06.94 12:56
+ * Aenderung : JP 27.10.98
+ ******************************************************************************/
+BOOL SwCalc::Str2Double( const String& rCommand, xub_StrLen& rCommandPos,
+ double& rVal, const LocaleDataWrapper* pLclData )
+{
+ const LocaleDataWrapper* pLclD = pLclData;
+ if( !pLclD )
+ pLclD = &SvtSysLocale().GetLocaleData();
+
+ const xub_Unicode nCurrCmdPos = rCommandPos;
+ rtl_math_ConversionStatus eStatus;
+ const sal_Unicode* pEnd;
+ rVal = rtl_math_uStringToDouble( rCommand.GetBuffer() + rCommandPos,
+ rCommand.GetBuffer() + rCommand.Len(),
+ pLclD->getNumDecimalSep().GetChar(0),
+ pLclD->getNumThousandSep().GetChar(0),
+ &eStatus, &pEnd );
+ rCommandPos = static_cast<xub_StrLen>(pEnd - rCommand.GetBuffer());
+
+ if( !pLclData && pLclD != &SvtSysLocale().GetLocaleData() )
+ delete (LocaleDataWrapper*)pLclD;
+
+ return rtl_math_ConversionStatus_Ok == eStatus && nCurrCmdPos != rCommandPos;
+}
+
+BOOL SwCalc::Str2Double( const String& rCommand, xub_StrLen& rCommandPos,
+ double& rVal, SwDoc* pDoc )
+{
+ const LocaleDataWrapper* pLclD = &SvtSysLocale().GetLocaleData();
+ if( pDoc )
+ {
+
+ LanguageType eLang = GetDocAppScriptLang( *pDoc );
+ if( eLang != SvxLocaleToLanguage( pLclD->getLocale() ) )
+ pLclD = new LocaleDataWrapper(
+ ::comphelper::getProcessServiceFactory(),
+ SvxCreateLocale( eLang ) );
+ }
+
+ const xub_Unicode nCurrCmdPos = rCommandPos;
+ rtl_math_ConversionStatus eStatus;
+ const sal_Unicode* pEnd;
+ rVal = rtl_math_uStringToDouble( rCommand.GetBuffer() + rCommandPos,
+ rCommand.GetBuffer() + rCommand.Len(),
+ pLclD->getNumDecimalSep().GetChar(0),
+ pLclD->getNumThousandSep().GetChar(0),
+ &eStatus, &pEnd );
+ rCommandPos = static_cast<xub_StrLen>(pEnd - rCommand.GetBuffer());
+
+ if( pLclD != &SvtSysLocale().GetLocaleData() )
+ delete (LocaleDataWrapper*)pLclD;
+
+ return rtl_math_ConversionStatus_Ok == eStatus && nCurrCmdPos != rCommandPos;
+}
+
+//------------------------------------------------------------------------------
+
+BOOL SwCalc::IsValidVarName( const String& rStr,
+ String* pValidName )
+{
+ BOOL bRet = FALSE;
+ using namespace ::com::sun::star::i18n;
+ {
+ // Parse any token.
+ ParseResult aRes = GetAppCharClass().parseAnyToken( rStr, 0,
+ coStartFlags, aEmptyStr,
+ coContFlags, aEmptyStr );
+
+ if( aRes.TokenType & KParseType::IDENTNAME )
+ {
+ bRet = aRes.EndPos == rStr.Len();
+ if( pValidName )
+ {
+ xub_StrLen nRealStt = (xub_StrLen)aRes.LeadingWhiteSpace;
+ *pValidName = rStr.Copy( nRealStt, static_cast<xub_StrLen>(aRes.EndPos) - nRealStt );
+ }
+ }
+ else if( pValidName )
+ pValidName->Erase();
+ }
+ return bRet;
+}
+
+//------------------------------------------------------------------------------
+
+/******************************************************************************
+|*
+|* CTOR DTOR der SwHash classes
+|*
+|* Ersterstellung OK 25.06.93 12:20
+|* Letzte Aenderung OK 25.06.93 12:20
+|*
+******************************************************************************/
+
+SwHash::SwHash( const String& rStr ) :
+ aStr( rStr ),
+ pNext( 0 )
+{}
+
+SwHash::~SwHash()
+{
+ if( pNext )
+ delete pNext;
+}
+
+void DeleteHashTable( SwHash **ppHashTable, USHORT nCount )
+{
+ for ( USHORT i = 0; i < nCount; ++i )
+ delete *(ppHashTable+i);
+ delete [] ppHashTable;
+}
+
+SwCalcExp::SwCalcExp( const String& rStr, const SwSbxValue& rVal,
+ const SwFieldType* pType )
+ : SwHash( rStr ),
+ nValue( rVal ),
+ pFldType( pType )
+{
+}
+
+
+SwSbxValue::~SwSbxValue()
+{
+}
+
+BOOL SwSbxValue::GetBool() const
+{
+ return SbxSTRING == GetType() ? 0 != GetString().Len()
+ : 0 != SbxValue::GetBool();
+}
+
+double SwSbxValue::GetDouble() const
+{
+ double nRet;
+ if( SbxSTRING == GetType() )
+ {
+ xub_StrLen nStt = 0;
+ SwCalc::Str2Double( GetString(), nStt, nRet );
+ }
+ else if (IsBool())
+ {
+ nRet = 0 != GetBool() ? 1.0 : 0.0;
+ }
+ else
+ nRet = SbxValue::GetDouble();
+ return nRet;
+}
+
+SwSbxValue& SwSbxValue::MakeDouble()
+{
+ if( SbxSTRING == GetType() )
+ PutDouble( GetDouble() );
+ return *this;
+}
+
+#ifdef STANDALONE_HASHCALC
+
+// dies ist der Beispielcode zu erzeugen der HashValues im CTOR:
+
+#include <stdio.h>
+
+void main()
+{
+static sal_Char
+ sNType0[] = "false", sNType1[] = "true", sNType2[] = "pi",
+ sNType3[] = "e", sNType4[] = "tables", sNType5[] = "graf",
+ sNType6[] = "ole", sNType7[] = "page", sNType8[] = "para",
+ sNType9[] = "word", sNType10[]= "char",
+ sNType11[] = "user_company" , sNType12[] = "user_firstname" ,
+ sNType13[] = "user_lastname" , sNType14[] = "user_initials",
+ sNType15[] = "user_street" , sNType16[] = "user_country" ,
+ sNType17[] = "user_zipcode" , sNType18[] = "user_city" ,
+ sNType19[] = "user_title" , sNType20[] = "user_position" ,
+ sNType21[] = "user_tel_home", sNType22[] = "user_tel_work",
+ sNType23[] = "user_fax" , sNType24[] = "user_email" ,
+ sNType25[] = "user_state", sNType26[] = "graph"
+ ;
+
+static const sal_Char* sNTypeTab[ 27 ] =
+{
+ sNType0, sNType1, sNType2, sNType3, sNType4, sNType5,
+ sNType6, sNType7, sNType8, sNType9, sNType10, sNType11,
+ sNType12, sNType13, sNType14, sNType15, sNType16, sNType17,
+ sNType18, sNType19, sNType20, sNType21, sNType22, sNType23,
+ sNType24, sNType25, sNType26
+};
+
+ const unsigned short nTblSize = 47;
+ int aArr[ nTblSize ] = { 0 };
+ sal_Char ch;
+
+ for( int n = 0; n < 27; ++n )
+ {
+ unsigned long ii = 0;
+ const sal_Char* pp = sNTypeTab[ n ];
+
+ while( *pp )
+ ii = ii << 1 ^ *pp++;
+ ii %= nTblSize;
+
+ ch = aArr[ ii ] ? 'X' : ' ';
+ aArr[ ii ] = 1;
+ printf( "%-20s -> %3d [%c]\n", sNTypeTab[ n ], ii, ch );
+ }
+}
+
+#endif
+
+
+
diff --git a/sw/source/core/bastyp/checkit.cxx b/sw/source/core/bastyp/checkit.cxx
new file mode 100644
index 000000000000..9e5ee1f368fd
--- /dev/null
+++ b/sw/source/core/bastyp/checkit.cxx
@@ -0,0 +1,51 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <comphelper/processfactory.hxx>
+#include <checkit.hxx>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::i18n;
+
+SwCheckIt::SwCheckIt()
+{
+ Reference< XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
+ Reference < XInterface > xI = xMSF->createInstance(
+ ::rtl::OUString::createFromAscii( "com.sun.star.i18n.InputSequenceChecker" ) );
+ if ( xI.is() )
+ {
+ Any x = xI->queryInterface( ::getCppuType((const Reference< XExtendedInputSequenceChecker >*)0) );
+ x >>= xCheck;
+ }
+}
+
diff --git a/sw/source/core/bastyp/index.cxx b/sw/source/core/bastyp/index.cxx
new file mode 100644
index 000000000000..2c1b6e2bbb65
--- /dev/null
+++ b/sw/source/core/bastyp/index.cxx
@@ -0,0 +1,593 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+
+#include <stdlib.h> // fuer qsort
+#include <tools/solar.h>
+
+#include "errhdl.hxx" // fuers ASSERT
+#include "index.hxx"
+#include "error.h" // fuers ASSERT
+
+#ifdef DBG_UTIL
+int SwIndex::nSerial = 0;
+#endif
+
+
+TYPEINIT0(SwIndexReg); // rtti
+
+
+#ifdef CHK
+
+#define IDX_CHK_ARRAY pArray->ChhkArr();
+#define ARR_CHK_ARRAY ChhkArr();
+
+
+void SwIndexReg::ChkArr()
+{
+ ASSERT( (pFirst && pLast) || (!pFirst && !pLast),
+ "Array falsch Indiziert" );
+
+ if( !pFirst )
+ return;
+
+ xub_StrLen nVal = 0;
+ const SwIndex* pIdx = pFirst, *pPrev = 0;
+ ASSERT( !pIdx->pPrev, "Array-pFirst nicht am Anfang" );
+
+ while( pIdx != pLast )
+ {
+ ASSERT( pIdx->pPrev != pIdx && pIdx->pNext != pIdx,
+ "Index zeigt auf sich selbst" )
+
+ ASSERT( pIdx->nIndex >= nVal, "Reihenfolge stimmt nicht" );
+ ASSERT( pPrev == pIdx->pPrev, "Verkettung stimmt nicht" );
+ pPrev = pIdx;
+ pIdx = pIdx->pNext;
+ nVal = pPrev->nIndex;
+ }
+}
+
+#else // CHK
+
+#define IDX_CHK_ARRAY
+#define ARR_CHK_ARRAY
+
+#endif // CHK
+
+
+
+SwIndex::SwIndex(SwIndexReg *const pArr, xub_StrLen const nIdx)
+ : nIndex( nIdx ), pArray( pArr ), pNext( 0 ), pPrev( 0 )
+{
+ if( !pArray )
+ {
+ pArray = SwIndexReg::pEmptyIndexArray;
+ nIndex = 0; // steht immer auf 0 !!!
+ }
+
+ if( !pArray->pFirst ) // 1. Index ??
+ pArray->pFirst = pArray->pLast = this;
+ else if( nIdx > ((pArray->pLast->nIndex - pArray->pFirst->nIndex) / 2) )
+ ChgValue( *pArray->pLast, nIdx );
+ else
+ ChgValue( *pArray->pFirst, nIdx );
+
+#ifdef DBG_UTIL
+ MySerial = ++nSerial; // nur in der nicht PRODUCT-Version
+#endif
+IDX_CHK_ARRAY
+}
+
+
+SwIndex::SwIndex( const SwIndex& rIdx, short nIdx )
+ : pArray( rIdx.pArray ), pNext( 0 ), pPrev( 0 )
+{
+ ChgValue( rIdx, rIdx.nIndex + nIdx );
+
+#ifdef DBG_UTIL
+ MySerial = ++nSerial; // nur in der nicht PRODUCT-Version
+#endif
+IDX_CHK_ARRAY
+}
+
+
+SwIndex::SwIndex( const SwIndex& rIdx )
+ : nIndex( rIdx.nIndex ), pArray( rIdx.pArray ), pNext( 0 ), pPrev( 0 )
+{
+ ChgValue( rIdx, rIdx.nIndex );
+#ifdef DBG_UTIL
+ MySerial = ++nSerial; // nur in der nicht PRODUCT-Version
+#endif
+IDX_CHK_ARRAY
+}
+
+
+SwIndex& SwIndex::ChgValue( const SwIndex& rIdx, xub_StrLen nNewValue )
+{
+ SwIndex* pFnd = (SwIndex*)&rIdx;
+ if( rIdx.nIndex > nNewValue ) // nach vorne versuchen
+ {
+ SwIndex* pPrv;
+ while( 0 != ( pPrv = pFnd->pPrev ) && pPrv->nIndex > nNewValue )
+ pFnd = pPrv;
+
+ if( pFnd != this )
+ {
+ // an alter Position ausketten
+ // erstmal an alter Position ausketten
+ if( pPrev )
+ pPrev->pNext = pNext;
+ else if( pArray->pFirst == this )
+ pArray->pFirst = pNext;
+
+ if( pNext )
+ pNext->pPrev = pPrev;
+ else if( pArray->pLast == this )
+ pArray->pLast = pPrev;
+
+ pNext = pFnd;
+ pPrev = pFnd->pPrev;
+ if( pPrev )
+ pPrev->pNext = this;
+ else
+ pArray->pFirst = this;
+ pFnd->pPrev = this;
+ }
+ }
+ else if( rIdx.nIndex < nNewValue )
+ {
+ SwIndex* pNxt;
+ while( 0 != ( pNxt = pFnd->pNext ) && pNxt->nIndex < nNewValue )
+ pFnd = pNxt;
+
+ if( pFnd != this )
+ {
+ // erstmal an alter Position ausketten
+ if( pPrev )
+ pPrev->pNext = pNext;
+ else if( pArray->pFirst == this )
+ pArray->pFirst = pNext;
+
+ if( pNext )
+ pNext->pPrev = pPrev;
+ else if( pArray->pLast == this )
+ pArray->pLast = pPrev;
+
+ pPrev = pFnd;
+ pNext = pFnd->pNext;
+ if( pNext )
+ pNext->pPrev = this;
+ else
+ pArray->pLast = this;
+ pFnd->pNext = this;
+ }
+ }
+ else if( pFnd != this )
+ {
+ // erstmal an alter Position ausketten
+ if( pPrev )
+ pPrev->pNext = pNext;
+ else if( pArray->pFirst == this )
+ pArray->pFirst = pNext;
+
+ if( pNext )
+ pNext->pPrev = pPrev;
+ else if( pArray->pLast == this )
+ pArray->pLast = pPrev;
+
+ pPrev = (SwIndex*)&rIdx;
+ pNext = rIdx.pNext;
+ pPrev->pNext = this;
+
+ if( !pNext ) // im IndexArray als letzes
+ pArray->pLast = this;
+ else
+ pNext->pPrev = this;
+ }
+ pArray = rIdx.pArray;
+
+ if( pArray->pFirst == pNext )
+ pArray->pFirst = this;
+ if( pArray->pLast == pPrev )
+ pArray->pLast = this;
+
+ nIndex = nNewValue;
+
+IDX_CHK_ARRAY
+
+ return *this; }
+
+
+void SwIndex::Remove()
+{
+ if( !pPrev )
+ pArray->pFirst = pNext;
+ else
+ pPrev->pNext = pNext;
+
+ if( !pNext )
+ pArray->pLast = pPrev;
+ else
+ pNext->pPrev = pPrev;
+
+IDX_CHK_ARRAY
+}
+
+/*************************************************************************
+|*
+|* SwIndex & SwIndex::operator=( const SwIndex & aSwIndex )
+|*
+|* Beschreibung
+|* Ersterstellung JP 07.11.90
+|* Letzte Aenderung JP 07.03.94
+|*
+*************************************************************************/
+
+
+SwIndex& SwIndex::operator=( const SwIndex& rIdx )
+{
+ int bEqual;
+ if( rIdx.pArray != pArray ) // im alten abmelden !!
+ {
+ Remove();
+ pArray = rIdx.pArray;
+ pNext = pPrev = 0;
+ bEqual = FALSE;
+ }
+ else
+ bEqual = rIdx.nIndex == nIndex;
+
+ if( !bEqual )
+ ChgValue( rIdx, rIdx.nIndex );
+ return *this;
+}
+
+/*************************************************************************
+|*
+|* SwIndex &SwIndex::Assign
+|*
+|* Beschreibung
+|* Ersterstellung VB 25.03.91
+|* Letzte Aenderung JP 07.03.94
+|*
+*************************************************************************/
+
+
+SwIndex& SwIndex::Assign( SwIndexReg* pArr, xub_StrLen nIdx )
+{
+ if( !pArr )
+ {
+ pArr = SwIndexReg::pEmptyIndexArray;
+ nIdx = 0; // steht immer auf 0 !!!
+ }
+
+ if( pArr != pArray ) // im alten abmelden !!
+ {
+ Remove();
+ pArray = pArr;
+ pNext = pPrev = 0;
+ if( !pArr->pFirst ) // 1. Index ??
+ {
+ pArr->pFirst = pArr->pLast = this;
+ nIndex = nIdx;
+ }
+ else if( pArr->pLast && (nIdx > ((pArr->pLast->nIndex - pArr->pFirst->nIndex) / 2)) )
+ ChgValue( *pArr->pLast, nIdx );
+ else
+ ChgValue( *pArr->pFirst, nIdx );
+ }
+ else if( nIndex != nIdx )
+ ChgValue( *this, nIdx );
+IDX_CHK_ARRAY
+ return *this;
+}
+
+
+SwIndexReg::SwIndexReg()
+ : pFirst( 0 ), pLast( 0 )
+{
+}
+
+
+
+SwIndexReg::~SwIndexReg()
+{
+ ASSERT( !pFirst || !pLast, "Es sind noch Indizies angemeldet" );
+}
+
+
+
+void SwIndexReg::Update( SwIndex const & rIdx, const xub_StrLen nDiff,
+ const bool bNeg, const bool /* argument is only used in derived class*/ )
+{
+ SwIndex* pStt = const_cast<SwIndex*>(&rIdx);
+ xub_StrLen nNewVal = rIdx.nIndex;
+ if( bNeg )
+ {
+ xub_StrLen nLast = rIdx.GetIndex() + nDiff;
+ while( pStt && pStt->nIndex == nNewVal )
+ {
+ pStt->nIndex = nNewVal;
+ pStt = pStt->pPrev;
+ }
+ pStt = rIdx.pNext;
+ while( pStt && pStt->nIndex >= nNewVal &&
+ pStt->nIndex <= nLast )
+ {
+ pStt->nIndex = nNewVal;
+ pStt = pStt->pNext;
+ }
+ while( pStt )
+ {
+ pStt->nIndex = pStt->nIndex - nDiff;
+ pStt = pStt->pNext;
+ }
+ }
+ else
+ {
+ while( pStt && pStt->nIndex == nNewVal )
+ {
+ pStt->nIndex = pStt->nIndex + nDiff;
+ pStt = pStt->pPrev;
+ }
+ pStt = rIdx.pNext;
+ while( pStt )
+ {
+ pStt->nIndex = pStt->nIndex + nDiff;
+ pStt = pStt->pNext;
+ }
+ }
+ARR_CHK_ARRAY
+}
+
+#ifdef DBG_UTIL
+#ifndef CFRONT
+
+/*************************************************************************
+|*
+|* SwIndex::operator++()
+|*
+|* Beschreibung
+|* Ersterstellung JP 07.11.90
+|* Letzte Aenderung JP 07.03.94
+|*
+*************************************************************************/
+xub_StrLen SwIndex::operator++(int)
+{
+ ASSERT_ID( nIndex < INVALID_INDEX, ERR_OUTOFSCOPE );
+
+ xub_StrLen nOldIndex = nIndex;
+ ChgValue( *this, nIndex+1 );
+ return nOldIndex;
+}
+
+#endif
+
+xub_StrLen SwIndex::operator++()
+{
+ ASSERT_ID( nIndex < INVALID_INDEX, ERR_OUTOFSCOPE );
+
+ ChgValue( *this, nIndex+1 );
+ return nIndex;
+}
+
+/*************************************************************************
+|*
+|* SwIndex::operator--()
+|*
+|* Beschreibung
+|* Ersterstellung JP 07.11.90
+|* Letzte Aenderung JP 07.03.94
+|*
+*************************************************************************/
+
+#ifndef CFRONT
+
+xub_StrLen SwIndex::operator--(int)
+{
+ ASSERT_ID( nIndex, ERR_OUTOFSCOPE );
+
+ xub_StrLen nOldIndex = nIndex;
+ ChgValue( *this, nIndex-1 );
+ return nOldIndex;
+}
+
+#endif
+
+xub_StrLen SwIndex::operator--()
+{
+ ASSERT_ID( nIndex, ERR_OUTOFSCOPE );
+ return ChgValue( *this, nIndex-1 ).nIndex;
+}
+
+/*************************************************************************
+|*
+|* SwIndex::operator+=( xub_StrLen )
+|*
+|* Beschreibung
+|* Ersterstellung JP 07.11.90
+|* Letzte Aenderung JP 07.03.94
+|*
+*************************************************************************/
+
+xub_StrLen SwIndex::operator+=( xub_StrLen nWert )
+{
+ ASSERT_ID( nIndex < INVALID_INDEX - nWert, ERR_OUTOFSCOPE);
+ return ChgValue( *this, nIndex + nWert ).nIndex;
+}
+
+/*************************************************************************
+|*
+|* SwIndex::operator-=( xub_StrLen )
+|*
+|* Beschreibung
+|* Ersterstellung JP 07.11.90
+|* Letzte Aenderung JP 07.03.94
+|*
+*************************************************************************/
+
+xub_StrLen SwIndex::operator-=( xub_StrLen nWert )
+{
+ ASSERT_ID( nIndex >= nWert, ERR_OUTOFSCOPE );
+ return ChgValue( *this, nIndex - nWert ).nIndex;
+}
+
+/*************************************************************************
+|*
+|* SwIndex::operator+=( const SwIndex & )
+|*
+|* Beschreibung
+|* Ersterstellung JP 07.11.90
+|* Letzte Aenderung JP 07.03.94
+|*
+*************************************************************************/
+
+xub_StrLen SwIndex::operator+=( const SwIndex & rIndex )
+{
+ ASSERT_ID( nIndex < INVALID_INDEX - rIndex.nIndex, ERR_OUTOFSCOPE );
+ return ChgValue( *this, nIndex + rIndex.nIndex ).nIndex;
+}
+
+/*************************************************************************
+|*
+|* SwIndex::operator-=( const SwIndex & )
+|*
+|* Beschreibung
+|* Ersterstellung JP 07.11.90
+|* Letzte Aenderung JP 07.03.94
+|*
+*************************************************************************/
+
+xub_StrLen SwIndex::operator-=( const SwIndex & rIndex )
+{
+ ASSERT_ID( nIndex >= rIndex.nIndex, ERR_OUTOFSCOPE );
+ return ChgValue( *this, nIndex - rIndex.nIndex ).nIndex;
+}
+
+/*************************************************************************
+|*
+|* SwIndex::operator<( const SwIndex & )
+|*
+|* Beschreibung
+|* Ersterstellung JP 07.11.90
+|* Letzte Aenderung JP 07.03.94
+|*
+*************************************************************************/
+
+BOOL SwIndex::operator<( const SwIndex & rIndex ) const
+{
+ ASSERT( pArray == rIndex.pArray, "Attempt to compare indices into different arrays.");
+ return nIndex < rIndex.nIndex;
+}
+
+/*************************************************************************
+|*
+|* SwIndex::operator<=( const SwIndex & )
+|*
+|* Beschreibung
+|* Ersterstellung JP 07.11.90
+|* Letzte Aenderung JP 04.06.92
+|*
+*************************************************************************/
+
+BOOL SwIndex::operator<=( const SwIndex & rIndex ) const
+{
+ ASSERT( pArray == rIndex.pArray, "Attempt to compare indices into different arrays.");
+ return nIndex <= rIndex.nIndex;
+}
+
+/*************************************************************************
+|*
+|* SwIndex::operator>( const SwIndex & )
+|*
+|* Beschreibung
+|* Ersterstellung JP 07.11.90
+|* Letzte Aenderung JP 04.06.92
+|*
+*************************************************************************/
+
+BOOL SwIndex::operator>( const SwIndex & rIndex ) const
+{
+ ASSERT( pArray == rIndex.pArray, "Attempt to compare indices into different arrays.");
+ return nIndex > rIndex.nIndex;
+}
+
+/*************************************************************************
+|*
+|* SwIndex::operator>=( const SwIndex & )
+|*
+|* Beschreibung
+|* Ersterstellung JP 07.11.90
+|* Letzte Aenderung JP 04.06.92
+|*
+*************************************************************************/
+
+BOOL SwIndex::operator>=( const SwIndex & rIndex ) const
+{
+ ASSERT( pArray == rIndex.pArray, "Attempt to compare indices into different arrays.");
+ return nIndex >= rIndex.nIndex;
+}
+
+/*************************************************************************
+|*
+|* SwIndex & SwIndex::operator=( xub_StrLen )
+|*
+|* Beschreibung
+|* Ersterstellung JP 10.12.90
+|* Letzte Aenderung JP 07.03.94
+|*
+*************************************************************************/
+
+SwIndex& SwIndex::operator=( xub_StrLen nWert )
+{
+ // Werte kopieren und im neuen Array anmelden
+ if( nIndex != nWert )
+ ChgValue( *this, nWert );
+
+ return *this;
+}
+
+#endif // ifndef PRODUCT
+
+void SwIndexReg::MoveTo( SwIndexReg& rArr )
+{
+ if( this != &rArr && pFirst )
+ {
+ SwIndex* pIdx = (SwIndex*)pFirst, *pNext;
+ while( pIdx )
+ {
+ pNext = pIdx->pNext;
+ pIdx->Assign( &rArr, pIdx->GetIndex() );
+ pIdx = pNext;
+ }
+ pFirst = 0, pLast = 0;
+ }
+}
diff --git a/sw/source/core/bastyp/init.cxx b/sw/source/core/bastyp/init.cxx
new file mode 100644
index 000000000000..345dd0221ffd
--- /dev/null
+++ b/sw/source/core/bastyp/init.cxx
@@ -0,0 +1,918 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+#include <hintids.hxx>
+#include <tools/globname.hxx>
+#include <vcl/mapmod.hxx>
+#include <editeng/xmlcnitm.hxx>
+#include <svl/macitem.hxx>
+#include <editeng/pbinitem.hxx>
+#include <editeng/keepitem.hxx>
+#include <editeng/nlbkitem.hxx>
+#include <editeng/hyznitem.hxx>
+#include <editeng/protitem.hxx>
+#include <editeng/ulspitem.hxx>
+#include <editeng/prszitem.hxx>
+#include <editeng/opaqitem.hxx>
+#include <editeng/shaditem.hxx>
+#include <editeng/prntitem.hxx>
+#include <editeng/brkitem.hxx>
+#include <editeng/tstpitem.hxx>
+#include <editeng/langitem.hxx>
+#include <editeng/wrlmitem.hxx>
+#include <editeng/kernitem.hxx>
+#include <editeng/escpitem.hxx>
+#include <editeng/cscoitem.hxx>
+#include <editeng/lrspitem.hxx>
+#include <editeng/orphitem.hxx>
+#include <editeng/widwitem.hxx>
+#include <editeng/nhypitem.hxx>
+#include <editeng/spltitem.hxx>
+#include <editeng/lspcitem.hxx>
+#include <editeng/blnkitem.hxx>
+#include <editeng/akrnitem.hxx>
+#include <editeng/emphitem.hxx>
+#include <editeng/twolinesitem.hxx>
+#include <editeng/scriptspaceitem.hxx>
+#include <editeng/hngpnctitem.hxx>
+#include <editeng/cmapitem.hxx>
+#include <editeng/charscaleitem.hxx>
+#include <editeng/charrotateitem.hxx>
+#include <editeng/charreliefitem.hxx>
+#include <editeng/frmdiritem.hxx>
+#ifndef _SVX_DIALOGS_HRC
+#include <svx/dialogs.hrc>
+#endif
+#include <editeng/swafopt.hxx>
+#include <editeng/svxacorr.hxx>
+#include <unotools/charclass.hxx>
+#include <editeng/unolingu.hxx>
+#include <editeng/forbiddenruleitem.hxx>
+#include <editeng/paravertalignitem.hxx>
+#include <editeng/pgrditem.hxx>
+#include <editeng/charhiddenitem.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <comphelper/processfactory.hxx>
+#include <unotools/collatorwrapper.hxx>
+#include <unotools/syslocale.hxx>
+#include <com/sun/star/i18n/CollatorOptions.hpp>
+#include <unotools/transliterationwrapper.hxx>
+#include <editeng/acorrcfg.hxx>
+#include <vcl/svapp.hxx>
+#include <fmtanchr.hxx>
+#include <fmtornt.hxx>
+#include <fmtsrnd.hxx>
+#include <fmtfsize.hxx>
+#include <fmtfld.hxx>
+#include <fmtrfmrk.hxx>
+#include <fmtlsplt.hxx>
+#include <fmtrowsplt.hxx>
+#include <fmteiro.hxx>
+#include <fmtclds.hxx>
+#include <fmturl.hxx>
+#include <fmtcntnt.hxx>
+#include <fmthdft.hxx>
+#include <fmtpdsc.hxx>
+#include <fmtftn.hxx>
+#include <fmtfordr.hxx>
+#include <fmtflcnt.hxx>
+#include <fchrfmt.hxx>
+#include <fmtautofmt.hxx>
+#include <fmtinfmt.hxx>
+#include <fmtcnct.hxx>
+#include <fmtline.hxx>
+#include <fmtftntx.hxx>
+#include <fmtruby.hxx>
+#include <fmtautofmt.hxx>
+#include <tgrditem.hxx>
+#include <hfspacingitem.hxx>
+#include <editsh.hxx>
+#include <pam.hxx>
+#include <init.hxx>
+#include <paratr.hxx>
+#include <grfatr.hxx>
+#include <tox.hxx>
+#include <cellatr.hxx>
+#include <tblafmt.hxx>
+#include <viscrs.hxx>
+#include <fntcache.hxx>
+#include <doc.hxx>
+#include <acmplwrd.hxx>
+#include <fmtclbl.hxx>
+#include <cmdid.h>
+#include <breakit.hxx>
+#include <checkit.hxx>
+#include <swcalwrp.hxx>
+#include <SwStyleNameMapper.hxx>
+
+// OD 09.10.2003 #i18732#
+#include <fmtfollowtextflow.hxx>
+// OD 2004-05-05 #i28701#
+#include <fmtwrapinfluenceonobjpos.hxx>
+
+#include <fmtmeta.hxx>
+
+
+using namespace ::com::sun::star;
+
+extern void _FrmFinit();
+extern void ClearFEShellTabCols();
+
+/*************************************************************************
+|* einige Bereiche fuer die Set in Collections / Nodes
+|*************************************************************************/
+ // AttrSet-Range fuer die 2 Break-Attribute
+USHORT __FAR_DATA aBreakSetRange[] = {
+ RES_PAGEDESC, RES_BREAK,
+ 0 };
+
+ // AttrSet-Range fuer die TxtFmtColl
+ // OD 2008-02-27 #refactorlists# :
+ // list attributes ( RES_PARATR_LIST_BEGIN - RES_PARATR_LIST_END ) are not
+ // included in the paragraph style's itemset.
+USHORT __FAR_DATA aTxtFmtCollSetRange[] = {
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1,
+ RES_CHRATR_BEGIN, RES_CHRATR_END-1,
+ RES_PARATR_BEGIN, RES_PARATR_END-1,
+ RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
+ 0
+};
+
+ // AttrSet-Range fuer die GrfFmtColl
+USHORT __FAR_DATA aGrfFmtCollSetRange[] = {
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1,
+ RES_GRFATR_BEGIN, RES_GRFATR_END-1,
+ RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
+ 0
+};
+
+ // AttrSet-Range fuer die TextNode
+USHORT __FAR_DATA aTxtNodeSetRange[] = {
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1,
+ RES_CHRATR_BEGIN, RES_CHRATR_END-1,
+ RES_PARATR_BEGIN, RES_PARATR_END-1,
+ // --> OD 2008-02-25 #refactorlists#
+ RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1,
+ // <--
+ RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
+ 0
+};
+
+ // AttrSet-Range fuer die NoTxtNode
+USHORT __FAR_DATA aNoTxtNodeSetRange[] = {
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1,
+ RES_GRFATR_BEGIN, RES_GRFATR_END-1,
+ RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
+ 0
+};
+
+USHORT __FAR_DATA aTableSetRange[] = {
+ RES_FILL_ORDER, RES_FRM_SIZE,
+ RES_LR_SPACE, RES_BREAK,
+ RES_BACKGROUND, RES_SHADOW,
+ RES_HORI_ORIENT, RES_HORI_ORIENT,
+ RES_KEEP, RES_KEEP,
+ RES_LAYOUT_SPLIT, RES_LAYOUT_SPLIT,
+ RES_FRAMEDIR, RES_FRAMEDIR,
+ // --> collapsing borders FME 2005-05-27 #i29550#
+ RES_COLLAPSING_BORDERS, RES_COLLAPSING_BORDERS,
+ // <-- collapsing
+ RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
+ 0
+};
+
+USHORT __FAR_DATA aTableLineSetRange[] = {
+ RES_FILL_ORDER, RES_FRM_SIZE,
+ RES_LR_SPACE, RES_UL_SPACE,
+ RES_BACKGROUND, RES_SHADOW,
+ RES_ROW_SPLIT, RES_ROW_SPLIT,
+ RES_PROTECT, RES_PROTECT,
+ RES_VERT_ORIENT, RES_VERT_ORIENT,
+ RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
+ 0
+};
+
+USHORT __FAR_DATA aTableBoxSetRange[] = {
+ RES_FILL_ORDER, RES_FRM_SIZE,
+ RES_LR_SPACE, RES_UL_SPACE,
+ RES_BACKGROUND, RES_SHADOW,
+ RES_PROTECT, RES_PROTECT,
+ RES_VERT_ORIENT, RES_VERT_ORIENT,
+ RES_FRAMEDIR, RES_FRAMEDIR,
+ RES_BOXATR_BEGIN, RES_BOXATR_END-1,
+ RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
+ 0
+};
+
+// AttrSet-Range fuer die SwFrmFmt
+USHORT __FAR_DATA aFrmFmtSetRange[] = {
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1,
+ RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
+ 0
+};
+
+// AttrSet-Range fuer die SwCharFmt
+USHORT __FAR_DATA aCharFmtSetRange[] = {
+ RES_CHRATR_BEGIN, RES_CHRATR_END-1,
+ RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
+ 0
+};
+
+// AttrSet-Range fuer die character autostyles
+USHORT __FAR_DATA aCharAutoFmtSetRange[] = {
+ RES_CHRATR_BEGIN, RES_CHRATR_END-1,
+ RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER,
+ RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
+ 0
+};
+
+// AttrSet-Range fuer die SwPageDescFmt
+USHORT __FAR_DATA aPgFrmFmtSetRange[] = {
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1,
+ RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
+ 0
+};
+
+/******************************************************************************
+ * lege eine Tabelle fuer einen Zugriff auf die
+ * Default-Format-Attribute an
+ ******************************************************************************/
+SwDfltAttrTab __FAR_DATA aAttrTab;
+
+SfxItemInfo __FAR_DATA aSlotTab[] =
+{
+ { SID_ATTR_CHAR_CASEMAP, SFX_ITEM_POOLABLE }, // RES_CHRATR_CASEMAP
+ { SID_ATTR_CHAR_CHARSETCOLOR, SFX_ITEM_POOLABLE }, // RES_CHRATR_CHARSETCOLOR
+ { SID_ATTR_CHAR_COLOR, SFX_ITEM_POOLABLE }, // RES_CHRATR_COLOR
+ { SID_ATTR_CHAR_CONTOUR, SFX_ITEM_POOLABLE }, // RES_CHRATR_CONTOUR
+ { SID_ATTR_CHAR_STRIKEOUT, SFX_ITEM_POOLABLE }, // RES_CHRATR_CROSSEDOUT
+ { SID_ATTR_CHAR_ESCAPEMENT, SFX_ITEM_POOLABLE }, // RES_CHRATR_ESCAPEMENT
+ { SID_ATTR_CHAR_FONT, SFX_ITEM_POOLABLE }, // RES_CHRATR_FONT
+ { SID_ATTR_CHAR_FONTHEIGHT, SFX_ITEM_POOLABLE }, // RES_CHRATR_FONTSIZE
+ { SID_ATTR_CHAR_KERNING, SFX_ITEM_POOLABLE }, // RES_CHRATR_KERNING
+ { SID_ATTR_CHAR_LANGUAGE, SFX_ITEM_POOLABLE }, // RES_CHRATR_LANGUAGE
+ { SID_ATTR_CHAR_POSTURE, SFX_ITEM_POOLABLE }, // RES_CHRATR_POSTURE
+ { SID_ATTR_CHAR_PROPSIZE, SFX_ITEM_POOLABLE }, // RES_CHRATR_PROPORTIONALFONTSIZE
+ { SID_ATTR_CHAR_SHADOWED, SFX_ITEM_POOLABLE }, // RES_CHRATR_SHADOWED
+ { SID_ATTR_CHAR_UNDERLINE, SFX_ITEM_POOLABLE }, // RES_CHRATR_UNDERLINE
+ { SID_ATTR_CHAR_WEIGHT, SFX_ITEM_POOLABLE }, // RES_CHRATR_WEIGHT
+ { SID_ATTR_CHAR_WORDLINEMODE, SFX_ITEM_POOLABLE }, // RES_CHRATR_WORDLINEMODE
+ { SID_ATTR_CHAR_AUTOKERN, SFX_ITEM_POOLABLE }, // RES_CHRATR_AUTOKERN
+ { SID_ATTR_FLASH, SFX_ITEM_POOLABLE }, // RES_CHRATR_BLINK
+ { 0, SFX_ITEM_POOLABLE }, // RES_CHRATR_NOLINEBREAK
+ { 0, SFX_ITEM_POOLABLE }, // RES_CHRATR_NOHYPHEN
+ { SID_ATTR_BRUSH_CHAR, SFX_ITEM_POOLABLE }, // RES_CHRATR_BACKGROUND
+ { SID_ATTR_CHAR_CJK_FONT, SFX_ITEM_POOLABLE }, // RES_CHRATR_CJK_FONT
+ { SID_ATTR_CHAR_CJK_FONTHEIGHT, SFX_ITEM_POOLABLE },// RES_CHRATR_CJK_FONTSIZE
+ { SID_ATTR_CHAR_CJK_LANGUAGE, SFX_ITEM_POOLABLE }, // RES_CHRATR_CJK_LANGUAGE
+ { SID_ATTR_CHAR_CJK_POSTURE, SFX_ITEM_POOLABLE }, // RES_CHRATR_CJK_POSTURE
+ { SID_ATTR_CHAR_CJK_WEIGHT, SFX_ITEM_POOLABLE }, // RES_CHRATR_CJK_WEIGHT
+ { SID_ATTR_CHAR_CTL_FONT, SFX_ITEM_POOLABLE }, // RES_CHRATR_CTL_FONT
+ { SID_ATTR_CHAR_CTL_FONTHEIGHT, SFX_ITEM_POOLABLE },// RES_CHRATR_CTL_FONTSIZE
+ { SID_ATTR_CHAR_CTL_LANGUAGE, SFX_ITEM_POOLABLE }, // RES_CHRATR_CTL_LANGUAGE
+ { SID_ATTR_CHAR_CTL_POSTURE, SFX_ITEM_POOLABLE }, // RES_CHRATR_CTL_POSTURE
+ { SID_ATTR_CHAR_CTL_WEIGHT, SFX_ITEM_POOLABLE }, // RES_CHRATR_CTL_WEIGHT
+ { SID_ATTR_CHAR_ROTATED, SFX_ITEM_POOLABLE }, // RES_CHRATR_ROTATE
+ { SID_ATTR_CHAR_EMPHASISMARK, SFX_ITEM_POOLABLE }, // RES_CHRATR_EMPHASIS_MARK
+ { SID_ATTR_CHAR_TWO_LINES, SFX_ITEM_POOLABLE }, // RES_CHRATR_TWO_LINES
+ { SID_ATTR_CHAR_SCALEWIDTH, SFX_ITEM_POOLABLE }, // RES_CHRATR_SCALEW
+ { SID_ATTR_CHAR_RELIEF, SFX_ITEM_POOLABLE }, // RES_CHRATR_RELIEF
+ { SID_ATTR_CHAR_HIDDEN, SFX_ITEM_POOLABLE }, // RES_CHRATR_HIDDEN
+ { SID_ATTR_CHAR_OVERLINE, SFX_ITEM_POOLABLE }, // RES_CHRATR_OVERLINE
+ { 0, SFX_ITEM_POOLABLE }, // RES_CHRATR_DUMMY1
+ { 0, SFX_ITEM_POOLABLE }, // RES_CHRATR_DUMMY2
+
+ { 0, 0 }, // RES_TXTATR_REFMARK
+ { 0, 0 }, // RES_TXTATR_TOXMARK
+ { 0, 0 }, // RES_TXTATR_META
+ { 0, 0 }, // RES_TXTATR_METAFIELD
+ { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_AUTOFMT
+ { FN_TXTATR_INET, 0 }, // RES_TXTATR_INETFMT
+ { 0, 0 }, // RES_TXTATR_CHARFMT
+ { SID_ATTR_CHAR_CJK_RUBY, 0 }, // RES_TXTATR_CJK_RUBY
+ { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_UNKNOWN_CONTAINER
+ { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_DUMMY5
+
+ { 0, 0 }, // RES_TXTATR_FIELD
+ { 0, 0 }, // RES_TXTATR_FLYCNT
+ { 0, 0 }, // RES_TXTATR_FTN
+ { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_DUMMY4
+ { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_DUMMY3
+ { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_DUMMY1
+ { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_DUMMY2
+
+ { SID_ATTR_PARA_LINESPACE, SFX_ITEM_POOLABLE }, // RES_PARATR_LINESPACING
+ { SID_ATTR_PARA_ADJUST, SFX_ITEM_POOLABLE }, // RES_PARATR_ADJUST
+ { SID_ATTR_PARA_SPLIT, SFX_ITEM_POOLABLE }, // RES_PARATR_SPLIT
+ { SID_ATTR_PARA_ORPHANS, SFX_ITEM_POOLABLE }, // RES_PARATR_ORPHANS
+ { SID_ATTR_PARA_WIDOWS, SFX_ITEM_POOLABLE }, // RES_PARATR_WIDOWS
+ { SID_ATTR_TABSTOP, SFX_ITEM_POOLABLE }, // RES_PARATR_TABSTOP
+ { SID_ATTR_PARA_HYPHENZONE, SFX_ITEM_POOLABLE }, // RES_PARATR_HYPHENZONE
+ { FN_FORMAT_DROPCAPS, 0 }, // RES_PARATR_DROP
+ { SID_ATTR_PARA_REGISTER, SFX_ITEM_POOLABLE }, // RES_PARATR_REGISTER
+ // --> OD 2008-03-04 #refactorlists#
+ // RES_PARATR_NUMRULE is now poolable
+ { SID_ATTR_PARA_NUMRULE, SFX_ITEM_POOLABLE }, // RES_PARATR_NUMRULE
+ // <--
+ { SID_ATTR_PARA_SCRIPTSPACE, SFX_ITEM_POOLABLE }, // RES_PARATR_SCRIPTSPACE
+ { SID_ATTR_PARA_HANGPUNCTUATION, SFX_ITEM_POOLABLE },// RES_PARATR_HANGINGPUNCTUATION
+
+ { SID_ATTR_PARA_FORBIDDEN_RULES, SFX_ITEM_POOLABLE },// RES_PARATR_FORBIDDEN_RULES
+ { SID_PARA_VERTALIGN, SFX_ITEM_POOLABLE }, // RES_PARATR_VERTALIGN
+ { SID_ATTR_PARA_SNAPTOGRID, SFX_ITEM_POOLABLE }, // RES_PARATR_SNAPTOGRID
+ { SID_ATTR_BORDER_CONNECT, SFX_ITEM_POOLABLE }, // RES_PARATR_CONNECT_BORDER
+
+ { SID_ATTR_PARA_OUTLINE_LEVEL, SFX_ITEM_POOLABLE }, // RES_PARATR_OUTLINELEVEL //#outline level,zhaojianwei
+
+ // --> OD 2008-02-19 #refactorlists#
+ { 0, SFX_ITEM_POOLABLE }, // RES_PARATR_LIST_ID
+ { 0, SFX_ITEM_POOLABLE }, // RES_PARATR_LIST_LEVEL
+ { 0, SFX_ITEM_POOLABLE }, // RES_PARATR_LIST_ISRESTART
+ { 0, SFX_ITEM_POOLABLE }, // RES_PARATR_LIST_RESTARTVALUE
+ { 0, SFX_ITEM_POOLABLE }, // RES_PARATR_LIST_ISCOUNTED
+ // <--
+
+ { 0, SFX_ITEM_POOLABLE }, // RES_FILL_ORDER
+ { 0, SFX_ITEM_POOLABLE }, // RES_FRM_SIZE
+ { SID_ATTR_PAGE_PAPERBIN, SFX_ITEM_POOLABLE }, // RES_PAPER_BIN
+ { SID_ATTR_LRSPACE, SFX_ITEM_POOLABLE }, // RES_LR_SPACE
+ { SID_ATTR_ULSPACE, SFX_ITEM_POOLABLE }, // RES_UL_SPACE
+ { 0, 0 }, // RES_PAGEDESC
+ { SID_ATTR_PARA_PAGEBREAK, SFX_ITEM_POOLABLE }, // RES_BREAK
+ { 0, 0 }, // RES_CNTNT
+ { 0, SFX_ITEM_POOLABLE }, // RES_HEADER
+ { 0, SFX_ITEM_POOLABLE }, // RES_FOOTER
+ { 0, SFX_ITEM_POOLABLE }, // RES_PRINT
+ { FN_OPAQUE, SFX_ITEM_POOLABLE }, // RES_OPAQUE
+ { FN_SET_PROTECT, SFX_ITEM_POOLABLE }, // RES_PROTECT
+ { FN_SURROUND, SFX_ITEM_POOLABLE }, // RES_SURROUND
+ { FN_VERT_ORIENT, SFX_ITEM_POOLABLE }, // RES_VERT_ORIENT
+ { FN_HORI_ORIENT, SFX_ITEM_POOLABLE }, // RES_HORI_ORIENT
+ { 0, 0 }, // RES_ANCHOR
+ { SID_ATTR_BRUSH, SFX_ITEM_POOLABLE }, // RES_BACKGROUND
+ { SID_ATTR_BORDER_OUTER, SFX_ITEM_POOLABLE }, // RES_BOX
+ { SID_ATTR_BORDER_SHADOW, SFX_ITEM_POOLABLE }, // RES_SHADOW
+ { SID_ATTR_MACROITEM, SFX_ITEM_POOLABLE }, // RES_FRMMACRO
+ { FN_ATTR_COLUMNS, SFX_ITEM_POOLABLE }, // RES_COL
+ { SID_ATTR_PARA_KEEP, SFX_ITEM_POOLABLE }, // RES_KEEP
+ { 0, SFX_ITEM_POOLABLE }, // RES_URL
+ { 0, SFX_ITEM_POOLABLE }, // RES_EDIT_IN_READONLY
+
+ { 0, SFX_ITEM_POOLABLE }, // RES_LAYOUT_SPLIT
+ { 0, 0 }, // RES_CHAIN
+ { 0, SFX_ITEM_POOLABLE }, // RES_TEXTGRID
+ { FN_FORMAT_LINENUMBER, SFX_ITEM_POOLABLE }, // RES_LINENUMBER
+ { 0, SFX_ITEM_POOLABLE }, // RES_FTN_AT_TXTEND
+ { 0, SFX_ITEM_POOLABLE }, // RES_END_AT_TXTEND
+ { 0, SFX_ITEM_POOLABLE }, // RES_COLUMNBALANCE
+
+ { SID_ATTR_FRAMEDIRECTION, SFX_ITEM_POOLABLE }, // RES_FRAMEDIR
+
+ { SID_ATTR_HDFT_DYNAMIC_SPACING, SFX_ITEM_POOLABLE }, // RES_HEADER_FOOTER_EAT_SPACING
+ { FN_TABLE_ROW_SPLIT, SFX_ITEM_POOLABLE }, // RES_ROW_SPLIT
+ // DVO, OD 18.09.2003 #i18732# - use slot-id define in svx
+ { SID_SW_FOLLOW_TEXT_FLOW, SFX_ITEM_POOLABLE }, // RES_FOLLOW_TEXT_FLOW
+ // --> collapsing borders FME 2005-05-27 #i29550#
+ { SID_SW_COLLAPSING_BORDERS, SFX_ITEM_POOLABLE }, // RES_COLLAPSING_BORDERS
+ // <-- collapsing
+ // OD 2004-05-04 #i28701#
+ { SID_SW_WRAP_INFLUENCE_ON_OBJPOS, SFX_ITEM_POOLABLE }, // RES_WRAP_INFLUENCE_ON_OBJPOS
+ { 0, 0 }, // RES_AUTO_STYLE
+ { 0, SFX_ITEM_POOLABLE }, // RES_FRMATR_STYLE_NAME
+ { 0, SFX_ITEM_POOLABLE }, // RES_FRMATR_CONDITIONAL_STYLE_NAME
+
+ { 0, SFX_ITEM_POOLABLE }, // RES_GRFATR_MIRRORGRF
+ { SID_ATTR_GRAF_CROP, SFX_ITEM_POOLABLE }, // RES_GRFATR_CROPGRF
+ { 0, SFX_ITEM_POOLABLE }, // RES_GRFATR_ROTATION,
+ { 0, SFX_ITEM_POOLABLE }, // RES_GRFATR_LUMINANCE,
+ { 0, SFX_ITEM_POOLABLE }, // RES_GRFATR_CONTRAST,
+ { 0, SFX_ITEM_POOLABLE }, // RES_GRFATR_CHANNELR,
+ { 0, SFX_ITEM_POOLABLE }, // RES_GRFATR_CHANNELG,
+ { 0, SFX_ITEM_POOLABLE }, // RES_GRFATR_CHANNELB,
+ { 0, SFX_ITEM_POOLABLE }, // RES_GRFATR_GAMMA,
+ { 0, SFX_ITEM_POOLABLE }, // RES_GRFATR_INVERT,
+ { 0, SFX_ITEM_POOLABLE }, // RES_GRFATR_TRANSPARENCY,
+ { 0, SFX_ITEM_POOLABLE }, // RES_GRFATR_DUMMY1,
+ { 0, SFX_ITEM_POOLABLE }, // RES_GRFATR_DUMMY2,
+ { 0, SFX_ITEM_POOLABLE }, // RES_GRFATR_DUMMY3,
+ { 0, SFX_ITEM_POOLABLE }, // RES_GRFATR_DUMMY4,
+ { 0, SFX_ITEM_POOLABLE }, // RES_GRFATR_DUMMY5,
+ { 0, SFX_ITEM_POOLABLE }, // RES_GRFATR_DUMMY6,
+
+ { 0, SFX_ITEM_POOLABLE }, // RES_BOXATR_FORMAT
+ { 0, 0 }, // RES_BOXATR_FORMULA,
+ { 0, SFX_ITEM_POOLABLE }, // RES_BOXATR_VALUE
+
+ { 0, SFX_ITEM_POOLABLE } // RES_UNKNOWNATR_CONTAINER
+};
+
+
+USHORT* SwAttrPool::pVersionMap1 = 0;
+USHORT* SwAttrPool::pVersionMap2 = 0;
+USHORT* SwAttrPool::pVersionMap3 = 0;
+USHORT* SwAttrPool::pVersionMap4 = 0;
+// OD 2004-01-21 #i18732#
+USHORT* SwAttrPool::pVersionMap5 = 0;
+USHORT* SwAttrPool::pVersionMap6 = 0;
+SwIndexReg* SwIndexReg::pEmptyIndexArray = 0;
+
+const sal_Char* __FAR_DATA pMarkToTable = "table";
+const sal_Char* __FAR_DATA pMarkToFrame = "frame";
+const sal_Char* __FAR_DATA pMarkToRegion = "region";
+const sal_Char* __FAR_DATA pMarkToText = "text";
+const sal_Char* __FAR_DATA pMarkToOutline = "outline";
+const sal_Char* __FAR_DATA pMarkToGraphic = "graphic";
+const sal_Char* __FAR_DATA pMarkToOLE = "ole";
+
+SvPtrarr *pGlobalOLEExcludeList = 0;
+
+SwAutoCompleteWord* SwDoc::pACmpltWords = 0;
+
+SwCheckIt* pCheckIt = 0;
+CharClass* pAppCharClass = 0;
+
+CollatorWrapper* pCollator = 0, *pCaseCollator = 0;
+::utl::TransliterationWrapper* pTransWrp = 0;
+
+/******************************************************************************
+ * void _InitCore()
+ ******************************************************************************/
+salhelper::SingletonRef<SwCalendarWrapper>* s_getCalendarWrapper()
+{
+ static salhelper::SingletonRef<SwCalendarWrapper> aCalendarWrapper;
+ return &aCalendarWrapper;
+}
+void _InitCore()
+{
+ SfxPoolItem* pItem;
+
+ // erstmal alle Attribut-Pointer auf 0 setzen
+ memset( aAttrTab, 0, (POOLATTR_END - POOLATTR_BEGIN) *
+ sizeof( SfxPoolItem* ) );
+
+ aAttrTab[ RES_CHRATR_CASEMAP- POOLATTR_BEGIN ] = new SvxCaseMapItem( SVX_CASEMAP_NOT_MAPPED, RES_CHRATR_CASEMAP);
+ aAttrTab[ RES_CHRATR_CHARSETCOLOR- POOLATTR_BEGIN ] = new SvxCharSetColorItem(RES_CHRATR_CHARSETCOLOR);
+ aAttrTab[ RES_CHRATR_COLOR- POOLATTR_BEGIN ] = new SvxColorItem(RES_CHRATR_COLOR);
+ aAttrTab[ RES_CHRATR_CONTOUR- POOLATTR_BEGIN ] = new SvxContourItem( sal_False, RES_CHRATR_CONTOUR );
+ aAttrTab[ RES_CHRATR_CROSSEDOUT- POOLATTR_BEGIN ] = new SvxCrossedOutItem( STRIKEOUT_NONE, RES_CHRATR_CROSSEDOUT );
+ aAttrTab[ RES_CHRATR_ESCAPEMENT- POOLATTR_BEGIN ] = new SvxEscapementItem( RES_CHRATR_ESCAPEMENT );
+ aAttrTab[ RES_CHRATR_FONT- POOLATTR_BEGIN ] = new SvxFontItem( RES_CHRATR_FONT );
+
+ aAttrTab[ RES_CHRATR_FONTSIZE- POOLATTR_BEGIN ] = new SvxFontHeightItem( 240, 100, RES_CHRATR_FONTSIZE );
+ aAttrTab[ RES_CHRATR_KERNING- POOLATTR_BEGIN ] = new SvxKerningItem( 0, RES_CHRATR_KERNING );
+ aAttrTab[ RES_CHRATR_LANGUAGE- POOLATTR_BEGIN ] = new SvxLanguageItem(LANGUAGE_DONTKNOW, RES_CHRATR_LANGUAGE );
+ aAttrTab[ RES_CHRATR_POSTURE- POOLATTR_BEGIN ] = new SvxPostureItem( ITALIC_NONE, RES_CHRATR_POSTURE );
+ aAttrTab[ RES_CHRATR_PROPORTIONALFONTSIZE- POOLATTR_BEGIN ] = new SvxPropSizeItem( 100, RES_CHRATR_PROPORTIONALFONTSIZE );
+ aAttrTab[ RES_CHRATR_SHADOWED- POOLATTR_BEGIN ] = new SvxShadowedItem( sal_False, RES_CHRATR_SHADOWED );
+ aAttrTab[ RES_CHRATR_UNDERLINE- POOLATTR_BEGIN ] = new SvxUnderlineItem( UNDERLINE_NONE, RES_CHRATR_UNDERLINE );
+ aAttrTab[ RES_CHRATR_WEIGHT- POOLATTR_BEGIN ] = new SvxWeightItem( WEIGHT_NORMAL, RES_CHRATR_WEIGHT );
+ aAttrTab[ RES_CHRATR_WORDLINEMODE- POOLATTR_BEGIN ] = new SvxWordLineModeItem( sal_False, RES_CHRATR_WORDLINEMODE );
+ aAttrTab[ RES_CHRATR_AUTOKERN- POOLATTR_BEGIN ] = new SvxAutoKernItem( sal_False, RES_CHRATR_AUTOKERN );
+ aAttrTab[ RES_CHRATR_BLINK - POOLATTR_BEGIN ] = new SvxBlinkItem( FALSE, RES_CHRATR_BLINK );
+ aAttrTab[ RES_CHRATR_NOHYPHEN - POOLATTR_BEGIN ] = new SvxNoHyphenItem( TRUE, RES_CHRATR_NOHYPHEN );
+ aAttrTab[ RES_CHRATR_NOLINEBREAK- POOLATTR_BEGIN ] = new SvxNoLinebreakItem( TRUE, RES_CHRATR_NOLINEBREAK );
+ aAttrTab[ RES_CHRATR_BACKGROUND - POOLATTR_BEGIN ] = new SvxBrushItem( RES_CHRATR_BACKGROUND );
+
+ // CJK-Attributes
+ aAttrTab[ RES_CHRATR_CJK_FONT - POOLATTR_BEGIN ] = new SvxFontItem( RES_CHRATR_CJK_FONT );
+ aAttrTab[ RES_CHRATR_CJK_FONTSIZE - POOLATTR_BEGIN ] = new SvxFontHeightItem( 240, 100, RES_CHRATR_CJK_FONTSIZE );
+ aAttrTab[ RES_CHRATR_CJK_LANGUAGE - POOLATTR_BEGIN ] = new SvxLanguageItem(LANGUAGE_DONTKNOW, RES_CHRATR_CJK_LANGUAGE);
+ aAttrTab[ RES_CHRATR_CJK_POSTURE - POOLATTR_BEGIN ] = new SvxPostureItem(ITALIC_NONE, RES_CHRATR_CJK_POSTURE );
+ aAttrTab[ RES_CHRATR_CJK_WEIGHT - POOLATTR_BEGIN ] = new SvxWeightItem( WEIGHT_NORMAL, RES_CHRATR_CJK_WEIGHT );
+
+ // CTL-Attributes
+ aAttrTab[ RES_CHRATR_CTL_FONT - POOLATTR_BEGIN ] = new SvxFontItem( RES_CHRATR_CTL_FONT );
+ aAttrTab[ RES_CHRATR_CTL_FONTSIZE - POOLATTR_BEGIN ] = new SvxFontHeightItem( 240, 100, RES_CHRATR_CTL_FONTSIZE );
+ aAttrTab[ RES_CHRATR_CTL_LANGUAGE - POOLATTR_BEGIN ] = new SvxLanguageItem(LANGUAGE_DONTKNOW, RES_CHRATR_CTL_LANGUAGE);
+ aAttrTab[ RES_CHRATR_CTL_POSTURE - POOLATTR_BEGIN ] = new SvxPostureItem(ITALIC_NONE, RES_CHRATR_CTL_POSTURE );
+ aAttrTab[ RES_CHRATR_CTL_WEIGHT - POOLATTR_BEGIN ] = new SvxWeightItem( WEIGHT_NORMAL, RES_CHRATR_CTL_WEIGHT );
+
+ aAttrTab[ RES_CHRATR_ROTATE - POOLATTR_BEGIN ] = new SvxCharRotateItem( 0, sal_False, RES_CHRATR_ROTATE );
+ aAttrTab[ RES_CHRATR_EMPHASIS_MARK - POOLATTR_BEGIN ] = new SvxEmphasisMarkItem( EMPHASISMARK_NONE, RES_CHRATR_EMPHASIS_MARK );
+ aAttrTab[ RES_CHRATR_TWO_LINES - POOLATTR_BEGIN ] = new SvxTwoLinesItem( FALSE, 0, 0, RES_CHRATR_TWO_LINES );
+ aAttrTab[ RES_CHRATR_SCALEW - POOLATTR_BEGIN ] = new SvxCharScaleWidthItem( 100, RES_CHRATR_SCALEW );
+ aAttrTab[ RES_CHRATR_RELIEF - POOLATTR_BEGIN ] = new SvxCharReliefItem( RELIEF_NONE, RES_CHRATR_RELIEF );
+ aAttrTab[ RES_CHRATR_HIDDEN - POOLATTR_BEGIN ] = new SvxCharHiddenItem( FALSE, RES_CHRATR_HIDDEN );
+ aAttrTab[ RES_CHRATR_OVERLINE- POOLATTR_BEGIN ] = new SvxOverlineItem( UNDERLINE_NONE, RES_CHRATR_OVERLINE );
+
+// CharakterAttr - Dummies
+ aAttrTab[ RES_CHRATR_DUMMY1 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_CHRATR_DUMMY1 );
+ aAttrTab[ RES_CHRATR_DUMMY2 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_CHRATR_DUMMY2 );
+// CharakterAttr - Dummies
+
+ aAttrTab[ RES_TXTATR_AUTOFMT- POOLATTR_BEGIN ] = new SwFmtAutoFmt;
+ aAttrTab[ RES_TXTATR_INETFMT - POOLATTR_BEGIN ] = new SwFmtINetFmt( aEmptyStr, aEmptyStr );
+ aAttrTab[ RES_TXTATR_REFMARK - POOLATTR_BEGIN ] = new SwFmtRefMark( aEmptyStr );
+ aAttrTab[ RES_TXTATR_TOXMARK - POOLATTR_BEGIN ] = new SwTOXMark;
+ aAttrTab[ RES_TXTATR_CHARFMT- POOLATTR_BEGIN ] = new SwFmtCharFmt( 0 );
+ aAttrTab[ RES_TXTATR_CJK_RUBY - POOLATTR_BEGIN ] = new SwFmtRuby( aEmptyStr );
+ aAttrTab[ RES_TXTATR_UNKNOWN_CONTAINER - POOLATTR_BEGIN ] = new SvXMLAttrContainerItem( RES_TXTATR_UNKNOWN_CONTAINER );
+ aAttrTab[ RES_TXTATR_META - POOLATTR_BEGIN ] = SwFmtMeta::CreatePoolDefault(RES_TXTATR_META);
+ aAttrTab[ RES_TXTATR_METAFIELD - POOLATTR_BEGIN ] = SwFmtMeta::CreatePoolDefault(RES_TXTATR_METAFIELD);
+
+ aAttrTab[ RES_TXTATR_FIELD- POOLATTR_BEGIN ] = new SwFmtFld;
+ aAttrTab[ RES_TXTATR_FLYCNT - POOLATTR_BEGIN ] = new SwFmtFlyCnt( 0 );
+ aAttrTab[ RES_TXTATR_FTN - POOLATTR_BEGIN ] = new SwFmtFtn;
+
+// TextAttr - Dummies
+ aAttrTab[ RES_TXTATR_DUMMY4 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_TXTATR_DUMMY4 );
+ aAttrTab[ RES_TXTATR_DUMMY3 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_TXTATR_DUMMY3 );
+ aAttrTab[ RES_TXTATR_DUMMY1 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_TXTATR_DUMMY1 );
+ aAttrTab[ RES_TXTATR_DUMMY2 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_TXTATR_DUMMY2 );
+ aAttrTab[ RES_TXTATR_DUMMY5 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_TXTATR_DUMMY5 );
+// TextAttr - Dummies
+
+ aAttrTab[ RES_PARATR_LINESPACING- POOLATTR_BEGIN ] = new SvxLineSpacingItem( LINE_SPACE_DEFAULT_HEIGHT, RES_PARATR_LINESPACING );
+ aAttrTab[ RES_PARATR_ADJUST- POOLATTR_BEGIN ] = new SvxAdjustItem( SVX_ADJUST_LEFT, RES_PARATR_ADJUST );
+ aAttrTab[ RES_PARATR_SPLIT- POOLATTR_BEGIN ] = new SvxFmtSplitItem( sal_True, RES_PARATR_SPLIT );
+ aAttrTab[ RES_PARATR_WIDOWS- POOLATTR_BEGIN ] = new SvxWidowsItem( 0, RES_PARATR_WIDOWS );
+ aAttrTab[ RES_PARATR_ORPHANS- POOLATTR_BEGIN ] = new SvxOrphansItem( 0, RES_PARATR_ORPHANS );
+ aAttrTab[ RES_PARATR_TABSTOP- POOLATTR_BEGIN ] = new SvxTabStopItem( 1, SVX_TAB_DEFDIST, SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP );
+
+ pItem = new SvxHyphenZoneItem( sal_False, RES_PARATR_HYPHENZONE );
+ ((SvxHyphenZoneItem*)pItem)->GetMaxHyphens() = 0; // Default z.Z. auf 0
+ aAttrTab[ RES_PARATR_HYPHENZONE- POOLATTR_BEGIN ] = pItem;
+
+ aAttrTab[ RES_PARATR_DROP- POOLATTR_BEGIN ] = new SwFmtDrop;
+ aAttrTab[ RES_PARATR_REGISTER - POOLATTR_BEGIN ] = new SwRegisterItem( FALSE );
+ aAttrTab[ RES_PARATR_NUMRULE - POOLATTR_BEGIN ] = new SwNumRuleItem( aEmptyStr );
+
+ aAttrTab[ RES_PARATR_SCRIPTSPACE - POOLATTR_BEGIN ] = new SvxScriptSpaceItem( TRUE, RES_PARATR_SCRIPTSPACE );
+ aAttrTab[ RES_PARATR_HANGINGPUNCTUATION - POOLATTR_BEGIN ] = new SvxHangingPunctuationItem( TRUE, RES_PARATR_HANGINGPUNCTUATION );
+ aAttrTab[ RES_PARATR_FORBIDDEN_RULES - POOLATTR_BEGIN ] = new SvxForbiddenRuleItem( TRUE, RES_PARATR_FORBIDDEN_RULES );
+ aAttrTab[ RES_PARATR_VERTALIGN - POOLATTR_BEGIN ] = new SvxParaVertAlignItem( 0, RES_PARATR_VERTALIGN );
+ aAttrTab[ RES_PARATR_SNAPTOGRID - POOLATTR_BEGIN ] = new SvxParaGridItem( sal_True, RES_PARATR_SNAPTOGRID );
+ aAttrTab[ RES_PARATR_CONNECT_BORDER - POOLATTR_BEGIN ] = new SwParaConnectBorderItem;
+
+ aAttrTab[ RES_PARATR_OUTLINELEVEL - POOLATTR_BEGIN ] = new SfxUInt16Item( RES_PARATR_OUTLINELEVEL, 0 );//#outline level,zhaojianwei
+
+ // --> OD 2008-02-19 #refactorlists#
+ aAttrTab[ RES_PARATR_LIST_ID - POOLATTR_BEGIN ] = new SfxStringItem( RES_PARATR_LIST_ID, aEmptyStr );
+ aAttrTab[ RES_PARATR_LIST_LEVEL - POOLATTR_BEGIN ] = new SfxInt16Item( RES_PARATR_LIST_LEVEL, 0 );
+ aAttrTab[ RES_PARATR_LIST_ISRESTART - POOLATTR_BEGIN ] = new SfxBoolItem( RES_PARATR_LIST_ISRESTART, FALSE );
+ aAttrTab[ RES_PARATR_LIST_RESTARTVALUE - POOLATTR_BEGIN ] = new SfxInt16Item( RES_PARATR_LIST_RESTARTVALUE, 1 );
+ aAttrTab[ RES_PARATR_LIST_ISCOUNTED - POOLATTR_BEGIN ] = new SfxBoolItem( RES_PARATR_LIST_ISCOUNTED, TRUE );
+ // <--
+
+ aAttrTab[ RES_FILL_ORDER- POOLATTR_BEGIN ] = new SwFmtFillOrder;
+ aAttrTab[ RES_FRM_SIZE- POOLATTR_BEGIN ] = new SwFmtFrmSize;
+ aAttrTab[ RES_PAPER_BIN- POOLATTR_BEGIN ] = new SvxPaperBinItem( RES_PAPER_BIN );
+ aAttrTab[ RES_LR_SPACE- POOLATTR_BEGIN ] = new SvxLRSpaceItem( RES_LR_SPACE );
+ aAttrTab[ RES_UL_SPACE- POOLATTR_BEGIN ] = new SvxULSpaceItem( RES_UL_SPACE );
+ aAttrTab[ RES_PAGEDESC- POOLATTR_BEGIN ] = new SwFmtPageDesc;
+ aAttrTab[ RES_BREAK- POOLATTR_BEGIN ] = new SvxFmtBreakItem( SVX_BREAK_NONE, RES_BREAK);
+ aAttrTab[ RES_CNTNT- POOLATTR_BEGIN ] = new SwFmtCntnt;
+ aAttrTab[ RES_HEADER- POOLATTR_BEGIN ] = new SwFmtHeader;
+ aAttrTab[ RES_FOOTER- POOLATTR_BEGIN ] = new SwFmtFooter;
+ aAttrTab[ RES_PRINT- POOLATTR_BEGIN ] = new SvxPrintItem( RES_PRINT );
+ aAttrTab[ RES_OPAQUE- POOLATTR_BEGIN ] = new SvxOpaqueItem( RES_OPAQUE );
+ aAttrTab[ RES_PROTECT- POOLATTR_BEGIN ] = new SvxProtectItem( RES_PROTECT );
+ aAttrTab[ RES_SURROUND- POOLATTR_BEGIN ] = new SwFmtSurround;
+ aAttrTab[ RES_VERT_ORIENT- POOLATTR_BEGIN ] = new SwFmtVertOrient;
+ aAttrTab[ RES_HORI_ORIENT- POOLATTR_BEGIN ] = new SwFmtHoriOrient;
+ aAttrTab[ RES_ANCHOR- POOLATTR_BEGIN ] = new SwFmtAnchor;
+ aAttrTab[ RES_BACKGROUND- POOLATTR_BEGIN ] = new SvxBrushItem( RES_BACKGROUND );
+ aAttrTab[ RES_BOX- POOLATTR_BEGIN ] = new SvxBoxItem( RES_BOX );
+ aAttrTab[ RES_SHADOW- POOLATTR_BEGIN ] = new SvxShadowItem( RES_SHADOW );
+ aAttrTab[ RES_FRMMACRO- POOLATTR_BEGIN ] = new SvxMacroItem( RES_FRMMACRO );
+ aAttrTab[ RES_COL- POOLATTR_BEGIN ] = new SwFmtCol;
+ aAttrTab[ RES_KEEP - POOLATTR_BEGIN ] = new SvxFmtKeepItem( FALSE, RES_KEEP );
+ aAttrTab[ RES_URL - POOLATTR_BEGIN ] = new SwFmtURL();
+ aAttrTab[ RES_EDIT_IN_READONLY - POOLATTR_BEGIN ] = new SwFmtEditInReadonly;
+ aAttrTab[ RES_LAYOUT_SPLIT - POOLATTR_BEGIN ] = new SwFmtLayoutSplit;
+ aAttrTab[ RES_CHAIN - POOLATTR_BEGIN ] = new SwFmtChain;
+ aAttrTab[ RES_TEXTGRID - POOLATTR_BEGIN ] = new SwTextGridItem;
+ aAttrTab[ RES_HEADER_FOOTER_EAT_SPACING - POOLATTR_BEGIN ] = new SwHeaderAndFooterEatSpacingItem;
+ aAttrTab[ RES_LINENUMBER - POOLATTR_BEGIN ] = new SwFmtLineNumber;
+ aAttrTab[ RES_FTN_AT_TXTEND - POOLATTR_BEGIN ] = new SwFmtFtnAtTxtEnd;
+ aAttrTab[ RES_END_AT_TXTEND - POOLATTR_BEGIN ] = new SwFmtEndAtTxtEnd;
+ aAttrTab[ RES_COLUMNBALANCE - POOLATTR_BEGIN ] = new SwFmtNoBalancedColumns;
+ aAttrTab[ RES_FRAMEDIR - POOLATTR_BEGIN ] = new SvxFrameDirectionItem( FRMDIR_ENVIRONMENT, RES_FRAMEDIR );
+ aAttrTab[ RES_ROW_SPLIT - POOLATTR_BEGIN ] = new SwFmtRowSplit;
+
+ // OD 18.09.2003 #i18732#
+ aAttrTab[ RES_FOLLOW_TEXT_FLOW - POOLATTR_BEGIN ] = new SwFmtFollowTextFlow( TRUE );
+ // --> collapsing borders FME 2005-05-27 #i29550#
+ aAttrTab[ RES_COLLAPSING_BORDERS - POOLATTR_BEGIN ] = new SfxBoolItem( RES_COLLAPSING_BORDERS, FALSE );
+ // <-- collapsing
+ // OD 2004-05-04 #i28701#
+ // --> OD 2004-10-18 #i35017# - constant name has changed
+ aAttrTab[ RES_WRAP_INFLUENCE_ON_OBJPOS - POOLATTR_BEGIN ] =
+ new SwFmtWrapInfluenceOnObjPos( text::WrapInfluenceOnPosition::ONCE_CONCURRENT );
+ // <--
+// FrmAttr-Dummies
+ aAttrTab[ RES_AUTO_STYLE - POOLATTR_BEGIN ] = new SwFmtAutoFmt( RES_AUTO_STYLE );
+ aAttrTab[ RES_FRMATR_STYLE_NAME - POOLATTR_BEGIN ] = new SfxStringItem( RES_FRMATR_STYLE_NAME, aEmptyStr );
+ aAttrTab[ RES_FRMATR_CONDITIONAL_STYLE_NAME - POOLATTR_BEGIN ] = new SfxStringItem( RES_FRMATR_CONDITIONAL_STYLE_NAME, aEmptyStr );
+// FrmAttr-Dummies
+
+ aAttrTab[ RES_GRFATR_MIRRORGRF- POOLATTR_BEGIN ] = new SwMirrorGrf;
+ aAttrTab[ RES_GRFATR_CROPGRF- POOLATTR_BEGIN ] = new SwCropGrf;
+ aAttrTab[ RES_GRFATR_ROTATION - POOLATTR_BEGIN ] = new SwRotationGrf;
+ aAttrTab[ RES_GRFATR_LUMINANCE - POOLATTR_BEGIN ] = new SwLuminanceGrf;
+ aAttrTab[ RES_GRFATR_CONTRAST - POOLATTR_BEGIN ] = new SwContrastGrf;
+ aAttrTab[ RES_GRFATR_CHANNELR - POOLATTR_BEGIN ] = new SwChannelRGrf;
+ aAttrTab[ RES_GRFATR_CHANNELG - POOLATTR_BEGIN ] = new SwChannelGGrf;
+ aAttrTab[ RES_GRFATR_CHANNELB - POOLATTR_BEGIN ] = new SwChannelBGrf;
+ aAttrTab[ RES_GRFATR_GAMMA - POOLATTR_BEGIN ] = new SwGammaGrf;
+ aAttrTab[ RES_GRFATR_INVERT - POOLATTR_BEGIN ] = new SwInvertGrf;
+ aAttrTab[ RES_GRFATR_TRANSPARENCY - POOLATTR_BEGIN ] = new SwTransparencyGrf;
+ aAttrTab[ RES_GRFATR_DRAWMODE - POOLATTR_BEGIN ] = new SwDrawModeGrf;
+
+// GraphicAttr - Dummies
+ aAttrTab[ RES_GRFATR_DUMMY1 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_GRFATR_DUMMY1 );
+ aAttrTab[ RES_GRFATR_DUMMY2 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_GRFATR_DUMMY2 );
+ aAttrTab[ RES_GRFATR_DUMMY3 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_GRFATR_DUMMY3 );
+ aAttrTab[ RES_GRFATR_DUMMY4 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_GRFATR_DUMMY4 );
+ aAttrTab[ RES_GRFATR_DUMMY5 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_GRFATR_DUMMY5 );
+// GraphicAttr - Dummies
+
+ aAttrTab[ RES_BOXATR_FORMAT- POOLATTR_BEGIN ] = new SwTblBoxNumFormat;
+ aAttrTab[ RES_BOXATR_FORMULA- POOLATTR_BEGIN ] = new SwTblBoxFormula( aEmptyStr );
+ aAttrTab[ RES_BOXATR_VALUE- POOLATTR_BEGIN ] = new SwTblBoxValue;
+
+ aAttrTab[ RES_UNKNOWNATR_CONTAINER- POOLATTR_BEGIN ] =
+ new SvXMLAttrContainerItem( RES_UNKNOWNATR_CONTAINER );
+
+ // get the correct fonts:
+ ::GetDefaultFonts( *(SvxFontItem*)aAttrTab[ RES_CHRATR_FONT- POOLATTR_BEGIN ],
+ *(SvxFontItem*)aAttrTab[ RES_CHRATR_CJK_FONT - POOLATTR_BEGIN ],
+ *(SvxFontItem*)aAttrTab[ RES_CHRATR_CTL_FONT - POOLATTR_BEGIN ] );
+
+ // 1. Version - neue Attribute:
+ // - RES_CHRATR_BLINK
+ // - RES_CHRATR_NOHYPHEN
+ // - RES_CHRATR_NOLINEBREAK
+ // - RES_PARATR_REGISTER
+ // + 2 Dummies fuer die einzelnen "Bereiche"
+ SwAttrPool::pVersionMap1 = new USHORT[ 60 ];
+ USHORT i;
+ for( i = 1; i <= 17; i++ )
+ SwAttrPool::pVersionMap1[ i-1 ] = i;
+ for ( i = 18; i <= 27; ++i )
+ SwAttrPool::pVersionMap1[ i-1 ] = i + 5;
+ for ( i = 28; i <= 35; ++i )
+ SwAttrPool::pVersionMap1[ i-1 ] = i + 7;
+ for ( i = 36; i <= 58; ++i )
+ SwAttrPool::pVersionMap1[ i-1 ] = i + 10;
+ for ( i = 59; i <= 60; ++i )
+ SwAttrPool::pVersionMap1[ i-1 ] = i + 12;
+
+ // 2. Version - neue Attribute:
+ // 10 Dummies fuer den Frame "Bereich"
+ SwAttrPool::pVersionMap2 = new USHORT[ 75 ];
+ for( i = 1; i <= 70; i++ )
+ SwAttrPool::pVersionMap2[ i-1 ] = i;
+ for ( i = 71; i <= 75; ++i )
+ SwAttrPool::pVersionMap2[ i-1 ] = i + 10;
+
+ // 3. Version - neue Attribute:
+ // neue Attribute und Dummies fuer die CJK-Version
+ // und neue Grafik-Attribute
+ SwAttrPool::pVersionMap3 = new USHORT[ 86 ];
+ for( i = 1; i <= 21; i++ )
+ SwAttrPool::pVersionMap3[ i-1 ] = i;
+ for ( i = 22; i <= 27; ++i )
+ SwAttrPool::pVersionMap3[ i-1 ] = i + 15;
+ for ( i = 28; i <= 82; ++i )
+ SwAttrPool::pVersionMap3[ i-1 ] = i + 20;
+ for ( i = 83; i <= 86; ++i )
+ SwAttrPool::pVersionMap3[ i-1 ] = i + 35;
+
+ // 4. Version - neue Paragraph Attribute fuer die CJK-Version
+ SwAttrPool::pVersionMap4 = new USHORT[ 121 ];
+ for( i = 1; i <= 65; i++ )
+ SwAttrPool::pVersionMap4[ i-1 ] = i;
+ for ( i = 66; i <= 121; ++i )
+ SwAttrPool::pVersionMap4[ i-1 ] = i + 9;
+
+ // OD 2004-01-21 #i18732# - setup new version map due to extension of
+ // the frame attributes (RES_FRMATR_*) for binary filters.
+ SwAttrPool::pVersionMap5 = new USHORT[ 130 ];
+ for( i = 1; i <= 109; i++ )
+ SwAttrPool::pVersionMap5[ i-1 ] = i;
+ for ( i = 110; i <= 130; ++i )
+ SwAttrPool::pVersionMap5[ i-1 ] = i + 6;
+
+ // 6. Version - new character attribute for overlining plus 2 dummies
+ SwAttrPool::pVersionMap6 = new USHORT[ 136 ];
+ for( i = 1; i <= 37; i++ )
+ SwAttrPool::pVersionMap6[ i-1 ] = i;
+ for ( i = 38; i <= 136; ++i )
+ SwAttrPool::pVersionMap6[ i-1 ] = i + 3;
+
+ uno::Reference<
+ lang::XMultiServiceFactory > xMSF =
+ ::comphelper::getProcessServiceFactory();
+
+ SwBreakIt::_Create( xMSF );
+ pCheckIt = NULL;
+ /*pAppCharClass = new CharClass(
+ xMSF, SwBreakIt::Get()->GetLocale( (LanguageType)GetAppLanguage() ));*/
+ //pCalendarWrapper = new SwCalendarWrapper( xMSF );
+
+ _FrmInit();
+ _TextInit();
+
+ SwSelPaintRects::pMapMode = new MapMode;
+ SwFntObj::pPixMap = new MapMode;
+
+ SwIndexReg::pEmptyIndexArray = new SwIndexReg;
+
+ pGlobalOLEExcludeList = new SvPtrarr;
+
+ const SvxSwAutoFmtFlags& rAFlags = SvxAutoCorrCfg::Get()->GetAutoCorrect()->GetSwFlags();
+ SwDoc::pACmpltWords = new SwAutoCompleteWord( rAFlags.nAutoCmpltListLen,
+ rAFlags.nAutoCmpltWordLen );
+}
+
+/******************************************************************************
+ * void _FinitCore()
+ ******************************************************************************/
+
+
+
+void _FinitCore()
+{
+ _FrmFinit();
+ _TextFinit();
+
+ SwBreakIt::_Delete();
+ delete pCheckIt;
+ delete pAppCharClass;
+ delete pCollator;
+ delete pCaseCollator;
+
+ // das default TableAutoFormat zerstoeren
+ delete SwTableAutoFmt::pDfltBoxAutoFmt;
+
+ delete SwSelPaintRects::pMapMode;
+ delete SwFntObj::pPixMap;
+
+ delete SwEditShell::pAutoFmtFlags;
+
+#ifdef DBG_UTIL
+ //Defaultattribut freigeben lassen um asserts zu vermeiden.
+ if ( aAttrTab[0]->GetRefCount() )
+ SfxItemPool::ReleaseDefaults( aAttrTab, POOLATTR_END-POOLATTR_BEGIN, FALSE);
+#endif
+ delete SwDoc::pACmpltWords;
+
+ delete SwStyleNameMapper::pTextUINameArray;
+ delete SwStyleNameMapper::pListsUINameArray;
+ delete SwStyleNameMapper::pExtraUINameArray;
+ delete SwStyleNameMapper::pRegisterUINameArray;
+ delete SwStyleNameMapper::pDocUINameArray;
+ delete SwStyleNameMapper::pHTMLUINameArray;
+ delete SwStyleNameMapper::pFrmFmtUINameArray;
+ delete SwStyleNameMapper::pChrFmtUINameArray;
+ delete SwStyleNameMapper::pHTMLChrFmtUINameArray;
+ delete SwStyleNameMapper::pPageDescUINameArray;
+ delete SwStyleNameMapper::pNumRuleUINameArray;
+
+ // Delete programmatic name arrays also
+ delete SwStyleNameMapper::pTextProgNameArray;
+ delete SwStyleNameMapper::pListsProgNameArray;
+ delete SwStyleNameMapper::pExtraProgNameArray;
+ delete SwStyleNameMapper::pRegisterProgNameArray;
+ delete SwStyleNameMapper::pDocProgNameArray;
+ delete SwStyleNameMapper::pHTMLProgNameArray;
+ delete SwStyleNameMapper::pFrmFmtProgNameArray;
+ delete SwStyleNameMapper::pChrFmtProgNameArray;
+ delete SwStyleNameMapper::pHTMLChrFmtProgNameArray;
+ delete SwStyleNameMapper::pPageDescProgNameArray;
+ delete SwStyleNameMapper::pNumRuleProgNameArray;
+
+ // And finally, any hash tables that we used
+ delete SwStyleNameMapper::pParaUIMap;
+ delete SwStyleNameMapper::pCharUIMap;
+ delete SwStyleNameMapper::pPageUIMap;
+ delete SwStyleNameMapper::pFrameUIMap;
+ delete SwStyleNameMapper::pNumRuleUIMap;
+
+ delete SwStyleNameMapper::pParaProgMap;
+ delete SwStyleNameMapper::pCharProgMap;
+ delete SwStyleNameMapper::pPageProgMap;
+ delete SwStyleNameMapper::pFrameProgMap;
+ delete SwStyleNameMapper::pNumRuleProgMap;
+
+
+ // loesche alle default-Attribute
+ SfxPoolItem* pHt;
+ for( USHORT n = 0; n < POOLATTR_END - POOLATTR_BEGIN; n++ )
+ if( 0 != ( pHt = aAttrTab[n] ))
+ delete pHt;
+
+ ::ClearFEShellTabCols();
+
+ delete SwIndexReg::pEmptyIndexArray;
+ delete[] SwAttrPool::pVersionMap1;
+ delete[] SwAttrPool::pVersionMap2;
+ delete[] SwAttrPool::pVersionMap3;
+ delete[] SwAttrPool::pVersionMap4;
+ // OD 2004-01-21 #i18732#
+ delete[] SwAttrPool::pVersionMap5;
+ delete[] SwAttrPool::pVersionMap6;
+
+ for ( USHORT i = 0; i < pGlobalOLEExcludeList->Count(); ++i )
+ delete (SvGlobalName*)(*pGlobalOLEExcludeList)[i];
+ delete pGlobalOLEExcludeList;
+}
+
+// returns the APP - CharClass instance - used for all ToUpper/ToLower/...
+CharClass& GetAppCharClass()
+{
+ if ( !pAppCharClass )
+ {
+ uno::Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
+ pAppCharClass = new CharClass(
+ xMSF, SwBreakIt::Get()->GetLocale( (LanguageType)GetAppLanguage() ));
+ }
+ return *pAppCharClass;
+}
+
+void SwCalendarWrapper::LoadDefaultCalendar( USHORT eLang )
+{
+ sUniqueId.Erase();
+ if( eLang != nLang )
+ loadDefaultCalendar( SvxCreateLocale( nLang = eLang ));
+}
+
+LanguageType GetAppLanguage()
+{
+ return Application::GetSettings().GetLanguage();
+}
+
+CollatorWrapper& GetAppCollator()
+{
+ if( !pCollator )
+ {
+ const lang::Locale& rLcl = pBreakIt->GetLocale(
+ (LanguageType)GetAppLanguage() );
+ uno::Reference<
+ lang::XMultiServiceFactory > xMSF =
+ ::comphelper::getProcessServiceFactory();
+
+ pCollator = new CollatorWrapper( xMSF );
+ pCollator->loadDefaultCollator( rLcl, SW_COLLATOR_IGNORES );
+ }
+ return *pCollator;
+}
+CollatorWrapper& GetAppCaseCollator()
+{
+ if( !pCaseCollator )
+ {
+ const lang::Locale& rLcl = pBreakIt->GetLocale(
+ (LanguageType)GetAppLanguage() );
+ uno::Reference<
+ lang::XMultiServiceFactory > xMSF =
+ ::comphelper::getProcessServiceFactory();
+
+ pCaseCollator = new CollatorWrapper( xMSF );
+ pCaseCollator->loadDefaultCollator( rLcl, 0 );
+ }
+ return *pCaseCollator;
+}
+
+const ::utl::TransliterationWrapper& GetAppCmpStrIgnore()
+{
+ if( !pTransWrp )
+ {
+ uno::Reference<
+ lang::XMultiServiceFactory > xMSF =
+ ::comphelper::getProcessServiceFactory();
+
+ pTransWrp = new ::utl::TransliterationWrapper( xMSF,
+ i18n::TransliterationModules_IGNORE_CASE |
+ i18n::TransliterationModules_IGNORE_KANA |
+ i18n::TransliterationModules_IGNORE_WIDTH );
+ pTransWrp->loadModuleIfNeeded( static_cast<sal_uInt16>(GetAppLanguage()) );
+ }
+ return *pTransWrp;
+}
diff --git a/sw/source/core/bastyp/makefile.mk b/sw/source/core/bastyp/makefile.mk
new file mode 100644
index 000000000000..8333dabd5f37
--- /dev/null
+++ b/sw/source/core/bastyp/makefile.mk
@@ -0,0 +1,79 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sw
+TARGET=bastyp
+
+AUTOSEG=true
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/inc$/swpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/inc$/sw.mk
+
+# --- Files --------------------------------------------------------
+
+CXXFILES = \
+ bparr.cxx \
+ breakit.cxx \
+ calc.cxx \
+ checkit.cxx \
+ index.cxx \
+ init.cxx \
+ ring.cxx \
+ swcache.cxx \
+ swrect.cxx \
+ swregion.cxx \
+ swtypes.cxx \
+ tabcol.cxx \
+ SwSmartTagMgr.cxx
+
+SLOFILES = \
+ $(SLO)$/bparr.obj \
+ $(SLO)$/breakit.obj \
+ $(SLO)$/calc.obj \
+ $(SLO)$/checkit.obj \
+ $(SLO)$/index.obj \
+ $(SLO)$/init.obj \
+ $(SLO)$/ring.obj \
+ $(SLO)$/swcache.obj \
+ $(SLO)$/swrect.obj \
+ $(SLO)$/swregion.obj \
+ $(SLO)$/swtypes.obj \
+ $(SLO)$/tabcol.obj \
+ $(SLO)$/SwSmartTagMgr.obj
+
+EXCEPTIONSFILES = \
+ $(SLO)$/tabcol.obj
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/sw/source/core/bastyp/ring.cxx b/sw/source/core/bastyp/ring.cxx
new file mode 100644
index 000000000000..1831093a1d19
--- /dev/null
+++ b/sw/source/core/bastyp/ring.cxx
@@ -0,0 +1,125 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+
+
+#include "ring.hxx"
+
+
+/*************************************************************************
+|*
+|* Ring::Ring()
+|*
+|* Ersterstellung VB 02.07.91
+|* Letzte Aenderung JP 10.10.97
+|*
+*************************************************************************/
+
+Ring::Ring( Ring *pObj )
+{
+ if( !pObj )
+ pNext = this, pPrev = this;
+ else
+ {
+ pNext = pObj;
+ pPrev = pObj->pPrev;
+ pObj->pPrev = this;
+ pPrev->pNext = this;
+ }
+}
+
+/*************************************************************************
+|*
+|* Ring::~Ring()
+|*
+|* Ersterstellung VB 02.07.91
+|* Letzte Aenderung JP 10.10.97
+|*
+*************************************************************************/
+
+Ring::~Ring()
+{
+ pNext->pPrev = pPrev;
+ pPrev->pNext = pNext;
+}
+
+/*************************************************************************
+|*
+|* Ring::MoveTo
+|*
+|* Ersterstellung VB 4.3.91
+|* Letzte Aenderung JP 10.10.97
+|*
+*************************************************************************/
+
+void Ring::MoveTo(Ring *pDestRing)
+{
+ // loeschen aus dem alten
+ pNext->pPrev = pPrev;
+ pPrev->pNext = pNext;
+
+ // im neuen einfuegen
+ if( pDestRing )
+ {
+ pNext = pDestRing;
+ pPrev = pDestRing->pPrev;
+ pDestRing->pPrev = this;
+ pPrev->pNext = this;
+ }
+ else
+ pNext = pPrev = this;
+
+}
+
+void Ring::MoveRingTo(Ring *pDestRing)
+{
+ // den gesamten Ring in den DestRing einfuegen
+ Ring* pMyPrev = pPrev;
+ Ring* pDestPrev = pDestRing->pPrev;
+
+ pMyPrev->pNext = pDestRing;
+ pDestPrev->pNext = this;
+ pDestRing->pPrev = pMyPrev;
+ pPrev = pDestPrev;
+}
+
+sal_uInt32 Ring::numberOf() const
+{
+ sal_uInt32 nRet = 1;
+ const Ring* pNxt = pNext;
+ while( pNxt != this )
+ {
+ ++nRet;
+ pNxt = pNxt->GetNext();
+ }
+ return nRet;
+}
+
+
diff --git a/sw/source/core/bastyp/swcache.cxx b/sw/source/core/bastyp/swcache.cxx
new file mode 100644
index 000000000000..c0611a85160a
--- /dev/null
+++ b/sw/source/core/bastyp/swcache.cxx
@@ -0,0 +1,656 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+
+#include <tools/debug.hxx>
+#include <errhdl.hxx>
+#include <swcache.hxx>
+
+SV_IMPL_PTRARR(SwCacheObjArr,SwCacheObj*);
+
+#ifndef DBG_UTIL
+#define INCREMENT( nVar )
+#else
+#define INCREMENT( nVar ) ++nVar
+#endif
+
+/*************************************************************************
+|*
+|* SwCache::Check()
+|*
+|* Ersterstellung MA 23. Mar. 94
+|* Letzte Aenderung MA 23. Mar. 94
+|*
+|*************************************************************************/
+
+#ifdef DBG_UTIL
+
+void SwCache::Check()
+{
+ if ( !pRealFirst )
+ return;
+
+ //Konsistenspruefung.
+ ASSERT( !pLast->GetNext(), "Last but not last." );
+ ASSERT( !pRealFirst->GetPrev(), "First but not first." );
+ USHORT nCnt = 0;
+ BOOL bFirstFound = FALSE;
+ SwCacheObj *pObj = pRealFirst;
+ SwCacheObj *pRekursive = pObj;
+ while ( pObj )
+ {
+ //Das Objekt muss auch auf dem Rueckwaertsweg gefunden werden.
+ SwCacheObj *pTmp = pLast;
+ while ( pTmp && pTmp != pObj )
+ pTmp = pTmp->GetPrev();
+ ASSERT( pTmp, "Objekt not found." );
+
+ ++nCnt;
+ if ( pObj == pFirst )
+ bFirstFound = TRUE;
+ if ( !pObj->GetNext() )
+ ASSERT( pObj == pLast, "Last not Found." );
+ pObj = pObj->GetNext();
+ ASSERT( pObj != pRekursive, "Recursion in SwCache." );
+ }
+ ASSERT( bFirstFound, "First not Found." );
+ ASSERT( (nCnt + aFreePositions.Count()) == Count(), "Lost Chain." );
+ if ( Count() == nCurMax )
+ ASSERT( (nCurMax - nCnt) == aFreePositions.Count(), "Lost FreePositions." );
+}
+#endif
+
+#if defined(DBG_UTIL) && defined(MADEBUG)
+#define CHECK Check();
+#else
+#define CHECK
+#endif
+
+/*************************************************************************
+|*
+|* SwCache::SwCache(), ~SwCache()
+|*
+|* Ersterstellung MA 15. Mar. 94
+|* Letzte Aenderung MA 15. Mar. 94
+|*
+|*************************************************************************/
+
+
+SwCache::SwCache( const USHORT nInitSize, const USHORT nGrowSize
+#ifdef DBG_UTIL
+ , const ByteString &rNm
+#endif
+ ) :
+ SwCacheObjArr( (BYTE)nInitSize, (BYTE)nGrowSize ),
+ aFreePositions( 5, 5 ),
+ pRealFirst( 0 ),
+ pFirst( 0 ),
+ pLast( 0 ),
+ nMax( nInitSize ),
+ nCurMax( nInitSize )
+#ifdef DBG_UTIL
+ , aName( rNm ),
+ nAppend( 0 ),
+ nInsertFree( 0 ),
+ nReplace( 0 ),
+ nGetSuccess( 0 ),
+ nGetFail( 0 ),
+ nToTop( 0 ),
+ nDelete( 0 ),
+ nGetSeek( 0 ),
+ nAverageSeekCnt( 0 ),
+ nFlushCnt( 0 ),
+ nFlushedObjects( 0 ),
+ nIncreaseMax( 0 ),
+ nDecreaseMax( 0 )
+#endif
+{
+}
+
+#ifdef DBG_UTIL
+
+
+SwCache::~SwCache()
+{
+#if OSL_DEBUG_LEVEL > 1
+ {
+ ByteString sOut( aName ); sOut += '\n';
+ (( sOut += "Anzahl neuer Eintraege: " )
+ += ByteString::CreateFromInt32( nAppend ))+= '\n';
+ (( sOut += "Anzahl Insert auf freie Plaetze: " )
+ += ByteString::CreateFromInt32( nInsertFree ))+= '\n';
+ (( sOut += "Anzahl Ersetzungen: " )
+ += ByteString::CreateFromInt32( nReplace ))+= '\n';
+ (( sOut += "Anzahl Erfolgreicher Get's: " )
+ += ByteString::CreateFromInt32( nGetSuccess ))+= '\n';
+ (( sOut += "Anzahl Fehlgeschlagener Get's: " )
+ += ByteString::CreateFromInt32( nGetFail ))+= '\n';
+ (( sOut += "Anzahl Umsortierungen (LRU): " )
+ += ByteString::CreateFromInt32( nToTop ))+= '\n';
+ (( sOut += "Anzahl Loeschungen: " )
+ += ByteString::CreateFromInt32( nDelete ))+= '\n';
+ (( sOut += "Anzahl Get's ohne Index: " )
+ += ByteString::CreateFromInt32( nGetSeek ))+= '\n';
+ (( sOut += "Anzahl Seek fuer Get ohne Index: " )
+ += ByteString::CreateFromInt32( nAverageSeekCnt ))+= '\n';
+ (( sOut += "Anzahl Flush-Aufrufe: " )
+ += ByteString::CreateFromInt32( nFlushCnt ))+= '\n';
+ (( sOut += "Anzahl geflush'ter Objekte: " )
+ += ByteString::CreateFromInt32( nFlushedObjects ))+= '\n';
+ (( sOut += "Anzahl Cache-Erweiterungen: " )
+ += ByteString::CreateFromInt32( nIncreaseMax ))+= '\n';
+ (( sOut += "Anzahl Cache-Verkleinerungen: " )
+ += ByteString::CreateFromInt32( nDecreaseMax ))+= '\n';
+
+ DBG_ERROR( sOut.GetBuffer() );
+ }
+ Check();
+#endif
+}
+#endif
+
+/*************************************************************************
+|*
+|* SwCache::Flush()
+|*
+|* Ersterstellung MA 15. Mar. 94
+|* Letzte Aenderung MA 15. Mar. 94
+|*
+|*************************************************************************/
+
+
+void SwCache::Flush( const BYTE )
+{
+ INCREMENT( nFlushCnt );
+ SwCacheObj *pObj = pRealFirst;
+ pRealFirst = pFirst = pLast = 0;
+ SwCacheObj *pTmp;
+ while ( pObj )
+ {
+#ifdef DBG_UTIL
+ if ( pObj->IsLocked() )
+ {
+ ASSERT( TRUE, "Flushing locked objects." );
+ if ( !pRealFirst )
+ {
+ pRealFirst = pFirst = pLast = pObj;
+ pTmp = pObj->GetNext();
+ pObj->SetNext( 0 ); pObj->SetPrev( 0 );
+ pObj = pTmp;
+ }
+ else
+ { pLast->SetNext( pObj );
+ pObj->SetPrev( pLast );
+ pLast = pObj;
+ pTmp = pObj->GetNext();
+ pObj->SetNext( 0 );
+ pObj = pTmp;
+ }
+ }
+ else
+#endif
+ {
+ pTmp = (SwCacheObj*)pObj;
+ pObj = pTmp->GetNext();
+ aFreePositions.Insert( pTmp->GetCachePos(), aFreePositions.Count() );
+ *(pData + pTmp->GetCachePos()) = (void*)0;
+ delete pTmp;
+ INCREMENT( nFlushedObjects );
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* SwCache::ToTop()
+|*
+|* Ersterstellung MA 15. Mar. 94
+|* Letzte Aenderung MA 24. Apr. 95
+|*
+|*************************************************************************/
+
+
+void SwCache::ToTop( SwCacheObj *pObj )
+{
+ INCREMENT( nToTop );
+
+ //Objekt aus der LRU-Kette ausschneiden und am Anfang einfuegen.
+ if ( pRealFirst == pObj ) //pFirst wurde vom Aufrufer geprueft!
+ { CHECK;
+ return;
+ }
+
+ if ( !pRealFirst )
+ { //Der erste wird eingetragen.
+ ASSERT( !pFirst && !pLast, "First not first." );
+ pRealFirst = pFirst = pLast = pObj;
+ CHECK;
+ return;
+ }
+
+ //Ausschneiden.
+ if ( pObj == pLast )
+ {
+ ASSERT( pObj->GetPrev(), "Last but no Prev." );
+ pLast = pObj->GetPrev();
+ pLast->SetNext( 0 );
+ }
+ else
+ {
+ if ( pObj->GetNext() )
+ pObj->GetNext()->SetPrev( pObj->GetPrev() );
+ if ( pObj->GetPrev() )
+ pObj->GetPrev()->SetNext( pObj->GetNext() );
+ }
+
+ //Am (virtuellen) Anfang einfuegen.
+ if ( pRealFirst == pFirst )
+ {
+ pRealFirst->SetPrev( pObj );
+ pObj->SetNext( pRealFirst );
+ pObj->SetPrev( 0 );
+ pRealFirst = pFirst = pObj;
+ CHECK;
+ }
+ else
+ {
+ ASSERT( pFirst, "ToTop, First ist not RealFirst an Empty." );
+
+ if ( pFirst->GetPrev() )
+ {
+ pFirst->GetPrev()->SetNext( pObj );
+ pObj->SetPrev( pFirst->GetPrev() );
+ }
+ else
+ pObj->SetPrev( 0 );
+ pFirst->SetPrev( pObj );
+ pObj->SetNext( pFirst );
+ pFirst = pObj;
+ CHECK;
+ }
+}
+
+/*************************************************************************
+|*
+|* SwCache::Get()
+|*
+|* Ersterstellung MA 15. Mar. 94
+|* Letzte Aenderung MA 22. Aug. 94
+|*
+|*************************************************************************/
+
+
+SwCacheObj *SwCache::Get( const void *pOwner, const USHORT nIndex,
+ const BOOL bToTop )
+{
+ SwCacheObj *pRet;
+ if ( 0 != (pRet = nIndex < Count() ? operator[]( nIndex ) : 0) )
+ {
+ if ( !pRet->IsOwner( pOwner ) )
+ pRet = 0;
+ else if ( bToTop && pRet != pFirst )
+ ToTop( pRet );
+ }
+
+#ifdef DBG_UTIL
+ if ( pRet )
+ ++nGetSuccess;
+ else
+ ++nGetFail;
+#endif
+
+ return pRet;
+}
+
+
+
+SwCacheObj *SwCache::Get( const void *pOwner, const BOOL bToTop )
+{
+ SwCacheObj *pRet = pRealFirst;
+ while ( pRet && !pRet->IsOwner( pOwner ) )
+ {
+ INCREMENT( nAverageSeekCnt );
+ pRet = pRet->GetNext();
+ }
+
+ if ( bToTop && pRet && pRet != pFirst )
+ ToTop( pRet );
+
+#ifdef DBG_UTIL
+ if ( pRet )
+ ++nGetSuccess;
+ else
+ ++nGetFail;
+ ++nGetSeek;
+#endif
+ return pRet;
+}
+
+/*************************************************************************
+|*
+|* SwCache::Delete()
+|*
+|* Ersterstellung MA 15. Mar. 94
+|* Letzte Aenderung MA 15. Mar. 94
+|*
+|*************************************************************************/
+
+
+void SwCache::DeleteObj( SwCacheObj *pObj )
+{
+ CHECK;
+ ASSERT( !pObj->IsLocked(), "SwCache::Delete: Object ist Locked." );
+ if ( pObj->IsLocked() )
+ return;
+
+ if ( pFirst == pObj )
+ {
+ if ( pFirst->GetNext() )
+ pFirst = pFirst->GetNext();
+ else
+ pFirst = pFirst->GetPrev();
+ }
+ if ( pRealFirst == pObj )
+ pRealFirst = pRealFirst->GetNext();
+ if ( pLast == pObj )
+ pLast = pLast->GetPrev();
+ if ( pObj->GetPrev() )
+ pObj->GetPrev()->SetNext( pObj->GetNext() );
+ if ( pObj->GetNext() )
+ pObj->GetNext()->SetPrev( pObj->GetPrev() );
+
+ aFreePositions.Insert( pObj->GetCachePos(), aFreePositions.Count() );
+ *(pData + pObj->GetCachePos()) = (void*)0;
+ delete pObj;
+
+ CHECK;
+ if ( Count() > nCurMax &&
+ (nCurMax <= (Count() - aFreePositions.Count())) )
+ {
+ //Falls moeglich wieder verkleinern, dazu muessen allerdings ausreichend
+ //Freie Positionen bereitstehen.
+ //Unangenehmer Nebeneffekt ist, das die Positionen verschoben werden
+ //muessen, und die Eigentuemer der Objekte diese wahrscheinlich nicht
+ //wiederfinden werden.
+ for ( USHORT i = 0; i < Count(); ++i )
+ {
+ SwCacheObj *pTmpObj = operator[](i);
+ if ( !pTmpObj )
+ { SwCacheObjArr::Remove( i, 1 );
+ --i;
+ }
+ else
+ pTmpObj->SetCachePos( i );
+ }
+ aFreePositions.Remove( 0, aFreePositions.Count() );
+ }
+ CHECK;
+}
+
+/*
+
+
+void SwCache::Delete( const void *pOwner, const USHORT nIndex )
+{
+ INCREMENT( nDelete );
+ SwCacheObj *pObj;
+ if ( 0 != (pObj = Get( pOwner, nIndex, FALSE )) )
+ DeleteObj( pObj );
+}
+*/
+
+
+
+void SwCache::Delete( const void *pOwner )
+{
+ INCREMENT( nDelete );
+ SwCacheObj *pObj;
+ if ( 0 != (pObj = Get( pOwner, BOOL(FALSE) )) )
+ DeleteObj( pObj );
+}
+
+
+/*************************************************************************
+|*
+|* SwCache::Insert()
+|*
+|* Ersterstellung MA 15. Mar. 94
+|* Letzte Aenderung MA 20. Sep. 94
+|*
+|*************************************************************************/
+
+
+BOOL SwCache::Insert( SwCacheObj *pNew )
+{
+ CHECK;
+ ASSERT( !pNew->GetPrev() && !pNew->GetNext(), "New but not new." );
+
+ USHORT nPos;//Wird hinter den if's zum setzen am Obj benutzt.
+ if ( Count() < nCurMax )
+ {
+ //Es ist noch Platz frei, also einfach einfuegen.
+ INCREMENT( nAppend );
+ nPos = Count();
+ SwCacheObjArr::C40_INSERT( SwCacheObj, pNew, nPos );
+ }
+ else if ( aFreePositions.Count() )
+ {
+ //Es exitieren Platzhalter, also den letzten benutzen.
+ INCREMENT( nInsertFree );
+ const USHORT nFreePos = aFreePositions.Count() - 1;
+ nPos = aFreePositions[ nFreePos ];
+ *(pData + nPos) = pNew;
+ aFreePositions.Remove( nFreePos );
+ }
+ else
+ {
+ INCREMENT( nReplace );
+ //Der letzte des LRU fliegt raus.
+ SwCacheObj *pObj = pLast;
+
+ while ( pObj && pObj->IsLocked() )
+ pObj = pObj->GetPrev();
+ if ( !pObj )
+ {
+ ASSERT( FALSE, "Cache overflow." );
+ return FALSE;
+ }
+
+ nPos = pObj->GetCachePos();
+ if ( pObj == pLast )
+ { ASSERT( pObj->GetPrev(), "Last but no Prev" );
+ pLast = pObj->GetPrev();
+ pLast->SetNext( 0 );
+ }
+ else
+ {
+ if ( pObj->GetPrev() )
+ pObj->GetPrev()->SetNext( pObj->GetNext() );
+ if ( pObj->GetNext() )
+ pObj->GetNext()->SetPrev( pObj->GetPrev() );
+ }
+ delete pObj;
+ *(pData + nPos) = pNew;
+ }
+ pNew->SetCachePos( nPos );
+
+ //Anstelle von ToTop, einfach als pFirst einfuegen.
+// ToTop( nPos );
+ if ( pFirst )
+ {
+ if ( pFirst->GetPrev() )
+ { pFirst->GetPrev()->SetNext( pNew );
+ pNew->SetPrev( pFirst->GetPrev() );
+ }
+ pFirst->SetPrev( pNew );
+ pNew->SetNext( pFirst );
+ }
+ else
+ { ASSERT( !pLast, "Last but no First." );
+ pLast = pNew;
+ }
+ if ( pFirst == pRealFirst )
+ pRealFirst = pNew;
+ pFirst = pNew;
+
+ CHECK;
+ return TRUE;
+}
+
+/*************************************************************************
+|*
+|* SwCache::SetLRUOfst()
+|*
+|* Ersterstellung MA 15. Mar. 94
+|* Letzte Aenderung MA 15. Mar. 94
+|*
+|*************************************************************************/
+
+
+void SwCache::SetLRUOfst( const USHORT nOfst )
+{
+ if ( !pRealFirst || ((Count() - aFreePositions.Count()) < nOfst) )
+ return;
+
+ CHECK;
+ pFirst = pRealFirst;
+ for ( USHORT i = 0; i < Count() && i < nOfst; ++i )
+ {
+ if ( pFirst->GetNext() && pFirst->GetNext()->GetNext() )
+ pFirst = pFirst->GetNext();
+ else
+ break;
+ }
+ CHECK;
+}
+
+/*************************************************************************
+|*
+|* SwCacheObj::SwCacheObj()
+|*
+|* Ersterstellung MA 15. Mar. 94
+|* Letzte Aenderung MA 24. Nov. 95
+|*
+|*************************************************************************/
+
+
+SwCacheObj::SwCacheObj( const void *pOwn ) :
+ pNext( 0 ),
+ pPrev( 0 ),
+ nCachePos( USHRT_MAX ),
+ nLock( 0 ),
+ pOwner( pOwn )
+{
+}
+
+
+
+SwCacheObj::~SwCacheObj()
+{
+}
+
+/*************************************************************************
+|*
+|* SwCacheObj::SetLock(), Unlock()
+|*
+|* Ersterstellung MA 15. Mar. 94
+|* Letzte Aenderung MA 15. Mar. 94
+|*
+|*************************************************************************/
+
+#ifdef DBG_UTIL
+
+
+
+void SwCacheObj::Lock()
+{
+ ASSERT( nLock < UCHAR_MAX, "To many Locks for CacheObject." );
+ ++nLock;
+}
+
+
+
+void SwCacheObj::Unlock()
+{
+ ASSERT( nLock, "No more Locks available." );
+ --nLock;
+}
+#endif
+
+
+SwCacheAccess::~SwCacheAccess()
+{
+ if ( pObj )
+ pObj->Unlock();
+}
+
+/*************************************************************************
+|*
+|* SwCacheAccess::Get()
+|*
+|* Ersterstellung MA 15. Mar. 94
+|* Letzte Aenderung MA 04. Apr. 95
+|*
+|*************************************************************************/
+
+
+void SwCacheAccess::_Get()
+{
+ ASSERT( !pObj, "SwCacheAcces Obj already available." );
+
+ pObj = NewObj();
+ if ( !rCache.Insert( pObj ) )
+ {
+ delete pObj;
+ pObj = 0;
+ }
+ else
+ pObj->Lock();
+}
+
+/*************************************************************************
+|*
+|* SwCacheAccess::IsAvailable()
+|*
+|* Ersterstellung MA 23. Mar. 94
+|* Letzte Aenderung MA 23. Mar. 94
+|*
+|*************************************************************************/
+
+
+BOOL SwCacheAccess::IsAvailable() const
+{
+ return pObj != 0;
+}
+
+
+
+
+
diff --git a/sw/source/core/bastyp/swrect.cxx b/sw/source/core/bastyp/swrect.cxx
new file mode 100644
index 000000000000..1213bfaea896
--- /dev/null
+++ b/sw/source/core/bastyp/swrect.cxx
@@ -0,0 +1,336 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+
+#ifdef DBG_UTIL
+#ifndef _STREAM_HXX //autogen
+#include <tools/stream.hxx>
+#endif
+#endif
+#include <stdlib.h>
+#include "swrect.hxx"
+#include <math.h>
+
+/*************************************************************************
+|*
+|* SwRect::SwRect()
+|*
+|* Ersterstellung MA 02. Feb. 93
+|* Letzte Aenderung MA 05. Sep. 93
+|*
+|*************************************************************************/
+
+
+
+SwRect::SwRect( const Rectangle &rRect ) :
+ m_Point( rRect.Left(), rRect.Top() )
+{
+ m_Size.setWidth(rRect.Right() == RECT_EMPTY ? 0 :
+ rRect.Right() - rRect.Left() +1);
+ m_Size.setHeight(rRect.Bottom() == RECT_EMPTY ? 0 :
+ rRect.Bottom() - rRect.Top() + 1);
+}
+
+/*************************************************************************
+|*
+|* SwRect::Center()
+|*
+|* Ersterstellung MA 27. Jan. 93
+|* Letzte Aenderung MA 27. Jan. 93
+|*
+|*************************************************************************/
+Point SwRect::Center() const
+{
+ return Point( Left() + Width() / 2,
+ Top() + Height() / 2 );
+
+/* Wer ruft schon ein Center auf ein "falsches" Rechteck?
+ const long nRight = Right();
+ const long nBottom= Bottom();
+ return Point( min( Left(), nRight ) + long(abs( (nRight - Left())/2) ),
+ min( Top(), nBottom) + long(abs( (nBottom - Top())/2)));
+*/
+}
+
+/*************************************************************************
+|*
+|* SwRect::Union()
+|*
+|* Ersterstellung MA 27. Jan. 93
+|* Letzte Aenderung MA 27. Jan. 93
+|*
+|*************************************************************************/
+
+
+
+SwRect& SwRect::Union( const SwRect& rRect )
+{
+ if ( Top() > rRect.Top() )
+ Top( rRect.Top() );
+ if ( Left() > rRect.Left() )
+ Left( rRect.Left() );
+ long n = rRect.Right();
+ if ( Right() < n )
+ Right( n );
+ n = rRect.Bottom();
+ if ( Bottom() < n )
+ Bottom( n );
+ return *this;
+}
+/*************************************************************************
+|*
+|* SwRect::Intersection(), _Intersection()
+|*
+|* Ersterstellung MA 27. Jan. 93
+|* Letzte Aenderung MA 05. Sep. 93
+|*
+|*************************************************************************/
+
+
+
+SwRect& SwRect::Intersection( const SwRect& rRect )
+{
+ //Hat das Teil ueberhaupt Gemeinsamkeiten mit mir?
+ if ( IsOver( rRect ) )
+ {
+ //Bestimmung der kleineren rechten sowie unteren und
+ // der groesseren linken sowie oberen Kante.
+ if ( Left() < rRect.Left() )
+ Left( rRect.Left() );
+ if ( Top() < rRect.Top() )
+ Top( rRect.Top() );
+ long n = rRect.Right();
+ if ( Right() > n )
+ Right( n );
+ n = rRect.Bottom();
+ if ( Bottom() > n )
+ Bottom( n );
+ }
+ else
+ //Def.: Bei einer leeren Intersection wird nur die SSize genullt.
+ SSize(0, 0);
+
+ return *this;
+}
+
+
+
+SwRect& SwRect::_Intersection( const SwRect& rRect )
+{
+ //Bestimmung der kleineren rechten sowie unteren und
+ // der groesseren linken sowie oberen Kante.
+ if ( Left() < rRect.Left() )
+ Left( rRect.Left() );
+ if ( Top() < rRect.Top() )
+ Top( rRect.Top() );
+ long n = rRect.Right();
+ if ( Right() > n )
+ Right( n );
+ n = rRect.Bottom();
+ if ( Bottom() > n )
+ Bottom( n );
+
+ return *this;
+}
+/*************************************************************************
+|*
+|* SwRect::IsInside()
+|*
+|* Ersterstellung MA 27. Jan. 93
+|* Letzte Aenderung MA 27. Jan. 93
+|*
+|*************************************************************************/
+
+
+
+BOOL SwRect::IsInside( const SwRect& rRect ) const
+{
+ const long nRight = Right();
+ const long nBottom = Bottom();
+ const long nrRight = rRect.Right();
+ const long nrBottom= rRect.Bottom();
+ return (Left() <= rRect.Left()) && (rRect.Left()<= nRight) &&
+ (Left() <= nrRight) && (nrRight <= nRight) &&
+ (Top() <= rRect.Top()) && (rRect.Top() <= nBottom) &&
+ (Top() <= nrBottom) && (nrBottom <= nBottom);
+}
+
+
+
+BOOL SwRect::IsInside( const Point& rPoint ) const
+{
+ return (Left() <= rPoint.X())
+ && (Top() <= rPoint.Y())
+ && (Right() >= rPoint.X())
+ && (Bottom()>= rPoint.Y());
+}
+/* -----------------------------11.04.00 15:46--------------------------------
+ mouse moving of table borders
+ ---------------------------------------------------------------------------*/
+BOOL SwRect::IsNear( const Point& rPoint, long nTolerance ) const
+{
+ return IsInside(rPoint) ||
+ (((Left() - nTolerance) <= rPoint.X())
+ && ((Top() - nTolerance) <= rPoint.Y())
+ && ((Right() + nTolerance) >= rPoint.X())
+ && ((Bottom() + nTolerance)>= rPoint.Y()));
+}
+
+/*************************************************************************
+|*
+|* SwRect::IsOver()
+|*
+|* Ersterstellung MA 25. Feb. 94
+|* Letzte Aenderung MA 27. Jun. 96
+|*
+|*************************************************************************/
+
+
+
+BOOL SwRect::IsOver( const SwRect& rRect ) const
+{
+ return (Top() <= rRect.Bottom())
+ && (Left() <= rRect.Right())
+ && (Right() >= rRect.Left())
+ && (Bottom()>= rRect.Top()) ? TRUE : FALSE;
+}
+
+/*************************************************************************
+|*
+|* SwRect::Justify()
+|*
+|* Ersterstellung MA 10. Oct. 94
+|* Letzte Aenderung MA 23. Oct. 96
+|*
+|*************************************************************************/
+
+
+
+void SwRect::Justify()
+{
+ if ( m_Size.getHeight() < 0 )
+ {
+ m_Point.Y() += m_Size.getHeight() + 1;
+ m_Size.setHeight(-m_Size.getHeight());
+ }
+ if ( m_Size.getWidth() < 0 )
+ {
+ m_Point.X() += m_Size.getWidth() + 1;
+ m_Size.setWidth(-m_Size.getWidth());
+ }
+}
+
+
+// Similiar to the inline methods, but we need the function pointers
+
+void SwRect::_Width( const long nNew ) { m_Size.setWidth(nNew); }
+void SwRect::_Height( const long nNew ) { m_Size.setHeight(nNew); }
+void SwRect::_Left( const long nLeft ){ m_Size.Width() += m_Point.getX() - nLeft; m_Point.setX(nLeft); }
+void SwRect::_Right( const long nRight ){ m_Size.setWidth(nRight - m_Point.getX()); }
+void SwRect::_Top( const long nTop ){ m_Size.Height() += m_Point.getY() - nTop; m_Point.setY(nTop); }
+void SwRect::_Bottom( const long nBottom ){ m_Size.setHeight(nBottom - m_Point.getY()); }
+
+long SwRect::_Width() const{ return m_Size.getWidth(); }
+long SwRect::_Height() const{ return m_Size.getHeight(); }
+long SwRect::_Left() const{ return m_Point.getX(); }
+long SwRect::_Right() const{ return m_Point.getX() + m_Size.getWidth(); }
+long SwRect::_Top() const{ return m_Point.getY(); }
+long SwRect::_Bottom() const{ return m_Point.getY() + m_Size.getHeight(); }
+
+void SwRect::AddWidth( const long nAdd ) { m_Size.Width() += nAdd; }
+void SwRect::AddHeight( const long nAdd ) { m_Size.Height() += nAdd; }
+void SwRect::SubLeft( const long nSub ){ m_Size.Width() += nSub; m_Point.X() -= nSub; }
+void SwRect::AddRight( const long nAdd ){ m_Size.Width() += nAdd; }
+void SwRect::SubTop( const long nSub ){ m_Size.Height() += nSub; m_Point.Y() -= nSub; }
+void SwRect::AddBottom( const long nAdd ){ m_Size.Height() += nAdd; }
+void SwRect::SetPosX( const long nNew ){ m_Point.setX(nNew); }
+void SwRect::SetPosY( const long nNew ){ m_Point.setY(nNew); }
+const Size SwRect::_Size() const { return SSize(); }
+const Size SwRect::SwappedSize() const { return Size( m_Size.getHeight(), m_Size.getWidth() ); }
+const Point SwRect::TopLeft() const { return Pos(); }
+const Point SwRect::TopRight() const { return Point( m_Point.getX() + m_Size.getWidth(), m_Point.getY() ); }
+const Point SwRect::BottomLeft() const { return Point( m_Point.getX(), m_Point.getY() + m_Size.getHeight() ); }
+const Point SwRect::BottomRight() const
+ { return Point( m_Point.getX() + m_Size.getWidth(), m_Point.getY() + m_Size.getHeight() ); }
+long SwRect::GetLeftDistance( long nLimit ) const { return m_Point.getX() - nLimit; }
+long SwRect::GetBottomDistance( long nLim ) const { return nLim - m_Point.getY() - m_Size.getHeight();}
+long SwRect::GetTopDistance( long nLimit ) const { return m_Point.getY() - nLimit; }
+long SwRect::GetRightDistance( long nLim ) const { return nLim - m_Point.getX() - m_Size.getWidth(); }
+BOOL SwRect::OverStepLeft( long nLimit ) const
+ { return nLimit > m_Point.getX() && m_Point.getX() + m_Size.getWidth() > nLimit; }
+BOOL SwRect::OverStepBottom( long nLimit ) const
+ { return nLimit > m_Point.getY() && m_Point.getY() + m_Size.getHeight() > nLimit; }
+BOOL SwRect::OverStepTop( long nLimit ) const
+ { return nLimit > m_Point.getY() && m_Point.getY() + m_Size.getHeight() > nLimit; }
+BOOL SwRect::OverStepRight( long nLimit ) const
+ { return nLimit > m_Point.getX() && m_Point.getX() + m_Size.getWidth() > nLimit; }
+void SwRect::SetLeftAndWidth( long nLeft, long nNew )
+{
+ m_Point.setX(nLeft);
+ m_Size.setWidth(nNew);
+}
+void SwRect::SetTopAndHeight( long nTop, long nNew )
+{
+ m_Point.setY(nTop);
+ m_Size.setHeight(nNew);
+}
+void SwRect::SetRightAndWidth( long nRight, long nNew )
+{
+ m_Point.setX(nRight - nNew);
+ m_Size.setWidth(nNew);
+}
+void SwRect::SetBottomAndHeight( long nBottom, long nNew )
+{
+ m_Point.setY(nBottom - nNew);
+ m_Size.setHeight(nNew);
+}
+void SwRect::SetUpperLeftCorner( const Point& rNew )
+ { m_Point = rNew; }
+void SwRect::SetUpperRightCorner( const Point& rNew )
+ { m_Point = Point(rNew.nA - m_Size.getWidth(), rNew.nB); }
+void SwRect::SetLowerLeftCorner( const Point& rNew )
+ { m_Point = Point(rNew.nA, rNew.nB - m_Size.getHeight()); }
+
+#ifdef DBG_UTIL
+/*************************************************************************
+ * operator<<( ostream&, SwRect&)
+ *************************************************************************/
+
+
+
+SvStream &operator<<( SvStream &rStream, const SwRect &rRect )
+{
+ rStream << '[' << rRect.Top() << '/' << rRect.Left()
+ << ',' << rRect.Width() << 'x' << rRect.Height() << "] ";
+ return rStream;
+}
+#endif
+
+
diff --git a/sw/source/core/bastyp/swregion.cxx b/sw/source/core/bastyp/swregion.cxx
new file mode 100644
index 000000000000..899b8f164194
--- /dev/null
+++ b/sw/source/core/bastyp/swregion.cxx
@@ -0,0 +1,254 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+
+
+
+#include <tools/debug.hxx>
+#include "swtypes.hxx"
+#include "swrect.hxx"
+#include "swregion.hxx"
+
+
+SV_IMPL_VARARR( SwRects, SwRect );
+
+/*************************************************************************
+|*
+|* SwRegionRects::SwRegionRects()
+|*
+|* Ersterstellung MA 28. Oct. 92
+|* Letzte Aenderung MA 01. Feb. 93
+|*
+|*************************************************************************/
+
+SwRegionRects::SwRegionRects( const SwRect &rStartRect, USHORT nInit,
+ USHORT nGrow ) :
+ SwRects( (BYTE)nInit, (BYTE)nGrow ),
+ aOrigin( rStartRect )
+{
+ Insert( aOrigin, 0 );
+}
+
+/*************************************************************************
+ * inline InsertRect()
+ *
+ * InsertRect() wird nur von operator-=() gerufen.
+ * Wenn bDel == TRUE ist, dann wird das Rect an der Position nPos mit
+ * rRect ueberschrieben, ansonsten wird rRect hinten angehaengt.
+ *************************************************************************/
+
+inline void SwRegionRects::InsertRect( const SwRect &rRect, const USHORT nPos,
+ BOOL &rDel )
+{
+ if( rDel )
+ {
+ pData = (SwRect*)pData; // looks weird but seems to help gcc ->i78417
+ *(pData+nPos) = rRect;
+ rDel = FALSE;
+ }
+ else
+ Insert( rRect, Count() );
+}
+
+/*************************************************************************
+|*
+|* SwRegionRects::operator-=()
+|*
+|* Beschreibung Alle Ueberschneidungen der Rechtecke, die sich
+|* gerade im Array befinden, mit dem uebergebenen Rechteck werden
+|* entfernt.
+|* Dazu muessen die vorhandenen Rechtecke entweder aufgeteilt oder
+|* geloescht werden.
+|* Ersterstellung MA 28. Oct. 92
+|* Letzte Aenderung MA 09. Sep. 93
+|*
+|*************************************************************************/
+
+void SwRegionRects::operator-=( const SwRect &rRect )
+{
+ USHORT nMax = Count();
+ for ( USHORT i = 0; i < nMax; ++i )
+ {
+ if ( rRect.IsOver( *(pData+i) ) )
+ {
+ SwRect aTmp( *(pData+i) );
+ SwRect aInter( aTmp );
+ aInter._Intersection( rRect );
+
+ // Das erste Rect, das wir inserten wollen, nimmt die
+ // Stelle von i ein. So ersparen wir uns das Delete().
+ BOOL bDel = TRUE;
+
+ //Jetzt aufteilen das Teil: Es sollen diejenigen Rechtecke
+ //zurueckbleiben, die im alten aber nicht im neuen liegen.
+ //Sprich alle Rechtecke die im alten aber nicht in der Intersection
+ //liegen.
+ long nTmp;
+ if ( 0 < (nTmp = aInter.Top() - aTmp.Top()) )
+ {
+ const long nOldVal = aTmp.Height();
+ aTmp.Height(nTmp);
+ InsertRect( aTmp, i, bDel );
+ aTmp.Height( nOldVal );
+ }
+
+ aTmp.Top( aInter.Top() + aInter.Height() );
+ if ( aTmp.Height() > 0 )
+ InsertRect( aTmp, i, bDel );
+
+ aTmp.Top( aInter.Top() );
+ aTmp.Bottom( aInter.Bottom() );
+ if ( 0 < (nTmp = aInter.Left() - aTmp.Left()) )
+ {
+ const long nOldVal = aTmp.Width();
+ aTmp.Width( nTmp );
+ InsertRect( aTmp, i, bDel );
+ aTmp.Width( nOldVal );
+ }
+
+ aTmp.Left( aInter.Left() + aInter.Width() ); //+1?
+ if ( aTmp.Width() > 0 )
+ InsertRect( aTmp, i, bDel );
+
+ if( bDel )
+ {
+ Remove( i );
+ --i; //Damit wir keinen uebergehen.
+ --nMax; //Damit wir keinen zuviel verarbeiten.
+ }
+ }
+ }
+
+}
+
+/*************************************************************************
+ * SwRegionRects::Invert()
+ *
+ * Bezugspunkt ist aOrigin, das Original-SRectangle.
+ * Aus Loechern werden Flaechen, aus Flaechen werden Loecher.
+ * Ein Hinweis: Wenn keine Rects abgezogen wurden, so ist das enthaltene
+ * Rechteck identisch mit aOrigin. Nach Invert() besteht die Region aus
+ * einem Null-SRectangle.
+ *************************************************************************/
+
+void SwRegionRects::Invert()
+{
+ // Nicht besonders elegant und schnell, aber wirkungsvoll:
+ // Wir legen eine weitere Region an und ziehen alle Flaechen ab,
+ // die in uns noch uebrig geblieben sind. Danach werden alle
+ // Werte uebertragen.
+
+ // Um unuetze Speicheranforderungen zu vermeiden versuchen wir die
+ // iniale Groesse moeglichst brauchbar anzulegen:
+ // Anzahl der Rechtecke in der Region * 2 + 2
+ // plus zwei um den Sonderfall eines einzelnen Loches (macht vier
+ // Rechtecke im inversen Fall) abzudecken.
+
+ SwRegionRects aInvRegion( aOrigin, Count()*2+2 );
+ const SwRect *pDat = GetData();
+ for( USHORT i = 0; i < Count(); ++pDat, ++i )
+ aInvRegion -= *pDat;
+
+ USHORT nCpy = Count(), nDel = 0;
+ if( aInvRegion.Count() < Count() )
+ {
+ nDel = Count() - aInvRegion.Count();
+ nCpy = aInvRegion.Count();
+ }
+ // alle vorhandenen ueberschreiben
+ memcpy( pData, aInvRegion.GetData(), nCpy * sizeof( SwRect ));
+
+ if( nCpy < aInvRegion.Count() )
+ Insert( &aInvRegion, nCpy, nCpy );
+ else if( nDel )
+ Remove( nCpy, nDel );
+}
+/*************************************************************************
+|*
+|* SwRegionRects::Compress()
+|*
+|* Beschreibung Zusammenfassen von benachbarten Rechtecken.
+|* Ersterstellung MA 16. Apr. 93
+|* Letzte Aenderung MA 21. Apr. 93
+|*
+|*************************************************************************/
+inline SwTwips CalcArea( const SwRect &rRect )
+{
+ return rRect.Width() * rRect.Height();
+}
+
+
+void SwRegionRects::Compress( BOOL bFuzzy )
+{
+ for ( int i = 0; i < Count(); ++i )
+ {
+ for ( int j = i+1; j < Count(); ++j )
+ {
+ //Wenn zwei Rechtecke ineinanderliegen, so ist eins davon
+ //uberfluessig.
+ if ( (*(pData + i)).IsInside( *(pData + j) ) )
+ {
+ Remove( static_cast<USHORT>(j), 1 );
+ --j;
+ }
+ else if ( (*(pData + j)).IsInside( *(pData + i) ) )
+ {
+ *(pData + i) = *(pData + j);
+ Remove( static_cast<USHORT>(j), 1 );
+ i = -1;
+ break;
+ }
+ else
+ {
+ //Wenn zwei Rechtecke dieselbe Flaeche haben wie deren
+ //Union abzueglich deren Intersection, so ist eines
+ //davon ueberfluessig.
+ //Um moeglichst viel zusammenzufassen und in der Folge
+ //moeglichst wenig einzelne Paints zu haben darf die Flaeche
+ //der Union ruhig ein bischen groesser sein
+ //( 9622 * 141.5 = 1361513 ~= ein virtel Zentimeter ueber die
+ // Breite einer DINA4 Seite)
+ const long nFuzzy = bFuzzy ? 1361513 : 0;
+ SwRect aUnion( *(pData + i) );aUnion.Union( *(pData + j) );
+ SwRect aInter( *(pData + i) );aInter.Intersection( *(pData + j));
+ if ( (::CalcArea( *(pData + i) ) +
+ ::CalcArea( *(pData + j) ) + nFuzzy) >=
+ (::CalcArea( aUnion ) - CalcArea( aInter )) )
+ {
+ *(pData + i) = aUnion;
+ Remove( static_cast<USHORT>(j), 1 );
+ i = -1;
+ break;
+ }
+ }
+ }
+ }
+}
+
diff --git a/sw/source/core/bastyp/swtypes.cxx b/sw/source/core/bastyp/swtypes.cxx
new file mode 100644
index 000000000000..1ce5e4b9cf6c
--- /dev/null
+++ b/sw/source/core/bastyp/swtypes.cxx
@@ -0,0 +1,133 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+#include "swtypes.hxx"
+#include "tools/string.hxx"
+#include <vcl/svapp.hxx>
+#include <vcl/window.hxx>
+#include <vcl/graph.hxx>
+#include <editeng/unolingu.hxx>
+#include <pagefrm.hxx>
+#include <swatrset.hxx>
+#include <frmfmt.hxx>
+#include <frmtool.hxx>
+#include <ndtxt.hxx>
+#include <undobj.hxx>
+#include <swtable.hxx>
+#include <viscrs.hxx>
+#include <fntcache.hxx>
+#include <swfntcch.hxx>
+#include <hffrm.hxx>
+#include <colfrm.hxx>
+#include <bodyfrm.hxx>
+#include <tabfrm.hxx>
+#include <txtfrm.hxx>
+#include <swtblfmt.hxx>
+#include <rowfrm.hxx>
+#include <cellfrm.hxx>
+#include <sectfrm.hxx>
+
+using namespace com::sun::star;
+
+ByteString aEmptyByteStr; // Konstante Strings
+String aEmptyStr; // Konstante Strings
+String aDotStr('.'); // Konstante Strings
+
+IMPL_FIXEDMEMPOOL_NEWDEL( SwAttrSet, 25, 25 )
+IMPL_FIXEDMEMPOOL_NEWDEL( SwStartNode, 20, 20 )
+IMPL_FIXEDMEMPOOL_NEWDEL( SwEndNode, 20, 20 )
+IMPL_FIXEDMEMPOOL_NEWDEL( SwTableBox, 50, 50 )
+IMPL_FIXEDMEMPOOL_NEWDEL( SwUndoDelete, 10, 10 )
+IMPL_FIXEDMEMPOOL_NEWDEL( SwUndoInsert, 10, 10 )
+IMPL_FIXEDMEMPOOL_NEWDEL( SwPaM, 10, 10 )
+IMPL_FIXEDMEMPOOL_NEWDEL( SwCursor, 10, 10 )
+IMPL_FIXEDMEMPOOL_NEWDEL( SwShellCrsr, 10, 10 )
+IMPL_FIXEDMEMPOOL_NEWDEL( SwTxtNode, 50, 50 )
+IMPL_FIXEDMEMPOOL_NEWDEL( SwpHints, 25, 25 )
+IMPL_FIXEDMEMPOOL_NEWDEL( SwFntObj, 50, 50 )
+IMPL_FIXEDMEMPOOL_NEWDEL( SwFontObj, 50, 50 )
+IMPL_FIXEDMEMPOOL_NEWDEL( SwBorderAttrs, 100, 100 )
+IMPL_FIXEDMEMPOOL_NEWDEL( SwCellFrm, 50, 50 )
+IMPL_FIXEDMEMPOOL_NEWDEL( SwRowFrm, 10, 10 )
+IMPL_FIXEDMEMPOOL_NEWDEL( SwColumnFrm, 40, 40 )
+IMPL_FIXEDMEMPOOL_NEWDEL( SwSectionFrm, 20, 20 )
+IMPL_FIXEDMEMPOOL_NEWDEL( SwTabFrm, 10, 10 )
+IMPL_FIXEDMEMPOOL_NEWDEL( SwPageFrm, 20, 20 )
+IMPL_FIXEDMEMPOOL_NEWDEL( SwBodyFrm, 20, 20 )
+IMPL_FIXEDMEMPOOL_NEWDEL( SwHeaderFrm, 20, 20 )
+IMPL_FIXEDMEMPOOL_NEWDEL( SwFooterFrm, 20, 20 )
+IMPL_FIXEDMEMPOOL_NEWDEL( SwTxtFrm, 50, 50 )
+IMPL_FIXEDMEMPOOL_NEWDEL( SwTableFmt, 10, 10 )
+IMPL_FIXEDMEMPOOL_NEWDEL( SwTableLineFmt, 10, 10 )
+IMPL_FIXEDMEMPOOL_NEWDEL( SwTableBoxFmt, 50, 50 )
+IMPL_FIXEDMEMPOOL_NEWDEL( _SwCursor_SavePos, 20, 20 )
+
+
+Size GetGraphicSizeTwip( const Graphic& rGraphic, OutputDevice* pOutDev )
+{
+ const MapMode aMapTwip( MAP_TWIP );
+ Size aSize( rGraphic.GetPrefSize() );
+ if( MAP_PIXEL == rGraphic.GetPrefMapMode().GetMapUnit() )
+ {
+ if( !pOutDev )
+ pOutDev = Application::GetDefaultDevice();
+ aSize = pOutDev->PixelToLogic( aSize, aMapTwip );
+ }
+ else
+ aSize = OutputDevice::LogicToLogic( aSize,
+ rGraphic.GetPrefMapMode(), aMapTwip );
+ return aSize;
+}
+
+
+uno::Reference< linguistic2::XSpellChecker1 > GetSpellChecker()
+{
+ return LinguMgr::GetSpellChecker();
+}
+
+
+uno::Reference< linguistic2::XHyphenator > GetHyphenator()
+{
+ return LinguMgr::GetHyphenator();
+}
+
+
+uno::Reference< linguistic2::XThesaurus > GetThesaurus()
+{
+ return LinguMgr::GetThesaurus();
+}
+
+
+uno::Reference< beans::XPropertySet > GetLinguPropertySet()
+{
+ return LinguMgr::GetLinguPropertySet();
+}
+
+
diff --git a/sw/source/core/bastyp/tabcol.cxx b/sw/source/core/bastyp/tabcol.cxx
new file mode 100644
index 000000000000..63d9ceee8043
--- /dev/null
+++ b/sw/source/core/bastyp/tabcol.cxx
@@ -0,0 +1,142 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+
+
+#include "tabcol.hxx"
+#include <errhdl.hxx> // fuer Create-Methoden
+
+
+SwTabCols::SwTabCols( USHORT nSize ) :
+ nLeftMin( 0 ),
+ nLeft( 0 ),
+ nRight( 0 ),
+ nRightMax( 0 ),
+ bLastRowAllowedToChange( true )
+{
+ if ( nSize )
+ aData.reserve( nSize );
+}
+
+SwTabCols::SwTabCols( const SwTabCols& rCpy ) :
+ nLeftMin( rCpy.GetLeftMin() ),
+ nLeft( rCpy.GetLeft() ),
+ nRight( rCpy.GetRight() ),
+ nRightMax( rCpy.GetRightMax() ),
+ bLastRowAllowedToChange( rCpy.IsLastRowAllowedToChange() ),
+ aData( rCpy.GetData() )
+{
+#if OSL_DEBUG_LEVEL > 1
+ for ( USHORT i = 0; i < Count(); ++i )
+ {
+ SwTabColsEntry aEntry1 = aData[i];
+ SwTabColsEntry aEntry2 = rCpy.GetData()[i];
+ (void) aEntry1;
+ (void) aEntry2;
+ ASSERT( aEntry1.nPos == aEntry2.nPos &&
+ aEntry1.nMin == aEntry2.nMin &&
+ aEntry1.nMax == aEntry2.nMax &&
+ aEntry1.bHidden == aEntry2.bHidden,
+ "CopyContructor of SwTabColsEntries did not succeed!" )
+ }
+#endif
+}
+
+SwTabCols &SwTabCols::operator=( const SwTabCols& rCpy )
+{
+ nLeftMin = rCpy.GetLeftMin();
+ nLeft = rCpy.GetLeft();
+ nRight = rCpy.GetRight();
+ nRightMax= rCpy.GetRightMax();
+ bLastRowAllowedToChange = rCpy.IsLastRowAllowedToChange();
+
+ Remove( 0, Count() );
+ aData = rCpy.GetData();
+
+ return *this;
+}
+
+BOOL SwTabCols::operator==( const SwTabCols& rCmp ) const
+{
+ USHORT i;
+
+ if ( !(nLeftMin == rCmp.GetLeftMin() &&
+ nLeft == rCmp.GetLeft() &&
+ nRight == rCmp.GetRight() &&
+ nRightMax== rCmp.GetRightMax()&&
+ bLastRowAllowedToChange== rCmp.IsLastRowAllowedToChange() &&
+ Count()== rCmp.Count()) )
+ return FALSE;
+
+ for ( i = 0; i < Count(); ++i )
+ {
+ SwTabColsEntry aEntry1 = aData[i];
+ SwTabColsEntry aEntry2 = rCmp.GetData()[i];
+ if ( aEntry1.nPos != aEntry2.nPos || aEntry1.bHidden != aEntry2.bHidden )
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+void SwTabCols::Insert( long nValue, long nMin, long nMax, BOOL bValue, USHORT nPos )
+{
+ SwTabColsEntry aEntry;
+ aEntry.nPos = nValue;
+ aEntry.nMin = nMin;
+ aEntry.nMax = nMax;
+ aEntry.bHidden = bValue;
+ aData.insert( aData.begin() + nPos, aEntry );
+}
+
+void SwTabCols::Insert( long nValue, BOOL bValue, USHORT nPos )
+{
+ SwTabColsEntry aEntry;
+ aEntry.nPos = nValue;
+ aEntry.nMin = 0;
+ aEntry.nMax = LONG_MAX;
+ aEntry.bHidden = bValue;
+ aData.insert( aData.begin() + nPos, aEntry );
+
+#if OSL_DEBUG_LEVEL > 1
+ SwTabColsEntries::iterator aPos = aData.begin();
+ for ( ; aPos != aData.end(); ++aPos )
+ {
+ aEntry =(*aPos);
+ }
+#endif
+}
+
+void SwTabCols::Remove( USHORT nPos, USHORT nAnz )
+{
+ SwTabColsEntries::iterator aStart = aData.begin() + nPos;
+ aData.erase( aStart, aStart + nAnz );
+}
+