summaryrefslogtreecommitdiff
path: root/sc/source/filter/ftools
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/filter/ftools')
-rw-r--r--sc/source/filter/ftools/fapihelper.cxx8
-rw-r--r--sc/source/filter/ftools/fprogressbar.cxx131
-rw-r--r--sc/source/filter/ftools/ftools.cxx123
-rw-r--r--sc/source/filter/ftools/makefile.mk4
4 files changed, 187 insertions, 79 deletions
diff --git a/sc/source/filter/ftools/fapihelper.cxx b/sc/source/filter/ftools/fapihelper.cxx
index 66f30846266c..560d29d700cd 100644
--- a/sc/source/filter/ftools/fapihelper.cxx
+++ b/sc/source/filter/ftools/fapihelper.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: fapihelper.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: dr $ $Date: 2002-11-21 12:09:09 $
+ * last change: $Author: hr $ $Date: 2003-03-26 18:04:50 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -105,8 +105,10 @@ bool getPropAny( Any& rAny, const Reference< XPropertySet >& rxProp, const OUStr
{
Reference< XPropertySetInfo > xInfo = rxProp->getPropertySetInfo();
if( xInfo.is() && xInfo->hasPropertyByName( rName ) )
+ {
rAny = rxProp->getPropertyValue( rName );
- bSuccess = true;
+ bSuccess = true;
+ }
}
catch( Exception& )
{
diff --git a/sc/source/filter/ftools/fprogressbar.cxx b/sc/source/filter/ftools/fprogressbar.cxx
index 4f9ccda49500..4aea61460bad 100644
--- a/sc/source/filter/ftools/fprogressbar.cxx
+++ b/sc/source/filter/ftools/fprogressbar.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: fprogressbar.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: dr $ $Date: 2002-11-21 12:09:09 $
+ * last change: $Author: hr $ $Date: 2003-03-26 18:04:50 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -81,6 +81,11 @@
// ============================================================================
+const sal_Int32 SCF_INVALID_SEG = -1;
+
+
+// ============================================================================
+
ScfProgressBar::ScfProgressSegment::ScfProgressSegment( sal_uInt32 nSize ) :
mpProgress( NULL ),
mnSize( nSize ),
@@ -95,40 +100,41 @@ ScfProgressBar::ScfProgressSegment::~ScfProgressSegment()
// ============================================================================
-ScfProgressBar::ScfProgressBar( const String& rText ) :
- maText( rText ),
- mpSysProgress( NULL ),
- mpParentProgress( NULL ),
- mpParentSegment( NULL ),
- mpCurrSegment( NULL ),
- mnTotalSize( 0 ),
- mnTotalPos( 0 ),
- mnUnitSize( 0 ),
- mnNextUnitPos( 0 ),
- mbInProgress( false )
+ScfProgressBar::ScfProgressBar( SfxObjectShell* pDocShell, const String& rText ) :
+ maText( rText )
+{
+ Init( pDocShell );
+}
+
+ScfProgressBar::ScfProgressBar( SfxObjectShell* pDocShell, sal_uInt16 nResId ) :
+ maText( ScGlobal::GetRscString( nResId ) )
{
+ Init( pDocShell );
}
-ScfProgressBar::ScfProgressBar( ScfProgressBar* pParProgress, ScfProgressSegment* pParSegment ) :
- mpSysProgress( NULL ),
- mpParentProgress( pParProgress ),
- mpParentSegment( pParSegment ),
- mpCurrSegment( NULL ),
- mnTotalSize( 0 ),
- mnTotalPos( 0 ),
- mnUnitSize( 0 ),
- mnNextUnitPos( 0 ),
- mbInProgress( false )
+ScfProgressBar::ScfProgressBar( ScfProgressBar& rParProgress, ScfProgressSegment* pParSegment )
{
+ Init( rParProgress.mpDocShell );
+ mpParentProgress = &rParProgress;
+ mpParentSegment = pParSegment;
}
ScfProgressBar::~ScfProgressBar()
{
}
-ScfProgressBar::ScfProgressSegment* ScfProgressBar::GetSegment( sal_uInt32 nSegment ) const
+void ScfProgressBar::Init( SfxObjectShell* pDocShell )
+{
+ mpDocShell = pDocShell;
+ mpParentProgress = NULL;
+ mpParentSegment = mpCurrSegment = NULL;
+ mnTotalSize = mnTotalPos = mnUnitSize = mnNextUnitPos = 0;
+ mbInProgress = false;
+}
+
+ScfProgressBar::ScfProgressSegment* ScfProgressBar::GetSegment( sal_Int32 nSegment ) const
{
- if( nSegment == ~0UL )
+ if( nSegment < 0 )
return NULL;
DBG_ASSERT( maSegments.GetObject( nSegment ), "ScfProgressBar::GetSegment - invalid segment index" );
return maSegments.GetObject( nSegment );
@@ -143,7 +149,7 @@ void ScfProgressBar::SetCurrSegment( ScfProgressSegment* pSegment )
if( mpParentProgress && mpParentSegment )
mpParentProgress->SetCurrSegment( mpParentSegment );
else if( !mpSysProgress.get() && mnTotalSize )
- mpSysProgress.reset( new ScProgress( NULL, maText, mnTotalSize ) );
+ mpSysProgress.reset( new ScProgress( mpDocShell, maText, mnTotalSize ) );
if( !mbInProgress && mpCurrSegment && mnTotalSize )
{
@@ -181,26 +187,31 @@ void ScfProgressBar::IncreaseProgressBar( sal_uInt32 nDelta )
mnTotalPos = nNewPos;
}
-sal_uInt32 ScfProgressBar::AddSegment( sal_uInt32 nSize )
+sal_Int32 ScfProgressBar::AddSegment( sal_uInt32 nSize )
{
DBG_ASSERT( !mbInProgress, "ScfProgressBar::AddSegment - already in progress mode" );
if( !nSize )
- return ~0UL;
+ return SCF_INVALID_SEG;
maSegments.Append( new ScfProgressSegment( nSize ) );
mnTotalSize += nSize;
return maSegments.Count() - 1;
}
-ScfProgressBar& ScfProgressBar::GetSegmentProgressBar( sal_uInt32 nSegment )
+ScfProgressBar& ScfProgressBar::GetSegmentProgressBar( sal_Int32 nSegment )
{
ScfProgressSegment* pSegment = GetSegment( nSegment );
- if( pSegment && !pSegment->mpProgress.get() )
- pSegment->mpProgress.reset( new ScfProgressBar( this, pSegment ) );
- return pSegment ? *pSegment->mpProgress : *this;
+ DBG_ASSERT( !pSegment || !pSegment->mnPos, "ScfProgressBar::GetSegmentProgressBar - segment already started" );
+ if( pSegment && !pSegment->mnPos )
+ {
+ if( !pSegment->mpProgress.get() )
+ pSegment->mpProgress.reset( new ScfProgressBar( *this, pSegment ) );
+ return *pSegment->mpProgress;
+ }
+ return *this;
}
-void ScfProgressBar::ActivateSegment( sal_uInt32 nSegment )
+void ScfProgressBar::ActivateSegment( sal_Int32 nSegment )
{
DBG_ASSERT( mnTotalSize, "ScfProgressBar::ActivateSegment - progress range is zero" );
if( mnTotalSize )
@@ -212,6 +223,7 @@ void ScfProgressBar::Progress( sal_uInt32 nPos )
DBG_ASSERT( mbInProgress && mpCurrSegment, "ScfProgressBar::Progress - no segment started" );
if( mpCurrSegment )
{
+ DBG_ASSERT( !mpCurrSegment->mpProgress.get(), "ScfProgressBar::Progress - contains sub progress" );
DBG_ASSERT( mpCurrSegment->mnPos <= nPos, "ScfProgressBar::Progress - delta pos < 0" );
DBG_ASSERT( nPos <= mpCurrSegment->mnSize, "ScfProgressBar::Progress - segment overflow" );
if( (mpCurrSegment->mnPos < nPos) && (nPos <= mpCurrSegment->mnSize) )
@@ -230,3 +242,56 @@ void ScfProgressBar::Progress()
// ============================================================================
+ScfSimpleProgressBar::ScfSimpleProgressBar( sal_uInt32 nSize, SfxObjectShell* pDocShell, const String& rText ) :
+ maProgress( pDocShell, rText )
+{
+ Init( nSize );
+}
+
+ScfSimpleProgressBar::ScfSimpleProgressBar( sal_uInt32 nSize, SfxObjectShell* pDocShell, sal_uInt16 nResId ) :
+ maProgress( pDocShell, nResId )
+{
+ Init( nSize );
+}
+
+void ScfSimpleProgressBar::Init( sal_uInt32 nSize )
+{
+ sal_Int32 nSegment = maProgress.AddSegment( nSize );
+ if( nSegment >= 0 )
+ maProgress.ActivateSegment( nSegment );
+}
+
+
+// ============================================================================
+
+ScfStreamProgressBar::ScfStreamProgressBar( SvStream& rStrm, SfxObjectShell* pDocShell, const String& rText ) :
+ mrStrm( rStrm )
+{
+ Init( pDocShell, rText );
+}
+
+ScfStreamProgressBar::ScfStreamProgressBar( SvStream& rStrm, SfxObjectShell* pDocShell, sal_uInt16 nResId ) :
+ mrStrm( rStrm )
+{
+ Init( pDocShell, ScGlobal::GetRscString( nResId ) );
+}
+
+void ScfStreamProgressBar::Progress()
+{
+ mpProgress->Progress( mrStrm.Tell() );
+}
+
+void ScfStreamProgressBar::Init( SfxObjectShell* pDocShell, const String& rText )
+{
+ sal_uInt32 nPos = mrStrm.Tell();
+ mrStrm.Seek( STREAM_SEEK_TO_END );
+ sal_uInt32 nSize = mrStrm.Tell();
+ mrStrm.Seek( nPos );
+
+ mpProgress.reset( new ScfSimpleProgressBar( nSize, pDocShell, rText ) );
+ Progress();
+}
+
+
+// ============================================================================
+
diff --git a/sc/source/filter/ftools/ftools.cxx b/sc/source/filter/ftools/ftools.cxx
index aca8c1686fa1..71b65cbfb347 100644
--- a/sc/source/filter/ftools/ftools.cxx
+++ b/sc/source/filter/ftools/ftools.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ftools.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: dr $ $Date: 2002-11-21 12:09:10 $
+ * last change: $Author: hr $ $Date: 2003-03-26 18:04:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -71,6 +71,9 @@
#include "ftools.hxx"
#endif
+#ifndef _SVSTOR_HXX
+#include <so3/svstor.hxx>
+#endif
#ifndef _UNOTOOLS_CHARCLASS_HXX
#include <unotools/charclass.hxx>
#endif
@@ -80,6 +83,9 @@
#ifndef SC_SCGLOB_HXX
#include "global.hxx"
#endif
+#ifndef SC_COMPILER_HXX
+#include "compiler.hxx"
+#endif
#include "excdefs.hxx"
@@ -225,39 +231,44 @@ void ScfTools::EraseQuotes( String& rString, sal_Unicode cQuote )
// *** conversion of names *** ------------------------------------------------
-void ScfTools::ConvertName( String& rName, bool bCheckPeriod )
+void ScfTools::ConvertToScSheetName( String& rName )
{
- if( !rName.Len() ) return;
+ for( xub_StrLen nPos = 0, nLen = rName.Len(); nPos < nLen; ++nPos )
+ {
+ sal_Unicode cChar = rName.GetChar( nPos );
+ bool bSpace = (cChar == ' ');
+ if( (!ScGlobal::pCharClass->isLetterNumeric( rName, nPos ) && !bSpace) || (!nPos && bSpace) )
+ rName.SetChar( nPos, '_' );
+ }
+}
- const sal_Unicode cUnderSc = '_';
- const sal_Unicode cBlank = ' ';
- const sal_Unicode cPoint = '.';
+void ScfTools::ConvertToScDefinedName( String& rName )
+{
+ xub_StrLen nLen = rName.Len();
+ if( nLen && !ScCompiler::IsCharWordChar( rName.GetChar( 0 ) ) )
+ rName.SetChar( 0, '_' );
+ for( xub_StrLen nPos = 1; nPos < nLen; ++nPos )
+ if( !ScCompiler::IsWordChar( rName.GetChar( nPos ) ) )
+ rName.SetChar( nPos, '_' );
+}
- String aNewTable;
- bool bSpace = false;
- for( const sal_Unicode* pChar = rName.GetBuffer(); *pChar; pChar++ )
- {
- if( !(ScGlobal::pCharClass->isLetterNumeric( rName, pChar - rName.GetBuffer() ) ||
- (*pChar == cUnderSc) || (*pChar == cBlank) || (bCheckPeriod && (*pChar == cPoint))) )
- {
- aNewTable += cUnderSc;
- bSpace = false;
- }
- else if( *pChar == cBlank )
- {
- if( bSpace )
- aNewTable += cUnderSc;
- else
- bSpace = true;
- }
- else
- {
- aNewTable += *pChar;
- bSpace = false;
- }
- }
- rName = aNewTable;
+// *** streams and storages *** -----------------------------------------------
+
+const SvStorageStreamRef ScfTools::OpenStorageStreamRead( SvStorage* pStorage, const String& rStrmName )
+{
+ SvStorageStreamRef xStrm;
+ if( pStorage && pStorage->IsContained( rStrmName ) && pStorage->IsStream( rStrmName ) )
+ xStrm = pStorage->OpenStream( rStrmName, STREAM_READ | STREAM_SHARE_DENYALL );
+ return xStrm;
+}
+
+const SvStorageStreamRef ScfTools::OpenStorageStreamWrite( SvStorage* pStorage, const String& rStrmName )
+{
+ SvStorageStreamRef xStrm;
+ if( pStorage )
+ xStrm = pStorage->OpenStream( rStrmName/*, STREAM_READWRITE | STREAM_TRUNC*/ );
+ return xStrm;
}
@@ -316,36 +327,66 @@ void ScfTools::AppendCString( SvStream& rStrm, String& rString, CharSet eSrc )
// *** HTML table names <-> named range names *** -----------------------------
-const String ScfTools::maHTMLDoc( RTL_CONSTASCII_USTRINGPARAM( "HTML_all" ) );
-const String ScfTools::maHTMLTables( RTL_CONSTASCII_USTRINGPARAM( "HTML_tables" ) );
-const String ScfTools::maHTMLTableIndex( RTL_CONSTASCII_USTRINGPARAM( "HTML_" ) );
-const String ScfTools::maHTMLTableName( RTL_CONSTASCII_USTRINGPARAM( "HTML__" ) );
+const String& ScfTools::GetHTMLDocName()
+{
+ static const String saHTMLDoc( RTL_CONSTASCII_USTRINGPARAM( "HTML_all" ) );
+ return saHTMLDoc;
+}
+
+const String& ScfTools::GetHTMLTablesName()
+{
+ static const String saHTMLTables( RTL_CONSTASCII_USTRINGPARAM( "HTML_tables" ) );
+ return saHTMLTables;
+}
+
+const String& ScfTools::GetHTMLIndexPrefix()
+{
+ static const String saHTMLIndexPrefix( RTL_CONSTASCII_USTRINGPARAM( "HTML_" ) );
+ return saHTMLIndexPrefix;
+
+}
+
+const String& ScfTools::GetHTMLNamePrefix()
+{
+ static const String saHTMLNamePrefix( RTL_CONSTASCII_USTRINGPARAM( "HTML__" ) );
+ return saHTMLNamePrefix;
+}
String ScfTools::GetNameFromHTMLIndex( sal_uInt32 nIndex )
{
- String aName( maHTMLTableIndex );
+ String aName( GetHTMLIndexPrefix() );
aName += String::CreateFromInt32( static_cast< sal_Int32 >( nIndex ) );
return aName;
}
String ScfTools::GetNameFromHTMLName( const String& rTabName )
{
- String aName( maHTMLTableName );
+ String aName( GetHTMLNamePrefix() );
aName += rTabName;
return aName;
}
+bool ScfTools::IsHTMLDocName( const String& rSource )
+{
+ return rSource.EqualsIgnoreCaseAscii( GetHTMLDocName() ) == TRUE;
+}
+
+bool ScfTools::IsHTMLTablesName( const String& rSource )
+{
+ return rSource.EqualsIgnoreCaseAscii( GetHTMLTablesName() ) == TRUE;
+}
+
bool ScfTools::GetHTMLNameFromName( const String& rSource, String& rName )
{
rName.Erase();
- if( rSource.EqualsIgnoreCaseAscii( maHTMLTableName, 0, maHTMLTableName.Len() ) )
+ if( rSource.EqualsIgnoreCaseAscii( GetHTMLNamePrefix(), 0, GetHTMLNamePrefix().Len() ) )
{
- rName = rSource.Copy( maHTMLTableName.Len() );
+ rName = rSource.Copy( GetHTMLNamePrefix().Len() );
AddQuotes( rName );
}
- else if( rSource.EqualsIgnoreCaseAscii( maHTMLTableIndex, 0, maHTMLTableIndex.Len() ) )
+ else if( rSource.EqualsIgnoreCaseAscii( GetHTMLIndexPrefix(), 0, GetHTMLIndexPrefix().Len() ) )
{
- String aIndex( rSource.Copy( maHTMLTableIndex.Len() ) );
+ String aIndex( rSource.Copy( GetHTMLIndexPrefix().Len() ) );
if( CharClass::isAsciiNumeric( aIndex ) && (aIndex.ToInt32() > 0) )
rName = aIndex;
}
diff --git a/sc/source/filter/ftools/makefile.mk b/sc/source/filter/ftools/makefile.mk
index f4265fc0558e..0c36c6101a47 100644
--- a/sc/source/filter/ftools/makefile.mk
+++ b/sc/source/filter/ftools/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.1 $
+# $Revision: 1.2 $
#
-# last change: $Author: dr $ $Date: 2002-11-21 12:09:10 $
+# last change: $Author: hr $ $Date: 2003-03-26 18:04:51 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses