oovbaapi/ooo/vba/excel/XApplication.idl | 10 + oovbaapi/ooo/vba/excel/XFileDialog.idl | 2 sc/CppunitTest_sc_macros_test.mk | 1 sc/qa/extras/testdocuments/MultiDocumentCopyPaste.xlsm |binary sc/qa/extras/testdocuments/SimpleCopyPaste.xlsm |binary sc/qa/extras/vba-macro-test.cxx | 148 +++++++++++++++++ sc/source/ui/vba/excelvbahelper.cxx | 25 +- sc/source/ui/vba/vbaapplication.cxx | 39 ++++ sc/source/ui/vba/vbaapplication.hxx | 2 sc/source/ui/vba/vbafiledialog.cxx | 11 + sc/source/ui/vba/vbafiledialog.hxx | 4 sc/source/ui/vba/vbafiledialogitems.hxx | 5 sc/source/ui/vba/vbarange.cxx | 7 sc/source/ui/vba/vbaworkbooks.cxx | 11 - 14 files changed, 248 insertions(+), 17 deletions(-)
New commits: commit 6482694c3d23f94a8d7fec4edbbe1fb3b1055df8 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Thu Jan 20 21:13:26 2022 +0900 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Mon Jan 31 03:45:03 2022 +0100 tdf#118246 add support for Application.GetOpenFilename func. Opens the file dialog and returns the selected filename. Change-Id: I4eccd34a7fbb892c0950b2f7c34977cf2aad6f89 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128721 Tested-by: Tomaž Vajngerl <qui...@gmail.com> Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> (cherry picked from commit 571438a34ad9aba0d496a89e8345851331740fbd) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129017 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/oovbaapi/ooo/vba/excel/XApplication.idl b/oovbaapi/ooo/vba/excel/XApplication.idl index 89a19197116f..b1bcf46336be 100644 --- a/oovbaapi/ooo/vba/excel/XApplication.idl +++ b/oovbaapi/ooo/vba/excel/XApplication.idl @@ -65,6 +65,16 @@ interface XApplication string getDefaultFilePath() raises(com::sun::star::script::BasicErrorException); + // Opens the file dialog and returns the selected file + // Parameters: + // Title: title of the file dialog + // MultiSelect: true if multi selection is allowed (false by default) + // returns: + // false - if file dialog was canceled + // filename - if "MultiSelect" is false + // array of filename - if "MultiSelect" is true + any GetOpenFilename([in] any FileFilter, [in] any FilterIndex, [in] any Title, [in] any ButtonText, [in] any MultiSelect); + any International( [in] long Index ); any Workbooks( [in] any Index ); any Worksheets( [in] any Index ); diff --git a/oovbaapi/ooo/vba/excel/XFileDialog.idl b/oovbaapi/ooo/vba/excel/XFileDialog.idl index e73813e53807..bf9ff2391ee8 100644 --- a/oovbaapi/ooo/vba/excel/XFileDialog.idl +++ b/oovbaapi/ooo/vba/excel/XFileDialog.idl @@ -34,6 +34,8 @@ interface XFileDialog [attribute] any InitialFileName; [attribute] any Title; + [attribute] any AllowMultiSelect; + [attribute, readonly] XFileDialogSelectedItems SelectedItems; long Show(); diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx index ced6d0c70eb3..0fd425c15cf6 100644 --- a/sc/source/ui/vba/vbaapplication.cxx +++ b/sc/source/ui/vba/vbaapplication.cxx @@ -34,6 +34,7 @@ #include <ooo/vba/excel/XlMousePointer.hpp> #include <ooo/vba/office/MsoShapeType.hpp> #include <ooo/vba/office/MsoAutoShapeType.hpp> +#include <ooo/vba/office/MsoFileDialogType.hpp> #include "vbaapplication.hxx" #include "vbaworkbooks.hxx" @@ -55,6 +56,7 @@ #include <sc.hrc> #include <macromgr.hxx> #include "vbafiledialog.hxx" +#include "vbafiledialogitems.hxx" #include <osl/file.hxx> #include <rtl/instance.hxx> @@ -71,13 +73,13 @@ #include <basic/sbuno.hxx> #include <basic/sbmeth.hxx> #include <basic/sberrors.hxx> +#include <comphelper/sequence.hxx> #include <convuno.hxx> #include <cellsuno.hxx> #include <unonames.hxx> #include <docsh.hxx> #include "excelvbahelper.hxx" - #include <basic/sbxobj.hxx> #include <viewutil.hxx> @@ -347,6 +349,41 @@ ScVbaApplication::getActiveCell() return new ScVbaRange( excel::getUnoSheetModuleObj( xRange ), mxContext, xRange->getCellRangeByPosition( nCursorX, nCursorY, nCursorX, nCursorY ) ); } +uno::Any SAL_CALL +ScVbaApplication::GetOpenFilename(const uno::Any& /*aFileFilter*/, const uno::Any& /*aFilterIndex*/, const uno::Any& aTitle, const uno::Any& /*aButtonText*/, const uno::Any& aMultiSelect) +{ + // TODO - take all parameters into account + auto xDialog = uno::Reference<excel::XFileDialog> (new ScVbaFileDialog( this, mxContext, office::MsoFileDialogType::msoFileDialogFilePicker)); + xDialog->setTitle(aTitle); + xDialog->setAllowMultiSelect(aMultiSelect); + + bool bMultiSelect = false; + aMultiSelect >>= bMultiSelect; + + if (xDialog->Show() == 0) + { + // return FALSE when canceled + return uno::makeAny(false); + } + + uno::Reference<excel::XFileDialogSelectedItems> xItems = xDialog->getSelectedItems(); + auto* pItems = dynamic_cast<ScVbaFileDialogSelectedItems*>(xItems.get()); + auto const & rItemVector = pItems->getItems(); + + if (!bMultiSelect) // only 1 selection allowed - return path + { + OUString aPath; + if (!rItemVector.empty()) + aPath = rItemVector.at(0); + return uno::makeAny(aPath); + } + else + { + // convert to sequence + return uno::makeAny(comphelper::containerToSequence(rItemVector)); + } +} + uno::Any SAL_CALL ScVbaApplication::International( sal_Int32 /*Index*/ ) { diff --git a/sc/source/ui/vba/vbaapplication.hxx b/sc/source/ui/vba/vbaapplication.hxx index eac54601d260..9a7eb8328363 100644 --- a/sc/source/ui/vba/vbaapplication.hxx +++ b/sc/source/ui/vba/vbaapplication.hxx @@ -97,6 +97,8 @@ public: virtual css::uno::Reference< ov::XAssistant > SAL_CALL getAssistant() override; virtual css::uno::Reference< ov::excel::XWorkbook > SAL_CALL getThisWorkbook() override; + + virtual css::uno::Any SAL_CALL GetOpenFilename(const css::uno::Any& FileFilter, const css::uno::Any& FilterIndex, const css::uno::Any& Title, const css::uno::Any& ButtonText, const css::uno::Any& MultiSelect) override; virtual css::uno::Any SAL_CALL International( sal_Int32 Index ) override; virtual css::uno::Any SAL_CALL FileDialog( const css::uno::Any& DialogType ) override; virtual css::uno::Any SAL_CALL Workbooks( const css::uno::Any& aIndex ) override; diff --git a/sc/source/ui/vba/vbafiledialog.cxx b/sc/source/ui/vba/vbafiledialog.cxx index 6f523c8c1d72..b33bbebd51ef 100644 --- a/sc/source/ui/vba/vbafiledialog.cxx +++ b/sc/source/ui/vba/vbafiledialog.cxx @@ -36,6 +36,7 @@ ScVbaFileDialog::ScVbaFileDialog( const uno::Reference< XHelperInterface >& xPar : ScVbaFileDialog_BASE( xParent, xContext) , m_nType(nType) , m_sTitle("FileDialog") + , m_bMultiSelectMode(false) {} uno::Any @@ -64,6 +65,16 @@ void ScVbaFileDialog::setTitle( const css::uno::Any& rTitle ) rTitle >>= m_sTitle; } +uno::Any ScVbaFileDialog::getAllowMultiSelect() +{ + return uno::makeAny(m_bMultiSelectMode); +} + +void ScVbaFileDialog::setAllowMultiSelect(const uno::Any& rAllowMultiSelect) +{ + rAllowMultiSelect >>= m_bMultiSelectMode; +} + uno::Reference< excel::XFileDialogSelectedItems > SAL_CALL ScVbaFileDialog::getSelectedItems() { // TODO use InitialFileName when m_xItems is empty diff --git a/sc/source/ui/vba/vbafiledialog.hxx b/sc/source/ui/vba/vbafiledialog.hxx index 9f2b8e0f2677..3218802da116 100644 --- a/sc/source/ui/vba/vbafiledialog.hxx +++ b/sc/source/ui/vba/vbafiledialog.hxx @@ -36,6 +36,7 @@ private: sal_Int32 m_nType; OUString m_sTitle; OUString m_sInitialFileName; + bool m_bMultiSelectMode; css::uno::Reference< ov::excel::XFileDialogSelectedItems> m_xItems; public: ScVbaFileDialog( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const sal_Int32 nType); @@ -44,6 +45,9 @@ public: virtual void SAL_CALL setInitialFileName( const css::uno::Any& rName ) override; virtual css::uno::Any SAL_CALL getTitle() override; virtual void SAL_CALL setTitle( const css::uno::Any& rTitle ) override; + virtual css::uno::Any SAL_CALL getAllowMultiSelect() override; + virtual void SAL_CALL setAllowMultiSelect(const css::uno::Any& rAllowMultiSelect) override; + virtual css::uno::Reference< ov::excel::XFileDialogSelectedItems > SAL_CALL getSelectedItems() override; virtual sal_Int32 SAL_CALL Show() override; diff --git a/sc/source/ui/vba/vbafiledialogitems.hxx b/sc/source/ui/vba/vbafiledialogitems.hxx index f0e2977fee7c..f52f1270157b 100644 --- a/sc/source/ui/vba/vbafiledialogitems.hxx +++ b/sc/source/ui/vba/vbafiledialogitems.hxx @@ -20,6 +20,11 @@ class ScVbaFileDialogSelectedItems final : public FileDialogSelectedItems_BASE public: ScVbaFileDialogSelectedItems( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const std::vector<OUString>& sItems); + std::vector<OUString> const& getItems() + { + return m_sItems; + } + // XEnumerationAccess virtual css::uno::Type SAL_CALL getElementType() override; virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override; commit 15ff0c022c695e76738ff78b043e0b6fdeae9077 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Tue Jan 18 15:34:49 2022 +0900 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Mon Jan 31 03:44:54 2022 +0100 sc: fix VBA Copy-Paste using same and separate document This fixes 2 issues with VBA copy-paste: - VBA command Range(..).Copy issue where the range wasn't selected when copying and the copied cells were from the previous selection. The Copy command now does the same selection as the Cut command. - VBA PasteSpecial issue where the wrong view was used to get the clip document. - VBA Workbooks.Add issue where the new workbook wasn't activated after it was created, which causes an issue when running tests, but not when running in LO application. The Add command does now the same as the Workbooks.Open command. All the issues are supported by new test cases. Change-Id: I36ec45c01f18f7f76e4f95a25a28402a6ee0e2e2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128720 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> (cherry picked from commit 0c6ee963e1f089cb73e0c68a28af29d0f8d9e0df) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128950 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/sc/CppunitTest_sc_macros_test.mk b/sc/CppunitTest_sc_macros_test.mk index b4f62624e693..4f8370701c66 100644 --- a/sc/CppunitTest_sc_macros_test.mk +++ b/sc/CppunitTest_sc_macros_test.mk @@ -19,6 +19,7 @@ $(eval $(call gb_CppunitTest_use_common_precompiled_header,sc_macros_test)) $(eval $(call gb_CppunitTest_add_exception_objects,sc_macros_test, \ sc/qa/extras/macros-test \ + sc/qa/extras/vba-macro-test \ )) $(eval $(call gb_CppunitTest_use_libraries,sc_macros_test, \ diff --git a/sc/qa/extras/testdocuments/MultiDocumentCopyPaste.xlsm b/sc/qa/extras/testdocuments/MultiDocumentCopyPaste.xlsm new file mode 100644 index 000000000000..4f24cf4e663f Binary files /dev/null and b/sc/qa/extras/testdocuments/MultiDocumentCopyPaste.xlsm differ diff --git a/sc/qa/extras/testdocuments/SimpleCopyPaste.xlsm b/sc/qa/extras/testdocuments/SimpleCopyPaste.xlsm new file mode 100644 index 000000000000..6c71c75b345e Binary files /dev/null and b/sc/qa/extras/testdocuments/SimpleCopyPaste.xlsm differ diff --git a/sc/qa/extras/vba-macro-test.cxx b/sc/qa/extras/vba-macro-test.cxx new file mode 100644 index 000000000000..36aa84badd2d --- /dev/null +++ b/sc/qa/extras/vba-macro-test.cxx @@ -0,0 +1,148 @@ +/* -*- 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 <sal/config.h> +#include <test/unoapi_test.hxx> +#include <osl/file.hxx> +#include <sal/log.hxx> +#include <vcl/svapp.hxx> + +#include <docsh.hxx> +#include <document.hxx> +#include <attrib.hxx> +#include <scitems.hxx> + +#include <com/sun/star/sheet/XSpreadsheet.hpp> + +using namespace css; + +class VBAMacroTest : public UnoApiTest +{ +public: + uno::Reference<lang::XComponent> mxComponent; + + VBAMacroTest() + : UnoApiTest("/sc/qa/extras/testdocuments") + { + } + + virtual void tearDown() override + { + if (mxComponent.is()) + { + mxComponent->dispose(); + mxComponent.set(nullptr); + } + + test::BootstrapFixture::tearDown(); + } + + void testSimpleCopyAndPaste(); + void testMultiDocumentCopyAndPaste(); + + CPPUNIT_TEST_SUITE(VBAMacroTest); + CPPUNIT_TEST(testSimpleCopyAndPaste); + CPPUNIT_TEST(testMultiDocumentCopyAndPaste); + CPPUNIT_TEST_SUITE_END(); +}; + +void VBAMacroTest::testSimpleCopyAndPaste() +{ + // Copy-paste values in the same sheet + + // Range(Cells(4, 3), Cells(6, 3)).Copy + // Cells(4, 2).Activate + // ActiveCell.PasteSpecial xlValues + + OUString aFileName; + createFileURL(u"SimpleCopyPaste.xlsm", aFileName); + mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument"); + + uno::Any aRet; + uno::Sequence<sal_Int16> aOutParamIndex; + uno::Sequence<uno::Any> aOutParam; + uno::Sequence<uno::Any> aParams; + + SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(mxComponent); + + CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell); + ScDocShell* pDocSh = static_cast<ScDocShell*>(pFoundShell); + ScDocument& rDoc = pDocSh->GetDocument(); + + // Check state + CPPUNIT_ASSERT_EQUAL(10.0, rDoc.GetValue(ScAddress(2, 3, 0))); + CPPUNIT_ASSERT_EQUAL(20.0, rDoc.GetValue(ScAddress(2, 4, 0))); + CPPUNIT_ASSERT_EQUAL(30.0, rDoc.GetValue(ScAddress(2, 5, 0))); + + CPPUNIT_ASSERT_EQUAL(0.0, rDoc.GetValue(ScAddress(1, 3, 0))); + CPPUNIT_ASSERT_EQUAL(0.0, rDoc.GetValue(ScAddress(1, 4, 0))); + CPPUNIT_ASSERT_EQUAL(0.0, rDoc.GetValue(ScAddress(1, 5, 0))); + + SfxObjectShell::CallXScript( + mxComponent, "vnd.sun.Star.script:VBAProject.Module1.test?language=Basic&location=document", + aParams, aRet, aOutParamIndex, aOutParam); + + // Copy from C4-C6 + CPPUNIT_ASSERT_EQUAL(10.0, rDoc.GetValue(ScAddress(2, 3, 0))); + CPPUNIT_ASSERT_EQUAL(20.0, rDoc.GetValue(ScAddress(2, 4, 0))); + CPPUNIT_ASSERT_EQUAL(30.0, rDoc.GetValue(ScAddress(2, 5, 0))); + + // Paste to B4-B6 + CPPUNIT_ASSERT_EQUAL(10.0, rDoc.GetValue(ScAddress(1, 3, 0))); + CPPUNIT_ASSERT_EQUAL(20.0, rDoc.GetValue(ScAddress(1, 4, 0))); + CPPUNIT_ASSERT_EQUAL(30.0, rDoc.GetValue(ScAddress(1, 5, 0))); +} + +void VBAMacroTest::testMultiDocumentCopyAndPaste() +{ + // Creates a new workbook (document) and copy-pastes values + // between the documents. + + // Set CurrentWB = ActiveWorkbook + // Workbooks.Add + // Set NewWB = ActiveWorkbook + // Cells(3, 2).Value = 200 + // Cells(4, 2).Value = 100 + // Range(Cells(3, 2), Cells(4, 2)).Copy + // CurrentWB.Activate + // Cells(2, 2).Activate + // ActiveCell.PasteSpecial xlValues + // ... + + OUString aFileName; + createFileURL(u"MultiDocumentCopyPaste.xlsm", aFileName); + mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument"); + + uno::Any aRet; + uno::Sequence<sal_Int16> aOutParamIndex; + uno::Sequence<uno::Any> aOutParam; + uno::Sequence<uno::Any> aParams; + + SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(mxComponent); + + CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell); + ScDocShell* pDocSh = static_cast<ScDocShell*>(pFoundShell); + ScDocument& rDoc = pDocSh->GetDocument(); + + CPPUNIT_ASSERT_EQUAL(0.0, rDoc.GetValue(ScAddress(1, 1, 0))); + CPPUNIT_ASSERT_EQUAL(0.0, rDoc.GetValue(ScAddress(1, 2, 0))); + CPPUNIT_ASSERT_EQUAL(0.0, rDoc.GetValue(ScAddress(1, 3, 0))); + + SfxObjectShell::CallXScript( + mxComponent, "vnd.sun.Star.script:VBAProject.Module1.test?language=Basic&location=document", + aParams, aRet, aOutParamIndex, aOutParam); + + CPPUNIT_ASSERT_EQUAL(200.0, rDoc.GetValue(ScAddress(1, 1, 0))); + CPPUNIT_ASSERT_EQUAL(100.0, rDoc.GetValue(ScAddress(1, 2, 0))); + CPPUNIT_ASSERT_EQUAL(0.0, rDoc.GetValue(ScAddress(1, 3, 0))); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(VBAMacroTest); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/vba/excelvbahelper.cxx b/sc/source/ui/vba/excelvbahelper.cxx index aa2c16378700..c43a4cb47e0d 100644 --- a/sc/source/ui/vba/excelvbahelper.cxx +++ b/sc/source/ui/vba/excelvbahelper.cxx @@ -210,25 +210,28 @@ void implnPasteSpecial( const uno::Reference< frame::XModel>& xModel, InsertDele { PasteCellsWarningReseter resetWarningBox; - ScTabViewShell* pTabViewShell = getBestViewShell( xModel ); - ScDocShell* pDocShell = getDocShell( xModel ); - if ( !(pTabViewShell && pDocShell) ) + ScTabViewShell* pTabViewShell = getBestViewShell(xModel); + if (!pTabViewShell) + return; + + ScDocShell* pDocShell = getDocShell(xModel); + if (!pDocShell) return; ScViewData& rView = pTabViewShell->GetViewData(); vcl::Window* pWin = rView.GetActiveWin(); - if (pWin) + if (!pWin) + return; + + const ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard(ScTabViewShell::GetClipData(pWin)); + if (pOwnClip) { - const ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard(pDocShell->GetClipData()); - ScDocument* pDoc = nullptr; - if ( pOwnClip ) - pDoc = pOwnClip->GetDocument(); - pTabViewShell->PasteFromClip( nFlags, pDoc, + pTabViewShell->PasteFromClip(nFlags, pOwnClip->GetDocument(), nFunction, bSkipEmpty, bTranspose, false, - INS_NONE, InsertDeleteFlags::NONE, true ); + INS_NONE, InsertDeleteFlags::NONE, true); + pTabViewShell->CellContentChanged(); } - } ScDocShell* diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index 323a4f394540..52c30724623f 100644 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -2510,7 +2510,9 @@ ScVbaRange::Copy(const ::uno::Any& Destination) } else { - excel::implnCopy( getUnoModel() ); + uno::Reference<frame::XModel> xModel = getModelFromRange(mxRange); + Select(); + excel::implnCopy(getUnoModel()); } } @@ -2868,7 +2870,8 @@ ScVbaRange::PasteSpecial( const uno::Any& Paste, const uno::Any& Operation, cons InsertDeleteFlags nFlags = getPasteFlags(nPaste); ScPasteFunc nFormulaBits = getPasteFormulaBits(nOperation); - excel::implnPasteSpecial(pShell->GetModel(), nFlags,nFormulaBits,bSkipBlanks,bTranspose); + + excel::implnPasteSpecial(xModel, nFlags, nFormulaBits, bSkipBlanks, bTranspose); } uno::Reference< excel::XRange > diff --git a/sc/source/ui/vba/vbaworkbooks.cxx b/sc/source/ui/vba/vbaworkbooks.cxx index 61edd810ba9c..6554eb176d06 100644 --- a/sc/source/ui/vba/vbaworkbooks.cxx +++ b/sc/source/ui/vba/vbaworkbooks.cxx @@ -140,9 +140,14 @@ ScVbaWorkbooks::Add( const uno::Any& Template ) // need to set up the document modules ( and vba mode ) here excel::setUpDocumentModules( xSpreadDoc ); - if( xSpreadDoc.is() ) - return getWorkbook( mxContext, xSpreadDoc, mxParent ); - return uno::Any(); + if (!xSpreadDoc.is()) + return uno::Any(); + + uno::Any aRet = getWorkbook( mxContext, xSpreadDoc, mxParent ); + uno::Reference< excel::XWorkbook > xWBook( aRet, uno::UNO_QUERY ); + if (xWBook.is()) + xWBook->Activate(); + return aRet; } void SAL_CALL