2010-10-12 15:59:00 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-09-18 23:16:46 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 18:24:13 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2008-04-10 18:24:13 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2008-04-10 18:24:13 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2008-04-10 18:24:13 +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 23:16:46 +00:00
|
|
|
*
|
2008-04-10 18:24:13 +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 23:16:46 +00:00
|
|
|
*
|
2008-04-10 18:24:13 +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 23:16:46 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#include "scitems.hxx"
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/eeitem.hxx>
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
#include <tools/string.hxx>
|
2011-05-25 15:33:36 -04:00
|
|
|
#include <tools/urlobj.hxx>
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/editobj.hxx>
|
|
|
|
#include <editeng/editstat.hxx>
|
|
|
|
#include <editeng/frmdiritem.hxx>
|
|
|
|
#include <editeng/langitem.hxx>
|
2010-01-13 22:25:07 +01:00
|
|
|
#include <sfx2/linkmgr.hxx>
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/scripttypeitem.hxx>
|
|
|
|
#include <editeng/unolingu.hxx>
|
2009-06-15 10:46:14 +00:00
|
|
|
#include <sfx2/bindings.hxx>
|
2000-09-18 23:16:46 +00:00
|
|
|
#include <sfx2/objsh.hxx>
|
|
|
|
#include <sfx2/printer.hxx>
|
2000-09-22 17:57:10 +00:00
|
|
|
#include <sfx2/viewfrm.hxx>
|
2000-09-18 23:16:46 +00:00
|
|
|
#include <sfx2/viewsh.hxx>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/flagitem.hxx>
|
|
|
|
#include <svl/intitem.hxx>
|
|
|
|
#include <svl/zforlist.hxx>
|
|
|
|
#include <svl/zformat.hxx>
|
|
|
|
#include <unotools/misccfg.hxx>
|
2000-10-27 09:46:10 +00:00
|
|
|
#include <sfx2/app.hxx>
|
2001-03-26 18:26:30 +00:00
|
|
|
#include <unotools/transliterationwrapper.hxx>
|
2009-10-06 07:38:24 +02:00
|
|
|
#include <unotools/securityoptions.hxx>
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2006-05-04 14:01:20 +00:00
|
|
|
#include <vcl/virdev.hxx>
|
2000-09-18 23:16:46 +00:00
|
|
|
#include <vcl/msgbox.hxx>
|
|
|
|
|
2011-06-08 12:16:24 +02:00
|
|
|
#include <com/sun/star/i18n/TransliterationModulesExtra.hpp>
|
|
|
|
|
2006-05-04 14:01:20 +00:00
|
|
|
#include "inputopt.hxx"
|
2000-09-18 23:16:46 +00:00
|
|
|
#include "global.hxx"
|
|
|
|
#include "table.hxx"
|
|
|
|
#include "column.hxx"
|
|
|
|
#include "cell.hxx"
|
2001-01-31 15:44:36 +00:00
|
|
|
#include "poolhelp.hxx"
|
2000-09-18 23:16:46 +00:00
|
|
|
#include "docpool.hxx"
|
|
|
|
#include "stlpool.hxx"
|
|
|
|
#include "stlsheet.hxx"
|
|
|
|
#include "docoptio.hxx"
|
|
|
|
#include "viewopti.hxx"
|
|
|
|
#include "scextopt.hxx"
|
|
|
|
#include "rechead.hxx"
|
|
|
|
#include "ddelink.hxx"
|
2000-11-17 15:35:55 +00:00
|
|
|
#include "scmatrix.hxx"
|
2000-09-18 23:16:46 +00:00
|
|
|
#include "arealink.hxx"
|
|
|
|
#include "dociter.hxx"
|
|
|
|
#include "patattr.hxx"
|
|
|
|
#include "hints.hxx"
|
|
|
|
#include "editutil.hxx"
|
|
|
|
#include "progress.hxx"
|
|
|
|
#include "document.hxx"
|
|
|
|
#include "chartlis.hxx"
|
2007-08-03 12:07:31 +00:00
|
|
|
#include "chartlock.hxx"
|
2000-10-30 10:33:41 +00:00
|
|
|
#include "refupdat.hxx"
|
2000-09-18 23:16:46 +00:00
|
|
|
#include "validat.hxx" // fuer HasMacroCalls
|
2001-03-26 18:26:30 +00:00
|
|
|
#include "markdata.hxx"
|
2003-05-27 14:07:32 +00:00
|
|
|
#include "scmod.hxx"
|
2007-11-26 17:42:03 +00:00
|
|
|
#include "printopt.hxx"
|
2008-12-12 09:38:47 +00:00
|
|
|
#include "externalrefmgr.hxx"
|
2000-09-18 23:16:46 +00:00
|
|
|
#include "globstr.hrc"
|
|
|
|
#include "sc.hrc"
|
2008-11-26 15:19:48 +00:00
|
|
|
#include "charthelper.hxx"
|
2010-10-06 10:15:43 +01:00
|
|
|
#include "macromgr.hxx"
|
2009-06-19 19:51:20 +00:00
|
|
|
#include "dpobject.hxx"
|
2010-11-03 12:37:26 +01:00
|
|
|
#include "docuno.hxx"
|
2011-05-25 15:33:36 -04:00
|
|
|
#include "scresid.hxx"
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
#define GET_SCALEVALUE(set,id) ((const SfxUInt16Item&)(set.Get( id ))).GetValue()
|
|
|
|
|
|
|
|
// states for online spelling in the visible range (0 is set initially)
|
|
|
|
#define VSPL_START 0
|
|
|
|
#define VSPL_DONE 1
|
|
|
|
|
|
|
|
|
|
|
|
// STATIC DATA -----------------------------------------------------------
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ScDocument::ImplCreateOptions()
|
|
|
|
{
|
|
|
|
pDocOptions = new ScDocOptions();
|
|
|
|
pViewOptions = new ScViewOptions();
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ScDocument::ImplDeleteOptions()
|
|
|
|
{
|
|
|
|
delete pDocOptions;
|
|
|
|
delete pViewOptions;
|
|
|
|
delete pExtDocOptions;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2011-11-05 07:00:32 +01:00
|
|
|
SfxPrinter* ScDocument::GetPrinter(bool bCreateIfNotExist)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2006-05-04 14:01:20 +00:00
|
|
|
if ( !pPrinter && bCreateIfNotExist )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
SfxItemSet* pSet =
|
2001-01-31 15:44:36 +00:00
|
|
|
new SfxItemSet( *xPoolHelper->GetDocPool(),
|
2007-11-26 17:42:03 +00:00
|
|
|
SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
|
|
|
|
SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
|
|
|
|
SID_PRINT_SELECTEDSHEET, SID_PRINT_SELECTEDSHEET,
|
|
|
|
SID_SCPRINTOPTIONS, SID_SCPRINTOPTIONS,
|
2000-09-18 23:16:46 +00:00
|
|
|
NULL );
|
|
|
|
|
2009-10-16 00:05:16 +02:00
|
|
|
::utl::MiscCfg aMisc;
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nFlags = 0;
|
2009-10-16 00:05:16 +02:00
|
|
|
if ( aMisc.IsPaperOrientationWarning() )
|
|
|
|
nFlags |= SFX_PRINTER_CHG_ORIENTATION;
|
|
|
|
if ( aMisc.IsPaperSizeWarning() )
|
|
|
|
nFlags |= SFX_PRINTER_CHG_SIZE;
|
|
|
|
pSet->Put( SfxFlagItem( SID_PRINTER_CHANGESTODOC, nFlags ) );
|
|
|
|
pSet->Put( SfxBoolItem( SID_PRINTER_NOTFOUND_WARN, aMisc.IsNotFoundWarning() ) );
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
pPrinter = new SfxPrinter( pSet );
|
2006-05-04 14:01:20 +00:00
|
|
|
pPrinter->SetMapMode( MAP_100TH_MM );
|
2000-09-18 23:16:46 +00:00
|
|
|
UpdateDrawPrinter();
|
2003-05-27 14:07:32 +00:00
|
|
|
pPrinter->SetDigitLanguage( SC_MOD()->GetOptDigitLanguage() );
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return pPrinter;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ScDocument::SetPrinter( SfxPrinter* pNewPrinter )
|
|
|
|
{
|
2003-03-26 17:07:02 +00:00
|
|
|
if ( pNewPrinter == pPrinter )
|
|
|
|
{
|
|
|
|
// #i6706# SetPrinter is called with the same printer again if
|
|
|
|
// the JobSetup has changed. In that case just call UpdateDrawPrinter
|
|
|
|
// (SetRefDevice for drawing layer) because of changed text sizes.
|
|
|
|
UpdateDrawPrinter();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SfxPrinter* pOld = pPrinter;
|
|
|
|
pPrinter = pNewPrinter;
|
|
|
|
UpdateDrawPrinter();
|
2003-05-27 14:07:32 +00:00
|
|
|
pPrinter->SetDigitLanguage( SC_MOD()->GetOptDigitLanguage() );
|
2003-03-26 17:07:02 +00:00
|
|
|
delete pOld;
|
|
|
|
}
|
2011-03-10 16:55:21 -05:00
|
|
|
InvalidateTextWidth(NULL, NULL, false); // in both cases
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ScDocument::SetPrintOptions()
|
|
|
|
{
|
|
|
|
if ( !pPrinter ) GetPrinter(); // setzt pPrinter
|
2011-05-21 13:29:51 +02:00
|
|
|
OSL_ENSURE( pPrinter, "Error in printer creation :-/" );
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
if ( pPrinter )
|
|
|
|
{
|
2009-10-16 00:05:16 +02:00
|
|
|
::utl::MiscCfg aMisc;
|
|
|
|
SfxItemSet aOptSet( pPrinter->GetOptions() );
|
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nFlags = 0;
|
2009-10-16 00:05:16 +02:00
|
|
|
if ( aMisc.IsPaperOrientationWarning() )
|
|
|
|
nFlags |= SFX_PRINTER_CHG_ORIENTATION;
|
|
|
|
if ( aMisc.IsPaperSizeWarning() )
|
|
|
|
nFlags |= SFX_PRINTER_CHG_SIZE;
|
|
|
|
aOptSet.Put( SfxFlagItem( SID_PRINTER_CHANGESTODOC, nFlags ) );
|
|
|
|
aOptSet.Put( SfxBoolItem( SID_PRINTER_NOTFOUND_WARN, aMisc.IsNotFoundWarning() ) );
|
|
|
|
|
|
|
|
pPrinter->SetOptions( aOptSet );
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2006-05-04 14:01:20 +00:00
|
|
|
VirtualDevice* ScDocument::GetVirtualDevice_100th_mm()
|
|
|
|
{
|
|
|
|
if (!pVirtualDevice_100th_mm)
|
|
|
|
{
|
|
|
|
pVirtualDevice_100th_mm = new VirtualDevice( 1 );
|
|
|
|
pVirtualDevice_100th_mm->SetReferenceDevice(VirtualDevice::REFDEV_MODE_MSO1);
|
|
|
|
MapMode aMapMode( pVirtualDevice_100th_mm->GetMapMode() );
|
|
|
|
aMapMode.SetMapUnit( MAP_100TH_MM );
|
|
|
|
pVirtualDevice_100th_mm->SetMapMode( aMapMode );
|
|
|
|
}
|
|
|
|
return pVirtualDevice_100th_mm;
|
|
|
|
}
|
|
|
|
|
|
|
|
OutputDevice* ScDocument::GetRefDevice()
|
|
|
|
{
|
|
|
|
// Create printer like ref device, see Writer...
|
|
|
|
OutputDevice* pRefDevice = NULL;
|
|
|
|
if ( SC_MOD()->GetInputOptions().GetTextWysiwyg() )
|
|
|
|
pRefDevice = GetPrinter();
|
|
|
|
else
|
|
|
|
pRefDevice = GetVirtualDevice_100th_mm();
|
|
|
|
return pRefDevice;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
void ScDocument::ModifyStyleSheet( SfxStyleSheetBase& rStyleSheet,
|
|
|
|
const SfxItemSet& rChanges )
|
|
|
|
{
|
|
|
|
SfxItemSet& rSet = rStyleSheet.GetItemSet();
|
|
|
|
|
|
|
|
switch ( rStyleSheet.GetFamily() )
|
|
|
|
{
|
|
|
|
case SFX_STYLE_FAMILY_PAGE:
|
|
|
|
{
|
2011-01-17 13:20:22 +01:00
|
|
|
const sal_uInt16 nOldScale = GET_SCALEVALUE(rSet,ATTR_PAGE_SCALE);
|
|
|
|
const sal_uInt16 nOldScaleToPages = GET_SCALEVALUE(rSet,ATTR_PAGE_SCALETOPAGES);
|
2000-09-18 23:16:46 +00:00
|
|
|
rSet.Put( rChanges );
|
2011-01-17 13:20:22 +01:00
|
|
|
const sal_uInt16 nNewScale = GET_SCALEVALUE(rSet,ATTR_PAGE_SCALE);
|
|
|
|
const sal_uInt16 nNewScaleToPages = GET_SCALEVALUE(rSet,ATTR_PAGE_SCALETOPAGES);
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
if ( (nOldScale != nNewScale) || (nOldScaleToPages != nNewScaleToPages) )
|
|
|
|
InvalidateTextWidth( rStyleSheet.GetName() );
|
2008-11-26 15:19:48 +00:00
|
|
|
|
|
|
|
if( SvtLanguageOptions().IsCTLFontEnabled() )
|
|
|
|
{
|
|
|
|
const SfxPoolItem *pItem = NULL;
|
2011-11-05 07:00:32 +01:00
|
|
|
if( rChanges.GetItemState(ATTR_WRITINGDIR, true, &pItem ) == SFX_ITEM_SET )
|
2008-11-26 15:19:48 +00:00
|
|
|
ScChartHelper::DoUpdateAllCharts( this );
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SFX_STYLE_FAMILY_PARA:
|
|
|
|
{
|
2011-11-05 07:00:32 +01:00
|
|
|
bool bNumFormatChanged;
|
2000-09-18 23:16:46 +00:00
|
|
|
if ( ScGlobal::CheckWidthInvalidate( bNumFormatChanged,
|
|
|
|
rSet, rChanges ) )
|
|
|
|
InvalidateTextWidth( NULL, NULL, bNumFormatChanged );
|
2009-09-07 15:38:19 +00:00
|
|
|
|
|
|
|
for (SCTAB nTab=0; nTab<=MAXTAB; ++nTab)
|
2011-06-07 20:57:16 -04:00
|
|
|
if (maTabs[nTab] && maTabs[nTab]->IsStreamValid())
|
|
|
|
maTabs[nTab]->SetStreamValid( false );
|
2009-09-07 15:38:19 +00:00
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uLong nOldFormat =
|
2000-09-18 23:16:46 +00:00
|
|
|
((const SfxUInt32Item*)&rSet.Get(
|
|
|
|
ATTR_VALUE_FORMAT ))->GetValue();
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uLong nNewFormat =
|
2000-09-18 23:16:46 +00:00
|
|
|
((const SfxUInt32Item*)&rChanges.Get(
|
|
|
|
ATTR_VALUE_FORMAT ))->GetValue();
|
|
|
|
LanguageType eNewLang, eOldLang;
|
|
|
|
eNewLang = eOldLang = LANGUAGE_DONTKNOW;
|
|
|
|
if ( nNewFormat != nOldFormat )
|
|
|
|
{
|
|
|
|
SvNumberFormatter* pFormatter = GetFormatTable();
|
|
|
|
eOldLang = pFormatter->GetEntry( nOldFormat )->GetLanguage();
|
|
|
|
eNewLang = pFormatter->GetEntry( nNewFormat )->GetLanguage();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Bedeutung der Items in rChanges:
|
|
|
|
// Item gesetzt - Aenderung uebernehmen
|
|
|
|
// Dontcare - Default setzen
|
|
|
|
// Default - keine Aenderung
|
|
|
|
// ("keine Aenderung" geht nicht mit PutExtended, darum Schleife)
|
2011-01-17 13:20:22 +01:00
|
|
|
for (sal_uInt16 nWhich = ATTR_PATTERN_START; nWhich <= ATTR_PATTERN_END; nWhich++)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
const SfxPoolItem* pItem;
|
2011-03-10 16:55:21 -05:00
|
|
|
SfxItemState eState = rChanges.GetItemState( nWhich, false, &pItem );
|
2000-09-18 23:16:46 +00:00
|
|
|
if ( eState == SFX_ITEM_SET )
|
|
|
|
rSet.Put( *pItem );
|
|
|
|
else if ( eState == SFX_ITEM_DONTCARE )
|
|
|
|
rSet.ClearItem( nWhich );
|
|
|
|
// bei Default nichts
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( eNewLang != eOldLang )
|
|
|
|
rSet.Put(
|
|
|
|
SvxLanguageItem( eNewLang, ATTR_LANGUAGE_FORMAT ) );
|
|
|
|
}
|
|
|
|
break;
|
2007-02-27 11:02:34 +00:00
|
|
|
default:
|
|
|
|
{
|
|
|
|
// added to avoid warnings
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ScDocument::CopyStdStylesFrom( ScDocument* pSrcDoc )
|
|
|
|
{
|
2011-02-27 23:59:21 +01:00
|
|
|
// number format exchange list has to be handled here, too
|
2009-09-09 07:31:32 +00:00
|
|
|
NumFmtMergeHandler aNumFmtMergeHdl(this, pSrcDoc);
|
2001-01-31 15:44:36 +00:00
|
|
|
xPoolHelper->GetStylePool()->CopyStdStylesFrom( pSrcDoc->xPoolHelper->GetStylePool() );
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2011-11-06 18:11:43 +01:00
|
|
|
void ScDocument::InvalidateTextWidth( const rtl::OUString& rStyleName )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-06-04 09:23:25 +00:00
|
|
|
const SCTAB nCount = GetTableCount();
|
2011-06-07 20:57:16 -04:00
|
|
|
for ( SCTAB i=0; i<nCount && maTabs[i]; i++ )
|
|
|
|
if ( maTabs[i]->GetPageStyle() == rStyleName )
|
2000-09-18 23:16:46 +00:00
|
|
|
InvalidateTextWidth( i );
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2004-06-04 09:23:25 +00:00
|
|
|
void ScDocument::InvalidateTextWidth( SCTAB nTab )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
ScAddress aAdrFrom( 0, 0, nTab );
|
|
|
|
ScAddress aAdrTo ( MAXCOL, MAXROW, nTab );
|
2011-03-10 16:55:21 -05:00
|
|
|
InvalidateTextWidth( &aAdrFrom, &aAdrTo, false );
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2011-11-06 18:11:43 +01:00
|
|
|
bool ScDocument::IsPageStyleInUse( const rtl::OUString& rStrPageStyle, SCTAB* pInTab )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2011-11-05 07:00:32 +01:00
|
|
|
bool bInUse = false;
|
2004-06-04 09:23:25 +00:00
|
|
|
const SCTAB nCount = GetTableCount();
|
|
|
|
SCTAB i;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2011-06-07 20:57:16 -04:00
|
|
|
for ( i = 0; !bInUse && i < nCount && maTabs[i]; i++ )
|
|
|
|
bInUse = ( maTabs[i]->GetPageStyle() == rStrPageStyle );
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
if ( pInTab )
|
|
|
|
*pInTab = i-1;
|
|
|
|
|
|
|
|
return bInUse;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2011-11-06 18:11:43 +01:00
|
|
|
bool ScDocument::RemovePageStyleInUse( const rtl::OUString& rStyle )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2011-11-05 07:00:32 +01:00
|
|
|
bool bWasInUse = false;
|
2004-06-04 09:23:25 +00:00
|
|
|
const SCTAB nCount = GetTableCount();
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2011-06-07 20:57:16 -04:00
|
|
|
for ( SCTAB i=0; i<nCount && maTabs[i]; i++ )
|
|
|
|
if ( maTabs[i]->GetPageStyle() == rStyle )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2011-11-05 07:00:32 +01:00
|
|
|
bWasInUse = true;
|
2011-06-07 20:57:16 -04:00
|
|
|
maTabs[i]->SetPageStyle( ScGlobal::GetRscString(STR_STYLENAME_STANDARD) );
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return bWasInUse;
|
|
|
|
}
|
|
|
|
|
2011-11-06 18:11:43 +01:00
|
|
|
bool ScDocument::RenamePageStyleInUse( const rtl::OUString& rOld, const rtl::OUString& rNew )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2011-11-05 07:00:32 +01:00
|
|
|
bool bWasInUse = false;
|
2004-06-04 09:23:25 +00:00
|
|
|
const SCTAB nCount = GetTableCount();
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2011-06-07 20:57:16 -04:00
|
|
|
for ( SCTAB i=0; i<nCount && maTabs[i]; i++ )
|
|
|
|
if ( maTabs[i]->GetPageStyle() == rOld )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2011-11-05 07:00:32 +01:00
|
|
|
bWasInUse = true;
|
2011-06-07 20:57:16 -04:00
|
|
|
maTabs[i]->SetPageStyle( rNew );
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return bWasInUse;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt8 ScDocument::GetEditTextDirection(SCTAB nTab) const
|
2002-09-09 13:00:39 +00:00
|
|
|
{
|
|
|
|
EEHorizontalTextDirection eRet = EE_HTEXTDIR_DEFAULT;
|
|
|
|
|
2011-11-06 18:11:43 +01:00
|
|
|
rtl::OUString aStyleName = GetPageStyle( nTab );
|
2002-09-09 13:00:39 +00:00
|
|
|
SfxStyleSheetBase* pStyle = xPoolHelper->GetStylePool()->Find( aStyleName, SFX_STYLE_FAMILY_PAGE );
|
|
|
|
if ( pStyle )
|
|
|
|
{
|
|
|
|
SfxItemSet& rStyleSet = pStyle->GetItemSet();
|
|
|
|
SvxFrameDirection eDirection = (SvxFrameDirection)
|
|
|
|
((const SvxFrameDirectionItem&)rStyleSet.Get( ATTR_WRITINGDIR )).GetValue();
|
|
|
|
|
|
|
|
if ( eDirection == FRMDIR_HORI_LEFT_TOP )
|
|
|
|
eRet = EE_HTEXTDIR_L2R;
|
|
|
|
else if ( eDirection == FRMDIR_HORI_RIGHT_TOP )
|
|
|
|
eRet = EE_HTEXTDIR_R2L;
|
|
|
|
// else (invalid for EditEngine): keep "default"
|
|
|
|
}
|
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
return sal::static_int_cast<sal_uInt8>(eRet);
|
2002-09-09 13:00:39 +00:00
|
|
|
}
|
|
|
|
|
2010-10-06 10:15:43 +01:00
|
|
|
ScMacroManager* ScDocument::GetMacroManager()
|
|
|
|
{
|
|
|
|
if (!mpMacroMgr.get())
|
|
|
|
mpMacroMgr.reset(new ScMacroManager(this));
|
|
|
|
return mpMacroMgr.get();
|
|
|
|
}
|
|
|
|
|
2002-09-09 13:00:39 +00:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2006-03-27 08:27:34 +00:00
|
|
|
void ScDocument::InvalidateTextWidth( const ScAddress* pAdrFrom, const ScAddress* pAdrTo,
|
2011-11-05 07:00:32 +01:00
|
|
|
bool bNumFormatChanged )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2011-11-05 07:00:32 +01:00
|
|
|
bool bBroadcast = (bNumFormatChanged && GetDocOptions().IsCalcAsShown() && !IsImportingXML() && !IsClipboard());
|
2000-09-18 23:16:46 +00:00
|
|
|
if ( pAdrFrom && !pAdrTo )
|
|
|
|
{
|
2004-06-04 09:23:25 +00:00
|
|
|
const SCTAB nTab = pAdrFrom->Tab();
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2011-06-07 20:57:16 -04:00
|
|
|
if (nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] )
|
|
|
|
maTabs[nTab]->InvalidateTextWidth( pAdrFrom, NULL, bNumFormatChanged, bBroadcast );
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-06-04 09:23:25 +00:00
|
|
|
const SCTAB nTabStart = pAdrFrom ? pAdrFrom->Tab() : 0;
|
|
|
|
const SCTAB nTabEnd = pAdrTo ? pAdrTo->Tab() : MAXTAB;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2011-06-07 20:57:16 -04:00
|
|
|
for ( SCTAB nTab=nTabStart; nTab<=nTabEnd && nTab < static_cast<SCTAB>(maTabs.size()); nTab++ )
|
|
|
|
if ( maTabs[nTab] )
|
|
|
|
maTabs[nTab]->InvalidateTextWidth( pAdrFrom, pAdrTo, bNumFormatChanged, bBroadcast );
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#define CALCMAX 1000 // Berechnungen
|
2011-10-24 16:04:07 +01:00
|
|
|
#define ABORT_EVENTS (VCL_INPUT_ANY & ~VCL_INPUT_TIMER & ~VCL_INPUT_OTHER)
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2011-11-05 07:00:32 +01:00
|
|
|
bool ScDocument::IdleCalcTextWidth() // true = demnaechst wieder versuchen
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2007-07-03 14:47:40 +00:00
|
|
|
// #i75610# if a printer hasn't been set or created yet, don't create one for this
|
2011-03-10 16:55:21 -05:00
|
|
|
if ( bIdleDisabled || IsInLinkUpdate() || GetPrinter(false) == NULL )
|
|
|
|
return false;
|
2011-11-05 07:00:32 +01:00
|
|
|
bIdleDisabled = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
const sal_uLong nStart = Time::GetSystemTicks();
|
2000-09-18 23:16:46 +00:00
|
|
|
OutputDevice* pDev = NULL;
|
|
|
|
MapMode aOldMap;
|
|
|
|
ScStyleSheet* pStyle = NULL;
|
|
|
|
ScColumnIterator* pColIter = NULL;
|
|
|
|
ScTable* pTable = NULL;
|
|
|
|
ScColumn* pColumn = NULL;
|
|
|
|
ScBaseCell* pCell = NULL;
|
2004-06-04 09:23:25 +00:00
|
|
|
SCTAB nTab = aCurTextWidthCalcPos.Tab();
|
|
|
|
SCROW nRow = aCurTextWidthCalcPos.Row();
|
|
|
|
SCsCOL nCol = aCurTextWidthCalcPos.Col();
|
2011-11-05 07:00:32 +01:00
|
|
|
bool bNeedMore= false;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2004-06-04 09:23:25 +00:00
|
|
|
if ( !ValidRow(nRow) )
|
2000-09-18 23:16:46 +00:00
|
|
|
nRow = 0, nCol--;
|
|
|
|
if ( nCol < 0 )
|
|
|
|
nCol = MAXCOL, nTab++;
|
2011-06-07 20:57:16 -04:00
|
|
|
if ( !ValidTab(nTab) || nTab >= static_cast<SCTAB>(maTabs.size()) || !maTabs[nTab] )
|
2000-09-18 23:16:46 +00:00
|
|
|
nTab = 0;
|
|
|
|
|
|
|
|
// SearchMask/Family muss gemerkt werden,
|
|
|
|
// damit z.B. der Organizer nicht durcheinanderkommt, wenn zwischendurch eine
|
|
|
|
// Query-Box aufgemacht wird !!!
|
|
|
|
|
2001-01-31 15:44:36 +00:00
|
|
|
ScStyleSheetPool* pStylePool = xPoolHelper->GetStylePool();
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nOldMask = pStylePool->GetSearchMask();
|
2000-09-18 23:16:46 +00:00
|
|
|
SfxStyleFamily eOldFam = pStylePool->GetSearchFamily();
|
|
|
|
|
2011-06-07 20:57:16 -04:00
|
|
|
pTable = maTabs[nTab];
|
2000-09-18 23:16:46 +00:00
|
|
|
pStylePool->SetSearchMask( SFX_STYLE_FAMILY_PAGE, SFXSTYLEBIT_ALL );
|
|
|
|
pStyle = (ScStyleSheet*)pStylePool->Find( pTable->aPageStyle,
|
|
|
|
SFX_STYLE_FAMILY_PAGE );
|
|
|
|
|
2011-05-21 13:29:51 +02:00
|
|
|
OSL_ENSURE( pStyle, "Missing StyleSheet :-/" );
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2011-11-05 07:00:32 +01:00
|
|
|
bool bProgress = false;
|
2000-09-18 23:16:46 +00:00
|
|
|
if ( pStyle && 0 == GET_SCALEVALUE(pStyle->GetItemSet(),ATTR_PAGE_SCALETOPAGES) )
|
|
|
|
{
|
2011-03-10 16:55:21 -05:00
|
|
|
sal_uInt16 nRestart = 0;
|
|
|
|
sal_uInt16 nZoom = 0;
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nCount = 0;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
nZoom = GET_SCALEVALUE(pStyle->GetItemSet(),ATTR_PAGE_SCALE);
|
|
|
|
Fraction aZoomFract( nZoom, 100 );
|
|
|
|
pColumn = &pTable->aCol[nCol];
|
|
|
|
pColIter = new ScColumnIterator( pColumn, nRow, MAXROW );
|
|
|
|
|
|
|
|
while ( (nZoom > 0) && (nCount < CALCMAX) && (nRestart < 2) )
|
|
|
|
{
|
|
|
|
if ( pColIter->Next( nRow, pCell ) )
|
|
|
|
{
|
|
|
|
if ( TEXTWIDTH_DIRTY == pCell->GetTextWidth() )
|
|
|
|
{
|
2011-01-04 17:59:15 +00:00
|
|
|
double nPPTX = 0.0;
|
|
|
|
double nPPTY = 0.0;
|
2000-09-18 23:16:46 +00:00
|
|
|
if ( !pDev )
|
|
|
|
{
|
|
|
|
pDev = GetPrinter();
|
|
|
|
aOldMap = pDev->GetMapMode();
|
|
|
|
pDev->SetMapMode( MAP_PIXEL ); // wichtig fuer GetNeededSize
|
|
|
|
|
|
|
|
Point aPix1000 = pDev->LogicToPixel( Point(1000,1000), MAP_TWIP );
|
|
|
|
nPPTX = aPix1000.X() / 1000.0;
|
|
|
|
nPPTY = aPix1000.Y() / 1000.0;
|
|
|
|
}
|
|
|
|
if ( !bProgress && pCell->GetCellType() == CELLTYPE_FORMULA
|
|
|
|
&& ((ScFormulaCell*)pCell)->GetDirty() )
|
|
|
|
{
|
2011-03-10 16:55:21 -05:00
|
|
|
ScProgress::CreateInterpretProgress( this, false );
|
2011-11-05 07:00:32 +01:00
|
|
|
bProgress = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nNewWidth = (sal_uInt16)GetNeededSize( nCol, nRow, nTab,
|
2000-09-18 23:16:46 +00:00
|
|
|
pDev, nPPTX, nPPTY,
|
2011-11-05 07:00:32 +01:00
|
|
|
aZoomFract,aZoomFract, true,
|
|
|
|
true ); // bTotalSize
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
pCell->SetTextWidth( nNewWidth );
|
|
|
|
|
2011-11-05 07:00:32 +01:00
|
|
|
bNeedMore = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-05 07:00:32 +01:00
|
|
|
bool bNewTab = false;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
nRow = 0;
|
|
|
|
nCol--;
|
|
|
|
|
|
|
|
if ( nCol < 0 )
|
|
|
|
{
|
|
|
|
nCol = MAXCOL;
|
|
|
|
nTab++;
|
2011-11-05 07:00:32 +01:00
|
|
|
bNewTab = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2011-06-07 20:57:16 -04:00
|
|
|
if ( !ValidTab(nTab) || nTab >= static_cast<SCTAB>(maTabs.size()) || !maTabs[nTab] )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
nTab = 0;
|
|
|
|
nRestart++;
|
2011-11-05 07:00:32 +01:00
|
|
|
bNewTab = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( nRestart < 2 )
|
|
|
|
{
|
|
|
|
if ( bNewTab )
|
|
|
|
{
|
2011-06-07 20:57:16 -04:00
|
|
|
pTable = maTabs[nTab];
|
2000-09-18 23:16:46 +00:00
|
|
|
pStyle = (ScStyleSheet*)pStylePool->Find( pTable->aPageStyle,
|
|
|
|
SFX_STYLE_FAMILY_PAGE );
|
|
|
|
|
|
|
|
if ( pStyle )
|
|
|
|
{
|
|
|
|
SfxItemSet& rSet = pStyle->GetItemSet();
|
|
|
|
if ( GET_SCALEVALUE( rSet, ATTR_PAGE_SCALETOPAGES ) == 0 )
|
|
|
|
nZoom = GET_SCALEVALUE(rSet, ATTR_PAGE_SCALE );
|
|
|
|
else
|
|
|
|
nZoom = 0;
|
|
|
|
}
|
|
|
|
else
|
2008-01-29 14:18:08 +00:00
|
|
|
{
|
2011-03-01 19:05:02 +01:00
|
|
|
OSL_FAIL( "Missing StyleSheet :-/" );
|
2008-01-29 14:18:08 +00:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( nZoom > 0 )
|
|
|
|
{
|
|
|
|
delete pColIter;
|
|
|
|
|
|
|
|
pColumn = &pTable->aCol[nCol];
|
|
|
|
pColIter = new ScColumnIterator( pColumn, nRow, MAXROW );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
nTab++; // Tabelle nicht mit absolutem Zoom -> naechste
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nCount++;
|
|
|
|
|
|
|
|
// Idle Berechnung abbrechen, wenn Berechnungen laenger als
|
|
|
|
// 50ms dauern, oder nach 32 Berechnungen mal nachschauen, ob
|
|
|
|
// bestimmte Events anstehen, die Beachtung wuenschen:
|
|
|
|
|
|
|
|
|
2004-11-15 15:34:03 +00:00
|
|
|
if ( ( 50L < Time::GetSystemTicks() - nStart )
|
2000-09-18 23:16:46 +00:00
|
|
|
|| ( !(nCount&31) && Application::AnyInput( ABORT_EVENTS ) ) )
|
|
|
|
nCount = CALCMAX;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
nTab++; // Tabelle nicht mit absolutem Zoom -> naechste
|
|
|
|
|
|
|
|
if ( bProgress )
|
|
|
|
ScProgress::DeleteInterpretProgress();
|
|
|
|
|
|
|
|
delete pColIter;
|
|
|
|
|
|
|
|
if (pDev)
|
|
|
|
pDev->SetMapMode(aOldMap);
|
|
|
|
|
|
|
|
aCurTextWidthCalcPos.SetTab( nTab );
|
|
|
|
aCurTextWidthCalcPos.SetRow( nRow );
|
2004-06-04 09:23:25 +00:00
|
|
|
aCurTextWidthCalcPos.SetCol( (SCCOL)nCol );
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
pStylePool->SetSearchMask( eOldFam, nOldMask );
|
2011-03-10 16:55:21 -05:00
|
|
|
bIdleDisabled = false;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
return bNeedMore;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class ScSpellStatus
|
|
|
|
{
|
|
|
|
public:
|
2011-11-05 07:00:32 +01:00
|
|
|
bool bModified;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2011-03-10 16:55:21 -05:00
|
|
|
ScSpellStatus() : bModified(false) {};
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
DECL_LINK (EventHdl, EditStatus*);
|
|
|
|
};
|
|
|
|
|
|
|
|
IMPL_LINK( ScSpellStatus, EventHdl, EditStatus *, pStatus )
|
|
|
|
{
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uLong nStatus = pStatus->GetStatusWord();
|
2000-09-18 23:16:46 +00:00
|
|
|
if ( nStatus & EE_STAT_WRONGWORDCHANGED )
|
2011-11-05 07:00:32 +01:00
|
|
|
bModified = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// SPELL_MAXCELLS muss mindestens 256 sein, solange am Iterator keine
|
|
|
|
// Start-Spalte gesetzt werden kann
|
|
|
|
|
|
|
|
//! SPELL_MAXTEST fuer Timer und Idle unterschiedlich ???
|
|
|
|
|
|
|
|
// SPELL_MAXTEST now divided between visible and rest of document
|
|
|
|
|
|
|
|
#define SPELL_MAXTEST_VIS 1
|
|
|
|
#define SPELL_MAXTEST_ALL 3
|
|
|
|
#define SPELL_MAXCELLS 256
|
|
|
|
|
2011-11-05 07:00:32 +01:00
|
|
|
bool ScDocument::OnlineSpellInRange( const ScRange& rSpellRange, ScAddress& rSpellPos,
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nMaxTest )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
ScEditEngineDefaulter* pEngine = NULL; //! am Dokument speichern
|
|
|
|
SfxItemSet* pDefaults = NULL;
|
|
|
|
ScSpellStatus aStatus;
|
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nCellCount = 0; // Zellen insgesamt
|
|
|
|
sal_uInt16 nTestCount = 0; // Aufrufe Spelling
|
2011-11-05 07:00:32 +01:00
|
|
|
bool bChanged = false; // Aenderungen?
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2004-06-04 09:23:25 +00:00
|
|
|
SCCOL nCol = rSpellRange.aStart.Col(); // iterator always starts on the left edge
|
|
|
|
SCROW nRow = rSpellPos.Row();
|
|
|
|
SCTAB nTab = rSpellPos.Tab();
|
2011-06-07 20:57:16 -04:00
|
|
|
if ( nTab >= static_cast<SCTAB>(maTabs.size()) || !maTabs[nTab] ) // sheet deleted?
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
nTab = rSpellRange.aStart.Tab();
|
|
|
|
nRow = rSpellRange.aStart.Row();
|
2011-06-07 20:57:16 -04:00
|
|
|
if ( nTab >= static_cast<SCTAB>(maTabs.size()) || !maTabs[nTab] )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
// may happen for visible range
|
2011-03-10 16:55:21 -05:00
|
|
|
return false;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
ScHorizontalCellIterator aIter( this, nTab,
|
|
|
|
rSpellRange.aStart.Col(), nRow,
|
|
|
|
rSpellRange.aEnd.Col(), rSpellRange.aEnd.Row() );
|
|
|
|
ScBaseCell* pCell = aIter.GetNext( nCol, nRow );
|
|
|
|
// skip everything left of rSpellPos:
|
|
|
|
while ( pCell && nRow == rSpellPos.Row() && nCol < rSpellPos.Col() )
|
|
|
|
pCell = aIter.GetNext( nCol, nRow );
|
2009-06-19 19:51:20 +00:00
|
|
|
|
|
|
|
for (; pCell; pCell = aIter.GetNext(nCol, nRow))
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2009-06-19 19:51:20 +00:00
|
|
|
if (pDPCollection && pDPCollection->HasDPTable(nCol, nRow, nTab))
|
|
|
|
// Don't spell check within datapilot table.
|
|
|
|
continue;
|
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
CellType eType = pCell->GetCellType();
|
|
|
|
if ( eType == CELLTYPE_STRING || eType == CELLTYPE_EDIT )
|
|
|
|
{
|
|
|
|
if (!pEngine)
|
|
|
|
{
|
2011-02-27 23:59:21 +01:00
|
|
|
// ScTabEditEngine is needed
|
2000-09-18 23:16:46 +00:00
|
|
|
// because MapMode must be set for some old documents
|
|
|
|
pEngine = new ScTabEditEngine( this );
|
|
|
|
pEngine->SetControlWord( pEngine->GetControlWord() |
|
|
|
|
( EE_CNTRL_ONLINESPELLING | EE_CNTRL_ALLOWBIGOBJS ) );
|
|
|
|
pEngine->SetStatusEventHdl( LINK( &aStatus, ScSpellStatus, EventHdl ) );
|
|
|
|
// Delimiters hier wie in inputhdl.cxx !!!
|
|
|
|
pEngine->SetWordDelimiters(
|
|
|
|
ScEditUtil::ModifyDelimiters( pEngine->GetWordDelimiters() ) );
|
|
|
|
pDefaults = new SfxItemSet( pEngine->GetEmptyItemSet() );
|
|
|
|
|
2001-12-05 11:47:07 +00:00
|
|
|
com::sun::star::uno::Reference<com::sun::star::linguistic2::XSpellChecker1> xXSpellChecker1( LinguMgr::GetSpellChecker() );
|
|
|
|
|
|
|
|
pEngine->SetSpeller( xXSpellChecker1 );
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const ScPatternAttr* pPattern = GetPattern( nCol, nRow, nTab );
|
|
|
|
pPattern->FillEditItemSet( pDefaults );
|
2011-03-10 16:55:21 -05:00
|
|
|
pEngine->SetDefaults( pDefaults, false ); //! noetig ?
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nCellLang = ((const SvxLanguageItem&)
|
2000-09-18 23:16:46 +00:00
|
|
|
pPattern->GetItem(ATTR_FONT_LANGUAGE)).GetValue();
|
|
|
|
if ( nCellLang == LANGUAGE_SYSTEM )
|
2001-06-25 13:17:05 +00:00
|
|
|
nCellLang = Application::GetSettings().GetLanguage(); // never use SYSTEM for spelling
|
2000-09-18 23:16:46 +00:00
|
|
|
pEngine->SetDefaultLanguage( nCellLang );
|
|
|
|
|
|
|
|
if ( eType == CELLTYPE_STRING )
|
|
|
|
{
|
2012-02-27 09:45:35 +00:00
|
|
|
rtl::OUString aText = static_cast<ScStringCell*>(pCell)->GetString();
|
2000-09-18 23:16:46 +00:00
|
|
|
pEngine->SetText( aText );
|
|
|
|
}
|
|
|
|
else
|
2011-11-06 18:11:43 +01:00
|
|
|
pEngine->SetText( *(static_cast<ScEditCell*>(pCell)->GetData() ) );
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2011-03-10 16:55:21 -05:00
|
|
|
aStatus.bModified = false;
|
2000-09-18 23:16:46 +00:00
|
|
|
pEngine->CompleteOnlineSpelling();
|
|
|
|
if ( aStatus.bModified ) // Fehler dazu oder weggekommen?
|
|
|
|
{
|
2011-11-05 07:00:32 +01:00
|
|
|
bool bNeedEdit = true; // Test auf einfachen Text
|
2000-09-18 23:16:46 +00:00
|
|
|
if ( !pEngine->HasOnlineSpellErrors() )
|
|
|
|
{
|
|
|
|
ScEditAttrTester aTester( pEngine );
|
|
|
|
bNeedEdit = aTester.NeedsObject();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bNeedEdit )
|
|
|
|
{
|
|
|
|
EditTextObject* pNewData = pEngine->CreateTextObject();
|
|
|
|
if ( eType == CELLTYPE_EDIT )
|
|
|
|
((ScEditCell*)pCell)->SetData( pNewData,
|
|
|
|
pEngine->GetEditTextObjectPool() );
|
|
|
|
else
|
|
|
|
PutCell( nCol, nRow, nTab, new ScEditCell( pNewData,
|
|
|
|
this, pEngine->GetEditTextObjectPool() ) );
|
|
|
|
delete pNewData;
|
|
|
|
}
|
|
|
|
else // einfacher String
|
|
|
|
PutCell( nCol, nRow, nTab, new ScStringCell( pEngine->GetText() ) );
|
|
|
|
|
|
|
|
// Paint
|
|
|
|
if (pShell)
|
|
|
|
{
|
2011-02-27 23:59:21 +01:00
|
|
|
// Seitenvorschau ist davon nicht betroffen
|
2000-09-18 23:16:46 +00:00
|
|
|
// (sollte jedenfalls nicht)
|
|
|
|
ScPaintHint aHint( ScRange( nCol, nRow, nTab ), PAINT_GRID );
|
2011-03-10 16:55:21 -05:00
|
|
|
aHint.SetPrintFlag( false );
|
2000-09-18 23:16:46 +00:00
|
|
|
pShell->Broadcast( aHint );
|
|
|
|
}
|
|
|
|
|
2011-11-05 07:00:32 +01:00
|
|
|
bChanged = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( ++nTestCount >= nMaxTest ) // checked enough text?
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ++nCellCount >= SPELL_MAXCELLS ) // seen enough cells?
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( pCell )
|
|
|
|
{
|
|
|
|
++nCol; // continue after last cell
|
|
|
|
if ( nCol > rSpellRange.aEnd.Col() )
|
|
|
|
{
|
|
|
|
nCol = rSpellRange.aStart.Col();
|
|
|
|
++nRow;
|
|
|
|
if ( nRow > rSpellRange.aEnd.Row() )
|
|
|
|
pCell = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pCell) // end of range reached -> next sheet
|
|
|
|
{
|
|
|
|
++nTab;
|
2011-06-07 20:57:16 -04:00
|
|
|
if ( nTab > rSpellRange.aEnd.Tab() || nTab >= static_cast<SCTAB>(maTabs.size()) || !maTabs[nTab] )
|
2000-09-18 23:16:46 +00:00
|
|
|
nTab = rSpellRange.aStart.Tab();
|
|
|
|
nCol = rSpellRange.aStart.Col();
|
|
|
|
nRow = rSpellRange.aStart.Row();
|
|
|
|
|
|
|
|
nVisSpellState = VSPL_DONE; //! only if this is for the visible range
|
|
|
|
}
|
|
|
|
rSpellPos.Set( nCol, nRow, nTab );
|
|
|
|
|
|
|
|
delete pDefaults;
|
|
|
|
delete pEngine; // bevor aStatus out of scope geht
|
|
|
|
|
|
|
|
return bChanged;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-05 07:00:32 +01:00
|
|
|
bool ScDocument::ContinueOnlineSpelling()
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
if ( bIdleDisabled || !pDocOptions->IsAutoSpell() || (pShell && pShell->IsReadOnly()) )
|
2011-03-10 16:55:21 -05:00
|
|
|
return false;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2005-09-28 10:31:22 +00:00
|
|
|
// #i48433# set bInsertingFromOtherDoc flag so there are no broadcasts when PutCell is called
|
|
|
|
// (same behavior as in RemoveAutoSpellObj: just transfer the broadcaster)
|
2011-11-05 07:00:32 +01:00
|
|
|
bool bOldInserting = IsInsertingFromOtherDoc();
|
|
|
|
SetInsertingFromOtherDoc( true );
|
2005-09-28 10:31:22 +00:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
//! use one EditEngine for both calls
|
|
|
|
|
2011-02-27 23:59:21 +01:00
|
|
|
// first check visible range
|
2011-11-05 07:00:32 +01:00
|
|
|
bool bResult = OnlineSpellInRange( aVisSpellRange, aVisSpellPos, SPELL_MAXTEST_VIS );
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
// during first pass through visible range, always continue
|
|
|
|
if ( nVisSpellState == VSPL_START )
|
2011-11-05 07:00:32 +01:00
|
|
|
bResult = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
if (bResult)
|
|
|
|
{
|
|
|
|
// if errors found, continue there
|
|
|
|
OnlineSpellInRange( aVisSpellRange, aVisSpellPos, SPELL_MAXTEST_ALL );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// if nothing found there, continue with rest of document
|
|
|
|
ScRange aTotalRange( 0,0,0, MAXCOL,MAXROW,MAXTAB );
|
|
|
|
bResult = OnlineSpellInRange( aTotalRange, aOnlineSpellPos, SPELL_MAXTEST_ALL );
|
|
|
|
}
|
2005-09-28 10:31:22 +00:00
|
|
|
|
|
|
|
SetInsertingFromOtherDoc( bOldInserting );
|
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
return bResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ScDocument::SetOnlineSpellPos( const ScAddress& rPos )
|
|
|
|
{
|
|
|
|
aOnlineSpellPos = rPos;
|
|
|
|
|
|
|
|
// skip visible area for aOnlineSpellPos
|
|
|
|
if ( aVisSpellRange.In( aOnlineSpellPos ) )
|
|
|
|
aOnlineSpellPos = aVisSpellRange.aEnd;
|
|
|
|
}
|
|
|
|
|
2011-11-05 07:00:32 +01:00
|
|
|
bool ScDocument::SetVisibleSpellRange( const ScRange& rNewRange )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2011-11-05 07:00:32 +01:00
|
|
|
bool bChange = ( aVisSpellRange != rNewRange );
|
2000-09-18 23:16:46 +00:00
|
|
|
if (bChange)
|
|
|
|
{
|
|
|
|
// continue spelling through visible range when scrolling down
|
2011-11-05 07:00:32 +01:00
|
|
|
bool bContDown = ( nVisSpellState == VSPL_START && rNewRange.In( aVisSpellPos ) &&
|
2000-09-18 23:16:46 +00:00
|
|
|
rNewRange.aStart.Row() > aVisSpellRange.aStart.Row() &&
|
|
|
|
rNewRange.aStart.Col() == aVisSpellRange.aStart.Col() &&
|
|
|
|
rNewRange.aEnd.Col() == aVisSpellRange.aEnd.Col() );
|
|
|
|
|
|
|
|
aVisSpellRange = rNewRange;
|
|
|
|
|
|
|
|
if ( !bContDown )
|
|
|
|
{
|
|
|
|
aVisSpellPos = aVisSpellRange.aStart;
|
|
|
|
nVisSpellState = VSPL_START;
|
|
|
|
}
|
|
|
|
|
|
|
|
// skip visible area for aOnlineSpellPos
|
|
|
|
if ( aVisSpellRange.In( aOnlineSpellPos ) )
|
|
|
|
aOnlineSpellPos = aVisSpellRange.aEnd;
|
|
|
|
}
|
|
|
|
return bChange;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScDocument::RemoveAutoSpellObj()
|
|
|
|
{
|
|
|
|
// alle Spelling-Informationen entfernen
|
|
|
|
|
2011-06-07 20:57:16 -04:00
|
|
|
for (SCTAB nTab=0; nTab< static_cast<SCTAB>(maTabs.size()) && maTabs[nTab]; nTab++)
|
|
|
|
maTabs[nTab]->RemoveAutoSpellObj();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2010-11-03 12:37:26 +01:00
|
|
|
void ScDocument::RepaintRange( const ScRange& rRange )
|
|
|
|
{
|
|
|
|
if ( bIsVisible && pShell )
|
|
|
|
{
|
|
|
|
ScModelObj* pModel = ScModelObj::getImplementation( pShell->GetModel() );
|
|
|
|
if ( pModel )
|
|
|
|
pModel->RepaintRange( rRange ); // locked repaints are checked there
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2011-11-05 07:00:32 +01:00
|
|
|
bool ScDocument::IdleCheckLinks() // true = demnaechst wieder versuchen
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2011-11-05 07:00:32 +01:00
|
|
|
bool bAnyLeft = false;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2009-09-08 04:57:32 +00:00
|
|
|
if (GetLinkManager())
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-10-04 19:04:49 +00:00
|
|
|
const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
|
2012-06-12 15:41:27 +02:00
|
|
|
sal_uInt16 nCount = rLinks.size();
|
2011-01-17 13:20:22 +01:00
|
|
|
for (sal_uInt16 i=0; i<nCount; i++)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-10-04 19:04:49 +00:00
|
|
|
::sfx2::SvBaseLink* pBase = *rLinks[i];
|
2002-11-27 14:08:07 +00:00
|
|
|
if (pBase->ISA(ScDdeLink))
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2002-11-27 14:08:07 +00:00
|
|
|
ScDdeLink* pDdeLink = (ScDdeLink*)pBase;
|
|
|
|
if (pDdeLink->NeedsUpdate())
|
|
|
|
{
|
|
|
|
pDdeLink->TryUpdate();
|
|
|
|
if (pDdeLink->NeedsUpdate()) // war nix?
|
2011-11-05 07:00:32 +01:00
|
|
|
bAnyLeft = true;
|
2002-11-27 14:08:07 +00:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bAnyLeft;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScDocument::SaveDdeLinks(SvStream& rStream) const
|
|
|
|
{
|
|
|
|
// bei 4.0-Export alle mit Modus != DEFAULT weglassen
|
2011-11-05 07:00:32 +01:00
|
|
|
bool bExport40 = ( rStream.GetVersion() <= SOFFICE_FILEFORMAT_40 );
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2009-09-08 04:57:32 +00:00
|
|
|
const ::sfx2::SvBaseLinks& rLinks = GetLinkManager()->GetLinks();
|
2012-06-12 15:41:27 +02:00
|
|
|
sal_uInt16 nCount = rLinks.size();
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
// erstmal zaehlen...
|
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nDdeCount = 0;
|
|
|
|
sal_uInt16 i;
|
2000-09-18 23:16:46 +00:00
|
|
|
for (i=0; i<nCount; i++)
|
|
|
|
{
|
2004-10-04 19:04:49 +00:00
|
|
|
::sfx2::SvBaseLink* pBase = *rLinks[i];
|
2000-09-18 23:16:46 +00:00
|
|
|
if (pBase->ISA(ScDdeLink))
|
|
|
|
if ( !bExport40 || ((ScDdeLink*)pBase)->GetMode() == SC_DDE_DEFAULT )
|
|
|
|
++nDdeCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Header
|
|
|
|
|
|
|
|
ScMultipleWriteHeader aHdr( rStream );
|
|
|
|
rStream << nDdeCount;
|
|
|
|
|
|
|
|
// Links speichern
|
|
|
|
|
|
|
|
for (i=0; i<nCount; i++)
|
|
|
|
{
|
2004-10-04 19:04:49 +00:00
|
|
|
::sfx2::SvBaseLink* pBase = *rLinks[i];
|
2000-09-18 23:16:46 +00:00
|
|
|
if (pBase->ISA(ScDdeLink))
|
|
|
|
{
|
|
|
|
ScDdeLink* pLink = (ScDdeLink*)pBase;
|
|
|
|
if ( !bExport40 || pLink->GetMode() == SC_DDE_DEFAULT )
|
|
|
|
pLink->Store( rStream, aHdr );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScDocument::LoadDdeLinks(SvStream& rStream)
|
|
|
|
{
|
|
|
|
ScMultipleReadHeader aHdr( rStream );
|
|
|
|
|
2009-09-08 04:57:32 +00:00
|
|
|
GetLinkManager();
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nCount;
|
2000-09-18 23:16:46 +00:00
|
|
|
rStream >> nCount;
|
2011-01-17 13:20:22 +01:00
|
|
|
for (sal_uInt16 i=0; i<nCount; i++)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
ScDdeLink* pLink = new ScDdeLink( this, rStream, aHdr );
|
2001-03-08 20:00:07 +00:00
|
|
|
pLinkManager->InsertDDELink( pLink,
|
2000-09-18 23:16:46 +00:00
|
|
|
pLink->GetAppl(), pLink->GetTopic(), pLink->GetItem() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-25 15:33:36 -04:00
|
|
|
bool ScDocument::HasDdeLinks() const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2009-09-08 04:57:32 +00:00
|
|
|
if (GetLinkManager()) // Clipboard z.B. hat keinen LinkManager
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-10-04 19:04:49 +00:00
|
|
|
const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
|
2012-06-12 15:41:27 +02:00
|
|
|
sal_uInt16 nCount = rLinks.size();
|
2011-01-17 13:20:22 +01:00
|
|
|
for (sal_uInt16 i=0; i<nCount; i++)
|
2000-09-18 23:16:46 +00:00
|
|
|
if ((*rLinks[i])->ISA(ScDdeLink))
|
2011-05-25 15:33:36 -04:00
|
|
|
return true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2011-03-10 16:55:21 -05:00
|
|
|
return false;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2011-11-05 07:00:32 +01:00
|
|
|
void ScDocument::SetInLinkUpdate(bool bSet)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
// called from TableLink and AreaLink
|
|
|
|
|
2011-05-21 13:29:51 +02:00
|
|
|
OSL_ENSURE( bInLinkUpdate != bSet, "SetInLinkUpdate twice" );
|
2000-09-18 23:16:46 +00:00
|
|
|
bInLinkUpdate = bSet;
|
|
|
|
}
|
|
|
|
|
2011-11-05 07:00:32 +01:00
|
|
|
bool ScDocument::IsInLinkUpdate() const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2002-01-16 14:04:43 +00:00
|
|
|
return bInLinkUpdate || IsInDdeLinkUpdate();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2011-05-25 15:33:36 -04:00
|
|
|
void ScDocument::UpdateExternalRefLinks(Window* pWin)
|
2008-12-12 09:38:47 +00:00
|
|
|
{
|
2009-09-08 04:57:32 +00:00
|
|
|
if (!GetLinkManager())
|
2008-12-12 09:38:47 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
|
2012-06-12 15:41:27 +02:00
|
|
|
sal_uInt16 nCount = rLinks.size();
|
2008-12-12 09:38:47 +00:00
|
|
|
|
|
|
|
bool bAny = false;
|
2011-01-17 13:20:22 +01:00
|
|
|
for (sal_uInt16 i = 0; i < nCount; ++i)
|
2008-12-12 09:38:47 +00:00
|
|
|
{
|
|
|
|
::sfx2::SvBaseLink* pBase = *rLinks[i];
|
|
|
|
ScExternalRefLink* pRefLink = dynamic_cast<ScExternalRefLink*>(pBase);
|
|
|
|
if (pRefLink)
|
|
|
|
{
|
2011-05-25 15:33:36 -04:00
|
|
|
if (pRefLink->Update())
|
|
|
|
bAny = true;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Update failed. Notify the user.
|
|
|
|
|
2012-01-20 16:36:06 -05:00
|
|
|
rtl::OUString aFile;
|
2011-05-25 15:33:36 -04:00
|
|
|
pLinkManager->GetDisplayNames(pRefLink, NULL, &aFile, NULL, NULL);
|
|
|
|
// Decode encoded URL for display friendliness.
|
|
|
|
INetURLObject aUrl(aFile,INetURLObject::WAS_ENCODED);
|
|
|
|
aFile = aUrl.GetMainURL(INetURLObject::DECODE_UNAMBIGUOUS);
|
|
|
|
|
|
|
|
rtl::OUStringBuffer aBuf;
|
|
|
|
aBuf.append(String(ScResId(SCSTR_EXTDOC_NOT_LOADED)));
|
|
|
|
aBuf.appendAscii("\n\n");
|
|
|
|
aBuf.append(aFile);
|
|
|
|
ErrorBox aBox(pWin, WB_OK, aBuf.makeStringAndClear());
|
|
|
|
aBox.Execute();
|
|
|
|
}
|
2008-12-12 09:38:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (bAny)
|
|
|
|
{
|
|
|
|
TrackFormulas();
|
|
|
|
pShell->Broadcast( SfxSimpleHint(FID_DATACHANGED) );
|
2009-06-15 10:46:14 +00:00
|
|
|
|
|
|
|
// #i101960# set document modified, as in TrackTimeHdl for DDE links
|
|
|
|
if (!pShell->IsModified())
|
|
|
|
{
|
2011-11-05 07:00:32 +01:00
|
|
|
pShell->SetModified( true );
|
2009-06-15 10:46:14 +00:00
|
|
|
SfxBindings* pBindings = GetViewBindings();
|
|
|
|
if (pBindings)
|
|
|
|
{
|
|
|
|
pBindings->Invalidate( SID_SAVEDOC );
|
|
|
|
pBindings->Invalidate( SID_DOC_MODIFIED );
|
|
|
|
}
|
|
|
|
}
|
2008-12-12 09:38:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-06 21:27:35 -04:00
|
|
|
void ScDocument::UpdateDdeLinks(Window* pWin)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2009-09-08 04:57:32 +00:00
|
|
|
if (GetLinkManager())
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-10-04 19:04:49 +00:00
|
|
|
const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
|
2012-06-12 15:41:27 +02:00
|
|
|
sal_uInt16 nCount = rLinks.size();
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 i;
|
2002-11-27 14:08:07 +00:00
|
|
|
|
2011-02-27 23:59:21 +01:00
|
|
|
// falls das Updaten laenger dauert, erstmal alle Werte
|
2002-11-27 14:08:07 +00:00
|
|
|
// zuruecksetzen, damit nichts altes (falsches) stehen bleibt
|
2011-06-06 21:27:35 -04:00
|
|
|
bool bAny = false;
|
2002-11-27 14:08:07 +00:00
|
|
|
for (i=0; i<nCount; i++)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-10-04 19:04:49 +00:00
|
|
|
::sfx2::SvBaseLink* pBase = *rLinks[i];
|
2011-06-06 21:27:35 -04:00
|
|
|
ScDdeLink* pDdeLink = dynamic_cast<ScDdeLink*>(pBase);
|
|
|
|
if (pDdeLink)
|
2002-11-27 14:08:07 +00:00
|
|
|
{
|
2011-06-06 21:27:35 -04:00
|
|
|
if (pDdeLink->Update())
|
|
|
|
bAny = true;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Update failed. Notify the user.
|
|
|
|
rtl::OUString aFile = pDdeLink->GetTopic();
|
|
|
|
rtl::OUString aElem = pDdeLink->GetItem();
|
|
|
|
rtl::OUString aType = pDdeLink->GetAppl();
|
|
|
|
|
|
|
|
rtl::OUStringBuffer aBuf;
|
|
|
|
aBuf.append(String(ScResId(SCSTR_DDEDOC_NOT_LOADED)));
|
|
|
|
aBuf.appendAscii("\n\n");
|
|
|
|
aBuf.appendAscii("Source : ");
|
|
|
|
aBuf.append(aFile);
|
|
|
|
aBuf.appendAscii("\nElement : ");
|
|
|
|
aBuf.append(aElem);
|
|
|
|
aBuf.appendAscii("\nType : ");
|
|
|
|
aBuf.append(aType);
|
|
|
|
ErrorBox aBox(pWin, WB_OK, aBuf.makeStringAndClear());
|
|
|
|
aBox.Execute();
|
|
|
|
}
|
2002-11-27 14:08:07 +00:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2002-11-27 14:08:07 +00:00
|
|
|
if (bAny)
|
|
|
|
{
|
|
|
|
// Formeln berechnen und painten wie im TrackTimeHdl
|
|
|
|
TrackFormulas();
|
|
|
|
pShell->Broadcast( SfxSimpleHint( FID_DATACHANGED ) );
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2002-11-27 14:08:07 +00:00
|
|
|
// wenn FID_DATACHANGED irgendwann mal asynchron werden sollte
|
|
|
|
// (z.B. mit Invalidate am Window), muss hier ein Update erzwungen werden.
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2010-10-05 15:42:37 -04:00
|
|
|
pLinkManager->CloseCachedComps();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-06 18:11:43 +01:00
|
|
|
bool ScDocument::UpdateDdeLink( const rtl::OUString& rAppl, const rtl::OUString& rTopic, const rtl::OUString& rItem )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
// fuer refresh() per StarOne Api
|
|
|
|
// ResetValue() fuer einzelnen Link nicht noetig
|
|
|
|
//! wenn's mal alles asynchron wird, aber auch hier
|
|
|
|
|
2011-11-05 07:00:32 +01:00
|
|
|
bool bFound = false;
|
2009-09-08 04:57:32 +00:00
|
|
|
if (GetLinkManager())
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-10-04 19:04:49 +00:00
|
|
|
const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
|
2012-06-12 15:41:27 +02:00
|
|
|
sal_uInt16 nCount = rLinks.size();
|
2011-01-17 13:20:22 +01:00
|
|
|
for (sal_uInt16 i=0; i<nCount; i++)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-10-04 19:04:49 +00:00
|
|
|
::sfx2::SvBaseLink* pBase = *rLinks[i];
|
2002-11-27 14:08:07 +00:00
|
|
|
if (pBase->ISA(ScDdeLink))
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2002-11-27 14:08:07 +00:00
|
|
|
ScDdeLink* pDdeLink = (ScDdeLink*)pBase;
|
2011-11-06 18:11:43 +01:00
|
|
|
if ( rtl::OUString(pDdeLink->GetAppl()) == rAppl &&
|
|
|
|
rtl::OUString(pDdeLink->GetTopic()) == rTopic &&
|
|
|
|
rtl::OUString(pDdeLink->GetItem()) == rItem )
|
2002-11-27 14:08:07 +00:00
|
|
|
{
|
|
|
|
pDdeLink->TryUpdate();
|
2011-11-05 07:00:32 +01:00
|
|
|
bFound = true; // koennen theoretisch mehrere sein (Mode), darum weitersuchen
|
2002-11-27 14:08:07 +00:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
2010-10-05 15:42:37 -04:00
|
|
|
pLinkManager->CloseCachedComps();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
return bFound;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScDocument::DisconnectDdeLinks()
|
|
|
|
{
|
2009-09-08 04:57:32 +00:00
|
|
|
if (GetLinkManager())
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-10-04 19:04:49 +00:00
|
|
|
const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
|
2012-06-12 15:41:27 +02:00
|
|
|
sal_uInt16 nCount = rLinks.size();
|
2011-01-17 13:20:22 +01:00
|
|
|
for (sal_uInt16 i=0; i<nCount; i++)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-10-04 19:04:49 +00:00
|
|
|
::sfx2::SvBaseLink* pBase = *rLinks[i];
|
2000-09-18 23:16:46 +00:00
|
|
|
if (pBase->ISA(ScDdeLink))
|
|
|
|
pBase->Disconnect(); // bleibt im LinkManager eingetragen
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScDocument::CopyDdeLinks( ScDocument* pDestDoc ) const
|
|
|
|
{
|
|
|
|
if (bIsClip) // aus Stream erzeugen
|
|
|
|
{
|
|
|
|
if (pClipData)
|
|
|
|
{
|
|
|
|
pClipData->Seek(0);
|
|
|
|
pDestDoc->LoadDdeLinks(*pClipData);
|
|
|
|
}
|
|
|
|
}
|
2009-09-08 04:57:32 +00:00
|
|
|
else if (GetLinkManager()) // Links direkt kopieren
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-10-04 19:04:49 +00:00
|
|
|
const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
|
2012-06-12 15:41:27 +02:00
|
|
|
sal_uInt16 nCount = rLinks.size();
|
2011-01-17 13:20:22 +01:00
|
|
|
for (sal_uInt16 i=0; i<nCount; i++)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-10-04 19:04:49 +00:00
|
|
|
::sfx2::SvBaseLink* pBase = *rLinks[i];
|
2000-09-18 23:16:46 +00:00
|
|
|
if (pBase->ISA(ScDdeLink))
|
|
|
|
{
|
|
|
|
ScDdeLink* pNew = new ScDdeLink( pDestDoc, *(ScDdeLink*)pBase );
|
|
|
|
|
2001-03-08 20:00:07 +00:00
|
|
|
pDestDoc->pLinkManager->InsertDDELink( pNew,
|
2000-09-18 23:16:46 +00:00
|
|
|
pNew->GetAppl(), pNew->GetTopic(), pNew->GetItem() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 ScDocument::GetDdeLinkCount() const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nDdeCount = 0;
|
2009-09-08 04:57:32 +00:00
|
|
|
if (GetLinkManager())
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-10-04 19:04:49 +00:00
|
|
|
const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
|
2012-06-12 15:41:27 +02:00
|
|
|
sal_uInt16 nCount = rLinks.size();
|
2011-01-17 13:20:22 +01:00
|
|
|
for (sal_uInt16 i=0; i<nCount; i++)
|
2000-09-18 23:16:46 +00:00
|
|
|
if ((*rLinks[i])->ISA(ScDdeLink))
|
|
|
|
++nDdeCount;
|
|
|
|
}
|
|
|
|
return nDdeCount;
|
|
|
|
}
|
|
|
|
|
2004-03-08 10:44:18 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
/** Tries to find the specified DDE link.
|
|
|
|
@param pnDdePos (out-param) if not 0, the index of the DDE link is returned here
|
|
|
|
(does not include other links from link manager).
|
|
|
|
@return The DDE link, if it exists, otherwise 0. */
|
|
|
|
ScDdeLink* lclGetDdeLink(
|
2010-01-13 22:25:07 +01:00
|
|
|
const sfx2::LinkManager* pLinkManager,
|
2011-11-06 18:11:43 +01:00
|
|
|
const rtl::OUString& rAppl, const rtl::OUString& rTopic, const rtl::OUString& rItem, sal_uInt8 nMode,
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16* pnDdePos = NULL )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-03-08 10:44:18 +00:00
|
|
|
if( pLinkManager )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-10-04 19:04:49 +00:00
|
|
|
const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
|
2012-06-12 15:41:27 +02:00
|
|
|
sal_uInt16 nCount = rLinks.size();
|
2004-03-08 10:44:18 +00:00
|
|
|
if( pnDdePos ) *pnDdePos = 0;
|
2011-01-17 13:20:22 +01:00
|
|
|
for( sal_uInt16 nIndex = 0; nIndex < nCount; ++nIndex )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-10-04 19:04:49 +00:00
|
|
|
::sfx2::SvBaseLink* pLink = *rLinks[ nIndex ];
|
2004-03-08 10:44:18 +00:00
|
|
|
if( ScDdeLink* pDdeLink = PTR_CAST( ScDdeLink, pLink ) )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2011-11-06 18:11:43 +01:00
|
|
|
if( (rtl::OUString(pDdeLink->GetAppl()) == rAppl) &&
|
|
|
|
(rtl::OUString(pDdeLink->GetTopic()) == rTopic) &&
|
|
|
|
(rtl::OUString(pDdeLink->GetItem()) == rItem) &&
|
2004-03-08 10:44:18 +00:00
|
|
|
((nMode == SC_DDE_IGNOREMODE) || (nMode == pDdeLink->GetMode())) )
|
|
|
|
return pDdeLink;
|
|
|
|
if( pnDdePos ) ++*pnDdePos;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-03-08 10:44:18 +00:00
|
|
|
return NULL;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2004-03-08 10:44:18 +00:00
|
|
|
/** Returns a pointer to the specified DDE link.
|
|
|
|
@param nDdePos Index of the DDE link (does not include other links from link manager).
|
|
|
|
@return The DDE link, if it exists, otherwise 0. */
|
2011-01-17 13:20:22 +01:00
|
|
|
ScDdeLink* lclGetDdeLink( const sfx2::LinkManager* pLinkManager, sal_uInt16 nDdePos )
|
2000-11-20 18:07:20 +00:00
|
|
|
{
|
2004-03-08 10:44:18 +00:00
|
|
|
if( pLinkManager )
|
2000-11-20 18:07:20 +00:00
|
|
|
{
|
2004-10-04 19:04:49 +00:00
|
|
|
const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
|
2012-06-12 15:41:27 +02:00
|
|
|
sal_uInt16 nCount = rLinks.size();
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nDdeIndex = 0; // counts only the DDE links
|
|
|
|
for( sal_uInt16 nIndex = 0; nIndex < nCount; ++nIndex )
|
2000-11-20 18:07:20 +00:00
|
|
|
{
|
2004-10-04 19:04:49 +00:00
|
|
|
::sfx2::SvBaseLink* pLink = *rLinks[ nIndex ];
|
2004-03-08 10:44:18 +00:00
|
|
|
if( ScDdeLink* pDdeLink = PTR_CAST( ScDdeLink, pLink ) )
|
2000-11-20 18:07:20 +00:00
|
|
|
{
|
2004-03-08 10:44:18 +00:00
|
|
|
if( nDdeIndex == nDdePos )
|
|
|
|
return pDdeLink;
|
|
|
|
++nDdeIndex;
|
2000-11-20 18:07:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-03-08 10:44:18 +00:00
|
|
|
return NULL;
|
2000-11-20 18:07:20 +00:00
|
|
|
}
|
|
|
|
|
2004-03-08 10:44:18 +00:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2011-11-06 18:11:43 +01:00
|
|
|
bool ScDocument::FindDdeLink( const rtl::OUString& rAppl, const rtl::OUString& rTopic, const rtl::OUString& rItem, sal_uInt8 nMode, sal_uInt16& rnDdePos )
|
2000-11-17 15:35:55 +00:00
|
|
|
{
|
2009-09-08 04:57:32 +00:00
|
|
|
return lclGetDdeLink( GetLinkManager(), rAppl, rTopic, rItem, nMode, &rnDdePos ) != NULL;
|
2000-11-17 15:35:55 +00:00
|
|
|
}
|
|
|
|
|
2011-11-06 18:11:43 +01:00
|
|
|
bool ScDocument::GetDdeLinkData( sal_uInt16 nDdePos, rtl::OUString& rAppl, rtl::OUString& rTopic, rtl::OUString& rItem ) const
|
2000-11-17 15:35:55 +00:00
|
|
|
{
|
2009-09-08 04:57:32 +00:00
|
|
|
if( const ScDdeLink* pDdeLink = lclGetDdeLink( GetLinkManager(), nDdePos ) )
|
2000-11-17 15:35:55 +00:00
|
|
|
{
|
2004-03-08 10:44:18 +00:00
|
|
|
rAppl = pDdeLink->GetAppl();
|
|
|
|
rTopic = pDdeLink->GetTopic();
|
|
|
|
rItem = pDdeLink->GetItem();
|
|
|
|
return true;
|
2000-11-17 15:35:55 +00:00
|
|
|
}
|
2004-03-08 10:44:18 +00:00
|
|
|
return false;
|
2000-11-21 15:28:20 +00:00
|
|
|
}
|
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
bool ScDocument::GetDdeLinkMode( sal_uInt16 nDdePos, sal_uInt8& rnMode ) const
|
2000-11-21 15:28:20 +00:00
|
|
|
{
|
2009-09-08 04:57:32 +00:00
|
|
|
if( const ScDdeLink* pDdeLink = lclGetDdeLink( GetLinkManager(), nDdePos ) )
|
2000-11-21 15:28:20 +00:00
|
|
|
{
|
2004-03-08 10:44:18 +00:00
|
|
|
rnMode = pDdeLink->GetMode();
|
|
|
|
return true;
|
2002-11-27 14:08:07 +00:00
|
|
|
}
|
2004-03-08 10:44:18 +00:00
|
|
|
return false;
|
2000-11-21 15:28:20 +00:00
|
|
|
}
|
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
const ScMatrix* ScDocument::GetDdeLinkResultMatrix( sal_uInt16 nDdePos ) const
|
2000-11-21 15:28:20 +00:00
|
|
|
{
|
2009-09-08 04:57:32 +00:00
|
|
|
const ScDdeLink* pDdeLink = lclGetDdeLink( GetLinkManager(), nDdePos );
|
2004-03-08 10:44:18 +00:00
|
|
|
return pDdeLink ? pDdeLink->GetResult() : NULL;
|
2000-11-21 15:28:20 +00:00
|
|
|
}
|
|
|
|
|
2011-11-06 18:11:43 +01:00
|
|
|
bool ScDocument::CreateDdeLink( const rtl::OUString& rAppl, const rtl::OUString& rTopic, const rtl::OUString& rItem, sal_uInt8 nMode, ScMatrixRef pResults )
|
2000-11-21 15:28:20 +00:00
|
|
|
{
|
2004-03-08 10:44:18 +00:00
|
|
|
/* Create a DDE link without updating it (i.e. for Excel import), to prevent
|
|
|
|
unwanted connections. First try to find existing link. Set result array
|
|
|
|
on existing and new links. */
|
|
|
|
//! store DDE links additionally at document (for efficiency)?
|
2011-05-21 13:29:51 +02:00
|
|
|
OSL_ENSURE( nMode != SC_DDE_IGNOREMODE, "ScDocument::CreateDdeLink - SC_DDE_IGNOREMODE not allowed here" );
|
2009-09-08 04:57:32 +00:00
|
|
|
if( GetLinkManager() && (nMode != SC_DDE_IGNOREMODE) )
|
2000-11-21 15:28:20 +00:00
|
|
|
{
|
2004-03-08 10:44:18 +00:00
|
|
|
ScDdeLink* pDdeLink = lclGetDdeLink( pLinkManager, rAppl, rTopic, rItem, nMode );
|
|
|
|
if( !pDdeLink )
|
2000-11-21 15:28:20 +00:00
|
|
|
{
|
2004-03-08 10:44:18 +00:00
|
|
|
// create a new DDE link, but without TryUpdate
|
|
|
|
pDdeLink = new ScDdeLink( this, rAppl, rTopic, rItem, nMode );
|
|
|
|
pLinkManager->InsertDDELink( pDdeLink, rAppl, rTopic, rItem );
|
2000-11-21 15:28:20 +00:00
|
|
|
}
|
2004-03-08 10:44:18 +00:00
|
|
|
|
|
|
|
// insert link results
|
|
|
|
if( pResults )
|
|
|
|
pDdeLink->SetResult( pResults );
|
|
|
|
|
|
|
|
return true;
|
2000-11-21 15:28:20 +00:00
|
|
|
}
|
2004-03-08 10:44:18 +00:00
|
|
|
return false;
|
2000-11-21 15:28:20 +00:00
|
|
|
}
|
|
|
|
|
2011-03-10 16:55:21 -05:00
|
|
|
bool ScDocument::SetDdeLinkResultMatrix( sal_uInt16 nDdePos, ScMatrixRef pResults )
|
2000-11-21 15:28:20 +00:00
|
|
|
{
|
2009-09-08 04:57:32 +00:00
|
|
|
if( ScDdeLink* pDdeLink = lclGetDdeLink( GetLinkManager(), nDdePos ) )
|
2000-11-21 15:28:20 +00:00
|
|
|
{
|
2004-03-08 10:44:18 +00:00
|
|
|
pDdeLink->SetResult( pResults );
|
|
|
|
return true;
|
2000-11-21 15:28:20 +00:00
|
|
|
}
|
2004-03-08 10:44:18 +00:00
|
|
|
return false;
|
2000-11-17 15:35:55 +00:00
|
|
|
}
|
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2011-05-25 15:33:36 -04:00
|
|
|
bool ScDocument::HasAreaLinks() const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2009-09-08 04:57:32 +00:00
|
|
|
if (GetLinkManager()) // Clipboard z.B. hat keinen LinkManager
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-10-04 19:04:49 +00:00
|
|
|
const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
|
2012-06-12 15:41:27 +02:00
|
|
|
sal_uInt16 nCount = rLinks.size();
|
2011-01-17 13:20:22 +01:00
|
|
|
for (sal_uInt16 i=0; i<nCount; i++)
|
2000-09-18 23:16:46 +00:00
|
|
|
if ((*rLinks[i])->ISA(ScAreaLink))
|
2011-05-25 15:33:36 -04:00
|
|
|
return true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2011-03-10 16:55:21 -05:00
|
|
|
return false;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScDocument::UpdateAreaLinks()
|
|
|
|
{
|
2009-09-08 04:57:32 +00:00
|
|
|
if (GetLinkManager())
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-10-04 19:04:49 +00:00
|
|
|
const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
|
2012-06-12 15:41:27 +02:00
|
|
|
sal_uInt16 nCount = rLinks.size();
|
2011-01-17 13:20:22 +01:00
|
|
|
for (sal_uInt16 i=0; i<nCount; i++)
|
2002-11-27 14:08:07 +00:00
|
|
|
{
|
2004-10-04 19:04:49 +00:00
|
|
|
::sfx2::SvBaseLink* pBase = *rLinks[i];
|
2002-11-27 14:08:07 +00:00
|
|
|
if (pBase->ISA(ScAreaLink))
|
|
|
|
pBase->Update();
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-28 10:31:22 +00:00
|
|
|
void ScDocument::DeleteAreaLinksOnTab( SCTAB nTab )
|
|
|
|
{
|
2009-09-08 04:57:32 +00:00
|
|
|
if (GetLinkManager())
|
2005-09-28 10:31:22 +00:00
|
|
|
{
|
|
|
|
const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nPos = 0;
|
2012-06-12 15:41:27 +02:00
|
|
|
while ( nPos < rLinks.size() )
|
2005-09-28 10:31:22 +00:00
|
|
|
{
|
|
|
|
const ::sfx2::SvBaseLink* pBase = *rLinks[nPos];
|
|
|
|
if ( pBase->ISA(ScAreaLink) &&
|
|
|
|
static_cast<const ScAreaLink*>(pBase)->GetDestArea().aStart.Tab() == nTab )
|
|
|
|
pLinkManager->Remove( nPos );
|
|
|
|
else
|
|
|
|
++nPos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-10-30 10:33:41 +00:00
|
|
|
void ScDocument::UpdateRefAreaLinks( UpdateRefMode eUpdateRefMode,
|
2004-06-04 09:23:25 +00:00
|
|
|
const ScRange& rRange, SCsCOL nDx, SCsROW nDy, SCsTAB nDz )
|
2000-10-30 10:33:41 +00:00
|
|
|
{
|
2009-09-08 04:57:32 +00:00
|
|
|
if (GetLinkManager())
|
2000-10-30 10:33:41 +00:00
|
|
|
{
|
2005-09-28 10:31:22 +00:00
|
|
|
bool bAnyUpdate = false;
|
|
|
|
|
2004-10-04 19:04:49 +00:00
|
|
|
const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
|
2012-06-12 15:41:27 +02:00
|
|
|
sal_uInt16 nCount = rLinks.size();
|
2011-01-17 13:20:22 +01:00
|
|
|
for (sal_uInt16 i=0; i<nCount; i++)
|
2000-10-30 10:33:41 +00:00
|
|
|
{
|
2004-10-04 19:04:49 +00:00
|
|
|
::sfx2::SvBaseLink* pBase = *rLinks[i];
|
2002-11-27 14:08:07 +00:00
|
|
|
if (pBase->ISA(ScAreaLink))
|
|
|
|
{
|
|
|
|
ScAreaLink* pLink = (ScAreaLink*) pBase;
|
|
|
|
ScRange aOutRange = pLink->GetDestArea();
|
|
|
|
|
2004-06-04 09:23:25 +00:00
|
|
|
SCCOL nCol1 = aOutRange.aStart.Col();
|
|
|
|
SCROW nRow1 = aOutRange.aStart.Row();
|
|
|
|
SCTAB nTab1 = aOutRange.aStart.Tab();
|
|
|
|
SCCOL nCol2 = aOutRange.aEnd.Col();
|
|
|
|
SCROW nRow2 = aOutRange.aEnd.Row();
|
|
|
|
SCTAB nTab2 = aOutRange.aEnd.Tab();
|
2002-11-27 14:08:07 +00:00
|
|
|
|
|
|
|
ScRefUpdateRes eRes =
|
|
|
|
ScRefUpdate::Update( this, eUpdateRefMode,
|
|
|
|
rRange.aStart.Col(), rRange.aStart.Row(), rRange.aStart.Tab(),
|
|
|
|
rRange.aEnd.Col(), rRange.aEnd.Row(), rRange.aEnd.Tab(), nDx, nDy, nDz,
|
|
|
|
nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
|
|
|
|
if ( eRes != UR_NOTHING )
|
2005-09-28 10:31:22 +00:00
|
|
|
{
|
2002-11-27 14:08:07 +00:00
|
|
|
pLink->SetDestArea( ScRange( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 ) );
|
2005-09-28 10:31:22 +00:00
|
|
|
bAnyUpdate = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bAnyUpdate )
|
|
|
|
{
|
|
|
|
// #i52120# Look for duplicates (after updating all positions).
|
|
|
|
// If several links start at the same cell, the one with the lower index is removed
|
|
|
|
// (file format specifies only one link definition for a cell).
|
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nFirstIndex = 0;
|
2005-09-28 10:31:22 +00:00
|
|
|
while ( nFirstIndex < nCount )
|
|
|
|
{
|
|
|
|
bool bFound = false;
|
|
|
|
::sfx2::SvBaseLink* pFirst = *rLinks[nFirstIndex];
|
|
|
|
if ( pFirst->ISA(ScAreaLink) )
|
|
|
|
{
|
|
|
|
ScAddress aFirstPos = static_cast<ScAreaLink*>(pFirst)->GetDestArea().aStart;
|
2011-01-17 13:20:22 +01:00
|
|
|
for ( sal_uInt16 nSecondIndex = nFirstIndex + 1; nSecondIndex < nCount && !bFound; ++nSecondIndex )
|
2005-09-28 10:31:22 +00:00
|
|
|
{
|
|
|
|
::sfx2::SvBaseLink* pSecond = *rLinks[nSecondIndex];
|
|
|
|
if ( pSecond->ISA(ScAreaLink) &&
|
|
|
|
static_cast<ScAreaLink*>(pSecond)->GetDestArea().aStart == aFirstPos )
|
|
|
|
{
|
|
|
|
// remove the first link, exit the inner loop, don't increment nFirstIndex
|
|
|
|
pLinkManager->Remove( pFirst );
|
2012-06-12 15:41:27 +02:00
|
|
|
nCount = rLinks.size();
|
2005-09-28 10:31:22 +00:00
|
|
|
bFound = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!bFound)
|
|
|
|
++nFirstIndex;
|
2002-11-27 14:08:07 +00:00
|
|
|
}
|
2000-10-30 10:33:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// TimerDelays etc.
|
2007-02-27 11:02:34 +00:00
|
|
|
void ScDocument::KeyInput( const KeyEvent& )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-01 16:13:39 -05:00
|
|
|
if ( pChartListenerCollection->hasListeners() )
|
2000-09-18 23:16:46 +00:00
|
|
|
pChartListenerCollection->StartTimer();
|
2007-08-03 12:07:31 +00:00
|
|
|
if( apTemporaryChartLock.get() )
|
|
|
|
apTemporaryChartLock->StartOrContinueLocking();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2011-11-05 07:00:32 +01:00
|
|
|
bool ScDocument::CheckMacroWarn()
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-12-19 18:50:39 +00:00
|
|
|
// The check for macro configuration, macro warning and disabling is now handled
|
|
|
|
// in SfxObjectShell::AdjustMacroMode, called by SfxObjectShell::CallBasic.
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2011-11-05 07:00:32 +01:00
|
|
|
return true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2000-09-22 17:57:10 +00:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
SfxBindings* ScDocument::GetViewBindings()
|
|
|
|
{
|
|
|
|
// used to invalidate slots after changes to this document
|
|
|
|
|
|
|
|
if ( !pShell )
|
|
|
|
return NULL; // no ObjShell -> no view
|
|
|
|
|
|
|
|
// first check current view
|
|
|
|
SfxViewFrame* pViewFrame = SfxViewFrame::Current();
|
|
|
|
if ( pViewFrame && pViewFrame->GetObjectShell() != pShell ) // wrong document?
|
|
|
|
pViewFrame = NULL;
|
|
|
|
|
|
|
|
// otherwise use first view for this doc
|
|
|
|
if ( !pViewFrame )
|
|
|
|
pViewFrame = SfxViewFrame::GetFirst( pShell );
|
|
|
|
|
|
|
|
if (pViewFrame)
|
|
|
|
return &pViewFrame->GetBindings();
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2011-10-05 17:09:38 -04:00
|
|
|
ScDrawLayer* ScDocument::GetDrawLayer()
|
|
|
|
{
|
|
|
|
return pDrawLayer;
|
|
|
|
}
|
|
|
|
|
2001-03-26 18:26:30 +00:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ScDocument::TransliterateText( const ScMarkData& rMultiMark, sal_Int32 nType )
|
|
|
|
{
|
2011-05-21 13:29:51 +02:00
|
|
|
OSL_ENSURE( rMultiMark.IsMultiMarked(), "TransliterateText: no selection" );
|
2001-03-26 18:26:30 +00:00
|
|
|
|
|
|
|
utl::TransliterationWrapper aTranslitarationWrapper( xServiceManager, nType );
|
2011-11-05 07:00:32 +01:00
|
|
|
bool bConsiderLanguage = aTranslitarationWrapper.needLanguageForTheMode();
|
2001-03-26 18:26:30 +00:00
|
|
|
sal_uInt16 nLanguage = LANGUAGE_SYSTEM;
|
|
|
|
|
2011-06-08 12:16:24 +02:00
|
|
|
ScEditEngineDefaulter* pEngine = NULL; // not using pEditEngine member because of defaults
|
2001-03-27 12:48:15 +00:00
|
|
|
|
2004-06-04 09:23:25 +00:00
|
|
|
SCTAB nCount = GetTableCount();
|
2011-07-05 12:08:41 +01:00
|
|
|
ScMarkData::const_iterator itr = rMultiMark.begin(), itrEnd = rMultiMark.end();
|
2011-07-05 06:01:06 +02:00
|
|
|
for (; itr != itrEnd && *itr < nCount; ++itr)
|
|
|
|
if ( maTabs[*itr] )
|
2001-03-26 18:26:30 +00:00
|
|
|
{
|
2011-07-05 06:01:06 +02:00
|
|
|
SCTAB nTab = *itr;
|
2004-06-04 09:23:25 +00:00
|
|
|
SCCOL nCol = 0;
|
|
|
|
SCROW nRow = 0;
|
2001-03-26 18:26:30 +00:00
|
|
|
|
2011-11-05 07:00:32 +01:00
|
|
|
bool bFound = rMultiMark.IsCellMarked( nCol, nRow );
|
2001-03-26 18:26:30 +00:00
|
|
|
if (!bFound)
|
|
|
|
bFound = GetNextMarkedCell( nCol, nRow, nTab, rMultiMark );
|
|
|
|
|
|
|
|
while (bFound)
|
|
|
|
{
|
|
|
|
const ScBaseCell* pCell = GetCell( ScAddress( nCol, nRow, nTab ) );
|
|
|
|
CellType eType = pCell ? pCell->GetCellType() : CELLTYPE_NONE;
|
2011-06-08 12:16:24 +02:00
|
|
|
// fdo#32786 TITLE_CASE/SENTENCE_CASE need the extra handling in EditEngine (loop over words/sentences).
|
|
|
|
// Still use TransliterationWrapper directly for text cells with other transliteration types,
|
|
|
|
// for performance reasons.
|
|
|
|
if ( eType == CELLTYPE_EDIT ||
|
|
|
|
( eType == CELLTYPE_STRING && ( nType == com::sun::star::i18n::TransliterationModulesExtra::SENTENCE_CASE ||
|
|
|
|
nType == com::sun::star::i18n::TransliterationModulesExtra::TITLE_CASE ) ) )
|
2001-03-27 12:48:15 +00:00
|
|
|
{
|
|
|
|
if (!pEngine)
|
2012-04-20 00:46:19 -04:00
|
|
|
pEngine = new ScFieldEditEngine(this, GetEnginePool(), GetEditPool());
|
2001-03-27 12:48:15 +00:00
|
|
|
|
|
|
|
// defaults from cell attributes must be set so right language is used
|
|
|
|
const ScPatternAttr* pPattern = GetPattern( nCol, nRow, nTab );
|
|
|
|
SfxItemSet* pDefaults = new SfxItemSet( pEngine->GetEmptyItemSet() );
|
|
|
|
pPattern->FillEditItemSet( pDefaults );
|
2011-11-05 07:00:32 +01:00
|
|
|
pEngine->SetDefaults( pDefaults, true );
|
2001-03-27 12:48:15 +00:00
|
|
|
|
2011-06-08 12:16:24 +02:00
|
|
|
if ( eType == CELLTYPE_STRING )
|
|
|
|
pEngine->SetText( static_cast<const ScStringCell*>(pCell)->GetString() );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const EditTextObject* pData = static_cast<const ScEditCell*>(pCell)->GetData();
|
|
|
|
pEngine->SetText( *pData );
|
|
|
|
}
|
2001-03-27 12:48:15 +00:00
|
|
|
pEngine->ClearModifyFlag();
|
|
|
|
|
2011-06-08 12:16:24 +02:00
|
|
|
sal_uInt16 nLastPar = pEngine->GetParagraphCount();
|
|
|
|
if (nLastPar)
|
|
|
|
--nLastPar;
|
|
|
|
xub_StrLen nTxtLen = pEngine->GetTextLen(nLastPar);
|
|
|
|
ESelection aSelAll( 0, 0, nLastPar, nTxtLen );
|
|
|
|
|
|
|
|
pEngine->TransliterateText( aSelAll, nType );
|
2001-03-27 12:48:15 +00:00
|
|
|
|
|
|
|
if ( pEngine->IsModified() )
|
|
|
|
{
|
|
|
|
ScEditAttrTester aTester( pEngine );
|
|
|
|
if ( aTester.NeedsObject() )
|
|
|
|
{
|
|
|
|
// remove defaults (paragraph attributes) before creating text object
|
|
|
|
SfxItemSet* pEmpty = new SfxItemSet( pEngine->GetEmptyItemSet() );
|
2011-11-05 07:00:32 +01:00
|
|
|
pEngine->SetDefaults( pEmpty, true );
|
2001-03-27 12:48:15 +00:00
|
|
|
|
|
|
|
EditTextObject* pNewData = pEngine->CreateTextObject();
|
|
|
|
PutCell( nCol, nRow, nTab,
|
|
|
|
new ScEditCell( pNewData, this, pEngine->GetEditTextObjectPool() ) );
|
|
|
|
delete pNewData;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-06 18:11:43 +01:00
|
|
|
rtl::OUString aNewStr = pEngine->GetText();
|
2001-03-27 12:48:15 +00:00
|
|
|
PutCell( nCol, nRow, nTab, new ScStringCell( aNewStr ) );
|
|
|
|
}
|
|
|
|
}
|
2001-03-26 18:26:30 +00:00
|
|
|
}
|
|
|
|
|
2011-06-08 12:16:24 +02:00
|
|
|
else if ( eType == CELLTYPE_STRING )
|
|
|
|
{
|
2012-02-27 09:45:35 +00:00
|
|
|
rtl::OUString aOldStr = ((const ScStringCell*)pCell)->GetString();
|
2011-11-06 18:11:43 +01:00
|
|
|
sal_Int32 nOldLen = aOldStr.getLength();
|
2011-06-08 12:16:24 +02:00
|
|
|
|
|
|
|
if ( bConsiderLanguage )
|
|
|
|
{
|
|
|
|
sal_uInt8 nScript = GetStringScriptType( aOldStr ); //! cell script type?
|
|
|
|
sal_uInt16 nWhich = ( nScript == SCRIPTTYPE_ASIAN ) ? ATTR_CJK_FONT_LANGUAGE :
|
|
|
|
( ( nScript == SCRIPTTYPE_COMPLEX ) ? ATTR_CTL_FONT_LANGUAGE :
|
|
|
|
ATTR_FONT_LANGUAGE );
|
|
|
|
nLanguage = ((const SvxLanguageItem*)GetAttr( nCol, nRow, nTab, nWhich ))->GetValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
com::sun::star::uno::Sequence<sal_Int32> aOffsets;
|
2011-11-06 18:11:43 +01:00
|
|
|
rtl::OUString aNewStr = aTranslitarationWrapper.transliterate( aOldStr, nLanguage, 0, nOldLen, &aOffsets );
|
2011-06-08 12:16:24 +02:00
|
|
|
|
|
|
|
if ( aNewStr != aOldStr )
|
|
|
|
PutCell( nCol, nRow, nTab, new ScStringCell( aNewStr ) );
|
|
|
|
}
|
2001-03-26 18:26:30 +00:00
|
|
|
bFound = GetNextMarkedCell( nCol, nRow, nTab, rMultiMark );
|
|
|
|
}
|
|
|
|
}
|
2001-03-27 12:48:15 +00:00
|
|
|
delete pEngine;
|
2001-03-26 18:26:30 +00:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2011-06-20 17:06:34 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|