Hi Alain,

The problem here, as Steffen has mentioned, is that TypeDetection does not always detect a corruption in files. Actually the main intention of TypeDetection is not to detect whether a document can be loaded, but to suggest a filter that looks to be most suitable.

In case of currupted file or an unknown format, the TypeDetection still might suggest a filter that looks to be suitable, and the pure text-filter is always suitable. Moreover, fast any document can be loaded as pure text-file.

As for the new API, from my point of view it does not make much sense, since the document has to be loaded anyway to guarantee that it is loadable. And the pure text filter can load everything anyway.

Best regards,
Mikhail.

On 10/21/08 09:55, Alain Rist wrote:
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to