Tag: cws_src680_dba202c
User: fs      
Date: 05/12/01 03:16:47

Modified:
 /dba/dbaccess/source/core/dataaccess/
  documentdefinition.cxx

Log:
 #i57669# reset the logical form's data source property when inserting from 
existing external document

File Changes:

Directory: /dba/dbaccess/source/core/dataaccess/
================================================

File [changed]: documentdefinition.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/documentdefinition.cxx?r1=1.32&r2=1.32.12.1
Delta lines:  +76 -3
--------------------
--- documentdefinition.cxx      3 Nov 2005 12:35:42 -0000       1.32
+++ documentdefinition.cxx      1 Dec 2005 11:16:44 -0000       1.32.12.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: documentdefinition.cxx,v $
  *
- *  $Revision: 1.32 $
+ *  $Revision: 1.32.12.1 $
  *
- *  last change: $Author: kz $ $Date: 2005/11/03 12:35:42 $
+ *  last change: $Author: fs $ $Date: 2005/12/01 11:16:44 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -45,6 +45,9 @@
 #ifndef _TOOLS_DEBUG_HXX
 #include <tools/debug.hxx>
 #endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
 #ifndef _COMPHELPER_PROPERTY_HXX_
 #include <comphelper/property.hxx>
 #endif
@@ -165,6 +168,18 @@
 #ifndef _COM_SUN_STAR_DOCUMENT_MACROEXECMODE_HPP_
 #include <com/sun/star/document/MacroExecMode.hpp>
 #endif
+#ifndef _COM_SUN_STAR_DRAWING_XDRAWPAGESUPPLIER_HPP_
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XINDEXCONTAINER_HPP_
+#include <com/sun/star/container/XIndexContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XFORMSSUPPLIER_HPP_
+#include <com/sun/star/form/XFormsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XFORM_HPP_
+#include <com/sun/star/form/XForm.hpp>
+#endif
 #ifndef _COMPHELPER_INTERACTION_HXX_
 #include <comphelper/interaction.hxx>
 #endif
@@ -227,6 +242,8 @@
 using namespace ::com::sun::star::container;
 using namespace ::com::sun::star::datatransfer;
 using namespace ::com::sun::star::task;
+using namespace ::com::sun::star::form;
+using namespace ::com::sun::star::drawing;
 using namespace ::osl;
 using namespace ::comphelper;
 using namespace ::cppu;
@@ -978,6 +995,58 @@
        return aRet;
 }
 // 
-----------------------------------------------------------------------------
+namespace
+{
+    void lcl_resetChildFormsToEmptyDataSource( const Reference< XIndexAccess>& 
_rxFormsContainer )
+    {
+        OSL_PRECOND( _rxFormsContainer.is(), 
"lcl_resetChildFormsToEmptyDataSource: illegal call!" );
+        sal_Int32 count = _rxFormsContainer->getCount();
+        for ( sal_Int32 i = 0; i < count; ++i )
+        {
+            Reference< XForm > xForm( _rxFormsContainer->getByIndex( i ), 
UNO_QUERY );
+            if ( !xForm.is() )
+                continue;
+
+            // if the element is a form, reset its DataSourceName property to 
an empty string
+            try
+            {
+                Reference< XPropertySet > xFormProps( xForm, UNO_QUERY_THROW );
+                xFormProps->setPropertyValue( PROPERTY_DATASOURCENAME, 
makeAny( ::rtl::OUString() ) );
+            }
+            catch( const Exception& )
+            {
+                DBG_UNHANDLED_EXCEPTION();
+            }
+
+            // if the element is a container itself, step down the component 
hierarchy
+            Reference< XIndexAccess > xContainer( xForm, UNO_QUERY );
+            if ( xContainer.is() )
+                lcl_resetChildFormsToEmptyDataSource( xContainer );
+        }
+    }
+
+    void lcl_resetFormsToEmptyDataSource( const Reference< XEmbeddedObject>& 
_rxEmbeddedObject )
+    {
+        try
+        {
+                       Reference< XComponentSupplier > xCompProv( 
_rxEmbeddedObject, UNO_QUERY_THROW );
+            Reference< XDrawPageSupplier > xSuppPage( 
xCompProv->getComponent(), UNO_QUERY_THROW );
+                // if this interface does not exist, then either getComponent 
returned NULL,
+                // or the document is a multi-page document. The latter is 
allowed, but currently
+                // simply not handled by this code, as it would not normally 
happen.
+
+            Reference< XFormsSupplier > xSuppForms( xSuppPage->getDrawPage(), 
UNO_QUERY_THROW );
+            Reference< XIndexAccess > xForms( xSuppForms->getForms(), 
UNO_QUERY_THROW );
+            lcl_resetChildFormsToEmptyDataSource( xForms );
+        }
+        catch( const Exception& )
+        {
+            DBG_UNHANDLED_EXCEPTION();
+        }
+
+    }
+}
+// 
-----------------------------------------------------------------------------
 void ODocumentDefinition::insert(const ::rtl::OUString& _sURL, const 
Reference< XCommandEnvironment >& Environment)
     throw( Exception )
 {
@@ -1015,6 +1084,10 @@
                                                                                
                                                                                
,m_pImpl->m_aProps.sPersistentName
                                                                                
                                                                                
,aMediaDesc
                                                                                
                                                                                
,aEmpty),UNO_QUERY);
+
+                lcl_resetFormsToEmptyDataSource( m_xEmbeddedObject );
+                // #i57669# / 2005-12-01 / [EMAIL PROTECTED]
+
                                Reference<XEmbedPersist> 
xPersist(m_xEmbeddedObject,UNO_QUERY);
                                if ( xPersist.is() )
                                {




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to