[Libreoffice-commits] .: 2 commits - sw/inc sw/sdi sw/source

Michael Meeks mmeeks at kemper.freedesktop.org
Thu Dec 2 06:37:51 PST 2010


 sw/inc/cmdid.h                |    4 +
 sw/sdi/_frmsh.sdi             |   14 +++
 sw/sdi/swriter.sdi            |   48 +++++++++++++
 sw/source/ui/app/mn.src       |   26 +++++++
 sw/source/ui/shells/frmsh.cxx |  151 ++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 243 insertions(+)

New commits:
commit 6f900529468c2ca340ba8ffa2dbb74a4b8d673bb
Author: Michael Meeks <michael.meeks at novell.com>
Date:   Thu Dec 2 14:30:23 2010 +0000

    Enable OLE object export, only as an experimental feature

diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index 84686b6..beb4e8a 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -639,8 +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_EXPORT_OLE                       (FN_FORMAT2 + 129)	  /* Export menu item */
+#define FN_EXPORT_OLE_AS_PDF                (FN_FORMAT2 + 130)	  /* Export as PDF */
+#define FN_EXPORT_OLE_AS_GRAPHIC            (FN_FORMAT2 + 131)	  /* Export as JPG */
 
 #define FN_FRAME_CHAIN						(FN_FORMAT2 + 136)
 #define FN_FRAME_UNCHAIN					(FN_FORMAT2 + 137)
diff --git a/sw/source/ui/shells/frmsh.cxx b/sw/source/ui/shells/frmsh.cxx
index b675eb9..66f0b0b 100644
--- a/sw/source/ui/shells/frmsh.cxx
+++ b/sw/source/ui/shells/frmsh.cxx
@@ -33,6 +33,7 @@
 #include <hintids.hxx>
 #include <svl/whiter.hxx>
 #include <svtools/imapobj.hxx>
+#include <svtools/miscopt.hxx>
 #include <svl/srchitem.hxx>
 #include <svtools/imap.hxx>
 #include <sfx2/viewfrm.hxx>
@@ -855,6 +856,16 @@ void SwFrameShell::GetState(SfxItemSet& rSet)
                         rSet.DisableItem( nWhich );
                 break;
 
+                case FN_EXPORT_OLE:
+                case FN_EXPORT_OLE_AS_PDF:
+                case FN_EXPORT_OLE_AS_GRAPHIC:
+                {
+                    SvtMiscOptions aMiscOptions;
+                    if ( !aMiscOptions.IsExperimentalMode() )
+                        rSet.DisableItem( nWhich );
+                    break;
+                }
+
                 case SID_OBJECT_ALIGN_UP     :
                 case SID_OBJECT_ALIGN_MIDDLE :
                 case SID_OBJECT_ALIGN_DOWN :
commit bb19320aff49a68de2ff254b370649a73e4a820e
Author: Gert Faller <gertfaller at aliceadsl.fr>
Date:   Thu Dec 2 14:14:46 2010 +0000

    Add export as PDF / JPG to OLE objects context menu

diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index ab896be..84686b6 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 82d6aff..d074710 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 5863907..c2fcc53 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 c033410..f57afa6 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 302d356..b675eb9 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() )
             {


More information about the Libreoffice-commits mailing list