diff options
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/core/data/documen2.cxx | 3 | ||||
-rw-r--r-- | sc/source/core/data/table1.cxx | 46 | ||||
-rw-r--r-- | sc/source/filter/inc/xlstring.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/app/inputwin.cxx | 14 | ||||
-rw-r--r-- | sc/source/ui/dbgui/dpuiglobal.hxx | 1 | ||||
-rw-r--r-- | sc/source/ui/dbgui/fieldwnd.cxx | 9 | ||||
-rw-r--r-- | sc/source/ui/dbgui/pvlaydlg.cxx | 22 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh5.cxx | 60 | ||||
-rw-r--r-- | sc/source/ui/inc/fieldwnd.hxx | 1 | ||||
-rw-r--r-- | sc/source/ui/inc/pvlaydlg.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/vba/excelvbahelper.cxx | 87 | ||||
-rw-r--r-- | sc/source/ui/vba/excelvbahelper.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/vba/vbaworkbooks.cxx | 82 | ||||
-rw-r--r-- | sc/source/ui/vba/vbaworksheet.cxx | 16 | ||||
-rw-r--r-- | sc/source/ui/vba/vbaworksheets.cxx | 6 | ||||
-rw-r--r-- | sc/source/ui/view/output.cxx | 10 |
16 files changed, 235 insertions, 128 deletions
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index c9db6e5b428b..2188a458a855 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -904,6 +904,9 @@ sal_Bool ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, const ScMarkData* pO pTab[nNewPos]->SetPageStyle( pTab[nOldPos]->GetPageStyle() ); pTab[nNewPos]->SetPendingRowHeights( pTab[nOldPos]->IsPendingRowHeights() ); + + // Copy the custom print range if exists. + pTab[nNewPos]->CopyPrintRange(*pTab[nOldPos]); } else SetAutoCalc( bOldAutoCalc ); diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index 583dc3f1d086..d4c194676471 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -1627,6 +1627,52 @@ void ScTable::MaybeAddExtraColumn(SCCOL& rCol, SCROW nRow, OutputDevice* pDev, d rCol = nNewCol; } +namespace { + +class SetTableIndex : public ::std::unary_function<ScRange, void> +{ + SCTAB mnTab; +public: + SetTableIndex(SCTAB nTab) : mnTab(nTab) {} + + void operator() (ScRange& rRange) const + { + rRange.aStart.SetTab(mnTab); + rRange.aEnd.SetTab(mnTab); + } +}; + +} + +void ScTable::CopyPrintRange(const ScTable& rTable) +{ + // The table index shouldn't be used when the print range is used, but + // just in case set the correct table index. + + aPrintRanges = rTable.aPrintRanges; + ::std::for_each(aPrintRanges.begin(), aPrintRanges.end(), SetTableIndex(nTab)); + + bPrintEntireSheet = rTable.bPrintEntireSheet; + + delete pRepeatColRange; + pRepeatColRange = NULL; + if (rTable.pRepeatColRange) + { + pRepeatColRange = new ScRange(*rTable.pRepeatColRange); + pRepeatColRange->aStart.SetTab(nTab); + pRepeatColRange->aEnd.SetTab(nTab); + } + + delete pRepeatRowRange; + pRepeatRowRange = NULL; + if (rTable.pRepeatRowRange) + { + pRepeatRowRange = new ScRange(*rTable.pRepeatRowRange); + pRepeatRowRange->aStart.SetTab(nTab); + pRepeatRowRange->aEnd.SetTab(nTab); + } +} + void ScTable::DoColResize( SCCOL nCol1, SCCOL nCol2, SCSIZE nAdd ) { for (SCCOL nCol=nCol1; nCol<=nCol2; nCol++) diff --git a/sc/source/filter/inc/xlstring.hxx b/sc/source/filter/inc/xlstring.hxx index 15adf3f919d9..c431a594ad1a 100644 --- a/sc/source/filter/inc/xlstring.hxx +++ b/sc/source/filter/inc/xlstring.hxx @@ -46,7 +46,7 @@ const XclStrFlags EXC_STR_NOHEADER = 0x0010; /// Export: Don't write // ---------------------------------------------------------------------------- const sal_uInt16 EXC_STR_MAXLEN_8BIT = 0x00FF; -const sal_uInt16 EXC_STR_MAXLEN = 0xFFFF; +const sal_uInt16 EXC_STR_MAXLEN = 0x7FFF; const sal_uInt8 EXC_STRF_16BIT = 0x01; const sal_uInt8 EXC_STRF_FAREAST = 0x04; diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx index 6a93fc130e02..c03799aa6ffe 100644 --- a/sc/source/ui/app/inputwin.cxx +++ b/sc/source/ui/app/inputwin.cxx @@ -1662,6 +1662,10 @@ void ScPosWnd::DoEnter() ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell(); if ( pViewSh ) { + ScViewData* pViewData = pViewSh->GetViewData(); + ScDocShell* pDocShell = pViewData->GetDocShell(); + ScDocument* pDoc = pDocShell->GetDocument(); + ScNameInputType eType = lcl_GetInputType( aText ); if ( eType == SC_NAME_INPUT_BAD_NAME || eType == SC_NAME_INPUT_BAD_SELECTION ) { @@ -1670,9 +1674,6 @@ void ScPosWnd::DoEnter() } else if ( eType == SC_NAME_INPUT_DEFINE ) { - ScViewData* pViewData = pViewSh->GetViewData(); - ScDocShell* pDocShell = pViewData->GetDocShell(); - ScDocument* pDoc = pDocShell->GetDocument(); ScRangeName* pNames = pDoc->GetRangeName(); ScRange aSelection; if ( pNames && !pNames->findByName(aText) && @@ -1695,7 +1696,12 @@ void ScPosWnd::DoEnter() } else { - // for all selection types, excecute the SID_CURRENTCELL slot + // for all selection types, excecute the SID_CURRENTCELL slot. + // Note that SID_CURRENTCELL always expects address to be + // in Calc A1 format. Convert the text. + ScRange aRange; + aRange.ParseAny(aText, pDoc, pDoc->GetAddressConvention()); + aRange.Format(aText, SCR_ABS_3D, pDoc, ::formula::FormulaGrammar::CONV_OOO); SfxStringItem aPosItem( SID_CURRENTCELL, aText ); SfxBoolItem aUnmarkItem( FN_PARAM_1, sal_True ); // remove existing selection diff --git a/sc/source/ui/dbgui/dpuiglobal.hxx b/sc/source/ui/dbgui/dpuiglobal.hxx index b64875030bcf..d27d8278d83b 100644 --- a/sc/source/ui/dbgui/dpuiglobal.hxx +++ b/sc/source/ui/dbgui/dpuiglobal.hxx @@ -33,7 +33,6 @@ #define OUTER_MARGIN_VER 4 #define DATA_FIELD_BTN_GAP 2 // must be an even number #define ROW_FIELD_BTN_GAP 2 // must be an even number -#define FIELD_BTN_WIDTH 81 #define FIELD_BTN_HEIGHT 23 #define SELECT_FIELD_BTN_SPACE 2 #define FIELD_AREA_GAP 3 // gap between row/column/data/page areas diff --git a/sc/source/ui/dbgui/fieldwnd.cxx b/sc/source/ui/dbgui/fieldwnd.cxx index 32ba4a949769..061900ce5e4d 100644 --- a/sc/source/ui/dbgui/fieldwnd.cxx +++ b/sc/source/ui/dbgui/fieldwnd.cxx @@ -611,6 +611,11 @@ void ScDPFieldControlBase::DrawInvertSelection() InvertTracking(aSel, SHOWTRACK_SMALL | SHOWTRACK_WINDOW); } +Size ScDPFieldControlBase::GetStdFieldBtnSize() const +{ + return mpDlg->GetStdFieldBtnSize(); +} + bool ScDPFieldControlBase::IsShortenedText( size_t nIndex ) const { const FieldNames& rFields = GetFieldNames(); @@ -726,7 +731,7 @@ Point ScDPHorFieldControl::GetFieldPosition( size_t nIndex ) Size ScDPHorFieldControl::GetFieldSize() const { - return Size(FIELD_BTN_WIDTH, FIELD_BTN_HEIGHT); + return GetStdFieldBtnSize(); } bool ScDPHorFieldControl::GetFieldIndex( const Point& rPos, size_t& rnIndex ) @@ -1032,7 +1037,7 @@ Point ScDPRowFieldControl::GetFieldPosition(size_t nIndex) Size ScDPRowFieldControl::GetFieldSize() const { - return Size(FIELD_BTN_WIDTH, FIELD_BTN_HEIGHT); + return GetStdFieldBtnSize(); } bool ScDPRowFieldControl::GetFieldIndex( const Point& rPos, size_t& rnIndex ) diff --git a/sc/source/ui/dbgui/pvlaydlg.cxx b/sc/source/ui/dbgui/pvlaydlg.cxx index d7109d1f7315..f280af43f7e0 100644 --- a/sc/source/ui/dbgui/pvlaydlg.cxx +++ b/sc/source/ui/dbgui/pvlaydlg.cxx @@ -1132,6 +1132,14 @@ void ScDPLayoutDlg::NotifyRemoveField( ScDPFieldType eType, size_t nFieldIndex ) RemoveField( eType, nFieldIndex ); } +Size ScDPLayoutDlg::GetStdFieldBtnSize() const +{ + // This size is static but is platform dependent. The field button size + // is calculated relative to the size of the OK button. + double w = static_cast<double>(aBtnOk.GetSizePixel().Width()) * 0.70; + return Size(static_cast<long>(w), FIELD_BTN_HEIGHT); +} + void ScDPLayoutDlg::Deactivate() { /* If the dialog has been deactivated (click into document), the LoseFocus @@ -1290,10 +1298,18 @@ Point ScDPLayoutDlg::DlgPos2WndPos( const Point& rPt, Window& rWnd ) void ScDPLayoutDlg::CalcWndSizes() { + // The pivot.src file only specifies the positions of the controls. Here, + // we calculate appropriate size of each control based on how they are + // positioned relative to each other. + // row/column/data area sizes - long nFldW = FIELD_BTN_WIDTH; - long nFldH = FIELD_BTN_HEIGHT; - aWndData.SetSizePixel(Size(338, 185)); + long nFldW = GetStdFieldBtnSize().Width(); + long nFldH = GetStdFieldBtnSize().Height(); + + aWndData.SetSizePixel( + Size(aWndSelect.GetPosPixel().X() - aWndData.GetPosPixel().X() - FIELD_AREA_GAP*4, + 185)); + aWndPage.SetSizePixel( Size(aWndData.GetSizePixel().Width() + 85, aWndCol.GetPosPixel().Y() - aWndPage.GetPosPixel().Y() - FIELD_AREA_GAP)); diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx index 368a1f39edd3..1bd3bfecbd53 100644 --- a/sc/source/ui/docshell/docsh5.cxx +++ b/sc/source/ui/docshell/docsh5.cxx @@ -924,37 +924,37 @@ sal_Bool ScDocShell::MoveTable( SCTAB nSrcTab, SCTAB nDestTab, sal_Bool bCopy, s } sal_Bool bVbaEnabled = aDocument.IsInVBAMode(); - if ( bVbaEnabled ) - { - String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); - Reference< XLibraryContainer > xLibContainer = GetBasicContainer(); - Reference< XVBACompatibility > xVBACompat( xLibContainer, UNO_QUERY ); - - if ( xVBACompat.is() ) - { - aLibName = xVBACompat->getProjectName(); - } - - SCTAB nTabToUse = nDestTab; - if ( nDestTab == SC_TAB_APPEND ) - nTabToUse = aDocument.GetMaxTableNumber() - 1; - String sCodeName; - String sSource; - Reference< XNameContainer > xLib; - if( xLibContainer.is() ) - { - com::sun::star::uno::Any aLibAny = xLibContainer->getByName( aLibName ); - aLibAny >>= xLib; - } - if( xLib.is() ) - { - rtl::OUString sRTLSource; - xLib->getByName( sSrcCodeName ) >>= sRTLSource; - sSource = sRTLSource; - } - VBA_InsertModule( aDocument, nTabToUse, sCodeName, sSource ); - } + if ( bVbaEnabled ) + { + String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); + Reference< XLibraryContainer > xLibContainer = GetBasicContainer(); + Reference< XVBACompatibility > xVBACompat( xLibContainer, UNO_QUERY ); + + if ( xVBACompat.is() ) + { + aLibName = xVBACompat->getProjectName(); + } + + SCTAB nTabToUse = nDestTab; + if ( nDestTab == SC_TAB_APPEND ) + nTabToUse = aDocument.GetMaxTableNumber() - 1; + String sCodeName; + String sSource; + Reference< XNameContainer > xLib; + if( xLibContainer.is() ) + { + com::sun::star::uno::Any aLibAny = xLibContainer->getByName( aLibName ); + aLibAny >>= xLib; + } + if( xLib.is() ) + { + rtl::OUString sRTLSource; + xLib->getByName( sSrcCodeName ) >>= sRTLSource; + sSource = sRTLSource; } + VBA_InsertModule( aDocument, nTabToUse, sCodeName, sSource ); + } + } Broadcast( ScTablesHint( SC_TAB_COPIED, nSrcTab, nDestTab ) ); } else diff --git a/sc/source/ui/inc/fieldwnd.hxx b/sc/source/ui/inc/fieldwnd.hxx index 78358557444c..edd8aec6a568 100644 --- a/sc/source/ui/inc/fieldwnd.hxx +++ b/sc/source/ui/inc/fieldwnd.hxx @@ -195,6 +195,7 @@ protected: void AppendPaintable(Window* p); void DrawPaintables(); void DrawInvertSelection(); + Size GetStdFieldBtnSize() const; /** @return The new selection index after moving to the given direction. */ virtual size_t CalcNewFieldIndex( SCsCOL nDX, SCsROW nDY ) const = 0; diff --git a/sc/source/ui/inc/pvlaydlg.hxx b/sc/source/ui/inc/pvlaydlg.hxx index 19176e7fdc61..875f25dbcde1 100644 --- a/sc/source/ui/inc/pvlaydlg.hxx +++ b/sc/source/ui/inc/pvlaydlg.hxx @@ -104,6 +104,8 @@ public: void NotifyMoveFieldToEnd ( ScDPFieldType eToType ); void NotifyRemoveField ( ScDPFieldType eType, size_t nFieldIndex ); + Size GetStdFieldBtnSize() const; + protected: virtual void Deactivate(); diff --git a/sc/source/ui/vba/excelvbahelper.cxx b/sc/source/ui/vba/excelvbahelper.cxx index 4f49aab539c4..d98f1ac7ee1e 100644 --- a/sc/source/ui/vba/excelvbahelper.cxx +++ b/sc/source/ui/vba/excelvbahelper.cxx @@ -39,6 +39,13 @@ #include "token.hxx" #include "tokenarray.hxx" +#include <com/sun/star/script/vba/VBAEventId.hpp> +#include <com/sun/star/script/vba/XVBACompatibility.hpp> +#include <com/sun/star/script/vba/XVBAEventProcessor.hpp> +#include <com/sun/star/script/vba/XVBAModuleInfo.hpp> +#include <com/sun/star/script/ModuleInfo.hpp> +#include <com/sun/star/script/ModuleType.hpp> + using namespace ::com::sun::star; using namespace ::ooo::vba; @@ -460,6 +467,86 @@ getUnoSheetModuleObj( const uno::Reference< frame::XModel >& xModel, SCTAB nTab return getUnoSheetModuleObj( xSheet ); } +void setUpDocumentModules( const uno::Reference< sheet::XSpreadsheetDocument >& xDoc ) +{ + uno::Reference< frame::XModel > xModel( xDoc, uno::UNO_QUERY ); + ScDocShell* pShell = excel::getDocShell( xModel ); + if ( pShell ) + { + String aPrjName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); + pShell->GetBasicManager()->SetName( aPrjName ); + + /* Set library container to VBA compatibility mode. This will create + the VBA Globals object and store it in the Basic manager of the + document. */ + uno::Reference<script::XLibraryContainer> xLibContainer = pShell->GetBasicContainer(); + uno::Reference<script::vba::XVBACompatibility> xVBACompat( xLibContainer, uno::UNO_QUERY_THROW ); + xVBACompat->setVBACompatibilityMode( sal_True ); + + if( xLibContainer.is() ) + { + if( !xLibContainer->hasByName( aPrjName ) ) + xLibContainer->createLibrary( aPrjName ); + uno::Any aLibAny = xLibContainer->getByName( aPrjName ); + uno::Reference< container::XNameContainer > xLib; + aLibAny >>= xLib; + if( xLib.is() ) + { + uno::Reference< script::vba::XVBAModuleInfo > xVBAModuleInfo( xLib, uno::UNO_QUERY_THROW ); + uno::Reference< lang::XMultiServiceFactory> xSF( pShell->GetModel(), uno::UNO_QUERY_THROW); + uno::Reference< container::XNameAccess > xVBACodeNamedObjectAccess( xSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAObjectModuleObjectProvider"))), uno::UNO_QUERY_THROW ); + // set up the module info for the workbook and sheets in the nealy created + // spreadsheet + ScDocument* pDoc = pShell->GetDocument(); + String sCodeName = pDoc->GetCodeName(); + if ( sCodeName.Len() == 0 ) + { + sCodeName = String( RTL_CONSTASCII_USTRINGPARAM("ThisWorkbook") ); + pDoc->SetCodeName( sCodeName ); + } + + std::vector< rtl::OUString > sDocModuleNames; + sDocModuleNames.push_back( sCodeName ); + + for ( SCTAB index = 0; index < pDoc->GetTableCount(); index++) + { + String aName; + pDoc->GetCodeName( index, aName ); + sDocModuleNames.push_back( aName ); + } + + std::vector<rtl::OUString>::iterator it_end = sDocModuleNames.end(); + + for ( std::vector<rtl::OUString>::iterator it = sDocModuleNames.begin(); it != it_end; ++it ) + { + script::ModuleInfo sModuleInfo; + + uno::Any aName= xVBACodeNamedObjectAccess->getByName( *it ); + sModuleInfo.ModuleObject.set( aName, uno::UNO_QUERY ); + sModuleInfo.ModuleType = script::ModuleType::DOCUMENT; + xVBAModuleInfo->insertModuleInfo( *it, sModuleInfo ); + if( xLib->hasByName( *it ) ) + xLib->replaceByName( *it, uno::makeAny( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Option VBASupport 1\n") ) ) ); + else + xLib->insertByName( *it, uno::makeAny( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Option VBASupport 1\n" ) ) ) ); + } + } + } + + /* Trigger the Workbook_Open event, event processor will register + itself as listener for specific events. */ + try + { + uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( pShell->GetDocument()->GetVbaEventProcessor(), uno::UNO_SET_THROW ); + uno::Sequence< uno::Any > aArgs; + xVbaEvents->processVbaEvent( script::vba::VBAEventId::WORKBOOK_OPEN, aArgs ); + } + catch( uno::Exception& ) + { + } + } +} + SfxItemSet* ScVbaCellRangeAccess::GetDataSet( ScCellRangesBase* pRangeObj ) { diff --git a/sc/source/ui/vba/excelvbahelper.hxx b/sc/source/ui/vba/excelvbahelper.hxx index 296b80862d8c..9befc1548357 100644 --- a/sc/source/ui/vba/excelvbahelper.hxx +++ b/sc/source/ui/vba/excelvbahelper.hxx @@ -35,6 +35,7 @@ #include <com/sun/star/table/XCellRange.hpp> #include <com/sun/star/sheet/XSheetCellRangeContainer.hpp> #include <com/sun/star/sheet/XSpreadsheet.hpp> +#include <com/sun/star/sheet/XSpreadsheetDocument.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp> #include <ooo/vba/XHelperInterface.hpp> #include <formula/grammar.hxx> @@ -76,6 +77,7 @@ ScDocShell* GetDocShellFromRange( const css::uno::Reference< css::uno::XInterfac ScDocShell* GetDocShellFromRanges( const css::uno::Reference< css::sheet::XSheetCellRangeContainer >& xRanges ) throw ( css::uno::RuntimeException ); ScDocument* GetDocumentFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException ); css::uno::Reference< css::frame::XModel > GetModelFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException ); +void setUpDocumentModules( const css::uno::Reference< css::sheet::XSpreadsheetDocument >& xDoc ); // ============================================================================ diff --git a/sc/source/ui/vba/vbaworkbooks.cxx b/sc/source/ui/vba/vbaworkbooks.cxx index 86b24c3dec92..39f6f66db091 100644 --- a/sc/source/ui/vba/vbaworkbooks.cxx +++ b/sc/source/ui/vba/vbaworkbooks.cxx @@ -70,86 +70,6 @@ using namespace ::com::sun::star; const sal_Int16 CUSTOM_CHAR = 5; -void setUpDocumentModules( const uno::Reference< sheet::XSpreadsheetDocument >& xDoc ) -{ - uno::Reference< frame::XModel > xModel( xDoc, uno::UNO_QUERY ); - ScDocShell* pShell = excel::getDocShell( xModel ); - if ( pShell ) - { - String aPrjName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); - pShell->GetBasicManager()->SetName( aPrjName ); - - /* Set library container to VBA compatibility mode. This will create - the VBA Globals object and store it in the Basic manager of the - document. */ - uno::Reference<script::XLibraryContainer> xLibContainer = pShell->GetBasicContainer(); - uno::Reference<script::vba::XVBACompatibility> xVBACompat( xLibContainer, uno::UNO_QUERY_THROW ); - xVBACompat->setVBACompatibilityMode( sal_True ); - - if( xLibContainer.is() ) - { - if( !xLibContainer->hasByName( aPrjName ) ) - xLibContainer->createLibrary( aPrjName ); - uno::Any aLibAny = xLibContainer->getByName( aPrjName ); - uno::Reference< container::XNameContainer > xLib; - aLibAny >>= xLib; - if( xLib.is() ) - { - uno::Reference< script::vba::XVBAModuleInfo > xVBAModuleInfo( xLib, uno::UNO_QUERY_THROW ); - uno::Reference< lang::XMultiServiceFactory> xSF( pShell->GetModel(), uno::UNO_QUERY_THROW); - uno::Reference< container::XNameAccess > xVBACodeNamedObjectAccess( xSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAObjectModuleObjectProvider"))), uno::UNO_QUERY_THROW ); - // set up the module info for the workbook and sheets in the nealy created - // spreadsheet - ScDocument* pDoc = pShell->GetDocument(); - String sCodeName = pDoc->GetCodeName(); - if ( sCodeName.Len() == 0 ) - { - sCodeName = String( RTL_CONSTASCII_USTRINGPARAM("ThisWorkbook") ); - pDoc->SetCodeName( sCodeName ); - } - - std::vector< rtl::OUString > sDocModuleNames; - sDocModuleNames.push_back( sCodeName ); - - uno::Reference<container::XNameAccess > xSheets( xDoc->getSheets(), uno::UNO_QUERY_THROW ); - uno::Sequence< rtl::OUString > sSheets( xSheets->getElementNames() ); - - for ( sal_Int32 index=0; index < sSheets.getLength() ; ++index ) - { - sDocModuleNames.push_back( sSheets[ index ] ); - } - - std::vector<rtl::OUString>::iterator it_end = sDocModuleNames.end(); - - for ( std::vector<rtl::OUString>::iterator it = sDocModuleNames.begin(); it != it_end; ++it ) - { - script::ModuleInfo sModuleInfo; - - sModuleInfo.ModuleObject.set( xVBACodeNamedObjectAccess->getByName( *it ), uno::UNO_QUERY ); - sModuleInfo.ModuleType = script::ModuleType::DOCUMENT; - xVBAModuleInfo->insertModuleInfo( *it, sModuleInfo ); - if( xLib->hasByName( *it ) ) - xLib->replaceByName( *it, uno::makeAny( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Option VBASupport 1\n") ) ) ); - else - xLib->insertByName( *it, uno::makeAny( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Option VBASupport 1\n" ) ) ) ); - } - } - } - - /* Trigger the Workbook_Open event, event processor will register - itself as listener for specific events. */ - try - { - uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( pShell->GetDocument()->GetVbaEventProcessor(), uno::UNO_SET_THROW ); - uno::Sequence< uno::Any > aArgs; - xVbaEvents->processVbaEvent( script::vba::VBAEventId::WORKBOOK_OPEN, aArgs ); - } - catch( uno::Exception& ) - { - } - } -} - static uno::Any getWorkbook( uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< sheet::XSpreadsheetDocument > &xDoc, const uno::Reference< XHelperInterface >& xParent ) { @@ -254,7 +174,7 @@ ScVbaWorkbooks::Add( const uno::Any& Template ) throw (uno::RuntimeException) } // need to set up the document modules ( and vba mode ) here - setUpDocumentModules( xSpreadDoc ); + excel::setUpDocumentModules( xSpreadDoc ); if( xSpreadDoc.is() ) return getWorkbook( mxContext, xSpreadDoc, mxParent ); return uno::Any(); diff --git a/sc/source/ui/vba/vbaworksheet.cxx b/sc/source/ui/vba/vbaworksheet.cxx index f3c5bb18efe2..87fb2e9a07e3 100644 --- a/sc/source/ui/vba/vbaworksheet.cxx +++ b/sc/source/ui/vba/vbaworksheet.cxx @@ -72,6 +72,13 @@ #include <comphelper/processfactory.hxx> #include <vbahelper/vbashapes.hxx> +#include <com/sun/star/script/vba/VBAEventId.hpp> +#include <com/sun/star/script/vba/XVBACompatibility.hpp> +#include <com/sun/star/script/vba/XVBAEventProcessor.hpp> +#include <com/sun/star/script/vba/XVBAModuleInfo.hpp> +#include <com/sun/star/script/ModuleInfo.hpp> +#include <com/sun/star/script/ModuleType.hpp> + #include <tools/string.hxx> //zhangyun showdataform @@ -245,12 +252,15 @@ ScVbaWorksheet::createSheetCopyInNewDoc(rtl::OUString aCurrSheetName) excel::implnPaste(xModel); } uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( xModel, uno::UNO_QUERY_THROW ); + excel::setUpDocumentModules(xSpreadDoc); uno::Reference <sheet::XSpreadsheets> xSheets( xSpreadDoc->getSheets(), uno::UNO_QUERY_THROW ); uno::Reference <container::XIndexAccess> xIndex( xSheets, uno::UNO_QUERY_THROW ); uno::Reference< sheet::XSpreadsheet > xSheet(xIndex->getByIndex(0), uno::UNO_QUERY_THROW); - //#TODO #FIXME - //get proper parent for Worksheet - return new ScVbaWorksheet( NULL, mxContext, xSheet, xModel ); + + ScDocShell* pShell = excel::getDocShell( xModel ); + String aCodeName; + pShell->GetDocument()->GetCodeName( 0, aCodeName ); + return uno::Reference< excel::XWorksheet >( getUnoDocModule( aCodeName, pShell ), uno::UNO_QUERY_THROW ); } css::uno::Reference< ov::excel::XWorksheet > diff --git a/sc/source/ui/vba/vbaworksheets.cxx b/sc/source/ui/vba/vbaworksheets.cxx index 80b6537d865c..e2c436b13966 100644 --- a/sc/source/ui/vba/vbaworksheets.cxx +++ b/sc/source/ui/vba/vbaworksheets.cxx @@ -447,8 +447,12 @@ ScVbaWorksheets::Copy ( const uno::Any& Before, const uno::Any& After) throw (cs xSheet = pSrcSheet->createSheetCopyInNewDoc(xSrcSheet->getName()); nItem = 1; } + else + { + nItem=0; + } - for (nItem = 0; nItem < nElems; ++nItem ) + for (; nItem < nElems; ++nItem ) { xSrcSheet = Sheets[nItem]; ScVbaWorksheet* pSrcSheet = excel::getImplFromDocModuleWrapper<ScVbaWorksheet>( xSrcSheet ); diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx index b1143ced0b10..b69f2ace659a 100644 --- a/sc/source/ui/view/output.cxx +++ b/sc/source/ui/view/output.cxx @@ -1222,6 +1222,9 @@ void ScOutputData::DrawFrame() // draw only rows with set RowInfo::bChanged flag size_t nRow1 = nFirstRow; drawinglayer::processor2d::BaseProcessor2D* pProcessor = CreateProcessor2D(); + if (!pProcessor) + return; + while( nRow1 <= nLastRow ) { while( (nRow1 <= nLastRow) && !pRowInfo[ nRow1 ].bChanged ) ++nRow1; @@ -1631,9 +1634,12 @@ void ScOutputData::DrawRotatedFrame( const Color* pForceColor ) drawinglayer::processor2d::BaseProcessor2D* ScOutputData::CreateProcessor2D( ) { - basegfx::B2DRange aViewRange; + ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer(); + if (!pDrawLayer) + return NULL; - SdrPage *pDrawPage = pDoc->GetDrawLayer()->GetPage( static_cast< sal_uInt16 >( nTab ) ); + basegfx::B2DRange aViewRange; + SdrPage *pDrawPage = pDrawLayer->GetPage( static_cast< sal_uInt16 >( nTab ) ); const drawinglayer::geometry::ViewInformation2D aNewViewInfos( basegfx::B2DHomMatrix( ), pDev->GetViewTransformation(), |