Tag: cws_src680_fwk23
User: abi     
Date: 05/10/17 21:32:46

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

Log:
 RESYNC: (1.27-1.29); FILE MERGED

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.27.8.1&r2=1.27.8.2
Delta lines:  +209 -189
-----------------------
--- documentdefinition.cxx      12 Oct 2005 05:53:59 -0000      1.27.8.1
+++ documentdefinition.cxx      18 Oct 2005 04:32:43 -0000      1.27.8.2
@@ -1,22 +1,20 @@
 /*************************************************************************
  *
+ *  OpenOffice.org - a multi-platform office productivity suite
+ *
  *  $RCSfile$
  *
  *  $Revision$
  *
  *  last change: $Author$ $Date$
  *
- *  The Contents of this file are made available subject to the terms of
- *  either of the following licenses
- *
- *         - GNU Lesser General Public License Version 2.1
- *         - Sun Industry Standards Source License Version 1.1
+ *  The Contents of this file are made available subject to
+ *  the terms of GNU Lesser General Public License Version 2.1.
  *
- *  Sun Microsystems Inc., October, 2000
  *
  *  GNU Lesser General Public License Version 2.1
  *  =============================================
- *  Copyright 2000 by Sun Microsystems, Inc.
+ *    Copyright 2005 by Sun Microsystems, Inc.
  *  901 San Antonio Road, Palo Alto, CA 94303, USA
  *
  *  This library is free software; you can redistribute it and/or
@@ -33,30 +31,6 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  *  MA  02111-1307  USA
  *
- *
- *  Sun Industry Standards Source License Version 1.1
- *  =================================================
- *  The contents of this file are subject to the Sun Industry Standards
- *  Source License Version 1.1 (the "License"); You may not use this file
- *  except in compliance with the License. You may obtain a copy of the
- *  License at http://www.openoffice.org/license.html.
- *
- *  Software provided under this License is provided on an "AS IS" basis,
- *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- *  See the License for the specific provisions governing your rights and
- *  obligations concerning the Software.
- *
- *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- *  Copyright: 2000 by Sun Microsystems, Inc.
- *
- *  All Rights Reserved.
- *
- *  Contributor(s): _______________________________________
- *
- *
  ************************************************************************/
 
 #ifndef _DBA_COREDATAACCESS_DOCUMENTDEFINITION_HXX_
@@ -479,6 +453,7 @@
        ,m_pClientHelper(NULL)
        ,m_bForm(_bForm)
        ,m_bOpenInDesign(sal_False)
+    ,m_bInExecute(sal_False)
 {
        DBG_CTOR(ODocumentDefinition, NULL);
        registerProperties();
@@ -573,11 +548,41 @@
        describeProperties(aProps);
        return new OPropertyArrayHelper(aProps);
 }
+class OExecuteImpl
+{
+    sal_Bool& m_rbSet;
+public:
+    OExecuteImpl(sal_Bool& _rbSet) : m_rbSet(_rbSet){ m_rbSet=sal_True; }
+    ~OExecuteImpl(){ m_rbSet = sal_False; }
+};
+// 
-----------------------------------------------------------------------------
+namespace
+{
+    bool lcl_extractOpenMode( const Any& _rValue, sal_Int32& /* [out] */ 
_rMode )
+    {
+        OpenCommandArgument aOpenCommand;
+        if ( _rValue >>= aOpenCommand )
+            _rMode = aOpenCommand.Mode;
+        else
+        {
+                   OpenCommandArgument2 aOpenCommand;
+            if ( _rValue >>= aOpenCommand )
+                _rMode = aOpenCommand.Mode;
+            else
+                return false;
+        }
+        return true;
+    }
+}
+
 // 
-----------------------------------------------------------------------------
 Any SAL_CALL ODocumentDefinition::execute( const Command& aCommand, sal_Int32 
CommandId, const Reference< XCommandEnvironment >& Environment ) throw 
(Exception, CommandAbortedException, RuntimeException)
 {
        Any aRet;
        ::osl::MutexGuard aGuard(m_aMutex);
+    if ( !m_bInExecute )
+    {
+        OExecuteImpl aExecuteGuard(m_bInExecute);
        sal_Bool bOpenInDesign = aCommand.Name.equalsAscii("openDesign");
        sal_Bool bOpenForMail = aCommand.Name.equalsAscii("openForMail");
        if ( aCommand.Name.compareToAscii( "open" ) == 0 || bOpenInDesign || 
bOpenForMail )
@@ -586,70 +591,43 @@
                // open command for a folder content
                
//////////////////////////////////////////////////////////////////
                Reference< XConnection> xConnection;
-               OpenCommandArgument2 aOpenCommand;
-       if ( !( aCommand.Argument >>= aOpenCommand ) )
-               {
-                       sal_Bool bFound = sal_False;
-                       Sequence< PropertyValue > aSeq;
-                       if ( aCommand.Argument >>= aSeq )
+            sal_Int32 nOpenMode = OpenMode::DOCUMENT;
+
+            lcl_extractOpenMode( aCommand.Argument, nOpenMode );
+
+                       Sequence< PropertyValue > aArguments;
+                       if ( aCommand.Argument >>= aArguments )
                        {
-                               const PropertyValue* pIter = 
aSeq.getConstArray();
-                               const PropertyValue* pEnd  = pIter + 
aSeq.getLength();
+                               const PropertyValue* pIter = 
aArguments.getConstArray();
+                               const PropertyValue* pEnd  = pIter + 
aArguments.getLength();
                                for(;pIter != pEnd;++pIter)
                                {
                                        if ( pIter->Name == 
PROPERTY_ACTIVECONNECTION )
                                                
xConnection.set(pIter->Value,UNO_QUERY);
-                                       else if ( !bFound )
-                                               bFound = ( pIter->Value >>= 
aOpenCommand );
-                               }
-                       }
-                       if ( !bFound )
-                       {
-                               OSL_ENSURE( sal_False, "Wrong argument type!" );
-                               ucbhelper::cancelCommandExecution(
-                                       makeAny( IllegalArgumentException(
-                                                                               
rtl::OUString(),
-                                                                               
static_cast< cppu::OWeakObject * >( this ),
-                                                                               
-1 ) ),
-                                       Environment );
-                               // Unreachable
+                                       else
+                                               lcl_extractOpenMode( 
pIter->Value, nOpenMode );
                        }
         }
-               sal_Bool bOpenFolder =
-            ( ( aOpenCommand.Mode == OpenMode::ALL ) ||
-              ( aOpenCommand.Mode == OpenMode::FOLDERS ) ||
-              ( aOpenCommand.Mode == OpenMode::DOCUMENTS ) );
+
         if ( xConnection.is() )
             m_xLastKnownConnection = xConnection;
 
-        if ( bOpenFolder )
-               {
-            // open as folder - return result set
-
-            ucbhelper::cancelCommandExecution(
-                    makeAny( UnsupportedOpenModeException(
-                                    rtl::OUString(),
-                                    static_cast< cppu::OWeakObject * >( this ),
-                                    sal_Int16( aOpenCommand.Mode ) ) ),
-                    Environment );
-                // Unreachable
-               }
-               else
-        {
-            // Check open mode
-            if ( ( aOpenCommand.Mode
-                    == OpenMode::DOCUMENT_SHARE_DENY_NONE ) ||
-                 ( aOpenCommand.Mode
-                    == OpenMode::DOCUMENT_SHARE_DENY_WRITE ) )
+            if  (   ( nOpenMode == OpenMode::ALL )
+                ||  ( nOpenMode == OpenMode::FOLDERS )
+                ||  ( nOpenMode == OpenMode::DOCUMENTS )
+                ||  ( nOpenMode == OpenMode::DOCUMENT_SHARE_DENY_NONE )
+                ||  ( nOpenMode == OpenMode::DOCUMENT_SHARE_DENY_WRITE )
+                )
             {
-                // Unsupported.
+                // opening as folder is not supported
                 ucbhelper::cancelCommandExecution(
                     makeAny( UnsupportedOpenModeException(
                                     rtl::OUString(),
                                     static_cast< cppu::OWeakObject * >( this ),
-                                    sal_Int16( aOpenCommand.Mode ) ) ),
+                                        sal_Int16( nOpenMode ) ) ),
                     Environment );
                 // Unreachable
+                DBG_ERROR( "unreachable" );
             }
 
                        Reference<XModel> xModel;
@@ -803,7 +781,6 @@
                                }
                        }
                }
-       }
        else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( 
"copyTo" ) ) )
        {
                Sequence<Any> aIni;
@@ -873,6 +850,7 @@
        }
        else
                aRet = OContentHelper::execute(aCommand,CommandId,Environment);
+    }
        return aRet;
 }
 // 
-----------------------------------------------------------------------------
@@ -946,6 +924,8 @@
 sal_Bool ODocumentDefinition::save(sal_Bool _bApprove)
 {
        // default handling: instantiate an interaction handler and let it 
handle the parameter request
+    if ( !m_bOpenInDesign )
+        return sal_False;
        try
        {
 
@@ -1337,6 +1317,48 @@
        return bRet;
 }
 // 
-----------------------------------------------------------------------------
+bool ODocumentDefinition::prepareClose()
+{
+    if ( !m_xEmbeddedObject.is() )
+        return true;
+
+    try
+    {
+        // suspend the controller. Embedded objects are not allowed to rais
+        // own UI on their own decision, instead, this has always to be 
triggered
+        // by the embedding component. Thus, we do the suspend call here.
+        // #i49370# / 2005-06-09 / [EMAIL PROTECTED]
+
+        Reference< XModel > xModel( getComponent(), UNO_QUERY );
+        Reference< XController > xController;
+        if ( xModel.is() )
+            xController = xModel->getCurrentController();
+        OSL_ENSURE( xController.is(), "ODocumentDefinition::prepareClose: no 
controller!" );
+        if ( !xController.is() )
+            return sal_False;
+        
+        sal_Bool bCouldSuspend = xController->suspend( sal_True );
+        if ( !bCouldSuspend )
+            // controller vetoed the closing
+            return false;
+
+        if ( isModified() && !save( sal_True ) )
+        {
+            if ( bCouldSuspend )
+                // revert suspension
+                xController->suspend( sal_False );
+            // saving failed or was cancelled
+            return false;
+        }
+    }
+    catch( const Exception& )
+    {
+       OSL_ENSURE( sal_False, "ODocumentDefinition::prepareClose: caught an 
exception!" );
+    }
+
+    return true;
+}
+// 
-----------------------------------------------------------------------------
 void ODocumentDefinition::setModelReadOnly(sal_Bool _bReadOnly)
 {
        Reference<XModel> xModel(getComponent(),UNO_QUERY);
@@ -1357,7 +1379,6 @@
 {
        if ( !m_bForm && _bFill && m_pImpl->m_aProps.bAsTemplate && 
!m_bOpenInDesign ) // open a report in alive mode, so we need to fill it
        {
-               // setModelReadOnly(sal_False);
                Sequence<Any> aArgs(2);
                PropertyValue aValue;
                aValue.Name = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TextDocument"));
@@ -1370,7 +1391,6 @@
                Reference< XJobExecutor > 
xExecuteable(m_xORB->createInstanceWithArguments(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.wizards.report.CallReportWizard")),aArgs),UNO_QUERY);
                if ( xExecuteable.is() )
                        
xExecuteable->trigger(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("fill")));
-//             setModelReadOnly(sal_True);
        }
 }
 // 
-----------------------------------------------------------------------------




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

Reply via email to