sc/source/filter/oox/workbookhelper.cxx |   39 ++++++++++++++------------------
 1 file changed, 18 insertions(+), 21 deletions(-)

New commits:
commit bc1fced1aedbaca367fc653c5806f1f8d9efeebe
Author: Kohei Yoshida <kohei.yosh...@collabora.com>
Date:   Thu Sep 12 00:05:31 2013 -0400

    No need to delay initialization of ScDocument member.
    
    Change-Id: Icf3ae78158e4a3844aa4ff393f1527c0c72e5131

diff --git a/sc/source/filter/oox/workbookhelper.cxx 
b/sc/source/filter/oox/workbookhelper.cxx
index dbdf45d..7a9a58f 100644
--- a/sc/source/filter/oox/workbookhelper.cxx
+++ b/sc/source/filter/oox/workbookhelper.cxx
@@ -77,6 +77,8 @@
 #include "editutil.hxx"
 #include "editeng/editstat.hxx"
 
+#include <boost/noncopyable.hpp>
+
 namespace oox {
 namespace xls {
 
@@ -107,7 +109,7 @@ bool IgnoreCaseCompare::operator()( const OUString& rName1, 
const OUString& rNam
 
 // ============================================================================
 
-class WorkbookGlobals
+class WorkbookGlobals : boost::noncopyable
 {
 public:
     explicit            WorkbookGlobals( ExcelFilter& rFilter );
@@ -143,24 +145,7 @@ public:
         return *mxEditEngine.get();
     }
 
-    inline ScDocument& getScDocument() const
-    {
-        if ( !mpDoc )
-        {
-            if ( mxDoc.get() )
-            {
-                ScModelObj* pModel = dynamic_cast< ScModelObj* >( mxDoc.get() 
);
-                ScDocShell* pDocShell = NULL;
-                if ( pModel )
-                    pDocShell = (ScDocShell*)pModel->GetEmbeddedObject();
-                if ( pDocShell )
-                    mpDoc = pDocShell->GetDocument();
-            }
-        }
-        if ( !mpDoc )
-            throw RuntimeException( OUString( 
"Workbookhelper::getScDocument(): Failed to access ScDocument from model" ), 
Reference< XInterface >() );
-        return *mpDoc;
-    }
+    ScDocument& getScDocument() const { return *mpDoc; }
 
     /** Returns a reference to the source/target spreadsheet document model. */
     inline Reference< XSpreadsheetDocument > getDocument() const { return 
mxDoc; }
@@ -314,7 +299,7 @@ private:
     BiffType            meBiff;                 /// BIFF version for BIFF 
import/export.
     rtl_TextEncoding    meTextEnc;              /// BIFF byte string text 
encoding.
     bool                mbHasCodePage;          /// True = CODEPAGE record 
exists in imported stream.
-    mutable ScDocument* mpDoc;
+    ScDocument* mpDoc;
 };
 
 // ----------------------------------------------------------------------------
@@ -338,7 +323,6 @@ WorkbookGlobals::~WorkbookGlobals()
     mrExcelFilter.unregisterWorkbookGlobals();
 }
 
-// document model -------------------------------------------------------------
 
 Reference< XNameContainer > WorkbookGlobals::getStyleFamily( bool bPageStyles 
) const
 {
@@ -535,6 +519,19 @@ void WorkbookGlobals::initialize( bool bWorkbookFile )
     mxDoc.set( mrBaseFilter.getModel(), UNO_QUERY );
     OSL_ENSURE( mxDoc.is(), "WorkbookGlobals::initialize - no spreadsheet 
document" );
 
+    if (mxDoc.get())
+    {
+        ScModelObj* pModel = dynamic_cast<ScModelObj*>(mxDoc.get());
+        ScDocShell* pDocShell = NULL;
+        if (pModel)
+            pDocShell = static_cast<ScDocShell*>(pModel->GetEmbeddedObject());
+        if (pDocShell)
+            mpDoc = pDocShell->GetDocument();
+    }
+
+    if (!mpDoc)
+        throw RuntimeException("Workbookhelper::getScDocument(): Failed to 
access ScDocument from model", Reference<XInterface>());
+
     mxFormulaBuffer.reset( new FormulaBuffer( *this ) );
     mxWorkbookSettings.reset( new WorkbookSettings( *this ) );
     mxViewSettings.reset( new ViewSettings( *this ) );
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to