diff options
author | Noel Power <noel.power@novell.com> | 2012-04-24 11:23:46 +0100 |
---|---|---|
committer | Noel Power <noel.power@novell.com> | 2012-04-24 11:26:32 +0100 |
commit | 7ddb8f73c1a5573eedc593168f702287921ecb7a (patch) | |
tree | 53909f45bb66b2c9bf6def612257012b48b027dd /sc | |
parent | 061e4e119cc932dadda976d2b8622f671201a6bd (diff) |
tweak support Sheets.PrintPreview bnc#75784 allow specific sheet(s) selection
this is a followup to commit 17c8f6745f9f98013c1b08de8ec03be66546c7fc
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/inc/preview.hxx | 10 | ||||
-rw-r--r-- | sc/source/ui/inc/prevwsh.hxx | 4 | ||||
-rw-r--r-- | sc/source/ui/vba/vbaworksheets.cxx | 48 |
3 files changed, 52 insertions, 10 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: */ |