summaryrefslogtreecommitdiffstats
path: root/sc
diff options
context:
space:
mode:
Diffstat (limited to 'sc')
-rw-r--r--sc/source/filter/excel/xiescher.cxx36
-rw-r--r--sc/source/filter/inc/xiescher.hxx11
-rw-r--r--sc/source/ui/vba/vbasheetobject.cxx13
-rw-r--r--sc/source/ui/vba/vbasheetobject.hxx4
4 files changed, 56 insertions, 8 deletions
diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx
index 43c6fb3aa788..1c90ef7a2847 100644
--- a/sc/source/filter/excel/xiescher.cxx
+++ b/sc/source/filter/excel/xiescher.cxx
@@ -47,6 +47,7 @@
#include <vcl/dibtools.hxx>
#include <vcl/wmf.hxx>
#include <comphelper/classids.hxx>
+#include <comphelper/documentinfo.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <basegfx/point/b2dpoint.hxx>
#include <basegfx/polygon/b2dpolygon.hxx>
@@ -170,7 +171,8 @@ XclImpDrawObjBase::XclImpDrawObjBase( const XclImpRoot& rRoot ) :
mbSimpleMacro( true ),
mbProcessSdr( true ),
mbInsertSdr( true ),
- mbCustomDff( false )
+ mbCustomDff( false ),
+ mbNotifyMacroEventRead( false )
{
}
@@ -506,7 +508,18 @@ SdrObjectUniquePtr XclImpDrawObjBase::CreateSdrObject( XclImpDffConverter& rDffC
return xSdrObj;
}
-void XclImpDrawObjBase::PreProcessSdrObject( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const
+void XclImpDrawObjBase::NotifyMacroEventRead()
+{
+ if (mbNotifyMacroEventRead)
+ return;
+ SfxObjectShell* pDocShell = GetDocShell();
+ if (!pDocShell)
+ return;
+ comphelper::DocumentInfo::notifyMacroEventRead(pDocShell->GetModel());
+ mbNotifyMacroEventRead = true;
+}
+
+void XclImpDrawObjBase::PreProcessSdrObject( XclImpDffConverter& rDffConv, SdrObject& rSdrObj )
{
// default: front layer, derived classes may have to set other layer in DoPreProcessSdrObj()
rSdrObj.NbcSetLayer( SC_LAYER_FRONT );
@@ -533,7 +546,10 @@ void XclImpDrawObjBase::PreProcessSdrObject( XclImpDffConverter& rDffConv, SdrOb
{
if( ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( &rSdrObj, true ) )
{
- pInfo->SetMacro( XclTools::GetSbMacroUrl( maMacroName, GetDocShell() ) );
+ OUString sMacro = XclTools::GetSbMacroUrl(maMacroName, GetDocShell());
+ if (!sMacro.isEmpty())
+ NotifyMacroEventRead();
+ pInfo->SetMacro(sMacro);
pInfo->SetHlink( maHyperlink );
}
}
@@ -3282,7 +3298,8 @@ static const OUStringLiteral gaStdFormName( "Standard" ); /// Standard name of c
XclImpDffConverter::XclImpDffConverter( const XclImpRoot& rRoot, SvStream& rDffStrm ) :
XclImpSimpleDffConverter( rRoot, rDffStrm ),
oox::ole::MSConvertOCXControls( rRoot.GetDocShell()->GetModel() ),
- mnOleImpFlags( 0 )
+ mnOleImpFlags( 0 ),
+ mbNotifyMacroEventRead(false)
{
const SvtFilterOptions& rFilterOpt = SvtFilterOptions::Get();
if( rFilterOpt.IsMathType2Math() )
@@ -3339,7 +3356,7 @@ void XclImpDffConverter::InitializeDrawing( XclImpDrawing& rDrawing, SdrModel& r
SetModel( &xConvData->mrSdrModel, 1440 );
}
-void XclImpDffConverter::ProcessObject( SdrObjList& rObjList, const XclImpDrawObjBase& rDrawObj )
+void XclImpDffConverter::ProcessObject( SdrObjList& rObjList, XclImpDrawObjBase& rDrawObj )
{
if( rDrawObj.IsProcessSdrObj() )
{
@@ -3388,6 +3405,14 @@ void XclImpDffConverter::FinalizeDrawing()
SetModel( &maDataStack.back()->mrSdrModel, 1440 );
}
+void XclImpDffConverter::NotifyMacroEventRead()
+{
+ if (mbNotifyMacroEventRead)
+ return;
+ comphelper::DocumentInfo::notifyMacroEventRead(mxModel);
+ mbNotifyMacroEventRead = true;
+}
+
SdrObjectUniquePtr XclImpDffConverter::CreateSdrObject( const XclImpTbxObjBase& rTbxObj, const tools::Rectangle& rAnchorRect )
{
SdrObjectUniquePtr xSdrObj;
@@ -3410,6 +3435,7 @@ SdrObjectUniquePtr XclImpDffConverter::CreateSdrObject( const XclImpTbxObjBase&
ScriptEventDescriptor aDescriptor;
if( (rConvData.mnLastCtrlIndex >= 0) && rTbxObj.FillMacroDescriptor( aDescriptor ) )
{
+ NotifyMacroEventRead();
Reference< XEventAttacherManager > xEventMgr( rConvData.mxCtrlForm, UNO_QUERY_THROW );
xEventMgr->registerScriptEvent( rConvData.mnLastCtrlIndex, aDescriptor );
}
diff --git a/sc/source/filter/inc/xiescher.hxx b/sc/source/filter/inc/xiescher.hxx
index f9e8d007724e..37f457920d57 100644
--- a/sc/source/filter/inc/xiescher.hxx
+++ b/sc/source/filter/inc/xiescher.hxx
@@ -125,7 +125,7 @@ public:
SdrObjectUniquePtr CreateSdrObject( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect, bool bIsDff ) const;
/** Additional processing for the passed SdrObject before insertion into
the drawing page (calls virtual DoPreProcessSdrObj() function). */
- void PreProcessSdrObject( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
+ void PreProcessSdrObject( XclImpDffConverter& rDffConv, SdrObject& rSdrObj );
/** Additional processing for the passed SdrObject after insertion into the
drawing page (calls virtual DoPostProcessSdrObj() function). */
void PostProcessSdrObject( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
@@ -172,6 +172,9 @@ protected:
virtual void DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
/** Derived classes may perform additional processing for the passed SdrObject after insertion. */
virtual void DoPostProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
+
+ /** Notify that the document contains a macro event handler */
+ void NotifyMacroEventRead();
private:
/** Reads the contents of a BIFF3 OBJ record. */
void ImplReadObj3( XclImpStream& rStrm );
@@ -202,6 +205,7 @@ private:
bool mbProcessSdr; /// true = Object is valid, do processing and insertion.
bool mbInsertSdr; /// true = Insert the SdrObject into draw page.
bool mbCustomDff; /// true = Recreate SdrObject in DFF import.
+ bool mbNotifyMacroEventRead; /// true == If we have already seen a macro event
};
class XclImpDrawObjVector
@@ -928,7 +932,7 @@ public:
/** Initially called before the objects of the passed drawing manager are converted. */
void InitializeDrawing( XclImpDrawing& rDrawing, SdrModel& rSdrModel, SdrPage& rSdrPage );
/** Processes BIFF5 drawing objects without DFF data, inserts into the passed object list. */
- void ProcessObject( SdrObjList& rObjList, const XclImpDrawObjBase& rDrawObj );
+ void ProcessObject( SdrObjList& rObjList, XclImpDrawObjBase& rDrawObj );
/** Processes all objects in the passed list. */
void ProcessDrawing( const XclImpDrawObjVector& rDrawObjs );
/** Processes a drawing container in the passed DFF stream, converts all objects. */
@@ -1017,6 +1021,8 @@ private:
void InsertSdrObject( SdrObjList& rObjList, const XclImpDrawObjBase& rDrawObj, SdrObject* pSdrObj );
/** Initializes the mxCtrlForm referring to the standard controls form. */
void InitControlForm();
+ /** Notify that this document contains a macro event handler */
+ void NotifyMacroEventRead();
private:
typedef std::shared_ptr< ScfProgressBar > ScfProgressBarRef;
@@ -1028,6 +1034,7 @@ private:
XclImpDffConvDataStack maDataStack; /// Stack for registered drawing managers.
sal_uInt32 mnOleImpFlags; /// Application OLE import settings.
sal_Int32 mnDefTextMargin; /// Default margin in text boxes.
+ bool mbNotifyMacroEventRead; /// If we have already seen a macro event
};
// Drawing manager ============================================================
diff --git a/sc/source/ui/vba/vbasheetobject.cxx b/sc/source/ui/vba/vbasheetobject.cxx
index 28d55a14c4e5..56903e24b468 100644
--- a/sc/source/ui/vba/vbasheetobject.cxx
+++ b/sc/source/ui/vba/vbasheetobject.cxx
@@ -25,6 +25,7 @@
#include <com/sun/star/script/ScriptEventDescriptor.hpp>
#include <com/sun/star/script/XEventAttacherManager.hpp>
#include <com/sun/star/style/VerticalAlignment.hpp>
+#include <comphelper/documentinfo.hxx>
#include <ooo/vba/excel/Constants.hpp>
#include <ooo/vba/excel/XlOrientation.hpp>
#include <ooo/vba/excel/XlPlacement.hpp>
@@ -300,7 +301,8 @@ ScVbaControlObjectBase::ScVbaControlObjectBase(
const uno::Reference< drawing::XControlShape >& rxControlShape ) :
ScVbaControlObject_BASE( rxParent, rxContext, rxModel, uno::Reference< drawing::XShape >( rxControlShape, uno::UNO_QUERY_THROW ) ),
mxFormIC( rxFormIC, uno::UNO_SET_THROW ),
- mxControlProps( rxControlShape->getControl(), uno::UNO_QUERY_THROW )
+ mxControlProps( rxControlShape->getControl(), uno::UNO_QUERY_THROW ),
+ mbNotifyMacroEventRead(false)
{
}
@@ -333,6 +335,14 @@ OUString SAL_CALL ScVbaControlObjectBase::getOnAction()
return OUString();
}
+void ScVbaControlObjectBase::NotifyMacroEventRead()
+{
+ if (mbNotifyMacroEventRead)
+ return;
+ comphelper::DocumentInfo::notifyMacroEventRead(mxModel);
+ mbNotifyMacroEventRead = true;
+}
+
void SAL_CALL ScVbaControlObjectBase::setOnAction( const OUString& rMacroName )
{
uno::Reference< script::XEventAttacherManager > xEventMgr( mxFormIC, uno::UNO_QUERY_THROW );
@@ -352,6 +362,7 @@ void SAL_CALL ScVbaControlObjectBase::setOnAction( const OUString& rMacroName )
aDescriptor.EventMethod = gaEventMethod;
aDescriptor.ScriptType = "Script";
aDescriptor.ScriptCode = makeMacroURL( aResolvedMacro.msResolvedMacro );
+ NotifyMacroEventRead();
xEventMgr->registerScriptEvent( nIndex, aDescriptor );
}
}
diff --git a/sc/source/ui/vba/vbasheetobject.hxx b/sc/source/ui/vba/vbasheetobject.hxx
index e53418ab0481..94d88fbb416b 100644
--- a/sc/source/ui/vba/vbasheetobject.hxx
+++ b/sc/source/ui/vba/vbasheetobject.hxx
@@ -153,6 +153,9 @@ public:
virtual sal_Bool SAL_CALL getAutoSize() override;
virtual void SAL_CALL setAutoSize( sal_Bool bAutoSize ) override;
+ /// Notify that the document contains a macro event handler
+ void NotifyMacroEventRead();
+
protected:
/// @throws css::uno::RuntimeException
sal_Int32 getModelIndexInForm() const;
@@ -160,6 +163,7 @@ protected:
protected:
css::uno::Reference< css::container::XIndexContainer > mxFormIC;
css::uno::Reference< css::beans::XPropertySet > mxControlProps;
+ bool mbNotifyMacroEventRead;
};
typedef ::cppu::ImplInheritanceHelper< ScVbaControlObjectBase, ov::excel::XButton > ScVbaButton_BASE;