summaryrefslogtreecommitdiff
path: root/sc/source/filter/excel
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/filter/excel')
-rw-r--r--sc/source/filter/excel/colrowst.cxx8
-rw-r--r--sc/source/filter/excel/excdoc.cxx19
-rw-r--r--sc/source/filter/excel/excimp8.cxx85
-rw-r--r--sc/source/filter/excel/impop.cxx78
-rw-r--r--sc/source/filter/excel/read.cxx8
-rw-r--r--sc/source/filter/excel/xeescher.cxx4
-rw-r--r--sc/source/filter/excel/xepage.cxx31
-rw-r--r--sc/source/filter/excel/xeroot.cxx23
-rw-r--r--sc/source/filter/excel/xestyle.cxx1
-rw-r--r--sc/source/filter/excel/xetable.cxx19
-rw-r--r--sc/source/filter/excel/xeview.cxx43
-rwxr-xr-xsc/source/filter/excel/xichart.cxx10
-rw-r--r--sc/source/filter/excel/xiescher.cxx21
-rw-r--r--sc/source/filter/excel/xipage.cxx4
-rw-r--r--sc/source/filter/excel/xiroot.cxx27
-rw-r--r--sc/source/filter/excel/xiview.cxx22
-rw-r--r--sc/source/filter/excel/xlescher.cxx93
-rw-r--r--sc/source/filter/excel/xltools.cxx35
-rw-r--r--sc/source/filter/excel/xlview.cxx1
19 files changed, 309 insertions, 223 deletions
diff --git a/sc/source/filter/excel/colrowst.cxx b/sc/source/filter/excel/colrowst.cxx
index 3a48aa6b96ba..01587c036dea 100644
--- a/sc/source/filter/excel/colrowst.cxx
+++ b/sc/source/filter/excel/colrowst.cxx
@@ -207,7 +207,7 @@ void XclImpColRowSettings::Convert( SCTAB nScTab )
// row heights ------------------------------------------------------------
// #i54252# set default row height
- rDoc.SetRowHeightRange( 0, MAXROW, nScTab, mnDefHeight );
+ rDoc.SetRowHeightOnly( 0, MAXROW, nScTab, mnDefHeight );
if( ::get_flag( mnDefRowFlags, EXC_DEFROW_UNSYNCED ) )
// first access to row flags, do not ask for old flags
rDoc.SetRowFlags( 0, MAXROW, nScTab, CR_MANUALSIZE );
@@ -258,7 +258,7 @@ void XclImpColRowSettings::Convert( SCTAB nScTab )
{
DBG_ASSERT( (nScRow == 0) || (nFirstScRow >= 0), "XclImpColRowSettings::Convert - algorithm error" );
if( nScRow > 0 )
- rDoc.SetRowHeightRange( nFirstScRow, nScRow - 1, nScTab, nLastHeight );
+ rDoc.SetRowHeightOnly( nFirstScRow, nScRow - 1, nScTab, nLastHeight );
nFirstScRow = nScRow;
nLastHeight = nHeight;
@@ -267,7 +267,7 @@ void XclImpColRowSettings::Convert( SCTAB nScTab )
// set row height of last portion
if( mnLastScRow >= 0 )
- rDoc.SetRowHeightRange( nFirstScRow, mnLastScRow, nScTab, nLastHeight );
+ rDoc.SetRowHeightOnly( nFirstScRow, mnLastScRow, nScTab, nLastHeight );
// ------------------------------------------------------------------------
@@ -307,7 +307,7 @@ void XclImpColRowSettings::ConvertHiddenFlags( SCTAB nScTab )
rDoc.ShowRow( nScRow, nScTab, FALSE );
// #i38093# rows hidden by filter need extra flag
if( (nFirstFilterScRow <= nScRow) && (nScRow <= nLastFilterScRow) )
- rDoc.SetRowFlags( nScRow, nScTab, rDoc.GetRowFlags( nScRow, nScTab ) | CR_FILTERED );
+ rDoc.SetRowFiltered(nScRow, nScRow, nScTab, true);
}
}
diff --git a/sc/source/filter/excel/excdoc.cxx b/sc/source/filter/excel/excdoc.cxx
index 5534f8e775a9..2cf2d8f580c0 100644
--- a/sc/source/filter/excel/excdoc.cxx
+++ b/sc/source/filter/excel/excdoc.cxx
@@ -200,17 +200,12 @@ void ExcTable::FillAsHeader( ExcBoundsheetList& rBoundsheetList )
UINT16 nExcTabCount = rTabInfo.GetXclTabCount();
UINT16 nCodenames = static_cast< UINT16 >( GetExtDocOptions().GetCodeNameCount() );
- sal_uInt16 nWriteProtHash = 0;
- if( SfxObjectShell* pDocShell = GetDocShell() )
- {
- ScfPropertySet aPropSet( pDocShell->GetModel() );
- sal_Int32 nApiHash = 0;
- if( aPropSet.GetProperty( nApiHash, CREATE_OUSTRING( "WriteProtectionPassword" ) ) && (0 < nApiHash) && (nApiHash <= SAL_MAX_UINT16) )
- {
- nWriteProtHash = static_cast< sal_uInt16 >( nApiHash );
- Add( new XclExpEmptyRecord( EXC_ID_WRITEPROT ) );
- }
- }
+ SfxObjectShell* pShell = GetDocShell();
+ sal_uInt16 nWriteProtHash = pShell ? pShell->GetModifyPasswordHash() : 0;
+ bool bRecommendReadOnly = pShell && pShell->IsLoadReadonly();
+
+ if( (nWriteProtHash > 0) || bRecommendReadOnly )
+ Add( new XclExpEmptyRecord( EXC_ID_WRITEPROT ) );
// TODO: correct codepage for BIFF5?
sal_uInt16 nCodePage = XclTools::GetXclCodePage( (GetBiff() <= EXC_BIFF5) ? RTL_TEXTENCODING_MS_1252 : RTL_TEXTENCODING_UNICODE );
@@ -234,7 +229,7 @@ void ExcTable::FillAsHeader( ExcBoundsheetList& rBoundsheetList )
Add( new XclExpWriteAccess );
}
- Add( new XclExpFileSharing( GetRoot(), nWriteProtHash ) );
+ Add( new XclExpFileSharing( GetRoot(), nWriteProtHash, bRecommendReadOnly ) );
Add( new XclExpUInt16Record( EXC_ID_CODEPAGE, nCodePage ) );
if( GetBiff() == EXC_BIFF8 )
diff --git a/sc/source/filter/excel/excimp8.cxx b/sc/source/filter/excel/excimp8.cxx
index a3ea403bf4c3..9608804da9f9 100644
--- a/sc/source/filter/excel/excimp8.cxx
+++ b/sc/source/filter/excel/excimp8.cxx
@@ -30,6 +30,7 @@
#include "excimp8.hxx"
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
#include <scitems.hxx>
#include <comphelper/processfactory.hxx>
@@ -54,6 +55,8 @@
#include <editeng/flditem.hxx>
#include <svx/xflclit.hxx>
#include <filter/msfilter/svxmsbas.hxx>
+#include <basic/basmgr.hxx>
+#include <oox/xls/excelvbaproject.hxx>
#include <vcl/graph.hxx>
#include <vcl/bmpacc.hxx>
@@ -64,6 +67,7 @@
#include <tools/string.hxx>
#include <tools/urlobj.hxx>
#include <rtl/math.hxx>
+#include <rtl/ustrbuf.hxx>
#include <unotools/localedatawrapper.hxx>
#include <unotools/charclass.hxx>
#include <drwlayer.hxx>
@@ -99,27 +103,19 @@
#include <com/sun/star/document/XDocumentProperties.hpp>
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
-#include <basic/basmgr.hxx>
#include <cppuhelper/component_context.hxx>
-#include <com/sun/star/container/XNameContainer.hpp>
#include <sfx2/app.hxx>
using namespace com::sun::star;
-
-
-#define INVALID_POS 0xFFFFFFFF
-
-
+using ::rtl::OUString;
ImportExcel8::ImportExcel8( XclImpRootData& rImpData, SvStream& rStrm ) :
- ImportExcel( rImpData, rStrm ), mnTab(0)
+ ImportExcel( rImpData, rStrm )
{
+ // replace BIFF2-BIFF5 formula importer with BIFF8 formula importer
delete pFormConv;
-
pFormConv = pExcRoot->pFmlaConverter = new ExcelToSc8( GetRoot() );
-
- bHasBasic = FALSE;
}
@@ -228,27 +224,6 @@ void ImportExcel8::Labelsst( void )
}
-void ImportExcel8::Codename( BOOL bWorkbookGlobals )
-{
- if( bHasBasic )
- {
- String aName( aIn.ReadUniString() );
- if( aName.Len() )
- {
- if( bWorkbookGlobals )
- {
- GetExtDocOptions().GetDocSettings().maGlobCodeName = aName;
- GetDoc().SetCodeName( aName );
- }
- else
- {
- GetExtDocOptions().AppendCodeName( aName );
- GetDoc().SetCodeName( mnTab++, aName );
- }
- }
- }
-}
-
void ImportExcel8::SheetProtection( void )
{
GetSheetProtectBuffer().ReadOptions( aIn, GetCurrScTab() );
@@ -294,9 +269,8 @@ void ImportExcel8::EndSheet( void )
void ImportExcel8::PostDocLoad( void )
{
- // delay reading basic until sheet object ( codenames etc. ) are read
-
- if ( bHasBasic )
+ // reading basic has been delayed until sheet objects (codenames etc.) are read
+ if( HasBasic() )
ReadBasic();
// #i11776# filtered ranges before outlines and hidden rows
if( pExcRoot->pAutoFilterBuffer )
@@ -317,24 +291,47 @@ void ImportExcel8::PostDocLoad( void )
}
// read doc info (no docshell while pasting from clipboard)
+ LoadDocumentProperties();
+ // attach document events to VBA macros
+ AttachDocumentEvents();
+
+ // #i45843# Pivot tables are now handled outside of PostDocLoad, so they are available
+ // when formula cells are calculated, for the GETPIVOTDATA function.
+}
+
+void ImportExcel8::LoadDocumentProperties()
+{
+ // no docshell while pasting from clipboard
if( SfxObjectShell* pShell = GetDocShell() )
{
// BIFF5+ without storage is possible
SotStorageRef xRootStrg = GetRootStorage();
- if( xRootStrg.Is() )
+ if( xRootStrg.Is() ) try
+ {
+ uno::Reference< document::XDocumentPropertiesSupplier > xDPS( pShell->GetModel(), uno::UNO_QUERY_THROW );
+ uno::Reference< document::XDocumentProperties > xDocProps( xDPS->getDocumentProperties(), uno::UNO_SET_THROW );
+ sfx2::LoadOlePropertySet( xDocProps, xRootStrg );
+ }
+ catch( uno::Exception& )
{
- uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
- pShell->GetModel(), uno::UNO_QUERY_THROW);
- uno::Reference<document::XDocumentProperties> xDocProps
- = xDPS->getDocumentProperties();
- sfx2::LoadOlePropertySet(xDocProps, GetRootStorage());
}
}
-
- // #i45843# Pivot tables are now handled outside of PostDocLoad, so they are available
- // when formula cells are calculated, for the GETPIVOTDATA function.
}
+void ImportExcel8::AttachDocumentEvents()
+{
+ SfxObjectShell* pShell = GetDocShell();
+ if( HasBasic() && pShell )
+ {
+ uno::Reference< lang::XMultiServiceFactory > xGlobalFactory = ::comphelper::getProcessServiceFactory();
+ uno::Reference< sheet::XSpreadsheetDocument > xDocument( pShell->GetModel(), uno::UNO_QUERY );
+ if( xGlobalFactory.is() && xDocument.is() )
+ {
+ ::oox::xls::VbaProject aVbaProject( xGlobalFactory, xDocument );
+ aVbaProject.attachToEvents();
+ }
+ }
+}
//___________________________________________________________________
// autofilter
diff --git a/sc/source/filter/excel/impop.cxx b/sc/source/filter/excel/impop.cxx
index e62f050f2351..209d24ac043d 100644
--- a/sc/source/filter/excel/impop.cxx
+++ b/sc/source/filter/excel/impop.cxx
@@ -122,7 +122,8 @@ ImportExcel::ImportExcel( XclImpRootData& rImpData, SvStream& rStrm ):
ImportTyp( &rImpData.mrDoc, rImpData.meTextEnc ),
XclImpRoot( rImpData ),
maStrm( rStrm, GetRoot() ),
- aIn( maStrm )
+ aIn( maStrm ),
+ maScOleSize( ScAddress::INITIALIZE_INVALID )
{
mnLastRefIdx = 0;
nBdshtTab = 0;
@@ -178,15 +179,16 @@ void ImportExcel::ReadFileSharing()
maStrm >> nRecommendReadOnly >> nPasswordHash;
if( (nRecommendReadOnly != 0) || (nPasswordHash != 0) )
+ {
if( SfxItemSet* pItemSet = GetMedium().GetItemSet() )
pItemSet->Put( SfxBoolItem( SID_DOC_READONLY, TRUE ) );
- if( nPasswordHash != 0 )
- {
- if( SfxObjectShell* pDocShell = GetDocShell() )
+ if( SfxObjectShell* pShell = GetDocShell() )
{
- ScfPropertySet aPropSet( pDocShell->GetModel() );
- aPropSet.SetProperty( CREATE_OUSTRING( "WriteProtectionPassword" ), static_cast< sal_Int32 >( nPasswordHash ) );
+ if( nRecommendReadOnly != 0 )
+ pShell->SetLoadReadonly( sal_True );
+ if( nPasswordHash != 0 )
+ pShell->SetModifyPasswordHash( nPasswordHash );
}
}
}
@@ -919,8 +921,7 @@ void ImportExcel::Olesize( void )
aXclOleSize.Read( maStrm, false );
SCTAB nScTab = GetCurrScTab();
- ScRange& rOleSize = GetExtDocOptions().GetDocSettings().maOleSize;
- GetAddressConverter().ConvertRange( rOleSize, aXclOleSize, nScTab, nScTab, false );
+ GetAddressConverter().ConvertRange( maScOleSize, aXclOleSize, nScTab, nScTab, false );
}
@@ -1204,45 +1205,40 @@ void ImportExcel::PostDocLoad( void )
// process all drawing objects (including OLE, charts, controls; after hiding rows/columns; before visible OLE area)
GetObjectManager().ConvertObjects();
- // visible area if embedded OLE
- if( ScModelObj* pDocObj = GetDocModelObj() )
+ // visible area (used if this document is an embedded OLE object)
+ if( SfxObjectShell* pDocShell = GetDocShell() )
{
- if( SfxObjectShell* pEmbObj = pDocObj->GetEmbeddedObject() )
+ // visible area if embedded
+ const ScExtDocSettings& rDocSett = GetExtDocOptions().GetDocSettings();
+ SCTAB nDisplScTab = rDocSett.mnDisplTab;
+
+ /* #i44077# If a new OLE object is inserted from file, there is no
+ OLESIZE record in the Excel file. Calculate used area from file
+ contents (used cells and drawing objects). */
+ if( !maScOleSize.IsValid() )
{
- // visible area if embedded
- const ScExtDocSettings& rDocSett = GetExtDocOptions().GetDocSettings();
- SCTAB nDisplScTab = rDocSett.mnDisplTab;
-
- // first try if there was an OLESIZE record
- ScRange aScOleSize = rDocSett.maOleSize;
-
- /* #i44077# If a new OLE object is inserted from file, there
- is no OLESIZE record in the Excel file. Calculate used area
- from file contents (used cells and drawing objects). */
- if( !aScOleSize.IsValid() )
- {
- // used area of displayed sheet (cell contents)
- if( const ScExtTabSettings* pTabSett = GetExtDocOptions().GetTabSettings( nDisplScTab ) )
- aScOleSize = pTabSett->maUsedArea;
- // add all valid drawing objects
- ScRange aScObjArea = GetObjectManager().GetUsedArea( nDisplScTab );
- if( aScObjArea.IsValid() )
- aScOleSize.ExtendTo( aScObjArea );
- }
+ // used area of displayed sheet (cell contents)
+ if( const ScExtTabSettings* pTabSett = GetExtDocOptions().GetTabSettings( nDisplScTab ) )
+ maScOleSize = pTabSett->maUsedArea;
+ // add all valid drawing objects
+ ScRange aScObjArea = GetObjectManager().GetUsedArea( nDisplScTab );
+ if( aScObjArea.IsValid() )
+ maScOleSize.ExtendTo( aScObjArea );
+ }
- // valid size found - set it at the document
- if( aScOleSize.IsValid() )
- {
- pEmbObj->SetVisArea( GetDoc().GetMMRect(
- aScOleSize.aStart.Col(), aScOleSize.aStart.Row(),
- aScOleSize.aEnd.Col(), aScOleSize.aEnd.Row(), nDisplScTab ) );
- GetDoc().SetVisibleTab( nDisplScTab );
- }
+ // valid size found - set it at the document
+ if( maScOleSize.IsValid() )
+ {
+ pDocShell->SetVisArea( GetDoc().GetMMRect(
+ maScOleSize.aStart.Col(), maScOleSize.aStart.Row(),
+ maScOleSize.aEnd.Col(), maScOleSize.aEnd.Row(), nDisplScTab ) );
+ GetDoc().SetVisibleTab( nDisplScTab );
}
+ }
- // #111099# open forms in alive mode (has no effect, if no controls in document)
+ // #111099# open forms in alive mode (has no effect, if no controls in document)
+ if( ScModelObj* pDocObj = GetDocModelObj() )
pDocObj->setPropertyValue( CREATE_OUSTRING( SC_UNO_APPLYFMDES ), uno::Any( false ) );
- }
// enables extended options to be set to the view after import
GetExtDocOptions().SetChanged( true );
diff --git a/sc/source/filter/excel/read.cxx b/sc/source/filter/excel/read.cxx
index 3aef51d10c54..cfe5aedb867e 100644
--- a/sc/source/filter/excel/read.cxx
+++ b/sc/source/filter/excel/read.cxx
@@ -986,10 +986,10 @@ FltError ImportExcel8::Read( void )
case 0x22: Rec1904(); break; // 1904 [ 2345 ]
case 0x56: Builtinfmtcnt(); break; // BUILTINFMTCNT[ 34 ]
case 0x8D: Hideobj(); break; // HIDEOBJ [ 345 ]
- case 0xD3: bHasBasic = true; break;
+ case 0xD3: SetHasBasic(); break;
case 0xDE: Olesize(); break;
- case 0x01BA: Codename( TRUE ); break;
+ case EXC_ID_CODENAME: ReadCodeName( aIn, true ); break;
case EXC_ID_USESELFS: ReadUsesElfs(); break;
case EXC_ID2_FONT: rFontBfr.ReadFont( maStrm ); break;
@@ -1082,6 +1082,8 @@ FltError ImportExcel8::Read( void )
case EXC_ID2_DIMENSIONS:
case EXC_ID3_DIMENSIONS: ReadDimensions(); break;
+ case EXC_ID_CODENAME: ReadCodeName( aIn, false ); break;
+
case 0x0A: // EOF [ 2345 ]
eAkt = EXC_STATE_SHEET;
aIn.SeekGlobalPosition(); // und zurueck an alte Position
@@ -1097,7 +1099,6 @@ FltError ImportExcel8::Read( void )
case 0x9B: FilterMode(); break; // FILTERMODE
case 0x9D: AutoFilterInfo(); break;// AUTOFILTERINFO
case 0x9E: AutoFilter(); break; // AUTOFILTER
- case 0x01BA: Codename( FALSE ); break;
case 0x0208: Row34(); break; // ROW [ 34 ]
case 0x0021:
case 0x0221: Array34(); break; // ARRAY [ 34 ]
@@ -1192,6 +1193,7 @@ FltError ImportExcel8::Read( void )
case EXC_ID_SXDI: rPTableMgr.ReadSxdi( maStrm ); break;
case EXC_ID_SXVDEX: rPTableMgr.ReadSxvdex( maStrm ); break;
case EXC_ID_SXEX: rPTableMgr.ReadSxex( maStrm ); break;
+ case EXC_ID_SHEETEXT: rTabViewSett.ReadTabBgColor( maStrm, rPal ); break;
case EXC_ID_SXVIEWEX9: rPTableMgr.ReadSxViewEx9( maStrm ); break;
}
}
diff --git a/sc/source/filter/excel/xeescher.cxx b/sc/source/filter/excel/xeescher.cxx
index a4b5864668b4..0509f2afa5fa 100644
--- a/sc/source/filter/excel/xeescher.cxx
+++ b/sc/source/filter/excel/xeescher.cxx
@@ -146,7 +146,7 @@ void XclExpDffSheetAnchor::ImplSetFlags( const SdrObject& rSdrObj )
void XclExpDffSheetAnchor::ImplCalcAnchorRect( const Rectangle& rRect, MapUnit eMapUnit )
{
- maAnchor.SetRect( GetDoc(), mnScTab, rRect, eMapUnit );
+ maAnchor.SetRect( GetRoot(), mnScTab, rRect, eMapUnit );
}
// ----------------------------------------------------------------------------
@@ -175,7 +175,7 @@ void XclExpDffEmbeddedAnchor::ImplCalcAnchorRect( const Rectangle& rRect, MapUni
XclExpDffNoteAnchor::XclExpDffNoteAnchor( const XclExpRoot& rRoot, const Rectangle& rRect ) :
XclExpDffAnchorBase( rRoot, EXC_ESC_ANCHOR_SIZELOCKED )
{
- maAnchor.SetRect( GetDoc(), rRoot.GetCurrScTab(), rRect, MAP_100TH_MM );
+ maAnchor.SetRect( rRoot, rRoot.GetCurrScTab(), rRect, MAP_100TH_MM );
}
// ----------------------------------------------------------------------------
diff --git a/sc/source/filter/excel/xepage.cxx b/sc/source/filter/excel/xepage.cxx
index 753d43e8d584..6194a04c27f6 100644
--- a/sc/source/filter/excel/xepage.cxx
+++ b/sc/source/filter/excel/xepage.cxx
@@ -45,9 +45,14 @@
#include "xehelper.hxx"
#include "xeescher.hxx"
+#include <set>
+#include <limits>
+
#include <oox/core/tokens.hxx>
using ::rtl::OString;
+using ::std::set;
+using ::std::numeric_limits;
// Page settings records ======================================================
@@ -299,17 +304,23 @@ XclExpPageSettings::XclExpPageSettings( const XclExpRoot& rRoot ) :
// *** page breaks ***
- ScCompressedArrayIterator< SCROW, BYTE> aIter( rDoc.GetRowFlagsArray( nScTab), 1, GetMaxPos().Row());
- do
+ set<SCROW> aRowBreaks;
+ rDoc.GetAllRowBreaks(aRowBreaks, nScTab, false, true);
+
+ SCROW nMaxRow = numeric_limits<sal_uInt16>::max();
+ for (set<SCROW>::const_iterator itr = aRowBreaks.begin(), itrEnd = aRowBreaks.end(); itr != itrEnd; ++itr)
{
- if (*aIter & CR_MANUALBREAK)
- for (SCROW j=aIter.GetRangeStart(); j<=aIter.GetRangeEnd(); ++j)
- maData.maHorPageBreaks.push_back( static_cast< sal_uInt16 >( j ) );
- } while (aIter.NextRange());
-
- for( SCCOL nScCol = 1, nScMaxCol = GetMaxPos().Col(); nScCol <= nScMaxCol; ++nScCol )
- if( rDoc.GetColFlags( nScCol, nScTab ) & CR_MANUALBREAK )
- maData.maVerPageBreaks.push_back( static_cast< sal_uInt16 >( nScCol ) );
+ SCROW nRow = *itr;
+ if (nRow > nMaxRow)
+ break;
+
+ maData.maHorPageBreaks.push_back(nRow);
+ }
+
+ set<SCCOL> aColBreaks;
+ rDoc.GetAllColBreaks(aColBreaks, nScTab, false, true);
+ for (set<SCCOL>::const_iterator itr = aColBreaks.begin(), itrEnd = aColBreaks.end(); itr != itrEnd; ++itr)
+ maData.maVerPageBreaks.push_back(*itr);
}
static void lcl_WriteHeaderFooter( XclExpXmlStream& rStrm )
diff --git a/sc/source/filter/excel/xeroot.cxx b/sc/source/filter/excel/xeroot.cxx
index 834873740d68..50e07ae1f2ed 100644
--- a/sc/source/filter/excel/xeroot.cxx
+++ b/sc/source/filter/excel/xeroot.cxx
@@ -33,6 +33,7 @@
#include <unotools/saveopt.hxx>
#include <svl/itemset.hxx>
#include <svl/stritem.hxx>
+#include <svl/intitem.hxx>
#include <svl/eitem.hxx>
#include "xecontent.hxx"
#include "xltracer.hxx"
@@ -247,24 +248,16 @@ bool XclExpRoot::IsDocumentEncrypted() const
return false;
}
-const String XclExpRoot::GetPassword() const
+String XclExpRoot::GetPassword() const
{
- SfxItemSet* pSet = GetMedium().GetItemSet();
- if (!pSet)
- return String();
-
- const SfxPoolItem* pItem = NULL;
- if (SFX_ITEM_SET == pSet->GetItemState(SID_PASSWORD, sal_True, &pItem))
+ if( SfxItemSet* pItemSet = GetMedium().GetItemSet() )
{
- const SfxStringItem* pStrItem = dynamic_cast<const SfxStringItem*>(pItem);
- if (pStrItem)
- {
- // Password from the save dialog.
- return pStrItem->GetValue();
- }
+ const SfxPoolItem* pItem = 0;
+ if( pItemSet->GetItemState( SID_PASSWORD, TRUE, &pItem ) == SFX_ITEM_SET )
+ if( const SfxStringItem* pStrItem = dynamic_cast< const SfxStringItem* >( pItem ) )
+ return pStrItem->GetValue();
}
-
- return String();
+ return String::EmptyString();
}
XclExpRootData::XclExpLinkMgrRef XclExpRoot::GetLocalLinkMgrRef() const
diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx
index 315282098cec..ccebe9a4280f 100644
--- a/sc/source/filter/excel/xestyle.cxx
+++ b/sc/source/filter/excel/xestyle.cxx
@@ -74,6 +74,7 @@ sal_uInt32 lclGetWeighting( XclExpColorType eType )
case EXC_COLOR_CELLTEXT:
case EXC_COLOR_CHARTTEXT:
case EXC_COLOR_CTRLTEXT: return 10;
+ case EXC_COLOR_TABBG:
case EXC_COLOR_CELLAREA: return 20;
case EXC_COLOR_GRID: return 50;
default: DBG_ERRORFILE( "lclGetWeighting - unknown color type" );
diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx
index e9aaa70bceba..b5ca318a91b4 100644
--- a/sc/source/filter/excel/xetable.cxx
+++ b/sc/source/filter/excel/xetable.cxx
@@ -1601,8 +1601,7 @@ XclExpColinfo::XclExpColinfo( const XclExpRoot& rRoot,
mnWidth = XclTools::GetXclColumnWidth( nScWidth, GetCharWidth() );
// column flags
- BYTE nScColFlags = rDoc.GetColFlags( nScCol, nScTab );
- ::set_flag( mnFlags, EXC_COLINFO_HIDDEN, (nScColFlags & CR_HIDDEN) != 0 );
+ ::set_flag( mnFlags, EXC_COLINFO_HIDDEN, rDoc.ColHidden(nScCol, nScTab) );
// outline data
rOutlineBfr.Update( nScCol );
@@ -1827,23 +1826,17 @@ XclExpRow::XclExpRow( const XclExpRoot& rRoot, sal_uInt16 nXclRow,
BYTE nRowFlags = GetDoc().GetRowFlags( nScRow, nScTab );
bool bUserHeight = ::get_flag< BYTE >( nRowFlags, CR_MANUALSIZE );
- bool bHidden = ::get_flag< BYTE >( nRowFlags, CR_HIDDEN );
+ bool bHidden = GetDoc().RowHidden(nScRow, nScTab);
::set_flag( mnFlags, EXC_ROW_UNSYNCED, bUserHeight );
::set_flag( mnFlags, EXC_ROW_HIDDEN, bHidden );
// *** Row height *** -----------------------------------------------------
- USHORT nScHeight = GetDoc().GetRowHeight( nScRow, nScTab );
- if( nScHeight == 0 )
- {
- ::set_flag( mnFlags, EXC_ROW_HIDDEN );
- mnHeight = EXC_ROW_DEFAULTHEIGHT;
- }
+ if (bUserHeight)
+ mnHeight = GetDoc().GetRowHeight(nScRow, nScTab, false);
else
- {
- // Calc and Excel use twips
- mnHeight = static_cast< sal_uInt16 >( nScHeight );
- }
+ mnHeight = EXC_ROW_DEFAULTHEIGHT;
+
// #76250# not usable in Applix
// ::set_flag( mnHeight, EXC_ROW_FLAGDEFHEIGHT, !bUserHeight );
diff --git a/sc/source/filter/excel/xeview.cxx b/sc/source/filter/excel/xeview.cxx
index c342b5a40ea1..035afd0a5830 100644
--- a/sc/source/filter/excel/xeview.cxx
+++ b/sc/source/filter/excel/xeview.cxx
@@ -256,6 +256,35 @@ void XclExpSelection::WriteBody( XclExpStream& rStrm )
maSelData.maXclSelection.Write( rStrm, false );
}
+// ----------------------------------------------------------------------------
+
+XclExpTabBgColor::XclExpTabBgColor( const XclTabViewData& rTabViewData ) :
+ XclExpRecord( EXC_ID_SHEETEXT, 18 ),
+ mrTabViewData( rTabViewData )
+{
+}
+//TODO Fix savexml...
+/*void XclExpTabBgColor::SaveXml( XclExpXmlStream& rStrm )
+{
+}*/
+
+void XclExpTabBgColor::WriteBody( XclExpStream& rStrm )
+{
+ if ( mrTabViewData.IsDefaultTabBgColor() )
+ return;
+ sal_uInt16 rt = 0x0862; //rt
+ sal_uInt16 grbitFrt = 0x0000; //grbit must be set to 0
+ sal_uInt32 unused = 0x00000000; //Use twice...
+ sal_uInt32 cb = 0x00000014; // Record Size, may be larger in future...
+ sal_uInt16 reserved = 0x0000; //trailing bits are 0
+ sal_uInt16 TabBgColorIndex;
+ XclExpPalette& rPal = rStrm.GetRoot().GetPalette();
+ TabBgColorIndex = rPal.GetColorIndex(mrTabViewData.mnTabBgColorId);
+ if (TabBgColorIndex < 8 || TabBgColorIndex > 63 ) // only numbers 8 - 63 are valid numbers
+ TabBgColorIndex = 127; //Excel specs: 127 makes excel ignore tab color information.
+ rStrm << rt << grbitFrt << unused << unused << cb << TabBgColorIndex << reserved;
+}
+
// Sheet view settings ========================================================
namespace {
@@ -366,6 +395,14 @@ XclExpTabViewSettings::XclExpTabViewSettings( const XclExpRoot& rRoot, SCTAB nSc
maData.mnPageZoom = lclGetXclZoom( rTabSett.mnPageZoom, EXC_WIN2_PAGEZOOM_DEF );
maData.mnCurrentZoom = maData.mbPageMode ? maData.mnPageZoom : maData.mnNormalZoom;
}
+
+ // Tab Bg Color
+ if ( GetBiff() == EXC_BIFF8 && !GetDoc().IsDefaultTabBgColor(nScTab) )
+ {
+ XclExpPalette& rPal = GetPalette();
+ maData.maTabBgColor = GetDoc().GetTabBgColor(nScTab);
+ maData.mnTabBgColorId = rPal.InsertColor(maData.maTabBgColor, EXC_COLOR_TABBG, EXC_COLOR_NOTABBG );
+ }
}
void XclExpTabViewSettings::Save( XclExpStream& rStrm )
@@ -377,6 +414,7 @@ void XclExpTabViewSettings::Save( XclExpStream& rStrm )
WriteSelection( rStrm, EXC_PANE_TOPRIGHT );
WriteSelection( rStrm, EXC_PANE_BOTTOMLEFT );
WriteSelection( rStrm, EXC_PANE_BOTTOMRIGHT );
+ WriteTabBgColor( rStrm );
}
static void lcl_WriteSelection( XclExpXmlStream& rStrm, const XclTabViewData& rData, sal_uInt8 nPane )
@@ -491,5 +529,10 @@ void XclExpTabViewSettings::WriteSelection( XclExpStream& rStrm, sal_uInt8 nPane
XclExpSelection( maData, nPane ).Save( rStrm );
}
+void XclExpTabViewSettings::WriteTabBgColor( XclExpStream& rStrm ) const
+{
+ if ( !maData.IsDefaultTabBgColor() )
+ XclExpTabBgColor( maData ).Save( rStrm );
+}
// ============================================================================
diff --git a/sc/source/filter/excel/xichart.cxx b/sc/source/filter/excel/xichart.cxx
index 35ad5b41e0cb..7cbd74a836d2 100755
--- a/sc/source/filter/excel/xichart.cxx
+++ b/sc/source/filter/excel/xichart.cxx
@@ -4053,6 +4053,16 @@ void XclImpChart::ReadChartSubStream( XclImpStream& rStrm )
case EXC_ID_WINDOW2: rTabViewSett.ReadWindow2( rStrm, true );break;
case EXC_ID_SCL: rTabViewSett.ReadScl( rStrm ); break;
+
+ case EXC_ID_SHEETEXT: //0x0862
+ {
+ // FIXME: do not need to pass palette, XclImpTabVieSettings is derived from root
+ XclImpPalette& rPal = GetPalette();
+ rTabViewSett.ReadTabBgColor( rStrm, rPal);
+ }
+ break;
+
+ case EXC_ID_CODENAME: ReadCodeName( rStrm, false ); break;
}
// common records
diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx
index 3d055d94a498..dc87bba4c050 100644
--- a/sc/source/filter/excel/xiescher.cxx
+++ b/sc/source/filter/excel/xiescher.cxx
@@ -62,10 +62,6 @@
#include <basegfx/point/b2dpoint.hxx>
#include <basegfx/polygon/b2dpolygon.hxx>
-#include <basic/sbstar.hxx>
-#include <basic/sbmod.hxx>
-#include <basic/sbmeth.hxx>
-
#include <svx/svdopath.hxx>
#include <svx/svdocirc.hxx>
#include <svx/svdoedge.hxx>
@@ -478,14 +474,14 @@ void XclImpDrawObjBase::PreProcessSdrObject( XclImpDffConverter& rDffConv, SdrOb
{
if( ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( &rSdrObj, TRUE ) )
{
- pInfo->SetMacro( XclControlHelper::GetScMacroName( maMacroName, GetDocShell() ) );
+ pInfo->SetMacro( XclTools::GetSbMacroUrl( maMacroName, GetDocShell() ) );
pInfo->SetHlink( maHyperlink );
}
}
#else
if( mbSimpleMacro && (maMacroName.Len() > 0) )
if( ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( &rSdrObj, TRUE ) )
- pInfo->SetMacro( XclControlHelper::GetScMacroName( maMacroName, GetDocShell() ) );
+ pInfo->SetMacro( XclTools::GetSbMacroUrl( maMacroName, GetDocShell() ) );
#endif
// call virtual function for object type specific processing
@@ -550,16 +546,7 @@ void XclImpDrawObjBase::ReadMacro8( XclImpStream& rStrm )
DBG_ASSERT( nTokenId == XclTokenArrayHelper::GetTokenId( EXC_TOKID_NAMEX, EXC_TOKCLASS_REF ),
"XclImpDrawObjBase::ReadMacro - tNameXR token expected" );
if( nTokenId == XclTokenArrayHelper::GetTokenId( EXC_TOKID_NAMEX, EXC_TOKCLASS_REF ) )
- {
maMacroName = GetLinkManager().GetMacroName( nExtSheet, nExtName );
- // #i38718# missing module name - try to find the macro in the imported modules
- if( maMacroName.Len() && (maMacroName.Search( '.' ) == STRING_NOTFOUND) )
- if( SfxObjectShell* pDocShell = GetDocShell() )
- if( StarBASIC* pBasic = pDocShell->GetBasic() )
- if( SbMethod* pMethod = dynamic_cast< SbMethod* >( pBasic->Find( maMacroName, SbxCLASS_METHOD ) ) )
- if( SbModule* pModule = pMethod->GetModule() )
- maMacroName.Insert( '.', 0 ).Insert( pModule->GetName(), 0 );
- }
}
}
}
@@ -1709,7 +1696,7 @@ void XclImpChartObj::FinalizeTabChart()
// create the object anchor
XclObjAnchor aAnchor;
- aAnchor.SetRect( GetDoc(), GetCurrScTab(), Rectangle( 1000, 500, nWidth, nHeight ), MAP_100TH_MM );
+ aAnchor.SetRect( GetRoot(), GetCurrScTab(), Rectangle( 1000, 500, nWidth, nHeight ), MAP_100TH_MM );
SetAnchor( aAnchor );
}
@@ -3939,7 +3926,7 @@ void XclImpSheetDrawing::ConvertObjects( XclImpDffConverter& rDffConv )
Rectangle XclImpSheetDrawing::CalcAnchorRect( const XclObjAnchor& rAnchor, bool /*bDffAnchor*/ ) const
{
- return rAnchor.GetRect( GetDoc(), maScUsedArea.aStart.Tab(), MAP_100TH_MM );
+ return rAnchor.GetRect( GetRoot(), maScUsedArea.aStart.Tab(), MAP_100TH_MM );
}
void XclImpSheetDrawing::OnObjectInserted( const XclImpDrawObjBase& rDrawObj )
diff --git a/sc/source/filter/excel/xipage.cxx b/sc/source/filter/excel/xipage.cxx
index c689d0eb7feb..38cebc2e6ca8 100644
--- a/sc/source/filter/excel/xipage.cxx
+++ b/sc/source/filter/excel/xipage.cxx
@@ -375,14 +375,14 @@ void XclImpPageSettings::Finalize()
{
SCROW nScRow = static_cast< SCROW >( *aIt );
if( nScRow <= MAXROW )
- rDoc.SetRowFlags( nScRow, nScTab, rDoc.GetRowFlags( nScRow, nScTab ) | CR_MANUALBREAK );
+ rDoc.SetRowBreak(nScRow, nScTab, false, true);
}
for( aIt = maData.maVerPageBreaks.begin(), aEnd = maData.maVerPageBreaks.end(); aIt != aEnd; ++aIt )
{
SCCOL nScCol = static_cast< SCCOL >( *aIt );
if( nScCol <= MAXCOL )
- rDoc.SetColFlags( nScCol, nScTab, rDoc.GetColFlags( nScCol, nScTab ) | CR_MANUALBREAK );
+ rDoc.SetColBreak(nScCol, nScTab, false, true);
}
}
diff --git a/sc/source/filter/excel/xiroot.cxx b/sc/source/filter/excel/xiroot.cxx
index 3384cf248c87..3fd2650cf2ff 100644
--- a/sc/source/filter/excel/xiroot.cxx
+++ b/sc/source/filter/excel/xiroot.cxx
@@ -29,6 +29,8 @@
#include "precompiled_sc.hxx"
#include "xiroot.hxx"
#include "addincol.hxx"
+#include "document.hxx"
+#include "scextopt.hxx"
#include "xltracer.hxx"
#include "xihelper.hxx"
#include "xiformula.hxx"
@@ -49,7 +51,8 @@
XclImpRootData::XclImpRootData( XclBiff eBiff, SfxMedium& rMedium,
SotStorageRef xRootStrg, ScDocument& rDoc, rtl_TextEncoding eTextEnc ) :
XclRootData( eBiff, rMedium, xRootStrg, rDoc, eTextEnc, false ),
- mbHasCodePage( false )
+ mbHasCodePage( false ),
+ mbHasBasic( false )
{
}
@@ -272,5 +275,25 @@ String XclImpRoot::GetScAddInName( const String& rXclName ) const
return rXclName;
}
-// ============================================================================
+void XclImpRoot::ReadCodeName( XclImpStream& rStrm, bool bGlobals )
+{
+ if( mrImpData.mbHasBasic && (GetBiff() == EXC_BIFF8) )
+ {
+ String aName = rStrm.ReadUniString();
+ if( aName.Len() > 0 )
+ {
+ if( bGlobals )
+ {
+ GetExtDocOptions().GetDocSettings().maGlobCodeName = aName;
+ GetDoc().SetCodeName( aName );
+ }
+ else
+ {
+ GetExtDocOptions().AppendCodeName( aName );
+ GetDoc().SetCodeName( GetCurrScTab(), aName );
+ }
+ }
+ }
+}
+// ============================================================================
diff --git a/sc/source/filter/excel/xiview.cxx b/sc/source/filter/excel/xiview.cxx
index 6eeee8e04839..f75032ff461e 100644
--- a/sc/source/filter/excel/xiview.cxx
+++ b/sc/source/filter/excel/xiview.cxx
@@ -106,6 +106,24 @@ void XclImpTabViewSettings::Initialize()
maData.SetDefaults();
}
+void XclImpTabViewSettings::ReadTabBgColor( XclImpStream& rStrm, XclImpPalette& rPal )
+{
+ DBG_ASSERT_BIFF( GetBiff() >= EXC_BIFF8 );
+ if( GetBiff() < EXC_BIFF8 )
+ return;
+
+ sal_uInt8 ColorIndex;
+ Color TabBgColor;
+
+ rStrm.Ignore( 16 );
+ ColorIndex = rStrm.ReaduInt8() & EXC_SHEETEXT_TABCOLOR; //0x7F
+ if ( ColorIndex >= 8 && ColorIndex <= 63 ) //only accept valid index values
+ {
+ TabBgColor = rPal.GetColor( ColorIndex );
+ maData.maTabBgColor = TabBgColor;
+ }
+}
+
void XclImpTabViewSettings::ReadWindow2( XclImpStream& rStrm, bool bChart )
{
if( GetBiff() == EXC_BIFF2 )
@@ -276,6 +294,10 @@ void XclImpTabViewSettings::Finalize()
aViewOpt.SetOption( VOPT_OUTLINER, maData.mbShowOutline );
rDoc.SetViewOptions( aViewOpt );
}
+
+ // *** set tab bg color
+ if ( !maData.IsDefaultTabBgColor() )
+ rDoc.SetTabBgColor(nScTab, maData.maTabBgColor);
}
// ============================================================================
diff --git a/sc/source/filter/excel/xlescher.cxx b/sc/source/filter/excel/xlescher.cxx
index e1132c1b5606..bb77fac2be73 100644
--- a/sc/source/filter/excel/xlescher.cxx
+++ b/sc/source/filter/excel/xlescher.cxx
@@ -28,14 +28,16 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sc.hxx"
+#include "xlescher.hxx"
+
#include <com/sun/star/drawing/XControlShape.hpp>
#include <com/sun/star/script/ScriptEventDescriptor.hpp>
#include <svx/unoapi.hxx>
-#include "xestream.hxx"
#include "document.hxx"
+#include "xestream.hxx"
#include "xistream.hxx"
-#include "xlescher.hxx"
-#include <filter/msfilter/msvbahelper.hxx>
+#include "xltools.hxx"
+#include "xlroot.hxx"
using ::rtl::OUString;
using ::com::sun::star::uno::Reference;
@@ -109,15 +111,15 @@ long lclGetYFromRow( ScDocument& rDoc, SCTAB nScTab, sal_uInt16 nXclRow, sal_uIn
/** Calculates an object column position from a drawing layer X position (in twips). */
void lclGetColFromX(
ScDocument& rDoc, SCTAB nScTab, sal_uInt16& rnXclCol,
- sal_uInt16& rnOffset, sal_uInt16 nXclStartCol,
+ sal_uInt16& rnOffset, sal_uInt16 nXclStartCol, sal_uInt16 nXclMaxCol,
long& rnStartW, long nX, double fScale )
{
// rnStartW in conjunction with nXclStartCol is used as buffer for previously calculated width
long nTwipsX = static_cast< long >( nX / fScale + 0.5 );
long nColW = 0;
- for( rnXclCol = nXclStartCol; rnXclCol <= MAXCOL; ++rnXclCol )
+ for( rnXclCol = nXclStartCol; rnXclCol <= nXclMaxCol; ++rnXclCol )
{
- nColW = rDoc.GetColWidth( static_cast<SCCOL>(rnXclCol), nScTab );
+ nColW = rDoc.GetColWidth( static_cast< SCCOL >( rnXclCol ), nScTab );
if( rnStartW + nColW > nTwipsX )
break;
rnStartW += nColW;
@@ -127,28 +129,27 @@ void lclGetColFromX(
/** Calculates an object row position from a drawing layer Y position (in twips). */
void lclGetRowFromY(
- ScDocument& rDoc, SCTAB nScTab,
- sal_uInt16& rnXclRow, sal_uInt16& rnOffset, sal_uInt16 nXclStartRow,
+ ScDocument& rDoc, SCTAB nScTab, sal_uInt16& rnXclRow,
+ sal_uInt16& rnOffset, sal_uInt16 nXclStartRow, sal_uInt16 nXclMaxRow,
long& rnStartH, long nY, double fScale )
{
// rnStartH in conjunction with nXclStartRow is used as buffer for previously calculated height
long nTwipsY = static_cast< long >( nY / fScale + 0.5 );
long nRowH = 0;
- ScCoupledCompressedArrayIterator< SCROW, BYTE, USHORT> aIter(
- rDoc.GetRowFlagsArray( nScTab), static_cast<SCROW>(nXclStartRow),
- MAXROW, CR_HIDDEN, 0, rDoc.GetRowHeightArray( nScTab));
- for ( ; aIter; ++aIter )
+ bool bFound = false;
+ for( SCROW nRow = static_cast< SCROW >( nXclStartRow ); nRow <= nXclMaxRow; ++nRow )
{
- nRowH = *aIter;
+ nRowH = rDoc.GetRowHeight( nRow, nScTab );
if( rnStartH + nRowH > nTwipsY )
{
- rnXclRow = static_cast< sal_uInt16 >( aIter.GetPos() );
+ rnXclRow = static_cast< sal_uInt16 >( nRow );
+ bFound = true;
break;
}
rnStartH += nRowH;
}
- if (!aIter)
- rnXclRow = static_cast< sal_uInt16 >( aIter.GetIterEnd() ); // down to the bottom..
+ if( !bFound )
+ rnXclRow = nXclMaxRow;
rnOffset = static_cast< sal_uInt16 >( nRowH ? ((nTwipsY - rnStartH) * 256.0 / nRowH + 0.5) : 0 );
}
@@ -177,8 +178,9 @@ XclObjAnchor::XclObjAnchor() :
{
}
-Rectangle XclObjAnchor::GetRect( ScDocument& rDoc, SCTAB nScTab, MapUnit eMapUnit ) const
+Rectangle XclObjAnchor::GetRect( const XclRoot& rRoot, SCTAB nScTab, MapUnit eMapUnit ) const
{
+ ScDocument& rDoc = rRoot.GetDoc();
double fScale = lclGetTwipsScale( eMapUnit );
Rectangle aRect(
lclGetXFromCol( rDoc, nScTab, maFirst.mnCol, mnLX, fScale ),
@@ -192,20 +194,24 @@ Rectangle XclObjAnchor::GetRect( ScDocument& rDoc, SCTAB nScTab, MapUnit eMapUni
return aRect;
}
-void XclObjAnchor::SetRect( ScDocument& rDoc, SCTAB nScTab, const Rectangle& rRect, MapUnit eMapUnit )
+void XclObjAnchor::SetRect( const XclRoot& rRoot, SCTAB nScTab, const Rectangle& rRect, MapUnit eMapUnit )
{
- Rectangle aRect( rRect );
+ ScDocument& rDoc = rRoot.GetDoc();
+ sal_uInt16 nXclMaxCol = rRoot.GetXclMaxPos().Col();
+ sal_uInt16 nXclMaxRow = static_cast<sal_uInt16>( rRoot.GetXclMaxPos().Row());
+
// #106948# adjust coordinates in mirrored sheets
+ Rectangle aRect( rRect );
if( rDoc.IsLayoutRTL( nScTab ) )
lclMirrorRectangle( aRect );
double fScale = lclGetTwipsScale( eMapUnit );
long nDummy = 0;
- lclGetColFromX( rDoc, nScTab, maFirst.mnCol, mnLX, 0, nDummy, aRect.Left(), fScale );
- lclGetColFromX( rDoc, nScTab, maLast.mnCol, mnRX, maFirst.mnCol, nDummy, aRect.Right(), fScale );
+ lclGetColFromX( rDoc, nScTab, maFirst.mnCol, mnLX, 0, nXclMaxCol, nDummy, aRect.Left(), fScale );
+ lclGetColFromX( rDoc, nScTab, maLast.mnCol, mnRX, maFirst.mnCol, nXclMaxCol, nDummy, aRect.Right(), fScale );
nDummy = 0;
- lclGetRowFromY( rDoc, nScTab, maFirst.mnRow, mnTY, 0, nDummy, aRect.Top(), fScale );
- lclGetRowFromY( rDoc, nScTab, maLast.mnRow, mnBY, maFirst.mnRow, nDummy, aRect.Bottom(), fScale );
+ lclGetRowFromY( rDoc, nScTab, maFirst.mnRow, mnTY, 0, nXclMaxRow, nDummy, aRect.Top(), fScale );
+ lclGetRowFromY( rDoc, nScTab, maLast.mnRow, mnBY, maFirst.mnRow, nXclMaxRow, nDummy, aRect.Bottom(), fScale );
}
void XclObjAnchor::SetRect( const Size& rPageSize, sal_Int32 nScaleX, sal_Int32 nScaleY,
@@ -326,33 +332,7 @@ Reference< XControlModel > XclControlHelper::GetControlModel( Reference< XShape
return xCtrlModel;
}
-#define EXC_MACRONAME_PRE "vnd.sun.star.script:Standard."
-#define EXC_MACRONAME_SUF "?language=Basic&location=document"
-
-OUString XclControlHelper::GetScMacroName( const String& rXclMacroName, SfxObjectShell* pDocShell )
-{
- String sTmp( rXclMacroName );
- if( rXclMacroName.Len() > 0 )
- {
- ooo::vba::VBAMacroResolvedInfo aMacro = ooo::vba::resolveVBAMacro( pDocShell, rXclMacroName, false );
- if ( aMacro.IsResolved() )
- return ooo::vba::makeMacroURL( aMacro.ResolvedMacro() );
-
- }
- return OUString();
-}
-
-String XclControlHelper::GetXclMacroName( const OUString& rScMacroName )
-{
- const OUString saMacroNamePre = CREATE_OUSTRING( EXC_MACRONAME_PRE );
- const OUString saMacroNameSuf = CREATE_OUSTRING( EXC_MACRONAME_SUF );
- sal_Int32 snScMacroNameLen = rScMacroName.getLength();
- sal_Int32 snXclMacroNameLen = snScMacroNameLen - saMacroNamePre.getLength() - saMacroNameSuf.getLength();
- if( (snXclMacroNameLen > 0) && rScMacroName.matchIgnoreAsciiCase( saMacroNamePre, 0 ) &&
- rScMacroName.matchIgnoreAsciiCase( saMacroNameSuf, snScMacroNameLen - saMacroNameSuf.getLength() ) )
- return rScMacroName.copy( saMacroNamePre.getLength(), snXclMacroNameLen );
- return String::EmptyString();
-}
+namespace {
static const struct
{
@@ -369,17 +349,17 @@ spTbxListenerData[] =
/*EXC_TBX_EVENT_CHANGE*/ { "XChangeListener", "changed" }
};
-#define EXC_MACROSCRIPT "Script"
+} // namespace
bool XclControlHelper::FillMacroDescriptor( ScriptEventDescriptor& rDescriptor,
- XclTbxEventType eEventType, const String& rXclMacroName, SfxObjectShell* pShell )
+ XclTbxEventType eEventType, const String& rXclMacroName, SfxObjectShell* pDocShell )
{
if( rXclMacroName.Len() > 0 )
{
rDescriptor.ListenerType = OUString::createFromAscii( spTbxListenerData[ eEventType ].mpcListenerType );
rDescriptor.EventMethod = OUString::createFromAscii( spTbxListenerData[ eEventType ].mpcEventMethod );
- rDescriptor.ScriptType = CREATE_OUSTRING( EXC_MACROSCRIPT );
- rDescriptor.ScriptCode = GetScMacroName( rXclMacroName, pShell );
+ rDescriptor.ScriptType = CREATE_OUSTRING( "Script" );
+ rDescriptor.ScriptCode = XclTools::GetSbMacroUrl( rXclMacroName, pDocShell );
return true;
}
return false;
@@ -389,12 +369,11 @@ String XclControlHelper::ExtractFromMacroDescriptor(
const ScriptEventDescriptor& rDescriptor, XclTbxEventType eEventType )
{
if( (rDescriptor.ScriptCode.getLength() > 0) &&
- rDescriptor.ScriptType.equalsIgnoreAsciiCaseAscii( EXC_MACROSCRIPT ) &&
+ rDescriptor.ScriptType.equalsIgnoreAsciiCaseAscii( "Script" ) &&
rDescriptor.ListenerType.equalsAscii( spTbxListenerData[ eEventType ].mpcListenerType ) &&
rDescriptor.EventMethod.equalsAscii( spTbxListenerData[ eEventType ].mpcEventMethod ) )
- return GetXclMacroName( rDescriptor.ScriptCode );
+ return XclTools::GetXclMacroName( rDescriptor.ScriptCode );
return String::EmptyString();
}
// ============================================================================
-
diff --git a/sc/source/filter/excel/xltools.cxx b/sc/source/filter/excel/xltools.cxx
index 90393ae6a787..0dd988d67586 100644
--- a/sc/source/filter/excel/xltools.cxx
+++ b/sc/source/filter/excel/xltools.cxx
@@ -34,6 +34,7 @@
#include <unotools/fontcvt.hxx>
#include <sfx2/objsh.hxx>
#include <editeng/editstat.hxx>
+#include <filter/msfilter/msvbahelper.hxx>
#include "xestream.hxx"
#include "document.hxx"
#include "docuno.hxx"
@@ -46,6 +47,8 @@
#include "xiroot.hxx"
#include "xltools.hxx"
+using ::rtl::OUString;
+
// GUID import/export =========================================================
XclGuid::XclGuid()
@@ -684,6 +687,37 @@ void XclTools::SkipSubStream( XclImpStream& rStrm )
}
}
+// Basic macro names ----------------------------------------------------------
+
+const OUString XclTools::maSbMacroPrefix( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.script:Standard." ) );
+const OUString XclTools::maSbMacroSuffix( RTL_CONSTASCII_USTRINGPARAM( "?language=Basic&location=document" ) );
+
+OUString XclTools::GetSbMacroUrl( const String& rMacroName, SfxObjectShell* pDocShell )
+{
+ OSL_ENSURE( rMacroName.Len() > 0, "XclTools::GetSbMacroUrl - macro name is empty" );
+ ::ooo::vba::VBAMacroResolvedInfo aMacroInfo = ::ooo::vba::resolveVBAMacro( pDocShell, rMacroName, false );
+ if( aMacroInfo.IsResolved() )
+ return ::ooo::vba::makeMacroURL( aMacroInfo.ResolvedMacro() );
+ return OUString();
+}
+
+OUString XclTools::GetSbMacroUrl( const String& rModuleName, const String& rMacroName, SfxObjectShell* pDocShell )
+{
+ OSL_ENSURE( rModuleName.Len() > 0, "XclTools::GetSbMacroUrl - module name is empty" );
+ OSL_ENSURE( rMacroName.Len() > 0, "XclTools::GetSbMacroUrl - macro name is empty" );
+ return GetSbMacroUrl( rModuleName + OUString( sal_Unicode( '.' ) ) + rMacroName, pDocShell );
+}
+
+String XclTools::GetXclMacroName( const OUString& rSbMacroUrl )
+{
+ sal_Int32 nSbMacroUrlLen = rSbMacroUrl.getLength();
+ sal_Int32 nMacroNameLen = nSbMacroUrlLen - maSbMacroPrefix.getLength() - maSbMacroSuffix.getLength();
+ if( (nMacroNameLen > 0) && rSbMacroUrl.matchIgnoreAsciiCase( maSbMacroPrefix, 0 ) &&
+ rSbMacroUrl.matchIgnoreAsciiCase( maSbMacroSuffix, nSbMacroUrlLen - maSbMacroSuffix.getLength() ) )
+ return rSbMacroUrl.copy( maSbMacroPrefix.getLength(), nMacroNameLen );
+ return String::EmptyString();
+}
+
// read/write colors ----------------------------------------------------------
XclImpStream& operator>>( XclImpStream& rStrm, Color& rColor )
@@ -700,4 +734,3 @@ XclExpStream& operator<<( XclExpStream& rStrm, const Color& rColor )
}
// ============================================================================
-
diff --git a/sc/source/filter/excel/xlview.cxx b/sc/source/filter/excel/xlview.cxx
index d9cbbbb4b7c0..8e9df7e0ac1f 100644
--- a/sc/source/filter/excel/xlview.cxx
+++ b/sc/source/filter/excel/xlview.cxx
@@ -76,6 +76,7 @@ void XclTabViewData::SetDefaults()
mbDefGridColor = true;
mbShowFormulas = false;
mbShowGrid = mbShowHeadings = mbShowZeros = mbShowOutline = true;
+ maTabBgColor.SetColor( COL_AUTO );
}
bool XclTabViewData::IsSplit() const