Tag: cws_dev300_odbmacros3
User: fs      
Date: 2008-04-13 19:17:51+0000
Modified:
   dba/dbaccess/source/core/dataaccess/documentdefinition.cxx
   dba/dbaccess/source/core/dataaccess/documentdefinition.hxx

Log:
 #i49133# support a Hidden flag

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.56&r2=1.56.6.1
Delta lines:  +82 -64
---------------------
--- documentdefinition.cxx      2008-03-06 18:00:13+0000        1.56
+++ documentdefinition.cxx      2008-04-13 19:17:48+0000        1.56.6.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: documentdefinition.cxx,v $
  *
- *  $Revision: 1.56 $
+ *  $Revision: 1.56.6.1 $
  *
- *  last change: $Author: kz $ $Date: 2008/03/06 18:00:13 $
+ *  last change: $Author: fs $ $Date: 2008/04/13 19:17:48 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -970,24 +970,31 @@
         DBG_ERROR( "unreachable" );
        }
 
-       Reference<XModel> xModel;
-       if ( m_pImpl->m_aProps.sPersistentName.getLength() )
-       {
-        Sequence< PropertyValue > aLoadArgs;
-        aDocumentArgs >>= aLoadArgs;
-               loadEmbeddedObject( xConnection, Sequence< sal_Int8 >(), 
aLoadArgs, false, !m_bOpenInDesign );
-               if ( m_xEmbeddedObject.is() )
-               {
-                       xModel.set(getComponent(),UNO_QUERY);
+    OSL_ENSURE( m_pImpl->m_aProps.sPersistentName.getLength(),
+        "ODocumentDefinition::onCommandOpenSomething: no persistent name - 
cannot load!" );
+       if ( !m_pImpl->m_aProps.sPersistentName.getLength() )
+        return;
+
+    // embedded objects themself do not support the hidden flag. We implement 
support for
+    // it by changing the STATE to RUNNING only, instead of ACTIVE.
+    bool bOpenHidden = aDocumentArgs.getOrDefault( "Hidden", false );
+    aDocumentArgs.remove( "Hidden" );
+
+       loadEmbeddedObject( xConnection, Sequence< sal_Int8 >(), 
aDocumentArgs.getPropertyValues(), false, !m_bOpenInDesign );
+    OSL_ENSURE( m_xEmbeddedObject.is(), 
"ODocumentDefinition::onCommandOpenSomething: what's this?" );
+       if ( !m_xEmbeddedObject.is() )
+        return;
+
+       Reference< XModel > xModel( getComponent(), UNO_QUERY );
             Reference< report::XReportDefinition > 
xReportDefinition(xModel,UNO_QUERY);
 
-            Reference< XModule> xModule(xModel,UNO_QUERY);
+    Reference< XModule > xModule( xModel, UNO_QUERY );
             if ( xModule.is() )
             {
                 if ( m_bForm )
-                    
xModule->setIdentifier(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.FormDesign")));
+            xModule->setIdentifier( ::rtl::OUString( 
RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.FormDesign" ) ) );
                                else if ( !xReportDefinition.is() )
-                    
xModule->setIdentifier(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.TextReportDesign")));
+            xModule->setIdentifier( ::rtl::OUString( 
RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.TextReportDesign" ) ) );
             }
 
             bool bIsAliveNewStyleReport = ( !m_bOpenInDesign && 
xReportDefinition.is() );
@@ -1003,7 +1010,7 @@
                 return;            
             }
 
-            if ( _bActivate )
+    if ( _bActivate && !bOpenHidden )
                        {
                                m_xEmbeddedObject->changeState( 
EmbedStates::ACTIVE );
                 impl_onActivateEmbeddedObject();
@@ -1011,8 +1018,6 @@
 
                        fillReportData();
                        _out_rComponent <<= xModel;
-               }
-       }
 }
 
 // 
-----------------------------------------------------------------------------
@@ -1027,8 +1032,15 @@
            sal_Bool bOpenForMail = aCommand.Name.equalsAscii( "openForMail" );
            if ( bOpen || bOpenInDesign || bOpenForMail )
            {
-            m_bOpenInDesign = bOpenInDesign;
-            onCommandOpenSomething( aCommand.Argument, !bOpenForMail, 
Environment, aRet );
+            bool bActivateObject = true;
+            if ( bOpenForMail )
+            {
+                OSL_ENSURE( false, "ODocumentDefinition::execute: 
'openForMail' should not be used anymore - use the 'Hidden' parameter instead!" 
);
+                bActivateObject = false;
+            }
+
+            m_bOpenInDesign = bOpenInDesign || bOpenForMail;
+            onCommandOpenSomething( aCommand.Argument, bActivateObject, 
Environment, aRet );
         }
            else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( 
"copyTo" ) ) )
            {
@@ -1048,7 +1060,7 @@
                    Reference< XStorage> xStorage(aIni[0],UNO_QUERY);
                    ::rtl::OUString sPersistentName;
                    aIni[1] >>= sPersistentName;
-            loadEmbeddedObject();
+            loadEmbeddedObject( true );
                    Reference<XEmbedPersist> 
xPersist(m_xEmbeddedObject,UNO_QUERY);
                    if ( xPersist.is() )
                    {
@@ -1082,7 +1094,9 @@
                    aIni[0] >>= sURL;
                    onCommandInsert( sURL, Environment );
            }
-           else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( 
"getdocumentinfo" ) ) )
+           else if (   aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( 
"getdocumentinfo" ) )   // compatibility
+                ||  aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( 
"getDocumentInfo" ) )
+                )
            {
                    onCommandGetDocumentProperties( aRet );
            }
@@ -1107,12 +1121,17 @@
                            notifyDataSourceModified();
                    }
         }
-        else if ( aCommand.Name.compareToAscii( "shutdown" ) == 0 )
+        else if (   ( aCommand.Name.compareToAscii( "shutdown" ) == 0 ) // 
compatibility
+                ||  ( aCommand.Name.compareToAscii( "close" ) == 0 )
+                )
         {
-            bool bClose = prepareClose();
-            if ( bClose && m_xEmbeddedObject.is() )
-                m_xEmbeddedObject->changeState(EmbedStates::LOADED);
-            aRet <<= bClose;
+            bool bSuccess = prepareClose();
+            if ( bSuccess && m_xEmbeddedObject.is() )
+            {
+                m_xEmbeddedObject->changeState( EmbedStates::LOADED );
+                bSuccess = m_xEmbeddedObject->getCurrentState() == 
EmbedStates::LOADED;
+            }
+            aRet <<= bSuccess;
         }
            else
                    aRet = 
OContentHelper::execute(aCommand,CommandId,Environment);
@@ -1478,11 +1497,7 @@
 // 
-----------------------------------------------------------------------------
 sal_Bool ODocumentDefinition::objectSupportsEmbeddedScripts() const
 {
-//    bool bAllowDocumentMacros = !m_pImpl->m_pDataSource || 
m_pImpl->m_pDataSource->hasAnyObjectWithMacros();
-    // TODO: revert to the disabled code. The current version is just to be 
able
-    // to integrate an intermediate version of the CWS, which should behave as
-    // if no macros in DB docs are allowed
-    bool bAllowDocumentMacros = true;
+    bool bAllowDocumentMacros = !m_pImpl->m_pDataSource || 
m_pImpl->m_pDataSource->hasAnyObjectWithMacros();
 
     // if *any* of the objects of the database document already has macros, we 
continue to allow it
     // to have them, until the user did a migration.
@@ -1822,8 +1837,8 @@
 
     try
     {
-        // suspend the controller. Embedded objects are not allowed to rais
-        // own UI on their own decision, instead, this has always to be 
triggered
+        // suspend the controller. Embedded objects are not allowed to raise
+        // own UI at their own discretion, instead, this has always to be 
triggered
         // by the embedding component. Thus, we do the suspend call here.
         // #i49370# / 2005-06-09 / [EMAIL PROTECTED]
 
@@ -1831,9 +1846,12 @@
         Reference< XController > xController;
         if ( xModel.is() )
             xController = xModel->getCurrentController();
-        OSL_ENSURE( xController.is(), "ODocumentDefinition::prepareClose: no 
controller!" );
+
+        OSL_ENSURE( xController.is() || ( m_xEmbeddedObject->getCurrentState() 
< EmbedStates::ACTIVE ),
+            "ODocumentDefinition::prepareClose: no controller!" );
         if ( !xController.is() )
-            return sal_False;
+            // document has not yet been activated, i.e. has no UI, yet
+            return true;
         
         sal_Bool bCouldSuspend = xController->suspend( sal_True );
         if ( !bCouldSuspend )

File [changed]: documentdefinition.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/documentdefinition.hxx?r1=1.28&r2=1.28.6.1
Delta lines:  +5 -5
-------------------
--- documentdefinition.hxx      2008-03-06 18:00:42+0000        1.28
+++ documentdefinition.hxx      2008-04-13 19:17:48+0000        1.28.6.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: documentdefinition.hxx,v $
  *
- *  $Revision: 1.28 $
+ *  $Revision: 1.28.6.1 $
  *
- *  last change: $Author: kz $ $Date: 2008/03/06 18:00:42 $
+ *  last change: $Author: fs $ $Date: 2008/04/13 19:17:48 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -226,13 +226,13 @@
 
     /** loads the embedded object, if not already loaded. No new object can be 
created with this method.
     */
-    void    loadEmbeddedObject()
+    void    loadEmbeddedObject( bool _bSuppressMacros = false )
     {
         loadEmbeddedObject(
             NULL,
             ::com::sun::star::uno::Sequence< sal_Int8 >(),
             ::com::sun::star::uno::Sequence< 
::com::sun::star::beans::PropertyValue >(),
-            false,
+            _bSuppressMacros,
             false
         );
     }




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

Reply via email to