summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/vbahelper/vbadialogbase.hxx5
-rw-r--r--include/vbahelper/vbadialogsbase.hxx4
-rw-r--r--include/vbahelper/vbadocumentbase.hxx6
-rw-r--r--include/vbahelper/vbahelper.hxx9
-rw-r--r--include/vbahelper/vbapagesetupbase.hxx1
-rw-r--r--include/vbahelper/vbawindowbase.hxx3
-rw-r--r--sc/source/ui/vba/vbadialog.hxx5
-rw-r--r--sc/source/ui/vba/vbadialogs.hxx4
-rw-r--r--sc/source/ui/vba/vbapagesetup.cxx8
-rw-r--r--sc/source/ui/vba/vbapagesetup.hxx1
-rw-r--r--sc/source/ui/vba/vbawindow.cxx6
-rw-r--r--sc/source/ui/vba/vbawindow.hxx1
-rw-r--r--sc/source/ui/vba/vbaworkbook.cxx10
-rw-r--r--sc/source/ui/vba/vbaworkbook.hxx5
-rw-r--r--sw/inc/unocoll.hxx7
-rw-r--r--sw/inc/unofieldcoll.hxx2
-rw-r--r--sw/inc/unoredlines.hxx2
-rw-r--r--sw/inc/unotxdoc.hxx3
-rw-r--r--sw/source/core/unocore/unocoll.cxx13
-rw-r--r--sw/source/ui/vba/vbaapplication.cxx24
-rw-r--r--sw/source/ui/vba/vbaapplication.hxx4
-rw-r--r--sw/source/ui/vba/vbaautotextentry.cxx6
-rw-r--r--sw/source/ui/vba/vbabookmark.cxx12
-rw-r--r--sw/source/ui/vba/vbabookmark.hxx7
-rw-r--r--sw/source/ui/vba/vbabookmarks.cxx24
-rw-r--r--sw/source/ui/vba/vbabookmarks.hxx10
-rw-r--r--sw/source/ui/vba/vbacolumn.cxx5
-rw-r--r--sw/source/ui/vba/vbacolumn.hxx5
-rw-r--r--sw/source/ui/vba/vbacolumns.cxx3
-rw-r--r--sw/source/ui/vba/vbacontentcontrol.cxx3
-rw-r--r--sw/source/ui/vba/vbacontentcontrol.hxx7
-rw-r--r--sw/source/ui/vba/vbacontentcontrols.cxx11
-rw-r--r--sw/source/ui/vba/vbacontentcontrols.hxx7
-rw-r--r--sw/source/ui/vba/vbadialog.cxx12
-rw-r--r--sw/source/ui/vba/vbadialog.hxx12
-rw-r--r--sw/source/ui/vba/vbadialogs.cxx6
-rw-r--r--sw/source/ui/vba/vbadialogs.hxx9
-rw-r--r--sw/source/ui/vba/vbadocument.cxx82
-rw-r--r--sw/source/ui/vba/vbadocument.hxx10
-rw-r--r--sw/source/ui/vba/vbadocumentproperties.cxx46
-rw-r--r--sw/source/ui/vba/vbadocumentproperties.hxx7
-rw-r--r--sw/source/ui/vba/vbadocuments.cxx12
-rw-r--r--sw/source/ui/vba/vbafield.cxx48
-rw-r--r--sw/source/ui/vba/vbafield.hxx11
-rw-r--r--sw/source/ui/vba/vbafind.cxx32
-rw-r--r--sw/source/ui/vba/vbafind.hxx16
-rw-r--r--sw/source/ui/vba/vbaformfield.cxx9
-rw-r--r--sw/source/ui/vba/vbaformfield.hxx7
-rw-r--r--sw/source/ui/vba/vbaformfields.cxx11
-rw-r--r--sw/source/ui/vba/vbaformfields.hxx3
-rw-r--r--sw/source/ui/vba/vbaframe.cxx6
-rw-r--r--sw/source/ui/vba/vbaframe.hxx10
-rw-r--r--sw/source/ui/vba/vbaframes.cxx21
-rw-r--r--sw/source/ui/vba/vbaframes.hxx8
-rw-r--r--sw/source/ui/vba/vbaheaderfooter.cxx21
-rw-r--r--sw/source/ui/vba/vbaheaderfooter.hxx11
-rw-r--r--sw/source/ui/vba/vbaheaderfooterhelper.cxx28
-rw-r--r--sw/source/ui/vba/vbaheaderfooterhelper.hxx17
-rw-r--r--sw/source/ui/vba/vbaheadersfooters.cxx22
-rw-r--r--sw/source/ui/vba/vbaheadersfooters.hxx11
-rw-r--r--sw/source/ui/vba/vbainformationhelper.cxx10
-rw-r--r--sw/source/ui/vba/vbainformationhelper.hxx8
-rw-r--r--sw/source/ui/vba/vbalistformat.cxx9
-rw-r--r--sw/source/ui/vba/vbapagesetup.cxx12
-rw-r--r--sw/source/ui/vba/vbapagesetup.hxx7
-rw-r--r--sw/source/ui/vba/vbapane.cxx11
-rw-r--r--sw/source/ui/vba/vbapane.hxx7
-rw-r--r--sw/source/ui/vba/vbapanes.cxx11
-rw-r--r--sw/source/ui/vba/vbapanes.hxx7
-rw-r--r--sw/source/ui/vba/vbaparagraph.cxx3
-rw-r--r--sw/source/ui/vba/vbarange.cxx60
-rw-r--r--sw/source/ui/vba/vbarange.hxx25
-rw-r--r--sw/source/ui/vba/vbarevision.cxx17
-rw-r--r--sw/source/ui/vba/vbarevision.hxx10
-rw-r--r--sw/source/ui/vba/vbarevisions.cxx34
-rw-r--r--sw/source/ui/vba/vbarevisions.hxx17
-rw-r--r--sw/source/ui/vba/vbarow.cxx5
-rw-r--r--sw/source/ui/vba/vbarow.hxx5
-rw-r--r--sw/source/ui/vba/vbarows.cxx3
-rw-r--r--sw/source/ui/vba/vbasection.cxx10
-rw-r--r--sw/source/ui/vba/vbasection.hxx10
-rw-r--r--sw/source/ui/vba/vbasections.cxx44
-rw-r--r--sw/source/ui/vba/vbasections.hxx9
-rw-r--r--sw/source/ui/vba/vbaselection.cxx40
-rw-r--r--sw/source/ui/vba/vbaselection.hxx4
-rw-r--r--sw/source/ui/vba/vbastyle.cxx10
-rw-r--r--sw/source/ui/vba/vbastyle.hxx10
-rw-r--r--sw/source/ui/vba/vbastyles.cxx30
-rw-r--r--sw/source/ui/vba/vbastyles.hxx10
-rw-r--r--sw/source/ui/vba/vbasystem.cxx13
-rw-r--r--sw/source/ui/vba/vbatable.cxx11
-rw-r--r--sw/source/ui/vba/vbatable.hxx8
-rw-r--r--sw/source/ui/vba/vbatables.cxx62
-rw-r--r--sw/source/ui/vba/vbatables.hxx9
-rw-r--r--sw/source/ui/vba/vbatablesofcontents.cxx16
-rw-r--r--sw/source/ui/vba/vbatablesofcontents.hxx7
-rw-r--r--sw/source/ui/vba/vbaview.cxx33
-rw-r--r--sw/source/ui/vba/vbaview.hxx10
-rw-r--r--sw/source/ui/vba/vbawindow.cxx6
-rw-r--r--sw/source/ui/vba/vbawindow.hxx8
-rw-r--r--sw/source/ui/vba/wordvbahelper.cxx69
-rw-r--r--sw/source/ui/vba/wordvbahelper.hxx26
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx15
-rw-r--r--vbahelper/source/vbahelper/vbadialogbase.cxx4
-rw-r--r--vbahelper/source/vbahelper/vbadocumentbase.cxx7
-rw-r--r--vbahelper/source/vbahelper/vbahelper.cxx29
-rw-r--r--vbahelper/source/vbahelper/vbawindowbase.cxx7
107 files changed, 961 insertions, 528 deletions
diff --git a/include/vbahelper/vbadialogbase.hxx b/include/vbahelper/vbadialogbase.hxx
index e56a27e08282..d3834e966551 100644
--- a/include/vbahelper/vbadialogbase.hxx
+++ b/include/vbahelper/vbadialogbase.hxx
@@ -46,13 +46,14 @@ typedef InheritedHelperInterfaceWeakImpl< ov::XDialogBase > VbaDialogBase_BASE;
class VBAHELPER_DLLPUBLIC VbaDialogBase : public VbaDialogBase_BASE
{
sal_Int32 mnIndex;
- css::uno::Reference< css::frame::XModel > m_xModel;
public:
- VbaDialogBase( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, css::uno::Reference< css::frame::XModel > xModel, sal_Int32 nIndex ):VbaDialogBase_BASE( xParent, xContext ), mnIndex( nIndex ), m_xModel(std::move( xModel )) {}
+ VbaDialogBase( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, sal_Int32 nIndex ):VbaDialogBase_BASE( xParent, xContext ), mnIndex( nIndex ) {}
// Methods
virtual void SAL_CALL Show() override;
virtual OUString mapIndexToName( sal_Int32 nIndex ) = 0;
+
+ virtual css::uno::Reference< css::frame::XModel > getModel() const = 0;
};
#endif // INCLUDED_VBAHELPER_VBADIALOGBASE_HXX
diff --git a/include/vbahelper/vbadialogsbase.hxx b/include/vbahelper/vbadialogsbase.hxx
index 6f44d825bec9..d4292cac9a81 100644
--- a/include/vbahelper/vbadialogsbase.hxx
+++ b/include/vbahelper/vbadialogsbase.hxx
@@ -45,10 +45,8 @@ typedef InheritedHelperInterfaceWeakImpl< ov::XDialogsBase > VbaDialogsBase_BASE
class VBAHELPER_DLLPUBLIC VbaDialogsBase : public VbaDialogsBase_BASE
{
-protected:
- css::uno::Reference< css::frame::XModel > m_xModel;
public:
- VbaDialogsBase( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, css::uno::Reference< css::frame::XModel > xModel ): VbaDialogsBase_BASE( xParent, xContext ), m_xModel(std::move( xModel )) {}
+ VbaDialogsBase( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext ): VbaDialogsBase_BASE( xParent, xContext ) {}
// XCollection
virtual ::sal_Int32 SAL_CALL getCount() override;
diff --git a/include/vbahelper/vbadocumentbase.hxx b/include/vbahelper/vbadocumentbase.hxx
index c26ae30d8188..e2fda81a58ff 100644
--- a/include/vbahelper/vbadocumentbase.hxx
+++ b/include/vbahelper/vbadocumentbase.hxx
@@ -48,13 +48,11 @@ typedef InheritedHelperInterfaceWeakImpl< ooo::vba::XDocumentBase > VbaDocumentB
class VBAHELPER_DLLPUBLIC VbaDocumentBase : public VbaDocumentBase_BASE
{
protected:
- css::uno::Reference< css::frame::XModel > mxModel;
css::uno::Reference< css::uno::XInterface > mxVBProject;
protected:
- const css::uno::Reference< css::frame::XModel >& getModel() const { return mxModel; }
+ virtual css::uno::Reference< css::frame::XModel > getModel() const = 0;
public:
- VbaDocumentBase( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext,
- css::uno::Reference< css::frame::XModel > xModel );
+ VbaDocumentBase( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext );
VbaDocumentBase( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext >const& xContext );
// Attributes
diff --git a/include/vbahelper/vbahelper.hxx b/include/vbahelper/vbahelper.hxx
index 82c676710263..7f9921e04035 100644
--- a/include/vbahelper/vbahelper.hxx
+++ b/include/vbahelper/vbahelper.hxx
@@ -75,15 +75,14 @@ namespace ooo::vba
VBAHELPER_DLLPUBLIC SfxObjectShell* getSfxObjShell( const css::uno::Reference< css::frame::XModel >& xModel );
/// @throws css::uno::RuntimeException
- css::uno::Reference< css::frame::XModel > getCurrentDoc( const OUString& sKey );
+ VBAHELPER_DLLPUBLIC css::uno::Reference< css::frame::XModel > getCurrentDoc( const OUString& sKey );
/// @throws css::uno::RuntimeException
VBAHELPER_DLLPUBLIC css::uno::Reference< css::frame::XModel > getThisExcelDoc( const css::uno::Reference< css::uno::XComponentContext >& xContext );
/// @throws css::uno::RuntimeException
- VBAHELPER_DLLPUBLIC css::uno::Reference< css::frame::XModel > getThisWordDoc( const css::uno::Reference< css::uno::XComponentContext >& xContext );
- /// @throws css::uno::RuntimeException
VBAHELPER_DLLPUBLIC css::uno::Reference< css::frame::XModel > getCurrentExcelDoc( const css::uno::Reference< css::uno::XComponentContext >& xContext );
- /// @throws css::uno::RuntimeException
- VBAHELPER_DLLPUBLIC css::uno::Reference< css::frame::XModel > getCurrentWordDoc( const css::uno::Reference< css::uno::XComponentContext >& xContext );
+
+ /// @throws uno::RuntimeException
+ VBAHELPER_DLLPUBLIC css::uno::Reference< css::frame::XModel > getCurrentDocCtx( const OUString& ctxName, const css::uno::Reference< css::uno::XComponentContext >& xContext );
/// @throws css::uno::RuntimeException
VBAHELPER_DLLPUBLIC css::uno::Reference< css::beans::XIntrospectionAccess > getIntrospectionAccess( const css::uno::Any& aObject );
diff --git a/include/vbahelper/vbapagesetupbase.hxx b/include/vbahelper/vbapagesetupbase.hxx
index c1b4668364d8..a6d8fadce7e6 100644
--- a/include/vbahelper/vbapagesetupbase.hxx
+++ b/include/vbahelper/vbapagesetupbase.hxx
@@ -44,7 +44,6 @@ typedef InheritedHelperInterfaceWeakImpl< ooo::vba::XPageSetupBase > VbaPageSetu
class VBAHELPER_DLLPUBLIC VbaPageSetupBase : public VbaPageSetupBase_BASE
{
protected:
- css::uno::Reference< css::frame::XModel > mxModel;
css::uno::Reference< css::beans::XPropertySet > mxPageProps;
sal_Int32 mnOrientLandscape;
sal_Int32 mnOrientPortrait;
diff --git a/include/vbahelper/vbawindowbase.hxx b/include/vbahelper/vbawindowbase.hxx
index bf2c6460ca23..c55d60b6bc82 100644
--- a/include/vbahelper/vbawindowbase.hxx
+++ b/include/vbahelper/vbawindowbase.hxx
@@ -55,7 +55,6 @@ public:
VbaWindowBase(
const css::uno::Reference< ov::XHelperInterface >& xParent,
const css::uno::Reference< css::uno::XComponentContext >& xContext,
- const css::uno::Reference< css::frame::XModel >& xModel,
const css::uno::Reference< css::frame::XController >& xController );
/// @throws css::uno::RuntimeException
VbaWindowBase(
@@ -86,8 +85,6 @@ protected:
/// @throws css::uno::RuntimeException
css::uno::Reference< css::awt::XWindow2 > getWindow2() const;
- css::uno::Reference< css::frame::XModel > m_xModel;
-
private:
/// @throws css::uno::RuntimeException
void construct( const css::uno::Reference< css::frame::XController >& xController );
diff --git a/sc/source/ui/vba/vbadialog.hxx b/sc/source/ui/vba/vbadialog.hxx
index 9317cbfaf20f..46ea538a84dd 100644
--- a/sc/source/ui/vba/vbadialog.hxx
+++ b/sc/source/ui/vba/vbadialog.hxx
@@ -27,7 +27,7 @@ typedef cppu::ImplInheritanceHelper< VbaDialogBase, ov::excel::XDialog > ScVbaDi
class ScVbaDialog : public ScVbaDialog_BASE
{
public:
- ScVbaDialog( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::frame::XModel >& xModel, sal_Int32 nIndex ):ScVbaDialog_BASE( xParent, xContext, xModel, nIndex ) {}
+ ScVbaDialog( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::frame::XModel >& xModel, sal_Int32 nIndex ):ScVbaDialog_BASE( xParent, xContext, nIndex ), m_xModel(xModel) {}
// Methods
virtual OUString mapIndexToName( sal_Int32 nIndex ) override;
@@ -35,6 +35,9 @@ public:
virtual OUString getServiceImplName() override;
virtual css::uno::Sequence<OUString> getServiceNames() override;
+ virtual css::uno::Reference< css::frame::XModel > getModel() const override { return m_xModel; }
+private:
+ css::uno::Reference< css::frame::XModel > m_xModel;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbadialogs.hxx b/sc/source/ui/vba/vbadialogs.hxx
index 97cbbda0442a..d5c7c5326655 100644
--- a/sc/source/ui/vba/vbadialogs.hxx
+++ b/sc/source/ui/vba/vbadialogs.hxx
@@ -30,7 +30,7 @@ typedef cppu::ImplInheritanceHelper< VbaDialogsBase, ov::excel::XDialogs > ScVba
class ScVbaDialogs : public ScVbaDialogs_BASE
{
public:
- ScVbaDialogs( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::frame::XModel >& xModel ): ScVbaDialogs_BASE( xParent, xContext, xModel ) {}
+ ScVbaDialogs( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::frame::XModel >& xModel ): ScVbaDialogs_BASE( xParent, xContext ), m_xModel(xModel) {}
// XCollection
virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index ) override;
@@ -38,6 +38,8 @@ public:
// XHelperInterface
virtual OUString getServiceImplName() override;
virtual css::uno::Sequence<OUString> getServiceNames() override;
+private:
+ css::uno::Reference< css::frame::XModel > m_xModel;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbapagesetup.cxx b/sc/source/ui/vba/vbapagesetup.cxx
index 009570e32dca..fa05584049a5 100644
--- a/sc/source/ui/vba/vbapagesetup.cxx
+++ b/sc/source/ui/vba/vbapagesetup.cxx
@@ -44,11 +44,13 @@ using namespace ::ooo::vba;
ScVbaPageSetup::ScVbaPageSetup(const uno::Reference< XHelperInterface >& xParent,
const uno::Reference< uno::XComponentContext >& xContext,
uno::Reference< sheet::XSpreadsheet > xSheet,
- const uno::Reference< frame::XModel >& xModel):
- ScVbaPageSetup_BASE( xParent, xContext ), mxSheet(std::move( xSheet )), mbIsLandscape( false )
+ const uno::Reference< frame::XModel >& xModel)
+: ScVbaPageSetup_BASE( xParent, xContext ),
+ mxModel(xModel),
+ mxSheet(std::move( xSheet )),
+ mbIsLandscape( false )
{
// query for current page style
- mxModel.set( xModel, uno::UNO_SET_THROW );
uno::Reference< beans::XPropertySet > xSheetProps( mxSheet, uno::UNO_QUERY_THROW );
uno::Any aValue = xSheetProps->getPropertyValue(u"PageStyle"_ustr);
OUString aStyleName;
diff --git a/sc/source/ui/vba/vbapagesetup.hxx b/sc/source/ui/vba/vbapagesetup.hxx
index 6f2f8b45c51f..8444b98a9831 100644
--- a/sc/source/ui/vba/vbapagesetup.hxx
+++ b/sc/source/ui/vba/vbapagesetup.hxx
@@ -28,6 +28,7 @@ typedef cppu::ImplInheritanceHelper<VbaPageSetupBase, ov::excel::XPageSetup> ScV
class ScVbaPageSetup : public ScVbaPageSetup_BASE
{
+ css::uno::Reference<css::frame::XModel> mxModel;
css::uno::Reference<css::sheet::XSpreadsheet> mxSheet;
bool mbIsLandscape;
diff --git a/sc/source/ui/vba/vbawindow.cxx b/sc/source/ui/vba/vbawindow.cxx
index 2c860eadcf86..c9847e6d523d 100644
--- a/sc/source/ui/vba/vbawindow.cxx
+++ b/sc/source/ui/vba/vbawindow.cxx
@@ -192,7 +192,8 @@ ScVbaWindow::ScVbaWindow(
const uno::Reference< uno::XComponentContext >& xContext,
const uno::Reference< frame::XModel >& xModel,
const uno::Reference< frame::XController >& xController ) :
- WindowImpl_BASE( xParent, xContext, xModel, xController )
+ WindowImpl_BASE( xParent, xContext, xController ),
+ m_xModel(xModel)
{
init();
}
@@ -200,7 +201,8 @@ ScVbaWindow::ScVbaWindow(
ScVbaWindow::ScVbaWindow(
const uno::Sequence< uno::Any >& args,
const uno::Reference< uno::XComponentContext >& xContext ) :
- WindowImpl_BASE( args, xContext )
+ WindowImpl_BASE( args, xContext ),
+ m_xModel(getXSomethingFromArgs< frame::XModel >( args, 1, false ))
{
init();
}
diff --git a/sc/source/ui/vba/vbawindow.hxx b/sc/source/ui/vba/vbawindow.hxx
index c4c0a0becb34..bb84719a6be3 100644
--- a/sc/source/ui/vba/vbawindow.hxx
+++ b/sc/source/ui/vba/vbawindow.hxx
@@ -32,6 +32,7 @@ typedef cppu::ImplInheritanceHelper< VbaWindowBase, ov::excel::XWindow > WindowI
class ScVbaWindow : public WindowImpl_BASE
{
private:
+ css::uno::Reference<css::frame::XModel> m_xModel;
css::uno::Reference< ov::excel::XPane > m_xPane;
void init();
diff --git a/sc/source/ui/vba/vbaworkbook.cxx b/sc/source/ui/vba/vbaworkbook.cxx
index 0313c86c12a8..8c8fcc424757 100644
--- a/sc/source/ui/vba/vbaworkbook.cxx
+++ b/sc/source/ui/vba/vbaworkbook.cxx
@@ -188,13 +188,19 @@ ScVbaWorkbook::init()
pShell->RegisterAutomationWorkbookObject( this );
}
-ScVbaWorkbook::ScVbaWorkbook( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, css::uno::Reference< css::frame::XModel > const & xModel ) : ScVbaWorkbook_BASE( xParent, xContext, xModel )
+ScVbaWorkbook::ScVbaWorkbook( const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ css::uno::Reference< css::frame::XModel > const & xModel )
+: ScVbaWorkbook_BASE( xParent, xContext ),
+ mxModel(xModel)
{
init();
}
ScVbaWorkbook::ScVbaWorkbook( uno::Sequence< uno::Any> const & args,
- uno::Reference< uno::XComponentContext> const & xContext ) : ScVbaWorkbook_BASE( args, xContext )
+ uno::Reference< uno::XComponentContext> const & xContext )
+: ScVbaWorkbook_BASE( args, xContext ),
+ mxModel(getXSomethingFromArgs< frame::XModel >( args, 1 ))
{
init();
}
diff --git a/sc/source/ui/vba/vbaworkbook.hxx b/sc/source/ui/vba/vbaworkbook.hxx
index e6a838b1ab1e..d6ee4b016779 100644
--- a/sc/source/ui/vba/vbaworkbook.hxx
+++ b/sc/source/ui/vba/vbaworkbook.hxx
@@ -31,6 +31,11 @@ class ScVbaWorkbook : public ScVbaWorkbook_BASE
static bool setFilterPropsFromFormat( sal_Int32 nFormat, css::uno::Sequence< css::beans::PropertyValue >& rProps );
void init();
+ css::uno::Reference< css::frame::XModel > mxModel;
+
+protected:
+ virtual css::uno::Reference< css::frame::XModel > getModel() const override { return mxModel; }
+
public:
ScVbaWorkbook( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext,
css::uno::Reference< css::frame::XModel > const & xModel );
diff --git a/sw/inc/unocoll.hxx b/sw/inc/unocoll.hxx
index 49bfae7d276b..b190f3e4ca1f 100644
--- a/sw/inc/unocoll.hxx
+++ b/sw/inc/unocoll.hxx
@@ -289,6 +289,7 @@ public:
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
rtl::Reference<SwXTextTable> getTextTableByName(std::u16string_view Name);
+ rtl::Reference<SwXTextTable> getTextTableByIndex(sal_Int32 nIndex);
static rtl::Reference<SwXTextTable> GetObject(SwFrameFormat& rFormat);
};
@@ -455,7 +456,7 @@ cppu::WeakImplHelper
>
SwSimpleIndexAccessBaseClass;
-class SAL_DLLPUBLIC_RTTI SwXFootnotes final : public SwSimpleIndexAccessBaseClass,
+class SW_DLLPUBLIC SwXFootnotes final : public SwSimpleIndexAccessBaseClass,
public SwUnoCollection
{
const bool m_bEndnote;
@@ -465,7 +466,7 @@ public:
SwXFootnotes(bool bEnd, SwDoc* pDoc);
//XIndexAccess
- SW_DLLPUBLIC virtual sal_Int32 SAL_CALL getCount() override;
+ virtual sal_Int32 SAL_CALL getCount() override;
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override;
//XElementAccess
@@ -477,7 +478,7 @@ public:
virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
- SW_DLLPUBLIC rtl::Reference<SwXFootnote> getFootnoteByIndex(sal_Int32 nIndex) ;
+ rtl::Reference<SwXFootnote> getFootnoteByIndex(sal_Int32 nIndex) ;
static rtl::Reference<SwXFootnote> GetObject( SwDoc& rDoc, const SwFormatFootnote& rFormat );
};
diff --git a/sw/inc/unofieldcoll.hxx b/sw/inc/unofieldcoll.hxx
index 658fb27b3130..392b15028dc0 100644
--- a/sw/inc/unofieldcoll.hxx
+++ b/sw/inc/unofieldcoll.hxx
@@ -73,7 +73,7 @@ typedef ::cppu::WeakImplHelper
, css::container::XUniqueIDAccess
> SwXTextFieldTypes_Base;
-class SwXTextFieldTypes final
+class SW_DLLPUBLIC SwXTextFieldTypes final
: public SwXTextFieldTypes_Base
, public SwUnoCollection
{
diff --git a/sw/inc/unoredlines.hxx b/sw/inc/unoredlines.hxx
index a32576e17d57..894f5a0e7937 100644
--- a/sw/inc/unoredlines.hxx
+++ b/sw/inc/unoredlines.hxx
@@ -38,7 +38,7 @@ cppu::WeakImplHelper
css::lang::XServiceInfo
>
SwRedlinesBaseClass;
-class SwXRedlines final : public SwRedlinesBaseClass,
+class SW_DLLPUBLIC SwXRedlines final : public SwRedlinesBaseClass,
public SwUnoCollection
{
virtual ~SwXRedlines() override;
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index 28241df41d82..5815515d8d90 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -554,6 +554,9 @@ public:
rtl::Reference<SwXTextEmbeddedObject> createTextEmbeddedObject();
rtl::Reference<SvXMLEmbeddedObjectHelper> createEmbeddedObjectResolver();
rtl::Reference< SwXStyleFamilies > getSwStyleFamilies();
+ rtl::Reference< SwXRedlines > getSwRedlines();
+ rtl::Reference<SwXTextFieldTypes> getSwTextFields();
+ rtl::Reference<SwXTextFrames> getSwTextFrames();
};
class SwXLinkTargetSupplier final : public cppu::WeakImplHelper
diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx
index 54c8416771b6..041e6cc3d4df 100644
--- a/sw/source/core/unocore/unocoll.cxx
+++ b/sw/source/core/unocore/unocoll.cxx
@@ -869,6 +869,14 @@ sal_Int32 SwXTextTables::getCount()
uno::Any SAL_CALL SwXTextTables::getByIndex(sal_Int32 nInputIndex)
{
+ uno::Reference<XTextTable> xTable = getTextTableByIndex(nInputIndex);
+ uno::Any aRet;
+ aRet <<= xTable;
+ return aRet;
+}
+
+rtl::Reference<SwXTextTable> SwXTextTables::getTextTableByIndex(sal_Int32 nInputIndex)
+{
SolarMutexGuard aGuard;
if (nInputIndex < 0)
@@ -883,10 +891,7 @@ uno::Any SAL_CALL SwXTextTables::getByIndex(sal_Int32 nInputIndex)
--nIndex;
else
{
- uno::Reference<XTextTable> xTable = SwXTextTables::GetObject(*pFormat);
- uno::Any aRet;
- aRet <<= xTable;
- return aRet;
+ return SwXTextTables::GetObject(*pFormat);
}
}
throw IndexOutOfBoundsException();
diff --git a/sw/source/ui/vba/vbaapplication.cxx b/sw/source/ui/vba/vbaapplication.cxx
index 1d1c8ef03806..3310f8688a05 100644
--- a/sw/source/ui/vba/vbaapplication.cxx
+++ b/sw/source/ui/vba/vbaapplication.cxx
@@ -49,11 +49,13 @@
#include <editeng/acorrcfg.hxx>
#include <swdll.hxx>
#include <swmodule.hxx>
+#include <unotxdoc.hxx>
#include "vbalistgalleries.hxx"
#include <tools/urlobj.hxx>
using namespace ::ooo;
using namespace ::ooo::vba;
+using namespace ::ooo::vba::word;
using namespace ::com::sun::star;
namespace {
@@ -113,14 +115,14 @@ SwVbaApplication::getName()
uno::Reference< word::XDocument > SAL_CALL
SwVbaApplication::getActiveDocument()
{
- return new SwVbaDocument( this, mxContext, getCurrentDocument() );
+ return new SwVbaDocument( this, mxContext, getCurrentSwDocument() );
}
rtl::Reference<SwVbaWindow>
SwVbaApplication::getActiveSwVbaWindow()
{
// #FIXME so far can't determine Parent
- uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_SET_THROW );
+ rtl::Reference< SwXTextDocument > xModel( getCurrentSwDocument() );
uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_SET_THROW );
return new SwVbaWindow( uno::Reference< XHelperInterface >(), mxContext, xModel, xController );
}
@@ -165,7 +167,7 @@ SwVbaApplication::CommandBars( const uno::Any& aIndex )
uno::Reference< word::XSelection > SAL_CALL
SwVbaApplication::getSelection()
{
- return new SwVbaSelection( this, mxContext, getCurrentDocument() );
+ return new SwVbaSelection( this, mxContext, getCurrentSwDocument() );
}
uno::Reference< word::XWordBasic > SAL_CALL
@@ -196,7 +198,7 @@ SwVbaApplication::Addins( const uno::Any& index )
uno::Any SAL_CALL
SwVbaApplication::Dialogs( const uno::Any& index )
{
- uno::Reference< word::XDialogs > xCol( new SwVbaDialogs( this, mxContext, getCurrentDocument() ));
+ uno::Reference< word::XDialogs > xCol( new SwVbaDialogs( this, mxContext, getCurrentSwDocument() ));
if ( index.hasValue() )
return xCol->Item( index );
return uno::Any( xCol );
@@ -205,7 +207,7 @@ SwVbaApplication::Dialogs( const uno::Any& index )
uno::Any SAL_CALL
SwVbaApplication::ListGalleries( const uno::Any& index )
{
- uno::Reference< text::XTextDocument > xTextDoc( getCurrentDocument(), uno::UNO_QUERY_THROW );
+ rtl::Reference< SwXTextDocument > xTextDoc( getCurrentSwDocument() );
uno::Reference< XCollection > xCol( new SwVbaListGalleries( this, mxContext, xTextDoc ) );
if ( index.hasValue() )
return xCol->Item( index, uno::Any() );
@@ -330,7 +332,7 @@ void SAL_CALL SwVbaApplication::setCustomizationContext(const uno::Any& /*_custo
void SAL_CALL SwVbaApplication::setStatusBar( const OUString& _statusbar )
{
// ScVbaAppSettings::setStatusBar() also uses the XStatusIndicator to show this, so maybe that is OK?
- uno::Reference< frame::XModel > xModel = getCurrentDocument();
+ rtl::Reference< SwXTextDocument > xModel = getCurrentSwDocument();
if (xModel.is())
{
uno::Reference< task::XStatusIndicatorSupplier > xStatusIndicatorSupplier( xModel->getCurrentController(), uno::UNO_QUERY );
@@ -365,7 +367,7 @@ float SAL_CALL SwVbaApplication::PointsToCentimeters( float Points )
float SAL_CALL SwVbaApplication::PixelsToPoints( float Pixels, ::sal_Bool fVertical )
{
//Set up xDevice
- uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_SET_THROW );
+ rtl::Reference< SwXTextDocument > xModel( getCurrentSwDocument() );
uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_SET_THROW );
uno::Reference< frame::XFrame > xFrame( xController->getFrame(), uno::UNO_SET_THROW );
uno::Reference< awt::XWindow > xWindow( xFrame->getContainerWindow(), uno::UNO_SET_THROW );
@@ -376,7 +378,7 @@ float SAL_CALL SwVbaApplication::PixelsToPoints( float Pixels, ::sal_Bool fVerti
float SAL_CALL SwVbaApplication::PointsToPixels( float Pixels, ::sal_Bool fVertical )
{
- uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_SET_THROW );
+ rtl::Reference< SwXTextDocument > xModel( getCurrentSwDocument() );
uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_SET_THROW );
uno::Reference< frame::XFrame > xFrame( xController->getFrame(), uno::UNO_SET_THROW );
uno::Reference< awt::XWindow > xWindow( xFrame->getContainerWindow(), uno::UNO_SET_THROW );
@@ -491,6 +493,12 @@ SwVbaApplication::getServiceNames()
uno::Reference< frame::XModel >
SwVbaApplication::getCurrentDocument()
{
+ return static_cast<SfxBaseModel*>(getCurrentWordDoc( mxContext ).get());
+}
+
+rtl::Reference< SwXTextDocument >
+SwVbaApplication::getCurrentSwDocument()
+{
return getCurrentWordDoc( mxContext );
}
diff --git a/sw/source/ui/vba/vbaapplication.hxx b/sw/source/ui/vba/vbaapplication.hxx
index 90b4322835fd..cf2e79ab414d 100644
--- a/sw/source/ui/vba/vbaapplication.hxx
+++ b/sw/source/ui/vba/vbaapplication.hxx
@@ -35,6 +35,8 @@
#include "vbawindow.hxx"
+class SwXTextDocument;
+
typedef cppu::ImplInheritanceHelper< VbaApplicationBase, ooo::vba::word::XApplication, ooo::vba::XSinkCaller > SwVbaApplication_BASE;
// This class is currently not a singleton. One instance is created per document with (potential?)
@@ -123,6 +125,8 @@ public:
virtual void SAL_CALL CallSinks( const OUString& Method, css::uno::Sequence< css::uno::Any >& Arguments ) override;
virtual css::uno::Reference< css::frame::XModel > getCurrentDocument() override;
+
+ rtl::Reference<SwXTextDocument> getCurrentSwDocument();
};
#endif // INCLUDED_SW_SOURCE_UI_VBA_VBAAPPLICATION_HXX
diff --git a/sw/source/ui/vba/vbaautotextentry.cxx b/sw/source/ui/vba/vbaautotextentry.cxx
index 051943cd1f41..fcfff74a36b0 100644
--- a/sw/source/ui/vba/vbaautotextentry.cxx
+++ b/sw/source/ui/vba/vbaautotextentry.cxx
@@ -22,8 +22,10 @@
#include <com/sun/star/text/XParagraphCursor.hpp>
#include "wordvbahelper.hxx"
#include "vbarange.hxx"
+#include <unotxdoc.hxx>
using namespace ::ooo::vba;
+using namespace ::ooo::vba::word;
using namespace ::com::sun::star;
SwVbaAutoTextEntry::SwVbaAutoTextEntry( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, uno::Reference< text::XAutoTextEntry > xEntry ) :
@@ -59,11 +61,11 @@ uno::Reference< word::XRange > SAL_CALL SwVbaAutoTextEntry::Insert( const uno::R
if( xParaCursor->isStartOfParagraph() && xParaCursor->isEndOfParagraph() )
{
//remove the blank paragraph
- uno::Reference< frame::XModel > xModel( getCurrentWordDoc( mxContext ), uno::UNO_SET_THROW );
+ rtl::Reference< SwXTextDocument > xModel( getCurrentWordDoc( mxContext ) );
uno::Reference< text::XTextViewCursor > xTVCursor = word::getXTextViewCursor( xModel );
uno::Reference< text::XTextRange > xCurrentRange( xTC->getEnd(), uno::UNO_SET_THROW );
xTVCursor->gotoRange( xCurrentRange, false );
- dispatchRequests( xModel,u".uno:Delete"_ustr );
+ dispatchRequests( static_cast<SfxBaseModel*>(xModel.get()), u".uno:Delete"_ustr );
xTVCursor->gotoRange( xEndMarker->getEnd(), false );
}
}
diff --git a/sw/source/ui/vba/vbabookmark.cxx b/sw/source/ui/vba/vbabookmark.cxx
index e03050b190f9..c94e0a282949 100644
--- a/sw/source/ui/vba/vbabookmark.cxx
+++ b/sw/source/ui/vba/vbabookmark.cxx
@@ -24,16 +24,16 @@
#include <com/sun/star/view/XSelectionSupplier.hpp>
#include <utility>
#include "vbarange.hxx"
+#include <unotxdoc.hxx>
using namespace ::ooo::vba;
using namespace ::com::sun::star;
SwVbaBookmark::SwVbaBookmark( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext,
- css::uno::Reference< frame::XModel > xModel, OUString aBookmarkName ) :
+ rtl::Reference< SwXTextDocument > xModel, OUString aBookmarkName ) :
SwVbaBookmark_BASE( rParent, rContext ), mxModel(std::move( xModel )), maBookmarkName(std::move( aBookmarkName )), mbValid( true )
{
- uno::Reference< text::XBookmarksSupplier > xBookmarksSupplier( mxModel, uno::UNO_QUERY_THROW );
- mxBookmark.set( xBookmarksSupplier->getBookmarks()->getByName( maBookmarkName ), uno::UNO_QUERY_THROW );
+ mxBookmark.set( mxModel->getBookmarks()->getByName( maBookmarkName ), uno::UNO_QUERY_THROW );
}
SwVbaBookmark::~SwVbaBookmark()
@@ -49,8 +49,7 @@ void SwVbaBookmark::checkVality()
void SAL_CALL SwVbaBookmark::Delete()
{
checkVality();
- uno::Reference< text::XTextDocument > xTextDocument( mxModel, uno::UNO_QUERY_THROW );
- xTextDocument->getText()->removeTextContent( mxBookmark );
+ mxModel->getText()->removeTextContent( mxBookmark );
mbValid = false;
}
@@ -75,9 +74,8 @@ void SAL_CALL SwVbaBookmark::setName( const OUString& _name )
uno::Any SAL_CALL SwVbaBookmark::Range()
{
uno::Reference< text::XTextContent > xTextContent( mxBookmark, uno::UNO_SET_THROW );
- uno::Reference< text::XTextDocument > xTextDocument( mxModel, uno::UNO_QUERY_THROW );
uno::Reference< text::XTextRange > xTextRange( xTextContent->getAnchor(), uno::UNO_SET_THROW );
- return uno::Any( uno::Reference< word::XRange>( new SwVbaRange( this, mxContext, xTextDocument, xTextRange->getStart(), xTextRange->getEnd(), xTextRange->getText() ) ) );
+ return uno::Any( uno::Reference< word::XRange>( new SwVbaRange( this, mxContext, mxModel, xTextRange->getStart(), xTextRange->getEnd(), xTextRange->getText() ) ) );
}
OUString
diff --git a/sw/source/ui/vba/vbabookmark.hxx b/sw/source/ui/vba/vbabookmark.hxx
index 24524df618a9..85a2e2b61388 100644
--- a/sw/source/ui/vba/vbabookmark.hxx
+++ b/sw/source/ui/vba/vbabookmark.hxx
@@ -22,13 +22,16 @@
#include <ooo/vba/word/XBookmark.hpp>
#include <vbahelper/vbahelperinterface.hxx>
#include <com/sun/star/text/XTextContent.hpp>
+#include <rtl/ref.hxx>
+
+class SwXTextDocument;
typedef InheritedHelperInterfaceWeakImpl<ooo::vba::word::XBookmark> SwVbaBookmark_BASE;
class SwVbaBookmark : public SwVbaBookmark_BASE
{
private:
- css::uno::Reference<css::frame::XModel> mxModel;
+ rtl::Reference<SwXTextDocument> mxModel;
css::uno::Reference<css::text::XTextContent> mxBookmark;
OUString maBookmarkName;
bool mbValid;
@@ -41,7 +44,7 @@ public:
/// @throws css::uno::RuntimeException
SwVbaBookmark(const css::uno::Reference<ooo::vba::XHelperInterface>& rParent,
const css::uno::Reference<css::uno::XComponentContext>& rContext,
- css::uno::Reference<css::frame::XModel> xModel, OUString aName);
+ rtl::Reference<SwXTextDocument> xModel, OUString aName);
virtual ~SwVbaBookmark() override;
// Methods
diff --git a/sw/source/ui/vba/vbabookmarks.cxx b/sw/source/ui/vba/vbabookmarks.cxx
index 386373cbdb9f..a37f9efc64ea 100644
--- a/sw/source/ui/vba/vbabookmarks.cxx
+++ b/sw/source/ui/vba/vbabookmarks.cxx
@@ -27,6 +27,7 @@
#include "wordvbahelper.hxx"
#include <cppuhelper/implbase.hxx>
#include <utility>
+#include <unotxdoc.hxx>
using namespace ::ooo::vba;
using namespace ::com::sun::star;
@@ -35,10 +36,15 @@ namespace {
class BookmarksEnumeration : public EnumerationHelperImpl
{
- uno::Reference< frame::XModel > mxModel;
+ rtl::Reference< SwXTextDocument > mxModel;
public:
/// @throws uno::RuntimeException
- BookmarksEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, uno::Reference< frame::XModel > xModel ) : EnumerationHelperImpl( xParent, xContext, xEnumeration ), mxModel(std::move( xModel )) {}
+ BookmarksEnumeration( const uno::Reference< XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext >& xContext,
+ const uno::Reference< container::XEnumeration >& xEnumeration,
+ rtl::Reference< SwXTextDocument > xModel )
+ : EnumerationHelperImpl( xParent, xContext, xEnumeration ),
+ mxModel(std::move( xModel )) {}
virtual uno::Any SAL_CALL nextElement( ) override
{
@@ -111,10 +117,13 @@ public:
}
-SwVbaBookmarks::SwVbaBookmarks( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< css::uno::XComponentContext > & xContext, const uno::Reference< container::XIndexAccess >& xBookmarks, uno::Reference< frame::XModel > xModel ): SwVbaBookmarks_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( new BookmarkCollectionHelper( xBookmarks ) ) ), mxModel(std::move( xModel ))
+SwVbaBookmarks::SwVbaBookmarks( const uno::Reference< XHelperInterface >& xParent,
+ const uno::Reference< css::uno::XComponentContext > & xContext,
+ const uno::Reference< container::XIndexAccess >& xBookmarks,
+ rtl::Reference< SwXTextDocument > xModel )
+ : SwVbaBookmarks_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( new BookmarkCollectionHelper( xBookmarks ) ) ),
+ mxModel(std::move( xModel ))
{
- mxBookmarksSupplier.set( mxModel, uno::UNO_QUERY_THROW );
- uno::Reference< text::XTextDocument > xDocument( mxModel, uno::UNO_QUERY_THROW );
}
// XEnumerationAccess
uno::Type
@@ -142,10 +151,9 @@ void SwVbaBookmarks::removeBookmarkByName( const OUString& rName )
word::getXTextViewCursor( mxModel )->getText()->removeTextContent( xBookmark );
}
-void SwVbaBookmarks::addBookmarkByName( const uno::Reference< frame::XModel >& xModel, const OUString& rName, const uno::Reference< text::XTextRange >& rTextRange )
+void SwVbaBookmarks::addBookmarkByName( const rtl::Reference< SwXTextDocument >& xModel, const OUString& rName, const uno::Reference< text::XTextRange >& rTextRange )
{
- uno::Reference< lang::XMultiServiceFactory > xDocMSF( xModel, uno::UNO_QUERY_THROW );
- uno::Reference< text::XTextContent > xBookmark( xDocMSF->createInstance(u"com.sun.star.text.Bookmark"_ustr), uno::UNO_QUERY_THROW );
+ uno::Reference< text::XTextContent > xBookmark( xModel->createInstance(u"com.sun.star.text.Bookmark"_ustr), uno::UNO_QUERY_THROW );
uno::Reference< container::XNamed > xNamed( xBookmark, uno::UNO_QUERY_THROW );
xNamed->setName( rName );
rTextRange->getText()->insertTextContent( rTextRange, xBookmark, false );
diff --git a/sw/source/ui/vba/vbabookmarks.hxx b/sw/source/ui/vba/vbabookmarks.hxx
index 1b264fb6b746..a363f01cfa38 100644
--- a/sw/source/ui/vba/vbabookmarks.hxx
+++ b/sw/source/ui/vba/vbabookmarks.hxx
@@ -24,24 +24,26 @@
#include <com/sun/star/container/XIndexAccess.hpp>
#include <com/sun/star/text/XBookmarksSupplier.hpp>
#include <com/sun/star/text/XTextRange.hpp>
+#include <rtl/ref.hxx>
+
+class SwXTextDocument;
typedef CollTestImplHelper< ooo::vba::word::XBookmarks > SwVbaBookmarks_BASE;
class SwVbaBookmarks : public SwVbaBookmarks_BASE
{
private:
- css::uno::Reference< css::frame::XModel > mxModel;
- css::uno::Reference< css::text::XBookmarksSupplier > mxBookmarksSupplier;
+ rtl::Reference< SwXTextDocument > mxModel;
private:
/// @throws css::uno::RuntimeException
void removeBookmarkByName( const OUString& rName );
public:
- SwVbaBookmarks( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::container::XIndexAccess >& xBookmarks, css::uno::Reference< css::frame::XModel > xModel );
+ SwVbaBookmarks( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::container::XIndexAccess >& xBookmarks, rtl::Reference< SwXTextDocument > xModel );
/// @throws css::uno::RuntimeException
- static void addBookmarkByName( const css::uno::Reference< css::frame::XModel >& xModel, const OUString& rName, const css::uno::Reference< css::text::XTextRange >& rTextRange );
+ static void addBookmarkByName( const rtl::Reference< SwXTextDocument >& xModel, const OUString& rName, const css::uno::Reference< css::text::XTextRange >& rTextRange );
// XEnumerationAccess
virtual css::uno::Type SAL_CALL getElementType() override;
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override;
diff --git a/sw/source/ui/vba/vbacolumn.cxx b/sw/source/ui/vba/vbacolumn.cxx
index fe7837c0f64e..0eeca32e06ed 100644
--- a/sw/source/ui/vba/vbacolumn.cxx
+++ b/sw/source/ui/vba/vbacolumn.cxx
@@ -23,8 +23,11 @@
#include <com/sun/star/table/XCellRange.hpp>
#include <com/sun/star/view/XSelectionSupplier.hpp>
#include "vbatablehelper.hxx"
+#include "wordvbahelper.hxx"
+#include <unotxdoc.hxx>
using namespace ::ooo::vba;
+using namespace ::ooo::vba::word;
using namespace ::com::sun::star;
SwVbaColumn::SwVbaColumn( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, uno::Reference< text::XTextTable > xTextTable, sal_Int32 nIndex ) :
@@ -57,7 +60,7 @@ SwVbaColumn::Select( )
SelectColumn( getCurrentWordDoc(mxContext), mxTextTable, mnIndex, mnIndex );
}
-void SwVbaColumn::SelectColumn( const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XTextTable >& xTextTable, sal_Int32 nStartColumn, sal_Int32 nEndColumn )
+void SwVbaColumn::SelectColumn( const rtl::Reference< SwXTextDocument >& xModel, const uno::Reference< text::XTextTable >& xTextTable, sal_Int32 nStartColumn, sal_Int32 nEndColumn )
{
OUString sStartCol = SwVbaTableHelper::getColumnStr( nStartColumn );
OUString aRangeName = sStartCol + OUString::number( 1 );
diff --git a/sw/source/ui/vba/vbacolumn.hxx b/sw/source/ui/vba/vbacolumn.hxx
index 4fe34de54a1c..d427cfc40a8f 100644
--- a/sw/source/ui/vba/vbacolumn.hxx
+++ b/sw/source/ui/vba/vbacolumn.hxx
@@ -22,6 +22,9 @@
#include <ooo/vba/word/XColumn.hpp>
#include <vbahelper/vbahelperinterface.hxx>
#include <com/sun/star/text/XTextTable.hpp>
+#include <rtl/ref.hxx>
+
+class SwXTextDocument;
typedef InheritedHelperInterfaceWeakImpl< ooo::vba::word::XColumn > SwVbaColumn_BASE;
@@ -42,7 +45,7 @@ public:
virtual void SAL_CALL Select( ) override;
/// @throws css::uno::RuntimeException
- static void SelectColumn( const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::text::XTextTable >& xTextTable, sal_Int32 nStartColumn, sal_Int32 nEndColumn );
+ static void SelectColumn( const rtl::Reference< SwXTextDocument >& xModel, const css::uno::Reference< css::text::XTextTable >& xTextTable, sal_Int32 nStartColumn, sal_Int32 nEndColumn );
// XHelperInterface
virtual OUString getServiceImplName() override;
diff --git a/sw/source/ui/vba/vbacolumns.cxx b/sw/source/ui/vba/vbacolumns.cxx
index 70272548c940..612443f34301 100644
--- a/sw/source/ui/vba/vbacolumns.cxx
+++ b/sw/source/ui/vba/vbacolumns.cxx
@@ -21,8 +21,11 @@
#include "vbacolumns.hxx"
#include "vbacolumn.hxx"
#include "vbatablehelper.hxx"
+#include "wordvbahelper.hxx"
+#include <unotxdoc.hxx>
using namespace ::ooo::vba;
+using namespace ::ooo::vba::word;
using namespace ::com::sun::star;
namespace {
diff --git a/sw/source/ui/vba/vbacontentcontrol.cxx b/sw/source/ui/vba/vbacontentcontrol.cxx
index 3646804436c7..a127d80636d6 100644
--- a/sw/source/ui/vba/vbacontentcontrol.cxx
+++ b/sw/source/ui/vba/vbacontentcontrol.cxx
@@ -20,6 +20,7 @@
#include "vbacontentcontrol.hxx"
#include "vbacontentcontrollistentries.hxx"
#include "vbarange.hxx"
+#include <unotxdoc.hxx>
using namespace ::ooo::vba;
using namespace ::com::sun::star;
@@ -33,7 +34,7 @@ using namespace ::com::sun::star;
*/
SwVbaContentControl::SwVbaContentControl(const uno::Reference<XHelperInterface>& rParent,
const uno::Reference<uno::XComponentContext>& rContext,
- const uno::Reference<text::XTextDocument>& xTextDocument,
+ const rtl::Reference<SwXTextDocument>& xTextDocument,
std::shared_ptr<SwContentControl> pContentControl)
: SwVbaContentControl_BASE(rParent, rContext)
, mxTextDocument(xTextDocument)
diff --git a/sw/source/ui/vba/vbacontentcontrol.hxx b/sw/source/ui/vba/vbacontentcontrol.hxx
index 9f98b92468b5..ba66d335ec10 100644
--- a/sw/source/ui/vba/vbacontentcontrol.hxx
+++ b/sw/source/ui/vba/vbacontentcontrol.hxx
@@ -14,20 +14,23 @@
#include <vbahelper/vbahelperinterface.hxx>
#include <textcontentcontrol.hxx>
+#include <rtl/ref.hxx>
+
+class SwXTextDocument;
typedef InheritedHelperInterfaceWeakImpl<ooo::vba::word::XContentControl> SwVbaContentControl_BASE;
class SwVbaContentControl : public SwVbaContentControl_BASE
{
private:
- css::uno::Reference<css::text::XTextDocument> mxTextDocument;
+ rtl::Reference<SwXTextDocument> mxTextDocument;
std::shared_ptr<SwContentControl> m_pCC;
public:
/// @throws css::uno::RuntimeException
SwVbaContentControl(const css::uno::Reference<ooo::vba::XHelperInterface>& rParent,
const css::uno::Reference<css::uno::XComponentContext>& rContext,
- const css::uno::Reference<css::text::XTextDocument>& xTextDocument,
+ const rtl::Reference<SwXTextDocument>& xTextDocument,
std::shared_ptr<SwContentControl> pContentControl);
~SwVbaContentControl() override;
diff --git a/sw/source/ui/vba/vbacontentcontrols.cxx b/sw/source/ui/vba/vbacontentcontrols.cxx
index 8383aee7e3f8..ce9e63b66583 100644
--- a/sw/source/ui/vba/vbacontentcontrols.cxx
+++ b/sw/source/ui/vba/vbacontentcontrols.cxx
@@ -17,6 +17,7 @@
#include "vbacontentcontrol.hxx"
#include "vbacontentcontrols.hxx"
#include "wordvbahelper.hxx"
+#include <unotxdoc.hxx>
using namespace ::ooo::vba;
using namespace ::com::sun::star;
@@ -29,10 +30,10 @@ using namespace ::com::sun::star;
static std::shared_ptr<SwContentControl>
lcl_getContentControl(std::u16string_view sName, std::u16string_view sTag,
std::u16string_view sTitle, sal_Int32& rIndex,
- const uno::Reference<text::XTextDocument>& xTextDocument,
+ const rtl::Reference<SwXTextDocument>& xTextDocument,
uno::Sequence<OUString>* pElementNames = nullptr)
{
- SwDoc* pDoc = word::getDocShell(xTextDocument)->GetDoc();
+ SwDoc* pDoc = xTextDocument->GetDocShell()->GetDoc();
if (!pDoc)
return nullptr;
@@ -126,7 +127,7 @@ class ContentControlCollectionHelper
private:
uno::Reference<XHelperInterface> mxParent;
uno::Reference<uno::XComponentContext> mxContext;
- uno::Reference<text::XTextDocument> mxTextDocument;
+ rtl::Reference<SwXTextDocument> mxTextDocument;
const OUString m_sTag;
const OUString m_sTitle;
std::shared_ptr<SwContentControl> m_pCache;
@@ -135,7 +136,7 @@ public:
/// @throws css::uno::RuntimeException
ContentControlCollectionHelper(uno::Reference<ov::XHelperInterface> xParent,
uno::Reference<uno::XComponentContext> xContext,
- uno::Reference<text::XTextDocument> xTextDocument,
+ rtl::Reference<SwXTextDocument> xTextDocument,
const OUString& rTag, const OUString& rTitle)
: mxParent(std::move(xParent))
@@ -217,7 +218,7 @@ public:
*/
SwVbaContentControls::SwVbaContentControls(const uno::Reference<XHelperInterface>& xParent,
const uno::Reference<uno::XComponentContext>& xContext,
- const uno::Reference<text::XTextDocument>& xTextDocument,
+ const rtl::Reference<SwXTextDocument>& xTextDocument,
const OUString& rTag, const OUString& rTitle)
: SwVbaContentControls_BASE(
xParent, xContext,
diff --git a/sw/source/ui/vba/vbacontentcontrols.hxx b/sw/source/ui/vba/vbacontentcontrols.hxx
index 20ff65ae8943..5bdfaf5f364f 100644
--- a/sw/source/ui/vba/vbacontentcontrols.hxx
+++ b/sw/source/ui/vba/vbacontentcontrols.hxx
@@ -12,6 +12,9 @@
#include <ooo/vba/word/XContentControls.hpp>
#include <vbahelper/vbacollectionimpl.hxx>
+#include <rtl/ref.hxx>
+
+class SwXTextDocument;
typedef CollTestImplHelper<ooo::vba::word::XContentControls> SwVbaContentControls_BASE;
@@ -21,8 +24,8 @@ public:
/// @throws css::uno::RuntimeException
SwVbaContentControls(const css::uno::Reference<ov::XHelperInterface>& xParent,
const css::uno::Reference<css::uno::XComponentContext>& xContext,
- const css::uno::Reference<css::text::XTextDocument>& xTextDocument,
- const OUString& rTag, const OUString& rTitle);
+ const rtl::Reference<SwXTextDocument>& xTextDocument, const OUString& rTag,
+ const OUString& rTitle);
// XContentControls
//css::uno::Reference<ooo::vba::word::XContentControl> SAL_CALL Add(const css::uno::Any& Type, const css::uno::Any& Range) override;
diff --git a/sw/source/ui/vba/vbadialog.cxx b/sw/source/ui/vba/vbadialog.cxx
index 5661851e7661..d4c224dfecde 100644
--- a/sw/source/ui/vba/vbadialog.cxx
+++ b/sw/source/ui/vba/vbadialog.cxx
@@ -18,6 +18,7 @@
*/
#include "vbadialog.hxx"
#include <ooo/vba/word/WdWordDialog.hpp>
+#include <unotxdoc.hxx>
using namespace ::ooo::vba;
using namespace ::com::sun::star;
@@ -41,6 +42,17 @@ const WordDialogTable aWordDialogTable[] =
{ 0, nullptr }
};
+SwVbaDialog::SwVbaDialog( const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext > & xContext,
+ const rtl::Reference< SwXTextDocument >& xModel,
+ sal_Int32 nIndex )
+ : SwVbaDialog_BASE( xParent, xContext, nIndex ), m_xModel(xModel) {}
+
+css::uno::Reference< css::frame::XModel > SwVbaDialog::getModel() const
+{
+ return static_cast<SfxBaseModel*>(m_xModel.get());
+}
+
OUString
SwVbaDialog::mapIndexToName( sal_Int32 nIndex )
{
diff --git a/sw/source/ui/vba/vbadialog.hxx b/sw/source/ui/vba/vbadialog.hxx
index df4443446f63..8ccbc4c44762 100644
--- a/sw/source/ui/vba/vbadialog.hxx
+++ b/sw/source/ui/vba/vbadialog.hxx
@@ -22,19 +22,29 @@
#include <cppuhelper/implbase.hxx>
#include <ooo/vba/word/XDialog.hpp>
#include <vbahelper/vbadialogbase.hxx>
+#include <rtl/ref.hxx>
+
+class SwXTextDocument;
typedef cppu::ImplInheritanceHelper< VbaDialogBase, ov::word::XDialog > SwVbaDialog_BASE;
class SwVbaDialog : public SwVbaDialog_BASE
{
public:
- SwVbaDialog( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::frame::XModel >& xModel, sal_Int32 nIndex ):SwVbaDialog_BASE( xParent, xContext, xModel, nIndex ) {}
+ SwVbaDialog( const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext > & xContext,
+ const rtl::Reference< SwXTextDocument >& xModel,
+ sal_Int32 nIndex );
// Methods
virtual OUString mapIndexToName( sal_Int32 nIndex ) override;
// XHelperInterface
virtual OUString getServiceImplName() override;
virtual css::uno::Sequence<OUString> getServiceNames() override;
+
+ virtual css::uno::Reference< css::frame::XModel > getModel() const override;
+private:
+ rtl::Reference< SwXTextDocument > m_xModel;
};
#endif // INCLUDED_SW_SOURCE_UI_VBA_VBADIALOG_HXX
diff --git a/sw/source/ui/vba/vbadialogs.cxx b/sw/source/ui/vba/vbadialogs.cxx
index c77fd0de91cd..60adb7885fff 100644
--- a/sw/source/ui/vba/vbadialogs.cxx
+++ b/sw/source/ui/vba/vbadialogs.cxx
@@ -19,10 +19,16 @@
#include <ooo/vba/word/XDialog.hpp>
#include "vbadialogs.hxx"
#include "vbadialog.hxx"
+#include <unotxdoc.hxx>
using namespace ::ooo::vba;
using namespace ::com::sun::star;
+SwVbaDialogs::SwVbaDialogs( const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext > &xContext,
+ const rtl::Reference< SwXTextDocument >& xModel )
+ : SwVbaDialogs_BASE( xParent, xContext ), m_xModel(xModel) {}
+
uno::Any
SwVbaDialogs::Item( const uno::Any &aItem )
{
diff --git a/sw/source/ui/vba/vbadialogs.hxx b/sw/source/ui/vba/vbadialogs.hxx
index 3703868f1be4..25080c3c16df 100644
--- a/sw/source/ui/vba/vbadialogs.hxx
+++ b/sw/source/ui/vba/vbadialogs.hxx
@@ -23,13 +23,18 @@
#include <ooo/vba/word/XDialogs.hpp>
#include <vbahelper/vbadialogsbase.hxx>
#include <cppuhelper/implbase.hxx>
+#include <rtl/ref.hxx>
+
+class SwXTextDocument;
typedef cppu::ImplInheritanceHelper< VbaDialogsBase, ov::word::XDialogs > SwVbaDialogs_BASE;
class SwVbaDialogs : public SwVbaDialogs_BASE
{
public:
- SwVbaDialogs( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::frame::XModel >& xModel ): SwVbaDialogs_BASE( xParent, xContext, xModel ) {}
+ SwVbaDialogs( const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext > &xContext,
+ const rtl::Reference< SwXTextDocument >& xModel );
// XCollection
virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index ) override;
@@ -37,6 +42,8 @@ public:
// XHelperInterface
virtual OUString getServiceImplName() override;
virtual css::uno::Sequence<OUString> getServiceNames() override;
+private:
+ rtl::Reference< SwXTextDocument > m_xModel;
};
#endif // INCLUDED_SW_SOURCE_UI_VBA_VBADIALOGS_HXX
diff --git a/sw/source/ui/vba/vbadocument.cxx b/sw/source/ui/vba/vbadocument.cxx
index c7a110d016ef..b742f6f843e1 100644
--- a/sw/source/ui/vba/vbadocument.cxx
+++ b/sw/source/ui/vba/vbadocument.cxx
@@ -67,6 +67,10 @@
#include <basic/sberrors.hxx>
#include <osl/file.hxx>
#include <tools/urlobj.hxx>
+#include <unotxdoc.hxx>
+#include <unoredlines.hxx>
+#include <unodraw.hxx>
+#include <unobasestyle.hxx>
using namespace ::ooo::vba;
using namespace ::com::sun::star;
@@ -88,11 +92,18 @@ public:
}
-SwVbaDocument::SwVbaDocument( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, uno::Reference< frame::XModel > const & xModel ): SwVbaDocument_BASE( xParent, xContext, xModel )
+SwVbaDocument::SwVbaDocument( const uno::Reference< XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext >& xContext,
+ rtl::Reference< SwXTextDocument > const & xModel )
+ : SwVbaDocument_BASE( xParent, xContext ),
+ mxTextDocument(xModel)
{
Initialize();
}
-SwVbaDocument::SwVbaDocument( uno::Sequence< uno::Any > const& aArgs, uno::Reference< uno::XComponentContext >const& xContext ) : SwVbaDocument_BASE( aArgs, xContext )
+
+SwVbaDocument::SwVbaDocument( uno::Sequence< uno::Any > const& aArgs, uno::Reference< uno::XComponentContext >const& xContext )
+ : SwVbaDocument_BASE( aArgs, xContext ),
+ mxTextDocument(dynamic_cast<SwXTextDocument*>(getXSomethingFromArgs< frame::XModel >( aArgs, 1 ).get()))
{
Initialize();
}
@@ -103,8 +114,7 @@ SwVbaDocument::~SwVbaDocument()
void SwVbaDocument::Initialize()
{
- mxTextDocument.set( getModel(), uno::UNO_QUERY_THROW );
- SwDocShell& rDocSh = *word::getDocShell(mxModel);
+ SwDocShell& rDocSh = *mxTextDocument->GetDocShell();
rDocSh.RegisterAutomationDocumentObject(this);
rDocSh.GetDoc()->SetVbaEventProcessor();
}
@@ -112,7 +122,7 @@ void SwVbaDocument::Initialize()
sal_uInt32
SwVbaDocument::AddSink( const uno::Reference< XSink >& xSink )
{
- word::getDocShell( mxModel )->RegisterAutomationDocumentEventsCaller( uno::Reference< XSinkCaller >(this) );
+ mxTextDocument->GetDocShell()->RegisterAutomationDocumentEventsCaller( uno::Reference< XSinkCaller >(this) );
mvSinks.push_back(xSink);
return mvSinks.size();
}
@@ -193,7 +203,7 @@ SwVbaDocument::Range( const uno::Any& rStart, const uno::Any& rEnd )
uno::Any SAL_CALL
SwVbaDocument::BuiltInDocumentProperties( const uno::Any& index )
{
- uno::Reference< XCollection > xCol( new SwVbaBuiltinDocumentProperties( mxParent, mxContext, getModel() ) );
+ uno::Reference< XCollection > xCol( new SwVbaBuiltinDocumentProperties( mxParent, mxContext, mxTextDocument ) );
if ( index.hasValue() )
return xCol->Item( index, uno::Any() );
return uno::Any( xCol );
@@ -202,7 +212,7 @@ SwVbaDocument::BuiltInDocumentProperties( const uno::Any& index )
uno::Any SAL_CALL
SwVbaDocument::CustomDocumentProperties( const uno::Any& index )
{
- uno::Reference< XCollection > xCol( new SwVbaCustomDocumentProperties( mxParent, mxContext, getModel() ) );
+ uno::Reference< XCollection > xCol( new SwVbaCustomDocumentProperties( mxParent, mxContext, mxTextDocument ) );
if ( index.hasValue() )
return xCol->Item( index, uno::Any() );
return uno::Any( xCol );
@@ -213,13 +223,16 @@ SwVbaDocument::Bookmarks( const uno::Any& rIndex )
{
uno::Reference< text::XBookmarksSupplier > xBookmarksSupplier( getModel(),uno::UNO_QUERY_THROW );
uno::Reference<container::XIndexAccess > xBookmarks( xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY_THROW );
- uno::Reference< XCollection > xBookmarksVba( new SwVbaBookmarks( this, mxContext, xBookmarks, getModel() ) );
+ uno::Reference< XCollection > xBookmarksVba( new SwVbaBookmarks( this, mxContext, xBookmarks, mxTextDocument ) );
if ( rIndex.getValueTypeClass() == uno::TypeClass_VOID )
return uno::Any( xBookmarksVba );
return xBookmarksVba->Item( rIndex, uno::Any() );
}
+uno::Reference< frame::XModel > SwVbaDocument::getModel() const
+{ return static_cast<SfxBaseModel*>(mxTextDocument.get()); }
+
uno::Any SwVbaDocument::ContentControls(const uno::Any& index)
{
uno::Reference<XCollection> xContentControls(
@@ -266,8 +279,8 @@ uno::Any SwVbaDocument::SelectContentControlsByTitle(const uno::Any& index)
uno::Reference<word::XWindow> SwVbaDocument::getActiveWindow()
{
// copied from vbaapplication which has a #FIXME so far can't determine Parent
- return new SwVbaWindow(uno::Reference< XHelperInterface >(), mxContext, mxModel,
- mxModel->getCurrentController());
+ return new SwVbaWindow(uno::Reference< XHelperInterface >(), mxContext, mxTextDocument,
+ mxTextDocument->getCurrentController());
}
uno::Any SAL_CALL
@@ -296,7 +309,7 @@ SwVbaDocument::Paragraphs( const uno::Any& index )
uno::Any SAL_CALL
SwVbaDocument::Styles( const uno::Any& index )
{
- uno::Reference< XCollection > xCol( new SwVbaStyles( mxParent, mxContext, getModel() ) );
+ uno::Reference< XCollection > xCol( new SwVbaStyles( mxParent, mxContext, mxTextDocument ) );
if ( index.hasValue() )
return xCol->Item( index, uno::Any() );
return uno::Any( xCol );
@@ -305,7 +318,7 @@ SwVbaDocument::Styles( const uno::Any& index )
uno::Any SAL_CALL
SwVbaDocument::Fields( const uno::Any& index )
{
- uno::Reference< XCollection > xCol( new SwVbaFields( mxParent, mxContext, getModel() ) );
+ uno::Reference< XCollection > xCol( new SwVbaFields( mxParent, mxContext, mxTextDocument ) );
if ( index.hasValue() )
return xCol->Item( index, uno::Any() );
return uno::Any( xCol );
@@ -314,10 +327,8 @@ SwVbaDocument::Fields( const uno::Any& index )
uno::Any SAL_CALL
SwVbaDocument::Shapes( const uno::Any& index )
{
- uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( getModel(), uno::UNO_QUERY_THROW );
- uno::Reference< container::XIndexAccess > xIndexAccess( xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY_THROW );
- uno::Reference< frame::XModel > xModel( mxTextDocument, uno::UNO_QUERY_THROW );
- uno::Reference< XCollection > xCol( new ScVbaShapes( this, mxContext, xIndexAccess, xModel ) );
+ rtl::Reference< SwFmDrawPage > xIndexAccess( mxTextDocument->getSwDrawPage() );
+ uno::Reference< XCollection > xCol( new ScVbaShapes( this, mxContext, xIndexAccess, static_cast<SfxBaseModel*>(mxTextDocument.get()) ) );
if ( index.hasValue() )
return xCol->Item( index, uno::Any() );
@@ -335,7 +346,7 @@ SwVbaDocument::Select()
uno::Any SAL_CALL
SwVbaDocument::Sections( const uno::Any& index )
{
- uno::Reference< XCollection > xCol( new SwVbaSections( mxParent, mxContext, getModel() ) );
+ uno::Reference< XCollection > xCol( new SwVbaSections( mxParent, mxContext, mxTextDocument ) );
if ( index.hasValue() )
return xCol->Item( index, uno::Any() );
return uno::Any( xCol );
@@ -361,8 +372,8 @@ uno::Any SAL_CALL SwVbaDocument::FormFields(const uno::Any& index)
uno::Any SAL_CALL
SwVbaDocument::PageSetup( )
{
- uno::Reference< beans::XPropertySet > xPageProps( word::getCurrentPageStyle( mxModel ), uno::UNO_QUERY_THROW );
- return uno::Any( uno::Reference< word::XPageSetup >( new SwVbaPageSetup( this, mxContext, mxModel, xPageProps ) ) );
+ rtl::Reference< SwXBaseStyle > xPageProps( word::getCurrentPageStyle( mxTextDocument ) );
+ return uno::Any( uno::Reference< word::XPageSetup >( new SwVbaPageSetup( this, mxContext, mxTextDocument, xPageProps ) ) );
}
OUString
@@ -409,8 +420,7 @@ SwVbaDocument::setAttachedTemplate( const css::uno::Any& _attachedtemplate )
uno::Any SAL_CALL
SwVbaDocument::Tables( const css::uno::Any& aIndex )
{
- uno::Reference< frame::XModel > xModel( mxTextDocument, uno::UNO_QUERY_THROW );
- uno::Reference< XCollection > xColl( new SwVbaTables( mxParent, mxContext, xModel ) );
+ uno::Reference< XCollection > xColl( new SwVbaTables( mxParent, mxContext, mxTextDocument ) );
if ( aIndex.hasValue() )
return xColl->Item( aIndex, uno::Any() );
@@ -448,7 +458,7 @@ sal_Bool SAL_CALL SwVbaDocument::getAutoHyphenation()
{
// check this property only in default paragraph style
bool IsAutoHyphenation = false;
- uno::Reference< beans::XPropertySet > xParaProps( word::getDefaultParagraphStyle( getModel() ), uno::UNO_QUERY_THROW );
+ rtl::Reference< SwXBaseStyle > xParaProps( word::getDefaultParagraphStyle( mxTextDocument ) );
xParaProps->getPropertyValue(u"ParaIsHyphenation"_ustr) >>= IsAutoHyphenation;
return IsAutoHyphenation;
}
@@ -456,7 +466,7 @@ sal_Bool SAL_CALL SwVbaDocument::getAutoHyphenation()
void SAL_CALL SwVbaDocument::setAutoHyphenation( sal_Bool _autohyphenation )
{
//TODO
- uno::Reference< beans::XPropertySet > xParaProps( word::getDefaultParagraphStyle( getModel() ), uno::UNO_QUERY_THROW );
+ rtl::Reference< SwXBaseStyle > xParaProps( word::getDefaultParagraphStyle( mxTextDocument ) );
xParaProps->setPropertyValue(u"ParaIsHyphenation"_ustr, uno::Any( _autohyphenation ) );
}
@@ -475,7 +485,7 @@ void SAL_CALL SwVbaDocument::setHyphenationZone( ::sal_Int32 /*_hyphenationzone*
{
//TODO
sal_Int16 nHyphensLimit = 0;
- uno::Reference< beans::XPropertySet > xParaProps( word::getDefaultParagraphStyle( getModel() ), uno::UNO_QUERY_THROW );
+ rtl::Reference< SwXBaseStyle > xParaProps( word::getDefaultParagraphStyle( mxTextDocument ) );
xParaProps->getPropertyValue(u"ParaHyphenationMaxHyphens"_ustr) >>= nHyphensLimit;
return nHyphensLimit;
}
@@ -483,7 +493,7 @@ void SAL_CALL SwVbaDocument::setHyphenationZone( ::sal_Int32 /*_hyphenationzone*
void SAL_CALL SwVbaDocument::setConsecutiveHyphensLimit( ::sal_Int32 _consecutivehyphenslimit )
{
sal_Int16 nHyphensLimit = static_cast< sal_Int16 >( _consecutivehyphenslimit );
- uno::Reference< beans::XPropertySet > xParaProps( word::getDefaultParagraphStyle( getModel() ), uno::UNO_QUERY_THROW );
+ rtl::Reference< SwXBaseStyle > xParaProps( word::getDefaultParagraphStyle( mxTextDocument ) );
xParaProps->setPropertyValue(u"ParaHyphenationMaxHyphens"_ustr, uno::Any( nHyphensLimit ) );
}
@@ -505,20 +515,19 @@ void SAL_CALL SwVbaDocument::PrintOut( const uno::Any& /*Background*/, const uno
void SAL_CALL SwVbaDocument::PrintPreview( )
{
- dispatchRequests( mxModel,u".uno:PrintPreview"_ustr );
+ dispatchRequests( static_cast<SfxBaseModel*>(mxTextDocument.get()), u".uno:PrintPreview"_ustr );
}
void SAL_CALL SwVbaDocument::ClosePrintPreview( )
{
- dispatchRequests( mxModel,u".uno:ClosePreview"_ustr );
+ dispatchRequests( static_cast<SfxBaseModel*>(mxTextDocument.get()), u".uno:ClosePreview"_ustr );
}
uno::Any SAL_CALL
SwVbaDocument::Revisions( const uno::Any& index )
{
- uno::Reference< css::document::XRedlinesSupplier > xRedlinesSupp( mxTextDocument, uno::UNO_QUERY_THROW );
- uno::Reference< container::XIndexAccess > xRedlines( xRedlinesSupp->getRedlines(), uno::UNO_QUERY_THROW );
- uno::Reference< XCollection > xCol( new SwVbaRevisions( this, mxContext, getModel(), xRedlines ) );
+ rtl::Reference< SwXRedlines > xRedlines( mxTextDocument->getSwRedlines() );
+ uno::Reference< XCollection > xCol( new SwVbaRevisions( this, mxContext, mxTextDocument, xRedlines ) );
if ( index.hasValue() )
return xCol->Item( index, uno::Any() );
return uno::Any( xCol );
@@ -527,9 +536,8 @@ SwVbaDocument::Revisions( const uno::Any& index )
uno::Any SAL_CALL
SwVbaDocument::Frames( const uno::Any& index )
{
- uno::Reference< text::XTextFramesSupplier > xTextFramesSupp( mxTextDocument, uno::UNO_QUERY_THROW );
- uno::Reference< container::XIndexAccess > xFrames( xTextFramesSupp->getTextFrames(), uno::UNO_QUERY_THROW );
- uno::Reference< XCollection > xCol( new SwVbaFrames( this, mxContext, xFrames, getModel() ) );
+ rtl::Reference< SwXTextFrames > xFrames( mxTextDocument->getSwTextFrames() );
+ uno::Reference< XCollection > xCol( new SwVbaFrames( this, mxContext, xFrames, mxTextDocument ) );
if ( index.hasValue() )
return xCol->Item( index, uno::Any() );
return uno::Any( xCol );
@@ -621,8 +629,7 @@ SwVbaDocument::SavePreviewPngAs( const uno::Any& FileName )
uno::Any
SwVbaDocument::getControlShape( std::u16string_view sName )
{
- uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( mxTextDocument, uno::UNO_QUERY_THROW );
- uno::Reference< container::XIndexAccess > xIndexAccess( xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY_THROW );
+ rtl::Reference< SwFmDrawPage > xIndexAccess( mxTextDocument->getSwDrawPage() );
sal_Int32 nCount = xIndexAccess->getCount();
for( int index = 0; index < nCount; index++ )
@@ -692,10 +699,7 @@ SwVbaDocument::getFormControls() const
uno::Reference< container::XNameAccess > xFormControls;
try
{
- uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( mxTextDocument, uno::UNO_QUERY );
- if (!xDrawPageSupplier)
- return xFormControls;
- uno::Reference< form::XFormsSupplier > xFormSupplier( xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY );
+ rtl::Reference< SwFmDrawPage > xFormSupplier( mxTextDocument->getSwDrawPage() );
if (!xFormSupplier)
return xFormControls;
uno::Reference< container::XIndexAccess > xIndexAccess( xFormSupplier->getForms(), uno::UNO_QUERY );
diff --git a/sw/source/ui/vba/vbadocument.hxx b/sw/source/ui/vba/vbadocument.hxx
index 069215513cc5..aeaedecedd1d 100644
--- a/sw/source/ui/vba/vbadocument.hxx
+++ b/sw/source/ui/vba/vbadocument.hxx
@@ -25,15 +25,18 @@
#include <vbahelper/vbadocumentbase.hxx>
#include <com/sun/star/text/XTextDocument.hpp>
#include <cppuhelper/implbase.hxx>
+#include <rtl/ref.hxx>
#include <vector>
+class SwXTextDocument;
+
typedef cppu::ImplInheritanceHelper< VbaDocumentBase, ooo::vba::word::XDocument, ooo::vba::XSinkCaller > SwVbaDocument_BASE;
class SwVbaDocument : public SwVbaDocument_BASE
{
private:
- css::uno::Reference< css::text::XTextDocument > mxTextDocument;
+ rtl::Reference< SwXTextDocument > mxTextDocument;
std::vector<css::uno::Reference< ooo::vba::XSink >> mvSinks;
@@ -41,8 +44,11 @@ private:
css::uno::Any getControlShape( std::u16string_view sName );
css::uno::Reference< css::container::XNameAccess > getFormControls() const;
+protected:
+ virtual css::uno::Reference< css::frame::XModel > getModel() const override;
+
public:
- SwVbaDocument( const css::uno::Reference< ooo::vba::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& m_xContext, css::uno::Reference< css::frame::XModel > const & xModel );
+ SwVbaDocument( const css::uno::Reference< ooo::vba::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& m_xContext, rtl::Reference< SwXTextDocument > const & xModel );
SwVbaDocument( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext >const& xContext );
virtual ~SwVbaDocument() override;
diff --git a/sw/source/ui/vba/vbadocumentproperties.cxx b/sw/source/ui/vba/vbadocumentproperties.cxx
index 3cdeba36e5ac..05471640e1af 100644
--- a/sw/source/ui/vba/vbadocumentproperties.cxx
+++ b/sw/source/ui/vba/vbadocumentproperties.cxx
@@ -30,7 +30,9 @@
#include "wordvbahelper.hxx"
#include <fesh.hxx>
#include <docsh.hxx>
+#include <unotxdoc.hxx>
#include <utility>
+
using namespace ::ooo::vba;
using namespace css;
@@ -67,15 +69,12 @@ namespace {
class PropertGetSetHelper
{
protected:
- uno::Reference< frame::XModel > m_xModel;
+ rtl::Reference< SwXTextDocument > m_xModel;
uno::Reference<document::XDocumentProperties> m_xDocProps;
public:
- explicit PropertGetSetHelper( uno::Reference< frame::XModel > xModel ):m_xModel(std::move( xModel ))
+ explicit PropertGetSetHelper( rtl::Reference< SwXTextDocument > xModel ) : m_xModel(std::move( xModel ))
{
- uno::Reference<document::XDocumentPropertiesSupplier> const
- xDocPropSupp(m_xModel, uno::UNO_QUERY_THROW);
- m_xDocProps.set(xDocPropSupp->getDocumentProperties(),
- uno::UNO_SET_THROW);
+ m_xDocProps.set(m_xModel->getDocumentProperties(), uno::UNO_SET_THROW);
}
virtual ~PropertGetSetHelper() {}
virtual uno::Any getPropertyValue( const OUString& rPropName ) = 0;
@@ -90,7 +89,7 @@ public:
class BuiltinPropertyGetSetHelper : public PropertGetSetHelper
{
public:
- explicit BuiltinPropertyGetSetHelper( const uno::Reference< frame::XModel >& xModel ) :PropertGetSetHelper( xModel )
+ explicit BuiltinPropertyGetSetHelper( const rtl::Reference< SwXTextDocument >& xModel ) :PropertGetSetHelper( xModel )
{
}
virtual uno::Any getPropertyValue( const OUString& rPropName ) override
@@ -271,7 +270,7 @@ public:
class CustomPropertyGetSetHelper : public BuiltinPropertyGetSetHelper
{
public:
- explicit CustomPropertyGetSetHelper( const uno::Reference< frame::XModel >& xModel ) :BuiltinPropertyGetSetHelper( xModel )
+ explicit CustomPropertyGetSetHelper( const rtl::Reference< SwXTextDocument >& xModel ) :BuiltinPropertyGetSetHelper( xModel )
{
}
virtual uno::Any getPropertyValue( const OUString& rPropName ) override
@@ -288,12 +287,10 @@ public:
class StatisticPropertyGetSetHelper : public PropertGetSetHelper
{
SwDocShell* mpDocShell;
- uno::Reference< beans::XPropertySet > mxModelProps;
public:
- explicit StatisticPropertyGetSetHelper( const uno::Reference< frame::XModel >& xModel ) :PropertGetSetHelper( xModel ) , mpDocShell( nullptr )
+ explicit StatisticPropertyGetSetHelper( const rtl::Reference< SwXTextDocument >& xModel ) :PropertGetSetHelper( xModel ) , mpDocShell( nullptr )
{
- mxModelProps.set( m_xModel, uno::UNO_QUERY_THROW );
- mpDocShell = word::getDocShell( xModel );
+ mpDocShell = m_xModel->GetDocShell();
}
virtual uno::Any getPropertyValue( const OUString& rPropName ) override
{
@@ -301,7 +298,7 @@ public:
{
// Characters, ParagraphCount & WordCount are available from
// the model ( and additionally these also update the statics object )
- return mxModelProps->getPropertyValue( rPropName );
+ return m_xModel->getPropertyValue( rPropName );
}
catch (const uno::Exception&)
{
@@ -398,7 +395,7 @@ class BuiltInIndexHelper
MSOIndexToOODocPropInfo m_docPropInfoMap;
public:
- explicit BuiltInIndexHelper( const uno::Reference< frame::XModel >& xModel )
+ explicit BuiltInIndexHelper( const rtl::Reference< SwXTextDocument >& xModel )
{
auto aStandardHelper = std::make_shared<BuiltinPropertyGetSetHelper>( xModel );
auto aUsingStatsHelper = std::make_shared<StatisticPropertyGetSetHelper>( xModel );
@@ -672,13 +669,13 @@ class BuiltInPropertiesImpl : public PropertiesImpl_BASE
{
protected:
- uno::Reference< frame::XModel > m_xModel;
+ rtl::Reference< SwXTextDocument > m_xModel;
DocProps mDocProps;
DocPropsByName mNamedDocProps;
public:
- BuiltInPropertiesImpl( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, uno::Reference< frame::XModel > xModel ) : m_xModel(std::move( xModel ))
+ BuiltInPropertiesImpl( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, rtl::Reference< SwXTextDocument > xModel ) : m_xModel(std::move( xModel ))
{
BuiltInIndexHelper builtIns( m_xModel );
for ( sal_Int32 index = word::WdBuiltInProperty::wdPropertyTitle; index <= word::WdBuiltInProperty::wdPropertyCharsWSpaces; ++index )
@@ -744,7 +741,11 @@ protected:
}
-SwVbaBuiltinDocumentProperties::SwVbaBuiltinDocumentProperties( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : SwVbaDocumentproperties_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( new BuiltInPropertiesImpl( xParent, xContext, xModel ) ) )
+SwVbaBuiltinDocumentProperties::SwVbaBuiltinDocumentProperties(
+ const uno::Reference< XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext >& xContext,
+ const rtl::Reference< SwXTextDocument >& xModel )
+: SwVbaDocumentproperties_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( new BuiltInPropertiesImpl( xParent, xContext, xModel ) ) )
{
}
@@ -799,11 +800,16 @@ class CustomPropertiesImpl : public PropertiesImpl_BASE
{
uno::Reference< XHelperInterface > m_xParent;
uno::Reference< uno::XComponentContext > m_xContext;
- uno::Reference< frame::XModel > m_xModel;
+ rtl::Reference< SwXTextDocument > m_xModel;
uno::Reference< beans::XPropertySet > mxUserDefinedProp;
std::shared_ptr< PropertGetSetHelper > mpPropGetSetHelper;
public:
- CustomPropertiesImpl( uno::Reference< XHelperInterface > xParent, uno::Reference< uno::XComponentContext > xContext, uno::Reference< frame::XModel > xModel ) : m_xParent(std::move( xParent )), m_xContext(std::move( xContext )), m_xModel(std::move( xModel ))
+ CustomPropertiesImpl( uno::Reference< XHelperInterface > xParent,
+ uno::Reference< uno::XComponentContext > xContext,
+ rtl::Reference< SwXTextDocument > xModel )
+ : m_xParent(std::move( xParent )),
+ m_xContext(std::move( xContext )),
+ m_xModel(std::move( xModel ))
{
// suck in the document( custom ) properties
mpPropGetSetHelper = std::make_shared<CustomPropertyGetSetHelper>( m_xModel );
@@ -885,7 +891,7 @@ public:
}
-SwVbaCustomDocumentProperties::SwVbaCustomDocumentProperties( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : SwVbaBuiltinDocumentProperties( xParent, xContext, xModel )
+SwVbaCustomDocumentProperties::SwVbaCustomDocumentProperties( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const rtl::Reference< SwXTextDocument >& xModel ) : SwVbaBuiltinDocumentProperties( xParent, xContext, xModel )
{
// replace the m_xIndexAccess implementation ( we need a virtual init )
m_xIndexAccess.set( new CustomPropertiesImpl( xParent, xContext, xModel ) );
diff --git a/sw/source/ui/vba/vbadocumentproperties.hxx b/sw/source/ui/vba/vbadocumentproperties.hxx
index 740353e8291b..eb88a1c22784 100644
--- a/sw/source/ui/vba/vbadocumentproperties.hxx
+++ b/sw/source/ui/vba/vbadocumentproperties.hxx
@@ -22,13 +22,16 @@
#include <ooo/vba/XDocumentProperties.hpp>
#include <com/sun/star/frame/XModel.hpp>
#include <vbahelper/vbacollectionimpl.hxx>
+#include <rtl/ref.hxx>
+
+class SwXTextDocument;
typedef CollTestImplHelper< ov::XDocumentProperties > SwVbaDocumentproperties_BASE;
class SwVbaBuiltinDocumentProperties : public SwVbaDocumentproperties_BASE
{
public:
- SwVbaBuiltinDocumentProperties( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::frame::XModel >& xDocument );
+ SwVbaBuiltinDocumentProperties( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const rtl::Reference< SwXTextDocument >& xDocument );
// XDocumentProperties
virtual css::uno::Reference< ::ooo::vba::XDocumentProperty > SAL_CALL Add( const OUString& Name, sal_Bool LinkToContent, ::sal_Int8 Type, const css::uno::Any& Value, const css::uno::Any& LinkSource ) override;
@@ -46,7 +49,7 @@ public:
class SwVbaCustomDocumentProperties : public SwVbaBuiltinDocumentProperties
{
public:
- SwVbaCustomDocumentProperties( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::frame::XModel >& xDocument );
+ SwVbaCustomDocumentProperties( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const rtl::Reference< SwXTextDocument >& xDocument );
// XDocumentProperties
virtual css::uno::Reference< ::ooo::vba::XDocumentProperty > SAL_CALL Add( const OUString& Name, sal_Bool LinkToContent, ::sal_Int8 Type, const css::uno::Any& Value, const css::uno::Any& LinkSource ) override;
// XHelperInterface
diff --git a/sw/source/ui/vba/vbadocuments.cxx b/sw/source/ui/vba/vbadocuments.cxx
index 47fdce3cf913..7c419a635816 100644
--- a/sw/source/ui/vba/vbadocuments.cxx
+++ b/sw/source/ui/vba/vbadocuments.cxx
@@ -28,11 +28,13 @@
#include <osl/file.hxx>
#include <utility>
+#include <unotxdoc.hxx>
+
using namespace ::ooo::vba;
using namespace ::com::sun::star;
static uno::Any
-getDocument( uno::Reference< uno::XComponentContext > const & xContext, const uno::Reference< text::XTextDocument > &xDoc, const uno::Any& aApplication )
+getDocument( uno::Reference< uno::XComponentContext > const & xContext, const rtl::Reference< SwXTextDocument > &xDoc, const uno::Any& aApplication )
{
// FIXME: fine as long as SwVbaDocument is stateless ...
if( !xDoc.is() )
@@ -54,7 +56,7 @@ public:
virtual uno::Any SAL_CALL nextElement( ) override
{
uno::Reference< text::XTextDocument > xDoc( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW );
- return getDocument( m_xContext, xDoc, m_aApplication );
+ return getDocument( m_xContext, dynamic_cast<SwXTextDocument*>(xDoc.get()), m_aApplication );
}
};
@@ -84,7 +86,7 @@ uno::Any
SwVbaDocuments::createCollectionObject( const uno::Any& aSource )
{
uno::Reference< text::XTextDocument > xDoc( aSource, uno::UNO_QUERY_THROW );
- return getDocument( mxContext, xDoc, Application() );
+ return getDocument( mxContext, dynamic_cast<SwXTextDocument*>(xDoc.get()), Application() );
}
uno::Any SAL_CALL
@@ -96,7 +98,7 @@ SwVbaDocuments::Add( const uno::Any& Template, const uno::Any& /*NewTemplate*/,
return Open( sFileName, uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any());
}
uno::Reference <text::XTextDocument> xTextDoc( createDocument() , uno::UNO_QUERY_THROW );
- return getDocument( mxContext, xTextDoc, Application() );
+ return getDocument( mxContext, dynamic_cast<SwXTextDocument*>(xTextDoc.get()), Application() );
}
// #TODO# #FIXME# can any of the unused params below be used?
@@ -123,7 +125,7 @@ SwVbaDocuments::Open( const OUString& Filename, const uno::Any& /*ConfirmConvers
osl::FileBase::getFileURLFromSystemPath( Filename, aURL );
uno::Reference <text::XTextDocument> xSpreadDoc( openDocument( Filename, ReadOnly, {}), uno::UNO_QUERY_THROW );
- uno::Any aRet = getDocument( mxContext, xSpreadDoc, Application() );
+ uno::Any aRet = getDocument( mxContext, dynamic_cast<SwXTextDocument*>(xSpreadDoc.get()), Application() );
uno::Reference< word::XDocument > xDocument( aRet, uno::UNO_QUERY );
if ( xDocument.is() )
xDocument->Activate();
diff --git a/sw/source/ui/vba/vbafield.cxx b/sw/source/ui/vba/vbafield.cxx
index 75e5ee5ce965..d1114e1cacd7 100644
--- a/sw/source/ui/vba/vbafield.cxx
+++ b/sw/source/ui/vba/vbafield.cxx
@@ -29,6 +29,8 @@
#include <cppuhelper/implbase.hxx>
#include <sal/log.hxx>
#include <tools/long.hxx>
+#include <unotxdoc.hxx>
+#include <unofieldcoll.hxx>
#include <utility>
using namespace ::ooo::vba;
@@ -217,10 +219,11 @@ sal_Int32 SwVbaReadFieldParams::FindNextStringPiece(const sal_Int32 nStart)
// SwVbaFields
-static uno::Any lcl_createField( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel, const uno::Any& aSource )
+static uno::Any lcl_createField( const uno::Reference< XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext >& xContext,
+ const uno::Any& aSource )
{
uno::Reference< text::XTextField > xTextField( aSource, uno::UNO_QUERY_THROW );
- uno::Reference< text::XTextDocument > xTextDocument( xModel, uno::UNO_QUERY_THROW );
uno::Reference< word::XField > xField( new SwVbaField( xParent, xContext, xTextField ) );
return uno::Any( xField );
}
@@ -231,10 +234,17 @@ class FieldEnumeration : public ::cppu::WeakImplHelper< css::container::XEnumera
{
uno::Reference< XHelperInterface > mxParent;
uno::Reference< uno::XComponentContext > mxContext;
- uno::Reference< frame::XModel > mxModel;
+ rtl::Reference< SwXTextDocument > mxModel;
uno::Reference< container::XEnumeration > mxEnumeration;
public:
- FieldEnumeration( uno::Reference< XHelperInterface > xParent, uno::Reference< uno::XComponentContext > xContext, uno::Reference< frame::XModel > xModel, uno::Reference< container::XEnumeration > xEnumeration ) : mxParent(std::move( xParent )), mxContext(std::move( xContext )), mxModel(std::move( xModel )), mxEnumeration(std::move( xEnumeration ))
+ FieldEnumeration( uno::Reference< XHelperInterface > xParent,
+ uno::Reference< uno::XComponentContext > xContext,
+ rtl::Reference< SwXTextDocument > xModel,
+ uno::Reference< container::XEnumeration > xEnumeration )
+ : mxParent(std::move( xParent )),
+ mxContext(std::move( xContext )),
+ mxModel(std::move( xModel )),
+ mxEnumeration(std::move( xEnumeration ))
{
}
virtual sal_Bool SAL_CALL hasMoreElements( ) override
@@ -245,7 +255,7 @@ public:
{
if ( !hasMoreElements() )
throw container::NoSuchElementException();
- return lcl_createField( mxParent, mxContext, mxModel, mxEnumeration->nextElement() );
+ return lcl_createField( mxParent, mxContext, mxEnumeration->nextElement() );
}
};
@@ -254,14 +264,16 @@ class FieldCollectionHelper : public ::cppu::WeakImplHelper< container::XIndexAc
{
uno::Reference< XHelperInterface > mxParent;
uno::Reference< uno::XComponentContext > mxContext;
- uno::Reference< frame::XModel > mxModel;
- uno::Reference< container::XEnumerationAccess > mxEnumerationAccess;
+ rtl::Reference< SwXTextDocument > mxModel;
+ rtl::Reference< SwXTextFieldTypes > mxEnumerationAccess;
public:
/// @throws css::uno::RuntimeException
- FieldCollectionHelper( uno::Reference< XHelperInterface > xParent, uno::Reference< uno::XComponentContext > xContext, const uno::Reference< frame::XModel >& xModel ) : mxParent(std::move( xParent )), mxContext(std::move( xContext )), mxModel( xModel )
+ FieldCollectionHelper( uno::Reference< XHelperInterface > xParent,
+ uno::Reference< uno::XComponentContext > xContext,
+ const rtl::Reference< SwXTextDocument >& xModel )
+ : mxParent(std::move( xParent )), mxContext(std::move( xContext )), mxModel( xModel )
{
- uno::Reference< text::XTextFieldsSupplier > xSupp( xModel, uno::UNO_QUERY_THROW );
- mxEnumerationAccess.set( xSupp->getTextFields(), uno::UNO_SET_THROW );
+ mxEnumerationAccess = xModel->getSwTextFields();
}
// XElementAccess
virtual uno::Type SAL_CALL getElementType( ) override { return mxEnumerationAccess->getElementType(); }
@@ -305,9 +317,12 @@ public:
}
-SwVbaFields::SwVbaFields( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel ) : SwVbaFields_BASE( xParent, xContext , uno::Reference< container::XIndexAccess >( new FieldCollectionHelper( xParent, xContext, xModel ) ) ), mxModel( xModel )
+SwVbaFields::SwVbaFields( const uno::Reference< XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext > & xContext,
+ const rtl::Reference< SwXTextDocument >& xModel )
+: SwVbaFields_BASE( xParent, xContext , uno::Reference< container::XIndexAccess >( new FieldCollectionHelper( xParent, xContext, xModel ) ) ),
+ mxModel( xModel )
{
- mxMSF.set( mxModel, uno::UNO_QUERY_THROW );
}
uno::Reference< word::XField > SAL_CALL
@@ -349,7 +364,7 @@ SwVbaFields::Add( const css::uno::Reference< ::ooo::vba::word::XRange >& Range,
uno::Reference< text::XTextField > SwVbaFields::Create_Field_FileName( const OUString& _text )
{
- uno::Reference< text::XTextField > xTextField( mxMSF->createInstance(u"com.sun.star.text.TextField.FileName"_ustr), uno::UNO_QUERY_THROW );
+ uno::Reference< text::XTextField > xTextField( mxModel->createInstance(u"com.sun.star.text.TextField.FileName"_ustr), uno::UNO_QUERY_THROW );
sal_Int16 nFileFormat = text::FilenameDisplayFormat::NAME_AND_EXT;
if( !_text.isEmpty() )
{
@@ -469,7 +484,7 @@ uno::Reference< text::XTextField > SwVbaFields::Create_Field_DocProperty( const
throw uno::RuntimeException(u"Not implemented"_ustr );
}
- uno::Reference< text::XTextField > xTextField( mxMSF->createInstance( sFieldService ), uno::UNO_QUERY_THROW );
+ uno::Reference< text::XTextField > xTextField( mxModel->createInstance( sFieldService ), uno::UNO_QUERY_THROW );
if( bCustom )
{
@@ -491,7 +506,7 @@ SwVbaFields::createEnumeration()
uno::Any
SwVbaFields::createCollectionObject( const uno::Any& aSource )
{
- return lcl_createField( mxParent, mxContext, mxModel, aSource );
+ return lcl_createField( mxParent, mxContext, aSource );
}
sal_Int32 SAL_CALL SwVbaFields::Update()
@@ -499,8 +514,7 @@ sal_Int32 SAL_CALL SwVbaFields::Update()
sal_Int32 nUpdate = 1;
try
{
- uno::Reference< text::XTextFieldsSupplier > xSupp( mxModel, uno::UNO_QUERY_THROW );
- uno::Reference< util::XRefreshable > xRef( xSupp->getTextFields(), uno::UNO_QUERY_THROW );
+ rtl::Reference< SwXTextFieldTypes > xRef( mxModel->getSwTextFields() );
xRef->refresh();
nUpdate = 0;
}
diff --git a/sw/source/ui/vba/vbafield.hxx b/sw/source/ui/vba/vbafield.hxx
index 292be2edb7f9..368d22bde53b 100644
--- a/sw/source/ui/vba/vbafield.hxx
+++ b/sw/source/ui/vba/vbafield.hxx
@@ -18,12 +18,16 @@
*/
#ifndef INCLUDED_SW_SOURCE_UI_VBA_VBAFIELD_HXX
#define INCLUDED_SW_SOURCE_UI_VBA_VBAFIELD_HXX
+
#include <vbahelper/vbahelperinterface.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/text/XTextField.hpp>
#include <ooo/vba/word/XField.hpp>
#include <ooo/vba/word/XFields.hpp>
#include <vbahelper/vbacollectionimpl.hxx>
+#include <rtl/ref.hxx>
+
+class SwXTextDocument;
typedef InheritedHelperInterfaceWeakImpl< ooo::vba::word::XField > SwVbaField_BASE;
@@ -44,8 +48,7 @@ typedef CollTestImplHelper< ov::word::XFields > SwVbaFields_BASE;
class SwVbaFields : public SwVbaFields_BASE
{
- css::uno::Reference< css::frame::XModel > mxModel;
- css::uno::Reference< css::lang::XMultiServiceFactory > mxMSF;
+ rtl::Reference< SwXTextDocument > mxModel;
private:
/// @throws css::uno::RuntimeException
/// @throws css::script::BasicErrorException
@@ -54,7 +57,9 @@ private:
css::uno::Reference< css::text::XTextField > Create_Field_DocProperty( const OUString& _text );
public:
- SwVbaFields( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::frame::XModel >& xModel );
+ SwVbaFields( const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext > & xContext,
+ const rtl::Reference< SwXTextDocument >& xModel );
// XFields
virtual css::uno::Reference< ::ooo::vba::word::XField > SAL_CALL Add( const css::uno::Reference< ::ooo::vba::word::XRange >& Range, const css::uno::Any& Type, const css::uno::Any& Text, const css::uno::Any& PreserveFormatting ) override;
virtual sal_Int32 SAL_CALL Update() override;
diff --git a/sw/source/ui/vba/vbafind.cxx b/sw/source/ui/vba/vbafind.cxx
index bd80d19c4fba..29aa99d06079 100644
--- a/sw/source/ui/vba/vbafind.cxx
+++ b/sw/source/ui/vba/vbafind.cxx
@@ -24,6 +24,7 @@
#include <com/sun/star/text/XTextRangeCompare.hpp>
#include <doc.hxx>
#include <docsh.hxx>
+#include <unotxdoc.hxx>
#include "wordvbahelper.hxx"
#include <rtl/ref.hxx>
#include <sal/log.hxx>
@@ -31,11 +32,16 @@
using namespace ::ooo::vba;
using namespace ::com::sun::star;
-SwVbaFind::SwVbaFind( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, uno::Reference< frame::XModel > xModel ) :
- SwVbaFind_BASE( rParent, rContext ), mxModel( std::move(xModel) ), mbReplace( false ), mnReplaceType( word::WdReplace::wdReplaceOne ), mnWrap( word::WdFindWrap::wdFindStop )
+SwVbaFind::SwVbaFind( const uno::Reference< ooo::vba::XHelperInterface >& rParent,
+ const uno::Reference< uno::XComponentContext >& rContext,
+ rtl::Reference< SwXTextDocument > xModel ) :
+ SwVbaFind_BASE( rParent, rContext ),
+ mxModel( std::move(xModel) ),
+ mbReplace( false ),
+ mnReplaceType( word::WdReplace::wdReplaceOne ),
+ mnWrap( word::WdFindWrap::wdFindStop )
{
- mxReplaceable.set( mxModel, uno::UNO_QUERY_THROW );
- mxPropertyReplace.set( mxReplaceable->createReplaceDescriptor(), uno::UNO_QUERY_THROW );
+ mxPropertyReplace.set( mxModel->createReplaceDescriptor(), uno::UNO_QUERY_THROW );
mxTVC = word::getXTextViewCursor( mxModel );
mxSelSupp.set( mxModel->getCurrentController(), uno::UNO_QUERY_THROW );
}
@@ -46,11 +52,11 @@ SwVbaFind::~SwVbaFind()
uno::Reference< word::XFind > SwVbaFind::GetOrCreateFind(const uno::Reference< ooo::vba::XHelperInterface >& rParent,
const uno::Reference< uno::XComponentContext >& rContext,
- const uno::Reference< frame::XModel >& xModel,
+ const rtl::Reference< SwXTextDocument >& xModel,
const uno::Reference< text::XTextRange >& xTextRange)
{
rtl::Reference< SwVbaFind > xFind;
- SwDoc* pDoc = word::getDocShell( xModel )->GetDoc();
+ SwDoc* pDoc = xModel->GetDocShell()->GetDoc();
if( pDoc )
xFind = dynamic_cast<SwVbaFind *>( pDoc->getVbaFind().get() );
if ( !xFind )
@@ -99,16 +105,16 @@ uno::Reference< text::XTextRange > SwVbaFind::FindOneElement()
{
if( getForward() )
{
- xFoundOne.set( mxReplaceable->findNext( mxTextRange->getStart(), uno::Reference< util::XSearchDescriptor >( mxPropertyReplace, uno::UNO_QUERY_THROW ) ), uno::UNO_QUERY );
+ xFoundOne.set( mxModel->findNext( mxTextRange->getStart(), uno::Reference< util::XSearchDescriptor >( mxPropertyReplace, uno::UNO_QUERY_THROW ) ), uno::UNO_QUERY );
}
else
{
- xFoundOne.set( mxReplaceable->findNext( mxTextRange->getEnd(), uno::Reference< util::XSearchDescriptor >( mxPropertyReplace, uno::UNO_QUERY_THROW ) ), uno::UNO_QUERY );
+ xFoundOne.set( mxModel->findNext( mxTextRange->getEnd(), uno::Reference< util::XSearchDescriptor >( mxPropertyReplace, uno::UNO_QUERY_THROW ) ), uno::UNO_QUERY );
}
if( xFoundOne.is() && InEqualRange( xFoundOne ) )
{
- xFoundOne.set( mxReplaceable->findNext( xFoundOne, uno::Reference< util::XSearchDescriptor >( mxPropertyReplace, uno::UNO_QUERY_THROW ) ), uno::UNO_QUERY );
+ xFoundOne.set( mxModel->findNext( xFoundOne, uno::Reference< util::XSearchDescriptor >( mxPropertyReplace, uno::UNO_QUERY_THROW ) ), uno::UNO_QUERY );
}
else if( xFoundOne.is() && !InRange( xFoundOne ) )
{
@@ -117,7 +123,7 @@ uno::Reference< text::XTextRange > SwVbaFind::FindOneElement()
}
else
{
- xFoundOne.set( mxReplaceable->findNext( mxTextRange, uno::Reference< util::XSearchDescriptor >( mxPropertyReplace, uno::UNO_QUERY_THROW ) ), uno::UNO_QUERY );
+ xFoundOne.set( mxModel->findNext( mxTextRange, uno::Reference< util::XSearchDescriptor >( mxPropertyReplace, uno::UNO_QUERY_THROW ) ), uno::UNO_QUERY );
}
if( !xFoundOne.is() && ( getWrap() == word::WdFindWrap::wdFindContinue || getWrap() == word::WdFindWrap::wdFindAsk ) )
@@ -125,12 +131,12 @@ uno::Reference< text::XTextRange > SwVbaFind::FindOneElement()
if( getForward() )
{
mxTVC->gotoStart(false);
- xFoundOne.set( mxReplaceable->findNext( mxTextRange->getStart(), uno::Reference< util::XSearchDescriptor >( mxPropertyReplace, uno::UNO_QUERY_THROW ) ), uno::UNO_QUERY );
+ xFoundOne.set( mxModel->findNext( mxTextRange->getStart(), uno::Reference< util::XSearchDescriptor >( mxPropertyReplace, uno::UNO_QUERY_THROW ) ), uno::UNO_QUERY );
}
else
{
mxTVC->gotoEnd( false );
- xFoundOne.set( mxReplaceable->findNext( mxTextRange->getEnd(), uno::Reference< util::XSearchDescriptor >( mxPropertyReplace, uno::UNO_QUERY_THROW ) ), uno::UNO_QUERY );
+ xFoundOne.set( mxModel->findNext( mxTextRange->getEnd(), uno::Reference< util::XSearchDescriptor >( mxPropertyReplace, uno::UNO_QUERY_THROW ) ), uno::UNO_QUERY );
}
}
@@ -164,7 +170,7 @@ bool SwVbaFind::SearchReplace()
}
case word::WdReplace::wdReplaceAll:
{
- uno::Reference< container::XIndexAccess > xIndexAccess = mxReplaceable->findAll( uno::Reference< util::XSearchDescriptor >( mxPropertyReplace, uno::UNO_QUERY_THROW ) );
+ uno::Reference< container::XIndexAccess > xIndexAccess = mxModel->findAll( uno::Reference< util::XSearchDescriptor >( mxPropertyReplace, uno::UNO_QUERY_THROW ) );
if( xIndexAccess->getCount() > 0 )
{
for( sal_Int32 i = 0; i < xIndexAccess->getCount(); i++ )
diff --git a/sw/source/ui/vba/vbafind.hxx b/sw/source/ui/vba/vbafind.hxx
index 58198d1f3125..ca20642614ae 100644
--- a/sw/source/ui/vba/vbafind.hxx
+++ b/sw/source/ui/vba/vbafind.hxx
@@ -26,15 +26,17 @@
#include <com/sun/star/util/XPropertyReplace.hpp>
#include <com/sun/star/text/XTextViewCursor.hpp>
#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <rtl/ref.hxx>
+
+class SwXTextDocument;
typedef InheritedHelperInterfaceWeakImpl< ooo::vba::word::XFind > SwVbaFind_BASE;
class SwVbaFind : public SwVbaFind_BASE
{
private:
- css::uno::Reference< css::frame::XModel > mxModel;
+ rtl::Reference< SwXTextDocument > mxModel;
css::uno::Reference< css::text::XTextRange > mxTextRange;
- css::uno::Reference< css::util::XReplaceable > mxReplaceable;
css::uno::Reference< css::util::XPropertyReplace> mxPropertyReplace;
css::uno::Reference< css::text::XTextViewCursor> mxTVC;
css::uno::Reference< css::view::XSelectionSupplier> mxSelSupp;
@@ -58,9 +60,15 @@ private:
bool SearchReplace();
/// @throws css::uno::RuntimeException
- SwVbaFind( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, css::uno::Reference< css::frame::XModel > xModel );
+ SwVbaFind( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent,
+ const css::uno::Reference< css::uno::XComponentContext >& rContext,
+ rtl::Reference< SwXTextDocument > xModel );
public:
- static css::uno::Reference< ooo::vba::word::XFind > GetOrCreateFind(const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::text::XTextRange >& xTextRange);
+ static css::uno::Reference< ooo::vba::word::XFind > GetOrCreateFind(
+ const css::uno::Reference< ooo::vba::XHelperInterface >& rParent,
+ const css::uno::Reference< css::uno::XComponentContext >& rContext,
+ const rtl::Reference< SwXTextDocument >& xModel,
+ const css::uno::Reference< css::text::XTextRange >& xTextRange);
virtual ~SwVbaFind() override;
// Attributes
diff --git a/sw/source/ui/vba/vbaformfield.cxx b/sw/source/ui/vba/vbaformfield.cxx
index 4fffbec0ff6c..5d2cd5d0b183 100644
--- a/sw/source/ui/vba/vbaformfield.cxx
+++ b/sw/source/ui/vba/vbaformfield.cxx
@@ -14,6 +14,7 @@
#include <doc.hxx>
#include <docsh.hxx>
#include <unotextrange.hxx>
+#include <unotxdoc.hxx>
#include "vbaformfield.hxx"
#include "vbaformfieldcheckbox.hxx"
@@ -33,7 +34,7 @@ using namespace ::com::sun::star;
*/
SwVbaFormField::SwVbaFormField(const uno::Reference<ooo::vba::XHelperInterface>& rParent,
const uno::Reference<uno::XComponentContext>& rContext,
- const uno::Reference<text::XTextDocument>& xTextDocument,
+ const rtl::Reference<SwXTextDocument>& xTextDocument,
sw::mark::Fieldmark& rFormField)
: SwVbaFormField_BASE(rParent, rContext)
, m_xTextDocument(xTextDocument)
@@ -63,7 +64,7 @@ uno::Any SwVbaFormField::TextInput()
uno::Any SwVbaFormField::Previous()
{
- SwDoc* pDoc = word::getDocShell(m_xTextDocument)->GetDoc();
+ SwDoc* pDoc = m_xTextDocument->GetDocShell()->GetDoc();
if (!pDoc)
return uno::Any();
@@ -91,7 +92,7 @@ uno::Any SwVbaFormField::Previous()
uno::Any SwVbaFormField::Next()
{
- SwDoc* pDoc = word::getDocShell(m_xTextDocument)->GetDoc();
+ SwDoc* pDoc = m_xTextDocument->GetDocShell()->GetDoc();
if (!pDoc)
return uno::Any();
@@ -120,7 +121,7 @@ uno::Any SwVbaFormField::Next()
uno::Reference<word::XRange> SwVbaFormField::Range()
{
uno::Reference<word::XRange> xRet;
- SwDoc* pDoc = word::getDocShell(m_xTextDocument)->GetDoc();
+ SwDoc* pDoc = m_xTextDocument->GetDocShell()->GetDoc();
if (pDoc)
{
rtl::Reference<SwXTextRange> xText(SwXTextRange::CreateXTextRange(
diff --git a/sw/source/ui/vba/vbaformfield.hxx b/sw/source/ui/vba/vbaformfield.hxx
index bc5921e99929..13ce6effb99c 100644
--- a/sw/source/ui/vba/vbaformfield.hxx
+++ b/sw/source/ui/vba/vbaformfield.hxx
@@ -12,22 +12,25 @@
#include <ooo/vba/word/XFormField.hpp>
#include <vbahelper/vbahelperinterface.hxx>
+#include <rtl/ref.hxx>
#include <IDocumentMarkAccess.hxx>
+class SwXTextDocument;
+
typedef InheritedHelperInterfaceWeakImpl<ooo::vba::word::XFormField> SwVbaFormField_BASE;
class SwVbaFormField : public SwVbaFormField_BASE
{
private:
- css::uno::Reference<css::text::XTextDocument> m_xTextDocument;
+ rtl::Reference<SwXTextDocument> m_xTextDocument;
sw::mark::Fieldmark& m_rFormField;
public:
/// @throws css::uno::RuntimeException
SwVbaFormField(const css::uno::Reference<ooo::vba::XHelperInterface>& rParent,
const css::uno::Reference<css::uno::XComponentContext>& rContext,
- const uno::Reference<text::XTextDocument>& xTextDocument,
+ const rtl::Reference<SwXTextDocument>& xTextDocument,
sw::mark::Fieldmark& rFormField);
~SwVbaFormField() override;
diff --git a/sw/source/ui/vba/vbaformfields.cxx b/sw/source/ui/vba/vbaformfields.cxx
index 737e5fa8e2fc..d647e9ea993a 100644
--- a/sw/source/ui/vba/vbaformfields.cxx
+++ b/sw/source/ui/vba/vbaformfields.cxx
@@ -17,6 +17,7 @@
#include "vbaformfield.hxx"
#include "vbaformfields.hxx"
#include "wordvbahelper.hxx"
+#include <unotxdoc.hxx>
using namespace ::ooo::vba;
using namespace ::com::sun::star;
@@ -26,11 +27,11 @@ using namespace ::com::sun::star;
// [in] -1 to indicate searching using the provided name, SAL_MAX_INT32 for totals
// [out] rIndex indicates the found index, or the total number of fieldmarks
static sw::mark::Fieldmark* lcl_getFieldmark(std::string_view rName, sal_Int32& rIndex,
- const uno::Reference<frame::XModel>& xModel,
+ const rtl::Reference<SwXTextDocument>& xModel,
uno::Sequence<OUString>* pElementNames = nullptr)
{
- SwDoc* pDoc = word::getDocShell(xModel)->GetDoc();
+ SwDoc* pDoc = xModel->GetDocShell()->GetDoc();
if (!pDoc)
return nullptr;
@@ -105,14 +106,14 @@ class FormFieldCollectionHelper
private:
uno::Reference<XHelperInterface> mxParent;
uno::Reference<uno::XComponentContext> mxContext;
- uno::Reference<text::XTextDocument> mxTextDocument;
+ rtl::Reference<SwXTextDocument> mxTextDocument;
sw::mark::Fieldmark* m_pCache;
public:
/// @throws css::uno::RuntimeException
FormFieldCollectionHelper(uno::Reference<ov::XHelperInterface> xParent,
uno::Reference<uno::XComponentContext> xContext,
- uno::Reference<text::XTextDocument> xTextDocument)
+ rtl::Reference<SwXTextDocument> xTextDocument)
: mxParent(std::move(xParent))
, mxContext(std::move(xContext))
, mxTextDocument(std::move(xTextDocument))
@@ -178,7 +179,7 @@ public:
SwVbaFormFields::SwVbaFormFields(const uno::Reference<XHelperInterface>& xParent,
const uno::Reference<uno::XComponentContext>& xContext,
- const uno::Reference<text::XTextDocument>& xTextDocument)
+ const rtl::Reference<SwXTextDocument>& xTextDocument)
: SwVbaFormFields_BASE(xParent, xContext,
uno::Reference<container::XIndexAccess>(
new FormFieldCollectionHelper(xParent, xContext, xTextDocument)))
diff --git a/sw/source/ui/vba/vbaformfields.hxx b/sw/source/ui/vba/vbaformfields.hxx
index 2dfa9e76b0c4..274931a51e2a 100644
--- a/sw/source/ui/vba/vbaformfields.hxx
+++ b/sw/source/ui/vba/vbaformfields.hxx
@@ -12,6 +12,7 @@
#include <ooo/vba/word/XFormFields.hpp>
#include <vbahelper/vbacollectionimpl.hxx>
+#include <rtl/ref.hxx>
typedef CollTestImplHelper<ooo::vba::word::XFormFields> SwVbaFormFields_BASE;
@@ -21,7 +22,7 @@ public:
/// @throws css::uno::RuntimeException
SwVbaFormFields(const css::uno::Reference<ov::XHelperInterface>& xParent,
const css::uno::Reference<css::uno::XComponentContext>& xContext,
- const css::uno::Reference<css::text::XTextDocument>& xTextDocument);
+ const rtl::Reference<SwXTextDocument>& xTextDocument);
// XFormFields
sal_Bool SAL_CALL getShaded() override;
diff --git a/sw/source/ui/vba/vbaframe.cxx b/sw/source/ui/vba/vbaframe.cxx
index 009fdec250a7..7e7f8f11f2cb 100644
--- a/sw/source/ui/vba/vbaframe.cxx
+++ b/sw/source/ui/vba/vbaframe.cxx
@@ -19,12 +19,16 @@
#include "vbaframe.hxx"
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <unotxdoc.hxx>
#include <utility>
using namespace ::ooo::vba;
using namespace ::com::sun::star;
-SwVbaFrame::SwVbaFrame( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, css::uno::Reference< frame::XModel > xModel, css::uno::Reference< text::XTextFrame > xTextFrame ) :
+SwVbaFrame::SwVbaFrame( const uno::Reference< ooo::vba::XHelperInterface >& rParent,
+ const uno::Reference< uno::XComponentContext >& rContext,
+ rtl::Reference< SwXTextDocument > xModel,
+ css::uno::Reference< text::XTextFrame > xTextFrame ) :
SwVbaFrame_BASE( rParent, rContext ), mxModel(std::move( xModel )), mxTextFrame(std::move( xTextFrame ))
{
}
diff --git a/sw/source/ui/vba/vbaframe.hxx b/sw/source/ui/vba/vbaframe.hxx
index c24ba4617cd7..9d1c802159b3 100644
--- a/sw/source/ui/vba/vbaframe.hxx
+++ b/sw/source/ui/vba/vbaframe.hxx
@@ -22,18 +22,24 @@
#include <ooo/vba/word/XFrame.hpp>
#include <vbahelper/vbahelperinterface.hxx>
#include <com/sun/star/text/XTextFrame.hpp>
+#include <rtl/ref.hxx>
+
+class SwXTextDocument;
typedef InheritedHelperInterfaceWeakImpl< ooo::vba::word::XFrame > SwVbaFrame_BASE;
class SwVbaFrame : public SwVbaFrame_BASE
{
private:
- css::uno::Reference< css::frame::XModel > mxModel;
+ rtl::Reference< SwXTextDocument > mxModel;
css::uno::Reference< css::text::XTextFrame > mxTextFrame;
public:
/// @throws css::uno::RuntimeException
- SwVbaFrame( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, css::uno::Reference< css::frame::XModel > xModel, css::uno::Reference< css::text::XTextFrame > xTextFrame );
+ SwVbaFrame( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent,
+ const css::uno::Reference< css::uno::XComponentContext >& rContext,
+ rtl::Reference< SwXTextDocument > xModel,
+ css::uno::Reference< css::text::XTextFrame > xTextFrame );
virtual ~SwVbaFrame() override;
// Methods
diff --git a/sw/source/ui/vba/vbaframes.cxx b/sw/source/ui/vba/vbaframes.cxx
index ff15f17f6827..737509d5a0a7 100644
--- a/sw/source/ui/vba/vbaframes.cxx
+++ b/sw/source/ui/vba/vbaframes.cxx
@@ -20,6 +20,7 @@
#include "vbaframe.hxx"
#include <com/sun/star/frame/XModel.hpp>
#include <cppuhelper/implbase.hxx>
+#include <unotxdoc.hxx>
#include <utility>
using namespace ::ooo::vba;
@@ -33,11 +34,19 @@ private:
uno::Reference< XHelperInterface > mxParent;
uno::Reference< uno::XComponentContext > mxContext;
uno::Reference< container::XIndexAccess> mxIndexAccess;
- uno::Reference< frame::XModel > mxModel;
+ rtl::Reference< SwXTextDocument > mxModel;
sal_Int32 mnCurrentPos;
public:
/// @throws uno::RuntimeException
- FramesEnumeration( uno::Reference< XHelperInterface > xParent, uno::Reference< uno::XComponentContext > xContext, uno::Reference< container::XIndexAccess > xIndexAccess, uno::Reference< frame::XModel > xModel ) : mxParent(std::move( xParent )), mxContext(std::move( xContext)), mxIndexAccess(std::move( xIndexAccess )), mxModel(std::move( xModel )), mnCurrentPos(0)
+ FramesEnumeration( uno::Reference< XHelperInterface > xParent,
+ uno::Reference< uno::XComponentContext > xContext,
+ uno::Reference< container::XIndexAccess > xIndexAccess,
+ rtl::Reference< SwXTextDocument > xModel )
+ : mxParent(std::move( xParent )),
+ mxContext(std::move( xContext)),
+ mxIndexAccess(std::move( xIndexAccess )),
+ mxModel(std::move( xModel )),
+ mnCurrentPos(0)
{
}
virtual sal_Bool SAL_CALL hasMoreElements( ) override
@@ -57,9 +66,13 @@ public:
}
-SwVbaFrames::SwVbaFrames( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< container::XIndexAccess >& xFrames, uno::Reference< frame::XModel > xModel ): SwVbaFrames_BASE( xParent, xContext, xFrames ), mxModel(std::move( xModel ))
+SwVbaFrames::SwVbaFrames( const uno::Reference< XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext > & xContext,
+ const uno::Reference< container::XIndexAccess >& xFrames,
+ rtl::Reference< SwXTextDocument > xModel )
+: SwVbaFrames_BASE( xParent, xContext, xFrames ),
+ mxModel(std::move( xModel ))
{
- mxFramesSupplier.set( mxModel, uno::UNO_QUERY_THROW );
}
// XEnumerationAccess
uno::Type
diff --git a/sw/source/ui/vba/vbaframes.hxx b/sw/source/ui/vba/vbaframes.hxx
index 6a0c20c3db53..41bcef34a8ec 100644
--- a/sw/source/ui/vba/vbaframes.hxx
+++ b/sw/source/ui/vba/vbaframes.hxx
@@ -22,17 +22,19 @@
#include <vbahelper/vbacollectionimpl.hxx>
#include <ooo/vba/word/XFrames.hpp>
#include <com/sun/star/text/XTextFramesSupplier.hpp>
+#include <rtl/ref.hxx>
+
+class SwXTextDocument;
typedef CollTestImplHelper< ooo::vba::word::XFrames > SwVbaFrames_BASE;
class SwVbaFrames : public SwVbaFrames_BASE
{
private:
- css::uno::Reference< css::frame::XModel > mxModel;
- css::uno::Reference< css::text::XTextFramesSupplier > mxFramesSupplier;
+ rtl::Reference< SwXTextDocument > mxModel;
public:
- SwVbaFrames( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::container::XIndexAccess >& xFrames, css::uno::Reference< css::frame::XModel > xModel );
+ SwVbaFrames( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::container::XIndexAccess >& xFrames, rtl::Reference< SwXTextDocument > xModel );
// XEnumerationAccess
virtual css::uno::Type SAL_CALL getElementType() override;
diff --git a/sw/source/ui/vba/vbaheaderfooter.cxx b/sw/source/ui/vba/vbaheaderfooter.cxx
index 9b25ce7bb52c..5bc71f3e7be4 100644
--- a/sw/source/ui/vba/vbaheaderfooter.cxx
+++ b/sw/source/ui/vba/vbaheaderfooter.cxx
@@ -25,11 +25,22 @@
#include "vbarange.hxx"
#include <utility>
#include <vbahelper/vbashapes.hxx>
+#include <unotxdoc.hxx>
+#include <unodraw.hxx>
using namespace ::ooo::vba;
using namespace ::com::sun::star;
-SwVbaHeaderFooter::SwVbaHeaderFooter( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, uno::Reference< frame::XModel > xModel, uno::Reference< beans::XPropertySet > xProps, bool isHeader, sal_Int32 index ) : SwVbaHeaderFooter_BASE( rParent, rContext ), mxModel(std::move( xModel )), mxPageStyleProps(std::move( xProps )), mbHeader( isHeader ), mnIndex( index )
+SwVbaHeaderFooter::SwVbaHeaderFooter( const uno::Reference< ooo::vba::XHelperInterface >& rParent,
+ const uno::Reference< uno::XComponentContext >& rContext,
+ rtl::Reference< SwXTextDocument > xModel,
+ uno::Reference< beans::XPropertySet > xProps,
+ bool isHeader, sal_Int32 index )
+: SwVbaHeaderFooter_BASE( rParent, rContext ),
+ mxModel(std::move( xModel )),
+ mxPageStyleProps(std::move( xProps )),
+ mbHeader( isHeader ),
+ mnIndex( index )
{
}
@@ -66,18 +77,16 @@ uno::Reference< word::XRange > SAL_CALL SwVbaHeaderFooter::getRange()
}
uno::Reference< text::XText > xText( mxPageStyleProps->getPropertyValue( sPropsNameText ), uno::UNO_QUERY_THROW );
- uno::Reference< text::XTextDocument > xDocument( mxModel, uno::UNO_QUERY_THROW );
- return uno::Reference< word::XRange >( new SwVbaRange( this, mxContext, xDocument, xText->getStart(), xText->getEnd(), xText ) );
+ return uno::Reference< word::XRange >( new SwVbaRange( this, mxContext, mxModel, xText->getStart(), xText->getEnd(), xText ) );
}
uno::Any SAL_CALL
SwVbaHeaderFooter::Shapes( const uno::Any& index )
{
// #FIXME: only get the shapes in the current header/footer
- uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( mxModel, uno::UNO_QUERY_THROW );
//uno::Reference< drawing::XShapes > xShapes( xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY_THROW );
- uno::Reference< container::XIndexAccess > xIndexAccess( xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY_THROW );
- uno::Reference< XCollection > xCol( new ScVbaShapes( this, mxContext, xIndexAccess, mxModel ) );
+ rtl::Reference< SwFmDrawPage > xIndexAccess( mxModel->getSwDrawPage() );
+ uno::Reference< XCollection > xCol( new ScVbaShapes( this, mxContext, xIndexAccess, static_cast<SfxBaseModel*>(mxModel.get()) ) );
if ( index.hasValue() )
return xCol->Item( index, uno::Any() );
return uno::Any( xCol );
diff --git a/sw/source/ui/vba/vbaheaderfooter.hxx b/sw/source/ui/vba/vbaheaderfooter.hxx
index 7425057b262a..1561f43f74f9 100644
--- a/sw/source/ui/vba/vbaheaderfooter.hxx
+++ b/sw/source/ui/vba/vbaheaderfooter.hxx
@@ -22,20 +22,27 @@
#include <ooo/vba/word/XHeaderFooter.hpp>
#include <ooo/vba/word/XRange.hpp>
#include <vbahelper/vbahelperinterface.hxx>
+#include <rtl/ref.hxx>
+
+class SwXTextDocument;
typedef InheritedHelperInterfaceWeakImpl< ooo::vba::word::XHeaderFooter > SwVbaHeaderFooter_BASE;
class SwVbaHeaderFooter : public SwVbaHeaderFooter_BASE
{
private:
- css::uno::Reference< css::frame::XModel > mxModel;
+ rtl::Reference< SwXTextDocument > mxModel;
css::uno::Reference< css::beans::XPropertySet > mxPageStyleProps;
bool mbHeader;
sal_Int32 mnIndex;
public:
/// @throws css::uno::RuntimeException
- SwVbaHeaderFooter( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, css::uno::Reference< css::frame::XModel > xModel, css::uno::Reference< css::beans::XPropertySet > xProps, bool isHeader, sal_Int32 index );
+ SwVbaHeaderFooter( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent,
+ const css::uno::Reference< css::uno::XComponentContext >& rContext,
+ rtl::Reference< SwXTextDocument > xModel,
+ css::uno::Reference< css::beans::XPropertySet > xProps,
+ bool isHeader, sal_Int32 index );
// Attributes
virtual sal_Bool SAL_CALL getIsHeader() override;
diff --git a/sw/source/ui/vba/vbaheaderfooterhelper.cxx b/sw/source/ui/vba/vbaheaderfooterhelper.cxx
index 11f93f456b7c..0507d6b848ac 100644
--- a/sw/source/ui/vba/vbaheaderfooterhelper.cxx
+++ b/sw/source/ui/vba/vbaheaderfooterhelper.cxx
@@ -23,6 +23,8 @@
#include <com/sun/star/text/XPageCursor.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <unotxdoc.hxx>
+#include <unobasestyle.hxx>
using namespace ::com::sun::star;
using namespace ::ooo::vba;
@@ -30,7 +32,8 @@ using namespace ::ooo::vba;
#define FIRST_PAGE 1
// Class HeaderFooterHelper
-bool HeaderFooterHelper::isHeaderFooter( const uno::Reference< frame::XModel >& xModel )
+
+bool HeaderFooterHelper::isHeaderFooter( const rtl::Reference< SwXTextDocument >& xModel )
{
return isHeaderFooter( word::getCurrentXText( xModel ) );
}
@@ -42,17 +45,16 @@ bool HeaderFooterHelper::isHeaderFooter( const uno::Reference< text::XText >& xT
return aImplName == "SwXHeadFootText";
}
-bool HeaderFooterHelper::isHeader( const uno::Reference< frame::XModel >& xModel )
+bool HeaderFooterHelper::isHeader( const rtl::Reference< SwXTextDocument >& xModel )
{
const uno::Reference< text::XText > xCurrentText = word::getCurrentXText( xModel );
if( !isHeaderFooter( xCurrentText ) )
return false;
OUString aPropText = u"HeaderText"_ustr;
- uno::Reference< style::XStyle > xPageStyle = word::getCurrentPageStyle( xModel );
- uno::Reference< beans::XPropertySet > xPageProps( xPageStyle, uno::UNO_QUERY_THROW );
+ rtl::Reference< SwXBaseStyle> xPageStyle = word::getCurrentPageStyle( xModel );
bool isShared = true;
- xPageProps->getPropertyValue( u"HeaderIsShared"_ustr ) >>= isShared;
+ xPageStyle->getPropertyValue( u"HeaderIsShared"_ustr ) >>= isShared;
if( !isShared )
{
uno::Reference< text::XPageCursor > xPageCursor( word::getXTextViewCursor( xModel ), uno::UNO_QUERY_THROW );
@@ -62,7 +64,7 @@ bool HeaderFooterHelper::isHeader( const uno::Reference< frame::XModel >& xModel
aPropText = "HeaderTextRight";
}
- uno::Reference< text::XText > xHeaderText( xPageProps->getPropertyValue( aPropText ), uno::UNO_QUERY_THROW );
+ uno::Reference< text::XText > xHeaderText( xPageStyle->getPropertyValue( aPropText ), uno::UNO_QUERY_THROW );
uno::Reference< text::XTextRangeCompare > xTRC( xHeaderText, uno::UNO_QUERY_THROW );
uno::Reference< text::XTextRange > xTR1( xCurrentText, uno::UNO_QUERY_THROW );
uno::Reference< text::XTextRange > xTR2( xHeaderText, uno::UNO_QUERY_THROW );
@@ -79,7 +81,7 @@ bool HeaderFooterHelper::isHeader( const uno::Reference< frame::XModel >& xModel
return false;
}
-bool HeaderFooterHelper::isFirstPageHeader( const uno::Reference< frame::XModel >& xModel )
+bool HeaderFooterHelper::isFirstPageHeader( const rtl::Reference< SwXTextDocument >& xModel )
{
if( isHeader( xModel ) )
{
@@ -91,11 +93,11 @@ bool HeaderFooterHelper::isFirstPageHeader( const uno::Reference< frame::XModel
return false;
}
-bool HeaderFooterHelper::isEvenPagesHeader( const uno::Reference< frame::XModel >& xModel )
+bool HeaderFooterHelper::isEvenPagesHeader( const rtl::Reference< SwXTextDocument >& xModel )
{
if( isHeader( xModel ) )
{
- uno::Reference< beans::XPropertySet > xStyleProps( word::getCurrentPageStyle( xModel ), uno::UNO_QUERY_THROW );
+ rtl::Reference< SwXBaseStyle > xStyleProps( word::getCurrentPageStyle( xModel ) );
bool isShared = false;
xStyleProps->getPropertyValue(u"HeaderIsShared"_ustr) >>= isShared;
if( !isShared )
@@ -107,7 +109,7 @@ bool HeaderFooterHelper::isEvenPagesHeader( const uno::Reference< frame::XModel
return false;
}
-bool HeaderFooterHelper::isFooter( const uno::Reference< frame::XModel >& xModel )
+bool HeaderFooterHelper::isFooter( const rtl::Reference< SwXTextDocument >& xModel )
{
const uno::Reference< text::XText > xCurrentText = word::getCurrentXText( xModel );
if( !isHeaderFooter( xCurrentText ) )
@@ -144,7 +146,7 @@ bool HeaderFooterHelper::isFooter( const uno::Reference< frame::XModel >& xModel
return false;
}
-bool HeaderFooterHelper::isFirstPageFooter( const uno::Reference< frame::XModel >& xModel )
+bool HeaderFooterHelper::isFirstPageFooter( const rtl::Reference< SwXTextDocument >& xModel )
{
if( isFooter( xModel ) )
{
@@ -155,11 +157,11 @@ bool HeaderFooterHelper::isFirstPageFooter( const uno::Reference< frame::XModel
return false;
}
-bool HeaderFooterHelper::isEvenPagesFooter( const uno::Reference< frame::XModel >& xModel )
+bool HeaderFooterHelper::isEvenPagesFooter( const rtl::Reference< SwXTextDocument >& xModel )
{
if( isFooter( xModel ) )
{
- uno::Reference< beans::XPropertySet > xStyleProps( word::getCurrentPageStyle( xModel ), uno::UNO_QUERY_THROW );
+ rtl::Reference< SwXBaseStyle > xStyleProps( word::getCurrentPageStyle( xModel ) );
bool isShared = false;
xStyleProps->getPropertyValue(u"FooterIsShared"_ustr) >>= isShared;
if( !isShared )
diff --git a/sw/source/ui/vba/vbaheaderfooterhelper.hxx b/sw/source/ui/vba/vbaheaderfooterhelper.hxx
index ca66b208addf..7b3cef50549a 100644
--- a/sw/source/ui/vba/vbaheaderfooterhelper.hxx
+++ b/sw/source/ui/vba/vbaheaderfooterhelper.hxx
@@ -21,26 +21,29 @@
#include <vbahelper/vbahelper.hxx>
#include <com/sun/star/text/XText.hpp>
+#include <rtl/ref.hxx>
+
+class SwXTextDocument;
class HeaderFooterHelper
{
public:
/// @throws css::uno::RuntimeException
- static bool isHeaderFooter(const css::uno::Reference<css::frame::XModel>& xModel);
+ static bool isHeaderFooter(const rtl::Reference<SwXTextDocument>& xModel);
/// @throws css::uno::RuntimeException
static bool isHeaderFooter(const css::uno::Reference<css::text::XText>& xText);
/// @throws css::uno::RuntimeException
- static bool isHeader(const css::uno::Reference<css::frame::XModel>& xModel);
+ static bool isHeader(const rtl::Reference<SwXTextDocument>& xModel);
/// @throws css::uno::RuntimeException
- static bool isFirstPageHeader(const css::uno::Reference<css::frame::XModel>& xModel);
+ static bool isFirstPageHeader(const rtl::Reference<SwXTextDocument>& xModel);
/// @throws css::uno::RuntimeException
- static bool isEvenPagesHeader(const css::uno::Reference<css::frame::XModel>& xModel);
+ static bool isEvenPagesHeader(const rtl::Reference<SwXTextDocument>& xModel);
/// @throws css::uno::RuntimeException
- static bool isFooter(const css::uno::Reference<css::frame::XModel>& xModel);
+ static bool isFooter(const rtl::Reference<SwXTextDocument>& xModel);
/// @throws css::uno::RuntimeException
- static bool isFirstPageFooter(const css::uno::Reference<css::frame::XModel>& xModel);
+ static bool isFirstPageFooter(const rtl::Reference<SwXTextDocument>& xModel);
/// @throws css::uno::RuntimeException
- static bool isEvenPagesFooter(const css::uno::Reference<css::frame::XModel>& xModel);
+ static bool isEvenPagesFooter(const rtl::Reference<SwXTextDocument>& xModel);
};
#endif
diff --git a/sw/source/ui/vba/vbaheadersfooters.cxx b/sw/source/ui/vba/vbaheadersfooters.cxx
index a683060a1492..7081bacfefef 100644
--- a/sw/source/ui/vba/vbaheadersfooters.cxx
+++ b/sw/source/ui/vba/vbaheadersfooters.cxx
@@ -20,6 +20,7 @@
#include "vbaheaderfooter.hxx"
#include <cppuhelper/implbase.hxx>
#include <utility>
+#include <unotxdoc.hxx>
using namespace ::ooo::vba;
using namespace ::com::sun::star;
@@ -32,12 +33,21 @@ class HeadersFootersIndexAccess : public ::cppu::WeakImplHelper<container::XInde
private:
uno::Reference< XHelperInterface > mxParent;
uno::Reference< uno::XComponentContext > mxContext;
- uno::Reference< frame::XModel > mxModel;
+ rtl::Reference< SwXTextDocument > mxModel;
uno::Reference< beans::XPropertySet > mxPageStyleProps;
bool mbHeader;
public:
- HeadersFootersIndexAccess( uno::Reference< XHelperInterface > xParent, uno::Reference< uno::XComponentContext > xContext, uno::Reference< frame::XModel > xModel, uno::Reference< beans::XPropertySet > xPageStyleProps, bool bHeader ) : mxParent(std::move( xParent )), mxContext(std::move( xContext )), mxModel(std::move( xModel )), mxPageStyleProps(std::move( xPageStyleProps )), mbHeader( bHeader ) {}
+ HeadersFootersIndexAccess( uno::Reference< XHelperInterface > xParent,
+ uno::Reference< uno::XComponentContext > xContext,
+ rtl::Reference< SwXTextDocument > xModel,
+ uno::Reference< beans::XPropertySet > xPageStyleProps,
+ bool bHeader )
+ : mxParent(std::move( xParent )),
+ mxContext(std::move( xContext )),
+ mxModel(std::move( xModel )),
+ mxPageStyleProps(std::move( xPageStyleProps )),
+ mbHeader( bHeader ) {}
// XIndexAccess
virtual sal_Int32 SAL_CALL getCount( ) override
@@ -82,7 +92,13 @@ public:
}
-SwVbaHeadersFooters::SwVbaHeadersFooters( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel, const uno::Reference< beans::XPropertySet >& xPageStyleProps, bool isHeader ): SwVbaHeadersFooters_BASE( xParent, xContext, new HeadersFootersIndexAccess( xParent, xContext, xModel, xPageStyleProps, isHeader ) ), mxModel( xModel ), mxPageStyleProps( xPageStyleProps ), mbHeader( isHeader )
+SwVbaHeadersFooters::SwVbaHeadersFooters( const uno::Reference< XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext > & xContext,
+ const rtl::Reference< SwXTextDocument >& xModel,
+ const uno::Reference< beans::XPropertySet >& xPageStyleProps,
+ bool isHeader )
+ : SwVbaHeadersFooters_BASE( xParent, xContext, new HeadersFootersIndexAccess( xParent, xContext, xModel, xPageStyleProps, isHeader ) ),
+ mxModel( xModel ), mxPageStyleProps( xPageStyleProps ), mbHeader( isHeader )
{
}
diff --git a/sw/source/ui/vba/vbaheadersfooters.hxx b/sw/source/ui/vba/vbaheadersfooters.hxx
index 44aa77cfde4d..10fdb9bd8040 100644
--- a/sw/source/ui/vba/vbaheadersfooters.hxx
+++ b/sw/source/ui/vba/vbaheadersfooters.hxx
@@ -21,18 +21,25 @@
#include <vbahelper/vbacollectionimpl.hxx>
#include <ooo/vba/word/XHeadersFooters.hpp>
+#include <rtl/ref.hxx>
+
+class SwXTextDocument;
typedef CollTestImplHelper< ooo::vba::word::XHeadersFooters > SwVbaHeadersFooters_BASE;
class SwVbaHeadersFooters : public SwVbaHeadersFooters_BASE
{
private:
- css::uno::Reference< css::frame::XModel > mxModel;
+ rtl::Reference< SwXTextDocument > mxModel;
css::uno::Reference< css::beans::XPropertySet > mxPageStyleProps;
bool mbHeader;
public:
- SwVbaHeadersFooters( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::beans::XPropertySet >& xProps, bool isHeader );
+ SwVbaHeadersFooters( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent,
+ const css::uno::Reference< css::uno::XComponentContext >& rContext,
+ const rtl::Reference< SwXTextDocument >& xModel,
+ const css::uno::Reference< css::beans::XPropertySet >& xProps,
+ bool isHeader );
virtual ::sal_Int32 SAL_CALL getCount() override;
virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index1, const css::uno::Any& ) override;
diff --git a/sw/source/ui/vba/vbainformationhelper.cxx b/sw/source/ui/vba/vbainformationhelper.cxx
index a38d7c058acd..66af301afc68 100644
--- a/sw/source/ui/vba/vbainformationhelper.cxx
+++ b/sw/source/ui/vba/vbainformationhelper.cxx
@@ -26,6 +26,8 @@
#include <vbahelper/vbahelper.hxx>
#include <viewsh.hxx>
#include <IDocumentLayoutAccess.hxx>
+#include <unotxdoc.hxx>
+#include <unobasestyle.hxx>
using namespace ::ooo::vba;
using namespace ::com::sun::star;
@@ -38,21 +40,21 @@ sal_Int32 SwVbaInformationHelper::handleWdActiveEndPageNumber( const css::uno::R
return xPageCursor->getPage();
}
-sal_Int32 SwVbaInformationHelper::handleWdNumberOfPagesInDocument( const css::uno::Reference< css::frame::XModel >& xModel )
+sal_Int32 SwVbaInformationHelper::handleWdNumberOfPagesInDocument( const rtl::Reference< SwXTextDocument >& xModel )
{
return word::getPageCount( xModel );
}
-double SwVbaInformationHelper::handleWdVerticalPositionRelativeToPage( const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::text::XTextViewCursor >& xTVCursor )
+double SwVbaInformationHelper::handleWdVerticalPositionRelativeToPage( const rtl::Reference< SwXTextDocument >& xModel, const css::uno::Reference< css::text::XTextViewCursor >& xTVCursor )
{
xTVCursor->collapseToStart();
- uno::Reference< beans::XPropertySet > xStyleProps( word::getCurrentPageStyle( xModel ), uno::UNO_QUERY_THROW );
+ rtl::Reference< SwXBaseStyle > xStyleProps( word::getCurrentPageStyle( xModel ) );
sal_Int32 nTopMargin = 0;
xStyleProps->getPropertyValue( u"TopMargin"_ustr ) >>= nTopMargin;
sal_Int32 nCurrentPos = xTVCursor->getPosition().Y;
sal_Int32 nCurrentPage = handleWdActiveEndPageNumber( xTVCursor );
- SwDoc* pDoc = word::getDocShell( xModel )->GetDoc();
+ SwDoc* pDoc = xModel->GetDocShell()->GetDoc();
SwViewShell* pViewSh = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell();
sal_Int32 nPageHeight = pViewSh ? pViewSh->GetPageSize( nCurrentPage, false ).Height() : 0;
// FIXME: handle multiple page style
diff --git a/sw/source/ui/vba/vbainformationhelper.hxx b/sw/source/ui/vba/vbainformationhelper.hxx
index c60b300cd430..5ec6d683197c 100644
--- a/sw/source/ui/vba/vbainformationhelper.hxx
+++ b/sw/source/ui/vba/vbainformationhelper.hxx
@@ -21,6 +21,9 @@
#include <com/sun/star/text/XTextViewCursor.hpp>
#include <com/sun/star/frame/XModel.hpp>
+#include <rtl/ref.hxx>
+
+class SwXTextDocument;
class SwVbaInformationHelper
{
@@ -29,11 +32,10 @@ public:
static sal_Int32
handleWdActiveEndPageNumber(const css::uno::Reference<css::text::XTextViewCursor>& xTVCursor);
/// @throws css::uno::RuntimeException
- static sal_Int32
- handleWdNumberOfPagesInDocument(const css::uno::Reference<css::frame::XModel>& xModel);
+ static sal_Int32 handleWdNumberOfPagesInDocument(const rtl::Reference<SwXTextDocument>& xModel);
/// @throws css::uno::RuntimeException
static double handleWdVerticalPositionRelativeToPage(
- const css::uno::Reference<css::frame::XModel>& xModel,
+ const rtl::Reference<SwXTextDocument>& xModel,
const css::uno::Reference<css::text::XTextViewCursor>& xTVCursor);
//static double verticalPositionRelativeToPageBoundary( const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::text::XTextViewCursor >& xTVCursor, const css::uno::Reference< css::beans::XPropertySet >& xStyleProps ) throw( css::uno::RuntimeException );
};
diff --git a/sw/source/ui/vba/vbalistformat.cxx b/sw/source/ui/vba/vbalistformat.cxx
index 0dcce10ee881..bb1a376f2c1d 100644
--- a/sw/source/ui/vba/vbalistformat.cxx
+++ b/sw/source/ui/vba/vbalistformat.cxx
@@ -36,10 +36,13 @@
#include <comphelper/scopeguard.hxx>
#include <editeng/numitem.hxx>
#include "vbalisttemplate.hxx"
+#include "wordvbahelper.hxx"
+#include <unotxdoc.hxx>
#include <vector>
using namespace ::ooo::vba;
+using namespace ::ooo::vba::word;
using namespace ::com::sun::star;
SwVbaListFormat::SwVbaListFormat( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, uno::Reference< text::XTextRange > xTextRange ) : SwVbaListFormat_BASE( rParent, rContext ), mxTextRange(std::move( xTextRange ))
@@ -131,10 +134,8 @@ static void addParagraphsToList(const Ref& a,
void SAL_CALL SwVbaListFormat::ConvertNumbersToText( )
{
- css::uno::Reference<css::frame::XModel> xModel(getThisWordDoc(mxContext));
- css::uno::Reference<css::document::XUndoManagerSupplier> xUndoSupplier(
- xModel, css::uno::UNO_QUERY_THROW);
- css::uno::Reference<css::document::XUndoManager> xUndoManager(xUndoSupplier->getUndoManager());
+ rtl::Reference<SwXTextDocument> xModel(getThisWordDoc(mxContext));
+ css::uno::Reference<css::document::XUndoManager> xUndoManager(xModel->getUndoManager());
xUndoManager->enterUndoContext(u"ConvertNumbersToText"_ustr);
xModel->lockControllers();
comphelper::ScopeGuard g([xModel, xUndoManager]() {
diff --git a/sw/source/ui/vba/vbapagesetup.cxx b/sw/source/ui/vba/vbapagesetup.cxx
index 8163ff48239d..e227d59043c3 100644
--- a/sw/source/ui/vba/vbapagesetup.cxx
+++ b/sw/source/ui/vba/vbapagesetup.cxx
@@ -22,17 +22,19 @@
#include <ooo/vba/word/WdSectionStart.hpp>
#include <ooo/vba/word/WdOrientation.hpp>
#include "wordvbahelper.hxx"
+#include <unotxdoc.hxx>
+#include <unobasestyle.hxx>
using namespace ::com::sun::star;
using namespace ::ooo::vba;
SwVbaPageSetup::SwVbaPageSetup(const uno::Reference< XHelperInterface >& xParent,
const uno::Reference< uno::XComponentContext >& xContext,
- const uno::Reference< frame::XModel >& xModel,
+ const rtl::Reference< SwXTextDocument >& xModel,
const uno::Reference< beans::XPropertySet >& xProps ):
- SwVbaPageSetup_BASE( xParent, xContext )
+ SwVbaPageSetup_BASE( xParent, xContext ),
+ mxModel(xModel)
{
- mxModel.set( xModel, uno::UNO_SET_THROW );
mxPageProps.set( xProps, uno::UNO_SET_THROW );
mnOrientPortrait = word::WdOrientation::wdOrientPortrait;
mnOrientLandscape = word::WdOrientation::wdOrientLandscape;
@@ -151,7 +153,7 @@ void SAL_CALL SwVbaPageSetup::setDifferentFirstPageHeaderFooter( sal_Bool status
else
newStyle = "Standard";
- uno::Reference< beans::XPropertySet > xStyleProps( word::getCurrentPageStyle( mxModel ), uno::UNO_QUERY_THROW );
+ rtl::Reference< SwXBaseStyle > xStyleProps( word::getCurrentPageStyle( mxModel ) );
sal_Int32 nTopMargin = 0;
xStyleProps->getPropertyValue(u"TopMargin"_ustr) >>= nTopMargin;
sal_Int32 nBottomMargin = 0;
@@ -191,7 +193,7 @@ void SAL_CALL SwVbaPageSetup::setDifferentFirstPageHeaderFooter( sal_Bool status
xCursorProps->setPropertyValue(u"PageDescName"_ustr, uno::Any( newStyle ) );
}
- uno::Reference< beans::XPropertySet > xFirstPageProps( word::getCurrentPageStyle( mxModel ), uno::UNO_QUERY_THROW );
+ rtl::Reference< SwXBaseStyle > xFirstPageProps( word::getCurrentPageStyle( mxModel ) );
xFirstPageProps->setPropertyValue(u"TopMargin"_ustr, uno::Any( nTopMargin ) );
xFirstPageProps->setPropertyValue(u"BottomMargin"_ustr, uno::Any( nBottomMargin ) );
xFirstPageProps->setPropertyValue(u"LeftMargin"_ustr, uno::Any( nLeftMargin ) );
diff --git a/sw/source/ui/vba/vbapagesetup.hxx b/sw/source/ui/vba/vbapagesetup.hxx
index b6b9c0155115..8ccf061d04e5 100644
--- a/sw/source/ui/vba/vbapagesetup.hxx
+++ b/sw/source/ui/vba/vbapagesetup.hxx
@@ -25,12 +25,17 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <vbahelper/vbahelperinterface.hxx>
#include <vbahelper/vbapagesetupbase.hxx>
+#include <rtl/ref.hxx>
+
+class SwXTextDocument;
typedef cppu::ImplInheritanceHelper< VbaPageSetupBase, ooo::vba::word::XPageSetup > SwVbaPageSetup_BASE;
class SwVbaPageSetup : public SwVbaPageSetup_BASE
{
private:
+ rtl::Reference< SwXTextDocument > mxModel;
+
/// @throws css::uno::RuntimeException
OUString getStyleOfFirstPage() const;
@@ -38,7 +43,7 @@ public:
/// @throws css::uno::RuntimeException
SwVbaPageSetup( const css::uno::Reference< ooo::vba::XHelperInterface >& xParent,
const css::uno::Reference< css::uno::XComponentContext >& xContext,
- const css::uno::Reference< css::frame::XModel >& xModel,
+ const rtl::Reference< SwXTextDocument >& xModel,
const css::uno::Reference< css::beans::XPropertySet >& xProps );
// Attributes
diff --git a/sw/source/ui/vba/vbapane.cxx b/sw/source/ui/vba/vbapane.cxx
index 26f579ccb5cd..3f631744ebec 100644
--- a/sw/source/ui/vba/vbapane.cxx
+++ b/sw/source/ui/vba/vbapane.cxx
@@ -20,13 +20,16 @@
#include <utility>
#include <vbahelper/vbahelper.hxx>
#include "vbaview.hxx"
+#include <unotxdoc.hxx>
using namespace ::ooo::vba;
using namespace ::com::sun::star;
-SwVbaPane::SwVbaPane( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext,
- uno::Reference< frame::XModel > xModel ) :
- SwVbaPane_BASE( rParent, rContext ), mxModel(std::move( xModel ))
+SwVbaPane::SwVbaPane( const uno::Reference< ooo::vba::XHelperInterface >& rParent,
+ const uno::Reference< uno::XComponentContext >& rContext,
+ rtl::Reference< SwXTextDocument > xModel )
+: SwVbaPane_BASE( rParent, rContext ),
+ mxModel(std::move( xModel ))
{
}
@@ -43,7 +46,7 @@ SwVbaPane::View()
void SAL_CALL
SwVbaPane::Close( )
{
- dispatchRequests( mxModel,u".uno:CloseWin"_ustr );
+ dispatchRequests( static_cast<SfxBaseModel*>(mxModel.get()), u".uno:CloseWin"_ustr );
}
OUString
diff --git a/sw/source/ui/vba/vbapane.hxx b/sw/source/ui/vba/vbapane.hxx
index e0a81b9e0f04..ad2cd50a1d8c 100644
--- a/sw/source/ui/vba/vbapane.hxx
+++ b/sw/source/ui/vba/vbapane.hxx
@@ -21,19 +21,22 @@
#include <ooo/vba/word/XPane.hpp>
#include <vbahelper/vbahelperinterface.hxx>
+#include <rtl/ref.hxx>
+
+class SwXTextDocument;
typedef InheritedHelperInterfaceWeakImpl<ooo::vba::word::XPane> SwVbaPane_BASE;
class SwVbaPane : public SwVbaPane_BASE
{
private:
- css::uno::Reference<css::frame::XModel> mxModel;
+ rtl::Reference<SwXTextDocument> mxModel;
public:
/// @throws css::uno::RuntimeException
SwVbaPane(const css::uno::Reference<ooo::vba::XHelperInterface>& rParent,
const css::uno::Reference<css::uno::XComponentContext>& rContext,
- css::uno::Reference<css::frame::XModel> xModel);
+ rtl::Reference<SwXTextDocument> xModel);
virtual ~SwVbaPane() override;
// Methods
diff --git a/sw/source/ui/vba/vbapanes.cxx b/sw/source/ui/vba/vbapanes.cxx
index d6a28a4d6894..0c6a4765a940 100644
--- a/sw/source/ui/vba/vbapanes.cxx
+++ b/sw/source/ui/vba/vbapanes.cxx
@@ -19,6 +19,7 @@
#include "vbapanes.hxx"
#include "vbapane.hxx"
#include <cppuhelper/implbase.hxx>
+#include <unotxdoc.hxx>
#include <utility>
using namespace ::ooo::vba;
@@ -32,10 +33,13 @@ class PanesIndexAccess : public ::cppu::WeakImplHelper<container::XIndexAccess >
private:
uno::Reference< XHelperInterface > mxParent;
uno::Reference< uno::XComponentContext > mxContext;
- uno::Reference< frame::XModel > mxModel;
+ rtl::Reference< SwXTextDocument > mxModel;
public:
- PanesIndexAccess( uno::Reference< XHelperInterface > xParent, uno::Reference< uno::XComponentContext > xContext, uno::Reference< frame::XModel > xModel ) : mxParent(std::move( xParent )), mxContext(std::move( xContext )), mxModel(std::move( xModel )) {}
+ PanesIndexAccess( uno::Reference< XHelperInterface > xParent,
+ uno::Reference< uno::XComponentContext > xContext,
+ rtl::Reference< SwXTextDocument > xModel )
+ : mxParent(std::move( xParent )), mxContext(std::move( xContext )), mxModel(std::move( xModel )) {}
// XIndexAccess
virtual sal_Int32 SAL_CALL getCount( ) override
@@ -79,9 +83,10 @@ public:
}
-SwVbaPanes::SwVbaPanes( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel ): SwVbaPanes_BASE( xParent, xContext, new PanesIndexAccess( xParent, xContext, xModel ) )
+SwVbaPanes::SwVbaPanes( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const rtl::Reference< SwXTextDocument >& xModel ): SwVbaPanes_BASE( xParent, xContext, new PanesIndexAccess( xParent, xContext, xModel ) )
{
}
+
// XEnumerationAccess
uno::Type
SwVbaPanes::getElementType()
diff --git a/sw/source/ui/vba/vbapanes.hxx b/sw/source/ui/vba/vbapanes.hxx
index 27a6d65671ce..5d38e5198834 100644
--- a/sw/source/ui/vba/vbapanes.hxx
+++ b/sw/source/ui/vba/vbapanes.hxx
@@ -20,13 +20,18 @@
#include <vbahelper/vbacollectionimpl.hxx>
#include <ooo/vba/word/XPanes.hpp>
+#include <rtl/ref.hxx>
+
+class SwXTextDocument;
typedef CollTestImplHelper< ooo::vba::word::XPanes > SwVbaPanes_BASE;
class SwVbaPanes : public SwVbaPanes_BASE
{
public:
- SwVbaPanes( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::frame::XModel >& xModel );
+ SwVbaPanes( const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext > & xContext,
+ const rtl::Reference< SwXTextDocument >& xModel );
// XEnumerationAccess
virtual css::uno::Type SAL_CALL getElementType() override;
diff --git a/sw/source/ui/vba/vbaparagraph.cxx b/sw/source/ui/vba/vbaparagraph.cxx
index 51eabcc612fd..c5e6a0e5e00e 100644
--- a/sw/source/ui/vba/vbaparagraph.cxx
+++ b/sw/source/ui/vba/vbaparagraph.cxx
@@ -21,6 +21,7 @@
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <cppuhelper/implbase.hxx>
#include <utility>
+#include <unotxdoc.hxx>
using namespace ::ooo::vba;
using namespace ::com::sun::star;
@@ -37,7 +38,7 @@ SwVbaParagraph::~SwVbaParagraph()
uno::Reference< word::XRange > SAL_CALL
SwVbaParagraph::getRange( )
{
- return uno::Reference< word::XRange >( new SwVbaRange( this, mxContext, mxTextDocument, mxTextRange->getStart(), mxTextRange->getEnd(), mxTextRange->getText() ) );
+ return uno::Reference< word::XRange >( new SwVbaRange( this, mxContext, dynamic_cast<SwXTextDocument*>(mxTextDocument.get()), mxTextRange->getStart(), mxTextRange->getEnd(), mxTextRange->getText() ) );
}
uno::Any SAL_CALL
diff --git a/sw/source/ui/vba/vbarange.cxx b/sw/source/ui/vba/vbarange.cxx
index 722dcfce92b1..6d800adee7c9 100644
--- a/sw/source/ui/vba/vbarange.cxx
+++ b/sw/source/ui/vba/vbarange.cxx
@@ -39,22 +39,43 @@
#include "vbasections.hxx"
#include "vbafield.hxx"
#include "wordvbahelper.hxx"
+#include <unotxdoc.hxx>
+#include <unostyle.hxx>
using namespace ::ooo::vba;
using namespace ::com::sun::star;
-SwVbaRange::SwVbaRange( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, uno::Reference< text::XTextDocument > xTextDocument, const uno::Reference< text::XTextRange >& rStart ) : SwVbaRange_BASE( rParent, rContext ), mxTextDocument(std::move( xTextDocument ))
+SwVbaRange::SwVbaRange( const uno::Reference< ooo::vba::XHelperInterface >& rParent,
+ const uno::Reference< uno::XComponentContext >& rContext,
+ rtl::Reference< SwXTextDocument > xTextDocument,
+ const uno::Reference< text::XTextRange >& rStart )
+: SwVbaRange_BASE( rParent, rContext ),
+ mxTextDocument(std::move( xTextDocument ))
{
uno::Reference< text::XTextRange > xEnd;
initialize( rStart, xEnd );
}
-SwVbaRange::SwVbaRange( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, uno::Reference< text::XTextDocument > xTextDocument, const uno::Reference< text::XTextRange >& rStart, const uno::Reference< text::XTextRange >& rEnd ) : SwVbaRange_BASE( rParent, rContext ), mxTextDocument(std::move( xTextDocument ))
+SwVbaRange::SwVbaRange( const uno::Reference< ooo::vba::XHelperInterface >& rParent,
+ const uno::Reference< uno::XComponentContext >& rContext,
+ rtl::Reference< SwXTextDocument > xTextDocument,
+ const uno::Reference< text::XTextRange >& rStart,
+ const uno::Reference< text::XTextRange >& rEnd )
+: SwVbaRange_BASE( rParent, rContext ),
+ mxTextDocument(std::move( xTextDocument ))
{
initialize( rStart, rEnd );
}
-SwVbaRange::SwVbaRange( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, uno::Reference< text::XTextDocument > xTextDocument, const uno::Reference< text::XTextRange >& rStart, const uno::Reference< text::XTextRange >& rEnd, uno::Reference< text::XText > xText ) : SwVbaRange_BASE( rParent, rContext ),mxTextDocument(std::move( xTextDocument )), mxText(std::move( xText ))
+SwVbaRange::SwVbaRange( const uno::Reference< ooo::vba::XHelperInterface >& rParent,
+ const uno::Reference< uno::XComponentContext >& rContext,
+ rtl::Reference< SwXTextDocument > xTextDocument,
+ const uno::Reference< text::XTextRange >& rStart,
+ const uno::Reference< text::XTextRange >& rEnd,
+ uno::Reference< text::XText > xText )
+: SwVbaRange_BASE( rParent, rContext ),
+ mxTextDocument(std::move( xTextDocument )),
+ mxText(std::move( xText ))
{
initialize( rStart, rEnd );
}
@@ -158,12 +179,10 @@ SwVbaRange::setText( const OUString& rText )
// insert the bookmark if the bookmark is deleted during setting text string
if( !sName.isEmpty() )
{
- uno::Reference< text::XBookmarksSupplier > xBookmarksSupplier( mxTextDocument, uno::UNO_QUERY_THROW );
- uno::Reference< container::XNameAccess > xNameAccess( xBookmarksSupplier->getBookmarks(), uno::UNO_SET_THROW );
+ uno::Reference< container::XNameAccess > xNameAccess( mxTextDocument->getBookmarks(), uno::UNO_SET_THROW );
if( !xNameAccess->hasByName( sName ) )
{
- uno::Reference< frame::XModel > xModel( mxTextDocument, uno::UNO_QUERY_THROW );
- SwVbaBookmarks::addBookmarkByName( xModel, sName, xRange->getStart() );
+ SwVbaBookmarks::addBookmarkByName( mxTextDocument, sName, xRange->getStart() );
}
}
}
@@ -215,8 +234,7 @@ void SAL_CALL SwVbaRange::InsertBreak(const uno::Any& _breakType)
void SAL_CALL
SwVbaRange::Select()
{
- uno::Reference< frame::XModel > xModel( mxTextDocument, uno::UNO_QUERY_THROW );
- uno::Reference< text::XTextViewCursor > xTextViewCursor = word::getXTextViewCursor( xModel );
+ uno::Reference< text::XTextViewCursor > xTextViewCursor = word::getXTextViewCursor( mxTextDocument );
xTextViewCursor->gotoRange( mxTextCursor->getStart(), false );
xTextViewCursor->gotoRange( mxTextCursor->getEnd(), true );
}
@@ -279,11 +297,9 @@ SwVbaRange::getStyle()
OUString aStyleName;
OUString aStyleType;
GetStyleInfo( aStyleName, aStyleType );
- uno::Reference< style::XStyleFamiliesSupplier > xStyleSupplier( mxTextDocument, uno::UNO_QUERY_THROW);
- uno::Reference< container::XNameAccess > xStylesAccess( xStyleSupplier->getStyleFamilies()->getByName( aStyleType ), uno::UNO_QUERY_THROW );
+ uno::Reference< container::XNameAccess > xStylesAccess( mxTextDocument->getStyleFamilies()->getByName( aStyleType ), uno::UNO_QUERY_THROW );
uno::Reference< beans::XPropertySet > xStyleProps( xStylesAccess->getByName( aStyleName ), uno::UNO_QUERY_THROW );
- uno::Reference< frame::XModel > xModel( mxTextDocument, uno::UNO_QUERY_THROW );
- return uno::Any( uno::Reference< word::XStyle >( new SwVbaStyle( this, mxContext, xModel, xStyleProps ) ) );
+ return uno::Any( uno::Reference< word::XStyle >( new SwVbaStyle( this, mxContext, mxTextDocument, xStyleProps ) ) );
}
void SAL_CALL
@@ -304,8 +320,7 @@ uno::Reference< word::XFind > SAL_CALL
SwVbaRange::getFind()
{
uno::Reference< text::XTextRange > xTextRange = getXTextRange();
- uno::Reference< frame::XModel > xModel( mxTextDocument, uno::UNO_QUERY_THROW );
- return SwVbaFind::GetOrCreateFind(this, mxContext, xModel, xTextRange);
+ return SwVbaFind::GetOrCreateFind(this, mxContext, mxTextDocument, xTextRange);
}
uno::Reference< word::XListFormat > SAL_CALL
@@ -330,14 +345,12 @@ uno::Any SAL_CALL
SwVbaRange::PageSetup( )
{
uno::Reference< beans::XPropertySet > xParaProps( mxTextCursor, uno::UNO_QUERY_THROW );
- uno::Reference< frame::XModel > xModel( mxTextDocument, uno::UNO_QUERY_THROW );
OUString aPageStyleName;
xParaProps->getPropertyValue(u"PageStyleName"_ustr) >>= aPageStyleName;
- uno::Reference< style::XStyleFamiliesSupplier > xSytleFamSupp( xModel, uno::UNO_QUERY_THROW );
- uno::Reference< container::XNameAccess > xSytleFamNames( xSytleFamSupp->getStyleFamilies(), uno::UNO_SET_THROW );
+ rtl::Reference< SwXStyleFamilies > xSytleFamNames( mxTextDocument->getSwStyleFamilies() );
uno::Reference< container::XNameAccess > xPageStyles( xSytleFamNames->getByName(u"PageStyles"_ustr), uno::UNO_QUERY_THROW );
uno::Reference< beans::XPropertySet > xPageProps( xPageStyles->getByName( aPageStyleName ), uno::UNO_QUERY_THROW );
- return uno::Any( uno::Reference< word::XPageSetup >( new SwVbaPageSetup( this, mxContext, xModel, xPageProps ) ) );
+ return uno::Any( uno::Reference< word::XPageSetup >( new SwVbaPageSetup( this, mxContext, mxTextDocument, xPageProps ) ) );
}
::sal_Int32 SAL_CALL SwVbaRange::getStart()
@@ -387,8 +400,7 @@ uno::Any SAL_CALL
SwVbaRange::Revisions( const uno::Any& index )
{
uno::Reference< text::XTextRange > xTextRange = getXTextRange();
- uno::Reference< frame::XModel > xModel( mxTextDocument, uno::UNO_QUERY_THROW );
- uno::Reference< XCollection > xCol( new SwVbaRevisions( mxParent, mxContext, xModel, xTextRange ) );
+ uno::Reference< XCollection > xCol( new SwVbaRevisions( mxParent, mxContext, mxTextDocument, xTextRange ) );
if ( index.hasValue() )
return xCol->Item( index, uno::Any() );
return uno::Any( xCol );
@@ -398,8 +410,7 @@ uno::Any SAL_CALL
SwVbaRange::Sections( const uno::Any& index )
{
uno::Reference< text::XTextRange > xTextRange = getXTextRange();
- uno::Reference< frame::XModel > xModel( mxTextDocument, uno::UNO_QUERY_THROW );
- uno::Reference< XCollection > xCol( new SwVbaSections( mxParent, mxContext, xModel, xTextRange ) );
+ uno::Reference< XCollection > xCol( new SwVbaSections( mxParent, mxContext, mxTextDocument, xTextRange ) );
if ( index.hasValue() )
return xCol->Item( index, uno::Any() );
return uno::Any( xCol );
@@ -409,8 +420,7 @@ uno::Any SAL_CALL
SwVbaRange::Fields( const uno::Any& index )
{
//FIXME: should be get the field in current range
- uno::Reference< frame::XModel > xModel( mxTextDocument, uno::UNO_QUERY_THROW );
- uno::Reference< XCollection > xCol( new SwVbaFields( mxParent, mxContext, xModel ) );
+ uno::Reference< XCollection > xCol( new SwVbaFields( mxParent, mxContext, mxTextDocument ) );
if ( index.hasValue() )
return xCol->Item( index, uno::Any() );
return uno::Any( xCol );
diff --git a/sw/source/ui/vba/vbarange.hxx b/sw/source/ui/vba/vbarange.hxx
index 6ae7af9113c7..b6f0c77c3c2a 100644
--- a/sw/source/ui/vba/vbarange.hxx
+++ b/sw/source/ui/vba/vbarange.hxx
@@ -27,13 +27,16 @@
#include <com/sun/star/text/XTextRange.hpp>
#include <com/sun/star/text/XTextDocument.hpp>
#include <ooo/vba/word/XListFormat.hpp>
+#include <rtl/ref.hxx>
+
+class SwXTextDocument;
typedef InheritedHelperInterfaceWeakImpl< ooo::vba::word::XRange > SwVbaRange_BASE;
class SwVbaRange : public SwVbaRange_BASE
{
private:
- css::uno::Reference< css::text::XTextDocument > mxTextDocument;
+ rtl::Reference< SwXTextDocument > mxTextDocument;
css::uno::Reference< css::text::XTextCursor > mxTextCursor;
css::uno::Reference< css::text::XText > mxText;
@@ -46,15 +49,27 @@ private:
public:
/// @throws css::script::BasicErrorException
/// @throws css::uno::RuntimeException
- SwVbaRange( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, css::uno::Reference< css::text::XTextDocument > xTextDocument, const css::uno::Reference< css::text::XTextRange >& rStart);
+ SwVbaRange( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent,
+ const css::uno::Reference< css::uno::XComponentContext >& rContext,
+ rtl::Reference< SwXTextDocument > xTextDocument,
+ const css::uno::Reference< css::text::XTextRange >& rStart);
/// @throws css::script::BasicErrorException
/// @throws css::uno::RuntimeException
- SwVbaRange( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, css::uno::Reference< css::text::XTextDocument > xTextDocument, const css::uno::Reference< css::text::XTextRange >& rStart, const css::uno::Reference< css::text::XTextRange >& rEnd );
+ SwVbaRange( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent,
+ const css::uno::Reference< css::uno::XComponentContext >& rContext,
+ rtl::Reference< SwXTextDocument > xTextDocument,
+ const css::uno::Reference< css::text::XTextRange >& rStart,
+ const css::uno::Reference< css::text::XTextRange >& rEnd );
/// @throws css::script::BasicErrorException
/// @throws css::uno::RuntimeException
- SwVbaRange( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, css::uno::Reference< css::text::XTextDocument > xTextDocument, const css::uno::Reference< css::text::XTextRange >& rStart, const css::uno::Reference< css::text::XTextRange >& rEnd, css::uno::Reference< css::text::XText > xText);
+ SwVbaRange( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent,
+ const css::uno::Reference< css::uno::XComponentContext >& rContext,
+ rtl::Reference< SwXTextDocument > xTextDocument,
+ const css::uno::Reference< css::text::XTextRange >& rStart,
+ const css::uno::Reference< css::text::XTextRange >& rEnd,
+ css::uno::Reference< css::text::XText > xText);
virtual ~SwVbaRange() override;
- const css::uno::Reference< css::text::XTextDocument >& getDocument() const { return mxTextDocument; }
+ const rtl::Reference< SwXTextDocument >& getDocument() const { return mxTextDocument; }
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getXTextRange() override;
const css::uno::Reference< css::text::XText >& getXText() const { return mxText; }
diff --git a/sw/source/ui/vba/vbarevision.cxx b/sw/source/ui/vba/vbarevision.cxx
index 79383e1046e7..6b5b4c1a7808 100644
--- a/sw/source/ui/vba/vbarevision.cxx
+++ b/sw/source/ui/vba/vbarevision.cxx
@@ -25,12 +25,20 @@
#include <docsh.hxx>
#include <doc.hxx>
#include <IDocumentRedlineAccess.hxx>
+#include <unotxdoc.hxx>
+#include <unoredlines.hxx>
#include <utility>
using namespace ::ooo::vba;
using namespace ::com::sun::star;
-SwVbaRevision::SwVbaRevision( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, uno::Reference< frame::XModel > xModel, uno::Reference< beans::XPropertySet > xRedlineProps ) : SwVbaRevision_BASE( rParent, rContext ), mxModel(std::move( xModel )), mxRedlineProps(std::move( xRedlineProps ))
+SwVbaRevision::SwVbaRevision( const uno::Reference< ooo::vba::XHelperInterface >& rParent,
+ const uno::Reference< uno::XComponentContext >& rContext,
+ rtl::Reference< SwXTextDocument > xModel,
+ uno::Reference< beans::XPropertySet > xRedlineProps )
+: SwVbaRevision_BASE( rParent, rContext ),
+ mxModel(std::move( xModel )),
+ mxRedlineProps(std::move( xRedlineProps ))
{
}
@@ -41,8 +49,7 @@ SwVbaRevision::~SwVbaRevision()
sal_Int32 SwVbaRevision::GetPosition()
{
sal_Int32 nPos = -1;
- uno::Reference< document::XRedlinesSupplier > xRedlinesSupp( mxModel, uno::UNO_QUERY_THROW );
- uno::Reference< container::XIndexAccess > xRedlines( xRedlinesSupp->getRedlines(), uno::UNO_QUERY_THROW );
+ rtl::Reference< SwXRedlines > xRedlines( mxModel->getSwRedlines() );
sal_Int32 nCount = xRedlines->getCount();
for( sal_Int32 i = 0; i < nCount; i++ )
{
@@ -63,7 +70,7 @@ sal_Int32 SwVbaRevision::GetPosition()
void SAL_CALL
SwVbaRevision::Accept()
{
- SwDoc* pDoc = word::getDocShell( mxModel )->GetDoc();
+ SwDoc* pDoc = mxModel->GetDocShell()->GetDoc();
if( pDoc )
pDoc->getIDocumentRedlineAccess().AcceptRedline( GetPosition(), true );
}
@@ -71,7 +78,7 @@ SwVbaRevision::Accept()
void SAL_CALL
SwVbaRevision::Reject( )
{
- SwDoc* pDoc = word::getDocShell( mxModel )->GetDoc();
+ SwDoc* pDoc = mxModel->GetDocShell()->GetDoc();
if( pDoc )
pDoc->getIDocumentRedlineAccess().RejectRedline( GetPosition(), true );
}
diff --git a/sw/source/ui/vba/vbarevision.hxx b/sw/source/ui/vba/vbarevision.hxx
index c483f6578fe5..3e48e65798da 100644
--- a/sw/source/ui/vba/vbarevision.hxx
+++ b/sw/source/ui/vba/vbarevision.hxx
@@ -21,13 +21,16 @@
#include <ooo/vba/word/XRevision.hpp>
#include <vbahelper/vbahelperinterface.hxx>
+#include <rtl/ref.hxx>
+
+class SwXTextDocument;
typedef InheritedHelperInterfaceWeakImpl< ooo::vba::word::XRevision > SwVbaRevision_BASE;
class SwVbaRevision : public SwVbaRevision_BASE
{
private:
- css::uno::Reference< css::frame::XModel > mxModel;
+ rtl::Reference< SwXTextDocument > mxModel;
css::uno::Reference< css::beans::XPropertySet > mxRedlineProps;
private:
@@ -36,7 +39,10 @@ private:
public:
/// @throws css::uno::RuntimeException
- SwVbaRevision( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, css::uno::Reference< css::frame::XModel > xModel, css::uno::Reference< css::beans::XPropertySet > xRedlineProps );
+ SwVbaRevision( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent,
+ const css::uno::Reference< css::uno::XComponentContext >& rContext,
+ rtl::Reference< SwXTextDocument > xModel,
+ css::uno::Reference< css::beans::XPropertySet > xRedlineProps );
virtual ~SwVbaRevision() override;
// Methods
diff --git a/sw/source/ui/vba/vbarevisions.cxx b/sw/source/ui/vba/vbarevisions.cxx
index d5ec68d07cf7..7fb51dda4e4d 100644
--- a/sw/source/ui/vba/vbarevisions.cxx
+++ b/sw/source/ui/vba/vbarevisions.cxx
@@ -23,6 +23,8 @@
#include <com/sun/star/document/XRedlinesSupplier.hpp>
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/text/XTextRangeCompare.hpp>
+#include <unotxdoc.hxx>
+#include <unoredlines.hxx>
#include <utility>
using namespace ::ooo::vba;
@@ -56,8 +58,8 @@ class RevisionCollectionHelper : public ::cppu::WeakImplHelper< container::XInde
{
RevisionMap mRevisionMap;
public:
-/// @throws css::uno::RuntimeException
-RevisionCollectionHelper( const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XTextRange >& xTextRange );
+ /// @throws css::uno::RuntimeException
+ RevisionCollectionHelper( const rtl::Reference< SwXTextDocument >& xModel, const uno::Reference< text::XTextRange >& xTextRange );
// XElementAccess
virtual uno::Type SAL_CALL getElementType( ) override { return cppu::UnoType<beans::XPropertySet>::get(); }
@@ -81,11 +83,10 @@ RevisionCollectionHelper( const uno::Reference< frame::XModel >& xModel, const u
}
-RevisionCollectionHelper::RevisionCollectionHelper( const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XTextRange >& xTextRange )
+RevisionCollectionHelper::RevisionCollectionHelper( const rtl::Reference< SwXTextDocument >& xModel, const uno::Reference< text::XTextRange >& xTextRange )
{
uno::Reference< text::XTextRangeCompare > xTRC( xTextRange->getText(), uno::UNO_QUERY_THROW );
- uno::Reference< document::XRedlinesSupplier > xRedlinesSupp( xModel, uno::UNO_QUERY_THROW );
- uno::Reference< container::XIndexAccess > xRedlines( xRedlinesSupp->getRedlines(), uno::UNO_QUERY_THROW );
+ rtl::Reference< SwXRedlines > xRedlines( xModel->getSwRedlines() );
sal_Int32 nCount = xRedlines->getCount();
for( sal_Int32 index = 0; index < nCount; index++ )
{
@@ -102,10 +103,15 @@ namespace {
class RevisionsEnumeration : public EnumerationHelperImpl
{
- uno::Reference< frame::XModel > m_xModel;
+ rtl::Reference< SwXTextDocument > m_xModel;
public:
/// @throws uno::RuntimeException
- RevisionsEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, uno::Reference< frame::XModel > xModel ) : EnumerationHelperImpl( xParent, xContext, xEnumeration ), m_xModel(std::move( xModel )) {}
+ RevisionsEnumeration( const uno::Reference< XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext >& xContext,
+ const uno::Reference< container::XEnumeration >& xEnumeration,
+ rtl::Reference< SwXTextDocument > xModel )
+ : EnumerationHelperImpl( xParent, xContext, xEnumeration ),
+ m_xModel(std::move( xModel )) {}
virtual uno::Any SAL_CALL nextElement( ) override
{
@@ -117,11 +123,21 @@ public:
}
-SwVbaRevisions::SwVbaRevisions( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XTextRange >& xTextRange ): SwVbaRevisions_BASE( xParent, xContext, new RevisionCollectionHelper( xModel, xTextRange ) ), mxModel( xModel )
+SwVbaRevisions::SwVbaRevisions( const uno::Reference< XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext > & xContext,
+ const rtl::Reference< SwXTextDocument >& xModel,
+ const uno::Reference< text::XTextRange >& xTextRange )
+: SwVbaRevisions_BASE( xParent, xContext, new RevisionCollectionHelper( xModel, xTextRange ) ),
+ mxModel( xModel )
{
}
-SwVbaRevisions::SwVbaRevisions( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, uno::Reference< frame::XModel > xModel, const uno::Reference< container::XIndexAccess >& xIndexAccess ): SwVbaRevisions_BASE( xParent, xContext, xIndexAccess ), mxModel(std::move( xModel ))
+SwVbaRevisions::SwVbaRevisions( const uno::Reference< XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext > & xContext,
+ rtl::Reference< SwXTextDocument > xModel,
+ const uno::Reference< container::XIndexAccess >& xIndexAccess )
+: SwVbaRevisions_BASE( xParent, xContext, xIndexAccess ),
+ mxModel(std::move( xModel ))
{
}
diff --git a/sw/source/ui/vba/vbarevisions.hxx b/sw/source/ui/vba/vbarevisions.hxx
index a3fe79108ad5..cebd820cc0a4 100644
--- a/sw/source/ui/vba/vbarevisions.hxx
+++ b/sw/source/ui/vba/vbarevisions.hxx
@@ -22,18 +22,27 @@
#include <vbahelper/vbacollectionimpl.hxx>
#include <ooo/vba/word/XRevisions.hpp>
#include <com/sun/star/text/XTextRange.hpp>
+#include <rtl/ref.hxx>
+
+class SwXTextDocument;
typedef CollTestImplHelper< ooo::vba::word::XRevisions > SwVbaRevisions_BASE;
class SwVbaRevisions : public SwVbaRevisions_BASE
{
private:
- css::uno::Reference< css::frame::XModel > mxModel;
+ rtl::Reference< SwXTextDocument > mxModel;
public:
- SwVbaRevisions( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::text::XTextRange >& xTextRange );
-
- SwVbaRevisions( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, css::uno::Reference< css::frame::XModel > xModel, const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess );
+ SwVbaRevisions( const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext > & xContext,
+ const rtl::Reference< SwXTextDocument >& xModel,
+ const css::uno::Reference< css::text::XTextRange >& xTextRange );
+
+ SwVbaRevisions( const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext > & xContext,
+ rtl::Reference< SwXTextDocument > xModel,
+ const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess );
// Methods
virtual void SAL_CALL AcceptAll( ) override;
diff --git a/sw/source/ui/vba/vbarow.cxx b/sw/source/ui/vba/vbarow.cxx
index 75b56d06a073..7b63286ab63c 100644
--- a/sw/source/ui/vba/vbarow.cxx
+++ b/sw/source/ui/vba/vbarow.cxx
@@ -26,8 +26,11 @@
#include <ooo/vba/word/WdRowHeightRule.hpp>
#include <ooo/vba/word/WdConstants.hpp>
#include "vbatablehelper.hxx"
+#include "wordvbahelper.hxx"
+#include <unotxdoc.hxx>
using namespace ::ooo::vba;
+using namespace ::ooo::vba::word;
using namespace ::com::sun::star;
SwVbaRow::SwVbaRow( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext,uno::Reference< text::XTextTable > xTextTable, sal_Int32 nIndex ) :
@@ -79,7 +82,7 @@ SwVbaRow::Select( )
SelectRow( getCurrentWordDoc(mxContext), mxTextTable, mnIndex, mnIndex );
}
-void SwVbaRow::SelectRow( const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XTextTable >& xTextTable, sal_Int32 nStartRow, sal_Int32 nEndRow )
+void SwVbaRow::SelectRow( const rtl::Reference< SwXTextDocument >& xModel, const uno::Reference< text::XTextTable >& xTextTable, sal_Int32 nStartRow, sal_Int32 nEndRow )
{
OUString sRangeName = "A" + OUString::number(nStartRow + 1);
SwVbaTableHelper aTableHelper( xTextTable );
diff --git a/sw/source/ui/vba/vbarow.hxx b/sw/source/ui/vba/vbarow.hxx
index 40abaee2eee5..717a8ed927da 100644
--- a/sw/source/ui/vba/vbarow.hxx
+++ b/sw/source/ui/vba/vbarow.hxx
@@ -23,6 +23,9 @@
#include <vbahelper/vbahelperinterface.hxx>
#include <com/sun/star/table/XTableRows.hpp>
#include <com/sun/star/text/XTextTable.hpp>
+#include <rtl/ref.hxx>
+
+class SwXTextDocument;
typedef InheritedHelperInterfaceWeakImpl< ooo::vba::word::XRow > SwVbaRow_BASE;
@@ -50,7 +53,7 @@ public:
virtual void SAL_CALL SetHeight( float height, sal_Int32 heightrule ) override;
/// @throws css::uno::RuntimeException
- static void SelectRow( const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::text::XTextTable >& xTextTable, sal_Int32 nStartRow, sal_Int32 nEndRow );
+ static void SelectRow( const rtl::Reference< SwXTextDocument >& xModel, const css::uno::Reference< css::text::XTextTable >& xTextTable, sal_Int32 nStartRow, sal_Int32 nEndRow );
// XHelperInterface
virtual OUString getServiceImplName() override;
diff --git a/sw/source/ui/vba/vbarows.cxx b/sw/source/ui/vba/vbarows.cxx
index f4ea969d347d..e33f732e7638 100644
--- a/sw/source/ui/vba/vbarows.cxx
+++ b/sw/source/ui/vba/vbarows.cxx
@@ -28,8 +28,11 @@
#include <utility>
#include "vbacolumns.hxx"
#include "vbatablehelper.hxx"
+#include "wordvbahelper.hxx"
+#include <unotxdoc.hxx>
using namespace ::ooo::vba;
+using namespace ::ooo::vba::word;
using namespace ::com::sun::star;
namespace {
diff --git a/sw/source/ui/vba/vbasection.cxx b/sw/source/ui/vba/vbasection.cxx
index a63d6f4a50d8..c47e6651552c 100644
--- a/sw/source/ui/vba/vbasection.cxx
+++ b/sw/source/ui/vba/vbasection.cxx
@@ -21,12 +21,18 @@
#include <vbahelper/vbahelper.hxx>
#include "vbapagesetup.hxx"
#include "vbaheadersfooters.hxx"
+#include <unotxdoc.hxx>
using namespace ::ooo::vba;
using namespace ::com::sun::star;
-SwVbaSection::SwVbaSection( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, uno::Reference< frame::XModel > xModel, uno::Reference< beans::XPropertySet > xProps ) :
- SwVbaSection_BASE( rParent, rContext ), mxModel(std::move( xModel )), mxPageProps(std::move( xProps ))
+SwVbaSection::SwVbaSection( const uno::Reference< ooo::vba::XHelperInterface >& rParent,
+ const uno::Reference< uno::XComponentContext >& rContext,
+ rtl::Reference< SwXTextDocument > xModel,
+ uno::Reference< beans::XPropertySet > xProps )
+: SwVbaSection_BASE( rParent, rContext ),
+ mxModel(std::move( xModel )),
+ mxPageProps(std::move( xProps ))
{
}
diff --git a/sw/source/ui/vba/vbasection.hxx b/sw/source/ui/vba/vbasection.hxx
index 9a1b92742413..1378fa189858 100644
--- a/sw/source/ui/vba/vbasection.hxx
+++ b/sw/source/ui/vba/vbasection.hxx
@@ -21,18 +21,24 @@
#include <ooo/vba/word/XSection.hpp>
#include <vbahelper/vbahelperinterface.hxx>
+#include <rtl/ref.hxx>
+
+class SwXTextDocument;
typedef InheritedHelperInterfaceWeakImpl< ooo::vba::word::XSection > SwVbaSection_BASE;
class SwVbaSection : public SwVbaSection_BASE
{
private:
- css::uno::Reference< css::frame::XModel > mxModel;
+ rtl::Reference< SwXTextDocument > mxModel;
css::uno::Reference< css::beans::XPropertySet > mxPageProps;
public:
/// @throws css::uno::RuntimeException
- SwVbaSection( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, css::uno::Reference< css::frame::XModel > xModel, css::uno::Reference< css::beans::XPropertySet > xProps );
+ SwVbaSection( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent,
+ const css::uno::Reference< css::uno::XComponentContext >& rContext,
+ rtl::Reference< SwXTextDocument > xModel,
+ css::uno::Reference< css::beans::XPropertySet > xProps );
virtual ~SwVbaSection() override;
// Attributes
diff --git a/sw/source/ui/vba/vbasections.cxx b/sw/source/ui/vba/vbasections.cxx
index a9c4442e4e6e..75fd915aae08 100644
--- a/sw/source/ui/vba/vbasections.cxx
+++ b/sw/source/ui/vba/vbasections.cxx
@@ -24,6 +24,8 @@
#include "wordvbahelper.hxx"
#include <cppuhelper/implbase.hxx>
#include <utility>
+#include <unotxdoc.hxx>
+#include <unostyle.hxx>
using namespace ::ooo::vba;
using namespace ::com::sun::star;
@@ -59,15 +61,19 @@ class SectionCollectionHelper : public ::cppu::WeakImplHelper< container::XIndex
private:
uno::Reference< XHelperInterface > mxParent;
uno::Reference< uno::XComponentContext > mxContext;
- uno::Reference< frame::XModel > mxModel;
+ rtl::Reference< SwXTextDocument > mxModel;
XSectionVec mxSections;
public:
/// @throws uno::RuntimeException
- SectionCollectionHelper( uno::Reference< XHelperInterface > xParent, uno::Reference< uno::XComponentContext > xContext, uno::Reference< frame::XModel > xModel ) : mxParent(std::move( xParent )), mxContext(std::move( xContext )), mxModel(std::move( xModel ))
+ SectionCollectionHelper( uno::Reference< XHelperInterface > xParent,
+ uno::Reference< uno::XComponentContext > xContext,
+ rtl::Reference< SwXTextDocument > xModel )
+ : mxParent(std::move( xParent )),
+ mxContext(std::move( xContext )),
+ mxModel(std::move( xModel ))
{
- uno::Reference< style::XStyleFamiliesSupplier > xSytleFamSupp( mxModel, uno::UNO_QUERY_THROW );
- uno::Reference< container::XNameAccess > xSytleFamNames( xSytleFamSupp->getStyleFamilies(), uno::UNO_SET_THROW );
+ rtl::Reference< SwXStyleFamilies > xSytleFamNames( mxModel->getSwStyleFamilies() );
uno::Reference< container::XIndexAccess > xPageStyles( xSytleFamNames->getByName(u"PageStyles"_ustr), uno::UNO_QUERY_THROW );
sal_Int32 nCount = xPageStyles->getCount();
for( sal_Int32 index = 0; index < nCount; ++index )
@@ -83,7 +89,13 @@ public:
}
/// @throws uno::RuntimeException
- SectionCollectionHelper( uno::Reference< XHelperInterface > xParent, uno::Reference< uno::XComponentContext > xContext, uno::Reference< frame::XModel > xModel, const uno::Reference< text::XTextRange >& xTextRange ) : mxParent(std::move( xParent )), mxContext(std::move( xContext )), mxModel(std::move( xModel ))
+ SectionCollectionHelper( uno::Reference< XHelperInterface > xParent,
+ uno::Reference< uno::XComponentContext > xContext,
+ rtl::Reference< SwXTextDocument > xModel,
+ const uno::Reference< text::XTextRange >& xTextRange )
+ : mxParent(std::move( xParent )),
+ mxContext(std::move( xContext )),
+ mxModel(std::move( xModel ))
{
// Hacky implementation of Range.Sections, only support 1 section
uno::Reference< beans::XPropertySet > xRangeProps( xTextRange, uno::UNO_QUERY_THROW );
@@ -122,10 +134,15 @@ public:
class SectionsEnumWrapper : public EnumerationHelperImpl
{
- uno::Reference< frame::XModel > mxModel;
+ rtl::Reference< SwXTextDocument > mxModel;
public:
/// @throws uno::RuntimeException
- SectionsEnumWrapper( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, uno::Reference< frame::XModel > xModel ) : EnumerationHelperImpl( xParent, xContext, xEnumeration ), mxModel(std::move( xModel )){}
+ SectionsEnumWrapper( const uno::Reference< XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext >& xContext,
+ const uno::Reference< container::XEnumeration >& xEnumeration,
+ rtl::Reference< SwXTextDocument > xModel )
+ : EnumerationHelperImpl( xParent, xContext, xEnumeration ),
+ mxModel(std::move( xModel )){}
virtual uno::Any SAL_CALL nextElement( ) override
{
@@ -136,11 +153,20 @@ public:
}
-SwVbaSections::SwVbaSections( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel ): SwVbaSections_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( new SectionCollectionHelper( xParent, xContext, xModel ) ) ), mxModel( xModel )
+SwVbaSections::SwVbaSections( const uno::Reference< XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext > & xContext,
+ const rtl::Reference< SwXTextDocument >& xModel )
+ : SwVbaSections_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( new SectionCollectionHelper( xParent, xContext, xModel ) ) ),
+ mxModel( xModel )
{
}
-SwVbaSections::SwVbaSections( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XTextRange >& xTextRange ): SwVbaSections_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( new SectionCollectionHelper( xParent, xContext, xModel, xTextRange ) ) ), mxModel( xModel )
+SwVbaSections::SwVbaSections( const uno::Reference< XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext > & xContext,
+ const rtl::Reference< SwXTextDocument >& xModel,
+ const uno::Reference< text::XTextRange >& xTextRange )
+ : SwVbaSections_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( new SectionCollectionHelper( xParent, xContext, xModel, xTextRange ) ) ),
+ mxModel( xModel )
{
}
diff --git a/sw/source/ui/vba/vbasections.hxx b/sw/source/ui/vba/vbasections.hxx
index 3bf3ab4ca3e5..49e4488931e3 100644
--- a/sw/source/ui/vba/vbasections.hxx
+++ b/sw/source/ui/vba/vbasections.hxx
@@ -22,17 +22,20 @@
#include <vbahelper/vbacollectionimpl.hxx>
#include <ooo/vba/word/XSections.hpp>
#include <com/sun/star/text/XTextRange.hpp>
+#include <rtl/ref.hxx>
+
+class SwXTextDocument;
typedef CollTestImplHelper< ooo::vba::word::XSections > SwVbaSections_BASE;
class SwVbaSections : public SwVbaSections_BASE
{
private:
- css::uno::Reference< css::frame::XModel > mxModel;
+ rtl::Reference< SwXTextDocument > mxModel;
public:
- SwVbaSections( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::frame::XModel >& xModel );
- SwVbaSections( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::text::XTextRange >& xTextRange );
+ SwVbaSections( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const rtl::Reference< SwXTextDocument >& xModel );
+ SwVbaSections( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const rtl::Reference< SwXTextDocument >& xModel, const css::uno::Reference< css::text::XTextRange >& xTextRange );
// XEnumerationAccess
virtual css::uno::Type SAL_CALL getElementType() override;
diff --git a/sw/source/ui/vba/vbaselection.cxx b/sw/source/ui/vba/vbaselection.cxx
index 0c2fae7e528e..db96bed0a99e 100644
--- a/sw/source/ui/vba/vbaselection.cxx
+++ b/sw/source/ui/vba/vbaselection.cxx
@@ -63,11 +63,18 @@
#include <tblenum.hxx>
#include <sal/log.hxx>
#include <fesh.hxx>
+#include <unotxdoc.hxx>
+#include <unodraw.hxx>
+#include <unobasestyle.hxx>
using namespace ::ooo::vba;
using namespace ::com::sun::star;
-SwVbaSelection::SwVbaSelection( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, uno::Reference< frame::XModel > xModel ) : SwVbaSelection_BASE( rParent, rContext ), mxModel(std::move( xModel ))
+SwVbaSelection::SwVbaSelection( const uno::Reference< ooo::vba::XHelperInterface >& rParent,
+ const uno::Reference< uno::XComponentContext >& rContext,
+ rtl::Reference< SwXTextDocument > xModel )
+: SwVbaSelection_BASE( rParent, rContext ),
+ mxModel(std::move( xModel ))
{
mxTextViewCursor = word::getXTextViewCursor( mxModel );
}
@@ -99,8 +106,7 @@ uno::Reference< word::XRange > SAL_CALL
SwVbaSelection::getRange()
{
uno::Reference< text::XTextRange > xTextRange = GetSelectedRange();
- uno::Reference< text::XTextDocument > xDocument( mxModel, uno::UNO_QUERY_THROW );
- return uno::Reference< word::XRange >( new SwVbaRange( this, mxContext, xDocument, xTextRange->getStart(), xTextRange->getEnd(), mxTextViewCursor->getText() ) );
+ return uno::Reference< word::XRange >( new SwVbaRange( this, mxContext, mxModel, xTextRange->getStart(), xTextRange->getEnd(), mxTextViewCursor->getText() ) );
}
OUString SAL_CALL
@@ -217,7 +223,7 @@ SwVbaSelection::Delete( const uno::Any& _unit, const uno::Any& _count )
}
}
}
- dispatchRequests( mxModel,u".uno:Delete"_ustr );
+ dispatchRequests( static_cast<SfxBaseModel*>(mxModel.get()), u".uno:Delete"_ustr );
}
void
@@ -554,7 +560,7 @@ SwVbaSelection::getFont()
void SAL_CALL
SwVbaSelection::TypeBackspace()
{
- dispatchRequests( mxModel,u".uno:SwBackspace"_ustr );
+ dispatchRequests( static_cast<SfxBaseModel*>(mxModel.get()), u".uno:SwBackspace"_ustr );
}
uno::Reference< word::XRange > SAL_CALL SwVbaSelection::GoTo( const uno::Any& _what, const uno::Any& _which, const uno::Any& _count, const uno::Any& _name )
@@ -796,8 +802,7 @@ SwVbaSelection::Tables( const uno::Any& aIndex )
xCursorProps->getPropertyValue(u"TextTable"_ustr) >>= xTextTable;
if( xTextTable.is() )
{
- uno::Reference< css::text::XTextDocument > xTextDoc( mxModel, uno::UNO_QUERY_THROW );
- uno::Reference< word::XTable > xVBATable = new SwVbaTable( mxParent, mxContext, xTextDoc, xTextTable );
+ uno::Reference< word::XTable > xVBATable = new SwVbaTable( mxParent, mxContext, mxModel, xTextTable );
aRet <<= xVBATable;
return aRet;
}
@@ -811,8 +816,7 @@ SwVbaSelection::Tables( const uno::Any& aIndex )
if ( pFormat )
{
uno::Reference< text::XTextTable > xTable = SwXTextTables::GetObject(*pFormat);
- uno::Reference< css::text::XTextDocument > xTextDoc( mxModel, uno::UNO_QUERY_THROW );
- uno::Reference< word::XTable > xVBATable = new SwVbaTable( mxParent, mxContext, xTextDoc, xTable );
+ uno::Reference< word::XTable > xVBATable = new SwVbaTable( mxParent, mxContext, mxModel, xTable );
aRet <<= xVBATable;
}
}
@@ -834,7 +838,7 @@ SwVbaSelection::getHeaderFooter()
{
if( HeaderFooterHelper::isHeaderFooter( mxModel ) )
{
- uno::Reference< beans::XPropertySet > xPageStyleProps( word::getCurrentPageStyle( mxModel ), uno::UNO_QUERY_THROW );
+ rtl::Reference< SwXBaseStyle > xPageStyleProps( word::getCurrentPageStyle( mxModel ) );
sal_Int32 nIndex = word::WdHeaderFooterIndex::wdHeaderFooterPrimary;
bool isHeader = HeaderFooterHelper::isHeader( mxModel );
if( HeaderFooterHelper::isEvenPagesHeader( mxModel ) || HeaderFooterHelper::isEvenPagesFooter( mxModel ) )
@@ -859,10 +863,9 @@ SwVbaSelection::ShapeRange( )
xShapes->add( xShape );
}
- uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( mxModel, uno::UNO_QUERY_THROW );
- uno::Reference< drawing::XDrawPage > xDrawPage = xDrawPageSupplier->getDrawPage();
+ rtl::Reference< SwFmDrawPage > xDrawPage = mxModel->getSwDrawPage();
uno::Reference< container::XIndexAccess > xShapesAccess( xShapes, uno::UNO_QUERY_THROW );
- return uno::Any( uno::Reference< msforms::XShapeRange >( new ScVbaShapeRange( this, mxContext, xShapesAccess, xDrawPage, mxModel ) ) );
+ return uno::Any( uno::Reference< msforms::XShapeRange >( new ScVbaShapeRange( this, mxContext, xShapesAccess, xDrawPage, static_cast<SfxBaseModel*>(mxModel.get()) ) ) );
}
::sal_Int32 SAL_CALL SwVbaSelection::getStart()
@@ -1035,7 +1038,7 @@ uno::Any SAL_CALL SwVbaSelection::Cells( const uno::Any& index )
void SAL_CALL SwVbaSelection::Copy( )
{
- dispatchRequests( mxModel,u".uno:Copy"_ustr );
+ dispatchRequests( static_cast<SfxBaseModel*>(mxModel.get()), u".uno:Copy"_ustr );
}
void SAL_CALL SwVbaSelection::CopyAsPicture( )
@@ -1046,7 +1049,7 @@ void SAL_CALL SwVbaSelection::CopyAsPicture( )
void SAL_CALL SwVbaSelection::Paste( )
{
- dispatchRequests( mxModel,u".uno:Paste"_ustr );
+ dispatchRequests( static_cast<SfxBaseModel*>(mxModel.get()), u".uno:Paste"_ustr );
}
void SAL_CALL SwVbaSelection::Collapse( const uno::Any& Direction )
@@ -1093,7 +1096,7 @@ void SAL_CALL SwVbaSelection::WholeStory( )
// insert an empty line
uno::Reference< text::XTextRange > xFirstCellRange = word::getFirstObjectPosition( xText );
mxTextViewCursor->gotoRange( xFirstCellRange, false );
- dispatchRequests( mxModel,u".uno:InsertPara"_ustr );
+ dispatchRequests( static_cast<SfxBaseModel*>(mxModel.get()), u".uno:InsertPara"_ustr );
}
}
uno::Reference< text::XTextRange > xStart = xText->getStart();
@@ -1112,7 +1115,7 @@ void SAL_CALL SwVbaSelection::SplitTable()
if( !IsInTable() )
throw uno::RuntimeException();
- SwDocShell* pDocShell = word::getDocShell( mxModel );
+ SwDocShell* pDocShell = mxModel->GetDocShell();
if( pDocShell )
{
if (SwFEShell* pFEShell = pDocShell->GetFEShell())
@@ -1142,9 +1145,8 @@ SwVbaSelection::Paragraphs( const uno::Any& aIndex )
xParaCursor->gotoStartOfParagraph( false );
xParaCursor->gotoStartOfParagraph( true );
- uno::Reference< text::XTextDocument > xTextDoc( mxModel, uno::UNO_QUERY_THROW );
uno::Reference< text::XTextRange > xParaRange( xParaCursor, uno::UNO_QUERY_THROW );
- uno::Reference< word::XParagraph > xParagraph = new SwVbaParagraph( mxParent, mxContext, xTextDoc, xParaRange );
+ uno::Reference< word::XParagraph > xParagraph = new SwVbaParagraph( mxParent, mxContext, mxModel, xParaRange );
aRet <<= xParagraph;
return aRet;
diff --git a/sw/source/ui/vba/vbaselection.hxx b/sw/source/ui/vba/vbaselection.hxx
index 0dba75b72995..92f92a9503fa 100644
--- a/sw/source/ui/vba/vbaselection.hxx
+++ b/sw/source/ui/vba/vbaselection.hxx
@@ -35,7 +35,7 @@ typedef InheritedHelperInterfaceWeakImpl< ooo::vba::word::XSelection > SwVbaSele
class SwVbaSelection : public SwVbaSelection_BASE
{
private:
- css::uno::Reference< css::frame::XModel > mxModel;
+ rtl::Reference< SwXTextDocument > mxModel;
css::uno::Reference< css::text::XTextViewCursor > mxTextViewCursor;
private:
@@ -58,7 +58,7 @@ private:
public:
/// @throws css::uno::RuntimeException
- SwVbaSelection( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, css::uno::Reference< css::frame::XModel > xModel );
+ SwVbaSelection( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, rtl::Reference< SwXTextDocument > xModel );
virtual ~SwVbaSelection() override;
// Attribute
diff --git a/sw/source/ui/vba/vbastyle.cxx b/sw/source/ui/vba/vbastyle.cxx
index ea637a53110b..be82d710a8d6 100644
--- a/sw/source/ui/vba/vbastyle.cxx
+++ b/sw/source/ui/vba/vbastyle.cxx
@@ -27,11 +27,18 @@
#include "vbapalette.hxx"
#include "vbaparagraphformat.hxx"
#include "vbastyles.hxx"
+#include <unotxdoc.hxx>
using namespace ::ooo::vba;
using namespace ::com::sun::star;
-SwVbaStyle::SwVbaStyle( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, uno::Reference< frame::XModel> xModel, const uno::Reference< beans::XPropertySet >& _xPropertySet ) : SwVbaStyle_BASE( xParent, xContext ) , mxModel(std::move( xModel )), mxStyleProps( _xPropertySet )
+SwVbaStyle::SwVbaStyle( const uno::Reference< XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext > & xContext,
+ rtl::Reference< SwXTextDocument> xModel,
+ const uno::Reference< beans::XPropertySet >& _xPropertySet )
+: SwVbaStyle_BASE( xParent, xContext ),
+ mxModel(std::move( xModel )),
+ mxStyleProps( _xPropertySet )
{
mxStyle.set( _xPropertySet, uno::UNO_QUERY_THROW );
}
@@ -132,7 +139,6 @@ uno::Reference< word::XParagraphFormat > SAL_CALL SwVbaStyle::getParagraphFormat
throw uno::RuntimeException();
}
- uno::Reference< text::XTextDocument > xTextDocument( mxModel, uno::UNO_QUERY_THROW );
return uno::Reference< word::XParagraphFormat >( new SwVbaParagraphFormat( this, mxContext, mxStyleProps ) );
}
diff --git a/sw/source/ui/vba/vbastyle.hxx b/sw/source/ui/vba/vbastyle.hxx
index df6de21fa5f9..b1a23e58472c 100644
--- a/sw/source/ui/vba/vbastyle.hxx
+++ b/sw/source/ui/vba/vbastyle.hxx
@@ -26,19 +26,25 @@
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/style/XStyle.hpp>
#include <ooo/vba/word/XFont.hpp>
+#include <rtl/ref.hxx>
+
+class SwXTextDocument;
typedef InheritedHelperInterfaceWeakImpl< ooo::vba::word::XStyle > SwVbaStyle_BASE;
class SwVbaStyle : public SwVbaStyle_BASE
{
private:
- css::uno::Reference< css::frame::XModel > mxModel;
+ rtl::Reference< SwXTextDocument > mxModel;
css::uno::Reference< css::beans::XPropertySet > mxStyleProps;
css::uno::Reference< css::style::XStyle > mxStyle;
public:
/// @throws css::script::BasicErrorException
/// @throws css::uno::RuntimeException
- SwVbaStyle( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, css::uno::Reference< css::frame::XModel > xModel, const css::uno::Reference< css::beans::XPropertySet >& _xPropertySet );
+ SwVbaStyle( const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext > & xContext,
+ rtl::Reference< SwXTextDocument > xModel,
+ const css::uno::Reference< css::beans::XPropertySet >& _xPropertySet );
/// @throws css::uno::RuntimeException
static void setStyle( const css::uno::Reference< css::beans::XPropertySet >& xParaProps, const css::uno::Any& xStyle );
diff --git a/sw/source/ui/vba/vbastyles.cxx b/sw/source/ui/vba/vbastyles.cxx
index 5e6dcecb740f..d4bfff6bd6e6 100644
--- a/sw/source/ui/vba/vbastyles.cxx
+++ b/sw/source/ui/vba/vbastyles.cxx
@@ -27,6 +27,8 @@
#include <com/sun/star/style/XStyle.hpp>
#include <ooo/vba/word/WdBuiltinStyle.hpp>
#include <ooo/vba/word/WdStyleType.hpp>
+#include <unotxdoc.hxx>
+#include <unostyle.hxx>
using namespace ::ooo::vba;
using namespace ::com::sun::star;
@@ -173,15 +175,14 @@ class StyleCollectionHelper : public ::cppu::WeakImplHelper< container::XNameAcc
container::XEnumerationAccess >
{
private:
- uno::Reference< container::XNameAccess > mxParaStyles;
+ rtl::Reference< SwXStyleFamily > mxParaStyles;
uno::Any m_cachePos;
public:
- explicit StyleCollectionHelper( const uno::Reference< frame::XModel >& _xModel )
+ explicit StyleCollectionHelper( const rtl::Reference< SwXTextDocument >& _xModel )
{
// we only concern about the Paragraph styles
- uno::Reference< style::XStyleFamiliesSupplier > xStyleSupplier( _xModel, uno::UNO_QUERY_THROW);
- uno::Reference< container::XNameAccess > xStyleFamilies = xStyleSupplier->getStyleFamilies();
- mxParaStyles.set( xStyleFamilies->getByName(u"ParagraphStyles"_ustr), uno::UNO_QUERY_THROW );
+ rtl::Reference< SwXStyleFamilies > xStyleFamilies = _xModel->getSwStyleFamilies();
+ mxParaStyles = xStyleFamilies->GetParagraphStyles();
}
// XElementAccess
virtual uno::Type SAL_CALL getElementType( ) override { return cppu::UnoType<style::XStyle>::get(); }
@@ -237,16 +238,14 @@ public:
// XIndexAccess
virtual ::sal_Int32 SAL_CALL getCount( ) override
{
- uno::Reference< container::XIndexAccess > xIndexAccess( mxParaStyles, uno::UNO_QUERY_THROW );
- return xIndexAccess->getCount();
+ return mxParaStyles->getCount();
}
virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) override
{
if ( Index < 0 || Index >= getCount() )
throw lang::IndexOutOfBoundsException();
- uno::Reference< container::XIndexAccess > xIndexAccess( mxParaStyles, uno::UNO_QUERY_THROW );
- return xIndexAccess->getByIndex( Index );
+ return mxParaStyles->getByIndex( Index );
}
// XEnumerationAccess
virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration( ) override
@@ -276,10 +275,12 @@ public:
}
-SwVbaStyles::SwVbaStyles( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< css::uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel )
- : SwVbaStyles_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( new StyleCollectionHelper( xModel ) ) ), mxModel( xModel )
+SwVbaStyles::SwVbaStyles( const uno::Reference< XHelperInterface >& xParent,
+ const uno::Reference< css::uno::XComponentContext > & xContext,
+ const rtl::Reference< SwXTextDocument >& xModel )
+ : SwVbaStyles_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( new StyleCollectionHelper( xModel ) ) ),
+ mxModel( xModel )
{
- mxMSF.set( mxModel, uno::UNO_QUERY_THROW );
}
uno::Any
@@ -338,9 +339,8 @@ SwVbaStyles::Item( const uno::Any& Index1, const uno::Any& Index2 )
default:
DebugHelper::basicexception( ERRCODE_BASIC_INTERNAL_ERROR, {} );
}
- uno::Reference< style::XStyleFamiliesSupplier > xStyleSupplier( mxModel, uno::UNO_QUERY_THROW);
- uno::Reference< container::XNameAccess > xStylesAccess( xStyleSupplier->getStyleFamilies()->getByName( aStyleType ), uno::UNO_QUERY_THROW );
- uno::Reference< beans::XPropertySet > xStyleProps( xStylesAccess->getByName( aStyleName ), uno::UNO_QUERY_THROW );
+ rtl::Reference< SwXStyleFamily > xStylesAccess( mxModel->getSwStyleFamilies()->GetStylesByName( aStyleType ) );
+ rtl::Reference< SwXBaseStyle > xStyleProps( xStylesAccess->getStyleByName( aStyleName ) );
// set the property "NumberingStyleName" if it is a listbullet
if( pTable->wdStyleType == word::WdStyleType::wdStyleTypeList )
{
diff --git a/sw/source/ui/vba/vbastyles.hxx b/sw/source/ui/vba/vbastyles.hxx
index 390225cd08c4..c4b2eccc6c05 100644
--- a/sw/source/ui/vba/vbastyles.hxx
+++ b/sw/source/ui/vba/vbastyles.hxx
@@ -22,16 +22,20 @@
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <ooo/vba/word/XStyles.hpp>
#include <vbahelper/vbacollectionimpl.hxx>
+#include <rtl/ref.hxx>
+
+class SwXTextDocument;
typedef CollTestImplHelper< ooo::vba::word::XStyles > SwVbaStyles_BASE;
class SwVbaStyles: public SwVbaStyles_BASE
{
- css::uno::Reference< css::frame::XModel > mxModel;
- css::uno::Reference< css::lang::XMultiServiceFactory > mxMSF;
+ rtl::Reference< SwXTextDocument > mxModel;
public:
/// @throws css::script::BasicErrorException
/// @throws css::uno::RuntimeException
- SwVbaStyles( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::frame::XModel >& xModel );
+ SwVbaStyles( const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext > & xContext,
+ const rtl::Reference< SwXTextDocument >& xModel );
virtual css::uno::Any SAL_CALL Item(const css::uno::Any& Index1, const css::uno::Any& Index2) override;
// XEnumerationAccess
diff --git a/sw/source/ui/vba/vbasystem.cxx b/sw/source/ui/vba/vbasystem.cxx
index 1414ad008b6b..7bd0e54957e1 100644
--- a/sw/source/ui/vba/vbasystem.cxx
+++ b/sw/source/ui/vba/vbasystem.cxx
@@ -23,6 +23,8 @@
#include <osl/file.hxx>
#include <tools/urlobj.hxx>
#include <o3tl/char16_t2wchar_t.hxx>
+#include "wordvbahelper.hxx"
+#include <unotxdoc.hxx>
#ifdef _WIN32
#include <cstddef>
@@ -34,6 +36,7 @@
#endif
using namespace ::ooo::vba;
+using namespace ::ooo::vba::word;
using namespace ::com::sun::star;
PrivateProfileStringListener::~PrivateProfileStringListener()
@@ -175,7 +178,7 @@ SwVbaSystem::~SwVbaSystem()
sal_Int32 SAL_CALL
SwVbaSystem::getCursor()
{
- PointerStyle nPointerStyle = getPointerStyle( getCurrentWordDoc(mxContext) );
+ PointerStyle nPointerStyle = getPointerStyle( static_cast<SfxBaseModel*>(getCurrentWordDoc(mxContext).get()) );
switch( nPointerStyle )
{
@@ -201,24 +204,24 @@ SwVbaSystem::setCursor( sal_Int32 _cursor )
{
case word::WdCursorType::wdCursorNorthwestArrow:
{
- setCursorHelper( getCurrentWordDoc(mxContext), PointerStyle::Arrow, false );
+ setCursorHelper( static_cast<SfxBaseModel*>(getCurrentWordDoc(mxContext).get()), PointerStyle::Arrow, false );
break;
}
case word::WdCursorType::wdCursorWait:
{
//It will set the edit window, toobar and statusbar's mouse pointer.
- setCursorHelper( getCurrentWordDoc(mxContext), PointerStyle::Wait, true );
+ setCursorHelper( static_cast<SfxBaseModel*>(getCurrentWordDoc(mxContext).get()), PointerStyle::Wait, true );
break;
}
case word::WdCursorType::wdCursorIBeam:
{
//It will set the edit window, toobar and statusbar's mouse pointer.
- setCursorHelper( getCurrentWordDoc( mxContext ), PointerStyle::Text, true );
+ setCursorHelper( static_cast<SfxBaseModel*>(getCurrentWordDoc( mxContext ).get()), PointerStyle::Text, true );
break;
}
case word::WdCursorType::wdCursorNormal:
{
- setCursorHelper( getCurrentWordDoc( mxContext ), PointerStyle::Null, false );
+ setCursorHelper( static_cast<SfxBaseModel*>(getCurrentWordDoc( mxContext ).get()), PointerStyle::Null, false );
break;
}
default:
diff --git a/sw/source/ui/vba/vbatable.cxx b/sw/source/ui/vba/vbatable.cxx
index 12825a7fadde..af247f7154f9 100644
--- a/sw/source/ui/vba/vbatable.cxx
+++ b/sw/source/ui/vba/vbatable.cxx
@@ -33,6 +33,7 @@
#include "vbarows.hxx"
#include "vbacolumns.hxx"
#include "vbaapplication.hxx"
+#include <unotxdoc.hxx>
#include <tools/UnitConversion.hxx>
@@ -41,7 +42,12 @@
using namespace ::ooo::vba;
using namespace ::com::sun::star;
-SwVbaTable::SwVbaTable( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, uno::Reference< text::XTextDocument > xDocument, const uno::Reference< text::XTextTable >& xTextTable) : SwVbaTable_BASE( rParent, rContext ), mxTextDocument(std::move( xDocument ))
+SwVbaTable::SwVbaTable( const uno::Reference< ooo::vba::XHelperInterface >& rParent,
+ const uno::Reference< uno::XComponentContext >& rContext,
+ rtl::Reference< SwXTextDocument > xDocument,
+ const uno::Reference< text::XTextTable >& xTextTable)
+: SwVbaTable_BASE( rParent, rContext ),
+ mxTextDocument(std::move( xDocument ))
{
mxTextTable.set( xTextTable, uno::UNO_SET_THROW );
}
@@ -55,8 +61,7 @@ SwVbaTable::Range( )
void SAL_CALL
SwVbaTable::Select( )
{
- uno::Reference< frame::XModel > xModel( mxTextDocument, uno::UNO_QUERY_THROW );
- uno::Reference< frame::XController > xController = xModel->getCurrentController();
+ uno::Reference< frame::XController > xController = mxTextDocument->getCurrentController();
uno::Reference< text::XTextViewCursorSupplier > xViewCursorSupplier( xController, uno::UNO_QUERY_THROW );
uno::Reference< view::XSelectionSupplier > xSelectionSupplier( xController, uno::UNO_QUERY_THROW );
diff --git a/sw/source/ui/vba/vbatable.hxx b/sw/source/ui/vba/vbatable.hxx
index 0cd2502e07b0..466c06e5befe 100644
--- a/sw/source/ui/vba/vbatable.hxx
+++ b/sw/source/ui/vba/vbatable.hxx
@@ -19,21 +19,25 @@
#ifndef INCLUDED_SW_SOURCE_UI_VBA_VBATABLE_HXX
#define INCLUDED_SW_SOURCE_UI_VBA_VBATABLE_HXX
+
#include <vbahelper/vbahelperinterface.hxx>
#include <com/sun/star/text/XTextDocument.hpp>
#include <com/sun/star/text/XTextTable.hpp>
#include <ooo/vba/word/XRange.hpp>
#include <ooo/vba/word/XTable.hpp>
+#include <rtl/ref.hxx>
+
+class SwXTextDocument;
typedef InheritedHelperInterfaceWeakImpl< ooo::vba::word::XTable > SwVbaTable_BASE;
class SwVbaTable : public SwVbaTable_BASE
{
- css::uno::Reference< css::text::XTextDocument > mxTextDocument;
+ rtl::Reference< SwXTextDocument > mxTextDocument;
css::uno::Reference< css::text::XTextTable > mxTextTable;
public:
/// @throws css::uno::RuntimeException
- SwVbaTable( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, css::uno::Reference< css::text::XTextDocument > xDocument, const css::uno::Reference< css::text::XTextTable >& xTextTable);
+ SwVbaTable( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, rtl::Reference< SwXTextDocument > xDocument, const css::uno::Reference< css::text::XTextTable >& xTextTable);
virtual css::uno::Reference< ::ooo::vba::word::XRange > SAL_CALL Range( ) override;
virtual void SAL_CALL Select( ) override;
virtual void SAL_CALL Delete( ) override;
diff --git a/sw/source/ui/vba/vbatables.cxx b/sw/source/ui/vba/vbatables.cxx
index ef07829e0d2e..b49cb7dd0571 100644
--- a/sw/source/ui/vba/vbatables.cxx
+++ b/sw/source/ui/vba/vbatables.cxx
@@ -29,25 +29,21 @@
#include <com/sun/star/text/XText.hpp>
#include <com/sun/star/table/XCellRange.hpp>
#include <cppuhelper/implbase.hxx>
+#include <unotxdoc.hxx>
+#include <unocoll.hxx>
+#include <unotbl.hxx>
#include <utility>
using namespace ::ooo::vba;
using namespace css;
-static uno::Reference< container::XIndexAccess > lcl_getTables( const uno::Reference< frame::XModel >& xDoc )
-{
- uno::Reference< container::XIndexAccess > xTables;
- uno::Reference< text::XTextTablesSupplier > xSupp( xDoc, uno::UNO_QUERY );
- if ( xSupp.is() )
- xTables.set( xSupp->getTextTables(), uno::UNO_QUERY_THROW );
- return xTables;
-}
-
-static uno::Any lcl_createTable( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xDocument, const uno::Any& aSource )
+static uno::Any lcl_createTable( const uno::Reference< XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext >& xContext,
+ const rtl::Reference< SwXTextDocument >& xDocument,
+ const uno::Any& aSource )
{
uno::Reference< text::XTextTable > xTextTable( aSource, uno::UNO_QUERY_THROW );
- uno::Reference< text::XTextDocument > xTextDocument( xDocument, uno::UNO_QUERY_THROW );
- uno::Reference< word::XTable > xTable( new SwVbaTable( xParent, xContext, xTextDocument, xTextTable ) );
+ uno::Reference< word::XTable > xTable( new SwVbaTable( xParent, xContext, xDocument, xTextTable ) );
return uno::Any( xTable );
}
@@ -62,25 +58,23 @@ static bool lcl_isInHeaderFooter( const uno::Reference< text::XTextTable >& xTab
return aImplName == "SwXHeadFootText";
}
-typedef std::vector< uno::Reference< text::XTextTable > > XTextTableVec;
-
namespace {
class TableCollectionHelper : public ::cppu::WeakImplHelper< container::XIndexAccess,
container::XNameAccess >
{
- XTextTableVec mxTables;
- XTextTableVec::iterator m_cachePos;
+ std::vector<rtl::Reference<SwXTextTable>> mxTables;
+ std::vector<rtl::Reference<SwXTextTable>>::iterator m_cachePos;
public:
- explicit TableCollectionHelper( const uno::Reference< frame::XModel >& xDocument )
+ explicit TableCollectionHelper( const rtl::Reference< SwXTextDocument >& xDocument )
{
// only count the tables in the body text, not in the header/footer
- uno::Reference< container::XIndexAccess > xTables = lcl_getTables( xDocument );
+ rtl::Reference< SwXTextTables > xTables = xDocument->getSwTextTables();
sal_Int32 nCount = xTables->getCount();
for( sal_Int32 i = 0; i < nCount; i++ )
{
- uno::Reference< text::XTextTable > xTable( xTables->getByIndex( i ) , uno::UNO_QUERY_THROW );
+ rtl::Reference< SwXTextTable > xTable = xTables->getTextTableByIndex( i );
if( !lcl_isInHeaderFooter( xTable ) )
mxTables.push_back( xTable );
}
@@ -95,7 +89,7 @@ public:
{
if ( Index < 0 || Index >= getCount() )
throw lang::IndexOutOfBoundsException();
- uno::Reference< text::XTextTable > xTable( mxTables[ Index ], uno::UNO_SET_THROW );
+ uno::Reference< text::XTextTable > xTable( mxTables[ Index ] );
return uno::Any( xTable );
}
// XElementAccess
@@ -115,8 +109,7 @@ public:
OUString* pString = sNames.getArray();
for ( const auto& rxTable : mxTables )
{
- uno::Reference< container::XNamed > xName( rxTable, uno::UNO_QUERY_THROW );
- *pString = xName->getName();
+ *pString = rxTable->getName();
++pString;
}
return sNames;
@@ -124,11 +117,10 @@ public:
virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override
{
m_cachePos = mxTables.begin();
- XTextTableVec::iterator it_end = mxTables.end();
+ auto it_end = mxTables.end();
for ( ; m_cachePos != it_end; ++m_cachePos )
{
- uno::Reference< container::XNamed > xName( *m_cachePos, uno::UNO_QUERY_THROW );
- if ( aName.equalsIgnoreAsciiCase( xName->getName() ) )
+ if ( aName.equalsIgnoreAsciiCase( (*m_cachePos)->getName() ) )
break;
}
return ( m_cachePos != it_end );
@@ -139,11 +131,16 @@ class TableEnumerationImpl : public ::cppu::WeakImplHelper< css::container::XEnu
{
uno::Reference< XHelperInterface > mxParent;
uno::Reference< uno::XComponentContext > mxContext;
- uno::Reference< frame::XModel > mxDocument;
+ rtl::Reference< SwXTextDocument > mxDocument;
uno::Reference< container::XIndexAccess > mxIndexAccess;
sal_Int32 mnCurIndex;
public:
- TableEnumerationImpl( uno::Reference< XHelperInterface > xParent, uno::Reference< uno::XComponentContext > xContext, uno::Reference< frame::XModel > xDocument, uno::Reference< container::XIndexAccess > xIndexAccess ) : mxParent(std::move( xParent )), mxContext(std::move( xContext )), mxDocument(std::move( xDocument )), mxIndexAccess(std::move( xIndexAccess )), mnCurIndex(0)
+ TableEnumerationImpl( uno::Reference< XHelperInterface > xParent,
+ uno::Reference< uno::XComponentContext > xContext,
+ rtl::Reference< SwXTextDocument > xDocument,
+ uno::Reference< container::XIndexAccess > xIndexAccess )
+ : mxParent(std::move( xParent )), mxContext(std::move( xContext )),
+ mxDocument(std::move( xDocument )), mxIndexAccess(std::move( xIndexAccess )), mnCurIndex(0)
{
}
virtual sal_Bool SAL_CALL hasMoreElements( ) override
@@ -161,7 +158,11 @@ public:
}
-SwVbaTables::SwVbaTables( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xDocument ) : SwVbaTables_BASE( xParent, xContext , uno::Reference< container::XIndexAccess >( new TableCollectionHelper( xDocument ) ) ), mxDocument( xDocument )
+SwVbaTables::SwVbaTables( const uno::Reference< XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext > & xContext,
+ const rtl::Reference< SwXTextDocument >& xDocument )
+: SwVbaTables_BASE( xParent, xContext , uno::Reference< container::XIndexAccess >( new TableCollectionHelper( xDocument ) ) ),
+ mxDocument( xDocument )
{
}
@@ -177,12 +178,11 @@ SwVbaTables::Add( const uno::Reference< word::XRange >& Range, const uno::Any& N
if ( nCols <= 0 || nRows <= 0 )
throw uno::RuntimeException(); // #FIXME better exception??
- uno::Reference< frame::XModel > xModel( pVbaRange->getDocument(), uno::UNO_QUERY_THROW );
- uno::Reference< lang::XMultiServiceFactory > xMsf( xModel, uno::UNO_QUERY_THROW );
+ rtl::Reference< SwXTextDocument > xModel( pVbaRange->getDocument() );
uno::Reference< text::XTextRange > xTextRange = pVbaRange->getXTextRange();
uno::Reference< text::XTextTable > xTable;
- xTable.set( xMsf->createInstance(u"com.sun.star.text.TextTable"_ustr), uno::UNO_QUERY_THROW );
+ xTable.set( xModel->createInstance(u"com.sun.star.text.TextTable"_ustr), uno::UNO_QUERY_THROW );
xTable->initialize( nRows, nCols );
uno::Reference< text::XText > xText = xTextRange->getText();
diff --git a/sw/source/ui/vba/vbatables.hxx b/sw/source/ui/vba/vbatables.hxx
index ae7de0b00cb5..6a9f728e8201 100644
--- a/sw/source/ui/vba/vbatables.hxx
+++ b/sw/source/ui/vba/vbatables.hxx
@@ -22,14 +22,19 @@
#include <ooo/vba/word/XTables.hpp>
#include <vbahelper/vbacollectionimpl.hxx>
+#include <rtl/ref.hxx>
+
+class SwXTextDocument;
typedef CollTestImplHelper< ov::word::XTables > SwVbaTables_BASE;
class SwVbaTables : public SwVbaTables_BASE
{
- css::uno::Reference< css::frame::XModel > mxDocument;
+ rtl::Reference< SwXTextDocument > mxDocument;
public:
- SwVbaTables( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::frame::XModel >& xDocument );
+ SwVbaTables( const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext > & xContext,
+ const rtl::Reference< SwXTextDocument >& xDocument );
// XTables
virtual css::uno::Reference< ov::word::XTable > SAL_CALL Add( const css::uno::Reference< ::ooo::vba::word::XRange >& Range, const css::uno::Any& NumRows, const css::uno::Any& NumColumns, const css::uno::Any& DefaultTableBehavior, const css::uno::Any& AutoFitBehavior ) override;
// XEnumerationAccess
diff --git a/sw/source/ui/vba/vbatablesofcontents.cxx b/sw/source/ui/vba/vbatablesofcontents.cxx
index 303b3041257e..774bfce34dcb 100644
--- a/sw/source/ui/vba/vbatablesofcontents.cxx
+++ b/sw/source/ui/vba/vbatablesofcontents.cxx
@@ -24,6 +24,8 @@
#include <com/sun/star/text/XDocumentIndexesSupplier.hpp>
#include <cppuhelper/implbase.hxx>
#include <utility>
+#include <unotxdoc.hxx>
+#include <unoidxcoll.hxx>
using namespace ::ooo::vba;
using namespace ::com::sun::star;
@@ -60,15 +62,15 @@ class TableOfContentsCollectionHelper : public ::cppu::WeakImplHelper< container
private:
uno::Reference< XHelperInterface > mxParent;
uno::Reference< uno::XComponentContext > mxContext;
- uno::Reference< text::XTextDocument > mxTextDocument;
+ rtl::Reference< SwXTextDocument > mxTextDocument;
std::vector< uno::Reference< text::XDocumentIndex > > maToc;
public:
/// @throws uno::RuntimeException
- TableOfContentsCollectionHelper( uno::Reference< ov::XHelperInterface > xParent, uno::Reference< uno::XComponentContext > xContext, uno::Reference< text::XTextDocument > xDoc ): mxParent(std::move( xParent )), mxContext(std::move( xContext )), mxTextDocument(std::move( xDoc ))
+ TableOfContentsCollectionHelper( uno::Reference< ov::XHelperInterface > xParent, uno::Reference< uno::XComponentContext > xContext, rtl::Reference< SwXTextDocument > xDoc )
+ : mxParent(std::move( xParent )), mxContext(std::move( xContext )), mxTextDocument(std::move( xDoc ))
{
- uno::Reference< text::XDocumentIndexesSupplier > xDocIndexSupp( mxTextDocument, uno::UNO_QUERY_THROW );
- uno::Reference< container::XIndexAccess > xDocIndexes = xDocIndexSupp->getDocumentIndexes();
+ rtl::Reference< SwXDocumentIndexes > xDocIndexes = mxTextDocument->getSwDocumentIndexes();
sal_Int32 nCount = xDocIndexes->getCount();
for( sal_Int32 i = 0; i < nCount; i++ )
{
@@ -109,15 +111,15 @@ public:
}
-SwVbaTablesOfContents::SwVbaTablesOfContents( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< text::XTextDocument >& xDoc ) : SwVbaTablesOfContents_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( new TableOfContentsCollectionHelper( xParent, xContext, xDoc ) ) ), mxTextDocument( xDoc )
+SwVbaTablesOfContents::SwVbaTablesOfContents( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const rtl::Reference< SwXTextDocument >& xDoc )
+ : SwVbaTablesOfContents_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( new TableOfContentsCollectionHelper( xParent, xContext, xDoc ) ) ), mxTextDocument( xDoc )
{
}
uno::Reference< word::XTableOfContents > SAL_CALL
SwVbaTablesOfContents::Add( const uno::Reference< word::XRange >& Range, const uno::Any& /*UseHeadingStyles*/, const uno::Any& /*UpperHeadingLevel*/, const uno::Any& LowerHeadingLevel, const uno::Any& UseFields, const uno::Any& /*TableID*/, const uno::Any& /*RightAlignPageNumbers*/, const uno::Any& /*IncludePageNumbers*/, const uno::Any& /*AddedStyles*/, const uno::Any& /*UseHyperlinks*/, const uno::Any& /*HidePageNumbersInWeb*/, const uno::Any& /*UseOutlineLevels*/ )
{
- uno::Reference< lang::XMultiServiceFactory > xDocMSF( mxTextDocument, uno::UNO_QUERY_THROW );
- uno::Reference< text::XDocumentIndex > xDocumentIndex( xDocMSF->createInstance(u"com.sun.star.text.ContentIndex"_ustr), uno::UNO_QUERY_THROW );
+ uno::Reference< text::XDocumentIndex > xDocumentIndex( mxTextDocument->createInstance(u"com.sun.star.text.ContentIndex"_ustr), uno::UNO_QUERY_THROW );
uno::Reference< beans::XPropertySet > xTocProps( xDocumentIndex, uno::UNO_QUERY_THROW );
xTocProps->setPropertyValue(u"IsProtected"_ustr, uno::Any( false ) );
diff --git a/sw/source/ui/vba/vbatablesofcontents.hxx b/sw/source/ui/vba/vbatablesofcontents.hxx
index 37048ae1bcaf..bc91e30a6809 100644
--- a/sw/source/ui/vba/vbatablesofcontents.hxx
+++ b/sw/source/ui/vba/vbatablesofcontents.hxx
@@ -24,17 +24,20 @@
#include <com/sun/star/text/XTextDocument.hpp>
#include <ooo/vba/word/XTableOfContents.hpp>
#include <ooo/vba/word/XRange.hpp>
+#include <rtl/ref.hxx>
+
+class SwXTextDocument;
typedef CollTestImplHelper< ooo::vba::word::XTablesOfContents > SwVbaTablesOfContents_BASE;
class SwVbaTablesOfContents : public SwVbaTablesOfContents_BASE
{
private:
- css::uno::Reference< css::text::XTextDocument > mxTextDocument;
+ rtl::Reference< SwXTextDocument > mxTextDocument;
public:
/// @throws css::uno::RuntimeException
- SwVbaTablesOfContents( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::text::XTextDocument >& xDoc );
+ SwVbaTablesOfContents( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const rtl::Reference< SwXTextDocument >& xDoc );
// Methods
virtual css::uno::Reference< ::ooo::vba::word::XTableOfContents > SAL_CALL Add( const css::uno::Reference< ::ooo::vba::word::XRange >& Range, const css::uno::Any& UseHeadingStyles, const css::uno::Any& UpperHeadingLevel, const css::uno::Any& LowerHeadingLevel, const css::uno::Any& UseFields, const css::uno::Any& TableID, const css::uno::Any& RightAlignPageNumbers, const css::uno::Any& IncludePageNumbers, const css::uno::Any& AddedStyles, const css::uno::Any& UseHyperlinks, const css::uno::Any& HidePageNumbersInWeb, const css::uno::Any& UseOutlineLevels ) override;
diff --git a/sw/source/ui/vba/vbaview.cxx b/sw/source/ui/vba/vbaview.cxx
index 7ce99c27a9fa..2570745d34aa 100644
--- a/sw/source/ui/vba/vbaview.cxx
+++ b/sw/source/ui/vba/vbaview.cxx
@@ -38,14 +38,19 @@
#include "wordvbahelper.hxx"
#include "vbaheaderfooterhelper.hxx"
#include <view.hxx>
+#include <unotxdoc.hxx>
+#include <unocoll.hxx>
+#include <unotextbodyhf.hxx>
+#include <unobasestyle.hxx>
using namespace ::ooo::vba;
using namespace ::com::sun::star;
const sal_Int32 DEFAULT_BODY_DISTANCE = 500;
-SwVbaView::SwVbaView( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext,
- uno::Reference< frame::XModel > xModel ) :
+SwVbaView::SwVbaView( const uno::Reference< ooo::vba::XHelperInterface >& rParent,
+ const uno::Reference< uno::XComponentContext >& rContext,
+ rtl::Reference< SwXTextDocument > xModel ) :
SwVbaView_BASE( rParent, rContext ), mxModel(std::move( xModel ))
{
uno::Reference< frame::XController > xController = mxModel->getCurrentController();
@@ -149,8 +154,7 @@ SwVbaView::setSeekView( ::sal_Int32 _seekview )
}
case word::WdSeekView::wdSeekFootnotes:
{
- uno::Reference< text::XFootnotesSupplier > xFootnotesSupp( mxModel, uno::UNO_QUERY_THROW );
- uno::Reference< container::XIndexAccess > xFootnotes( xFootnotesSupp->getFootnotes(), uno::UNO_SET_THROW );
+ rtl::Reference< SwXFootnotes > xFootnotes( mxModel->getSwXFootnotes() );
if( xFootnotes->getCount() > 0 )
{
uno::Reference< text::XText > xText( xFootnotes->getByIndex(0), uno::UNO_QUERY_THROW );
@@ -164,8 +168,7 @@ SwVbaView::setSeekView( ::sal_Int32 _seekview )
}
case word::WdSeekView::wdSeekEndnotes:
{
- uno::Reference< text::XEndnotesSupplier > xEndnotesSupp( mxModel, uno::UNO_QUERY_THROW );
- uno::Reference< container::XIndexAccess > xEndnotes( xEndnotesSupp->getEndnotes(), uno::UNO_SET_THROW );
+ rtl::Reference< SwXFootnotes > xEndnotes( mxModel->getSwXEndnotes() );
if( xEndnotes->getCount() > 0 )
{
uno::Reference< text::XText > xText( xEndnotes->getByIndex(0), uno::UNO_QUERY_THROW );
@@ -179,8 +182,7 @@ SwVbaView::setSeekView( ::sal_Int32 _seekview )
}
case word::WdSeekView::wdSeekMainDocument:
{
- uno::Reference< text::XTextDocument > xTextDocument( mxModel, uno::UNO_QUERY_THROW );
- uno::Reference< text::XText > xText = xTextDocument->getText();
+ rtl::Reference< SwXBodyText > xText = mxModel->getBodyText();
mxViewCursor->gotoRange( word::getFirstObjectPosition( xText ), false );
break;
}
@@ -293,7 +295,7 @@ uno::Reference< text::XTextRange > SwVbaView::getHFTextRange( sal_Int32 nType )
xPageCursor->jumpToFirstPage();
}
- uno::Reference< style::XStyle > xStyle;
+ rtl::Reference< SwXBaseStyle > xStyle;
uno::Reference< text::XText > xText;
switch( nType )
{
@@ -337,15 +339,14 @@ uno::Reference< text::XTextRange > SwVbaView::getHFTextRange( sal_Int32 nType )
}
xStyle = word::getCurrentPageStyle( mxModel );
- uno::Reference< beans::XPropertySet > xPageProps( xStyle, uno::UNO_QUERY_THROW );
bool isOn = false;
- xPageProps->getPropertyValue( aPropIsOn ) >>= isOn;
+ xStyle->getPropertyValue( aPropIsOn ) >>= isOn;
bool isShared = false;
- xPageProps->getPropertyValue( aPropIsShared ) >>= isShared;
+ xStyle->getPropertyValue( aPropIsShared ) >>= isShared;
if( !isOn )
{
- xPageProps->setPropertyValue( aPropIsOn, uno::Any( true ) );
- xPageProps->setPropertyValue( aPropBodyDistance, uno::Any( DEFAULT_BODY_DISTANCE ) );
+ xStyle->setPropertyValue( aPropIsOn, uno::Any( true ) );
+ xStyle->setPropertyValue( aPropBodyDistance, uno::Any( DEFAULT_BODY_DISTANCE ) );
}
if( !isShared )
{
@@ -359,7 +360,7 @@ uno::Reference< text::XTextRange > SwVbaView::getHFTextRange( sal_Int32 nType )
{
aTempPropText += "Right";
}
- xText.set( xPageProps->getPropertyValue( aTempPropText), uno::UNO_QUERY_THROW );
+ xText.set( xStyle->getPropertyValue( aTempPropText), uno::UNO_QUERY_THROW );
}
else
{
@@ -368,7 +369,7 @@ uno::Reference< text::XTextRange > SwVbaView::getHFTextRange( sal_Int32 nType )
{
DebugHelper::basicexception( ERRCODE_BASIC_BAD_ACTION, {} );
}
- xText.set( xPageProps->getPropertyValue( aPropText ), uno::UNO_QUERY_THROW );
+ xText.set( xStyle->getPropertyValue( aPropText ), uno::UNO_QUERY_THROW );
}
mxModel->unlockControllers();
diff --git a/sw/source/ui/vba/vbaview.hxx b/sw/source/ui/vba/vbaview.hxx
index 66cd0db612ef..ab2ff3567ba7 100644
--- a/sw/source/ui/vba/vbaview.hxx
+++ b/sw/source/ui/vba/vbaview.hxx
@@ -23,13 +23,16 @@
#include <com/sun/star/text/XTextViewCursor.hpp>
#include <com/sun/star/text/XTextRange.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
+#include <rtl/ref.hxx>
+
+class SwXTextDocument;
typedef InheritedHelperInterfaceWeakImpl< ooo::vba::word::XView > SwVbaView_BASE;
class SwVbaView : public SwVbaView_BASE
{
private:
- css::uno::Reference< css::frame::XModel > mxModel;
+ rtl::Reference< SwXTextDocument > mxModel;
css::uno::Reference< css::text::XTextViewCursor > mxViewCursor;
css::uno::Reference< css::beans::XPropertySet > mxViewSettings;
@@ -39,8 +42,9 @@ private:
public:
/// @throws css::uno::RuntimeException
- SwVbaView( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext,
- css::uno::Reference< css::frame::XModel > xModel );
+ SwVbaView( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent,
+ const css::uno::Reference< css::uno::XComponentContext >& rContext,
+ rtl::Reference< SwXTextDocument > xModel );
virtual ~SwVbaView() override;
// XView
diff --git a/sw/source/ui/vba/vbawindow.cxx b/sw/source/ui/vba/vbawindow.cxx
index 5597f08b48de..f8551111d2ea 100644
--- a/sw/source/ui/vba/vbawindow.cxx
+++ b/sw/source/ui/vba/vbawindow.cxx
@@ -29,6 +29,7 @@
#include "vbapane.hxx"
#include "wordvbahelper.hxx"
#include <view.hxx>
+#include <unotxdoc.hxx>
using namespace ::com::sun::star;
using namespace ::ooo::vba;
@@ -36,9 +37,10 @@ using namespace ::ooo::vba;
SwVbaWindow::SwVbaWindow(
const uno::Reference< XHelperInterface >& xParent,
const uno::Reference< uno::XComponentContext >& xContext,
- const uno::Reference< frame::XModel >& xModel,
+ const rtl::Reference< SwXTextDocument >& xModel,
const uno::Reference< frame::XController >& xController ) :
- WindowImpl_BASE( xParent, xContext, xModel, xController )
+ WindowImpl_BASE( xParent, xContext, xController ),
+ m_xModel(xModel)
{
}
diff --git a/sw/source/ui/vba/vbawindow.hxx b/sw/source/ui/vba/vbawindow.hxx
index ee435b1505ac..24144060b79a 100644
--- a/sw/source/ui/vba/vbawindow.hxx
+++ b/sw/source/ui/vba/vbawindow.hxx
@@ -18,12 +18,16 @@
*/
#ifndef INCLUDED_SW_SOURCE_UI_VBA_VBAWINDOW_HXX
#define INCLUDED_SW_SOURCE_UI_VBA_VBAWINDOW_HXX
+
#include <cppuhelper/implbase.hxx>
#include <ooo/vba/word/XWindow.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <vbahelper/vbahelperinterface.hxx>
#include <vbahelper/vbawindowbase.hxx>
+#include <rtl/ref.hxx>
+
+class SwXTextDocument;
typedef cppu::ImplInheritanceHelper< VbaWindowBase, ov::word::XWindow > WindowImpl_BASE;
@@ -34,7 +38,7 @@ public:
SwVbaWindow(
const css::uno::Reference< ov::XHelperInterface >& xParent,
const css::uno::Reference< css::uno::XComponentContext >& xContext,
- const css::uno::Reference< css::frame::XModel >& xModel,
+ const rtl::Reference< SwXTextDocument >& xModel,
const css::uno::Reference< css::frame::XController >& xController );
// Attributes
@@ -52,6 +56,8 @@ public:
// XHelperInterface
virtual OUString getServiceImplName() override;
virtual css::uno::Sequence<OUString> getServiceNames() override;
+private:
+ rtl::Reference< SwXTextDocument > m_xModel;
};
#endif // INCLUDED_SW_SOURCE_UI_VBA_VBAWINDOW_HXX
diff --git a/sw/source/ui/vba/wordvbahelper.cxx b/sw/source/ui/vba/wordvbahelper.cxx
index 61abc6dd0c3a..c74c5243286a 100644
--- a/sw/source/ui/vba/wordvbahelper.cxx
+++ b/sw/source/ui/vba/wordvbahelper.cxx
@@ -26,12 +26,14 @@
#include <com/sun/star/container/XIndexAccess.hpp>
#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <vbahelper/vbahelper.hxx>
#include <unotxdoc.hxx>
#include <doc.hxx>
#include <IDocumentLayoutAccess.hxx>
#include <view.hxx>
#include <viewsh.hxx>
#include <comphelper/servicehelper.hxx>
+#include <unostyle.hxx>
using namespace ::com::sun::star;
using namespace ::ooo::vba;
@@ -39,20 +41,13 @@ using namespace ::ooo::vba;
namespace ooo::vba::word
{
-SwDocShell* getDocShell( const uno::Reference< frame::XModel>& xModel )
+SwView* getView( const rtl::Reference< SwXTextDocument>& xModel )
{
- uno::Reference< lang::XUnoTunnel > xTunnel( xModel, uno::UNO_QUERY_THROW );
- SwXTextDocument* pXDoc = comphelper::getFromUnoTunnel<SwXTextDocument>(xTunnel);
- return pXDoc ? pXDoc->GetDocShell() : nullptr;
-}
-
-SwView* getView( const uno::Reference< frame::XModel>& xModel )
-{
- SwDocShell* pDocShell = getDocShell( xModel );
+ SwDocShell* pDocShell = xModel->GetDocShell( );
return pDocShell? pDocShell->GetView() : nullptr;
}
-uno::Reference< text::XTextViewCursor > getXTextViewCursor( const uno::Reference< frame::XModel >& xModel )
+uno::Reference< text::XTextViewCursor > getXTextViewCursor( const rtl::Reference< SwXTextDocument >& xModel )
{
uno::Reference< frame::XController > xController = xModel->getCurrentController();
uno::Reference< text::XTextViewCursorSupplier > xTextViewCursorSupp( xController, uno::UNO_QUERY_THROW );
@@ -60,37 +55,33 @@ uno::Reference< text::XTextViewCursor > getXTextViewCursor( const uno::Reference
return xTextViewCursor;
}
-uno::Reference< style::XStyle > getCurrentPageStyle( const uno::Reference< frame::XModel >& xModel )
+rtl::Reference< SwXBaseStyle > getCurrentPageStyle( const rtl::Reference< SwXTextDocument >& xModel )
{
uno::Reference< beans::XPropertySet > xCursorProps( getXTextViewCursor( xModel ), uno::UNO_QUERY_THROW );
return getCurrentPageStyle( xModel, xCursorProps );
}
-uno::Reference< style::XStyle > getCurrentPageStyle( const uno::Reference< frame::XModel >& xModel, const uno::Reference< beans::XPropertySet >& xProps )
+rtl::Reference< SwXBaseStyle > getCurrentPageStyle( const rtl::Reference< SwXTextDocument >& xModel, const uno::Reference< beans::XPropertySet >& xProps )
{
OUString aPageStyleName;
xProps->getPropertyValue(u"PageStyleName"_ustr) >>= aPageStyleName;
- uno::Reference< style::XStyleFamiliesSupplier > xSytleFamSupp( xModel, uno::UNO_QUERY_THROW );
- uno::Reference< container::XNameAccess > xSytleFamNames( xSytleFamSupp->getStyleFamilies(), uno::UNO_SET_THROW );
- uno::Reference< container::XNameAccess > xPageStyles( xSytleFamNames->getByName(u"PageStyles"_ustr), uno::UNO_QUERY_THROW );
- uno::Reference< style::XStyle > xStyle( xPageStyles->getByName( aPageStyleName ), uno::UNO_QUERY_THROW );
-
- return xStyle;
+ rtl::Reference< SwXStyleFamilies > xStyleFamNames( xModel->getSwStyleFamilies() );
+ rtl::Reference< SwXStyleFamily > xPageStyles( xStyleFamNames->GetPageStyles() );
+ return xPageStyles->getStyleByName( aPageStyleName );
}
-sal_Int32 getPageCount( const uno::Reference< frame::XModel>& xModel )
+sal_Int32 getPageCount( const rtl::Reference<SwXTextDocument>& xModel )
{
- SwDocShell* pDocShell = getDocShell( xModel );
+ SwDocShell* pDocShell = xModel->GetDocShell();
SwViewShell* pViewSh = pDocShell ? pDocShell->GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell() : nullptr;
return pViewSh ? pViewSh->GetPageCount() : 0;
}
-uno::Reference< style::XStyle > getDefaultParagraphStyle( const uno::Reference< frame::XModel >& xModel )
+rtl::Reference< SwXBaseStyle > getDefaultParagraphStyle( const rtl::Reference< SwXTextDocument >& xModel )
{
- uno::Reference< style::XStyleFamiliesSupplier > xSytleFamSupp( xModel, uno::UNO_QUERY_THROW );
- uno::Reference< container::XNameAccess > xSytleFamNames( xSytleFamSupp->getStyleFamilies(), uno::UNO_SET_THROW );
- uno::Reference< container::XNameAccess > xParaStyles( xSytleFamNames->getByName(u"ParagraphStyles"_ustr), uno::UNO_QUERY_THROW );
- uno::Reference< style::XStyle > xStyle( xParaStyles->getByName(u"Standard"_ustr), uno::UNO_QUERY_THROW );
+ rtl::Reference< SwXStyleFamilies > xStyleFamNames( xModel->getSwStyleFamilies() );
+ rtl::Reference< SwXStyleFamily > xParaStyles( xStyleFamNames->GetParagraphStyles() );
+ rtl::Reference< SwXBaseStyle > xStyle( xParaStyles->getStyleByName(u"Standard"_ustr) );
return xStyle;
}
@@ -116,7 +107,7 @@ uno::Reference< text::XTextRange > getFirstObjectPosition( const uno::Reference<
return xTextRange;
}
-uno::Reference< text::XText > getCurrentXText( const uno::Reference< frame::XModel >& xModel )
+uno::Reference< text::XText > getCurrentXText( const rtl::Reference< SwXTextDocument >& xModel )
{
uno::Reference< text::XTextRange > xTextRange;
uno::Reference< text::XTextContent > xTextContent( xModel->getCurrentSelection(), uno::UNO_QUERY );
@@ -157,7 +148,7 @@ uno::Reference< text::XText > getCurrentXText( const uno::Reference< frame::XMod
return xText;
}
-bool gotoSelectedObjectAnchor( const uno::Reference< frame::XModel>& xModel )
+bool gotoSelectedObjectAnchor( const rtl::Reference<SwXTextDocument>& xModel )
{
bool isObjectSelected = false;
uno::Reference< text::XTextContent > xTextContent( xModel->getCurrentSelection(), uno::UNO_QUERY );
@@ -171,6 +162,30 @@ bool gotoSelectedObjectAnchor( const uno::Reference< frame::XModel>& xModel )
return isObjectSelected;
}
+rtl::Reference< SwXTextDocument > getCurrentWordDoc( const uno::Reference< uno::XComponentContext >& xContext )
+{
+ try
+ {
+ return dynamic_cast<SwXTextDocument*>(getCurrentDoc( u"ThisWordDoc"_ustr ).get());
+ }
+ catch (const uno::Exception&)
+ {
+ try
+ {
+ return getThisWordDoc( xContext );
+ }
+ catch (const uno::Exception&)
+ {
+ }
+ }
+ return {};
+}
+
+rtl::Reference< SwXTextDocument > getThisWordDoc( const uno::Reference< uno::XComponentContext >& xContext )
+{
+ return dynamic_cast<SwXTextDocument*>(::ooo::vba::getCurrentDocCtx( u"WordDocumentContext"_ustr , xContext ).get());
+}
+
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/vba/wordvbahelper.hxx b/sw/source/ui/vba/wordvbahelper.hxx
index ba8f77885ca8..f80f710c422f 100644
--- a/sw/source/ui/vba/wordvbahelper.hxx
+++ b/sw/source/ui/vba/wordvbahelper.hxx
@@ -24,30 +24,36 @@
#include <com/sun/star/text/XTextViewCursor.hpp>
#include <com/sun/star/style/XStyle.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
+#include <rtl/ref.hxx>
class SwDocShell;
class SwView;
+class SwXTextDocument;
+class SwXBaseStyle;
+
namespace ooo::vba::word
{
- //css::uno::Reference< css::frame::XModel > getCurrentDocument() throw (css::uno::RuntimeException);
- SwDocShell* getDocShell( const css::uno::Reference< css::frame::XModel>& xModel );
- SwView* getView( const css::uno::Reference< css::frame::XModel>& xModel );
+ SwView* getView( const rtl::Reference<SwXTextDocument>& xModel );
/// @throws css::uno::RuntimeException
- css::uno::Reference< css::text::XTextViewCursor > getXTextViewCursor( const css::uno::Reference< css::frame::XModel >& xModel );
+ css::uno::Reference< css::text::XTextViewCursor > getXTextViewCursor( const rtl::Reference< SwXTextDocument >& xModel );
/// @throws css::uno::RuntimeException
- css::uno::Reference< css::style::XStyle > getCurrentPageStyle( const css::uno::Reference< css::frame::XModel >& xModel );
+ rtl::Reference< SwXBaseStyle > getCurrentPageStyle( const rtl::Reference< SwXTextDocument >& xModel );
/// @throws css::uno::RuntimeException
- css::uno::Reference< css::style::XStyle > getCurrentPageStyle( const css::uno::Reference< css::frame::XModel>& xModel, const css::uno::Reference< css::beans::XPropertySet >& xProps );
+ rtl::Reference< SwXBaseStyle > getCurrentPageStyle( const rtl::Reference< SwXTextDocument>& xModel, const css::uno::Reference< css::beans::XPropertySet >& xProps );
/// @throws css::uno::RuntimeException
- sal_Int32 getPageCount( const css::uno::Reference< css::frame::XModel>& xModel );
+ sal_Int32 getPageCount( const rtl::Reference<SwXTextDocument>& xModel );
/// @throws css::uno::RuntimeException
- css::uno::Reference< css::style::XStyle > getDefaultParagraphStyle( const css::uno::Reference< css::frame::XModel >& xModel );
+ rtl::Reference< SwXBaseStyle > getDefaultParagraphStyle( const rtl::Reference< SwXTextDocument >& xModel );
/// @throws css::uno::RuntimeException
css::uno::Reference< css::text::XTextRange > getFirstObjectPosition( const css::uno::Reference< css::text::XText >& xText );
/// @throws css::uno::RuntimeException
- css::uno::Reference< css::text::XText > getCurrentXText( const css::uno::Reference< css::frame::XModel>& xModel );
+ css::uno::Reference< css::text::XText > getCurrentXText( const rtl::Reference<SwXTextDocument>& xModel );
+ /// @throws css::uno::RuntimeException
+ bool gotoSelectedObjectAnchor( const rtl::Reference<SwXTextDocument>& xModel );
+ /// @throws css::uno::RuntimeException
+ rtl::Reference< SwXTextDocument > getCurrentWordDoc( const css::uno::Reference< css::uno::XComponentContext >& xContext );
/// @throws css::uno::RuntimeException
- bool gotoSelectedObjectAnchor( const css::uno::Reference< css::frame::XModel>& xModel );
+ rtl::Reference< SwXTextDocument > getThisWordDoc( const css::uno::Reference< css::uno::XComponentContext >& xContext );
enum E_DIRECTION
{
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index a878670e9489..8b0de66032de 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -1176,6 +1176,11 @@ Reference< XNameAccess > SwXTextDocument::getReferenceMarks()
Reference< XEnumerationAccess > SwXTextDocument::getTextFields()
{
+ return getSwTextFields();
+}
+
+rtl::Reference< SwXTextFieldTypes > SwXTextDocument::getSwTextFields()
+{
SolarMutexGuard aGuard;
ThrowIfInvalid();
if(!mxXTextFieldTypes.is())
@@ -1263,6 +1268,11 @@ Reference< XNameAccess > SwXTextDocument::getGraphicObjects()
Reference< XNameAccess > SwXTextDocument::getTextFrames()
{
+ return getSwTextFrames();
+}
+
+rtl::Reference< SwXTextFrames > SwXTextDocument::getSwTextFrames()
+{
SolarMutexGuard aGuard;
ThrowIfInvalid();
if(!mxXTextFrames.is())
@@ -2329,6 +2339,11 @@ Reference< XNameAccess > SwXTextDocument::getLinks()
Reference< XEnumerationAccess > SwXTextDocument::getRedlines( )
{
+ return getSwRedlines();
+}
+
+rtl::Reference< SwXRedlines > SwXTextDocument::getSwRedlines( )
+{
if(!mxXRedlines.is())
{
mxXRedlines = new SwXRedlines(m_pDocShell->GetDoc());
diff --git a/vbahelper/source/vbahelper/vbadialogbase.cxx b/vbahelper/source/vbahelper/vbadialogbase.cxx
index 8110582382d9..982e523d9d8f 100644
--- a/vbahelper/source/vbahelper/vbadialogbase.cxx
+++ b/vbahelper/source/vbahelper/vbadialogbase.cxx
@@ -25,13 +25,13 @@ using namespace ::com::sun::star;
void SAL_CALL VbaDialogBase::Show()
{
- if (m_xModel.is())
+ if (auto xModel = getModel())
{
OUString aURL = mapIndexToName(mnIndex);
if (aURL.isEmpty())
throw uno::RuntimeException(u"Unable to open the specified dialog"_ustr);
- dispatchRequests(m_xModel, aURL, {});
+ dispatchRequests(xModel, aURL, {});
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/vbahelper/vbadocumentbase.cxx b/vbahelper/source/vbahelper/vbadocumentbase.cxx
index ff9ef8c1bc72..7db25a6bbba5 100644
--- a/vbahelper/source/vbahelper/vbadocumentbase.cxx
+++ b/vbahelper/source/vbahelper/vbadocumentbase.cxx
@@ -43,12 +43,15 @@
using namespace ::com::sun::star;
using namespace ::ooo::vba;
-VbaDocumentBase::VbaDocumentBase( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, uno::Reference< frame::XModel > xModel ) : VbaDocumentBase_BASE( xParent, xContext ), mxModel(std::move( xModel ))
+VbaDocumentBase::VbaDocumentBase( const uno::Reference< ov::XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext >& xContext )
+: VbaDocumentBase_BASE( xParent, xContext )
{
}
VbaDocumentBase::VbaDocumentBase( uno::Sequence< uno::Any> const & args,
- uno::Reference< uno::XComponentContext> const & xContext ) : VbaDocumentBase_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0 ), xContext ), mxModel( getXSomethingFromArgs< frame::XModel >( args, 1 ) )
+ uno::Reference< uno::XComponentContext> const & xContext )
+: VbaDocumentBase_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0 ), xContext )
{
}
diff --git a/vbahelper/source/vbahelper/vbahelper.cxx b/vbahelper/source/vbahelper/vbahelper.cxx
index 5a39f691eeea..b2b9d7290c30 100644
--- a/vbahelper/source/vbahelper/vbahelper.cxx
+++ b/vbahelper/source/vbahelper/vbahelper.cxx
@@ -222,7 +222,7 @@ getCurrentDoc( const OUString& sKey )
}
/// @throws uno::RuntimeException
-static uno::Reference< frame::XModel >
+uno::Reference< frame::XModel >
getCurrentDocCtx( const OUString& ctxName, const uno::Reference< uno::XComponentContext >& xContext )
{
uno::Reference< frame::XModel > xModel;
@@ -238,12 +238,6 @@ getThisExcelDoc( const uno::Reference< uno::XComponentContext >& xContext )
return getCurrentDocCtx( u"ExcelDocumentContext"_ustr , xContext );
}
-uno::Reference< frame::XModel >
-getThisWordDoc( const uno::Reference< uno::XComponentContext >& xContext )
-{
- return getCurrentDocCtx( u"WordDocumentContext"_ustr , xContext );
-}
-
uno::Reference< frame::XModel >
getCurrentExcelDoc( const uno::Reference< uno::XComponentContext >& xContext )
{
@@ -265,27 +259,6 @@ getCurrentExcelDoc( const uno::Reference< uno::XComponentContext >& xContext )
return xModel;
}
- uno::Reference< frame::XModel >
-getCurrentWordDoc( const uno::Reference< uno::XComponentContext >& xContext )
-{
- uno::Reference< frame::XModel > xModel;
- try
- {
- xModel = getCurrentDoc( u"ThisWordDoc"_ustr );
- }
- catch (const uno::Exception&)
- {
- try
- {
- xModel = getThisWordDoc( xContext );
- }
- catch (const uno::Exception&)
- {
- }
- }
- return xModel;
-}
-
sal_Int32
OORGBToXLRGB( sal_Int32 nCol )
{
diff --git a/vbahelper/source/vbahelper/vbawindowbase.cxx b/vbahelper/source/vbahelper/vbawindowbase.cxx
index 0773821d431b..248252661943 100644
--- a/vbahelper/source/vbahelper/vbawindowbase.cxx
+++ b/vbahelper/source/vbahelper/vbawindowbase.cxx
@@ -30,18 +30,15 @@ using namespace ::ooo::vba;
VbaWindowBase::VbaWindowBase(
const uno::Reference< XHelperInterface >& xParent,
const uno::Reference< uno::XComponentContext >& xContext,
- const css::uno::Reference< css::frame::XModel >& xModel,
const uno::Reference< frame::XController >& xController ) :
- WindowBaseImpl_BASE( xParent, xContext ),
- m_xModel( xModel, uno::UNO_SET_THROW )
+ WindowBaseImpl_BASE( xParent, xContext )
{
construct( xController );
}
VbaWindowBase::VbaWindowBase( uno::Sequence< uno::Any > const & args,
uno::Reference< uno::XComponentContext > const & xContext ) :
- WindowBaseImpl_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0, false ), xContext ),
- m_xModel( getXSomethingFromArgs< frame::XModel >( args, 1, false ) )
+ WindowBaseImpl_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0, false ), xContext )
{
construct( getXSomethingFromArgs< frame::XController >( args, 2 ) );
}