summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-03-14 11:06:16 +0000
committerCaolán McNamara <caolanm@redhat.com>2012-03-14 11:06:16 +0000
commitcfa62900291dc2d89793044a045ac1f29ca8b128 (patch)
tree2acc1c9a75966329d88d4a12eabc1cdc17c7b186
parent8eda3f334d982f1533e87e28edc549da224d10f4 (diff)
Resolves: fdo#45521 restore ascii export for getTextFromPam
We need getTextFromPam to get the text of a selection for the uno api, which some parts of the export to xml require
-rw-r--r--binfilter/bf_sw/source/core/unocore/sw_unoobj.cxx36
-rw-r--r--binfilter/bf_sw/source/filter/ascii/makefile.mk2
-rw-r--r--binfilter/bf_sw/source/filter/ascii/sw_ascatr.cxx226
-rw-r--r--binfilter/bf_sw/source/filter/ascii/sw_wrtasc.cxx234
-rw-r--r--binfilter/bf_sw/source/filter/ascii/wrtasc.hxx57
-rw-r--r--binfilter/bf_sw/source/filter/basflt/sw_shellio.cxx133
-rw-r--r--binfilter/bf_sw/source/filter/inc/wrt_fn.hxx76
-rw-r--r--binfilter/bf_sw/source/filter/makefile.mk1
-rw-r--r--binfilter/bf_sw/source/filter/writer/makefile.mk4
-rw-r--r--binfilter/bf_sw/source/filter/writer/sw_writer.cxx361
-rw-r--r--binfilter/bf_sw/source/filter/writer/sw_wrt_fn.cxx129
-rw-r--r--binfilter/inc/bf_sw/shellio.hxx117
-rw-r--r--binfilter/inc/bf_sw/undobj.hxx60
13 files changed, 1425 insertions, 11 deletions
diff --git a/binfilter/bf_sw/source/core/unocore/sw_unoobj.cxx b/binfilter/bf_sw/source/core/unocore/sw_unoobj.cxx
index b65f33efe..e101cb4ae 100644
--- a/binfilter/bf_sw/source/core/unocore/sw_unoobj.cxx
+++ b/binfilter/bf_sw/source/core/unocore/sw_unoobj.cxx
@@ -255,7 +255,7 @@ void SwXTextCursor::SelectPam(SwPaM& rCrsr, sal_Bool bExpand)
}
-void SwXTextCursor::getTextFromPam(SwPaM& aCrsr, OUString&)
+void SwXTextCursor::getTextFromPam(SwPaM& aCrsr, OUString& rBuffer)
{
if(!aCrsr.HasMark())
return;
@@ -265,22 +265,40 @@ void SwXTextCursor::getTextFromPam(SwPaM& aCrsr, OUString&)
#else
aStream.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
#endif
-/* this part is commented out since is not more executable due to the
- deletion of the Writer class.
- Investigation needs to be done in order to know if the function can be
- removed too, or needs to be adapted
-*/
-/* WriterRef xWrt;
- SwIoSystem::GetWriter( C2S(FILTER_TEXT_DLG), xWrt );
+ WriterRef xWrt = GetASCWriter(C2S(FILTER_TEXT_DLG));
if( xWrt.Is() )
{
+ SwWriter aWriter( aStream, aCrsr );
xWrt->bASCII_NoLastLineEnd = sal_True;
SwAsciiOptions aOpt = xWrt->GetAsciiOptions();
aOpt.SetCharSet( RTL_TEXTENCODING_UNICODE );
xWrt->SetAsciiOptions( aOpt );
xWrt->bUCS2_WithStartChar = FALSE;
+
+ long lLen;
+ if( !IsError( aWriter.Write( xWrt ) ) &&
+ STRING_MAXLEN > (( lLen = aStream.GetSize() )
+ / sizeof( sal_Unicode )) + 1 )
+ {
+ aStream << (sal_Unicode)'\0';
+
+ String sBuf;
+ const sal_Unicode *p = (sal_Unicode*)aStream.GetBuffer();
+ if( p )
+ sBuf = p;
+ else
+ {
+ long lUniLen = (lLen / sizeof( sal_Unicode ));
+ sal_Unicode* pStrBuf = sBuf.AllocBuffer( xub_StrLen(
+ lUniLen + 1));
+ aStream.Seek( 0 );
+ aStream.ResetError();
+ aStream.Read( pStrBuf, lLen );
+ pStrBuf[ lUniLen ] = '\0';
+ }
+ rBuffer = OUString( sBuf );
+ }
}
-*/
}
void lcl_setCharStyle(SwDoc* pDoc, const uno::Any aValue, SfxItemSet& rSet)
diff --git a/binfilter/bf_sw/source/filter/ascii/makefile.mk b/binfilter/bf_sw/source/filter/ascii/makefile.mk
index c6539972e..5b57a4424 100644
--- a/binfilter/bf_sw/source/filter/ascii/makefile.mk
+++ b/binfilter/bf_sw/source/filter/ascii/makefile.mk
@@ -42,6 +42,8 @@ INC+= -I$(PRJ)$/inc$/bf_sw
# --- Files --------------------------------------------------------
SLOFILES = \
+ $(SLO)$/sw_ascatr.obj \
+ $(SLO)$/sw_wrtasc.obj
# --- Tagets -------------------------------------------------------
diff --git a/binfilter/bf_sw/source/filter/ascii/sw_ascatr.cxx b/binfilter/bf_sw/source/filter/ascii/sw_ascatr.cxx
new file mode 100644
index 000000000..30247ec42
--- /dev/null
+++ b/binfilter/bf_sw/source/filter/ascii/sw_ascatr.cxx
@@ -0,0 +1,226 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifdef _MSC_VER
+#pragma hdrstop
+#endif
+
+#include <hintids.hxx>
+
+#include <tools/stream.hxx>
+#ifndef _SVSTDARR_HXX
+#define _SVSTDARR_USHORTS
+#endif
+
+#include <pam.hxx>
+
+#include <horiornt.hxx>
+
+#include <doc.hxx>
+#include <ndtxt.hxx>
+#include <wrtasc.hxx>
+#include <txtfld.hxx>
+#include <fmtftn.hxx>
+#include <fmtfld.hxx>
+#include <fldbas.hxx>
+#include <ftninfo.hxx>
+namespace binfilter {
+
+/*
+ * Dieses File enthaelt alle Ausgabe-Funktionen des ASCII-Writers;
+ * fuer alle Nodes, Attribute, Formate und Chars.
+ */
+
+class SwASC_AttrIter
+{
+ SwASCWriter& rWrt;
+ const SwTxtNode& rNd;
+ xub_StrLen nAktSwPos;
+
+ xub_StrLen SearchNext( xub_StrLen nStartPos );
+
+public:
+ SwASC_AttrIter( SwASCWriter& rWrt, const SwTxtNode& rNd, xub_StrLen nStt );
+
+ void NextPos() { nAktSwPos = SearchNext( nAktSwPos + 1 ); }
+
+ xub_StrLen WhereNext() const { return nAktSwPos; }
+ BOOL OutAttr( xub_StrLen nSwPos );
+};
+
+
+/*N*/ SwASC_AttrIter::SwASC_AttrIter( SwASCWriter& rWr, const SwTxtNode& rTxtNd,
+/*N*/ xub_StrLen nStt )
+/*N*/ : rWrt( rWr ), rNd( rTxtNd ), nAktSwPos( 0 )
+/*N*/ {
+/*N*/ nAktSwPos = SearchNext( nStt + 1 );
+/*N*/ }
+
+
+/*N*/ xub_StrLen SwASC_AttrIter::SearchNext( xub_StrLen nStartPos )
+/*N*/ {
+/*N*/ register xub_StrLen nMinPos = STRING_MAXLEN;
+/*N*/ const SwpHints* pTxtAttrs = rNd.GetpSwpHints();
+/*N*/ if( pTxtAttrs )
+/*N*/ {
+/*?*/ register USHORT i;
+/*?*/ register xub_StrLen nPos;
+/*?*/ const xub_StrLen * pPos;
+/*?*/
+/*?*/ // kann noch optimiert werden, wenn ausgenutzt wird, dass die TxtAttrs
+/*?*/ // nach der Anfangsposition geordnet sind. Dann muessten
+/*?*/ // allerdings noch 2 Indices gemerkt werden
+/*?*/ for( i = 0; i < pTxtAttrs->Count(); i++ )
+/*?*/ {
+/*?*/ const SwTxtAttr* pHt = (*pTxtAttrs)[i];
+/*?*/ nPos = *pHt->GetStart(); // gibt erstes Attr-Zeichen
+/*?*/ pPos = pHt->GetEnd();
+/*?*/ if( !pPos )
+/*?*/ {
+/*?*/ if( nPos >= nStartPos && nPos <= nMinPos )
+/*?*/ nMinPos = nPos;
+/*?*/
+/*?*/ if( ( ++nPos ) >= nStartPos && nPos < nMinPos )
+/*?*/ nMinPos = nPos;
+/*?*/ }
+/*?*/ }
+/*N*/ }
+/*N*/ return nMinPos;
+/*N*/ }
+
+
+/*N*/ BOOL SwASC_AttrIter::OutAttr( xub_StrLen nSwPos )
+/*N*/ {
+/*N*/ BOOL bRet = FALSE;
+/*N*/ const SwpHints* pTxtAttrs = rNd.GetpSwpHints();
+/*N*/ if( pTxtAttrs )
+/*N*/ {
+/*?*/ register USHORT i;
+/*?*/ for( i = 0; i < pTxtAttrs->Count(); i++ )
+/*?*/ {
+/*?*/ const SwTxtAttr* pHt = (*pTxtAttrs)[i];
+/*?*/ const xub_StrLen * pEnd = pHt->GetEnd();
+/*?*/ if( !pEnd && nSwPos == *pHt->GetStart() )
+/*?*/ {
+/*?*/ bRet = TRUE;
+/*?*/ String sOut;
+/*?*/ switch( pHt->Which() )
+/*?*/ {
+/*?*/ case RES_TXTATR_FIELD:
+/*?*/ sOut = ((SwTxtFld*)pHt)->GetFld().GetFld()->Expand();
+/*?*/ break;
+/*?*/
+/*?*/ case RES_TXTATR_HARDBLANK:
+ {DBG_BF_ASSERT(0, "STRIP");}
+/*?*/ break;
+/*?*/
+/*?*/ case RES_TXTATR_FTN:
+/*?*/ {
+/*?*/ const SwFmtFtn& rFtn = pHt->GetFtn();
+/*?*/ if( rFtn.GetNumStr().Len() )
+/*?*/ sOut = rFtn.GetNumStr();
+/*?*/ else if( rFtn.IsEndNote() )
+/*?*/ sOut = rWrt.pDoc->GetEndNoteInfo().aFmt.
+/*?*/ GetNumStr( rFtn.GetNumber() );
+/*?*/ else
+/*?*/ sOut = rWrt.pDoc->GetFtnInfo().aFmt.
+/*?*/ GetNumStr( rFtn.GetNumber() );
+/*?*/ }
+/*?*/ break;
+/*?*/ }
+/*?*/ if( sOut.Len() )
+/*?*/ rWrt.Strm().WriteUnicodeOrByteText( sOut );
+/*?*/ }
+/*?*/ else if( nSwPos < *pHt->GetStart() )
+/*?*/ break;
+/*?*/ }
+/*N*/ }
+/*N*/ return bRet;
+/*N*/ }
+
+
+//------------------------
+/* Ausgabe der Nodes */
+//------------------------
+
+/*N*/ static Writer& OutASC_SwTxtNode( Writer& rWrt, SwCntntNode& rNode )
+/*N*/ {
+/*N*/ const SwTxtNode& rNd = (SwTxtNode&)rNode;
+/*N*/
+/*N*/ xub_StrLen nStrPos = rWrt.pCurPam->GetPoint()->nContent.GetIndex();
+/*N*/ xub_StrLen nNodeEnde = rNd.Len(), nEnde = nNodeEnde;
+/*N*/ BOOL bLastNd = rWrt.pCurPam->GetPoint()->nNode == rWrt.pCurPam->GetMark()->nNode;
+/*N*/ if( bLastNd )
+/*N*/ nEnde = rWrt.pCurPam->GetMark()->nContent.GetIndex();
+/*N*/
+/*N*/ SwASC_AttrIter aAttrIter( (SwASCWriter&)rWrt, rNd, nStrPos );
+/*N*/
+/*N*/ if( !nStrPos )
+/*N*/ rWrt.Strm().WriteUnicodeOrByteText( rNd.GetNumString() );
+/*N*/
+/*N*/ String aStr( rNd.GetTxt() );
+/*N*/ if( rWrt.bASCII_ParaAsBlanc )
+/*?*/ aStr.SearchAndReplaceAll( 0x0A, ' ' );
+/*N*/
+/*N*/ do {
+/*N*/ xub_StrLen nNextAttr = aAttrIter.WhereNext();
+/*N*/
+/*N*/ if( nNextAttr > nEnde )
+/*N*/ nNextAttr = nEnde;
+/*N*/
+/*N*/ if( !aAttrIter.OutAttr( nStrPos ))
+/*N*/ rWrt.Strm().WriteUnicodeOrByteText(
+/*N*/ aStr.Copy( nStrPos, nNextAttr - nStrPos ));
+/*N*/ nStrPos = nNextAttr;
+/*N*/ aAttrIter.NextPos();
+/*N*/ } while( nStrPos < nEnde );
+/*N*/
+/*N*/ if( !bLastNd ||
+/*N*/ (( !rWrt.bWriteClipboardDoc && !rWrt.bASCII_NoLastLineEnd )
+/*N*/ && !nStrPos && nEnde == nNodeEnde ))
+/*?*/ rWrt.Strm().WriteUnicodeOrByteText( ((SwASCWriter&)rWrt).GetLineEnd());
+/*N*/
+/*N*/ return rWrt;
+/*N*/ }
+
+/*
+ * lege hier jetzt die Tabellen fuer die ASCII-Funktions-Pointer auf
+ * die Ausgabe-Funktionen an.
+ * Es sind lokale Strukturen, die nur innerhalb der ASCII-DLL
+ * bekannt sein muessen.
+ */
+
+SwNodeFnTab aASCNodeFnTab = {
+/* RES_TXTNODE */ OutASC_SwTxtNode,
+/* RES_GRFNODE */ 0,
+/* RES_OLENODE */ 0
+};
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_sw/source/filter/ascii/sw_wrtasc.cxx b/binfilter/bf_sw/source/filter/ascii/sw_wrtasc.cxx
new file mode 100644
index 000000000..41a573c2b
--- /dev/null
+++ b/binfilter/bf_sw/source/filter/ascii/sw_wrtasc.cxx
@@ -0,0 +1,234 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifdef _MSC_VER
+#pragma hdrstop
+#endif
+
+
+#include <tools/stream.hxx>
+
+#include <pam.hxx>
+
+#include <horiornt.hxx>
+
+#include <doc.hxx>
+#include <ndtxt.hxx>
+#include <mdiexp.hxx> // ...Percent()
+#include <docary.hxx>
+#include <fmtcntnt.hxx>
+#include <frmfmt.hxx>
+#include <wrtasc.hxx>
+
+#include <statstr.hrc> // ResId fuer Statusleiste
+#include <osl/endian.h>
+namespace binfilter {
+
+//-----------------------------------------------------------------
+
+/*N*/ SwASCWriter::SwASCWriter( const String& rFltNm )
+/*N*/ {
+/*N*/ SwAsciiOptions aNewOpts;
+/*N*/
+/*N*/ switch( 5 <= rFltNm.Len() ? rFltNm.GetChar( 4 ) : 0 )
+/*N*/ {
+/*?*/ case 'D':
+/*?*/ #if !defined(PM2)
+/*?*/ aNewOpts.SetCharSet( RTL_TEXTENCODING_IBM_850 );
+/*?*/ aNewOpts.SetParaFlags( LINEEND_CRLF );
+/*?*/ #endif
+/*?*/ if( 5 < rFltNm.Len() )
+/*?*/ switch( rFltNm.Copy( 5 ).ToInt32() )
+/*?*/ {
+/*?*/ case 437: aNewOpts.SetCharSet( RTL_TEXTENCODING_IBM_437 ); break;
+/*?*/ case 850: aNewOpts.SetCharSet( RTL_TEXTENCODING_IBM_850 ); break;
+/*?*/ case 860: aNewOpts.SetCharSet( RTL_TEXTENCODING_IBM_860 ); break;
+/*?*/ case 861: aNewOpts.SetCharSet( RTL_TEXTENCODING_IBM_861 ); break;
+/*?*/ case 863: aNewOpts.SetCharSet( RTL_TEXTENCODING_IBM_863 ); break;
+/*?*/ case 865: aNewOpts.SetCharSet( RTL_TEXTENCODING_IBM_865 ); break;
+/*?*/ }
+/*?*/ break;
+/*?*/
+/*?*/ case 'A':
+/*?*/ #if !defined(WIN) && !defined(WNT)
+/*?*/ aNewOpts.SetCharSet( RTL_TEXTENCODING_MS_1252 );
+/*?*/ aNewOpts.SetParaFlags( LINEEND_CRLF );
+/*?*/ #endif
+/*?*/ break;
+/*?*/
+/*?*/ case 'M':
+/*?*/ #if !defined(MAC)
+/*?*/ aNewOpts.SetCharSet( RTL_TEXTENCODING_APPLE_ROMAN );
+/*?*/ aNewOpts.SetParaFlags( LINEEND_CR );
+/*?*/ #endif
+/*?*/ break;
+/*?*/
+/*?*/ case 'X':
+/*?*/ #if !defined(UNX)
+/*?*/ aNewOpts.SetCharSet( RTL_TEXTENCODING_MS_1252 );
+/*?*/ aNewOpts.SetParaFlags( LINEEND_LF );
+/*?*/ #endif
+/*?*/ break;
+/*?*/
+/*N*/ default:
+/*N*/ if( rFltNm.Copy( 4 ).EqualsAscii( "_DLG" ))
+/*N*/ {
+/*N*/ // use the options
+/*N*/ aNewOpts = GetAsciiOptions();
+/*N*/ }
+/*N*/ }
+/*N*/ SetAsciiOptions( aNewOpts );
+/*N*/ }
+
+
+/*N*/ ULONG SwASCWriter::WriteStream()
+/*N*/ {
+/*N*/ sal_Char cLineEnd[ 3 ];
+/*N*/ sal_Char* pCEnd = cLineEnd;
+/*N*/ if( bASCII_ParaAsCR ) // falls vorgegeben ist.
+/*?*/ *pCEnd++ = '\015';
+/*N*/ else if( bASCII_ParaAsBlanc )
+/*?*/ *pCEnd++ = ' ';
+/*N*/ else
+/*N*/ switch( GetAsciiOptions().GetParaFlags() )
+/*N*/ {
+/*?*/ case LINEEND_CR: *pCEnd++ = '\015'; break;
+/*?*/ case LINEEND_LF: *pCEnd++ = '\012'; break;
+/*N*/ case LINEEND_CRLF: *pCEnd++ = '\015', *pCEnd++ = '\012'; break;
+/*N*/ }
+/*N*/ *pCEnd = 0;
+/*N*/
+/*N*/ sLineEnd.AssignAscii( cLineEnd );
+/*N*/
+/*N*/ long nMaxNode = pDoc->GetNodes().Count();
+/*N*/
+/*N*/ if( bShowProgress )
+/*N*/ ::binfilter::StartProgress( STR_STATSTR_W4WWRITE, 0, nMaxNode, pDoc->GetDocShell() );
+/*N*/
+/*N*/ SwPaM* pPam = pOrigPam;
+/*N*/
+/*N*/ BOOL bWriteSttTag = bUCS2_WithStartChar &&
+/*M*/ (RTL_TEXTENCODING_UCS2 == GetAsciiOptions().GetCharSet() ||
+/*M*/ RTL_TEXTENCODING_UTF8 == GetAsciiOptions().GetCharSet());
+/*N*/
+/*N*/ rtl_TextEncoding eOld = Strm().GetStreamCharSet();
+/*N*/ Strm().SetStreamCharSet( GetAsciiOptions().GetCharSet() );
+/*N*/
+/*N*/ // gebe alle Bereich des Pams in das ASC-File aus.
+/*N*/ do {
+/*N*/ BOOL bTstFly = TRUE;
+/*N*/ while( pCurPam->GetPoint()->nNode.GetIndex() < pCurPam->GetMark()->nNode.GetIndex() ||
+/*N*/ (pCurPam->GetPoint()->nNode.GetIndex() == pCurPam->GetMark()->nNode.GetIndex() &&
+/*N*/ pCurPam->GetPoint()->nContent.GetIndex() <= pCurPam->GetMark()->nContent.GetIndex()) )
+/*N*/ {
+/*N*/ SwTxtNode* pNd = pCurPam->GetPoint()->nNode.GetNode().GetTxtNode();
+/*N*/ if( pNd )
+/*N*/ {
+/*N*/ // sollten nur Rahmen vorhanden sein?
+/*N*/ // (Moeglich, wenn Rahmen-Selektion ins Clipboard
+/*N*/ // gestellt wurde)
+/*N*/ if( bTstFly && bWriteAll &&
+/*N*/ // keine Laenge
+/*N*/ !pNd->GetTxt().Len() &&
+/*N*/ // Rahmen vorhanden
+/*N*/ pDoc->GetSpzFrmFmts()->Count() &&
+/*N*/ // nur ein Node im Array
+/*N*/ pDoc->GetNodes().GetEndOfExtras().GetIndex() + 3 ==
+/*N*/ pDoc->GetNodes().GetEndOfContent().GetIndex() &&
+/*N*/ // und genau der ist selektiert
+/*N*/ pDoc->GetNodes().GetEndOfContent().GetIndex() - 1 ==
+/*N*/ pCurPam->GetPoint()->nNode.GetIndex() )
+/*N*/ {
+/*N*/ // dann den Inhalt vom Rahmen ausgeben.
+/*N*/ // dieser steht immer an Position 0 !!
+/*?*/ SwFrmFmt* pFmt = (*pDoc->GetSpzFrmFmts())[ 0 ];
+/*?*/ const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
+/*?*/ if( pIdx )
+/*?*/ {
+/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 delete pCurPam;
+/*N*/ }
+/*N*/ }
+/*N*/ else
+/*M*/ {
+/*M*/ if (bWriteSttTag)
+/*M*/ {
+/*M*/ switch(GetAsciiOptions().GetCharSet())
+/*M*/ {
+/*M*/ case RTL_TEXTENCODING_UTF8:
+/*M*/ Strm() << BYTE(0xEF) << BYTE(0xBB) <<
+/*M*/ BYTE(0xBF);
+/*M*/ break;
+/*M*/ case RTL_TEXTENCODING_UCS2:
+/*M*/ //Strm().StartWritingUnicodeText();
+/*M*/ Strm().SetEndianSwap(FALSE);
+/*M*/ #ifdef OSL_LITENDIAN
+/*M*/ Strm() << BYTE(0xFF) << BYTE(0xFE);
+/*M*/ #else
+/*M*/ Strm() << BYTE(0xFE) << BYTE(0xFF);
+/*M*/ #endif
+/*M*/ break;
+/*M*/
+/*M*/ }
+/*?*/ bWriteSttTag = FALSE;
+/*N*/ }
+/*N*/ Out( aASCNodeFnTab, *pNd, *this );
+/*N*/ }
+/*N*/ bTstFly = FALSE; // eimal Testen reicht
+/*N*/ }
+/*N*/
+/*N*/ if( !pCurPam->Move( fnMoveForward, fnGoNode ) )
+/*N*/ break;
+/*N*/
+/*N*/ if( bShowProgress )
+/*N*/ ::binfilter::SetProgressState( pCurPam->GetPoint()->nNode.GetIndex(),
+/*N*/ pDoc->GetDocShell() ); // Wie weit ?
+/*N*/
+/*N*/ }
+/*N*/ } while( CopyNextPam( &pPam ) ); // bis alle Pam bearbeitet
+/*N*/
+/*N*/ Strm().SetStreamCharSet( eOld );
+/*N*/
+/*N*/ if( bShowProgress )
+/*N*/ ::binfilter::EndProgress( pDoc->GetDocShell() );
+/*N*/
+/*N*/ return 0;
+/*N*/ }
+
+
+/*N*/ SwASCWriter::~SwASCWriter() {}
+
+/*N*/ WriterRef GetASCWriter( const String& rFltNm )
+/*N*/ {
+/*N*/ return new SwASCWriter( rFltNm );
+/*N*/ }
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_sw/source/filter/ascii/wrtasc.hxx b/binfilter/bf_sw/source/filter/ascii/wrtasc.hxx
new file mode 100644
index 000000000..8332e6a94
--- /dev/null
+++ b/binfilter/bf_sw/source/filter/ascii/wrtasc.hxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _WRTASC_HXX
+#define _WRTASC_HXX
+
+#include <shellio.hxx>
+#include <wrt_fn.hxx>
+namespace binfilter {
+
+extern SwNodeFnTab aASCNodeFnTab;
+
+
+// der ASC-Writer
+
+class SwASCWriter : public Writer
+{
+ String sLineEnd;
+
+ virtual ULONG WriteStream();
+
+public:
+ SwASCWriter( const String& rFilterName );
+ virtual ~SwASCWriter();
+
+ const String& GetLineEnd() const { return sLineEnd; }
+};
+
+
+} //namespace binfilter
+#endif // _WRTASC_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_sw/source/filter/basflt/sw_shellio.cxx b/binfilter/bf_sw/source/filter/basflt/sw_shellio.cxx
index 6ca07034c..d22771878 100644
--- a/binfilter/bf_sw/source/filter/basflt/sw_shellio.cxx
+++ b/binfilter/bf_sw/source/filter/basflt/sw_shellio.cxx
@@ -53,8 +53,9 @@
#include <doc.hxx>
#include <pagedesc.hxx>
#include <poolfmt.hxx>
-#include <fltini.hxx>
+#include <crsrsh.hxx>
#include <docsh.hxx>
+#include <fltini.hxx>
#include <redline.hxx>
#include <linkenum.hxx>
#include <swerror.h>
@@ -425,6 +426,136 @@ void Reader::SetNoOutlineNum( SwDoc& /*rDoc*/ )
{
}
+/*N*/ SwWriter::SwWriter( SvStream& rStrm, SwPaM& rPam, BOOL bInWriteAll )
+/*N*/ : pStrm( &rStrm ),
+/*N*/ pOutPam( &rPam ),
+/*N*/ pShell( 0 ),
+/*N*/ rDoc( *rPam.GetDoc() ),
+/*N*/ bWriteAll( bInWriteAll )
+/*N*/ {
+/*N*/ }
+
+/*N*/ ULONG SwWriter::Write( WriterRef& rxWriter )
+/*N*/ {
+/*N*/ BOOL bHasMark = FALSE;
+/*N*/ SwPaM * pPam;
+/*N*/
+/*N*/ SwDoc *pDoc = 0L;
+/*N*/ SvEmbeddedObjectRef* pRefForDocSh = 0;
+/*N*/
+/*N*/ if ( pShell && !bWriteAll && pShell->IsTableMode() )
+/*N*/ {
+/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 bWriteAll = TRUE;
+/*N*/ }
+/*N*/
+/*N*/ if( !bWriteAll && ( pShell || pOutPam ))
+/*N*/ {
+/*N*/ if( pShell )
+/*?*/ pPam = pShell->GetCrsr();
+/*N*/ else
+/*N*/ pPam = pOutPam;
+/*N*/
+/*N*/ SwPaM *pEnd = pPam;
+/*N*/
+/*N*/ // Erste Runde: Nachsehen, ob eine Selektion besteht.
+/*N*/ while(TRUE)
+/*N*/ {
+/*N*/ bHasMark = bHasMark || pPam->HasMark();
+/*N*/ pPam = (SwPaM *) pPam->GetNext();
+/*N*/ if(bHasMark || pPam == pEnd)
+/*N*/ break;
+/*N*/ }
+/*N*/
+/*N*/ // Wenn keine Selektion besteht, eine ueber das ganze Dokument aufspannen.
+/*N*/ if(!bHasMark)
+/*N*/ {
+/*?*/ if( pShell )
+/*?*/ {
+/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 pShell->Push();
+/*?*/ }
+/*?*/ else
+/*?*/ {
+/*?*/ pPam = new SwPaM( *pPam );
+/*?*/ pPam->Move( fnMoveBackward, fnGoDoc );
+/*?*/ pPam->SetMark();
+/*?*/ pPam->Move( fnMoveForward, fnGoDoc );
+/*?*/ }
+/*N*/ }
+/*N*/ // pPam ist immer noch der akt. Cursor !!
+/*N*/ }
+/*N*/ else
+/*N*/ {
+/*N*/ // keine Shell oder alles schreiben -> eigenen Pam erzeugen
+/*N*/ SwDoc* pOutDoc = pDoc ? pDoc : &rDoc;
+/*N*/ pPam = new SwPaM( pOutDoc->GetNodes().GetEndOfContent() );
+/*N*/ pPam->Move( fnMoveBackward, fnGoDoc );
+/*N*/ pPam->SetMark();
+/*N*/ pPam->Move( fnMoveForward, fnGoDoc );
+/*N*/ }
+/*N*/
+/*N*/ rxWriter->bWriteAll = bWriteAll;
+/*N*/ SwDoc* pOutDoc = pDoc ? pDoc : &rDoc;
+/*N*/
+/*N*/ // falls der Standart PageDesc. immer noch auf initalen Werten steht
+/*N*/ // (wenn z.B. kein Drucker gesetzt wurde) dann setze jetzt auf DIN A4
+/*N*/ if( !pOutDoc->GetPrt() )
+/*N*/ {
+/*?*/ const SwPageDesc& rPgDsc = pOutDoc->GetPageDesc( 0L );
+/*?*/ //const SwPageDesc& rPgDsc = *pOutDoc->GetPageDescFromPool( RES_POOLPAGE_STANDARD );;
+/*?*/ const SwFmtFrmSize& rSz = rPgDsc.GetMaster().GetFrmSize();
+/*?*/ // Clipboard-Dokument wird immer ohne Drucker angelegt, so ist
+/*?*/ // der Std.PageDesc immer aug LONG_MAX !! Mappe dann auf DIN A4
+/*?*/ if( LONG_MAX == rSz.GetHeight() || LONG_MAX == rSz.GetWidth() )
+/*?*/ {
+/*?*/ SwPageDesc aNew( rPgDsc );
+/*?*/ SwFmtFrmSize aNewSz( rSz );
+/*?*/ aNewSz.SetHeight( lA4Height );
+/*?*/ aNewSz.SetWidth( lA4Width );
+/*?*/ aNew.GetMaster().SetAttr( aNewSz );
+/*?*/ pOutDoc->ChgPageDesc( 0, aNew );
+/*?*/ }
+/*N*/ }
+/*N*/
+/*N*/ BOOL bWasPurgeOle = pOutDoc->IsPurgeOLE();
+/*N*/ pOutDoc->SetPurgeOLE( FALSE );
+/*N*/
+/*N*/ ULONG nError = 0;
+/*N*/ if( pStrm )
+/*N*/ nError = rxWriter->Write( *pPam, *pStrm );
+/*N*/
+/*N*/ pOutDoc->SetPurgeOLE( bWasPurgeOle );
+/*N*/
+/*N*/ // Falls nur zum Schreiben eine Selektion aufgespannt wurde, vor der
+/*N*/ // Rueckkehr den alten Crsr wieder herstellen.
+/*N*/ if( !bWriteAll && ( pShell || pOutPam ))
+/*N*/ {
+/*N*/ if(!bHasMark)
+/*N*/ {
+/*?*/ if( pShell )
+/*?*/ {DBG_BF_ASSERT(0, "STRIP");} //STRIP001 pShell->Pop( FALSE );
+/*?*/ else
+/*?*/ delete pPam;
+/*N*/ }
+/*N*/ }
+/*N*/ else
+/*N*/ {
+/*N*/ delete pPam; // loesche den hier erzeugten Pam
+/*N*/ // Alles erfolgreich geschrieben? Sag' das dem Dokument!
+/*N*/ if( !IsError( nError ) && !pDoc )
+/*N*/ rDoc.ResetModified();
+/*N*/ }
+/*N*/
+/*N*/ if ( pDoc )
+/*N*/ {
+/*N*/ delete pRefForDocSh;
+/*?*/ if ( !pDoc->RemoveLink() )
+/*?*/ delete pDoc;
+/*?*/ bWriteAll = FALSE;
+/*N*/ }
+/*N*/
+/*N*/ return nError;
+/*N*/ }
+
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_sw/source/filter/inc/wrt_fn.hxx b/binfilter/bf_sw/source/filter/inc/wrt_fn.hxx
new file mode 100644
index 000000000..f0fd7072b
--- /dev/null
+++ b/binfilter/bf_sw/source/filter/inc/wrt_fn.hxx
@@ -0,0 +1,76 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _WRT_FN_HXX
+#define _WRT_FN_HXX
+
+#include "hintids.hxx" // fuer die Konstanten
+
+namespace binfilter {
+
+class SfxPoolItem;
+class SfxItemSet;
+
+// einige Forward-Deklarationen
+class SwFmt;
+class SwNode;
+class SwCntntNode;
+class Writer;
+
+
+/* Funktionspointer auf die Attribut-Write-Funktionen */
+typedef Writer& (*FnAttrOut)( Writer&, const SfxPoolItem& );
+typedef FnAttrOut SwAttrFnTab[ POOLATTR_END - POOLATTR_BEGIN ];
+
+Writer& Out( const SwAttrFnTab, const SfxPoolItem&, Writer& );
+Writer& Out_SfxItemSet( const SwAttrFnTab, Writer&, const SfxItemSet&,
+ BOOL bDeep, BOOL bTstForDefault = TRUE );
+
+
+/* Funktionspointer auf die Node-Write-Funktionen */
+
+enum RES_NODE
+{
+RES_NODE_BEGIN = 0,
+ RES_TXTNODE = RES_NODE_BEGIN,
+ RES_GRFNODE,
+ RES_OLENODE,
+RES_NODE_END
+};
+
+typedef Writer& (*FnNodeOut)( Writer&, SwCntntNode& );
+typedef FnNodeOut SwNodeFnTab[ RES_NODE_END - RES_NODE_BEGIN ];
+
+Writer& Out( const SwNodeFnTab, SwNode&, Writer & rWrt );
+
+
+
+
+} //namespace binfilter
+#endif // _WRT_FN_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_sw/source/filter/makefile.mk b/binfilter/bf_sw/source/filter/makefile.mk
index 40d765d47..d45bb9439 100644
--- a/binfilter/bf_sw/source/filter/makefile.mk
+++ b/binfilter/bf_sw/source/filter/makefile.mk
@@ -47,6 +47,7 @@ INC+= -I$(PRJ)$/inc$/bf_sw
SUBLIBS= \
+ $(SLB)$/sw_ascii.lib \
$(SLB)$/sw_basflt.lib \
$(SLB)$/sw_writer.lib \
$(SLB)$/sw_excel.lib \
diff --git a/binfilter/bf_sw/source/filter/writer/makefile.mk b/binfilter/bf_sw/source/filter/writer/makefile.mk
index 6e2447537..68a5d24b5 100644
--- a/binfilter/bf_sw/source/filter/writer/makefile.mk
+++ b/binfilter/bf_sw/source/filter/writer/makefile.mk
@@ -42,9 +42,13 @@ INC+= -I$(PRJ)$/inc$/bf_sw
# --- Files --------------------------------------------------------
CXXFILES = \
+ sw_writer.cxx \
+ sw_wrt_fn.cxx \
sw_wrtswtbl.cxx
SLOFILES = \
+ $(SLO)$/sw_writer.obj \
+ $(SLO)$/sw_wrt_fn.obj \
$(SLO)$/sw_wrtswtbl.obj
# --- Tagets -------------------------------------------------------
diff --git a/binfilter/bf_sw/source/filter/writer/sw_writer.cxx b/binfilter/bf_sw/source/filter/writer/sw_writer.cxx
new file mode 100644
index 000000000..0dcc3beaa
--- /dev/null
+++ b/binfilter/bf_sw/source/filter/writer/sw_writer.cxx
@@ -0,0 +1,361 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifdef _MSC_VER
+#pragma hdrstop
+#endif
+
+#include <hintids.hxx>
+
+#define _SVSTDARR_STRINGSSORTDTOR
+
+ #ifndef _STREAM_HXX //autogen
+ #include <tools/stream.hxx>
+ #endif
+#include <bf_svx/fontitem.hxx>
+#include <bf_svx/eeitem.hxx>
+
+#include <shellio.hxx>
+
+#include <horiornt.hxx>
+
+#include <pam.hxx>
+#include <doc.hxx>
+#include <docary.hxx>
+#include <bookmrk.hxx> // fuer SwBookmark ...
+#include <numrule.hxx>
+
+#include <swerror.h>
+namespace binfilter {
+
+// Stringbuffer fuer die umgewandelten Zahlen
+static sal_Char aNToABuf[] = "0000000000000000000000000";
+#define NTOABUFLEN (sizeof(aNToABuf))
+
+/*N*/ DECLARE_TABLE( SwBookmarkNodeTable, SvPtrarr* )
+
+/*N*/ struct Writer_Impl
+/*N*/ {
+/*N*/ SvStringsSortDtor *pSrcArr, *pDestArr;
+/*N*/ SvPtrarr* pFontRemoveLst, *pBkmkArr;
+/*N*/ SwBookmarkNodeTable* pBkmkNodePos;
+/*N*/
+/*N*/ Writer_Impl();
+/*N*/ ~Writer_Impl();
+/*N*/
+/*N*/ void RemoveFontList( SwDoc& rDoc );
+/*N*/ };
+
+/*N*/ Writer_Impl::Writer_Impl()
+/*N*/ : pSrcArr( 0 ), pDestArr( 0 ), pFontRemoveLst( 0 ), pBkmkNodePos( 0 )
+/*N*/ {
+/*N*/ }
+
+/*N*/ Writer_Impl::~Writer_Impl()
+/*N*/ {
+/*N*/ delete pSrcArr;
+/*N*/ delete pDestArr;
+/*N*/ delete pFontRemoveLst;
+/*N*/
+/*N*/ if( pBkmkNodePos )
+/*N*/ {
+/*?*/ for( SvPtrarr* p = pBkmkNodePos->First(); p; p = pBkmkNodePos->Next() )
+/*?*/ delete p;
+/*?*/ delete pBkmkNodePos;
+/*N*/ }
+/*N*/ }
+
+/*N*/ void Writer_Impl::RemoveFontList( SwDoc& rDoc )
+/*N*/ {
+/*N*/ OSL_ENSURE( pFontRemoveLst, "wo ist die FontListe?" );
+/*N*/ for( USHORT i = pFontRemoveLst->Count(); i; )
+/*N*/ {
+/*N*/ SvxFontItem* pItem = (SvxFontItem*)(*pFontRemoveLst)[ --i ];
+/*N*/ rDoc.GetAttrPool().Remove( *pItem );
+/*N*/ }
+/*N*/ }
+
+/*
+ * Dieses Modul ist die Zentrale-Sammelstelle fuer alle Write-Filter
+ * und ist eine DLL !
+ *
+ * Damit der Writer mit den unterschiedlichen Writern arbeiten kann,
+ * muessen fuer diese die Ausgabe-Funktionen der Inhalts tragenden
+ * Objecte auf die verschiedenen Ausgabe-Funktionen gemappt werden.
+ *
+ * Dazu kann fuer jedes Object ueber den Which-Wert in einen Tabelle ge-
+ * griffen werden, um seine Ausgabe-Funktion zu erfragen.
+ * Diese Funktionen stehen in den entsprechenden Writer-DLL's.
+ */
+
+/*N*/ Writer::Writer()
+/*N*/ : pImpl( 0 ), pStrm( 0 ), pOrigPam( 0 ),
+/*N*/ pDoc(0), pCurPam(0)
+/*N*/ {
+/*N*/ bWriteAll = bShowProgress = bUCS2_WithStartChar = TRUE;
+/*N*/ bASCII_NoLastLineEnd = bASCII_ParaAsBlanc = bASCII_ParaAsCR =
+/*N*/ bWriteClipboardDoc = bWriteOnlyFirstTable = bBlock =
+/*N*/ bOrganizerMode = FALSE;
+/*N*/ }
+
+/*N*/ Writer::~Writer()
+/*N*/ {
+/*N*/ }
+
+/*N*/ void Writer::ResetWriter()
+/*N*/ {
+/*N*/ if( pImpl && pImpl->pFontRemoveLst )
+/*N*/ pImpl->RemoveFontList( *pDoc );
+/*N*/ delete pImpl, pImpl = 0;
+/*N*/
+/*N*/ if( pCurPam )
+/*N*/ {
+/*N*/ while( pCurPam->GetNext() != pCurPam )
+/*?*/ delete pCurPam->GetNext();
+/*N*/ delete pCurPam;
+/*N*/ }
+/*N*/ pCurPam = 0;
+/*N*/ pDoc = 0;
+/*N*/ pStrm = 0;
+/*N*/
+/*N*/ bShowProgress = bUCS2_WithStartChar = TRUE;
+/*N*/ bASCII_NoLastLineEnd = bASCII_ParaAsBlanc = bASCII_ParaAsCR =
+/*N*/ bWriteClipboardDoc = bWriteOnlyFirstTable = bBlock =
+/*N*/ bOrganizerMode = FALSE;
+/*N*/ }
+
+/*N*/ BOOL Writer::CopyNextPam( SwPaM ** ppPam )
+/*N*/ {
+/*N*/ if( (*ppPam)->GetNext() == pOrigPam )
+/*N*/ {
+/*N*/ *ppPam = pOrigPam; // wieder auf den Anfangs-Pam setzen
+/*N*/ return FALSE; // Ende vom Ring
+/*N*/ }
+/*N*/
+/*N*/ // ansonsten kopiere den die Werte aus dem naechsten Pam
+/*?*/ *ppPam = ((SwPaM*)(*ppPam)->GetNext() );
+/*?*/
+/*?*/ *pCurPam->GetPoint() = *(*ppPam)->Start();
+/*?*/ *pCurPam->GetMark() = *(*ppPam)->End();
+/*?*/
+/*?*/ return TRUE;
+/*N*/ }
+
+// suche die naechste Bookmark-Position aus der Bookmark-Tabelle
+
+ SwPaM* Writer::NewSwPaM( SwDoc & rDoc, ULONG nStartIdx, ULONG nEndIdx ) const
+ {
+ SwNodes* pNds = &rDoc.GetNodes();
+
+ SwNodeIndex aStt( *pNds, nStartIdx );
+ SwCntntNode* pCNode = aStt.GetNode().GetCntntNode();
+ if( !pCNode && 0 == ( pCNode = pNds->GoNext( &aStt )) )
+ OSL_ENSURE( !this, "An StartPos kein ContentNode mehr" );
+
+ SwPaM* pNew = new SwPaM( aStt );
+ pNew->SetMark();
+ aStt = nEndIdx;
+ if( 0 == (pCNode = aStt.GetNode().GetCntntNode()) &&
+ 0 == (pCNode = pNds->GoPrevious( &aStt )) )
+ OSL_ENSURE( !this, "An StartPos kein ContentNode mehr" );
+ pCNode->MakeEndIndex( &pNew->GetPoint()->nContent );
+ pNew->GetPoint()->nNode = aStt;
+ return pNew;
+ }
+
+// Stream-spezifisches
+/*N*/ #ifdef DBG_UTIL
+/*N*/ SvStream& Writer::Strm()
+/*N*/ {
+/*N*/ OSL_ENSURE( pStrm, "Oh-oh. Dies ist ein Storage-Writer. Gleich knallts!" );
+/*N*/ return *pStrm;
+/*N*/ }
+/*N*/ #endif
+
+
+SvStream& Writer::OutHex( SvStream& rStrm, ULONG nHex, BYTE nLen )
+{ // in einen Stream aus
+ // Pointer an das Bufferende setzen
+ sal_Char* pStr = aNToABuf + (NTOABUFLEN-1);
+ for( BYTE n = 0; n < nLen; ++n )
+ {
+ *(--pStr) = (sal_Char)(nHex & 0xf ) + 48;
+ if( *pStr > '9' )
+ *pStr += 39;
+ nHex >>= 4;
+ }
+ return rStrm << pStr;
+}
+
+SvStream& Writer::OutLong( SvStream& rStrm, long nVal )
+{
+ // Pointer an das Bufferende setzen
+ sal_Char* pStr = aNToABuf + (NTOABUFLEN-1);
+
+ int bNeg = nVal < 0;
+ if( bNeg )
+ nVal = -nVal;
+
+ do {
+ *(--pStr) = (sal_Char)(nVal % 10 ) + 48;
+ nVal /= 10;
+ } while( nVal );
+
+ // Ist Zahl negativ, dann noch -
+ if( bNeg )
+ *(--pStr) = '-';
+
+ return rStrm << pStr;
+}
+
+SvStream& Writer::OutULong( SvStream& rStrm, ULONG nVal )
+{
+ // Pointer an das Bufferende setzen
+ sal_Char* pStr = aNToABuf + (NTOABUFLEN-1);
+
+ do {
+ *(--pStr) = (sal_Char)(nVal % 10 ) + 48;
+ nVal /= 10;
+ } while ( nVal );
+ return rStrm << pStr;
+}
+
+/*N*/ ULONG Writer::Write( SwPaM& rPaM, SvStream& rStrm )
+/*N*/ {
+/*N*/ pStrm = &rStrm;
+/*N*/ pDoc = rPaM.GetDoc();
+/*N*/ pImpl = new Writer_Impl;
+/*N*/
+/*N*/ // PaM kopieren, damit er veraendert werden kann
+/*N*/ pCurPam = new SwPaM( *rPaM.End(), *rPaM.Start() );
+/*N*/ // zum Vergleich auf den akt. Pam sichern
+/*N*/ pOrigPam = &rPaM;
+/*N*/
+/*N*/ ULONG nRet = WriteStream();
+/*N*/
+/*N*/ ResetWriter();
+/*N*/
+/*N*/ return nRet;
+/*N*/ }
+
+/*N*/ void Writer::PutNumFmtFontsInAttrPool()
+/*N*/ {
+/*N*/ if( !pImpl )
+/*?*/ pImpl = new Writer_Impl;
+/*N*/
+/*N*/ // dann gibt es noch in den NumRules ein paar Fonts
+/*N*/ // Diese in den Pool putten. Haben sie danach einen RefCount > 1
+/*N*/ // kann es wieder entfernt werden - ist schon im Pool
+/*N*/ SfxItemPool& rPool = pDoc->GetAttrPool();
+/*N*/ const SwNumRuleTbl& rListTbl = pDoc->GetNumRuleTbl();
+/*N*/ const SwNumRule* pRule;
+/*N*/ const SwNumFmt* pFmt;
+/*N*/ const Font *pFont, *pDefFont = &SwNumRule::GetDefBulletFont();
+/*N*/ BOOL bCheck = FALSE;
+/*N*/
+/*N*/ for( USHORT nGet = rListTbl.Count(); nGet; )
+/*N*/ if( pDoc->IsUsed( *(pRule = rListTbl[ --nGet ] )))
+/*?*/ for( BYTE nLvl = 0; nLvl < MAXLEVEL; ++nLvl )
+/*?*/ if( SVX_NUM_CHAR_SPECIAL == (pFmt = &pRule->Get( nLvl ))->GetNumberingType() ||
+/*?*/ SVX_NUM_BITMAP == pFmt->GetNumberingType() )
+/*?*/ {
+/*?*/ if( 0 == ( pFont = pFmt->GetBulletFont() ) )
+/*?*/ pFont = pDefFont;
+/*?*/
+/*?*/ if( bCheck )
+/*?*/ {
+/*?*/ if( *pFont == *pDefFont )
+/*?*/ continue;
+/*?*/ }
+/*?*/ else if( *pFont == *pDefFont )
+/*?*/ bCheck = TRUE;
+/*?*/
+/*?*/ _AddFontItem( rPool, SvxFontItem( pFont->GetFamily(),
+/*?*/ pFont->GetName(), pFont->GetStyleName(),
+/*?*/ pFont->GetPitch(), pFont->GetCharSet() ));
+/*N*/ }
+/*N*/ }
+
+/*N*/ void Writer::PutEditEngFontsInAttrPool( BOOL bIncl_CJK_CTL )
+/*N*/ {
+/*N*/ if( !pImpl )
+/*?*/ pImpl = new Writer_Impl;
+/*N*/
+/*N*/ SfxItemPool& rPool = pDoc->GetAttrPool();
+/*N*/ if( rPool.GetSecondaryPool() )
+/*N*/ {
+/*N*/ _AddFontItems( rPool, EE_CHAR_FONTINFO );
+/*N*/ if( bIncl_CJK_CTL )
+/*N*/ {
+/*N*/ _AddFontItems( rPool, EE_CHAR_FONTINFO_CJK );
+/*N*/ _AddFontItems( rPool, EE_CHAR_FONTINFO_CTL );
+/*N*/ }
+/*N*/ }
+/*N*/ }
+
+/*N*/ void Writer::_AddFontItems( SfxItemPool& rPool, USHORT nW )
+/*N*/ {
+/*N*/ const SvxFontItem* pFont = (const SvxFontItem*)&rPool.GetDefaultItem( nW );
+/*N*/ _AddFontItem( rPool, *pFont );
+/*N*/
+/*N*/ if( 0 != ( pFont = (const SvxFontItem*)rPool.GetPoolDefaultItem( nW )) )
+/*N*/ _AddFontItem( rPool, *pFont );
+/*N*/
+/*N*/ USHORT nMaxItem = rPool.GetItemCount( nW );
+/*N*/ for( USHORT nGet = 0; nGet < nMaxItem; ++nGet )
+/*N*/ if( 0 != (pFont = (const SvxFontItem*)rPool.GetItem( nW, nGet )) )
+/*N*/ _AddFontItem( rPool, *pFont );
+/*N*/ }
+
+/*N*/ void Writer::_AddFontItem( SfxItemPool& rPool, const SvxFontItem& rFont )
+/*N*/ {
+/*N*/ const SvxFontItem* pItem;
+/*N*/ if( RES_CHRATR_FONT != rFont.Which() )
+/*N*/ {
+/*N*/ SvxFontItem aFont( rFont );
+/*N*/ aFont.SetWhich( RES_CHRATR_FONT );
+/*N*/ pItem = (SvxFontItem*)&rPool.Put( aFont );
+/*N*/ }
+/*N*/ else
+/*?*/ pItem = (SvxFontItem*)&rPool.Put( rFont );
+/*N*/
+/*N*/ if( 1 < pItem->GetRefCount() )
+/*N*/ rPool.Remove( *pItem );
+/*N*/ else
+/*N*/ {
+/*N*/ if( !pImpl->pFontRemoveLst )
+/*N*/ pImpl->pFontRemoveLst = new SvPtrarr( 0, 10 );
+/*N*/
+/*N*/ void* p = (void*)pItem;
+/*N*/ pImpl->pFontRemoveLst->Insert( p, pImpl->pFontRemoveLst->Count() );
+/*N*/ }
+/*N*/ }
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_sw/source/filter/writer/sw_wrt_fn.cxx b/binfilter/bf_sw/source/filter/writer/sw_wrt_fn.cxx
new file mode 100644
index 000000000..944e269dd
--- /dev/null
+++ b/binfilter/bf_sw/source/filter/writer/sw_wrt_fn.cxx
@@ -0,0 +1,129 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifdef _MSC_VER
+#pragma hdrstop
+#endif
+
+#include <bf_svtools/itemiter.hxx>
+#include <bf_svtools/whiter.hxx>
+
+
+#include "shellio.hxx"
+#include "wrt_fn.hxx"
+
+#include "node.hxx"
+namespace binfilter {
+
+
+
+Writer& Out( const SwAttrFnTab pTab, const SfxPoolItem& rHt, Writer & rWrt )
+{
+ USHORT nId = rHt.Which();
+ OSL_ENSURE( nId < POOLATTR_END && nId >= POOLATTR_BEGIN, "SwAttrFnTab::Out()" );
+ FnAttrOut pOut;
+ if( 0 != ( pOut = pTab[ nId - RES_CHRATR_BEGIN] ))
+ (*pOut)( rWrt, rHt );
+ return rWrt;
+
+}
+
+Writer& Out_SfxItemSet( const SwAttrFnTab pTab, Writer& rWrt,
+ const SfxItemSet& rSet, BOOL bDeep,
+ BOOL bTstForDefault )
+{
+ // erst die eigenen Attribute ausgeben
+ const SfxItemPool& rPool = *rSet.GetPool();
+ const SfxItemSet* pSet = &rSet;
+ if( !pSet->Count() ) // Optimierung - leere Sets
+ {
+ if( !bDeep )
+ return rWrt;
+ while( 0 != ( pSet = pSet->GetParent() ) && !pSet->Count() )
+ ;
+ if( !pSet )
+ return rWrt;
+ }
+ const SfxPoolItem* pItem;
+ FnAttrOut pOut;
+ if( !bDeep || !pSet->GetParent() )
+ {
+ OSL_ENSURE( rSet.Count(), "Wurde doch schon behandelt oder?" );
+ SfxItemIter aIter( *pSet );
+ pItem = aIter.GetCurItem();
+ do {
+ if( 0 != ( pOut = pTab[ pItem->Which() - RES_CHRATR_BEGIN] ))
+ (*pOut)( rWrt, *pItem );
+ } while( !aIter.IsAtEnd() && 0 != ( pItem = aIter.NextItem() ) );
+ }
+ else
+ {
+ SfxWhichIter aIter( *pSet );
+ register USHORT nWhich = aIter.FirstWhich();
+ while( nWhich )
+ {
+ if( SFX_ITEM_SET == pSet->GetItemState( nWhich, bDeep, &pItem ) &&
+ ( !bTstForDefault || (
+ *pItem != rPool.GetDefaultItem( nWhich )
+ || ( pSet->GetParent() &&
+ *pItem != pSet->GetParent()->Get( nWhich ))
+ )) && 0 != ( pOut = pTab[ nWhich - RES_CHRATR_BEGIN] ))
+ (*pOut)( rWrt, *pItem );
+ nWhich = aIter.NextWhich();
+ }
+ }
+ return rWrt;
+}
+
+/*N*/ Writer& Out( const SwNodeFnTab pTab, SwNode& rNode, Writer & rWrt )
+/*N*/ {
+/*N*/ // es muss ein CntntNode sein !!
+/*N*/ SwCntntNode * pCNd = rNode.GetCntntNode();
+/*N*/ if( !pCNd )
+/*?*/ return rWrt;
+/*N*/
+/*N*/ USHORT nId = RES_TXTNODE;
+/*N*/ switch( pCNd->GetNodeType() )
+/*N*/ {
+/*N*/ case ND_TEXTNODE: nId = RES_TXTNODE; break;
+/*?*/ case ND_GRFNODE: nId = RES_GRFNODE; break;
+/*?*/ case ND_OLENODE: nId = RES_OLENODE; break;
+/*?*/ default:
+/*?*/ OSL_ENSURE( FALSE, "was fuer ein Node ist es denn nun?" );
+/*N*/ }
+/*N*/ FnNodeOut pOut;
+/*N*/ if( 0 != ( pOut = pTab[ nId - RES_NODE_BEGIN ] ))
+/*N*/ (*pOut)( rWrt, *pCNd );
+/*N*/ return rWrt;
+/*N*/ }
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/inc/bf_sw/shellio.hxx b/binfilter/inc/bf_sw/shellio.hxx
index 2794d2588..0f030bd23 100644
--- a/binfilter/inc/bf_sw/shellio.hxx
+++ b/binfilter/inc/bf_sw/shellio.hxx
@@ -100,6 +100,100 @@ public:
SwAsciiOptions() { Reset(); }
};
+
+/* Basis-Klasse aller Writer */
+
+struct Writer_Impl;
+
+class Writer : public SvRefBase
+{
+ SwAsciiOptions aAscOpts;
+
+ void _AddFontItem( SfxItemPool& rPool, const SvxFontItem& rFont );
+ void _AddFontItems( SfxItemPool& rPool, USHORT nWhichId );
+
+protected:
+ Writer_Impl* pImpl;
+
+ SvStream* pStrm;
+ SwPaM* pOrigPam; // der letze zu bearbeitende Pam
+
+ void ResetWriter();
+ BOOL CopyNextPam( SwPaM ** );
+
+ void PutNumFmtFontsInAttrPool();
+ void PutEditEngFontsInAttrPool( BOOL bIncl_CJK_CTL = TRUE );
+
+ virtual ULONG WriteStream() = 0;
+
+public:
+ SwDoc* pDoc;
+ SwPaM* pCurPam;
+ BOOL bWriteAll : 1;
+ BOOL bShowProgress : 1;
+ BOOL bWriteClipboardDoc : 1;
+ BOOL bWriteOnlyFirstTable : 1;
+ BOOL bASCII_ParaAsCR : 1;
+ BOOL bASCII_ParaAsBlanc : 1;
+ BOOL bASCII_NoLastLineEnd : 1;
+ BOOL bUCS2_WithStartChar : 1;
+
+ BOOL bBlock : 1;
+ BOOL bOrganizerMode : 1;
+
+ Writer();
+ virtual ~Writer();
+
+ ULONG Write( SwPaM&, SvStream& );
+
+ BOOL ShowProgress() const { return bShowProgress; }
+ void SetShowProgress( BOOL bFlag = FALSE ) { bShowProgress = bFlag; }
+
+ const SwAsciiOptions& GetAsciiOptions() const { return aAscOpts; }
+ void SetAsciiOptions( const SwAsciiOptions& rOpt ) { aAscOpts = rOpt; }
+
+ // suche die naechste Bookmark-Position aus der Bookmark-Tabelle
+ // build a bookmark table, which is sort by the node position. The
+ // OtherPos of the bookmarks also inserted.
+ // search alle Bookmarks in the range and return it in the Array
+ // lege einen neuen PaM an der Position an
+ SwPaM* NewSwPaM( SwDoc & rDoc, ULONG nStartIdx, ULONG nEndIdx ) const;
+
+ // kopiere ggfs. eine lokale Datei ins Internet
+
+ // Stream-spezifische Routinen, im Storage-Writer NICHT VERWENDEN!
+
+ // Optimierung der Ausgabe auf den Stream.
+SvStream& OutLong( SvStream& rStrm, long nVal );
+SvStream& OutULong( SvStream& rStrm, ULONG nVal );
+
+ // Hex-Zahl ausgeben, default ist 2.stellige Zahl
+SvStream& OutHex( SvStream& rStrm, ULONG nHex, BYTE nLen = 2 );
+ // 4-st. Hex-Zahl ausgeben
+ // 8-st. Hex-Zahl ausgeben
+
+inline SvStream& OutHex( USHORT nHex, BYTE nLen = 2 ) { return OutHex( Strm(), nHex, nLen ); }
+inline SvStream& OutHex4( USHORT nHex ) { return OutHex( Strm(), nHex, 4 ); }
+inline SvStream& OutLong( long nVal ) { return OutLong( Strm(), nVal ); }
+inline SvStream& OutULong( ULONG nVal ) { return OutULong( Strm(), nVal ); }
+
+ void SetStrm( SvStream& rStrm ) { pStrm = &rStrm; }
+#ifndef DBG_UTIL
+ SvStream& Strm() { return *pStrm; }
+#else
+ SvStream& Strm();
+#endif
+
+ BOOL IsOrganizerMode() const { return bOrganizerMode; }
+ void SetOrganizerMode( BOOL bSet ) { bOrganizerMode = bSet; }
+};
+
+#ifndef SW_DECL_WRITER_DEFINED
+#define SW_DECL_WRITER_DEFINED
+SV_DECL_REF(Writer)
+#endif
+SV_IMPL_REF(Writer)
+
/**************** SwReader/Reader ************************/
// Basisklasse der moeglichen Optionen fuer einen speziellen Reader
class Reader;
@@ -256,6 +350,8 @@ private:
virtual int SetStrmStgPtr();
};
+
+
class AsciiReader: public Reader
{
friend class SwReader;
@@ -361,10 +457,31 @@ public:
static const SfxFilter* GetTextFilter(const sal_Char* pBuf, ULONG nLen);
// gebe einen bestimmten Reader zurueck
static Reader* GetReader( const String& rFltName );
+
static const String GetSubStorageName( const SfxFilter& rFltr );
};
+// Schnittstellenklasse fuer den allgemeinen Zugriff auf die
+// speziellen Writer
+
+class SwWriter
+{
+ SvStream* pStrm;
+
+ SwPaM* pOutPam;
+ SwCrsrShell *pShell;
+ SwDoc &rDoc;
+ BOOL bWriteAll;
+
+public:
+ ULONG Write( WriterRef& rxWriter );
+ SwWriter( SvStream&, SwPaM &, BOOL bWriteAll = FALSE );
+};
+
+WriterRef GetASCWriter( const String& rFltNm );
+
+
// diese Filter sind immer vorhanden und koennen ueber die
// Formatnamen gesucht werden. Alle anderen Filter sind nur intern
// bekannt. Die UI-Seite benutzt die GetReader()/GetWriter() -Funktionen,
diff --git a/binfilter/inc/bf_sw/undobj.hxx b/binfilter/inc/bf_sw/undobj.hxx
index ef57fc5ad..41e98c220 100644
--- a/binfilter/inc/bf_sw/undobj.hxx
+++ b/binfilter/inc/bf_sw/undobj.hxx
@@ -105,8 +105,10 @@ namespace utl {
}
#ifdef DBG_UTIL
+class Writer;
class SwUndo;
-#define OUT_UNDOBJ( name )
+#define OUT_UNDOBJ( name ) \
+ friend Writer& OutUndo_ ## name( Writer&, const SwUndo& );
#else
#define OUT_UNDOBJ( name )
#endif
@@ -535,6 +537,12 @@ public:
--------------------------------------------------------------------*/
+
+
+
+
+//--------------------------------------------------------------------
+
class SwUndoFlyBase : public SwUndo, private SwUndoSaveSection
{
protected:
@@ -589,11 +597,18 @@ public:
};
+//--------------------------------------------------------------------
+
class _UnReplaceData;
SV_DECL_PTRARR_DEL( _UnReplaceDatas, _UnReplaceData*, 10, 25 )
+//--------------------------------------------------------------------
+
+
+
+
//------------ Undo von Insert-/Delete-Sections ----------------------
class SwUndoInsSection : public SwUndo, private SwUndRng
@@ -647,6 +662,8 @@ public:
//------------ Undo von verschieben/stufen von Gliederung ----------------
+//--------------------------------------------------------------------
+
class SwUndoDefaultAttr : public SwUndo
{
SfxItemSet* pOldSet; // die alten Attribute
@@ -658,6 +675,7 @@ public:
OUT_UNDOBJ( DefaultAttr )
};
+//--------------------------------------------------------------------
// ---------- Undo fuer Numerierung ----------------------------------
class SwUndoInsNum : public SwUndo, private SwUndRng
@@ -679,6 +697,7 @@ public:
};
+
class SwUndoNumUpDown : public SwUndo, private SwUndRng
{
short nOffset;
@@ -699,6 +718,20 @@ public:
OUT_UNDOBJ( NumRuleStart )
};
+//--------------------------------------------------------------------
+// ---------- Undo fuer DrawObjecte ----------------------------------
+
+
+
+
+
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
class SwUndoChgFtn : public SwUndo, private SwUndRng
{
@@ -716,6 +749,31 @@ public:
};
+
+
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+
+
+
+
+
+
+//--------------------------------------------------------------------
+
+
+
+//--------------------------------------------------------------------
+
+// Object der als Iterator durch die Undo-Liste laeuft, bis die
+// letze oder die angegebene Klammerung/Id erreicht ist.
+
+
+
+
+
}
#endif