summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2013-09-12 00:05:31 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2013-09-12 10:29:13 -0400
commitbc1fced1aedbaca367fc653c5806f1f8d9efeebe (patch)
tree8ec8ff5ae103f449c99d7e0e3844812116d5f0da
parent08fb2bfeb18b6d5329bae8490bd02043d101bb06 (diff)
No need to delay initialization of ScDocument member.
Change-Id: Icf3ae78158e4a3844aa4ff393f1527c0c72e5131
-rw-r--r--sc/source/filter/oox/workbookhelper.cxx39
1 files changed, 18 insertions, 21 deletions
diff --git a/sc/source/filter/oox/workbookhelper.cxx b/sc/source/filter/oox/workbookhelper.cxx
index dbdf45dc3054..7a9a58f21ee7 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 ) );