[ooo-build-commit] Branch 'ooo/master' - 8 commits - sw/inc sw/source

Jan Holesovsky kendy at kemper.freedesktop.org
Fri Jul 31 19:58:21 PDT 2009


 sw/inc/IDocumentContentOperations.hxx |    2 
 sw/inc/authratr.hxx                   |    2 
 sw/inc/doc.hxx                        |   14 -
 sw/inc/unotxdoc.hxx                   |   30 +-
 sw/source/core/doc/doccomp.cxx        |    6 
 sw/source/core/doc/docdde.cxx         |    2 
 sw/source/core/doc/docfmt.cxx         |    2 
 sw/source/core/doc/docglbl.cxx        |    4 
 sw/source/core/doc/docglos.cxx        |    2 
 sw/source/core/doc/doclay.cxx         |    4 
 sw/source/core/doc/docnew.cxx         |  371 +++++++++++++++++++++++++++++++++-
 sw/source/core/doc/docnum.cxx         |    2 
 sw/source/core/doc/docredln.cxx       |    6 
 sw/source/core/doc/notxtfrm.cxx       |   54 ++++
 sw/source/core/doc/swserv.cxx         |    7 
 sw/source/core/doc/tblcpy.cxx         |    2 
 sw/source/core/doc/tblrwcl.cxx        |    2 
 sw/source/core/docnode/ndcopy.cxx     |   73 +++++-
 sw/source/core/docnode/section.cxx    |    4 
 sw/source/core/draw/dcontact.cxx      |   21 +
 sw/source/core/draw/dpage.cxx         |    4 
 sw/source/core/edit/acorrect.cxx      |    2 
 sw/source/core/edit/eddel.cxx         |    2 
 sw/source/core/edit/edglss.cxx        |    6 
 sw/source/core/frmedt/fecopy.cxx      |    4 
 sw/source/core/frmedt/fefly1.cxx      |    4 
 sw/source/core/layout/paintfrm.cxx    |   19 +
 sw/source/core/text/txttab.cxx        |   10 
 sw/source/core/txtnode/atrftn.cxx     |    2 
 sw/source/core/undo/untblk.cxx        |    2 
 sw/source/core/view/vprint.cxx        |    4 
 sw/source/filter/ww8/wrtww8.cxx       |  149 +++++++++++++
 sw/source/filter/ww8/wrtww8.hxx       |    6 
 sw/source/filter/ww8/ww8glsy.cxx      |    2 
 sw/source/filter/ww8/ww8par.cxx       |    9 
 sw/source/filter/ww8/ww8scan.cxx      |   61 +++--
 sw/source/filter/ww8/ww8scan.hxx      |    2 
 sw/source/filter/xml/xmltbli.cxx      |    2 
 sw/source/ui/app/docsh.cxx            |   11 -
 sw/source/ui/app/swmodul1.cxx         |    2 
 sw/source/ui/config/optpage.cxx       |    4 
 sw/source/ui/dbui/dbmgr.cxx           |  253 +++++++++--------------
 sw/source/ui/dochdl/swdtflvr.cxx      |    6 
 sw/source/ui/envelp/mailmrge.cxx      |   17 -
 sw/source/ui/inc/uivwimp.hxx          |    2 
 sw/source/ui/shells/basesh.cxx        |    9 
 sw/source/ui/uno/unoatxt.cxx          |    4 
 sw/source/ui/uno/unotxdoc.cxx         |   30 +-
 48 files changed, 947 insertions(+), 291 deletions(-)

New commits:
commit d5d24f140a34f64aba15a2f808fff30c401c5c6e
Author: Jens-Heiner Rechtien <hr at openoffice.org>
Date:   Fri Jul 31 13:18:02 2009 +0000

    #i10000#: needed for solaris compiler: implement SwWW8Writer::Write(SwPam&, SvStream&, const String*)

diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index cdc7588..4b2a7f3 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -3188,8 +3188,9 @@ ULONG SwWW8Writer::Write( SwPaM& rPaM, SfxMedium& rMed,
                                const String* pFileName )
 {
     mpMedium = &rMed;
-    return StgWriter::Write( rPaM, rMed, pFileName );
+    ULONG nRet = StgWriter::Write( rPaM, rMed, pFileName );
     mpMedium = NULL;
+    return nRet;
 }
 
 ULONG SwWW8Writer::Write( SwPaM& rPaM, const uno::Reference < embed::XStorage >& xStorage, const String* pFileName, SfxMedium* pMedium )
@@ -3204,6 +3205,12 @@ ULONG SwWW8Writer::Write( SwPaM& rPaM, SotStorage& rStorage, const String* pFile
     return StgWriter::Write( rPaM, rStorage, pFileName );
 }
 
+ULONG SwWW8Writer::Write( SwPaM& rPaM, SvStream& rStream, const String* pFileName )
+{
+    // this method was added to let the solaris compiler be happy, otherwise it shows warning
+    return StgWriter::Write( rPaM, rStream, pFileName );
+}
+
 SwWW8Writer::SwWW8Writer(const String& rFltName, const String& rBaseURL)
     : aMainStg(sMainStream), pISet(0), pUsedNumTbl(0), mpTopNodeOfHdFtPage(0),
     pBmpPal(0), pKeyMap(0), pOLEExp(0), pOCXExp(0), pOleMap(0), 
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index 5dd0d99..fa44b97 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -525,6 +525,7 @@ public:
     virtual ULONG Write( SwPaM&, SfxMedium&, const String* = 0 );
     virtual ULONG Write( SwPaM&, const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >&, const String* = 0, SfxMedium* = 0 );
     virtual ULONG Write( SwPaM&, SotStorage&, const String* = 0 );
+    virtual ULONG Write( SwPaM&, SvStream&, const String* = 0 );
 
 
     SvxMSExportOLEObjects& GetOLEExp()      { return *pOLEExp; }
commit 2ad285614e99cc8532682ada354db97e5e4b3408
Author: Jens-Heiner Rechtien <hr at openoffice.org>
Date:   Thu Jul 30 10:24:24 2009 +0000

    CWS-TOOLING: integrate CWS wordencryption
    2009-07-10 09:42:25 +0200 mav  r273872 : resolve merge problem
    2009-07-08 07:46:13 +0200 mav  r273815 : CWS-TOOLING: rebase CWS wordencryption to trunk at 273468 (milestone: DEV300:m51)
    2009-07-03 10:38:03 +0200 mav  r273682 : #i10000# resolve conflict
    2009-07-02 08:47:35 +0200 steve_yin  r273618 : Removed IBM(C) from modified files.
    2009-06-22 04:34:44 +0200 steve_yin  r273191 : Based on Mikhail suggestions, I changed some code.
    2009-06-18 09:37:14 +0200 mav  r273100 : #i10000# get rid of windows warnings
    2009-06-17 08:18:33 +0200 mav  r273047 : #i10000# adopt for linux build

diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index c67bc93..4acb292 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -480,7 +480,6 @@ private:
     bool mbPurgeOLE              : 1;    // TRUE: Purge OLE-Objects
     bool mbKernAsianPunctuation  : 1;    // TRUE: kerning also for ASIAN punctuation
     bool mbReadlineChecked       : 1;    // TRUE: if the query was already shown
-    bool mbWinEncryption         : 1;    // imported document password encrypted?
     bool mbLinksUpdated          : 1;    // OD 2005-02-11 #i38810#
                                          // flag indicating, that the links have been updated.
     bool mbClipBoard             : 1;    // true: this document represents the clipboard
@@ -1958,9 +1957,6 @@ public:
     USHORT SetRubyList( const SwPaM& rPam, const SwRubyList& rList,
                         USHORT nMode );
 
-    inline void SetWinEncryption(const bool bImportWinEncryption) {mbWinEncryption = bImportWinEncryption; }
-    inline bool IsWinEncrypted() const         { return mbWinEncryption; }
-
     void ReadLayoutCache( SvStream& rStream );
     void WriteLayoutCache( SvStream& rStream );
     SwLayoutCache* GetLayoutCache() const { return pLayoutCache; }
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index a541ff7..2dce6c0 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -278,7 +278,6 @@ SwDoc::SwDoc() :
     mIdleBlockCount(0),
     nLockExpFld( 0 ),
     mbReadlineChecked(false),
-    mbWinEncryption(sal_False),
     // --> OD 2005-02-11 #i38810#
     mbLinksUpdated( sal_False ),
     mbClipBoard( false ),
diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index 4a03712..cdc7588 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -107,6 +107,13 @@
 
 #include "dbgoutsw.hxx"
 
+#include <sfx2/docfile.hxx>
+#include <svtools/stritem.hxx>
+#include <unotools/tempfile.hxx>
+#include <svx/mscodec.hxx>
+#include <osl/time.h>
+#include <rtl/random.h>
+
 using namespace sw::util;
 using namespace sw::types;
 
@@ -2687,6 +2694,28 @@ void SwWW8Writer::CollectOutlineBookmarks(const SwDoc &rDoc)
     }
 }
 
+namespace
+{
+#define WW_BLOCKSIZE 0x200
+
+    void EncryptRC4(svx::MSCodec_Std97& rCtx, SvStream &rIn, SvStream &rOut)
+    {
+        rIn.Seek(STREAM_SEEK_TO_END);
+        ULONG nLen = rIn.Tell();
+        rIn.Seek(0);
+
+        sal_uInt8 in[WW_BLOCKSIZE];
+        for (ULONG nI = 0, nBlock = 0; nI < nLen; nI += WW_BLOCKSIZE, ++nBlock)
+        {
+            ULONG nBS = (nLen - nI > WW_BLOCKSIZE) ? WW_BLOCKSIZE : nLen - nI;
+            rIn.Read(in, nBS);
+            rCtx.InitCipher(nBlock);
+            rCtx.Encode(in, nBS, in, nBS);
+            rOut.Write(in, nBS);
+        }
+    }    
+}
+
 ULONG SwWW8Writer::StoreDoc()
 {
     nCharFmtStart = ANZ_DEFAULT_STYLES;
@@ -2785,6 +2814,41 @@ ULONG SwWW8Writer::StoreDoc()
 
     pStrm->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
 
+    String sUniPassword;
+    if ( mpMedium )
+    {
+        SfxItemSet* pSet = mpMedium->GetItemSet();
+
+        const SfxPoolItem* pPasswordItem = NULL;
+        if ( pSet && SFX_ITEM_SET == pSet->GetItemState( SID_PASSWORD, sal_True, &pPasswordItem ) )
+            if( pPasswordItem != NULL )
+                sUniPassword = ( (const SfxStringItem*)pPasswordItem )->GetValue();
+    }
+
+    utl::TempFile aTempMain;
+    aTempMain.EnableKillingFile();
+    utl::TempFile aTempTable;
+    aTempTable.EnableKillingFile();
+    utl::TempFile aTempData;
+    aTempData.EnableKillingFile();
+    
+    bool bEncrypt = false;
+
+    xub_StrLen nLen = sUniPassword.Len();
+    if ( nLen > 0 && nLen <= 15) // Password has been set
+    {
+        bEncrypt =true;
+        
+        pStrm = aTempMain.GetStream( STREAM_READWRITE | STREAM_SHARE_DENYWRITE );
+
+        pTableStrm = aTempTable.GetStream( STREAM_READWRITE | STREAM_SHARE_DENYWRITE );
+
+        pDataStrm = aTempData.GetStream( STREAM_READWRITE | STREAM_SHARE_DENYWRITE );
+        
+        sal_uInt8 aRC4EncryptionHeader[ 52 ] = {0};
+        pTableStrm->Write( aRC4EncryptionHeader, 52 );
+    }
+
     const SwSectionFmt *pFmt=0;
     // Default: "Standard"
     pAktPageDesc = &const_cast<const SwDoc *>(pDoc)->GetPageDesc( 0 );
@@ -2883,6 +2947,62 @@ ULONG SwWW8Writer::StoreDoc()
 
     StoreDoc1();
 
+    if ( bEncrypt )
+    {	
+        // Generate random number with a seed of time as salt.
+        TimeValue aTime;
+        osl_getSystemTime( &aTime );
+        rtlRandomPool aRandomPool = rtl_random_createPool ();
+        rtl_random_addBytes ( aRandomPool, &aTime, 8 ); 
+
+        sal_uInt8 aDocId[ 16 ] = {0};
+        rtl_random_getBytes( aRandomPool, aDocId, 16 );
+        
+        rtl_random_destroyPool( aRandomPool );
+
+        sal_Unicode aPassword[16] = {0};
+        for (xub_StrLen nChar = 0; nChar < nLen; ++nChar )
+            aPassword[nChar] = sUniPassword.GetChar(nChar);
+
+        svx::MSCodec_Std97 aCtx;
+        aCtx.InitKey(aPassword, aDocId);
+        
+        SvStream *pStrmTemp, *pTableStrmTemp, *pDataStrmTemp;
+        pStrmTemp = &xWwStrm;
+        pTableStrmTemp = &xTableStrm;
+        pDataStrmTemp = &xDataStrm;
+
+        if ( pDataStrmTemp && pDataStrmTemp != pStrmTemp)
+            EncryptRC4(aCtx, *pDataStrm, *pDataStrmTemp);			
+
+        EncryptRC4(aCtx, *pTableStrm, *pTableStrmTemp);
+
+        // Write Unencrypted Header 52 bytes to the start of the table stream 
+        // EncryptionVersionInfo (4 bytes): A Version structure where Version.vMajor MUST be 0x0001, and Version.vMinor MUST be 0x0001.
+        pTableStrmTemp->Seek( 0 );
+        sal_uInt32 nEncType = 0x10001;
+        *pTableStrmTemp << nEncType;
+
+        sal_uInt8 pSaltData[16] = {0};
+        sal_uInt8 pSaltDigest[16] = {0};
+        aCtx.GetEncryptKey( aDocId, pSaltData, pSaltDigest );
+
+        pTableStrmTemp->Write( aDocId, 16 );
+        pTableStrmTemp->Write( pSaltData, 16 );
+        pTableStrmTemp->Write( pSaltDigest, 16 );			
+
+        EncryptRC4(aCtx, *pStrm, *pStrmTemp);
+
+        // Write Unencrypted Fib 68 bytes to the start of the workdocument stream 	
+        pFib->fEncrypted = 1; // fEncrypted indicates the document is encrypted.
+        pFib->fObfuscated = 0; // Must be 0 for RC4.
+        pFib->nHash = 0x34; // encrypt header bytes count of table stream.
+        pFib->nKey = 0; // lkey2 must be 0 for RC4.
+        
+        pStrmTemp->Seek( 0 );				
+        pFib->WriteHeader( *pStrmTemp );		
+    }		
+
     if (nRedlineMode != pDoc->GetRedlineMode())
       pDoc->SetRedlineMode((RedlineMode_t)(nRedlineMode));
 
@@ -3064,11 +3184,31 @@ ULONG SwWW8Writer::WriteMedium( SfxMedium& )
     return WriteStorage();
 }
 
+ULONG SwWW8Writer::Write( SwPaM& rPaM, SfxMedium& rMed,
+                               const String* pFileName )
+{
+    mpMedium = &rMed;
+    return StgWriter::Write( rPaM, rMed, pFileName );
+    mpMedium = NULL;
+}
+
+ULONG SwWW8Writer::Write( SwPaM& rPaM, const uno::Reference < embed::XStorage >& xStorage, const String* pFileName, SfxMedium* pMedium )
+{
+    // this method was added to let the windows compiler be happy, otherwise it shows warning
+    return StgWriter::Write( rPaM, xStorage, pFileName, pMedium );
+}
+
+ULONG SwWW8Writer::Write( SwPaM& rPaM, SotStorage& rStorage, const String* pFileName )
+{
+    // this method was added to let the windows compiler be happy, otherwise it shows warning
+    return StgWriter::Write( rPaM, rStorage, pFileName );
+}
+
 SwWW8Writer::SwWW8Writer(const String& rFltName, const String& rBaseURL)
     : aMainStg(sMainStream), pISet(0), pUsedNumTbl(0), mpTopNodeOfHdFtPage(0),
     pBmpPal(0), pKeyMap(0), pOLEExp(0), pOCXExp(0), pOleMap(0), 
     mpTableInfo(new ww8::WW8TableInfo()), nUniqueList(0),
-    mnHdFtIndex(0), pAktPageDesc(0), pPapPlc(0), pChpPlc(0), pChpIter(0), pO(0),
+    mnHdFtIndex(0), mpMedium(0), pAktPageDesc(0), pPapPlc(0), pChpPlc(0), pChpIter(0), pO(0), 
     bHasHdr(false), bHasFtr(false)
 {
     SetBaseURL( rBaseURL );
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index cbc4ad6..5dd0d99 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -405,6 +405,8 @@ friend Writer& OutWW8_SwTxtNode( Writer& rWrt, SwCntntNode& rNode );
     USHORT nUniqueList;         // current number for creating unique list names
     unsigned int mnHdFtIndex;
 
+    SfxMedium*          mpMedium;
+
     virtual ULONG WriteStorage();
     virtual ULONG WriteMedium( SfxMedium& );
 
@@ -520,6 +522,9 @@ public:
     BYTE bHasFtr : 1;
 
 
+    virtual ULONG Write( SwPaM&, SfxMedium&, const String* = 0 );
+    virtual ULONG Write( SwPaM&, const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >&, const String* = 0, SfxMedium* = 0 );
+    virtual ULONG Write( SwPaM&, SotStorage&, const String* = 0 );
 
 
     SvxMSExportOLEObjects& GetOLEExp()      { return *pOLEExp; }
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 815f685..00713be 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -4346,6 +4346,13 @@ ULONG SwWW8ImplReader::LoadThroughDecryption(SwPaM& rPaM ,WW8Glossary *pGloss)
                             DecryptRC4(aCtx, *pDataStream, aDecryptData);
                             pDataStream = &aDecryptData;
                         }
+                        SfxMedium* pMedium = mpDocShell->GetMedium();
+                        if ( pMedium )
+                        {
+                            SfxItemSet* pSet = pMedium->GetItemSet();
+                            if ( pSet )								
+                                pSet->Put( SfxStringItem(SID_PASSWORD, sUniPassword) );
+                        }
                     }
                 }
             }
@@ -4360,8 +4367,6 @@ ULONG SwWW8ImplReader::LoadThroughDecryption(SwPaM& rPaM ,WW8Glossary *pGloss)
             pWwFib = new WW8Fib(*pStrm, nWantedVersion);
             if (pWwFib->nFibError)
                 nErrRet = ERR_SWG_READ_ERROR;
-            if(!nErrRet && mpDocShell->GetDoc())
-                mpDocShell->GetDoc()->SetWinEncryption(true);
         }
     }
 
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index dfc4b27..4ea643e 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -5624,14 +5624,15 @@ WW8Fib::WW8Fib(BYTE nVer)
     // <-- #i90932# 
 }
 
-bool WW8Fib::Write(SvStream& rStrm)
-{
-    BYTE *pDataPtr = new BYTE[ fcMin ];
-    BYTE *pData = pDataPtr;
-    memset( pData, 0, fcMin );
-
+bool WW8Fib::WriteHeader(SvStream& rStrm)
+{	
     bool bVer8 = 8 == nVersion;
 
+    size_t nUnencryptedHdr = bVer8 ? 0x44 : 0x24;
+    BYTE *pDataPtr = new BYTE[ nUnencryptedHdr ];
+    BYTE *pData = pDataPtr;
+    memset( pData, 0, nUnencryptedHdr );
+
     ULONG nPos = rStrm.Tell();
     cbMac = rStrm.Seek( STREAM_SEEK_TO_END );
     rStrm.Seek( nPos );
@@ -5643,15 +5644,16 @@ bool WW8Fib::Write(SvStream& rStrm)
     Set_UInt16( pData, pnNext );
 
     UINT16 nBits16 = 0;
-    if( fDot )          nBits16 |= 0x0001;
-    if( fGlsy)          nBits16 |= 0x0002;
-    if( fComplex )      nBits16 |= 0x0004;
-    if( fHasPic )       nBits16 |= 0x0008;
+    if( fDot ) 			nBits16 |= 0x0001;
+    if( fGlsy) 			nBits16 |= 0x0002;
+    if( fComplex )		nBits16 |= 0x0004;
+    if( fHasPic ) 		nBits16 |= 0x0008;
     nBits16 |= (0xf0 & ( cQuickSaves << 4 ));
-    if( fEncrypted )    nBits16 |= 0x0100;
-    if( fWhichTblStm )  nBits16 |= 0x0200;
-    if( fExtChar )      nBits16 |= 0x1000;
+    if( fEncrypted ) 	nBits16 |= 0x0100;
+    if( fWhichTblStm ) 	nBits16 |= 0x0200;
+    if( fExtChar ) 		nBits16 |= 0x1000;
     if( fFarEast )      nBits16 |= 0x4000;  // #i90932#
+    if( fObfuscated )	nBits16 |= 0x8000;
     Set_UInt16( pData, nBits16 );
 
     Set_UInt16( pData, nFibBack );
@@ -5662,11 +5664,11 @@ bool WW8Fib::Write(SvStream& rStrm)
     BYTE nBits8 = 0;
     if( bVer8 )
     {
-        if( fMac )                  nBits8 |= 0x0001;
-        if( fEmptySpecial )         nBits8 |= 0x0002;
-        if( fLoadOverridePage )     nBits8 |= 0x0004;
-        if( fFuturesavedUndo )      nBits8 |= 0x0008;
-        if( fWord97Saved )          nBits8 |= 0x0010;
+        if( fMac ) 					nBits8 |= 0x0001;
+        if( fEmptySpecial ) 		nBits8 |= 0x0002;
+        if( fLoadOverridePage )		nBits8 |= 0x0004;
+        if( fFuturesavedUndo ) 		nBits8 |= 0x0008;
+        if( fWord97Saved ) 			nBits8 |= 0x0010;
         if( fWord2000Saved )        nBits8 |= 0x0020;
     }
     // unter Ver67 these are only reserved
@@ -5697,6 +5699,27 @@ bool WW8Fib::Write(SvStream& rStrm)
     // Marke: "rglw"  Beginning of the array of longs
     Set_UInt32( pData, cbMac );
 
+    rStrm.Write( pDataPtr, nUnencryptedHdr );
+    delete[] pDataPtr;
+    return 0 == rStrm.GetError();
+}
+
+bool WW8Fib::Write(SvStream& rStrm)
+{
+    bool bVer8 = 8 == nVersion;
+
+    WriteHeader( rStrm );
+
+    size_t nUnencryptedHdr = bVer8 ? 0x44 : 0x24;
+
+    BYTE *pDataPtr = new BYTE[ fcMin - nUnencryptedHdr ];
+    BYTE *pData = pDataPtr;
+    memset( pData, 0, fcMin - nUnencryptedHdr );
+
+    ULONG nPos = rStrm.Tell();
+    cbMac = rStrm.Seek( STREAM_SEEK_TO_END );
+    rStrm.Seek( nPos );    
+
     // 2 Longs uebergehen, da unwichtiger Quatsch
     pData += 2 * sizeof( INT32);
 
@@ -5905,7 +5928,7 @@ bool WW8Fib::Write(SvStream& rStrm)
         Set_UInt32( pData, 0);
     }
 
-    rStrm.Write( pDataPtr, fcMin );
+    rStrm.Write( pDataPtr, fcMin - nUnencryptedHdr );
     delete[] pDataPtr;
     return 0 == rStrm.GetError();
 }
diff --git a/sw/source/filter/ww8/ww8scan.hxx b/sw/source/filter/ww8/ww8scan.hxx
index 9d56615..395eeaa 100644
--- a/sw/source/filter/ww8/ww8scan.hxx
+++ b/sw/source/filter/ww8/ww8scan.hxx
@@ -1040,6 +1040,7 @@ public:
     UINT16 fExtChar :1; // 1000 =1, when using extended character set in file
     UINT16 fFarEast :1; // 4000 =1, probably, when far-East language vaiants of Word is used to create a file #i90932#
 
+    UINT16 fObfuscated :1; // 8000=1. specifies whether the document is obfuscated using XOR obfuscation. otherwise this bit MUST be ignored.
 
     UINT16 nFibBack;    // 0xc
     UINT16 nHash;       // 0xe  file encrypted hash
@@ -1434,6 +1435,7 @@ public:
 
     /* leider falsch, man braucht auch noch einen fuer den Export */
     WW8Fib( BYTE nVersion = 6 );
+    bool WriteHeader(SvStream& rStrm);
     bool Write(SvStream& rStrm);
     static rtl_TextEncoding GetFIBCharset(UINT16 chs);
     ww::WordVersion GetFIBVersion() const;
diff --git a/sw/source/ui/app/docsh.cxx b/sw/source/ui/app/docsh.cxx
index 057bd55..0d71a7f 100644
--- a/sw/source/ui/app/docsh.cxx
+++ b/sw/source/ui/app/docsh.cxx
@@ -578,17 +578,6 @@ BOOL SwDocShell::ConvertTo( SfxMedium& rMedium )
         return FALSE;
     }
 
-    // if the imported word document is password protected - warn the user
-    // about saving it without the password.
-    if(pDoc->IsWinEncrypted())
-    {
-        if(!SwWarnPassword::WarningOnPassword( rMedium ))
-        {
-            SetError(ERRCODE_ABORT, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
-            return FALSE;
-        }
-    }
-
     //#i3370# remove quick help to prevent saving of autocorrection suggestions
     if(pView)
         pView->GetEditWin().StopQuickHelp();
commit 52976d0ee4345f1944f47d0c02ca0da16e56c879
Author: Jens-Heiner Rechtien <hr at openoffice.org>
Date:   Wed Jul 29 15:33:56 2009 +0000

    CWS-TOOLING: integrate CWS cmcfixes61
    2009-07-22 10:53:14 +0200 cmc  r274224 : #i103714# duplicate patch
    2009-07-22 10:45:26 +0200 cmc  r274223 : #i103715# fix up m68k makefile.mk
    2009-07-22 10:32:16 +0200 cmc  r274222 : #i103714# || && new gcc warnings
    2009-07-21 13:29:17 +0200 cmc  r274190 : #i103651# fix for subpixel gray line in cairo canvas animations
    2009-07-20 17:35:58 +0200 cmc  r274151 : #i103668# WaE over use of const
    2009-07-20 15:53:51 +0200 cmc  r274146 : #i103664# use boost::addressof instead
    2009-07-20 15:38:40 +0200 cmc  r274145 : #i103451# long -> INT32 for these streamable values
    2009-07-20 15:33:15 +0200 cmc  r274144 : #i103663 clear low-hanging aliasing warnings
    2009-07-20 15:28:23 +0200 cmc  r274143 : #i103662 clear low-hanging aliasing warnings
    2009-07-20 15:21:46 +0200 cmc  r274142 : #i103661 clear low-hanging aliasing warnings
    2009-07-20 15:16:05 +0200 cmc  r274141 : #i103660 clear low-hanging aliasing warnings

diff --git a/sw/source/core/draw/dpage.cxx b/sw/source/core/draw/dpage.cxx
index 4bb42dc..3b03da3 100644
--- a/sw/source/core/draw/dpage.cxx
+++ b/sw/source/core/draw/dpage.cxx
@@ -203,8 +203,8 @@ BOOL SwDPage::RequestHelp( Window* pWindow, SdrView* pView,
                     aPt -= pFly->Frm().Pos();
                     // ohne MapMode-Offset !!!!!
                     // ohne MapMode-Offset, ohne Offset, o ... !!!!!
-                    aPt = (Point&)(const Size&)pWindow->LogicToPixel(
-                            (const Size&)aPt, MapMode( MAP_TWIP ) );
+                    aPt = pWindow->LogicToPixel(
+                            aPt, MapMode( MAP_TWIP ) );
                     ((( sTxt += '?' ) += String::CreateFromInt32( aPt.X() ))
                              += ',' ) += String::CreateFromInt32( aPt.Y() );
                 }
diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx
index aca2c50..a1dc1d4 100644
--- a/sw/source/core/frmedt/fefly1.cxx
+++ b/sw/source/core/frmedt/fefly1.cxx
@@ -1651,8 +1651,8 @@ const SwFrmFmt* SwFEShell::IsURLGrfAtPos( const Point& rPt, String* pURL,
                         Point aPt( rPt );
                         aPt -= pFly->Frm().Pos();
                         // ohne MapMode-Offset, ohne Offset, o ... !!!!!
-                        aPt = (Point&)(const Size&)GetOut()->LogicToPixel(
-                                (const Size&)aPt, MapMode( MAP_TWIP ) );
+                        aPt = GetOut()->LogicToPixel(
+                                aPt, MapMode( MAP_TWIP ) );
                         ((( *pURL += '?' ) += String::CreateFromInt32( aPt.X() ))
                                   += ',' ) += String::CreateFromInt32(aPt.Y() );
                     }
diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx
index ccf60b4..08957c1 100644
--- a/sw/source/core/view/vprint.cxx
+++ b/sw/source/core/view/vprint.cxx
@@ -750,7 +750,7 @@ SwDoc * ViewShell::CreatePrtDoc( SfxPrinter* pPrt, SfxObjectShellRef &rDocShellR
     // Wir bauen uns ein neues Dokument
     SwDoc *pPrtDoc = new SwDoc;
     pPrtDoc->acquire();
-    pPrtDoc->SetRefForDocShell( (SfxObjectShellRef*)&(long&)rDocShellRef );
+    pPrtDoc->SetRefForDocShell( boost::addressof(rDocShellRef) );
     pPrtDoc->LockExpFlds();
 
     // Der Drucker wird uebernommen
@@ -838,7 +838,7 @@ SwDoc * ViewShell::FillPrtDoc( SwDoc *pPrtDoc, const SfxPrinter* pPrt)
     // Wir bauen uns ein neues Dokument
 //    SwDoc *pPrtDoc = new SwDoc;
 //    pPrtDoc->acquire();
-//    pPrtDoc->SetRefForDocShell( (SvEmbeddedObjectRef*)&(long&)rDocShellRef );
+//    pPrtDoc->SetRefForDocShell( boost::addressof(rDocShellRef) );
     pPrtDoc->LockExpFlds();
 
     // Der Drucker wird uebernommen
diff --git a/sw/source/ui/dochdl/swdtflvr.cxx b/sw/source/ui/dochdl/swdtflvr.cxx
index c3e1f23..2ff17d0 100644
--- a/sw/source/ui/dochdl/swdtflvr.cxx
+++ b/sw/source/ui/dochdl/swdtflvr.cxx
@@ -468,7 +468,7 @@ sal_Bool SwTransferable::GetData( const DATA_FLAVOR& rFlavor )
         pClpDocFac = new SwDocFac;
         SwDoc* pTmpDoc = pClpDocFac->GetDoc();
 
-        pTmpDoc->SetRefForDocShell( (SfxObjectShellRef*)&(long&)aDocShellRef );
+        pTmpDoc->SetRefForDocShell( boost::addressof(aDocShellRef) );
         pTmpDoc->LockExpFlds(); 	// nie die Felder updaten - Text so belassen
         pWrtShell->Copy( pTmpDoc );
 
@@ -883,7 +883,7 @@ int SwTransferable::PrepareForCopy( BOOL bIsCut )
         SwDoc* pTmpDoc = pClpDocFac->GetDoc();
         pTmpDoc->SetClipBoard( true );
 
-        pTmpDoc->SetRefForDocShell( (SfxObjectShellRef*)&(long&)aDocShellRef );
+        pTmpDoc->SetRefForDocShell( boost::addressof(aDocShellRef) );
         pTmpDoc->LockExpFlds(); 	// nie die Felder updaten - Text so belassen
         pWrtShell->Copy( pTmpDoc );
 
@@ -1067,7 +1067,7 @@ int SwTransferable::CopyGlossary( SwTextBlocks& rGlossary,
     SwCntntNode* pCNd = rNds.GoNext( &aNodeIdx ); // gehe zum 1. ContentNode
     SwPaM aPam( *pCNd );
 
-    pCDoc->SetRefForDocShell( (SfxObjectShellRef*)&(long&)aDocShellRef );
+    pCDoc->SetRefForDocShell( boost::addressof(aDocShellRef) );
     pCDoc->LockExpFlds(); 	// nie die Felder updaten - Text so belassen
 
     pCDoc->InsertGlossary( rGlossary, rStr, aPam, 0 );
diff --git a/sw/source/ui/inc/uivwimp.hxx b/sw/source/ui/inc/uivwimp.hxx
index 4ec0511..52f87ec 100644
--- a/sw/source/ui/inc/uivwimp.hxx
+++ b/sw/source/ui/inc/uivwimp.hxx
@@ -153,7 +153,7 @@ public:
 
     SfxObjectShellRef &             GetTmpSelectionDoc()    { return xTmpSelDocSh; }
 
-    SfxObjectShellRef&              GetEmbeddedObjRef()     { return (SfxObjectShellRef&)(long&)aEmbeddedObjRef; }
+    SfxObjectShellRef&              GetEmbeddedObjRef()     { return *boost::addressof(aEmbeddedObjRef); }
 
     void                            AddTransferable(SwTransferable& rTransferable);
 
commit 5061b23d7a1d53633becd7234d210f609439593e
Author: Jens-Heiner Rechtien <hr at openoffice.org>
Date:   Tue Jul 28 16:42:49 2009 +0000

    CWS-TOOLING: integrate CWS sw311bf01_DEV300
    2009-07-21 17:05:41 +0200 od  r274207 : #i103685# method <SwTxtFormatter::NewTabPortion(..)>
    	  - adjust condition to apply automatic tab stop at left margin correctly
                in case that tab stops are not relative to indent

diff --git a/sw/source/core/text/txttab.cxx b/sw/source/core/text/txttab.cxx
index 5a3ebd0..b299cae 100644
--- a/sw/source/core/text/txttab.cxx
+++ b/sw/source/core/text/txttab.cxx
@@ -254,8 +254,14 @@ SwTabPortion *SwTxtFormatter::NewTabPortion( SwTxtFormatInfo &rInf, bool bAuto )
         // <--
              ( ( bRTL && nCurrentAbsPos > nTabLeft - nForced ) ||
                ( !bRTL && nCurrentAbsPos < nTabLeft + nForced ) ) &&
-             nNextPos > nForced )
-        // <--
+               // --> OD 2009-07-21 #i103685#
+               //  adjust condition:
+               // - back to pre OOo 3.0 condition, if tab stops are relative to indent
+               // - further checks needed, if tab stops are not relative to indent
+               ( nNextPos > 0 &&
+               ( bTabsRelativeToIndent ||
+                 ( !pTabStop || nNextPos > nForced ) ) ) )
+               // <--
         {
             eAdj = SVX_TAB_ADJUST_DEFAULT;
             cFill = 0;
commit 1841a42005c0b956e9274dd2d2798b91a0742631
Author: Jens-Heiner Rechtien <hr at openoffice.org>
Date:   Tue Jul 28 13:59:44 2009 +0000

    CWS-TOOLING: integrate CWS os131
    2009-07-14 15:57:33 +0200 os  r273979 : #i103542# no access to members after deletion
    2009-06-15 13:18:52 +0200 os  r272980 : #i40827# wrong param in Copy() fixed
    2009-06-15 10:09:27 +0200 os  r272964 : #i40827# first document copied with storage, later only copy SwDoc
    2009-06-11 10:37:51 +0200 os  r272851 : CWS-TOOLING: rebase CWS os131 to trunk at 272827 (milestone: DEV300:m50)
    2009-06-08 10:07:50 +0200 os  r272721 : #i40827# warnings fixed
    2009-06-04 16:31:04 +0200 os  r272644 : #i40827# enable document copies - inactive

diff --git a/sw/inc/IDocumentContentOperations.hxx b/sw/inc/IDocumentContentOperations.hxx
index 8cb1aeb..6725057 100644
--- a/sw/inc/IDocumentContentOperations.hxx
+++ b/sw/inc/IDocumentContentOperations.hxx
@@ -71,7 +71,7 @@
     /** Kopieren eines Bereiches im oder in ein anderes Dokument !
         Die Position kann auch im Bereich liegen !!
     */
-    virtual bool Copy(SwPaM&, SwPosition&) const = 0;
+    virtual bool Copy(SwPaM&, SwPosition&, bool bCopyAll ) const = 0;
 
     /** Loesche die Section, in der der Node steht.
     */
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 29676ec..c67bc93 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -616,7 +616,7 @@ private:
         // Kopieren eines Bereiches im oder in ein anderes Dokument !
         // Die Position darf nicht im Bereich liegen !!
     sal_Bool _Copy( SwPaM&, SwPosition&,
-                sal_Bool MakeNewFrms = sal_True, SwPaM* pCpyRng = 0 ) const;	// in ndcopy.cxx
+                sal_Bool MakeNewFrms /*= sal_True*/, bool bCopyAll, SwPaM* pCpyRng /*= 0*/ ) const;	// in ndcopy.cxx
 
     SwFlyFrmFmt* _MakeFlySection( const SwPosition& rAnchPos,
                                 const SwCntntNode& rNode, RndStdIds eRequestId,
@@ -628,7 +628,8 @@ private:
                                 const SfxItemSet* pGrfAttrSet,
                                 SwFrmFmt* = 0 );
 
-    void _CopyFlyInFly( const SwNodeRange& rRg, const SwNodeIndex& rSttIdx,
+    void _CopyFlyInFly( const SwNodeRange& rRg, const xub_StrLen nEndContentIndex,
+                        const SwNodeIndex& rSttIdx,
                         sal_Bool bCopyFlyAtFly = sal_False ) const;	// steht im ndcopy.cxx
     sal_Int8 SetFlyFrmAnchor( SwFrmFmt& rFlyFmt, SfxItemSet& rSet, sal_Bool bNewFrms );
 
@@ -701,6 +702,7 @@ private:
      SwFmt *_MakeTxtFmtColl(const String &, SwFmt *, BOOL, BOOL );
 
      void InitTOXTypes();
+     void   Paste( const SwDoc& );
 public:
 
     /** Life cycle
@@ -877,7 +879,7 @@ public:
 
     /** IDocumentContentOperations
     */
-    virtual bool Copy(SwPaM&, SwPosition&) const;
+    virtual bool Copy(SwPaM&, SwPosition&, bool bCopyAll) const;
     virtual void DeleteSection(SwNode* pNode);
     virtual bool Delete(SwPaM&);
     virtual bool DelFullPara(SwPaM&);
@@ -1080,6 +1082,7 @@ public:
                                 SwFrmFmt *pParent = 0 );
 
     void CopyWithFlyInFly( const SwNodeRange& rRg,
+                            const xub_StrLen nEndContentIndex,
                             const SwNodeIndex& rInsPos,
                             sal_Bool bMakeNewFrms = sal_True,
                             sal_Bool bDelRedlines = sal_True,
@@ -2082,6 +2085,7 @@ public:
     }
 
     ::sfx2::IXmlIdRegistry& GetXmlIdRegistry();
+    SwDoc* CreateCopy() const;
 };
 
 
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index f4e3fe7..a7865fd 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -68,9 +68,8 @@
 #include <com/sun/star/xforms/XFormsSupplier.hpp>
 #include <com/sun/star/container/XNameContainer.hpp>
 #include <com/sun/star/text/XFlatParagraphIteratorProvider.hpp>
-#ifndef _COM_SUN_STAR_DOCUMENT_XDOCUMENTLANGUAGES_HPP
 #include <com/sun/star/document/XDocumentLanguages.hpp>
-#endif
+#include <com/sun/star/util/XCloneable.hpp>
 #include <svtools/itemprop.hxx>
 #include <svx/fmdmod.hxx>
 #include <svx/UnoForbiddenCharsTable.hxx>
@@ -79,22 +78,22 @@
 #include <cppuhelper/implbase4.hxx>	// helper for implementations
 #include <RefreshListenerContainer.hxx>
 
-#define __IFC31 Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, Ifc13, Ifc14, Ifc15, Ifc16, \
-Ifc17, Ifc18, Ifc19, Ifc20, Ifc21, Ifc22, Ifc23, Ifc24, Ifc25, Ifc26, Ifc27, Ifc28, Ifc29, Ifc30, Ifc31
+#define __IFC32 Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, Ifc13, Ifc14, Ifc15, Ifc16, \
+Ifc17, Ifc18, Ifc19, Ifc20, Ifc21, Ifc22, Ifc23, Ifc24, Ifc25, Ifc26, Ifc27, Ifc28, Ifc29, Ifc30, Ifc31, Ifc32
 
-#define __CLASS_IFC31 class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, \
+#define __CLASS_IFC32 class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, \
 class Ifc8, class Ifc9, class Ifc10, class Ifc11, class Ifc12, class Ifc13, class Ifc14, class Ifc15, class Ifc16, \
 class Ifc17, class Ifc18, class Ifc19, class Ifc20, class Ifc21, class Ifc22, class Ifc23, class Ifc24,\
-class Ifc25, class Ifc26, class Ifc27, class Ifc28, class Ifc29, class Ifc30, class Ifc31
+class Ifc25, class Ifc26, class Ifc27, class Ifc28, class Ifc29, class Ifc30, class Ifc31 , class Ifc32
 
-#define __PUBLIC_IFC31 public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11, public Ifc12, \
+#define __PUBLIC_IFC32 public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11, public Ifc12, \
 public Ifc13, public Ifc14, public Ifc15, public Ifc16, public Ifc17, public Ifc18, \
 public Ifc19, public Ifc20, public Ifc21, public Ifc22, public Ifc23, public Ifc24, \
 public Ifc25, public Ifc26, public Ifc27, public Ifc28, public Ifc29, public Ifc30, \
-public Ifc31
+public Ifc31, public Ifc32
 #include <cppuhelper/implbase_ex.hxx>
 #include <cppuhelper/implbase_ex_pre.hxx>
-#define __IFC_EX_TYPE_INIT31( class_cast ) \
+#define __IFC_EX_TYPE_INIT32( class_cast ) \
     __IFC_EX_TYPE_INIT( class_cast, 1 ), __IFC_EX_TYPE_INIT( class_cast, 2 ), \
     __IFC_EX_TYPE_INIT( class_cast, 3 ), __IFC_EX_TYPE_INIT( class_cast, 4 ), \
     __IFC_EX_TYPE_INIT( class_cast, 5 ), __IFC_EX_TYPE_INIT( class_cast, 6 ), \
@@ -110,10 +109,10 @@ public Ifc31
     __IFC_EX_TYPE_INIT( class_cast, 25 ), __IFC_EX_TYPE_INIT( class_cast, 26 ), \
     __IFC_EX_TYPE_INIT( class_cast, 27 ), __IFC_EX_TYPE_INIT( class_cast, 28 ), \
     __IFC_EX_TYPE_INIT( class_cast, 29 ), __IFC_EX_TYPE_INIT( class_cast, 30 ), \
-    __IFC_EX_TYPE_INIT( class_cast, 31)
+    __IFC_EX_TYPE_INIT( class_cast, 31 ), __IFC_EX_TYPE_INIT( class_cast, 32)
 #include <cppuhelper/implbase_ex_post.hxx>
 
-__DEF_IMPLHELPER_EX( 31 )
+__DEF_IMPLHELPER_EX( 32 )
 
 class SwDoc;
 class SwDocShell;
@@ -132,7 +131,7 @@ SV_DECL_PTRARR(ActionContextArr, UnoActionContextPtr, 4, 4)
  ******************************************************************************/
 
 
-typedef cppu::WeakImplHelper31
+typedef cppu::WeakImplHelper32
 <
     ::com::sun::star::text::XTextDocument,
     ::com::sun::star::text::XLineNumberingProperties,
@@ -164,7 +163,8 @@ typedef cppu::WeakImplHelper31
     ::com::sun::star::view::XRenderable,
     ::com::sun::star::xforms::XFormsSupplier,
     ::com::sun::star::text::XFlatParagraphIteratorProvider,
-    ::com::sun::star::document::XDocumentLanguages
+    ::com::sun::star::document::XDocumentLanguages,
+    ::com::sun::star::util::XCloneable
 >
 SwXTextDocumentBaseClass;
 
@@ -402,6 +402,10 @@ public:
     // ::com::sun::star::text::XFlatParagraphIteratorProvider:
     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XFlatParagraphIterator > SAL_CALL getFlatParagraphIterator(::sal_Int32 nTextMarkupType, sal_Bool bAutomatic ) throw (::com::sun::star::uno::RuntimeException);
 
+    // ::com::sun::star::util::XCloneable
+    virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone(  ) throw (::com::sun::star::uno::RuntimeException);
+    
+    
     //
     void						Invalidate();
     void						Reactivate(SwDocShell* pNewDocShell);
diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx
index 05d6209..1a80dd6 100644
--- a/sw/source/core/doc/doccomp.cxx
+++ b/sw/source/core/doc/doccomp.cxx
@@ -1196,7 +1196,7 @@ BOOL SwCompareLine::ChangesInLine( const SwCompareLine& rLine,
                     SwPaM aCpyPam( rSrcNd, nStt );
                     aCpyPam.SetMark();
                     aCpyPam.GetPoint()->nContent = nSEnd;
-                    aCpyPam.GetDoc()->Copy( aCpyPam, *aPam.GetPoint() );
+                    aCpyPam.GetDoc()->Copy( aCpyPam, *aPam.GetPoint(), false );
                     pDoc->DoUndo( bUndo );
                 }
 
@@ -1367,7 +1367,7 @@ void SwCompareData::ShowDelete( const CompareData& rData, ULONG nStt,
     SwNodeIndex aInsPos( *pLineNd, nOffset );
     SwNodeIndex aSavePos( aInsPos, -1 );
 
-    ((SwCompareData&)rData).rDoc.CopyWithFlyInFly( aRg, aInsPos );
+    ((SwCompareData&)rData).rDoc.CopyWithFlyInFly( aRg, 0, aInsPos );
     rDoc.SetModified();
     aSavePos++;
 
@@ -1624,7 +1624,7 @@ USHORT _SaveMergeRedlines::InsertRedline( FNInsUndo pFn )
         RedlineMode_t eOld = pDoc->GetRedlineMode();
         pDoc->SetRedlineMode_intern((RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE));
 
-        pSrcRedl->GetDoc()->Copy( *(SwPaM*)pSrcRedl, *pDestRedl->GetPoint() );
+        pSrcRedl->GetDoc()->Copy( *(SwPaM*)pSrcRedl, *pDestRedl->GetPoint(), false );
 
         pDoc->SetRedlineMode_intern( eOld );
         pDoc->DoUndo( bUndo );
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index 562eb37..db943ca 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -2139,7 +2139,7 @@ void SwDoc::_CopyPageDescHeaderFooter( BOOL bCpyHeader,
                 aTmpIdx = *pSttNd->EndOfSectionNode();
                 rSrcNds._Copy( aRg, aTmpIdx );
                 aTmpIdx = *pSttNd;
-                rSrcFmt.GetDoc()->_CopyFlyInFly( aRg, aTmpIdx );
+                rSrcFmt.GetDoc()->_CopyFlyInFly( aRg, 0, aTmpIdx );
                 pNewFmt->SetFmtAttr( SwFmtCntnt( pSttNd ));
             }
             else
diff --git a/sw/source/core/doc/docglbl.cxx b/sw/source/core/doc/docglbl.cxx
index a761724..5e77a85 100644
--- a/sw/source/core/doc/docglbl.cxx
+++ b/sw/source/core/doc/docglbl.cxx
@@ -307,7 +307,7 @@ BOOL SwDoc::SplitDoc( USHORT eDocType, const String& rPath,
                         pDoc->GetNodes().Delete( aIdx, 1 );
 
                     // alle Flys in dem Bereich
-                    _CopyFlyInFly( aRg, aIdx );
+                    _CopyFlyInFly( aRg, 0, aIdx );
 
 
                     // und noch alle Bookmarks
@@ -653,7 +653,7 @@ BOOL SwDoc::SplitDoc( USHORT eDocType, const String& rPath, int nOutlineLevel )
                         pDoc->GetNodes().Delete( aIdx, 1 );
 
                     // alle Flys in dem Bereich
-                    _CopyFlyInFly( aRg, aIdx );
+                    _CopyFlyInFly( aRg, 0, aIdx );
 
 
                     // und noch alle Bookmarks
diff --git a/sw/source/core/doc/docglos.cxx b/sw/source/core/doc/docglos.cxx
index f883084..a357946 100644
--- a/sw/source/core/doc/docglos.cxx
+++ b/sw/source/core/doc/docglos.cxx
@@ -183,7 +183,7 @@ BOOL SwDoc::InsertGlossary( SwTextBlocks& rBlock, const String& rEntry,
                 SwDontExpandItem aACD;
                 aACD.SaveDontExpandItems( rInsPos );
 
-                pGDoc->Copy( aCpyPam, rInsPos );
+                pGDoc->Copy( aCpyPam, rInsPos, false );
 
                 aACD.RestoreDontExpandItems( rInsPos );
                 if( pShell )
diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx
index 37542fb..7b32161 100644
--- a/sw/source/core/doc/doclay.cxx
+++ b/sw/source/core/doc/doclay.cxx
@@ -507,7 +507,7 @@ SwFrmFmt *SwDoc::CopyLayoutFmt( const SwFrmFmt& rSource,
 
         // sorge dafuer das auch Fly's in Fly's kopiert werden
         aIdx = *pSttNd->EndOfSectionNode();
-        pSrcDoc->CopyWithFlyInFly( aRg, aIdx, sal_False, sal_True, sal_True );
+        pSrcDoc->CopyWithFlyInFly( aRg, 0, aIdx, sal_False, sal_True, sal_True );
     }
     else
     {
@@ -885,7 +885,7 @@ if( DoesUndo() )	// werden erstmal alle Undo - Objecte geloescht.
                 do {
                     if( pTmp->HasMark() &&
                         *pTmp->GetPoint() != *pTmp->GetMark() )
-                        Copy( *pTmp, aPos );
+                        Copy( *pTmp, aPos, false );
                 } while( &rPam != ( pTmp = (SwPaM*)pTmp->GetNext() ) );
                 mbCopyIsMove = bOldFlag;
                 mbUndo = bOldUndo;
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 30ed6e8..a541ff7 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -32,6 +32,7 @@
 #include "precompiled_sw.hxx"
 #define ROLBCK_HISTORY_ONLY 	// Der Kampf gegen die CLOOK's
 #include <doc.hxx>
+#include <dcontact.hxx>
 #include <com/sun/star/document/PrinterIndependentLayout.hpp>
 #include <com/sun/star/document/UpdateDocMode.hpp>
 #include <com/sun/star/text/XTextDocument.hpp>
@@ -48,6 +49,7 @@
 
 #include <svtools/macitem.hxx>
 #include <svx/svxids.hrc>
+#include <svx/svdogrp.hxx>
 #include <svx/linkmgr.hxx>
 #include <svx/forbiddencharacterstable.hxx>
 #include <svtools/zforlist.hxx>
@@ -95,8 +97,8 @@
 #include <istyleaccess.hxx>
 #include <swstylemanager.hxx>
 #include <IGrammarContact.hxx>
+#include <tblsel.hxx>
 #include <MarkManager.hxx>
-
 #include <unochart.hxx>
 
 #include <cmdid.h>              // fuer den dflt - Printer in SetJob
@@ -1057,3 +1059,369 @@ void SwDoc::InitTOXTypes()
    pTOXTypes->Insert( pNew, pTOXTypes->Count() );
 }
 
+/*-- 08.05.2009 10:07:57---------------------------------------------------
+
+  -----------------------------------------------------------------------*/
+SwDoc* SwDoc::CreateCopy() const
+{
+    SwDoc* pRet = new SwDoc;
+    //copy settings
+/*
+    //aNodes( this ),
+    //aUndoNodes( this ),
+    mpAttrPool(new SwAttrPool(this)),*/
+    USHORT __FAR_DATA aRangeOfDefaults[] = {
+        RES_FRMATR_BEGIN, RES_FRMATR_END-1,
+        RES_CHRATR_BEGIN, RES_CHRATR_END-1,
+        RES_PARATR_BEGIN, RES_PARATR_END-1,
+        // --> OD 2008-02-25 #refactorlists##
+        RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1,
+        // <--
+        RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
+        0
+    };
+
+    SfxItemSet aNewDefaults( pRet->GetAttrPool(), aRangeOfDefaults );
+
+    USHORT nWhich;
+    USHORT nRange = 0;
+    while( aRangeOfDefaults[nRange] != 0)
+    {
+        for( nWhich = aRangeOfDefaults[nRange]; nWhich < aRangeOfDefaults[nRange + 1]; ++nWhich )
+        {
+            const SfxPoolItem& rSourceAttr = mpAttrPool->GetDefaultItem( nWhich );
+            if( rSourceAttr != pRet->mpAttrPool->GetDefaultItem( nWhich ) )
+                aNewDefaults.Put( rSourceAttr );
+        }
+        nRange += 2;
+    }
+    if( aNewDefaults.Count() )
+        pRet->SetDefault( aNewDefaults );
+    
+    /*
+    pDfltFrmFmt( new SwFrmFmt( GetAttrPool(), sFrmFmtStr, 0 ) ),
+    pEmptyPageFmt( new SwFrmFmt( GetAttrPool(), sEmptyPageStr, pDfltFrmFmt ) ),
+    pColumnContFmt( new SwFrmFmt( GetAttrPool(), sColumnCntStr, pDfltFrmFmt ) ),
+    pDfltCharFmt( new SwCharFmt( GetAttrPool(), sCharFmtStr, 0 ) ),
+    pDfltTxtFmtColl( new SwTxtFmtColl( GetAttrPool(), sTxtCollStr ) ),
+    pDfltGrfFmtColl( new SwGrfFmtColl( GetAttrPool(), sGrfCollStr ) ),
+    pFrmFmtTbl( new SwFrmFmts() ),
+    pCharFmtTbl( new SwCharFmts() ),
+    pSpzFrmFmtTbl( new SwSpzFrmFmts() ),
+    pSectionFmtTbl( new SwSectionFmts() ),
+    pTblFrmFmtTbl( new SwFrmFmts() ),
+    pTxtFmtCollTbl( new SwTxtFmtColls() ),
+    pGrfFmtCollTbl( new SwGrfFmtColls() ),
+    pBookmarkTbl( new SwBookmarks( 0, 16 ) ),
+    pTOXTypes( new SwTOXTypes() ),
+    pDefTOXBases( new SwDefTOXBase_Impl() ),
+    pLayout( 0 ),                   // Rootframe des spezifischen Layouts.
+    pDrawModel( 0 ),
+    pUndos( new SwUndos( 0, 20 ) ),
+    pUpdtFlds( new SwDocUpdtFld() ),
+    pFldTypes( new SwFldTypes() ),
+    pVirDev( 0 ),
+    pPrt( 0 ),
+    pPrtData( 0 ),
+    pGlossaryDoc( 0 ),
+    pOutlineRule( 0 ),
+    pFtnInfo( new SwFtnInfo ),
+    pEndNoteInfo( new SwEndNoteInfo ),
+    pLineNumberInfo( new SwLineNumberInfo ),
+    pFtnIdxs( new SwFtnIdxs ),
+    pDocStat( new SwDocStat ),
+    pDocShell( 0 ),
+    pDocShRef( 0 ),
+    pLinkMgr( new SvxLinkManager( 0 ) ),
+    pACEWord( 0 ),
+    pURLStateChgd( 0 ),
+    pNumberFormatter( 0 ),
+    pNumRuleTbl( new SwNumRuleTbl ),
+    // --> OD 2008-03-26 #refactorlists#
+    maLists(),
+    maListStyleLists(),
+    // <--
+    pRedlineTbl( new SwRedlineTbl ),
+    pAutoFmtRedlnComment( 0 ),
+    pUnoCrsrTbl( new SwUnoCrsrTbl( 0, 16 ) ),
+    pPgPViewPrtData( 0 ),
+    pExtInputRing( 0 ),
+    pLayouter( 0 ),
+    // --> OD 2008-03-07 #refactorlists#
+    pStyleAccess( 0 ),
+    // <--
+    pLayoutCache( 0 ),
+    pUnoCallBack(new SwUnoCallBack(0)),
+    mpGrammarContact( 0 ),
+    aChartDataProviderImplRef(),
+    pChartControllerHelper( 0 ),
+    // --> OD 2007-10-31 #i83479#
+    mpListItemsList( new tImplSortedNodeNumList() ),
+    // <--
+    nUndoPos( 0 ),
+    nUndoSavePos( 0 ),
+    nUndoCnt( 0 ),
+    nUndoSttEnd( 0 ),
+    nAutoFmtRedlnCommentNo( 0 ),
+    nLinkUpdMode( GLOBALSETTING ),
+    eFldUpdMode( AUTOUPD_GLOBALSETTING ),
+    eRedlineMode((RedlineMode_t)(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE)),
+    eChrCmprType( CHARCOMPRESS_NONE ),
+    mReferenceCount(0),
+    mIdleBlockCount(0),
+    nLockExpFld( 0 ),
+    mbReadlineChecked(false),
+    mbWinEncryption(sal_False),
+    // --> OD 2005-02-11 #i38810#
+    mbLinksUpdated( sal_False ),
+    mbClipBoard( false ),
+    mbColumnSelection( false ),
+    // i#78591#
+    mbProtectForm(false),*/
+    pRet->n32DummyCompatabilityOptions1 = n32DummyCompatabilityOptions1;
+    pRet->n32DummyCompatabilityOptions2 = n32DummyCompatabilityOptions2;
+    /*
+    mbStartIdleTimer(sal_False)
+{
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722",  "SwDoc::SwDoc" );
+
+    mbGlossDoc =
+    mbModified =
+    mbDtor =
+    mbUndo =
+    mbPageNums =
+    mbLoaded =
+    mbUpdateExpFld =
+    mbNewDoc =
+    mbCopyIsMove =
+    mbNoDrawUndoObj =
+    mbBrowseMode =
+    mbInReading =
+    mbInXMLImport =
+    mbUpdateTOX =
+    mbInLoadAsynchron =
+    mbHTMLMode =
+    mbInCallModified =
+    mbIsGlobalDoc =
+    mbGlblDocSaveLinks =
+    mbIsLabelDoc =
+    mbIsAutoFmtRedline =
+    mbOLEPrtNotifyPending =
+    mbAllOLENotify =
+    mbIsRedlineMove =
+    mbInsOnlyTxtGlssry =
+    mbContains_MSVBasic =
+    mbKernAsianPunctuation =
+#ifndef PRODUCT
+    mbXMLExport =
+#endif
+    // --> OD 2006-03-21 #b6375613#
+    mbApplyWorkaroundForB6375613 =
+    // <--
+                            false;
+
+    mbGroupUndo =
+    mbNewFldLst =
+    mbVisibleLinks =
+    mbPurgeOLE =
+                            true;
+
+    //
+    // COMPATIBILITY FLAGS START
+    //
+
+    // Note: Any non-hidden compatibility flag should obtain its default
+    // by asking SvtCompatibilityOptions, see below.
+    //
+    const SvtCompatibilityOptions aOptions;
+     */ 
+    pRet->mbParaSpaceMax                          = mbParaSpaceMax                          ;
+    pRet->mbParaSpaceMaxAtPages                   = mbParaSpaceMaxAtPages                   ;
+    pRet->mbTabCompat                             = mbTabCompat                             ;
+    pRet->mbUseVirtualDevice                      = mbUseVirtualDevice                      ;
+    pRet->mbAddExternalLeading                    = mbAddExternalLeading                    ;
+    pRet->mbOldLineSpacing                        = mbOldLineSpacing                        ;
+    pRet->mbAddParaSpacingToTableCells            = mbAddParaSpacingToTableCells            ;
+    pRet->mbUseFormerObjectPos                    = mbUseFormerObjectPos                    ;
+    pRet->mbUseFormerTextWrapping                 = mbUseFormerTextWrapping                 ;
+    pRet->mbConsiderWrapOnObjPos                  = mbConsiderWrapOnObjPos                  ;
+    pRet->mbAddFlyOffsets                         = mbAddFlyOffsets                         ;
+    pRet->mbOldNumbering                          = mbOldNumbering                          ;
+    pRet->mbUseHiResolutionVirtualDevice          = mbUseHiResolutionVirtualDevice          ;
+    pRet->mbIgnoreFirstLineIndentInNumbering      = mbIgnoreFirstLineIndentInNumbering      ;
+    pRet->mbDoNotJustifyLinesWithManualBreak      = mbDoNotJustifyLinesWithManualBreak      ;
+    pRet->mbDoNotResetParaAttrsForNumFont         = mbDoNotResetParaAttrsForNumFont         ;
+    pRet->mbOutlineLevelYieldsOutlineRule         = mbOutlineLevelYieldsOutlineRule         ;
+    pRet->mbTableRowKeep                          = mbTableRowKeep                          ;
+    pRet->mbIgnoreTabsAndBlanksForLineCalculation = mbIgnoreTabsAndBlanksForLineCalculation ;
+    pRet->mbDoNotCaptureDrawObjsOnPage            = mbDoNotCaptureDrawObjsOnPage            ;
+    pRet->mbClipAsCharacterAnchoredWriterFlyFrames= mbClipAsCharacterAnchoredWriterFlyFrames;
+    pRet->mbUnixForceZeroExtLeading               = mbUnixForceZeroExtLeading               ;
+    pRet->mbOldPrinterMetrics                     = mbOldPrinterMetrics                     ;
+    pRet->mbTabRelativeToIndent                   = mbTabRelativeToIndent                   ;
+    pRet->mbTabAtLeftIndentForParagraphsInList    = mbTabAtLeftIndentForParagraphsInList    ;
+                                            
+    //                                      
+    // COMPATIBILITY FLAGS END
+    //
+    /*
+    pMacroTable = new SvxMacroTableDtor;
+    
+    mpGrammarContact = ::createGrammarContact();
+
+    // Formate
+    pFrmFmtTbl->Insert(pDfltFrmFmt, 0 );
+    pCharFmtTbl->Insert(pDfltCharFmt, 0 );
+
+    // FmtColls 
+    // TXT
+    pTxtFmtCollTbl->Insert(pDfltTxtFmtColl, 0 );
+    // GRF
+    pGrfFmtCollTbl->Insert(pDfltGrfFmtColl, 0 );
+
+    // PageDesc, EmptyPageFmt und ColumnFmt anlegen
+    if ( !aPageDescs.Count() )
+        GetPageDescFromPool( RES_POOLPAGE_STANDARD );
+
+        //Leere Seite Einstellen.
+    pEmptyPageFmt->SetFmtAttr( SwFmtFrmSize( ATT_FIX_SIZE ) );
+        //BodyFmt fuer Spalten Einstellen.
+    pColumnContFmt->SetFmtAttr( SwFmtFillOrder( ATT_LEFT_TO_RIGHT ) );
+
+    _InitFieldTypes();
+
+    // lege (fuer die Filter) eine Default-OutlineNumRule an
+    // --> OD 2008-02-11 #newlistlevelattrs#
+    pOutlineRule = new SwNumRule( String::CreateFromAscii( SwNumRule::GetOutlineRuleName() ),
+                                  // --> OD 2008-06-06 #i89178#
+                                  numfunc::GetDefaultPositionAndSpaceMode(),
+                                  // <--
+                                  OUTLINE_RULE );
+    // <--
+    // #115901#
+    AddNumRule(pOutlineRule);
+    // --> OD 2005-10-21 - counting of phantoms depends on <IsOldNumbering()>
+    pOutlineRule->SetCountPhantoms( !get(IDocumentSettingAccess::OLD_NUMBERING) );
+    // <--
+
+    new SwTxtNode( SwNodeIndex( aUndoNodes.GetEndOfContent() ), pDfltTxtFmtColl );
+    new SwTxtNode( SwNodeIndex( aNodes.GetEndOfContent() ),
+                    GetTxtCollFromPool( RES_POOLCOLL_STANDARD ));
+
+    // den eigenen IdleTimer setzen
+    aIdleTimer.SetTimeout( 600 );
+    aIdleTimer.SetTimeoutHdl( LINK(this, SwDoc, DoIdleJobs) );
+
+    aOLEModifiedTimer.SetTimeout( 1000 );
+    aOLEModifiedTimer.SetTimeoutHdl( LINK( this, SwDoc, DoUpdateModifiedOLE ));
+
+    // DBMgr anlegen
+    pNewDBMgr = new SwNewDBMgr;
+
+    // create TOXTypes
+    ShellResource* pShellRes = ViewShell::GetShellRes();
+
+    SwTOXType * pNew = new SwTOXType(TOX_CONTENT,   pShellRes->aTOXContentName        );
+    pTOXTypes->Insert( pNew, pTOXTypes->Count() );
+    pNew = new SwTOXType(TOX_INDEX,                 pShellRes->aTOXIndexName  );
+    pTOXTypes->Insert( pNew, pTOXTypes->Count() );
+    pNew = new SwTOXType(TOX_USER,                  pShellRes->aTOXUserName  );
+    pTOXTypes->Insert( pNew, pTOXTypes->Count() );
+    pNew = new SwTOXType(TOX_ILLUSTRATIONS,         pShellRes->aTOXIllustrationsName );
+    pTOXTypes->Insert( pNew, pTOXTypes->Count() );
+    pNew = new SwTOXType(TOX_OBJECTS,               pShellRes->aTOXObjectsName       );
+    pTOXTypes->Insert( pNew, pTOXTypes->Count() );
+    pNew = new SwTOXType(TOX_TABLES,                pShellRes->aTOXTablesName        );
+    pTOXTypes->Insert( pNew, pTOXTypes->Count() );
+    pNew = new SwTOXType(TOX_AUTHORITIES,           pShellRes->aTOXAuthoritiesName   );
+    pTOXTypes->Insert( pNew, pTOXTypes->Count() );
+
+    {
+        SfxItemSet aIgnorableParagraphItems( GetAttrPool(),
+                                             RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1,
+                                             0 );
+        pStyleAccess = createStyleManager( &aIgnorableParagraphItems );
+    }
+
+    ResetModified();
+
+*/    
+    //copy content 
+    pRet->Paste( *this );
+    return pRet;
+}
+/*-- 08.05.2009 10:52:40---------------------------------------------------
+    copy document content - code from SwFEShell::Paste( SwDoc* , BOOL  )
+  -----------------------------------------------------------------------*/
+void SwDoc::Paste( const SwDoc& rSource )
+{
+//  this has to be empty const USHORT nStartPageNumber = GetPhyPageNum();
+    // until the end of the NodesArray
+    SwNodeIndex aSourceIdx( rSource.GetNodes().GetEndOfExtras(), 2 );
+    SwPaM aCpyPam( aSourceIdx ); //DocStart
+    SwNodeIndex aTargetIdx( GetNodes().GetEndOfExtras(), 2 );
+    SwPaM aInsertPam( aTargetIdx ); //replaces PCURCRSR from SwFEShell::Paste()
+
+
+    aCpyPam.SetMark();
+    aCpyPam.Move( fnMoveForward, fnGoDoc );
+
+    this->StartUndo( UNDO_INSGLOSSARY, NULL );
+    this->LockExpFlds();
+
+    {
+        SwPosition& rInsPos = *aInsertPam.GetPoint();
+        //find out if the clipboard document starts with a table
+        bool bStartWithTable = 0 != aCpyPam.Start()->nNode.GetNode().FindTableNode();
+        SwPosition aInsertPosition( rInsPos );
+
+        {
+            SwNodeIndex aIndexBefore(rInsPos.nNode);
+
+            aIndexBefore--;
+
+            rSource.Copy( aCpyPam, rInsPos, true );
+
+            {
+                aIndexBefore++;
+                SwPaM aPaM(SwPosition(aIndexBefore, 0),
+                           SwPosition(rInsPos.nNode, 0));
+
+                MakeUniqueNumRules(aPaM);
+            }
+        }
+
+        //TODO: Is this necessary here? SaveTblBoxCntnt( &rInsPos );
+        if(/*bIncludingPageFrames && */bStartWithTable)
+        {
+            //remove the paragraph in front of the table
+            SwPaM aPara(aInsertPosition);
+            this->DelFullPara(aPara);
+        }
+        //additionally copy page bound frames
+        if( /*bIncludingPageFrames && */rSource.GetSpzFrmFmts()->Count() )
+        {
+            for ( USHORT i = 0; i < rSource.GetSpzFrmFmts()->Count(); ++i )
+            {
+                BOOL bInsWithFmt = TRUE;
+                const SwFrmFmt& rCpyFmt = *(*rSource.GetSpzFrmFmts())[i];
+                if( bInsWithFmt  )
+                {
+                    SwFmtAnchor aAnchor( rCpyFmt.GetAnchor() );
+                    if( FLY_PAGE == aAnchor.GetAnchorId() )
+                    {
+                        aAnchor.SetPageNum( aAnchor.GetPageNum() + /*nStartPageNumber - */1 );
+                    }
+                    else
+                        continue;
+                    this->CopyLayoutFmt( rCpyFmt, aAnchor, true, true );
+                }
+            }
+        }
+    }
+
+    this->EndUndo( UNDO_INSGLOSSARY, NULL );
+
+    UnlockExpFlds();
+    UpdateFlds(NULL, false);
+}
diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx
index 611dcb0..30aa235 100644
--- a/sw/source/core/doc/docnum.cxx
+++ b/sw/source/core/doc/docnum.cxx
@@ -2277,7 +2277,7 @@ BOOL SwDoc::MoveParagraph( const SwPaM& rPam, long nOffset, BOOL bIsOutlMv )
                 }
             }
 
-            Copy( aPam, aInsPos );
+            Copy( aPam, aInsPos, false );
             if( bDelLastPara )
             {
                 // dann muss der letzte leere Node wieder entfernt werden
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index d1ebf39..d838609 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -3419,7 +3419,7 @@ void SwRedline::CopyToSection()
             SwNodeIndex aNdIdx( *pSttNd, 1 );
             SwTxtNode* pTxtNd = aNdIdx.GetNode().GetTxtNode();
             SwPosition aPos( aNdIdx, SwIndex( pTxtNd ));
-            pDoc->Copy( *this, aPos );
+            pDoc->Copy( *this, aPos, false );
 
             // JP 08.10.98: die Vorlage vom EndNode ggfs. mit uebernehmen
             //				- ist im Doc::Copy nicht erwuenscht
@@ -3444,13 +3444,13 @@ void SwRedline::CopyToSection()
             if( pCEndNd )
             {
                 SwPosition aPos( *pSttNd->EndOfSectionNode() );
-                pDoc->Copy( *this, aPos );
+                pDoc->Copy( *this, aPos, false );
             }
             else
             {
                 SwNodeIndex aInsPos( *pSttNd->EndOfSectionNode() );
                 SwNodeRange aRg( pStt->nNode, 0, pEnd->nNode, 1 );
-                pDoc->CopyWithFlyInFly( aRg, aInsPos );
+                pDoc->CopyWithFlyInFly( aRg, 0, aInsPos );
             }
         }
         pCntntSect = new SwNodeIndex( *pSttNd );
diff --git a/sw/source/core/doc/swserv.cxx b/sw/source/core/doc/swserv.cxx
index 686aeef..1d99c82 100644
--- a/sw/source/core/doc/swserv.cxx
+++ b/sw/source/core/doc/swserv.cxx
@@ -299,9 +299,12 @@ void SwServerObject::SetNoServer()
     if(eType == BOOKMARK_SERVER && CNTNT_TYPE.pBkmk)
     {
         ::sw::mark::DdeBookmark* const pDdeBookmark = dynamic_cast< ::sw::mark::DdeBookmark* >(CNTNT_TYPE.pBkmk);
-        if(pDdeBookmark) pDdeBookmark->SetRefObject(NULL);
+        if(pDdeBookmark) 
+        {
+            CNTNT_TYPE.pBkmk = 0, eType = NONE_SERVER;
+            pDdeBookmark->SetRefObject(NULL);
+        }
     }
-    CNTNT_TYPE.pBkmk = 0, eType = NONE_SERVER;
 }
 
 void SwServerObject::SetDdeBookmark( ::sw::mark::IMark& rBookmark)
diff --git a/sw/source/core/doc/tblcpy.cxx b/sw/source/core/doc/tblcpy.cxx
index 02a4431..6bca094 100644
--- a/sw/source/core/doc/tblcpy.cxx
+++ b/sw/source/core/doc/tblcpy.cxx
@@ -567,7 +567,7 @@ void lcl_CpyBox( const SwTable& rCpyTbl, const SwTableBox* pCpyBox,
 
     SwNodeIndex aSavePos( aInsIdx, -1 );
     if( pRg.get() )
-        pCpyDoc->CopyWithFlyInFly( *pRg, aInsIdx, FALSE );
+        pCpyDoc->CopyWithFlyInFly( *pRg, 0, aInsIdx, FALSE );
     else
         pDoc->GetNodes().MakeTxtNode( aInsIdx, (SwTxtFmtColl*)pDoc->GetDfltTxtFmtColl() );
     aSavePos++;
diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx
index 6176a7d..39b7f95 100644
--- a/sw/source/core/doc/tblrwcl.cxx
+++ b/sw/source/core/doc/tblrwcl.cxx
@@ -2103,7 +2103,7 @@ BOOL lcl_CopyBoxToDoc( const _FndBox*& rpFndBox, void* pPara )
                             *rpFndBox->GetBox()->GetSttNd()->EndOfSectionNode() );
                 SwNodeIndex aInsIdx( *pBox->GetSttNd(), 1 );
 
-                pFromDoc->CopyWithFlyInFly( aCpyRg, aInsIdx, FALSE );
+                pFromDoc->CopyWithFlyInFly( aCpyRg, 0, aInsIdx, FALSE );
                 // den initialen TextNode loeschen
                 pCpyPara->pDoc->GetNodes().Delete( aInsIdx, 1 );
             }
diff --git a/sw/source/core/docnode/ndcopy.cxx b/sw/source/core/docnode/ndcopy.cxx
index 067278e..dba567c 100644
--- a/sw/source/core/docnode/ndcopy.cxx
+++ b/sw/source/core/docnode/ndcopy.cxx
@@ -673,7 +673,7 @@ void lcl_DeleteRedlines( const SwNodeRange& rRg, SwNodeRange& rCpyRg )
 
 // Kopieren eines Bereiches im oder in ein anderes Dokument !
 
-bool SwDoc::Copy( SwPaM& rPam, SwPosition& rPos ) const
+bool SwDoc::Copy( SwPaM& rPam, SwPosition& rPos, bool bCopyAll ) const
 {
     const SwPosition *pStt = rPam.Start(), *pEnd = rPam.End();
 
@@ -712,13 +712,13 @@ bool SwDoc::Copy( SwPaM& rPam, SwPosition& rPos ) const
     BOOL bRet = FALSE;
 
     if( pDoc != this )
-        bRet = _Copy( rPam, rPos, TRUE, pRedlineRange );    // nur normales Kopieren
+        bRet = _Copy( rPam, rPos, TRUE, bCopyAll, pRedlineRange );    // nur normales Kopieren
     // Copy in sich selbst (ueber mehrere Nodes wird hier gesondert
     // behandelt; in einem TextNode wird normal behandelt)
     else if( ! ( *pStt <= rPos && rPos < *pEnd &&
             ( pStt->nNode != pEnd->nNode ||
               !pStt->nNode.GetNode().IsTxtNode() )) )
-        bRet = _Copy( rPam, rPos, TRUE, pRedlineRange );	// nur normales Kopieren
+        bRet = _Copy( rPam, rPos, TRUE, bCopyAll, pRedlineRange );	// nur normales Kopieren
 
     else
     {
@@ -742,7 +742,7 @@ bool SwDoc::Copy( SwPaM& rPam, SwPosition& rPos ) const
         SwStartNode* pSttNd = pDoc->GetNodes().MakeEmptySection(
                                 SwNodeIndex( GetNodes().GetEndOfAutotext() ));
         aPam.GetPoint()->nNode = *pSttNd->EndOfSectionNode();
-        pDoc->_Copy( rPam, *aPam.GetPoint(), FALSE );		// kopieren ohne Frames
+        pDoc->_Copy( rPam, *aPam.GetPoint(), FALSE, bCopyAll, 0 );		// kopieren ohne Frames
 
         aPam.GetPoint()->nNode = pDoc->GetNodes().GetEndOfAutotext();
         aPam.SetMark();
@@ -817,7 +817,7 @@ BOOL lcl_MarksWholeNode(const SwPaM & rPam)
 }
 
 BOOL SwDoc::_Copy( SwPaM& rPam, SwPosition& rPos,
-                    BOOL bMakeNewFrms, SwPaM* pCpyRange ) const
+                    BOOL bMakeNewFrms, bool bCopyAll, SwPaM* pCpyRange ) const
 {
     SwDoc* pDoc = rPos.nNode.GetNode().GetDoc();
     bool bColumnSel = pDoc->IsClipBoard() && pDoc->IsColumnSelection();
@@ -1101,7 +1101,7 @@ BOOL SwDoc::_Copy( SwPaM& rPam, SwPosition& rPos,
             }
         }
 
-        if( aRg.aStart != aRg.aEnd )
+        if( bCopyAll || aRg.aStart != aRg.aEnd )
         {
             SfxItemSet aBrkSet( pDoc->GetAttrPool(), aBreakSetRange );
             if( pSttNd && bCopyCollFmt && pDestNd->HasSwAttrSet() )
@@ -1116,13 +1116,13 @@ BOOL SwDoc::_Copy( SwPaM& rPam, SwPosition& rPos,
             if( aInsPos == pEnd->nNode )
             {
                 SwNodeIndex aSaveIdx( aInsPos, -1 );
-                CopyWithFlyInFly( aRg, aInsPos, bMakeNewFrms, FALSE );
+                CopyWithFlyInFly( aRg, 0,aInsPos, bMakeNewFrms, FALSE );
                 aSaveIdx++;
                 pEnd->nNode = aSaveIdx;
                 pEnd->nContent.Assign( aSaveIdx.GetNode().GetTxtNode(), 0 );
             }
             else
-                CopyWithFlyInFly( aRg, aInsPos, bMakeNewFrms, FALSE );
+                CopyWithFlyInFly( aRg, pEnd->nContent.GetIndex(), aInsPos, bMakeNewFrms, FALSE );
 
             bCopyBookmarks = FALSE;
 
@@ -1181,7 +1181,7 @@ BOOL SwDoc::_Copy( SwPaM& rPam, SwPosition& rPos,
 
 //  ----- Copy-Methode vom SwDoc - "kopiere Fly's in Fly's" ------
 
-void SwDoc::CopyWithFlyInFly( const SwNodeRange& rRg,
+void SwDoc::CopyWithFlyInFly( const SwNodeRange& rRg, const xub_StrLen nEndContentIndex, 
                             const SwNodeIndex& rInsPos, BOOL bMakeNewFrms,
                             BOOL bDelRedlines, BOOL bCopyFlyAtFly ) const
 {
@@ -1220,7 +1220,7 @@ void SwDoc::CopyWithFlyInFly( const SwNodeRange& rRg,
     // Undo abschalten
     BOOL bUndo = pDest->DoesUndo();
     pDest->DoUndo( FALSE );
-    _CopyFlyInFly( rRg, aSavePos, bCopyFlyAtFly );
+    _CopyFlyInFly( rRg, nEndContentIndex, aSavePos, bCopyFlyAtFly );
     pDest->DoUndo( bUndo );
 
     SwNodeRange aCpyRange( aSavePos, rInsPos );
@@ -1256,7 +1256,7 @@ void lcl_ChainFmts( SwFlyFrmFmt *pSrc, SwFlyFrmFmt *pDest )
     }
 }
 
-void SwDoc::_CopyFlyInFly( const SwNodeRange& rRg, const SwNodeIndex& rSttIdx,
+void SwDoc::_CopyFlyInFly( const SwNodeRange& rRg, const xub_StrLen nEndContentIndex, const SwNodeIndex& rSttIdx,
                             BOOL bCopyFlyAtFly ) const
 {
     // Bug 22727: suche erst mal alle Flys zusammen, sortiere sie entsprechend
@@ -1273,7 +1273,8 @@ void SwDoc::_CopyFlyInFly( const SwNodeRange& rRg, const SwNodeIndex& rSttIdx,
         const SwFrmFmt* pFmt = (*GetSpzFrmFmts())[n];
         const SwFmtAnchor* pAnchor = &pFmt->GetAnchor();
         const SwPosition* pAPos;
-        if ( ( pAnchor->GetAnchorId() == FLY_AT_CNTNT ||
+        bool bAtCntnt = pAnchor->GetAnchorId() == FLY_AT_CNTNT;
+        if ( ( bAtCntnt ||
                pAnchor->GetAnchorId() == FLY_AT_FLY ||
                pAnchor->GetAnchorId() == FLY_AUTO_CNTNT ) &&
              0 != ( pAPos = pAnchor->GetCntntAnchor()) &&
@@ -1282,9 +1283,53 @@ void SwDoc::_CopyFlyInFly( const SwNodeRange& rRg, const SwNodeIndex& rSttIdx,
                     : ( IsRedlineMove()
                             ? rRg.aStart < pAPos->nNode
                             : rRg.aStart <= pAPos->nNode )) &&
-             pAPos->nNode < rRg.aEnd )
+             pAPos->nNode <= rRg.aEnd )
         {
-            aArr.Insert( _ZSortFly( pFmt, pAnchor, nArrLen + aArr.Count() ));
+            //frames at the last source node are not always copied:
+            //- if the node is empty and is the last node of the document or a table cell
+            //  or a text frame then tey have to be copied
+            //- if the content index in this node is > 0 then paragph and frame bound objects are copied
+            //- to-character bound objects are copied if their index is <= nEndContentIndex
+            bool bAdd = false;
+            if( pAPos->nNode < rRg.aEnd )
+                bAdd = true;
+            if( !bAdd )
+            {
+                bool bEmptyNode = false;
+                bool bLastNode = false;
+                // is the node empty?
+                const SwNodes& rNodes = pAPos->nNode.GetNodes();
+                SwTxtNode* pTxtNode;
+                if( 0 != ( pTxtNode = pAPos->nNode.GetNode().GetTxtNode() ))
+                {
+                    bEmptyNode = !pTxtNode->GetTxt().Len();
+                    if( bEmptyNode )
+                    {
+                        //last node information is only necessary to know for the last TextNode
+                        SwNodeIndex aTmp( pAPos->nNode );
+                        ++aTmp;//goto next node
+                        while( rNodes[aTmp ]->IsEndNode() )
+                        {
+                            if( aTmp == rNodes.GetEndOfContent().GetIndex() )
+                            {
+                                bLastNode = true;
+                                break;
+                            }
+                            ++aTmp;
+                        }
+                    }
+                }
+                bAdd = bLastNode && bEmptyNode;
+                if( !bAdd )
+                {
+                    if( bAtCntnt )
+                        bAdd = nEndContentIndex > 0;
+                    else 
+                        bAdd = pAPos->nContent <= nEndContentIndex;
+                }
+            }
+            if( bAdd )                
+                aArr.Insert( _ZSortFly( pFmt, pAnchor, nArrLen + aArr.Count() ));
         }
     }
 
diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx
index 29fcbf0..a10833f 100644
--- a/sw/source/core/docnode/section.cxx
+++ b/sw/source/core/docnode/section.cxx
@@ -1414,7 +1414,7 @@ void SwIntrnlSectRefLink::DataChanged( const String& rMimeType,
                         if( pSrcDoc != pDoc ||
                             pCpyPam->Start()->nNode > rInsPos ||
                             rInsPos >= pCpyPam->End()->nNode )
-                            pSrcDoc->Copy( *pCpyPam, *pPam->GetPoint() );
+                            pSrcDoc->Copy( *pCpyPam, *pPam->GetPoint(), false );
                         delete pCpyPam;
                     }
                     if( pCpyRg && pSrcDoc == pDoc &&
@@ -1443,7 +1443,7 @@ void SwIntrnlSectRefLink::DataChanged( const String& rMimeType,
 
                     SwTblNumFmtMerge aTNFM( *pSrcDoc, *pDoc );
 
-                    pSrcDoc->CopyWithFlyInFly( *pCpyRg, rInsPos, bCreateFrm );
+                    pSrcDoc->CopyWithFlyInFly( *pCpyRg, 0, rInsPos, bCreateFrm );
                     aSave++;
 
                     if( !bCreateFrm )
diff --git a/sw/source/core/edit/acorrect.cxx b/sw/source/core/edit/acorrect.cxx
index 1f4395c..ede1df3 100644
--- a/sw/source/core/edit/acorrect.cxx
+++ b/sw/source/core/edit/acorrect.cxx
@@ -374,7 +374,7 @@ BOOL SwAutoCorrDoc::ChgAutoCorrWord( xub_StrLen & rSttPos, xub_StrLen nEndPos,
                 SwDontExpandItem aExpItem;
                 aExpItem.SaveDontExpandItems( *aPam.GetPoint() );
 
-                pAutoDoc->Copy( aCpyPam, *aPam.GetPoint() );
+                pAutoDoc->Copy( aCpyPam, *aPam.GetPoint(), false );
 
                 aExpItem.RestoreDontExpandItems( *aPam.GetPoint() );
 
diff --git a/sw/source/core/edit/eddel.cxx b/sw/source/core/edit/eddel.cxx
index 1e0ad70..f3942ff 100644
--- a/sw/source/core/edit/eddel.cxx
+++ b/sw/source/core/edit/eddel.cxx
@@ -249,7 +249,7 @@ long SwEditShell::Copy( SwEditShell* pDestShell )
             bFirstMove = FALSE;
         }
 
-        if( !GetDoc()->Copy( *PCURCRSR, *pPos ))
+        if( !GetDoc()->Copy( *PCURCRSR, *pPos, false ))
             continue;
 
         SwPaM aInsertPaM(*pPos, SwPosition(aSttNdIdx));
diff --git a/sw/source/core/edit/edglss.cxx b/sw/source/core/edit/edglss.cxx
index 93a48eb..0196844 100644
--- a/sw/source/core/edit/edglss.cxx
+++ b/sw/source/core/edit/edglss.cxx
@@ -168,7 +168,7 @@ USHORT SwEditShell::SaveGlossaryDoc( SwTextBlocks& rBlock,
             aStt = pGDoc->GetNodes().GetEndOfExtras();
             pCntntNd = pGDoc->GetNodes().GoNext( &aStt );
             SwPosition aInsPos( aStt, SwIndex( pCntntNd ));
-            pMyDoc->Copy( aCpyPam, aInsPos );
+            pMyDoc->Copy( aCpyPam, aInsPos, false );
 
             nRet = rBlock.PutDoc();
         }
@@ -250,13 +250,13 @@ BOOL SwEditShell::_CopySelToDoc( SwDoc* pInsDoc, SwNodeIndex* pSttNd )
                 {
                     PCURCRSR->SetMark();
                     PCURCRSR->Move( fnMoveForward, fnGoCntnt );
-                    bRet = GetDoc()->Copy( *PCURCRSR, aPos ) || bRet;
+                    bRet = GetDoc()->Copy( *PCURCRSR, aPos, false ) || bRet;
                     PCURCRSR->Exchange();
                     PCURCRSR->DeleteMark();
                 }
             }
             else
-                bRet = GetDoc()->Copy( *PCURCRSR, aPos ) || bRet;
+                bRet = GetDoc()->Copy( *PCURCRSR, aPos, false ) || bRet;
 
         FOREACHPAM_END()
         }
diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx
index aa5dce2..bc2467e 100644
--- a/sw/source/core/frmedt/fecopy.cxx
+++ b/sw/source/core/frmedt/fecopy.cxx
@@ -840,7 +840,7 @@ BOOL SwFEShell::Paste( SwDoc* pClpDoc, BOOL bIncludingPageFrames )
             {
                 SwNodeIndex aIndexBefore(rInsPos.nNode);
                 aIndexBefore--;
-                pClpDoc->Copy( rCopy, rInsPos );
+                pClpDoc->Copy( rCopy, rInsPos, false );
                 {
                     aIndexBefore++;
                     SwPaM aPaM(SwPosition(aIndexBefore, 0),
@@ -1069,7 +1069,7 @@ BOOL SwFEShell::Paste( SwDoc* pClpDoc, BOOL bIncludingPageFrames )
 
                 aIndexBefore--;
 
-                pClpDoc->Copy( aCpyPam, rInsPos );
+                pClpDoc->Copy( aCpyPam, rInsPos, false );
 
                 {
                     aIndexBefore++;
diff --git a/sw/source/core/txtnode/atrftn.cxx b/sw/source/core/txtnode/atrftn.cxx
index f5c83ba..3edd575 100644
--- a/sw/source/core/txtnode/atrftn.cxx
+++ b/sw/source/core/txtnode/atrftn.cxx
@@ -310,7 +310,7 @@ void SwTxtFtn::CopyFtn( SwTxtFtn *pDest )
         SwNodeIndex aEnd( *aStart.GetNode().EndOfSectionNode() );
         ULONG  nDestLen = aEnd.GetIndex() - aStart.GetIndex() - 1;
 
-        m_pTxtNode->GetDoc()->CopyWithFlyInFly( aRg, aEnd, TRUE );
+        m_pTxtNode->GetDoc()->CopyWithFlyInFly( aRg, 0, aEnd, TRUE );
 
         // Wenn die Dest-Sektion nicht leer war, so muessen die alten
         // Nodes geloescht werden:
diff --git a/sw/source/core/undo/untblk.cxx b/sw/source/core/undo/untblk.cxx
index ee30cf7..05f7afb 100644
--- a/sw/source/core/undo/untblk.cxx
+++ b/sw/source/core/undo/untblk.cxx
@@ -346,7 +346,7 @@ void SwUndoInserts::Repeat( SwUndoIter& rUndoIter )
 
     SwPaM aPam( *rUndoIter.pAktPam->GetPoint() );
     SetPaM( aPam );
-    aPam.GetDoc()->Copy( aPam, *rUndoIter.pAktPam->GetPoint() );
+    aPam.GetDoc()->Copy( aPam, *rUndoIter.pAktPam->GetPoint(), false );
 
     rUndoIter.pLastUndoObj = this;
 }
diff --git a/sw/source/filter/ww8/ww8glsy.cxx b/sw/source/filter/ww8/ww8glsy.cxx
index b617ba2..1eb9ae9 100644
--- a/sw/source/filter/ww8/ww8glsy.cxx
+++ b/sw/source/filter/ww8/ww8glsy.cxx
@@ -187,7 +187,7 @@ bool WW8Glossary::MakeEntries(SwDoc *pD, SwTextBlocks &rBlocks,
                         -1 );
                     pCNd = aIdx.GetNode().GetCntntNode();
                     SwPosition aPos( aIdx, SwIndex( pCNd, pCNd->Len() ));
-                    pD->Copy( aPam, aPos );
+                    pD->Copy( aPam, aPos, false );
                     rBlocks.PutDoc();
                 }
             }
diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx
index 3b353cc..22c222e 100644
--- a/sw/source/filter/xml/xmltbli.cxx
+++ b/sw/source/filter/xml/xmltbli.cxx
@@ -699,7 +699,7 @@ void SwXMLTableCellContext_Impl::EndElement()
                     SwPaM aSrcPaM( *pSrcPaM->GetPoint(),
                                    *pSrcPaM->GetMark() );
                     SwPosition aDstPos( *pDstTxtCrsr->GetPaM()->GetPoint() );
-                    pDoc->Copy( aSrcPaM, aDstPos );
+                    pDoc->Copy( aSrcPaM, aDstPos, false );
 
                     nColRepeat--;
                 }
diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx
index 5b364e7..128d0e7 100644
--- a/sw/source/ui/dbui/dbmgr.cxx
+++ b/sw/source/ui/dbui/dbmgr.cxx
@@ -35,7 +35,7 @@
 #endif
 
 #include <stdio.h>
-
+#include <unotxdoc.hxx>
 #include <com/sun/star/text/NotePrintMode.hpp>
 #include <sfx2/app.hxx>
 #include <com/sun/star/sdb/CommandType.hpp>
@@ -43,17 +43,13 @@
 #include <com/sun/star/frame/XComponentLoader.hpp>
 #include <com/sun/star/lang/DisposedException.hpp>
 #include <com/sun/star/lang/XEventListener.hpp>
-#ifndef _COM_SUN_STAR_UTIL_iXNUMBERFORMATTER_HPP_
 #include <com/sun/star/util/XNumberFormatter.hpp>
-#endif
 #include <com/sun/star/sdb/XCompletedConnection.hpp>
 #include <com/sun/star/sdb/XCompletedExecution.hpp>
 #include <com/sun/star/container/XChild.hpp>
-#ifndef _COM_SUN_STAR_TEXT_MAILMERGEEVENT_
 #include <com/sun/star/text/MailMergeEvent.hpp>
-#endif
 #include <com/sun/star/frame/XStorable.hpp>
-#include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
+#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
 #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
 #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
 #include <com/sun/star/uno/XNamingService.hpp>
@@ -65,9 +61,7 @@
 #include <dbconfig.hxx>
 #include <swdbtoolsclient.hxx>
 #include <pagedesc.hxx>
-#ifndef _LSTBOX_HXX //autogen
 #include <vcl/lstbox.hxx>
-#endif
 #include <unotools/tempfile.hxx>
 #include <svtools/pathoptions.hxx>
 #include <svtools/urihelper.hxx>
@@ -86,39 +80,25 @@
 #include <goodies/mailenum.hxx>
 #include <cmdid.h>
 #include <swmodule.hxx>
-#ifndef _VIEW_HXX
 #include <view.hxx>
-#endif
-#ifndef _DOCSH_HXX
 #include <docsh.hxx>
-#endif
 #include <edtwin.hxx>
 #include <wrtsh.hxx>
 #include <fldbas.hxx>
 #include <initui.hxx>
 #include <swundo.hxx>
 #include <flddat.hxx>
-#ifndef _MODCFG_HXX
 #include <modcfg.hxx>
-#endif
 #include <swprtopt.hxx>
 #include <shellio.hxx>
 #include <dbui.hxx>
-#ifndef _DBMGR_HXX
 #include <dbmgr.hxx>
-#endif
 #include <doc.hxx>
 #include <swwait.hxx>
 #include <swunohelper.hxx>
-#ifndef _DBUI_HRC
 #include <dbui.hrc>
-#endif
-#ifndef _GLOBALS_HRC
 #include <globals.hrc>
-#endif
-#ifndef _STATSTR_HRC
 #include <statstr.hrc>
-#endif
 #include <mmconfigitem.hxx>
 #include <sfx2/request.hxx>
 #include <hintids.hxx>
@@ -3185,7 +3165,6 @@ sal_Int32 SwNewDBMgr::MergeDocuments( SwMailMergeConfigItem& rMMConfig,
 
     SwWrtShell& rSourceShell = rSourceView.GetWrtShell();
     BOOL bSynchronizedDoc = rSourceShell.IsLabelDoc() && rSourceShell.GetSectionFmtCount() > 1;
-    String sSourceDocURL;
     //save the settings of the first
     rSourceShell.SttEndDoc(TRUE);
     USHORT nStartingPageNo = rSourceShell.GetVirtPageNum();
@@ -3195,22 +3174,6 @@ sal_Int32 SwNewDBMgr::MergeDocuments( SwMailMergeConfigItem& rMMConfig,
 
     try
     {
-        // save the working document into a temporary location
-        sSourceDocURL = URIHelper::SmartRel2Abs(
-            INetURLObject(), utl::TempFile::CreateTempName(),
-            URIHelper::GetMaybeFileHdl());
-        const SfxFilter *pSfxFlt = SwIoSystem::GetFilterOfFormat(
-                String::CreateFromAscii( FILTER_XML ),
-                SwDocShell::Factory().GetFilterContainer() );
-
-        SfxStringItem aFilterName( SID_FILTER_NAME, pSfxFlt->GetFilterName());
-        uno::Sequence< beans::PropertyValue > aValues(1);
-        beans::PropertyValue* pValues = aValues.getArray();
-        pValues[0].Name = C2U("FilterName");
-        pValues[0].Value <<= ::rtl::OUString(pSfxFlt->GetFilterName());
-        uno::Reference< frame::XStorable > xStore( rSourceView.GetDocShell()->GetModel(), uno::UNO_QUERY);
-        xStore->storeToURL( sSourceDocURL, aValues );
-
         // create a target docshell to put the merged document into
         SfxObjectShellRef xTargetDocShell( new SwDocShell( SFX_CREATE_MODE_STANDARD ) );
         xTargetDocShell->DoInitNew( 0 );
@@ -3259,116 +3222,120 @@ sal_Int32 SwNewDBMgr::MergeDocuments( SwMailMergeConfigItem& rMMConfig,
                     Application::Reschedule();
             }
 
-            // create a new docshell from the temporary document
-            SfxBoolItem aHidden( SID_HIDDEN, TRUE );
-            SfxStringItem aReferer( SID_REFERER, String::CreateFromAscii(URL_PREFIX_PRIV_SOFFICE ));
-            SfxStringItem aTarget( SID_TARGETNAME, String::CreateFromAscii("_blank") );
-            SfxStringItem aURL( SID_FILE_NAME, sSourceDocURL );
-            const SfxPoolItem* pReturnValue =
-                            rSourceView.GetViewFrame()->GetDispatcher()->Execute( SID_OPENDOC, SFX_CALLMODE_SYNCHRON,
-                                    &aURL, &aFilterName, &aHidden, &aReferer, &aTarget, 0L);
-            if(pReturnValue)
+            // copy the source document
+            SfxObjectShellRef xWorkDocSh;
+            if(nDocNo == 1 )
             {
-                SfxViewFrameItem* pVItem = (SfxViewFrameItem*)pReturnValue;
-                SwView* pWorkView = (SwView*) pVItem->GetFrame()->GetViewShell();
-                SwWrtShell& rWorkShell = pWorkView->GetWrtShell();
-                pWorkView->AttrChangedNotify( &rWorkShell );//Damit SelectShell gerufen wird.
-
-                // merge the data
-                SwDoc* pWorkDoc = rWorkShell.GetDoc();
-                SwNewDBMgr* pWorkDBMgr = pWorkDoc->GetNewDBMgr();
-                pWorkDoc->SetNewDBMgr( this );
-                pWorkDoc->EmbedAllLinks();
-                if(UNDO_UI_DELETE_INVISIBLECNTNT == rWorkShell.GetUndoIds())
-                    rWorkShell.Undo();
-                // create a layout
-                rWorkShell.CalcLayout();
-                SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE, rWorkShell.GetView().GetViewFrame()->GetObjectShell()));
-                rWorkShell.ViewShell::UpdateFlds();
-                SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE_FINISHED, rWorkShell.GetView().GetViewFrame()->GetObjectShell()));
-
-                // strip invisible content and convert fields to text
-                rWorkShell.RemoveInvisibleContent();
-                rWorkShell.ConvertFieldsToText();
-                rWorkShell.SetNumberingRestart();
-
-
-                // insert the document into the target document
-                rWorkShell.SttEndDoc(FALSE);
-                rWorkShell.SttEndDoc(TRUE);
-                rWorkShell.SelAll();
-                pTargetShell->SttEndDoc(FALSE);
-
-                //#i63806# put the styles to the target document
-                //if the source uses headers or footers each new copy need to copy a new page styles
-                if(bPageStylesWithHeaderFooter)
-                {
-                    //create a new pagestyle
-                    //copy the pagedesc from the current document to the new document and change the name of the to-be-applied style
-
-                    SwDoc* pTargetDoc = pTargetShell->GetDoc();
-                    String sNewPageDescName = lcl_FindUniqueName(pTargetShell, sStartingPageDesc, nDocNo );
-                    pTargetShell->GetDoc()->MakePageDesc( sNewPageDescName );
-                    SwPageDesc* pTargetPageDesc = pTargetShell->FindPageDescByName( sNewPageDescName );
-                    if(pSourcePageDesc && pTargetPageDesc)
-                    {
-                        pTargetDoc->CopyPageDesc( *pSourcePageDesc, *pTargetPageDesc, sal_False );
-                        sModifiedStartingPageDesc = sNewPageDescName;
-                        lcl_CopyFollowPageDesc( *pTargetShell, *pSourcePageDesc, *pTargetPageDesc, nDocNo );
-                    }
-                }
-                if(nDocNo == 1 || bPageStylesWithHeaderFooter)
-                {
-                    pTargetView->GetDocShell()->_LoadStyles( *pWorkView->GetDocShell(), sal_True );
-                }
-                if(nDocNo > 1)
-                {
-                    pTargetShell->InsertPageBreak( &sModifiedStartingPageDesc, nStartingPageNo );
-                }
-                else
-                {
-                    pTargetShell->SetPageStyle(sModifiedStartingPageDesc);
-                }
-                USHORT nPageCountBefore = pTargetShell->GetPageCnt();
-                DBG_ASSERT(!pTargetShell->GetTableFmt(),"target document ends with a table - paragraph should be appended");
-                //#i51359# add a second paragraph in case there's only one
+                uno::Reference< util::XCloneable > xClone( rSourceView.GetDocShell()->GetModel(), uno::UNO_QUERY);
+                uno::Reference< lang::XUnoTunnel > xWorkDocShell( xClone->createClone(), uno::UNO_QUERY); 
+                SwXTextDocument* pWorkModel = reinterpret_cast<SwXTextDocument*>(xWorkDocShell->getSomething(SwXTextDocument::getUnoTunnelId()));
+                xWorkDocSh = pWorkModel->GetDocShell();
+            }
+            else
+            {
+                SwDoc* pNewDoc = rSourceView.GetDocShell()->GetDoc()->CreateCopy();
+                xWorkDocSh = new SwDocShell( pNewDoc, SFX_CREATE_MODE_STANDARD );
+                xWorkDocSh->DoInitNew();
+            }    
+            //create a ViewFrame
+            SwView* pWorkView = static_cast< SwView* >( SfxViewFrame::CreateViewFrame( *xWorkDocSh, 0, sal_True )->GetViewShell() );
+            SwWrtShell& rWorkShell = pWorkView->GetWrtShell();
+            pWorkView->AttrChangedNotify( &rWorkShell );//Damit SelectShell gerufen wird.
+
+            // merge the data
+            SwDoc* pWorkDoc = rWorkShell.GetDoc();
+            SwNewDBMgr* pWorkDBMgr = pWorkDoc->GetNewDBMgr();
+            pWorkDoc->SetNewDBMgr( this );
+            pWorkDoc->EmbedAllLinks();
+            if(UNDO_UI_DELETE_INVISIBLECNTNT == rWorkShell.GetUndoIds())
+                rWorkShell.Undo();
+            // create a layout
+            rWorkShell.CalcLayout();
+            SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE, rWorkShell.GetView().GetViewFrame()->GetObjectShell()));
+            rWorkShell.ViewShell::UpdateFlds();
+            SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE_FINISHED, rWorkShell.GetView().GetViewFrame()->GetObjectShell()));
+
+            // strip invisible content and convert fields to text
+            rWorkShell.RemoveInvisibleContent();
+            rWorkShell.ConvertFieldsToText();
+            rWorkShell.SetNumberingRestart();
+
+
+            // insert the document into the target document
+            rWorkShell.SttEndDoc(FALSE);
+            rWorkShell.SttEndDoc(TRUE);
+            rWorkShell.SelAll();
+            pTargetShell->SttEndDoc(FALSE);
+
+            //#i63806# put the styles to the target document
+            //if the source uses headers or footers each new copy need to copy a new page styles
+            if(bPageStylesWithHeaderFooter)
+            {
+                //create a new pagestyle
+                //copy the pagedesc from the current document to the new document and change the name of the to-be-applied style
+
+                SwDoc* pTargetDoc = pTargetShell->GetDoc();
+                String sNewPageDescName = lcl_FindUniqueName(pTargetShell, sStartingPageDesc, nDocNo );
+                pTargetShell->GetDoc()->MakePageDesc( sNewPageDescName );
+                SwPageDesc* pTargetPageDesc = pTargetShell->FindPageDescByName( sNewPageDescName );
+                if(pSourcePageDesc && pTargetPageDesc)
                 {
-                    SwNodeIndex aIdx( pWorkDoc->GetNodes().GetEndOfExtras(), 2 );
-                  SwPosition aTestPos( aIdx );
-                  SwCursor aTestCrsr(aTestPos,0,false);
-                    if(!aTestCrsr.MovePara(fnParaNext, fnParaStart))
-                    {
-                        //append a paragraph
-                        pWorkDoc->AppendTxtNode( aTestPos );
-                    }
+                    pTargetDoc->CopyPageDesc( *pSourcePageDesc, *pTargetPageDesc, sal_False );
+                    sModifiedStartingPageDesc = sNewPageDescName;
+                    lcl_CopyFollowPageDesc( *pTargetShell, *pSourcePageDesc, *pTargetPageDesc, nDocNo );
                 }
-                pTargetShell->Paste( rWorkShell.GetDoc(), sal_True );
-                //convert fields in page styles (header/footer - has to be done after the first document has been pasted
-                if(1 == nDocNo)
+            }
+            if(nDocNo == 1 || bPageStylesWithHeaderFooter)
+            {
+                pTargetView->GetDocShell()->_LoadStyles( *pWorkView->GetDocShell(), sal_True );
+            }
+            if(nDocNo > 1)
+            {
+                pTargetShell->InsertPageBreak( &sModifiedStartingPageDesc, nStartingPageNo );
+            }
+            else
+            {
+                pTargetShell->SetPageStyle(sModifiedStartingPageDesc);
+            }
+            USHORT nPageCountBefore = pTargetShell->GetPageCnt();
+            DBG_ASSERT(!pTargetShell->GetTableFmt(),"target document ends with a table - paragraph should be appended");
+            //#i51359# add a second paragraph in case there's only one
+            {
+                SwNodeIndex aIdx( pWorkDoc->GetNodes().GetEndOfExtras(), 2 );
+              SwPosition aTestPos( aIdx );
+              SwCursor aTestCrsr(aTestPos,0,false);
+                if(!aTestCrsr.MovePara(fnParaNext, fnParaStart))
                 {
-                    pTargetShell->CalcLayout();
-                    pTargetShell->ConvertFieldsToText();
+                    //append a paragraph
+                    pWorkDoc->AppendTxtNode( aTestPos );
                 }
-                //add the document info to the config item
-                SwDocMergeInfo aMergeInfo;
-                aMergeInfo.nStartPageInTarget = nPageCountBefore;
-                //#i72820# calculate layout to be able to find the correct page index
+            }
+            pTargetShell->Paste( rWorkShell.GetDoc(), sal_True );
+            //convert fields in page styles (header/footer - has to be done after the first document has been pasted
+            if(1 == nDocNo)
+            {
                 pTargetShell->CalcLayout();
-                aMergeInfo.nEndPageInTarget = pTargetShell->GetPageCnt();
-                aMergeInfo.nDBRow = nStartRow;
-                rMMConfig.AddMergedDocument( aMergeInfo );
-                ++nRet;
-
-                // the print monitor needs some time to act
-                for( USHORT i = 0; i < 25; i++)
-                    Application::Reschedule();
-
-                //restore the ole DBMgr
-                pWorkDoc->SetNewDBMgr( pWorkDBMgr );
-                //now the temporary document should be closed
-                SfxObjectShellRef xDocSh(pWorkView->GetDocShell());
-                xDocSh->DoClose();
+                pTargetShell->ConvertFieldsToText();
             }
+            //add the document info to the config item
+            SwDocMergeInfo aMergeInfo;
+            aMergeInfo.nStartPageInTarget = nPageCountBefore;
+            //#i72820# calculate layout to be able to find the correct page index
+            pTargetShell->CalcLayout();
+            aMergeInfo.nEndPageInTarget = pTargetShell->GetPageCnt();
+            aMergeInfo.nDBRow = nStartRow;
+            rMMConfig.AddMergedDocument( aMergeInfo );
+            ++nRet;
+
+            // the print monitor needs some time to act
+            for( USHORT i = 0; i < 25; i++)
+                Application::Reschedule();
+
+            //restore the ole DBMgr
+            pWorkDoc->SetNewDBMgr( pWorkDBMgr );
+            //now the temporary document should be closed
+            SfxObjectShellRef xDocSh(pWorkView->GetDocShell());
+            xDocSh->DoClose();
             nEndRow = pImpl->pMergeData->xResultSet->getRow();
             ++nDocNo;
         } while( !bCancel &&
@@ -3390,8 +3357,6 @@ sal_Int32 SwNewDBMgr::MergeDocuments( SwMailMergeConfigItem& rMMConfig,
     {
         DBG_ERROR("exception caught in SwNewDBMgr::MergeDocuments");
     }
-    if(sSourceDocURL.Len())
-        File::remove( sSourceDocURL );
     DELETEZ(pImpl->pMergeData);
     bInMerge = FALSE;
     return nRet;
diff --git a/sw/source/ui/uno/unoatxt.cxx b/sw/source/ui/uno/unoatxt.cxx
index b90c50b..a2133be 100644
--- a/sw/source/ui/uno/unoatxt.cxx
+++ b/sw/source/ui/uno/unoatxt.cxx
@@ -416,7 +416,7 @@ sal_Bool lcl_CopySelToDoc( SwDoc* pInsDoc, OTextCursorHelper* pxCursor, SwXTextR
         if(pxCursor)
         {
             SwPaM* pUnoCrsr = pxCursor->GetPaM();
-            bRet |= (true == pxCursor->GetDoc()->Copy( *pUnoCrsr, aPos ));
+            bRet |= (true == pxCursor->GetDoc()->Copy( *pUnoCrsr, aPos, false ));
         }
         else
         {
@@ -424,7 +424,7 @@ sal_Bool lcl_CopySelToDoc( SwDoc* pInsDoc, OTextCursorHelper* pxCursor, SwXTextR
             if(pBkmk && pBkmk->IsExpanded())
             {
                 SwPaM aTmp(pBkmk->GetOtherMarkPos(), pBkmk->GetMarkPos());
-                bRet |= (true == pxRange->GetDoc()->Copy(aTmp, aPos));
+                bRet |= (true == pxRange->GetDoc()->Copy(aTmp, aPos, false));
             }
         }
     }
diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx
index 56c3a0b..6fc167c 100644
--- a/sw/source/ui/uno/unotxdoc.cxx
+++ b/sw/source/ui/uno/unotxdoc.cxx
@@ -37,16 +37,12 @@
 #include <vcl/virdev.hxx>
 #include <vcl/svapp.hxx>
 #include <sfx2/viewfrm.hxx>
-#ifndef _TOOLKIT_UNOHLP_HXX
 #include <toolkit/helper/vclunohelper.hxx>
-#endif
 #include <wdocsh.hxx>
 #include <wrtsh.hxx>
 #include <view.hxx>
 #include <pview.hxx>
-#ifndef _SRCVIEW_HXX
 #include <srcview.hxx>
-#endif
 #include <viewsh.hxx>
 #include <pvprtdat.hxx>
 #include <swprtopt.hxx>
@@ -84,9 +80,7 @@
 #include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
 #include <com/sun/star/lang/DisposedException.hpp>
 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
-#ifndef _COM_SUN_STAR_BEANS_PropertyAttribute_HPP_
 #include <com/sun/star/beans/PropertyAttribute.hpp>
-#endif
 #include <com/sun/star/document/RedlineDisplayType.hpp>
 #include <svx/linkmgr.hxx>
 #include <svx/unofill.hxx>
@@ -94,13 +88,9 @@
 #include <sfx2/progress.hxx>
 #include <swmodule.hxx>
 #include <docstat.hxx>
-#ifndef _MODOPT_HXX //
 #include <modcfg.hxx>
-#endif
 #include <ndtxt.hxx>
-#ifndef _UTLUI_HRC
 #include <utlui.hrc>
-#endif
 #include <swcont.hxx>
 #include <unodefaults.hxx>
 #include <SwXDocumentSettings.hxx>
@@ -2851,7 +2841,27 @@ uno::Reference< text::XFlatParagraphIterator > SAL_CALL SwXTextDocument::getFlat
 {
     return new SwXFlatParagraphIterator( *pDocShell->GetDoc(), nTextMarkupType, bAutomatic );
 }
+/*-- 07.05.2009 09:21:12---------------------------------------------------
 
+  -----------------------------------------------------------------------*/
+uno::Reference< util::XCloneable > SwXTextDocument::createClone(  ) throw (uno::RuntimeException)
+{
+    ::vos::OGuard aGuard(Application::GetSolarMutex());
+    if(!IsValid())
+        throw RuntimeException();
+    //create a new document - hidden - copy the storage and return it
+    SwDoc* pCopyDoc = pDocShell->GetDoc()->CreateCopy();
+    SfxObjectShell* pShell = new SwDocShell( pCopyDoc, SFX_CREATE_MODE_STANDARD );
+    pShell->DoInitNew();
+    
+    uno::Reference< embed::XStorage > xSourceStorage = getDocumentStorage();
+    uno::Reference< frame::XModel > xNewModel = pShell->GetModel();
+    //copy this storage
+    uno::Reference< document::XStorageBasedDocument > xStorageDoc( xNewModel, uno::UNO_QUERY );
+    uno::Reference< embed::XStorage > xNewStorage = xStorageDoc->getDocumentStorage();
+    xSourceStorage->copyToStorage( xNewStorage );
+    return uno::Reference< util::XCloneable >( xNewModel, UNO_QUERY );
+}
 /* -----------------------------20.06.00 09:54--------------------------------
 
  ---------------------------------------------------------------------------*/
commit 79d3ae0dea83ce40fde1a6d12298e6bf954ef19e
Author: Jens-Heiner Rechtien <hr at openoffice.org>
Date:   Tue Jul 28 10:25:31 2009 +0000

    CWS-TOOLING: integrate CWS chart39
    2009-06-30 16:55:46 +0200 iha  r273522 : #i103209# im-/export attribute xlink:href at chart:chart element + some cleanup in naming
    2009-06-30 16:45:59 +0200 iha  r273521 : #i102701# apply patch for P1 issue on dev300m50 to be able to save again
    2009-06-30 16:32:32 +0200 iha  r273520 : #i103209# im-/export attribute xlink:href at chart:chart element + some cleanup in naming
    2009-06-29 10:04:34 +0200 iha  r273454 : #i103147# ODF, workaround broken files with a missing table:cell-range-address at the plot-area
    2009-06-26 19:31:16 +0200 iha  r273437 : #i103147# ODF, workaround broken files with a missing table:cell-range-address at the plot-area
    2009-06-25 10:36:28 +0200 iha  r273367 : #i101968# text values in data range cause incorrect x values
    2009-06-24 17:34:18 +0200 iha  r273357 : #i102428# x values are wrong in xy-scatter-chart with own data table if empty cells are contained in x values
    2009-06-24 10:16:25 +0200 iha  r273317 : #i99915# wrong matrix translation causes broken chart display for small values
    2009-06-19 17:20:06 +0200 iha  r273174 : #i78025# charts own borders are not completely visible
    2009-06-19 17:18:41 +0200 iha  r273172 : #i102950# don't paint additional borders for charts
    2009-06-11 16:27:54 +0200 iha  r272884 : CWS-TOOLING: rebase CWS chart39 to trunk at 272827 (milestone: DEV300:m50)
    2009-06-09 17:50:10 +0200 iha  r272790 : #i97222# when converting a chart via API to 3D categories get lost and for line,area&xy the stacking mode is wrong
    2009-06-09 16:00:27 +0200 iha  r272775 : #i98319# data point properties get lost while copying charts from calc to impress
    2009-06-09 10:26:51 +0200 iha  r272755 : #i98392# correct orienation of gradient fillings on 3D walls
    2009-05-29 10:35:16 +0200 iha  r272436 : #i100529# Plot missing values - leave gap fails for smoothed lines
    2009-05-04 18:20:31 +0200 iha  r271478 : #i99841# Title with Vertically stacked attribute is wrong after editing
    2009-05-04 18:03:01 +0200 iha  r271477 : #i101050# avoid a corner in closed lines, which are smoothed by spline
    2009-05-04 16:45:18 +0200 iha  r271472 : #i101050# avoid crash in case the normals sequence has less points than the polygon

diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx
index 71ff112..9624e81 100644
--- a/sw/source/core/doc/notxtfrm.cxx
+++ b/sw/source/core/doc/notxtfrm.cxx
@@ -799,6 +799,34 @@ void SwNoTxtFrm::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew )
     }
 }
 
+void lcl_correctlyAlignRect( SwRect& rAlignedGrfArea, const SwRect& rInArea, OutputDevice* pOut )
+{
+    if(!pOut)
+        return;
+    Rectangle aPxRect = pOut->LogicToPixel( rInArea.SVRect() );
+    Rectangle aNewPxRect( aPxRect );
+    while( aNewPxRect.Left() < aPxRect.Left() )
+    {
+        rAlignedGrfArea.Left( rAlignedGrfArea.Left()+1 );
+        aNewPxRect = pOut->LogicToPixel( rAlignedGrfArea.SVRect() );
+    }
+    while( aNewPxRect.Top() < aPxRect.Top() )
+    {
+        rAlignedGrfArea.Top( rAlignedGrfArea.Top()+1 );
+        aNewPxRect = pOut->LogicToPixel( rAlignedGrfArea.SVRect() );
+    }
+    while( aNewPxRect.Bottom() > aPxRect.Bottom() )
+    {
+        rAlignedGrfArea.Bottom( rAlignedGrfArea.Bottom()-1 );
+        aNewPxRect = pOut->LogicToPixel( rAlignedGrfArea.SVRect() );
+    }
+    while( aNewPxRect.Right() > aPxRect.Right() )
+    {
+        rAlignedGrfArea.Right( rAlignedGrfArea.Right()-1 );
+        aNewPxRect = pOut->LogicToPixel( rAlignedGrfArea.SVRect() );
+    }
+}
+
 // Ausgabe der Grafik. Hier wird entweder eine QuickDraw-Bmp oder
 // eine Grafik vorausgesetzt. Ist nichts davon vorhanden, wird
 // eine Ersatzdarstellung ausgegeben.
@@ -816,15 +844,30 @@ void SwNoTxtFrm::PaintPicture( OutputDevice* pOut, const SwRect &rGrfArea ) cons
     const BOOL bPrn = pOut == rNoTNd.getIDocumentDeviceAccess()->getPrinter( false ) ||
                           pOut->GetConnectMetaFile();
 
+    const bool bIsChart = pOLENd && ChartPrettyPainter::IsChart( pOLENd->GetOLEObj().GetObject() );
+    
     /// OD 25.09.2002 #99739# - calculate aligned rectangle from parameter <rGrfArea>.
     ///     Use aligned rectangle <aAlignedGrfArea> instead of <rGrfArea> in
     ///     the following code.
     SwRect aAlignedGrfArea = rGrfArea;
     ::SwAlignRect( aAlignedGrfArea,  pShell );
-    /// OD 25.09.2002 #99739#
-    /// Because for drawing a graphic left-top-corner and size coordinations are
-    /// used, these coordinations have to be determined on pixel level.
-    ::SwAlignGrfRect( &aAlignedGrfArea, *pOut );
+
+    if( !bIsChart )
+    {
+        /// OD 25.09.2002 #99739#
+        /// Because for drawing a graphic left-top-corner and size coordinations are
+        /// used, these coordinations have to be determined on pixel level.
+        ::SwAlignGrfRect( &aAlignedGrfArea, *pOut );
+    }
+    else //if( bIsChart )
+    {
+        //#i78025# charts own borders are not completely visible
+        //the above pixel correction is not correct - at least not for charts
+        //so a different pixel correction is choosen here
+        //this might be a good idea for all other OLE objects also,
+        //but as I cannot oversee the consequences I fix it only for charts for now
+        lcl_correctlyAlignRect( aAlignedGrfArea, rGrfArea, pOut );
+     }
 
     if( pGrfNd )
     {
@@ -946,9 +989,8 @@ void SwNoTxtFrm::PaintPicture( OutputDevice* pOut, const SwRect &rGrfArea ) cons
         if( bForceSwap )
             pGrfNd->SwapOut();
     }
-    else if( pOLENd
+    else if( bIsChart
         //charts must be painted resolution dependent!! #i82893#, #i75867#
-        && ChartPrettyPainter::IsChart(pOLENd->GetOLEObj().GetObject())
         && ChartPrettyPainter::ShouldPrettyPaintChartOnThisDevice( pOut )
         && svt::EmbeddedObjectRef::TryRunningState( pOLENd->GetOLEObj().GetOleRef() )
         && ChartPrettyPainter::DoPrettyPaintChart( uno::Reference< frame::XModel >(
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 05686b9..34b9441 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -112,6 +112,9 @@
 #include <EnhancedPDFExportHelper.hxx>
 // <--
 
+#include <ndole.hxx>
+#include <svtools/chartprettypainter.hxx>
+
 #include <PostItMgr.hxx>
 #include <tools/color.hxx>
 #define COL_NOTES_SIDEPANE					RGB_COLORDATA(230,230,230)
@@ -3512,6 +3515,19 @@ void SwFlyFrm::Paint( const SwRect& rRect ) const
     const SwNoTxtFrm *pNoTxt = Lower() && Lower()->IsNoTxtFrm()
                                                 ? (SwNoTxtFrm*)Lower() : 0;
 
+    bool bIsChart = false; //#i102950# don't paint additional borders for charts
+    //check whether we have a chart
+    if(pNoTxt)
+    {
+        const SwNoTxtNode* pNoTNd = dynamic_cast<const SwNoTxtNode*>(pNoTxt->GetNode());
+        if( pNoTNd )
+        {
+            SwOLENode* pOLENd = const_cast<SwOLENode*>(pNoTNd->GetOLENode());
+            if( pOLENd && ChartPrettyPainter::IsChart( pOLENd->GetOLEObj().GetObject() ) )
+                bIsChart = true;
+        }
+    }
+
     {
         bool bContour = GetFmt()->GetSurround().IsContour();
         PolyPolygon aPoly;
@@ -3641,7 +3657,8 @@ void SwFlyFrm::Paint( const SwRect& rRect ) const
     // OD 19.12.2002 #106318# - fly frame will paint it's subsidiary lines and
     // the subsidiary lines of its lowers on its own, due to overlapping with
     // other fly frames or other objects.
-    if( pGlobalShell->GetWin() )
+    if( pGlobalShell->GetWin()
+        && !bIsChart ) //#i102950# don't paint additional borders for charts
     {
         bool bSubsLineRectsCreated;
         if ( pSubsLines )
commit 5d7df94e4ed54c72f34c72debab543005af7dc6f
Author: Jens-Heiner Rechtien <hr at openoffice.org>
Date:   Mon Jul 27 17:18:56 2009 +0000

    CWS-TOOLING: integrate CWS cmcfixes60
    2009-07-03 21:56:04 +0200 cmc  r273718 : #i103313# org.openoffice.System not org.openoffice.Setup for looking up default locale
    2009-07-01 17:15:31 +0200 cmc  r273606 : #i102636# extra rounding precision
    2009-07-01 11:04:47 +0200 cmc  r273556 : #i100000# workaround build issue
    2009-06-30 17:27:41 +0200 cmc  r273525 : #i102636# extra rounding precision
    2009-06-30 09:42:46 +0200 cmc  r273491 : #i102634# numbers got mixed up somehow
    2009-06-30 09:19:56 +0200 cmc  r273490 : CWS-TOOLING: rebase CWS cmcfixes60 to trunk at 273468 (milestone: DEV300:m51)
    2009-06-22 12:54:45 +0200 cmc  r273217 : #i103000# micro-optimization to remove unused symbols from fpicker etc.
    2009-06-19 10:06:21 +0200 cmc  r273148 : #i102932# put same type into an Any as we take out of that Any, affect 64bit
    2009-06-13 17:38:42 +0200 cmc  r272957 : #i102742# gcc44 warnings, return of const primitive type doesn't mean anything
    2009-06-13 16:22:40 +0200 cmc  r272955 : #i102737# keep existing logic and silence new gcc44 warnings
    2009-06-13 16:06:25 +0200 cmc  r272954 : #i102736# confirm existing logic to be gcc44 warnings free
    2009-06-10 19:40:24 +0200 cmc  r272837 : #i87461# 64bit color lossage
    2009-06-10 19:23:38 +0200 cmc  r272836 : #i102636# tidy up UI rounding errors

diff --git a/sw/inc/authratr.hxx b/sw/inc/authratr.hxx
index 150fc33..7fd320e 100644
--- a/sw/inc/authratr.hxx
+++ b/sw/inc/authratr.hxx
@@ -42,7 +42,7 @@ class SW_DLLPUBLIC AuthorCharAttr
 public:
     USHORT	nItemId;
     USHORT	nAttr;
-    ULONG	nColor;
+    ColorData nColor;
 
     AuthorCharAttr();
 
diff --git a/sw/source/core/doc/docdde.cxx b/sw/source/core/doc/docdde.cxx
index f81fd19..02edef6 100644
--- a/sw/source/core/doc/docdde.cxx
+++ b/sw/source/core/doc/docdde.cxx
@@ -62,7 +62,7 @@ using namespace ::com::sun::star;
 namespace
 {
 
-    static ::sw::mark::DdeBookmark* const lcl_FindDdeBookmark(const IDocumentMarkAccess& rMarkAccess, const String& rName)
+    static ::sw::mark::DdeBookmark* lcl_FindDdeBookmark(const IDocumentMarkAccess& rMarkAccess, const String& rName)
     {
         //Iterating over all bookmarks, checking DdeBookmarks
         const String sNameLc = GetAppCharClass().lower(rName);
diff --git a/sw/source/ui/app/swmodul1.cxx b/sw/source/ui/app/swmodul1.cxx
index d7c7473..50e2870 100644
--- a/sw/source/ui/app/swmodul1.cxx
+++ b/sw/source/ui/app/swmodul1.cxx
@@ -437,7 +437,7 @@ sal_uInt16 SwModule::InsertRedlineAuthor(const String& rAuthor)
 void lcl_FillAuthorAttr( sal_uInt16 nAuthor, SfxItemSet &rSet,
                         const AuthorCharAttr &rAttr )
 {
-    Color aCol( (ColorData)rAttr.nColor );
+    Color aCol( rAttr.nColor );
 
     if( COL_TRANSPARENT == rAttr.nColor )
     {
diff --git a/sw/source/ui/config/optpage.cxx b/sw/source/ui/config/optpage.cxx
index c364347..4835aaa 100644
--- a/sw/source/ui/config/optpage.cxx
+++ b/sw/source/ui/config/optpage.cxx
@@ -1945,7 +1945,7 @@ BOOL SwRedlineOptionsTabPage::FillItemSet( SfxItemSet& )
     AuthorCharAttr aOldDeletedAttr(pOpt->GetDeletedAuthorAttr());
     AuthorCharAttr aOldChangedAttr(pOpt->GetFormatAuthorAttr());
 
-    ULONG nOldMarkColor = pOpt->GetMarkAlignColor().GetColor();
+    ColorData nOldMarkColor = pOpt->GetMarkAlignColor().GetColor();
     USHORT nOldMarkMode = pOpt->GetMarkAlignMode();
 
     USHORT nPos = aInsertLB.GetSelectEntryPos();
@@ -2105,7 +2105,7 @@ void SwRedlineOptionsTabPage::Reset( const SfxItemSet&  )
     aChangedColorLB.SetUpdateMode( TRUE );
     aMarkColorLB.SetUpdateMode( TRUE );
 
-    ULONG nColor = rInsertAttr.nColor;
+    ColorData nColor = rInsertAttr.nColor;
 
     switch (nColor)
     {
diff --git a/sw/source/ui/envelp/mailmrge.cxx b/sw/source/ui/envelp/mailmrge.cxx
index 56ddbf3..c5f6385 100644
--- a/sw/source/ui/envelp/mailmrge.cxx
+++ b/sw/source/ui/envelp/mailmrge.cxx
@@ -76,6 +76,8 @@
 
 #include <unomid.h>
 
+#include <algorithm>
+
 using namespace rtl;
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::container;
@@ -387,6 +389,8 @@ SwMailMergeDlg::SwMailMergeDlg(Window* pParent, SwWrtShell& rShell,
     aLk = LINK(this, SwMailMergeDlg, ModifyHdl);
     aFromNF.SetModifyHdl(aLk);
     aToNF.SetModifyHdl(aLk);
+    aFromNF.SetMax(SAL_MAX_INT32);
+    aToNF.SetMax(SAL_MAX_INT32);
 
     SwNewDBMgr* pNewDBMgr = rSh.GetNewDBMgr();
     if(_xConnection.is())
@@ -768,19 +772,16 @@ bool SwMailMergeDlg::ExecQryShell()
 
     if (aFromRB.IsChecked())	// Liste Einfuegen
     {
-        ULONG nStart = static_cast< ULONG >(aFromNF.GetValue());
-        ULONG nEnd   = static_cast< ULONG >(aToNF.GetValue());
+        // Safe: the maximal value of the fields is limited
+        sal_Int32 nStart = sal::static_int_cast<sal_Int32>(aFromNF.GetValue());
+        sal_Int32 nEnd = sal::static_int_cast<sal_Int32>(aToNF.GetValue());
 
         if (nEnd < nStart)
-        {
-            ULONG nZw = nEnd;
-            nEnd = nStart;
-            nStart = nZw;
-        }
+            std::swap(nEnd, nStart);
 
         m_aSelection.realloc(nEnd - nStart + 1);
         Any* pSelection = m_aSelection.getArray();
-        for (ULONG i = nStart; i <= nEnd; ++i, ++pSelection)
+        for (sal_Int32 i = nStart; i != nEnd; ++i, ++pSelection)
             *pSelection <<= i;
     }
     else if (aAllRB.IsChecked() )
commit 2f541350069e9dd57afadfde5cd35e542f10efe7
Author: Jens-Heiner Rechtien <hr at openoffice.org>
Date:   Mon Jul 27 16:24:52 2009 +0000

    CWS-TOOLING: integrate CWS aw073
    2009-07-16 11:21:19 +0200 aw  r274036 : corrections after resync
    2009-07-15 13:34:18 +0200 aw  r274009 : CWS-TOOLING: rebase CWS aw073 to trunk at 273858 (milestone: DEV300:m52)
    2009-07-01 20:04:27 +0200 aw  r273613 : CWS-TOOLING: rebase CWS aw073 to trunk at 273468 (milestone: DEV300:m51)
    2009-06-24 11:51:03 +0200 aw  r273324 : #i102062# added using statement for solaris compiler
    2009-06-23 12:53:50 +0200 aw  r273278 : #i100158# force filled polygons to closed state
    2009-06-23 12:28:33 +0200 aw  r273276 : #i100158#, #i102371# corrected all (mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW) shortcuts to support line/fill and to be not used when FillMode is not overpaint
    2009-06-23 12:15:14 +0200 aw  r273274 : #i100158# added PolyPolygon support for snapPointsOfHorizontalOrVerticalEdges helper
    2009-06-22 17:28:33 +0200 aw  r273244 : #i101508# added taking care of cell's distance-to-border values for cell text primitive creation
    2009-06-22 12:59:10 +0200 aw  r273218 : #i102253# applied patch from OD (see task)
    2009-06-18 17:00:52 +0200 aw  r273125 : #i102251# added EE_CNTRL_ONLINESPELLING switch off at DrawOutliner during GraphicExporter::GetGraphic
    2009-06-18 14:35:57 +0200 aw  r273120 : #i102241# added mergeToSinglePolyPolygon usage to SdrObject::ImpConvertToContourObj
    2009-06-18 14:35:20 +0200 aw  r273119 : #i102241# improved PolygonStrokePrimitive2D::createLocalDecomposition
    2009-06-18 14:34:49 +0200 aw  r273118 : #i102241# Made B2DCubicBezier::testAndSolveTrivialBezier() numerically more stable
    2009-06-17 16:11:21 +0200 aw  r273078 : #i102062# added compare support for OutlireParaObject's WrongList in an extra method; using in primitive comparators
    2009-06-16 19:10:18 +0200 aw  r273037 : #i101957# corrected: offset needs to be added before rotation and shear
    2009-06-16 18:58:43 +0200 aw  r273035 : #i101957# added needed offset by object width to SdrTextObj::impDecomposeStretchTextPrimitive for vertical texts
    2009-06-16 18:35:55 +0200 aw  r273034 : #i101941# corrected object initialisation for 3D Scenes on Clone operator
    2009-06-16 16:07:30 +0200 aw  r273024 : #i101811# extended renderChartPrimitive2D to create a correct embedding in a new MapMode
    2009-06-12 19:38:07 +0200 aw  r272940 : #i101734# added test code to experiment on demand with more complex transformations for virtual objects than only translations
    2009-06-12 19:37:07 +0200 aw  r272939 : #i101734# corrected SvtGraphicStroke preparation in MetaFile renderer (AFAP)
    2009-06-12 16:31:55 +0200 aw  r272931 : #i101648# re-enabled object creation with objecttype OBJ_NONE for SW Frame creation
    2009-06-12 13:59:05 +0200 aw  r272917 : #i101598# supported AAed single line paint in VCL
    2009-06-12 11:34:25 +0200 aw  r272907 : #i101598# adapted Graphic::GetBitmap() usage
    2009-06-10 16:34:19 +0200 aw  r272830 : #i101598# added VCL_DLLPUBLIC to parameter class
    2009-06-10 16:30:27 +0200 aw  r272829 : #i101598# extended calls to Graphic::GetBitmap/Ex where conversions to Bitmap objects is needed to user defined parameters like AntiAlisasing
    2009-06-10 16:28:44 +0200 aw  r272828 : #i101598# extended Graphic::GetBitmap/Ex interfaces to transport raster conversion parameters since these calls potentially need to rasterconvert a contained MetaFile
    2009-06-09 16:26:40 +0200 aw  r272781 : #i100945# checked in proposed patch for now
    2009-06-08 18:01:42 +0200 aw  r272742 : #i101239# teached BinTextObject to register at EditEngineItemPool sub-pool, not on given pool directly

diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index 4b3e5f4..6712f04 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -2321,6 +2321,15 @@ namespace sdr
 
         drawinglayer::primitive2d::Primitive2DSequence VOCOfDrawVirtObj::createPrimitive2DSequence(const DisplayInfo& rDisplayInfo) const
         {
+#ifdef DBG_UTIL
+            // #i101734#
+            static bool bCheckOtherThanTranslate(false);
+            static double fShearX(0.0);
+            static double fRotation(0.0);
+            static double fScaleX(0.0);
+            static double fScaleY(0.0);
+#endif
+
             const VCOfDrawVirtObj& rVC = static_cast< const VCOfDrawVirtObj& >(GetViewContact());
             const SdrObject& rReferencedObject = rVC.GetSwDrawVirtObj().GetReferencedObj();
             drawinglayer::primitive2d::Primitive2DSequence xRetval;
@@ -2331,8 +2340,20 @@ namespace sdr
 
             if(aLocalOffset.X() || aLocalOffset.Y())
             {
+#ifdef DBG_UTIL
+                // #i101734# added debug code to check more complex transformations
+                // than just a translation
+                if(bCheckOtherThanTranslate)
+                {
+                    aOffsetMatrix.scale(fScaleX, fScaleY);
+                    aOffsetMatrix.shearX(tan(fShearX * F_PI180));
+                    aOffsetMatrix.rotate(fRotation * F_PI180);
+                }
+#endif
+
                 aOffsetMatrix.set(0, 2, aLocalOffset.X());
                 aOffsetMatrix.set(1, 2, aLocalOffset.Y());
+
             }
 
             if(rReferencedObject.ISA(SdrObjGroup))
diff --git a/sw/source/ui/shells/basesh.cxx b/sw/source/ui/shells/basesh.cxx
index cb69690..168441d 100644
--- a/sw/source/ui/shells/basesh.cxx
+++ b/sw/source/ui/shells/basesh.cxx
@@ -1751,9 +1751,12 @@ void SwBaseShell::GetState( SfxItemSet &rSet )
                                         rSh.GetGraphic(FALSE);  // start the loading
                                 }
                                 else if( rSh.IsFrmSelected() )
-                                    bDisable = GRAPHIC_NONE ==
-                                            rSh.GetIMapGraphic().GetType()||
-                                            nSel & nsSelectionType::SEL_FRM;
+                                {
+                                    // #i102253# applied patch from OD (see task)
+                                    bDisable =
+                                        nSel & nsSelectionType::SEL_FRM ||
+                                        GRAPHIC_NONE == rSh.GetIMapGraphic().GetType();
+                                }
                             }
                             bSet = bDisable ? FALSE : rWrap.IsContour();
 


More information about the ooo-build-commit mailing list