[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - 2 commits - oovbaapi/ooo svx/source sw/source

Tor Lillqvist (via logerrit) logerrit at kemper.freedesktop.org
Tue Mar 26 14:23:20 UTC 2019


 oovbaapi/ooo/vba/word/XDocument.idl |    3 
 svx/source/svdraw/svdograf.cxx      |    4 +
 sw/source/ui/vba/vbadocument.cxx    |  112 ++++++++++++++++++++++++++++++++++++
 sw/source/ui/vba/vbadocument.hxx    |    2 
 4 files changed, 121 insertions(+)

New commits:
commit c6056a8f913a161199a2833b6afa3735680a1c4d
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Tue Mar 26 16:16:44 2019 +0200
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Tue Mar 26 16:16:44 2019 +0200

    Stopgap measure to fix compilation error on Windows
    
    Somehow <windows.h> gets included here and it #defines GetMetaFile as
    GetMetaFileA. Undo that.
    
    Change-Id: Ia99c077ef7b3f845efabaf286f12e2688fe4a132

diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index 5829d508f687..df190f4861ee 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -1098,6 +1098,10 @@ GDIMetaFile SdrGrafObj::getMetafileFromEmbeddedVectorGraphicData() const
     return aRetval;
 }
 
+#ifdef _WIN32
+#undef GetMetaFile
+#endif
+
 GDIMetaFile SdrGrafObj::GetMetaFile(GraphicType &rGraphicType) const
 {
     if (isEmbeddedVectorGraphicData())
commit 0de4f894cf23635db639a64fcac2e77b8560c122
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Tue Mar 26 15:05:02 2019 +0200
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Tue Mar 26 15:53:18 2019 +0200

    Add SaveAs2000() and SaveAs() to ooo.vba.word.XDocument and implement
    
    Change-Id: If7e45e2f791a7806e6cf8e7fc9693e19e87d2dbb

diff --git a/oovbaapi/ooo/vba/word/XDocument.idl b/oovbaapi/ooo/vba/word/XDocument.idl
index 9259fc9fa4a9..888287b34e1b 100644
--- a/oovbaapi/ooo/vba/word/XDocument.idl
+++ b/oovbaapi/ooo/vba/word/XDocument.idl
@@ -61,6 +61,9 @@ interface XDocument
     void ClosePrintPreview();
     any Revisions( [in] any index );
     any Frames( [in] any index );
+    void SaveAs2000( [in] any FileName, [in] any FileFormat, [in] any LockComments, [in] any Password, [in] any AddToRecentFiles, [in] any WritePassword, [in] any ReadOnlyRecommended, [in] any EmbedTrueTypeFonts, [in] any SaveNativePictureFormat, [in] any SaveFormsData, [in] any SaveAsAOCELetter );
+    void SaveAs( [in] any FileName, [in] any FileFormat, [in] any LockComments, [in] any Password, [in] any AddToRecentFiles, [in] any WritePassword, [in] any ReadOnlyRecommended, [in] any EmbedTrueTypeFonts, [in] any SaveNativePictureFormat, [in] any SaveFormsData, [in] any SaveAsAOCELetter, [in] any Encoding, [in] any InsertLineBreaks, [in] any AllowSubstitutions, [in] any LineEnding, [in] any AddBiDiMarks );
+
 };
 
 }; }; };
diff --git a/sw/source/ui/vba/vbadocument.cxx b/sw/source/ui/vba/vbadocument.cxx
index eb3f5c2d011d..9b44c92c9176 100644
--- a/sw/source/ui/vba/vbadocument.cxx
+++ b/sw/source/ui/vba/vbadocument.cxx
@@ -33,9 +33,13 @@
 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
 #include <com/sun/star/drawing/XControlShape.hpp>
 #include <com/sun/star/form/XFormsSupplier.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
 #include <com/sun/star/document/XRedlinesSupplier.hpp>
+#include <com/sun/star/util/thePathSettings.hpp>
 #include <ooo/vba/XControlProvider.hpp>
 #include <ooo/vba/word/WdProtectionType.hpp>
+#include <ooo/vba/word/WdSaveFormat.hpp>
+#include <ooo/vba/word/XApplication.hpp>
 #include <ooo/vba/word/XDocumentOutgoing.hpp>
 
 #include <vbahelper/helperdecl.hxx>
@@ -450,6 +454,114 @@ SwVbaDocument::Frames( const uno::Any& index )
     return uno::makeAny( xCol );
 }
 
+namespace {
+
+bool setFilterPropsFromFormat( sal_Int32 nFormat, uno::Sequence< beans::PropertyValue >& rProps )
+{
+    bool bRes = false;
+    for ( sal_Int32 index = 0; index < rProps.getLength(); ++index )
+    {
+        if ( rProps[ index ].Name == "FilterName" )
+        {
+            switch( nFormat )
+            {
+                case word::WdSaveFormat::wdFormatDocument:
+                    rProps[ index ].Value <<= OUString("MS Word 97");
+                    break;
+                // Just save all the text formats as "Text"
+                case word::WdSaveFormat::wdFormatDOSText:
+                case word::WdSaveFormat::wdFormatDOSTextLineBreaks:
+                case word::WdSaveFormat::wdFormatEncodedText:
+                case word::WdSaveFormat::wdFormatText:
+                case word::WdSaveFormat::wdFormatTextLineBreaks:
+                    rProps[ index ].Value <<= OUString("Text");
+                    break;
+                case word::WdSaveFormat::wdFormatFilteredHTML:
+                case word::WdSaveFormat::wdFormatHTML:
+                    rProps[ index ].Value <<= OUString("HTML");
+                    break;
+                case word::WdSaveFormat::wdFormatRTF:
+                    rProps[ index ].Value <<= OUString("Rich Text Format");
+                    break;
+                case word::WdSaveFormat::wdFormatTemplate:
+                    rProps[ index ].Value <<= OUString("MS Word 97 Vorlage");
+                    break;
+
+                // Default to "MS Word 97"
+                default:
+                    rProps[ index ].Value <<= OUString("MS Word 97");
+                    break;
+            }
+            bRes = true;
+            break;
+        }
+    }
+    return bRes;
+}
+
+}
+
+void SAL_CALL
+SwVbaDocument::SaveAs2000( const uno::Any& FileName, const uno::Any& FileFormat, const uno::Any& /*LockComments*/, const uno::Any& /*Password*/, const uno::Any& /*AddToRecentFiles*/, const uno::Any& /*WritePassword*/, const uno::Any& /*ReadOnlyRecommended*/, const uno::Any& /*EmbedTrueTypeFonts*/, const uno::Any& /*SaveNativePictureFormat*/, const uno::Any& /*SaveFormsData*/, const uno::Any& /*SaveAsAOCELetter*/ )
+{
+    // Based on ScVbaWorkbook::SaveAs.
+    OUString sFileName;
+    FileName >>= sFileName;
+    OUString sURL;
+    osl::FileBase::getFileURLFromSystemPath( sFileName, sURL );
+
+    // Detect if there is no path then we need to use the current folder.
+    INetURLObject aURL( sURL );
+    sURL = aURL.GetMainURL( INetURLObject::DecodeMechanism::ToIUri );
+    if( sURL.isEmpty() )
+    {
+        // Need to add cur dir ( of this document ) or else the 'Work' dir
+        sURL = getModel()->getURL();
+
+        if ( sURL.isEmpty() )
+        {
+            // Not path available from 'this' document. Need to add the 'document'/work directory then.
+            // Based on SwVbaOptions::getValueEvent()
+            uno::Reference< util::XPathSettings > xPathSettings = util::thePathSettings::get( comphelper::getProcessComponentContext() );
+            OUString sPathUrl;
+            xPathSettings->getPropertyValue( "Work" ) >>= sPathUrl;
+            // Path could be a multipath, Microsoft doesn't support this feature in Word currently.
+            // Only the last path is from interest.
+            sal_Int32 nIndex = sPathUrl.lastIndexOf( ';' );
+            if( nIndex != -1 )
+            {
+                sPathUrl = sPathUrl.copy( nIndex + 1 );
+            }
+
+            aURL.SetURL( sPathUrl );
+        }
+        else
+        {
+            aURL.SetURL( sURL );
+            aURL.Append( sFileName );
+        }
+        sURL = aURL.GetMainURL( INetURLObject::DecodeMechanism::ToIUri );
+
+    }
+
+    sal_Int32 nFileFormat = word::WdSaveFormat::wdFormatDocument;
+    FileFormat >>= nFileFormat;
+
+    uno::Sequence<  beans::PropertyValue > storeProps(1);
+    storeProps[0].Name = "FilterName" ;
+
+    setFilterPropsFromFormat( nFileFormat, storeProps );
+
+    uno::Reference< frame::XStorable > xStor( getModel(), uno::UNO_QUERY_THROW );
+    xStor->storeAsURL( sURL, storeProps );
+}
+
+void SAL_CALL
+SwVbaDocument::SaveAs( const uno::Any& FileName, const uno::Any& FileFormat, const uno::Any& LockComments, const uno::Any& Password, const uno::Any& AddToRecentFiles, const uno::Any& WritePassword, const uno::Any& ReadOnlyRecommended, const uno::Any& EmbedTrueTypeFonts, const uno::Any& SaveNativePictureFormat, const uno::Any& SaveFormsData, const uno::Any& SaveAsAOCELetter, const uno::Any& /*Encoding*/, const uno::Any& /*InsertLineBreaks*/, const uno::Any& /*AllowSubstitutions*/, const uno::Any& /*LineEnding*/, const uno::Any& /*AddBiDiMarks*/ )
+{
+    return SaveAs2000( FileName, FileFormat, LockComments, Password, AddToRecentFiles, WritePassword, ReadOnlyRecommended, EmbedTrueTypeFonts, SaveNativePictureFormat, SaveFormsData, SaveAsAOCELetter );
+}
+
 uno::Any
 SwVbaDocument::getControlShape( const OUString& sName )
 {
diff --git a/sw/source/ui/vba/vbadocument.hxx b/sw/source/ui/vba/vbadocument.hxx
index dee256ef63d4..c5a4e0d9d8b0 100644
--- a/sw/source/ui/vba/vbadocument.hxx
+++ b/sw/source/ui/vba/vbadocument.hxx
@@ -88,6 +88,8 @@ public:
     virtual void SAL_CALL ClosePrintPreview(  ) override;
     virtual css::uno::Any SAL_CALL Revisions( const css::uno::Any& aIndex ) override;
     virtual css::uno::Any SAL_CALL Frames( const css::uno::Any& aIndex ) override;
+    virtual void SAL_CALL SaveAs2000( const css::uno::Any& FileName, const css::uno::Any& FileFormat, const css::uno::Any& LockComments, const css::uno::Any& Password, const css::uno::Any& AddToRecentFiles, const css::uno::Any& WritePassword, const css::uno::Any& ReadOnlyRecommended, const css::uno::Any& EmbedTrueTypeFonts, const css::uno::Any& SaveNativePictureFormat, const css::uno::Any& SaveFormsData, const css::uno::Any& SaveAsAOCELetter ) override;
+    virtual void SAL_CALL SaveAs( const css::uno::Any& FileName, const css::uno::Any& FileFormat, const css::uno::Any& LockComments, const css::uno::Any& Password, const css::uno::Any& AddToRecentFiles, const css::uno::Any& WritePassword, const css::uno::Any& ReadOnlyRecommended, const css::uno::Any& EmbedTrueTypeFonts, const css::uno::Any& SaveNativePictureFormat, const css::uno::Any& SaveFormsData, const css::uno::Any& SaveAsAOCELetter, const css::uno::Any& Encoding, const css::uno::Any& InsertLineBreaks, const css::uno::Any& AllowSubstitutions, const css::uno::Any& LineEnding, const css::uno::Any& AddBiDiMarks ) override;
 
     // XInvocation
     virtual css::uno::Reference< css::beans::XIntrospectionAccess > SAL_CALL getIntrospection(  ) override;


More information about the Libreoffice-commits mailing list