Thanks Steffen,
I more or less hoped that TypeDetection could be used in that purpose :(
Is this the right place to suggest a
sal_Bool com::sun::star::frame::XComponentLoader::checkComponentFromURL()
API?
cheers,
AR
----- Original Message -----
From: "Steffen Grund" <[EMAIL PROTECTED]>
Newsgroups: openoffice.api.dev
To: <[email protected]>
Sent: Monday, October 20, 2008 12:18 PM
Subject: Re: [api-dev] Best way to know if <SomeFileName> is loadable ?
Hello Alain,
I do not think so. You could check the extension of the file, if it's one
of the known extensions of OOo. But you surely thought of that. If we are
talking about possibly corrupt files, then I see no other way than opening
them and see if it works.
Regards, Steffen
Alain Rist wrote:
Hi,
I need to know if a user selected file can be loaded by OOo.
My current (working) implementation tests if OOo can load the file (in
hidden mode). It is costly, specially when the answer is yes, as the file
will actually be loaded before return. Is there a lighter way to get the
answer?
inline bool CanLoad(LPCWSTR sPath)
{
Reference<XComponent> xDoc;
using com::sun::star::frame::XComponentLoader;
Reference<XComponentLoader>
xLoader(Instance<XComponentLoader>(L"com.sun.star.frame.Desktop"));
if (xLoader.is())
try
{
using com::sun::star::beans::PropertyValue;
using com::sun::star::beans::PropertyState_DIRECT_VALUE;
PropertyValue pvHidden(L"Hidden", 0, Any(true),
PropertyState_DIRECT_VALUE);
Sequence<PropertyValue> sPV(&pvHidden, 1);
using com::sun::star::frame::FrameSearchFlag::CREATE;
xDoc = xLoader->loadComponentFromURL(GetPathURL(sPath).Complete,
L"_blank", CREATE, sPV);
}
catch (Exception e)
{}
return xDoc.is() ? xDoc->dispose(), true : false;
}Thanks,
AR
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]