diff options
| author | Kohei Yoshida <kyoshida@novell.com> | 2009-12-29 12:32:37 -0500 |
|---|---|---|
| committer | Kohei Yoshida <kyoshida@novell.com> | 2009-12-29 12:32:37 -0500 |
| commit | 2605839fcb9701ebf3b9f1b773ad91cb3b669f78 (patch) | |
| tree | 43c6f2e47b5fdf89437a2b1facb877d92672508b /source/global.cxx | |
| parent | cfcb5a25dec927279a739d53884058b9221bcb49 (diff) | |
Load each xls document into frame.
Diffstat (limited to 'source/global.cxx')
| -rw-r--r-- | source/global.cxx | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/source/global.cxx b/source/global.cxx index 4a9f1e2..39e63a0 100644 --- a/source/global.cxx +++ b/source/global.cxx @@ -4,18 +4,25 @@ #include "rtl/ustring.hxx" #include "rtl/textenc.h" +#include <com/sun/star/frame/XDesktop.hpp> #include <com/sun/star/sheet/XSpreadsheetDocument.hpp> #include <com/sun/star/lang/XMultiComponentFactory.hpp> +#include <com/sun/star/frame/XComponentLoader.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> #include <cstring> #include <iostream> +using ::com::sun::star::beans::PropertyValue; using ::com::sun::star::frame::XDesktop; +using ::com::sun::star::frame::XComponentLoader; using ::com::sun::star::sheet::XSpreadsheetDocument; using ::com::sun::star::uno::XComponentContext; using ::com::sun::star::lang::XMultiComponentFactory;; +using ::com::sun::star::lang::XComponent;; using ::com::sun::star::uno::UNO_QUERY_THROW; using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; using ::rtl::OUString; using namespace ::std; @@ -39,6 +46,24 @@ Reference<XDesktop> bootstrap() return xDesktop; } +Reference<XSpreadsheetDocument> loadComponent(const Reference<XDesktop>& xDesktop, const OUString& rPath) +{ + Reference<XSpreadsheetDocument> xSpDoc; + Reference<XComponentLoader> xLoader(xDesktop, UNO_QUERY_THROW); + Sequence<PropertyValue> args; + Reference<XComponent> xComponent = xLoader->loadComponentFromURL( + rPath, ascii("_default"), 0, args); + + if (!xComponent.is()) + { + error("component failed to load"); + return xSpDoc; + } + + xSpDoc.set(xComponent, UNO_QUERY_THROW); + return xSpDoc; +} + void info(const string& msg) { cout << "info: " << msg << endl; |
