User: rt      
Date: 2008-06-06 14:06:19+0000
Modified:
   dba/dbaccess/source/filter/xml/dbloader2.cxx

Log:
 INTEGRATION: CWS dba30c (1.34.6); FILE MERGED
 2008/05/13 08:56:03 fs 1.34.6.2: joining changes from CWS odbmacros3 to CWS 
dba30c:

 2008/04/13 19:18:44 fs 1.32.28.1: remove unused includes

 2008/04/15 13:11:35 fs 1.32.28.2: RESYNC: (1.32-1.34); FILE MERGED

 2008/05/07 08:30:52 fs 1.32.28.3: #i49133# support 
XModel2::createViewController, MediaDescriptor::ViewControllerName, 
MediaDescriptor::Model / some more changes, especially for being able to reload 
a document
 2008/04/28 12:08:44 oj 1.34.6.1: #i84173# open tables view as default for 
newly created files

File Changes:

Directory: /dba/dbaccess/source/filter/xml/
===========================================

File [changed]: dbloader2.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/filter/xml/dbloader2.cxx?r1=1.34&r2=1.35
Delta lines:  +86 -98
---------------------
--- dbloader2.cxx       2008-04-10 13:21:11+0000        1.34
+++ dbloader2.cxx       2008-06-06 14:06:16+0000        1.35
@@ -48,7 +48,7 @@
 #include <com/sun/star/frame/XFrameLoader.hpp>
 #include <com/sun/star/frame/XFramesSupplier.hpp>
 #include <com/sun/star/frame/XLoadEventListener.hpp>
-#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/frame/XModel2.hpp>
 #include <com/sun/star/io/XInputStream.hpp>
 #include <com/sun/star/lang/XInitialization.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
@@ -57,10 +57,9 @@
 #include <com/sun/star/registry/XRegistryKey.hpp>
 #include <com/sun/star/sdb/XDocumentDataSource.hpp>
 #include <com/sun/star/task/XJobExecutor.hpp>
-#include <com/sun/star/task/XStatusIndicator.hpp>
-#include <com/sun/star/task/XStatusIndicatorFactory.hpp>
 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
 #include <com/sun/star/util/XURLTransformer.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
 /** === end UNO includes === **/
 
 #include <comphelper/componentcontext.hxx>
@@ -101,7 +100,6 @@
 using namespace ::com::sun::star::embed;
 namespace css = ::com::sun::star;
 using namespace ::com::sun::star::ui::dialogs;
-namespace css = ::com::sun::star;
 using ::com::sun::star::awt::XWindow;
 
 // -------------------------------------------------------------------------
@@ -141,34 +139,34 @@
 {
        try
        {
-               ::comphelper::SequenceAsHashMap aTemp(Descriptor);
-               Reference< XInputStream > xInStream = 
aTemp.getUnpackedValueOrDefault(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("InputStream")),
 Reference< XInputStream >() );
-
-               Reference<XPropertySet> xProp;
+        ::comphelper::NamedValueCollection aMedia( Descriptor );
+               Reference< XInputStream > xInStream( aMedia.getOrDefault( 
"InputStream",  Reference< XInputStream >() ) );
+               Reference< XPropertySet > xStorageProperties;
                if ( xInStream.is() )
                {
-                       xProp.set( 
::comphelper::OStorageHelper::GetStorageFromInputStream(
+                       xStorageProperties.set( 
::comphelper::OStorageHelper::GetStorageFromInputStream(
                 xInStream, m_aContext.getLegacyServiceFactory() ), UNO_QUERY );
                }
                else
                {
-                       ::rtl::OUString sTemp = 
aTemp.getUnpackedValueOrDefault(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("URL")),::rtl::OUString());
+            ::rtl::OUString sURL = aMedia.getOrDefault( "URL", 
::rtl::OUString() );
+            ::rtl::OUString sSalvagedURL( aMedia.getOrDefault( "SalvagedFile", 
::rtl::OUString() ) );
 
-                       if ( sTemp.getLength() )
+            ::rtl::OUString sFileLocation( sSalvagedURL.getLength() ? 
sSalvagedURL : sURL );
+                       if ( sFileLocation.getLength() )
                        {
-                               INetURLObject aURL(sTemp);
-                               xProp.set( 
::comphelper::OStorageHelper::GetStorageFromURL(
-                    sTemp, ElementModes::READ, 
m_aContext.getLegacyServiceFactory() ), UNO_QUERY );
+                               xStorageProperties.set( 
::comphelper::OStorageHelper::GetStorageFromURL(
+                    sFileLocation, ElementModes::READ, 
m_aContext.getLegacyServiceFactory() ), UNO_QUERY );
                        }
                }
 
-               if ( xProp.is() )
+               if ( xStorageProperties.is() )
                {
                        ::rtl::OUString sMediaType;
-                       xProp->getPropertyValue( INFO_MEDIATYPE ) >>= 
sMediaType;
+                       xStorageProperties->getPropertyValue( INFO_MEDIATYPE ) 
>>= sMediaType;
                        if ( 
sMediaType.equalsAscii(MIMETYPE_OASIS_OPENDOCUMENT_DATABASE_ASCII) || 
sMediaType.equalsAscii(MIMETYPE_VND_SUN_XML_BASE_ASCII) )
                                return 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StarBase"));
-                       ::comphelper::disposeComponent(xProp);
+                       ::comphelper::disposeComponent(xStorageProperties);
                }
        } catch(Exception&){}
        return ::rtl::OUString();
@@ -396,7 +394,6 @@
                const Sequence< PropertyValue >& rArgs,
                const Reference< XLoadEventListener > & rListener) 
throw(::com::sun::star::uno::RuntimeException)
 {
-
        // first check if preview is true, if so return with out creating a 
controller. Preview is not supported
     ::comphelper::NamedValueCollection aMediaDesc( rArgs );
     sal_Bool bPreview = aMediaDesc.getOrDefault( "Preview", sal_False );
@@ -429,16 +426,21 @@
             aMediaDesc.put( "InteractionHandler", xHandler );
     }
 
-    /* special mode: use already loaded model ...
-        In such case no filter name will be selected and no URL will be given!
-        Such informations are not neccessary. We have to create a new view only
-        and call setComponent() at the corresponding frame. */
+    // it's allowed to pass an existing document
+    Reference< XOfficeDatabaseDocument > xExistentDBDoc;
+    xModel.set( aMediaDesc.getOrDefault( "Model", xExistentDBDoc ), UNO_QUERY 
);
+    aMediaDesc.remove( "Model" );
+
+    // also, it's allowed to specify the type of view which should be created
+    ::rtl::OUString sViewName = aMediaDesc.getOrDefault( "ViewName", 
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Default" ) ) );
+    aMediaDesc.remove( "ViewName" );
+
+    sal_Bool bInteractive = sal_False;
        if ( !xModel.is() )
        {
                Reference< XSingleServiceFactory > xDatabaseContext;
-        if ( m_aContext.createComponent( 
(::rtl::OUString)SERVICE_SDB_DATABASECONTEXT, xDatabaseContext ) )
-               {
-            sal_Bool bInteractive = sal_False;
+        if ( !m_aContext.createComponent( 
(::rtl::OUString)SERVICE_SDB_DATABASECONTEXT, xDatabaseContext ) )
+            throw RuntimeException( ::rtl::OUString( 
RTL_CONSTASCII_USTRINGPARAM( "css.sdb.DatabaseContext not available" ) ), NULL 
);
 
                        ::rtl::OUString sFactoryName = 
SvtModuleOptions().GetFactoryEmptyDocumentURL(SvtModuleOptions::E_DATABASE);
             bCreateNew = sFactoryName.match(_rURL);
@@ -459,9 +461,7 @@
                 const ::rtl::OUString sURL = xModel->getURL();
                 if ( bCreateNew )
                 {
-                    Sequence< PropertyValue > aDocResource;
-                    aMediaDesc >>= aDocResource;
-                    xModel->attachResource( sURL, aDocResource );
+                xModel->attachResource( sURL, aMediaDesc.getPropertyValues() );
                 }
 
                 if ( bInteractive )
@@ -472,7 +472,6 @@
                 }
             }
                }
-       }
 
     if ( !xModel.is() )
     {
@@ -486,9 +485,7 @@
                try
                {
             aMediaDesc.put( "FileName", _rURL );
-            Sequence< PropertyValue > aDocResource;
-            aMediaDesc >>= aDocResource;
-                       xModel->attachResource( _rURL, aDocResource );
+                       xModel->attachResource( _rURL, 
aMediaDesc.getPropertyValues() );
                }
                catch(const Exception&)
                {
@@ -497,53 +494,32 @@
                }
        }
 
-    Reference< XController > xController;
-    if ( bSuccess )
-    {
-        bSuccess = m_aContext.createComponent( 
"org.openoffice.comp.dbu.OApplicationController", xController );
+    Reference< XController2 > xController;
            if ( bSuccess )
            {
-                   xController->attachModel(xModel);
-                   xModel->setCurrentController(xController);
-
-                   ::vos::OGuard aGuard(Application::GetSolarMutex());
-
-                   // and initialize
                    try
                    {
-                Sequence< PropertyValue > aLoadArgs;
-                aMediaDesc >>= aLoadArgs;
+            Reference< XModel2 > xModel2( xModel, UNO_QUERY_THROW );
+            xController = xModel2->createViewController( sViewName, Sequence< 
PropertyValue >(), rFrame );
 
-                           Reference<XInitialization > 
xIni(xController,UNO_QUERY);
-                Sequence< Any > aInitArgs( aLoadArgs.getLength() + 1 );
-
-                           Any* pArgIter = aInitArgs.getArray();
-                           Any* pEnd   = pArgIter + aInitArgs.getLength();
-                           *pArgIter++ <<= PropertyValue(
-                            ::rtl::OUString::createFromAscii( "Frame" ),
-                            0,
-                            makeAny( rFrame ),
-                            PropertyState_DIRECT_VALUE );
-
-                           const PropertyValue* pIter = 
aLoadArgs.getConstArray();
-                           for(++pArgIter;pArgIter != pEnd;++pArgIter,++pIter)
+            bSuccess = xController.is();
+            if ( bSuccess )
                            {
-                                   *pArgIter <<= *pIter;
+                xController->attachModel( xModel );
+                rFrame->setComponent( xController->getComponentWindow(), 
xController.get() );
+                xModel->setCurrentController( xController.get() );
+                xController->attachFrame( rFrame );
                            }
-
-                           xIni->initialize(aInitArgs);
                    }
-                   catch(Exception&)
+        catch( const Exception& )
                    {
+               DBG_UNHANDLED_EXCEPTION();
                            bSuccess = sal_False;
                    }
            }
-    }
 
        if (bSuccess)
        {
-               if ( xController.is() && rFrame.is() )
-                       xController->attachFrame(rFrame);
         try
         {
             Reference< css::container::XSet > xModelCollection;
@@ -584,6 +560,18 @@
         if ( rListener.is() )
                    rListener->loadFinished(this);
 
+        if ( bCreateNew && bInteractive )
+        {
+            Reference< css::view::XSelectionSupplier >  xDocView( 
xModel->getCurrentController(), UNO_QUERY );
+            if ( xDocView.is() )
+            {
+                Sequence< NamedValue > aSelection(1);
+                aSelection[0].Name = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Type"));
+                aSelection[0].Value <<= sal_Int32(0);
+                xDocView->select(makeAny(aSelection));
+            }
+        }
+
                if ( bStartTableWizard )
                {
                        // reset the data of the previous async drop (if any)




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

Reply via email to