Kaydet (Commit) 3797e61e authored tarafından Kohei Yoshida's avatar Kohei Yoshida

More removal of UNO API for setting document properties.

Change-Id: I8c68308394a64eee0985d7d1f8c8b34637a6da74
üst 0762f059
...@@ -1126,7 +1126,7 @@ public: ...@@ -1126,7 +1126,7 @@ public:
bool IsUndo() const { return bIsUndo; } bool IsUndo() const { return bIsUndo; }
bool IsClipboard() const { return bIsClip; } bool IsClipboard() const { return bIsClip; }
bool IsUndoEnabled() const { return mbUndoEnabled; } bool IsUndoEnabled() const { return mbUndoEnabled; }
void EnableUndo( bool bVal ); SC_DLLPUBLIC void EnableUndo( bool bVal );
bool IsAdjustHeightEnabled() const { return mbAdjustHeightEnabled; } bool IsAdjustHeightEnabled() const { return mbAdjustHeightEnabled; }
void EnableAdjustHeight( bool bVal ) { mbAdjustHeightEnabled = bVal; } void EnableAdjustHeight( bool bVal ) { mbAdjustHeightEnabled = bVal; }
......
...@@ -56,6 +56,7 @@ namespace oox { namespace core { ...@@ -56,6 +56,7 @@ namespace oox { namespace core {
} } } }
class ScDocument; class ScDocument;
class ScDocShell;
class ScDocumentImport; class ScDocumentImport;
class ScEditEngineDefaulter; class ScEditEngineDefaulter;
...@@ -152,6 +153,7 @@ public: ...@@ -152,6 +153,7 @@ public:
ScDocument& getScDocument(); ScDocument& getScDocument();
const ScDocument& getScDocument() const; const ScDocument& getScDocument() const;
ScDocShell& getDocShell();
ScDocumentImport& getDocImport(); ScDocumentImport& getDocImport();
ScEditEngineDefaulter& getEditEngine() const; ScEditEngineDefaulter& getEditEngine() const;
......
...@@ -338,7 +338,7 @@ void WorkbookFragment::finalizeImport() ...@@ -338,7 +338,7 @@ void WorkbookFragment::finalizeImport()
// Recalculate formula cells. // Recalculate formula cells.
ScDocument& rDoc = getScDocument(); ScDocument& rDoc = getScDocument();
ScDocShell* pDocSh = static_cast<ScDocShell*>(rDoc.GetDocumentShell()); ScDocShell& rDocSh = getDocShell();
Reference< XComponentContext > xContext = comphelper::getProcessComponentContext(); Reference< XComponentContext > xContext = comphelper::getProcessComponentContext();
ScRecalcOptions nRecalcMode = ScRecalcOptions nRecalcMode =
static_cast<ScRecalcOptions>(officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::get(xContext)); static_cast<ScRecalcOptions>(officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::get(xContext));
...@@ -349,7 +349,7 @@ void WorkbookFragment::finalizeImport() ...@@ -349,7 +349,7 @@ void WorkbookFragment::finalizeImport()
{ {
// Ask the user if full re-calculation is desired. // Ask the user if full re-calculation is desired.
QueryBox aBox( QueryBox aBox(
pDocSh->GetActiveDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES), rDocSh.GetActiveDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES),
ScGlobal::GetRscString(STR_QUERY_FORMULA_RECALC_ONLOAD_XLS)); ScGlobal::GetRscString(STR_QUERY_FORMULA_RECALC_ONLOAD_XLS));
aBox.SetCheckBoxText(ScGlobal::GetRscString(STR_ALWAYS_PERFORM_SELECTED)); aBox.SetCheckBoxText(ScGlobal::GetRscString(STR_ALWAYS_PERFORM_SELECTED));
...@@ -373,7 +373,7 @@ void WorkbookFragment::finalizeImport() ...@@ -373,7 +373,7 @@ void WorkbookFragment::finalizeImport()
bHardRecalc = true; bHardRecalc = true;
if (bHardRecalc) if (bHardRecalc)
pDocSh->DoHardRecalc(false); rDocSh.DoHardRecalc(false);
else else
rDoc.CalcFormulaTree(false, true, false); rDoc.CalcFormulaTree(false, true, false);
} }
......
...@@ -72,6 +72,7 @@ ...@@ -72,6 +72,7 @@
#include "datauno.hxx" #include "datauno.hxx"
#include "globalnames.hxx" #include "globalnames.hxx"
#include "documentimport.hxx" #include "documentimport.hxx"
#include "drwlayer.hxx"
#include "formulabuffer.hxx" #include "formulabuffer.hxx"
#include "vcl/mapmod.hxx" #include "vcl/mapmod.hxx"
...@@ -150,6 +151,7 @@ public: ...@@ -150,6 +151,7 @@ public:
ScDocument& getScDocument() { return *mpDoc; } ScDocument& getScDocument() { return *mpDoc; }
const ScDocument& getScDocument() const { return *mpDoc; } const ScDocument& getScDocument() const { return *mpDoc; }
ScDocShell& getDocShell();
ScDocumentImport& getDocImport(); ScDocumentImport& getDocImport();
/** Returns a reference to the source/target spreadsheet document model. */ /** Returns a reference to the source/target spreadsheet document model. */
...@@ -305,6 +307,7 @@ private: ...@@ -305,6 +307,7 @@ private:
rtl_TextEncoding meTextEnc; /// BIFF byte string text encoding. rtl_TextEncoding meTextEnc; /// BIFF byte string text encoding.
bool mbHasCodePage; /// True = CODEPAGE record exists in imported stream. bool mbHasCodePage; /// True = CODEPAGE record exists in imported stream.
ScDocument* mpDoc; ScDocument* mpDoc;
ScDocShell* mpDocShell;
boost::scoped_ptr<ScDocumentImport> mxDocImport; boost::scoped_ptr<ScDocumentImport> mxDocImport;
}; };
...@@ -316,7 +319,8 @@ WorkbookGlobals::WorkbookGlobals( ExcelFilter& rFilter ) : ...@@ -316,7 +319,8 @@ WorkbookGlobals::WorkbookGlobals( ExcelFilter& rFilter ) :
meFilterType( FILTER_OOXML ), meFilterType( FILTER_OOXML ),
mpOoxFilter( &rFilter ), mpOoxFilter( &rFilter ),
meBiff( BIFF_UNKNOWN ), meBiff( BIFF_UNKNOWN ),
mpDoc( NULL ) mpDoc(NULL),
mpDocShell(NULL)
{ {
// register at the filter, needed for virtual callbacks (even during construction) // register at the filter, needed for virtual callbacks (even during construction)
mrExcelFilter.registerWorkbookGlobals( *this ); mrExcelFilter.registerWorkbookGlobals( *this );
...@@ -329,6 +333,11 @@ WorkbookGlobals::~WorkbookGlobals() ...@@ -329,6 +333,11 @@ WorkbookGlobals::~WorkbookGlobals()
mrExcelFilter.unregisterWorkbookGlobals(); mrExcelFilter.unregisterWorkbookGlobals();
} }
ScDocShell& WorkbookGlobals::getDocShell()
{
return *mpDocShell;
}
ScDocumentImport& WorkbookGlobals::getDocImport() ScDocumentImport& WorkbookGlobals::getDocImport()
{ {
return *mxDocImport; return *mxDocImport;
...@@ -534,11 +543,10 @@ void WorkbookGlobals::initialize( bool bWorkbookFile ) ...@@ -534,11 +543,10 @@ void WorkbookGlobals::initialize( bool bWorkbookFile )
if (mxDoc.get()) if (mxDoc.get())
{ {
ScModelObj* pModel = dynamic_cast<ScModelObj*>(mxDoc.get()); ScModelObj* pModel = dynamic_cast<ScModelObj*>(mxDoc.get());
ScDocShell* pDocShell = NULL;
if (pModel) if (pModel)
pDocShell = static_cast<ScDocShell*>(pModel->GetEmbeddedObject()); mpDocShell = static_cast<ScDocShell*>(pModel->GetEmbeddedObject());
if (pDocShell) if (mpDocShell)
mpDoc = pDocShell->GetDocument(); mpDoc = mpDocShell->GetDocument();
} }
if (!mpDoc) if (!mpDoc)
...@@ -578,19 +586,16 @@ void WorkbookGlobals::initialize( bool bWorkbookFile ) ...@@ -578,19 +586,16 @@ void WorkbookGlobals::initialize( bool bWorkbookFile )
// set some document properties needed during import // set some document properties needed during import
if( mrBaseFilter.isImportFilter() ) if( mrBaseFilter.isImportFilter() )
{ {
PropertySet aPropSet( mxDoc );
// enable editing read-only documents (e.g. from read-only files) // enable editing read-only documents (e.g. from read-only files)
aPropSet.setProperty( PROP_IsChangeReadOnlyEnabled, true ); mpDoc->EnableChangeReadOnly(true);
// #i76026# disable Undo while loading the document // #i76026# disable Undo while loading the document
aPropSet.setProperty( PROP_IsUndoEnabled, false ); mpDoc->EnableUndo(false);
// #i79826# disable calculating automatic row height while loading the document // #i79826# disable calculating automatic row height while loading the document
aPropSet.setProperty( PROP_IsAdjustHeightEnabled, false ); mpDoc->EnableAdjustHeight(true);
// disable automatic update of linked sheets and DDE links // disable automatic update of linked sheets and DDE links
aPropSet.setProperty( PROP_IsExecuteLinkEnabled, false ); mpDoc->EnableExecuteLink(false);
// #i79890# disable automatic update of defined names // #i79890# disable automatic update of defined names
Reference< XActionLockable > xLockable( aPropSet.getAnyProperty( PROP_NamedRanges ), UNO_QUERY ); mpDoc->CompileNameFormula(true);
if( xLockable.is() )
xLockable->addActionLock();
//! TODO: localize progress bar text //! TODO: localize progress bar text
mxProgressBar.reset( new SegmentProgressBar( mrBaseFilter.getStatusIndicator(), "Loading..." ) ); mxProgressBar.reset( new SegmentProgressBar( mrBaseFilter.getStatusIndicator(), "Loading..." ) );
...@@ -598,7 +603,7 @@ void WorkbookGlobals::initialize( bool bWorkbookFile ) ...@@ -598,7 +603,7 @@ void WorkbookGlobals::initialize( bool bWorkbookFile )
//prevent unnecessary broadcasts and "half way listeners" as //prevent unnecessary broadcasts and "half way listeners" as
//is done in ScDocShell::BeforeXMLLoading() for ods //is done in ScDocShell::BeforeXMLLoading() for ods
getScDocument().SetInsertingFromOtherDoc(true); mpDoc->SetInsertingFromOtherDoc(true);
} }
else if( mrBaseFilter.isExportFilter() ) else if( mrBaseFilter.isExportFilter() )
{ {
...@@ -625,26 +630,28 @@ void WorkbookGlobals::finalize() ...@@ -625,26 +630,28 @@ void WorkbookGlobals::finalize()
// set some document properties needed after import // set some document properties needed after import
if( mrBaseFilter.isImportFilter() ) if( mrBaseFilter.isImportFilter() )
{ {
PropertySet aPropSet( mxDoc );
// #i74668# do not insert default sheets // #i74668# do not insert default sheets
aPropSet.setProperty( PROP_IsLoaded, true ); mpDocShell->SetEmpty(false);
// #i79890# Compile named ranges before re-enabling row height adjustment. (no idea why). // #i79890# Compile named ranges before re-enabling row height adjustment. (no idea why).
mpDoc->CompileNameFormula(false); mpDoc->CompileNameFormula(false);
// enable automatic update of linked sheets and DDE links // enable automatic update of linked sheets and DDE links
aPropSet.setProperty( PROP_IsExecuteLinkEnabled, true ); mpDoc->EnableExecuteLink(true);
// #i79826# enable updating automatic row height after loading the document // #i79826# enable updating automatic row height after loading the document
aPropSet.setProperty( PROP_IsAdjustHeightEnabled, true ); mpDoc->EnableAdjustHeight(true);
// #i76026# enable Undo after loading the document // #i76026# enable Undo after loading the document
aPropSet.setProperty( PROP_IsUndoEnabled, true ); mpDoc->EnableUndo(true);
// disable editing read-only documents (e.g. from read-only files) // disable editing read-only documents (e.g. from read-only files)
aPropSet.setProperty( PROP_IsChangeReadOnlyEnabled, false ); mpDoc->EnableChangeReadOnly(false);
// #111099# open forms in alive mode (has no effect, if no controls in document) // #111099# open forms in alive mode (has no effect, if no controls in document)
aPropSet.setProperty( PROP_ApplyFormDesignMode, false ); ScDrawLayer* pModel = mpDoc->GetDrawLayer();
if (pModel)
pModel->SetOpenInDesignMode(false);
//stop preventing establishment of listeners as is done in //stop preventing establishment of listeners as is done in
//ScDocShell::AfterXMLLoading() for ods //ScDocShell::AfterXMLLoading() for ods
getScDocument().SetInsertingFromOtherDoc(false); mpDoc->SetInsertingFromOtherDoc(false);
getDocImport().finalize(); getDocImport().finalize();
} }
} }
...@@ -745,6 +752,11 @@ const ScDocument& WorkbookHelper::getScDocument() const ...@@ -745,6 +752,11 @@ const ScDocument& WorkbookHelper::getScDocument() const
return mrBookGlob.getScDocument(); return mrBookGlob.getScDocument();
} }
ScDocShell& WorkbookHelper::getDocShell()
{
return mrBookGlob.getDocShell();
}
ScDocumentImport& WorkbookHelper::getDocImport() ScDocumentImport& WorkbookHelper::getDocImport()
{ {
return mrBookGlob.getDocImport(); return mrBookGlob.getDocImport();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment