summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2013-05-15 17:09:16 +0200
committerMichael Stahl <mstahl@redhat.com>2013-05-15 18:41:58 +0200
commit3905bd92b038374d22e4ff9f74480decb116d727 (patch)
tree61602d069a6549ee9fe8f16716079cd558098584
parent3e5d7723e038ccfea812b941aea6fff1078579f7 (diff)
factor out SvXMLImport::IsOOoXML()
Change-Id: I9ccfe565bde1112f9f3cb8c666e901bf121862dc
-rw-r--r--include/xmloff/xmlimp.hxx1
-rw-r--r--xmloff/source/core/xmlimp.cxx33
2 files changed, 29 insertions, 5 deletions
diff --git a/include/xmloff/xmlimp.hxx b/include/xmloff/xmlimp.hxx
index 750f56725aaf..d8a72d516b82 100644
--- a/include/xmloff/xmlimp.hxx
+++ b/include/xmloff/xmlimp.hxx
@@ -338,6 +338,7 @@ public:
bool IsTableShapeSupported() const { return mbIsTableShapeSupported; }
OUString GetODFVersion() const;
+ bool IsOOoXML() const; // legacy non-ODF format?
/**
* Record an error condition that occurred during import. The
diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx
index 1b0893356cd7..d76eefe95d0d 100644
--- a/xmloff/source/core/xmlimp.cxx
+++ b/xmloff/source/core/xmlimp.cxx
@@ -270,6 +270,8 @@ public:
OUString aODFVersion;
+ bool mbIsOOoXML;
+
// Boolean, indicating that position attributes
// of shapes are given in horizontal left-to-right layout. This is the case
// for the OpenOffice.org file format. (#i28749#)
@@ -289,7 +291,7 @@ public:
, hMathFontConv( 0 )
, mbOwnGraphicResolver( false )
, mbOwnEmbeddedResolver( false )
- , mStreamName()
+ , mbIsOOoXML(false)
// Convert drawing object positions from OOo file format to OASIS (#i28749#)
, mbShapePositionInHoriL2R( sal_False )
, mbTextDocInOOoFileFormat( sal_False )
@@ -831,7 +833,25 @@ void SAL_CALL SvXMLImport::setTargetDocument( const uno::Reference< lang::XCompo
mxModel = uno::Reference< frame::XModel >::query( xDoc );
if( !mxModel.is() )
throw lang::IllegalArgumentException();
- if (mxModel.is() && !mxEventListener.is())
+
+ try
+ {
+ uno::Reference<document::XStorageBasedDocument> const xSBDoc(mxModel,
+ uno::UNO_QUERY_THROW);
+ uno::Reference<embed::XStorage> const xStor(
+ xSBDoc->getDocumentStorage());
+ if (xStor.is())
+ {
+ mpImpl->mbIsOOoXML =
+ ::comphelper::OStorageHelper::GetXStorageFormat(xStor)
+ < SOFFICE_FILEFORMAT_8;
+ }
+ }
+ catch (uno::Exception const& e)
+ {
+ SAL_WARN("xmloff.core", "exception caught: " << e.Message);
+ }
+ if (!mxEventListener.is())
{
mxEventListener.set(new SvXMLImportEventListener(this));
mxModel->addEventListener(mxEventListener);
@@ -1577,9 +1597,7 @@ sal_Bool SvXMLImport::IsODFVersionConsistent( const OUString& aODFVersion )
uno::Reference< beans::XPropertySet > xStorProps( xStor, uno::UNO_QUERY_THROW );
// the check should be done only for OASIS format
- OUString aMediaType;
- xStorProps->getPropertyValue( "MediaType" ) >>= aMediaType;
- if ( ::comphelper::OStorageHelper::GetXStorageFormat( xStor ) >= SOFFICE_FILEFORMAT_8 )
+ if (!IsOOoXML())
{
sal_Bool bRepairPackage = sal_False;
try
@@ -1846,6 +1864,11 @@ OUString SvXMLImport::GetODFVersion() const
return mpImpl->aODFVersion;
}
+bool SvXMLImport::IsOOoXML() const
+{
+ return mpImpl->mbIsOOoXML;
+}
+
// xml:id for RDF metadata
void SvXMLImport::SetXmlId(uno::Reference<uno::XInterface> const & i_xIfc,
OUString const & i_rXmlId)