tdf#93005, tdf#100611, remove the incomplete ODC export feature

Change-Id: I96a3882cd412ea5d993971df7e20b1fd8da73642
Reviewed-on: https://gerrit.libreoffice.org/64283
Tested-by: Jenkins
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
(cherry picked from commit d543e8dfd3d8ae718e29304a155e1cf70d08325d)
Reviewed-on: https://gerrit.libreoffice.org/64311
diff --git a/filter/source/config/fragments/filters/chart8.xcu b/filter/source/config/fragments/filters/chart8.xcu
index 3c33792..6bcfbd8 100644
--- a/filter/source/config/fragments/filters/chart8.xcu
+++ b/filter/source/config/fragments/filters/chart8.xcu
@@ -16,7 +16,7 @@
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
    <node oor:name="chart8" oor:op="replace">
        <prop oor:name="Flags"><value>IMPORT EXPORT OWN DEFAULT PREFERRED ENCRYPTION</value></prop>
        <prop oor:name="Flags"><value>IMPORT EXPORT OWN DEFAULT NOTINFILEDIALOG NOTINCHOOSER PREFERRED ENCRYPTION</value></prop>
        <prop oor:name="UIComponent"/>
        <prop oor:name="FilterService"><value>com.sun.star.comp.chart2.XMLFilter</value></prop>
        <prop oor:name="UserData"><value>XML</value></prop>
diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx
index af6c050..0f2c09a 100644
--- a/include/sfx2/objsh.hxx
+++ b/include/sfx2/objsh.hxx
@@ -604,7 +604,7 @@ public:
     */
    void            SetupStorage(
                        const css::uno::Reference< css::embed::XStorage >& xStorage,
                        sal_Int32 nVersion, bool bTemplate, bool bChart = false ) const;
                        sal_Int32 nVersion, bool bTemplate ) const;

    css::uno::Reference< css::embed::XStorage > const & GetStorage();

diff --git a/include/svx/svxids.hrc b/include/svx/svxids.hrc
index acd2df6..5ccb79d 100644
--- a/include/svx/svxids.hrc
+++ b/include/svx/svxids.hrc
@@ -267,7 +267,6 @@ class SfxStringItem;
#define SID_OBJECT_ALIGN_UP                             ( SID_SVX_START + 134 )
#define SID_OBJECT_ALIGN_MIDDLE                         ( SID_SVX_START + 135 )
#define SID_OBJECT_ALIGN_DOWN                           ( SID_SVX_START + 136 )
#define SID_INSERT_DIAGRAM_FROM_FILE                    ( SID_SVX_START + 139 )
#define SID_INSERT_DIAGRAM                              ( SID_SVX_START + 140 )
#define SID_INSERT_TABLE                                ( SID_SVX_START + 141 )
#define SID_ATTRIBUTES_AREA                             ( SID_SVX_START + 142 )
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
index 69856aa..e13acb9 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
@@ -2549,14 +2549,6 @@
          <value>1</value>
        </prop>
      </node>
      <node oor:name=".uno:InsertObjectChartFromFile" oor:op="replace">
        <prop oor:name="Label" oor:type="xs:string">
          <value xml:lang="en-US">Chart from File...</value>
        </prop>
        <prop oor:name="Properties" oor:type="xs:int">
          <value>1</value>
        </prop>
      </node>
      <node oor:name=".uno:DefaultBullet" oor:op="replace">
        <prop oor:name="Label" oor:type="xs:string">
          <value xml:lang="en-US">Bullets</value>
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index fe0e436..82bd3ba 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -349,7 +349,6 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
    sc/source/filter/xml/xmltabi \
    sc/source/filter/xml/xmltransformationi \
    sc/source/filter/xml/xmlwrap \
    sc/source/filter/chart/chart_imp \
    sc/source/filter/importfilterdata \
    sc/source/ui/Accessibility/AccessibilityHints \
    sc/source/ui/Accessibility/AccessibleCell \
diff --git a/sc/sdi/tabvwsh.sdi b/sc/sdi/tabvwsh.sdi
index 7f33a24..4f9b451 100644
--- a/sc/sdi/tabvwsh.sdi
+++ b/sc/sdi/tabvwsh.sdi
@@ -125,7 +125,6 @@ interface BaseSelection
    SID_FM_CREATE_CONTROL   [ ExecMethod = ExecDraw ; ]
    SID_LINKS               [ ExecMethod = ExecDrawIns; StateMethod = GetDrawInsState; ]
    SID_DRAW_CHART          [ ExecMethod = ExecDraw; StateMethod = GetDrawState; ]
    SID_INSERT_DIAGRAM_FROM_FILE [ ExecMethod = ExecDrawIns; StateMethod = GetDrawState; ]
    SID_FM_CREATE_FIELDCONTROL [ ExecMethod = ExecDrawIns ; ]

    // } insert objects
diff --git a/sc/source/filter/chart/chart_imp.cxx b/sc/source/filter/chart/chart_imp.cxx
deleted file mode 100644
index da76b4a..0000000
--- a/sc/source/filter/chart/chart_imp.cxx
+++ /dev/null
@@ -1,32 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#include <sfx2/docfile.hxx>
#include <xmlwrap.hxx>

#include <com/sun/star/document/XStorageBasedDocument.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>

using namespace com::sun::star;

ScXMLChartExportWrapper::ScXMLChartExportWrapper( css::uno::Reference< css::frame::XModel > const & xModel, SfxMedium& rMed ):
    mxModel(xModel),
    mrMedium(rMed)
{

}

void ScXMLChartExportWrapper::Export()
{
    if ( !mxStorage.is() )
        mxStorage = mrMedium.GetOutputStorage();

    uno::Reference< document::XStorageBasedDocument>(mxModel, uno::UNO_QUERY_THROW)->storeToStorage(mxStorage, uno::Sequence< beans::PropertyValue >() );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 6e65890..608e995 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -580,28 +580,6 @@ bool ScDocShell::SaveXML( SfxMedium* pSaveMedium, const css::uno::Reference< css
    return bRet;
}

bool ScDocShell::SaveCurrentChart( SfxMedium& rMedium )
{
    try
    {

        uno::Reference< lang::XComponent > xCurrentComponent = frame::Desktop::create( comphelper::getProcessComponentContext() )->getCurrentComponent();

        uno::Reference< frame::XStorable2 > xStorable( xCurrentComponent, uno::UNO_QUERY_THROW );

        uno::Reference< frame::XModel > xChartDoc ( xCurrentComponent, uno::UNO_QUERY_THROW );

        ScXMLChartExportWrapper aExport( xChartDoc, rMedium );
        aExport.Export();
        return true;
    }
    catch(...)
    {
        SAL_WARN("sc", "exception thrown while saving chart. Bug!!!");
        return false;
    }
}

bool ScDocShell::Load( SfxMedium& rMedium )
{
    LoadMediumGuard aLoadGuard(&m_aDocument);
@@ -1846,21 +1824,10 @@ bool ScDocShell::SaveAs( SfxMedium& rMedium )

    PrepareSaveGuard aPrepareGuard( *this);

    OUString aFltName = rMedium.GetFilter()->GetFilterName();
    bool bChartExport = aFltName.indexOf("chart8") != -1;

    //  wait cursor is handled with progress bar
    bool bRet = false;
    if(!bChartExport)
    {
        bRet = SfxObjectShell::SaveAs( rMedium );
        if (bRet)
            bRet = SaveXML( &rMedium, nullptr );
    }
    else
    {
        bRet = SaveCurrentChart( rMedium );
    }
    bool bRet = SfxObjectShell::SaveAs( rMedium );
    if (bRet)
        bRet = SaveXML( &rMedium, nullptr );

    return bRet;
}
diff --git a/sc/source/ui/drawfunc/fuins2.cxx b/sc/source/ui/drawfunc/fuins2.cxx
index cebad75..dc01065 100644
--- a/sc/source/ui/drawfunc/fuins2.cxx
+++ b/sc/source/ui/drawfunc/fuins2.cxx
@@ -733,41 +733,4 @@ FuInsertChart::FuInsertChart(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawV
    // BM/IHA --
}

FuInsertChartFromFile::FuInsertChartFromFile(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawView* pViewP,
           SdrModel* pDoc, const SfxRequest& rReq, const OUString& rURL):
    FuPoor(rViewSh, pWin, pViewP, pDoc, rReq)
{
    uno::Reference< io::XInputStream > xStorage = comphelper::OStorageHelper::GetInputStreamFromURL(
            rURL, comphelper::getProcessComponentContext());

    comphelper::EmbeddedObjectContainer& rObjContainer =
        rViewShell.GetObjectShell()->GetEmbeddedObjectContainer();

    OUString aName;
    uno::Reference< embed::XEmbeddedObject > xObj = rObjContainer.InsertEmbeddedObject( xStorage, aName );

    const sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
    awt::Size aSz = xObj->getVisualAreaSize( nAspect );
    Size aSize( aSz.Width, aSz.Height );

    ScRange aPositionRange = rViewSh.GetViewData().GetCurPos();
    Point aStart = rViewSh.GetChartInsertPos( aSize, aPositionRange );
    tools::Rectangle aRect (aStart, aSize);
    SdrOle2Obj* pObj = new SdrOle2Obj(
        *pDoc, // TTTT should be reference
        svt::EmbeddedObjectRef(xObj, nAspect),
        aName,
        aRect);

    SdrPageView* pPV = pView->GetSdrPageView();

    // use the page instead of the view to insert, so no undo action is created yet
    SdrPage* pInsPage = pPV->GetPage();
    pInsPage->InsertObject( pObj );
    pView->UnmarkAllObj();
    pView->MarkObj( pObj, pPV );

    rViewShell.ActivateObject(pObj, embed::EmbedVerbs::MS_OLEVERB_SHOW);
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx
index 2870fc3..b6c5239 100644
--- a/sc/source/ui/inc/docsh.hxx
+++ b/sc/source/ui/inc/docsh.hxx
@@ -137,8 +137,6 @@ class SC_DLLPUBLIC ScDocShell final: public SfxObjectShell, public SfxListener
    SAL_DLLPRIVATE bool          SaveXML( SfxMedium* pMedium, const css::uno::Reference< css::embed::XStorage >& );
    SAL_DLLPRIVATE SCTAB         GetSaveTab();

    SAL_DLLPRIVATE static bool   SaveCurrentChart( SfxMedium& rMedium );

    SAL_DLLPRIVATE ErrCode       DBaseImport( const OUString& rFullFileName, rtl_TextEncoding eCharSet,
                                             std::map<SCCOL, ScColWidthParam>& aColWidthParam, ScFlatBoolRowSegments& rRowHeightsRecalc );
    SAL_DLLPRIVATE ErrCode       DBaseExport(
diff --git a/sc/source/ui/inc/fuinsert.hxx b/sc/source/ui/inc/fuinsert.hxx
index 31a1cb0..863aa6d 100644
--- a/sc/source/ui/inc/fuinsert.hxx
+++ b/sc/source/ui/inc/fuinsert.hxx
@@ -45,13 +45,6 @@ public:
           SdrModel* pDoc, SfxRequest& rReq);
};

class FuInsertChartFromFile : public FuPoor
{
public:
    FuInsertChartFromFile(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawView* pView,
           SdrModel* pDoc, const SfxRequest& rReq, const OUString& rURL);
};

class FuInsertMedia : public FuPoor
{
public:
diff --git a/sc/source/ui/view/tabvwshb.cxx b/sc/source/ui/view/tabvwshb.cxx
index 80984cf..5ea064f 100644
--- a/sc/source/ui/view/tabvwshb.cxx
+++ b/sc/source/ui/view/tabvwshb.cxx
@@ -369,25 +369,6 @@ void ScTabViewShell::ExecDrawIns(SfxRequest& rReq)
                break;
            }

        case SID_INSERT_DIAGRAM_FROM_FILE:
            try
            {
                sfx2::FileDialogHelper aDlg(ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
                        FileDialogFlags::NONE, "com.sun.star.chart2.ChartDocument",
                        SfxFilterFlags::NONE, SfxFilterFlags::NONE, pWin ? pWin->GetFrameWeld() : nullptr);
                if(aDlg.Execute() == ERRCODE_NONE )
                {
                    INetURLObject aURLObj( aDlg.GetPath() );
                    OUString aURL = aURLObj.GetURLNoPass();
                    FuInsertChartFromFile(*this, pWin, pView, pDrModel, rReq, aURL);
                }
            }
            catch (const uno::Exception& e)
            {
                SAL_WARN( "sc", "Cannot Insert Chart: " << e);
            }
            break;

        case SID_OBJECTRESIZE:
            {
                //         the server would like to change the client size
diff --git a/sc/uiconfig/scalc/menubar/menubar.xml b/sc/uiconfig/scalc/menubar/menubar.xml
index 046e6e16..dd6d9a9 100644
--- a/sc/uiconfig/scalc/menubar/menubar.xml
+++ b/sc/uiconfig/scalc/menubar/menubar.xml
@@ -217,7 +217,6 @@
                <menu:menupopup>
                    <menu:menuitem menu:id=".uno:InsertObjectStarMath"/>
                    <menu:menuitem menu:id=".uno:InsertObject"/>
                    <menu:menuitem menu:id=".uno:InsertObjectChartFromFile"/>
                </menu:menupopup>
            </menu:menu>
            <menu:menu menu:id=".uno:ShapesMenu">
diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx
index 1f75ff2..c9692ca 100644
--- a/sfx2/source/doc/guisaveas.cxx
+++ b/sfx2/source/doc/guisaveas.cxx
@@ -355,27 +355,6 @@ ModelData_Impl::ModelData_Impl( SfxStoringHelper& aOwner,
, m_bRecommendReadOnly( false )
{
    CheckInteractionHandler();
    try
    {
        uno::Reference< lang::XComponent > xCurrentComponent = frame::Desktop::create( comphelper::getProcessComponentContext() )->getCurrentComponent();
        if (aOwner.GetModuleManager()->identify(xCurrentComponent) == "com.sun.star.chart2.ChartDocument")
        {
            // let us switch the model and set the xStorable and
            // XStorable2 to the old model.
            // This is an ugly hack because we have no SfxObjectShell for chart2 yet.
            // We need SfxObjectShell for the heavy work around ODF document creation
            // because chart2 only writes the basic stream out.
            // In future in might make sense to implement a full scale object shell in
            // chart2 and make chart2 an own program.
            m_xModel.set(xCurrentComponent, uno::UNO_QUERY_THROW );
            m_xStorable.set(xModel, uno::UNO_QUERY_THROW );
            m_xStorable2.set(xModel, uno::UNO_QUERY_THROW );
        }
    }
    catch(...)
    {
        // we don't want to pass on any errors;
    }
}


diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index 78f00ad..f1ae5b0 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -300,38 +300,9 @@ SvGlobalName const & SfxObjectShell::GetClassName() const
    return GetFactory().GetClassId();
}

namespace {

/**
 * Chart2 does not have an Object shell, so handle this here for now
 * If we ever implement a full scale object shell in chart2 move it there
 */
SotClipboardFormatId GetChartVersion( sal_Int32 nVersion, bool bTemplate )
{
    if( nVersion == SOFFICE_FILEFORMAT_60)
    {
        return SotClipboardFormatId::STARCHART_60;
    }
    else if( nVersion == SOFFICE_FILEFORMAT_8)
    {
        if (bTemplate)
        {
            SAL_WARN("sfx.doc", "no chart template support yet");
            return SotClipboardFormatId::STARCHART_8;
        }
        else
            return SotClipboardFormatId::STARCHART_8;
    }

    SAL_WARN("sfx.doc", "unsupported version");
    return SotClipboardFormatId::NONE;
}

}


void SfxObjectShell::SetupStorage( const uno::Reference< embed::XStorage >& xStorage,
                                   sal_Int32 nVersion, bool bTemplate, bool bChart ) const
                                   sal_Int32 nVersion, bool bTemplate ) const
{
    uno::Reference< beans::XPropertySet > xProps( xStorage, uno::UNO_QUERY );

@@ -339,14 +310,9 @@ void SfxObjectShell::SetupStorage( const uno::Reference< embed::XStorage >& xSto
    {
        SotClipboardFormatId nClipFormat = SotClipboardFormatId::NONE;

        if(!bChart)
        {
            SvGlobalName aName;
            OUString aFullTypeName, aShortTypeName, aAppName;
            FillClass( &aName, &nClipFormat, &aAppName, &aFullTypeName, &aShortTypeName, nVersion, bTemplate );
        }
        else
            nClipFormat = GetChartVersion(nVersion, bTemplate);
        SvGlobalName aName;
        OUString aFullTypeName, aShortTypeName, aAppName;
        FillClass( &aName, &nClipFormat, &aAppName, &aFullTypeName, &aShortTypeName, nVersion, bTemplate );

        if ( nClipFormat != SotClipboardFormatId::NONE )
        {
@@ -3069,12 +3035,7 @@ bool SfxObjectShell::SaveAsOwnFormat( SfxMedium& rMedium )
        const bool bTemplate = rMedium.GetFilter()->IsOwnTemplateFormat()
            && nVersion > SOFFICE_FILEFORMAT_60;

        std::shared_ptr<const SfxFilter> pFilter = rMedium.GetFilter();
        bool bChart = false;
        if(pFilter->GetName() == "chart8")
            bChart = true;

        SetupStorage( xStorage, nVersion, bTemplate, bChart );
        SetupStorage( xStorage, nVersion, bTemplate );
#if HAVE_FEATURE_SCRIPTING
        if ( HasBasic() )
        {
diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi
index d38f9d7..bf58e9e 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -4789,25 +4789,6 @@ SfxVoidItem InsertObjectChart SID_INSERT_DIAGRAM
]


SfxVoidItem InsertObjectChartFromFile SID_INSERT_DIAGRAM_FROM_FILE
()
[
    AutoUpdate = FALSE,
    FastCall = FALSE,
    ReadOnlyDoc = FALSE,
    Toggle = FALSE,
    Container = FALSE,
    RecordAbsolute = FALSE,
    RecordPerSet;
    Asynchron;

    AccelConfig = TRUE,
    MenuConfig = TRUE,
    ToolBoxConfig = TRUE,
    GroupId = SfxGroupId::Insert;
]


SfxVoidItem InsertSymbol SID_CHARMAP
(SfxStringItem Symbols SID_CHARMAP, SfxStringItem FontName SID_ATTR_SPECIALCHAR)
[