summaryrefslogtreecommitdiff
path: root/editeng/source/rtf
diff options
context:
space:
mode:
Diffstat (limited to 'editeng/source/rtf')
-rw-r--r--editeng/source/rtf/makefile.mk55
-rw-r--r--editeng/source/rtf/rtfgrf.cxx561
-rw-r--r--editeng/source/rtf/rtfitem.cxx2104
-rw-r--r--editeng/source/rtf/segincr.asm43
-rw-r--r--editeng/source/rtf/svxrtf.cxx1517
5 files changed, 4280 insertions, 0 deletions
diff --git a/editeng/source/rtf/makefile.mk b/editeng/source/rtf/makefile.mk
new file mode 100644
index 000000000000..b633d5c08879
--- /dev/null
+++ b/editeng/source/rtf/makefile.mk
@@ -0,0 +1,55 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2008 by Sun Microsystems, Inc.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.5 $
+#
+# 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=editeng
+TARGET=rtf
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+EXCEPTIONSFILES= \
+ $(SLO)$/svxrtf.obj
+
+SLOFILES= \
+ $(EXCEPTIONSFILES) \
+ $(SLO)$/rtfitem.obj \
+ $(SLO)$/rtfgrf.obj
+
+# ==========================================================================
+
+.INCLUDE : target.mk
+
diff --git a/editeng/source/rtf/rtfgrf.cxx b/editeng/source/rtf/rtfgrf.cxx
new file mode 100644
index 000000000000..5903090205f0
--- /dev/null
+++ b/editeng/source/rtf/rtfgrf.cxx
@@ -0,0 +1,561 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: rtfgrf.cxx,v $
+ * $Revision: 1.13 $
+ *
+ * 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_editeng.hxx"
+
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil -*- */
+#include <osl/endian.h>
+#include <tools/cachestr.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/svapp.hxx>
+#include <svtools/rtfkeywd.hxx>
+#include <svtools/rtftoken.h>
+#include <svtools/filter.hxx>
+
+#include <editeng/svxrtf.hxx>
+
+
+#ifndef DBG_UTIL
+#undef DEBUG_JP
+#endif
+
+#ifdef DEBUG_JP
+
+#include <tools/fsys.hxx>
+
+class GrfWindow : public WorkWindow
+{
+ Graphic aGrf;
+public:
+ GrfWindow( const Graphic& rGrf );
+ virtual void Paint( const Rectangle& rRect );
+};
+
+GrfWindow::GrfWindow( const Graphic& rGrf )
+ : WorkWindow( NULL ),
+ aGrf( rGrf )
+{
+ SetPosSizePixel( Point( 100, 0 ), Size( 300, 300 ));
+ Show();
+ Invalidate();
+ Update();
+}
+
+void GrfWindow::Paint( const Rectangle& )
+{
+ aGrf.Draw( this, Point(0,0), GetSizePixel() );
+}
+#endif
+
+static BYTE __FAR_DATA aPal1[ 2 * 4 ] = {
+ 0x00, 0x00, 0x00, 0x00, // Schwarz
+ 0xFF, 0xFF, 0xFF, 0x00 // Weiss
+};
+
+static BYTE __FAR_DATA aPal4[ 16 * 4 ] = {
+ 0x00, 0x00, 0x00, 0x00,
+ 0x80, 0x00, 0x00, 0x00,
+ 0x00, 0x80, 0x00, 0x00,
+ 0x80, 0x80, 0x00, 0x00,
+ 0x00, 0x00, 0x80, 0x00,
+ 0x80, 0x00, 0x80, 0x00,
+ 0x00, 0x80, 0x80, 0x00,
+ 0x80, 0x80, 0x80, 0x00,
+ 0xC0, 0xC0, 0xC0, 0x00,
+ 0xFF, 0x00, 0x00, 0x00,
+ 0x00, 0xFF, 0x00, 0x00,
+ 0xFF, 0xFF, 0x00, 0x00,
+ 0x00, 0x00, 0xFF, 0x00,
+ 0xFF, 0x00, 0xFF, 0x00,
+ 0x00, 0xFF, 0xFF, 0x00,
+ 0xFF, 0xFF, 0xFF, 0x00
+};
+
+static BYTE __FAR_DATA aPal8[ 256 * 4 ] =
+{
+0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x92, 0x00, 0x00,
+0x80, 0x92, 0x00, 0x00, 0x00, 0x00, 0xAA, 0x00, 0x80, 0x00, 0xAA, 0x00,
+0x00, 0x92, 0xAA, 0x00, 0xC1, 0xC1, 0xC1, 0x00, 0xC9, 0xC9, 0xC9, 0x00,
+0xAA, 0xDB, 0xFF, 0x00, 0x00, 0x49, 0xAA, 0x00, 0x00, 0x49, 0xFF, 0x00,
+0x00, 0x6D, 0x00, 0x00, 0x00, 0x6D, 0x55, 0x00, 0x00, 0x6D, 0xAA, 0x00,
+0x00, 0x6D, 0xFF, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x92, 0x55, 0x00,
+0x00, 0x24, 0xAA, 0x00, 0x00, 0x92, 0xFF, 0x00, 0x00, 0xB6, 0x00, 0x00,
+0x00, 0xB6, 0x55, 0x00, 0x00, 0xB6, 0xAA, 0x00, 0x00, 0xB6, 0xFF, 0x00,
+0x00, 0xDB, 0x00, 0x00, 0x00, 0xDB, 0x55, 0x00, 0x00, 0xDB, 0xAA, 0x00,
+0x00, 0xDB, 0xFF, 0x00, 0xFF, 0xDB, 0xAA, 0x00, 0x00, 0xFF, 0x55, 0x00,
+0x00, 0xFF, 0xAA, 0x00, 0xFF, 0xFF, 0xAA, 0x00, 0x2B, 0x00, 0x00, 0x00,
+0x2B, 0x00, 0x55, 0x00, 0x2B, 0x00, 0xAA, 0x00, 0x2B, 0x00, 0xFF, 0x00,
+0x2B, 0x24, 0x00, 0x00, 0x2B, 0x24, 0x55, 0x00, 0x2B, 0x24, 0xAA, 0x00,
+0x2B, 0x24, 0xFF, 0x00, 0x2B, 0x49, 0x00, 0x00, 0x2B, 0x49, 0x55, 0x00,
+0x2B, 0x49, 0xAA, 0x00, 0x2B, 0x49, 0xFF, 0x00, 0x2B, 0x6D, 0x00, 0x00,
+0x2B, 0x6D, 0x55, 0x00, 0x2B, 0x6D, 0xAA, 0x00, 0x2B, 0x6D, 0xFF, 0x00,
+0x2B, 0x92, 0x00, 0x00, 0x2B, 0x92, 0x55, 0x00, 0x2B, 0x92, 0xAA, 0x00,
+0x2B, 0x92, 0xFF, 0x00, 0x2B, 0xB6, 0x00, 0x00, 0x2B, 0xB6, 0x55, 0x00,
+0x2B, 0xB6, 0xAA, 0x00, 0x2B, 0xB6, 0xFF, 0x00, 0x2B, 0xDB, 0x00, 0x00,
+0x2B, 0xDB, 0x55, 0x00, 0x2B, 0xDB, 0xAA, 0x00, 0x2B, 0xDB, 0xFF, 0x00,
+0x2B, 0xFF, 0x00, 0x00, 0x2B, 0xFF, 0x55, 0x00, 0x2B, 0xFF, 0xAA, 0x00,
+0x2B, 0xFF, 0xFF, 0x00, 0x55, 0x00, 0x00, 0x00, 0x55, 0x00, 0x55, 0x00,
+0x55, 0x00, 0xAA, 0x00, 0x55, 0x00, 0xFF, 0x00, 0x55, 0x24, 0x00, 0x00,
+0x55, 0x24, 0x55, 0x00, 0x55, 0x24, 0xAA, 0x00, 0x55, 0x24, 0xFF, 0x00,
+0x55, 0x49, 0x00, 0x00, 0x55, 0x49, 0x55, 0x00, 0x55, 0x49, 0xAA, 0x00,
+0x55, 0x49, 0xFF, 0x00, 0x55, 0x6D, 0x00, 0x00, 0x55, 0x6D, 0x55, 0x00,
+0x55, 0x6D, 0xAA, 0x00, 0x55, 0x6D, 0xFF, 0x00, 0x55, 0x92, 0x00, 0x00,
+0x55, 0x92, 0x55, 0x00, 0x55, 0x92, 0xAA, 0x00, 0x55, 0x92, 0xFF, 0x00,
+0x55, 0xB6, 0x00, 0x00, 0x55, 0xB6, 0x55, 0x00, 0x55, 0xB6, 0xAA, 0x00,
+0x55, 0xB6, 0xFF, 0x00, 0x55, 0xDB, 0x00, 0x00, 0x55, 0xDB, 0x55, 0x00,
+0x55, 0xDB, 0xAA, 0x00, 0x55, 0xDB, 0xFF, 0x00, 0x55, 0xFF, 0x00, 0x00,
+0x55, 0xFF, 0x55, 0x00, 0x55, 0xFF, 0xAA, 0x00, 0x55, 0xFF, 0xFF, 0x00,
+0x00, 0x00, 0x55, 0x00, 0x80, 0x00, 0x55, 0x00, 0x00, 0x24, 0x55, 0x00,
+0x80, 0x00, 0xFF, 0x00, 0x80, 0x24, 0x00, 0x00, 0x80, 0x24, 0x55, 0x00,
+0x80, 0x24, 0xAA, 0x00, 0x80, 0x24, 0xFF, 0x00, 0x80, 0x49, 0x00, 0x00,
+0x80, 0x49, 0x55, 0x00, 0x80, 0x49, 0xAA, 0x00, 0x80, 0x49, 0xFF, 0x00,
+0x80, 0x6D, 0x00, 0x00, 0x80, 0x6D, 0x55, 0x00, 0x80, 0x6D, 0xAA, 0x00,
+0x80, 0x6D, 0xFF, 0x00, 0x08, 0x08, 0x08, 0x00, 0x0F, 0x0F, 0x0F, 0x00,
+0x17, 0x17, 0x17, 0x00, 0x1F, 0x1F, 0x1F, 0x00, 0x27, 0x27, 0x27, 0x00,
+0x2E, 0x2E, 0x2E, 0x00, 0x36, 0x36, 0x36, 0x00, 0x3E, 0x3E, 0x3E, 0x00,
+0x46, 0x46, 0x46, 0x00, 0x4D, 0x4D, 0x4D, 0x00, 0x55, 0x55, 0x55, 0x00,
+0x5D, 0x5D, 0x5D, 0x00, 0x64, 0x64, 0x64, 0x00, 0x6C, 0x6C, 0x6C, 0x00,
+0x74, 0x74, 0x74, 0x00, 0x7C, 0x7C, 0x7C, 0x00, 0xFF, 0xDB, 0x00, 0x00,
+0x8B, 0x8B, 0x8B, 0x00, 0x93, 0x93, 0x93, 0x00, 0x9B, 0x9B, 0x9B, 0x00,
+0xFF, 0xB6, 0xFF, 0x00, 0xAA, 0xAA, 0xAA, 0x00, 0xB2, 0xB2, 0xB2, 0x00,
+0xB9, 0xB9, 0xB9, 0x00, 0x00, 0x24, 0xFF, 0x00, 0x00, 0x49, 0x00, 0x00,
+0xD1, 0xD1, 0xD1, 0x00, 0xD8, 0xD8, 0xD8, 0x00, 0xE0, 0xE0, 0xE0, 0x00,
+0xE8, 0xE8, 0xE8, 0x00, 0xF0, 0xF0, 0xF0, 0x00, 0xFF, 0xB6, 0xAA, 0x00,
+0xFF, 0xDB, 0xFF, 0x00, 0x80, 0x92, 0x55, 0x00, 0x80, 0x92, 0xAA, 0x00,
+0x80, 0x92, 0xFF, 0x00, 0x80, 0xB6, 0x00, 0x00, 0x80, 0xB6, 0x55, 0x00,
+0x80, 0xB6, 0xAA, 0x00, 0x80, 0xB6, 0xFF, 0x00, 0x80, 0xDB, 0x00, 0x00,
+0x80, 0xDB, 0x55, 0x00, 0x80, 0xDB, 0xAA, 0x00, 0x80, 0xDB, 0xFF, 0x00,
+0x80, 0xFF, 0x00, 0x00, 0x80, 0xFF, 0x55, 0x00, 0x80, 0xFF, 0xAA, 0x00,
+0x80, 0xFF, 0xFF, 0x00, 0xAA, 0x00, 0x00, 0x00, 0xAA, 0x00, 0x55, 0x00,
+0xAA, 0x00, 0xAA, 0x00, 0xAA, 0x00, 0xFF, 0x00, 0xAA, 0x24, 0x00, 0x00,
+0xAA, 0x24, 0x55, 0x00, 0xAA, 0x24, 0xAA, 0x00, 0xAA, 0x24, 0xFF, 0x00,
+0xAA, 0x49, 0x00, 0x00, 0xAA, 0x49, 0x55, 0x00, 0xAA, 0x49, 0xAA, 0x00,
+0xAA, 0x49, 0xFF, 0x00, 0xAA, 0x6D, 0x00, 0x00, 0xAA, 0x6D, 0x55, 0x00,
+0xAA, 0x6D, 0xAA, 0x00, 0xAA, 0x6D, 0xFF, 0x00, 0xAA, 0x92, 0x00, 0x00,
+0xAA, 0x92, 0x55, 0x00, 0xAA, 0x92, 0xAA, 0x00, 0xAA, 0x92, 0xFF, 0x00,
+0xAA, 0xB6, 0x00, 0x00, 0xAA, 0xB6, 0x55, 0x00, 0xAA, 0xB6, 0xAA, 0x00,
+0xAA, 0xB6, 0xFF, 0x00, 0xAA, 0xDB, 0x00, 0x00, 0xAA, 0xDB, 0x55, 0x00,
+0xAA, 0xDB, 0xAA, 0x00, 0x00, 0x49, 0x55, 0x00, 0xAA, 0xFF, 0x00, 0x00,
+0xAA, 0xFF, 0x55, 0x00, 0xAA, 0xFF, 0xAA, 0x00, 0xAA, 0xFF, 0xFF, 0x00,
+0xD5, 0x00, 0x00, 0x00, 0xD5, 0x00, 0x55, 0x00, 0xD5, 0x00, 0xAA, 0x00,
+0xD5, 0x00, 0xFF, 0x00, 0xD5, 0x24, 0x00, 0x00, 0xD5, 0x24, 0x55, 0x00,
+0xD5, 0x24, 0xAA, 0x00, 0xD5, 0x24, 0xFF, 0x00, 0xD5, 0x49, 0x00, 0x00,
+0xD5, 0x49, 0x55, 0x00, 0xD5, 0x49, 0xAA, 0x00, 0xD5, 0x49, 0xFF, 0x00,
+0xD5, 0x6D, 0x00, 0x00, 0xD5, 0x6D, 0x55, 0x00, 0xD5, 0x6D, 0xAA, 0x00,
+0xD5, 0x6D, 0xFF, 0x00, 0xD5, 0x92, 0x00, 0x00, 0xD5, 0x92, 0x55, 0x00,
+0xD5, 0x92, 0xAA, 0x00, 0xD5, 0x92, 0xFF, 0x00, 0xD5, 0xB6, 0x00, 0x00,
+0xD5, 0xB6, 0x55, 0x00, 0xD5, 0xB6, 0xAA, 0x00, 0xD5, 0xB6, 0xFF, 0x00,
+0xD5, 0xDB, 0x00, 0x00, 0xD5, 0xDB, 0x55, 0x00, 0xD5, 0xDB, 0xAA, 0x00,
+0xD5, 0xDB, 0xFF, 0x00, 0xD5, 0xFF, 0x00, 0x00, 0xD5, 0xFF, 0x55, 0x00,
+0xD5, 0xFF, 0xAA, 0x00, 0xD5, 0xFF, 0xFF, 0x00, 0xFF, 0xDB, 0x55, 0x00,
+0xFF, 0x00, 0x55, 0x00, 0xFF, 0x00, 0xAA, 0x00, 0xFF, 0xFF, 0x55, 0x00,
+0xFF, 0x24, 0x00, 0x00, 0xFF, 0x24, 0x55, 0x00, 0xFF, 0x24, 0xAA, 0x00,
+0xFF, 0x24, 0xFF, 0x00, 0xFF, 0x49, 0x00, 0x00, 0xFF, 0x49, 0x55, 0x00,
+0xFF, 0x49, 0xAA, 0x00, 0xFF, 0x49, 0xFF, 0x00, 0xFF, 0x6D, 0x00, 0x00,
+0xFF, 0x6D, 0x55, 0x00, 0xFF, 0x6D, 0xAA, 0x00, 0xFF, 0x6D, 0xFF, 0x00,
+0xFF, 0x92, 0x00, 0x00, 0xFF, 0x92, 0x55, 0x00, 0xFF, 0x92, 0xAA, 0x00,
+0xFF, 0x92, 0xFF, 0x00, 0xFF, 0xB6, 0x00, 0x00, 0xFF, 0xB6, 0x55, 0x00,
+0xF7, 0xF7, 0xF7, 0x00, 0xA2, 0xA2, 0xA2, 0x00, 0x83, 0x83, 0x83, 0x00,
+0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00,
+0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00,
+0xFF, 0xFF, 0xFF, 0x00
+};
+
+
+/* */
+
+
+inline long SwapLong( long n )
+{
+#ifndef OSL_LITENDIAN
+ return SWAPLONG( n );
+#else
+ return n;
+#endif
+}
+
+inline short SwapShort( short n )
+{
+#ifndef OSL_LITENDIAN
+ return SWAPSHORT( n );
+#else
+ return n;
+#endif
+}
+
+
+static void WriteBMPHeader( SvStream& rStream,
+ const SvxRTFPictureType& rPicType )
+{
+ ULONG n4Width = rPicType.nWidth;
+ ULONG n4Height = rPicType.nHeight;
+ USHORT n4ColBits = rPicType.nBitsPerPixel;
+
+ USHORT nColors = (1 << n4ColBits); // Anzahl der Farben ( 1, 16, 256 )
+ USHORT nWdtOut = rPicType.nWidthBytes;
+ if( !nWdtOut )
+ nWdtOut = (USHORT)((( n4Width * n4ColBits + 31 ) / 32 ) * 4 );
+
+ long nOffset = 14 + 40; // BMP_FILE_HD_SIZ + sizeof(*pBmpInfo);
+ if( 256 >= nColors )
+ nOffset += nColors * 4;
+ long nSize = nOffset + nWdtOut * n4Height;
+ rStream << "BM" // = "BM"
+ << SwapLong(nSize) // Filesize in Bytes
+ << SwapShort(0) // Reserviert
+ << SwapShort(0) // Reserviert
+ << SwapLong(nOffset); // Offset?
+
+ rStream << SwapLong(40) // sizeof( BmpInfo )
+ << SwapLong(n4Width)
+ << SwapLong(n4Height)
+ << (USHORT)1
+ << n4ColBits
+ << SwapLong(0)
+ << SwapLong(0)
+ << SwapLong( rPicType.nGoalWidth
+ ? rPicType.nGoalWidth * 1000L / 254L
+ : 0 ) // DPI in Pixel per Meter
+ << SwapLong( rPicType.nGoalHeight
+ ? rPicType.nGoalHeight * 1000L / 254L // dito
+ : 0 )
+ << SwapLong(0)
+ << SwapLong(0);
+
+
+ switch( rPicType.nBitsPerPixel )
+ {
+ case 1: rStream.Write( aPal1, sizeof( aPal1 )); break;
+ case 4: rStream.Write( aPal4, sizeof( aPal4 )); break;
+ case 8: rStream.Write( aPal8, sizeof( aPal8 )); break;
+ }
+}
+
+/* */
+
+ // wandel die ASCII-HexCodes in binaere Zeichen um. Werden
+ // ungueltige Daten gefunden (Zeichen ausser 0-9|a-f|A-F, so
+ // wird USHRT_MAX returnt, ansonsten die Anzahl der umgewandelten Ze.
+xub_StrLen SvxRTFParser::HexToBin( String& rToken )
+{
+ // dann mache aus den Hex-Werten mal "Binare Daten"
+ // (missbrauche den String als temp Buffer)
+ if( rToken.Len() & 1 ) // ungerade Anzahl, mit 0 auffuellen
+ rToken += '0';
+
+ xub_StrLen n, nLen;
+ sal_Unicode nVal;
+ BOOL bValidData = TRUE;
+ const sal_Unicode* pStr = rToken.GetBufferAccess();
+ sal_Char* pData = (sal_Char*)pStr;
+ for( n = 0, nLen = rToken.Len(); n < nLen; ++n, ++pStr )
+ {
+ if( ((nVal = *pStr) >= '0') && ( nVal <= '9') )
+ nVal -= '0';
+ else if( (nVal >= 'A') && (nVal <= 'F') )
+ nVal -= 'A' - 10;
+ else if( (nVal >= 'a') && (nVal <= 'f') )
+ nVal -= 'a' - 10;
+ else
+ {
+ DBG_ASSERT( !this, "ungueltiger Hex-Wert" );
+ bValidData = FALSE;
+ break;
+ }
+
+ if( n & 1 )
+ *(pData++) |= nVal & 0x0f;
+ else
+ *(pData) = sal::static_int_cast< char >( ( nVal << 4 ) & 0xf0 );
+ }
+ // the len div 2, because 2 character are one byte
+ return bValidData ? nLen / 2 : STRING_NOTFOUND;
+}
+
+BOOL SvxRTFParser::ReadBmpData( Graphic& rGrf, SvxRTFPictureType& rPicType )
+{
+ // die alten Daten loeschen
+ rGrf.Clear();
+// ULONG nBmpSize = 0;
+
+ rtl_TextEncoding eOldEnc = GetSrcEncoding();
+ SetSrcEncoding( RTL_TEXTENCODING_MS_1252 );
+
+ const sal_Char* pFilterNm = 0;
+ SvCacheStream* pTmpFile = 0;
+
+ int nToken = 0;
+ bool bValidBmp = true, bFirstTextToken = true;
+ int _nOpenBrakets = 1, // die erste wurde schon vorher erkannt !!
+ nValidDataBraket = 1;
+
+ if( RTF_SHPPICT == GetStackPtr(0)->nTokenId )
+ ++nValidDataBraket;
+
+ while( _nOpenBrakets && IsParserWorking() && bValidBmp )
+ {
+ nToken = GetNextToken();
+ USHORT nVal = USHORT( nTokenValue );
+ switch( nToken )
+ {
+ case '}': --_nOpenBrakets; break;
+ case '{':
+ {
+ if( RTF_IGNOREFLAG != GetNextToken() )
+ nToken = SkipToken( -1 );
+ else if( RTF_UNKNOWNCONTROL != GetNextToken() )
+ nToken = SkipToken( -2 );
+ else
+ {
+ // gleich herausfiltern
+ ReadUnknownData();
+ nToken = GetNextToken();
+ if( '}' != nToken )
+ eState = SVPAR_ERROR;
+ break;
+ }
+ ++_nOpenBrakets;
+ }
+ break;
+
+ case RTF_MACPICT:
+ {
+ rPicType.eStyle = SvxRTFPictureType::MAC_QUICKDRAW;
+ // Mac-Pict bekommt einen leeren Header voran
+ pTmpFile = new SvCacheStream;
+ ByteString aStr;
+ aStr.Fill( 512, '\0' );
+ pTmpFile->Write( aStr.GetBuffer(), aStr.Len() );
+ pFilterNm = "PCT";
+ }
+ break;
+
+ case RTF_EMFBLIP:
+ case RTF_WMETAFILE:
+ case RTF_PNGBLIP:
+ case RTF_JPEGBLIP:
+ case RTF_WBITMAP:
+ case RTF_OSMETAFILE:
+ case RTF_DIBITMAP:
+ {
+ switch( nToken )
+ {
+ case RTF_EMFBLIP:
+ rPicType.eStyle = SvxRTFPictureType::ENHANCED_MF;
+ pFilterNm = "EMF";
+ break;
+ case RTF_WMETAFILE:
+ rPicType.eStyle = SvxRTFPictureType::WIN_METAFILE;
+ pFilterNm = "WMF";
+ break;
+ case RTF_PNGBLIP:
+ rPicType.eStyle = SvxRTFPictureType::RTF_PNG;
+ pFilterNm = "PNG";
+ break;
+ case RTF_JPEGBLIP:
+ rPicType.eStyle = SvxRTFPictureType::RTF_JPG;
+ pFilterNm = "JPG";
+ break;
+
+ case RTF_WBITMAP:
+ rPicType.eStyle = SvxRTFPictureType::RTF_BITMAP;
+ break;
+ case RTF_OSMETAFILE:
+ rPicType.eStyle = SvxRTFPictureType::OS2_METAFILE;
+ break;
+ case RTF_DIBITMAP:
+ rPicType.eStyle = SvxRTFPictureType::RTF_DI_BMP;
+ break;
+ }
+
+ rPicType.nType = nVal;
+ pTmpFile = new SvCacheStream;
+ }
+ break;
+
+ case RTF_PICW: rPicType.nWidth = nVal; break;
+ case RTF_PICH: rPicType.nHeight = nVal; break;
+ case RTF_WBMBITSPIXEL: rPicType.nBitsPerPixel = nVal; break;
+ case RTF_WBMPLANES: rPicType.nPlanes = nVal; break;
+ case RTF_WBMWIDTHBYTES: rPicType.nWidthBytes = nVal; break;
+ case RTF_PICWGOAL: rPicType.nGoalWidth = nVal; break;
+ case RTF_PICHGOAL: rPicType.nGoalHeight = nVal; break;
+ case RTF_BIN:
+ rPicType.nMode = SvxRTFPictureType::BINARY_MODE;
+ rPicType.uPicLen = nTokenValue;
+ if (rPicType.uPicLen)
+ {
+ ULONG nPos = rStrm.Tell();
+ nPos = nPos;
+ rStrm.SeekRel(-1);
+ sal_uInt8 aData[4096];
+ ULONG nSize = sizeof(aData);
+
+ while (rPicType.uPicLen > 0)
+ {
+ if (rPicType.uPicLen < nSize)
+ nSize = rPicType.uPicLen;
+
+ rStrm.Read(aData, nSize);
+ pTmpFile->Write(aData, nSize);
+ rPicType.uPicLen -= nSize;
+ }
+ nNextCh = GetNextChar();
+ bValidBmp = !pTmpFile->GetError();
+ nPos = rStrm.Tell();
+ nPos = nPos;
+ }
+ break;
+ case RTF_PICSCALEX: rPicType.nScalX = nVal; break;
+ case RTF_PICSCALEY: rPicType.nScalY = nVal; break;
+ case RTF_PICSCALED: break;
+
+ case RTF_PICCROPT: rPicType.nCropT = (short)nTokenValue; break;
+ case RTF_PICCROPB: rPicType.nCropB = (short)nTokenValue; break;
+ case RTF_PICCROPL: rPicType.nCropL = (short)nTokenValue; break;
+ case RTF_PICCROPR: rPicType.nCropR = (short)nTokenValue; break;
+
+ case RTF_TEXTTOKEN:
+ // JP 26.06.98: Bug #51719# - nur TextToken auf 1. Ebene
+ // auswerten. Alle anderen sind irgendwelche
+ // nicht auszuwertende Daten
+ if( nValidDataBraket != _nOpenBrakets )
+ break;
+
+ if( bFirstTextToken )
+ {
+ switch( rPicType.eStyle )
+ {
+ case SvxRTFPictureType::RTF_BITMAP:
+ // erstmal die Header und Info-Struktur schreiben
+ if( pTmpFile )
+ ::WriteBMPHeader( *pTmpFile, rPicType );
+ break;
+ default:
+ break;
+ }
+ bFirstTextToken = FALSE;
+ }
+
+ if( pTmpFile && SvxRTFPictureType::HEX_MODE == rPicType.nMode )
+ {
+ xub_StrLen nTokenLen = HexToBin( aToken );
+ if( STRING_NOTFOUND == nTokenLen )
+ bValidBmp = FALSE;
+ else
+ {
+ pTmpFile->Write( (sal_Char*)aToken.GetBuffer(),
+ nTokenLen );
+ bValidBmp = 0 == pTmpFile->GetError();
+ }
+ }
+ break;
+ }
+ }
+
+ if (pTmpFile)
+ {
+ //#i20775#
+ if (pTmpFile->Tell() == 0)
+ bValidBmp = false;
+
+ if( bValidBmp )
+ {
+ GraphicFilter* pGF = GraphicFilter::GetGraphicFilter();
+ USHORT nImportFilter = GRFILTER_FORMAT_DONTKNOW;
+
+ if( pFilterNm )
+ {
+ String sTmp;
+ for( USHORT n = pGF->GetImportFormatCount(); n; )
+ {
+ sTmp = pGF->GetImportFormatShortName( --n );
+ if( sTmp.EqualsAscii( pFilterNm ))
+ {
+ nImportFilter = n;
+ break;
+ }
+ }
+ }
+
+ String sTmpStr;
+ pTmpFile->Seek( STREAM_SEEK_TO_BEGIN );
+ bValidBmp = 0 == pGF->ImportGraphic( rGrf, sTmpStr, *pTmpFile,
+ nImportFilter );
+ }
+ delete pTmpFile;
+ }
+
+ if( !bValidBmp )
+ {
+ rGrf.Clear();
+ //TODO If nToken were not initialized to 0 above, it would potentially
+ // be used uninitialized here (if IsParserWorking() is false at the
+ // start of the while loop above):
+ if( '}' != nToken )
+ SkipGroup();
+ }
+ else
+ {
+ switch( rPicType.eStyle )
+ {
+//?? ENHANCED_MF, // in den Pict.Daten steht ein Enhanced-Metafile
+ case SvxRTFPictureType::RTF_PNG:
+ case SvxRTFPictureType::RTF_JPG:
+ {
+ const MapMode aMap( MAP_100TH_MM );
+ Size aSize( rGrf.GetPrefSize() );
+ if( MAP_PIXEL == rGrf.GetPrefMapMode().GetMapUnit() )
+ aSize = Application::GetDefaultDevice()->PixelToLogic(
+ aSize, aMap );
+ else
+ aSize = OutputDevice::LogicToLogic( aSize,
+ rGrf.GetPrefMapMode(), aMap );
+ rPicType.nWidth = sal::static_int_cast< USHORT >(aSize.Width());
+ rPicType.nHeight = sal::static_int_cast< USHORT >(
+ aSize.Height());
+ }
+ break;
+ default:
+ break;
+ }
+
+#ifdef DEBUG_JP
+ new GrfWindow( rGrf );
+#endif
+ }
+ SetSrcEncoding( eOldEnc );
+
+ SkipToken( -1 ); // die schliesende Klammer wird "oben" ausgewertet
+ return bValidBmp;
+}
+
+/* vi:set tabstop=4 shiftwidth=4 expandtab: */
diff --git a/editeng/source/rtf/rtfitem.cxx b/editeng/source/rtf/rtfitem.cxx
new file mode 100644
index 000000000000..a8e3d4b3d25e
--- /dev/null
+++ b/editeng/source/rtf/rtfitem.cxx
@@ -0,0 +1,2104 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: rtfitem.cxx,v $
+ * $Revision: 1.35.212.1 $
+ *
+ * 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_editeng.hxx"
+
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil -*- */
+
+#include <editeng/flstitem.hxx>
+#include <editeng/fontitem.hxx>
+#include <editeng/postitem.hxx>
+#include <editeng/wghtitem.hxx>
+#include <editeng/fhgtitem.hxx>
+#include <editeng/fwdtitem.hxx>
+#include <editeng/udlnitem.hxx>
+#include <editeng/crsditem.hxx>
+#include <editeng/shdditem.hxx>
+#include <editeng/akrnitem.hxx>
+#include <editeng/wrlmitem.hxx>
+#include <editeng/cntritem.hxx>
+#include <editeng/prszitem.hxx>
+#include <editeng/colritem.hxx>
+#include <editeng/cscoitem.hxx>
+#include <editeng/kernitem.hxx>
+#include <editeng/cmapitem.hxx>
+#include <editeng/escpitem.hxx>
+#include <editeng/langitem.hxx>
+#include <editeng/nlbkitem.hxx>
+#include <editeng/nhypitem.hxx>
+#include <editeng/lcolitem.hxx>
+#include <editeng/blnkitem.hxx>
+#include <editeng/emphitem.hxx>
+#include <editeng/twolinesitem.hxx>
+#include <editeng/pbinitem.hxx>
+#include <editeng/sizeitem.hxx>
+#include <editeng/lrspitem.hxx>
+#include <editeng/ulspitem.hxx>
+#include <editeng/prntitem.hxx>
+#include <editeng/opaqitem.hxx>
+#include <editeng/protitem.hxx>
+#include <editeng/shaditem.hxx>
+#include <editeng/boxitem.hxx>
+#include <editeng/brkitem.hxx>
+#include <editeng/keepitem.hxx>
+#include <editeng/bolnitem.hxx>
+#include <editeng/brshitem.hxx>
+#include <editeng/lspcitem.hxx>
+#include <editeng/adjitem.hxx>
+#include <editeng/orphitem.hxx>
+#include <editeng/widwitem.hxx>
+#include <editeng/tstpitem.hxx>
+#include <editeng/pmdlitem.hxx>
+#include <editeng/spltitem.hxx>
+#include <editeng/hyznitem.hxx>
+#include <editeng/charscaleitem.hxx>
+#include <editeng/charrotateitem.hxx>
+#include <editeng/charreliefitem.hxx>
+#include <editeng/paravertalignitem.hxx>
+#include <editeng/forbiddenruleitem.hxx>
+#include <editeng/hngpnctitem.hxx>
+#include <editeng/scriptspaceitem.hxx>
+#include <editeng/frmdiritem.hxx>
+#include <editeng/charhiddenitem.hxx>
+
+#include <svtools/rtftoken.h>
+#include <svl/itempool.hxx>
+#include <svl/itemiter.hxx>
+
+#include <editeng/svxrtf.hxx>
+#include <editeng/editids.hrc>
+
+#define BRACELEFT '{'
+#define BRACERIGHT '}'
+
+
+// einige Hilfs-Funktionen
+// char
+inline const SvxEscapementItem& GetEscapement(const SfxItemSet& rSet,USHORT nId,BOOL bInP=TRUE)
+ { return (const SvxEscapementItem&)rSet.Get( nId,bInP); }
+inline const SvxLineSpacingItem& GetLineSpacing(const SfxItemSet& rSet,USHORT nId,BOOL bInP=TRUE)
+ { return (const SvxLineSpacingItem&)rSet.Get( nId,bInP); }
+// frm
+inline const SvxLRSpaceItem& GetLRSpace(const SfxItemSet& rSet,USHORT nId,BOOL bInP=TRUE)
+ { return (const SvxLRSpaceItem&)rSet.Get( nId,bInP); }
+inline const SvxULSpaceItem& GetULSpace(const SfxItemSet& rSet,USHORT nId,BOOL bInP=TRUE)
+ { return (const SvxULSpaceItem&)rSet.Get( nId,bInP); }
+
+#define PARDID ((RTFPardAttrMapIds*)aPardMap.GetData())
+#define PLAINID ((RTFPlainAttrMapIds*)aPlainMap.GetData())
+
+void SvxRTFParser::SetScriptAttr( RTF_CharTypeDef eType, SfxItemSet& rSet,
+ SfxPoolItem& rItem )
+{
+ const USHORT *pNormal = 0, *pCJK = 0, *pCTL = 0;
+ const RTFPlainAttrMapIds* pIds = (RTFPlainAttrMapIds*)aPlainMap.GetData();
+ switch( rItem.Which() )
+ {
+ case SID_ATTR_CHAR_FONT:
+ pNormal = &pIds->nFont;
+ pCJK = &pIds->nCJKFont;
+ pCTL = &pIds->nCTLFont;
+ break;
+
+ case SID_ATTR_CHAR_FONTHEIGHT:
+ pNormal = &pIds->nFontHeight;
+ pCJK = &pIds->nCJKFontHeight;
+ pCTL = &pIds->nCTLFontHeight;
+ break;
+
+ case SID_ATTR_CHAR_POSTURE:
+ pNormal = &pIds->nPosture;
+ pCJK = &pIds->nCJKPosture;
+ pCTL = &pIds->nCTLPosture;
+ break;
+
+ case SID_ATTR_CHAR_WEIGHT:
+ pNormal = &pIds->nWeight;
+ pCJK = &pIds->nCJKWeight;
+ pCTL = &pIds->nCTLWeight;
+ break;
+
+ case SID_ATTR_CHAR_LANGUAGE:
+ pNormal = &pIds->nLanguage;
+ pCJK = &pIds->nCJKLanguage;
+ pCTL = &pIds->nCTLLanguage;
+ break;
+
+ case 0:
+ // it exist no WhichId - don't set this item
+ break;
+
+ default:
+ rSet.Put( rItem );
+ break;
+ }
+
+
+ if( DOUBLEBYTE_CHARTYPE == eType )
+ {
+ if( bIsLeftToRightDef && *pCJK )
+ {
+ rItem.SetWhich( *pCJK );
+ rSet.Put( rItem );
+ }
+ }
+ else if( !bIsLeftToRightDef )
+ {
+ if( *pCTL )
+ {
+ rItem.SetWhich( *pCTL );
+ rSet.Put( rItem );
+ }
+ }
+ else
+ {
+ if( LOW_CHARTYPE == eType )
+ {
+ if( *pNormal )
+ {
+ rItem.SetWhich( *pNormal );
+ rSet.Put( rItem );
+ }
+ }
+ else if( HIGH_CHARTYPE == eType )
+ {
+ if( *pCTL )
+ {
+ rItem.SetWhich( *pCTL );
+ rSet.Put( rItem );
+ }
+ }
+ else
+ {
+ if( *pCJK )
+ {
+ rItem.SetWhich( *pCJK );
+ rSet.Put( rItem );
+ }
+ if( *pCTL )
+ {
+ rItem.SetWhich( *pCTL );
+ rSet.Put( rItem );
+ }
+ if( *pNormal )
+ {
+ rItem.SetWhich( *pNormal );
+ rSet.Put( rItem );
+ }
+ }
+ }
+}
+
+// --------------------
+
+void SvxRTFParser::ReadAttr( int nToken, SfxItemSet* pSet )
+{
+ DBG_ASSERT( pSet, "Es muss ein SfxItemSet uebergeben werden!" );
+ int bFirstToken = TRUE, bWeiter = TRUE;
+ USHORT nStyleNo = 0; // default
+ FontUnderline eUnderline;
+ FontUnderline eOverline;
+ FontEmphasisMark eEmphasis;
+ bPardTokenRead = FALSE;
+ RTF_CharTypeDef eCharType = NOTDEF_CHARTYPE;
+ USHORT nFontAlign;
+
+ int bChkStkPos = !bNewGroup && aAttrStack.Top();
+
+ while( bWeiter && IsParserWorking() ) // solange bekannte Attribute erkannt werden
+ {
+ switch( nToken )
+ {
+ case RTF_PARD:
+ RTFPardPlain( TRUE, &pSet );
+ ResetPard();
+ nStyleNo = 0;
+ bPardTokenRead = TRUE;
+ break;
+
+ case RTF_PLAIN:
+ RTFPardPlain( FALSE, &pSet );
+ break;
+
+ default:
+ do { // middle checked loop
+ if( !bChkStkPos )
+ break;
+
+ SvxRTFItemStackType* pAkt = aAttrStack.Top();
+ if( !pAkt || (pAkt->pSttNd->GetIdx() == pInsPos->GetNodeIdx() &&
+ pAkt->nSttCnt == pInsPos->GetCntIdx() ))
+ break;
+
+ int nLastToken = GetStackPtr(-1)->nTokenId;
+ if( RTF_PARD == nLastToken || RTF_PLAIN == nLastToken )
+ break;
+
+ if( pAkt->aAttrSet.Count() || pAkt->pChildList ||
+ pAkt->nStyleNo )
+ {
+ // eine neue Gruppe aufmachen
+ SvxRTFItemStackType* pNew = new SvxRTFItemStackType(
+ *pAkt, *pInsPos, TRUE );
+ pNew->SetRTFDefaults( GetRTFDefaults() );
+
+ // alle bis hierher gueltigen Attribute "setzen"
+ AttrGroupEnd();
+ pAkt = aAttrStack.Top(); // can be changed after AttrGroupEnd!
+ pNew->aAttrSet.SetParent( pAkt ? &pAkt->aAttrSet : 0 );
+
+ aAttrStack.Push( pNew );
+ pAkt = pNew;
+ }
+ else
+ // diesen Eintrag als neuen weiterbenutzen
+ pAkt->SetStartPos( *pInsPos );
+
+ pSet = &pAkt->aAttrSet;
+ } while( FALSE );
+
+ switch( nToken )
+ {
+ case RTF_INTBL:
+ case RTF_PAGEBB:
+ case RTF_SBYS:
+ case RTF_CS:
+ case RTF_LS:
+ case RTF_ILVL:
+ UnknownAttrToken( nToken, pSet );
+ break;
+
+ case RTF_S:
+ if( bIsInReadStyleTab )
+ {
+ if( !bFirstToken )
+ SkipToken( -1 );
+ bWeiter = FALSE;
+ }
+ else
+ {
+ nStyleNo = -1 == nTokenValue ? 0 : USHORT(nTokenValue);
+ // setze am akt. auf dem AttrStack stehenden Style die
+ // StyleNummer
+ SvxRTFItemStackType* pAkt = aAttrStack.Top();
+ if( !pAkt )
+ break;
+
+ pAkt->nStyleNo = USHORT( nStyleNo );
+
+#if 0
+// JP 05.09.95: zuruecksetzen der Style-Attribute fuehrt nur zu Problemen.
+// Es muss reichen, wenn das ueber pard/plain erfolgt
+// ansonsten Bugdoc 15304.rtf - nach nur "\pard" falscher Font !!
+
+ SvxRTFStyleType* pStyle = aStyleTbl.Get( pAkt->nStyleNo );
+ if( pStyle && pStyle->aAttrSet.Count() )
+ {
+ //JP 07.07.95:
+ // alle Attribute, die in der Vorlage gesetzt werden
+ // auf defaults setzen. In RTF werden die Attribute
+ // der Vorlage danach ja wiederholt.
+ // WICHTIG: Attribute die in der Vorlage definiert
+ // sind, werden zurueckgesetzt !!!!
+ // pAkt->aAttrSet.Put( pStyle->aAttrSet );
+
+ SfxItemIter aIter( pStyle->aAttrSet );
+ SfxItemPool* pPool = pStyle->aAttrSet.GetPool();
+ USHORT nWh = aIter.GetCurItem()->Which();
+ while( TRUE )
+ {
+ pAkt->aAttrSet.Put( pPool->GetDefaultItem( nWh ));
+ if( aIter.IsAtEnd() )
+ break;
+ nWh = aIter.NextItem()->Which();
+ }
+ }
+#endif
+ }
+ break;
+
+ case RTF_KEEP:
+ if( PARDID->nSplit )
+ {
+ pSet->Put( SvxFmtSplitItem( FALSE, PARDID->nSplit ));
+ }
+ break;
+
+ case RTF_KEEPN:
+ if( PARDID->nKeep )
+ {
+ pSet->Put( SvxFmtKeepItem( TRUE, PARDID->nKeep ));
+ }
+ break;
+
+ case RTF_LEVEL:
+ if( PARDID->nOutlineLvl )
+ {
+ pSet->Put( SfxUInt16Item( PARDID->nOutlineLvl,
+ (UINT16)nTokenValue ));
+ }
+ break;
+
+ case RTF_QL:
+ if( PARDID->nAdjust )
+ {
+ pSet->Put( SvxAdjustItem( SVX_ADJUST_LEFT, PARDID->nAdjust ));
+ }
+ break;
+ case RTF_QR:
+ if( PARDID->nAdjust )
+ {
+ pSet->Put( SvxAdjustItem( SVX_ADJUST_RIGHT, PARDID->nAdjust ));
+ }
+ break;
+ case RTF_QJ:
+ if( PARDID->nAdjust )
+ {
+ pSet->Put( SvxAdjustItem( SVX_ADJUST_BLOCK, PARDID->nAdjust ));
+ }
+ break;
+ case RTF_QC:
+ if( PARDID->nAdjust )
+ {
+ pSet->Put( SvxAdjustItem( SVX_ADJUST_CENTER, PARDID->nAdjust ));
+ }
+ break;
+
+ case RTF_FI:
+ if( PARDID->nLRSpace )
+ {
+ SvxLRSpaceItem aLR( GetLRSpace(*pSet, PARDID->nLRSpace ));
+ USHORT nSz = 0;
+ if( -1 != nTokenValue )
+ {
+ if( IsCalcValue() )
+ CalcValue();
+ nSz = USHORT(nTokenValue);
+ }
+ aLR.SetTxtFirstLineOfst( nSz );
+ pSet->Put( aLR );
+ }
+ break;
+
+ case RTF_LI:
+ case RTF_LIN:
+ if( PARDID->nLRSpace )
+ {
+ SvxLRSpaceItem aLR( GetLRSpace(*pSet, PARDID->nLRSpace ));
+ USHORT nSz = 0;
+ if( 0 < nTokenValue )
+ {
+ if( IsCalcValue() )
+ CalcValue();
+ nSz = USHORT(nTokenValue);
+ }
+ aLR.SetTxtLeft( nSz );
+ pSet->Put( aLR );
+ }
+ break;
+
+ case RTF_RI:
+ case RTF_RIN:
+ if( PARDID->nLRSpace )
+ {
+ SvxLRSpaceItem aLR( GetLRSpace(*pSet, PARDID->nLRSpace ));
+ USHORT nSz = 0;
+ if( 0 < nTokenValue )
+ {
+ if( IsCalcValue() )
+ CalcValue();
+ nSz = USHORT(nTokenValue);
+ }
+ aLR.SetRight( nSz );
+ pSet->Put( aLR );
+ }
+ break;
+
+ case RTF_SB:
+ if( PARDID->nULSpace )
+ {
+ SvxULSpaceItem aUL( GetULSpace(*pSet, PARDID->nULSpace ));
+ USHORT nSz = 0;
+ if( 0 < nTokenValue )
+ {
+ if( IsCalcValue() )
+ CalcValue();
+ nSz = USHORT(nTokenValue);
+ }
+ aUL.SetUpper( nSz );
+ pSet->Put( aUL );
+ }
+ break;
+
+ case RTF_SA:
+ if( PARDID->nULSpace )
+ {
+ SvxULSpaceItem aUL( GetULSpace(*pSet, PARDID->nULSpace ));
+ USHORT nSz = 0;
+ if( 0 < nTokenValue )
+ {
+ if( IsCalcValue() )
+ CalcValue();
+ nSz = USHORT(nTokenValue);
+ }
+ aUL.SetLower( nSz );
+ pSet->Put( aUL );
+ }
+ break;
+
+ case RTF_SLMULT:
+ if( PARDID->nLinespacing && 1 == nTokenValue )
+ {
+ // dann wird auf mehrzeilig umgeschaltet!
+ SvxLineSpacingItem aLSpace( GetLineSpacing( *pSet,
+ PARDID->nLinespacing, FALSE ));
+
+ // wieviel bekommt man aus dem LineHeight Wert heraus
+
+ // Proportionale-Groesse:
+ // D.H. das Verhaeltnis ergibt sich aus ( n / 240 ) Twips
+
+ nTokenValue = 240;
+ if( IsCalcValue() )
+ CalcValue();
+
+ nTokenValue = short( 100L * aLSpace.GetLineHeight()
+ / long( nTokenValue ) );
+
+ if( nTokenValue > 200 ) // Datenwert fuer PropLnSp
+ nTokenValue = 200; // ist ein BYTE !!!
+
+ aLSpace.SetPropLineSpace( (const BYTE)nTokenValue );
+ aLSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
+
+ pSet->Put( aLSpace );
+ }
+ break;
+
+ case RTF_SL:
+ if( PARDID->nLinespacing )
+ {
+ // errechne das Verhaeltnis aus dem default Font zu der
+ // Size Angabe. Der Abstand besteht aus der Zeilenhoehe
+ // (100%) und dem Leerraum ueber der Zeile (20%).
+ SvxLineSpacingItem aLSpace(0, PARDID->nLinespacing);
+
+ nTokenValue = !bTokenHasValue ? 0 : nTokenValue;
+ if (1000 == nTokenValue )
+ nTokenValue = 240;
+
+ SvxLineSpace eLnSpc;
+ if (nTokenValue < 0)
+ {
+ eLnSpc = SVX_LINE_SPACE_FIX;
+ nTokenValue = -nTokenValue;
+ }
+ else if (nTokenValue == 0)
+ {
+ //if \sl0 is used, the line spacing is automatically
+ //determined
+ eLnSpc = SVX_LINE_SPACE_AUTO;
+ }
+ else
+ eLnSpc = SVX_LINE_SPACE_MIN;
+
+ if (IsCalcValue())
+ CalcValue();
+
+ if (eLnSpc != SVX_LINE_SPACE_AUTO)
+ aLSpace.SetLineHeight( (const USHORT)nTokenValue );
+
+ aLSpace.GetLineSpaceRule() = eLnSpc;
+ pSet->Put(aLSpace);
+ }
+ break;
+
+ case RTF_NOCWRAP:
+ if( PARDID->nForbRule )
+ {
+ pSet->Put( SvxForbiddenRuleItem( FALSE,
+ PARDID->nForbRule ));
+ }
+ break;
+ case RTF_NOOVERFLOW:
+ if( PARDID->nHangPunct )
+ {
+ pSet->Put( SvxHangingPunctuationItem( FALSE,
+ PARDID->nHangPunct ));
+ }
+ break;
+
+ case RTF_ASPALPHA:
+ if( PARDID->nScriptSpace )
+ {
+ pSet->Put( SvxScriptSpaceItem( TRUE,
+ PARDID->nScriptSpace ));
+ }
+ break;
+
+ case RTF_FAFIXED:
+ case RTF_FAAUTO: nFontAlign = SvxParaVertAlignItem::AUTOMATIC;
+ goto SET_FONTALIGNMENT;
+ case RTF_FAHANG: nFontAlign = SvxParaVertAlignItem::TOP;
+ goto SET_FONTALIGNMENT;
+ case RTF_FAVAR: nFontAlign = SvxParaVertAlignItem::BOTTOM;
+ goto SET_FONTALIGNMENT;
+ case RTF_FACENTER: nFontAlign = SvxParaVertAlignItem::CENTER;
+ goto SET_FONTALIGNMENT;
+ case RTF_FAROMAN: nFontAlign = SvxParaVertAlignItem::BASELINE;
+ goto SET_FONTALIGNMENT;
+SET_FONTALIGNMENT:
+ if( PARDID->nFontAlign )
+ {
+ pSet->Put( SvxParaVertAlignItem( nFontAlign,
+ PARDID->nFontAlign ));
+ }
+ break;
+
+/* */
+ case RTF_B:
+ case RTF_AB:
+ if( IsAttrSttPos() ) // nicht im Textfluss ?
+ {
+
+ SvxWeightItem aTmpItem(
+ nTokenValue ? WEIGHT_BOLD : WEIGHT_NORMAL,
+ SID_ATTR_CHAR_WEIGHT );
+ SetScriptAttr( eCharType, *pSet, aTmpItem);
+ }
+ break;
+
+ case RTF_CAPS:
+ case RTF_SCAPS:
+ if( PLAINID->nCaseMap &&
+ IsAttrSttPos() ) // nicht im Textfluss ?
+ {
+ SvxCaseMap eCaseMap;
+ if( !nTokenValue )
+ eCaseMap = SVX_CASEMAP_NOT_MAPPED;
+ else if( RTF_CAPS == nToken )
+ eCaseMap = SVX_CASEMAP_VERSALIEN;
+ else
+ eCaseMap = SVX_CASEMAP_KAPITAELCHEN;
+
+ pSet->Put( SvxCaseMapItem( eCaseMap, PLAINID->nCaseMap ));
+ }
+ break;
+
+ case RTF_DN:
+ case RTF_SUB:
+ if( PLAINID->nEscapement )
+ {
+ const USHORT nEsc = PLAINID->nEscapement;
+ if( -1 == nTokenValue || RTF_SUB == nToken )
+ nTokenValue = 6;
+ if( IsCalcValue() )
+ CalcValue();
+ const SvxEscapementItem& rOld = GetEscapement( *pSet, nEsc, FALSE );
+ short nEs;
+ BYTE nProp;
+ if( DFLT_ESC_AUTO_SUPER == rOld.GetEsc() )
+ {
+ nEs = DFLT_ESC_AUTO_SUB;
+ nProp = rOld.GetProp();
+ }
+ else
+ {
+ nEs = (short)-nTokenValue;
+ nProp = (nToken == RTF_SUB) ? DFLT_ESC_PROP : 100;
+ }
+ pSet->Put( SvxEscapementItem( nEs, nProp, nEsc ));
+ }
+ break;
+
+ case RTF_NOSUPERSUB:
+ if( PLAINID->nEscapement )
+ {
+ const USHORT nEsc = PLAINID->nEscapement;
+ pSet->Put( SvxEscapementItem( nEsc ));
+ }
+ break;
+
+ case RTF_EXPND:
+ if( PLAINID->nKering )
+ {
+ if( -1 == nTokenValue )
+ nTokenValue = 0;
+ else
+ nTokenValue *= 5;
+ if( IsCalcValue() )
+ CalcValue();
+ pSet->Put( SvxKerningItem( (short)nTokenValue, PLAINID->nKering ));
+ }
+ break;
+
+ case RTF_KERNING:
+ if( PLAINID->nAutoKerning )
+ {
+ if( -1 == nTokenValue )
+ nTokenValue = 0;
+ else
+ nTokenValue *= 10;
+ if( IsCalcValue() )
+ CalcValue();
+ pSet->Put( SvxAutoKernItem( 0 != nTokenValue,
+ PLAINID->nAutoKerning ));
+ }
+ break;
+
+ case RTF_EXPNDTW:
+ if( PLAINID->nKering )
+ {
+ if( -1 == nTokenValue )
+ nTokenValue = 0;
+ if( IsCalcValue() )
+ CalcValue();
+ pSet->Put( SvxKerningItem( (short)nTokenValue, PLAINID->nKering ));
+ }
+ break;
+
+ case RTF_F:
+ case RTF_AF:
+ {
+ const Font& rSVFont = GetFont( USHORT(nTokenValue) );
+ SvxFontItem aTmpItem( rSVFont.GetFamily(),
+ rSVFont.GetName(), rSVFont.GetStyleName(),
+ rSVFont.GetPitch(), rSVFont.GetCharSet(),
+ SID_ATTR_CHAR_FONT );
+ SetScriptAttr( eCharType, *pSet, aTmpItem );
+ if( RTF_F == nToken )
+ {
+ SetEncoding( rSVFont.GetCharSet() );
+ RereadLookahead();
+ }
+ }
+ break;
+
+ case RTF_FS:
+ case RTF_AFS:
+ {
+ if( -1 == nTokenValue )
+ nTokenValue = 240;
+ else
+ nTokenValue *= 10;
+// #i66167#
+// for the SwRTFParser 'IsCalcValue' will be false and for the EditRTFParser
+// the converiosn takes now place in EditRTFParser since for other reasons
+// the wrong MapUnit might still be use there
+// if( IsCalcValue() )
+// CalcValue();
+ SvxFontHeightItem aTmpItem(
+ (const USHORT)nTokenValue, 100,
+ SID_ATTR_CHAR_FONTHEIGHT );
+ SetScriptAttr( eCharType, *pSet, aTmpItem );
+ }
+ break;
+
+ case RTF_I:
+ case RTF_AI:
+ if( IsAttrSttPos() ) // nicht im Textfluss ?
+ {
+ SvxPostureItem aTmpItem(
+ nTokenValue ? ITALIC_NORMAL : ITALIC_NONE,
+ SID_ATTR_CHAR_POSTURE );
+ SetScriptAttr( eCharType, *pSet, aTmpItem );
+ }
+ break;
+
+ case RTF_OUTL:
+ if( PLAINID->nContour &&
+ IsAttrSttPos() ) // nicht im Textfluss ?
+ {
+ pSet->Put( SvxContourItem( nTokenValue ? TRUE : FALSE,
+ PLAINID->nContour ));
+ }
+ break;
+
+ case RTF_SHAD:
+ if( PLAINID->nShadowed &&
+ IsAttrSttPos() ) // nicht im Textfluss ?
+ {
+ pSet->Put( SvxShadowedItem( nTokenValue ? TRUE : FALSE,
+ PLAINID->nShadowed ));
+ }
+ break;
+
+ case RTF_STRIKE:
+ if( PLAINID->nCrossedOut &&
+ IsAttrSttPos() ) // nicht im Textfluss ?
+ {
+ pSet->Put( SvxCrossedOutItem(
+ nTokenValue ? STRIKEOUT_SINGLE : STRIKEOUT_NONE,
+ PLAINID->nCrossedOut ));
+ }
+ break;
+
+ case RTF_STRIKED:
+ if( PLAINID->nCrossedOut ) // nicht im Textfluss ?
+ {
+ pSet->Put( SvxCrossedOutItem(
+ nTokenValue ? STRIKEOUT_DOUBLE : STRIKEOUT_NONE,
+ PLAINID->nCrossedOut ));
+ }
+ break;
+
+ case RTF_UL:
+ if( !IsAttrSttPos() )
+ break;
+ eUnderline = nTokenValue ? UNDERLINE_SINGLE : UNDERLINE_NONE;
+ goto ATTR_SETUNDERLINE;
+
+ case RTF_ULD:
+ eUnderline = UNDERLINE_DOTTED;
+ goto ATTR_SETUNDERLINE;
+ case RTF_ULDASH:
+ eUnderline = UNDERLINE_DASH;
+ goto ATTR_SETUNDERLINE;
+ case RTF_ULDASHD:
+ eUnderline = UNDERLINE_DASHDOT;
+ goto ATTR_SETUNDERLINE;
+ case RTF_ULDASHDD:
+ eUnderline = UNDERLINE_DASHDOTDOT;
+ goto ATTR_SETUNDERLINE;
+ case RTF_ULDB:
+ eUnderline = UNDERLINE_DOUBLE;
+ goto ATTR_SETUNDERLINE;
+ case RTF_ULNONE:
+ eUnderline = UNDERLINE_NONE;
+ goto ATTR_SETUNDERLINE;
+ case RTF_ULTH:
+ eUnderline = UNDERLINE_BOLD;
+ goto ATTR_SETUNDERLINE;
+ case RTF_ULWAVE:
+ eUnderline = UNDERLINE_WAVE;
+ goto ATTR_SETUNDERLINE;
+ case RTF_ULTHD:
+ eUnderline = UNDERLINE_BOLDDOTTED;
+ goto ATTR_SETUNDERLINE;
+ case RTF_ULTHDASH:
+ eUnderline = UNDERLINE_BOLDDASH;
+ goto ATTR_SETUNDERLINE;
+ case RTF_ULLDASH:
+ eUnderline = UNDERLINE_LONGDASH;
+ goto ATTR_SETUNDERLINE;
+ case RTF_ULTHLDASH:
+ eUnderline = UNDERLINE_BOLDLONGDASH;
+ goto ATTR_SETUNDERLINE;
+ case RTF_ULTHDASHD:
+ eUnderline = UNDERLINE_BOLDDASHDOT;
+ goto ATTR_SETUNDERLINE;
+ case RTF_ULTHDASHDD:
+ eUnderline = UNDERLINE_BOLDDASHDOTDOT;
+ goto ATTR_SETUNDERLINE;
+ case RTF_ULHWAVE:
+ eUnderline = UNDERLINE_BOLDWAVE;
+ goto ATTR_SETUNDERLINE;
+ case RTF_ULULDBWAVE:
+ eUnderline = UNDERLINE_DOUBLEWAVE;
+ goto ATTR_SETUNDERLINE;
+
+ case RTF_ULW:
+ eUnderline = UNDERLINE_SINGLE;
+
+ if( PLAINID->nWordlineMode )
+ {
+ pSet->Put( SvxWordLineModeItem( TRUE, PLAINID->nWordlineMode ));
+ }
+ goto ATTR_SETUNDERLINE;
+
+ATTR_SETUNDERLINE:
+ if( PLAINID->nUnderline )
+ {
+ pSet->Put( SvxUnderlineItem( eUnderline, PLAINID->nUnderline ));
+ }
+ break;
+
+ case RTF_ULC:
+ if( PLAINID->nUnderline )
+ {
+ SvxUnderlineItem aUL( UNDERLINE_SINGLE, PLAINID->nUnderline );
+ const SfxPoolItem* pItem;
+ if( SFX_ITEM_SET == pSet->GetItemState(
+ PLAINID->nUnderline, FALSE, &pItem ) )
+ {
+ // is switched off ?
+ if( UNDERLINE_NONE ==
+ ((SvxUnderlineItem*)pItem)->GetLineStyle() )
+ break;
+ aUL = *(SvxUnderlineItem*)pItem;
+ }
+ else
+ aUL = (const SvxUnderlineItem&)pSet->Get( PLAINID->nUnderline, FALSE );
+
+ if( UNDERLINE_NONE == aUL.GetLineStyle() )
+ aUL.SetLineStyle( UNDERLINE_SINGLE );
+ aUL.SetColor( GetColor( USHORT(nTokenValue) ));
+ pSet->Put( aUL );
+ }
+ break;
+
+ case RTF_OL:
+ if( !IsAttrSttPos() )
+ break;
+ eOverline = nTokenValue ? UNDERLINE_SINGLE : UNDERLINE_NONE;
+ goto ATTR_SETOVERLINE;
+
+ case RTF_OLD:
+ eOverline = UNDERLINE_DOTTED;
+ goto ATTR_SETOVERLINE;
+ case RTF_OLDASH:
+ eOverline = UNDERLINE_DASH;
+ goto ATTR_SETOVERLINE;
+ case RTF_OLDASHD:
+ eOverline = UNDERLINE_DASHDOT;
+ goto ATTR_SETOVERLINE;
+ case RTF_OLDASHDD:
+ eOverline = UNDERLINE_DASHDOTDOT;
+ goto ATTR_SETOVERLINE;
+ case RTF_OLDB:
+ eOverline = UNDERLINE_DOUBLE;
+ goto ATTR_SETOVERLINE;
+ case RTF_OLNONE:
+ eOverline = UNDERLINE_NONE;
+ goto ATTR_SETOVERLINE;
+ case RTF_OLTH:
+ eOverline = UNDERLINE_BOLD;
+ goto ATTR_SETOVERLINE;
+ case RTF_OLWAVE:
+ eOverline = UNDERLINE_WAVE;
+ goto ATTR_SETOVERLINE;
+ case RTF_OLTHD:
+ eOverline = UNDERLINE_BOLDDOTTED;
+ goto ATTR_SETOVERLINE;
+ case RTF_OLTHDASH:
+ eOverline = UNDERLINE_BOLDDASH;
+ goto ATTR_SETOVERLINE;
+ case RTF_OLLDASH:
+ eOverline = UNDERLINE_LONGDASH;
+ goto ATTR_SETOVERLINE;
+ case RTF_OLTHLDASH:
+ eOverline = UNDERLINE_BOLDLONGDASH;
+ goto ATTR_SETOVERLINE;
+ case RTF_OLTHDASHD:
+ eOverline = UNDERLINE_BOLDDASHDOT;
+ goto ATTR_SETOVERLINE;
+ case RTF_OLTHDASHDD:
+ eOverline = UNDERLINE_BOLDDASHDOTDOT;
+ goto ATTR_SETOVERLINE;
+ case RTF_OLHWAVE:
+ eOverline = UNDERLINE_BOLDWAVE;
+ goto ATTR_SETOVERLINE;
+ case RTF_OLOLDBWAVE:
+ eOverline = UNDERLINE_DOUBLEWAVE;
+ goto ATTR_SETOVERLINE;
+
+ case RTF_OLW:
+ eOverline = UNDERLINE_SINGLE;
+
+ if( PLAINID->nWordlineMode )
+ {
+ pSet->Put( SvxWordLineModeItem( TRUE, PLAINID->nWordlineMode ));
+ }
+ goto ATTR_SETOVERLINE;
+
+ATTR_SETOVERLINE:
+ if( PLAINID->nUnderline )
+ {
+ pSet->Put( SvxOverlineItem( eOverline, PLAINID->nOverline ));
+ }
+ break;
+
+ case RTF_OLC:
+ if( PLAINID->nOverline )
+ {
+ SvxOverlineItem aOL( UNDERLINE_SINGLE, PLAINID->nOverline );
+ const SfxPoolItem* pItem;
+ if( SFX_ITEM_SET == pSet->GetItemState(
+ PLAINID->nOverline, FALSE, &pItem ) )
+ {
+ // is switched off ?
+ if( UNDERLINE_NONE ==
+ ((SvxOverlineItem*)pItem)->GetLineStyle() )
+ break;
+ aOL = *(SvxOverlineItem*)pItem;
+ }
+ else
+ aOL = (const SvxOverlineItem&)pSet->Get( PLAINID->nUnderline, FALSE );
+
+ if( UNDERLINE_NONE == aOL.GetLineStyle() )
+ aOL.SetLineStyle( UNDERLINE_SINGLE );
+ aOL.SetColor( GetColor( USHORT(nTokenValue) ));
+ pSet->Put( aOL );
+ }
+ break;
+
+ case RTF_UP:
+ case RTF_SUPER:
+ if( PLAINID->nEscapement )
+ {
+ const USHORT nEsc = PLAINID->nEscapement;
+ if( -1 == nTokenValue || RTF_SUPER == nToken )
+ nTokenValue = 6;
+ if( IsCalcValue() )
+ CalcValue();
+ const SvxEscapementItem& rOld = GetEscapement( *pSet, nEsc, FALSE );
+ short nEs;
+ BYTE nProp;
+ if( DFLT_ESC_AUTO_SUB == rOld.GetEsc() )
+ {
+ nEs = DFLT_ESC_AUTO_SUPER;
+ nProp = rOld.GetProp();
+ }
+ else
+ {
+ nEs = (short)nTokenValue;
+ nProp = (nToken == RTF_SUPER) ? DFLT_ESC_PROP : 100;
+ }
+ pSet->Put( SvxEscapementItem( nEs, nProp, nEsc ));
+ }
+ break;
+
+ case RTF_CF:
+ if( PLAINID->nColor )
+ {
+ pSet->Put( SvxColorItem( GetColor( USHORT(nTokenValue) ),
+ PLAINID->nColor ));
+ }
+ break;
+#if 0
+ //#i12501# While cb is clearly documented in the rtf spec, word
+ //doesn't accept it at all
+ case RTF_CB:
+ if( PLAINID->nBgColor )
+ {
+ pSet->Put( SvxBrushItem( GetColor( USHORT(nTokenValue) ),
+ PLAINID->nBgColor ));
+ }
+ break;
+#endif
+ case RTF_LANG:
+ if( PLAINID->nLanguage )
+ {
+ pSet->Put( SvxLanguageItem( (LanguageType)nTokenValue,
+ PLAINID->nLanguage ));
+ }
+ break;
+
+ case RTF_LANGFE:
+ if( PLAINID->nCJKLanguage )
+ {
+ pSet->Put( SvxLanguageItem( (LanguageType)nTokenValue,
+ PLAINID->nCJKLanguage ));
+ }
+ break;
+ case RTF_ALANG:
+ {
+ SvxLanguageItem aTmpItem( (LanguageType)nTokenValue,
+ SID_ATTR_CHAR_LANGUAGE );
+ SetScriptAttr( eCharType, *pSet, aTmpItem );
+ }
+ break;
+
+ case RTF_RTLCH:
+ bIsLeftToRightDef = FALSE;
+ break;
+ case RTF_LTRCH:
+ bIsLeftToRightDef = TRUE;
+ break;
+ case RTF_RTLPAR:
+ if (PARDID->nDirection)
+ {
+ pSet->Put(SvxFrameDirectionItem(FRMDIR_HORI_RIGHT_TOP,
+ PARDID->nDirection));
+ }
+ break;
+ case RTF_LTRPAR:
+ if (PARDID->nDirection)
+ {
+ pSet->Put(SvxFrameDirectionItem(FRMDIR_HORI_LEFT_TOP,
+ PARDID->nDirection));
+ }
+ break;
+ case RTF_LOCH: eCharType = LOW_CHARTYPE; break;
+ case RTF_HICH: eCharType = HIGH_CHARTYPE; break;
+ case RTF_DBCH: eCharType = DOUBLEBYTE_CHARTYPE; break;
+
+
+ case RTF_ACCNONE:
+ eEmphasis = EMPHASISMARK_NONE;
+ goto ATTR_SETEMPHASIS;
+ case RTF_ACCDOT:
+ eEmphasis = EMPHASISMARK_DOTS_ABOVE;
+ goto ATTR_SETEMPHASIS;
+
+ case RTF_ACCCOMMA:
+ eEmphasis = EMPHASISMARK_SIDE_DOTS;
+ATTR_SETEMPHASIS:
+ if( PLAINID->nEmphasis )
+ {
+ pSet->Put( SvxEmphasisMarkItem( eEmphasis,
+ PLAINID->nEmphasis ));
+ }
+ break;
+
+ case RTF_TWOINONE:
+ if( PLAINID->nTwoLines )
+ {
+ sal_Unicode cStt, cEnd;
+ switch ( nTokenValue )
+ {
+ case 1: cStt = '(', cEnd = ')'; break;
+ case 2: cStt = '[', cEnd = ']'; break;
+ case 3: cStt = '<', cEnd = '>'; break;
+ case 4: cStt = '{', cEnd = '}'; break;
+ default: cStt = 0, cEnd = 0; break;
+ }
+
+ pSet->Put( SvxTwoLinesItem( TRUE, cStt, cEnd,
+ PLAINID->nTwoLines ));
+ }
+ break;
+
+ case RTF_CHARSCALEX :
+ if (PLAINID->nCharScaleX)
+ {
+ //i21372
+ if (nTokenValue < 1 || nTokenValue > 600)
+ nTokenValue = 100;
+ pSet->Put( SvxCharScaleWidthItem( USHORT(nTokenValue),
+ PLAINID->nCharScaleX ));
+ }
+ break;
+
+ case RTF_HORZVERT:
+ if( PLAINID->nHorzVert )
+ {
+ // RTF knows only 90deg
+ pSet->Put( SvxCharRotateItem( 900, 1 == nTokenValue,
+ PLAINID->nHorzVert ));
+ }
+ break;
+
+ case RTF_EMBO:
+ if (PLAINID->nRelief)
+ {
+ pSet->Put(SvxCharReliefItem(RELIEF_EMBOSSED,
+ PLAINID->nRelief));
+ }
+ break;
+ case RTF_IMPR:
+ if (PLAINID->nRelief)
+ {
+ pSet->Put(SvxCharReliefItem(RELIEF_ENGRAVED,
+ PLAINID->nRelief));
+ }
+ break;
+ case RTF_V:
+ if (PLAINID->nHidden)
+ {
+ pSet->Put(SvxCharHiddenItem(nTokenValue != 0,
+ PLAINID->nHidden));
+ }
+ break;
+ case RTF_CHBGFDIAG:
+ case RTF_CHBGDKVERT:
+ case RTF_CHBGDKHORIZ:
+ case RTF_CHBGVERT:
+ case RTF_CHBGHORIZ:
+ case RTF_CHBGDKFDIAG:
+ case RTF_CHBGDCROSS:
+ case RTF_CHBGCROSS:
+ case RTF_CHBGBDIAG:
+ case RTF_CHBGDKDCROSS:
+ case RTF_CHBGDKCROSS:
+ case RTF_CHBGDKBDIAG:
+ case RTF_CHCBPAT:
+ case RTF_CHCFPAT:
+ case RTF_CHSHDNG:
+ if( PLAINID->nBgColor )
+ ReadBackgroundAttr( nToken, *pSet );
+ break;
+
+
+/* */
+
+ case BRACELEFT:
+ {
+ // teste auf Swg-Interne Tokens
+ bool bHandled = false;
+ short nSkip = 0;
+ if( RTF_IGNOREFLAG != GetNextToken())
+ nSkip = -1;
+ else if( (nToken = GetNextToken() ) & RTF_SWGDEFS )
+ {
+ bHandled = true;
+ switch( nToken )
+ {
+ case RTF_PGDSCNO:
+ case RTF_PGBRK:
+ case RTF_SOUTLVL:
+ UnknownAttrToken( nToken, pSet );
+ // ueberlese die schliessende Klammer
+ break;
+
+ case RTF_SWG_ESCPROP:
+ {
+ // prozentuale Veraenderung speichern !
+ BYTE nProp = BYTE( nTokenValue / 100 );
+ short nEsc = 0;
+ if( 1 == ( nTokenValue % 100 ))
+ // Erkennung unseres AutoFlags!
+ nEsc = DFLT_ESC_AUTO_SUPER;
+
+ if( PLAINID->nEscapement )
+ pSet->Put( SvxEscapementItem( nEsc, nProp,
+ PLAINID->nEscapement ));
+ }
+ break;
+
+ case RTF_HYPHEN:
+ {
+ SvxHyphenZoneItem aHypenZone(
+ (nTokenValue & 1) ? TRUE : FALSE,
+ PARDID->nHyphenzone );
+ aHypenZone.SetPageEnd(
+ (nTokenValue & 2) ? TRUE : FALSE );
+
+ if( PARDID->nHyphenzone &&
+ RTF_HYPHLEAD == GetNextToken() &&
+ RTF_HYPHTRAIL == GetNextToken() &&
+ RTF_HYPHMAX == GetNextToken() )
+ {
+ aHypenZone.GetMinLead() =
+ BYTE(GetStackPtr( -2 )->nTokenValue);
+ aHypenZone.GetMinTrail() =
+ BYTE(GetStackPtr( -1 )->nTokenValue);
+ aHypenZone.GetMaxHyphens() =
+ BYTE(nTokenValue);
+
+ pSet->Put( aHypenZone );
+ }
+ else
+ SkipGroup(); // ans Ende der Gruppe
+ }
+ break;
+
+ case RTF_SHADOW:
+ {
+ int bSkip = TRUE;
+ do { // middle check loop
+ SvxShadowLocation eSL = SvxShadowLocation( nTokenValue );
+ if( RTF_SHDW_DIST != GetNextToken() )
+ break;
+ USHORT nDist = USHORT( nTokenValue );
+
+ if( RTF_SHDW_STYLE != GetNextToken() )
+ break;
+ //! (pb) class Brush removed -> obsolete
+ //! BrushStyle eStyle = BrushStyle( nTokenValue );
+
+ if( RTF_SHDW_COL != GetNextToken() )
+ break;
+ USHORT nCol = USHORT( nTokenValue );
+
+ if( RTF_SHDW_FCOL != GetNextToken() )
+ break;
+// USHORT nFillCol = USHORT( nTokenValue );
+
+ Color aColor = GetColor( nCol );
+
+ if( PARDID->nShadow )
+ pSet->Put( SvxShadowItem( PARDID->nShadow,
+ &aColor, nDist, eSL ) );
+
+ bSkip = FALSE;
+ } while( FALSE );
+
+ if( bSkip )
+ SkipGroup(); // ans Ende der Gruppe
+ }
+ break;
+
+ default:
+ bHandled = false;
+ if( (nToken & ~(0xff | RTF_SWGDEFS)) == RTF_TABSTOPDEF )
+ {
+ nToken = SkipToken( -2 );
+ ReadTabAttr( nToken, *pSet );
+
+ /*
+ cmc: #i76140, he who consumed the { must consume the }
+ We rewound to a state of { being the current
+ token so it is our responsibility to consume the }
+ token if we consumed the {. We will not have consumed
+ the { if it belonged to our caller, i.e. if the { we
+ are handling is the "firsttoken" passed to us then
+ the *caller* must consume it, not us. Otherwise *we*
+ should consume it.
+ */
+ if (nToken == BRACELEFT && !bFirstToken)
+ {
+ nToken = GetNextToken();
+ DBG_ASSERT( nToken == BRACERIGHT,
+ "} did not follow { as expected\n");
+ }
+ }
+ else if( (nToken & ~(0xff| RTF_SWGDEFS)) == RTF_BRDRDEF)
+ {
+ nToken = SkipToken( -2 );
+ ReadBorderAttr( nToken, *pSet );
+ }
+ else // also kein Attribut mehr
+ nSkip = -2;
+ break;
+ }
+
+#if 1
+ /*
+ cmc: #i4727# / #i12713# Who owns this closing bracket?
+ If we read the opening one, we must read this one, if
+ other is counting the brackets so as to push/pop off
+ the correct environment then we will have pushed a new
+ environment for the start { of this, but will not see
+ the } and so is out of sync for the rest of the
+ document.
+ */
+ if (bHandled && !bFirstToken)
+ GetNextToken();
+#endif
+ }
+ else
+ nSkip = -2;
+
+ if( nSkip ) // alles voellig unbekannt
+ {
+ if (!bFirstToken)
+ --nSkip; // BRACELEFT: ist das naechste Token
+ SkipToken( nSkip );
+ bWeiter = FALSE;
+ }
+ }
+ break;
+ default:
+ if( (nToken & ~0xff ) == RTF_TABSTOPDEF )
+ ReadTabAttr( nToken, *pSet );
+ else if( (nToken & ~0xff ) == RTF_BRDRDEF )
+ ReadBorderAttr( nToken, *pSet );
+ else if( (nToken & ~0xff ) == RTF_SHADINGDEF )
+ ReadBackgroundAttr( nToken, *pSet );
+ else
+ {
+ // kenne das Token nicht also das Token "in den Parser zurueck"
+ if( !bFirstToken )
+ SkipToken( -1 );
+ bWeiter = FALSE;
+ }
+ }
+ }
+ if( bWeiter )
+ {
+ nToken = GetNextToken();
+ }
+ bFirstToken = FALSE;
+ }
+
+/*
+ // teste Attribute gegen ihre Styles
+ if( IsChkStyleAttr() && pSet->Count() && !pInsPos->GetCntIdx() )
+ {
+ SvxRTFStyleType* pStyle = aStyleTbl.Get( nStyleNo );
+ if( pStyle && pStyle->aAttrSet.Count() )
+ {
+ // alle Attribute, die schon vom Style definiert sind, aus dem
+ // akt. Set entfernen
+ const SfxPoolItem* pItem;
+ SfxItemIter aIter( *pSet );
+ USHORT nWhich = aIter.GetCurItem()->Which();
+ while( TRUE )
+ {
+ if( SFX_ITEM_SET == pStyle->aAttrSet.GetItemState(
+ nWhich, FALSE, &pItem ) && *pItem == *aIter.GetCurItem())
+ pSet->ClearItem( nWhich ); // loeschen
+
+ if( aIter.IsAtEnd() )
+ break;
+ nWhich = aIter.NextItem()->Which();
+ }
+ }
+ }
+*/
+}
+
+void SvxRTFParser::ReadTabAttr( int nToken, SfxItemSet& rSet )
+{
+ bool bMethodOwnsToken = false; // #i52542# patch from cmc.
+// dann lese doch mal alle TabStops ein
+ SvxTabStop aTabStop;
+ SvxTabStopItem aAttr( 0, 0, SVX_TAB_ADJUST_DEFAULT, PARDID->nTabStop );
+ int bWeiter = TRUE;
+ do {
+ switch( nToken )
+ {
+ case RTF_TB: // BarTab ???
+ case RTF_TX:
+ {
+ if( IsCalcValue() )
+ CalcValue();
+ aTabStop.GetTabPos() = nTokenValue;
+ aAttr.Insert( aTabStop );
+ aTabStop = SvxTabStop(); // alle Werte default
+ }
+ break;
+
+ case RTF_TQL:
+ aTabStop.GetAdjustment() = SVX_TAB_ADJUST_LEFT;
+ break;
+ case RTF_TQR:
+ aTabStop.GetAdjustment() = SVX_TAB_ADJUST_RIGHT;
+ break;
+ case RTF_TQC:
+ aTabStop.GetAdjustment() = SVX_TAB_ADJUST_CENTER;
+ break;
+ case RTF_TQDEC:
+ aTabStop.GetAdjustment() = SVX_TAB_ADJUST_DECIMAL;
+ break;
+
+ case RTF_TLDOT: aTabStop.GetFill() = '.'; break;
+ case RTF_TLHYPH: aTabStop.GetFill() = ' '; break;
+ case RTF_TLUL: aTabStop.GetFill() = '_'; break;
+ case RTF_TLTH: aTabStop.GetFill() = '-'; break;
+ case RTF_TLEQ: aTabStop.GetFill() = '='; break;
+
+ case BRACELEFT:
+ {
+ // Swg - Kontrol BRACELEFT RTF_IGNOREFLAG RTF_TLSWG BRACERIGHT
+ short nSkip = 0;
+ if( RTF_IGNOREFLAG != GetNextToken() )
+ nSkip = -1;
+ else if( RTF_TLSWG != ( nToken = GetNextToken() ))
+ nSkip = -2;
+ else
+ {
+ aTabStop.GetDecimal() = BYTE(nTokenValue & 0xff);
+ aTabStop.GetFill() = BYTE((nTokenValue >> 8) & 0xff);
+ // ueberlese noch die schliessende Klammer
+ if (bMethodOwnsToken)
+ GetNextToken();
+ }
+ if( nSkip )
+ {
+ SkipToken( nSkip ); // Ignore wieder zurueck
+ bWeiter = FALSE;
+ }
+ }
+ break;
+
+ default:
+ bWeiter = FALSE;
+ }
+ if( bWeiter )
+ {
+ nToken = GetNextToken();
+ bMethodOwnsToken = true;
+ }
+ } while( bWeiter );
+
+ // mit Defaults aufuellen fehlt noch !!!
+ rSet.Put( aAttr );
+ SkipToken( -1 );
+}
+
+static void SetBorderLine( int nBorderTyp, SvxBoxItem& rItem,
+ const SvxBorderLine& rBorder )
+{
+ switch( nBorderTyp )
+ {
+ case RTF_BOX: // alle Stufen durchlaufen
+
+ case RTF_BRDRT:
+ rItem.SetLine( &rBorder, BOX_LINE_TOP );
+ if( RTF_BOX != nBorderTyp )
+ return;
+
+ case RTF_BRDRB:
+ rItem.SetLine( &rBorder, BOX_LINE_BOTTOM );
+ if( RTF_BOX != nBorderTyp )
+ return;
+
+ case RTF_BRDRL:
+ rItem.SetLine( &rBorder, BOX_LINE_LEFT );
+ if( RTF_BOX != nBorderTyp )
+ return;
+
+ case RTF_BRDRR:
+ rItem.SetLine( &rBorder, BOX_LINE_RIGHT );
+ if( RTF_BOX != nBorderTyp )
+ return;
+ }
+}
+
+void SvxRTFParser::ReadBorderAttr( int nToken, SfxItemSet& rSet,
+ int bTableDef )
+{
+ // dann lese doch mal das BoderAttribut ein
+ SvxBoxItem aAttr( PARDID->nBox );
+ const SfxPoolItem* pItem;
+ if( SFX_ITEM_SET == rSet.GetItemState( PARDID->nBox, FALSE, &pItem ) )
+ aAttr = *(SvxBoxItem*)pItem;
+
+ SvxBorderLine aBrd( 0, DEF_LINE_WIDTH_0, 0, 0 ); // einfache Linien
+ int bWeiter = TRUE, nBorderTyp = 0;
+
+ do {
+ switch( nToken )
+ {
+ case RTF_BOX:
+ case RTF_BRDRT:
+ case RTF_BRDRB:
+ case RTF_BRDRL:
+ case RTF_BRDRR:
+ nBorderTyp = nToken;
+ goto SETBORDER;
+
+ case RTF_CLBRDRT:
+ if( !bTableDef )
+ break;
+ nBorderTyp = RTF_BRDRT;
+ goto SETBORDER;
+ case RTF_CLBRDRB:
+ if( !bTableDef )
+ break;
+ nBorderTyp = RTF_BRDRB;
+ goto SETBORDER;
+ case RTF_CLBRDRL:
+ if( !bTableDef )
+ break;
+ nBorderTyp = RTF_BRDRL;
+ goto SETBORDER;
+ case RTF_CLBRDRR:
+ if( !bTableDef )
+ break;
+ nBorderTyp = RTF_BRDRR;
+ goto SETBORDER;
+
+SETBORDER:
+ {
+ // auf defaults setzen
+ aBrd.SetOutWidth( DEF_LINE_WIDTH_0 );
+ aBrd.SetInWidth( 0 );
+ aBrd.SetDistance( 0 );
+ aBrd.SetColor( Color( COL_BLACK ) );
+ }
+ break;
+
+
+// werden noch nicht ausgewertet
+ case RTF_BRSP:
+ {
+ switch( nBorderTyp )
+ {
+ case RTF_BRDRB:
+ aAttr.SetDistance( (USHORT)nTokenValue, BOX_LINE_BOTTOM );
+ break;
+
+ case RTF_BRDRT:
+ aAttr.SetDistance( (USHORT)nTokenValue, BOX_LINE_TOP );
+ break;
+
+ case RTF_BRDRL:
+ aAttr.SetDistance( (USHORT)nTokenValue, BOX_LINE_LEFT );
+ break;
+
+ case RTF_BRDRR:
+ aAttr.SetDistance( (USHORT)nTokenValue, BOX_LINE_RIGHT );
+ break;
+
+ case RTF_BOX:
+ aAttr.SetDistance( (USHORT)nTokenValue );
+ break;
+ }
+ }
+ break;
+
+case RTF_BRDRBTW:
+case RTF_BRDRBAR: break;
+
+
+ case RTF_BRDRCF:
+ {
+ aBrd.SetColor( GetColor( USHORT(nTokenValue) ) );
+ SetBorderLine( nBorderTyp, aAttr, aBrd );
+ }
+ break;
+
+ case RTF_BRDRTH:
+ aBrd.SetOutWidth( DEF_LINE_WIDTH_1 );
+ aBrd.SetInWidth( 0 );
+ aBrd.SetDistance( 0 );
+ goto SETBORDERLINE;
+
+ case RTF_BRDRDB:
+ aBrd.SetOutWidth( DEF_DOUBLE_LINE0_OUT );
+ aBrd.SetInWidth( DEF_DOUBLE_LINE0_IN );
+ aBrd.SetDistance( DEF_DOUBLE_LINE0_DIST );
+ goto SETBORDERLINE;
+
+ case RTF_BRDRSH:
+ // schattierte Box
+ {
+ rSet.Put( SvxShadowItem( PARDID->nShadow, (Color*) 0, 60 /*3pt*/,
+ SVX_SHADOW_BOTTOMRIGHT ) );
+ }
+ break;
+
+ case RTF_BRDRW:
+ if( -1 != nTokenValue )
+ {
+ // sollte es eine "dicke" Linie sein ?
+ if( DEF_LINE_WIDTH_0 != aBrd.GetOutWidth() )
+ nTokenValue *= 2;
+
+ // eine Doppelline?
+ if( aBrd.GetInWidth() )
+ {
+ // WinWord - Werte an StarOffice anpassen
+ if( nTokenValue < DEF_LINE_WIDTH_1 - (DEF_LINE_WIDTH_1/10))
+ {
+ aBrd.SetOutWidth( DEF_DOUBLE_LINE0_OUT );
+ aBrd.SetInWidth( DEF_DOUBLE_LINE0_IN );
+ aBrd.SetDistance( DEF_DOUBLE_LINE0_DIST );
+ }
+ else
+ if( nTokenValue < DEF_LINE_WIDTH_2 - (DEF_LINE_WIDTH_2/10))
+ {
+ aBrd.SetOutWidth( DEF_DOUBLE_LINE1_OUT );
+ aBrd.SetInWidth( DEF_DOUBLE_LINE1_IN );
+ aBrd.SetDistance( DEF_DOUBLE_LINE1_DIST );
+ }
+ else
+ {
+ aBrd.SetOutWidth( DEF_DOUBLE_LINE2_OUT );
+ aBrd.SetInWidth( DEF_DOUBLE_LINE2_IN );
+ aBrd.SetDistance( DEF_DOUBLE_LINE2_DIST );
+ }
+ }
+ else
+ {
+ // WinWord - Werte an StarOffice anpassen
+ if( nTokenValue < DEF_LINE_WIDTH_1 - (DEF_LINE_WIDTH_1/10))
+ aBrd.SetOutWidth( DEF_LINE_WIDTH_0 );
+ else
+ if( nTokenValue < DEF_LINE_WIDTH_2 - (DEF_LINE_WIDTH_2/10))
+ aBrd.SetOutWidth( DEF_LINE_WIDTH_1 );
+ else
+ if( nTokenValue < DEF_LINE_WIDTH_3 - (DEF_LINE_WIDTH_3/10))
+ aBrd.SetOutWidth( DEF_LINE_WIDTH_2 );
+ else
+ if( nTokenValue < DEF_LINE_WIDTH_4 )
+ aBrd.SetOutWidth( DEF_LINE_WIDTH_3 );
+ else
+ aBrd.SetOutWidth( DEF_LINE_WIDTH_4 );
+ }
+ }
+ goto SETBORDERLINE;
+
+ case RTF_BRDRS:
+ case RTF_BRDRDOT:
+ case RTF_BRDRHAIR:
+ case RTF_BRDRDASH:
+SETBORDERLINE:
+ SetBorderLine( nBorderTyp, aAttr, aBrd );
+ break;
+
+ case BRACELEFT:
+ {
+ short nSkip = 0;
+ if( RTF_IGNOREFLAG != GetNextToken() )
+ nSkip = -1;
+ else
+ {
+ int bSwgControl = TRUE, bFirstToken = TRUE;
+ nToken = GetNextToken();
+ do {
+ switch( nToken )
+ {
+ case RTF_BRDBOX:
+ aAttr.SetDistance( USHORT(nTokenValue) );
+ break;
+
+ case RTF_BRDRT:
+ case RTF_BRDRB:
+ case RTF_BRDRR:
+ case RTF_BRDRL:
+ nBorderTyp = nToken;
+ bFirstToken = FALSE;
+ if( RTF_BRDLINE_COL != GetNextToken() )
+ {
+ bSwgControl = FALSE;
+ break;
+ }
+ aBrd.SetColor( GetColor( USHORT(nTokenValue) ));
+
+ if( RTF_BRDLINE_IN != GetNextToken() )
+ {
+ bSwgControl = FALSE;
+ break;
+ }
+ aBrd.SetInWidth( USHORT(nTokenValue));
+
+ if( RTF_BRDLINE_OUT != GetNextToken() )
+ {
+ bSwgControl = FALSE;
+ break;
+ }
+ aBrd.SetOutWidth( USHORT(nTokenValue));
+
+ if( RTF_BRDLINE_DIST != GetNextToken() )
+ {
+ bSwgControl = FALSE;
+ break;
+ }
+ aBrd.SetDistance( USHORT(nTokenValue));
+ SetBorderLine( nBorderTyp, aAttr, aBrd );
+ break;
+
+ default:
+ bSwgControl = FALSE;
+ break;
+ }
+
+ if( bSwgControl )
+ {
+ nToken = GetNextToken();
+ bFirstToken = FALSE;
+ }
+ } while( bSwgControl );
+
+ // Ende der Swg-Gruppe
+ // -> lese noch die schliessende Klammer
+ if( BRACERIGHT == nToken )
+ ;
+ else if( !bFirstToken )
+ {
+ // es ist ein Parser-Fehler, springe zum
+ // Ende der Gruppe
+ SkipGroup();
+ // schliessende BRACERIGHT ueberspringen
+ GetNextToken();
+ }
+ else
+ nSkip = -2;
+ }
+
+ if( nSkip )
+ {
+ SkipToken( nSkip ); // Ignore wieder zurueck
+ bWeiter = FALSE;
+ }
+ }
+ break;
+
+ default:
+ bWeiter = (nToken & ~(0xff| RTF_SWGDEFS)) == RTF_BRDRDEF;
+ }
+ if( bWeiter )
+ nToken = GetNextToken();
+ } while( bWeiter );
+ rSet.Put( aAttr );
+ SkipToken( -1 );
+}
+
+inline ULONG CalcShading( ULONG nColor, ULONG nFillColor, BYTE nShading )
+{
+ nColor = (nColor * nShading) / 100;
+ nFillColor = (nFillColor * ( 100 - nShading )) / 100;
+ return nColor + nFillColor;
+}
+
+void SvxRTFParser::ReadBackgroundAttr( int nToken, SfxItemSet& rSet,
+ int bTableDef )
+{
+ // dann lese doch mal das BoderAttribut ein
+ int bWeiter = TRUE;
+ USHORT nColor = USHRT_MAX, nFillColor = USHRT_MAX;
+ BYTE nFillValue = 0;
+
+ USHORT nWh = ( nToken & ~0xff ) == RTF_CHRFMT
+ ? PLAINID->nBgColor
+ : PARDID->nBrush;
+
+ do {
+ switch( nToken )
+ {
+ case RTF_CLCBPAT:
+ case RTF_CHCBPAT:
+ case RTF_CBPAT:
+ nFillColor = USHORT( nTokenValue );
+ break;
+
+ case RTF_CLCFPAT:
+ case RTF_CHCFPAT:
+ case RTF_CFPAT:
+ nColor = USHORT( nTokenValue );
+ break;
+
+ case RTF_CLSHDNG:
+ case RTF_CHSHDNG:
+ case RTF_SHADING:
+ nFillValue = (BYTE)( nTokenValue / 100 );
+ break;
+
+ case RTF_CLBGDKHOR:
+ case RTF_CHBGDKHORIZ:
+ case RTF_BGDKHORIZ:
+ case RTF_CLBGDKVERT:
+ case RTF_CHBGDKVERT:
+ case RTF_BGDKVERT:
+ case RTF_CLBGDKBDIAG:
+ case RTF_CHBGDKBDIAG:
+ case RTF_BGDKBDIAG:
+ case RTF_CLBGDKFDIAG:
+ case RTF_CHBGDKFDIAG:
+ case RTF_BGDKFDIAG:
+ case RTF_CLBGDKCROSS:
+ case RTF_CHBGDKCROSS:
+ case RTF_BGDKCROSS:
+ case RTF_CLBGDKDCROSS:
+ case RTF_CHBGDKDCROSS:
+ case RTF_BGDKDCROSS:
+ // dark -> 60%
+ nFillValue = 60;
+ break;
+
+ case RTF_CLBGHORIZ:
+ case RTF_CHBGHORIZ:
+ case RTF_BGHORIZ:
+ case RTF_CLBGVERT:
+ case RTF_CHBGVERT:
+ case RTF_BGVERT:
+ case RTF_CLBGBDIAG:
+ case RTF_CHBGBDIAG:
+ case RTF_BGBDIAG:
+ case RTF_CLBGFDIAG:
+ case RTF_CHBGFDIAG:
+ case RTF_BGFDIAG:
+ case RTF_CLBGCROSS:
+ case RTF_CHBGCROSS:
+ case RTF_BGCROSS:
+ case RTF_CLBGDCROSS:
+ case RTF_CHBGDCROSS:
+ case RTF_BGDCROSS:
+ // light -> 20%
+ nFillValue = 20;
+ break;
+
+ default:
+ if( bTableDef )
+ bWeiter = (nToken & ~(0xff | RTF_TABLEDEF) ) == RTF_SHADINGDEF;
+ else
+ bWeiter = (nToken & ~0xff) == RTF_SHADINGDEF;
+ }
+ if( bWeiter )
+ nToken = GetNextToken();
+ } while( bWeiter );
+
+ Color aCol( COL_WHITE ), aFCol;
+ if( !nFillValue )
+ {
+ // es wurde nur eine von beiden Farben angegeben oder kein BrushTyp
+ if( USHRT_MAX != nFillColor )
+ {
+ nFillValue = 100;
+ aCol = GetColor( nFillColor );
+ }
+ else if( USHRT_MAX != nColor )
+ aFCol = GetColor( nColor );
+ }
+ else
+ {
+ if( USHRT_MAX != nColor )
+ aCol = GetColor( nColor );
+ else
+ aCol = Color( COL_BLACK );
+
+ if( USHRT_MAX != nFillColor )
+ aFCol = GetColor( nFillColor );
+ else
+ aFCol = Color( COL_WHITE );
+ }
+
+ Color aColor;
+ if( 0 == nFillValue || 100 == nFillValue )
+ aColor = aCol;
+ else
+ aColor = Color(
+ (BYTE)CalcShading( aCol.GetRed(), aFCol.GetRed(), nFillValue ),
+ (BYTE)CalcShading( aCol.GetGreen(), aFCol.GetGreen(), nFillValue ),
+ (BYTE)CalcShading( aCol.GetBlue(), aFCol.GetBlue(), nFillValue ) );
+
+ rSet.Put( SvxBrushItem( aColor, nWh ) );
+ SkipToken( -1 );
+}
+
+
+// pard / plain abarbeiten
+void SvxRTFParser::RTFPardPlain( int bPard, SfxItemSet** ppSet )
+{
+ if( !bNewGroup && aAttrStack.Top() ) // nicht am Anfang einer neuen Gruppe
+ {
+ SvxRTFItemStackType* pAkt = aAttrStack.Top();
+
+ int nLastToken = GetStackPtr(-1)->nTokenId;
+ int bNewStkEntry = TRUE;
+ if( RTF_PARD != nLastToken &&
+ RTF_PLAIN != nLastToken &&
+ BRACELEFT != nLastToken )
+ {
+ if( pAkt->aAttrSet.Count() || pAkt->pChildList || pAkt->nStyleNo )
+ {
+ // eine neue Gruppe aufmachen
+ SvxRTFItemStackType* pNew = new SvxRTFItemStackType( *pAkt, *pInsPos, TRUE );
+ pNew->SetRTFDefaults( GetRTFDefaults() );
+
+ // alle bis hierher gueltigen Attribute "setzen"
+ AttrGroupEnd();
+ pAkt = aAttrStack.Top(); // can be changed after AttrGroupEnd!
+ pNew->aAttrSet.SetParent( pAkt ? &pAkt->aAttrSet : 0 );
+ aAttrStack.Push( pNew );
+ pAkt = pNew;
+ }
+ else
+ {
+ // diesen Eintrag als neuen weiterbenutzen
+ pAkt->SetStartPos( *pInsPos );
+ bNewStkEntry = FALSE;
+ }
+ }
+
+ // jetzt noch alle auf default zuruecksetzen
+ if( bNewStkEntry &&
+ ( pAkt->aAttrSet.GetParent() || pAkt->aAttrSet.Count() ))
+ {
+ const SfxPoolItem *pItem, *pDef;
+ const USHORT* pPtr;
+ USHORT nCnt;
+ const SfxItemSet* pDfltSet = &GetRTFDefaults();
+ if( bPard )
+ {
+ pAkt->nStyleNo = 0;
+ pPtr = aPardMap.GetData();
+ nCnt = aPardMap.Count();
+ }
+ else
+ {
+ pPtr = aPlainMap.GetData();
+ nCnt = aPlainMap.Count();
+ }
+
+ for( USHORT n = 0; n < nCnt; ++n, ++pPtr )
+ {
+ // Item gesetzt und unterschiedlich -> das Pooldefault setzen
+ //JP 06.04.98: bei Items die nur SlotItems sind, darf nicht
+ // auf das Default zugefriffen werden. Diese
+ // werden gecleart
+ if( !*pPtr )
+ ;
+ else if( SFX_WHICH_MAX < *pPtr )
+ pAkt->aAttrSet.ClearItem( *pPtr );
+ else if( IsChkStyleAttr() )
+ pAkt->aAttrSet.Put( pDfltSet->Get( *pPtr ) );
+ else if( !pAkt->aAttrSet.GetParent() )
+ {
+ if( SFX_ITEM_SET ==
+ pDfltSet->GetItemState( *pPtr, FALSE, &pDef ))
+ pAkt->aAttrSet.Put( *pDef );
+ else
+ pAkt->aAttrSet.ClearItem( *pPtr );
+ }
+ else if( SFX_ITEM_SET == pAkt->aAttrSet.GetParent()->
+ GetItemState( *pPtr, TRUE, &pItem ) &&
+ *( pDef = &pDfltSet->Get( *pPtr )) != *pItem )
+ pAkt->aAttrSet.Put( *pDef );
+ else
+ {
+ if( SFX_ITEM_SET ==
+ pDfltSet->GetItemState( *pPtr, FALSE, &pDef ))
+ pAkt->aAttrSet.Put( *pDef );
+ else
+ pAkt->aAttrSet.ClearItem( *pPtr );
+ }
+ }
+ }
+ else if( bPard )
+ pAkt->nStyleNo = 0; // Style-Nummer zuruecksetzen
+
+ *ppSet = &pAkt->aAttrSet;
+
+ if (!bPard)
+ {
+ //Once we have a default font, then any text without a font specifier is
+ //in the default font, and thus has the default font charset, otherwise
+ //we can fall back to the ansicpg set codeset
+ if (nDfltFont != -1)
+ {
+ const Font& rSVFont = GetFont(USHORT(nDfltFont));
+ SetEncoding(rSVFont.GetCharSet());
+ }
+ else
+ SetEncoding(GetCodeSet());
+ }
+ }
+}
+
+void SvxRTFParser::SetDefault( int nToken, int nValue )
+{
+ if( !bNewDoc )
+ return;
+
+ SfxItemSet aTmp( *pAttrPool, aWhichMap.GetData() );
+ BOOL bOldFlag = bIsLeftToRightDef;
+ bIsLeftToRightDef = TRUE;
+ switch( nToken )
+ {
+ case RTF_ADEFF: bIsLeftToRightDef = FALSE; // no break!
+ case RTF_DEFF:
+ {
+ if( -1 == nValue )
+ nValue = 0;
+ const Font& rSVFont = GetFont( USHORT(nValue) );
+ SvxFontItem aTmpItem(
+ rSVFont.GetFamily(), rSVFont.GetName(),
+ rSVFont.GetStyleName(), rSVFont.GetPitch(),
+ rSVFont.GetCharSet(), SID_ATTR_CHAR_FONT );
+ SetScriptAttr( NOTDEF_CHARTYPE, aTmp, aTmpItem );
+ }
+ break;
+
+ case RTF_ADEFLANG: bIsLeftToRightDef = FALSE; // no break!
+ case RTF_DEFLANG:
+ // default Language merken
+ if( -1 != nValue )
+ {
+ SvxLanguageItem aTmpItem( (const LanguageType)nValue,
+ SID_ATTR_CHAR_LANGUAGE );
+ SetScriptAttr( NOTDEF_CHARTYPE, aTmp, aTmpItem );
+ }
+ break;
+
+ case RTF_DEFTAB:
+ if( PARDID->nTabStop )
+ {
+ // RTF definiert 720 twips als default
+ bIsSetDfltTab = TRUE;
+ if( -1 == nValue || !nValue )
+ nValue = 720;
+
+ // wer keine Twips haben moechte ...
+ if( IsCalcValue() )
+ {
+ nTokenValue = nValue;
+ CalcValue();
+ nValue = nTokenValue;
+ }
+#if 1
+ /*
+ cmc:
+ This stuff looks a little hairy indeed, this should be totally
+ unnecessary where default tabstops are understood. Just make one
+ tabstop and stick the value in there, the first one is all that
+ matters.
+
+ e.g.
+
+ SvxTabStopItem aNewTab(1, USHORT(nValue), SVX_TAB_ADJUST_DEFAULT,
+ PARDID->nTabStop);
+ ((SvxTabStop&)aNewTab[0]).GetAdjustment() = SVX_TAB_ADJUST_DEFAULT;
+
+
+ It must exist as a foul hack to support somebody that does not
+ have a true concept of default tabstops by making a tabsetting
+ result from the default tabstop, creating a lot of them all at
+ the default locations to give the effect of the first real
+ default tabstop being in use just in case the receiving
+ application doesn't do that for itself.
+ */
+#endif
+
+ // Verhaeltnis der def. TabWidth / Tabs errechnen und
+ // enstsprechend die neue Anzahl errechnen.
+/*-----------------14.12.94 19:32-------------------
+ ?? wie kommt man auf die 13 ??
+--------------------------------------------------*/
+ USHORT nAnzTabs = (SVX_TAB_DEFDIST * 13 ) / USHORT(nValue);
+ /*
+ cmc, make sure we have at least one, or all hell breaks loose in
+ everybodies exporters, #i8247#
+ */
+ if (nAnzTabs < 1)
+ nAnzTabs = 1;
+
+ // wir wollen Defaulttabs
+ SvxTabStopItem aNewTab( nAnzTabs, USHORT(nValue),
+ SVX_TAB_ADJUST_DEFAULT, PARDID->nTabStop );
+ while( nAnzTabs )
+ ((SvxTabStop&)aNewTab[ --nAnzTabs ]).GetAdjustment() = SVX_TAB_ADJUST_DEFAULT;
+
+ pAttrPool->SetPoolDefaultItem( aNewTab );
+ }
+ break;
+ }
+ bIsLeftToRightDef = bOldFlag;
+
+ if( aTmp.Count() )
+ {
+ SfxItemIter aIter( aTmp );
+ const SfxPoolItem* pItem = aIter.GetCurItem();
+ while( TRUE )
+ {
+ pAttrPool->SetPoolDefaultItem( *pItem );
+ if( aIter.IsAtEnd() )
+ break;
+ pItem = aIter.NextItem();
+ }
+ }
+}
+
+// default: keine Umrechnung, alles bei Twips lassen.
+void SvxRTFParser::CalcValue()
+{
+}
+
+ // fuer Tokens, die im ReadAttr nicht ausgewertet werden
+void SvxRTFParser::UnknownAttrToken( int, SfxItemSet* )
+{
+}
+
+/* vi:set tabstop=4 shiftwidth=4 expandtab: */
diff --git a/editeng/source/rtf/segincr.asm b/editeng/source/rtf/segincr.asm
new file mode 100644
index 000000000000..d90d79dbd8be
--- /dev/null
+++ b/editeng/source/rtf/segincr.asm
@@ -0,0 +1,43 @@
+;*************************************************************************
+;
+; DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+;
+; Copyright 2008 by Sun Microsystems, Inc.
+;
+; OpenOffice.org - a multi-platform office productivity suite
+;
+; $RCSfile: segincr.asm,v $
+;
+; $Revision: 1.6 $
+;
+; 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.
+;
+;*************************************************************************
+
+EXTRN __AHINCR:abs
+ .MODEL LARGE
+STARTWS0_SEG SEGMENT WORD PUBLIC 'STARTWS_CODE'
+
+ PUBLIC _SegIncr
+_SegIncr PROC
+ MOV AX, __AHINCR
+ RET
+_SegIncr ENDP
+
+STARTWS0_SEG ENDS
+ END
diff --git a/editeng/source/rtf/svxrtf.cxx b/editeng/source/rtf/svxrtf.cxx
new file mode 100644
index 000000000000..c659abe45a90
--- /dev/null
+++ b/editeng/source/rtf/svxrtf.cxx
@@ -0,0 +1,1517 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: svxrtf.cxx,v $
+ * $Revision: 1.34.212.1 $
+ *
+ * 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_editeng.hxx"
+
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil -*- */
+
+
+#include <ctype.h>
+#include <tools/datetime.hxx>
+#include <rtl/tencinfo.h>
+#include <svl/itemiter.hxx>
+#include <svl/whiter.hxx>
+#include <svtools/rtftoken.h>
+#include <svl/itempool.hxx>
+
+#include <comphelper/string.hxx>
+
+#include <com/sun/star/lang/Locale.hpp>
+#include <editeng/scriptspaceitem.hxx>
+#include <editeng/fontitem.hxx>
+#include <editeng/colritem.hxx>
+#include <editeng/svxrtf.hxx>
+#include <editeng/editids.hrc>
+#include <vcl/svapp.hxx>
+
+#include <com/sun/star/document/XDocumentProperties.hpp>
+
+
+using namespace ::com::sun::star;
+
+
+SV_IMPL_PTRARR( SvxRTFColorTbl, ColorPtr )
+SV_IMPL_PTRARR( SvxRTFItemStackList, SvxRTFItemStackType* )
+
+CharSet lcl_GetDefaultTextEncodingForRTF()
+{
+
+ ::com::sun::star::lang::Locale aLocale;
+ ::rtl::OUString aLangString;
+
+ aLocale = Application::GetSettings().GetLocale();
+ aLangString = aLocale.Language;
+
+ if ( aLangString.equals( ::rtl::OUString::createFromAscii( "ru" ) )
+ || aLangString.equals( ::rtl::OUString::createFromAscii( "uk" ) ) )
+ return RTL_TEXTENCODING_MS_1251;
+ if ( aLangString.equals( ::rtl::OUString::createFromAscii( "tr" ) ) )
+ return RTL_TEXTENCODING_MS_1254;
+ else
+ return RTL_TEXTENCODING_MS_1252;
+}
+
+// -------------- Methoden --------------------
+
+SvxRTFParser::SvxRTFParser( SfxItemPool& rPool, SvStream& rIn,
+ uno::Reference<document::XDocumentProperties> i_xDocProps,
+ int bReadNewDoc )
+ : SvRTFParser( rIn, 5 ),
+ rStrm(rIn),
+ aColorTbl( 16, 4 ),
+ aFontTbl( 16, 4 ),
+ pInsPos( 0 ),
+ pAttrPool( &rPool ),
+ m_xDocProps( i_xDocProps ),
+ pRTFDefaults( 0 ),
+ nVersionNo( 0 )
+{
+ bNewDoc = bReadNewDoc;
+
+ bChkStyleAttr = bCalcValue = bReadDocInfo = bIsInReadStyleTab = FALSE;
+ bIsLeftToRightDef = TRUE;
+
+ {
+ RTFPlainAttrMapIds aTmp( rPool );
+ aPlainMap.Insert( (USHORT*)&aTmp,
+ sizeof( RTFPlainAttrMapIds ) / sizeof(USHORT), 0 );
+ }
+ {
+ RTFPardAttrMapIds aTmp( rPool );
+ aPardMap.Insert( (USHORT*)&aTmp,
+ sizeof( RTFPardAttrMapIds ) / sizeof(USHORT), 0 );
+ }
+ pDfltFont = new Font;
+ pDfltColor = new Color;
+}
+
+void SvxRTFParser::EnterEnvironment()
+{
+}
+
+void SvxRTFParser::LeaveEnvironment()
+{
+}
+
+void SvxRTFParser::ResetPard()
+{
+}
+
+SvxRTFParser::~SvxRTFParser()
+{
+ if( aColorTbl.Count() )
+ ClearColorTbl();
+ if( aFontTbl.Count() )
+ ClearFontTbl();
+ if( aStyleTbl.Count() )
+ ClearStyleTbl();
+ if( aAttrStack.Count() )
+ ClearAttrStack();
+
+ delete pRTFDefaults;
+
+ delete pInsPos;
+ delete pDfltFont;
+ delete pDfltColor;
+}
+
+void SvxRTFParser::SetInsPos( const SvxPosition& rNew )
+{
+ if( pInsPos )
+ delete pInsPos;
+ pInsPos = rNew.Clone();
+}
+
+SvParserState SvxRTFParser::CallParser()
+{
+ DBG_ASSERT( pInsPos, "keine Einfuegeposition" );
+
+ if( !pInsPos )
+ return SVPAR_ERROR;
+
+ if( aColorTbl.Count() )
+ ClearColorTbl();
+ if( aFontTbl.Count() )
+ ClearFontTbl();
+ if( aStyleTbl.Count() )
+ ClearStyleTbl();
+ if( aAttrStack.Count() )
+ ClearAttrStack();
+
+ bIsSetDfltTab = FALSE;
+ bNewGroup = FALSE;
+ nDfltFont = 0;
+
+ sBaseURL.Erase();
+
+ // erzeuge aus den gesetzten WhichIds die richtige WhichId-Tabelle.
+ BuildWhichTbl();
+
+ return SvRTFParser::CallParser();
+}
+
+void SvxRTFParser::Continue( int nToken )
+{
+ SvRTFParser::Continue( nToken );
+
+ if( SVPAR_PENDING != GetStatus() )
+ {
+ SetAllAttrOfStk();
+#if 0
+ //Regardless of what "color 0" is, word defaults to auto as the default colour.
+ //e.g. see #i7713#
+ if( bNewDoc && ((RTFPlainAttrMapIds*)aPlainMap.GetData())->nColor )
+ pAttrPool->SetPoolDefaultItem( SvxColorItem( GetColor( 0 ),
+ ((RTFPlainAttrMapIds*)aPlainMap.GetData())->nColor ));
+#endif
+ }
+}
+
+
+// wird fuer jedes Token gerufen, das in CallParser erkannt wird
+void SvxRTFParser::NextToken( int nToken )
+{
+ sal_Unicode cCh;
+ switch( nToken )
+ {
+ case RTF_COLORTBL: ReadColorTable(); break;
+ case RTF_FONTTBL: ReadFontTable(); break;
+ case RTF_STYLESHEET: ReadStyleTable(); break;
+
+ case RTF_DEFF:
+ if( bNewDoc )
+ {
+ if( aFontTbl.Count() )
+ // koennen wir sofort setzen
+ SetDefault( nToken, nTokenValue );
+ else
+ // wird nach einlesen der Fonttabelle gesetzt
+ nDfltFont = int(nTokenValue);
+ }
+ break;
+
+ case RTF_DEFTAB:
+ case RTF_DEFLANG:
+ if( bNewDoc )
+ SetDefault( nToken, nTokenValue );
+ break;
+
+
+ case RTF_PICT: ReadBitmapData(); break;
+
+ case RTF_LINE: cCh = '\n'; goto INSINGLECHAR;
+ case RTF_TAB: cCh = '\t'; goto INSINGLECHAR;
+ case RTF_SUBENTRYINDEX: cCh = ':'; goto INSINGLECHAR;
+
+ case RTF_EMDASH: cCh = 151; goto INSINGLECHAR;
+ case RTF_ENDASH: cCh = 150; goto INSINGLECHAR;
+ case RTF_BULLET: cCh = 149; goto INSINGLECHAR;
+ case RTF_LQUOTE: cCh = 145; goto INSINGLECHAR;
+ case RTF_RQUOTE: cCh = 146; goto INSINGLECHAR;
+ case RTF_LDBLQUOTE: cCh = 147; goto INSINGLECHAR;
+ case RTF_RDBLQUOTE: cCh = 148; goto INSINGLECHAR;
+INSINGLECHAR:
+ aToken = ByteString::ConvertToUnicode( (sal_Char)cCh,
+ RTL_TEXTENCODING_MS_1252 );
+
+ // kein Break, aToken wird als Text gesetzt
+ case RTF_TEXTTOKEN:
+ {
+ InsertText();
+ // alle angesammelten Attribute setzen
+ for( USHORT n = aAttrSetList.Count(); n; )
+ {
+ SvxRTFItemStackType* pStkSet = aAttrSetList[--n];
+ SetAttrSet( *pStkSet );
+ aAttrSetList.DeleteAndDestroy( n );
+ }
+ }
+ break;
+
+
+ case RTF_PAR:
+ InsertPara();
+ break;
+ case '{':
+ if (bNewGroup) // Verschachtelung !!
+ _GetAttrSet();
+ EnterEnvironment();
+ bNewGroup = true;
+ break;
+ case '}':
+ if( !bNewGroup ) // leere Gruppe ??
+ AttrGroupEnd();
+ LeaveEnvironment();
+ bNewGroup = false;
+ break;
+ case RTF_INFO:
+#ifndef SVX_LIGHT
+ if (bReadDocInfo && bNewDoc && m_xDocProps.is())
+ ReadInfo();
+ else
+#endif
+ SkipGroup();
+ break;
+
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ // erstmal gesamt ueberlesen (muessen alle in einer Gruppe stehen !!)
+ // Koennen auch ohne dem IGNORE-Flag im RTF-File auftreten; alle Gruppen
+ // mit IGNORE-Flag werden im default-Zweig ueberlesen.
+
+ case RTF_SWG_PRTDATA:
+ case RTF_FIELD:
+ case RTF_ATNID:
+ case RTF_ANNOTATION:
+
+ case RTF_BKMKSTART:
+ case RTF_BKMKEND:
+ case RTF_BKMK_KEY:
+ case RTF_XE:
+ case RTF_TC:
+ case RTF_NEXTFILE:
+ case RTF_TEMPLATE:
+#if 0
+ //disabled for #i19718#
+ case RTF_SHPRSLT: // RTF_SHP fehlt noch !!
+#endif
+ SkipGroup();
+ break;
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+ case RTF_PGDSCNO:
+ case RTF_PGBRK:
+ case RTF_SHADOW:
+ if( RTF_IGNOREFLAG != GetStackPtr( -1 )->nTokenId )
+ break;
+ nToken = SkipToken( -1 );
+ if( '{' == GetStackPtr( -1 )->nTokenId )
+ nToken = SkipToken( -1 );
+
+ ReadAttr( nToken, &GetAttrSet() );
+ break;
+
+ default:
+ switch( nToken & ~(0xff | RTF_SWGDEFS) )
+ {
+ case RTF_PARFMT: // hier gibts keine Swg-Defines
+ ReadAttr( nToken, &GetAttrSet() );
+ break;
+
+ case RTF_CHRFMT:
+ case RTF_BRDRDEF:
+ case RTF_TABSTOPDEF:
+
+ if( RTF_SWGDEFS & nToken)
+ {
+ if( RTF_IGNOREFLAG != GetStackPtr( -1 )->nTokenId )
+ break;
+ nToken = SkipToken( -1 );
+ if( '{' == GetStackPtr( -1 )->nTokenId )
+ {
+ nToken = SkipToken( -1 );
+ }
+ }
+ ReadAttr( nToken, &GetAttrSet() );
+ break;
+ default:
+ {
+ if( /*( '{' == GetStackPtr( -1 )->nTokenId ) ||*/
+ ( RTF_IGNOREFLAG == GetStackPtr( -1 )->nTokenId &&
+ '{' == GetStackPtr( -2 )->nTokenId ) )
+ SkipGroup();
+ }
+ break;
+ }
+ break;
+ }
+}
+
+void SvxRTFParser::ReadStyleTable()
+{
+ int nToken, bSaveChkStyleAttr = bChkStyleAttr;
+ short nStyleNo = 0;
+ int _nOpenBrakets = 1; // die erste wurde schon vorher erkannt !!
+ SvxRTFStyleType* pStyle = new SvxRTFStyleType( *pAttrPool, aWhichMap.GetData() );
+ pStyle->aAttrSet.Put( GetRTFDefaults() );
+
+ bIsInReadStyleTab = TRUE;
+ bChkStyleAttr = FALSE; // Attribute nicht gegen die Styles checken
+
+ while( _nOpenBrakets && IsParserWorking() )
+ {
+ switch( nToken = GetNextToken() )
+ {
+ case '}': if( --_nOpenBrakets && IsParserWorking() )
+ // Style konnte vollstaendig gelesen werden,
+ // also ist das noch ein stabiler Status
+ SaveState( RTF_STYLESHEET );
+ break;
+ case '{':
+ {
+ if( RTF_IGNOREFLAG != GetNextToken() )
+ nToken = SkipToken( -1 );
+ else if( RTF_UNKNOWNCONTROL != ( nToken = GetNextToken() ) &&
+ RTF_PN != nToken )
+ nToken = SkipToken( -2 );
+ else
+ {
+ // gleich herausfiltern
+ ReadUnknownData();
+ nToken = GetNextToken();
+ if( '}' != nToken )
+ eState = SVPAR_ERROR;
+ break;
+ }
+ ++_nOpenBrakets;
+ }
+ break;
+
+ case RTF_SBASEDON: pStyle->nBasedOn = USHORT(nTokenValue); pStyle->bBasedOnIsSet=TRUE; break;
+ case RTF_SNEXT: pStyle->nNext = USHORT(nTokenValue); break;
+ case RTF_OUTLINELEVEL:
+ case RTF_SOUTLVL: pStyle->nOutlineNo = BYTE(nTokenValue); break;
+ case RTF_S: nStyleNo = (short)nTokenValue; break;
+ case RTF_CS: nStyleNo = (short)nTokenValue;
+ pStyle->bIsCharFmt = TRUE;
+ break;
+
+ case RTF_TEXTTOKEN:
+ {
+ pStyle->sName = DelCharAtEnd( aToken, ';' );
+
+/*
+??? soll man das umsetzen ???
+ if( !pStyle->sName.Len() )
+ pStyle->sName = "Standard";
+*/
+ // sollte die Nummer doppelt vergeben werden ?
+ if( aStyleTbl.Count() )
+ {
+ SvxRTFStyleType* pOldSt = aStyleTbl.Remove( nStyleNo );
+ if( pOldSt )
+ delete pOldSt;
+ }
+ // alle Daten vom Style vorhanden, also ab in die Tabelle
+ aStyleTbl.Insert( nStyleNo, pStyle );
+ pStyle = new SvxRTFStyleType( *pAttrPool, aWhichMap.GetData() );
+ pStyle->aAttrSet.Put( GetRTFDefaults() );
+ nStyleNo = 0;
+ }
+ break;
+ default:
+ switch( nToken & ~(0xff | RTF_SWGDEFS) )
+ {
+ case RTF_PARFMT: // hier gibts keine Swg-Defines
+ ReadAttr( nToken, &pStyle->aAttrSet );
+ break;
+
+ case RTF_CHRFMT:
+ case RTF_BRDRDEF:
+ case RTF_TABSTOPDEF:
+
+ if( RTF_SWGDEFS & nToken)
+ {
+ if( RTF_IGNOREFLAG != GetStackPtr( -1 )->nTokenId )
+ break;
+ nToken = SkipToken( -1 );
+ if( '{' == GetStackPtr( -1 )->nTokenId )
+ {
+ nToken = SkipToken( -1 );
+#if 0
+ --_nOpenBrakets; // korrigieren!!
+#endif
+ }
+ }
+ ReadAttr( nToken, &pStyle->aAttrSet );
+ break;
+ }
+ break;
+ }
+ }
+ delete pStyle; // loesche das letze Style
+ SkipToken( -1 ); // die schliesende Klammer wird "oben" ausgewertet
+
+ // Flag wieder auf alten Zustand
+ bChkStyleAttr = bSaveChkStyleAttr;
+ bIsInReadStyleTab = FALSE;
+}
+
+void SvxRTFParser::ReadColorTable()
+{
+ int nToken;
+ BYTE nRed = 0xff, nGreen = 0xff, nBlue = 0xff;
+
+ while( '}' != ( nToken = GetNextToken() ) && IsParserWorking() )
+ {
+ switch( nToken )
+ {
+ case RTF_RED: nRed = BYTE(nTokenValue); break;
+ case RTF_GREEN: nGreen = BYTE(nTokenValue); break;
+ case RTF_BLUE: nBlue = BYTE(nTokenValue); break;
+
+ case RTF_TEXTTOKEN: // oder sollte irgendein Unsin darumstehen?
+ if( 1 == aToken.Len()
+ ? aToken.GetChar( 0 ) != ';'
+ : STRING_NOTFOUND == aToken.Search( ';' ) )
+ break; // es muss zumindestens das ';' gefunden werden
+
+ // else kein break !!
+
+ case ';':
+ if( IsParserWorking() )
+ {
+ // eine Farbe ist Fertig, in die Tabelle eintragen
+ // versuche die Werte auf SV interne Namen zu mappen
+ ColorPtr pColor = new Color( nRed, nGreen, nBlue );
+ if( !aColorTbl.Count() &&
+ BYTE(-1) == nRed && BYTE(-1) == nGreen && BYTE(-1) == nBlue )
+ pColor->SetColor( COL_AUTO );
+ aColorTbl.Insert( pColor, aColorTbl.Count() );
+ nRed = 0, nGreen = 0, nBlue = 0;
+
+ // Color konnte vollstaendig gelesen werden,
+ // also ist das noch ein stabiler Status
+ SaveState( RTF_COLORTBL );
+ }
+ break;
+ }
+ }
+ SkipToken( -1 ); // die schliesende Klammer wird "oben" ausgewertet
+}
+
+void SvxRTFParser::ReadFontTable()
+{
+ int nToken;
+ int _nOpenBrakets = 1; // die erste wurde schon vorher erkannt !!
+ Font* pFont = new Font();
+ short nFontNo(0), nInsFontNo (0);
+ String sAltNm, sFntNm;
+ BOOL bIsAltFntNm = FALSE, bCheckNewFont;
+
+ CharSet nSystemChar = lcl_GetDefaultTextEncodingForRTF();
+ pFont->SetCharSet( nSystemChar );
+ SetEncoding( nSystemChar );
+
+ while( _nOpenBrakets && IsParserWorking() )
+ {
+ bCheckNewFont = FALSE;
+ switch( ( nToken = GetNextToken() ))
+ {
+ case '}':
+ bIsAltFntNm = FALSE;
+ // Style konnte vollstaendig gelesen werden,
+ // also ist das noch ein stabiler Status
+ if( --_nOpenBrakets <= 1 && IsParserWorking() )
+ SaveState( RTF_FONTTBL );
+ bCheckNewFont = TRUE;
+ nInsFontNo = nFontNo;
+ break;
+ case '{':
+ if( RTF_IGNOREFLAG != GetNextToken() )
+ nToken = SkipToken( -1 );
+ // Unknown und alle bekannten nicht ausgewerteten Gruppen
+ // sofort ueberspringen
+ else if( RTF_UNKNOWNCONTROL != ( nToken = GetNextToken() ) &&
+ RTF_PANOSE != nToken && RTF_FNAME != nToken &&
+ RTF_FONTEMB != nToken && RTF_FONTFILE != nToken )
+ nToken = SkipToken( -2 );
+ else
+ {
+ // gleich herausfiltern
+ ReadUnknownData();
+ nToken = GetNextToken();
+ if( '}' != nToken )
+ eState = SVPAR_ERROR;
+ break;
+ }
+ ++_nOpenBrakets;
+ break;
+ case RTF_FROMAN:
+ pFont->SetFamily( FAMILY_ROMAN );
+ break;
+ case RTF_FSWISS:
+ pFont->SetFamily( FAMILY_SWISS );
+ break;
+ case RTF_FMODERN:
+ pFont->SetFamily( FAMILY_MODERN );
+ break;
+ case RTF_FSCRIPT:
+ pFont->SetFamily( FAMILY_SCRIPT );
+ break;
+ case RTF_FDECOR:
+ pFont->SetFamily( FAMILY_DECORATIVE );
+ break;
+ // bei technischen/symbolischen Font wird der CharSet ungeschaltet!!
+ case RTF_FTECH:
+ pFont->SetCharSet( RTL_TEXTENCODING_SYMBOL );
+ // deliberate fall through
+ case RTF_FNIL:
+ pFont->SetFamily( FAMILY_DONTKNOW );
+ break;
+ case RTF_FCHARSET:
+ if (-1 != nTokenValue)
+ {
+ CharSet nCharSet = rtl_getTextEncodingFromWindowsCharset(
+ (BYTE)nTokenValue);
+ pFont->SetCharSet(nCharSet);
+ //When we're in a font, the fontname is in the font
+ //charset, except for symbol fonts I believe
+ if (nCharSet == RTL_TEXTENCODING_SYMBOL)
+ nCharSet = RTL_TEXTENCODING_DONTKNOW;
+ SetEncoding(nCharSet);
+ }
+ break;
+ case RTF_FPRQ:
+ switch( nTokenValue )
+ {
+ case 1:
+ pFont->SetPitch( PITCH_FIXED );
+ break;
+ case 2:
+ pFont->SetPitch( PITCH_VARIABLE );
+ break;
+ }
+ break;
+ case RTF_F:
+ bCheckNewFont = TRUE;
+ nInsFontNo = nFontNo;
+ nFontNo = (short)nTokenValue;
+ break;
+ case RTF_FALT:
+ bIsAltFntNm = TRUE;
+ break;
+ case RTF_TEXTTOKEN:
+ DelCharAtEnd( aToken, ';' );
+ if ( aToken.Len() )
+ {
+ if( bIsAltFntNm )
+ sAltNm = aToken;
+ else
+ sFntNm = aToken;
+ }
+ break;
+ }
+
+ if( bCheckNewFont && 1 >= _nOpenBrakets && sFntNm.Len() ) // one font is ready
+ {
+ // alle Daten vom Font vorhanden, also ab in die Tabelle
+ if (sAltNm.Len())
+ (sFntNm += ';' ) += sAltNm;
+
+ pFont->SetName( sFntNm );
+ aFontTbl.Insert( nInsFontNo, pFont );
+ pFont = new Font();
+ pFont->SetCharSet( nSystemChar );
+ sAltNm.Erase();
+ sFntNm.Erase();
+ }
+ }
+ // den letzen muessen wir selbst loeschen
+ delete pFont;
+ SkipToken( -1 ); // die schliesende Klammer wird "oben" ausgewertet
+
+ // setze den default Font am Doc
+ if( bNewDoc && IsParserWorking() )
+ SetDefault( RTF_DEFF, nDfltFont );
+}
+
+void SvxRTFParser::ReadBitmapData()
+{
+ SvRTFParser::ReadBitmapData();
+}
+
+void SvxRTFParser::ReadOLEData()
+{
+ SvRTFParser::ReadOLEData();
+}
+
+String& SvxRTFParser::GetTextToEndGroup( String& rStr )
+{
+ rStr.Erase( 0 );
+ int _nOpenBrakets = 1, nToken; // die erste wurde schon vorher erkannt !!
+
+ while( _nOpenBrakets && IsParserWorking() )
+ {
+ switch( nToken = GetNextToken() )
+ {
+ case '}': --_nOpenBrakets; break;
+ case '{':
+ {
+ if( RTF_IGNOREFLAG != GetNextToken() )
+ nToken = SkipToken( -1 );
+ else if( RTF_UNKNOWNCONTROL != GetNextToken() )
+ nToken = SkipToken( -2 );
+ else
+ {
+ // gleich herausfiltern
+ ReadUnknownData();
+ nToken = GetNextToken();
+ if( '}' != nToken )
+ eState = SVPAR_ERROR;
+ break;
+ }
+ ++_nOpenBrakets;
+ }
+ break;
+
+ case RTF_TEXTTOKEN:
+ rStr += aToken;
+ break;
+ }
+ }
+ SkipToken( -1 ); // die schliesende Klammer wird "oben" ausgewertet
+ return rStr;
+}
+
+util::DateTime SvxRTFParser::GetDateTimeStamp( )
+{
+ util::DateTime aDT;
+ BOOL bWeiter = TRUE;
+ int nToken;
+ while( bWeiter && IsParserWorking() )
+ {
+ switch( nToken = GetNextToken() )
+ {
+ case RTF_YR: aDT.Year = (USHORT)nTokenValue; break;
+ case RTF_MO: aDT.Month = (USHORT)nTokenValue; break;
+ case RTF_DY: aDT.Day = (USHORT)nTokenValue; break;
+ case RTF_HR: aDT.Hours = (USHORT)nTokenValue; break;
+ case RTF_MIN: aDT.Minutes = (USHORT)nTokenValue; break;
+ default:
+ bWeiter = FALSE;
+ }
+ }
+ SkipToken( -1 ); // die schliesende Klammer wird "oben" ausgewertet
+ return aDT;
+}
+
+void SvxRTFParser::ReadInfo( const sal_Char* pChkForVerNo )
+{
+#ifndef SVX_LIGHT
+ int _nOpenBrakets = 1, nToken; // die erste wurde schon vorher erkannt !!
+ DBG_ASSERT(m_xDocProps.is(),
+ "SvxRTFParser::ReadInfo: no DocumentProperties");
+ String sStr, sComment;
+ long nVersNo = 0;
+
+ while( _nOpenBrakets && IsParserWorking() )
+ {
+ switch( nToken = GetNextToken() )
+ {
+ case '}': --_nOpenBrakets; break;
+ case '{':
+ {
+ if( RTF_IGNOREFLAG != GetNextToken() )
+ nToken = SkipToken( -1 );
+ else if( RTF_UNKNOWNCONTROL != GetNextToken() )
+ nToken = SkipToken( -2 );
+ else
+ {
+ // gleich herausfiltern
+ ReadUnknownData();
+ nToken = GetNextToken();
+ if( '}' != nToken )
+ eState = SVPAR_ERROR;
+ break;
+ }
+ ++_nOpenBrakets;
+ }
+ break;
+
+ case RTF_TITLE:
+ m_xDocProps->setTitle( GetTextToEndGroup( sStr ) );
+ break;
+ case RTF_SUBJECT:
+ m_xDocProps->setSubject( GetTextToEndGroup( sStr ) );
+ break;
+ case RTF_AUTHOR:
+ m_xDocProps->setAuthor( GetTextToEndGroup( sStr ) );
+ break;
+ case RTF_OPERATOR:
+ m_xDocProps->setModifiedBy( GetTextToEndGroup( sStr ) );
+ break;
+ case RTF_KEYWORDS:
+ {
+ ::rtl::OUString sTemp = GetTextToEndGroup( sStr );
+ m_xDocProps->setKeywords(
+ ::comphelper::string::convertCommaSeparated(sTemp) );
+ break;
+ }
+ case RTF_DOCCOMM:
+ m_xDocProps->setDescription( GetTextToEndGroup( sStr ) );
+ break;
+
+ case RTF_HLINKBASE:
+ sBaseURL = GetTextToEndGroup( sStr ) ;
+ break;
+
+ case RTF_CREATIM:
+ m_xDocProps->setCreationDate( GetDateTimeStamp() );
+ break;
+
+ case RTF_REVTIM:
+ m_xDocProps->setModificationDate( GetDateTimeStamp() );
+ break;
+
+ case RTF_PRINTIM:
+ m_xDocProps->setPrintDate( GetDateTimeStamp() );
+ break;
+
+ case RTF_COMMENT:
+ GetTextToEndGroup( sComment );
+ break;
+
+ case RTF_BUPTIM:
+ SkipGroup();
+ break;
+
+ case RTF_VERN:
+ nVersNo = nTokenValue;
+ break;
+
+ case RTF_EDMINS:
+ case RTF_ID:
+ case RTF_VERSION:
+ case RTF_NOFPAGES:
+ case RTF_NOFWORDS:
+ case RTF_NOFCHARS:
+ NextToken( nToken );
+ break;
+
+// default:
+ }
+ }
+
+ if( pChkForVerNo &&
+ COMPARE_EQUAL == sComment.CompareToAscii( pChkForVerNo ))
+ nVersionNo = nVersNo;
+
+ SkipToken( -1 ); // die schliesende Klammer wird "oben" ausgewertet
+#endif
+}
+
+
+void SvxRTFParser::ClearColorTbl()
+{
+ aColorTbl.DeleteAndDestroy( 0, aColorTbl.Count() );
+}
+
+void SvxRTFParser::ClearFontTbl()
+{
+ for( ULONG nCnt = aFontTbl.Count(); nCnt; )
+ delete aFontTbl.GetObject( --nCnt );
+}
+
+void SvxRTFParser::ClearStyleTbl()
+{
+ for( ULONG nCnt = aStyleTbl.Count(); nCnt; )
+ delete aStyleTbl.GetObject( --nCnt );
+}
+
+void SvxRTFParser::ClearAttrStack()
+{
+ SvxRTFItemStackType* pTmp;
+ for( ULONG nCnt = aAttrStack.Count(); nCnt; --nCnt )
+ {
+ pTmp = aAttrStack.Pop();
+ delete pTmp;
+ }
+}
+
+String& SvxRTFParser::DelCharAtEnd( String& rStr, const sal_Unicode cDel )
+{
+ if( rStr.Len() && ' ' == rStr.GetChar( 0 ))
+ rStr.EraseLeadingChars();
+ if( rStr.Len() && ' ' == rStr.GetChar( rStr.Len()-1 ))
+ rStr.EraseTrailingChars();
+ if( rStr.Len() && cDel == rStr.GetChar( rStr.Len()-1 ))
+ rStr.Erase( rStr.Len()-1 );
+ return rStr;
+}
+
+
+const Font& SvxRTFParser::GetFont( USHORT nId )
+{
+ const Font* pFont = aFontTbl.Get( nId );
+ if( !pFont )
+ {
+ const SvxFontItem& rDfltFont = (const SvxFontItem&)
+ pAttrPool->GetDefaultItem(
+ ((RTFPlainAttrMapIds*)aPlainMap.GetData())->nFont );
+ pDfltFont->SetName( rDfltFont.GetStyleName() );
+ pDfltFont->SetFamily( rDfltFont.GetFamily() );
+ pFont = pDfltFont;
+ }
+ return *pFont;
+}
+
+SvxRTFItemStackType* SvxRTFParser::_GetAttrSet( int bCopyAttr )
+{
+ SvxRTFItemStackType* pAkt = aAttrStack.Top();
+ SvxRTFItemStackType* pNew;
+ if( pAkt )
+ pNew = new SvxRTFItemStackType( *pAkt, *pInsPos, bCopyAttr );
+ else
+ pNew = new SvxRTFItemStackType( *pAttrPool, aWhichMap.GetData(),
+ *pInsPos );
+ pNew->SetRTFDefaults( GetRTFDefaults() );
+
+ aAttrStack.Push( pNew );
+ bNewGroup = FALSE;
+ return pNew;
+}
+
+
+void SvxRTFParser::_ClearStyleAttr( SvxRTFItemStackType& rStkType )
+{
+ // check attributes to the attributes of the stylesheet or to
+ // the default attrs of the document
+ SfxItemSet &rSet = rStkType.GetAttrSet();
+ const SfxItemPool& rPool = *rSet.GetPool();
+ const SfxPoolItem* pItem;
+ SfxWhichIter aIter( rSet );
+
+ SvxRTFStyleType* pStyle;
+ if( !IsChkStyleAttr() ||
+ !rStkType.GetAttrSet().Count() ||
+ 0 == ( pStyle = aStyleTbl.Get( rStkType.nStyleNo ) ))
+ {
+ for( USHORT nWhich = aIter.GetCurWhich(); nWhich; nWhich = aIter.NextWhich() )
+ {
+ if( SFX_WHICH_MAX > nWhich &&
+ SFX_ITEM_SET == rSet.GetItemState( nWhich, FALSE, &pItem ) &&
+ rPool.GetDefaultItem( nWhich ) == *pItem )
+ rSet.ClearItem( nWhich ); // loeschen
+ }
+ }
+ else
+ {
+ // alle Attribute, die schon vom Style definiert sind, aus dem
+ // akt. AttrSet entfernen
+ SfxItemSet &rStyleSet = pStyle->aAttrSet;
+ const SfxPoolItem* pSItem;
+ for( USHORT nWhich = aIter.GetCurWhich(); nWhich; nWhich = aIter.NextWhich() )
+ {
+ if( SFX_ITEM_SET == rStyleSet.GetItemState( nWhich, TRUE, &pSItem ))
+ {
+ // JP 22.06.99: im Style und im Set gleich gesetzt -> loeschen
+ if( SFX_ITEM_SET == rSet.GetItemState( nWhich, FALSE, &pItem )
+ && *pItem == *pSItem )
+ rSet.ClearItem( nWhich ); // loeschen
+ }
+ // Bug 59571 - falls nicht im Style gesetzt und gleich mit
+ // dem PoolDefault -> auch dann loeschen
+ else if( SFX_WHICH_MAX > nWhich &&
+ SFX_ITEM_SET == rSet.GetItemState( nWhich, FALSE, &pItem ) &&
+ rPool.GetDefaultItem( nWhich ) == *pItem )
+ rSet.ClearItem( nWhich ); // loeschen
+ }
+ }
+}
+
+void SvxRTFParser::AttrGroupEnd() // den akt. Bearbeiten, vom Stack loeschen
+{
+ if( aAttrStack.Count() )
+ {
+ SvxRTFItemStackType *pOld = aAttrStack.Pop();
+ SvxRTFItemStackType *pAkt = aAttrStack.Top();
+
+ do { // middle check loop
+ ULONG nOldSttNdIdx = pOld->pSttNd->GetIdx();
+ if( !pOld->pChildList &&
+ ((!pOld->aAttrSet.Count() && !pOld->nStyleNo ) ||
+ (nOldSttNdIdx == pInsPos->GetNodeIdx() &&
+ pOld->nSttCnt == pInsPos->GetCntIdx() )))
+ break; // keine Attribute oder Bereich
+
+ // setze nur die Attribute, die unterschiedlich zum Parent sind
+ if( pAkt && pOld->aAttrSet.Count() )
+ {
+ SfxItemIter aIter( pOld->aAttrSet );
+ const SfxPoolItem* pItem = aIter.GetCurItem(), *pGet;
+ while( TRUE )
+ {
+ if( SFX_ITEM_SET == pAkt->aAttrSet.GetItemState(
+ pItem->Which(), FALSE, &pGet ) &&
+ *pItem == *pGet )
+ pOld->aAttrSet.ClearItem( pItem->Which() );
+
+ if( aIter.IsAtEnd() )
+ break;
+ pItem = aIter.NextItem();
+ }
+
+ if( !pOld->aAttrSet.Count() && !pOld->pChildList &&
+ !pOld->nStyleNo )
+ break;
+ }
+
+ // setze alle Attribute, die von Start bis hier
+ // definiert sind.
+ int bCrsrBack = !pInsPos->GetCntIdx();
+ if( bCrsrBack )
+ {
+ // am Absatzanfang ? eine Position zurueck
+ ULONG nNd = pInsPos->GetNodeIdx();
+ MovePos( FALSE );
+ // if can not move backward then later dont move forward !
+ bCrsrBack = nNd != pInsPos->GetNodeIdx();
+ }
+
+ //Bug #46608#: ungueltige Bereiche ignorieren!
+ if( ( pOld->pSttNd->GetIdx() < pInsPos->GetNodeIdx() ||
+ ( pOld->pSttNd->GetIdx() == pInsPos->GetNodeIdx() &&
+ pOld->nSttCnt <= pInsPos->GetCntIdx() ))
+#if 0
+//BUG 68555 - dont test for empty paragraph or any range
+ && ( nOldSttNdIdx != pInsPos->GetNodeIdx() ||
+ pOld->nSttCnt != pInsPos->GetCntIdx() ||
+ !pOld->nSttCnt )
+#endif
+ )
+ {
+ if( !bCrsrBack )
+ {
+ // alle pard-Attribute gelten nur bis zum vorherigen
+ // Absatz !!
+ if( nOldSttNdIdx == pInsPos->GetNodeIdx() )
+ {
+#if 0
+//BUG 68555 - dont reset pard attrs, if the group not begins not at start of
+// paragraph
+ // Bereich innerhalb eines Absatzes:
+ // alle Absatz-Attribute und StyleNo loeschen
+ // aber nur wenn mitten drin angefangen wurde
+ if( pOld->nSttCnt )
+ {
+ pOld->nStyleNo = 0;
+ for( USHORT n = 0; n < aPardMap.Count() &&
+ pOld->aAttrSet.Count(); ++n )
+ if( aPardMap[n] )
+ pOld->aAttrSet.ClearItem( aPardMap[n] );
+
+ if( !pOld->aAttrSet.Count() && !pOld->pChildList &&
+ !pOld->nStyleNo )
+ break; // auch dieser verlaesst uns jetzt
+ }
+#endif
+ }
+ else
+ {
+ // jetzt wirds kompliziert:
+ // - alle Zeichen-Attribute behalten den Bereich,
+ // - alle Absatz-Attribute bekommen den Bereich
+ // bis zum vorherigen Absatz
+ SvxRTFItemStackType* pNew = new SvxRTFItemStackType(
+ *pOld, *pInsPos, TRUE );
+ pNew->aAttrSet.SetParent( pOld->aAttrSet.GetParent() );
+
+ // loesche aus pNew alle Absatz Attribute
+ for( USHORT n = 0; n < aPardMap.Count() &&
+ pNew->aAttrSet.Count(); ++n )
+ if( aPardMap[n] )
+ pNew->aAttrSet.ClearItem( aPardMap[n] );
+ pNew->SetRTFDefaults( GetRTFDefaults() );
+
+ // gab es ueberhaupt welche ?
+ if( pNew->aAttrSet.Count() == pOld->aAttrSet.Count() )
+ delete pNew; // das wars dann
+ else
+ {
+ pNew->nStyleNo = 0;
+
+ // spanne jetzt den richtigen Bereich auf
+ // pNew von alter
+ SetEndPrevPara( pOld->pEndNd, pOld->nEndCnt );
+ pNew->nSttCnt = 0;
+
+ if( IsChkStyleAttr() )
+ {
+ _ClearStyleAttr( *pOld );
+ _ClearStyleAttr( *pNew ); //#i10381#, methinks.
+ }
+
+ if( pAkt )
+ {
+ pAkt->Add( pOld );
+ pAkt->Add( pNew );
+ }
+ else
+ {
+ // letzter vom Stack, also zwischenspeichern, bis der
+ // naechste Text eingelesen wurde. (keine Attribute
+ // aufspannen!!)
+ aAttrSetList.Insert( pOld, aAttrSetList.Count() );
+ aAttrSetList.Insert( pNew, aAttrSetList.Count() );
+ }
+ pOld = 0; // pOld nicht loeschen
+ break; // das wars !!
+ }
+ }
+ }
+
+ pOld->pEndNd = pInsPos->MakeNodeIdx();
+ pOld->nEndCnt = pInsPos->GetCntIdx();
+
+#if 0
+ if( IsChkStyleAttr() )
+ _ClearStyleAttr( *pOld );
+#else
+ /*
+ #i21422#
+ If the parent (pAkt) sets something e.g. , and the child (pOld)
+ unsets it and the style both are based on has it unset then
+ clearing the pOld by looking at the style is clearly a disaster
+ as the text ends up with pAkts bold and not pOlds no bold, this
+ should be rethought out. For the moment its safest to just do
+ the clean if we have no parent, all we suffer is too many
+ redundant properties.
+ */
+ if (IsChkStyleAttr() && !pAkt)
+ _ClearStyleAttr( *pOld );
+#endif
+
+ if( pAkt )
+ {
+ pAkt->Add( pOld );
+ // split up and create new entry, because it make no sense
+ // to create a "so long" depend list. Bug 95010
+ if( bCrsrBack && 50 < pAkt->pChildList->Count() )
+ {
+ // am Absatzanfang ? eine Position zurueck
+ MovePos( TRUE );
+ bCrsrBack = FALSE;
+
+ // eine neue Gruppe aufmachen
+ SvxRTFItemStackType* pNew = new SvxRTFItemStackType(
+ *pAkt, *pInsPos, TRUE );
+ pNew->SetRTFDefaults( GetRTFDefaults() );
+
+ // alle bis hierher gueltigen Attribute "setzen"
+ AttrGroupEnd();
+ pAkt = aAttrStack.Top(); // can be changed after AttrGroupEnd!
+ pNew->aAttrSet.SetParent( pAkt ? &pAkt->aAttrSet : 0 );
+ aAttrStack.Push( pNew );
+ pAkt = pNew;
+ }
+ }
+ else
+ // letzter vom Stack, also zwischenspeichern, bis der
+ // naechste Text eingelesen wurde. (keine Attribute
+ // aufspannen!!)
+ aAttrSetList.Insert( pOld, aAttrSetList.Count() );
+
+ pOld = 0;
+ }
+
+ if( bCrsrBack )
+ // am Absatzanfang ? eine Position zurueck
+ MovePos( TRUE );
+
+ } while( FALSE );
+
+ if( pOld )
+ delete pOld;
+
+ bNewGroup = FALSE;
+ }
+}
+
+void SvxRTFParser::SetAllAttrOfStk() // end all Attr. and set it into doc
+{
+ // noch alle Attrbute vom Stack holen !!
+ while( aAttrStack.Count() )
+ AttrGroupEnd();
+
+ for( USHORT n = aAttrSetList.Count(); n; )
+ {
+ SvxRTFItemStackType* pStkSet = aAttrSetList[--n];
+ SetAttrSet( *pStkSet );
+ aAttrSetList.DeleteAndDestroy( n );
+ }
+}
+
+// setzt alle Attribute, die unterschiedlich zum aktuellen sind
+void SvxRTFParser::SetAttrSet( SvxRTFItemStackType &rSet )
+{
+ // wurde DefTab nie eingelesen? dann setze auf default
+ if( !bIsSetDfltTab )
+ SetDefault( RTF_DEFTAB, 720 );
+
+ if( rSet.pChildList )
+ rSet.Compress( *this );
+ if( rSet.aAttrSet.Count() || rSet.nStyleNo )
+ SetAttrInDoc( rSet );
+
+ // dann mal alle Childs abarbeiten
+ if( rSet.pChildList )
+ for( USHORT n = 0; n < rSet.pChildList->Count(); ++n )
+ SetAttrSet( *(*rSet.pChildList)[ n ] );
+}
+
+ // wurde noch kein Text eingefuegt ? (SttPos vom obersten StackEintrag!)
+int SvxRTFParser::IsAttrSttPos()
+{
+ SvxRTFItemStackType* pAkt = aAttrStack.Top();
+ return !pAkt || (pAkt->pSttNd->GetIdx() == pInsPos->GetNodeIdx() &&
+ pAkt->nSttCnt == pInsPos->GetCntIdx());
+}
+
+
+void SvxRTFParser::SetAttrInDoc( SvxRTFItemStackType & )
+{
+}
+
+#ifdef USED
+void SvxRTFParser::SaveState( int nToken )
+{
+ SvRTFParser::SaveState( nToken );
+}
+
+void SvxRTFParser::RestoreState()
+{
+ SvRTFParser::RestoreState();
+}
+#endif
+
+void SvxRTFParser::BuildWhichTbl()
+{
+ if( aWhichMap.Count() )
+ aWhichMap.Remove( 0, aWhichMap.Count() );
+ aWhichMap.Insert( (USHORT)0, (USHORT)0 );
+
+ // Aufbau einer Which-Map 'rWhichMap' aus einem Array von
+ // 'pWhichIds' von Which-Ids. Es hat die Lange 'nWhichIds'.
+ // Die Which-Map wird nicht geloescht.
+ SvParser::BuildWhichTbl( aWhichMap, (USHORT*)aPardMap.GetData(), aPardMap.Count() );
+ SvParser::BuildWhichTbl( aWhichMap, (USHORT*)aPlainMap.GetData(), aPlainMap.Count() );
+}
+
+const SfxItemSet& SvxRTFParser::GetRTFDefaults()
+{
+ if( !pRTFDefaults )
+ {
+ pRTFDefaults = new SfxItemSet( *pAttrPool, aWhichMap.GetData() );
+ USHORT nId;
+ if( 0 != ( nId = ((RTFPardAttrMapIds*)aPardMap.GetData())->nScriptSpace ))
+ {
+ SvxScriptSpaceItem aItem( FALSE, nId );
+ if( bNewDoc )
+ pAttrPool->SetPoolDefaultItem( aItem );
+ else
+ pRTFDefaults->Put( aItem );
+ }
+ }
+ return *pRTFDefaults;
+}
+
+/* */
+
+SvxRTFStyleType::SvxRTFStyleType( SfxItemPool& rPool, const USHORT* pWhichRange )
+ : aAttrSet( rPool, pWhichRange )
+{
+ nOutlineNo = BYTE(-1); // nicht gesetzt
+ nBasedOn = 0;
+ bBasedOnIsSet = FALSE; //$flr #117411#
+ nNext = 0;
+ bIsCharFmt = FALSE;
+}
+
+
+SvxRTFItemStackType::SvxRTFItemStackType(
+ SfxItemPool& rPool, const USHORT* pWhichRange,
+ const SvxPosition& rPos )
+ : aAttrSet( rPool, pWhichRange ),
+ pChildList( 0 ),
+ nStyleNo( 0 )
+{
+ pSttNd = rPos.MakeNodeIdx();
+ nSttCnt = rPos.GetCntIdx();
+ pEndNd = pSttNd;
+ nEndCnt = nSttCnt;
+}
+
+SvxRTFItemStackType::SvxRTFItemStackType(
+ const SvxRTFItemStackType& rCpy,
+ const SvxPosition& rPos,
+ int bCopyAttr )
+ : aAttrSet( *rCpy.aAttrSet.GetPool(), rCpy.aAttrSet.GetRanges() ),
+ pChildList( 0 ),
+ nStyleNo( rCpy.nStyleNo )
+{
+ pSttNd = rPos.MakeNodeIdx();
+ nSttCnt = rPos.GetCntIdx();
+ pEndNd = pSttNd;
+ nEndCnt = nSttCnt;
+
+ aAttrSet.SetParent( &rCpy.aAttrSet );
+ if( bCopyAttr )
+ aAttrSet.Put( rCpy.aAttrSet );
+}
+
+SvxRTFItemStackType::~SvxRTFItemStackType()
+{
+ if( pChildList )
+ delete pChildList;
+ if( pSttNd != pEndNd )
+ delete pEndNd;
+ delete pSttNd;
+}
+
+void SvxRTFItemStackType::Add( SvxRTFItemStackType* pIns )
+{
+ if( !pChildList )
+ pChildList = new SvxRTFItemStackList( 4, 16 );
+ pChildList->Insert( pIns, pChildList->Count() );
+}
+
+#if 0
+//cmc: This is the original. nEndCnt is redundantly assigned to itself, and
+//pEndNd can leak if not equal to pSttNd.
+void SvxRTFItemStackType::SetStartPos( const SvxPosition& rPos )
+{
+ delete pSttNd;
+ pSttNd = rPos.MakeNodeIdx();
+ nSttCnt = rPos.GetCntIdx();
+ pEndNd = pSttNd;
+ nEndCnt = nEndCnt;
+}
+#else
+void SvxRTFItemStackType::SetStartPos( const SvxPosition& rPos )
+{
+ if (pSttNd != pEndNd)
+ delete pEndNd;
+ delete pSttNd;
+ pSttNd = rPos.MakeNodeIdx();
+ pEndNd = pSttNd;
+ nSttCnt = rPos.GetCntIdx();
+}
+#endif
+
+void SvxRTFItemStackType::MoveFullNode(const SvxNodeIdx &rOldNode,
+ const SvxNodeIdx &rNewNode)
+{
+ bool bSameEndAsStart = (pSttNd == pEndNd) ? true : false;
+
+ if (GetSttNodeIdx() == rOldNode.GetIdx())
+ {
+ delete pSttNd;
+ pSttNd = rNewNode.Clone();
+ if (bSameEndAsStart)
+ pEndNd = pSttNd;
+ }
+
+ if (!bSameEndAsStart && GetEndNodeIdx() == rOldNode.GetIdx())
+ {
+ delete pEndNd;
+ pEndNd = rNewNode.Clone();
+ }
+
+ //And the same for all the children
+ USHORT nCount = pChildList ? pChildList->Count() : 0;
+ for (USHORT i = 0; i < nCount; ++i)
+ {
+ SvxRTFItemStackType* pStk = (*pChildList)[i];
+ pStk->MoveFullNode(rOldNode, rNewNode);
+ }
+}
+
+bool SvxRTFParser::UncompressableStackEntry(const SvxRTFItemStackType &) const
+{
+ return false;
+}
+
+void SvxRTFItemStackType::Compress( const SvxRTFParser& rParser )
+{
+ DBG_ASSERT( pChildList, "es gibt keine ChildListe" );
+
+ USHORT n;
+ SvxRTFItemStackType* pTmp = (*pChildList)[0];
+
+ if( !pTmp->aAttrSet.Count() ||
+ pSttNd->GetIdx() != pTmp->pSttNd->GetIdx() ||
+ nSttCnt != pTmp->nSttCnt )
+ return;
+
+ SvxNodeIdx* pLastNd = pTmp->pEndNd;
+ xub_StrLen nLastCnt = pTmp->nEndCnt;
+
+ SfxItemSet aMrgSet( pTmp->aAttrSet );
+ for( n = 1; n < pChildList->Count(); ++n )
+ {
+ pTmp = (*pChildList)[n];
+ if( pTmp->pChildList )
+ pTmp->Compress( rParser );
+
+ if( !pTmp->nSttCnt
+ ? (pLastNd->GetIdx()+1 != pTmp->pSttNd->GetIdx() ||
+ !rParser.IsEndPara( pLastNd, nLastCnt ) )
+ : ( pTmp->nSttCnt != nLastCnt ||
+ pLastNd->GetIdx() != pTmp->pSttNd->GetIdx() ))
+ {
+ while( ++n < pChildList->Count() )
+ if( (pTmp = (*pChildList)[n])->pChildList )
+ pTmp->Compress( rParser );
+ return;
+ }
+
+ if (rParser.UncompressableStackEntry(*pTmp))
+ return;
+
+ if( n )
+ {
+ // suche alle, die ueber den gesamten Bereich gesetzt sind
+ SfxItemIter aIter( aMrgSet );
+ const SfxPoolItem* pItem;
+ do {
+ USHORT nWhich = aIter.GetCurItem()->Which();
+ if( SFX_ITEM_SET != pTmp->aAttrSet.GetItemState( nWhich,
+ FALSE, &pItem ) || *pItem != *aIter.GetCurItem() )
+ aMrgSet.ClearItem( nWhich );
+
+ if( aIter.IsAtEnd() )
+ break;
+ aIter.NextItem();
+ } while( TRUE );
+
+ if( !aMrgSet.Count() )
+ return;
+ }
+
+ pLastNd = pTmp->pEndNd;
+ nLastCnt = pTmp->nEndCnt;
+ }
+
+ if( pEndNd->GetIdx() != pLastNd->GetIdx() || nEndCnt != nLastCnt )
+ return;
+
+ // es kann zusammengefasst werden
+ aAttrSet.Put( aMrgSet );
+
+ for( n = 0; n < pChildList->Count(); ++n )
+ {
+ pTmp = (*pChildList)[n];
+ pTmp->aAttrSet.Differentiate( aMrgSet );
+
+ if( !pTmp->pChildList && !pTmp->aAttrSet.Count() && !pTmp->nStyleNo )
+ {
+ pChildList->Remove( n );
+ delete pTmp;
+ --n;
+ continue;
+ }
+ }
+ if( !pChildList->Count() )
+ {
+ delete pChildList;
+ pChildList = 0;
+ }
+}
+void SvxRTFItemStackType::SetRTFDefaults( const SfxItemSet& rDefaults )
+{
+ if( rDefaults.Count() )
+ {
+ SfxItemIter aIter( rDefaults );
+ do {
+ USHORT nWhich = aIter.GetCurItem()->Which();
+ if( SFX_ITEM_SET != aAttrSet.GetItemState( nWhich, FALSE ))
+ aAttrSet.Put( *aIter.GetCurItem() );
+
+ if( aIter.IsAtEnd() )
+ break;
+ aIter.NextItem();
+ } while( TRUE );
+ }
+}
+
+/* */
+
+RTFPlainAttrMapIds::RTFPlainAttrMapIds( const SfxItemPool& rPool )
+{
+ nCaseMap = rPool.GetTrueWhich( SID_ATTR_CHAR_CASEMAP, FALSE );
+ nBgColor = rPool.GetTrueWhich( SID_ATTR_BRUSH_CHAR, FALSE );
+ nColor = rPool.GetTrueWhich( SID_ATTR_CHAR_COLOR, FALSE );
+ nContour = rPool.GetTrueWhich( SID_ATTR_CHAR_CONTOUR, FALSE );
+ nCrossedOut = rPool.GetTrueWhich( SID_ATTR_CHAR_STRIKEOUT, FALSE );
+ nEscapement = rPool.GetTrueWhich( SID_ATTR_CHAR_ESCAPEMENT, FALSE );
+ nFont = rPool.GetTrueWhich( SID_ATTR_CHAR_FONT, FALSE );
+ nFontHeight = rPool.GetTrueWhich( SID_ATTR_CHAR_FONTHEIGHT, FALSE );
+ nKering = rPool.GetTrueWhich( SID_ATTR_CHAR_KERNING, FALSE );
+ nLanguage = rPool.GetTrueWhich( SID_ATTR_CHAR_LANGUAGE, FALSE );
+ nPosture = rPool.GetTrueWhich( SID_ATTR_CHAR_POSTURE, FALSE );
+ nShadowed = rPool.GetTrueWhich( SID_ATTR_CHAR_SHADOWED, FALSE );
+ nUnderline = rPool.GetTrueWhich( SID_ATTR_CHAR_UNDERLINE, FALSE );
+ nOverline = rPool.GetTrueWhich( SID_ATTR_CHAR_OVERLINE, FALSE );
+ nWeight = rPool.GetTrueWhich( SID_ATTR_CHAR_WEIGHT, FALSE );
+ nWordlineMode = rPool.GetTrueWhich( SID_ATTR_CHAR_WORDLINEMODE, FALSE );
+ nAutoKerning = rPool.GetTrueWhich( SID_ATTR_CHAR_AUTOKERN, FALSE );
+
+ nCJKFont = rPool.GetTrueWhich( SID_ATTR_CHAR_CJK_FONT, FALSE );
+ nCJKFontHeight = rPool.GetTrueWhich( SID_ATTR_CHAR_CJK_FONTHEIGHT, FALSE );
+ nCJKLanguage = rPool.GetTrueWhich( SID_ATTR_CHAR_CJK_LANGUAGE, FALSE );
+ nCJKPosture = rPool.GetTrueWhich( SID_ATTR_CHAR_CJK_POSTURE, FALSE );
+ nCJKWeight = rPool.GetTrueWhich( SID_ATTR_CHAR_CJK_WEIGHT, FALSE );
+ nCTLFont = rPool.GetTrueWhich( SID_ATTR_CHAR_CTL_FONT, FALSE );
+ nCTLFontHeight = rPool.GetTrueWhich( SID_ATTR_CHAR_CTL_FONTHEIGHT, FALSE );
+ nCTLLanguage = rPool.GetTrueWhich( SID_ATTR_CHAR_CTL_LANGUAGE, FALSE );
+ nCTLPosture = rPool.GetTrueWhich( SID_ATTR_CHAR_CTL_POSTURE, FALSE );
+ nCTLWeight = rPool.GetTrueWhich( SID_ATTR_CHAR_CTL_WEIGHT, FALSE );
+ nEmphasis = rPool.GetTrueWhich( SID_ATTR_CHAR_EMPHASISMARK, FALSE );
+ nTwoLines = rPool.GetTrueWhich( SID_ATTR_CHAR_TWO_LINES, FALSE );
+ nRuby = 0; //rPool.GetTrueWhich( SID_ATTR_CHAR_CJK_RUBY, FALSE );
+ nCharScaleX = rPool.GetTrueWhich( SID_ATTR_CHAR_SCALEWIDTH, FALSE );
+ nHorzVert = rPool.GetTrueWhich( SID_ATTR_CHAR_ROTATED, FALSE );
+ nRelief = rPool.GetTrueWhich( SID_ATTR_CHAR_RELIEF, FALSE );
+ nHidden = rPool.GetTrueWhich( SID_ATTR_CHAR_HIDDEN, FALSE );
+}
+
+RTFPardAttrMapIds ::RTFPardAttrMapIds ( const SfxItemPool& rPool )
+{
+ nLinespacing = rPool.GetTrueWhich( SID_ATTR_PARA_LINESPACE, FALSE );
+ nAdjust = rPool.GetTrueWhich( SID_ATTR_PARA_ADJUST, FALSE );
+ nTabStop = rPool.GetTrueWhich( SID_ATTR_TABSTOP, FALSE );
+ nHyphenzone = rPool.GetTrueWhich( SID_ATTR_PARA_HYPHENZONE, FALSE );
+ nLRSpace = rPool.GetTrueWhich( SID_ATTR_LRSPACE, FALSE );
+ nULSpace = rPool.GetTrueWhich( SID_ATTR_ULSPACE, FALSE );
+ nBrush = rPool.GetTrueWhich( SID_ATTR_BRUSH, FALSE );
+ nBox = rPool.GetTrueWhich( SID_ATTR_BORDER_OUTER, FALSE );
+ nShadow = rPool.GetTrueWhich( SID_ATTR_BORDER_SHADOW, FALSE );
+ nOutlineLvl = rPool.GetTrueWhich( SID_ATTR_PARA_OUTLLEVEL, FALSE );
+ nSplit = rPool.GetTrueWhich( SID_ATTR_PARA_SPLIT, FALSE );
+ nKeep = rPool.GetTrueWhich( SID_ATTR_PARA_KEEP, FALSE );
+ nFontAlign = rPool.GetTrueWhich( SID_PARA_VERTALIGN, FALSE );
+ nScriptSpace = rPool.GetTrueWhich( SID_ATTR_PARA_SCRIPTSPACE, FALSE );
+ nHangPunct = rPool.GetTrueWhich( SID_ATTR_PARA_HANGPUNCTUATION, FALSE );
+ nForbRule = rPool.GetTrueWhich( SID_ATTR_PARA_FORBIDDEN_RULES, FALSE );
+ nDirection = rPool.GetTrueWhich( SID_ATTR_FRAMEDIRECTION, FALSE );
+}
+
+/* vi:set tabstop=4 shiftwidth=4 expandtab: */