diff options
author | Rafael Dominguez <venccsralph@gmail.com> | 2012-08-14 15:28:00 -0430 |
---|---|---|
committer | Rafael Dominguez <venccsralph@gmail.com> | 2012-08-14 16:07:04 -0430 |
commit | c319e6258c34afa70ff0ab1f997ed88d53f94961 (patch) | |
tree | 381070ec720d7c7448c737bd71c9700ff76ebd76 /sfx2 | |
parent | cda4febfcf81473e7c0d4f8fe52212d282fa14d1 (diff) |
Display template preview in property dialog.
Change-Id: I7479bac95a93a156889e19921373c441ef8fd881
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/inc/sfx2/templateinfodlg.hxx | 8 | ||||
-rw-r--r-- | sfx2/source/dialog/templateinfodlg.cxx | 54 |
2 files changed, 61 insertions, 1 deletions
diff --git a/sfx2/inc/sfx2/templateinfodlg.hxx b/sfx2/inc/sfx2/templateinfodlg.hxx index dd031bebcbc8..8fe79984d97f 100644 --- a/sfx2/inc/sfx2/templateinfodlg.hxx +++ b/sfx2/inc/sfx2/templateinfodlg.hxx @@ -17,6 +17,9 @@ namespace svtools { class ODocumentInfoPreview; } +namespace com{ namespace sun { namespace star { namespace awt { class XWindow; } } } } +namespace com{ namespace sun { namespace star { namespace frame { class XFrame; } } } } + class SfxTemplateInfoDlg : public ModalDialog { public: @@ -31,8 +34,11 @@ private: PushButton maBtnClose; - Window *mpPreviewView; + Window *mpPreviewView; // gets released when xWindows get destroyed (dont delete in constructor) svtools::ODocumentInfoPreview *mpInfoView; + + ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame > xFrame; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xWindow; }; #endif // __SFX2_TEMPLATEINFODLG_HXX__ diff --git a/sfx2/source/dialog/templateinfodlg.cxx b/sfx2/source/dialog/templateinfodlg.cxx index 2ed6794ac9c3..40e3f1436688 100644 --- a/sfx2/source/dialog/templateinfodlg.cxx +++ b/sfx2/source/dialog/templateinfodlg.cxx @@ -12,11 +12,17 @@ #include <comphelper/processfactory.hxx> #include <sfx2/sfxresid.hxx> #include <svtools/DocumentInfoPreview.hxx> +#include <toolkit/helper/vclunohelper.hxx> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/document/XDocumentProperties.hpp> +#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/frame/XFrame.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/task/XInteractionHandler.hpp> +#include <com/sun/star/util/URL.hpp> +#include <com/sun/star/util/URLTransformer.hpp> +#include <com/sun/star/util/XURLTransformer.hpp> #include "templateinfodlg.hrc" @@ -25,28 +31,44 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::document; +using namespace ::com::sun::star::frame; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::task; +using namespace ::com::sun::star::util; SfxTemplateInfoDlg::SfxTemplateInfoDlg (Window *pParent) : ModalDialog(pParent,SfxResId(DLG_TEMPLATE_INFORMATION)), maBtnClose(this,SfxResId(BTN_TEMPLATE_INFO_CLOSE)), + mpPreviewView(new Window(this)), mpInfoView(new svtools::ODocumentInfoPreview(this,WB_LEFT | WB_VSCROLL | WB_READONLY | WB_BORDER | WB_3DLOOK)) { Size aWinSize = GetOutputSizePixel(); aWinSize.setHeight( aWinSize.getHeight() - 3*DLG_BORDER_SIZE - maBtnClose.GetOutputHeightPixel() ); aWinSize.setWidth( (aWinSize.getWidth() - 3*DLG_BORDER_SIZE)/2 ); mpInfoView->SetPosSizePixel(Point(DLG_BORDER_SIZE,DLG_BORDER_SIZE),aWinSize); + + mpPreviewView->SetPosSizePixel(Point(aWinSize.getWidth()+2*DLG_BORDER_SIZE,DLG_BORDER_SIZE),aWinSize); + + xWindow = VCLUnoHelper::GetInterface(mpPreviewView); + + xFrame.set(comphelper::getProcessServiceFactory()->createInstance("com.sun.star.frame.Frame"), uno::UNO_QUERY ); + xFrame->initialize( xWindow ); + + mpPreviewView->Show(); mpInfoView->Show(); } SfxTemplateInfoDlg::~SfxTemplateInfoDlg() { + xFrame->dispose(); + delete mpInfoView; } void SfxTemplateInfoDlg::loadDocument(const OUString &rURL) { + assert(!rURL.isEmpty()); + uno::Reference<lang::XMultiServiceFactory> xContext(comphelper::getProcessServiceFactory()); try @@ -64,6 +86,38 @@ void SfxTemplateInfoDlg::loadDocument(const OUString &rURL) xDocProps->loadFromMedium( rURL, aProps ); mpInfoView->fill( xDocProps, rURL ); + + // Create template preview + uno::Reference<util::XURLTransformer > xTrans( + util::URLTransformer::create(comphelper::getProcessComponentContext())); + + util::URL aURL; + aURL.Complete = rURL; + xTrans->parseStrict(aURL); + + uno::Reference<frame::XDispatchProvider> xProv( xFrame, uno::UNO_QUERY ); + + uno::Reference<frame::XDispatch> xDisp = xProv.is() ? + xProv->queryDispatch( aURL, "_self", 0 ) : uno::Reference<XDispatch>(); + + if ( xDisp.is() ) + { + mpPreviewView->EnableInput( false, true ); + + bool b = true; + uno::Sequence <beans::PropertyValue> aArgs( 4 ); + aArgs[0].Name = "Preview"; + aArgs[0].Value.setValue( &b, ::getBooleanCppuType() ); + aArgs[1].Name = "ReadOnly"; + aArgs[1].Value.setValue( &b, ::getBooleanCppuType() ); + aArgs[2].Name = "AsTemplate"; // prevents getting an empty URL with getURL()! + aArgs[3].Name = "InteractionHandler"; + aArgs[3].Value <<= xInteractionHandler; + + b = false; + aArgs[2].Value.setValue( &b, ::getBooleanCppuType() ); + xDisp->dispatch( aURL, aArgs ); + } } catch ( beans::UnknownPropertyException& ) { |