From c77e5c548c08163ab494ef25beeb4788a2ff1c4c Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 20 Apr 2009 16:57:13 +0000 Subject: CWS-TOOLING: rebase CWS printerpullpages to trunk@270723 (milestone: DEV300:m46) --- sc/source/ui/docshell/docsh.cxx | 60 ++++++--- sc/source/ui/docshell/externalrefmgr.cxx | 207 ++++++++++++++++++++++++++++++- 2 files changed, 246 insertions(+), 21 deletions(-) (limited to 'sc/source/ui/docshell') diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 7f1fb3b549cf..4545406ac3c9 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -1265,22 +1265,51 @@ BOOL __EXPORT ScDocShell::ConvertFrom( SfxMedium& rMedium ) } +ScDocShell::PrepareSaveGuard::PrepareSaveGuard( ScDocShell& rDocShell ) + : mrDocShell( rDocShell) +{ + // DoEnterHandler not here (because of AutoSave), is in ExecuteSave. + + ScChartListenerCollection* pCharts = mrDocShell.aDocument.GetChartListenerCollection(); + if (pCharts) + pCharts->UpdateDirtyCharts(); // Charts to be updated. + mrDocShell.aDocument.StopTemporaryChartLock(); + if (mrDocShell.pAutoStyleList) + mrDocShell.pAutoStyleList->ExecuteAllNow(); // Execute template timeouts now. + if (mrDocShell.aDocument.HasExternalRefManager()) + { + ScExternalRefManager* pRefMgr = mrDocShell.aDocument.GetExternalRefManager(); + if (pRefMgr && pRefMgr->hasExternalData()) + { + pRefMgr->setAllCacheTableReferencedStati( false); + mrDocShell.aDocument.MarkUsedExternalReferences(); // Mark tables of external references to be written. + } + } + if (mrDocShell.GetCreateMode()== SFX_CREATE_MODE_STANDARD) + mrDocShell.SfxObjectShell::SetVisArea( Rectangle() ); // "Normally" worked on => no VisArea. +} + +ScDocShell::PrepareSaveGuard::~PrepareSaveGuard() +{ + if (mrDocShell.aDocument.HasExternalRefManager()) + { + ScExternalRefManager* pRefMgr = mrDocShell.aDocument.GetExternalRefManager(); + if (pRefMgr && pRefMgr->hasExternalData()) + { + // Prevent accidental data loss due to lack of knowledge. + pRefMgr->setAllCacheTableReferencedStati( true); + } + } +} + + BOOL __EXPORT ScDocShell::Save() { RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::Save" ); ScRefreshTimerProtector( aDocument.GetRefreshTimerControlAddress() ); - // DoEnterHandler hier nicht (wegen AutoSave), ist im ExecuteSave - - ScChartListenerCollection* pCharts = aDocument.GetChartListenerCollection(); - if (pCharts) - pCharts->UpdateDirtyCharts(); // Charts, die noch upgedated werden muessen - aDocument.StopTemporaryChartLock(); - if (pAutoStyleList) - pAutoStyleList->ExecuteAllNow(); // Vorlagen-Timeouts jetzt ausfuehren - if (GetCreateMode()== SFX_CREATE_MODE_STANDARD) - SfxObjectShell::SetVisArea( Rectangle() ); // normal bearbeitet -> keine VisArea + PrepareSaveGuard aPrepareGuard( *this); // wait cursor is handled with progress bar BOOL bRet = SfxObjectShell::Save(); @@ -1296,16 +1325,7 @@ BOOL __EXPORT ScDocShell::SaveAs( SfxMedium& rMedium ) ScRefreshTimerProtector( aDocument.GetRefreshTimerControlAddress() ); - // DoEnterHandler hier nicht (wegen AutoSave), ist im ExecuteSave - - ScChartListenerCollection* pCharts = aDocument.GetChartListenerCollection(); - if (pCharts) - pCharts->UpdateDirtyCharts(); // Charts, die noch upgedated werden muessen - aDocument.StopTemporaryChartLock(); - if (pAutoStyleList) - pAutoStyleList->ExecuteAllNow(); // Vorlagen-Timeouts jetzt ausfuehren - if (GetCreateMode()== SFX_CREATE_MODE_STANDARD) - SfxObjectShell::SetVisArea( Rectangle() ); // normal bearbeitet -> keine VisArea + PrepareSaveGuard aPrepareGuard( *this); // wait cursor is handled with progress bar BOOL bRet = SfxObjectShell::SaveAs( rMedium ); diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx index 913ad89f8cab..d78aa6fe3d84 100644 --- a/sc/source/ui/docshell/externalrefmgr.cxx +++ b/sc/source/ui/docshell/externalrefmgr.cxx @@ -143,6 +143,7 @@ private: // ============================================================================ ScExternalRefCache::Table::Table() + : mbReferenced( true) // Prevent accidental data loss due to lack of knowledge. { } @@ -150,6 +151,16 @@ ScExternalRefCache::Table::~Table() { } +void ScExternalRefCache::Table::setReferenced( bool bReferenced ) +{ + mbReferenced = bReferenced; +} + +bool ScExternalRefCache::Table::isReferenced() const +{ + return mbReferenced; +} + void ScExternalRefCache::Table::setCell(SCCOL nCol, SCROW nRow, TokenRef pToken, sal_uInt32 nFmtIndex) { using ::std::pair; @@ -702,6 +713,168 @@ size_t ScExternalRefCache::getCacheTableCount(sal_uInt16 nFileId) const return pDoc ? pDoc->maTables.size() : 0; } +bool ScExternalRefCache::setCacheDocReferenced( sal_uInt16 nFileId ) +{ + DocItem* pDocItem = getDocItem(nFileId); + if (!pDocItem) + return areAllCacheTablesReferenced(); + + for (::std::vector::iterator itrTab = pDocItem->maTables.begin(); + itrTab != pDocItem->maTables.end(); ++itrTab) + { + if ((*itrTab).get()) + (*itrTab)->setReferenced( true); + } + addCacheDocToReferenced( nFileId); + return areAllCacheTablesReferenced(); +} + +bool ScExternalRefCache::setCacheTableReferenced( sal_uInt16 nFileId, const String& rTabName ) +{ + size_t nIndex = 0; + TableTypeRef pTab = getCacheTable( nFileId, rTabName, false, &nIndex); + if (pTab.get()) + { + if (!pTab->isReferenced()) + { + pTab->setReferenced( true); + addCacheTableToReferenced( nFileId, nIndex); + } + } + return areAllCacheTablesReferenced(); +} + +void ScExternalRefCache::setAllCacheTableReferencedStati( bool bReferenced ) +{ + if (bReferenced) + { + maReferenced.reset(0); + for (DocDataType::iterator itrDoc = maDocs.begin(); itrDoc != maDocs.end(); ++itrDoc) + { + ScExternalRefCache::DocItem& rDocItem = (*itrDoc).second; + for (::std::vector::iterator itrTab = rDocItem.maTables.begin(); + itrTab != rDocItem.maTables.end(); ++itrTab) + { + if ((*itrTab).get()) + (*itrTab)->setReferenced( true); + } + } + } + else + { + size_t nDocs = 0; + for (DocDataType::const_iterator itrDoc = maDocs.begin(); itrDoc != maDocs.end(); ++itrDoc) + { + if (nDocs <= (*itrDoc).first) + nDocs = (*itrDoc).first + 1; + } + maReferenced.reset( nDocs); + + for (DocDataType::iterator itrDoc = maDocs.begin(); itrDoc != maDocs.end(); ++itrDoc) + { + ScExternalRefCache::DocItem& rDocItem = (*itrDoc).second; + sal_uInt16 nFileId = (*itrDoc).first; + size_t nTables = rDocItem.maTables.size(); + ReferencedStatus::DocReferenced & rDocReferenced = maReferenced.maDocs[nFileId]; + // All referenced => non-existing tables evaluate as completed. + rDocReferenced.maTables.resize( nTables, true); + for (size_t i=0; i < nTables; ++i) + { + TableTypeRef & xTab = rDocItem.maTables[i]; + if (xTab.get()) + { + xTab->setReferenced( false); + rDocReferenced.maTables[i] = false; + rDocReferenced.mbAllTablesReferenced = false; + } + } + } + } +} + +void ScExternalRefCache::addCacheTableToReferenced( sal_uInt16 nFileId, size_t nIndex ) +{ + if (nFileId >= maReferenced.maDocs.size()) + return; + + ::std::vector & rTables = maReferenced.maDocs[nFileId].maTables; + size_t nTables = rTables.size(); + if (nIndex >= nTables) + return; + + if (!rTables[nIndex]) + { + rTables[nIndex] = true; + size_t i = 0; + while (i < nTables && rTables[i]) + ++i; + if (i == nTables) + { + maReferenced.maDocs[nFileId].mbAllTablesReferenced = true; + maReferenced.checkAllDocs(); + } + } +} + +void ScExternalRefCache::addCacheDocToReferenced( sal_uInt16 nFileId ) +{ + if (nFileId >= maReferenced.maDocs.size()) + return; + + if (!maReferenced.maDocs[nFileId].mbAllTablesReferenced) + { + ::std::vector & rTables = maReferenced.maDocs[nFileId].maTables; + size_t nSize = rTables.size(); + for (size_t i=0; i < nSize; ++i) + rTables[i] = true; + maReferenced.maDocs[nFileId].mbAllTablesReferenced = true; + maReferenced.checkAllDocs(); + } +} + +bool ScExternalRefCache::areAllCacheTablesReferenced() const +{ + return maReferenced.mbAllReferenced; +} + +ScExternalRefCache::ReferencedStatus::ReferencedStatus() : + mbAllReferenced(false) +{ + reset(0); +} + +ScExternalRefCache::ReferencedStatus::ReferencedStatus( size_t nDocs ) : + mbAllReferenced(false) +{ + reset( nDocs); +} + +void ScExternalRefCache::ReferencedStatus::reset( size_t nDocs ) +{ + if (nDocs) + { + mbAllReferenced = false; + DocReferencedVec aRefs( nDocs); + maDocs.swap( aRefs); + } + else + { + mbAllReferenced = true; + DocReferencedVec aRefs; + maDocs.swap( aRefs); + } +} + +void ScExternalRefCache::ReferencedStatus::checkAllDocs() +{ + for (DocReferencedVec::const_iterator itr = maDocs.begin(); itr != maDocs.end(); ++itr) + { + if (!(*itr).mbAllTablesReferenced) + return; + } + mbAllReferenced = true; +} + ScExternalRefCache::TableTypeRef ScExternalRefCache::getCacheTable(sal_uInt16 nFileId, size_t nTabIndex) const { DocItem* pDoc = getDocItem(nFileId); @@ -987,7 +1160,8 @@ static ScTokenArray* lcl_convertToTokenArray(ScDocument* pSrcDoc, const ScRange& } ScExternalRefManager::ScExternalRefManager(ScDocument* pDoc) : - mpDoc(pDoc) + mpDoc(pDoc), + bInReferenceMarking(false) { maSrcDocTimer.SetTimeoutHdl( LINK(this, ScExternalRefManager, TimeOutHdl) ); maSrcDocTimer.SetTimeout(SRCDOC_SCAN_INTERVAL); @@ -1278,6 +1452,37 @@ sal_uInt16 ScExternalRefManager::getExternalFileCount() const return static_cast< sal_uInt16 >( maSrcFiles.size() ); } +bool ScExternalRefManager::markUsedByLinkListeners() +{ + bool bAllMarked = false; + for (LinkListenerMap::const_iterator itr = maLinkListeners.begin(); + itr != maLinkListeners.end() && !bAllMarked; ++itr) + { + if (!(*itr).second.empty()) + bAllMarked = maRefCache.setCacheDocReferenced( (*itr).first); + /* TODO: LinkListeners should remember the table they're listening to. + * As is, listening to one table will mark all tables of the document + * being referenced. */ + } + return bAllMarked; +} + +bool ScExternalRefManager::setCacheDocReferenced( sal_uInt16 nFileId ) +{ + return maRefCache.setCacheDocReferenced( nFileId); +} + +bool ScExternalRefManager::setCacheTableReferenced( sal_uInt16 nFileId, const String& rTabName ) +{ + return maRefCache.setCacheTableReferenced( nFileId, rTabName); +} + +void ScExternalRefManager::setAllCacheTableReferencedStati( bool bReferenced ) +{ + bInReferenceMarking = !bReferenced; + maRefCache.setAllCacheTableReferencedStati( bReferenced ); +} + void ScExternalRefManager::storeRangeNameTokens(sal_uInt16 nFileId, const String& rName, const ScTokenArray& rArray) { ScExternalRefCache::TokenArrayRef pArray(rArray.Clone()); -- cgit From 3860a9a00d22d0b726f49c6fcaa6f9dc2b7e05b7 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 28 May 2009 16:57:36 +0000 Subject: #i96402# SetDuplexMode --- sc/source/ui/docshell/docsh4.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sc/source/ui/docshell') diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index 3da74feae40e..3bcb2ddca129 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -2108,7 +2108,9 @@ void ScDocShell::Print( SfxProgress& rProgress, PrintDialog* pPrintDialog, } } - if ( n+1 < nCollateCopies && pPrinter->GetDuplexMode() == DUPLEX_ON && ( nPrinted % 2 ) == 1 ) + 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 -- cgit From 4dd1488ef305663ee693a11f95f45574697a376d Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 11 Jun 2009 16:57:21 +0000 Subject: make compile again, needs adaption ? --- sc/source/ui/docshell/docsh4.cxx | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sc/source/ui/docshell') diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index 0a8ef7889612..1e81762438a5 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -2143,8 +2143,11 @@ void ScDocShell::Print( SfxProgress& rProgress, PrintDialog* pPrintDialog, // 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 } } } -- cgit