[Libreoffice-commits] core.git: Branch 'private/kohei/external-ref-refresh' - sc/inc sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Tue May 20 19:32:46 PDT 2014
sc/inc/xmlwrap.hxx | 9 +++-
sc/source/filter/xml/xmlwrap.cxx | 81 ++++++++++++++++++---------------------
sc/source/ui/docshell/docsh.cxx | 8 +--
3 files changed, 50 insertions(+), 48 deletions(-)
New commits:
commit ec639ad118ecb02ab0efea3a60c793d9b6ea3ef6
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Tue May 20 22:32:43 2014 -0400
Finer grained ODS import mode selection.
Change-Id: I18520837f8d25103bf8482a0204b8a7b7740feb1
diff --git a/sc/inc/xmlwrap.hxx b/sc/inc/xmlwrap.hxx
index e74c01a..b7ec5cd 100644
--- a/sc/inc/xmlwrap.hxx
+++ b/sc/inc/xmlwrap.hxx
@@ -72,10 +72,17 @@ class ScXMLImportWrapper
ScMySharedData*& pSharedData);
public:
+
+ static const sal_uInt8 STYLES = 0x01;
+ static const sal_uInt8 CONTENT = 0x02;
+ static const sal_uInt8 METADATA = 0x04;
+ static const sal_uInt8 SETTINGS = 0x08;
+ static const sal_uInt8 ALL = STYLES | CONTENT | METADATA | SETTINGS;
+
ScXMLImportWrapper(
ScDocShell& rDocSh, SfxMedium* pM, const css::uno::Reference<css::embed::XStorage>& xStor );
- bool Import(bool bStylesOnly, ErrCode& );
+ bool Import( sal_uInt8 nMode, ErrCode& rError );
bool Export(bool bStylesOnly);
const sc::ImportPostProcessData& GetImportPostProcessData() const;
diff --git a/sc/source/filter/xml/xmlwrap.cxx b/sc/source/filter/xml/xmlwrap.cxx
index cc1cbff..159c3d8 100644
--- a/sc/source/filter/xml/xmlwrap.cxx
+++ b/sc/source/filter/xml/xmlwrap.cxx
@@ -309,7 +309,7 @@ sal_uInt32 ScXMLImportWrapper::ImportFromComponent(const uno::Reference<uno::XCo
return nReturn;
}
-bool ScXMLImportWrapper::Import(bool bStylesOnly, ErrCode& nError)
+bool ScXMLImportWrapper::Import( sal_uInt8 nMode, ErrCode& rError )
{
uno::Reference<uno::XComponentContext> xContext = comphelper::getProcessComponentContext();
@@ -349,6 +349,7 @@ bool ScXMLImportWrapper::Import(bool bStylesOnly, ErrCode& nError)
};
uno::Reference< beans::XPropertySet > xInfoSet( comphelper::GenericPropertySet_CreateInstance( new comphelper::PropertySetInfo( aImportInfoMap ) ) );
+ // No need to lock solar mutex when calling from the wrapper.
xInfoSet->setPropertyValue(SC_UNO_ODS_LOCK_SOLAR_MUTEX, uno::makeAny(false));
// ---- get BuildId from parent container if available
@@ -403,14 +404,14 @@ bool ScXMLImportWrapper::Import(bool bStylesOnly, ErrCode& nError)
}
}
- if (bStylesOnly)
- xInfoSet->setPropertyValue("OrganizerMode", uno::makeAny(sal_True));
+ if (mrDocShell.GetCreateMode() == SFX_CREATE_MODE_ORGANIZER)
+ xInfoSet->setPropertyValue("OrganizerMode", uno::makeAny(true));
xInfoSet->setPropertyValue( "SourceStorage", uno::Any( xStorage ) );
bool bOasis = ( SotStorage::GetVersion( xStorage ) > SOFFICE_FILEFORMAT_60 );
- if (!bStylesOnly && bOasis)
+ if ((nMode & METADATA) == METADATA && bOasis)
{
// RDF metadata: ODF >= 1.2
try
@@ -428,34 +429,37 @@ bool ScXMLImportWrapper::Import(bool bStylesOnly, ErrCode& nError)
ucb::InteractiveAugmentedIOException iaioe;
if ( e.TargetException >>= iaioe )
{
- nError = SCERR_IMPORT_UNKNOWN;
+ rError = SCERR_IMPORT_UNKNOWN;
}
else
{
- nError = SCWARN_IMPORT_FEATURES_LOST;
+ rError = SCWARN_IMPORT_FEATURES_LOST;
}
}
catch ( const uno::Exception &)
{
- nError = SCWARN_IMPORT_FEATURES_LOST;
+ rError = SCWARN_IMPORT_FEATURES_LOST;
}
}
// #i103539#: always read meta.xml for generator
sal_uInt32 nMetaRetval(0);
- uno::Sequence<uno::Any> aMetaArgs(1);
- uno::Any* pMetaArgs = aMetaArgs.getArray();
- pMetaArgs[0] <<= xInfoSet;
+ if ((nMode & METADATA) == METADATA)
+ {
+ uno::Sequence<uno::Any> aMetaArgs(1);
+ uno::Any* pMetaArgs = aMetaArgs.getArray();
+ pMetaArgs[0] <<= xInfoSet;
- SAL_INFO( "sc.filter", "meta import start" );
+ SAL_INFO( "sc.filter", "meta import start" );
- nMetaRetval = ImportFromComponent(
- xContext, xModel, xXMLParser, aParserInput,
- bOasis ? OUString("com.sun.star.comp.Calc.XMLOasisMetaImporter")
- : OUString("com.sun.star.comp.Calc.XMLMetaImporter"),
- "meta.xml", "Meta.xml", aMetaArgs, false);
+ nMetaRetval = ImportFromComponent(
+ xContext, xModel, xXMLParser, aParserInput,
+ bOasis ? OUString("com.sun.star.comp.Calc.XMLOasisMetaImporter")
+ : OUString("com.sun.star.comp.Calc.XMLMetaImporter"),
+ "meta.xml", "Meta.xml", aMetaArgs, false);
- SAL_INFO( "sc.filter", "meta import end" );
+ SAL_INFO( "sc.filter", "meta import end" );
+ }
SvXMLGraphicHelper* pGraphicHelper = NULL;
uno::Reference< document::XGraphicObjectResolver > xGrfContainer;
@@ -479,7 +483,7 @@ bool ScXMLImportWrapper::Import(bool bStylesOnly, ErrCode& nError)
pStylesArgs[3] <<= xObjectResolver;
sal_uInt32 nSettingsRetval(0);
- if (!bStylesOnly)
+ if ((nMode & SETTINGS) == SETTINGS)
{
// Settings must be loaded first because of the printer setting,
// which is needed in the page styles (paper tray).
@@ -500,6 +504,7 @@ bool ScXMLImportWrapper::Import(bool bStylesOnly, ErrCode& nError)
}
sal_uInt32 nStylesRetval(0);
+ if ((nMode & STYLES) == STYLES)
{
SAL_INFO( "sc.filter", "styles import start" );
@@ -513,7 +518,7 @@ bool ScXMLImportWrapper::Import(bool bStylesOnly, ErrCode& nError)
}
sal_uInt32 nDocRetval(0);
- if (!bStylesOnly)
+ if ((nMode & CONTENT) == CONTENT)
{
uno::Sequence<uno::Any> aDocArgs(4);
uno::Any* pDocArgs = aDocArgs.getArray();
@@ -542,34 +547,24 @@ bool ScXMLImportWrapper::Import(bool bStylesOnly, ErrCode& nError)
if (xStatusIndicator.is())
xStatusIndicator->end();
- bool bRet(false);
- if (bStylesOnly)
+ bool bRet = false;
+ if (nDocRetval)
{
- if (nStylesRetval)
- nError = nStylesRetval;
- else
+ rError = nDocRetval;
+ if (nDocRetval == SCWARN_IMPORT_RANGE_OVERFLOW ||
+ nDocRetval == SCWARN_IMPORT_ROW_OVERFLOW ||
+ nDocRetval == SCWARN_IMPORT_COLUMN_OVERFLOW ||
+ nDocRetval == SCWARN_IMPORT_SHEET_OVERFLOW)
bRet = true;
}
+ else if (nStylesRetval)
+ rError = nStylesRetval;
+ else if (nMetaRetval)
+ rError = nMetaRetval;
+ else if (nSettingsRetval)
+ rError = nSettingsRetval;
else
- {
- if (nDocRetval)
- {
- nError = nDocRetval;
- if (nDocRetval == SCWARN_IMPORT_RANGE_OVERFLOW ||
- nDocRetval == SCWARN_IMPORT_ROW_OVERFLOW ||
- nDocRetval == SCWARN_IMPORT_COLUMN_OVERFLOW ||
- nDocRetval == SCWARN_IMPORT_SHEET_OVERFLOW)
- bRet = true;
- }
- else if (nStylesRetval)
- nError = nStylesRetval;
- else if (nMetaRetval)
- nError = nMetaRetval;
- else if (nSettingsRetval)
- nError = nSettingsRetval;
- else
- bRet = true;
- }
+ bRet = true;
// set BuildId on XModel for later OLE object loading
if( xInfoSet.is() )
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index e85008d..7ed1836 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -441,13 +441,13 @@ bool ScDocShell::LoadXML( SfxMedium* pLoadMedium, const ::com::sun::star::uno::R
ScXMLImportWrapper aImport(*this, pLoadMedium, xStor);
- bool bRet(false);
+ bool bRet = false;
ErrCode nError = ERRCODE_NONE;
aDocument.EnableAdjustHeight(false);
- if (GetCreateMode() != SFX_CREATE_MODE_ORGANIZER)
- bRet = aImport.Import(false, nError);
+ if (GetCreateMode() == SFX_CREATE_MODE_ORGANIZER)
+ bRet = aImport.Import(ScXMLImportWrapper::STYLES, nError);
else
- bRet = aImport.Import(true, nError);
+ bRet = aImport.Import(ScXMLImportWrapper::ALL, nError);
if ( nError )
pLoadMedium->SetError( nError, OUString( OSL_LOG_PREFIX ) );
More information about the Libreoffice-commits
mailing list