Am Montag, den 20.10.2008, 08:09 +0200 schrieb Alain Rist:
> 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);
"_default"
This way the frame loader tries to find an already loaded document. I
don't know if this works as expected in "hidden" mode though.
> }
> catch (Exception e)
> {}
> return xDoc.is() ? xDoc->dispose(), true : false;
> }Thanks,
> AR
HTH,
Marc
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]