use more concrete UNO class in the form of ScModelObj

Change-Id: I9ad26f05635583e203ff338a88add65838c9188e
Reviewed-on: https://gerrit.collaboraoffice.com/c/core/+/555
Reviewed-by: Noel Grandin <noel.grandin@collabora.com>
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
(cherry picked from commit 0a6ee7a99d6a5d624c4303256cc385ca6e23d456)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/211619
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
This commit is contained in:
Noel Grandin
2026-10-01 09:01:29 +02:00
committed by Xisco Fauli
parent e5856e9912
commit ce16bc37fd
29 changed files with 158 additions and 155 deletions
+1 -1
View File
@@ -47,7 +47,7 @@ protected:
virtual ~VbaApplicationBase() override;
/// @throws css::uno::RuntimeException
virtual css::uno::Reference< css::frame::XModel > getCurrentDocument() = 0;
virtual css::frame::XModel* getCurrentDocument() = 0;
public:
// XHelperInterface ( parent is itself )
virtual css::uno::Reference< ov::XHelperInterface > SAL_CALL getParent( ) override { return this; }
+1 -1
View File
@@ -47,7 +47,7 @@ class VBAHELPER_DLLPUBLIC VbaDocumentBase : public VbaDocumentBase_BASE
protected:
css::uno::Reference< css::uno::XInterface > mxVBProject;
protected:
virtual css::uno::Reference< css::frame::XModel > getModel() const = 0;
virtual css::frame::XModel* getModel() const = 0;
public:
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 );
+2 -2
View File
@@ -2036,12 +2036,12 @@ static OUString getFileNameFromDoc( const ScDocument* pDoc )
// TODO : er points at ScGlobal::GetAbsDocName()
// as a better template. Look into it
OUString sFileName;
SfxObjectShell* pShell;
ScDocShell* pShell;
if( nullptr != pDoc &&
nullptr != (pShell = pDoc->GetDocumentShell() ) )
{
uno::Reference< frame::XModel > xModel = pShell->GetModel();
rtl::Reference< ScModelObj > xModel = pShell->GetModel();
if( xModel.is() )
{
if( !xModel->getURL().isEmpty() )
+3 -4
View File
@@ -244,14 +244,13 @@ void XclExpRoot::InitializeGlobals()
SAL_WARN( "sc", "XclExpRoot::InitializeGlobals - no object shell");
break;
}
uno::Reference< lang::XComponent > xComponent = pShell->GetModel();
if (!xComponent.is())
rtl::Reference< ScModelObj > xModel = pShell->GetModel();
if (!xModel.is())
{
SAL_WARN( "sc", "XclExpRoot::InitializeGlobals - no component");
break;
}
uno::Reference< lang::XMultiServiceFactory > xModelFactory( xComponent, uno::UNO_QUERY);
oox::xls::OpCodeProvider aOpCodeProvider(xModelFactory, false);
oox::xls::OpCodeProvider aOpCodeProvider(xModel, false);
// Compiler mocks about non-matching ctor or conversion from
// Sequence<...> to Sequence<const ...> if directly created or passed,
// conversion through Any works around.
+1 -1
View File
@@ -414,7 +414,7 @@ std::unique_ptr<XclExpOcxControlObj> XclEscherEx::CreateOCXCtrlObj( Reference< X
// writes from xCtrlModel into mxCtlsStrm, raw class name returned in aClassName
Reference< XOutputStream > xOut( new utl::OSeekableOutputStreamWrapper( *mxCtlsStrm ) );
Reference< css::frame::XModel > xModel( GetDocShell() ? GetDocShell()->GetModel() : nullptr );
rtl::Reference< ScModelObj > xModel( GetDocShell() ? GetDocShell()->GetModel() : nullptr );
if( xModel.is() && xOut.is() && oox::ole::MSConvertOCXControls::WriteOCXExcelKludgeStream( xModel, xOut, xCtrlModel, xShape->getSize(), aClassName ) )
{
sal_uInt32 nStrmSize = static_cast< sal_uInt32 >( mxCtlsStrm->Tell() - nStrmStart );
+9 -6
View File
@@ -1687,9 +1687,10 @@ extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportFODS(SvStream &rStream)
{
ScDLL::Init();
SfxObjectShellLock xDocSh(new ScDocShell);
rtl::Reference<ScDocShell> xDocSh(new ScDocShell);
SfxObjectShellLock xLock(xDocSh.get());
xDocSh->DoInitNew();
uno::Reference<frame::XModel> xModel(xDocSh->GetModel());
rtl::Reference<ScModelObj> xModel(xDocSh->GetModel());
uno::Reference<lang::XMultiServiceFactory> xMultiServiceFactory(comphelper::getProcessServiceFactory());
uno::Reference<io::XInputStream> xStream(new ::utl::OSeekableInputStreamWrapper(rStream));
@@ -1740,9 +1741,10 @@ extern "C" SAL_DLLPUBLIC_EXPORT bool TestFODSExportXLS(SvStream &rStream)
{
ScDLL::Init();
SfxObjectShellLock xDocSh(new ScDocShell);
rtl::Reference<ScDocShell> xDocSh(new ScDocShell);
SfxObjectShellLock xLock(xDocSh.get());
xDocSh->DoInitNew();
uno::Reference<frame::XModel> xModel(xDocSh->GetModel());
rtl::Reference<ScModelObj> xModel(xDocSh->GetModel());
uno::Reference<lang::XMultiServiceFactory> xMultiServiceFactory(comphelper::getProcessServiceFactory());
uno::Reference<io::XInputStream> xStream(new ::utl::OSeekableInputStreamWrapper(rStream));
@@ -1814,9 +1816,10 @@ extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportXLSX(SvStream &rStream)
{
ScDLL::Init();
SfxObjectShellLock xDocSh(new ScDocShell);
rtl::Reference<ScDocShell> xDocSh(new ScDocShell);
SfxObjectShellLock xLock(xDocSh.get());
xDocSh->DoInitNew();
uno::Reference<frame::XModel> xModel(xDocSh->GetModel());
rtl::Reference<ScModelObj> xModel(xDocSh->GetModel());
uno::Reference<lang::XMultiServiceFactory> xMultiServiceFactory(comphelper::getProcessServiceFactory());
uno::Reference<io::XInputStream> xStream(new utl::OSeekableInputStreamWrapper(rStream));
+13 -20
View File
@@ -290,7 +290,7 @@ bool ScXMLImportWrapper::Import( ImportFlags nMode, ErrCodeMsg& rError )
xStorage = pMedium->GetStorage();
// get filter
uno::Reference<frame::XModel> xModel = mrDocShell.GetModel();
rtl::Reference<ScModelObj> xModel = mrDocShell.GetModel();
/** property map for export info set */
static comphelper::PropertyMapEntry const aImportInfoMap[] =
@@ -318,10 +318,9 @@ bool ScXMLImportWrapper::Import( ImportFlags nMode, ErrCodeMsg& rError )
// ---- get BuildId from parent container if available
uno::Reference< container::XChild > xChild( xModel, uno::UNO_QUERY );
if( xChild.is() )
if( xModel.is() )
{
uno::Reference< beans::XPropertySet > xParentSet( xChild->getParent(), uno::UNO_QUERY );
uno::Reference< beans::XPropertySet > xParentSet( xModel->getParent(), uno::UNO_QUERY );
if( xParentSet.is() )
{
uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xParentSet->getPropertySetInfo() );
@@ -382,13 +381,11 @@ bool ScXMLImportWrapper::Import( ImportFlags nMode, ErrCodeMsg& rError )
// RDF metadata: ODF >= 1.2
try
{
const uno::Reference< rdf::XDocumentMetadataAccess > xDMA(
xModel, uno::UNO_QUERY_THROW );
const uno::Reference< rdf::XURI > xBaseURI(
::sfx2::createBaseURI( xContext, xModel, aBaseURL, aName ) );
uno::Reference<task::XInteractionHandler> xHandler =
mrDocShell.GetMedium()->GetInteractionHandler();
xDMA->loadMetadataFromStorage( xStorage, xBaseURI, xHandler );
xModel->loadMetadataFromStorage( xStorage, xBaseURI, xHandler );
}
catch ( const lang::WrappedTargetException & e)
{
@@ -534,19 +531,18 @@ bool ScXMLImportWrapper::Import( ImportFlags nMode, ErrCodeMsg& rError )
bool bRet = !rError.IsError();
::svx::DropUnusedNamedItems(xModel);
::svx::DropUnusedNamedItems(cppu::getXWeak(xModel.get()));
// set BuildId on XModel for later OLE object loading
if( xInfoSet.is() )
{
uno::Reference< beans::XPropertySet > xModelSet( xModel, uno::UNO_QUERY );
if( xModelSet.is() )
if( xModel.is() )
{
uno::Reference< beans::XPropertySetInfo > xModelSetInfo( xModelSet->getPropertySetInfo() );
uno::Reference< beans::XPropertySetInfo > xModelSetInfo( xModel->getPropertySetInfo() );
OUString sBuildPropName(u"BuildId"_ustr );
if( xModelSetInfo.is() && xModelSetInfo->hasPropertyByName(sBuildPropName) )
{
xModelSet->setPropertyValue( sBuildPropName, xInfoSet->getPropertyValue(sBuildPropName) );
xModel->setPropertyValue( sBuildPropName, xInfoSet->getPropertyValue(sBuildPropName) );
}
}
@@ -563,9 +559,9 @@ bool ScXMLImportWrapper::Import( ImportFlags nMode, ErrCodeMsg& rError )
/* Set library container to VBA compatibility mode, this
forces loading the Basic project, which in turn creates the
VBA Globals object and does all related initialization. */
if ( xModelSet.is() ) try
if ( xModel.is() ) try
{
uno::Reference< script::vba::XVBACompatibility > xVBACompat( xModelSet->getPropertyValue(
uno::Reference< script::vba::XVBACompatibility > xVBACompat( xModel->getPropertyValue(
u"BasicLibraries"_ustr ), uno::UNO_QUERY_THROW );
xVBACompat->setVBACompatibilityMode( true );
}
@@ -763,11 +759,10 @@ bool ScXMLImportWrapper::Export(bool bStylesOnly)
if ( pObjSh && xStorage.is() )
{
uno::Reference<frame::XModel> xModel(pObjSh->GetModel());
rtl::Reference<ScModelObj> xModel(pObjSh->GetModel());
// sorting wants to create undo actions
assert(SfxObjectCreateMode::STANDARD != pObjSh->GetCreateMode() || rDoc.GetDrawLayer()->IsUndoEnabled());
uno::Reference<drawing::XDrawPagesSupplier> const xDPS(xModel, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> const xDPs(xDPS->getDrawPages());
uno::Reference<container::XIndexAccess> const xDPs(xModel->getDrawPages());
assert(xDPs.is());
for (auto i = xDPs->getCount(); 0 < i; )
{
@@ -852,9 +847,7 @@ bool ScXMLImportWrapper::Export(bool bStylesOnly)
&& aVersion != ODFVER_010_TEXT
&& aVersion != ODFVER_011_TEXT )
{
const uno::Reference< rdf::XDocumentMetadataAccess > xDMA(
xModel, uno::UNO_QUERY_THROW );
xDMA->storeMetadataToStorage( xStorage );
xModel->storeMetadataToStorage( xStorage );
}
}
catch ( const beans::UnknownPropertyException &)
+9 -10
View File
@@ -256,7 +256,7 @@ ScVbaApplication::hasProperty( const OUString& Name )
uno::Reference< excel::XWorkbook >
ScVbaApplication::getActiveWorkbook()
{
uno::Reference< frame::XModel > xModel( getCurrentExcelDoc( mxContext ), uno::UNO_SET_THROW );
rtl::Reference< ScModelObj > xModel( dynamic_cast<ScModelObj*>(getCurrentExcelDoc( mxContext ).get()) );
uno::Reference< excel::XWorkbook > xWorkbook( getVBADocument( xModel ), uno::UNO_QUERY );
if( xWorkbook.is() ) return xWorkbook;
// #i116936# getVBADocument() may return null in documents without global VBA mode enabled
@@ -266,7 +266,7 @@ ScVbaApplication::getActiveWorkbook()
uno::Reference< excel::XWorkbook > SAL_CALL
ScVbaApplication::getThisWorkbook()
{
uno::Reference< frame::XModel > xModel( getThisExcelDoc( mxContext ), uno::UNO_SET_THROW );
rtl::Reference< ScModelObj > xModel( dynamic_cast<ScModelObj*>(getThisExcelDoc( mxContext ).get()) );
uno::Reference< excel::XWorkbook > xWorkbook( getVBADocument( xModel ), uno::UNO_QUERY );
if( xWorkbook.is() ) return xWorkbook;
// #i116936# getVBADocument() may return null in documents without global VBA mode enabled
@@ -481,7 +481,7 @@ ScVbaApplication::Dialogs( const uno::Any &aIndex )
uno::Reference< excel::XWindow > SAL_CALL
ScVbaApplication::getActiveWindow()
{
uno::Reference< frame::XModel > xModel = getCurrentDocument();
rtl::Reference< ScModelObj > xModel = getCurrentDocument();
uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_SET_THROW );
uno::Reference< XHelperInterface > xParent( getActiveWorkbook(), uno::UNO_QUERY_THROW );
uno::Reference< excel::XWindow > xWin( new ScVbaWindow( xParent, mxContext, xModel, xController ) );
@@ -551,7 +551,7 @@ ScVbaApplication::setStatusBar( const uno::Any& _statusbar )
ScVbaApplication::getCalculation()
{
// TODO: in Excel, this is an application-wide setting
uno::Reference<sheet::XCalculatable> xCalc(getCurrentDocument(), uno::UNO_QUERY_THROW);
rtl::Reference<ScModelObj> xCalc(getCurrentDocument());
if(xCalc->isAutomaticCalculationEnabled())
return excel::XlCalculation::xlCalculationAutomatic;
else
@@ -562,7 +562,7 @@ void SAL_CALL
ScVbaApplication::setCalculation( ::sal_Int32 _calculation )
{
// TODO: in Excel, this is an application-wide setting
uno::Reference< sheet::XCalculatable > xCalc(getCurrentDocument(), uno::UNO_QUERY_THROW);
rtl::Reference< ScModelObj > xCalc(getCurrentDocument());
switch(_calculation)
{
case excel::XlCalculation::xlCalculationManual:
@@ -978,9 +978,8 @@ ScVbaApplication::setIteration( sal_Bool bSet )
void SAL_CALL
ScVbaApplication::Calculate()
{
uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_SET_THROW );
uno::Reference< sheet::XCalculatable > xCalculatable( getCurrentDocument(), uno::UNO_QUERY_THROW );
xCalculatable->calculateAll();
rtl::Reference< ScModelObj > xModel( getCurrentDocument() );
xModel->calculateAll();
}
/// @throws uno::RuntimeException
@@ -1429,10 +1428,10 @@ ScVbaApplication::Caller( const uno::Any& /*aIndex*/ )
return aRet;
}
uno::Reference< frame::XModel >
ScModelObj*
ScVbaApplication::getCurrentDocument()
{
return getCurrentExcelDoc(mxContext);
return dynamic_cast<ScModelObj*>(getCurrentExcelDoc(mxContext).get());
}
uno::Any SAL_CALL
+2 -1
View File
@@ -26,6 +26,7 @@
#include <vbahelper/vbaapplicationbase.hxx>
#include <comphelper/invocationhelper.hxx>
#include <cppuhelper/implbase.hxx>
#include <docuno.hxx>
namespace com::sun::star::uno { class XComponentContext; }
namespace ooo::vba { class XSink; }
@@ -53,7 +54,7 @@ private:
comphelper::InvocationHelper m_aInvocationHelper;
protected:
virtual css::uno::Reference< css::frame::XModel > getCurrentDocument() override;
virtual ScModelObj* getCurrentDocument() override;
public:
explicit ScVbaApplication( const css::uno::Reference< css::uno::XComponentContext >& m_xContext );
+3 -3
View File
@@ -61,12 +61,12 @@ template< typename... Ifc >
ScVbaFormat< Ifc... >::ScVbaFormat( const uno::Reference< XHelperInterface >& xParent,
const uno::Reference< uno::XComponentContext > & xContext,
uno::Reference< beans::XPropertySet > _xPropertySet,
uno::Reference< frame::XModel > xModel,
const rtl::Reference< ScModelObj >& xModel,
bool bCheckAmbiguoity )
: ScVbaFormat_BASE( xParent, xContext ),
m_aDefaultLocale( u"en"_ustr, u"US"_ustr, OUString() ),
mxPropertySet(std::move( _xPropertySet )),
mxModel(std::move( xModel )),
mxModel( xModel ),
mbCheckAmbiguoity( bCheckAmbiguoity ),
mbAddIndent( false )
{
@@ -773,7 +773,7 @@ ScVbaFormat< Ifc... >::initializeNumberFormats()
{
if ( !xNumberFormats.is() )
{
mxNumberFormatsSupplier.set( mxModel, uno::UNO_QUERY_THROW );
mxNumberFormatsSupplier.set( cppu::getXWeak(mxModel.get()), uno::UNO_QUERY_THROW );
xNumberFormats = mxNumberFormatsSupplier->getNumberFormats();
xNumberFormatTypes.set( xNumberFormats, uno::UNO_QUERY ); // _THROW?
}
+4 -2
View File
@@ -20,6 +20,7 @@
#include <com/sun/star/lang/Locale.hpp>
#include <vbahelper/vbahelperinterface.hxx>
#include <rtl/ref.hxx>
namespace com::sun::star::beans { class XPropertySet; }
namespace com::sun::star::beans { class XPropertyState; }
@@ -31,6 +32,7 @@ namespace ooo::vba::excel { class XFont; }
namespace ooo::vba::excel { class XInterior; }
class ScCellRangesBase;
class ScModelObj;
class SfxItemSet;
template< typename... Ifc >
@@ -43,7 +45,7 @@ protected:
css::uno::Reference< css::util::XNumberFormatsSupplier > mxNumberFormatsSupplier;
css::uno::Reference< css::util::XNumberFormats > xNumberFormats;
css::uno::Reference< css::util::XNumberFormatTypes > xNumberFormatTypes;
css::uno::Reference< css::frame::XModel > mxModel;
rtl::Reference< ScModelObj > mxModel;
css::uno::Reference< css::beans::XPropertyState > xPropertyState;
bool mbCheckAmbiguoity;
bool mbAddIndent;
@@ -61,7 +63,7 @@ protected:
virtual ScCellRangesBase* getCellRangesBase();
public:
/// @throws css::script::BasicErrorException
ScVbaFormat( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, css::uno::Reference< css::beans::XPropertySet > _xPropertySet, css::uno::Reference< css::frame::XModel > xModel, bool bCheckAmbiguoity );
ScVbaFormat( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, css::uno::Reference< css::beans::XPropertySet > _xPropertySet, const rtl::Reference<ScModelObj>& xModel, bool bCheckAmbiguoity );
virtual css::uno::Reference< ov::XHelperInterface > thisHelperIface() = 0;
/// @throws css::uno::RuntimeException
void SAL_CALL setAddIndent( const css::uno::Any& BAddIndent) { BAddIndent >>= mbAddIndent; }
+13 -6
View File
@@ -388,14 +388,14 @@ getDocShellFromRanges( const uno::Reference< sheet::XSheetCellRangeContainer >&
}
/// @throws uno::RuntimeException
static uno::Reference< frame::XModel > getModelFromXIf( const uno::Reference< uno::XInterface >& xIf )
static rtl::Reference< ScModelObj > getModelFromXIf( const uno::Reference< uno::XInterface >& xIf )
{
ScDocShell* pDocShell = getDocShellFromIf(xIf );
return pDocShell->GetModel();
}
/// @throws uno::RuntimeException
static uno::Reference< frame::XModel > getModelFromRange( const uno::Reference< table::XCellRange >& xRange )
static rtl::Reference< ScModelObj > getModelFromRange( const uno::Reference< table::XCellRange >& xRange )
{
// the XInterface for getImplementation can be any derived interface, no need for queryInterface
uno::Reference< uno::XInterface > xIf( xRange );
@@ -480,7 +480,7 @@ class NumFormatHelper
public:
explicit NumFormatHelper( const uno::Reference< table::XCellRange >& xRange )
{
mxSupplier.set( getModelFromRange( xRange ), uno::UNO_QUERY_THROW );
mxSupplier.set( cppu::getXWeak(getModelFromRange( xRange ).get()), uno::UNO_QUERY_THROW );
mxRangeProps.set( xRange, uno::UNO_QUERY_THROW);
mxFormats = mxSupplier->getNumberFormats();
}
@@ -1418,7 +1418,14 @@ lcl_setupBorders( const uno::Reference< excel::XRange >& xParentRange, const uno
}
ScVbaRange::ScVbaRange( uno::Sequence< uno::Any> const & args,
uno::Reference< uno::XComponentContext> const & xContext ) : ScVbaRange_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0 ), xContext, getXSomethingFromArgs< beans::XPropertySet >( args, 1, false ), getModelFromXIf( getXSomethingFromArgs< uno::XInterface >( args, 1 ) ), true ), mbIsRows( false ), mbIsColumns( false )
uno::Reference< uno::XComponentContext> const & xContext )
: ScVbaRange_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0 ),
xContext,
getXSomethingFromArgs< beans::XPropertySet >( args, 1, false ),
getModelFromXIf( getXSomethingFromArgs< uno::XInterface >( args, 1 ) ),
true ),
mbIsRows( false ),
mbIsColumns( false )
{
mxRange.set( mxPropertySet, uno::UNO_QUERY );
mxRanges.set( mxPropertySet, uno::UNO_QUERY );
@@ -5374,8 +5381,8 @@ ScVbaRange::getStyle()
OUString sStyleName;
xProps->getPropertyValue( CELLSTYLE ) >>= sStyleName;
ScDocShell* pShell = getScDocShell();
uno::Reference< frame::XModel > xModel( pShell->GetModel() );
uno::Reference< excel::XStyle > xStyle = new ScVbaStyle( this, mxContext, sStyleName, xModel );
ScModelObj* pModel( pShell->GetModel() );
uno::Reference< excel::XStyle > xStyle = new ScVbaStyle( this, mxContext, sStyleName, pModel );
return uno::Any( xStyle );
}
void SAL_CALL
+8 -8
View File
@@ -21,6 +21,7 @@
#include <basic/sberrors.hxx>
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <docuno.hxx>
using namespace ::ooo::vba;
using namespace ::com::sun::star;
@@ -28,17 +29,18 @@ using namespace ::com::sun::star;
constexpr OUString DISPLAYNAME = u"DisplayName"_ustr;
uno::Reference< container::XNameAccess >
ScVbaStyle::getStylesNameContainer( const uno::Reference< frame::XModel >& xModel )
ScVbaStyle::getStylesNameContainer( const rtl::Reference<ScModelObj>& xModel )
{
uno::Reference< style::XStyleFamiliesSupplier > xStyleSupplier( xModel, uno::UNO_QUERY_THROW);
uno::Reference< container::XNameAccess > xStylesAccess( xStyleSupplier->getStyleFamilies()->getByName(u"CellStyles"_ustr), uno::UNO_QUERY_THROW );
if (!xModel)
throw uno::RuntimeException();
uno::Reference< container::XNameAccess > xStylesAccess( xModel->getStyleFamilies()->getByName(u"CellStyles"_ustr), uno::UNO_QUERY_THROW );
return xStylesAccess;
}
/// @throws script::BasicErrorException
/// @throws uno::RuntimeException
static uno::Reference< beans::XPropertySet >
lcl_getStyleProps( const OUString& sStyleName, const uno::Reference< frame::XModel >& xModel )
lcl_getStyleProps( const OUString& sStyleName, const rtl::Reference<ScModelObj>& xModel )
{
uno::Reference< beans::XPropertySet > xStyleProps( ScVbaStyle::getStylesNameContainer( xModel )->getByName( sStyleName ), uno::UNO_QUERY_THROW );
@@ -56,14 +58,12 @@ void ScVbaStyle::initialise()
}
mxStyle.set( mxPropertySet, uno::UNO_QUERY_THROW );
uno::Reference< style::XStyleFamiliesSupplier > xStyleSupplier( mxModel, uno::UNO_QUERY_THROW );
mxStyleFamilyNameContainer.set( ScVbaStyle::getStylesNameContainer( mxModel ), uno::UNO_QUERY_THROW );
}
ScVbaStyle::ScVbaStyle( const uno::Reference< ov::XHelperInterface >& xParent,
const uno::Reference< uno::XComponentContext > & xContext,
const OUString& sStyleName, const uno::Reference< frame::XModel >& _xModel )
const OUString& sStyleName, const rtl::Reference<ScModelObj>& _xModel )
: ScVbaStyle_BASE( xParent, xContext, lcl_getStyleProps( sStyleName, _xModel ), _xModel, false )
{
try
@@ -79,7 +79,7 @@ ScVbaStyle::ScVbaStyle( const uno::Reference< ov::XHelperInterface >& xParent,
ScVbaStyle::ScVbaStyle( const uno::Reference< XHelperInterface >& xParent,
const uno::Reference< uno::XComponentContext > & xContext,
const uno::Reference< beans::XPropertySet >& _xPropertySet,
const uno::Reference< frame::XModel >& _xModel )
const rtl::Reference<ScModelObj>& _xModel )
: ScVbaStyle_BASE( xParent, xContext, _xPropertySet, _xModel, false )
{
try
+5 -3
View File
@@ -25,6 +25,8 @@
#include <com/sun/star/container/XNameContainer.hpp>
#include "vbaformat.hxx"
class ScModelObj;
typedef ScVbaFormat< ov::excel::XStyle > ScVbaStyle_BASE;
class ScVbaStyle final : public ScVbaStyle_BASE
@@ -37,12 +39,12 @@ class ScVbaStyle final : public ScVbaStyle_BASE
public:
/// @throws css::script::BasicErrorException
/// @throws css::uno::RuntimeException
ScVbaStyle( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const OUString& sStyleName, const css::uno::Reference< css::frame::XModel >& _xModel );
ScVbaStyle( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const OUString& sStyleName, const rtl::Reference<ScModelObj>& _xModel );
/// @throws css::script::BasicErrorException
/// @throws css::uno::RuntimeException
ScVbaStyle( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::beans::XPropertySet >& _xPropertySet, const css::uno::Reference< css::frame::XModel >& _xModel );
ScVbaStyle( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::beans::XPropertySet >& _xPropertySet, const rtl::Reference<ScModelObj>& _cModel );
/// @throws css::uno::RuntimeException
static css::uno::Reference< css::container::XNameAccess > getStylesNameContainer( const css::uno::Reference< css::frame::XModel >& xModel );
static css::uno::Reference< css::container::XNameAccess > getStylesNameContainer( const rtl::Reference<ScModelObj>& xModel );
virtual css::uno::Reference< ov::XHelperInterface > thisHelperIface() override { return this; };
// XStyle Methods
virtual sal_Bool SAL_CALL BuiltIn() override;
+8 -7
View File
@@ -24,12 +24,13 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <utility>
#include <docuno.hxx>
using namespace ::ooo::vba;
using namespace ::com::sun::star;
static css::uno::Any
lcl_createAPIStyleToVBAObject( const css::uno::Any& aObject, const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel )
lcl_createAPIStyleToVBAObject( const css::uno::Any& aObject, const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const rtl::Reference<ScModelObj>& xModel )
{
uno::Reference< beans::XPropertySet > xStyleProps( aObject, uno::UNO_QUERY_THROW );
uno::Reference< excel::XStyle > xStyle( new ScVbaStyle( xParent, xContext, xStyleProps, xModel ) );
@@ -38,15 +39,15 @@ lcl_createAPIStyleToVBAObject( const css::uno::Any& aObject, const uno::Referenc
ScVbaStyles::ScVbaStyles( const uno::Reference< XHelperInterface >& xParent,
const uno::Reference< css::uno::XComponentContext > & xContext,
const uno::Reference< frame::XModel >& xModel )
ScModelObj* pModel )
: ScVbaStyles_BASE( xParent,
xContext,
uno::Reference< container::XIndexAccess >( ScVbaStyle::getStylesNameContainer( xModel ), uno::UNO_QUERY_THROW ) ),
mxModel( xModel )
uno::Reference< container::XIndexAccess >( ScVbaStyle::getStylesNameContainer( pModel ), uno::UNO_QUERY_THROW ) ),
mxModel( pModel )
{
try
{
mxMSF.set( mxModel, uno::UNO_QUERY_THROW );
mxMSF = mxModel;
mxNameContainerCellStyles.set( m_xNameAccess, uno::UNO_QUERY_THROW );
}
catch (uno::Exception& )
@@ -80,11 +81,11 @@ class EnumWrapper : public EnumerationHelper_BASE
uno::Reference<container::XIndexAccess > m_xIndexAccess;
uno::Reference<XHelperInterface > m_xParent;
uno::Reference<uno::XComponentContext > m_xContext;
uno::Reference<frame::XModel > m_xModel;
rtl::Reference<ScModelObj > m_xModel;
sal_Int32 nIndex;
public:
EnumWrapper( uno::Reference< container::XIndexAccess > xIndexAccess, uno::Reference<XHelperInterface > xParent, uno::Reference<uno::XComponentContext > xContext, uno::Reference<frame::XModel > xModel ) : m_xIndexAccess(std::move( xIndexAccess )), m_xParent(std::move( xParent )), m_xContext(std::move( xContext )), m_xModel(std::move( xModel )), nIndex( 0 ) {}
EnumWrapper( uno::Reference< container::XIndexAccess > xIndexAccess, uno::Reference<XHelperInterface > xParent, uno::Reference<uno::XComponentContext > xContext, rtl::Reference<ScModelObj > xModel ) : m_xIndexAccess(std::move( xIndexAccess )), m_xParent(std::move( xParent )), m_xContext(std::move( xContext )), m_xModel(std::move( xModel )), nIndex( 0 ) {}
virtual sal_Bool SAL_CALL hasMoreElements( ) override
{
return ( nIndex < m_xIndexAccess->getCount() );
+4 -2
View File
@@ -19,19 +19,21 @@
#pragma once
#include <ooo/vba/excel/XStyles.hpp>
#include <vbahelper/vbacollectionimpl.hxx>
#include <rtl/ref.hxx>
namespace com::sun::star::lang { class XMultiServiceFactory; }
namespace com::sun::star::container { class XNameContainer; }
class ScModelObj;
typedef CollTestImplHelper< ov::excel::XStyles > ScVbaStyles_BASE;
class ScVbaStyles: public ScVbaStyles_BASE
{
css::uno::Reference< css::frame::XModel > mxModel;
rtl::Reference< ScModelObj > mxModel;
css::uno::Reference< css::lang::XMultiServiceFactory > mxMSF;
css::uno::Reference< css::container::XNameContainer > mxNameContainerCellStyles;
public:
/// @throws css::script::BasicErrorException
ScVbaStyles( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::frame::XModel >& xModel );
ScVbaStyles( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, ScModelObj* pModel );
/// @throws css::uno::RuntimeException
css::uno::Sequence< OUString > getStyleNames();
/// @throws css::script::BasicErrorException
+3 -3
View File
@@ -190,7 +190,7 @@ public:
ScVbaWindow::ScVbaWindow(
const uno::Reference< XHelperInterface >& xParent,
const uno::Reference< uno::XComponentContext >& xContext,
const uno::Reference< frame::XModel >& xModel,
const rtl::Reference< ScModelObj >& xModel,
const uno::Reference< frame::XController >& xController ) :
WindowImpl_BASE( xParent, xContext, xController ),
m_xModel(xModel)
@@ -202,7 +202,7 @@ ScVbaWindow::ScVbaWindow(
const uno::Sequence< uno::Any >& args,
const uno::Reference< uno::XComponentContext >& xContext ) :
WindowImpl_BASE( args, xContext ),
m_xModel(getXSomethingFromArgs< frame::XModel >( args, 1, false ))
m_xModel(dynamic_cast<ScModelObj*>(getXSomethingFromArgs< frame::XModel >( args, 1, false ).get()))
{
init();
}
@@ -729,7 +729,7 @@ void SAL_CALL ScVbaWindow::setZoom(const uno::Any& _zoom)
{
sal_Int16 nZoom = 100;
_zoom >>= nZoom;
uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( m_xModel, uno::UNO_QUERY_THROW );
uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( m_xModel );
uno::Reference< excel::XWorksheet > xActiveSheet = ActiveSheet();
SCTAB nTab = 0;
if ( !ScVbaWorksheets::nameExists (xSpreadDoc, xActiveSheet->getName(), nTab) )
+4 -2
View File
@@ -27,12 +27,14 @@
#include <vbahelper/vbawindowbase.hxx>
class ScModelObj;
typedef cppu::ImplInheritanceHelper< VbaWindowBase, ov::excel::XWindow > WindowImpl_BASE;
class ScVbaWindow : public WindowImpl_BASE
{
private:
css::uno::Reference<css::frame::XModel> m_xModel;
rtl::Reference<ScModelObj> m_xModel;
css::uno::Reference< ov::excel::XPane > m_xPane;
void init();
@@ -55,7 +57,7 @@ public:
ScVbaWindow(
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< ScModelObj >& xModel,
const css::uno::Reference< css::frame::XController >& xController );
/// @throws css::uno::RuntimeException
ScVbaWindow(
+8 -4
View File
@@ -41,7 +41,7 @@ using namespace ::ooo::vba;
typedef std::unordered_map< OUString,
sal_Int32 > NameIndexHash;
static uno::Reference< XHelperInterface > lcl_createWorkbookHIParent( const uno::Reference< frame::XModel >& xModel, const uno::Reference< uno::XComponentContext >& xContext, const uno::Any& aApplication )
static uno::Reference< XHelperInterface > lcl_createWorkbookHIParent( const rtl::Reference< ScModelObj >& xModel, const uno::Reference< uno::XComponentContext >& xContext, const uno::Any& aApplication )
{
return new ScVbaWorkbook( uno::Reference< XHelperInterface >( aApplication, uno::UNO_QUERY_THROW ), xContext, xModel );
}
@@ -49,9 +49,10 @@ static uno::Reference< XHelperInterface > lcl_createWorkbookHIParent( const uno:
static uno::Any ComponentToWindow( const uno::Any& aSource, const uno::Reference< uno::XComponentContext > & xContext, const uno::Any& aApplication )
{
uno::Reference< frame::XModel > xModel( aSource, uno::UNO_QUERY_THROW );
ScModelObj* pModel = dynamic_cast<ScModelObj*>(xModel.get());
// !! TODO !! iterate over all controllers
uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_SET_THROW );
uno::Reference< excel::XWindow > xWin( new ScVbaWindow( lcl_createWorkbookHIParent( xModel, xContext, aApplication ), xContext, xModel, xController ) );
uno::Reference< frame::XController > xController( pModel->getCurrentController(), uno::UNO_SET_THROW );
uno::Reference< excel::XWindow > xWin( new ScVbaWindow( lcl_createWorkbookHIParent( pModel, xContext, aApplication ), xContext, pModel, xController ) );
return uno::Any( xWin );
}
@@ -144,7 +145,10 @@ public:
if ( xNext.is() )
{
m_windows.push_back( xNext );
uno::Reference< frame::XModel > xModel( xNext, uno::UNO_QUERY_THROW ); // that the spreadsheetdocument is a xmodel is a given
// that the spreadsheetdocument is a xmodel is a given
rtl::Reference<ScModelObj> xModel = dynamic_cast<ScModelObj*>(xNext.get());
if (!xModel)
throw uno::RuntimeException();
// tdf#126457 - add workbook name to window titles
rtl::Reference<ScVbaWorkbook> workbook(new ScVbaWorkbook(
+8 -9
View File
@@ -190,7 +190,7 @@ ScVbaWorkbook::init()
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 )
rtl::Reference< ScModelObj > const & xModel )
: ScVbaWorkbook_BASE( xParent, xContext ),
mxModel(xModel)
{
@@ -200,7 +200,7 @@ ScVbaWorkbook::ScVbaWorkbook( const css::uno::Reference< ov::XHelperInterface >&
ScVbaWorkbook::ScVbaWorkbook( uno::Sequence< uno::Any> const & args,
uno::Reference< uno::XComponentContext> const & xContext )
: ScVbaWorkbook_BASE( args, xContext ),
mxModel(getXSomethingFromArgs< frame::XModel >( args, 1 ))
mxModel(dynamic_cast<ScModelObj*>(getXSomethingFromArgs< frame::XModel >( args, 1 ).get()))
{
init();
}
@@ -263,8 +263,7 @@ ScVbaWorkbook::Protect( const uno::Any &aPassword )
sal_Bool
ScVbaWorkbook::getProtectStructure()
{
uno::Reference< util::XProtectable > xProt( getModel(), uno::UNO_QUERY_THROW );
return xProt->isProtected();
return getModel()->isProtected();
}
sal_Bool SAL_CALL ScVbaWorkbook::getPrecisionAsDisplayed()
@@ -290,7 +289,7 @@ void SAL_CALL ScVbaWorkbook::setPrecisionAsDisplayed( sal_Bool _precisionAsDispl
OUString SAL_CALL ScVbaWorkbook::getAuthor()
{
uno::Reference<document::XDocumentPropertiesSupplier> xDPS( getModel(), uno::UNO_QUERY );
rtl::Reference<ScModelObj> xDPS( getModel() );
if (!xDPS.is())
return u"?"_ustr;
uno::Reference<document::XDocumentProperties> xDocProps = xDPS->getDocumentProperties();
@@ -299,7 +298,7 @@ OUString SAL_CALL ScVbaWorkbook::getAuthor()
void SAL_CALL ScVbaWorkbook::setAuthor( const OUString& _author )
{
uno::Reference<document::XDocumentPropertiesSupplier> xDPS( getModel(), uno::UNO_QUERY );
rtl::Reference<ScModelObj> xDPS( getModel() );
if (!xDPS.is())
return;
uno::Reference<document::XDocumentProperties> xDocProps = xDPS->getDocumentProperties();
@@ -311,7 +310,7 @@ ScVbaWorkbook::SaveCopyAs( const OUString& sFileName )
{
OUString aURL;
osl::FileBase::getFileURLFromSystemPath( sFileName, aURL );
uno::Reference< frame::XStorable > xStor( getModel(), uno::UNO_QUERY_THROW );
rtl::Reference< ScModelObj > xStor( getModel() );
uno::Sequence< beans::PropertyValue > storeProps{ comphelper::makePropertyValue(
u"FilterName"_ustr, SC_XL97_FILTER_NAME) };
xStor->storeToURL( aURL, storeProps );
@@ -358,7 +357,7 @@ ScVbaWorkbook::SaveAs( const uno::Any& FileName, const uno::Any& FileFormat, con
uno::Sequence storeProps{ comphelper::makePropertyValue(u"FilterName"_ustr, uno::Any()) };
setFilterPropsFromFormat( nFileFormat, storeProps );
uno::Reference< frame::XStorable > xStor( getModel(), uno::UNO_QUERY_THROW );
rtl::Reference< ScModelObj > xStor( getModel() );
xStor->storeAsURL( sURL, storeProps );
}
@@ -417,7 +416,7 @@ ScVbaWorkbook::getServiceNames()
OUString SAL_CALL
ScVbaWorkbook::getCodeName()
{
uno::Reference< beans::XPropertySet > xModelProp( getModel(), uno::UNO_QUERY_THROW );
rtl::Reference< ScModelObj > xModelProp( getModel() );
return xModelProp->getPropertyValue(u"CodeName"_ustr).get< OUString >();
}
+4 -3
View File
@@ -22,6 +22,7 @@
#include <ooo/vba/excel/XWorkbook.hpp>
#include <cppuhelper/implbase.hxx>
#include <vbahelper/vbadocumentbase.hxx>
#include <docuno.hxx>
typedef cppu::ImplInheritanceHelper< VbaDocumentBase, ov::excel::XWorkbook > ScVbaWorkbook_BASE;
@@ -31,14 +32,14 @@ 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;
rtl::Reference< ScModelObj > mxModel;
protected:
virtual css::uno::Reference< css::frame::XModel > getModel() const override { return mxModel; }
virtual ScModelObj* getModel() const override { return mxModel.get(); }
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 );
rtl::Reference< ScModelObj > const & xModel );
ScVbaWorkbook( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext >const& xContext );
// Attributes
+5 -6
View File
@@ -42,11 +42,10 @@ const sal_Int16 CUSTOM_CHAR = 5;
static uno::Any
getWorkbook( const uno::Reference< uno::XComponentContext >& xContext,
const uno::Reference< sheet::XSpreadsheetDocument > &xDoc,
const rtl::Reference< ScModelObj > &xModel,
const uno::Reference< XHelperInterface >& xParent )
{
// FIXME: fine as long as ScVbaWorkbook is stateless ...
uno::Reference< frame::XModel > xModel( xDoc, uno::UNO_QUERY );
if( !xModel.is() )
return uno::Any();
@@ -71,7 +70,7 @@ public:
virtual uno::Any SAL_CALL nextElement( ) override
{
uno::Reference< sheet::XSpreadsheetDocument > xDoc( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW );
return getWorkbook( m_xContext, xDoc, m_xParent );
return getWorkbook( m_xContext, static_cast<ScModelObj*>(xDoc.get()), m_xParent );
}
};
@@ -102,7 +101,7 @@ uno::Any
ScVbaWorkbooks::createCollectionObject( const css::uno::Any& aSource )
{
uno::Reference< sheet::XSpreadsheetDocument > xDoc( aSource, uno::UNO_QUERY_THROW );
return getWorkbook( mxContext, xDoc, mxParent );
return getWorkbook( mxContext, dynamic_cast<ScModelObj*>(xDoc.get()), mxParent );
}
uno::Any SAL_CALL
@@ -147,7 +146,7 @@ ScVbaWorkbooks::Add( const uno::Any& Template )
if (!xSpreadDoc.is())
return uno::Any();
uno::Any aRet = getWorkbook( mxContext, xSpreadDoc, mxParent );
uno::Any aRet = getWorkbook( mxContext, dynamic_cast<ScModelObj*>(xSpreadDoc.get()), mxParent );
uno::Reference< excel::XWorkbook > xWBook( aRet, uno::UNO_QUERY );
if (xWBook.is())
xWBook->Activate();
@@ -266,7 +265,7 @@ ScVbaWorkbooks::Open( const OUString& rFileName, const uno::Any& /*UpdateLinks*/
throw uno::RuntimeException(u"Bad Format"_ustr );
uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( openDocument( rFileName, ReadOnly, sProps ), uno::UNO_QUERY_THROW );
uno::Any aRet = getWorkbook( mxContext, xSpreadDoc, mxParent );
uno::Any aRet = getWorkbook( mxContext, dynamic_cast<ScModelObj*>(xSpreadDoc.get()), mxParent );
uno::Reference< excel::XWorkbook > xWBook( aRet, uno::UNO_QUERY );
if ( xWBook.is() )
xWBook->Activate();
+23 -30
View File
@@ -1881,8 +1881,8 @@ static bool lcl_CheckInArrayCols(std::vector<uno::Sequence<uno::Any>>& nUniqueRe
rtl::Reference<ScTableSheetObj> ScTabViewShell::GetRangeWithSheet(css::table::CellRangeAddress& rRangeData, bool& bHasData, bool bHasUnoArguments)
{
// get spreadsheet document model & controller
uno::Reference<frame::XModel> xModel(GetViewData().GetDocShell()->GetModel());
uno::Reference<frame::XController> xController(xModel->getCurrentController());
ScModelObj* pModel(GetViewData().GetDocShell()->GetModel());
uno::Reference<frame::XController> xController(pModel->getCurrentController());
// spreadsheet's extension of com.sun.star.frame.Controller service
ScTabViewObj* pSpreadsheetDocument = dynamic_cast<ScTabViewObj*>(xController.get());
@@ -1952,30 +1952,27 @@ void ScTabViewShell::HandleDuplicateRecordsHighlight(const rtl::Reference<ScTabl
return;
}
uno::Reference<frame::XModel> xModel(GetViewData().GetDocShell()->GetModel());
ScModelObj* pModel(GetViewData().GetDocShell()->GetModel());
rtl::Reference<ScCellRangeObj> xSheetRange(
ActiveSheet->getScCellRangeByPosition(aRange.StartColumn, aRange.StartRow, aRange.EndColumn, aRange.EndRow));
uno::Sequence<uno::Sequence<uno::Any>> aDataArray = xSheetRange->getDataArray();
uno::Reference< document::XUndoManagerSupplier > xUndoManager( xModel, uno::UNO_QUERY );
uno::Reference<document::XActionLockable> xLockable(xModel, uno::UNO_QUERY);
ScDocument& rDoc = GetViewData().GetDocShell()->GetDocument();
comphelper::ScopeGuard aUndoContextGuard(
[&xUndoManager, &xLockable, &xModel, &rDoc] {
xUndoManager->getUndoManager()->leaveUndoContext();
xLockable->removeActionLock();
if (xModel->hasControllersLocked())
xModel->unlockControllers();
[pModel, &rDoc] {
pModel->getUndoManager()->leaveUndoContext();
pModel->removeActionLock();
if (pModel->hasControllersLocked())
pModel->unlockControllers();
rDoc.UnlockAdjustHeight();
});
rDoc.LockAdjustHeight();
xModel->lockControllers();
xLockable->addActionLock();
xUndoManager->getUndoManager()->enterUndoContext("HandleDuplicateRecords");
pModel->lockControllers();
pModel->addActionLock();
pModel->getUndoManager()->enterUndoContext("HandleDuplicateRecords");
bool nModifier = false; // modifier key pressed?
bool bNoDuplicatesForSelection = true;
@@ -2052,34 +2049,30 @@ void ScTabViewShell::HandleDuplicateRecordsRemove(const rtl::Reference<ScTableSh
return;
}
uno::Reference<frame::XModel> xModel(GetViewData().GetDocShell()->GetModel());
ScModelObj* pModel(GetViewData().GetDocShell()->GetModel());
rtl::Reference<ScCellRangeObj> xSheetRange(
ActiveSheet->getScCellRangeByPosition(aRange.StartColumn, aRange.StartRow, aRange.EndColumn, aRange.EndRow));
uno::Sequence<uno::Sequence<uno::Any>> aDataArray = xSheetRange->getDataArray();
uno::Reference< document::XUndoManagerSupplier > xUndoManager( xModel, uno::UNO_QUERY );
uno::Reference<document::XActionLockable> xLockable(xModel, uno::UNO_QUERY);
uno::Reference<sheet::XCalculatable> xCalculatable(xModel, uno::UNO_QUERY);
bool bAutoCalc = xCalculatable->isAutomaticCalculationEnabled();
bool bAutoCalc = pModel->isAutomaticCalculationEnabled();
ScDocument& rDoc = GetViewData().GetDocShell()->GetDocument();
comphelper::ScopeGuard aUndoContextGuard(
[&xUndoManager, &xLockable, &xModel, &xCalculatable, &bAutoCalc, &rDoc] {
xUndoManager->getUndoManager()->leaveUndoContext();
xCalculatable->enableAutomaticCalculation(bAutoCalc);
xLockable->removeActionLock();
if (xModel->hasControllersLocked())
xModel->unlockControllers();
[pModel, &bAutoCalc, &rDoc] {
pModel->getUndoManager()->leaveUndoContext();
pModel->enableAutomaticCalculation(bAutoCalc);
pModel->removeActionLock();
if (pModel->hasControllersLocked())
pModel->unlockControllers();
rDoc.UnlockAdjustHeight();
});
rDoc.LockAdjustHeight();
xModel->lockControllers();
xLockable->addActionLock();
xCalculatable->enableAutomaticCalculation(true);
xUndoManager->getUndoManager()->enterUndoContext("HandleDuplicateRecords");
pModel->lockControllers();
pModel->addActionLock();
pModel->enableAutomaticCalculation(true);
pModel->getUndoManager()->enterUndoContext("HandleDuplicateRecords");
if (bDuplicateRows)
{
+2 -2
View File
@@ -490,10 +490,10 @@ SwVbaApplication::getServiceNames()
return aServiceNames;
}
uno::Reference< frame::XModel >
SfxBaseModel*
SwVbaApplication::getCurrentDocument()
{
return static_cast<SfxBaseModel*>(getCurrentWordDoc( mxContext ).get());
return getCurrentWordDoc( mxContext ).get();
}
rtl::Reference< SwXTextDocument >
+3 -1
View File
@@ -32,6 +32,7 @@
#include <vbahelper/vbaapplicationbase.hxx>
#include <cppuhelper/implbase.hxx>
#include <rtl/ref.hxx>
#include <sfx2/sfxbasemodel.hxx>
#include "vbawindow.hxx"
@@ -124,7 +125,8 @@ public:
// XSinkCaller
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;
// this should be SwXTextDocument, but the inheritance hierarchy makes that impossoble
virtual SfxBaseModel* getCurrentDocument() override;
rtl::Reference<SwXTextDocument> getCurrentSwDocument();
};
+7 -15
View File
@@ -221,8 +221,7 @@ SwVbaDocument::CustomDocumentProperties( const uno::Any& index )
uno::Any SAL_CALL
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<container::XIndexAccess > xBookmarks( mxTextDocument->getBookmarks(), uno::UNO_QUERY_THROW );
uno::Reference< XCollection > xBookmarksVba( new SwVbaBookmarks( this, mxContext, xBookmarks, mxTextDocument ) );
if ( rIndex.getValueTypeClass() == uno::TypeClass_VOID )
return uno::Any( xBookmarksVba );
@@ -230,7 +229,7 @@ SwVbaDocument::Bookmarks( const uno::Any& rIndex )
return xBookmarksVba->Item( rIndex, uno::Any() );
}
uno::Reference< frame::XModel > SwVbaDocument::getModel() const
SfxBaseModel* SwVbaDocument::getModel() const
{ return static_cast<SfxBaseModel*>(mxTextDocument.get()); }
uno::Any SwVbaDocument::ContentControls(const uno::Any& index)
@@ -286,8 +285,7 @@ uno::Reference<word::XWindow> SwVbaDocument::getActiveWindow()
uno::Any SAL_CALL
SwVbaDocument::Variables( const uno::Any& rIndex )
{
uno::Reference< css::document::XDocumentPropertiesSupplier > xDocumentPropertiesSupplier( getModel(),uno::UNO_QUERY_THROW );
uno::Reference< css::document::XDocumentProperties > xDocumentProperties = xDocumentPropertiesSupplier->getDocumentProperties();
uno::Reference< css::document::XDocumentProperties > xDocumentProperties = mxTextDocument->getDocumentProperties();
uno::Reference< beans::XPropertyAccess > xUserDefined( xDocumentProperties->getUserDefinedProperties(), uno::UNO_QUERY_THROW );
uno::Reference< XCollection > xVariables( new SwVbaVariables( this, mxContext, xUserDefined ) );
@@ -386,9 +384,7 @@ uno::Any SAL_CALL
SwVbaDocument::getAttachedTemplate()
{
uno::Reference< word::XTemplate > xTemplate;
uno::Reference<css::document::XDocumentPropertiesSupplier> const xDocPropSupp(
getModel(), uno::UNO_QUERY_THROW);
uno::Reference< css::document::XDocumentProperties > xDocProps( xDocPropSupp->getDocumentProperties(), uno::UNO_SET_THROW );
uno::Reference< css::document::XDocumentProperties > xDocProps( mxTextDocument->getDocumentProperties(), uno::UNO_SET_THROW );
xTemplate = new SwVbaTemplate( this, mxContext, xDocProps->getTemplateURL() );
return uno::Any( xTemplate );
@@ -411,9 +407,7 @@ SwVbaDocument::setAttachedTemplate( const css::uno::Any& _attachedtemplate )
else
osl::FileBase::getFileURLFromSystemPath( sTemplate, aURL );
uno::Reference<css::document::XDocumentPropertiesSupplier> const xDocPropSupp(
getModel(), uno::UNO_QUERY_THROW );
uno::Reference< css::document::XDocumentProperties > xDocProps( xDocPropSupp->getDocumentProperties(), uno::UNO_SET_THROW );
uno::Reference< css::document::XDocumentProperties > xDocProps( mxTextDocument->getDocumentProperties(), uno::UNO_SET_THROW );
xDocProps->setTemplateURL( aURL );
}
@@ -595,8 +589,7 @@ SwVbaDocument::SaveAs2000( const uno::Any& FileName, const uno::Any& FileFormat,
setFilterPropsFromFormat( nFileFormat, storeProps );
uno::Reference< frame::XStorable > xStor( getModel(), uno::UNO_QUERY_THROW );
xStor->storeAsURL( sURL, storeProps );
mxTextDocument->storeAsURL( sURL, storeProps );
}
void SAL_CALL
@@ -622,8 +615,7 @@ SwVbaDocument::SavePreviewPngAs( const uno::Any& FileName )
uno::Sequence storeProps{ comphelper::makePropertyValue(u"FilterName"_ustr,
u"writer_png_Export"_ustr) };
uno::Reference< frame::XStorable > xStor( getModel(), uno::UNO_QUERY_THROW );
xStor->storeToURL( sURL, storeProps );
mxTextDocument->storeToURL( sURL, storeProps );
}
uno::Any
+3 -1
View File
@@ -26,6 +26,7 @@
#include <com/sun/star/text/XTextDocument.hpp>
#include <cppuhelper/implbase.hxx>
#include <rtl/ref.hxx>
#include <sfx2/sfxbasemodel.hxx>
#include <vector>
@@ -45,7 +46,8 @@ private:
css::uno::Reference< css::container::XNameAccess > getFormControls() const;
protected:
virtual css::uno::Reference< css::frame::XModel > getModel() const override;
// this should be SwXTextDocument, but the inheritance hierarchy makes that impossoble
virtual SfxBaseModel* getModel() const override;
public:
SwVbaDocument( const css::uno::Reference< ooo::vba::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& m_xContext, rtl::Reference< SwXTextDocument > const & xModel );
@@ -419,7 +419,7 @@ uno::Any SAL_CALL VbaApplicationBase::getVBE()
try // return empty object on error
{
// "VBE" object does not have a parent, but pass document model to be able to determine application type
uno::Sequence< uno::Any > aArgs{ uno::Any(getCurrentDocument()) };
uno::Sequence< uno::Any > aArgs{ uno::Any(uno::Reference(getCurrentDocument())) };
uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_SET_THROW );
uno::Reference< uno::XInterface > xVBE = xServiceManager->createInstanceWithArgumentsAndContext(
u"ooo.vba.vbide.VBE"_ustr , aArgs, mxContext );
@@ -290,7 +290,7 @@ VbaDocumentBase::getVBProject()
if (xVBE)
{
uno::Sequence< uno::Any > aArgs{ uno::Any(xVBE), // the VBE
uno::Any(getModel()) }; // document model for script container access
uno::Any(uno::Reference(getModel())) }; // document model for script container access
uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager() );
if (xServiceManager)
mxVBProject = xServiceManager->createInstanceWithArgumentsAndContext(