[Libreoffice-commits] core.git: include/oox include/svx oox/source svx/source

Miklos Vajna vmiklos at collabora.co.uk
Fri Feb 3 08:25:08 UTC 2017


 include/oox/core/xmlfilterbase.hxx           |    6 +++++
 include/svx/dialogs.hrc                      |    3 +-
 oox/source/core/xmlfilterbase.cxx            |    8 ++++++-
 oox/source/drawingml/graphicshapecontext.cxx |    5 ++++
 oox/source/ppt/pptimport.cxx                 |   28 ++++++++++++++++++++++++++-
 svx/source/stbctrls/stbctrls.src             |    6 +++++
 6 files changed, 53 insertions(+), 3 deletions(-)

New commits:
commit ae828495be9c2ac5fdb4c1747ed7bdd51e5d87a7
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Feb 3 08:35:59 2017 +0100

    tdf#105707 PPTX import: warn when SmartArt is missing DrawingML fallback
    
    By the time DiagramGraphicDataContext::onCreateContext() completes, we
    know if there will be a DrawingML fallback for the SmartArt (called
    ExtDrawing in the code) or not.
    
    Warn about this case once at the end of the import when in interactive
    mode. Headless mode silently ignores the warning as expected.
    
    Change-Id: I2bfeeedcaa244f08d8a0c208167e79d7bb697e6d
    Reviewed-on: https://gerrit.libreoffice.org/33866
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/include/oox/core/xmlfilterbase.hxx b/include/oox/core/xmlfilterbase.hxx
index 7763fb3..2694858 100644
--- a/include/oox/core/xmlfilterbase.hxx
+++ b/include/oox/core/xmlfilterbase.hxx
@@ -233,6 +233,10 @@ public:
 
     bool isMSO2007Document() const;
 
+    /// Signal that an MSO 2007-created SmartArt was found, need to warn the
+    /// user about it.
+    void setMissingExtDrawing();
+
     void checkDocumentProperties(
             const css::uno::Reference<css::document::XDocumentProperties>& xDocProps);
 
@@ -258,6 +262,8 @@ private:
     sal_Int32 mnRelId;
     sal_Int32 mnMaxDocId;
     bool mbMSO2007;
+protected:
+    bool mbMissingExtDrawing;
 };
 
 } // namespace core
diff --git a/include/svx/dialogs.hrc b/include/svx/dialogs.hrc
index ee81ddd..4b7ecd6 100644
--- a/include/svx/dialogs.hrc
+++ b/include/svx/dialogs.hrc
@@ -1008,9 +1008,10 @@
 #define RID_SVXSTR_ERR_REPEAT_PASSWD     (SVX_OOO_BUILD_START + 8) // 1238
 #define RID_SVXBMP_ZOOM_PAGE             (SVX_OOO_BUILD_START + 9) // 1239
 #define RID_SVXSTR_FIT_SLIDE             (SVX_OOO_BUILD_START + 10) // 1240
+#define RID_SVXSTR_WARN_MISSING_SMARTART (SVX_OOO_BUILD_START + 11) // 1241
 
 // sidebar-related resources
-#define RID_SVX_SIDEBAR_BEGIN            (RID_SVX_START + 1241)
+#define RID_SVX_SIDEBAR_BEGIN            (RID_SVX_START + 1242)
 #define BMP_SPACE3                       (RID_SVX_SIDEBAR_BEGIN +  0)
 #define BMP_INDENT_HANG                  (RID_SVX_SIDEBAR_BEGIN +  1)
 #define BMP_NONE_ICON                    (RID_SVX_SIDEBAR_BEGIN + 21)
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx
index 5c5d5d8..5e4ae8e 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -199,7 +199,8 @@ XmlFilterBase::XmlFilterBase( const Reference< XComponentContext >& rxContext )
     mxImpl( new XmlFilterBaseImpl( rxContext ) ),
     mnRelId( 1 ),
     mnMaxDocId( 0 ),
-    mbMSO2007(false)
+    mbMSO2007(false),
+    mbMissingExtDrawing(false)
 {
 }
 
@@ -908,6 +909,11 @@ bool XmlFilterBase::isMSO2007Document() const
     return mbMSO2007;
 }
 
+void XmlFilterBase::setMissingExtDrawing()
+{
+    mbMissingExtDrawing = true;
+}
+
 OUString XmlFilterBase::getNamespaceURL(sal_Int32 nNSID) const
 {
     auto itr = mxImpl->mrNamespaceMap.maTransitionalNamespaceMap.find(nNSID);
diff --git a/oox/source/drawingml/graphicshapecontext.cxx b/oox/source/drawingml/graphicshapecontext.cxx
index 201a989..90d4818 100644
--- a/oox/source/drawingml/graphicshapecontext.cxx
+++ b/oox/source/drawingml/graphicshapecontext.cxx
@@ -271,6 +271,11 @@ ContextHandlerRef DiagramGraphicDataContext::onCreateContext( ::sal_Int32 aEleme
                  << "," << mpShapePtr->getSize().Width
                  << "," << mpShapePtr->getSize().Height
                  <<")");
+
+        // No DrawingML fallback, need to warn the user at the end.
+        if (mpShapePtr->getExtDrawings().empty())
+            getFilter().setMissingExtDrawing();
+
         break;
     }
     default:
diff --git a/oox/source/ppt/pptimport.cxx b/oox/source/ppt/pptimport.cxx
index 414a149..043d014 100644
--- a/oox/source/ppt/pptimport.cxx
+++ b/oox/source/ppt/pptimport.cxx
@@ -22,6 +22,13 @@
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/uno/XComponentContext.hpp>
 #include <osl/diagnose.h>
+#include <vcl/msgbox.hxx>
+#include <vcl/svapp.hxx>
+#include <svtools/sfxecode.hxx>
+#include <svtools/ehdl.hxx>
+#include <svtools/svtools.hrc>
+#include <tools/urlobj.hxx>
+#include <svx/dialogs.hrc>
 #include "oox/ppt/pptimport.hxx"
 #include "oox/drawingml/chart/chartconverter.hxx"
 #include "oox/dump/pptxdumper.hxx"
@@ -91,7 +98,26 @@ bool PowerPointImport::importDocument()
     OUString aFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc( "officeDocument" );
     FragmentHandlerRef xPresentationFragmentHandler( new PresentationFragmentHandler( *this, aFragmentPath ) );
     maTableStyleListPath = xPresentationFragmentHandler->getFragmentPathFromFirstTypeFromOfficeDoc( "tableStyles" );
-    return importFragment( xPresentationFragmentHandler );
+    bool bRet = importFragment(xPresentationFragmentHandler);
+
+    if (mbMissingExtDrawing)
+    {
+        // Construct a warning message.
+        INetURLObject aURL(getFileUrl());
+        SfxErrorContext aContext(ERRCTX_SFX_OPENDOC, aURL.getName(INetURLObject::LAST_SEGMENT), nullptr, RID_ERRCTX);
+        OUString aWarning;
+        aContext.GetString(ERRCODE_WARNING_MASK, aWarning);
+        aWarning += ":\n";
+        static ResMgr* pResMgr = ResMgr::CreateResMgr("svx", Application::GetSettings().GetUILanguageTag());
+        aWarning += ResId(RID_SVXSTR_WARN_MISSING_SMARTART, *pResMgr).toString();
+
+        // Show it.
+        WinBits eBits = WB_OK | WB_DEF_OK;
+        ScopedVclPtrInstance<WarningBox> pBox(nullptr, eBits, aWarning);
+        pBox->Execute();
+    }
+
+    return bRet;
 
 }
 
diff --git a/svx/source/stbctrls/stbctrls.src b/svx/source/stbctrls/stbctrls.src
index 36eb871..7d4f6b6d7 100644
--- a/svx/source/stbctrls/stbctrls.src
+++ b/svx/source/stbctrls/stbctrls.src
@@ -116,6 +116,12 @@ String RID_SVXSTR_DOC_LOAD
 String RID_SVXSTR_FIT_SLIDE
 {
     Text [ en-US ] = "Fit slide to current window.";
+}
+;
+
+String RID_SVXSTR_WARN_MISSING_SMARTART
+{
+    Text [ en-US ] = "Could not load all SmartArts. Saving in Microsoft Office 2010 or later would avoid this issue.";
 };
 
 String RID_SVXSTR_ZOOMTOOL_HINT


More information about the Libreoffice-commits mailing list