21#include <com/sun/star/awt/XControlModel.hpp>
22#include <com/sun/star/embed/XClassifiedObject.hpp>
23#include <com/sun/star/embed/XEmbeddedObject.hpp>
24#include <com/sun/star/form/XFormsSupplier.hpp>
25#include <com/sun/star/script/XEventAttacherManager.hpp>
26#include <com/sun/star/beans/XPropertySet.hpp>
52using ::com::sun::star::uno::Any;
53using ::com::sun::star::uno::Exception;
54using ::com::sun::star::uno::Reference;
55using ::com::sun::star::uno::Sequence;
56using ::com::sun::star::uno::UNO_QUERY;
57using ::com::sun::star::uno::UNO_QUERY_THROW;
58using ::com::sun::star::container::XIndexAccess;
59using ::com::sun::star::embed::XClassifiedObject;
60using ::com::sun::star::drawing::XShape;
61using ::com::sun::star::awt::XControlModel;
62using ::com::sun::star::beans::XPropertySet;
63using ::com::sun::star::uno::Any;
64using ::com::sun::star::form::XFormsSupplier;
65using ::com::sun::star::io::XOutputStream;
66using ::com::sun::star::script::ScriptEventDescriptor;
67using ::com::sun::star::script::XEventAttacherManager;
88 pCurrXclObj( nullptr ),
90 pAdditionalText( nullptr ),
93 mbIsRootDff( pParent == nullptr )
100 OSL_ENSURE(
aStack.empty(),
"~XclEscherEx: stack not empty" );
162bool lcl_IsFontwork(
const SdrObject* pObj )
164 bool bIsFontwork =
false;
167 static constexpr OUStringLiteral aTextPath =
u"TextPath";
171 *pAny >>= bIsFontwork;
195 sal_Int16 nMsCtlType = 0;
203 if( nObjType == SdrObjKind::OLE2 )
209 Reference < XClassifiedObject > xObj(
static_cast<SdrOle2Obj*
>(pObj)->GetObjRef() );
227 else if( nObjType == SdrObjKind::UNO )
230 Reference< XPropertySet > xPropSet( rxShape, UNO_QUERY );
234 aAny = xPropSet->getPropertyValue(
"ControlTypeinMSO");
239 SAL_WARN(
"sc",
"XclEscherEx::StartShape, this control can't get the property ControlTypeinMSO!");
241 if( nMsCtlType == 2 )
279 if( pTextObj && !lcl_IsFontwork( pTextObj ) && (pObj->
GetObjIdentifier() != SdrObjKind::Caption) )
312 Reference< XPropertySet > xPropSet( rxShape, UNO_QUERY );
316 aAny = xPropSet->getPropertyValue(
"ObjIDinMSO");
320 SAL_WARN(
"sc",
"XclEscherEx::StartShape, this control can't get the property ObjIDinMSO!");
322 sal_uInt16 nObjIDinMSO = 0xFFFF;
323 aAny >>= nObjIDinMSO;
324 if( nObjIDinMSO != 0xFFFF && nMsCtlType == 2)
347 OSL_ENSURE( pLastObj.get() ==
pCurrXclObj,
"XclEscherEx::EndShape - wrong object" );
400 ::std::unique_ptr< XclExpOcxControlObj > xOcxCtrl;
403 if( xCtrlModel.is() )
411 sal_uInt32 nStrmStart =
static_cast< sal_uInt32
>(
mxCtlsStrm->Tell() );
418 sal_uInt32 nStrmSize =
static_cast< sal_uInt32
>(
mxCtlsStrm->Tell() - nStrmStart );
420 aClassName =
"Forms." + aClassName +
".1";
445 if( !(xCtrlModel.is() &&
GetDocShell() && pSdrPage) )
450 Reference< XFormsSupplier > xFormsSupplier( pSdrPage->
getUnoPage(), UNO_QUERY_THROW );
451 Reference< XIndexAccess > xFormsIA( xFormsSupplier->getForms(), UNO_QUERY_THROW );
455 Reference< XIndexAccess > xFormIA;
456 sal_Int32 nFoundIdx = -1;
459 for( sal_Int32 nFormIdx = 0, nFormCount = xFormsIA->getCount();
460 (nFoundIdx < 0) && (nFormIdx < nFormCount); ++nFormIdx )
463 if( xFormIA.set( xFormsIA->getByIndex( nFormIdx ), UNO_QUERY ) )
466 for( sal_Int32 nCtrlIdx = 0, nCtrlCount = xFormIA->getCount();
467 (nFoundIdx < 0) && (nCtrlIdx < nCtrlCount); ++nCtrlIdx )
470 Reference< XControlModel > xCurrModel( xFormIA->getByIndex( nCtrlIdx ), UNO_QUERY );
471 if( xCtrlModel.get() == xCurrModel.get() )
472 nFoundIdx = nCtrlIdx;
479 if( xFormIA.is() && (nFoundIdx >= 0) )
481 Reference< XEventAttacherManager > xEventMgr( xFormIA, UNO_QUERY_THROW );
483 const Sequence< ScriptEventDescriptor > aEventSeq( xEventMgr->getScriptEvents( nFoundIdx ) );
484 for(
const auto& rEvent : aEventSeq )
538 const Reference<XShape>& xShape,
551 sMacro = pInfo->GetMacro();
553 if (!sHyperLink.isEmpty())
559 aUrlField.
SetURL(sHyperLink);
563 if (!sHyperLink.isEmpty() || !sMacro.isEmpty())
SvStream * GetPictureStream()
void SetInteractionInfo(InteractionInfo *p)
sal_uInt32 GetPersistOffset(sal_uInt32 nKey)
void AddAtom(sal_uInt32 nAtomSitze, sal_uInt16 nRecType, int nRecVersion=0, int nRecInstance=0)
void Flush(SvStream *pPicStreamMergeBSE=nullptr)
sal_uInt64 GetStreamPos() const
void ReplacePersistOffset(sal_uInt32 nKey, sal_uInt32 nOffset)
void InsertPersistOffset(sal_uInt32 nKey, sal_uInt32 nOffset)
void SetBaseURI(const OUString &rBaseURI)
static bool IsNoteCaption(SdrObject *pObj)
Returns true, if the passed object is the caption of a cell note.
static ScMacroInfo * GetMacroInfo(SdrObject *pObj, bool bCreate=false)
css::uno::Any * GetPropertyValueByName(const OUString &rPropName)
static SdrObject * getSdrObjectFromXShape(const css::uno::Reference< css::uno::XInterface > &xInt)
const SfxPoolItem & GetMergedItem(const sal_uInt16 nWhich) const
const OUString & getHyperlink() const
virtual SdrObjKind GetObjIdentifier() const
css::uno::Reference< css::uno::XInterface > const & getUnoPage()
virtual OutlinerParaObject * GetOutlinerParaObject() const override
static void PopulateShapeInteractionInfo(const XclExpObjectManager &rObjMgr, const css::uno::Reference< css::drawing::XShape > &xShape, EscherExHostAppData &rHostAppData)
static XclExpShapeObj * CreateShapeObj(XclExpObjectManager &rObjMgr, const css::uno::Reference< css::drawing::XShape > &xShape, ScDocument *pDoc)
static sal_uInt16 IsChart(const SvGlobalName &rName)
void SetEndian(SvStreamEndian SvStreamEndian)
sal_uInt64 Seek(sal_uInt64 nPos)
void SetURL(const OUString &rURL)
static css::uno::Reference< css::awt::XControlModel > GetControlModel(css::uno::Reference< css::drawing::XShape > const &xShape)
Returns the API control model from the passed API shape object.
virtual void WriteData(EscherEx &rEx) const override
virtual void WriteData(EscherEx &rEx) const override
void SetXclObj(XclObj *p)
ONLY for the AdditionalText mimic.
XclEscherClientTextbox(const XclExpRoot &rRoot, const SdrTextObj &rObj, XclObj *pObj)
const SdrTextObj & rTextObj
virtual SvStream * ImplQueryPictureStream() override
Override to create a new temporary file and return its stream.
::std::optional< ::utl::TempFileFast > moPicTempFile
XclEscherExGlobal(const XclExpRoot &rRoot)
bool HasPendingDffData()
Returns true, if there is more data left in the DFF stream than owned by the last MSODRAWING record.
std::unique_ptr< XclEscherClientData > pTheClientData
virtual void EndShape(sal_uInt16 nShapeType, sal_uInt32 nShapeID) override
XclEscherEx(const XclExpRoot &rRoot, XclExpObjectManager &rObjMgr, SvStream &rStrm, const XclEscherEx *pParent=nullptr)
sal_uInt32 InitNextDffFragment()
Called by MSODRAWING record constructors to initialize the DFF stream fragment they will own.
std::unique_ptr< XclEscherHostAppData > pCurrAppData
std::unique_ptr< XclExpOcxControlObj > CreateOCXCtrlObj(css::uno::Reference< css::drawing::XShape > const &xShape, const tools::Rectangle *pChildAnchor)
Creates an OCX form control OBJ record from the passed form control.
virtual ~XclEscherEx() override
sal_uInt32 GetDffFragmentPos(sal_uInt32 nFragmentKey)
Returns the position of the specified DFF stream fragment.
std::stack< std::pair< XclObj *, std::unique_ptr< XclEscherHostAppData > > > aStack
sal_uInt32 GetDffFragmentSize(sal_uInt32 nFragmentKey)
Returns the size of the specified DFF stream fragment.
virtual EscherExHostAppData * StartShape(const css::uno::Reference< css::drawing::XShape > &rxShape, const tools::Rectangle *pChildAnchor) override
void EndDocument()
Flush and merge PicStream into EscherStream.
void UpdateDffFragmentEnd()
Called after some data has been written to the DFF stream, to update the end position of the DFF frag...
std::unique_ptr< XclExpTbxControlObj > CreateTBXCtrlObj(css::uno::Reference< css::drawing::XShape > const &xShape, const tools::Rectangle *pChildAnchor)
The 'Ctls' stream.
XclExpObjectManager & mrObjMgr
sal_uInt16 nAdditionalText
XclEscherClientTextbox * pAdditionalText
void ConvertTbxMacro(XclExpTbxControlObj &rTbxCtrlObj, css::uno::Reference< css::awt::XControlModel > const &xCtrlModel)
Tries to get the name of a Basic macro from a control.
XclExpDffAnchorBase * CreateDffAnchor(const SdrObject &rSdrObj) const
Creates a new DFF client anchor object and calculates the anchor position of the passed object.
tools::SvRef< SotStorageStream > mxCtlsStrm
virtual EscherExHostAppData * EnterAdditionalTextGroup() override
Base class for DFF client anchor atoms used in spreadsheets.
void SetFlags(const SdrObject &rSdrObj)
Sets the flags according to the passed SdrObject.
void SetSdrObject(const SdrObject &rSdrObj)
Sets the anchor position and flags according to the passed SdrObject.
Provides export of hyperlink data.
void WriteEmbeddedData(XclExpStream &rStrm)
virtual XclExpDffAnchorBase * CreateDffAnchor() const
Creates a new DFF client anchor object.
sal_uInt16 AddObj(std::unique_ptr< XclObj > pObjRec)
std::unique_ptr< XclObj > RemoveLastObj()
Represents an OBJ record for an OCX form control.
Access to global data from other classes.
const XclExpRoot & GetRoot() const
Returns this root instance - for code readability in derived classes.
This class is used to export Excel record streams.
Represents an OBJ record for a TBX form control.
bool SetMacroLink(const css::script::ScriptEventDescriptor &rEvent)
Sets the name of a macro attached to this control.
void SetEscherShapeTypeGroup()
void SetId(sal_uInt16 nId)
void SetEscherShapeType(sal_uInt16 nType)
bool IsOwnEscher() const
If set to true, this object has created its own escher data.
void SetText(const XclExpRoot &rRoot, const SdrTextObj &rObj)
actually writes ESCHER_ClientTextbox
SfxObjectShell * GetDocShell() const
Returns the object shell of the Calc document.
SfxMedium & GetMedium() const
Returns the medium to import from.
tools::SvRef< SotStorageStream > OpenStream(tools::SvRef< SotStorage > const &xStrg, const OUString &rStrmName) const
Tries to open a new stream in the specified storage for reading or writing.
SCTAB GetCurrScTab() const
Returns the current Calc sheet index.
ScDocument & GetDoc() const
Returns reference to the destination document (import) or source document (export).
SdrPage * GetSdrPage(SCTAB nScTab) const
Returns the drawing layer page of the passed sheet, if present.
static bool WriteOCXExcelKludgeStream(const css::uno::Reference< css::frame::XModel > &rxModel, const css::uno::Reference< css::io::XOutputStream > &xOutStrm, const css::uno::Reference< css::awt::XControlModel > &rControlModel, const css::awt::Size &rSize, OUString &rName)
#define ESCHER_ClientData
#define SAL_WARN(area, stream)
std::shared_ptr< T > make_shared(Args &&... args)
Reference< XModel > xModel
SVXCORE_DLLPUBLIC SdrTextObj * DynCastSdrTextObj(SdrObject *)
constexpr OUStringLiteral EXC_STREAM_CTLS
const sal_uInt16 EXC_OBJTYPE_UNKNOWN