Commits

Anonymous committed c2cc6b9

cws swcoreseparation: #i117814#: split code for copying a document into SwDoc and SwDocShell part where the latter includes the former

  • Participants
  • Parent commits 6b24005

Comments (0)

Files changed (6)

      SwFmt *_MakeTxtFmtColl(const String &, SwFmt *, sal_Bool, sal_Bool );
 
      void InitTOXTypes();
-     void   Paste( const SwDoc& );
      bool DeleteAndJoinImpl(SwPaM&, const bool);
      bool DeleteAndJoinWithRedlineImpl(SwPaM&, const bool unused = false);
      bool DeleteRangeImpl(SwPaM&, const bool unused = false);
     ::sw::MetaFieldManager & GetMetaFieldManager();
     ::sw::UndoManager      & GetUndoManager();
     ::sw::UndoManager const& GetUndoManager() const;
-    SfxObjectShell* CreateCopy(bool bCallInitNew) const;
+    SwDoc* CreateCopy() const;
+    void   Paste( const SwDoc& );
 };
 
 
     virtual void    SetChangeRecording( bool bActivate );
     virtual bool    SetProtectionPassword( const String &rPassword );
     virtual bool    GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal_Int8 > &rPasswordHash );
+    SfxObjectShell* CreateCopy(bool bCallInitNew) const;
 };
 
 class Graphic;

sw/source/core/doc/docnew.cxx

 /*-- 08.05.2009 10:07:57---------------------------------------------------
 
   -----------------------------------------------------------------------*/
-SfxObjectShell* SwDoc::CreateCopy(bool bCallInitNew ) const
+SwDoc* SwDoc::CreateCopy() const
 {
     SwDoc* pRet = new SwDoc;
     //copy settings
     // COMPATIBILITY FLAGS END
     //
     pRet->ReplaceStyles( * const_cast< SwDoc*>( this ));
+    return pRet;
+}
 
-    // we have to use pointer here, since the callee has to decide whether SfxObjectShellLock or SfxObjectShellRef should be used
-    // sometimes the object will be returned with refcount set to 0 ( if no DoInitNew is done )
-    SfxObjectShell* pRetShell = new SwDocShell( pRet, SFX_CREATE_MODE_STANDARD );
-    if( bCallInitNew )
-    {
-        // it could happen that DoInitNew creates model, that increases the refcount of the object
-        pRetShell->DoInitNew();
-    }
-
-    //copy content 
-    pRet->Paste( *this );
-
-    // remove the temporary shell if it is there as it was done before
-    pRet->SetTmpDocShell( (SfxObjectShell*)NULL );
-
-    return pRetShell;
-}
-/*-- 08.05.2009 10:52:40---------------------------------------------------
+/*-------------------------------------------------------------------------
     copy document content - code from SwFEShell::Paste( SwDoc* , sal_Bool  )
   -----------------------------------------------------------------------*/
 void SwDoc::Paste( const SwDoc& rSource )

sw/source/ui/app/docshini.cxx

 	pDoc->ResetModified();
 }
 
+SfxObjectShell* SwDocShell::CreateCopy(bool bCallInitNew ) const
+{
+    SwDoc* pRet = GetDoc()->CreateCopy();
+
+    // we have to use pointer here, since the callee has to decide whether SfxObjectShellLock or SfxObjectShellRef should be used
+    // sometimes the object will be returned with refcount set to 0 ( if no DoInitNew is done )
+    SwDocShell* pRetShell = new SwDocShell( pRet, SFX_CREATE_MODE_STANDARD );
+    if( bCallInitNew )
+        pRetShell->DoInitNew();
+	else
+		pRetShell->AddLink();
+
+    //copy content 
+    pRet->Paste( *GetDoc() );
+
+    // remove the temporary shell if it is there as it was done before
+    pRet->SetTmpDocShell( (SfxObjectShell*)NULL );
+    return pRetShell;
+}
+
 /*
  * Document Interface Access
  */

sw/source/ui/dbui/dbmgr.cxx

             }
             else
             {
-                xWorkDocSh = rSourceView.GetDocShell()->GetDoc()->CreateCopy(true);
+                xWorkDocSh = rSourceView.GetDocShell()->CreateCopy(true);
             }
             //create a ViewFrame
             SwView* pWorkView = static_cast< SwView* >( SfxViewFrame::LoadHiddenDocument( *xWorkDocSh, 0 )->GetViewShell() );

sw/source/ui/uno/unotxdoc.cxx

     // SfxObjectShellRef is used here, since the model should control object lifetime after creation
     // and thus SfxObjectShellLock is not allowed here
     // the model holds reference to the shell, so the shell will not destructed at the end of method
-    SfxObjectShellRef pShell = pDocShell->GetDoc()->CreateCopy(false);
+    SfxObjectShellRef pShell = pDocShell->CreateCopy(false);
     uno::Reference< frame::XModel > xNewModel = pShell->GetModel();
     uno::Reference< embed::XStorage > xNewStorage = ::comphelper::OStorageHelper::GetTemporaryStorage( );
     uno::Sequence< beans::PropertyValue > aTempMediaDescriptor;