Tag: cws_src680_dba201b
User: fs      
Date: 05/07/26 00:51:51

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

Log:
 #i52479# execute: be more tolerant: accept OpenCommandArgument, 
OpenCommandArgument2, and no OpenCommandArgument at all

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.26.18.5&r2=1.26.18.6
Delta lines:  +187 -195
-----------------------
--- documentdefinition.cxx      11 Jul 2005 13:37:01 -0000      1.26.18.5
+++ documentdefinition.cxx      26 Jul 2005 07:51:47 -0000      1.26.18.6
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: documentdefinition.cxx,v $
  *
- *  $Revision: 1.26.18.5 $
+ *  $Revision: 1.26.18.6 $
  *
- *  last change: $Author: fs $ $Date: 2005/07/11 13:37:01 $
+ *  last change: $Author: fs $ $Date: 2005/07/26 07:51:47 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -582,6 +582,26 @@
     ~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;
@@ -597,70 +617,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;
@@ -802,7 +795,6 @@
                                                    
fillReportData(!bOpenInDesign);
                                                    aRet <<= xModel;
                                            }
-                                   }
                            }
                    }
            }




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

Reply via email to