summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--oovbaapi/ooo/vba/word/XWordBasic.idl1
-rw-r--r--sw/source/ui/vba/vbaapplication.cxx88
-rw-r--r--sw/source/ui/vba/vbadocument.cxx48
-rw-r--r--sw/source/ui/vba/vbafilterpropsfromformat.hxx76
4 files changed, 166 insertions, 47 deletions
diff --git a/oovbaapi/ooo/vba/word/XWordBasic.idl b/oovbaapi/ooo/vba/word/XWordBasic.idl
index 40717488ce9f..5a381daf3867 100644
--- a/oovbaapi/ooo/vba/word/XWordBasic.idl
+++ b/oovbaapi/ooo/vba/word/XWordBasic.idl
@@ -18,6 +18,7 @@ interface XWordBasic
void FileOpen( [in] string Name, [in] any ConfirmConversions, [in] any ReadOnly, [in] any AddToMru, [in] any PasswordDoc, [in] any PasswordDot, [in] any Revert, [in] any WritePasswordDoc, [in] any WritePasswordDot );
void FileSave();
+ void FileSaveAs( [in] any Name, [in] any Format, [in] any LockAnnot, [in] any Password, [in] any AddToMru, [in] any WritePassword, [in] any RecommendReadOnly, [in] any EmbedFonts, [in] any NativePictureFormat, [in] any FormsData, [in] any SaveAsAOCELetter );
void FileClose( [in] any Save );
void ToolsOptionsView( [in] any DraftFont, [in] any WrapToWindow, [in] any PicturePlaceHolders, [in] any FieldCodes, [in] any BookMarks, [in] any FieldShading, [in] any StatusBar, [in] any HScroll, [in] any VScroll, [in] any StyleAreaWidth, [in] any Tabs, [in] any Spaces, [in] any Paras, [in] any Hyphens, [in] any Hidden, [in] any ShowAll, [in] any Drawings, [in] any Anchors, [in] any TextBoundaries, [in] any VRuler, [in] any Highlight );
any WindowName( [in] any Number );
diff --git a/sw/source/ui/vba/vbaapplication.cxx b/sw/source/ui/vba/vbaapplication.cxx
index f47f9affc00a..785c48a45057 100644
--- a/sw/source/ui/vba/vbaapplication.cxx
+++ b/sw/source/ui/vba/vbaapplication.cxx
@@ -19,9 +19,11 @@
#include <com/sun/star/task/XStatusIndicatorSupplier.hpp>
#include <com/sun/star/task/XStatusIndicator.hpp>
+#include <com/sun/star/util/thePathSettings.hpp>
#include "vbaapplication.hxx"
#include "vbadocument.hxx"
+#include "vbafilterpropsfromformat.hxx"
#include <sal/log.hxx>
#include <osl/file.hxx>
#include <vcl/svapp.hxx>
@@ -39,6 +41,7 @@
#include <ooo/vba/word/WdWindowState.hpp>
#include <ooo/vba/word/XApplicationOutgoing.hpp>
#include <ooo/vba/word/XBookmarks.hpp>
+#include <comphelper/processfactory.hxx>
#include <basic/sbuno.hxx>
#include <editeng/acorrcfg.hxx>
#include "wordvbahelper.hxx"
@@ -46,6 +49,7 @@
#include <swdll.hxx>
#include <swmodule.hxx>
#include "vbalistgalleries.hxx"
+#include <tools/urlobj.hxx>
using namespace ::ooo;
using namespace ::ooo::vba;
@@ -78,6 +82,17 @@ public:
virtual void SAL_CALL FileOpen( const OUString& Name, const uno::Any& ConfirmConversions, const uno::Any& ReadOnly, const uno::Any& AddToMru, const uno::Any& PasswordDoc, const uno::Any& PasswordDot, const uno::Any& Revert, const uno::Any& WritePasswordDoc, const uno::Any& WritePasswordDot ) override;
virtual void SAL_CALL FileSave() override;
+ virtual void SAL_CALL FileSaveAs( const css::uno::Any& Name,
+ const css::uno::Any& Format,
+ const css::uno::Any& LockAnnot,
+ const css::uno::Any& Password,
+ const css::uno::Any& AddToMru,
+ const css::uno::Any& WritePassword,
+ const css::uno::Any& RecommendReadOnly,
+ const css::uno::Any& EmbedFonts,
+ const css::uno::Any& NativePictureFormat,
+ const css::uno::Any& FormsData,
+ const css::uno::Any& SaveAsAOCELetter ) override;
virtual void SAL_CALL FileClose( const css::uno::Any& Save ) override;
virtual void SAL_CALL ToolsOptionsView( const css::uno::Any& DraftFont,
const css::uno::Any& WrapToWindow,
@@ -551,6 +566,79 @@ SwWordBasic::FileSave()
}
void SAL_CALL
+SwWordBasic::FileSaveAs( const css::uno::Any& Name,
+ const css::uno::Any& Format,
+ const css::uno::Any& /*LockAnnot*/,
+ const css::uno::Any& /*Password*/,
+ const css::uno::Any& /*AddToMru*/,
+ const css::uno::Any& /*WritePassword*/,
+ const css::uno::Any& /*RecommendReadOnly*/,
+ const css::uno::Any& /*EmbedFonts*/,
+ const css::uno::Any& /*NativePictureFormat*/,
+ const css::uno::Any& /*FormsData*/,
+ const css::uno::Any& /*SaveAsAOCELetter*/ )
+{
+ SAL_INFO("sw.vba", "WordBasic.FileSaveAs(Name:=" << Name << ",Format:=" << Format << ")");
+
+ uno::Reference< frame::XModel > xModel( mpApp->getCurrentDocument(), uno::UNO_SET_THROW );
+
+ // Based on SwVbaDocument::SaveAs2000.
+
+ OUString sFileName;
+ Name >>= 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 = xModel->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.
+ // No idea if this crack is relevant for WordBasic or not.
+ 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;
+ Format >>= nFileFormat;
+
+ uno::Sequence< beans::PropertyValue > aProps(2);
+ aProps[0].Name = "FilterName";
+
+ setFilterPropsFromFormat( nFileFormat, aProps );
+
+ aProps[1].Name = "FileName";
+ aProps[1].Value <<= sURL;
+
+ dispatchRequests(xModel,".uno:SaveAs",aProps);
+}
+
+void SAL_CALL
SwWordBasic::FileClose( const css::uno::Any& Save )
{
uno::Reference< frame::XModel > xModel( mpApp->getCurrentDocument(), uno::UNO_SET_THROW );
diff --git a/sw/source/ui/vba/vbadocument.cxx b/sw/source/ui/vba/vbadocument.cxx
index 8be412841206..4faabec00be2 100644
--- a/sw/source/ui/vba/vbadocument.cxx
+++ b/sw/source/ui/vba/vbadocument.cxx
@@ -21,6 +21,7 @@
#include <sal/log.hxx>
#include "service.hxx"
+#include "vbafilterpropsfromformat.hxx"
#include "vbadocument.hxx"
#include "vbarange.hxx"
#include "vbarangehelper.hxx"
@@ -456,53 +457,6 @@ 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*/ )
{
diff --git a/sw/source/ui/vba/vbafilterpropsfromformat.hxx b/sw/source/ui/vba/vbafilterpropsfromformat.hxx
new file mode 100644
index 000000000000..e51cdc3cc30e
--- /dev/null
+++ b/sw/source/ui/vba/vbafilterpropsfromformat.hxx
@@ -0,0 +1,76 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_VBA_VBAFILTERPROPSFROMFORMAT_HXX
+#define INCLUDED_SW_SOURCE_UI_VBA_VBAFILTERPROPSFROMFORMAT_HXX
+
+#include <sal/config.h>
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <rtl/ustring.hxx>
+#include <ooo/vba/word/WdSaveFormat.hpp>
+
+namespace
+{
+inline bool setFilterPropsFromFormat(sal_Int32 nFormat,
+ css::uno::Sequence<css::beans::PropertyValue>& rProps)
+{
+ bool bRes = false;
+ for (sal_Int32 index = 0; index < rProps.getLength(); ++index)
+ {
+ if (rProps[index].Name == "FilterName")
+ {
+ switch (nFormat)
+ {
+ case ooo::vba::word::WdSaveFormat::wdFormatDocument:
+ rProps[index].Value <<= OUString("MS Word 97");
+ break;
+ // Just save all the text formats as "Text"
+ case ooo::vba::word::WdSaveFormat::wdFormatDOSText:
+ case ooo::vba::word::WdSaveFormat::wdFormatDOSTextLineBreaks:
+ case ooo::vba::word::WdSaveFormat::wdFormatEncodedText:
+ case ooo::vba::word::WdSaveFormat::wdFormatText:
+ case ooo::vba::word::WdSaveFormat::wdFormatTextLineBreaks:
+ rProps[index].Value <<= OUString("Text");
+ break;
+ case ooo::vba::word::WdSaveFormat::wdFormatFilteredHTML:
+ case ooo::vba::word::WdSaveFormat::wdFormatHTML:
+ rProps[index].Value <<= OUString("HTML");
+ break;
+ case ooo::vba::word::WdSaveFormat::wdFormatRTF:
+ rProps[index].Value <<= OUString("Rich Text Format");
+ break;
+ case ooo::vba::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;
+}
+}
+
+#endif