Tag: cws_dev300_odbmacros3
User: fs      
Date: 2008-05-07 08:34:04+0000
Modified:
   dba/dbaccess/source/core/dataaccess/databasedocument.cxx

Log:
 #i49133# proper XModel2 implementation

File Changes:

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

File [changed]: databasedocument.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/databasedocument.cxx?r1=1.40.6.2&r2=1.40.6.3
Delta lines:  +44 -15
---------------------
--- databasedocument.cxx        2008-04-15 13:11:25+0000        1.40.6.2
+++ databasedocument.cxx        2008-05-07 08:34:02+0000        1.40.6.3
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: databasedocument.cxx,v $
- * $Revision: 1.40.6.2 $
+ * $Revision: 1.40.6.3 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -142,6 +142,8 @@
 using namespace ::cppu;
 using namespace ::osl;
 
+using ::com::sun::star::awt::XWindow;
+
 //........................................................................
 namespace dbaccess
 {
@@ -290,7 +292,10 @@
 {
     static void lcl_stripLoadArguments( ::comphelper::NamedValueCollection& 
_rArguments, Sequence< PropertyValue >& _rArgs )
     {
+        OSL_ENSURE( !_rArguments.has( "Model" ), "lcl_stripLoadArguments: this 
is suspicious (1)!" );
+        OSL_ENSURE( !_rArguments.has( "ViewName" ), "lcl_stripLoadArguments: 
this is suspicious (2)!" );
         _rArguments.remove( "Model" );
+        _rArguments.remove( "ViewName" );
         _rArguments >>= _rArgs;
     }
 
@@ -318,14 +323,13 @@
 
     static Sequence< PropertyValue > lcl_appendFileNameToDescriptor( const 
Sequence< PropertyValue >& _rDescriptor, const ::rtl::OUString _rURL )
     {
-        Sequence< PropertyValue > aMediaDescriptor( _rDescriptor );
+        ::comphelper::NamedValueCollection aMediaDescriptor( _rDescriptor );
         if ( _rURL.getLength() )
         {
-            aMediaDescriptor.realloc( _rDescriptor.getLength() + 1 );
-            aMediaDescriptor[ _rDescriptor.getLength() ].Name = 
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FileName" ) );
-            aMediaDescriptor[ _rDescriptor.getLength() ].Value <<= _rURL;
+            aMediaDescriptor.put( "FileName", _rURL );
+            aMediaDescriptor.put( "URL", _rURL );
         }
-        return aMediaDescriptor;
+        return aMediaDescriptor.getPropertyValues();
     }
 }
 
@@ -401,12 +405,12 @@
     ::comphelper::NamedValueCollection aResource( _aArguments );
     lcl_stripLoadArguments( aResource, m_pImpl->m_aArgs );
 
-    ::rtl::OUString sDocumentURL( aResource.getOrDefault( "SalvagedFile", 
_rURL ) );
-    if ( !sDocumentURL.getLength() )
+    ::rtl::OUString sDocumentLocation( aResource.getOrDefault( "SalvagedFile", 
_rURL ) );
+    if ( !sDocumentLocation.getLength() )
         // this indicates "the document is being recovered, but _rURL already 
is the real document URL,
         // not the temporary document location"
-        sDocumentURL = _rURL;
-    m_pImpl->switchToURL( _rURL, sDocumentURL );
+        sDocumentLocation = _rURL;
+    m_pImpl->switchToURL( sDocumentLocation, _rURL );
 
     bool bSuccess =
         (   m_pImpl->getOrCreateRootStorage().is()
@@ -1435,15 +1439,40 @@
     return aNames;
 }
 // 
-----------------------------------------------------------------------------
-Reference< XController > SAL_CALL 
ODatabaseDocument::createDefaultViewController( const Reference< XFrame >& 
/*Frame*/, Reference< ::com::sun::star::awt::XWindow >& /*ComponentWindow*/ ) 
throw (IllegalArgumentException, Exception, RuntimeException)
+Reference< XController2 > SAL_CALL 
ODatabaseDocument::createDefaultViewController( const Reference< XFrame >& 
_Frame ) throw (IllegalArgumentException, Exception, RuntimeException)
 {
-    return Reference< XController >();
+    return createViewController(
+        ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Default" ) ),
+        Sequence< PropertyValue >(),
+        _Frame
+    );
 }
+
 // 
-----------------------------------------------------------------------------
-Reference< XController > SAL_CALL ODatabaseDocument::createViewController( 
const ::rtl::OUString& /*ViewName*/, const Sequence< PropertyValue >& 
/*Arguments*/, const Reference< XFrame >& /*Frame*/, Reference< 
::com::sun::star::awt::XWindow >& /*ComponentWindow*/ ) throw 
(IllegalArgumentException, Exception, RuntimeException)
+Reference< XController2 > SAL_CALL ODatabaseDocument::createViewController( 
const ::rtl::OUString& _ViewName, const Sequence< PropertyValue >& _Arguments, 
const Reference< XFrame >& _Frame ) throw (IllegalArgumentException, Exception, 
RuntimeException)
 {
-    return Reference< XController >();
+    if ( !_ViewName.equalsAscii( "Default" ) && !_ViewName.equalsAscii( 
"Preview" ) )
+        throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
+    if ( !_Frame.is() )
+        throw IllegalArgumentException( ::rtl::OUString(), *this, 3 );
+
+    ModelMethodGuard aGuard( *this );
+    ::comphelper::ComponentContext aContext( m_pImpl->m_aContext );
+    aGuard.clear();
+
+    Reference< XController2 > xController;
+    aContext.createComponent( 
"org.openoffice.comp.dbu.OApplicationController", xController );
+
+    ::comphelper::NamedValueCollection aInitArgs( _Arguments );
+    aInitArgs.put( "Frame", _Frame );
+    if ( _ViewName.equalsAscii( "Preview" ) )
+        aInitArgs.put( "Preview", sal_Bool( sal_True ) );
+    Reference< XInitialization > xInitController( xController, UNO_QUERY_THROW 
);
+    xInitController->initialize( aInitArgs.getWrappedPropertyValues() );
+
+    return xController;
 }
+
 // 
-----------------------------------------------------------------------------
 //=============================================================================
 Reference< XTitle > ODatabaseDocument::impl_getTitleHelper_throw()




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

Reply via email to