[Libreoffice-commits] core.git: desktop/source

Miklos Vajna vmiklos at collabora.co.uk
Tue Dec 16 06:00:19 PST 2014


 desktop/source/lib/init.cxx |   24 ++++++------------------
 1 file changed, 6 insertions(+), 18 deletions(-)

New commits:
commit 0946e2da2a310d9cfb5feeed94a6b2ad9f829751
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Dec 16 14:31:16 2014 +0100

    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

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 9910fd1..40cc467 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -28,7 +28,6 @@
 #include <comphelper/processfactory.hxx>
 
 #include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/frame/XModel.hpp>
 #include <com/sun/star/frame/Desktop.hpp>
 #include <com/sun/star/frame/XStorable.hpp>
 #include <com/sun/star/lang/Locale.hpp>
@@ -423,38 +422,27 @@ static LibreOfficeKitDocumentType doc_getDocumentType (LibreOfficeKitDocument* p
 
     try
     {
-        uno::Reference<frame::XModel> xDocument(pDocument->mxComponent, uno::UNO_QUERY_THROW);
-        uno::Sequence<beans::PropertyValue> aSequence = xDocument->getArgs();
+        uno::Reference<lang::XServiceInfo> 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)


More information about the Libreoffice-commits mailing list