[PATCH 7/7] support Sheets.PrintPreview bnc#757844

Noel Power noel.power at novell.com
Fri May 11 02:57:15 PDT 2012


there is still a little wrinkle, the preview shell always shows what sheets are selected, it's currently not possible to specify the sheets to preview
---
 oovbaapi/ooo/vba/excel/XWorksheets.idl   |    1 +
 sc/source/ui/vba/vbaworksheets.cxx       |    7 +++++++
 sc/source/ui/vba/vbaworksheets.hxx       |    1 +
 vbahelper/source/vbahelper/vbahelper.cxx |   13 ++++++++++++-
 4 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/oovbaapi/ooo/vba/excel/XWorksheets.idl b/oovbaapi/ooo/vba/excel/XWorksheets.idl
index 17c80ce..cca74f9 100644
--- a/oovbaapi/ooo/vba/excel/XWorksheets.idl
+++ b/oovbaapi/ooo/vba/excel/XWorksheets.idl
@@ -45,6 +45,7 @@ interface XWorksheets
     void PrintOut( [in] any From, [in] any To, [in] any Copies, [in] any Preview, [in] any ActivePrinter, [in] any PrintToFile, [in] any Collate, [in] any PrToFileName );
     void Select( [in] any Replace );
     void Copy( [in] any Before, [in] any After);
+    void PrintPreview( [in] any EnableChanges );
 };
 }; }; };
 
diff --git a/sc/source/ui/vba/vbaworksheets.cxx b/sc/source/ui/vba/vbaworksheets.cxx
index 02828ef..b9c8342 100644
--- a/sc/source/ui/vba/vbaworksheets.cxx
+++ b/sc/source/ui/vba/vbaworksheets.cxx
@@ -538,4 +538,11 @@ bool ScVbaWorksheets::nameExists( uno::Reference <sheet::XSpreadsheetDocument>&
     return false;
 }
 
+void ScVbaWorksheets::PrintPreview( const css::uno::Any& EnableChanges ) throw (css::uno::RuntimeException)
+{
+    // need test, print preview current active sheet
+    // !! TODO !! get view shell from controller
+    PrintPreviewHelper( EnableChanges, excel::getBestViewShell( mxModel ) );
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaworksheets.hxx b/sc/source/ui/vba/vbaworksheets.hxx
index c15d713..37834da 100644
--- a/sc/source/ui/vba/vbaworksheets.hxx
+++ b/sc/source/ui/vba/vbaworksheets.hxx
@@ -73,6 +73,7 @@ public:
     virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
     virtual void SAL_CALL Select( const css::uno::Any& Replace ) throw (css::uno::RuntimeException);
     virtual void SAL_CALL Copy ( const css::uno::Any& Before, const css::uno::Any& After) throw (css::uno::RuntimeException);
+    virtual void SAL_CALL PrintPreview( const css::uno::Any& EnableChanges ) throw (css::uno::RuntimeException);
     // ScVbaWorksheets_BASE
     virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index1, const css::uno::Any& Index2 ) throw
 (css::uno::RuntimeException);
diff --git a/vbahelper/source/vbahelper/vbahelper.cxx b/vbahelper/source/vbahelper/vbahelper.cxx
index adc1d63..eef065a 100644
--- a/vbahelper/source/vbahelper/vbahelper.cxx
+++ b/vbahelper/source/vbahelper/vbahelper.cxx
@@ -482,7 +482,18 @@ void PrintOutHelper( SfxViewShell* pViewShell, const uno::Any& From, const uno::
 
  void PrintPreviewHelper( const css::uno::Any& /*EnableChanges*/, SfxViewShell* pViewShell )
 {
-    dispatchExecute( pViewShell, SID_VIEWSHELL1 );
+    SfxViewFrame* pViewFrame = NULL;
+    if ( pViewShell )
+        pViewFrame = pViewShell->GetViewFrame();
+    if ( pViewFrame )
+    {
+        if ( !pViewFrame->GetFrame().IsInPlace() )
+        {
+            dispatchExecute( pViewShell, SID_VIEWSHELL1 );
+            while ( isInPrintPreview( pViewFrame ) )
+                Application::Yield();
+        }
+    }
 }
 
 sal_Int32 extractIntFromAny( const uno::Any& rAny ) throw (uno::RuntimeException)
-- 
1.7.3.4


--------------070704010006060703060206--


More information about the LibreOffice mailing list