summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Power <noel.power@novell.com>2012-04-24 11:23:46 +0100
committerNoel Power <noel.power@novell.com>2012-04-24 11:26:32 +0100
commit7ddb8f73c1a5573eedc593168f702287921ecb7a (patch)
tree53909f45bb66b2c9bf6def612257012b48b027dd
parent061e4e119cc932dadda976d2b8622f671201a6bd (diff)
tweak support Sheets.PrintPreview bnc#75784 allow specific sheet(s) selection
this is a followup to commit 17c8f6745f9f98013c1b08de8ec03be66546c7fc
-rw-r--r--sc/source/ui/inc/preview.hxx10
-rw-r--r--sc/source/ui/inc/prevwsh.hxx4
-rw-r--r--sc/source/ui/vba/vbaworksheets.cxx48
-rw-r--r--vbahelper/inc/vbahelper/vbahelper.hxx1
-rw-r--r--vbahelper/source/vbahelper/vbahelper.cxx12
5 files changed, 61 insertions, 14 deletions
diff --git a/sc/source/ui/inc/preview.hxx b/sc/source/ui/inc/preview.hxx
index f926e1abb7db..6482c05f9222 100644
--- a/sc/source/ui/inc/preview.hxx
+++ b/sc/source/ui/inc/preview.hxx
@@ -130,13 +130,13 @@ public:
virtual void DataChanged( const DataChangedEvent& rDCEvt );
- void DataChanged(bool bNewTime = false); // statt Invalidate rufen
+ SC_DLLPUBLIC void DataChanged(bool bNewTime = false); // statt Invalidate rufen
void DoInvalidate();
void SetXOffset( long nX );
void SetYOffset( long nY );
void SetZoom(sal_uInt16 nNewZoom);
- void SetPageNo( long nPage );
+ SC_DLLPUBLIC void SetPageNo( long nPage );
bool GetPageMargins() const { return bPageMargin; }
void SetPageMargins( bool bVal ) { bPageMargin = bVal; }
@@ -158,7 +158,7 @@ public:
bool AllTested() const { return bValid && nTabsTested >= nTabCount; }
sal_uInt16 GetOptimalZoom(bool bWidthOnly);
- long GetFirstPage(SCTAB nTab);
+ SC_DLLPUBLIC long GetFirstPage(SCTAB nTab);
void CalcAll() { CalcPages(); }
void SetInGetState(bool bSet) { bInGetState = bSet; }
@@ -168,8 +168,8 @@ public:
FmFormView* GetDrawView() { return pDrawView; }
- void SetSelectedTabs(const ScMarkData& rMark);
- const ScMarkData::MarkedTabsType& GetSelectedTabs() const;
+ SC_DLLPUBLIC void SetSelectedTabs(const ScMarkData& rMark);
+ SC_DLLPUBLIC const ScMarkData::MarkedTabsType& GetSelectedTabs() const;
};
diff --git a/sc/source/ui/inc/prevwsh.hxx b/sc/source/ui/inc/prevwsh.hxx
index 1ac668a11144..0664c1e5de21 100644
--- a/sc/source/ui/inc/prevwsh.hxx
+++ b/sc/source/ui/inc/prevwsh.hxx
@@ -90,7 +90,7 @@ protected:
virtual void ReadUserDataSequence (const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >&, sal_Bool bBrowse = false );
public:
- TYPEINFO();
+ TYPEINFO_VISIBILITY( SC_DLLPUBLIC );
SFX_DECL_INTERFACE(SCID_PREVIEW_SHELL)
SFX_DECL_VIEWFACTORY(ScPreviewShell);
@@ -127,7 +127,7 @@ public:
const ScPreviewLocationData& GetLocationData();
ScDocument* GetDocument();
- ScPreview* GetPreview() { return pPreview; }
+ SC_DLLPUBLIC ScPreview* GetPreview() { return pPreview; }
};
diff --git a/sc/source/ui/vba/vbaworksheets.cxx b/sc/source/ui/vba/vbaworksheets.cxx
index 3d218fab8700..e952d9a2d1cb 100644
--- a/sc/source/ui/vba/vbaworksheets.cxx
+++ b/sc/source/ui/vba/vbaworksheets.cxx
@@ -57,7 +57,8 @@
#include "markdata.hxx"
#include <vector>
-
+#include "prevwsh.hxx"
+#include "preview.hxx"
using namespace ::ooo::vba;
using namespace ::com::sun::star;
@@ -537,11 +538,52 @@ bool ScVbaWorksheets::nameExists( uno::Reference <sheet::XSpreadsheetDocument>&
return false;
}
-void ScVbaWorksheets::PrintPreview( const css::uno::Any& EnableChanges ) throw (css::uno::RuntimeException)
+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 ) );
+ ScTabViewShell* pViewShell = excel::getBestViewShell( mxModel );
+ SfxViewFrame* pViewFrame = NULL;
+ if ( pViewShell )
+ pViewFrame = pViewShell->GetViewFrame();
+ if ( pViewFrame )
+ {
+ if ( !pViewFrame->GetFrame().IsInPlace() )
+ {
+ dispatchExecute( pViewShell, SID_VIEWSHELL1 );
+ SfxViewShell* pShell = SfxViewShell::Get( pViewFrame->GetFrame().GetFrameInterface()->getController() );
+
+ if ( pShell->ISA( ScPreviewShell ) )
+ {
+ ScPreviewShell* pPrvShell = static_cast< ScPreviewShell* >( pShell );
+ ScPreview* pPrvView = pPrvShell->GetPreview();
+ ScMarkData aMarkData;
+ sal_Int32 nElems = getCount();
+ for ( sal_Int32 nItem = 1; nItem <= nElems; ++nItem )
+ {
+ uno::Reference< excel::XWorksheet > xSheet( Item( uno::makeAny( nItem ), uno::Any() ), uno::UNO_QUERY_THROW );
+ ScVbaWorksheet* pSheet = excel::getImplFromDocModuleWrapper<ScVbaWorksheet>( xSheet );
+ if ( pSheet )
+ aMarkData.SelectTable(static_cast< SCTAB >( pSheet->getSheetID() ), true );
+ }
+ // save old selection, setting the selectedtabs in the preview
+ // can affect the current selection when preview has been
+ // closed
+ ScMarkData::MarkedTabsType aOldTabs = pPrvView->GetSelectedTabs();
+ pPrvView->SetSelectedTabs( aMarkData );
+ // force update
+ pPrvView->DataChanged();
+ // set sensible first page
+ long nPage = pPrvView->GetFirstPage( 1 );
+ pPrvView->SetPageNo( nPage );
+ WaitUntilPreviewIsClosed( pViewFrame );
+ // restore old tab selection
+ pViewShell = excel::getBestViewShell( mxModel );
+ pViewShell->GetViewData()->GetMarkData().SetSelectedTabs(aOldTabs);
+ }
+ }
+ }
+
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/inc/vbahelper/vbahelper.hxx b/vbahelper/inc/vbahelper/vbahelper.hxx
index e9a316ba1e8c..0acd625053a2 100644
--- a/vbahelper/inc/vbahelper/vbahelper.hxx
+++ b/vbahelper/inc/vbahelper/vbahelper.hxx
@@ -98,6 +98,7 @@ namespace ooo
VBAHELPER_DLLPUBLIC const css::uno::Any& aNULL();
VBAHELPER_DLLPUBLIC void PrintOutHelper( SfxViewShell* pViewShell, const css::uno::Any& From, const css::uno::Any& To, const css::uno::Any& Copies, const css::uno::Any& Preview, const css::uno::Any& ActivePrinter, const css::uno::Any& PrintToFile, const css::uno::Any& Collate, const css::uno::Any& PrToFileName, sal_Bool bSelection );
VBAHELPER_DLLPUBLIC void PrintPreviewHelper( const css::uno::Any& EnableChanges, SfxViewShell* );
+ VBAHELPER_DLLPUBLIC void WaitUntilPreviewIsClosed( SfxViewFrame* );
/** Extracts a boolean value from the passed Any, which may contain a Boolean or an integer or floating-point value.
Throws, if the Any is empty or contains an incompatible type. */
diff --git a/vbahelper/source/vbahelper/vbahelper.cxx b/vbahelper/source/vbahelper/vbahelper.cxx
index 0ef22fd4fa43..ebfc85476be3 100644
--- a/vbahelper/source/vbahelper/vbahelper.cxx
+++ b/vbahelper/source/vbahelper/vbahelper.cxx
@@ -450,8 +450,7 @@ void PrintOutHelper( SfxViewShell* pViewShell, const uno::Any& From, const uno::
// #TODO is this necessary ( calc specific )
// SC_MOD()->InputEnterHandler();
pViewFrame->GetDispatcher()->Execute( SID_VIEWSHELL1, SFX_CALLMODE_SYNCHRON );
- while ( isInPrintPreview( pViewFrame ) )
- Application::Yield();
+ WaitUntilPreviewIsClosed( pViewFrame );
}
}
else
@@ -481,12 +480,17 @@ void PrintOutHelper( SfxViewShell* pViewShell, const uno::Any& From, const uno::
if ( !pViewFrame->GetFrame().IsInPlace() )
{
dispatchExecute( pViewShell, SID_VIEWSHELL1 );
- while ( isInPrintPreview( pViewFrame ) )
- Application::Yield();
+ WaitUntilPreviewIsClosed( pViewFrame );
}
}
}
+void WaitUntilPreviewIsClosed( SfxViewFrame* pViewFrame )
+{
+ while ( pViewFrame && isInPrintPreview( pViewFrame ) )
+ Application::Yield();
+}
+
bool extractBoolFromAny( const uno::Any& rAny ) throw (uno::RuntimeException)
{
switch( rAny.getValueType().getTypeClass() )