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