Tag: cws_dev300_odbmacros3
User: fs      
Date: 2008-05-19 21:20:13+0000
Modified:
   dba/dbaccess/source/ext/macromigration/migrationengine.cxx

Log:
 more error message tuning / ScriptsStorage::AccessMode is not really needed

File Changes:

Directory: /dba/dbaccess/source/ext/macromigration/
===================================================

File [changed]: migrationengine.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ext/macromigration/migrationengine.cxx?r1=1.4.2.11&r2=1.4.2.12
Delta lines:  +26 -51
---------------------
--- migrationengine.cxx 2008-05-19 20:20:09+0000        1.4.2.11
+++ migrationengine.cxx 2008-05-19 21:20:10+0000        1.4.2.12
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: migrationengine.cxx,v $
- * $Revision: 1.4.2.11 $
+ * $Revision: 1.4.2.12 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -243,6 +243,14 @@
         }
 
            //----------------------------------------------------------------
+        ::rtl::OUString lcl_getSubDocumentDescription( const SubDocument& 
_rDocument )
+        {
+            ::rtl::OUString sObjectName = String( MacroMigrationResId( 
_rDocument.eType == eForm ? STR_FORM : STR_REPORT ) );
+            ::comphelper::string::searchAndReplaceAsciiI( sObjectName, 
"$name$", _rDocument.sHierarchicalName );
+            return sObjectName;
+        }
+
+        //----------------------------------------------------------------
         static Any lcl_executeCommand_throw( const Reference< 
XCommandProcessor >& _rxCommandProc,
             const sal_Char* _pAsciiCommand )
         {
@@ -286,7 +294,7 @@
             {
                 _rLogger.logFailure( MigrationError(
                     ERR_OPENING_SUB_DOCUMENT_FAILED,
-                    _rDocument.sHierarchicalName,
+                    lcl_getSubDocumentDescription( _rDocument ),
                     ::cppu::getCaughtException()
                 ) );
             }
@@ -312,7 +320,7 @@
             {
                 _rLogger.logFailure( MigrationError(
                     ERR_CLOSING_SUB_DOCUMENT_FAILED,
-                    _rDocument.sHierarchicalName,
+                    lcl_getSubDocumentDescription( _rDocument ),
                     aException
                 ) );
             }
@@ -405,14 +413,6 @@
             }
             return true;
         }
-
-        //----------------------------------------------------------------
-        ::rtl::OUString lcl_getSubDocumentDescription( const SubDocument& 
_rDocument )
-        {
-            ::rtl::OUString sObjectName = String( MacroMigrationResId( 
_rDocument.eType == eForm ? STR_FORM : STR_REPORT ) );
-            ::comphelper::string::searchAndReplaceAsciiI( sObjectName, 
"$name$", _rDocument.sHierarchicalName );
-            return sObjectName;
-        }
     }
 
     //====================================================================
@@ -554,15 +554,8 @@
     class ScriptsStorage
     {
     public:
-        enum AccessMode
-        {
-            READ,
-            WRITE
-        };
-
-    public:
         ScriptsStorage( MigrationLog& _rLogger );
-        ScriptsStorage( const Reference< XModel >& _rxDocument, const 
AccessMode _eMode, MigrationLog& _rLogger );
+        ScriptsStorage( const Reference< XModel >& _rxDocument, MigrationLog& 
_rLogger );
         ~ScriptsStorage();
 
         /** determines whether the instance is valid, i.e. refers to a valid 
root storage
@@ -570,14 +563,10 @@
         */
         inline bool isValid() const { return m_xScriptsStorage.is(); }
 
-        /** determines whether the storage is writeable
-        */
-        inline bool isWriteable() const { return isValid() && ( 
m_nStorageOpenMode != ElementModes::READ ); }
-
         /** binds the instance to a new document. Only to be called when the 
instance is not yet
             bound (i.e. isValid returns <FALSE/>).
         */
-        void    bind( const Reference< XModel >& _rxDocument, const AccessMode 
_eMode );
+        void    bind( const Reference< XModel >& _rxDocument );
 
         /// determines whether scripts of the given type are present
         bool    hasScripts( const ScriptType _eType ) const;
@@ -613,7 +602,6 @@
     private:
         MigrationLog&   m_rLogger;
         SharedStorage   m_xScriptsStorage;
-        sal_Int32       m_nStorageOpenMode;
     };
 
     //====================================================================
@@ -623,17 +611,15 @@
     ScriptsStorage::ScriptsStorage( MigrationLog& _rLogger )
         :m_rLogger( _rLogger )
         ,m_xScriptsStorage()
-        ,m_nStorageOpenMode( ElementModes::READ )
     {
     }
 
        //--------------------------------------------------------------------
-    ScriptsStorage::ScriptsStorage( const Reference< XModel >& _rxDocument, 
const AccessMode _eMode, MigrationLog& _rLogger )
+    ScriptsStorage::ScriptsStorage( const Reference< XModel >& _rxDocument, 
MigrationLog& _rLogger )
         :m_rLogger( _rLogger )
         ,m_xScriptsStorage()
-        ,m_nStorageOpenMode( ElementModes::READ )
     {
-        bind( _rxDocument, _eMode );
+        bind( _rxDocument );
     }
 
        //--------------------------------------------------------------------
@@ -644,35 +630,29 @@
     //--------------------------------------------------------------------
     bool ScriptsStorage::commit()
     {
-        OSL_PRECOND( isWriteable(), "ScriptsStorage::~ScriptsStorage: not 
writeable!" );
         return lcl_commitStorage_nothrow( m_xScriptsStorage );
     }
 
        //--------------------------------------------------------------------
-    void ScriptsStorage::bind( const Reference< XModel >& _rxDocument, const 
AccessMode _eMode )
+    void ScriptsStorage::bind( const Reference< XModel >& _rxDocument )
     {
         OSL_PRECOND( !isValid(), "ScriptsStorage:bind: did not bother, yet, to 
check whether this is allowed!" );
-        const bool bForWrite = ( _eMode == WRITE );
         try
         {
             Reference< XStorageBasedDocument > xStorageDoc( _rxDocument, 
UNO_QUERY_THROW );
             Reference< XStorage > xDocStorage( 
xStorageDoc->getDocumentStorage(), UNO_QUERY_THROW );
 
-            m_nStorageOpenMode = bForWrite ? ElementModes::READWRITE : 
ElementModes::READ;
-
             // the the "Scripts" storage exist, or if it does not (yet) exist 
and we are in write mode
             // => open the storage
             if  (   (   xDocStorage->hasByName( lcl_getScriptsStorageName() )
                     &&  xDocStorage->isStorageElement( 
lcl_getScriptsStorageName() )
                     )
-                ||  (   !xDocStorage->hasByName( lcl_getScriptsStorageName() )
-                    &&  bForWrite
-                    )
+                ||  !xDocStorage->hasByName( lcl_getScriptsStorageName() )
                 )
             {
                 m_xScriptsStorage.set(
                     xDocStorage->openStorageElement(
-                        lcl_getScriptsStorageName(), m_nStorageOpenMode
+                        lcl_getScriptsStorageName(), ElementModes::READWRITE
                     ),
                     UNO_QUERY_THROW
                 );
@@ -683,7 +663,6 @@
             m_rLogger.logFailure( MigrationError(
                 ERR_BIND_SCRIPT_STORAGE_FAILED,
                 ::comphelper::DocumentInfo::getDocumentTitle( _rxDocument ),
-                ::rtl::OUString::createFromAscii( bForWrite ? "write" : "read" 
),
                 ::cppu::getCaughtException()
             ) );
         }
@@ -708,7 +687,7 @@
         if ( isValid() )
         {
             xStorage.reset( m_xScriptsStorage->openStorageElement(
-                lcl_getScriptsSubStorageName( _eType ), m_nStorageOpenMode
+                lcl_getScriptsSubStorageName( _eType ), ElementModes::READWRITE
             ) );
         }
         return xStorage;
@@ -733,14 +712,10 @@
     //--------------------------------------------------------------------
     void ScriptsStorage::removeScriptTypeStorage( const ScriptType _eType ) 
const
     {
-        OSL_PRECOND( isWriteable(), "ScriptsStorage::removeScriptTypeStorage: 
not writeable!" );
-        if ( isWriteable() )
-        {
             ::rtl::OUString sSubStorageName( lcl_getScriptsSubStorageName( 
_eType ) );
             if ( m_xScriptsStorage->hasByName( sSubStorageName ) )
                 m_xScriptsStorage->removeElement( sSubStorageName );
         }
-    }
 
     //--------------------------------------------------------------------
     bool ScriptsStorage::removeFromDocument( const Reference< XModel >& 
_rxDocument, MigrationLog& _rLogger )
@@ -1209,7 +1184,7 @@
         try
         {
             // the root storage of the document whose scripts are to be 
migrated
-            ScriptsStorage aDocStorage( _rDocument.xDocument, 
ScriptsStorage::WRITE, m_rLogger );
+            ScriptsStorage aDocStorage( _rDocument.xDocument, m_rLogger );
             if  ( !aDocStorage.isValid() )
             {   // no scripts at all, or no scripts of the given type
                 return !m_rLogger.hadFailure();
@@ -1263,7 +1238,7 @@
         try
         {
             // the root storage of the document whose scripts are to be 
migrated
-            ScriptsStorage aDocStorage( _rDocument.xDocument, 
ScriptsStorage::WRITE, m_rLogger );
+            ScriptsStorage aDocStorage( _rDocument.xDocument, m_rLogger );
             if  (   !aDocStorage.isValid()
                 ||  !aDocStorage.hasScripts( _eScriptType )
                 )
@@ -1307,7 +1282,7 @@
                 // ensure we have access to the DBDoc's scripts storage
                 if ( !aDatabaseScripts.isValid() )
                 {   // not needed 'til now
-                    aDatabaseScripts.bind( m_xDocumentModel, 
ScriptsStorage::WRITE );
+                    aDatabaseScripts.bind( m_xDocumentModel );
                     if ( aDatabaseScripts.isValid() )
                         xTargetStorage = aDatabaseScripts.getScriptsRoot( 
_eScriptType );
 




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

Reply via email to