24#include <config_features.h>
25#include <rtl/character.hxx>
26#include <rtl/malformeduriexception.hxx>
47#include <sfx2/sfxsids.hrc>
54static OUString SfxDdeServiceName_Impl(
const OUString& sIn )
56 OUStringBuffer sReturn(sIn.getLength());
58 for ( sal_uInt16 n = sIn.getLength(); n; --n )
61 if (rtl::isAsciiAlphanumeric(cChar))
62 sReturn.append(cChar);
65 return sReturn.makeStringAndClear();
73 explicit ImplDdeService(
const OUString& rNm )
76 virtual bool MakeTopic(
const OUString& );
80 virtual bool SysTopicExecute(
const OUString* pStr );
83 bool lcl_IsDocument( std::u16string_view rContent )
89 DBG_ASSERT( aObj.GetProtocol() != INetProtocol::NotValid,
"Invalid URL!" );
94 bRet = aCnt.isDocument();
96 catch(
const uno::Exception& )
105bool ImplDdeService::MakeTopic(
const OUString& rNm )
116 OUString sNm( rNm.toAsciiLowerCase() );
121 if( sNm == sTmp.toAsciiLowerCase() )
135 url = rtl::Uri::convertRelToAbs(
SvtPathOptions().GetWorkPath(), rNm);
137 }
catch (rtl::MalformedUriException &) {
140 if ( abs && lcl_IsDocument( url ) )
150 { &
aName, &aNewView, &aSilent });
155 nullptr != ( pShell = item->GetFrame()->GetObjectShell() ) )
165OUString ImplDdeService::Topics()
169 sRet += GetSysTopic()->
GetName();
176 if( !sRet.isEmpty() )
182 if( !sRet.isEmpty() )
187bool ImplDdeService::SysTopicExecute(
const OUString* pStr )
189 return SfxApplication::DdeExecute( *pStr );
199 css::uno::Sequence< sal_Int8 >
aSeq;
207 virtual bool Execute(
const OUString* )
override;
209 virtual bool MakeItem(
const OUString& rItem )
override;
230bool SfxAppEvent_Impl(
const OUString& rCmd, std::u16string_view rEvent,
233 OUString sEvent(OUString::Concat(rEvent) +
"(");
234 if (rCmd.startsWithIgnoreAsciiCase(sEvent))
236 sal_Int32
start = sEvent.getLength();
237 if ( rCmd.getLength() - start >= 2 )
247 std::vector<OUString>
aData;
248 for ( sal_Int32 n = start;
n < rCmd.getLength() - 1; )
261 sal_Int32
i = rCmd.indexOf(
'"', ++n);
262 if (i < 0 || i > rCmd.getLength() - 1) {
263 i = rCmd.getLength() - 1;
265 aData.push_back(rCmd.copy(n, i - n));
274 sal_Int32
i = rCmd.indexOf(
' ', n);
275 if (i < 0 || i > rCmd.getLength() - 1) {
276 i = rCmd.getLength() - 1;
278 aData.push_back(rCmd.copy(n, i - n));
304bool SfxApplication::DdeExecute(
const OUString& rCmd )
330bool SfxObjectShell::DdeExecute(
const OUString& rCmd )
332#if !HAVE_FEATURE_SCRIPTING
354bool SfxObjectShell::DdeGetData(
const OUString&,
369bool SfxObjectShell::DdeSetData(
const OUString&,
371 const css::uno::Any& )
400 p->ReconnectDdeLink(rServer);
411 "Dde can not be initialized multiple times" );
414 nError =
pImpl->pDdeService->GetError();
418 pImpl->pDdeService->AddFormat( SotClipboardFormatId::RTF );
419 pImpl->pDdeService->AddFormat( SotClipboardFormatId::RICHTEXT );
424 OUString aService( SfxDdeServiceName_Impl(
426 aService = aService.toAsciiUpperCase();
427 pImpl->pDdeService2.reset(
new ImplDdeService( aService ));
429 pImpl->pDdeService2->AddTopic( *
pImpl->pTriggerTopic );
447 if(
pImpl->maDocTopics.empty() )
453 for (
size_t n =
pImpl->maDocTopics.size(); n;)
455 if(
pImpl->maDocTopics[ --n ]->pSh == pSh )
463 OUString sNm(
pImpl->maDocTopics[ n ]->GetName() );
464 if( sShellNm == sNm.toAsciiLowerCase() )
470 pImpl->maDocTopics.push_back(pTopic);
471 pImpl->pDdeService->AddTopic( *pTopic );
479 if(
pImpl->maDocTopics.empty() )
482 for (
size_t n =
pImpl->maDocTopics.size();
n; )
485 if (pTopic->pSh == pSh)
487 pImpl->pDdeService->RemoveTopic( *pTopic );
489 pImpl->maDocTopics.erase(
pImpl->maDocTopics.begin() +
n );
499 return pImpl->pDdeService.get();
504 return pImpl->pDdeService.get();
512 css::uno::Any aValue;
513 bool bRet = pSh->DdeGetData(
GetCurItem(), sMimeType, aValue );
514 if( bRet && aValue.hasValue() && ( aValue >>=
aSeq ) )
525 aSeq = css::uno::Sequence< sal_Int8 >(
528 if(
aSeq.getLength() )
530 css::uno::Any aValue;
533 bRet = pSh->DdeSetData(
GetCurItem(), sMimeType, aValue );
542 return pStr && pSh->DdeExecute( *pStr );
SfxApplication * SfxGetpApp()
static bool IsInExecute()
virtual void AppEvent(const ApplicationEvent &rAppEvent)
static OUString GetAppName()
virtual bool MakeItem(const OUString &rItem)
virtual bool StartAdviseLoop()
DdeTopic(SAL_UNUSED_PARAMETER const OUString &)
const OUString & GetCurItem() const
virtual bool Put(const DdeData *)
virtual bool Execute(const OUString *)
DdeItem * AddItem(const DdeItem &)
friend friend class DdeItem
virtual DdeData * Get(SotClipboardFormatId)
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
bool insertName(std::u16string_view rTheName, bool bAppendFinalSlash=false, sal_Int32 nIndex=LAST_SEGMENT, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
std::unique_ptr< DdeService > pDdeService
std::vector< SfxDdeDocTopic_Impl * > maDocTopics
std::unique_ptr< SfxDdeTriggerTopic_Impl > pTriggerTopic
std::unique_ptr< DdeService > pDdeService2
static StarBASIC * GetBasic()
SAL_DLLPRIVATE SfxDispatcher * GetDispatcher_Impl()
std::unique_ptr< SfxAppData_Impl > pImpl
void RemoveDdeTopic(SfxObjectShell const *)
const DdeService * GetDdeService() const
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
Method to execute a <SfxSlot>s over the Slot-Id.
virtual void ReconnectDdeLink(SfxObjectShell &rServer)
virtual ::sfx2::SvLinkSource * DdeCreateLinkSource(const OUString &rItem)
static SAL_WARN_UNUSED_RESULT SfxObjectShell * GetNext(const SfxObjectShell &rPrev, const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
OUString GetTitle(sal_uInt16 nMaxLen=0) const
StarBASIC * GetBasic() const
static SAL_WARN_UNUSED_RESULT SfxObjectShell * GetFirst(const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
static void ReconnectDdeLinks(SfxObjectShell &rServer)
const OUString & GetName() const
Returns the name of the Shell object.
SfxViewFrame * GetFrame() const
static SAL_WARN_UNUSED_RESULT SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
static OUString GetFormatMimeType(SotClipboardFormatId nFormat)
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
Sequence< sal_Int8 > aSeq
std::unique_ptr< sal_Int32[]> pData
Reference< XComponentContext > getProcessComponentContext()
void MakeLnkName(OUString &rName, const OUString *pType, std::u16string_view rFile, std::u16string_view rLink, const OUString *pFilter)
SwNodeOffset abs(const SwNodeOffset &a)
#define SFX_TITLE_FULLNAME
VCL_DLLPUBLIC Application * GetpApp()