Anonymous avatar Anonymous committed c39e66e

cws swcoreseparation: #i117814#: don't create TmpDocShell in core

Comments (0)

Files changed (2)

sw/source/core/ole/ndole.cxx

 #include <com/sun/star/util/XModifiable.hpp>
 #include <com/sun/star/document/XEventBroadcaster.hpp>
 #include <cppuhelper/implbase1.hxx>
-
 #include <cppuhelper/implbase2.hxx>
 #include <toolkit/helper/vclunohelper.hxx>
 #include <hintids.hxx>
 #include <sfx2/app.hxx>
 #include <sfx2/linkmgr.hxx>
 #include <unotools/configitem.hxx>
-#ifndef _OUTDEV_HXX //autogen
 #include <vcl/outdev.hxx>
-#endif
 #include <fmtanchr.hxx>
 #include <frmfmt.hxx>
 #include <doc.hxx>
-#include <docsh.hxx>
 #include <pam.hxx>
 #include <section.hxx>
 #include <cntfrm.hxx>
 #include <frmatr.hxx>
-#ifndef _DOCSH_HXX
-#include <docsh.hxx>
-#endif
 #include <ndole.hxx>
-
+#include <sfx2/objsh.hxx>
 #include <comphelper/classids.hxx>
 #include <vcl/graph.hxx>
 #include <sot/formats.hxx>
 #include <unotools/ucbstreamhelper.hxx>
 #include <svtools/filter.hxx>
-#ifndef _COMCORE_HRC
 #include <comcore.hrc>
-#endif
 
 using rtl::OUString;
 using namespace utl;
         SfxObjectShell* p = GetDoc()->GetPersist();
         if( !p )
         {
-            // TODO/LATER: reicht hier nicht ein EmbeddedObjectContainer? Was passiert mit
-            // diesem Dokument?
-			ASSERT( !this, "warum wird hier eine DocShell angelegt?" );
-            p = new SwDocShell( GetDoc(), SFX_CREATE_MODE_INTERNAL );
-            p->DoInitNew( NULL );
+			p = GetDoc()->GetTmpDocShell();
+			DBG_ASSERT( p, "No Persist object!" );
+			if (!p)
+				return sal_False;
         }
 
         uno::Reference < container::XChild > xChild( aOLEObj.xOLERef.GetObject(), uno::UNO_QUERY );
 
 SwCntntNode* SwOLENode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const
 {
-	// Falls bereits eine SvPersist-Instanz existiert, nehmen wir diese
     SfxObjectShell* pPersistShell = pDoc->GetPersist();
 	if( !pPersistShell )
 	{
-        // TODO/LATER: is EmbeddedObjectContainer not enough?
-        // the created document will be closed by pDoc ( should use SfxObjectShellLock )
-		pPersistShell = new SwDocShell( pDoc, SFX_CREATE_MODE_INTERNAL );
-		pDoc->SetTmpDocShell( pPersistShell );
-		pPersistShell->DoInitNew( NULL );
+		pPersistShell = pDoc->GetTmpDocShell();
+		DBG_ASSERT( pPersistShell, "No Persist object!" );
+		if (!pPersistShell)
+			return 0;
 	}
 
-	// Wir hauen das Ding auf SvPersist-Ebene rein
     // TODO/LATER: check if using the same naming scheme for all apps works here
     ::rtl::OUString aNewName/*( Sw3Io::UniqueName( p->GetStorage(), "Obj" ) )*/;
     SfxObjectShell* pSrc = GetDoc()->GetPersist();
         SfxObjectShell* p = pDoc->GetPersist();
         if( !p )
         {
-            // TODO/LATER: reicht hier nicht ein EmbeddedObjectContainer? Was passiert mit
-            // diesem Dokument?
-			ASSERT( !this, "warum wird hier eine DocShell angelegt?" );
-            p = new SwDocShell( pDoc, SFX_CREATE_MODE_INTERNAL );
-            p->DoInitNew( NULL );
+			p = pDoc->GetTmpDocShell();
+			DBG_ASSERT( p, "No Persist object!" );
+			if (!p)
+				return;
         }
 
         ::rtl::OUString aObjName;

sw/source/ui/dochdl/swdtflvr.cxx

 #include <swundo.hxx>		// fuer Undo-Ids
 #include <pam.hxx>
 #include <ndole.hxx>
+
 #include <viewopt.hxx>
 #include <swunodef.hxx>
 #include <vcl/sound.hxx>
 
 		pClpDocFac = new SwDocFac;
         SwDoc *const pTmpDoc = lcl_GetDoc(*pClpDocFac);
+        aDocShellRef = new SwDocShell( pTmpDoc, SFX_CREATE_MODE_INTERNAL );
+        aDocShellRef->DoInitNew(0);
+		pTmpDoc->SetTmpDocShell( aDocShellRef );
 
 		pTmpDoc->LockExpFlds(); 	// nie die Felder updaten - Text so belassen
 		pWrtShell->Copy( pTmpDoc );
-
-		// es wurde in der CORE eine neu angelegt (OLE-Objekte kopiert!)
-        aDocShellRef = pTmpDoc->GetTmpDocShell();
-		if( aDocShellRef.Is() )
+		if( aDocShellRef->HasEmbeddedObjects() )
 			SwTransferable::InitOle( aDocShellRef, *pTmpDoc );
+		else
+			aDocShellRef = 0;
 		pTmpDoc->SetTmpDocShell( (SfxObjectShell*)NULL );
 
 		if( nSelectionType & nsSelectionType::SEL_TXT && !pWrtShell->HasMark() )
 			pWrtShell->CreateCrsr();
 
         SwDoc *const pTmpDoc = lcl_GetDoc(*pClpDocFac);
+        aDocShellRef = new SwDocShell( pTmpDoc, SFX_CREATE_MODE_INTERNAL );
+        aDocShellRef->DoInitNew(0);
+		pTmpDoc->SetTmpDocShell( aDocShellRef );
 
 		pTmpDoc->LockExpFlds(); 	// nie die Felder updaten - Text so belassen
 		pWrtShell->Copy( pTmpDoc );
                 pMarkAccess->deleteMark(*ppMark);
         }
 
-		// es wurde in der CORE eine neu angelegt (OLE-Objekte kopiert!)
-        aDocShellRef = pTmpDoc->GetTmpDocShell();
-		if( aDocShellRef.Is() )
+		if( aDocShellRef->HasEmbeddedObjects() )
 			SwTransferable::InitOle( aDocShellRef, *pTmpDoc );
+		else
+			aDocShellRef = 0;
 		pTmpDoc->SetTmpDocShell( (SfxObjectShell*)NULL );
 
 		if( pWrtShell->IsObjSelected() )
 
 	pClpDocFac = new SwDocFac;
     SwDoc *const pCDoc = lcl_GetDoc(*pClpDocFac);
+	aDocShellRef = new SwDocShell( pCDoc, SFX_CREATE_MODE_INTERNAL );
+	aDocShellRef->DoInitNew(0);
+	pCDoc->SetTmpDocShell( aDocShellRef );
 
 	SwNodes& rNds = pCDoc->GetNodes();
 	SwNodeIndex aNodeIdx( *rNds.GetEndOfContent().StartOfSectionNode() );
 
 	pCDoc->InsertGlossary( rGlossary, rStr, aPam, 0 );
 
-	// es wurde in der CORE eine neu angelegt (OLE-Objekte kopiert!)
-    aDocShellRef = pCDoc->GetTmpDocShell();
-	if( aDocShellRef.Is() )
+	if( aDocShellRef->HasEmbeddedObjects() )
 		SwTransferable::InitOle( aDocShellRef, *pCDoc );
+	else
+		aDocShellRef = 0;
     pCDoc->SetTmpDocShell( (SfxObjectShell*)NULL );
 
 	eBufferType = TRNSFR_DOCUMENT;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.