Tag: cws_ooh680_dba241d
User: fs      
Date: 2008-05-05 10:18:21+0000
Modified:
   dba/dbaccess/source/core/dataaccess/documentdefinition.cxx

Log:
 #i88977# do not reset MacroExecution to NEVER if the document was already 
loaded

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.50.18.4&r2=1.50.18.4.10.1
Delta lines:  +71 -45
---------------------
--- documentdefinition.cxx      2008-03-12 08:38:33+0000        1.50.18.4
+++ documentdefinition.cxx      2008-05-05 10:18:17+0000        1.50.18.4.10.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: documentdefinition.cxx,v $
  *
- *  $Revision: 1.50.18.4 $
+ *  $Revision: 1.50.18.4.10.1 $
  *
- *  last change: $Author: obo $ $Date: 2008/03/12 08:38:33 $
+ *  last change: $Author: fs $ $Date: 2008/05/05 10:18:17 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -283,6 +283,10 @@
 //........................................................................
 namespace dbaccess
 {
+//........................................................................
+
+    typedef ::boost::optional< bool > optional_bool;
+
        //==================================================================
        // OEmbedObjectHolder
        //==================================================================
@@ -1425,10 +1429,12 @@
 namespace
 {
     // 
.........................................................................
-    void    lcl_putLoadArgs( ::comphelper::NamedValueCollection& _io_rArgs, 
const bool _bSuppressMacros, const bool _bReadOnly,
+    void    lcl_putLoadArgs( ::comphelper::NamedValueCollection& _io_rArgs, 
const optional_bool _bSuppressMacros, const optional_bool _bReadOnly,
         const ::rtl::OUString& _rDocTitle )
     {
-        if ( _bSuppressMacros )
+        if ( !!_bSuppressMacros )
+        {
+            if ( *_bSuppressMacros )
         {
             // if we're to suppress macros, do exactly this
             _io_rArgs.put( "MacroExecutionMode", MacroExecMode::NEVER_EXECUTE 
);
@@ -1441,8 +1447,10 @@
                 _io_rArgs.put( "MacroExecutionMode", MacroExecMode::USE_CONFIG 
);
             }
         }
+        }
 
-        _io_rArgs.put( "ReadOnly", _bReadOnly );
+        if ( !!_bReadOnly )
+            _io_rArgs.put( "ReadOnly", *_bReadOnly );
 
         if ( _rDocTitle.getLength() )
            {
@@ -1467,7 +1475,7 @@
         aMediaDesc.put( "ComponentData", aDocumentContext );
        }
 
-    lcl_putLoadArgs( aMediaDesc, _bSuppressMacros, _bReadOnly, 
m_pImpl->m_aProps.aTitle );
+    lcl_putLoadArgs( aMediaDesc, optional_bool( _bSuppressMacros ), 
optional_bool( _bReadOnly ), m_pImpl->m_aProps.aTitle );
 
        if ( m_pInterceptor )
        {
@@ -1599,7 +1607,10 @@
                }
                }
        }
-       else if ( m_xEmbeddedObject->getCurrentState() == EmbedStates::LOADED )
+       else
+    {
+        sal_Int32 nCurrentState = m_xEmbeddedObject->getCurrentState();
+        if ( nCurrentState == EmbedStates::LOADED )
        {
                if ( !m_pClientHelper )
         {
@@ -1619,11 +1630,37 @@
                        xCommon->reload( aLoadArgs, aEmbeddedObjectDescriptor );
                m_xEmbeddedObject->changeState(EmbedStates::RUNNING);
        }
+        else
+        {
+            OSL_ENSURE( ( nCurrentState == EmbedStates::RUNNING ) || ( 
nCurrentState == EmbedStates::ACTIVE ),
+                "ODocumentDefinition::loadEmbeddedObject: unexpected state!" );
+
+            // if the document was already loaded (which means the embedded 
object is in state RUNNING or ACTIVE),
+            // then just re-set some model parameters
+            try
+            {
+                Reference< XModel > xModel( getComponent(), UNO_QUERY_THROW );
+                   Sequence< PropertyValue > aArgs = xModel->getArgs();
+
+                ::comphelper::NamedValueCollection aMediaDesc( aArgs );
+                lcl_putLoadArgs( aMediaDesc, optional_bool(), optional_bool(), 
m_pImpl->m_aProps.aTitle );
+                    // don't put _bSuppressMacros and _bReadOnly here - if the 
document was already
+                    // loaded, we should not tamper with its settings.
+                    // #i88977# / 2008-05-05 / [EMAIL PROTECTED]
+
+                       aMediaDesc >>= aArgs;
+                       xModel->attachResource( xModel->getURL(), aArgs );
+            }
+            catch( const Exception& )
+            {
+               DBG_UNHANDLED_EXCEPTION();
+            }
+        }
+    }
 
-    Reference<XModel> xModel(getComponent(),UNO_QUERY);
        // set the OfficeDatabaseDocument instance as parent of the embedded 
document
     // #i40358# / 2005-01-19 / [EMAIL PROTECTED]
-    Reference< XChild > xDepdendDocAsChild( xModel, UNO_QUERY );
+    Reference< XChild > xDepdendDocAsChild( getComponent(), UNO_QUERY );
     if ( xDepdendDocAsChild.is() )
     {
         try
@@ -1638,17 +1675,6 @@
             DBG_UNHANDLED_EXCEPTION();
         }
     }
-
-    if ( xModel.is() )
-       {
-               Sequence<PropertyValue> aArgs = xModel->getArgs();
-
-        ::comphelper::NamedValueCollection aMediaDesc( aArgs );
-        lcl_putLoadArgs( aMediaDesc, _bSuppressMacros, _bReadOnly, 
m_pImpl->m_aProps.aTitle );
-
-               aMediaDesc >>= aArgs;
-               xModel->attachResource( xModel->getURL(), aArgs );
-       }
 }
 // 
-----------------------------------------------------------------------------
 void ODocumentDefinition::onCommandPreview(Any& _rImage)




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

Reply via email to