summaryrefslogtreecommitdiff
path: root/sc/source/ui/docshell
diff options
context:
space:
mode:
authorCarsten Driesner <cd@openoffice.org>2011-01-21 17:18:37 +0100
committerCarsten Driesner <cd@openoffice.org>2011-01-21 17:18:37 +0100
commitd672102cc70fa4b24eed730e89e9e766cc10a525 (patch)
treeee6e081a403e1e23af6ec7850a34eb10fc7fc8fd /sc/source/ui/docshell
parent9617758b4b0997f5981a1303684ba9c9a4dd148b (diff)
parent6f68642b7b2310b902264849a5ffc5dca6c15510 (diff)
removetooltypes01: Rebase to DEV300m98
Diffstat (limited to 'sc/source/ui/docshell')
-rw-r--r--sc/source/ui/docshell/arealink.cxx4
-rw-r--r--sc/source/ui/docshell/docfunc.cxx13
-rw-r--r--sc/source/ui/docshell/docsh.cxx1
-rw-r--r--sc/source/ui/docshell/docsh4.cxx371
-rw-r--r--sc/source/ui/docshell/tablink.cxx3
5 files changed, 16 insertions, 376 deletions
diff --git a/sc/source/ui/docshell/arealink.cxx b/sc/source/ui/docshell/arealink.cxx
index 6182ada4836e..1be8b2aa9dc0 100644
--- a/sc/source/ui/docshell/arealink.cxx
+++ b/sc/source/ui/docshell/arealink.cxx
@@ -270,9 +270,9 @@ sal_Bool ScAreaLink::Refresh( const String& rNewFile, const String& rNewFilter,
SfxMedium* pMed = new SfxMedium(aNewUrl, STREAM_STD_READ, sal_False, pFilter);
+ // aRef->DoClose() will be closed explicitly, but it is still more safe to use SfxObjectShellLock here
ScDocShell* pSrcShell = new ScDocShell(SFX_CREATE_MODE_INTERNAL);
-//REMOVE SvEmbeddedObjectRef aRef = pSrcShell;
- SfxObjectShellRef aRef = pSrcShell;
+ SfxObjectShellLock aRef = pSrcShell;
pSrcShell->DoLoad(pMed);
ScDocument* pSrcDoc = pSrcShell->GetDocument();
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index fa219689d933..7ec023717a6a 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -3126,6 +3126,8 @@ sal_Bool ScDocFunc::SetWidthOrHeight( sal_Bool bWidth, SCCOLROW nRangeCnt, SCCOL
ScSizeMode eMode, sal_uInt16 nSizeTwips,
sal_Bool bRecord, sal_Bool bApi )
{
+ ScDocShellModificator aModificator( rDocShell );
+
if (!nRangeCnt)
return sal_True;
@@ -3287,6 +3289,7 @@ sal_Bool ScDocFunc::SetWidthOrHeight( sal_Bool bWidth, SCCOLROW nRangeCnt, SCCOL
pDoc->UpdatePageBreaks( nTab );
rDocShell.PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_ALL);
+ aModificator.SetDocumentModified();
return bSuccess;
}
@@ -4866,10 +4869,12 @@ sal_Bool ScDocFunc::InsertAreaLink( const String& rFile, const String& rFilter,
}
// Update hat sein eigenes Undo
-
- pLink->SetDoInsert(bFitBlock); // beim ersten Update ggf. nichts einfuegen
- pLink->Update(); // kein SetInCreate -> Update ausfuehren
- pLink->SetDoInsert(sal_True); // Default = TRUE
+ if (pDoc->IsExecuteLinkEnabled())
+ {
+ pLink->SetDoInsert(bFitBlock); // beim ersten Update ggf. nichts einfuegen
+ pLink->Update(); // kein SetInCreate -> Update ausfuehren
+ }
+ pLink->SetDoInsert(sal_True); // Default = sal_True
SfxBindings* pBindings = rDocShell.GetViewBindings();
if (pBindings)
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 9ded868e872d..ea6fa3ce08db 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -2605,6 +2605,7 @@ void ScDocShell::SetDocumentModified( sal_Bool bIsModified /* = sal_True */ )
if ( pPaintLockData && bIsModified )
{
//! BCA_BRDCST_ALWAYS etc. also needed here?
+ aDocument.InvalidateTableArea(); // #i105279# needed here
aDocument.BroadcastUno( SfxSimpleHint( SFX_HINT_DATACHANGED ) );
pPaintLockData->SetModified(); // spaeter...
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index fe147466bd80..7dcfbf027577 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -55,7 +55,6 @@ using namespace ::com::sun::star;
#include <svtools/sfxecode.hxx>
#include <svx/ofaitem.hxx>
#include <sot/formats.hxx>
-#include <svtools/printdlg.hxx>
#include <svl/whiter.hxx>
#include <vcl/msgbox.hxx>
#include <vcl/waitobj.hxx>
@@ -782,8 +781,9 @@ void ScDocShell::Execute( SfxRequest& rReq )
{
SfxErrorContext aEc( ERRCTX_SFX_OPENDOC, pMed->GetName() );
+ // pOtherDocSh->DoClose() will be called explicitly later, but it is still more safe to use SfxObjectShellLock here
ScDocShell* pOtherDocSh = new ScDocShell;
- SfxObjectShellRef aDocShTablesRef = pOtherDocSh;
+ SfxObjectShellLock aDocShTablesRef = pOtherDocSh;
pOtherDocSh->DoLoad( pMed );
sal_uLong nErr = pOtherDocSh->GetErrorCode();
if (nErr)
@@ -1828,373 +1828,6 @@ void ScDocShell::GetStatePageStyle( SfxViewShell& /* rCaller */,
}
}
-void lcl_GetPrintData( ScDocShell* pDocShell /*in*/,
- ScDocument* pDocument /*in*/, SfxPrinter* pPrinter /*in*/,
- PrintDialog* pPrintDialog /*in*/, bool bForceSelected /*in*/,
- ScMarkData* pMarkData /*inout*/, bool& rbHasOptions /*out*/,
- ScPrintOptions& rOptions /*out*/, bool& rbAllTabs /*out*/,
- long& rnTotalPages /*out*/, long aPageArr[] /*out*/,
- MultiSelection& rPageRanges /*out*/, ScRange** ppMarkedRange /*out*/ )
-{
- // get settings from print options sub-dialog
- const SfxItemSet& rOptionSet = pPrinter->GetOptions();
- const SfxPoolItem* pItem;
- rbHasOptions = ( rOptionSet.GetItemState( SID_SCPRINTOPTIONS, sal_False, &pItem ) == SFX_ITEM_SET );
- if ( rbHasOptions )
- {
- rOptions = ((const ScTpPrintItem*)pItem)->GetPrintOptions();
- }
- else
- {
- // use configuration
- rOptions = SC_MOD()->GetPrintOptions();
- }
-
- // update all pending row heights with a single progress bar,
- // instead of a separate progress for each sheet from ScPrintFunc
- pDocShell->UpdatePendingRowHeights( MAXTAB, true );
-
- // get number of total pages
- rnTotalPages = 0;
- SCTAB nTabCount = pDocument->GetTableCount();
- for ( SCTAB nTab = 0; nTab < nTabCount; ++nTab )
- {
- ScPrintFunc aPrintFunc( pDocShell, pPrinter, nTab, 0, 0, NULL, &rOptions );
- long nThisTab = aPrintFunc.GetTotalPages();
- aPageArr[nTab] = nThisTab;
- rnTotalPages += nThisTab;
- }
-
- rPageRanges.SetTotalRange( Range( 0, RANGE_MAX ) );
- rPageRanges.Select( Range( 1, rnTotalPages ) );
-
- rbAllTabs = ( pPrintDialog ? ( pPrintDialog->GetCheckedSheetRange() == PRINTSHEETS_ALL ) : SC_MOD()->GetPrintOptions().GetAllSheets() );
- if ( bForceSelected )
- {
- rbAllTabs = false;
- }
-
- if ( ( pPrintDialog && pPrintDialog->GetCheckedSheetRange() == PRINTSHEETS_SELECTED_CELLS ) || bForceSelected )
- {
- if ( pMarkData && ( pMarkData->IsMarked() || pMarkData->IsMultiMarked() ) )
- {
- pMarkData->MarkToMulti();
- *ppMarkedRange = new ScRange;
- pMarkData->GetMultiMarkArea( **ppMarkedRange );
- pMarkData->MarkToSimple();
- }
- }
-
- PrintDialogRange eDlgOption = pPrintDialog ? pPrintDialog->GetCheckedRange() : PRINTDIALOG_ALL;
- if ( eDlgOption == PRINTDIALOG_RANGE )
- {
- rPageRanges = MultiSelection( pPrintDialog->GetRangeText() );
- }
-
- // get number of total pages if selection
- if ( !rbAllTabs )
- {
- rnTotalPages = 0;
- for ( SCTAB nTab = 0; nTab < nTabCount; ++nTab )
- {
- if ( *ppMarkedRange ) // selected range is used instead of print ranges -> page count is different
- {
- ScPrintFunc aPrintFunc( pDocShell, pPrinter, nTab, 0, 0, *ppMarkedRange, &rOptions );
- aPageArr[nTab] = aPrintFunc.GetTotalPages();
- }
- if ( !pMarkData || pMarkData->GetTableSelect( nTab ) )
- {
- rnTotalPages += aPageArr[nTab];
- }
- }
- if ( eDlgOption == PRINTDIALOG_ALL || bForceSelected )
- {
- rPageRanges.Select( Range( 1, rnTotalPages ) );
- }
- }
-}
-
-bool ScDocShell::CheckPrint( PrintDialog* pPrintDialog, ScMarkData* pMarkData, bool bForceSelected, bool bIsAPI )
-{
- SfxPrinter* pPrinter = GetPrinter();
- if ( !pPrinter )
- {
- return false;
- }
-
- bool bHasOptions = false;
- ScPrintOptions aOptions;
- bool bAllTabs = true;
- long nTotalPages = 0;
- long aPageArr[MAXTABCOUNT]; // pages per sheet
- MultiSelection aPageRanges; // pages to print
- ScRange* pMarkedRange = NULL;
-
- lcl_GetPrintData( this, &aDocument, pPrinter, pPrintDialog, bForceSelected,
- pMarkData, bHasOptions, aOptions, bAllTabs, nTotalPages,
- aPageArr, aPageRanges, &pMarkedRange );
-
- delete pMarkedRange;
-
- if ( nTotalPages == 0 )
- {
- if ( !bIsAPI )
- {
- WarningBox aWarningBox( GetActiveDialogParent(), WinBits( WB_OK ),
- String( ScResId( STR_PRINT_NOTHING ) ) );
- aWarningBox.Execute();
- }
- return false;
- }
-
- return true;
-}
-
-void ScDocShell::PreparePrint( PrintDialog* pPrintDialog, ScMarkData* pMarkData )
-{
- SfxPrinter* pPrinter = GetPrinter();
- if ( !pPrinter )
- {
- return;
- }
-
- delete pOldJobSetup; // gesetzt nur bei Fehler in StartJob()
- pOldJobSetup = new ScJobSetup( pPrinter ); // Einstellungen merken
-
- // Einstellungen fuer die erste gedruckte Seite muessen hier (vor StartJob) gesetzt werden
- //! Selection etc. mit Print() zusammenfassen !!!
- //! Seiten nur einmal zaehlen
-
- bool bHasOptions = false;
- ScPrintOptions aOptions;
- bool bAllTabs = true;
- long nTotalPages = 0;
- long aPageArr[MAXTABCOUNT]; // pages per sheet
- MultiSelection aPageRanges; // pages to print
- ScRange* pMarkedRange = NULL;
-
- lcl_GetPrintData( this, &aDocument, pPrinter, pPrintDialog, false,
- pMarkData, bHasOptions, aOptions, bAllTabs, nTotalPages,
- aPageArr, aPageRanges, &pMarkedRange );
-
- sal_Bool bFound = sal_False; // erste Seite gefunden
- long nTabStart = 0;
- SCTAB nTabCount = aDocument.GetTableCount();
- for ( SCTAB nTab=0; nTab<nTabCount && !bFound; nTab++ )
- {
- if ( bAllTabs || !pMarkData || pMarkData->GetTableSelect( nTab ) )
- {
- long nNext = nTabStart + aPageArr[nTab];
- sal_Bool bSelected = sal_False;
- for (long nP=nTabStart+1; nP<=nNext; nP++) // 1-basiert
- if (aPageRanges.IsSelected( nP )) // eine Seite von dieser Tabelle selektiert?
- bSelected = sal_True;
-
- if (bSelected)
- {
- ScPrintFunc aPrintFunc( this, pPrinter, nTab );
-
- aPrintFunc.ApplyPrintSettings(); // dann Settings fuer diese Tabelle
- bFound = sal_True;
- }
- nTabStart = nNext;
- }
- }
-
- delete pMarkedRange;
-}
-
-sal_Bool lcl_HasTransparent( ScDocument* pDoc, SCTAB nTab, const ScRange* pRange )
-{
- sal_Bool bFound = sal_False;
- ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
- if (pDrawLayer)
- {
- SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
- DBG_ASSERT(pPage,"Page ?");
- if (pPage)
- {
- Rectangle aMMRect;
- if ( pRange )
- aMMRect = pDoc->GetMMRect( pRange->aStart.Col(), pRange->aStart.Row(),
- pRange->aEnd.Col(), pRange->aEnd.Row(), nTab );
-
- SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
- SdrObject* pObject = aIter.Next();
- while (pObject && !bFound)
- {
- if (pObject->IsTransparent())
- {
- if ( pRange )
- {
- Rectangle aObjRect = pObject->GetLogicRect();
- if ( aObjRect.IsOver( aMMRect ) )
- bFound = sal_True;
- }
- else
- bFound = sal_True;
- }
-
- pObject = aIter.Next();
- }
- }
- }
-
- return bFound;
-}
-
-void ScDocShell::Print( SfxProgress& rProgress, PrintDialog* pPrintDialog,
- ScMarkData* pMarkData, Window* pDialogParent, sal_Bool bForceSelected, sal_Bool bIsAPI )
-{
- SfxPrinter* pPrinter = GetPrinter();
- if ( !pPrinter )
- {
- return;
- }
-
- bool bHasOptions = false;
- ScPrintOptions aOptions;
- bool bAllTabs = true;
- long nTotalPages = 0;
- long aPageArr[MAXTABCOUNT]; // pages per sheet
- MultiSelection aPageRanges; // pages to print
- ScRange* pMarkedRange = NULL;
-
- lcl_GetPrintData( this, &aDocument, pPrinter, pPrintDialog, bForceSelected,
- pMarkData, bHasOptions, aOptions, bAllTabs, nTotalPages,
- aPageArr, aPageRanges, &pMarkedRange );
-
- sal_uInt16 nCollateCopies = 1;
- if ( pPrintDialog && pPrintDialog->IsCollateEnabled() && pPrintDialog->IsCollateChecked() )
- nCollateCopies = pPrintDialog->GetCopyCount();
-
- // test if printed range contains transparent objects
-
- sal_Bool bHasTransp = sal_False;
- sal_Bool bAnyPrintRanges = aDocument.HasPrintRange();
- ScStyleSheetPool* pStylePool = aDocument.GetStyleSheetPool();
- SCTAB nTabCount = aDocument.GetTableCount();
- for ( SCTAB nTab=0; nTab<nTabCount && !bHasTransp; nTab++ )
- {
- if ( bAllTabs || !pMarkData || pMarkData->GetTableSelect( nTab ) )
- {
- SfxStyleSheetBase* pStyleSheet = pStylePool->Find(
- aDocument.GetPageStyle( nTab ), SFX_STYLE_FAMILY_PAGE );
- if ( pStyleSheet )
- {
- const SfxItemSet& rSet = pStyleSheet->GetItemSet();
- if ( ((const ScViewObjectModeItem&)rSet.Get(ATTR_PAGE_CHARTS)).GetValue() == VOBJ_MODE_SHOW ||
- ((const ScViewObjectModeItem&)rSet.Get(ATTR_PAGE_OBJECTS)).GetValue() == VOBJ_MODE_SHOW ||
- ((const ScViewObjectModeItem&)rSet.Get(ATTR_PAGE_DRAWINGS)).GetValue() == VOBJ_MODE_SHOW )
- {
- if ( pMarkedRange )
- bHasTransp = bHasTransp || lcl_HasTransparent( &aDocument, nTab, pMarkedRange );
- else if ( aDocument.GetPrintRangeCount(nTab) )
- {
- sal_uInt16 nRangeCount = aDocument.GetPrintRangeCount(nTab);
- for (sal_uInt16 i=0; i<nRangeCount; i++)
- bHasTransp = bHasTransp ||
- lcl_HasTransparent( &aDocument, nTab, aDocument.GetPrintRange( nTab, i ) );
- }
- else if (!bAnyPrintRanges || aDocument.IsPrintEntireSheet(nTab))
- bHasTransp = bHasTransp || lcl_HasTransparent( &aDocument, nTab, NULL );
- }
- }
- }
- }
-
- sal_Bool bContinue = pPrinter->InitJob( pDialogParent, !bIsAPI && bHasTransp );
-
- if ( bContinue )
- {
- for ( sal_uInt16 n=0; n<nCollateCopies; n++ )
- {
- long nTabStart = 0;
- long nDisplayStart = 0;
- long nAttrPage = 1;
- long nPrinted = 0;
-
- for ( SCTAB nTab=0; nTab<nTabCount; nTab++ )
- {
- if ( bAllTabs || !pMarkData || pMarkData->GetTableSelect( nTab ) )
- {
- FmFormView* pDrawView = NULL;
- Rectangle aFull( 0, 0, LONG_MAX, LONG_MAX );
-
- // #114135#
- ScDrawLayer* pModel = aDocument.GetDrawLayer(); // ist nicht NULL
-
- if(pModel)
- {
- pDrawView = new FmFormView( pModel, pPrinter );
- pDrawView->ShowSdrPage(pDrawView->GetModel()->GetPage(nTab));
- pDrawView->SetPrintPreview( sal_True );
- }
-
- ScPrintFunc aPrintFunc( this, pPrinter, nTab, nAttrPage, nTotalPages, pMarkedRange, &aOptions );
- aPrintFunc.SetDrawView( pDrawView );
- nPrinted += aPrintFunc.DoPrint( aPageRanges, nTabStart, nDisplayStart, sal_True, &rProgress, NULL );
-
- nTabStart += aPageArr[nTab];
- if ( aDocument.NeedPageResetAfterTab(nTab) )
- nDisplayStart = 0;
- else
- nDisplayStart += aPageArr[nTab];
- nAttrPage = aPrintFunc.GetFirstPageNo(); // behalten oder aus Vorlage
-
- delete pDrawView;
- }
- }
-
- if ( n+1 < nCollateCopies &&
- (pPrinter->GetDuplexMode() == DUPLEX_SHORTEDGE || pPrinter->GetDuplexMode() == DUPLEX_LONGEDGE) &&
- ( nPrinted % 2 ) == 1 )
- {
- // #105584# when several collated copies are printed in duplex mode, and there is
- // an odd number of pages, print an empty page between copies, so the first page of
- // the second copy isn't printed on the back of the last page of the first copy.
- // (same as in Writer ViewShell::Prt)
-
- // FIXME: needs to be adapted to XRenderable interface
- #if 0
- pPrinter->StartPage();
- pPrinter->EndPage();
- #endif
- }
- }
- }
-
- delete pMarkedRange;
-
- if (pOldJobSetup)
- {
- pPrinter->SetOrientation( pOldJobSetup->eOrientation );
- pPrinter->SetPaperBin ( pOldJobSetup->nPaperBin );
- pPrinter->SetPaper ( pOldJobSetup->ePaper );
-
- if ( PAPER_USER == pOldJobSetup->ePaper )
- {
- pPrinter->SetMapMode( pOldJobSetup->aUserMapMode );
- pPrinter->SetPaperSizeUser( pOldJobSetup->aUserSize );
- }
-
- delete pOldJobSetup;
- pOldJobSetup = NULL;
- }
-
- if ( bHasOptions )
- {
- // remove PrintOptions from printer ItemSet,
- // so next time the options from the configuration are used
-
- SfxItemSet aSet( pPrinter->GetOptions() );
- aSet.ClearItem( SID_SCPRINTOPTIONS );
- pPrinter->SetOptions( aSet );
- }
-
- PostPaintGridAll(); //! nur wenn geaendert
-}
-
void ScDocShell::GetState( SfxItemSet &rSet )
{
SfxWhichIter aIter(rSet);
diff --git a/sc/source/ui/docshell/tablink.cxx b/sc/source/ui/docshell/tablink.cxx
index f794f3fb7e54..04755f9b8c82 100644
--- a/sc/source/ui/docshell/tablink.cxx
+++ b/sc/source/ui/docshell/tablink.cxx
@@ -219,8 +219,9 @@ sal_Bool ScTableLink::Refresh(const String& rNewFile, const String& rNewFilter,
if ( bInEdit ) // only if using the edit dialog,
pMed->UseInteractionHandler( sal_True ); // enable the filter options dialog
+ // aRef->DoClose() will be called explicitly, but it is still more safe to use SfxObjectShellLock here
ScDocShell* pSrcShell = new ScDocShell(SFX_CREATE_MODE_INTERNAL);
- SfxObjectShellRef aRef = pSrcShell;
+ SfxObjectShellLock aRef = pSrcShell;
pSrcShell->DoLoad(pMed);
// Optionen koennten gesetzt worden sein