From 0946e2da2a310d9cfb5feeed94a6b2ad9f829751 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 16 Dec 2014 14:31:16 +0100 Subject: LOK: let doc_getDocumentType() use supportsService() css::frame::XModel::getArgs() may or may not return a Sequence that contains a DocumentService key, while css::lang::XServiceInfo::supportsService() can always determine the document type. This fixes the problem that doc_getDocumentType() returned LOK_DOCTYPE_OTHER for Writer documents on Android. Change-Id: I380d59a963553fb30a3eb20fbe84dcfc6a1bbd61 --- desktop/source/lib/init.cxx | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) (limited to 'desktop') diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 9910fd151f65..40cc46784175 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -28,7 +28,6 @@ #include #include -#include #include #include #include @@ -423,38 +422,27 @@ static LibreOfficeKitDocumentType doc_getDocumentType (LibreOfficeKitDocument* p try { - uno::Reference xDocument(pDocument->mxComponent, uno::UNO_QUERY_THROW); - uno::Sequence aSequence = xDocument->getArgs(); + uno::Reference xDocument(pDocument->mxComponent, uno::UNO_QUERY_THROW); - MediaDescriptor aMediaDescriptor(aSequence); - OUString sPropertyName = MediaDescriptor::PROP_DOCUMENTSERVICE(); - OUString aDocumentService = aMediaDescriptor.getUnpackedValueOrDefault(sPropertyName, OUString()); - - if (aDocumentService.isEmpty()) - { - gImpl->maLastExceptionMsg = "unknown document type"; - return LOK_DOCTYPE_OTHER; - } - - if (aDocumentService == "com.sun.star.sheet.SpreadsheetDocument") + if (xDocument->supportsService("com.sun.star.sheet.SpreadsheetDocument")) { return LOK_DOCTYPE_SPREADSHEET; } - else if (aDocumentService == "com.sun.star.presentation.PresentationDocument") + else if (xDocument->supportsService("com.sun.star.presentation.PresentationDocument")) { return LOK_DOCTYPE_PRESENTATION; } - else if (aDocumentService == "com.sun.star.drawing.DrawingDocument") + else if (xDocument->supportsService("com.sun.star.drawing.DrawingDocument")) { return LOK_DOCTYPE_DRAWING; } - else if (aDocumentService == "com.sun.star.text.TextDocument") + else if (xDocument->supportsService("com.sun.star.text.TextDocument")) { return LOK_DOCTYPE_TEXT; } else { - gImpl->maLastExceptionMsg = "unknown document mapping"; + gImpl->maLastExceptionMsg = "unknown document type"; } } catch (const uno::Exception& exception) -- cgit