2000-09-18 16:07:07 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 21:11:23 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 21:11:23 +00:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 21:11:23 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 21:11:23 +00:00
|
|
|
* $RCSfile: docsh.cxx,v $
|
|
|
|
* $Revision: 1.99 $
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 21:11:23 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 21:11:23 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 21:11:23 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 21:11:23 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
2006-07-21 12:37:27 +00:00
|
|
|
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_sc.hxx"
|
2000-09-18 16:07:07 +00:00
|
|
|
// System - Includes -----------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "scitems.hxx"
|
2002-03-04 18:38:57 +00:00
|
|
|
#include <svx/eeitem.hxx>
|
2002-07-17 16:28:09 +00:00
|
|
|
#include <svx/svxenum.hxx>
|
|
|
|
#include <svx/algitem.hxx>
|
|
|
|
|
2007-05-10 15:55:37 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-10-04 19:14:39 +00:00
|
|
|
#include <sot/clsids.hxx>
|
2001-11-30 13:00:25 +00:00
|
|
|
#include <svtools/securityoptions.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <tools/stream.hxx>
|
|
|
|
#include <tools/string.hxx>
|
2000-10-05 16:13:03 +00:00
|
|
|
#include <tools/urlobj.hxx>
|
2000-10-26 18:07:53 +00:00
|
|
|
#include <vcl/msgbox.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <vcl/virdev.hxx>
|
2000-10-26 18:07:53 +00:00
|
|
|
#include <vcl/waitobj.hxx>
|
|
|
|
#include <svtools/ctrltool.hxx>
|
|
|
|
#include <svtools/sfxecode.hxx>
|
|
|
|
#include <svtools/zforlist.hxx>
|
|
|
|
#include <sfx2/app.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <sfx2/bindings.hxx>
|
|
|
|
#include <sfx2/dinfdlg.hxx>
|
2000-10-26 18:07:53 +00:00
|
|
|
#include <sfx2/docfile.hxx>
|
|
|
|
#include <sfx2/docfilt.hxx>
|
2003-09-19 07:23:05 +00:00
|
|
|
#include <sfx2/fcontnr.hxx>
|
2000-10-26 18:07:53 +00:00
|
|
|
#include <sfx2/evntconf.hxx>
|
|
|
|
#include <sfx2/sfx.hrc>
|
|
|
|
#include <sfx2/topfrm.hxx>
|
2004-10-04 19:14:39 +00:00
|
|
|
#include <sfx2/objface.hxx>
|
2000-10-26 18:07:53 +00:00
|
|
|
#include <svx/srchitem.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <svx/svxmsbas.hxx>
|
2004-02-03 19:29:30 +00:00
|
|
|
#include <svtools/fltrcfg.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <unotools/charclass.hxx>
|
2001-10-15 10:29:21 +00:00
|
|
|
#include <vcl/virdev.hxx>
|
2004-08-31 11:29:54 +00:00
|
|
|
#include "chgtrack.hxx"
|
2008-03-07 11:19:13 +00:00
|
|
|
#include "chgviset.hxx"
|
2002-09-25 08:59:01 +00:00
|
|
|
#include <sfx2/request.hxx>
|
|
|
|
#include <com/sun/star/document/UpdateDocMode.hpp>
|
|
|
|
|
2004-05-10 14:58:42 +00:00
|
|
|
|
|
|
|
#include "scabstdlg.hxx" //CHINA001
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <sot/formats.hxx>
|
|
|
|
#define SOT_FORMATSTR_ID_STARCALC_30 SOT_FORMATSTR_ID_STARCALC
|
|
|
|
|
2004-10-04 19:14:39 +00:00
|
|
|
//REMOVE #ifndef SO2_DECL_SVSTORAGESTREAM_DEFINED
|
|
|
|
//REMOVE #define SO2_DECL_SVSTORAGESTREAM_DEFINED
|
|
|
|
//REMOVE SO2_DECL_REF(SotStorageStream)
|
|
|
|
//REMOVE #endif
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// INCLUDE ---------------------------------------------------------------
|
|
|
|
|
2000-10-26 18:07:53 +00:00
|
|
|
#include "cell.hxx"
|
2000-09-18 16:07:07 +00:00
|
|
|
#include "global.hxx"
|
|
|
|
#include "filter.hxx"
|
|
|
|
#include "scmod.hxx"
|
|
|
|
#include "tabvwsh.hxx"
|
|
|
|
#include "docfunc.hxx"
|
|
|
|
#include "imoptdlg.hxx"
|
|
|
|
#include "impex.hxx"
|
|
|
|
#include "scresid.hxx"
|
|
|
|
#include "sc.hrc"
|
|
|
|
#include "globstr.hrc"
|
2004-05-10 14:58:42 +00:00
|
|
|
//CHINA001 #include "tpstat.hxx"
|
2000-09-18 16:07:07 +00:00
|
|
|
#include "scerrors.hxx"
|
|
|
|
#include "brdcst.hxx"
|
|
|
|
#include "stlpool.hxx"
|
|
|
|
#include "autostyl.hxx"
|
|
|
|
#include "attrib.hxx"
|
|
|
|
#include "asciiopt.hxx"
|
|
|
|
#include "waitoff.hxx"
|
|
|
|
#include "docpool.hxx" // LoadCompleted
|
|
|
|
#include "progress.hxx"
|
|
|
|
#include "pntlock.hxx"
|
|
|
|
#include "collect.hxx"
|
|
|
|
#include "docuno.hxx"
|
|
|
|
#include "appoptio.hxx"
|
|
|
|
#include "detdata.hxx"
|
2000-10-26 18:07:53 +00:00
|
|
|
#include "printfun.hxx"
|
2000-09-18 16:07:07 +00:00
|
|
|
#include "dociter.hxx"
|
|
|
|
#include "cellform.hxx"
|
|
|
|
#include "chartlis.hxx"
|
|
|
|
#include "hints.hxx"
|
|
|
|
#include "xmlwrap.hxx"
|
2001-01-30 15:52:33 +00:00
|
|
|
#include "drwlayer.hxx"
|
2001-04-21 19:31:39 +00:00
|
|
|
#include "refreshtimer.hxx"
|
2001-04-23 08:44:43 +00:00
|
|
|
#include "dbcolect.hxx"
|
2001-05-10 16:31:17 +00:00
|
|
|
#include "scextopt.hxx"
|
2004-03-08 10:53:55 +00:00
|
|
|
#include "compiler.hxx"
|
2003-09-19 07:23:05 +00:00
|
|
|
#include "cfgids.hxx"
|
2004-08-11 08:07:57 +00:00
|
|
|
#include "warnpassword.hxx"
|
2008-02-05 14:45:03 +00:00
|
|
|
#include "optsolver.hxx"
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
#include "docsh.hxx"
|
2006-11-22 09:45:18 +00:00
|
|
|
#include "docshimp.hxx"
|
2001-07-27 12:20:07 +00:00
|
|
|
#include <rtl/logfile.hxx>
|
|
|
|
|
2008-03-07 11:19:13 +00:00
|
|
|
#include <comphelper/processfactory.hxx>
|
|
|
|
|
2004-10-04 19:14:39 +00:00
|
|
|
using namespace com::sun::star;
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// STATIC DATA -----------------------------------------------------------
|
|
|
|
|
|
|
|
// Stream-Namen im Storage
|
|
|
|
|
|
|
|
const sal_Char __FAR_DATA ScDocShell::pStarCalcDoc[] = STRING_SCSTREAM; // "StarCalcDocument"
|
|
|
|
const sal_Char __FAR_DATA ScDocShell::pStyleName[] = "SfxStyleSheets";
|
|
|
|
|
|
|
|
// Filter-Namen (wie in sclib.cxx)
|
|
|
|
|
|
|
|
static const sal_Char __FAR_DATA pFilterSc50[] = "StarCalc 5.0";
|
|
|
|
//static const sal_Char __FAR_DATA pFilterSc50Temp[] = "StarCalc 5.0 Vorlage/Template";
|
|
|
|
static const sal_Char __FAR_DATA pFilterSc40[] = "StarCalc 4.0";
|
|
|
|
//static const sal_Char __FAR_DATA pFilterSc40Temp[] = "StarCalc 4.0 Vorlage/Template";
|
|
|
|
static const sal_Char __FAR_DATA pFilterSc30[] = "StarCalc 3.0";
|
|
|
|
//static const sal_Char __FAR_DATA pFilterSc30Temp[] = "StarCalc 3.0 Vorlage/Template";
|
|
|
|
static const sal_Char __FAR_DATA pFilterSc10[] = "StarCalc 1.0";
|
|
|
|
static const sal_Char __FAR_DATA pFilterXML[] = "StarOffice XML (Calc)";
|
|
|
|
static const sal_Char __FAR_DATA pFilterAscii[] = "Text - txt - csv (StarCalc)";
|
|
|
|
static const sal_Char __FAR_DATA pFilterLotus[] = "Lotus";
|
2006-01-27 14:51:57 +00:00
|
|
|
static const sal_Char __FAR_DATA pFilterQPro6[] = "Quattro Pro 6.0";
|
2000-09-18 16:07:07 +00:00
|
|
|
static const sal_Char __FAR_DATA pFilterExcel4[] = "MS Excel 4.0";
|
|
|
|
static const sal_Char __FAR_DATA pFilterEx4Temp[] = "MS Excel 4.0 Vorlage/Template";
|
|
|
|
static const sal_Char __FAR_DATA pFilterExcel5[] = "MS Excel 5.0/95";
|
|
|
|
static const sal_Char __FAR_DATA pFilterEx5Temp[] = "MS Excel 5.0/95 Vorlage/Template";
|
|
|
|
static const sal_Char __FAR_DATA pFilterExcel95[] = "MS Excel 95";
|
|
|
|
static const sal_Char __FAR_DATA pFilterEx95Temp[] = "MS Excel 95 Vorlage/Template";
|
|
|
|
static const sal_Char __FAR_DATA pFilterExcel97[] = "MS Excel 97";
|
|
|
|
static const sal_Char __FAR_DATA pFilterEx97Temp[] = "MS Excel 97 Vorlage/Template";
|
|
|
|
static const sal_Char __FAR_DATA pFilterDBase[] = "dBase";
|
|
|
|
static const sal_Char __FAR_DATA pFilterDif[] = "DIF";
|
|
|
|
static const sal_Char __FAR_DATA pFilterSylk[] = "SYLK";
|
|
|
|
static const sal_Char __FAR_DATA pFilterHtml[] = "HTML (StarCalc)";
|
2001-05-10 13:11:39 +00:00
|
|
|
static const sal_Char __FAR_DATA pFilterHtmlWebQ[] = "calc_HTML_WebQuery";
|
2000-09-18 16:07:07 +00:00
|
|
|
static const sal_Char __FAR_DATA pFilterRtf[] = "Rich Text Format (StarCalc)";
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
#define ScDocShell
|
|
|
|
#include "scslots.hxx"
|
|
|
|
|
|
|
|
|
|
|
|
SFX_IMPL_INTERFACE(ScDocShell,SfxObjectShell, ScResId(SCSTR_DOCSHELL))
|
2004-02-03 19:29:30 +00:00
|
|
|
{
|
|
|
|
SFX_CHILDWINDOW_REGISTRATION( SID_HYPERLINK_INSERT );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// GlobalName der aktuellen Version:
|
2004-10-04 19:14:39 +00:00
|
|
|
SFX_IMPL_OBJECTFACTORY( ScDocShell, SvGlobalName(SO3_SC_CLASSID), SFXOBJECTSHELL_STD_NORMAL, "scalc" )
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
TYPEINIT1( ScDocShell, SfxObjectShell ); // SfxInPlaceObject: kein Type-Info ?
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
|
|
|
void __EXPORT ScDocShell::FillClass( SvGlobalName* pClassName,
|
2005-12-14 14:09:34 +00:00
|
|
|
sal_uInt32* pFormat,
|
2007-02-27 12:06:59 +00:00
|
|
|
String* /* pAppName */,
|
2000-09-18 16:07:07 +00:00
|
|
|
String* pFullTypeName,
|
|
|
|
String* pShortTypeName,
|
2004-10-04 19:14:39 +00:00
|
|
|
sal_Int32 nFileFormat ) const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-10-04 19:14:39 +00:00
|
|
|
if ( nFileFormat == SOFFICE_FILEFORMAT_60 )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-01-28 12:28:27 +00:00
|
|
|
*pClassName = SvGlobalName( SO3_SC_CLASSID_60 );
|
|
|
|
*pFormat = SOT_FORMATSTR_ID_STARCALC_60;
|
2000-09-18 16:07:07 +00:00
|
|
|
*pFullTypeName = String( ScResId( SCSTR_LONG_SCDOC_NAME ) );
|
|
|
|
*pShortTypeName = String( ScResId( SCSTR_SHORT_SCDOC_NAME ) );
|
|
|
|
}
|
2004-07-13 06:49:46 +00:00
|
|
|
else if ( nFileFormat == SOFFICE_FILEFORMAT_8 )
|
|
|
|
{
|
|
|
|
*pClassName = SvGlobalName( SO3_SC_CLASSID_60 );
|
|
|
|
*pFormat = SOT_FORMATSTR_ID_STARCALC_8;
|
|
|
|
*pFullTypeName = String( RTL_CONSTASCII_USTRINGPARAM("calc8") );
|
|
|
|
*pShortTypeName = String( ScResId( SCSTR_SHORT_SCDOC_NAME ) );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
2008-01-29 14:41:14 +00:00
|
|
|
{
|
2000-09-18 16:07:07 +00:00
|
|
|
DBG_ERROR("wat fuer ne Version?");
|
2008-01-29 14:41:14 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ScDocShell::DoEnterHandler()
|
|
|
|
{
|
|
|
|
ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
|
|
|
|
if (pViewSh)
|
|
|
|
if (pViewSh->GetViewData()->GetDocShell() == this)
|
|
|
|
SC_MOD()->InputEnterHandler();
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
2004-06-04 10:23:23 +00:00
|
|
|
SCTAB ScDocShell::GetSaveTab()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-06-04 10:23:23 +00:00
|
|
|
SCTAB nTab = 0;
|
2000-09-18 16:07:07 +00:00
|
|
|
ScTabViewShell* pSh = GetBestViewShell();
|
|
|
|
if (pSh)
|
|
|
|
{
|
|
|
|
const ScMarkData& rMark = pSh->GetViewData()->GetMarkData();
|
|
|
|
for ( nTab = 0; nTab <= MAXTAB; nTab++ ) // erste markierte Tabelle
|
|
|
|
if ( rMark.GetTableSelect( nTab ) )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return nTab;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
2004-10-04 19:14:39 +00:00
|
|
|
/*
|
|
|
|
BOOL ScDocShell::LoadCalc( SotStorage* pStor ) // StarCalc 3, 4 or 5 file
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-12-19 18:48:07 +00:00
|
|
|
// MacroCallMode is no longer needed, state is kept in SfxObjectShell now
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
BOOL bRet = TRUE;
|
|
|
|
|
2004-10-04 19:14:39 +00:00
|
|
|
SotStorageStreamRef aPoolStm = pStor->OpenStream( String::CreateFromAscii(pStyleName), STREAM_STD_READ );
|
|
|
|
SotStorageStreamRef aDocStm = pStor->OpenStream( String::CreateFromAscii(pStarCalcDoc), STREAM_STD_READ );
|
2000-09-18 16:07:07 +00:00
|
|
|
ULONG nPoolErr = aPoolStm->GetError();
|
|
|
|
ULONG nDocErr = aDocStm->GetError();
|
|
|
|
|
|
|
|
ScProgress* pProgress = NULL;
|
2003-04-17 12:23:04 +00:00
|
|
|
SfxObjectCreateMode eShellMode = GetCreateMode();
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( eShellMode == SFX_CREATE_MODE_STANDARD && !nDocErr )
|
|
|
|
{
|
|
|
|
ULONG nCurPos = aDocStm->Tell();
|
|
|
|
ULONG nEndPos = aDocStm->Seek( STREAM_SEEK_TO_END );
|
|
|
|
aDocStm->Seek( nCurPos );
|
|
|
|
ULONG nRange = nEndPos - nCurPos;
|
|
|
|
pProgress = new ScProgress( this, ScGlobal::GetRscString(STR_LOAD_DOC), nRange );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( nPoolErr == ERRCODE_IO_NOTEXISTS && nDocErr == ERRCODE_IO_NOTEXISTS )
|
|
|
|
{
|
|
|
|
// leerer Storage = leeres Dokument -> wie InitNew
|
|
|
|
|
|
|
|
aDocument.MakeTable(0);
|
|
|
|
Size aSize( (long) ( STD_COL_WIDTH * HMM_PER_TWIPS * OLE_STD_CELLS_X ),
|
|
|
|
(long) ( ScGlobal::nStdRowHeight * HMM_PER_TWIPS * OLE_STD_CELLS_Y ) );
|
|
|
|
// hier muss auch der Start angepasst werden
|
|
|
|
SetVisAreaOrSize( Rectangle( Point(), aSize ), TRUE );
|
|
|
|
aDocument.GetStyleSheetPool()->CreateStandardStyles();
|
|
|
|
aDocument.UpdStlShtPtrsFrmNms();
|
|
|
|
}
|
|
|
|
else if ( !nPoolErr && !nDocErr )
|
|
|
|
{
|
|
|
|
aPoolStm->SetVersion(pStor->GetVersion());
|
|
|
|
aDocStm->SetVersion(pStor->GetVersion());
|
|
|
|
|
|
|
|
aDocument.Clear(); // keine Referenzen auf Pool behalten!
|
|
|
|
|
|
|
|
RemoveItem( SID_ATTR_CHAR_FONTLIST );
|
|
|
|
RemoveItem( ITEMID_COLOR_TABLE );
|
|
|
|
RemoveItem( ITEMID_GRADIENT_LIST );
|
|
|
|
RemoveItem( ITEMID_HATCH_LIST );
|
|
|
|
RemoveItem( ITEMID_BITMAP_LIST );
|
|
|
|
RemoveItem( ITEMID_DASH_LIST );
|
|
|
|
RemoveItem( ITEMID_LINEEND_LIST );
|
|
|
|
|
|
|
|
aDocument.LoadPool( *aPoolStm, FALSE ); // FALSE: RefCounts nicht laden
|
|
|
|
bRet = (aPoolStm->GetError() == 0);
|
|
|
|
|
|
|
|
if ( !bRet )
|
|
|
|
{
|
|
|
|
pStor->SetError( aPoolStm->GetError() );
|
|
|
|
DBG_ERROR( "Fehler im Pool-Stream" );
|
|
|
|
}
|
|
|
|
else if (eShellMode != SFX_CREATE_MODE_ORGANIZER)
|
|
|
|
{
|
|
|
|
// ViewOptions are not completely stored (to avoid warnings),
|
|
|
|
// so must be initialized from global settings.
|
|
|
|
//! This can be removed if a new file format loads all ViewOptions !!!
|
|
|
|
|
|
|
|
aDocument.SetViewOptions( SC_MOD()->GetViewOptions() );
|
|
|
|
|
|
|
|
ULONG nErrCode = aPoolStm->GetErrorCode();
|
|
|
|
const ByteString aStrKey = pStor->GetKey();
|
|
|
|
const BOOL bKeySet = (aStrKey.Len() > 0);
|
|
|
|
|
|
|
|
if ( bKeySet )
|
|
|
|
aDocStm->SetKey( aStrKey ); // Passwort setzen
|
|
|
|
|
|
|
|
bRet = aDocument.Load( *aDocStm, pProgress );
|
|
|
|
|
|
|
|
if ( !bRet && bKeySet ) // Passwort falsch
|
|
|
|
{
|
|
|
|
SetError( ERRCODE_SFX_WRONGPASSWORD );
|
|
|
|
pStor->SetError( ERRCODE_SFX_WRONGPASSWORD );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( aDocStm->GetError() )
|
|
|
|
{
|
|
|
|
// Zeile-8192-Meldung braucht nur zu kommen, wenn die Zeilen
|
|
|
|
// beschraenkt sind, sonst ist "falsches Format" besser
|
|
|
|
#ifdef SC_LIMIT_ROWS
|
|
|
|
if ( aDocument.HasLostData() ) // zuviele Zeilen?
|
|
|
|
pStor->SetError( SCERR_IMPORT_8K_LIMIT );
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
pStor->SetError( aDocStm->GetError() );
|
|
|
|
bRet = FALSE;
|
|
|
|
DBG_ERROR( "Fehler im Document-Stream" );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( !(nErrCode & ERRCODE_WARNING_MASK) )
|
|
|
|
nErrCode = aDocStm->GetErrorCode();
|
|
|
|
if ( nErrCode & ERRCODE_WARNING_MASK )
|
|
|
|
SetError( nErrCode );
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bRet)
|
|
|
|
{
|
|
|
|
aDocument.UpdateFontCharSet();
|
|
|
|
|
|
|
|
UpdateLinks(); // verknuepfte Tabellen in Link-Manager
|
|
|
|
RemoveUnknownObjects(); // unbekannte Ole-Objekte loeschen
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // SFX_CREATE_MODE_ORGANIZER
|
|
|
|
{
|
|
|
|
// UpdateStdNames is called from ScDocument::Load, but is also needed
|
|
|
|
// if only the styles are loaded!
|
|
|
|
ScStyleSheetPool* pStylePool = aDocument.GetStyleSheetPool();
|
|
|
|
if (pStylePool)
|
|
|
|
pStylePool->UpdateStdNames(); // correct style names for different languages
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bRet)
|
|
|
|
aDocument.GetPool()->MyLoadCompleted();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DBG_ERROR( "Stream-Fehler");
|
|
|
|
bRet = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!aDocument.HasTable(0))
|
|
|
|
aDocument.MakeTable(0);
|
|
|
|
|
|
|
|
if (eShellMode == SFX_CREATE_MODE_EMBEDDED)
|
|
|
|
{
|
2004-06-04 10:23:23 +00:00
|
|
|
SCTAB nVisTab = aDocument.GetVisibleTab();
|
2000-09-18 16:07:07 +00:00
|
|
|
BOOL bHasVis = aDocument.HasTable(nVisTab);
|
|
|
|
if ( SfxInPlaceObject::GetVisArea().IsEmpty() || !bHasVis )
|
|
|
|
{
|
|
|
|
if (!bHasVis)
|
|
|
|
{
|
|
|
|
nVisTab = 0;
|
|
|
|
aDocument.SetVisibleTab(nVisTab);
|
|
|
|
}
|
2004-06-04 10:23:23 +00:00
|
|
|
SCCOL nStartCol;
|
|
|
|
SCROW nStartRow;
|
2000-09-18 16:07:07 +00:00
|
|
|
aDocument.GetDataStart( nVisTab, nStartCol, nStartRow );
|
2004-06-04 10:23:23 +00:00
|
|
|
SCCOL nEndCol;
|
|
|
|
SCROW nEndRow;
|
2000-09-18 16:07:07 +00:00
|
|
|
aDocument.GetPrintArea( nVisTab, nEndCol, nEndRow );
|
|
|
|
if (nStartCol>nEndCol)
|
|
|
|
nStartCol = nEndCol;
|
|
|
|
if (nStartRow>nEndRow)
|
|
|
|
nStartRow = nEndRow;
|
|
|
|
// hier muss auch der Start angepasst werden
|
|
|
|
SetVisAreaOrSize( aDocument.GetMMRect( nStartCol,nStartRow, nEndCol,nEndRow, nVisTab ),
|
|
|
|
TRUE );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
delete pProgress;
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-04 19:14:39 +00:00
|
|
|
BOOL ScDocShell::SaveCalc( SotStorage* pStor ) // Calc 3, 4 or 5 file
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
BOOL bRet = TRUE;
|
|
|
|
|
|
|
|
ScProgress* pProgress = NULL;
|
2003-04-17 12:23:04 +00:00
|
|
|
SfxObjectCreateMode eShellMode = GetCreateMode();
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( eShellMode == SFX_CREATE_MODE_STANDARD )
|
|
|
|
{
|
|
|
|
ULONG nRange = aDocument.GetWeightedCount() + 1;
|
|
|
|
pProgress = new ScProgress( this, ScGlobal::GetRscString(STR_SAVE_DOC), nRange );
|
|
|
|
}
|
|
|
|
|
2004-10-04 19:14:39 +00:00
|
|
|
SotStorageStreamRef aPoolStm = pStor->OpenStream( String::CreateFromAscii(pStyleName) );
|
2000-09-18 16:07:07 +00:00
|
|
|
if( !aPoolStm->GetError() )
|
|
|
|
{
|
|
|
|
aPoolStm->SetVersion(pStor->GetVersion());
|
|
|
|
aPoolStm->SetSize(0);
|
|
|
|
bRet = aDocument.SavePool( *aPoolStm );
|
2003-03-26 17:07:02 +00:00
|
|
|
if ( aPoolStm->GetErrorCode() && !pStor->GetErrorCode() )
|
|
|
|
pStor->SetError(aPoolStm->GetErrorCode());
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DBG_ERROR( "Stream Error" );
|
|
|
|
bRet = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bRet && eShellMode != SFX_CREATE_MODE_ORGANIZER )
|
|
|
|
{
|
2004-10-04 19:14:39 +00:00
|
|
|
SotStorageStreamRef aDocStm = pStor->OpenStream( String::CreateFromAscii(pStarCalcDoc) );
|
2000-09-18 16:07:07 +00:00
|
|
|
if( !aDocStm->GetError() )
|
|
|
|
{
|
|
|
|
aDocStm->SetVersion(pStor->GetVersion());
|
|
|
|
aDocStm->SetKey(pStor->GetKey()); // Passwort setzen
|
|
|
|
aDocStm->SetSize(0);
|
|
|
|
bRet = aDocument.Save( *aDocStm, pProgress );
|
2000-10-05 16:13:03 +00:00
|
|
|
DBG_ASSERT( bRet, "Error while saving" );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( aDocument.HasLostData() )
|
|
|
|
{
|
|
|
|
// Warnung, dass nicht alles gespeichert wurde
|
|
|
|
|
|
|
|
if (!pStor->GetError())
|
|
|
|
pStor->SetError(SCWARN_EXPORT_MAXROW);
|
|
|
|
}
|
|
|
|
else if ( aDocStm->GetErrorCode() && !pStor->GetErrorCode() )
|
|
|
|
pStor->SetError(aDocStm->GetErrorCode());
|
2004-02-03 19:29:30 +00:00
|
|
|
else if ( SvtFilterOptions::Get()->IsLoadExcelBasicStorage() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
// #75497# warning if MS VBA macros are lost
|
|
|
|
// GetSaveWarningOfMSVBAStorage checks if sub-storage with VBA macros is present
|
|
|
|
// (only possible when editing Excel documents -- storage is not copied to
|
|
|
|
// StarCalc files)
|
|
|
|
ULONG nVBAWarn = SvxImportMSVBasic::GetSaveWarningOfMSVBAStorage( *this );
|
|
|
|
if ( nVBAWarn && !pStor->GetErrorCode() )
|
|
|
|
pStor->SetError( nVBAWarn );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DBG_ERROR( "Stream Error" );
|
|
|
|
bRet = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
delete pProgress;
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
2004-10-04 19:14:39 +00:00
|
|
|
*/
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-08-31 11:29:54 +00:00
|
|
|
sal_uInt16 ScDocShell::GetHiddenInformationState( sal_uInt16 nStates )
|
|
|
|
{
|
|
|
|
// get global state like HIDDENINFORMATION_DOCUMENTVERSIONS
|
|
|
|
sal_uInt16 nState = SfxObjectShell::GetHiddenInformationState( nStates );
|
|
|
|
|
|
|
|
if ( nStates & HIDDENINFORMATION_RECORDEDCHANGES )
|
|
|
|
{
|
|
|
|
if ( aDocument.GetChangeTrack() && aDocument.GetChangeTrack()->GetFirst() )
|
|
|
|
nState |= HIDDENINFORMATION_RECORDEDCHANGES;
|
|
|
|
}
|
|
|
|
if ( nStates & HIDDENINFORMATION_NOTES )
|
|
|
|
{
|
|
|
|
SCTAB nTableCount = aDocument.GetTableCount();
|
|
|
|
SCTAB nTable = 0;
|
|
|
|
sal_Bool bFound(sal_False);
|
|
|
|
while ( nTable < nTableCount && !bFound )
|
|
|
|
{
|
|
|
|
ScCellIterator aCellIter( &aDocument, 0,0, nTable, MAXCOL,MAXROW, nTable );
|
|
|
|
ScBaseCell* pCell = aCellIter.GetFirst();
|
|
|
|
while (pCell && !bFound)
|
|
|
|
{
|
|
|
|
if (pCell->GetNotePtr())
|
|
|
|
bFound = sal_True;
|
|
|
|
pCell = aCellIter.GetNext();
|
|
|
|
}
|
|
|
|
nTable++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bFound)
|
|
|
|
nState |= HIDDENINFORMATION_NOTES;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nState;
|
|
|
|
}
|
|
|
|
|
2003-06-04 11:36:58 +00:00
|
|
|
void ScDocShell::BeforeXMLLoading()
|
2001-02-09 19:04:16 +00:00
|
|
|
{
|
2005-03-23 12:04:31 +00:00
|
|
|
aDocument.DisableIdle( TRUE );
|
|
|
|
|
2001-02-09 19:04:16 +00:00
|
|
|
// prevent unnecessary broadcasts and updates
|
2003-06-04 11:36:58 +00:00
|
|
|
DBG_ASSERT(pModificator == NULL, "The Modificator should not exist");
|
|
|
|
pModificator = new ScDocShellModificator( *this );
|
2001-02-09 19:04:16 +00:00
|
|
|
|
|
|
|
aDocument.SetImportingXML( TRUE );
|
2008-01-10 12:15:39 +00:00
|
|
|
aDocument.EnableUndo( FALSE );
|
2001-02-16 14:24:11 +00:00
|
|
|
// prevent unnecessary broadcasts and "half way listeners"
|
|
|
|
aDocument.SetInsertingFromOtherDoc( TRUE );
|
2001-02-09 19:04:16 +00:00
|
|
|
|
2003-04-17 12:23:04 +00:00
|
|
|
if (GetCreateMode() != SFX_CREATE_MODE_ORGANIZER)
|
2001-05-18 16:06:29 +00:00
|
|
|
ScColumn::bDoubleAlloc = sal_True;
|
2003-06-04 11:36:58 +00:00
|
|
|
}
|
2002-09-25 08:59:01 +00:00
|
|
|
|
2003-06-04 11:36:58 +00:00
|
|
|
void ScDocShell::AfterXMLLoading(sal_Bool bRet)
|
|
|
|
{
|
|
|
|
if (GetCreateMode() != SFX_CREATE_MODE_ORGANIZER)
|
|
|
|
{
|
2001-03-29 09:49:18 +00:00
|
|
|
UpdateLinks();
|
|
|
|
// don't prevent establishing of listeners anymore
|
|
|
|
aDocument.SetInsertingFromOtherDoc( FALSE );
|
|
|
|
if ( bRet )
|
|
|
|
{
|
|
|
|
ScChartListenerCollection* pChartListener = aDocument.GetChartListenerCollection();
|
|
|
|
if (pChartListener)
|
|
|
|
pChartListener->UpdateDirtyCharts();
|
2001-12-12 17:32:12 +00:00
|
|
|
|
|
|
|
// #95582#; set the table names of linked tables to the new path
|
2004-06-04 10:23:23 +00:00
|
|
|
SCTAB nTabCount = aDocument.GetTableCount();
|
|
|
|
for (SCTAB i = 0; i < nTabCount; ++i)
|
2001-12-12 17:32:12 +00:00
|
|
|
{
|
|
|
|
if (aDocument.IsLinked( i ))
|
|
|
|
{
|
|
|
|
String aName;
|
|
|
|
aDocument.GetName(i, aName);
|
|
|
|
String aLinkTabName = aDocument.GetLinkTab(i);
|
2002-07-17 16:28:09 +00:00
|
|
|
xub_StrLen nLinkTabNameLength = aLinkTabName.Len();
|
|
|
|
xub_StrLen nNameLength = aName.Len();
|
2001-12-12 17:32:12 +00:00
|
|
|
if (nLinkTabNameLength < nNameLength)
|
|
|
|
{
|
|
|
|
|
|
|
|
// remove the quottes on begin and end of the docname and restore the escaped quotes
|
|
|
|
const sal_Unicode* pNameBuffer = aName.GetBuffer();
|
|
|
|
if ( *pNameBuffer == '\'' && // all docnames have to have a ' character on the first pos
|
|
|
|
ScGlobal::UnicodeStrChr( pNameBuffer, SC_COMPILER_FILE_TAB_SEP ) )
|
|
|
|
{
|
|
|
|
rtl::OUStringBuffer aDocURLBuffer;
|
|
|
|
BOOL bQuote = TRUE; // Dokumentenname ist immer quoted
|
|
|
|
++pNameBuffer;
|
|
|
|
while ( bQuote && *pNameBuffer )
|
|
|
|
{
|
|
|
|
if ( *pNameBuffer == '\'' && *(pNameBuffer-1) != '\\' )
|
|
|
|
bQuote = FALSE;
|
|
|
|
else if( !(*pNameBuffer == '\\' && *(pNameBuffer+1) == '\'') )
|
|
|
|
aDocURLBuffer.append(*pNameBuffer); // falls escaped Quote: nur Quote in den Namen
|
|
|
|
++pNameBuffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if( *pNameBuffer == SC_COMPILER_FILE_TAB_SEP ) // after the last quote of the docname should be the # char
|
|
|
|
{
|
2002-07-17 16:28:09 +00:00
|
|
|
xub_StrLen nIndex = nNameLength - nLinkTabNameLength;
|
2001-12-12 17:32:12 +00:00
|
|
|
INetURLObject aINetURLObject(aDocURLBuffer.makeStringAndClear());
|
|
|
|
if( aName.Equals(aLinkTabName, nIndex, nLinkTabNameLength) &&
|
|
|
|
(aName.GetChar(nIndex - 1) == '#') && // before the table name should be the # char
|
|
|
|
!aINetURLObject.HasError()) // the docname should be a valid URL
|
|
|
|
{
|
|
|
|
aName = ScGlobal::GetDocTabName( aDocument.GetLinkDoc( i ), aDocument.GetLinkTab( i ) );
|
|
|
|
aDocument.RenameTab(i, aName, TRUE, TRUE);
|
|
|
|
}
|
|
|
|
// else; nothing has to happen, because it is a user given name
|
|
|
|
}
|
|
|
|
// else; nothing has to happen, because it is a user given name
|
|
|
|
}
|
|
|
|
// else; nothing has to happen, because it is a user given name
|
|
|
|
}
|
|
|
|
// else; nothing has to happen, because it is a user given name
|
|
|
|
}
|
|
|
|
}
|
2001-03-29 09:49:18 +00:00
|
|
|
}
|
2001-05-18 16:06:29 +00:00
|
|
|
ScColumn::bDoubleAlloc = sal_False;
|
2001-03-29 09:49:18 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
aDocument.SetInsertingFromOtherDoc( FALSE );
|
2003-06-04 11:36:58 +00:00
|
|
|
|
2001-02-09 19:04:16 +00:00
|
|
|
aDocument.SetImportingXML( FALSE );
|
2008-01-10 12:15:39 +00:00
|
|
|
aDocument.EnableUndo( TRUE );
|
2004-06-28 11:41:49 +00:00
|
|
|
bIsEmpty = FALSE;
|
2001-02-09 19:04:16 +00:00
|
|
|
|
2003-06-04 11:36:58 +00:00
|
|
|
if (pModificator)
|
|
|
|
{
|
|
|
|
delete pModificator;
|
|
|
|
pModificator = NULL;
|
|
|
|
}
|
|
|
|
else
|
2008-01-29 14:41:14 +00:00
|
|
|
{
|
2003-06-04 11:36:58 +00:00
|
|
|
DBG_ERROR("The Modificator should exist");
|
2008-01-29 14:41:14 +00:00
|
|
|
}
|
2005-03-23 12:04:31 +00:00
|
|
|
|
|
|
|
aDocument.DisableIdle( FALSE );
|
2003-06-04 11:36:58 +00:00
|
|
|
}
|
|
|
|
|
2007-02-27 12:06:59 +00:00
|
|
|
BOOL ScDocShell::LoadXML( SfxMedium* pLoadMedium, const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStor )
|
2003-06-04 11:36:58 +00:00
|
|
|
{
|
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "sb99857", "ScDocShell::LoadXML" );
|
|
|
|
|
|
|
|
// MacroCallMode is no longer needed, state is kept in SfxObjectShell now
|
|
|
|
|
|
|
|
// no Seek(0) here - always loading from storage, GetInStream must not be called
|
|
|
|
|
|
|
|
BeforeXMLLoading();
|
|
|
|
|
2006-03-27 08:36:04 +00:00
|
|
|
// #i62677# BeforeXMLLoading is also called from ScXMLImport::startDocument when invoked
|
|
|
|
// from an external component. The XMLFromWrapper flag is only set here, when called
|
|
|
|
// through ScDocShell.
|
|
|
|
aDocument.SetXMLFromWrapper( TRUE );
|
|
|
|
|
2007-02-27 12:06:59 +00:00
|
|
|
ScXMLImportWrapper aImport( aDocument, pLoadMedium, xStor );
|
2003-06-04 11:36:58 +00:00
|
|
|
|
|
|
|
sal_Bool bRet(sal_False);
|
2004-10-04 19:14:39 +00:00
|
|
|
ErrCode nError = ERRCODE_NONE;
|
2003-06-04 11:36:58 +00:00
|
|
|
if (GetCreateMode() != SFX_CREATE_MODE_ORGANIZER)
|
2004-10-04 19:14:39 +00:00
|
|
|
bRet = aImport.Import(sal_False, nError);
|
2003-06-04 11:36:58 +00:00
|
|
|
else
|
2004-10-04 19:14:39 +00:00
|
|
|
bRet = aImport.Import(sal_True, nError);
|
|
|
|
|
|
|
|
if ( nError )
|
2007-02-27 12:06:59 +00:00
|
|
|
pLoadMedium->SetError( nError );
|
2003-06-04 11:36:58 +00:00
|
|
|
|
2006-03-27 08:36:04 +00:00
|
|
|
aDocument.SetXMLFromWrapper( FALSE );
|
2003-06-04 11:36:58 +00:00
|
|
|
AfterXMLLoading(bRet);
|
|
|
|
|
2001-02-09 19:04:16 +00:00
|
|
|
//! row heights...
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
2007-02-27 12:06:59 +00:00
|
|
|
BOOL ScDocShell::SaveXML( SfxMedium* pSaveMedium, const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStor )
|
2001-02-09 19:04:16 +00:00
|
|
|
{
|
2001-08-01 06:32:37 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "sb99857", "ScDocShell::SaveXML" );
|
2001-07-27 12:20:07 +00:00
|
|
|
|
2005-03-23 12:04:31 +00:00
|
|
|
aDocument.DisableIdle( TRUE );
|
|
|
|
|
2007-02-27 12:06:59 +00:00
|
|
|
ScXMLImportWrapper aImport( aDocument, pSaveMedium, xStor );
|
2001-03-29 09:49:18 +00:00
|
|
|
sal_Bool bRet(sal_False);
|
2003-04-17 12:23:04 +00:00
|
|
|
if (GetCreateMode() != SFX_CREATE_MODE_ORGANIZER)
|
2001-03-29 09:49:18 +00:00
|
|
|
bRet = aImport.Export(sal_False);
|
|
|
|
else
|
|
|
|
bRet = aImport.Export(sal_True);
|
2005-03-23 12:04:31 +00:00
|
|
|
|
|
|
|
aDocument.DisableIdle( FALSE );
|
|
|
|
|
2001-02-09 19:04:16 +00:00
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
2005-01-11 12:20:20 +00:00
|
|
|
BOOL __EXPORT ScDocShell::Load( SfxMedium& rMedium )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-08-01 06:32:37 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::Load" );
|
2001-07-27 18:19:54 +00:00
|
|
|
|
2001-04-21 19:31:39 +00:00
|
|
|
ScRefreshTimerProtector( aDocument.GetRefreshTimerControlAddress() );
|
|
|
|
|
2000-11-26 12:55:25 +00:00
|
|
|
// only the latin script language is loaded
|
|
|
|
// -> initialize the others from options (before loading)
|
|
|
|
InitOptions();
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
GetUndoManager()->Clear();
|
|
|
|
|
2005-01-11 12:20:20 +00:00
|
|
|
BOOL bRet = SfxObjectShell::Load( rMedium );
|
2000-09-18 16:07:07 +00:00
|
|
|
if( bRet )
|
2001-02-09 19:04:16 +00:00
|
|
|
{
|
2002-11-12 07:43:47 +00:00
|
|
|
if (GetMedium())
|
|
|
|
{
|
2005-01-11 12:20:20 +00:00
|
|
|
SFX_ITEMSET_ARG( rMedium.GetItemSet(), pUpdateDocItem, SfxUInt16Item, SID_UPDATEDOCMODE, sal_False);
|
2002-11-12 07:43:47 +00:00
|
|
|
nCanUpdate = pUpdateDocItem ? pUpdateDocItem->GetValue() : com::sun::star::document::UpdateDocMode::NO_UPDATE;
|
|
|
|
}
|
|
|
|
|
2001-02-09 19:04:16 +00:00
|
|
|
{
|
|
|
|
// prepare a valid document for XML filter
|
|
|
|
// (for ConvertFrom, InitNew is called before)
|
|
|
|
aDocument.MakeTable(0);
|
|
|
|
aDocument.GetStyleSheetPool()->CreateStandardStyles();
|
|
|
|
aDocument.UpdStlShtPtrsFrmNms();
|
|
|
|
|
2005-01-11 12:20:20 +00:00
|
|
|
bRet = LoadXML( &rMedium, NULL );
|
2001-02-09 19:04:16 +00:00
|
|
|
}
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2005-01-11 12:20:20 +00:00
|
|
|
if (!bRet && !rMedium.GetError())
|
|
|
|
rMedium.SetError( SVSTREAM_FILEFORMAT_ERROR );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2005-01-11 12:20:20 +00:00
|
|
|
if (rMedium.GetError())
|
|
|
|
SetError( rMedium.GetError() );
|
2001-06-26 17:52:37 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
InitItems();
|
|
|
|
CalcOutputFactor();
|
|
|
|
|
|
|
|
// #73762# invalidate eventually temporary table areas
|
|
|
|
if ( bRet )
|
|
|
|
aDocument.InvalidateTableArea();
|
|
|
|
|
|
|
|
bIsEmpty = FALSE;
|
|
|
|
FinishedLoading( SFX_LOADED_MAINDOCUMENT | SFX_LOADED_IMAGES );
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-02-27 12:06:59 +00:00
|
|
|
void __EXPORT ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if (rHint.ISA(SfxSimpleHint)) // ohne Parameter
|
|
|
|
{
|
|
|
|
ULONG nSlot = ((const SfxSimpleHint&)rHint).GetId();
|
|
|
|
switch ( nSlot )
|
|
|
|
{
|
|
|
|
case SFX_HINT_TITLECHANGED:
|
|
|
|
aDocument.SetName( SfxShell::GetName() );
|
|
|
|
// RegisterNewTargetNames gibts nicht mehr
|
|
|
|
SFX_APP()->Broadcast(SfxSimpleHint( SC_HINT_DOCNAME_CHANGED )); // Navigator
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (rHint.ISA(SfxStyleSheetHint)) // Vorlagen geaendert
|
|
|
|
NotifyStyle((const SfxStyleSheetHint&) rHint);
|
|
|
|
else if (rHint.ISA(ScAutoStyleHint))
|
|
|
|
{
|
|
|
|
//! direct call for AutoStyles
|
|
|
|
|
|
|
|
// this is called synchronously from ScInterpreter::ScStyle,
|
|
|
|
// modifying the document must be asynchronous
|
|
|
|
// (handled by AddInitial)
|
|
|
|
|
|
|
|
ScAutoStyleHint& rStlHint = (ScAutoStyleHint&)rHint;
|
|
|
|
ScRange aRange = rStlHint.GetRange();
|
|
|
|
String aName1 = rStlHint.GetStyle1();
|
|
|
|
String aName2 = rStlHint.GetStyle2();
|
|
|
|
UINT32 nTimeout = rStlHint.GetTimeout();
|
|
|
|
|
|
|
|
if (!pAutoStyleList)
|
|
|
|
pAutoStyleList = new ScAutoStyleList(this);
|
|
|
|
pAutoStyleList->AddInitial( aRange, aName1, nTimeout, aName2 );
|
|
|
|
}
|
2008-03-07 11:19:13 +00:00
|
|
|
else if ( rHint.ISA( SfxEventHint ) )
|
|
|
|
{
|
|
|
|
ULONG nEventId = ((SfxEventHint&)rHint).GetEventId();
|
|
|
|
switch ( nEventId )
|
|
|
|
{
|
|
|
|
case SFX_EVENT_LOADFINISHED:
|
|
|
|
{
|
|
|
|
if ( IsDocShared() && !SC_MOD()->IsInSharedDocLoading() )
|
|
|
|
{
|
|
|
|
SetSharedFileUrl( GetMedium()->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) );
|
|
|
|
GetMedium()->SwitchDocumentToTempFile();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SFX_EVENT_VIEWCREATED:
|
|
|
|
{
|
|
|
|
if ( IsDocShared() )
|
|
|
|
{
|
|
|
|
ScAppOptions aAppOptions = SC_MOD()->GetAppOptions();
|
|
|
|
if ( aAppOptions.GetShowSharedDocumentWarning() )
|
|
|
|
{
|
|
|
|
WarningBox aBox( GetActiveDialogParent(), WinBits( WB_OK ),
|
|
|
|
ScGlobal::GetRscString( STR_SHARED_DOC_WARNING ) );
|
|
|
|
aBox.SetDefaultCheckBoxText();
|
|
|
|
aBox.Execute();
|
|
|
|
BOOL bChecked = aBox.GetCheckBoxState();
|
|
|
|
if ( bChecked )
|
|
|
|
{
|
|
|
|
aAppOptions.SetShowSharedDocumentWarning( !bChecked );
|
|
|
|
SC_MOD()->SetAppOptions( aAppOptions );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SFX_EVENT_SAVEDOC:
|
|
|
|
{
|
|
|
|
if ( IsDocShared() && !SC_MOD()->IsInSharedDocSaving() )
|
|
|
|
{
|
|
|
|
bool bRetry = true;
|
|
|
|
while ( bRetry )
|
|
|
|
{
|
|
|
|
bRetry = false;
|
|
|
|
uno::Reference< frame::XLoadable > xLoadable;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// load shared file
|
|
|
|
xLoadable.set( LoadSharedDocument(), uno::UNO_QUERY_THROW );
|
|
|
|
uno::Reference< util::XCloseable > xCloseable( xLoadable, uno::UNO_QUERY_THROW );
|
|
|
|
|
|
|
|
// check if shared flag is set in shared file
|
|
|
|
bool bShared = false;
|
|
|
|
ScModelObj* pDocObj = ScModelObj::getImplementation( xLoadable );
|
|
|
|
if ( pDocObj )
|
|
|
|
{
|
|
|
|
ScDocShell* pDocShell = dynamic_cast< ScDocShell* >( pDocObj->GetEmbeddedObject() );
|
|
|
|
if ( pDocShell )
|
|
|
|
{
|
|
|
|
bShared = pDocShell->IsDocShared();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bShared )
|
|
|
|
{
|
|
|
|
uno::Reference< frame::XStorable > xStorable( xLoadable, uno::UNO_QUERY_THROW );
|
|
|
|
|
|
|
|
if ( xStorable->isReadonly() )
|
|
|
|
{
|
|
|
|
xCloseable->close( sal_True );
|
|
|
|
// TODO: get name of user who has the write lock
|
|
|
|
String aUserName( ScGlobal::GetRscString( STR_UNKNOWN_USER ) );
|
|
|
|
String aMessage( ScGlobal::GetRscString( STR_FILE_LOCKED_SAVE_LATER ) );
|
|
|
|
aMessage.SearchAndReplaceAscii( "%1", aUserName );
|
|
|
|
WarningBox aBox( GetActiveDialogParent(), WinBits( WB_RETRY_CANCEL | WB_DEF_RETRY ), aMessage );
|
|
|
|
if ( aBox.Execute() == RET_RETRY )
|
|
|
|
{
|
|
|
|
bRetry = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// merge changes from shared file into temp file
|
|
|
|
bool bSaveToShared = false;
|
|
|
|
if ( pDocObj )
|
|
|
|
{
|
|
|
|
ScDocument* pShareDoc = pDocObj->GetDocument();
|
|
|
|
bSaveToShared = MergeSharedDocument( *pShareDoc );
|
|
|
|
}
|
|
|
|
|
|
|
|
// close shared file
|
|
|
|
xCloseable->close( sal_True );
|
|
|
|
|
|
|
|
// TODO: keep file lock on shared file
|
|
|
|
|
|
|
|
// store to shared file
|
|
|
|
if ( bSaveToShared )
|
|
|
|
{
|
|
|
|
bool bChangedViewSettings = false;
|
|
|
|
ScChangeViewSettings* pChangeViewSet = aDocument.GetChangeViewSettings();
|
|
|
|
if ( pChangeViewSet && pChangeViewSet->ShowChanges() )
|
|
|
|
{
|
|
|
|
pChangeViewSet->SetShowChanges( FALSE );
|
|
|
|
pChangeViewSet->SetShowAccepted( FALSE );
|
|
|
|
aDocument.SetChangeViewSettings( *pChangeViewSet );
|
|
|
|
bChangedViewSettings = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
uno::Reference< frame::XStorable > xStor( GetModel(), uno::UNO_QUERY_THROW );
|
|
|
|
uno::Sequence< beans::PropertyValue > aValues(1);
|
|
|
|
aValues[0].Name = ::rtl::OUString::createFromAscii( "FilterName" );
|
|
|
|
aValues[0].Value <<= ::rtl::OUString( GetMedium()->GetFilter()->GetFilterName() );
|
|
|
|
SC_MOD()->SetInSharedDocSaving( true );
|
|
|
|
xStor->storeToURL( GetSharedFileUrl(), aValues );
|
|
|
|
SC_MOD()->SetInSharedDocSaving( false );
|
|
|
|
|
|
|
|
if ( bChangedViewSettings )
|
|
|
|
{
|
|
|
|
pChangeViewSet->SetShowChanges( TRUE );
|
|
|
|
pChangeViewSet->SetShowAccepted( TRUE );
|
|
|
|
aDocument.SetChangeViewSettings( *pChangeViewSet );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GetUndoManager()->Clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xCloseable->close( sal_True );
|
|
|
|
WarningBox aBox( GetActiveDialogParent(), WinBits( WB_OK ),
|
|
|
|
ScGlobal::GetRscString( STR_DOC_NOLONGERSHARED ) );
|
|
|
|
aBox.Execute();
|
|
|
|
SfxBindings* pBindings = GetViewBindings();
|
|
|
|
if ( pBindings )
|
|
|
|
{
|
|
|
|
SfxStringItem aPathItem( SID_PATH, GetSharedFileUrl() );
|
|
|
|
const SfxPoolItem* ppArgs[] = { &aPathItem, 0 };
|
|
|
|
const SfxBoolItem* pRet = (const SfxBoolItem*)pBindings->ExecuteSynchron( SID_SAVEASDOC, ppArgs );
|
|
|
|
if ( pRet && pRet->GetValue() )
|
|
|
|
{
|
|
|
|
SwitchDocumentToShared( false );
|
|
|
|
pBindings->ExecuteSynchron( SID_SAVEDOC );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch ( uno::Exception& )
|
|
|
|
{
|
|
|
|
DBG_ERROR( "SFX_EVENT_SAVEDOC: caught exception\n" );
|
|
|
|
SC_MOD()->SetInSharedDocSaving( false );
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Reference< util::XCloseable > xClose( xLoadable, uno::UNO_QUERY_THROW );
|
|
|
|
xClose->close( sal_True );
|
|
|
|
}
|
|
|
|
catch ( uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SFX_EVENT_SAVEDOCDONE:
|
|
|
|
{
|
|
|
|
if ( IsDocShared() && !SC_MOD()->IsInSharedDocSaving() )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Inhalte fuer Organizer laden
|
|
|
|
|
|
|
|
|
2005-01-11 12:20:20 +00:00
|
|
|
BOOL __EXPORT ScDocShell::LoadFrom( SfxMedium& rMedium )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-08-01 06:32:37 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::LoadFrom" );
|
2001-07-27 18:19:54 +00:00
|
|
|
|
2001-04-21 19:31:39 +00:00
|
|
|
ScRefreshTimerProtector( aDocument.GetRefreshTimerControlAddress() );
|
|
|
|
|
2007-02-27 12:06:59 +00:00
|
|
|
WaitObject aWait( GetActiveDialogParent() );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
BOOL bRet = FALSE;
|
2001-03-27 15:49:00 +00:00
|
|
|
|
2002-11-12 07:43:47 +00:00
|
|
|
if (GetMedium())
|
|
|
|
{
|
2005-01-11 12:20:20 +00:00
|
|
|
SFX_ITEMSET_ARG( rMedium.GetItemSet(), pUpdateDocItem, SfxUInt16Item, SID_UPDATEDOCMODE, sal_False);
|
2002-11-12 07:43:47 +00:00
|
|
|
nCanUpdate = pUpdateDocItem ? pUpdateDocItem->GetValue() : com::sun::star::document::UpdateDocMode::NO_UPDATE;
|
|
|
|
}
|
|
|
|
|
2004-10-04 19:14:39 +00:00
|
|
|
// until loading/saving only the styles in XML is implemented,
|
|
|
|
// load the whole file
|
2005-01-11 12:20:20 +00:00
|
|
|
bRet = LoadXML( &rMedium, NULL );
|
2004-10-04 19:14:39 +00:00
|
|
|
InitItems();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2005-01-11 12:20:20 +00:00
|
|
|
SfxObjectShell::LoadFrom( rMedium );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOOL __EXPORT ScDocShell::ConvertFrom( SfxMedium& rMedium )
|
|
|
|
{
|
2001-08-01 06:32:37 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::ConvertFrom" );
|
2001-07-27 18:19:54 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
BOOL bRet = FALSE; // FALSE heisst Benutzerabbruch !!
|
|
|
|
// bei Fehler: Fehler am Stream setzen!!
|
|
|
|
|
2001-04-21 19:31:39 +00:00
|
|
|
ScRefreshTimerProtector( aDocument.GetRefreshTimerControlAddress() );
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
GetUndoManager()->Clear();
|
|
|
|
|
|
|
|
// ob nach dem Import optimale Spaltenbreiten gesetzt werden sollen
|
|
|
|
BOOL bSetColWidths = FALSE;
|
|
|
|
BOOL bSetSimpleTextColWidths = FALSE;
|
2004-06-04 10:23:23 +00:00
|
|
|
BOOL bSimpleColWidth[MAXCOLCOUNT];
|
|
|
|
memset( bSimpleColWidth, 1, (MAXCOLCOUNT) * sizeof(BOOL) );
|
2000-09-18 16:07:07 +00:00
|
|
|
ScRange aColWidthRange;
|
|
|
|
// ob nach dem Import optimale Zeilenhoehen gesetzt werden sollen
|
|
|
|
BOOL bSetRowHeights = FALSE;
|
|
|
|
|
|
|
|
aConvFilterName.Erase(); //@ #BugId 54198
|
|
|
|
|
|
|
|
// Alle Filter brauchen die komplette Datei am Stueck (nicht asynchron),
|
|
|
|
// darum vorher per CreateFileStream dafuer sorgen, dass die komplette
|
|
|
|
// Datei uebertragen wird.
|
|
|
|
rMedium.GetPhysicalName(); //! CreateFileStream direkt rufen, wenn verfuegbar
|
|
|
|
|
2002-11-12 07:43:47 +00:00
|
|
|
SFX_ITEMSET_ARG( rMedium.GetItemSet(), pUpdateDocItem, SfxUInt16Item, SID_UPDATEDOCMODE, sal_False);
|
|
|
|
nCanUpdate = pUpdateDocItem ? pUpdateDocItem->GetValue() : com::sun::star::document::UpdateDocMode::NO_UPDATE;
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
const SfxFilter* pFilter = rMedium.GetFilter();
|
|
|
|
if (pFilter)
|
|
|
|
{
|
|
|
|
String aFltName = pFilter->GetFilterName();
|
|
|
|
|
|
|
|
aConvFilterName=aFltName; //@ #BugId 54198
|
|
|
|
|
|
|
|
BOOL bCalc3 = ( aFltName.EqualsAscii(pFilterSc30) );
|
|
|
|
BOOL bCalc4 = ( aFltName.EqualsAscii(pFilterSc40) );
|
|
|
|
if (!bCalc3 && !bCalc4)
|
|
|
|
aDocument.SetInsertingFromOtherDoc( TRUE );
|
|
|
|
|
2004-10-04 19:14:39 +00:00
|
|
|
if (aFltName.EqualsAscii(pFilterXML))
|
2001-02-09 19:04:16 +00:00
|
|
|
bRet = LoadXML( &rMedium, NULL );
|
2000-09-18 16:07:07 +00:00
|
|
|
else if (aFltName.EqualsAscii(pFilterSc10))
|
|
|
|
{
|
|
|
|
SvStream* pStream = rMedium.GetInStream();
|
|
|
|
if (pStream)
|
|
|
|
{
|
|
|
|
FltError eError = ScImportStarCalc10( *pStream, &aDocument );
|
|
|
|
if (eError != eERR_OK)
|
|
|
|
{
|
|
|
|
if (!GetError())
|
|
|
|
SetError(eError);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bRet = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (aFltName.EqualsAscii(pFilterLotus))
|
|
|
|
{
|
2004-11-26 12:52:13 +00:00
|
|
|
String sItStr;
|
|
|
|
SfxItemSet* pSet = rMedium.GetItemSet();
|
|
|
|
const SfxPoolItem* pItem;
|
|
|
|
if ( pSet && SFX_ITEM_SET ==
|
|
|
|
pSet->GetItemState( SID_FILE_FILTEROPTIONS, TRUE, &pItem ) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-11-26 12:52:13 +00:00
|
|
|
sItStr = ((const SfxStringItem*)pItem)->GetValue();
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-11-26 12:52:13 +00:00
|
|
|
if (sItStr.Len() == 0)
|
|
|
|
{
|
|
|
|
// default for lotus import (from API without options):
|
|
|
|
// IBM_437 encoding
|
|
|
|
sItStr = ScGlobal::GetCharsetString( RTL_TEXTENCODING_IBM_437 );
|
|
|
|
}
|
2002-05-29 12:36:53 +00:00
|
|
|
|
2004-11-26 12:52:13 +00:00
|
|
|
ScColumn::bDoubleAlloc = TRUE;
|
|
|
|
FltError eError = ScImportLotus123( rMedium, &aDocument,
|
|
|
|
ScGlobal::GetCharsetValue(sItStr));
|
|
|
|
ScColumn::bDoubleAlloc = FALSE;
|
|
|
|
if (eError != eERR_OK)
|
|
|
|
{
|
|
|
|
if (!GetError())
|
|
|
|
SetError(eError);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-11-26 12:52:13 +00:00
|
|
|
if( ( eError & ERRCODE_WARNING_MASK ) == ERRCODE_WARNING_MASK )
|
2002-05-29 12:36:53 +00:00
|
|
|
bRet = TRUE;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2004-11-26 12:52:13 +00:00
|
|
|
else
|
|
|
|
bRet = TRUE;
|
|
|
|
bSetColWidths = TRUE;
|
|
|
|
bSetRowHeights = TRUE;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else if ( aFltName.EqualsAscii(pFilterExcel4) || aFltName.EqualsAscii(pFilterExcel5) ||
|
|
|
|
aFltName.EqualsAscii(pFilterExcel95) || aFltName.EqualsAscii(pFilterExcel97) ||
|
|
|
|
aFltName.EqualsAscii(pFilterEx4Temp) || aFltName.EqualsAscii(pFilterEx5Temp) ||
|
|
|
|
aFltName.EqualsAscii(pFilterEx95Temp) || aFltName.EqualsAscii(pFilterEx97Temp) )
|
|
|
|
{
|
|
|
|
EXCIMPFORMAT eFormat = EIF_AUTO;
|
|
|
|
if ( aFltName.EqualsAscii(pFilterExcel4) || aFltName.EqualsAscii(pFilterEx4Temp) )
|
|
|
|
eFormat = EIF_BIFF_LE4;
|
|
|
|
else if ( aFltName.EqualsAscii(pFilterExcel5) || aFltName.EqualsAscii(pFilterExcel95) ||
|
|
|
|
aFltName.EqualsAscii(pFilterEx5Temp) || aFltName.EqualsAscii(pFilterEx95Temp) )
|
|
|
|
eFormat = EIF_BIFF5;
|
|
|
|
else if ( aFltName.EqualsAscii(pFilterExcel97) || aFltName.EqualsAscii(pFilterEx97Temp) )
|
|
|
|
eFormat = EIF_BIFF8;
|
|
|
|
|
|
|
|
MakeDrawLayer(); //! im Filter
|
2001-10-23 13:51:33 +00:00
|
|
|
CalcOutputFactor(); // #93255# prepare update of row height
|
2000-09-18 16:07:07 +00:00
|
|
|
ScColumn::bDoubleAlloc = TRUE;
|
|
|
|
FltError eError = ScImportExcel( rMedium, &aDocument, eFormat );
|
|
|
|
ScColumn::bDoubleAlloc = FALSE;
|
|
|
|
aDocument.UpdateFontCharSet();
|
|
|
|
if ( aDocument.IsChartListenerCollectionNeedsUpdate() )
|
|
|
|
aDocument.UpdateChartListenerCollection(); //! fuer alle Importe?
|
|
|
|
|
|
|
|
// #75299# all graphics objects must have names
|
|
|
|
aDocument.EnsureGraphicNames();
|
|
|
|
|
|
|
|
if (eError == SCWARN_IMPORT_RANGE_OVERFLOW)
|
|
|
|
{
|
|
|
|
if (!GetError())
|
|
|
|
SetError(eError);
|
|
|
|
bRet = TRUE;
|
|
|
|
}
|
|
|
|
else if (eError != eERR_OK)
|
|
|
|
{
|
|
|
|
if (!GetError())
|
|
|
|
SetError(eError);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bRet = TRUE;
|
|
|
|
|
2001-10-23 13:51:33 +00:00
|
|
|
// #93255# update of row height done inside of Excel filter to speed up chart import
|
|
|
|
// bSetRowHeights = TRUE; // #75357# optimal row heights must be updated
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else if (aFltName.EqualsAscii(pFilterAscii))
|
|
|
|
{
|
|
|
|
SfxItemSet* pSet = rMedium.GetItemSet();
|
|
|
|
const SfxPoolItem* pItem;
|
|
|
|
ScAsciiOptions aOptions;
|
|
|
|
BOOL bOptInit = FALSE;
|
|
|
|
|
|
|
|
if ( pSet && SFX_ITEM_SET ==
|
|
|
|
pSet->GetItemState( SID_FILE_FILTEROPTIONS, TRUE, &pItem ) )
|
|
|
|
{
|
|
|
|
aOptions.ReadFromString( ((const SfxStringItem*)pItem)->GetValue() );
|
|
|
|
bOptInit = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !bOptInit )
|
|
|
|
{
|
2002-05-29 12:36:53 +00:00
|
|
|
// default for ascii import (from API without options):
|
|
|
|
// ISO8859-1/MS_1252 encoding, comma, double quotes
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2002-05-29 12:36:53 +00:00
|
|
|
aOptions.SetCharSet( RTL_TEXTENCODING_MS_1252 );
|
|
|
|
aOptions.SetFieldSeps( (sal_Unicode) ',' );
|
|
|
|
aOptions.SetTextSep( (sal_Unicode) '"' );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2002-05-29 12:36:53 +00:00
|
|
|
FltError eError = eERR_OK;
|
|
|
|
BOOL bOverflow = FALSE;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2002-05-29 12:36:53 +00:00
|
|
|
if( ! rMedium.IsStorage() )
|
|
|
|
{
|
|
|
|
ScImportExport aImpEx( &aDocument );
|
|
|
|
aImpEx.SetExtOptions( aOptions );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2002-05-29 12:36:53 +00:00
|
|
|
SvStream* pInStream = rMedium.GetInStream();
|
|
|
|
if (pInStream)
|
|
|
|
{
|
|
|
|
pInStream->SetStreamCharSet( aOptions.GetCharSet() );
|
|
|
|
pInStream->Seek( 0 );
|
2005-01-11 12:20:20 +00:00
|
|
|
bRet = aImpEx.ImportStream( *pInStream, rMedium.GetBaseURL() );
|
2002-05-29 12:36:53 +00:00
|
|
|
eError = bRet ? eERR_OK : SCERR_IMPORT_CONNECT;
|
|
|
|
aDocument.StartAllListeners();
|
|
|
|
aDocument.SetDirty();
|
|
|
|
bOverflow = aImpEx.IsOverflow();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
2008-01-29 14:41:14 +00:00
|
|
|
{
|
2000-09-18 16:07:07 +00:00
|
|
|
DBG_ERROR( "No Stream" );
|
2008-01-29 14:41:14 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2002-05-29 12:36:53 +00:00
|
|
|
if (eError != eERR_OK)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-05-29 12:36:53 +00:00
|
|
|
if (!GetError())
|
|
|
|
SetError(eError);
|
|
|
|
}
|
|
|
|
else if ( bOverflow )
|
|
|
|
{
|
|
|
|
if (!GetError())
|
|
|
|
SetError(SCWARN_IMPORT_RANGE_OVERFLOW);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2002-05-29 12:36:53 +00:00
|
|
|
bSetColWidths = TRUE;
|
|
|
|
bSetSimpleTextColWidths = TRUE;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else if (aFltName.EqualsAscii(pFilterDBase))
|
|
|
|
{
|
|
|
|
String sItStr;
|
|
|
|
SfxItemSet* pSet = rMedium.GetItemSet();
|
|
|
|
const SfxPoolItem* pItem;
|
|
|
|
if ( pSet && SFX_ITEM_SET ==
|
|
|
|
pSet->GetItemState( SID_FILE_FILTEROPTIONS, TRUE, &pItem ) )
|
|
|
|
{
|
|
|
|
sItStr = ((const SfxStringItem*)pItem)->GetValue();
|
|
|
|
}
|
2002-05-29 12:36:53 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
if (sItStr.Len() == 0)
|
|
|
|
{
|
2002-05-29 12:36:53 +00:00
|
|
|
// default for dBase import (from API without options):
|
|
|
|
// IBM_850 encoding
|
2000-10-26 18:07:53 +00:00
|
|
|
|
2002-05-29 12:36:53 +00:00
|
|
|
sItStr = ScGlobal::GetCharsetString( RTL_TEXTENCODING_IBM_850 );
|
|
|
|
}
|
2000-10-26 18:07:53 +00:00
|
|
|
|
2002-05-29 12:36:53 +00:00
|
|
|
ULONG eError = DBaseImport( rMedium.GetPhysicalName(),
|
|
|
|
ScGlobal::GetCharsetValue(sItStr), bSimpleColWidth );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2002-05-29 12:36:53 +00:00
|
|
|
if (eError != eERR_OK)
|
|
|
|
{
|
|
|
|
if (!GetError())
|
|
|
|
SetError(eError);
|
|
|
|
bRet = ( eError == SCWARN_IMPORT_RANGE_OVERFLOW );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
2002-05-29 12:36:53 +00:00
|
|
|
bRet = TRUE;
|
2000-10-26 18:07:53 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
aColWidthRange.aStart.SetRow( 1 ); // Spaltenheader nicht
|
|
|
|
bSetColWidths = TRUE;
|
|
|
|
bSetSimpleTextColWidths = TRUE;
|
|
|
|
// Memo-Felder fuehren zu einem bSimpleColWidth[nCol]==FALSE
|
2004-06-04 10:23:23 +00:00
|
|
|
for ( SCCOL nCol=0; nCol <= MAXCOL && !bSetRowHeights; nCol++ )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if ( !bSimpleColWidth[nCol] )
|
|
|
|
bSetRowHeights = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (aFltName.EqualsAscii(pFilterDif))
|
|
|
|
{
|
|
|
|
SvStream* pStream = rMedium.GetInStream();
|
|
|
|
if (pStream)
|
|
|
|
{
|
|
|
|
FltError eError;
|
|
|
|
String sItStr;
|
|
|
|
SfxItemSet* pSet = rMedium.GetItemSet();
|
|
|
|
const SfxPoolItem* pItem;
|
|
|
|
if ( pSet && SFX_ITEM_SET ==
|
|
|
|
pSet->GetItemState( SID_FILE_FILTEROPTIONS, TRUE, &pItem ) )
|
|
|
|
{
|
|
|
|
sItStr = ((const SfxStringItem*)pItem)->GetValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sItStr.Len() == 0)
|
|
|
|
{
|
2002-05-29 12:36:53 +00:00
|
|
|
// default for DIF import (from API without options):
|
|
|
|
// ISO8859-1/MS_1252 encoding
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2002-05-29 12:36:53 +00:00
|
|
|
sItStr = ScGlobal::GetCharsetString( RTL_TEXTENCODING_MS_1252 );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2002-05-29 12:36:53 +00:00
|
|
|
|
|
|
|
eError = ScImportDif( *pStream, &aDocument, ScAddress(0,0,0),
|
|
|
|
ScGlobal::GetCharsetValue(sItStr));
|
|
|
|
if (eError != eERR_OK)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-05-29 12:36:53 +00:00
|
|
|
if (!GetError())
|
|
|
|
SetError(eError);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2002-05-29 12:36:53 +00:00
|
|
|
if( ( eError & ERRCODE_WARNING_MASK ) == ERRCODE_WARNING_MASK )
|
2000-09-18 16:07:07 +00:00
|
|
|
bRet = TRUE;
|
|
|
|
}
|
2002-05-29 12:36:53 +00:00
|
|
|
else
|
|
|
|
bRet = TRUE;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
bSetColWidths = TRUE;
|
|
|
|
bSetSimpleTextColWidths = TRUE;
|
|
|
|
}
|
|
|
|
else if (aFltName.EqualsAscii(pFilterSylk))
|
|
|
|
{
|
|
|
|
FltError eError = SCERR_IMPORT_UNKNOWN;
|
|
|
|
if( !rMedium.IsStorage() )
|
|
|
|
{
|
|
|
|
ScImportExport aImpEx( &aDocument );
|
|
|
|
|
|
|
|
SvStream* pInStream = rMedium.GetInStream();
|
|
|
|
if (pInStream)
|
|
|
|
{
|
|
|
|
pInStream->Seek( 0 );
|
2005-01-11 12:20:20 +00:00
|
|
|
bRet = aImpEx.ImportStream( *pInStream, rMedium.GetBaseURL(), SOT_FORMATSTR_ID_SYLK );
|
2000-09-18 16:07:07 +00:00
|
|
|
eError = bRet ? eERR_OK : SCERR_IMPORT_UNKNOWN;
|
|
|
|
aDocument.StartAllListeners();
|
|
|
|
aDocument.SetDirty();
|
|
|
|
}
|
|
|
|
else
|
2008-01-29 14:41:14 +00:00
|
|
|
{
|
2000-09-18 16:07:07 +00:00
|
|
|
DBG_ERROR( "No Stream" );
|
2008-01-29 14:41:14 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( eError != eERR_OK && !GetError() )
|
|
|
|
SetError(eError);
|
|
|
|
bSetColWidths = TRUE;
|
|
|
|
bSetSimpleTextColWidths = TRUE;
|
|
|
|
}
|
2006-01-27 14:51:57 +00:00
|
|
|
else if (aFltName.EqualsAscii(pFilterQPro6))
|
|
|
|
{
|
|
|
|
ScColumn::bDoubleAlloc = TRUE;
|
|
|
|
FltError eError = ScImportQuattroPro( rMedium, &aDocument);
|
|
|
|
ScColumn::bDoubleAlloc = FALSE;
|
|
|
|
if (eError != eERR_OK)
|
|
|
|
{
|
|
|
|
if (!GetError())
|
|
|
|
SetError( eError );
|
|
|
|
if( ( eError & ERRCODE_WARNING_MASK ) == ERRCODE_WARNING_MASK )
|
|
|
|
bRet = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bRet = TRUE;
|
|
|
|
// TODO: Filter should set column widths. Not doing it here, it may
|
|
|
|
// result in very narrow or wide columns, depending on content.
|
|
|
|
// Setting row heights makes cells with font size attribution or
|
|
|
|
// wrapping enabled look nicer..
|
|
|
|
bSetRowHeights = TRUE;
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
else if (aFltName.EqualsAscii(pFilterRtf))
|
|
|
|
{
|
|
|
|
FltError eError = SCERR_IMPORT_UNKNOWN;
|
|
|
|
if( !rMedium.IsStorage() )
|
|
|
|
{
|
|
|
|
SvStream* pInStream = rMedium.GetInStream();
|
|
|
|
if (pInStream)
|
|
|
|
{
|
|
|
|
pInStream->Seek( 0 );
|
|
|
|
ScRange aRange;
|
2005-01-11 12:20:20 +00:00
|
|
|
eError = ScImportRTF( *pInStream, rMedium.GetBaseURL(), &aDocument, aRange );
|
2000-09-18 16:07:07 +00:00
|
|
|
if (eError != eERR_OK)
|
|
|
|
{
|
|
|
|
if (!GetError())
|
|
|
|
SetError(eError);
|
|
|
|
|
|
|
|
if( ( eError & ERRCODE_WARNING_MASK ) == ERRCODE_WARNING_MASK )
|
|
|
|
bRet = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bRet = TRUE;
|
|
|
|
aDocument.StartAllListeners();
|
|
|
|
aDocument.SetDirty();
|
|
|
|
bSetColWidths = TRUE;
|
|
|
|
bSetRowHeights = TRUE;
|
|
|
|
}
|
|
|
|
else
|
2008-01-29 14:41:14 +00:00
|
|
|
{
|
2000-09-18 16:07:07 +00:00
|
|
|
DBG_ERROR( "No Stream" );
|
2008-01-29 14:41:14 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( eError != eERR_OK && !GetError() )
|
|
|
|
SetError(eError);
|
|
|
|
}
|
2001-04-05 09:52:34 +00:00
|
|
|
else if (aFltName.EqualsAscii(pFilterHtml) || aFltName.EqualsAscii(pFilterHtmlWebQ))
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
FltError eError = SCERR_IMPORT_UNKNOWN;
|
2001-04-05 09:52:34 +00:00
|
|
|
BOOL bWebQuery = aFltName.EqualsAscii(pFilterHtmlWebQ);
|
2000-09-18 16:07:07 +00:00
|
|
|
if( !rMedium.IsStorage() )
|
|
|
|
{
|
|
|
|
SvStream* pInStream = rMedium.GetInStream();
|
|
|
|
if (pInStream)
|
|
|
|
{
|
|
|
|
pInStream->Seek( 0 );
|
|
|
|
ScRange aRange;
|
|
|
|
// HTML macht eigenes ColWidth/RowHeight
|
|
|
|
CalcOutputFactor();
|
2005-01-11 12:20:20 +00:00
|
|
|
eError = ScImportHTML( *pInStream, rMedium.GetBaseURL(), &aDocument, aRange,
|
2001-04-05 09:52:34 +00:00
|
|
|
GetOutputFactor(), !bWebQuery );
|
2000-09-18 16:07:07 +00:00
|
|
|
if (eError != eERR_OK)
|
|
|
|
{
|
|
|
|
if (!GetError())
|
|
|
|
SetError(eError);
|
|
|
|
|
|
|
|
if( ( eError & ERRCODE_WARNING_MASK ) == ERRCODE_WARNING_MASK )
|
|
|
|
bRet = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bRet = TRUE;
|
|
|
|
aDocument.StartAllListeners();
|
|
|
|
aDocument.SetDirty();
|
|
|
|
}
|
|
|
|
else
|
2008-01-29 14:41:14 +00:00
|
|
|
{
|
2000-09-18 16:07:07 +00:00
|
|
|
DBG_ERROR( "No Stream" );
|
2008-01-29 14:41:14 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( eError != eERR_OK && !GetError() )
|
|
|
|
SetError(eError);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!GetError())
|
|
|
|
SetError(SCERR_IMPORT_NI);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!bCalc3)
|
|
|
|
aDocument.SetInsertingFromOtherDoc( FALSE );
|
|
|
|
}
|
|
|
|
else
|
2008-01-29 14:41:14 +00:00
|
|
|
{
|
2000-09-18 16:07:07 +00:00
|
|
|
DBG_ERROR("Kein Filter bei ConvertFrom");
|
2008-01-29 14:41:14 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
InitItems();
|
|
|
|
CalcOutputFactor();
|
|
|
|
if ( bRet && (bSetColWidths || bSetRowHeights) )
|
|
|
|
{ // Spaltenbreiten/Zeilenhoehen anpassen, Basis 100% Zoom
|
|
|
|
Fraction aZoom( 1, 1 );
|
|
|
|
double nPPTX = ScGlobal::nScreenPPTX * (double) aZoom
|
|
|
|
/ GetOutputFactor(); // Faktor ist Drucker zu Bildschirm
|
|
|
|
double nPPTY = ScGlobal::nScreenPPTY * (double) aZoom;
|
|
|
|
VirtualDevice aVirtDev;
|
|
|
|
// all sheets (for Excel import)
|
2004-06-04 10:23:23 +00:00
|
|
|
SCTAB nTabCount = aDocument.GetTableCount();
|
|
|
|
for (SCTAB nTab=0; nTab<nTabCount; nTab++)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-06-04 10:23:23 +00:00
|
|
|
SCCOL nEndCol;
|
|
|
|
SCROW nEndRow;
|
2000-09-18 16:07:07 +00:00
|
|
|
aDocument.GetCellArea( nTab, nEndCol, nEndRow );
|
|
|
|
aColWidthRange.aEnd.SetCol( nEndCol );
|
|
|
|
aColWidthRange.aEnd.SetRow( nEndRow );
|
|
|
|
ScMarkData aMark;
|
|
|
|
aMark.SetMarkArea( aColWidthRange );
|
|
|
|
aMark.MarkToMulti();
|
|
|
|
// Reihenfolge erst Breite dann Hoehe ist wichtig (vergl. hund.rtf)
|
|
|
|
if ( bSetColWidths )
|
|
|
|
{
|
2004-06-04 10:23:23 +00:00
|
|
|
for ( SCCOL nCol=0; nCol <= nEndCol; nCol++ )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
USHORT nWidth = aDocument.GetOptimalColWidth(
|
|
|
|
nCol, nTab, &aVirtDev, nPPTX, nPPTY, aZoom, aZoom, FALSE, &aMark,
|
|
|
|
(bSetSimpleTextColWidths && bSimpleColWidth[nCol]) );
|
|
|
|
aDocument.SetColWidth( nCol, nTab,
|
|
|
|
nWidth + (USHORT)ScGlobal::nLastColWidthExtra );
|
|
|
|
}
|
|
|
|
}
|
2001-05-11 16:11:53 +00:00
|
|
|
// if ( bSetRowHeights )
|
|
|
|
// {
|
|
|
|
// // nExtra must be 0
|
|
|
|
// aDocument.SetOptimalHeight( 0, nEndRow, nTab, 0, &aVirtDev,
|
|
|
|
// nPPTX, nPPTY, aZoom, aZoom, FALSE );
|
|
|
|
// }
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2001-05-11 16:11:53 +00:00
|
|
|
if ( bSetRowHeights )
|
|
|
|
UpdateAllRowHeights(); // with vdev or printer, depending on configuration
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
FinishedLoading( SFX_LOADED_MAINDOCUMENT | SFX_LOADED_IMAGES );
|
|
|
|
|
|
|
|
// #73762# invalidate eventually temporary table areas
|
|
|
|
if ( bRet )
|
|
|
|
aDocument.InvalidateTableArea();
|
|
|
|
|
|
|
|
bIsEmpty = FALSE;
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOOL __EXPORT ScDocShell::Save()
|
|
|
|
{
|
2001-08-01 06:32:37 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::Save" );
|
2001-07-27 18:19:54 +00:00
|
|
|
|
2001-04-21 19:31:39 +00:00
|
|
|
ScRefreshTimerProtector( aDocument.GetRefreshTimerControlAddress() );
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// DoEnterHandler hier nicht (wegen AutoSave), ist im ExecuteSave
|
|
|
|
|
|
|
|
ScChartListenerCollection* pCharts = aDocument.GetChartListenerCollection();
|
|
|
|
if (pCharts)
|
|
|
|
pCharts->UpdateDirtyCharts(); // Charts, die noch upgedated werden muessen
|
2007-08-03 12:08:10 +00:00
|
|
|
aDocument.StopTemporaryChartLock();
|
2000-09-18 16:07:07 +00:00
|
|
|
if (pAutoStyleList)
|
|
|
|
pAutoStyleList->ExecuteAllNow(); // Vorlagen-Timeouts jetzt ausfuehren
|
2003-04-17 12:23:04 +00:00
|
|
|
if (GetCreateMode()== SFX_CREATE_MODE_STANDARD)
|
2004-10-04 19:14:39 +00:00
|
|
|
SfxObjectShell::SetVisArea( Rectangle() ); // normal bearbeitet -> keine VisArea
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// wait cursor is handled with progress bar
|
2004-10-04 19:14:39 +00:00
|
|
|
BOOL bRet = SfxObjectShell::Save();
|
2000-09-18 16:07:07 +00:00
|
|
|
if( bRet )
|
2005-01-11 12:20:20 +00:00
|
|
|
bRet = SaveXML( GetMedium(), NULL );
|
2000-09-18 16:07:07 +00:00
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-01-11 12:20:20 +00:00
|
|
|
BOOL __EXPORT ScDocShell::SaveAs( SfxMedium& rMedium )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-08-01 06:32:37 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::SaveAs" );
|
2001-07-27 18:19:54 +00:00
|
|
|
|
2001-04-21 19:31:39 +00:00
|
|
|
ScRefreshTimerProtector( aDocument.GetRefreshTimerControlAddress() );
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// DoEnterHandler hier nicht (wegen AutoSave), ist im ExecuteSave
|
|
|
|
|
|
|
|
ScChartListenerCollection* pCharts = aDocument.GetChartListenerCollection();
|
|
|
|
if (pCharts)
|
|
|
|
pCharts->UpdateDirtyCharts(); // Charts, die noch upgedated werden muessen
|
2007-08-03 12:08:10 +00:00
|
|
|
aDocument.StopTemporaryChartLock();
|
2000-09-18 16:07:07 +00:00
|
|
|
if (pAutoStyleList)
|
|
|
|
pAutoStyleList->ExecuteAllNow(); // Vorlagen-Timeouts jetzt ausfuehren
|
2003-04-17 12:23:04 +00:00
|
|
|
if (GetCreateMode()== SFX_CREATE_MODE_STANDARD)
|
2004-10-04 19:14:39 +00:00
|
|
|
SfxObjectShell::SetVisArea( Rectangle() ); // normal bearbeitet -> keine VisArea
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// wait cursor is handled with progress bar
|
2005-01-11 12:20:20 +00:00
|
|
|
BOOL bRet = SfxObjectShell::SaveAs( rMedium );
|
2000-09-18 16:07:07 +00:00
|
|
|
if( bRet )
|
2005-01-11 12:20:20 +00:00
|
|
|
bRet = SaveXML( &rMedium, NULL );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOOL __EXPORT ScDocShell::IsInformationLost()
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
const SfxFilter *pFilt = GetMedium()->GetFilter();
|
|
|
|
BOOL bRet = pFilt && pFilt->IsAlienFormat() && bNoInformLost;
|
|
|
|
if (bNoInformLost) // nur einmal!!
|
|
|
|
bNoInformLost = FALSE;
|
|
|
|
return bRet;
|
|
|
|
*/
|
|
|
|
//!!! bei Gelegenheit ein korrekte eigene Behandlung einbauen
|
|
|
|
|
|
|
|
return SfxObjectShell::IsInformationLost();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-17 16:28:09 +00:00
|
|
|
// Xcl-like column width measured in characters of standard font.
|
|
|
|
xub_StrLen lcl_ScDocShell_GetColWidthInChars( USHORT nWidth )
|
|
|
|
{
|
|
|
|
// double fColScale = 1.0;
|
|
|
|
double f = nWidth;
|
|
|
|
f *= 1328.0 / 25.0;
|
|
|
|
f += 90.0;
|
|
|
|
f *= 1.0 / 23.0;
|
|
|
|
// f /= fColScale * 256.0;
|
|
|
|
f /= 256.0;
|
|
|
|
|
|
|
|
return xub_StrLen( f );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void lcl_ScDocShell_GetFixedWidthString( String& rStr, const ScDocument& rDoc,
|
2004-06-04 10:23:23 +00:00
|
|
|
SCTAB nTab, SCCOL nCol, BOOL bValue, SvxCellHorJustify eHorJust )
|
2002-07-17 16:28:09 +00:00
|
|
|
{
|
|
|
|
xub_StrLen nLen = lcl_ScDocShell_GetColWidthInChars(
|
|
|
|
rDoc.GetColWidth( nCol, nTab ) );
|
|
|
|
if ( nLen < rStr.Len() )
|
|
|
|
{
|
|
|
|
if ( bValue )
|
|
|
|
rStr.AssignAscii( "###" );
|
|
|
|
rStr.Erase( nLen );
|
|
|
|
}
|
|
|
|
if ( nLen > rStr.Len() )
|
|
|
|
{
|
|
|
|
if ( bValue && eHorJust == SVX_HOR_JUSTIFY_STANDARD )
|
|
|
|
eHorJust = SVX_HOR_JUSTIFY_RIGHT;
|
|
|
|
switch ( eHorJust )
|
|
|
|
{
|
|
|
|
case SVX_HOR_JUSTIFY_RIGHT:
|
|
|
|
{
|
|
|
|
String aTmp;
|
|
|
|
aTmp.Fill( nLen - rStr.Len() );
|
|
|
|
rStr.Insert( aTmp, 0 );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SVX_HOR_JUSTIFY_CENTER:
|
|
|
|
{
|
|
|
|
xub_StrLen nLen2 = (nLen - rStr.Len()) / 2;
|
|
|
|
String aTmp;
|
|
|
|
aTmp.Fill( nLen2 );
|
|
|
|
rStr.Insert( aTmp, 0 );
|
|
|
|
rStr.Expand( nLen );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
rStr.Expand( nLen );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void lcl_ScDocShell_WriteEmptyFixedWidthString( SvStream& rStream,
|
2004-06-04 10:23:23 +00:00
|
|
|
const ScDocument& rDoc, SCTAB nTab, SCCOL nCol )
|
2002-07-17 16:28:09 +00:00
|
|
|
{
|
|
|
|
String aString;
|
|
|
|
lcl_ScDocShell_GetFixedWidthString( aString, rDoc, nTab, nCol, FALSE,
|
|
|
|
SVX_HOR_JUSTIFY_STANDARD );
|
|
|
|
rStream.WriteUnicodeOrByteText( aString );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-07-17 16:28:09 +00:00
|
|
|
sal_Unicode cDelim = rAsciiOpt.nFieldSepCode;
|
|
|
|
sal_Unicode cStrDelim = rAsciiOpt.nTextSepCode;
|
|
|
|
CharSet eCharSet = rAsciiOpt.eCharSet;
|
|
|
|
BOOL bFixedWidth = rAsciiOpt.bFixedWidth;
|
2006-03-22 11:10:46 +00:00
|
|
|
BOOL bSaveAsShown = rAsciiOpt.bSaveAsShown;
|
2002-07-17 16:28:09 +00:00
|
|
|
|
2000-12-22 00:29:17 +00:00
|
|
|
CharSet eOldCharSet = rStream.GetStreamCharSet();
|
|
|
|
rStream.SetStreamCharSet( eCharSet );
|
|
|
|
USHORT nOldNumberFormatInt = rStream.GetNumberFormatInt();
|
2002-11-25 17:12:53 +00:00
|
|
|
ByteString aStrDelimEncoded; // only used if not Unicode
|
|
|
|
UniString aStrDelimDecoded; // only used if context encoding
|
2003-03-26 17:07:02 +00:00
|
|
|
BOOL bContextOrNotAsciiEncoding;
|
2000-12-22 00:29:17 +00:00
|
|
|
if ( eCharSet == RTL_TEXTENCODING_UNICODE )
|
2002-11-25 17:12:53 +00:00
|
|
|
{
|
2000-12-22 00:29:17 +00:00
|
|
|
rStream.StartWritingUnicodeText();
|
2003-03-26 17:07:02 +00:00
|
|
|
bContextOrNotAsciiEncoding = FALSE;
|
2002-11-25 17:12:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aStrDelimEncoded = ByteString( cStrDelim, eCharSet );
|
|
|
|
rtl_TextEncodingInfo aInfo;
|
|
|
|
aInfo.StructSize = sizeof(aInfo);
|
|
|
|
if ( rtl_getTextEncodingInfo( eCharSet, &aInfo ) )
|
|
|
|
{
|
2003-03-26 17:07:02 +00:00
|
|
|
bContextOrNotAsciiEncoding =
|
|
|
|
(((aInfo.Flags & RTL_TEXTENCODING_INFO_CONTEXT) != 0) ||
|
|
|
|
((aInfo.Flags & RTL_TEXTENCODING_INFO_ASCII) == 0));
|
|
|
|
if ( bContextOrNotAsciiEncoding )
|
2002-11-25 17:12:53 +00:00
|
|
|
aStrDelimDecoded = String( aStrDelimEncoded, eCharSet );
|
|
|
|
}
|
|
|
|
else
|
2003-03-26 17:07:02 +00:00
|
|
|
bContextOrNotAsciiEncoding = FALSE;
|
2002-11-25 17:12:53 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-06-04 10:23:23 +00:00
|
|
|
SCCOL nStartCol = 0;
|
|
|
|
SCROW nStartRow = 0;
|
|
|
|
SCTAB nTab = GetSaveTab();
|
|
|
|
SCCOL nEndCol;
|
|
|
|
SCROW nEndRow;
|
2000-09-18 16:07:07 +00:00
|
|
|
aDocument.GetCellArea( nTab, nEndCol, nEndRow );
|
|
|
|
|
|
|
|
ScProgress aProgress( this, ScGlobal::GetRscString( STR_SAVE_DOC ), nEndRow );
|
|
|
|
|
|
|
|
String aString;
|
|
|
|
|
|
|
|
ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell, SfxViewShell::Current());
|
|
|
|
const ScViewOptions& rOpt = (pViewSh)
|
|
|
|
? pViewSh->GetViewData()->GetOptions()
|
|
|
|
: aDocument.GetViewOptions();
|
|
|
|
BOOL bShowFormulas = rOpt.GetOption( VOPT_FORMULAS );
|
|
|
|
BOOL bTabProtect = aDocument.IsTabProtected( nTab );
|
|
|
|
|
2004-06-04 10:23:23 +00:00
|
|
|
SCCOL nCol;
|
|
|
|
SCROW nRow;
|
|
|
|
SCCOL nNextCol = nStartCol;
|
|
|
|
SCROW nNextRow = nStartRow;
|
|
|
|
SCCOL nEmptyCol;
|
|
|
|
SCROW nEmptyRow;
|
2000-09-18 16:07:07 +00:00
|
|
|
SvNumberFormatter& rFormatter = *aDocument.GetFormatTable();
|
|
|
|
|
|
|
|
ScHorizontalCellIterator aIter( &aDocument, nTab, nStartCol, nStartRow,
|
|
|
|
nEndCol, nEndRow );
|
|
|
|
ScBaseCell* pCell;
|
2007-02-27 12:06:59 +00:00
|
|
|
while ( ( pCell = aIter.GetNext( nCol, nRow ) ) != NULL )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-12-22 00:29:17 +00:00
|
|
|
BOOL bProgress = FALSE; // only upon line change
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( nNextRow < nRow )
|
2000-12-22 00:29:17 +00:00
|
|
|
{ // empty rows or/and empty columns up to end of row
|
2000-09-18 16:07:07 +00:00
|
|
|
bProgress = TRUE;
|
2002-07-17 16:28:09 +00:00
|
|
|
for ( nEmptyCol = nNextCol; nEmptyCol < nEndCol; nEmptyCol++ )
|
|
|
|
{ // remaining columns of last row
|
|
|
|
if ( bFixedWidth )
|
|
|
|
lcl_ScDocShell_WriteEmptyFixedWidthString( rStream,
|
|
|
|
aDocument, nTab, nEmptyCol );
|
|
|
|
else if ( cDelim != 0 )
|
2000-12-22 00:29:17 +00:00
|
|
|
rStream.WriteUniOrByteChar( cDelim );
|
2002-07-17 16:28:09 +00:00
|
|
|
}
|
2000-12-22 00:29:17 +00:00
|
|
|
endlub( rStream );
|
2000-09-18 16:07:07 +00:00
|
|
|
nNextRow++;
|
|
|
|
for ( nEmptyRow = nNextRow; nEmptyRow < nRow; nEmptyRow++ )
|
2000-12-22 00:29:17 +00:00
|
|
|
{ // completely empty rows
|
2002-07-17 16:28:09 +00:00
|
|
|
for ( nEmptyCol = nStartCol; nEmptyCol < nEndCol; nEmptyCol++ )
|
|
|
|
{
|
|
|
|
if ( bFixedWidth )
|
|
|
|
lcl_ScDocShell_WriteEmptyFixedWidthString( rStream,
|
|
|
|
aDocument, nTab, nEmptyCol );
|
|
|
|
else if ( cDelim != 0 )
|
2000-12-22 00:29:17 +00:00
|
|
|
rStream.WriteUniOrByteChar( cDelim );
|
2002-07-17 16:28:09 +00:00
|
|
|
}
|
2000-12-22 00:29:17 +00:00
|
|
|
endlub( rStream );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2002-07-17 16:28:09 +00:00
|
|
|
for ( nEmptyCol = nStartCol; nEmptyCol < nCol; nEmptyCol++ )
|
|
|
|
{ // empty columns at beginning of row
|
|
|
|
if ( bFixedWidth )
|
|
|
|
lcl_ScDocShell_WriteEmptyFixedWidthString( rStream,
|
|
|
|
aDocument, nTab, nEmptyCol );
|
|
|
|
else if ( cDelim != 0 )
|
2000-12-22 00:29:17 +00:00
|
|
|
rStream.WriteUniOrByteChar( cDelim );
|
2002-07-17 16:28:09 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
nNextRow = nRow;
|
|
|
|
}
|
|
|
|
else if ( nNextCol < nCol )
|
2000-12-22 00:29:17 +00:00
|
|
|
{ // empty columns in same row
|
2002-07-17 16:28:09 +00:00
|
|
|
for ( nEmptyCol = nNextCol; nEmptyCol < nCol; nEmptyCol++ )
|
|
|
|
{ // columns in between
|
|
|
|
if ( bFixedWidth )
|
|
|
|
lcl_ScDocShell_WriteEmptyFixedWidthString( rStream,
|
|
|
|
aDocument, nTab, nEmptyCol );
|
|
|
|
else if ( cDelim != 0 )
|
2000-12-22 00:29:17 +00:00
|
|
|
rStream.WriteUniOrByteChar( cDelim );
|
2002-07-17 16:28:09 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
if ( nCol == nEndCol )
|
|
|
|
{
|
|
|
|
bProgress = TRUE;
|
|
|
|
nNextCol = nStartCol;
|
|
|
|
nNextRow = nRow + 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
nNextCol = nCol + 1;
|
|
|
|
|
|
|
|
CellType eType = pCell->GetCellType();
|
|
|
|
if ( bTabProtect )
|
|
|
|
{
|
|
|
|
const ScProtectionAttr* pProtAttr =
|
|
|
|
(const ScProtectionAttr*) aDocument.GetAttr(
|
2002-07-17 16:28:09 +00:00
|
|
|
nCol, nRow, nTab, ATTR_PROTECTION );
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( pProtAttr->GetHideCell() ||
|
2002-07-17 16:28:09 +00:00
|
|
|
( eType == CELLTYPE_FORMULA && bShowFormulas &&
|
|
|
|
pProtAttr->GetHideFormula() ) )
|
2000-12-22 00:29:17 +00:00
|
|
|
eType = CELLTYPE_NONE; // hide
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
BOOL bString;
|
|
|
|
switch ( eType )
|
|
|
|
{
|
|
|
|
case CELLTYPE_NOTE:
|
|
|
|
case CELLTYPE_NONE:
|
|
|
|
aString.Erase();
|
|
|
|
bString = FALSE;
|
2002-07-17 16:28:09 +00:00
|
|
|
break;
|
2000-09-18 16:07:07 +00:00
|
|
|
case CELLTYPE_FORMULA :
|
|
|
|
{
|
2002-07-17 16:28:09 +00:00
|
|
|
USHORT nErrCode;
|
|
|
|
if ( bShowFormulas )
|
|
|
|
{
|
|
|
|
((ScFormulaCell*)pCell)->GetFormula( aString );
|
|
|
|
bString = TRUE;
|
|
|
|
}
|
2007-02-27 12:06:59 +00:00
|
|
|
else if ( ( nErrCode = ((ScFormulaCell*)pCell)->GetErrCode() ) != 0 )
|
2002-07-17 16:28:09 +00:00
|
|
|
{
|
|
|
|
aString = ScGlobal::GetErrorString( nErrCode );
|
|
|
|
bString = TRUE;
|
|
|
|
}
|
|
|
|
else if ( ((ScFormulaCell*)pCell)->IsValue() )
|
|
|
|
{
|
2005-12-14 14:09:34 +00:00
|
|
|
sal_uInt32 nFormat;
|
2002-07-17 16:28:09 +00:00
|
|
|
aDocument.GetNumberFormat( nCol, nRow, nTab, nFormat );
|
2006-03-22 11:10:46 +00:00
|
|
|
if ( bFixedWidth || bSaveAsShown )
|
2002-07-17 16:28:09 +00:00
|
|
|
{
|
|
|
|
Color* pDummy;
|
|
|
|
ScCellFormat::GetString( pCell, nFormat, aString, &pDummy, rFormatter );
|
2006-03-22 11:10:46 +00:00
|
|
|
bString = bSaveAsShown && rFormatter.IsTextFormat( nFormat);
|
2002-07-17 16:28:09 +00:00
|
|
|
}
|
|
|
|
else
|
2006-03-22 11:10:46 +00:00
|
|
|
{
|
2002-07-17 16:28:09 +00:00
|
|
|
ScCellFormat::GetInputString( pCell, nFormat, aString, rFormatter );
|
2006-03-22 11:10:46 +00:00
|
|
|
bString = FALSE;
|
|
|
|
}
|
2002-07-17 16:28:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-03-22 11:10:46 +00:00
|
|
|
if ( bSaveAsShown )
|
|
|
|
{
|
|
|
|
sal_uInt32 nFormat;
|
|
|
|
aDocument.GetNumberFormat( nCol, nRow, nTab, nFormat );
|
|
|
|
Color* pDummy;
|
|
|
|
ScCellFormat::GetString( pCell, nFormat, aString, &pDummy, rFormatter );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
((ScFormulaCell*)pCell)->GetString( aString );
|
2002-07-17 16:28:09 +00:00
|
|
|
bString = TRUE;
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2002-07-17 16:28:09 +00:00
|
|
|
break;
|
2000-09-18 16:07:07 +00:00
|
|
|
case CELLTYPE_STRING :
|
2006-03-22 11:10:46 +00:00
|
|
|
if ( bSaveAsShown )
|
|
|
|
{
|
|
|
|
sal_uInt32 nFormat;
|
|
|
|
aDocument.GetNumberFormat( nCol, nRow, nTab, nFormat );
|
|
|
|
Color* pDummy;
|
|
|
|
ScCellFormat::GetString( pCell, nFormat, aString, &pDummy, rFormatter );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
((ScStringCell*)pCell)->GetString( aString );
|
2000-09-18 16:07:07 +00:00
|
|
|
bString = TRUE;
|
2002-07-17 16:28:09 +00:00
|
|
|
break;
|
2000-09-18 16:07:07 +00:00
|
|
|
case CELLTYPE_EDIT :
|
2004-10-11 11:29:23 +00:00
|
|
|
{
|
|
|
|
const EditTextObject* pObj;
|
|
|
|
static_cast<const ScEditCell*>(pCell)->GetData( pObj);
|
|
|
|
EditEngine& rEngine = aDocument.GetEditEngine();
|
|
|
|
rEngine.SetText( *pObj);
|
|
|
|
aString = rEngine.GetText(); // including LF
|
|
|
|
bString = TRUE;
|
|
|
|
}
|
2002-07-17 16:28:09 +00:00
|
|
|
break;
|
2000-09-18 16:07:07 +00:00
|
|
|
case CELLTYPE_VALUE :
|
2002-07-17 16:28:09 +00:00
|
|
|
{
|
2005-12-14 14:09:34 +00:00
|
|
|
sal_uInt32 nFormat;
|
2002-07-17 16:28:09 +00:00
|
|
|
aDocument.GetNumberFormat( nCol, nRow, nTab, nFormat );
|
2006-03-22 11:10:46 +00:00
|
|
|
if ( bFixedWidth || bSaveAsShown )
|
2002-07-17 16:28:09 +00:00
|
|
|
{
|
|
|
|
Color* pDummy;
|
|
|
|
ScCellFormat::GetString( pCell, nFormat, aString, &pDummy, rFormatter );
|
2006-03-22 11:10:46 +00:00
|
|
|
bString = bSaveAsShown && rFormatter.IsTextFormat( nFormat);
|
2002-07-17 16:28:09 +00:00
|
|
|
}
|
|
|
|
else
|
2006-03-22 11:10:46 +00:00
|
|
|
{
|
2002-07-17 16:28:09 +00:00
|
|
|
ScCellFormat::GetInputString( pCell, nFormat, aString, rFormatter );
|
2006-03-22 11:10:46 +00:00
|
|
|
bString = FALSE;
|
|
|
|
}
|
2002-07-17 16:28:09 +00:00
|
|
|
}
|
|
|
|
break;
|
2000-09-18 16:07:07 +00:00
|
|
|
default:
|
|
|
|
DBG_ERROR( "ScDocShell::AsciiSave: unknown CellType" );
|
|
|
|
aString.Erase();
|
|
|
|
bString = FALSE;
|
|
|
|
}
|
|
|
|
|
2002-07-17 16:28:09 +00:00
|
|
|
if ( bFixedWidth )
|
|
|
|
{
|
|
|
|
SvxCellHorJustify eHorJust = (SvxCellHorJustify)
|
|
|
|
((const SvxHorJustifyItem*) aDocument.GetAttr( nCol, nRow,
|
|
|
|
nTab, ATTR_HOR_JUSTIFY ))->GetValue();
|
|
|
|
lcl_ScDocShell_GetFixedWidthString( aString, aDocument, nTab, nCol,
|
|
|
|
!bString, eHorJust );
|
2002-11-25 17:12:53 +00:00
|
|
|
rStream.WriteUnicodeOrByteText( aString );
|
2002-07-17 16:28:09 +00:00
|
|
|
}
|
2004-10-11 11:29:23 +00:00
|
|
|
else
|
2002-11-25 17:12:53 +00:00
|
|
|
{
|
2006-03-22 11:10:46 +00:00
|
|
|
if (!bString && cStrDelim != 0 && aString.Len() > 0)
|
|
|
|
{
|
|
|
|
sal_Unicode c = aString.GetChar(0);
|
|
|
|
bString = (c == cStrDelim || c == ' ' ||
|
|
|
|
aString.GetChar( aString.Len()-1) == ' ' ||
|
|
|
|
aString.Search( cStrDelim) != STRING_NOTFOUND);
|
|
|
|
if (!bString && cDelim != 0)
|
|
|
|
bString = (aString.Search( cDelim) != STRING_NOTFOUND);
|
|
|
|
}
|
2004-10-11 11:29:23 +00:00
|
|
|
if ( bString )
|
2002-11-25 17:12:53 +00:00
|
|
|
{
|
2004-10-11 11:29:23 +00:00
|
|
|
if ( cStrDelim != 0 ) //@ BugId 55355
|
2002-11-25 17:12:53 +00:00
|
|
|
{
|
2004-10-11 11:29:23 +00:00
|
|
|
if ( eCharSet == RTL_TEXTENCODING_UNICODE )
|
2002-11-25 17:12:53 +00:00
|
|
|
{
|
2004-10-11 11:29:23 +00:00
|
|
|
xub_StrLen nPos = aString.Search( cStrDelim );
|
2002-11-25 17:12:53 +00:00
|
|
|
while ( nPos != STRING_NOTFOUND )
|
|
|
|
{
|
2004-10-11 11:29:23 +00:00
|
|
|
aString.Insert( cStrDelim, nPos );
|
|
|
|
nPos = aString.Search( cStrDelim, nPos+2 );
|
2002-11-25 17:12:53 +00:00
|
|
|
}
|
|
|
|
rStream.WriteUniOrByteChar( cStrDelim, eCharSet );
|
2004-10-11 11:29:23 +00:00
|
|
|
rStream.WriteUnicodeText( aString );
|
2002-11-25 17:12:53 +00:00
|
|
|
rStream.WriteUniOrByteChar( cStrDelim, eCharSet );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-10-11 11:29:23 +00:00
|
|
|
// #105549# This is nasty. The Unicode to byte encoding
|
|
|
|
// may convert typographical quotation marks to ASCII
|
|
|
|
// quotation marks, which may interfer with the delimiter,
|
|
|
|
// so we have to escape delimiters after the string has
|
|
|
|
// been encoded. Since this may happen also with UTF-8
|
|
|
|
// encoded typographical quotation marks if such was
|
|
|
|
// specified as a delimiter we have to check for the full
|
|
|
|
// encoded delimiter string, not just one character.
|
|
|
|
// Now for RTL_TEXTENCODING_ISO_2022_... and similar brain
|
|
|
|
// dead encodings where one code point (and especially a
|
|
|
|
// low ASCII value) may represent different characters, we
|
|
|
|
// have to convert forth and back and forth again. Same for
|
|
|
|
// UTF-7 since it is a context sensitive encoding too.
|
|
|
|
|
|
|
|
if ( bContextOrNotAsciiEncoding )
|
2002-11-25 17:12:53 +00:00
|
|
|
{
|
2004-10-11 11:29:23 +00:00
|
|
|
// to byte encoding
|
|
|
|
ByteString aStrEnc( aString, eCharSet );
|
|
|
|
// back to Unicode
|
|
|
|
UniString aStrDec( aStrEnc, eCharSet );
|
|
|
|
// search on re-decoded string
|
|
|
|
xub_StrLen nPos = aStrDec.Search( aStrDelimDecoded );
|
|
|
|
while ( nPos != STRING_NOTFOUND )
|
|
|
|
{
|
|
|
|
aStrDec.Insert( aStrDelimDecoded, nPos );
|
|
|
|
nPos = aStrDec.Search( aStrDelimDecoded,
|
|
|
|
nPos+1+aStrDelimDecoded.Len() );
|
|
|
|
}
|
|
|
|
// write byte re-encoded
|
|
|
|
rStream.WriteUniOrByteChar( cStrDelim, eCharSet );
|
|
|
|
rStream.WriteUnicodeOrByteText( aStrDec, eCharSet );
|
|
|
|
rStream.WriteUniOrByteChar( cStrDelim, eCharSet );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ByteString aStrEnc( aString, eCharSet );
|
|
|
|
// search on encoded string
|
|
|
|
xub_StrLen nPos = aStrEnc.Search( aStrDelimEncoded );
|
|
|
|
while ( nPos != STRING_NOTFOUND )
|
|
|
|
{
|
|
|
|
aStrEnc.Insert( aStrDelimEncoded, nPos );
|
|
|
|
nPos = aStrEnc.Search( aStrDelimEncoded,
|
|
|
|
nPos+1+aStrDelimEncoded.Len() );
|
|
|
|
}
|
|
|
|
// write byte encoded
|
|
|
|
rStream.Write( aStrDelimEncoded.GetBuffer(),
|
|
|
|
aStrDelimEncoded.Len() );
|
|
|
|
rStream.Write( aStrEnc.GetBuffer(), aStrEnc.Len() );
|
|
|
|
rStream.Write( aStrDelimEncoded.GetBuffer(),
|
|
|
|
aStrDelimEncoded.Len() );
|
2002-11-25 17:12:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-10-11 11:29:23 +00:00
|
|
|
else
|
|
|
|
rStream.WriteUnicodeOrByteText( aString );
|
2002-11-25 17:12:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
rStream.WriteUnicodeOrByteText( aString );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if( nCol < nEndCol )
|
|
|
|
{
|
|
|
|
if(cDelim!=0) //@ BugId 55355
|
2000-12-22 00:29:17 +00:00
|
|
|
rStream.WriteUniOrByteChar( cDelim );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
2000-12-22 00:29:17 +00:00
|
|
|
endlub( rStream );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( bProgress )
|
|
|
|
aProgress.SetStateOnPercent( nRow );
|
|
|
|
}
|
|
|
|
|
2000-12-22 00:29:17 +00:00
|
|
|
// write out empty if requested
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( nNextRow <= nEndRow )
|
|
|
|
{
|
2002-07-17 16:28:09 +00:00
|
|
|
for ( nEmptyCol = nNextCol; nEmptyCol < nEndCol; nEmptyCol++ )
|
|
|
|
{ // remaining empty columns of last row
|
|
|
|
if ( bFixedWidth )
|
|
|
|
lcl_ScDocShell_WriteEmptyFixedWidthString( rStream,
|
|
|
|
aDocument, nTab, nEmptyCol );
|
|
|
|
else if ( cDelim != 0 )
|
2000-12-22 00:29:17 +00:00
|
|
|
rStream.WriteUniOrByteChar( cDelim );
|
2002-07-17 16:28:09 +00:00
|
|
|
}
|
2000-12-22 00:29:17 +00:00
|
|
|
endlub( rStream );
|
2000-09-18 16:07:07 +00:00
|
|
|
nNextRow++;
|
|
|
|
}
|
|
|
|
for ( nEmptyRow = nNextRow; nEmptyRow <= nEndRow; nEmptyRow++ )
|
2000-12-22 00:29:17 +00:00
|
|
|
{ // entire empty rows
|
2002-07-17 16:28:09 +00:00
|
|
|
for ( nEmptyCol = nStartCol; nEmptyCol < nEndCol; nEmptyCol++ )
|
|
|
|
{
|
|
|
|
if ( bFixedWidth )
|
|
|
|
lcl_ScDocShell_WriteEmptyFixedWidthString( rStream,
|
|
|
|
aDocument, nTab, nEmptyCol );
|
|
|
|
else if ( cDelim != 0 )
|
2000-12-22 00:29:17 +00:00
|
|
|
rStream.WriteUniOrByteChar( cDelim );
|
2002-07-17 16:28:09 +00:00
|
|
|
}
|
2000-12-22 00:29:17 +00:00
|
|
|
endlub( rStream );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2000-12-22 00:29:17 +00:00
|
|
|
|
|
|
|
rStream.SetStreamCharSet( eOldCharSet );
|
|
|
|
rStream.SetNumberFormatInt( nOldNumberFormatInt );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOOL __EXPORT ScDocShell::ConvertTo( SfxMedium &rMed )
|
|
|
|
{
|
2001-08-01 06:32:37 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::ConvertTo" );
|
2001-07-27 18:19:54 +00:00
|
|
|
|
2001-04-21 19:31:39 +00:00
|
|
|
ScRefreshTimerProtector( aDocument.GetRefreshTimerControlAddress() );
|
|
|
|
|
2003-03-26 17:07:02 +00:00
|
|
|
// #i6500# don't call DoEnterHandler here (doesn't work with AutoSave),
|
|
|
|
// it's already in ExecuteSave (as for Save and SaveAs)
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
if (pAutoStyleList)
|
|
|
|
pAutoStyleList->ExecuteAllNow(); // Vorlagen-Timeouts jetzt ausfuehren
|
2003-04-17 12:23:04 +00:00
|
|
|
if (GetCreateMode()== SFX_CREATE_MODE_STANDARD)
|
2004-10-04 19:14:39 +00:00
|
|
|
SfxObjectShell::SetVisArea( Rectangle() ); // normal bearbeitet -> keine VisArea
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
DBG_ASSERT( rMed.GetFilter(), "Filter == 0" );
|
|
|
|
|
|
|
|
BOOL bRet = FALSE;
|
|
|
|
String aFltName = rMed.GetFilter()->GetFilterName();
|
|
|
|
|
|
|
|
/*
|
|
|
|
if (aFltName.EqualsAscii(pFilterLotus))
|
|
|
|
{
|
|
|
|
SvStream* pStream = rMed.GetOutStream();
|
|
|
|
if (pStream)
|
|
|
|
{
|
|
|
|
FltError eError = ScExportLotus123( *pStream, &aDocument, ExpWK1,
|
|
|
|
CHARSET_IBMPC_437 );
|
|
|
|
bRet = eError == eERR_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*/
|
2004-10-04 19:14:39 +00:00
|
|
|
if (aFltName.EqualsAscii(pFilterXML))
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-10-04 19:14:39 +00:00
|
|
|
//TODO/LATER: this shouldn't happen!
|
|
|
|
DBG_ERROR("XML filter in ConvertFrom?!");
|
2001-02-09 19:04:16 +00:00
|
|
|
bRet = SaveXML( &rMed, NULL );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else if (aFltName.EqualsAscii(pFilterExcel5) || aFltName.EqualsAscii(pFilterExcel95) ||
|
|
|
|
aFltName.EqualsAscii(pFilterExcel97) || aFltName.EqualsAscii(pFilterEx5Temp) ||
|
|
|
|
aFltName.EqualsAscii(pFilterEx95Temp) || aFltName.EqualsAscii(pFilterEx97Temp))
|
|
|
|
{
|
2007-02-27 12:06:59 +00:00
|
|
|
WaitObject aWait( GetActiveDialogParent() );
|
2001-05-10 16:31:17 +00:00
|
|
|
|
2005-02-21 12:50:23 +00:00
|
|
|
bool bDoSave = true;
|
|
|
|
if( ScTabViewShell* pViewShell = GetBestViewShell() )
|
2001-05-10 16:31:17 +00:00
|
|
|
{
|
2001-06-08 13:55:10 +00:00
|
|
|
ScExtDocOptions* pExtDocOpt = aDocument.GetExtDocOptions();
|
|
|
|
if( !pExtDocOpt )
|
2005-02-21 12:50:23 +00:00
|
|
|
aDocument.SetExtDocOptions( pExtDocOpt = new ScExtDocOptions );
|
2001-05-10 16:31:17 +00:00
|
|
|
pViewShell->GetViewData()->WriteExtOptions( *pExtDocOpt );
|
2004-08-11 08:07:57 +00:00
|
|
|
|
2005-03-29 12:48:40 +00:00
|
|
|
/* #115980 #If the imported document contained an encrypted password -
|
|
|
|
determine if we should save without it. */
|
|
|
|
ScExtDocSettings& rDocSett = pExtDocOpt->GetDocSettings();
|
|
|
|
if( rDocSett.mbEncrypted )
|
|
|
|
{
|
2005-02-21 12:50:23 +00:00
|
|
|
bDoSave = ScWarnPassword::WarningOnPassword( rMed );
|
2005-03-29 12:48:40 +00:00
|
|
|
// #i42858# warn only on time
|
|
|
|
rDocSett.mbEncrypted = false;
|
|
|
|
}
|
2001-05-10 16:31:17 +00:00
|
|
|
}
|
|
|
|
|
2005-02-21 12:50:23 +00:00
|
|
|
if( bDoSave )
|
2004-08-11 08:07:57 +00:00
|
|
|
{
|
2005-02-21 12:50:23 +00:00
|
|
|
bool bBiff8 = aFltName.EqualsAscii( pFilterExcel97 ) || aFltName.EqualsAscii( pFilterEx97Temp );
|
|
|
|
FltError eError = ScExportExcel5( rMed, &aDocument, bBiff8, RTL_TEXTENCODING_MS_1252 );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2005-02-21 12:50:23 +00:00
|
|
|
if( eError && !GetError() )
|
|
|
|
SetError( eError );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2005-02-21 12:50:23 +00:00
|
|
|
// don't return false for warnings
|
|
|
|
bRet = ((eError & ERRCODE_WARNING_MASK) == ERRCODE_WARNING_MASK) || (eError == eERR_OK);
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
2005-02-21 12:50:23 +00:00
|
|
|
{
|
|
|
|
// export aborted, i.e. "Save without password" warning
|
|
|
|
SetError( ERRCODE_ABORT );
|
2004-08-11 08:07:57 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else if (aFltName.EqualsAscii(pFilterAscii))
|
|
|
|
{
|
|
|
|
SvStream* pStream = rMed.GetOutStream();
|
|
|
|
if (pStream)
|
|
|
|
{
|
|
|
|
String sItStr;
|
|
|
|
SfxItemSet* pSet = rMed.GetItemSet();
|
|
|
|
const SfxPoolItem* pItem;
|
|
|
|
if ( pSet && SFX_ITEM_SET ==
|
|
|
|
pSet->GetItemState( SID_FILE_FILTEROPTIONS, TRUE, &pItem ) )
|
|
|
|
{
|
|
|
|
sItStr = ((const SfxStringItem*)pItem)->GetValue();
|
|
|
|
}
|
2002-05-29 12:36:53 +00:00
|
|
|
|
|
|
|
if ( sItStr.Len() == 0 )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-05-29 12:36:53 +00:00
|
|
|
// default for ascii export (from API without options):
|
|
|
|
// ISO8859-1/MS_1252 encoding, comma, double quotes
|
|
|
|
|
|
|
|
ScImportOptions aDefOptions( ',', '"', RTL_TEXTENCODING_MS_1252 );
|
|
|
|
sItStr = aDefOptions.BuildString();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2002-05-29 12:36:53 +00:00
|
|
|
|
2007-02-27 12:06:59 +00:00
|
|
|
WaitObject aWait( GetActiveDialogParent() );
|
2002-05-29 12:36:53 +00:00
|
|
|
ScImportOptions aOptions( sItStr );
|
2002-07-17 16:28:09 +00:00
|
|
|
AsciiSave( *pStream, aOptions );
|
2002-05-29 12:36:53 +00:00
|
|
|
bRet = TRUE;
|
|
|
|
|
|
|
|
if (aDocument.GetTableCount() > 1)
|
|
|
|
if (!rMed.GetError())
|
|
|
|
rMed.SetError(SCWARN_EXPORT_ASCII);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (aFltName.EqualsAscii(pFilterDBase))
|
|
|
|
{
|
|
|
|
String sCharSet;
|
|
|
|
SfxItemSet* pSet = rMed.GetItemSet();
|
|
|
|
const SfxPoolItem* pItem;
|
|
|
|
if ( pSet && SFX_ITEM_SET ==
|
|
|
|
pSet->GetItemState( SID_FILE_FILTEROPTIONS, TRUE, &pItem ) )
|
|
|
|
{
|
|
|
|
sCharSet = ((const SfxStringItem*)pItem)->GetValue();
|
|
|
|
}
|
2002-05-29 12:36:53 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
if (sCharSet.Len() == 0)
|
|
|
|
{
|
2002-05-29 12:36:53 +00:00
|
|
|
// default for dBase export (from API without options):
|
|
|
|
// IBM_850 encoding
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2002-05-29 12:36:53 +00:00
|
|
|
sCharSet = ScGlobal::GetCharsetString( RTL_TEXTENCODING_IBM_850 );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2002-05-29 12:36:53 +00:00
|
|
|
|
2007-02-27 12:06:59 +00:00
|
|
|
WaitObject aWait( GetActiveDialogParent() );
|
2000-09-18 16:07:07 +00:00
|
|
|
// HACK damit Sba geoffnetes TempFile ueberschreiben kann
|
2002-05-29 12:36:53 +00:00
|
|
|
rMed.CloseOutStream();
|
|
|
|
BOOL bHasMemo = FALSE;
|
2000-10-26 18:07:53 +00:00
|
|
|
|
2002-05-29 12:36:53 +00:00
|
|
|
ULONG eError = DBaseExport( rMed.GetPhysicalName(),
|
|
|
|
ScGlobal::GetCharsetValue(sCharSet), bHasMemo );
|
2000-10-26 18:07:53 +00:00
|
|
|
|
2002-05-29 12:36:53 +00:00
|
|
|
if ( eError != eERR_OK && (eError & ERRCODE_WARNING_MASK) )
|
|
|
|
{
|
|
|
|
//! if ( !rMed.GetError() )
|
|
|
|
//! rMed.SetError( eError );
|
|
|
|
eError = eERR_OK;
|
|
|
|
}
|
|
|
|
//! else if ( aDocument.GetTableCount() > 1 && !rMed.GetError() )
|
|
|
|
//! rMed.SetError( SCWARN_EXPORT_ASCII );
|
2000-11-03 18:27:07 +00:00
|
|
|
|
2002-05-29 12:36:53 +00:00
|
|
|
INetURLObject aTmpFile( rMed.GetPhysicalName(), INET_PROT_FILE );
|
|
|
|
if ( bHasMemo )
|
|
|
|
aTmpFile.setExtension( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("dbt")) );
|
|
|
|
if ( eError != eERR_OK )
|
|
|
|
{
|
|
|
|
if (!GetError())
|
|
|
|
SetError(eError);
|
|
|
|
if ( bHasMemo && IsDocument( aTmpFile ) )
|
|
|
|
KillFile( aTmpFile );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bRet = TRUE;
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( bHasMemo )
|
|
|
|
{
|
2002-05-29 12:36:53 +00:00
|
|
|
SfxStringItem* pNameItem =
|
|
|
|
(SfxStringItem*) rMed.GetItemSet()->GetItem( SID_FILE_NAME );
|
|
|
|
INetURLObject aDbtFile( pNameItem->GetValue(), INET_PROT_FILE );
|
|
|
|
aDbtFile.setExtension( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("dbt")) );
|
|
|
|
if ( IsDocument( aDbtFile ) && !KillFile( aDbtFile ) )
|
|
|
|
bRet = FALSE;
|
|
|
|
if ( bRet && !MoveFile( aTmpFile, aDbtFile ) )
|
|
|
|
bRet = FALSE;
|
|
|
|
if ( !bRet )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-05-29 12:36:53 +00:00
|
|
|
KillFile( aTmpFile );
|
|
|
|
if ( !GetError() )
|
|
|
|
SetError( SCERR_EXPORT_DATA );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (aFltName.EqualsAscii(pFilterDif))
|
|
|
|
{
|
|
|
|
SvStream* pStream = rMed.GetOutStream();
|
|
|
|
if (pStream)
|
|
|
|
{
|
|
|
|
String sItStr;
|
|
|
|
SfxItemSet* pSet = rMed.GetItemSet();
|
|
|
|
const SfxPoolItem* pItem;
|
|
|
|
if ( pSet && SFX_ITEM_SET ==
|
|
|
|
pSet->GetItemState( SID_FILE_FILTEROPTIONS, TRUE, &pItem ) )
|
|
|
|
{
|
|
|
|
sItStr = ((const SfxStringItem*)pItem)->GetValue();
|
|
|
|
}
|
2002-05-29 12:36:53 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
if (sItStr.Len() == 0)
|
|
|
|
{
|
2002-05-29 12:36:53 +00:00
|
|
|
// default for DIF export (from API without options):
|
|
|
|
// ISO8859-1/MS_1252 encoding
|
|
|
|
|
|
|
|
sItStr = ScGlobal::GetCharsetString( RTL_TEXTENCODING_MS_1252 );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2002-05-29 12:36:53 +00:00
|
|
|
|
2007-02-27 12:06:59 +00:00
|
|
|
WaitObject aWait( GetActiveDialogParent() );
|
2002-05-29 12:36:53 +00:00
|
|
|
ScExportDif( *pStream, &aDocument, ScAddress(0,0,0),
|
|
|
|
ScGlobal::GetCharsetValue(sItStr) );
|
|
|
|
bRet = TRUE;
|
|
|
|
|
|
|
|
if (aDocument.GetTableCount() > 1)
|
|
|
|
if (!rMed.GetError())
|
|
|
|
rMed.SetError(SCWARN_EXPORT_ASCII);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (aFltName.EqualsAscii(pFilterSylk))
|
|
|
|
{
|
|
|
|
SvStream* pStream = rMed.GetOutStream();
|
|
|
|
if ( pStream )
|
|
|
|
{
|
2007-02-27 12:06:59 +00:00
|
|
|
WaitObject aWait( GetActiveDialogParent() );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-06-04 10:23:23 +00:00
|
|
|
SCCOL nEndCol;
|
|
|
|
SCROW nEndRow;
|
2000-09-18 16:07:07 +00:00
|
|
|
aDocument.GetCellArea( 0, nEndCol, nEndRow );
|
|
|
|
ScRange aRange( 0,0,0, nEndCol,nEndRow,0 );
|
|
|
|
|
|
|
|
ScImportExport aImExport( &aDocument, aRange );
|
2001-05-22 12:03:32 +00:00
|
|
|
aImExport.SetFormulas( TRUE );
|
2005-01-11 12:20:20 +00:00
|
|
|
bRet = aImExport.ExportStream( *pStream, rMed.GetBaseURL( true ), SOT_FORMATSTR_ID_SYLK );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (aFltName.EqualsAscii(pFilterHtml))
|
|
|
|
{
|
|
|
|
SvStream* pStream = rMed.GetOutStream();
|
|
|
|
if ( pStream )
|
|
|
|
{
|
2007-02-27 12:06:59 +00:00
|
|
|
WaitObject aWait( GetActiveDialogParent() );
|
2000-09-18 16:07:07 +00:00
|
|
|
ScImportExport aImExport( &aDocument );
|
|
|
|
aImExport.SetStreamPath( rMed.GetName() );
|
2005-01-11 12:20:20 +00:00
|
|
|
bRet = aImExport.ExportStream( *pStream, rMed.GetBaseURL( true ), SOT_FORMATSTR_ID_HTML );
|
2001-07-20 17:37:51 +00:00
|
|
|
if ( bRet && aImExport.GetNonConvertibleChars().Len() )
|
|
|
|
SetError( *new StringErrorInfo(
|
|
|
|
SCWARN_EXPORT_NONCONVERTIBLE_CHARS,
|
|
|
|
aImExport.GetNonConvertibleChars(),
|
|
|
|
ERRCODE_BUTTON_OK | ERRCODE_MSG_INFO ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (GetError())
|
|
|
|
SetError(SCERR_IMPORT_NI);
|
|
|
|
}
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-04 19:14:39 +00:00
|
|
|
BOOL __EXPORT ScDocShell::SaveCompleted( const uno::Reference < embed::XStorage >& xStor )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-10-04 19:14:39 +00:00
|
|
|
return SfxObjectShell::SaveCompleted( xStor );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOOL __EXPORT ScDocShell::DoSaveCompleted( SfxMedium * pNewStor )
|
|
|
|
{
|
|
|
|
BOOL bRet = SfxObjectShell::DoSaveCompleted( pNewStor );
|
|
|
|
|
|
|
|
// SC_HINT_DOC_SAVED fuer Wechsel ReadOnly -> Read/Write
|
|
|
|
Broadcast( SfxSimpleHint( SC_HINT_DOC_SAVED ) );
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
USHORT __EXPORT ScDocShell::PrepareClose( BOOL bUI, BOOL bForBrowsing )
|
|
|
|
{
|
|
|
|
if(SC_MOD()->GetCurRefDlgId()>0)
|
|
|
|
{
|
|
|
|
SfxViewFrame* pFrame = SfxViewFrame::GetFirst( this, TYPE(SfxTopViewFrame) );
|
|
|
|
if( pFrame )
|
|
|
|
{
|
|
|
|
SfxViewShell* p = pFrame->GetViewShell();
|
|
|
|
ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell,p);
|
|
|
|
if(pViewSh!=NULL)
|
|
|
|
{
|
|
|
|
Window *pWin=pViewSh->GetWindow();
|
|
|
|
if(pWin!=NULL) pWin->GrabFocus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if ( aDocument.IsInLinkUpdate() || aDocument.IsInInterpreter() )
|
|
|
|
{
|
|
|
|
ErrorMessage(STR_CLOSE_ERROR_LINK);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
DoEnterHandler();
|
|
|
|
|
|
|
|
USHORT nRet = SfxObjectShell::PrepareClose( bUI, bForBrowsing );
|
|
|
|
if (nRet == TRUE) // TRUE = schliessen
|
|
|
|
aDocument.DisableIdle(TRUE); // nicht mehr drin rumpfuschen !!!
|
|
|
|
|
|
|
|
return nRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScDocShell::PrepareReload()
|
|
|
|
{
|
|
|
|
SfxObjectShell::PrepareReload(); // tut nichts?
|
|
|
|
|
|
|
|
// Das Disconnect von DDE-Links kann Reschedule ausloesen.
|
|
|
|
// Wenn die DDE-Links erst im Dokument-dtor geloescht werden, kann beim Reload
|
|
|
|
// aus diesem Reschedule das DDE-Link-Update fuer das neue Dokument ausgeloest
|
|
|
|
// werden. Dabei verklemmt sicht dann irgendwas.
|
|
|
|
// -> Beim Reload die DDE-Links des alten Dokuments vorher disconnecten
|
|
|
|
|
|
|
|
aDocument.DisconnectDdeLinks();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String ScDocShell::GetOwnFilterName() // static
|
|
|
|
{
|
|
|
|
return String::CreateFromAscii(pFilterSc50);
|
|
|
|
}
|
|
|
|
|
2001-05-10 13:11:39 +00:00
|
|
|
String ScDocShell::GetWebQueryFilterName() // static
|
|
|
|
{
|
|
|
|
return String::CreateFromAscii(pFilterHtmlWebQ);
|
|
|
|
}
|
|
|
|
|
2002-05-29 12:36:53 +00:00
|
|
|
String ScDocShell::GetAsciiFilterName() // static
|
|
|
|
{
|
|
|
|
return String::CreateFromAscii(pFilterAscii);
|
|
|
|
}
|
|
|
|
|
|
|
|
String ScDocShell::GetLotusFilterName() // static
|
|
|
|
{
|
|
|
|
return String::CreateFromAscii(pFilterLotus);
|
|
|
|
}
|
|
|
|
|
|
|
|
String ScDocShell::GetDBaseFilterName() // static
|
|
|
|
{
|
|
|
|
return String::CreateFromAscii(pFilterDBase);
|
|
|
|
}
|
|
|
|
|
|
|
|
String ScDocShell::GetDifFilterName() // static
|
|
|
|
{
|
|
|
|
return String::CreateFromAscii(pFilterDif);
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
BOOL ScDocShell::HasAutomaticTableName( const String& rFilter ) // static
|
|
|
|
{
|
|
|
|
// TRUE for those filters that keep the default table name
|
|
|
|
// (which is language specific)
|
|
|
|
|
|
|
|
return rFilter.EqualsAscii( pFilterAscii )
|
|
|
|
|| rFilter.EqualsAscii( pFilterLotus )
|
|
|
|
|| rFilter.EqualsAscii( pFilterExcel4 )
|
|
|
|
|| rFilter.EqualsAscii( pFilterEx4Temp )
|
|
|
|
|| rFilter.EqualsAscii( pFilterDBase )
|
|
|
|
|| rFilter.EqualsAscii( pFilterDif )
|
|
|
|
|| rFilter.EqualsAscii( pFilterSylk )
|
|
|
|
|| rFilter.EqualsAscii( pFilterHtml )
|
|
|
|
|| rFilter.EqualsAscii( pFilterRtf );
|
|
|
|
}
|
|
|
|
|
|
|
|
//==================================================================
|
|
|
|
|
|
|
|
#define __SCDOCSHELL_INIT \
|
|
|
|
aDocument ( SCDOCMODE_DOCUMENT, this ), \
|
2007-02-27 12:06:59 +00:00
|
|
|
aDdeTextFmt(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("TEXT"))), \
|
|
|
|
nPrtToScreenFactor( 1.0 ), \
|
2006-11-22 09:45:18 +00:00
|
|
|
pImpl ( new DocShell_Impl ), \
|
2007-02-27 12:06:59 +00:00
|
|
|
pUndoManager ( NULL ), \
|
2000-09-18 16:07:07 +00:00
|
|
|
bHeaderOn ( TRUE ), \
|
|
|
|
bFooterOn ( TRUE ), \
|
2007-02-27 12:06:59 +00:00
|
|
|
bNoInformLost ( TRUE ), \
|
2000-09-18 16:07:07 +00:00
|
|
|
bIsEmpty ( TRUE ), \
|
|
|
|
bIsInUndo ( FALSE ), \
|
2001-07-23 14:18:23 +00:00
|
|
|
bDocumentModifiedPending( FALSE ), \
|
2001-10-15 10:29:21 +00:00
|
|
|
nDocumentLock ( 0 ), \
|
2002-09-25 08:59:01 +00:00
|
|
|
nCanUpdate (com::sun::star::document::UpdateDocMode::ACCORDING_TO_CONFIG), \
|
2002-12-02 07:34:27 +00:00
|
|
|
bUpdateEnabled ( TRUE ), \
|
2004-07-23 09:52:08 +00:00
|
|
|
pOldAutoDBRange ( NULL ), \
|
2007-02-27 12:06:59 +00:00
|
|
|
pDocHelper ( NULL ), \
|
|
|
|
pAutoStyleList ( NULL ), \
|
|
|
|
pPaintLockData ( NULL ), \
|
|
|
|
pOldJobSetup ( NULL ), \
|
2008-02-05 14:45:03 +00:00
|
|
|
pSolverSaveData ( NULL ), \
|
2003-06-04 11:36:58 +00:00
|
|
|
pModificator ( NULL )
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
|
|
|
ScDocShell::ScDocShell( const ScDocShell& rShell )
|
2007-02-27 12:06:59 +00:00
|
|
|
: SvRefBase(),
|
|
|
|
SotObject(),
|
|
|
|
SfxObjectShell( rShell.GetCreateMode() ),
|
|
|
|
SfxListener(),
|
2000-09-18 16:07:07 +00:00
|
|
|
__SCDOCSHELL_INIT
|
|
|
|
{
|
2001-08-01 06:32:37 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::ScDocShell" );
|
2001-07-27 18:19:54 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
SetPool( &SC_MOD()->GetPool() );
|
|
|
|
|
|
|
|
bIsInplace = rShell.bIsInplace;
|
|
|
|
|
|
|
|
pDocFunc = new ScDocFunc(*this);
|
|
|
|
|
|
|
|
// SetBaseModel needs exception handling
|
|
|
|
ScModelObj::CreateAndSet( this );
|
|
|
|
|
|
|
|
StartListening(*this);
|
|
|
|
SfxStyleSheetPool* pStlPool = aDocument.GetStyleSheetPool();
|
|
|
|
if (pStlPool)
|
|
|
|
StartListening(*pStlPool);
|
|
|
|
|
|
|
|
GetPageOnFromPageStyleSet( NULL, 0, bHeaderOn, bFooterOn );
|
|
|
|
SetHelpId( HID_SCSHELL_DOCSH );
|
|
|
|
|
|
|
|
// InitItems und CalcOutputFactor werden jetzt nach bei Load/ConvertFrom/InitNew gerufen
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
2008-03-06 18:34:42 +00:00
|
|
|
ScDocShell::ScDocShell( SfxObjectCreateMode eMode, const bool _bScriptSupport )
|
2000-09-18 16:07:07 +00:00
|
|
|
: SfxObjectShell( eMode ),
|
|
|
|
__SCDOCSHELL_INIT
|
|
|
|
{
|
2001-08-01 06:32:37 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::ScDocShell" );
|
2001-07-27 18:19:54 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
SetPool( &SC_MOD()->GetPool() );
|
|
|
|
|
2003-04-17 12:23:04 +00:00
|
|
|
bIsInplace = (eMode == SFX_CREATE_MODE_EMBEDDED);
|
2000-09-18 16:07:07 +00:00
|
|
|
// wird zurueckgesetzt, wenn nicht inplace
|
|
|
|
|
|
|
|
pDocFunc = new ScDocFunc(*this);
|
|
|
|
|
2008-03-06 18:34:42 +00:00
|
|
|
if ( !_bScriptSupport )
|
|
|
|
SetHasNoBasic();
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// SetBaseModel needs exception handling
|
|
|
|
ScModelObj::CreateAndSet( this );
|
|
|
|
|
|
|
|
StartListening(*this);
|
|
|
|
SfxStyleSheetPool* pStlPool = aDocument.GetStyleSheetPool();
|
|
|
|
if (pStlPool)
|
|
|
|
StartListening(*pStlPool);
|
|
|
|
SetHelpId( HID_SCSHELL_DOCSH );
|
|
|
|
|
2001-04-23 08:44:43 +00:00
|
|
|
aDocument.GetDBCollection()->SetRefreshHandler(
|
|
|
|
LINK( this, ScDocShell, RefreshDBDataHdl ) );
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// InitItems und CalcOutputFactor werden jetzt nach bei Load/ConvertFrom/InitNew gerufen
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
|
|
|
__EXPORT ScDocShell::~ScDocShell()
|
|
|
|
{
|
|
|
|
ResetDrawObjectShell(); // #55570# falls der Drawing-Layer noch versucht, darauf zuzugreifen
|
|
|
|
|
|
|
|
SfxStyleSheetPool* pStlPool = aDocument.GetStyleSheetPool();
|
|
|
|
if (pStlPool)
|
|
|
|
EndListening(*pStlPool);
|
|
|
|
EndListening(*this);
|
|
|
|
|
|
|
|
delete pAutoStyleList;
|
|
|
|
|
|
|
|
SfxApplication *pSfxApp = SFX_APP();
|
|
|
|
if ( pSfxApp->GetDdeService() ) // DDE vor Dokument loeschen
|
|
|
|
pSfxApp->RemoveDdeTopic( this );
|
|
|
|
|
|
|
|
delete pDocFunc;
|
|
|
|
delete pUndoManager;
|
2006-11-22 09:45:18 +00:00
|
|
|
delete pImpl;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
delete pPaintLockData;
|
|
|
|
|
|
|
|
delete pOldJobSetup; // gesetzt nur bei Fehler in StartJob()
|
2001-10-15 10:29:21 +00:00
|
|
|
|
2008-02-05 14:45:03 +00:00
|
|
|
delete pSolverSaveData;
|
2004-07-23 09:52:08 +00:00
|
|
|
delete pOldAutoDBRange;
|
|
|
|
|
2003-06-04 11:36:58 +00:00
|
|
|
if (pModificator)
|
|
|
|
{
|
|
|
|
DBG_ERROR("The Modificator should not exist");
|
|
|
|
delete pModificator;
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
|
|
|
SfxUndoManager* __EXPORT ScDocShell::GetUndoManager()
|
|
|
|
{
|
|
|
|
if (!pUndoManager)
|
|
|
|
pUndoManager = new SfxUndoManager;
|
|
|
|
return pUndoManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScDocShell::SetModified( BOOL bModified )
|
|
|
|
{
|
2007-06-26 15:07:45 +00:00
|
|
|
if ( SfxObjectShell::IsEnableSetModified() )
|
|
|
|
{
|
|
|
|
SfxObjectShell::SetModified( bModified );
|
|
|
|
Broadcast( SfxSimpleHint( SFX_HINT_DOCCHANGED ) );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ScDocShell::SetDocumentModified( BOOL bIsModified /* = TRUE */ )
|
|
|
|
{
|
|
|
|
// BroadcastUno muss auch mit pPaintLockData sofort passieren
|
|
|
|
//! auch bei SetDrawModified, wenn Drawing angebunden ist
|
|
|
|
//! dann eigener Hint???
|
|
|
|
|
|
|
|
if (bIsModified)
|
|
|
|
aDocument.BroadcastUno( SfxSimpleHint( SFX_HINT_DATACHANGED ) );
|
|
|
|
|
|
|
|
if ( pPaintLockData && bIsModified )
|
|
|
|
{
|
|
|
|
pPaintLockData->SetModified(); // spaeter...
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetDrawModified( bIsModified );
|
|
|
|
|
|
|
|
if ( bIsModified )
|
|
|
|
{
|
|
|
|
if ( aDocument.IsAutoCalcShellDisabled() )
|
|
|
|
SetDocumentModifiedPending( TRUE );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetDocumentModifiedPending( FALSE );
|
2002-12-05 14:45:58 +00:00
|
|
|
aDocument.InvalidateStyleSheetUsage();
|
2000-09-18 16:07:07 +00:00
|
|
|
aDocument.InvalidateTableArea();
|
2003-03-26 17:07:02 +00:00
|
|
|
aDocument.InvalidateLastTableOpParams();
|
2000-09-18 16:07:07 +00:00
|
|
|
aDocument.Broadcast( SC_HINT_DATACHANGED, BCA_BRDCST_ALWAYS, NULL );
|
|
|
|
if ( aDocument.IsForcedFormulaPending() && aDocument.GetAutoCalc() )
|
|
|
|
aDocument.CalcFormulaTree( TRUE );
|
|
|
|
PostDataChanged();
|
|
|
|
|
2002-11-04 14:49:33 +00:00
|
|
|
// Detective AutoUpdate:
|
|
|
|
// Update if formulas were modified (DetectiveDirty) or the list contains
|
|
|
|
// "Trace Error" entries (#75362# - Trace Error can look completely different
|
|
|
|
// after changes to non-formula cells).
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2002-11-04 14:49:33 +00:00
|
|
|
ScDetOpList* pList = aDocument.GetDetOpList();
|
|
|
|
if ( pList && ( aDocument.IsDetectiveDirty() || pList->HasAddError() ) &&
|
|
|
|
pList->Count() && !IsInUndo() && SC_MOD()->GetAppOptions().GetDetectiveAuto() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-11-04 14:49:33 +00:00
|
|
|
GetDocFunc().DetectiveRefresh(TRUE); // TRUE = caused by automatic update
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2002-11-04 14:49:33 +00:00
|
|
|
aDocument.SetDetectiveDirty(FALSE); // always reset, also if not refreshed
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetDrawModified - ohne Formel-Update
|
|
|
|
// (Drawing muss auch beim normalen SetDocumentModified upgedated werden,
|
|
|
|
// z.B. bei Tabelle loeschen etc.)
|
|
|
|
|
|
|
|
void ScDocShell::SetDrawModified( BOOL bIsModified /* = TRUE */ )
|
|
|
|
{
|
|
|
|
BOOL bUpdate = ( bIsModified != IsModified() );
|
|
|
|
|
|
|
|
SetModified( bIsModified );
|
|
|
|
|
|
|
|
if (bUpdate)
|
|
|
|
{
|
2000-09-22 17:57:10 +00:00
|
|
|
SfxBindings* pBindings = GetViewBindings();
|
|
|
|
if (pBindings)
|
|
|
|
{
|
|
|
|
pBindings->Invalidate( SID_SAVEDOC );
|
|
|
|
pBindings->Invalidate( SID_DOC_MODIFIED );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (bIsModified)
|
|
|
|
{
|
|
|
|
if ( aDocument.IsChartListenerCollectionNeedsUpdate() )
|
|
|
|
{
|
|
|
|
aDocument.UpdateChartListenerCollection();
|
|
|
|
SFX_APP()->Broadcast(SfxSimpleHint( SC_HINT_DRAW_CHANGED )); // Navigator
|
|
|
|
}
|
|
|
|
SC_MOD()->AnythingChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScDocShell::SetInUndo(BOOL bSet)
|
|
|
|
{
|
|
|
|
bIsInUndo = bSet;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ScDocShell::GetDocStat( ScDocStat& rDocStat )
|
|
|
|
{
|
|
|
|
SfxPrinter* pPrinter = GetPrinter();
|
|
|
|
|
|
|
|
aDocument.GetDocStat( rDocStat );
|
|
|
|
rDocStat.nPageCount = 0;
|
|
|
|
|
|
|
|
if ( pPrinter )
|
2004-06-04 10:23:23 +00:00
|
|
|
for ( SCTAB i=0; i<rDocStat.nTableCount; i++ )
|
2007-02-27 12:06:59 +00:00
|
|
|
rDocStat.nPageCount = sal::static_int_cast<USHORT>( rDocStat.nPageCount +
|
|
|
|
(USHORT) ScPrintFunc( this, pPrinter, i ).GetTotalPages() );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SfxDocumentInfoDialog* __EXPORT ScDocShell::CreateDocumentInfoDialog(
|
|
|
|
Window *pParent, const SfxItemSet &rSet )
|
|
|
|
{
|
|
|
|
SfxDocumentInfoDialog* pDlg = new SfxDocumentInfoDialog( pParent, rSet );
|
|
|
|
ScDocShell* pDocSh = PTR_CAST(ScDocShell,SfxObjectShell::Current());
|
|
|
|
|
|
|
|
//nur mit Statistik, wenn dieses Doc auch angezeigt wird, nicht
|
|
|
|
//aus dem Doc-Manager
|
|
|
|
|
|
|
|
if( pDocSh == this )
|
2004-05-10 14:58:42 +00:00
|
|
|
{
|
|
|
|
ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
|
|
|
|
DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
|
|
|
|
::CreateTabPage ScDocStatPageCreate = pFact->GetTabPageCreatorFunc( RID_SCPAGE_STAT );
|
|
|
|
DBG_ASSERT(ScDocStatPageCreate, "Tabpage create fail!");//CHINA001
|
2000-09-18 16:07:07 +00:00
|
|
|
pDlg->AddTabPage( 42,
|
2004-05-10 14:58:42 +00:00
|
|
|
ScGlobal::GetRscString( STR_DOC_STAT ),
|
|
|
|
ScDocStatPageCreate,
|
|
|
|
NULL);
|
|
|
|
//CHINA001 pDlg->AddTabPage( 42,
|
|
|
|
//CHINA001 ScGlobal::GetRscString( STR_DOC_STAT ),
|
|
|
|
//CHINA001 ScDocStatPage::Create,
|
|
|
|
//CHINA001 NULL );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
return pDlg;
|
|
|
|
}
|
|
|
|
|
2007-02-27 12:06:59 +00:00
|
|
|
Window* ScDocShell::GetActiveDialogParent()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
|
|
|
|
if ( pViewSh )
|
|
|
|
return pViewSh->GetDialogParent();
|
|
|
|
else
|
|
|
|
return Application::GetDefDialogParent();
|
|
|
|
}
|
|
|
|
|
2008-02-05 14:45:03 +00:00
|
|
|
void ScDocShell::SetSolverSaveData( const ScOptSolverSave& rData )
|
|
|
|
{
|
|
|
|
delete pSolverSaveData;
|
|
|
|
pSolverSaveData = new ScOptSolverSave( rData );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// --- ScDocShellModificator ------------------------------------------
|
|
|
|
|
2001-04-21 19:31:39 +00:00
|
|
|
ScDocShellModificator::ScDocShellModificator( ScDocShell& rDS )
|
|
|
|
:
|
|
|
|
rDocShell( rDS ),
|
|
|
|
aProtector( rDS.GetDocument()->GetRefreshTimerControlAddress() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
ScDocument* pDoc = rDocShell.GetDocument();
|
|
|
|
bAutoCalcShellDisabled = pDoc->IsAutoCalcShellDisabled();
|
|
|
|
bIdleDisabled = pDoc->IsIdleDisabled();
|
|
|
|
pDoc->SetAutoCalcShellDisabled( TRUE );
|
|
|
|
pDoc->DisableIdle( TRUE );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ScDocShellModificator::~ScDocShellModificator()
|
|
|
|
{
|
|
|
|
ScDocument* pDoc = rDocShell.GetDocument();
|
|
|
|
pDoc->SetAutoCalcShellDisabled( bAutoCalcShellDisabled );
|
|
|
|
if ( !bAutoCalcShellDisabled && rDocShell.IsDocumentModifiedPending() )
|
2001-04-21 19:31:39 +00:00
|
|
|
rDocShell.SetDocumentModified(); // last one shuts off the lights
|
2000-09-18 16:07:07 +00:00
|
|
|
pDoc->DisableIdle( bIdleDisabled );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ScDocShellModificator::SetDocumentModified()
|
|
|
|
{
|
|
|
|
ScDocument* pDoc = rDocShell.GetDocument();
|
|
|
|
if ( !pDoc->IsImportingXML() )
|
|
|
|
{
|
|
|
|
// AutoCalcShellDisabled temporaer restaurieren
|
|
|
|
BOOL bDisabled = pDoc->IsAutoCalcShellDisabled();
|
|
|
|
pDoc->SetAutoCalcShellDisabled( bAutoCalcShellDisabled );
|
|
|
|
rDocShell.SetDocumentModified();
|
|
|
|
pDoc->SetAutoCalcShellDisabled( bDisabled );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// uno broadcast is necessary for api to work
|
|
|
|
// -> must also be done during xml import
|
|
|
|
pDoc->BroadcastUno( SfxSimpleHint( SFX_HINT_DATACHANGED ) );
|
|
|
|
}
|
|
|
|
}
|