summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorGert Faller <gertfaller@aliceadsl.fr>2010-12-02 14:14:46 +0000
committerMichael Meeks <michael.meeks@novell.com>2010-12-02 14:14:46 +0000
commit4a554264ce017cc8f6817fe1f3ca9e3ddf21d1ed (patch)
treee24dc560695a46ab180d48f84e69b2267de0f80f /sw
parente39e41ddc74402b3b3cdeff52ae0e381c7c0b883 (diff)
Add export as PDF / JPG to OLE objects context menu
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/cmdid.h3
-rw-r--r--sw/sdi/_frmsh.sdi14
-rw-r--r--sw/sdi/swriter.sdi48
-rw-r--r--sw/source/ui/app/mn.src26
-rw-r--r--sw/source/ui/shells/frmsh.cxx140
5 files changed, 231 insertions, 0 deletions
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index d9f13e1324a1..c55f462f2b06 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -639,6 +639,9 @@ included in c-context files, so c++ style stuff will cause problems.
#define FN_NUMBER_CURRENCY (FN_FORMAT2 + 127)
#define FN_NUMBER_PERCENT (FN_FORMAT2 + 128)
+#define FN_EXPORT_OLE_AS_PDF (FN_FORMAT2 + 129) /* Test PDF */
+#define FN_EXPORT_OLE_AS_GRAPHIC (FN_FORMAT2 + 130) /* Test JPG */
+
#define FN_FRAME_CHAIN (FN_FORMAT2 + 136)
#define FN_FRAME_UNCHAIN (FN_FORMAT2 + 137)
diff --git a/sw/sdi/_frmsh.sdi b/sw/sdi/_frmsh.sdi
index a83270a6d196..484adb90220e 100644
--- a/sw/sdi/_frmsh.sdi
+++ b/sw/sdi/_frmsh.sdi
@@ -173,6 +173,20 @@ interface BaseTextFrame
DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR";
]
+ FN_EXPORT_OLE_AS_PDF // status(final|play)
+ [
+ ExecMethod = Execute ;
+ StateMethod = GetState ;
+ DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR";
+ ]
+
+ FN_EXPORT_OLE_AS_GRAPHIC // status(final|play)
+ [
+ ExecMethod = Execute ;
+ StateMethod = GetState ;
+ DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR";
+ ]
+
SID_FRAME_LINESTYLE // status()
[
ExecMethod = ExecFrameStyle ;
diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi
index 5863907049dc..c2fcc53bf29a 100644
--- a/sw/sdi/swriter.sdi
+++ b/sw/sdi/swriter.sdi
@@ -2034,6 +2034,54 @@ SfxVoidItem FormatColumns FN_FORMAT_COLUMN
GroupId = GID_FORMAT;
]
+SfxVoidItem ExportPDF FN_EXPORT_OLE_AS_PDF
+()
+[
+ /* flags: */
+ AutoUpdate = FALSE,
+ Cachable = Cachable,
+ FastCall = FALSE,
+ HasCoreId = FALSE,
+ HasDialog = FALSE,
+ ReadOnlyDoc = FALSE,
+ Toggle = FALSE,
+ Container = FALSE,
+ RecordAbsolute = FALSE,
+ RecordPerItem;
+ Asynchron;
+
+ /* config: */
+ AccelConfig = TRUE,
+ MenuConfig = TRUE,
+ StatusBarConfig = FALSE,
+ ToolBoxConfig = TRUE,
+ GroupId = GID_FRAME;
+]
+
+SfxVoidItem ExportGraphic FN_EXPORT_OLE_AS_GRAPHIC
+()
+[
+ /* flags: */
+ AutoUpdate = FALSE,
+ Cachable = Cachable,
+ FastCall = FALSE,
+ HasCoreId = FALSE,
+ HasDialog = FALSE,
+ ReadOnlyDoc = FALSE,
+ Toggle = FALSE,
+ Container = FALSE,
+ RecordAbsolute = FALSE,
+ RecordPerItem;
+ Asynchron;
+
+ /* config: */
+ AccelConfig = TRUE,
+ MenuConfig = TRUE,
+ StatusBarConfig = FALSE,
+ ToolBoxConfig = TRUE,
+ GroupId = GID_FRAME;
+]
+
//--------------------------------------------------------------------------
SwFmtDrop FormatDropcap FN_FORMAT_DROPCAPS
diff --git a/sw/source/ui/app/mn.src b/sw/source/ui/app/mn.src
index 82954e440683..d3d837f7eb74 100644
--- a/sw/source/ui/app/mn.src
+++ b/sw/source/ui/app/mn.src
@@ -953,6 +953,29 @@ String MN_OLE_POPUPMENU
Text [ en-US ] = "Object" ;
};
+#define MN_OLE_EXPORT \
+ MenuItem\
+ {\
+ Text [ en-US ] = "Export..." ; \
+ SubMenu = Menu\
+ {\
+ ItemList = \
+ {\
+ MenuItem\
+ {\
+ Identifier = FN_EXPORT_OLE_AS_PDF ;\
+ HelpID = FN_EXPORT_OLE_AS_PDF ; \
+ Text [ en-US ] = "Export as P~DF..." ; \
+ };\
+ MenuItem\
+ {\
+ Identifier = FN_EXPORT_OLE_AS_GRAPHIC ;\
+ HelpID = FN_EXPORT_OLE_AS_GRAPHIC ; \
+ Text [ en-US ] = "Export as JPG..." ; \
+ };\
+ };\
+ };\
+ };
Menu MN_OLE_POPUPMENU
{
@@ -969,6 +992,9 @@ Menu MN_OLE_POPUPMENU
HelpID = FN_FORMAT_FRAME_DLG ;
Text [ en-US ] = "Object..." ;
};
+ SEPARATOR ;
+ MN_OLE_EXPORT
+ SEPARATOR ;
MN_FRM_CAPTION_ITEM
};
};
diff --git a/sw/source/ui/shells/frmsh.cxx b/sw/source/ui/shells/frmsh.cxx
index 27843a00bf20..115598a793c6 100644
--- a/sw/source/ui/shells/frmsh.cxx
+++ b/sw/source/ui/shells/frmsh.cxx
@@ -88,6 +88,13 @@
#include <svx/dialogs.hrc>
// <--
+#include <sfx2/filedlghelper.hxx>
+#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
+#include <com/sun/star/beans/PropertyValues.hpp>
+#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/uno/Any.h>
+
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -115,6 +122,10 @@ SFX_IMPL_INTERFACE(SwFrameShell, SwBaseShell, SW_RES(STR_SHELLNAME_FRAME))
SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_FRAME_TOOLBOX));
}
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/frame/XDesktop.hpp>
+#include <com/sun/star/frame/XDispatchHelper.hpp>
+
void SwFrameShell::Execute(SfxRequest &rReq)
{
//Erstmal die, die keinen FrmMgr benoetigen.
@@ -126,6 +137,135 @@ void SwFrameShell::Execute(SfxRequest &rReq)
switch ( nSlot )
{
+ case FN_EXPORT_OLE_AS_GRAPHIC:
+ {
+ const int nSel = rSh.GetSelectionType();
+ if (nSel & nsSelectionType::SEL_OLE)
+ {
+ sfx2::FileDialogHelper aDlgHelper( ::ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION, 0 );
+ aDlgHelper.SetTitle(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Export as JPG" )));
+ String aExt(RTL_CONSTASCII_USTRINGPARAM("*.jpg"));
+ aDlgHelper.AddFilter( aExt, aExt );
+ aDlgHelper.SetCurrentFilter( aExt );
+ if( aDlgHelper.Execute() == ERRCODE_NONE )
+ {
+ String aFile(aDlgHelper.GetPath());
+ // copy the object
+ uno::Reference< frame::XController > xController = rSh.GetView().GetViewFrame()->GetFrame().GetFrameInterface()->getController();
+ uno::Reference< frame::XFrame > xFrame = xController->getFrame();
+ uno::Reference< frame::XDispatchHelper > xDispatchHelper(::comphelper::getProcessServiceFactory()->createInstance(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.DispatchHelper" )) ),
+ uno::UNO_QUERY );
+ uno::Reference< frame::XDispatchProvider > xDispatchProvider(xFrame,UNO_QUERY);
+ xDispatchHelper->executeDispatch(xDispatchProvider, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:Copy")),
+ ::rtl::OUString(), 0,
+ Sequence < ::com::sun::star::beans::PropertyValue >());
+ // create new draw document
+ ::beans::PropertyValues aPropertyValue(1);
+ aPropertyValue[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Hidden" ) );
+ aPropertyValue[0].Value <<= sal_Bool(sal_False);
+
+ uno::Reference< ::frame::XComponentLoader > xLoader(xFrame, UNO_QUERY);
+ uno::Reference< ::lang::XComponent > xDrawComponent( xLoader->loadComponentFromURL(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:factory/sdraw" ) ),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_blank" ) ), 0,
+ aPropertyValue));
+
+ // paste it into draw
+ uno::Reference< frame::XModel > xDrawModel(xDrawComponent, UNO_QUERY);
+ xController = xDrawModel->getCurrentController();
+ xFrame = xController->getFrame();
+ uno::Reference< frame::XDispatchProvider > xDrawDispatchProvider(xFrame,UNO_QUERY);
+
+ xDispatchHelper->executeDispatch(xDrawDispatchProvider,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:Paste")),
+ ::rtl::OUString(), 0,
+ Sequence < ::com::sun::star::beans::PropertyValue >());
+ xDispatchHelper->executeDispatch(xDrawDispatchProvider,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:AlignUp")),
+ ::rtl::OUString(), 0,
+ Sequence < ::com::sun::star::beans::PropertyValue >());
+ xDispatchHelper->executeDispatch(xDrawDispatchProvider,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:AlignCenter")),
+ ::rtl::OUString(), 0,
+ Sequence < ::com::sun::star::beans::PropertyValue >());
+ // export as jpeg
+ xController = xFrame->getController();
+ aPropertyValue[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "FilterName" ) );
+ aPropertyValue[0].Value <<= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "draw_jpg_Export" ) );
+ uno::Reference< frame::XStorable > xStorable(xController->getModel(), uno::UNO_QUERY );
+ xStorable->storeToURL(aFile, aPropertyValue);
+
+ // destroy draw document
+ xDrawComponent->dispose();
+ }
+ }
+ rReq.Ignore();
+ }
+ break;
+ case FN_EXPORT_OLE_AS_PDF:
+ {
+ const int nSel = rSh.GetSelectionType();
+ if (nSel & nsSelectionType::SEL_OLE)
+ {
+ sfx2::FileDialogHelper aDlgHelper( ::ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION, 0 );
+ aDlgHelper.SetTitle(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Export as PDF" )));
+ String aExt(RTL_CONSTASCII_USTRINGPARAM("*.pdf"));
+ aDlgHelper.AddFilter( aExt, aExt );
+ aDlgHelper.SetCurrentFilter( aExt );
+ if( aDlgHelper.Execute() == ERRCODE_NONE )
+ {
+ String aFile(aDlgHelper.GetPath());
+ Reference< frame::XController > xController = rSh.GetView().GetViewFrame()->GetFrame().GetFrameInterface()->getController();
+ ::beans::PropertyValues aPropertyValue(3);
+ aPropertyValue[0].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "FilterName" ) );
+ aPropertyValue[0].Value <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "writer_pdf_Export" ) );
+ Sequence< ::beans::PropertyValue > aSequence(10);
+ ::beans::PropertyValue aValue;
+ aValue.Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "UseLosslessCompression" ));
+ aValue.Value <<= sal_Bool(sal_False);
+ aSequence[0] = aValue;
+ aValue.Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Quality" ));
+ aValue.Value <<= sal_Int32(90);
+ aSequence[1] = aValue;
+ aValue.Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ReduceImageResolution" ));
+ aValue.Value <<= sal_Bool(sal_False);
+ aSequence[2] = aValue;
+ aValue.Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "MaxImageResolution" ));
+ aValue.Value <<= sal_Int32(300);
+ aSequence[3] = aValue;
+ aValue.Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "UseTaggedPDF" ));
+ aValue.Value <<= sal_Bool(sal_False);
+ aSequence[4] = aValue;
+ aValue.Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ExportNotes" ));
+ aValue.Value <<= sal_Bool(sal_False);
+ aSequence[5] = aValue;
+ aValue.Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "UseTransitionEffects" ));
+ aValue.Value <<= sal_Bool(sal_True);
+ aSequence[6] = aValue;
+ aValue.Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "FormsType" ));
+ aValue.Value <<= sal_Int32(0);
+ aSequence[7] = aValue;
+ uno::Any aAny;
+ Reference< view::XSelectionSupplier > xView( xController, UNO_QUERY );
+ xView->getSelection() >>= aAny;
+ aValue.Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Selection" ));
+ aValue.Value <<= aAny;
+ aSequence[8] = aValue;
+ aValue.Name = rtl::OUString();
+ aValue.Value <<= sal_Int32(0);
+ aSequence[9] = aValue;
+ aPropertyValue[1].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "FilterData" ) );
+ aPropertyValue[1].Value <<= aSequence;
+ aPropertyValue[2].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Selection" ) );
+ aPropertyValue[2].Value <<= sal_Bool(sal_True);
+ Reference< frame::XStorable > xStorable(xController->getModel(), uno::UNO_QUERY );
+ xStorable->storeToURL(aFile, aPropertyValue);
+ }
+ }
+ rReq.Ignore();
+ }
+ break;
case FN_FRAME_TO_ANCHOR:
if ( rSh.IsFrmSelected() )
{