[Libreoffice-commits] core.git: 2 commits - filter/source sw/source

Maxim Monastirsky momonasmon at gmail.com
Thu Aug 28 15:02:00 PDT 2014


 filter/source/textfilterdetect/filterdetect.cxx |   16 +++++++---------
 sw/source/uibase/shells/annotsh.cxx             |    8 +++-----
 sw/source/uibase/shells/drwtxtex.cxx            |    8 +++-----
 3 files changed, 13 insertions(+), 19 deletions(-)

New commits:
commit 1298c1d13572c6fbfbabb813b2d6843368c6df1f
Author: Maxim Monastirsky <momonasmon at gmail.com>
Date:   Thu Aug 28 23:35:33 2014 +0300

    We don't check the extension for html
    
    ...since 86c6f18c2766aad43d6e3bfcf3530e40440ebca7,
    so move the related code and comment to the plain
    text scope.
    
    Change-Id: I501ebaba915ddaa3f5d1d8d2977d3ba70fb6071b

diff --git a/filter/source/textfilterdetect/filterdetect.cxx b/filter/source/textfilterdetect/filterdetect.cxx
index 1d29dd4..0b7ae1f 100644
--- a/filter/source/textfilterdetect/filterdetect.cxx
+++ b/filter/source/textfilterdetect/filterdetect.cxx
@@ -125,12 +125,6 @@ OUString SAL_CALL PlainTextFilterDetect::detect(uno::Sequence<beans::PropertyVal
 
     OUString aType = aMediaDesc.getUnpackedValueOrDefault(MediaDescriptor::PROP_TYPENAME(), OUString() );
     OUString aDocService = aMediaDesc.getUnpackedValueOrDefault(MediaDescriptor::PROP_DOCUMENTSERVICE(), OUString() );
-    OUString aUrl = aMediaDesc.getUnpackedValueOrDefault(MediaDescriptor::PROP_URL(), OUString() );
-
-    // Get the file name extension.
-    INetURLObject aParser(aUrl);
-    OUString aExt = aParser.getExtension(INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET);
-    aExt = aExt.toAsciiLowerCase();
 
     if ((aType == "generic_HTML") || (aType == "calc_HTML"))
     {
@@ -138,9 +132,6 @@ OUString SAL_CALL PlainTextFilterDetect::detect(uno::Sequence<beans::PropertyVal
         if (!xInStream.is() || !IsHTMLStream(xInStream))
             return OUString();
 
-        // Decide which filter to use based on the document service first,
-        // then on extension if that's not available.
-
         if ((aDocService == CALC_DOCSERVICE) || (aType == "calc_HTML"))
             aMediaDesc[MediaDescriptor::PROP_FILTERNAME()] <<= OUString(CALC_HTML_FILTER);
         else if (aDocService == WRITER_DOCSERVICE)
@@ -151,6 +142,13 @@ OUString SAL_CALL PlainTextFilterDetect::detect(uno::Sequence<beans::PropertyVal
 
     else if (aType == "generic_Text")
     {
+        // Get the file name extension.
+        INetURLObject aParser(aMediaDesc.getUnpackedValueOrDefault(MediaDescriptor::PROP_URL(), OUString() ) );
+        OUString aExt = aParser.getExtension(INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET);
+        aExt = aExt.toAsciiLowerCase();
+
+        // Decide which filter to use based on the document service first,
+        // then on extension if that's not available.
         if (aDocService == CALC_DOCSERVICE)
             aMediaDesc[MediaDescriptor::PROP_FILTERNAME()] <<= OUString(CALC_TEXT_FILTER);
         else if (aDocService == WRITER_DOCSERVICE)
commit 65f70e0d57be14c55063709e86f252f84dab087b
Author: Maxim Monastirsky <momonasmon at gmail.com>
Date:   Thu Aug 28 23:05:47 2014 +0300

    Remove these intermediate variables
    
    ...and pointless subsequent null check.
    
    Change-Id: I50721a17eeec2f9ee0b515507cdda4ed05ddcae5

diff --git a/sw/source/uibase/shells/annotsh.cxx b/sw/source/uibase/shells/annotsh.cxx
index ad5b11c..5c74c35 100644
--- a/sw/source/uibase/shells/annotsh.cxx
+++ b/sw/source/uibase/shells/annotsh.cxx
@@ -466,9 +466,9 @@ void SwAnnotationShell::Exec( SfxRequest &rReq )
         case SID_CHAR_DLG:
         {
             const SfxItemSet* pArgs = rReq.GetArgs();
-            const SfxPoolItem* pItem = 0;
+            const SfxStringItem* pItem = 0;
             if (nSlot == SID_CHAR_DLG)
-                pItem = pArgs->GetItem(FN_PARAM_1, false, TYPE(SfxStringItem) );
+                pItem = static_cast< const SfxStringItem* >(pArgs->GetItem(FN_PARAM_1, false, TYPE(SfxStringItem) ) );
 
             if( !pArgs || pItem )
             {
@@ -495,9 +495,7 @@ void SwAnnotationShell::Exec( SfxRequest &rReq )
                 }
                 else if (pItem)
                 {
-                    const SfxStringItem* pStringItem = static_cast< const SfxStringItem* >(pItem);
-                    if (pStringItem)
-                        pDlg->SetCurPageId(OUStringToOString(pStringItem->GetValue(), RTL_TEXTENCODING_UTF8));
+                    pDlg->SetCurPageId(OUStringToOString(pItem->GetValue(), RTL_TEXTENCODING_UTF8));
                 }
 
                 sal_uInt16 nRet = pDlg->Execute();
diff --git a/sw/source/uibase/shells/drwtxtex.cxx b/sw/source/uibase/shells/drwtxtex.cxx
index 907dc5a..84b1fa5 100644
--- a/sw/source/uibase/shells/drwtxtex.cxx
+++ b/sw/source/uibase/shells/drwtxtex.cxx
@@ -298,9 +298,9 @@ void SwDrawTextShell::Execute( SfxRequest &rReq )
         case SID_CHAR_DLG_FOR_PARAGRAPH:
         {
             const SfxItemSet* pArgs = rReq.GetArgs();
-            const SfxPoolItem* pItem = 0;
+            const SfxStringItem* pItem = 0;
             if (nSlot == SID_CHAR_DLG)
-                pItem = pArgs->GetItem(FN_PARAM_1, false, TYPE(SfxStringItem) );
+                pItem = static_cast< const SfxStringItem* >(pArgs->GetItem(FN_PARAM_1, false, TYPE(SfxStringItem) ) );
 
             if( !pArgs || pItem )
             {
@@ -338,9 +338,7 @@ void SwDrawTextShell::Execute( SfxRequest &rReq )
                 }
                 else if (pItem)
                 {
-                    const SfxStringItem* pStringItem = static_cast< const SfxStringItem* >(pItem);
-                    if (pStringItem)
-                        pDlg->SetCurPageId(OUStringToOString(pStringItem->GetValue(), RTL_TEXTENCODING_UTF8));
+                    pDlg->SetCurPageId(OUStringToOString(pItem->GetValue(), RTL_TEXTENCODING_UTF8));
                 }
 
                 sal_uInt16 nRet = pDlg->Execute();


More information about the Libreoffice-commits mailing list