20#include <config_features.h>
23#include <osl/diagnose.h>
31#include <com/sun/star/document/XEventsSupplier.hpp>
32#include <com/sun/star/uno/Reference.hxx>
33#include <com/sun/star/script/XLibraryContainer.hpp>
34#include <com/sun/star/container/XNameContainer.hpp>
55 {
nullptr,
nullptr, SvMacroItemId::NONE }
72 bool bInsIntoBasic =
false,
73 bInsSrcIntoField =
false;
77 case HTMLScriptLanguage::StarBasic:
81 bInsSrcIntoField =
true;
102 bInsIntoBasic && IsNewDoc() )
114 aLibName =
"Standard";
117 Reference< script::XLibraryContainer > xModLibContainer = pDocSh->
GetBasicContainer();
119 if ( xModLibContainer.is() )
121 Reference< container::XNameContainer > xModLib;
122 if ( xModLibContainer->hasByName( aLibName ) )
125 Any aElement = xModLibContainer->getByName( aLibName );
126 aElement >>= xModLib;
131 xModLib = xModLibContainer->createLibrary( aLibName );
149 if ( !xModLib->hasByName( aModName ) )
153 xModLib->insertByName( aModName , aElement );
159 Reference< script::XLibraryContainer > xDlgLibContainer = pDocSh->
GetDialogContainer();
161 if ( xDlgLibContainer.is() )
163 if ( !xDlgLibContainer->hasByName( aLibName ) )
166 xDlgLibContainer->createLibrary( aLibName );
182 if( aToken.getLength() > 2 &&
183 (HTMLScriptLanguage::StarBasic==
m_eScriptLang && aToken[ 0 ] ==
'\'') )
228 const OUString& rScrType )
230 OSL_ENSURE( !rName.isEmpty(),
"InsertBasicDocEvent() called without macro" );
231 if( rName.isEmpty() )
235 OSL_ENSURE( pDocSh,
"Where is the DocShell?" );
240 OUString sScriptType;
242 sScriptType = rScrType;
250#if !HAVE_FEATURE_SCRIPTING
257 OSL_ENSURE( pBasicMan,
"Where is the Basic-Manager?" );
269 const OUString& rLibName = pBasic->
GetName();
270 for(
const auto& pModule: pBasic->
GetModules() )
291 const OUString& rModName = pModule->GetName();
295 &rLibName, &rModName );
303 "OnLoad",
"OnPrepareUnload",
"OnFocus",
"OnUnfocus"
314 uno::Reference< document::XEventsSupplier > xSup( pDocSh->
GetModel(), uno::UNO_QUERY );
315 uno::Reference < container::XNameReplace > xEvents = xSup->getEvents();
316 for ( sal_Int32
i=0;
i<4;
i++ )
325 if( !aDocTable.
empty() )
StarBASIC * GetLib(sal_uInt16 nLib) const
sal_uInt16 GetLibCount() const
const OUString & GetName(SbxNameType=SbxNameType::NONE) const
static BasicManager * GetBasicManager()
static void ConfigureEvent(const OUString &aName, const SvxMacro &, SfxObjectShell const *pObjSh)
static std::unique_ptr< SvxMacro > ConvertToMacro(const css::uno::Any &rElement, SfxObjectShell *pDoc)
css::uno::Reference< css::script::XLibraryContainer > GetBasicContainer()
BasicManager * GetBasicManager() const
css::uno::Reference< css::script::XLibraryContainer > GetDialogContainer()
css::uno::Reference< css::frame::XModel3 > GetModel() const
SvStream & WriteOString(std::string_view rStr)
SvxMacro & Insert(SvMacroItemId nEvent, const SvxMacro &rMacro)
SwDocShell * GetDocShell()
void InsertAttr(const SfxPoolItem &rItem, bool bInsAtStart)
sal_uInt16 m_nSBModuleCnt
bool m_bIgnoreHTMLComments
rtl::Reference< SwDoc > m_xDoc
HTMLScriptLanguage m_eScriptLang
void InsertBasicDocEvent(const OUString &aEventName, const OUString &rName, ScriptType eScrType, const OUString &rScrType)
void OutBasic(const SwHTMLWriter &rHTMLWrt)
OString GetNamespace() const
Determines the prefix string needed to respect the requested namespace alias.
void OutBasicBodyEvents()
void OutNewLine(bool bCheck=false)
const OUString & GetBaseURL() const
#define SAL_NEWLINE_STRING
HTMLOutEvent const aBodyEventTable[]
static const char * aEventNames[]
#define OOO_STRING_SVTOOLS_HTML_O_httpequiv
#define OOO_STRING_SVTOOLS_HTML_meta
#define OOO_STRING_SVTOOLS_HTML_O_SDonunload
#define OOO_STRING_SVTOOLS_HTML_O_onunload
#define OOO_STRING_SVTOOLS_HTML_O_onfocus
#define OOO_STRING_SVTOOLS_HTML_O_SDonfocus
#define OOO_STRING_SVTOOLS_HTML_O_SDonblur
#define OOO_STRING_SVTOOLS_HTML_O_SDonload
#define OOO_STRING_SVTOOLS_HTML_META_content_script_type
#define OOO_STRING_SVTOOLS_HTML_O_content
#define OOO_STRING_SVTOOLS_HTML_O_onblur
#define OOO_STRING_SVTOOLS_HTML_SB_module
#define OOO_STRING_SVTOOLS_HTML_O_onload
#define OOO_STRING_SVTOOLS_HTML_SB_library
LineEnd GetSystemLineEnd()
TOOLS_DLLPUBLIC OString convertLineEnd(const OString &rIn, LineEnd eLineEnd)
constexpr OUStringLiteral SVX_MACRO_LANGUAGE_STARBASIC
OString strip(const OString &rIn, char c)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
static SVT_DLLPUBLIC SvStream & OutScript(SvStream &rStrm, const OUString &rBaseURL, std::u16string_view rSource, const OUString &rLanguage, ScriptType eScriptType, const OUString &rSrc, const OUString *pSBLibrary, const OUString *pSBModule)
static SVT_DLLPUBLIC SvStream & Out_Events(SvStream &, const SvxMacroTableDtor &, const HTMLOutEvent *, bool bOutStarBasic, OUString *pNonConvertableChars=nullptr)