summaryrefslogtreecommitdiff
path: root/sw/source/core
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/core')
-rw-r--r--sw/source/core/access/accpage.cxx5
-rwxr-xr-x[-rw-r--r--]sw/source/core/doc/doc.cxx638
-rw-r--r--sw/source/core/doc/docdesc.cxx1
-rw-r--r--sw/source/core/doc/docnew.cxx33
-rw-r--r--sw/source/core/doc/notxtfrm.cxx58
-rw-r--r--sw/source/core/draw/dcontact.cxx29
-rw-r--r--sw/source/core/draw/dflyobj.cxx12
-rw-r--r--sw/source/core/fields/dbfld.cxx4
-rw-r--r--sw/source/core/fields/docufld.cxx3
-rw-r--r--sw/source/core/inc/cellfrm.hxx2
-rw-r--r--sw/source/core/inc/flyfrm.hxx2
-rw-r--r--sw/source/core/inc/frame.hxx3
-rw-r--r--sw/source/core/inc/layfrm.hxx2
-rw-r--r--sw/source/core/inc/notxtfrm.hxx2
-rw-r--r--sw/source/core/inc/rootfrm.hxx2
-rw-r--r--sw/source/core/inc/tabfrm.hxx2
-rw-r--r--sw/source/core/inc/txtfrm.hxx2
-rw-r--r--sw/source/core/inc/viewimp.hxx10
-rw-r--r--sw/source/core/layout/paintfrm.cxx22
-rw-r--r--sw/source/core/layout/unusedf.cxx2
-rw-r--r--sw/source/core/layout/wsfrm.cxx5
-rw-r--r--sw/source/core/text/frmpaint.cxx2
-rw-r--r--sw/source/core/text/itrform2.cxx6
-rw-r--r--sw/source/core/text/porrst.cxx1
-rw-r--r--sw/source/core/unocore/unodraw.cxx39
-rw-r--r--sw/source/core/unocore/unotext.cxx4
-rw-r--r--sw/source/core/view/vdraw.cxx8
-rwxr-xr-x[-rw-r--r--]sw/source/core/view/viewpg.cxx744
-rw-r--r--sw/source/core/view/vnew.cxx7
-rwxr-xr-x[-rw-r--r--]sw/source/core/view/vprint.cxx1395
30 files changed, 1471 insertions, 1574 deletions
diff --git a/sw/source/core/access/accpage.cxx b/sw/source/core/access/accpage.cxx
index 9d1f39acfc5b..bc2a74809420 100644
--- a/sw/source/core/access/accpage.cxx
+++ b/sw/source/core/access/accpage.cxx
@@ -129,8 +129,9 @@ void SwAccessiblePage::_InvalidateFocus()
}
SwAccessiblePage::SwAccessiblePage( SwAccessibleMap* pInitMap,
- const SwFrm* pFrame ) :
- SwAccessibleContext( pInitMap, AccessibleRole::PANEL, pFrame )
+ const SwFrm* pFrame )
+ : SwAccessibleContext( pInitMap, AccessibleRole::PANEL, pFrame )
+ , bIsSelected( sal_False )
{
DBG_ASSERT( pFrame != NULL, "need frame" );
DBG_ASSERT( pInitMap != NULL, "need map" );
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 8eac59dfb792..624c787f241a 100644..100755
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -46,8 +46,11 @@
#include <comphelper/processfactory.hxx>
#include <tools/urlobj.hxx>
#include <tools/poly.hxx>
+#include <tools/multisel.hxx>
+#include <rtl/ustring.hxx>
#include <vcl/virdev.hxx>
#include <svl/itemiter.hxx>
+#include <unotools/syslocale.hxx>
#include <sfx2/printer.hxx>
#include <editeng/keepitem.hxx>
#include <editeng/cscoitem.hxx>
@@ -56,6 +59,8 @@
#include <editeng/forbiddencharacterstable.hxx>
#include <svx/svdmodel.hxx>
#include <unotools/charclass.hxx>
+#include <unotools/localedatawrapper.hxx>
+
#include <swmodule.hxx>
#include <fmtpdsc.hxx>
#include <fmtanchr.hxx>
@@ -95,20 +100,22 @@
#include <fldupde.hxx>
#include <swbaslnk.hxx>
#include <printdata.hxx>
-#ifndef _CMDID_H
+#include <swprtopt.hxx>
#include <cmdid.h> // fuer den dflt - Printer in SetJob
-#endif
-#ifndef _STATSTR_HRC
#include <statstr.hrc> // StatLine-String
-#endif
#include <comcore.hrc>
#include <SwUndoTOXChange.hxx>
#include <SwUndoFmt.hxx>
#include <unocrsr.hxx>
#include <docsh.hxx>
-#include <docufld.hxx>
+#include <docfld.hxx> // _SetGetExpFld
+#include <docufld.hxx> // SwPostItField
+#include <viewsh.hxx>
+#include <shellres.hxx>
+#include <txtfrm.hxx>
#include <vector>
+#include <map>
#include <osl/diagnose.h>
#include <osl/interlck.h>
@@ -121,6 +128,8 @@
// <--
using namespace ::com::sun::star;
+using ::rtl::OUString;
+
// Seiten-Deskriptoren
SV_IMPL_PTRARR(SwPageDescs,SwPageDescPtr);
@@ -1028,6 +1037,625 @@ const SwDocStat& SwDoc::GetDocStat() const
return *pDocStat;
}
+/*************************************************************************/
+
+
+struct _PostItFld : public _SetGetExpFld
+{
+ _PostItFld( const SwNodeIndex& rNdIdx, const SwTxtFld* pFld, const SwIndex* pIdx = 0 )
+ : _SetGetExpFld( rNdIdx, pFld, pIdx ) {}
+
+ USHORT GetPageNo( const StringRangeEnumerator &rRangeEnum,
+ const std::set< sal_Int32 > &rPossiblePages,
+ USHORT& rVirtPgNo, USHORT& rLineNo );
+
+ SwPostItField* GetPostIt() const
+ {
+ return (SwPostItField*) GetFld()->GetFld().GetFld();
+ }
+};
+
+
+USHORT _PostItFld::GetPageNo(
+ const StringRangeEnumerator &rRangeEnum,
+ const std::set< sal_Int32 > &rPossiblePages,
+ /* out */ USHORT& rVirtPgNo, /* out */ USHORT& rLineNo )
+{
+ //Problem: Wenn ein PostItFld in einem Node steht, der von mehr als
+ //einer Layout-Instanz repraesentiert wird, steht die Frage im Raum,
+ //ob das PostIt nur ein- oder n-mal gedruck werden soll.
+ //Wahrscheinlich nur einmal, als Seitennummer soll hier keine Zufaellige
+ //sondern die des ersten Auftretens des PostIts innerhalb des selektierten
+ //Bereichs ermittelt werden.
+ rVirtPgNo = 0;
+ USHORT nPos = GetCntnt();
+ SwClientIter aIter( (SwModify &)GetFld()->GetTxtNode() );
+ for( SwTxtFrm* pFrm = (SwTxtFrm*)aIter.First( TYPE( SwFrm ));
+ pFrm; pFrm = (SwTxtFrm*)aIter.Next() )
+ {
+ if( pFrm->GetOfst() > nPos ||
+ (pFrm->HasFollow() && pFrm->GetFollow()->GetOfst() <= nPos) )
+ continue;
+ USHORT nPgNo = pFrm->GetPhyPageNum();
+ if( rRangeEnum.hasValue( nPgNo, &rPossiblePages ))
+ {
+ rLineNo = (USHORT)(pFrm->GetLineCount( nPos ) +
+ pFrm->GetAllLines() - pFrm->GetThisLines());
+ rVirtPgNo = pFrm->GetVirtPageNum();
+ return nPgNo;
+ }
+ }
+ return 0;
+}
+
+
+bool lcl_GetPostIts(
+ IDocumentFieldsAccess* pIDFA,
+ _SetGetExpFlds * pSrtLst )
+{
+ bool bHasPostIts = false;
+
+ SwFieldType* pFldType = pIDFA->GetSysFldType( RES_POSTITFLD );
+ DBG_ASSERT( pFldType, "kein PostItType ? ");
+
+ if( pFldType->GetDepends() )
+ {
+ // Modify-Object gefunden, trage alle Felder ins Array ein
+ SwClientIter aIter( *pFldType );
+ SwClient* pLast;
+ const SwTxtFld* pTxtFld;
+
+ for( pLast = aIter.First( TYPE(SwFmtFld)); pLast; pLast = aIter.Next() )
+ {
+ if( 0 != ( pTxtFld = ((SwFmtFld*)pLast)->GetTxtFld() ) &&
+ pTxtFld->GetTxtNode().GetNodes().IsDocNodes() )
+ {
+ bHasPostIts = true;
+ if (pSrtLst)
+ {
+ SwNodeIndex aIdx( pTxtFld->GetTxtNode() );
+ _PostItFld* pNew = new _PostItFld( aIdx, pTxtFld );
+ pSrtLst->Insert( pNew );
+ }
+ else
+ break; // we just wanted to check for the existence of postits ...
+ }
+ }
+ }
+
+ return bHasPostIts;
+}
+
+
+static void lcl_FormatPostIt(
+ IDocumentContentOperations* pIDCO,
+ SwPaM& aPam,
+ SwPostItField* pField,
+ bool bNewPage, bool bIsFirstPostIt,
+ USHORT nPageNo, USHORT nLineNo )
+{
+ static char __READONLY_DATA sTmp[] = " : ";
+
+ DBG_ASSERT( ViewShell::GetShellRes(), "missing ShellRes" );
+
+ if (bNewPage)
+ {
+ pIDCO->InsertPoolItem( aPam, SvxFmtBreakItem( SVX_BREAK_PAGE_AFTER, RES_BREAK ), 0 );
+ pIDCO->SplitNode( *aPam.GetPoint(), false );
+ }
+ else if (!bIsFirstPostIt)
+ {
+ // add an empty line between different notes
+ pIDCO->SplitNode( *aPam.GetPoint(), false );
+ pIDCO->SplitNode( *aPam.GetPoint(), false );
+ }
+
+ String aStr( ViewShell::GetShellRes()->aPostItPage );
+ aStr.AppendAscii(sTmp);
+
+ aStr += XubString::CreateFromInt32( nPageNo );
+ aStr += ' ';
+ if( nLineNo )
+ {
+ aStr += ViewShell::GetShellRes()->aPostItLine;
+ aStr.AppendAscii(sTmp);
+ aStr += XubString::CreateFromInt32( nLineNo );
+ aStr += ' ';
+ }
+ aStr += ViewShell::GetShellRes()->aPostItAuthor;
+ aStr.AppendAscii(sTmp);
+ aStr += pField->GetPar1();
+ aStr += ' ';
+ SvtSysLocale aSysLocale;
+ aStr += /*(LocaleDataWrapper&)*/aSysLocale.GetLocaleData().getDate( pField->GetDate() );
+ pIDCO->InsertString( aPam, aStr );
+
+ pIDCO->SplitNode( *aPam.GetPoint(), false );
+ aStr = pField->GetPar2();
+#if defined( WIN ) || defined( WNT ) || defined( PM2 )
+ // Bei Windows und Co alle CR rausschmeissen
+ aStr.EraseAllChars( '\r' );
+#endif
+ pIDCO->InsertString( aPam, aStr );
+}
+
+
+void SwDoc::CalculatePagesForPrinting(
+ /* out */ SwRenderData &rData,
+ const SwPrintUIOptions &rOptions,
+ bool bIsPDFExport,
+ sal_Int32 nDocPageCount )
+{
+ DBG_ASSERT( pLayout, "no layout present" );
+ if (!pLayout)
+ return;
+
+ // properties to take into account when calcualting the set of pages
+ // (PDF export UI does not allow for selecting left or right pages only)
+ bool bPrintLeftPages = bIsPDFExport ? true : rOptions.IsPrintLeftPages();
+ bool bPrintRightPages = bIsPDFExport ? true : rOptions.IsPrintRightPages();
+ bool bPrintEmptyPages = rOptions.IsPrintEmptyPages( bIsPDFExport );
+
+ Range aPages( 1, nDocPageCount );
+
+ MultiSelection aMulti( aPages );
+ aMulti.SetTotalRange( Range( 0, RANGE_MAX ) );
+ aMulti.Select( aPages );
+
+ const SwPageFrm *pStPage = (SwPageFrm*)pLayout->Lower();
+ const SwFrm *pEndPage = pStPage;
+
+ USHORT nFirstPageNo = 0;
+ USHORT nLastPageNo = 0;
+ USHORT nPageNo = 1;
+
+ for( USHORT i = 1; i <= (USHORT)aPages.Max(); ++i )
+ {
+ if( i < (USHORT)aPages.Min() )
+ {
+ if( !pStPage->GetNext() )
+ break;
+ pStPage = (SwPageFrm*)pStPage->GetNext();
+ pEndPage= pStPage;
+ }
+ else if( i == (USHORT)aPages.Min() )
+ {
+ nFirstPageNo = i;
+ nLastPageNo = nFirstPageNo;
+ if( !pStPage->GetNext() || (i == (USHORT)aPages.Max()) )
+ break;
+ pEndPage = pStPage->GetNext();
+ }
+ else if( i > (USHORT)aPages.Min() )
+ {
+ nLastPageNo = i;
+ if( !pEndPage->GetNext() || (i == (USHORT)aPages.Max()) )
+ break;
+ pEndPage = pEndPage->GetNext();
+ }
+ }
+
+ DBG_ASSERT( nFirstPageNo, "first page not found! Should not happen!" );
+ if (nFirstPageNo)
+ {
+// HACK: Hier muss von der MultiSelection noch eine akzeptable Moeglichkeit
+// geschaffen werden, alle Seiten von Seite x an zu deselektieren.
+// Z.B. durch SetTotalRange ....
+
+// aMulti.Select( Range( nLastPageNo+1, SELECTION_MAX ), FALSE );
+ MultiSelection aTmpMulti( Range( 1, nLastPageNo ) );
+ long nTmpIdx = aMulti.FirstSelected();
+ static long nEndOfSelection = SFX_ENDOFSELECTION;
+ while ( nEndOfSelection != nTmpIdx && nTmpIdx <= long(nLastPageNo) )
+ {
+ aTmpMulti.Select( nTmpIdx );
+ nTmpIdx = aMulti.NextSelected();
+ }
+ aMulti = aTmpMulti;
+// Ende des HACKs
+
+ nPageNo = nFirstPageNo;
+
+ std::set< sal_Int32 > &rValidPages = rData.GetValidPagesSet();
+ std::map< sal_Int32, const SwPageFrm * > &rValidStartFrms = rData.GetValidStartFrames();
+ rValidPages.clear();
+ rValidStartFrms.clear();
+ while ( pStPage )
+ {
+ const BOOL bRightPg = pStPage->OnRightPage();
+ if ( aMulti.IsSelected( nPageNo ) &&
+ ( (bRightPg && bPrintRightPages) ||
+ (!bRightPg && bPrintLeftPages) ) )
+ {
+ // --> FME 2005-12-12 #b6354161# Feature - Print empty pages
+ if ( bPrintEmptyPages || pStPage->Frm().Height() )
+ // <--
+ {
+ // pStPage->GetUpper()->Paint( pStPage->Frm() );
+ rValidPages.insert( nPageNo );
+ rValidStartFrms[ nPageNo ] = pStPage;
+ }
+ }
+
+ if ( pStPage == pEndPage )
+ {
+ pStPage = 0;
+ }
+ else
+ { ++nPageNo;
+ pStPage = (SwPageFrm*)pStPage->GetNext();
+ }
+ }
+ }
+
+
+ //
+ // now that we have identified the valid pages for printing according
+ // to the print settings we need to get the PageRange to use and
+ // use both results to get the actual pages to be printed
+ // (post-it settings need to be taken into account later on!)
+ //
+
+ // get PageRange value to use
+ OUString aPageRange;
+ if (bIsPDFExport)
+ {
+ // ?? rOptions.getValue( C2U("Selection") );
+ aPageRange = rOptions.getStringValue( "PageRange", OUString() );
+ }
+ else
+ {
+ // PageContent :
+ // 0 -> print all pages (default if aPageRange is empty)
+ // 1 -> print range according to PageRange
+ // 2 -> print selection
+ const sal_Int32 nContent = rOptions.getIntValue( "PrintContent", 0 );
+ if (1 == nContent)
+ aPageRange = rOptions.getStringValue( "PageRange", OUString() );
+ if (2 == nContent)
+ {
+ // note that printing selections is actually implemented by copying
+ // the selection to a new temporary document and printing all of that one.
+ // Thus for Writer "PrintContent" must never be 2.
+ // See SwXTextDocument::GetRenderDoc for evaluating if a selection is to be
+ // printed and for creating the temporary document.
+ }
+
+ // please note
+ }
+ if (aPageRange.getLength() == 0) // empty string -> print all
+ {
+ // set page range to print to 'all pages'
+ aPageRange = OUString::valueOf( (sal_Int32)1 );
+ aPageRange += OUString::valueOf( (sal_Unicode)'-');
+ aPageRange += OUString::valueOf( nDocPageCount );
+ }
+ rData.SetPageRange( aPageRange );
+
+ // get vector of pages to print according to PageRange and valid pages set from above
+ // (result may be an empty vector, for example if the range string is not correct)
+ StringRangeEnumerator::getRangesFromString(
+ aPageRange, rData.GetPagesToPrint(),
+ 1, nDocPageCount, 0, &rData.GetValidPagesSet() );
+}
+
+
+void SwDoc::UpdatePagesForPrintingWithPostItData(
+ /* out */ SwRenderData &rData,
+ const SwPrintUIOptions &rOptions,
+ bool /*bIsPDFExport*/,
+ sal_Int32 nDocPageCount )
+{
+
+ sal_Int16 nPostItMode = (sal_Int16) rOptions.getIntValue( "PrintAnnotationMode", 0 );
+ DBG_ASSERT(nPostItMode == POSTITS_NONE || rData.HasPostItData(),
+ "print post-its without post-it data?" );
+ const USHORT nPostItCount = rData.HasPostItData() ? rData.m_pPostItFields->Count() : 0;
+ if (nPostItMode != POSTITS_NONE && nPostItCount > 0)
+ {
+ SET_CURR_SHELL( rData.m_pPostItShell );
+
+ // clear document and move to end of it
+ SwPaM aPam( rData.m_pPostItDoc->GetNodes().GetEndOfContent() );
+ aPam.Move( fnMoveBackward, fnGoDoc );
+ aPam.SetMark();
+ aPam.Move( fnMoveForward, fnGoDoc );
+ rData.m_pPostItDoc->DeleteRange( aPam );
+
+ const StringRangeEnumerator aRangeEnum( rData.GetPageRange(), 1, nDocPageCount, 0 );
+
+ // For mode POSTITS_ENDPAGE:
+ // maps a physical page number to the page number in post-it document that holds
+ // the first post-it for that physical page . Needed to relate the correct start frames
+ // from the post-it doc to the physical page of the document
+ std::map< sal_Int32, sal_Int32 > aPostItLastStartPageNum;
+
+ // add all post-its on valid pages within the the page range to the
+ // temporary post-it document.
+ // Since the array of post-it fileds is sorted by page and line number we will
+ // already get them in the correct order
+ USHORT nVirtPg = 0, nLineNo = 0, nLastPageNum = 0, nPhyPageNum = 0;
+ bool bIsFirstPostIt = true;
+ for (USHORT i = 0; i < nPostItCount; ++i)
+ {
+ _PostItFld& rPostIt = (_PostItFld&)*(*rData.m_pPostItFields)[ i ];
+ nLastPageNum = nPhyPageNum;
+ nPhyPageNum = rPostIt.GetPageNo(
+ aRangeEnum, rData.GetValidPagesSet(), nVirtPg, nLineNo );
+ if (nPhyPageNum)
+ {
+ // need to insert a page break?
+ // In POSTITS_ENDPAGE mode for each document page the following
+ // post-it page needs to start on a new page
+ const bool bNewPage = nPostItMode == POSTITS_ENDPAGE &&
+ !bIsFirstPostIt && nPhyPageNum != nLastPageNum;
+
+ lcl_FormatPostIt( rData.m_pPostItShell->GetDoc(), aPam,
+ rPostIt.GetPostIt(), bNewPage, bIsFirstPostIt, nVirtPg, nLineNo );
+ bIsFirstPostIt = false;
+
+ if (nPostItMode == POSTITS_ENDPAGE)
+ {
+ // get the correct number of current pages for the post-it document
+ rData.m_pPostItShell->CalcLayout();
+ const sal_Int32 nPages = rData.m_pPostItDoc->GetPageCount();
+ aPostItLastStartPageNum[ nPhyPageNum ] = nPages;
+ }
+ }
+ }
+
+ // format post-it doc to get correct number of pages
+ rData.m_pPostItShell->CalcLayout();
+ const sal_Int32 nPostItDocPageCount = rData.m_pPostItDoc->GetPageCount();
+
+ if (nPostItMode == POSTITS_ONLY || nPostItMode == POSTITS_ENDDOC)
+ {
+ // now add those post-it pages to the vector of pages to print
+ // or replace them if only post-its should be printed
+
+ rData.GetPostItStartFrames().clear();
+ if (nPostItMode == POSTITS_ENDDOC)
+ {
+ // set all values up to number of pages to print currently known to NULL,
+ // meaning none of the pages currently in the vector is from the
+ // post-it document, they are the documents pages.
+ rData.GetPostItStartFrames().resize( rData.GetPagesToPrint().size() );
+ }
+ else if (nPostItMode == POSTITS_ONLY)
+ {
+ // no document page to be printed
+ rData.GetPagesToPrint().clear();
+ }
+
+ // now we just need to add the post-it pages to be printed to the end
+ // of the vector of pages to print and keep the GetValidStartFrames
+ // data conform with it
+ sal_Int32 nPageNum = 0;
+ const SwPageFrm * pPageFrm = (SwPageFrm*)rData.m_pPostItShell->GetLayout()->Lower();
+ while( pPageFrm && nPageNum < nPostItDocPageCount )
+ {
+ DBG_ASSERT( pPageFrm, "Empty page frame. How are we going to print this?" );
+ ++nPageNum;
+ rData.GetPagesToPrint().push_back( 0 ); // a page number of 0 indicates this page is from the post-it doc
+ DBG_ASSERT( pPageFrm, "pPageFrm is NULL!" );
+ rData.GetPostItStartFrames().push_back( pPageFrm );
+ pPageFrm = (SwPageFrm*)pPageFrm->GetNext();
+ }
+ DBG_ASSERT( nPageNum == nPostItDocPageCount, "unexpected number of pages" );
+ }
+ else if (nPostItMode == POSTITS_ENDPAGE)
+ {
+ // the next step is to find all the start frames from the post-it
+ // document that should be printed for a given physical page of the document
+ std::map< sal_Int32, std::vector< const SwPageFrm * > > aPhysPageToPostItFrames;
+
+ // ... thus, first collect all post-it doc start frames in a vector
+ sal_Int32 nPostItPageNum = 0;
+ std::vector< const SwPageFrm * > aAllPostItStartFrames;
+ const SwPageFrm * pPageFrm = (SwPageFrm*)rData.m_pPostItShell->GetLayout()->Lower();
+ while( pPageFrm && sal_Int32(aAllPostItStartFrames.size()) < nPostItDocPageCount )
+ {
+ DBG_ASSERT( pPageFrm, "Empty page frame. How are we going to print this?" );
+ ++nPostItPageNum;
+ aAllPostItStartFrames.push_back( pPageFrm );
+ pPageFrm = (SwPageFrm*)pPageFrm->GetNext();
+ }
+ DBG_ASSERT( sal_Int32(aAllPostItStartFrames.size()) == nPostItDocPageCount,
+ "unexpected number of frames; does not match number of pages" );
+
+ // get a map that holds all post-it frames to be printed for a
+ // given physical page from the document
+ sal_Int32 nLastStartPageNum = 0;
+ std::map< sal_Int32, sal_Int32 >::const_iterator aIt;
+ for (aIt = aPostItLastStartPageNum.begin(); aIt != aPostItLastStartPageNum.end(); ++aIt)
+ {
+ const sal_Int32 nFrames = aIt->second - nLastStartPageNum;
+ const sal_Int32 nFirstStartPageNum = aIt == aPostItLastStartPageNum.begin() ?
+ 1 : aIt->second - nFrames + 1;
+ DBG_ASSERT( 1 <= nFirstStartPageNum && nFirstStartPageNum <= nPostItDocPageCount,
+ "page number for first frame out of range" );
+ std::vector< const SwPageFrm * > aStartFrames;
+ for (sal_Int32 i = 0; i < nFrames; ++i)
+ {
+ const sal_Int32 nIdx = nFirstStartPageNum - 1 + i; // -1 because lowest page num is 1
+ DBG_ASSERT( 0 <= nIdx && nIdx < sal_Int32(aAllPostItStartFrames.size()),
+ "index out of range" );
+ aStartFrames.push_back( aAllPostItStartFrames[ nIdx ] );
+ }
+ aPhysPageToPostItFrames[ aIt->first /* phys page num */ ] = aStartFrames;
+ nLastStartPageNum = aIt->second;
+ }
+
+
+ // ok, now that aPhysPageToPostItFrames can give the start frames for all
+ // post-it pages to be printed we need to merge those at the correct
+ // position into the GetPagesToPrint vector and build and maintain the
+ // GetValidStartFrames vector as well.
+ // Since inserting a larger number of entries in the middle of a vector
+ // isn't that efficient we will create new vectors by copying the required data
+ std::vector< sal_Int32 > aTmpPagesToPrint;
+ std::vector< const SwPageFrm * > aTmpPostItStartFrames;
+ const size_t nNum = rData.GetPagesToPrint().size();
+ for (size_t i = 0 ; i < nNum; ++i)
+ {
+ // add the physical page to print from the document
+ const sal_Int32 nPhysPage = rData.GetPagesToPrint()[i];
+ aTmpPagesToPrint.push_back( nPhysPage );
+ aTmpPostItStartFrames.push_back( NULL );
+
+ // add the post-it document pages to print, i.e those
+ // post-it pages that have the data for the above physical page
+ const std::vector< const SwPageFrm * > &rPostItFrames = aPhysPageToPostItFrames[ nPhysPage ];
+ const size_t nPostItFrames = rPostItFrames.size();
+ for (size_t k = 0; k < nPostItFrames; ++k)
+ {
+ aTmpPagesToPrint.push_back( 0 );
+ aTmpPostItStartFrames.push_back( rPostItFrames[k] );
+ }
+ }
+
+ // finally we need to assign those vectors to the resulting ones.
+ // swapping the data should be more efficient than assigning since
+ // we won't need the temporary vectors anymore
+ rData.GetPagesToPrint().swap( aTmpPagesToPrint );
+ rData.GetPostItStartFrames().swap( aTmpPostItStartFrames );
+ }
+ }
+}
+
+
+void SwDoc::CalculatePagePairsForProspectPrinting(
+ /* out */ SwRenderData &rData,
+ const SwPrintUIOptions &rOptions,
+ sal_Int32 nDocPageCount )
+{
+ std::set< sal_Int32 > &rValidPagesSet = rData.GetValidPagesSet();
+ std::map< sal_Int32, const SwPageFrm * > &rValidStartFrms = rData.GetValidStartFrames();
+ std::vector< std::pair< sal_Int32, sal_Int32 > > &rPagePairs = rData.GetPagePairsForProspectPrinting();
+
+ rPagePairs.clear();
+ rValidPagesSet.clear();
+ rValidStartFrms.clear();
+
+ rtl::OUString aPageRange = rOptions.getStringValue( "PageRange", rtl::OUString() );
+ StringRangeEnumerator aRange( aPageRange, 1, nDocPageCount, 0 );
+
+ DBG_ASSERT( pLayout, "no layout present" );
+ if (!pLayout || aRange.size() <= 0)
+ return;
+
+ const SwPageFrm *pStPage = (SwPageFrm*)pLayout->Lower();
+ sal_Int32 i = 0;
+ for ( i = 1; pStPage && i < nDocPageCount; ++i )
+ pStPage = (SwPageFrm*)pStPage->GetNext();
+ if ( !pStPage ) // dann wars das
+ return;
+
+ // currently for prospect printing all pages are valid to be printed
+ // thus we add them all to the respective map and set for later use
+ sal_Int32 nPageNum = 0;
+ const SwPageFrm *pPageFrm = (SwPageFrm*)pLayout->Lower();
+ while( pPageFrm && nPageNum < nDocPageCount )
+ {
+ DBG_ASSERT( pPageFrm, "Empty page frame. How are we going to print this?" );
+ ++nPageNum;
+ rValidPagesSet.insert( nPageNum );
+ rValidStartFrms[ nPageNum ] = pPageFrm;
+ pPageFrm = (SwPageFrm*)pPageFrm->GetNext();
+ }
+ DBG_ASSERT( nPageNum == nDocPageCount, "unexpected number of pages" );
+
+ // properties to take into account when calcualting the set of pages
+ // Note: here bPrintLeftPages and bPrintRightPages refer to the (virtual) resulting pages
+ // of the prospect!
+ bool bPrintLeftPages = rOptions.IsPrintLeftPages();
+ bool bPrintRightPages = rOptions.IsPrintRightPages();
+ bool bPrintProspectRTL = rOptions.getIntValue( "PrintProspectRTL", 0 ) ? true : false;
+
+ // get pages for prospect printing according to the 'PageRange'
+ // (duplicates and any order allowed!)
+ std::vector< sal_Int32 > aPagesToPrint;
+ StringRangeEnumerator::getRangesFromString(
+ aPageRange, aPagesToPrint, 1, nDocPageCount, 0 );
+
+ // now fill the vector for calculating the page pairs with the start frames
+ // from the above obtained vector
+ std::vector< const SwPageFrm * > aVec;
+ for ( i = 0; i < sal_Int32(aPagesToPrint.size()); ++i)
+ {
+ const sal_Int32 nPage = aPagesToPrint[i];
+ const SwPageFrm *pFrm = rValidStartFrms[ nPage ];
+ aVec.push_back( pFrm );
+ }
+
+ // just one page is special ...
+ if ( 1 == aVec.size() )
+ aVec.insert( aVec.begin() + 1, 0 ); // insert a second empty page
+ else
+ {
+ // now extend the number of pages to fit a multiple of 4
+ // (4 'normal' pages are needed for a single prospect paper
+ // with back and front)
+ while( aVec.size() & 3 )
+ aVec.push_back( 0 );
+ }
+
+ // dann sorge mal dafuer, das alle Seiten in der richtigen
+ // Reihenfolge stehen:
+ USHORT nSPg = 0, nEPg = aVec.size(), nStep = 1;
+ if ( 0 == (nEPg & 1 )) // ungerade gibt es nicht!
+ --nEPg;
+
+ if ( !bPrintLeftPages )
+ ++nStep;
+ else if ( !bPrintRightPages )
+ {
+ ++nStep;
+ ++nSPg, --nEPg;
+ }
+
+ // the number of 'virtual' pages to be printed
+ sal_Int32 nCntPage = (( nEPg - nSPg ) / ( 2 * nStep )) + 1;
+
+ for ( USHORT nPrintCount = 0; nSPg < nEPg &&
+ nPrintCount < nCntPage; ++nPrintCount )
+ {
+ pStPage = aVec[ nSPg ];
+ const SwPageFrm* pNxtPage = nEPg < aVec.size() ? aVec[ nEPg ] : 0;
+
+ short nRtlOfs = bPrintProspectRTL ? 1 : 0;
+ if ( 0 == (( nSPg + nRtlOfs) & 1 ) ) // switch for odd number in LTR, even number in RTL
+ {
+ const SwPageFrm* pTmp = pStPage;
+ pStPage = pNxtPage;
+ pNxtPage = pTmp;
+ }
+
+ sal_Int32 nFirst = -1, nSecond = -1;
+ for ( int nC = 0; nC < 2; ++nC )
+ {
+ sal_Int32 nPage = -1;
+ if ( pStPage )
+ nPage = pStPage->GetPhyPageNum();
+ if (nC == 0)
+ nFirst = nPage;
+ else
+ nSecond = nPage;
+
+ pStPage = pNxtPage;
+ }
+ rPagePairs.push_back( std::pair< sal_Int32, sal_Int32 >(nFirst, nSecond) );
+
+ nSPg = nSPg + nStep;
+ nEPg = nEPg - nStep;
+ }
+ DBG_ASSERT( size_t(nCntPage) == rPagePairs.size(), "size mismatch for number of page pairs" );
+
+ // luckily prospect printing does not make use of post-its so far,
+ // thus we are done here.
+}
+
+
sal_uInt16 SwDoc::GetPageCount() const
{
return GetRootFrm() ? GetRootFrm()->GetPageNum() : 0;
diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx
index 7a7d423c1cb2..5a30fa55edc2 100644
--- a/sw/source/core/doc/docdesc.cxx
+++ b/sw/source/core/doc/docdesc.cxx
@@ -39,6 +39,7 @@
#include "editeng/frmdiritem.hxx"
#include <tools/urlobj.hxx>
#include <sfx2/docfile.hxx>
+#include <sfx2/printer.hxx>
#include <unotools/localedatawrapper.hxx>
#include <com/sun/star/document/PrinterIndependentLayout.hpp>
#include <fmtfsize.hxx>
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 449b02f4af61..728c8f6c1f3c 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -46,6 +46,7 @@
#include <sfx2/printer.hxx>
#include <sfx2/docfile.hxx>
#include <sfx2/frame.hxx>
+#include <sfx2/viewfrm.hxx>
#include <svl/macitem.hxx>
#include <svx/svxids.hrc>
@@ -169,15 +170,33 @@ SV_IMPL_PTRARR( SwGrfFmtColls, SwGrfFmtCollPtr)
void StartGrammarChecking( SwDoc &rDoc )
{
- uno::Reference< linguistic2::XProofreadingIterator > xGCIterator( rDoc.GetGCIterator() );
- if ( xGCIterator.is() )
+ // check for a visible view
+ bool bVisible = false;
+ const SwDocShell *pDocShell = rDoc.GetDocShell();
+ SfxViewFrame *pFrame = SfxViewFrame::GetFirst( pDocShell, 0, sal_False );
+ while (pFrame && !bVisible)
{
- uno::Reference< lang::XComponent > xDoc( rDoc.GetDocShell()->GetBaseModel(), uno::UNO_QUERY );
- uno::Reference< text::XFlatParagraphIteratorProvider > xFPIP( xDoc, uno::UNO_QUERY );
+ if (pFrame->IsVisible())
+ bVisible = true;
+ pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell, 0, sal_False );
+ }
- // start automatic background checking if not active already
- if ( xFPIP.is() && !xGCIterator->isProofreading( xDoc ) )
- xGCIterator->startProofreading( xDoc, xFPIP );
+ //!! only documents with visible views need to be checked
+ //!! (E.g. don't check temporary documents created for printing, see printing of notes and selections.
+ //!! Those get created on the fly and get hard deleted a bit later as well, and no one should have
+ //!! a uno reference to them)
+ if (bVisible)
+ {
+ uno::Reference< linguistic2::XProofreadingIterator > xGCIterator( rDoc.GetGCIterator() );
+ if ( xGCIterator.is() )
+ {
+ uno::Reference< lang::XComponent > xDoc( rDoc.GetDocShell()->GetBaseModel(), uno::UNO_QUERY );
+ uno::Reference< text::XFlatParagraphIteratorProvider > xFPIP( xDoc, uno::UNO_QUERY );
+
+ // start automatic background checking if not active already
+ if ( xFPIP.is() && !xGCIterator->isProofreading( xDoc ) )
+ xGCIterator->startProofreading( xDoc, xFPIP );
+ }
}
}
diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx
index 136415616777..6e01f4967e34 100644
--- a/sw/source/core/doc/notxtfrm.cxx
+++ b/sw/source/core/doc/notxtfrm.cxx
@@ -269,7 +269,7 @@ void lcl_ClearArea( const SwFrm &rFrm,
|*
*************************************************************************/
-void SwNoTxtFrm::Paint( const SwRect &rRect ) const
+void SwNoTxtFrm::Paint( const SwRect &rRect, const SwPrtOptions * /*pPrintData*/ ) const
{
if ( Frm().IsEmpty() )
return;
@@ -804,27 +804,27 @@ void lcl_correctlyAlignRect( SwRect& rAlignedGrfArea, const SwRect& rInArea, Out
{
if(!pOut)
return;
- Rectangle aPxRect = pOut->LogicToPixel( rInArea.SVRect() );
- Rectangle aNewPxRect( aPxRect );
- while( aNewPxRect.Left() < aPxRect.Left() )
- {
- rAlignedGrfArea.Left( rAlignedGrfArea.Left()+1 );
- aNewPxRect = pOut->LogicToPixel( rAlignedGrfArea.SVRect() );
- }
- while( aNewPxRect.Top() < aPxRect.Top() )
- {
- rAlignedGrfArea.Top( rAlignedGrfArea.Top()+1 );
- aNewPxRect = pOut->LogicToPixel( rAlignedGrfArea.SVRect() );
- }
- while( aNewPxRect.Bottom() > aPxRect.Bottom() )
- {
- rAlignedGrfArea.Bottom( rAlignedGrfArea.Bottom()-1 );
- aNewPxRect = pOut->LogicToPixel( rAlignedGrfArea.SVRect() );
- }
- while( aNewPxRect.Right() > aPxRect.Right() )
- {
- rAlignedGrfArea.Right( rAlignedGrfArea.Right()-1 );
- aNewPxRect = pOut->LogicToPixel( rAlignedGrfArea.SVRect() );
+ Rectangle aPxRect = pOut->LogicToPixel( rInArea.SVRect() );
+ Rectangle aNewPxRect( aPxRect );
+ while( aNewPxRect.Left() < aPxRect.Left() )
+ {
+ rAlignedGrfArea.Left( rAlignedGrfArea.Left()+1 );
+ aNewPxRect = pOut->LogicToPixel( rAlignedGrfArea.SVRect() );
+ }
+ while( aNewPxRect.Top() < aPxRect.Top() )
+ {
+ rAlignedGrfArea.Top( rAlignedGrfArea.Top()+1 );
+ aNewPxRect = pOut->LogicToPixel( rAlignedGrfArea.SVRect() );
+ }
+ while( aNewPxRect.Bottom() > aPxRect.Bottom() )
+ {
+ rAlignedGrfArea.Bottom( rAlignedGrfArea.Bottom()-1 );
+ aNewPxRect = pOut->LogicToPixel( rAlignedGrfArea.SVRect() );
+ }
+ while( aNewPxRect.Right() > aPxRect.Right() )
+ {
+ rAlignedGrfArea.Right( rAlignedGrfArea.Right()-1 );
+ aNewPxRect = pOut->LogicToPixel( rAlignedGrfArea.SVRect() );
}
}
@@ -861,13 +861,13 @@ void SwNoTxtFrm::PaintPicture( OutputDevice* pOut, const SwRect &rGrfArea ) cons
::SwAlignGrfRect( &aAlignedGrfArea, *pOut );
}
else //if( bIsChart )
- {
- //#i78025# charts own borders are not completely visible
- //the above pixel correction is not correct - at least not for charts
- //so a different pixel correction is choosen here
- //this might be a good idea for all other OLE objects also,
- //but as I cannot oversee the consequences I fix it only for charts for now
- lcl_correctlyAlignRect( aAlignedGrfArea, rGrfArea, pOut );
+ {
+ //#i78025# charts own borders are not completely visible
+ //the above pixel correction is not correct - at least not for charts
+ //so a different pixel correction is choosen here
+ //this might be a good idea for all other OLE objects also,
+ //but as I cannot oversee the consequences I fix it only for charts for now
+ lcl_correctlyAlignRect( aAlignedGrfArea, rGrfArea, pOut );
}
if( pGrfNd )
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index cf86b47fcc58..c1f62224f4a5 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -44,7 +44,6 @@
#include <svx/svdviter.hxx>
#include <svx/svdview.hxx>
#include <svx/shapepropertynotifier.hxx>
-// AW, OD 2004-04-30 #i28501#
#include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
#include <svx/sdr/contact/displayinfo.hxx>
#include <fmtornt.hxx>
@@ -69,31 +68,17 @@
#include <txtfrm.hxx>
#include <editsh.hxx>
#include <docary.hxx>
-
-// OD 2004-02-11 #110582#-2
#include <flyfrms.hxx>
-
-// OD 18.06.2003 #108784#
-#include <algorithm>
-// OD 2004-05-24 #i28701#
#include <sortedobjs.hxx>
#include <basegfx/matrix/b2dhommatrix.hxx>
-
-// AW: For VCOfDrawVirtObj and stuff
-#ifndef _SDR_CONTACT_VIEWCONTACTOFVIRTOBJ_HXX
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
#include <svx/sdr/contact/viewcontactofvirtobj.hxx>
-#endif
-
-#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_TRANSFORMPRIMITIVE2D_HXX
#include <drawinglayer/primitive2d/transformprimitive2d.hxx>
-#endif
-
-#ifndef _SDR_CONTACT_VIEWOBJECTCONTACTOFSDROBJ_HXX
#include <svx/sdr/contact/viewobjectcontactofsdrobj.hxx>
-#endif
-
#include <com/sun/star/text/WritingMode2.hpp>
+#include <algorithm>
+
using namespace ::com::sun::star;
@@ -2605,9 +2590,7 @@ void SwDrawVirtObj::RecalcBoundRect()
basegfx::B2DPolyPolygon SwDrawVirtObj::TakeXorPoly() const
{
basegfx::B2DPolyPolygon aRetval(rRefObj.TakeXorPoly());
- basegfx::B2DHomMatrix aMatrix;
- aMatrix.translate(GetOffset().X(), GetOffset().Y());
- aRetval.transform(aMatrix);
+ aRetval.transform(basegfx::tools::createTranslateB2DHomMatrix(GetOffset().X(), GetOffset().Y()));
return aRetval;
}
@@ -2615,9 +2598,7 @@ basegfx::B2DPolyPolygon SwDrawVirtObj::TakeXorPoly() const
basegfx::B2DPolyPolygon SwDrawVirtObj::TakeContour() const
{
basegfx::B2DPolyPolygon aRetval(rRefObj.TakeContour());
- basegfx::B2DHomMatrix aMatrix;
- aMatrix.translate(GetOffset().X(), GetOffset().Y());
- aRetval.transform(aMatrix);
+ aRetval.transform(basegfx::tools::createTranslateB2DHomMatrix(GetOffset().X(), GetOffset().Y()));
return aRetval;
}
diff --git a/sw/source/core/draw/dflyobj.cxx b/sw/source/core/draw/dflyobj.cxx
index b43e15be3111..9c66f5c6a151 100644
--- a/sw/source/core/draw/dflyobj.cxx
+++ b/sw/source/core/draw/dflyobj.cxx
@@ -196,7 +196,7 @@ namespace drawinglayer
{
namespace primitive2d
{
- class SwVirtFlyDrawObjPrimitive : public BasePrimitive2D
+ class SwVirtFlyDrawObjPrimitive : public BufferedDecompositionPrimitive2D
{
private:
const SwVirtFlyDrawObj& mrSwVirtFlyDrawObj;
@@ -204,13 +204,13 @@ namespace drawinglayer
protected:
// method which is to be used to implement the local decomposition of a 2D primitive
- virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
+ virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
public:
SwVirtFlyDrawObjPrimitive(
const SwVirtFlyDrawObj& rSwVirtFlyDrawObj,
const basegfx::B2DRange &rOuterRange)
- : BasePrimitive2D(),
+ : BufferedDecompositionPrimitive2D(),
mrSwVirtFlyDrawObj(rSwVirtFlyDrawObj),
maOuterRange(rOuterRange)
{
@@ -239,7 +239,7 @@ namespace drawinglayer
{
namespace primitive2d
{
- Primitive2DSequence SwVirtFlyDrawObjPrimitive::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
+ Primitive2DSequence SwVirtFlyDrawObjPrimitive::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
{
Primitive2DSequence aRetval;
@@ -269,7 +269,7 @@ namespace drawinglayer
bool SwVirtFlyDrawObjPrimitive::operator==(const BasePrimitive2D& rPrimitive) const
{
- if(BasePrimitive2D::operator==(rPrimitive))
+ if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
{
const SwVirtFlyDrawObjPrimitive& rCompare = (SwVirtFlyDrawObjPrimitive&)rPrimitive;
@@ -295,7 +295,7 @@ namespace drawinglayer
getSwVirtFlyDrawObj().wrap_DoPaintObject();
// call parent
- return BasePrimitive2D::get2DDecomposition(rViewInformation);
+ return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation);
}
// provide unique ID
diff --git a/sw/source/core/fields/dbfld.cxx b/sw/source/core/fields/dbfld.cxx
index 7c6b991be535..642ca2ed2fdc 100644
--- a/sw/source/core/fields/dbfld.cxx
+++ b/sw/source/core/fields/dbfld.cxx
@@ -96,6 +96,10 @@ SwDBFieldType::SwDBFieldType(SwDoc* pDocPtr, const String& rNam, const SwDBData&
sName += GetColumnName();
}
//------------------------------------------------------------------------------
+SwDBFieldType::~SwDBFieldType()
+{
+}
+//------------------------------------------------------------------------------
SwFieldType* SwDBFieldType::Copy() const
{
diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx
index 751dd2c006eb..8d19c82396a7 100644
--- a/sw/source/core/fields/docufld.cxx
+++ b/sw/source/core/fields/docufld.cxx
@@ -1368,7 +1368,8 @@ BOOL SwDocInfoField::PutValue( const uno::Any& rAny, USHORT nWhichId )
SwHiddenTxtFieldType::SwHiddenTxtFieldType( sal_Bool bSetHidden )
: SwFieldType( RES_HIDDENTXTFLD ), bHidden( bSetHidden )
-{}
+{
+}
SwFieldType* SwHiddenTxtFieldType::Copy() const
{
diff --git a/sw/source/core/inc/cellfrm.hxx b/sw/source/core/inc/cellfrm.hxx
index c8bbc7be70c6..0825ccc2dfd7 100644
--- a/sw/source/core/inc/cellfrm.hxx
+++ b/sw/source/core/inc/cellfrm.hxx
@@ -51,7 +51,7 @@ public:
virtual BOOL GetCrsrOfst( SwPosition *, Point&, SwCrsrMoveState* = 0 ) const;
virtual void Modify( SfxPoolItem*, SfxPoolItem* );
- virtual void Paint( const SwRect& ) const;
+ virtual void Paint( const SwRect&, const SwPrtOptions *pPrintData = NULL ) const;
virtual void CheckDirection( BOOL bVert );
const SwTableBox *GetTabBox() const { return pTabBox; }
diff --git a/sw/source/core/inc/flyfrm.hxx b/sw/source/core/inc/flyfrm.hxx
index 4e3c196814c6..65dc532f4667 100644
--- a/sw/source/core/inc/flyfrm.hxx
+++ b/sw/source/core/inc/flyfrm.hxx
@@ -161,7 +161,7 @@ public:
virtual void Modify( SfxPoolItem*, SfxPoolItem* );
// erfrage vom Client Informationen
virtual BOOL GetInfo( SfxPoolItem& ) const;
- virtual void Paint( const SwRect& ) const;
+ virtual void Paint( const SwRect&, const SwPrtOptions *pPrintData = NULL ) const;
virtual Size ChgSize( const Size& aNewSize );
virtual BOOL GetCrsrOfst( SwPosition *, Point&,
SwCrsrMoveState* = 0 ) const;
diff --git a/sw/source/core/inc/frame.hxx b/sw/source/core/inc/frame.hxx
index c9bbb72693ce..aa56e2db55d9 100644
--- a/sw/source/core/inc/frame.hxx
+++ b/sw/source/core/inc/frame.hxx
@@ -56,6 +56,7 @@ class SvxBrushItem;
class SwSelectionList;
struct SwPosition;
struct SwCrsrMoveState;
+class SwPrtOptions;
// --> OD 2004-07-06 #i28701#
class SwSortedObjs;
@@ -828,7 +829,7 @@ public:
SwCrsrMoveState* = 0 ) const;
virtual BOOL GetCharRect( SwRect &, const SwPosition&,
SwCrsrMoveState* = 0 ) const;
- virtual void Paint( const SwRect& ) const;
+ virtual void Paint( const SwRect&, const SwPrtOptions *pPrintData = NULL ) const;
// der "kurze Dienstweg" zwischen den Frames und der Formatierung.
// Wer den void* falsch Casted ist selbst schuld!
diff --git a/sw/source/core/inc/layfrm.hxx b/sw/source/core/inc/layfrm.hxx
index 76262d18a894..e3ee5edf60c1 100644
--- a/sw/source/core/inc/layfrm.hxx
+++ b/sw/source/core/inc/layfrm.hxx
@@ -108,7 +108,7 @@ public:
SwLayoutFrm( SwFrmFmt* );
~SwLayoutFrm();
- virtual void Paint( const SwRect& ) const;
+ virtual void Paint( const SwRect&, const SwPrtOptions *pPrintData = NULL ) const;
const SwFrm *Lower() const { return pLower; }
SwFrm *Lower() { return pLower; }
const SwCntntFrm *ContainsCntnt() const;
diff --git a/sw/source/core/inc/notxtfrm.hxx b/sw/source/core/inc/notxtfrm.hxx
index 81d63e733f9c..ff739b530758 100644
--- a/sw/source/core/inc/notxtfrm.hxx
+++ b/sw/source/core/inc/notxtfrm.hxx
@@ -59,7 +59,7 @@ public:
~SwNoTxtFrm();
virtual void Modify( SfxPoolItem*, SfxPoolItem* );
- virtual void Paint(const SwRect& ) const;
+ virtual void Paint(const SwRect&, const SwPrtOptions *pPrintData = NULL ) const;
virtual BOOL GetCharRect( SwRect &, const SwPosition&,
SwCrsrMoveState* = 0) const;
BOOL GetCrsrOfst(SwPosition* pPos, Point& aPoint,
diff --git a/sw/source/core/inc/rootfrm.hxx b/sw/source/core/inc/rootfrm.hxx
index be5b8acd22da..fd7f97dcb5b3 100644
--- a/sw/source/core/inc/rootfrm.hxx
+++ b/sw/source/core/inc/rootfrm.hxx
@@ -200,7 +200,7 @@ public:
virtual BOOL GetCrsrOfst( SwPosition *, Point&,
SwCrsrMoveState* = 0 ) const;
- virtual void Paint( const SwRect& ) const;
+ virtual void Paint( const SwRect&, const SwPrtOptions *pPrintData = NULL ) const;
virtual SwTwips ShrinkFrm( SwTwips, BOOL bTst = FALSE, BOOL bInfo = FALSE );
virtual SwTwips GrowFrm ( SwTwips, BOOL bTst = FALSE, BOOL bInfo = FALSE );
#ifdef DBG_UTIL
diff --git a/sw/source/core/inc/tabfrm.hxx b/sw/source/core/inc/tabfrm.hxx
index b41ba4214aa0..bbd2931d7839 100644
--- a/sw/source/core/inc/tabfrm.hxx
+++ b/sw/source/core/inc/tabfrm.hxx
@@ -132,7 +132,7 @@ public:
virtual void Modify( SfxPoolItem*, SfxPoolItem* );
virtual BOOL GetInfo( SfxPoolItem &rHnt ) const;
- virtual void Paint( const SwRect& ) const;
+ virtual void Paint( const SwRect&, const SwPrtOptions *pPrintData = NULL ) const;
virtual void CheckDirection( BOOL bVert );
virtual void Cut();
diff --git a/sw/source/core/inc/txtfrm.hxx b/sw/source/core/inc/txtfrm.hxx
index 79cd2a1a574c..dc91b188e439 100644
--- a/sw/source/core/inc/txtfrm.hxx
+++ b/sw/source/core/inc/txtfrm.hxx
@@ -296,7 +296,7 @@ public:
void PaintExtraData( const SwRect & rRect ) const; //Seitennummer usw.
SwRect Paint();
- virtual void Paint( const SwRect & ) const;
+ virtual void Paint( const SwRect &, const SwPrtOptions *pPrintData = NULL ) const;
virtual void Modify( SfxPoolItem*, SfxPoolItem* );
virtual sal_Bool GetInfo( SfxPoolItem & ) const;
diff --git a/sw/source/core/inc/viewimp.hxx b/sw/source/core/inc/viewimp.hxx
index eba323bd52a2..026b293a827c 100644
--- a/sw/source/core/inc/viewimp.hxx
+++ b/sw/source/core/inc/viewimp.hxx
@@ -57,6 +57,7 @@ struct SdrPaintProcRec;
class SwAccessibleMap;
class SdrObject;
class Fraction;
+class SwPrtOptions;
// OD 12.12.2002 #103492#
class SwPagePreviewLayout;
// OD 15.01.2003 #103492#
@@ -270,10 +271,11 @@ public:
// direction at the outliner of the draw view for painting layers <hell>
// and <heaven>.
// OD 25.06.2003 #108784# - correct type of 1st parameter
- void PaintLayer ( const SdrLayerID _nLayerID,
- const SwRect& _rRect,
- const Color* _pPageBackgrdColor = 0,
- const bool _bIsPageRightToLeft = false ) const;
+ void PaintLayer( const SdrLayerID _nLayerID,
+ const SwPrtOptions *pPrintData,
+ const SwRect& _rRect,
+ const Color* _pPageBackgrdColor = 0,
+ const bool _bIsPageRightToLeft = false ) const;
//wird als Link an die DrawEngine uebergeben, entscheidet was wie
//gepaintet wird oder nicht.
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index c6c21d61fbbc..df0393c3f213 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -2738,7 +2738,7 @@ void SwTabFrmPainter::Insert( SwLineEntry& rNew, bool bHori )
|*
|*************************************************************************/
-void SwRootFrm::Paint( const SwRect& rRect ) const
+void SwRootFrm::Paint( const SwRect& rRect, const SwPrtOptions *pPrintData ) const
{
ASSERT( Lower() && Lower()->IsPageFrm(), "Lower der Root keine Seite." );
@@ -2937,7 +2937,7 @@ void SwRootFrm::Paint( const SwRect& rRect ) const
// OD 29.08.2002 #102450# - add 3rd parameter
// OD 09.12.2002 #103045# - add 4th parameter for horizontal text direction.
const IDocumentDrawModelAccess* pIDDMA = pSh->getIDocumentDrawModelAccess();
- pSh->Imp()->PaintLayer( pIDDMA->GetHellId(), aPaintRect,
+ pSh->Imp()->PaintLayer( pIDDMA->GetHellId(), pPrintData, aPaintRect,
&aPageBackgrdColor, (pPage->IsRightToLeft() ? true : false) );
pLines->PaintLines( pSh->GetOut() );
pLines->LockLines( FALSE );
@@ -2970,7 +2970,7 @@ void SwRootFrm::Paint( const SwRect& rRect ) const
{
/// OD 29.08.2002 #102450# - add 3rd parameter
// OD 09.12.2002 #103045# - add 4th parameter for horizontal text direction.
- pSh->Imp()->PaintLayer( pSh->GetDoc()->GetHeavenId(), aPaintRect,
+ pSh->Imp()->PaintLayer( pSh->GetDoc()->GetHeavenId(), pPrintData, aPaintRect,
&aPageBackgrdColor,
(pPage->IsRightToLeft() ? true : false) );
}
@@ -3188,7 +3188,7 @@ SwShortCut::SwShortCut( const SwFrm& rFrm, const SwRect& rRect )
}
}
-void SwLayoutFrm::Paint( const SwRect& rRect ) const
+void SwLayoutFrm::Paint( const SwRect& rRect, const SwPrtOptions* /* pPrintData */ ) const
{
ViewShell *pSh = GetShell();
@@ -3476,7 +3476,7 @@ BOOL SwFlyFrm::IsPaint( SdrObject *pObj, const ViewShell *pSh )
/*************************************************************************
|* SwCellFrm::Paint( const SwRect& ) const
|*************************************************************************/
-void SwCellFrm::Paint( const SwRect& rRect ) const
+void SwCellFrm::Paint( const SwRect& rRect, const SwPrtOptions* /* pPrintData */ ) const
{
if ( GetLayoutRowSpan() >= 1 )
SwLayoutFrm::Paint( rRect );
@@ -3495,7 +3495,7 @@ void SwCellFrm::Paint( const SwRect& rRect ) const
void MA_FASTCALL lcl_PaintLowerBorders( const SwLayoutFrm *pLay,
const SwRect &rRect, const SwPageFrm *pPage );
-void SwFlyFrm::Paint( const SwRect& rRect ) const
+void SwFlyFrm::Paint( const SwRect& rRect, const SwPrtOptions* /* pPrintData */ ) const
{
//wegen der Ueberlappung von Rahmen und Zeichenobjekten muessen die
//Flys ihre Umrandung (und die der Innenliegenden) direkt ausgeben.
@@ -3730,7 +3730,7 @@ void SwFlyFrm::Paint( const SwRect& rRect ) const
|*
|*************************************************************************/
-void SwTabFrm::Paint( const SwRect& rRect ) const
+void SwTabFrm::Paint( const SwRect& rRect, const SwPrtOptions* /* pPrintData */ ) const
{
if ( pGlobalShell->GetViewOptions()->IsTable() )
{
@@ -6436,10 +6436,10 @@ void SwFrm::Retouche( const SwPageFrm * pPage, const SwRect &rRect ) const
// OD 09.12.2002 #103045# - add 4th parameter for horizontal text direction.
const IDocumentDrawModelAccess* pIDDMA = pSh->getIDocumentDrawModelAccess();
- pSh->Imp()->PaintLayer( pIDDMA->GetHellId(),
+ pSh->Imp()->PaintLayer( pIDDMA->GetHellId(), 0,
aRetouchePart, &aPageBackgrdColor,
(pPage->IsRightToLeft() ? true : false) );
- pSh->Imp()->PaintLayer( pIDDMA->GetHeavenId(),
+ pSh->Imp()->PaintLayer( pIDDMA->GetHeavenId(), 0,
aRetouchePart, &aPageBackgrdColor,
(pPage->IsRightToLeft() ? true : false) );
}
@@ -6689,14 +6689,14 @@ Graphic SwFlyFrmFmt::MakeGraphic( ImageMap* pMap )
// OD 30.08.2002 #102450# - add 3rd parameter
// OD 09.12.2002 #103045# - add 4th parameter for horizontal text direction.
const IDocumentDrawModelAccess* pIDDMA = pSh->getIDocumentDrawModelAccess();
- pImp->PaintLayer( pIDDMA->GetHellId(), aOut, &aPageBackgrdColor,
+ pImp->PaintLayer( pIDDMA->GetHellId(), 0, aOut, &aPageBackgrdColor,
(pFlyPage->IsRightToLeft() ? true : false) );
pLines->PaintLines( &aDev );
if ( pFly->IsFlyInCntFrm() )
pFly->Paint( aOut );
pLines->PaintLines( &aDev );
/// OD 30.08.2002 #102450# - add 3rd parameter
- pImp->PaintLayer( pIDDMA->GetHeavenId(), aOut, &aPageBackgrdColor,
+ pImp->PaintLayer( pIDDMA->GetHeavenId(), 0, aOut, &aPageBackgrdColor,
(pFlyPage->IsRightToLeft() ? true : false) );
pLines->PaintLines( &aDev );
DELETEZ( pLines );
diff --git a/sw/source/core/layout/unusedf.cxx b/sw/source/core/layout/unusedf.cxx
index 994a4d9ce625..bbbf10a0901f 100644
--- a/sw/source/core/layout/unusedf.cxx
+++ b/sw/source/core/layout/unusedf.cxx
@@ -44,7 +44,7 @@ void SwFrm::Format( const SwBorderAttrs * )
ASSERT( FALSE, "Format() der Basisklasse gerufen." );
}
-void SwFrm::Paint(const SwRect &) const
+void SwFrm::Paint(const SwRect &, const SwPrtOptions * ) const
{
ASSERT( FALSE, "Paint() der Basisklasse gerufen." );
}
diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index e24d96620509..ec856ca29f6c 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -101,6 +101,11 @@ SwFrm::SwFrm( SwModify *pMod ) :
pNext( 0 ),
pPrev( 0 ),
pDrawObjs( 0 )
+ , bInfBody( FALSE )
+ , bInfTab ( FALSE )
+ , bInfFly ( FALSE )
+ , bInfFtn ( FALSE )
+ , bInfSct ( FALSE )
{
#ifdef DBG_UTIL
bFlag01 = bFlag02 = bFlag03 = bFlag04 = bFlag05 = 0;
diff --git a/sw/source/core/text/frmpaint.cxx b/sw/source/core/text/frmpaint.cxx
index 0e6ab1d2cb27..6bef7bd3c02e 100644
--- a/sw/source/core/text/frmpaint.cxx
+++ b/sw/source/core/text/frmpaint.cxx
@@ -600,7 +600,7 @@ sal_Bool SwTxtFrm::PaintEmpty( const SwRect &rRect, sal_Bool bCheck ) const
* SwTxtFrm::Paint()
*************************************************************************/
-void SwTxtFrm::Paint( const SwRect &rRect ) const
+void SwTxtFrm::Paint( const SwRect &rRect, const SwPrtOptions * /*pPrintData*/ ) const
{
ResetRepaint();
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx
index 9c16d296b1cf..5c493c67ed98 100644
--- a/sw/source/core/text/itrform2.cxx
+++ b/sw/source/core/text/itrform2.cxx
@@ -101,6 +101,7 @@ void SwTxtFormatter::CtorInitTxtFormatter( SwTxtFrm *pNewFrm, SwTxtFormatInfo *p
pMulti = NULL;
bOnceMore = sal_False;
+ bFlyInCntBase = sal_False;
bChanges = sal_False;
bTruncLines = sal_False;
nCntEndHyph = 0;
@@ -2106,7 +2107,10 @@ long SwTxtFormatter::CalcOptRepaint( xub_StrLen nOldLineEnd,
bool lcl_BuildHiddenPortion( const SwTxtSizeInfo& rInf, xub_StrLen &rPos )
{
// Only if hidden text should not be shown:
- if ( rInf.GetVsh() && rInf.GetVsh()->GetWin() && rInf.GetOpt().IsShowHiddenChar() )
+// if ( rInf.GetVsh() && rInf.GetVsh()->GetWin() && rInf.GetOpt().IsShowHiddenChar() )
+ const bool bShowInDocView = rInf.GetVsh() && rInf.GetVsh()->GetWin() && rInf.GetOpt().IsShowHiddenChar();
+ const bool bShowForPrinting = rInf.GetOpt().IsShowHiddenChar( TRUE ) && rInf.GetOpt().IsPrinting();
+ if (bShowInDocView || bShowForPrinting)
return false;
const SwScriptInfo& rSI = rInf.GetParaPortion()->GetScriptInfo();
diff --git a/sw/source/core/text/porrst.cxx b/sw/source/core/text/porrst.cxx
index 2c4e9e27ce2e..f9b1332650da 100644
--- a/sw/source/core/text/porrst.cxx
+++ b/sw/source/core/text/porrst.cxx
@@ -219,6 +219,7 @@ SwArrowPortion::SwArrowPortion( const SwTxtPaintInfo &rInf )
rInf.GetTxtFrm()->Prt().Right();
aPos.Y() = rInf.GetTxtFrm()->Frm().Top() +
rInf.GetTxtFrm()->Prt().Bottom();
+ SetWhichPor( POR_ARROW );
}
void SwArrowPortion::Paint( const SwTxtPaintInfo &rInf ) const
diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx
index f1b8921f0224..0c40f0ff43f5 100644
--- a/sw/source/core/unocore/unodraw.cxx
+++ b/sw/source/core/unocore/unodraw.cxx
@@ -75,19 +75,12 @@
#include <com/sun/star/text/HoriOrientation.hpp>
#include <com/sun/star/text/VertOrientation.hpp>
#include <basegfx/numeric/ftools.hxx>
-// OD 2004-05-05 #i28701#
+#include <algorithm>
#include <fmtwrapinfluenceonobjpos.hxx>
-// --> OD 2004-11-10 #i35007#
#include <com/sun/star/text/TextContentAnchorType.hpp>
-// <--
-// --> OD 2005-03-10 #i44334#, #i44681#
-// --> OD 2007-01-03 #i73079# - use correct matrix type
#include <basegfx/matrix/b2dhommatrix.hxx>
-// <--
-// --> OD 2009-01-16 #i59051
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
#include <com/sun/star/drawing/PointSequence.hpp>
-// <--
-
#include <vcl/svapp.hxx>
#include <slist>
#include <iterator>
@@ -2744,12 +2737,14 @@ void SwXShape::_AdjustPositionProperties( const awt::Point _aPosition )
rtl::OUString aHoriOrientPropStr( RTL_CONSTASCII_USTRINGPARAM("HoriOrient") );
uno::Any aHoriOrient( getPropertyValue( aHoriOrientPropStr ) );
sal_Int16 eHoriOrient;
- aHoriOrient >>= eHoriOrient;
- if ( eHoriOrient != text::HoriOrientation::NONE )
+ if (aHoriOrient >>= eHoriOrient) // may be void
{
- eHoriOrient = text::HoriOrientation::NONE;
- aHoriOrient <<= eHoriOrient;
- setPropertyValue( aHoriOrientPropStr, aHoriOrient );
+ if ( eHoriOrient != text::HoriOrientation::NONE )
+ {
+ eHoriOrient = text::HoriOrientation::NONE;
+ aHoriOrient <<= eHoriOrient;
+ setPropertyValue( aHoriOrientPropStr, aHoriOrient );
+ }
}
// set x-position attribute
aHoriPos <<= _aPosition.X;
@@ -2772,12 +2767,14 @@ void SwXShape::_AdjustPositionProperties( const awt::Point _aPosition )
rtl::OUString aVertOrientPropStr( RTL_CONSTASCII_USTRINGPARAM("VertOrient") );
uno::Any aVertOrient( getPropertyValue( aVertOrientPropStr ) );
sal_Int16 eVertOrient;
- aVertOrient >>= eVertOrient;
- if ( eVertOrient != text::VertOrientation::NONE )
+ if (aVertOrient >>= eVertOrient) // may be void
{
- eVertOrient = text::VertOrientation::NONE;
- aVertOrient <<= eVertOrient;
- setPropertyValue( aVertOrientPropStr, aVertOrient );
+ if ( eVertOrient != text::VertOrientation::NONE )
+ {
+ eVertOrient = text::VertOrientation::NONE;
+ aVertOrient <<= eVertOrient;
+ setPropertyValue( aVertOrientPropStr, aVertOrient );
+ }
}
// set y-position attribute
aVertPos <<= _aPosition.Y;
@@ -2860,8 +2857,8 @@ void SwXShape::_AdjustPositionProperties( const awt::Point _aPosition )
// apply translation difference to PolyPolygonBezier.
if ( aTranslateDiff.X != 0 || aTranslateDiff.Y != 0 )
{
- basegfx::B2DHomMatrix aMatrix;
- aMatrix.translate( aTranslateDiff.X, aTranslateDiff.Y );
+ const basegfx::B2DHomMatrix aMatrix(basegfx::tools::createTranslateB2DHomMatrix(
+ aTranslateDiff.X, aTranslateDiff.Y));
const sal_Int32 nOuterSequenceCount(aConvertedPath.Coordinates.getLength());
drawing::PointSequence* pInnerSequence = aConvertedPath.Coordinates.getArray();
diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx
index 7ae4b209f49f..ee1055b276c9 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -270,8 +270,8 @@ void SwXText::insertString(const uno::Reference< text::XTextRange >& xTextRange,
sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) ));
}
- if(pRange && pRange->GetDoc() == GetDoc() ||
- pCursor && pCursor->GetDoc() == GetDoc())
+ if( (pRange && pRange->GetDoc() == GetDoc()) ||
+ (pCursor && pCursor->GetDoc() == GetDoc()) )
{
const SwStartNode* pOwnStartNode = GetStartNode();
if(pCursor)
diff --git a/sw/source/core/view/vdraw.cxx b/sw/source/core/view/vdraw.cxx
index da9800c9068a..1b692f36ad8d 100644
--- a/sw/source/core/view/vdraw.cxx
+++ b/sw/source/core/view/vdraw.cxx
@@ -57,6 +57,7 @@
#include "viewimp.hxx"
#include "dflyobj.hxx"
#include "viewopt.hxx"
+#include "swprtopt.hxx"
#include "dcontact.hxx"
#include "dview.hxx"
#include "flyfrm.hxx"
@@ -184,6 +185,7 @@ void SwViewImp::UnlockPaint()
// outliner of the draw view for painting layers <hell> and <heaven>.
// OD 25.06.2003 #108784# - correct type of 1st parameter
void SwViewImp::PaintLayer( const SdrLayerID _nLayerID,
+ const SwPrtOptions * _pPrintData,
const SwRect& ,
const Color* _pPageBackgrdColor,
const bool _bIsPageRightToLeft ) const
@@ -230,6 +232,12 @@ void SwViewImp::PaintLayer( const SdrLayerID _nLayerID,
}
pOutDev->Push( PUSH_LINECOLOR ); // #114231#
+ if (_pPrintData)
+ {
+ // hide drawings but not form controls (form controls are handled elsewhere)
+ SdrView &rSdrView = const_cast< SdrView & >(GetPageView()->GetView());
+ rSdrView.setHideDraw( !_pPrintData->IsPrintDraw() );
+ }
GetPageView()->DrawLayer(_nLayerID, pOutDev);
pOutDev->Pop();
diff --git a/sw/source/core/view/viewpg.cxx b/sw/source/core/view/viewpg.cxx
index cad53470e95b..61594065c3db 100644..100755
--- a/sw/source/core/view/viewpg.cxx
+++ b/sw/source/core/view/viewpg.cxx
@@ -31,9 +31,11 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sw.hxx"
+#include <com/sun/star/uno/Sequence.hxx>
#include <hintids.hxx>
#include <vcl/window.hxx>
+#include <vcl/oldprintadaptor.hxx>
#include <sfx2/printer.hxx>
#include <sfx2/progress.hxx>
#include <pvprtdat.hxx>
@@ -59,6 +61,10 @@
#include <IDocumentFieldsAccess.hxx>
#include <IDocumentDeviceAccess.hxx>
+
+using namespace ::com::sun::star;
+
+
// OD 12.12.2002 #103492#
SwPagePreviewLayout* ViewShell::PagePreviewLayout()
{
@@ -87,671 +93,173 @@ void ViewShell::AdjustOptionsForPagePreview( const SwPrtOptions &_rPrintOptions
return;
}
-// output print preview on printer
-// OD 05.05.2003 #i14016# - consider empty pages on calculation of scaling
-// and on calculation of paint offset.
-void ViewShell::PrintPreViewPage( SwPrtOptions& rOptions,
- USHORT nRowCol, SfxProgress& rProgress,
- const SwPagePreViewPrtData* pPrtData )
-{
- if( !rOptions.aMulti.GetSelectCount() )
- return;
- // wenn kein Drucker vorhanden ist, wird nicht gedruckt
- SfxPrinter* pPrt = getIDocumentDeviceAccess()->getPrinter(false);
- if( !pPrt || !pPrt->GetName().Len() )
+// print brochure
+// OD 05.05.2003 #i14016# - consider empty pages on calculation of the scaling
+// for a page to be printed.
+void ViewShell::PrintProspect(
+ OutputDevice *pOutDev,
+ const SwPrintData &rPrintData,
+ sal_Int32 nRenderer // the index in the vector of prospect pages to be printed
+ )
+{
+ const sal_Int32 nMaxRenderer = rPrintData.GetRenderData().GetPagePairsForProspectPrinting().size() - 1;
+#if OSL_DEBUG_LEVEL > 1
+ DBG_ASSERT( 0 <= nRenderer && nRenderer <= nMaxRenderer, "nRenderer out of bounds");
+#endif
+ Printer *pPrinter = dynamic_cast< Printer * >(pOutDev);
+ if (!pPrinter || nMaxRenderer < 0 || nRenderer < 0 || nRenderer > nMaxRenderer)
return;
-// schoen waers gewesen !!! const MultiSelection& rMulti = rOptions.aMulti;
- MultiSelection aMulti( rOptions.aMulti );
- Range aPages( aMulti.FirstSelected(), aMulti.LastSelected() );
- if ( aPages.Max() > USHRT_MAX )
- aPages.Max() = USHRT_MAX;
-
- ASSERT( aPages.Min() > 0,
- "Seite 0 Drucken?" );
- ASSERT( aPages.Min() <= aPages.Max(),
- "MinSeite groesser MaxSeite." );
+ // save settings of OutputDevice (should be done always since the
+ // output device is now provided by a call from outside the Writer)
+ pPrinter->Push();
+
+ std::pair< sal_Int32, sal_Int32 > rPagesToPrint =
+ rPrintData.GetRenderData().GetPagePairsForProspectPrinting()[ nRenderer ];
+// const USHORT nPageMax = static_cast< USHORT >(rPagesToPrint.first > rPagesToPrint.second ?
+// rPagesToPrint.first : rPagesToPrint.second);
+#if OSL_DEBUG_LEVEL > 1
+ DBG_ASSERT( rPagesToPrint.first == -1 || rPrintData.GetRenderData().GetValidPagesSet().count( rPagesToPrint.first ) == 1, "first Page not valid" );
+ DBG_ASSERT( rPagesToPrint.second == -1 || rPrintData.GetRenderData().GetValidPagesSet().count( rPagesToPrint.second ) == 1, "second Page not valid" );
+#endif
// eine neue Shell fuer den Printer erzeugen
- ViewShell aShell( *this, 0 );
- if ( &GetRefDev() == pPrt )
- aShell.mpTmpRef = new SfxPrinter( *pPrt );
+ ViewShell aShell( *this, 0, pPrinter );
SET_CURR_SHELL( &aShell );
- aShell.PrepareForPrint( rOptions );
+ aShell.PrepareForPrint( rPrintData );
- // gibt es versteckte Absatzfelder, unnoetig wenn die Absaetze bereits
- // ausgeblendet sind.
- int bHiddenFlds = FALSE;
- SwFieldType* pFldType = 0;
- if ( GetViewOptions()->IsShowHiddenPara() )
- {
- pFldType = getIDocumentFieldsAccess()->GetSysFldType( RES_HIDDENPARAFLD );
- bHiddenFlds = 0 != pFldType->GetDepends();
- if( bHiddenFlds )
- {
- SwMsgPoolItem aHnt( RES_HIDDENPARA_PRINT );
- pFldType->Modify( &aHnt, 0);
- }
- }
-
- // Seiten fuers Drucken formatieren
- aShell.CalcPagesForPrint( (USHORT)aPages.Max(), &rProgress );
+ //!! applying view options and formatting the dcoument should now only be done in getRendererCount!
- USHORT nCopyCnt = rOptions.bCollate ? rOptions.nCopyCount : 1;
- BOOL bStartJob = FALSE;
+ MapMode aMapMode( MAP_TWIP );
+ Size aPrtSize( pPrinter->PixelToLogic( pPrinter->GetPaperSizePixel(), aMapMode ) );
- const bool bPrintEmptyPages = rOptions.IsPrintEmptyPages();
+ SwTwips nMaxRowSz, nMaxColSz;
- for ( USHORT nCnt = 0; nCnt < nCopyCnt; nCnt++ )
+ const SwPageFrm *pStPage = 0;
+ const SwPageFrm *pNxtPage = 0;
+ const SwRenderData::ValidStartFramesMap_t &rFrms = rPrintData.GetRenderData().GetValidStartFrames();
+ if (rPagesToPrint.first > 0)
{
- if( rOptions.IsPrintSingleJobs() && rOptions.GetJobName().Len() &&
- ( bStartJob || rOptions.bJobStartet ) )
- {
- pPrt->EndJob();
- rOptions.bJobStartet = TRUE;
-
- // Reschedule statt Yield, da Yield keine Events abarbeitet
- // und es sonst eine Endlosschleife gibt.
- while( pPrt->IsPrinting() )
- rProgress.Reschedule();
-
- rOptions.MakeNextJobName();
- bStartJob = pPrt->StartJob( rOptions.GetJobName() );
- }
-
- const SwPageFrm *pStPage = (SwPageFrm*)GetLayout()->Lower();
- const SwFrm *pEndPage = pStPage;
- USHORT i;
-
- for( i = 1; pStPage && i < (USHORT)aPages.Min(); ++i )
- pStPage = (SwPageFrm*)pStPage->GetNext();
-
- if( !pStPage ) // dann wars das
- {
- if( bHiddenFlds )
- {
- SwMsgPoolItem aHnt( RES_HIDDENPARA_PRINT );
- pFldType->Modify( &aHnt, 0);
- CalcPagesForPrint( (USHORT)aPages.Max() );
- }
- return;
- }
-
- // unsere SttPage haben wir, dann die EndPage suchen
- USHORT nFirstPageNo = i;
- USHORT nLastPageNo = i;
- USHORT nPageNo = 1;
-
- pEndPage = pStPage;
-
- if( pStPage->GetNext() && (i != (USHORT)aPages.Max()) )
- {
- pEndPage = pEndPage->GetNext();
- for( ++i,++nLastPageNo;
- pEndPage->GetNext() && i < (USHORT)aPages.Max(); ++i )
- {
- pEndPage = pEndPage->GetNext();
- ++nLastPageNo;
- }
- }
+ SwRenderData::ValidStartFramesMap_t::const_iterator aIt( rFrms.find( rPagesToPrint.first ) );
+ DBG_ASSERT( aIt != rFrms.end(), "failed to find start frame" );
+ pStPage = aIt->second;
+ }
+ if (rPagesToPrint.second > 0)
+ {
+ SwRenderData::ValidStartFramesMap_t::const_iterator aIt( rFrms.find( rPagesToPrint.second ) );
+ DBG_ASSERT( aIt != rFrms.end(), "failed to find start frame" );
+ pNxtPage = aIt->second;
+ }
- if( rOptions.bPrintReverse )
+ // OD 05.05.2003 #i14016# - consider empty pages on calculation
+ // of page size, used for calculation of scaling.
+ Size aSttPageSize;
+ if ( pStPage )
+ {
+ if ( pStPage->IsEmptyPage() )
{
- const SwFrm *pTmp = pStPage;
- pStPage = (SwPageFrm*)pEndPage;
- pEndPage = pTmp;
- nPageNo = nLastPageNo;
+ if ( pStPage->GetPhyPageNum() % 2 == 0 )
+ aSttPageSize = pStPage->GetPrev()->Frm().SSize();
+ else
+ aSttPageSize = pStPage->GetNext()->Frm().SSize();
}
else
- nPageNo = nFirstPageNo;
-
- // ein Array fuer die Seiten anlegen, die auf eine Drucker-Seite
- // gedruckt werden sollen.
- BYTE nRow = BYTE(nRowCol >> 8), nCol = BYTE(nRowCol & 0xff);
- USHORT nPages = nRow * nCol;
- SwPageFrm** aPageArr = new SwPageFrm* [ nPages ];
- memset( aPageArr, 0, sizeof( SwPageFrm* ) * nPages );
- USHORT nCntPage = 0;
-
- SwTwips nCalcW = 0, nCalcH = 0, nMaxRowSz = 0, nMaxColSz = 0;
-
- MapMode aOld( pPrt->GetMapMode() );
- MapMode aMapMode( MAP_TWIP );
- Size aPrtSize( pPrt->PixelToLogic( pPrt->GetPaperSizePixel(), aMapMode ));
- if( pPrtData )
{
- aPrtSize.Width() -= pPrtData->GetLeftSpace() +
- pPrtData->GetRightSpace() +
- ( pPrtData->GetHorzSpace() * (nCol - 1));
- aPrtSize.Height() -= pPrtData->GetTopSpace() +
- pPrtData->GetBottomSpace() +
- ( pPrtData->GetVertSpace() * (nRow - 1));
+ aSttPageSize = pStPage->Frm().SSize();
}
-
- aMulti.Select( Range( nLastPageNo+1, USHRT_MAX ), FALSE );
- USHORT nSelCount = USHORT((aMulti.GetSelectCount()+nPages-1) / nPages);
- nSelCount = nSelCount * nCopyCnt;
- USHORT nPrintCount = 1;
-
- const XubString aTmp( SW_RES( STR_STATSTR_PRINT ) );
- rProgress.SetText( aTmp );
- //HACK, damit die Anzeige nicht durcheinander kommt:
- rProgress.SetState( 1, nSelCount );
- rProgress.SetText( aTmp );
- bStartJob = TRUE;
-
- while( pStPage )
+ }
+ Size aNxtPageSize;
+ if ( pNxtPage )
+ {
+ if ( pNxtPage->IsEmptyPage() )
{
- // Mag der Anwender noch ?
- rProgress.Reschedule();
-
- if ( !pPrt->IsJobActive() )
- break;
-
- // --> FME 2005-12-12 #b6354161# Feature - Print empty pages
- // --> OD 2007-10-22 #i79738# - correct condition:
- // always consider, if page is selected for print.
- if( aMulti.IsSelected( nPageNo ) &&
- ( bPrintEmptyPages || !pStPage->IsEmptyPage() ) )
- // <--
- {
- if( rOptions.bPrintReverse )
- aPageArr[ nPages - ++nCntPage ] = (SwPageFrm*)pStPage;
- else
- aPageArr[ nCntPage++ ] = (SwPageFrm*)pStPage;
-
- // OD 05.05.2003 #i14016# - consider empty pages on calculation
- // of page size, used for calculation of scaling.
- Size aPageSize;
- if ( pStPage->IsEmptyPage() )
- {
- if ( pStPage->GetPhyPageNum() % 2 == 0 )
- aPageSize = pStPage->GetPrev()->Frm().SSize();
- else
- aPageSize = pStPage->GetNext()->Frm().SSize();
- }
- else
- {
- aPageSize = pStPage->Frm().SSize();
- }
- nCalcW += aPageSize.Width();
- if( nCalcH < aPageSize.Height() )
- nCalcH = aPageSize.Height();
-
- if( 0 == (nCntPage % nCol ) || // neue Zeile
- nCntPage == nPages || pStPage == pEndPage )
- {
- // sollte die Seite nicht gefuellt sein, so erweiter
- // anhand der letzen Seite. Dadurch hat auch die
- // letze Seite die richtigen Spalten/Reihen.
- // BUG: 17695
- if( pStPage == pEndPage && nCntPage != nPages )
- {
- // dann Werte mit der letzen Seite auffuellen
- if( nCntPage < nCol )
- nCalcW += aPageSize.Width() * (nCol - nCntPage);
-
- BYTE nRows = (BYTE) ( nCntPage / nCol + 1 );
- if( nRows < nRow )
- nCalcH += ( nRow - nRows ) * nCalcH;
- }
-
- if( nMaxColSz < nCalcW )
- nMaxColSz = nCalcW;
- nCalcW = 0;
- nMaxRowSz += nCalcH;
- }
-
- if( nCntPage == nPages || pStPage == pEndPage )
- {
- // den MapMode einstellen
- aMapMode.SetOrigin( Point() );
- {
- Fraction aScX( aPrtSize.Width(), nMaxColSz );
- Fraction aScY( aPrtSize.Height(), nMaxRowSz );
-
- {
- if( aScX < aScY )
- aScY = aScX;
-
- // fuer Drawing, damit diese ihre Objecte vernuenftig Painten
- // koennen, auf "glatte" Prozentwerte setzen
- aScY *= Fraction( 1000, 1 );
- long nTmp = (long)aScY;
- if( 1 < nTmp )
- --nTmp;
- else
- nTmp = 1;
- aScY = Fraction( nTmp, 1000 );
- aScX = aScY;
- }
-
- aMapMode.SetScaleY( aScY );
- aMapMode.SetScaleX( aScX );
- }
-
- Point aPrtOff( pPrt->PixelToLogic(
- pPrt->GetPageOffsetPixel(), aMapMode ) );
- long nPageHeight = (nMaxRowSz / nRow);
-
- // dann kann das drucken losgehen
- rProgress.SetState( nPrintCount++, nSelCount );
-
- pPrt->StartPage();
- Point aCalcPt;
- SwPageFrm** ppTmpPg = aPageArr;
-
- // ist das Array nicht vollsteandig gefuellt ?
- if( rOptions.bPrintReverse && nCntPage != nPages )
- {
- // beim Rueckwaertsdruck alle Seiten nach vorne
- // verschieben!
- memmove( ppTmpPg, ppTmpPg + (nPages - nCntPage),
- nCntPage * sizeof( SwPageFrm*) );
- aPageArr[ nCntPage ] = 0; // Endekennung
- }
-
- long nHOffs = 0, nVOffs = 0, nXStt = 0;
- if( pPrtData )
- {
- const Fraction& rScaleX = aMapMode.GetScaleX();
- const Fraction& rScaleY = aMapMode.GetScaleY();
- Fraction aF( pPrtData->GetTopSpace(), 1 );
- aCalcPt.Y() = aF /= rScaleY;
- aF = Fraction( pPrtData->GetLeftSpace(), 1 );
- nXStt = aF /= rScaleX;
- aF = Fraction( pPrtData->GetVertSpace(), 1 );
- nVOffs = aF /= rScaleY;
- aF = Fraction( pPrtData->GetHorzSpace(), 1 );
- nHOffs = aF /= rScaleX;
- }
-
- for( BYTE nR = 0; *ppTmpPg && nR < nRow; ++nR )
- {
- aCalcPt.X() = nXStt;
- for( BYTE nC = 0; *ppTmpPg && nC < nCol; ++nC )
- {
- aShell.Imp()->SetFirstVisPageInvalid();
- aShell.aVisArea = (*ppTmpPg)->Frm();
-
- Point aPos( aCalcPt );
- aPos -= aShell.aVisArea.Pos();
- aPos -= aPrtOff;
- aMapMode.SetOrigin( aPos );
- pPrt->SetMapMode( aMapMode );
- (*ppTmpPg)->GetUpper()->Paint( (*ppTmpPg)->Frm() );
- // OD 05.05.2003 #i14016# - consider empty pages
- // on calculation of the paint offset for the next page.
- aCalcPt.X() += nHOffs;
- if ( (*ppTmpPg)->IsEmptyPage() )
- {
- if ( (*ppTmpPg)->GetPhyPageNum() % 2 == 0 )
- aCalcPt.X() += (*ppTmpPg)->GetPrev()->Frm().SSize().Width();
- else
- aCalcPt.X() += (*ppTmpPg)->GetNext()->Frm().SSize().Width();
- }
- else
- {
- aCalcPt.X() += (*ppTmpPg)->Frm().Width();
- }
- ++ppTmpPg;
- }
- aCalcPt.Y() += nVOffs + nPageHeight;
- }
- pPrt->EndPage();
- SwPaintQueue::Repaint();
-
- memset( aPageArr, 0, sizeof( SwPageFrm* ) * nPages );
- nCntPage = 0;
- nMaxRowSz = nMaxColSz = nCalcH = nCalcW = 0;
- }
- }
-
- if( pStPage == pEndPage )
- pStPage = 0;
- else if( rOptions.bPrintReverse )
- {
- --nPageNo;
- pStPage = (SwPageFrm*)pStPage->GetPrev();
- }
+ if ( pNxtPage->GetPhyPageNum() % 2 == 0 )
+ aNxtPageSize = pNxtPage->GetPrev()->Frm().SSize();
else
- {
- ++nPageNo;
- pStPage = (SwPageFrm*)pStPage->GetNext();
- }
+ aNxtPageSize = pNxtPage->GetNext()->Frm().SSize();
}
- pPrt->SetMapMode( aOld );
-
- if( bHiddenFlds )
+ else
{
- SwMsgPoolItem aHnt( RES_HIDDENPARA_PRINT );
- pFldType->Modify( &aHnt, 0);
- CalcPagesForPrint( (USHORT)aPages.Max() );
+ aNxtPageSize = pNxtPage->Frm().SSize();
}
- delete[] aPageArr;
-
- if( bStartJob )
- rOptions.bJobStartet = TRUE;
}
- pFntCache->Flush();
-}
-// print brochure
-// OD 05.05.2003 #i14016# - consider empty pages on calculation of the scaling
-// for a page to be printed.
-void ViewShell::PrintProspect( SwPrtOptions& rOptions,
- SfxProgress& rProgress , BOOL bRTL)
-{
- if( !rOptions.aMulti.GetSelectCount() )
- return;
-
- // wenn kein Drucker vorhanden ist, wird nicht gedruckt
- SfxPrinter* pPrt = getIDocumentDeviceAccess()->getPrinter(false);
- if( !pPrt || !pPrt->GetName().Len() ||
- ( !rOptions.bPrintLeftPage && !rOptions.bPrintRightPage ))
- return;
-
- MultiSelection aMulti( rOptions.aMulti );
- Range aPages( aMulti.FirstSelected(), aMulti.LastSelected() );
- if ( aPages.Max() > USHRT_MAX )
- aPages.Max() = USHRT_MAX;
-
- ASSERT( aPages.Min() > 0,
- "Seite 0 Drucken?" );
- ASSERT( aPages.Min() <= aPages.Max(),
- "MinSeite groesser MaxSeite." );
-
- // eine neue Shell fuer den Printer erzeugen
- ViewShell aShell( *this, 0 );
- if ( &GetRefDev() == pPrt )
- aShell.mpTmpRef = new SfxPrinter( *pPrt );
-
- SET_CURR_SHELL( &aShell );
-
- aShell.PrepareForPrint( rOptions );
-
- // gibt es versteckte Absatzfelder, unnoetig wenn die Absaetze bereits
- // ausgeblendet sind.
- int bHiddenFlds = FALSE;
- SwFieldType* pFldType = 0;
- if ( GetViewOptions()->IsShowHiddenPara() )
+ if( !pStPage )
{
- pFldType = getIDocumentFieldsAccess()->GetSysFldType( RES_HIDDENPARAFLD );
- bHiddenFlds = 0 != pFldType->GetDepends();
- if( bHiddenFlds )
- {
- SwMsgPoolItem aHnt( RES_HIDDENPARA_PRINT );
- pFldType->Modify( &aHnt, 0);
- }
+ nMaxColSz = 2 * aNxtPageSize.Width();
+ nMaxRowSz = aNxtPageSize.Height();
}
-
- // Seiten fuers Drucken formatieren
- aShell.CalcPagesForPrint( (USHORT)aPages.Max(), &rProgress );
-
- USHORT nCopyCnt = rOptions.bCollate ? rOptions.nCopyCount : 1;
-
- const SwPageFrm *pStPage = (SwPageFrm*)GetLayout()->Lower();
- USHORT i;
-
- for( i = 1; pStPage && i < (USHORT)aPages.Min(); ++i )
- pStPage = (SwPageFrm*)pStPage->GetNext();
-
- if( !pStPage ) // dann wars das
+ else if( !pNxtPage )
{
- if( bHiddenFlds )
- {
- SwMsgPoolItem aHnt( RES_HIDDENPARA_PRINT );
- pFldType->Modify( &aHnt, 0);
- CalcPagesForPrint( (USHORT)aPages.Max() );
- }
- return;
+ nMaxColSz = 2 * aSttPageSize.Width();
+ nMaxRowSz = aSttPageSize.Height();
}
-
- // unsere SttPage haben wir, dann die EndPage suchen
- SvPtrarr aArr( 255, 255 );
- aArr.Insert( (void*)pStPage, aArr.Count() );
-
- while( pStPage->GetNext() && i < (USHORT)aPages.Max() )
+ else
{
- pStPage = (SwPageFrm*)pStPage->GetNext();
- if( aMulti.IsSelected( ++i ) )
- aArr.Insert( (void*)pStPage, aArr.Count() );
+ nMaxColSz = aNxtPageSize.Width() + aSttPageSize.Width();
+ nMaxRowSz = Max( aNxtPageSize.Height(), aSttPageSize.Height() );
}
- // auf Doppelseiten auffuellen
- if( 1 == aArr.Count() ) // eine Seite ist ein Sonderfall
- aArr.Insert( (void*)0, 1 );
- else
+ // den MapMode einstellen
+ aMapMode.SetOrigin( Point() );
{
- while( aArr.Count() & 3 )
- aArr.Insert( (void*)0, aArr.Count() );
+ Fraction aScX( aPrtSize.Width(), nMaxColSz );
+ Fraction aScY( aPrtSize.Height(), nMaxRowSz );
+ if( aScX < aScY )
+ aScY = aScX;
- if( rOptions.bPrintReverse && 4 < aArr.Count() )
{
- // das Array umsortieren
- // Array: 1 2 3 4 5 6 7 8
- // soll: 3 4 1 2 7 8 5 6
- // Algorhytmus:
- // vordere Haelfte: Austausch von 2 Pointer von Vorne vor die Haelfte
- // hintere Haelfte: Austausch von 2 Pointer von der Haelfte nach hinten
-
- USHORT nHalf = aArr.Count() / 2;
- USHORT nSwapCount = nHalf / 4;
-
- VoidPtr* ppArrStt = (VoidPtr*)aArr.GetData();
- VoidPtr* ppArrHalf = (VoidPtr*)aArr.GetData() + nHalf;
-
- for( int nLoop = 0; nLoop < 2; ++nLoop )
- {
- for( USHORT n = 0; n < nSwapCount; ++n )
- {
- void* pTmp = *ppArrStt;
- *ppArrStt++ = *(ppArrHalf-2);
- *(ppArrHalf-2) = pTmp;
-
- pTmp = *ppArrStt;
- *ppArrStt++ = *--ppArrHalf;
- *ppArrHalf-- = pTmp;
- }
- ppArrStt = (VoidPtr*)aArr.GetData() + nHalf;
- ppArrHalf = (VoidPtr*)aArr.GetData() + aArr.Count();
- }
+ // fuer Drawing, damit diese ihre Objecte vernuenftig Painten
+ // koennen, auf "glatte" Prozentwerte setzen
+ aScY *= Fraction( 1000, 1 );
+ long nTmp = (long)aScY;
+ if( 1 < nTmp )
+ --nTmp;
+ else
+ nTmp = 1;
+ aScY = Fraction( nTmp, 1000 );
}
+
+ aMapMode.SetScaleY( aScY );
+ aMapMode.SetScaleX( aScY );
}
- BOOL bStartJob = FALSE;
+ Size aTmpPrtSize( pPrinter->PixelToLogic( pPrinter->GetPaperSizePixel(), aMapMode ) );
- for( USHORT nCnt = 0; nCnt < nCopyCnt; nCnt++ )
+ // calculate start point for equal border on all sides
+ Point aSttPt( (aTmpPrtSize.Width() - nMaxColSz) / 2,
+ (aTmpPrtSize.Height() - nMaxRowSz) / 2 );
+ for( int nC = 0; nC < 2; ++nC )
{
- if( rOptions.IsPrintSingleJobs() && rOptions.GetJobName().Len() &&
- ( bStartJob || rOptions.bJobStartet ) )
+ if( pStPage )
{
- pPrt->EndJob();
- rOptions.bJobStartet = TRUE;
-
- // Reschedule statt Yield, da Yield keine Events abarbeitet
- // und es sonst eine Endlosschleife gibt.
- while( pPrt->IsPrinting() )
- rProgress.Reschedule();
-
- rOptions.MakeNextJobName();
- bStartJob = pPrt->StartJob( rOptions.GetJobName() );
+ aShell.Imp()->SetFirstVisPageInvalid();
+ aShell.aVisArea = pStPage->Frm();
+
+ Point aPos( aSttPt );
+ aPos -= aShell.aVisArea.Pos();
+// aPos -= aPrtOff;
+ aMapMode.SetOrigin( aPos );
+ pPrinter->SetMapMode( aMapMode );
+ pStPage->GetUpper()->Paint( pStPage->Frm() );
}
- // dann sorge mal dafuer, das alle Seiten in der richtigen
- // Reihenfolge stehen:
- USHORT nSPg = 0, nEPg = aArr.Count(), nStep = 1;
- if( 0 == (nEPg & 1 )) // ungerade gibt es nicht!
- --nEPg;
-
- if( !rOptions.bPrintLeftPage )
- ++nStep;
- else if( !rOptions.bPrintRightPage )
- {
- ++nStep;
- ++nSPg, --nEPg;
- }
+ pStPage = pNxtPage;
+ aSttPt.X() += aTmpPrtSize.Width() / 2;
+ }
- USHORT nCntPage = (( nEPg - nSPg ) / ( 2 * nStep )) + 1;
+ SwPaintQueue::Repaint();
- MapMode aOld( pPrt->GetMapMode() );
- MapMode aMapMode( MAP_TWIP );
- Size aPrtSize( pPrt->PixelToLogic( pPrt->GetPaperSizePixel(), aMapMode ) );
+ //!! applying/modifying view options and formatting the dcoument should now only be done in getRendererCount!
- const XubString aTmp( SW_RES( STR_STATSTR_PRINT ) );
- rProgress.SetText( aTmp );
- //HACK, damit die Anzeige nicht durcheinander kommt:
- rProgress.SetState( 1, nCntPage );
- rProgress.SetText( aTmp );
+ pFntCache->Flush();
- for( USHORT nPrintCount = 0; nSPg < nEPg &&
- nPrintCount < nCntPage; ++nPrintCount )
- {
- // Mag der Anwender noch ?
- rProgress.Reschedule();
-
- if ( !pPrt->IsJobActive() )
- break;
-
- SwTwips nMaxRowSz, nMaxColSz;
- pStPage = (SwPageFrm*)aArr[ nSPg ];
- const SwPageFrm* pNxtPage = nEPg < aArr.Count()
- ? (SwPageFrm*)aArr[ nEPg ]
- : 0;
-
- // OD 05.05.2003 #i14016# - consider empty pages on calculation
- // of page size, used for calculation of scaling.
- Size aSttPageSize;
- if ( pStPage )
- {
- if ( pStPage->IsEmptyPage() )
- {
- if ( pStPage->GetPhyPageNum() % 2 == 0 )
- aSttPageSize = pStPage->GetPrev()->Frm().SSize();
- else
- aSttPageSize = pStPage->GetNext()->Frm().SSize();
- }
- else
- {
- aSttPageSize = pStPage->Frm().SSize();
- }
- }
- Size aNxtPageSize;
- if ( pNxtPage )
- {
- if ( pNxtPage->IsEmptyPage() )
- {
- if ( pNxtPage->GetPhyPageNum() % 2 == 0 )
- aNxtPageSize = pNxtPage->GetPrev()->Frm().SSize();
- else
- aNxtPageSize = pNxtPage->GetNext()->Frm().SSize();
- }
- else
- {
- aNxtPageSize = pNxtPage->Frm().SSize();
- }
- }
-
- if( !pStPage )
- {
- nMaxColSz = 2 * aNxtPageSize.Width();
- nMaxRowSz = aNxtPageSize.Height();
- }
- else if( !pNxtPage )
- {
- nMaxColSz = 2 * aSttPageSize.Width();
- nMaxRowSz = aSttPageSize.Height();
- }
- else
- {
- nMaxColSz = aNxtPageSize.Width() +
- aSttPageSize.Width();
- nMaxRowSz = Max( aNxtPageSize.Height(),
- aSttPageSize.Height() );
- }
-
- short nRtlOfs = bRTL ? 1 : 0;
- if( 0 == (( nSPg + nRtlOfs) & 1 ) ) // switch for odd number in LTR, even number in RTL
- {
- const SwPageFrm* pTmp = pStPage;
- pStPage = pNxtPage;
- pNxtPage = pTmp;
- }
-
- // den MapMode einstellen
- aMapMode.SetOrigin( Point() );
- {
- Fraction aScX( aPrtSize.Width(), nMaxColSz );
- Fraction aScY( aPrtSize.Height(), nMaxRowSz );
- if( aScX < aScY )
- aScY = aScX;
-
- {
- // fuer Drawing, damit diese ihre Objecte vernuenftig Painten
- // koennen, auf "glatte" Prozentwerte setzen
- aScY *= Fraction( 1000, 1 );
- long nTmp = (long)aScY;
- if( 1 < nTmp )
- --nTmp;
- else
- nTmp = 1;
- aScY = Fraction( nTmp, 1000 );
- }
-
- aMapMode.SetScaleY( aScY );
- aMapMode.SetScaleX( aScY );
- }
-
- Point aPrtOff( pPrt->PixelToLogic(
- pPrt->GetPageOffsetPixel(), aMapMode ) );
- Size aTmpPrtSize( pPrt->PixelToLogic(
- pPrt->GetPaperSizePixel(), aMapMode ) );
-
- // dann kann das drucken losgehen
- bStartJob = TRUE;
- rProgress.SetState( nPrintCount, nCntPage );
-
- pPrt->StartPage();
-
- Point aSttPt;
- for( int nC = 0; nC < 2; ++nC )
- {
- if( pStPage )
- {
- aShell.Imp()->SetFirstVisPageInvalid();
- aShell.aVisArea = pStPage->Frm();
-
- Point aPos( aSttPt );
- aPos -= aShell.aVisArea.Pos();
- aPos -= aPrtOff;
- aMapMode.SetOrigin( aPos );
- pPrt->SetMapMode( aMapMode );
- pStPage->GetUpper()->Paint( pStPage->Frm() );
- }
-
- pStPage = pNxtPage;
- aSttPt.X() += aTmpPrtSize.Width() / 2;
- }
-
- pPrt->EndPage();
- SwPaintQueue::Repaint();
- nSPg = nSPg + nStep;
- nEPg = nEPg - nStep;
- }
- pPrt->SetMapMode( aOld );
+ // restore settings of OutputDevice (should be done always now since the
+ // output device is now provided by a call from outside the Writer)
+ pPrinter->Pop();
+}
- if( bHiddenFlds )
- {
- SwMsgPoolItem aHnt( RES_HIDDENPARA_PRINT );
- pFldType->Modify( &aHnt, 0);
- CalcPagesForPrint( (USHORT)aPages.Max() );
- }
- if( bStartJob )
- rOptions.bJobStartet = TRUE;
- }
- pFntCache->Flush();
-}
diff --git a/sw/source/core/view/vnew.cxx b/sw/source/core/view/vnew.cxx
index a270c6f78492..99c16d68f2bd 100644
--- a/sw/source/core/view/vnew.cxx
+++ b/sw/source/core/view/vnew.cxx
@@ -116,11 +116,8 @@ void ViewShell::Init( const SwViewOption *pNewOpt )
// Only setup the printer if we need one:
const IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
const bool bBrowseMode = pIDSA->get(IDocumentSettingAccess::BROWSE_MODE);
- const bool bCreatePrinter = !bBrowseMode &&
- !pIDSA->get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE);
- SfxPrinter* pPrinter = getIDocumentDeviceAccess()->getPrinter( bCreatePrinter );
- if( pPrinter )
- InitPrt( pPrinter, pPDFOut );
+ if( pPDFOut )
+ InitPrt( pPDFOut );
// <--
// --> FME 2005-03-16 #i44963# Good occasion to check if page sizes in
diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx
index 02b31ae0ac4b..2e0f12b0ee3c 100644..100755
--- a/sw/source/core/view/vprint.cxx
+++ b/sw/source/core/view/vprint.cxx
@@ -33,11 +33,19 @@
#include "precompiled_sw.hxx"
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/uno/Any.hxx>
+
#include <hintids.hxx>
+#include <vcl/oldprintadaptor.hxx>
#include <sfx2/printer.hxx>
#include <sfx2/objsh.hxx>
+#include <tools/resary.hxx>
+#include <tools/debug.hxx>
+#include <rtl/ustring.hxx>
+#include <toolkit/awt/vclxdevice.hxx>
+#include <toolkit/awt/vclxdevice.hxx>
-// #include <tools/intn.hxx>
#include <sfx2/progress.hxx>
#include <sfx2/app.hxx>
#include <sfx2/prnmon.hxx>
@@ -45,6 +53,16 @@
#include <editeng/pbinitem.hxx>
#include <svx/svdview.hxx>
#include <unotools/localedatawrapper.hxx>
+
+#include <unotools/moduleoptions.hxx>
+#include <svl/languageoptions.hxx>
+
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/view/XRenderable.hpp>
+
+#include <unotxdoc.hxx>
+
+#include <docsh.hxx>
#include <unotools/syslocale.hxx>
#include <txtfld.hxx>
#include <fmtfld.hxx>
@@ -54,14 +72,15 @@
#include <pagefrm.hxx>
#include <cntfrm.hxx>
#include <doc.hxx>
+#include <wdocsh.hxx>
#include <fesh.hxx>
#include <pam.hxx>
#include <viewimp.hxx> // Imp->SetFirstVisPageInvalid()
#include <layact.hxx>
#include <ndtxt.hxx>
#include <fldbas.hxx>
-#include <docufld.hxx> // PostItFld /-Type
#include <docfld.hxx> // _SetGetExpFld
+#include <docufld.hxx> // PostItFld /-Type
#include <shellres.hxx>
#include <viewopt.hxx>
#include <swprtopt.hxx> // SwPrtOptions
@@ -76,11 +95,18 @@
#include <txtfrm.hxx> // MinPrtLine
#include <viscrs.hxx> // SwShellCrsr
#include <fmtpdsc.hxx> // SwFmtPageDesc
+#include <globals.hrc>
#define JOBSET_ERR_DEFAULT 0
#define JOBSET_ERR_ERROR 1
#define JOBSET_ERR_ISSTARTET 2
+
+extern bool lcl_GetPostIts( IDocumentFieldsAccess* pIDFA, _SetGetExpFlds * pSrtLst );
+
+
+using namespace ::com::sun::star;
+
//--------------------------------------------------------------------
//Klasse zum Puffern von Paints
class SwQueuedPaint
@@ -99,19 +125,6 @@ public:
SwQueuedPaint *SwPaintQueue::pQueue = 0;
-//Klasse zum Speichern einiger Druckereinstellungen
-class SwPrtOptSave
-{
- Printer *pPrt;
- Size aSize;
- Paper ePaper;
- Orientation eOrientation;
- USHORT nPaperBin;
-public:
- SwPrtOptSave( Printer *pPrinter );
- ~SwPrtOptSave();
-};
-
// saves some settings from the draw view
class SwDrawViewSave
{
@@ -201,6 +214,7 @@ void SwPaintQueue::Remove( ViewShell *pSh )
}
}
+/*****************************************************************************/
const XubString& SwPrtOptions::MakeNextJobName()
{
@@ -214,340 +228,538 @@ const XubString& SwPrtOptions::MakeNextJobName()
return sJobName += XubString::CreateFromInt32( ++nJobNo );
}
-/******************************************************************************
- * Methode : void SetSwVisArea( ViewShell *pSh, Point aPrtOffset, ...
- * Beschreibung:
- * Erstellt : OK 04.11.94 16:27
- * Aenderung :
- ******************************************************************************/
+/*****************************************************************************/
-void SetSwVisArea( ViewShell *pSh, const SwRect &rRect, BOOL bPDFExport )
+SwRenderData::SwRenderData()
{
- ASSERT( !pSh->GetWin(), "Drucken mit Window?" );
- pSh->aVisArea = rRect;
- pSh->Imp()->SetFirstVisPageInvalid();
- Point aPt( rRect.Pos() );
+ m_pPostItFields = 0;
+ m_pPostItDoc = 0;
+ m_pPostItShell = 0;
- if (!bPDFExport)
- aPt += pSh->aPrtOffst;
- aPt.X() = -aPt.X(); aPt.Y() = -aPt.Y();
+ m_pViewOptionAdjust = 0;
+ m_pPrtOptions = 0;
+}
- OutputDevice *pOut = bPDFExport ?
- pSh->GetOut() :
- pSh->getIDocumentDeviceAccess()->getPrinter( false );
- MapMode aMapMode( pOut->GetMapMode() );
- aMapMode.SetOrigin( aPt );
- pOut->SetMapMode( aMapMode );
+SwRenderData::~SwRenderData()
+{
+ delete m_pViewOptionAdjust; m_pViewOptionAdjust = 0;
+ delete m_pPrtOptions; m_pPrtOptions = 0;
+ DBG_ASSERT( !m_pPostItShell, "m_pPostItShell should already have been deleted" );
+ DBG_ASSERT( !m_pPostItDoc, "m_pPostItDoc should already have been deleted" );
+ DBG_ASSERT( !m_pPostItFields, " should already have been deleted" );
}
-/******************************************************************************
- * Methode : struct _PostItFld : public _SetGetExpFld
- * Beschreibung: Update an das PostItFeld
- * Erstellt : OK 07.11.94 10:18
- * Aenderung :
- ******************************************************************************/
-struct _PostItFld : public _SetGetExpFld
-{
- _PostItFld( const SwNodeIndex& rNdIdx, const SwTxtFld* pFld,
- const SwIndex* pIdx = 0 )
- : _SetGetExpFld( rNdIdx, pFld, pIdx ) {}
-
- USHORT GetPageNo( MultiSelection &rMulti, BOOL bRgt, BOOL bLft,
- USHORT& rVirtPgNo, USHORT& rLineNo );
- SwPostItField* GetPostIt() const
- { return (SwPostItField*) GetFld()->GetFld().GetFld(); }
-};
+void SwRenderData::CreatePostItData( SwDoc *pDoc, const SwViewOption *pViewOpt, OutputDevice *pOutDev )
+{
+ DBG_ASSERT( !m_pPostItFields && !m_pPostItDoc && !m_pPostItShell, "some post-it data already exists" );
+ m_pPostItFields = new _SetGetExpFlds;
+ lcl_GetPostIts( pDoc, m_pPostItFields );
+ m_pPostItDoc = new SwDoc;
+
+ //!! Disable spell and grammar checking in the temporary document.
+ //!! Otherwise the grammar checker might process it and crash if we later on
+ //!! simply delete this document while he is still at it.
+ SwViewOption aViewOpt( *pViewOpt );
+ aViewOpt.SetOnlineSpell( FALSE );
+
+ m_pPostItShell = new ViewShell( *m_pPostItDoc, 0, &aViewOpt, pOutDev );
+}
-USHORT _PostItFld::GetPageNo( MultiSelection &rMulti, BOOL bRgt, BOOL bLft,
- USHORT& rVirtPgNo, USHORT& rLineNo )
+void SwRenderData::DeletePostItData()
{
- //Problem: Wenn ein PostItFld in einem Node steht, der von mehr als
- //einer Layout-Instanz repraesentiert wird, steht die Frage im Raum,
- //ob das PostIt nur ein- oder n-mal gedruck werden soll.
- //Wahrscheinlich nur einmal, als Seitennummer soll hier keine Zufaellige
- //sondern die des ersten Auftretens des PostIts innerhalb des selektierten
- //Bereichs ermittelt werden.
- rVirtPgNo = 0;
- USHORT nPos = GetCntnt();
- SwClientIter aIter( (SwModify &)GetFld()->GetTxtNode() );
- for( SwTxtFrm* pFrm = (SwTxtFrm*)aIter.First( TYPE( SwFrm ));
- pFrm; pFrm = (SwTxtFrm*)aIter.Next() )
+ if (HasPostItData())
{
- if( pFrm->GetOfst() > nPos ||
- (pFrm->HasFollow() && pFrm->GetFollow()->GetOfst() <= nPos) )
- continue;
- USHORT nPgNo = pFrm->GetPhyPageNum();
- BOOL bRight = pFrm->OnRightPage();
- if( rMulti.IsSelected( nPgNo ) &&
- ( (bRight && bRgt) || (!bRight && bLft) ) )
- {
- rLineNo = (USHORT)(pFrm->GetLineCount( nPos ) +
- pFrm->GetAllLines() - pFrm->GetThisLines());
- rVirtPgNo = pFrm->GetVirtPageNum();
- return nPgNo;
- }
+ m_pPostItDoc->setPrinter( 0, false, false ); //damit am echten DOC der Drucker bleibt
+ delete m_pPostItShell; //Nimmt das PostItDoc mit ins Grab.
+ delete m_pPostItFields;
+ m_pPostItDoc = 0;
+ m_pPostItShell = 0;
+ m_pPostItFields = 0;
}
- return 0;
}
-/******************************************************************************
- * Methode : void lcl_GetPostIts( IDocumentFieldsAccess* pIDFA, _SetGetExpFlds& ...
- * Beschreibung:
- * Erstellt : OK 07.11.94 10:20
- * Aenderung :
- ******************************************************************************/
-
-void lcl_GetPostIts( IDocumentFieldsAccess* pIDFA, _SetGetExpFlds& rSrtLst )
+void SwRenderData::ViewOptionAdjustStart( SwWrtShell &rSh, const SwViewOption &rViewOptions )
{
- SwFieldType* pFldType = pIDFA->GetSysFldType( RES_POSTITFLD );
- ASSERT( pFldType, "kein PostItType ? ");
-
- if( pFldType->GetDepends() )
+ if (m_pViewOptionAdjust)
{
- // Modify-Object gefunden, trage alle Felder ins Array ein
- SwClientIter aIter( *pFldType );
- SwClient* pLast;
- const SwTxtFld* pTxtFld;
-
- for( pLast = aIter.First( TYPE(SwFmtFld)); pLast; pLast = aIter.Next() )
- if( 0 != ( pTxtFld = ((SwFmtFld*)pLast)->GetTxtFld() ) &&
- pTxtFld->GetTxtNode().GetNodes().IsDocNodes() )
- {
- SwNodeIndex aIdx( pTxtFld->GetTxtNode() );
- _PostItFld* pNew = new _PostItFld( aIdx, pTxtFld );
- rSrtLst.Insert( pNew );
- }
+ DBG_ASSERT( 0, "error: there should be no ViewOptionAdjust active when calling this function" );
}
+ m_pViewOptionAdjust = new SwViewOptionAdjust_Impl( rSh, rViewOptions );
}
-/******************************************************************************
- * Methode : void lcl_FormatPostIt( IDocumentContentOperations* pIDCO, SwPaM& aPam, ...
- * Beschreibung:
- * Erstellt : OK 07.11.94 10:20
- * Aenderung :
- ******************************************************************************/
-
-void lcl_FormatPostIt( IDocumentContentOperations* pIDCO, SwPaM& aPam, SwPostItField* pField,
- USHORT nPageNo, USHORT nLineNo )
+void SwRenderData::ViewOptionAdjust( const SwPrtOptions *pPrtOptions )
{
- static char __READONLY_DATA sTmp[] = " : ";
-
- ASSERT( ViewShell::GetShellRes(), "missing ShellRes" );
+ m_pViewOptionAdjust->AdjustViewOptions( pPrtOptions );
+}
- String aStr( ViewShell::GetShellRes()->aPostItPage );
- aStr.AppendAscii(sTmp);
- aStr += XubString::CreateFromInt32( nPageNo );
- aStr += ' ';
- if( nLineNo )
+void SwRenderData::ViewOptionAdjustStop()
+{
+ if (m_pViewOptionAdjust)
{
- aStr += ViewShell::GetShellRes()->aPostItLine;
- aStr.AppendAscii(sTmp);
- aStr += XubString::CreateFromInt32( nLineNo );
- aStr += ' ';
+ delete m_pViewOptionAdjust;
+ m_pViewOptionAdjust = 0;
}
- aStr += ViewShell::GetShellRes()->aPostItAuthor;
- aStr.AppendAscii(sTmp);
- aStr += pField->GetPar1();
- aStr += ' ';
- aStr += SvtSysLocale().GetLocaleData().getDate( pField->GetDate() );
- pIDCO->InsertString( aPam, aStr );
-
- pIDCO->SplitNode( *aPam.GetPoint(), false );
- aStr = pField->GetPar2();
-#if defined( WIN ) || defined( WNT ) || defined( PM2 )
- // Bei Windows und Co alle CR rausschmeissen
- aStr.EraseAllChars( '\r' );
-#endif
- pIDCO->InsertString( aPam, aStr );
- pIDCO->SplitNode( *aPam.GetPoint(), false );
- pIDCO->SplitNode( *aPam.GetPoint(), false );
}
-/******************************************************************************
- * Methode : void lcl_PrintPostIts( ViewShell* pPrtShell )
- * Beschreibung:
- * Erstellt : OK 07.11.94 10:21
- * Aenderung : MA 10. May. 95
- ******************************************************************************/
+void SwRenderData::MakeSwPrtOptions(
+ SwPrtOptions &rOptions,
+ const SwDocShell *pDocShell,
+ const SwPrintUIOptions *pOpt,
+ const SwRenderData *pData,
+ bool bIsPDFExport )
+{
+ if (!pDocShell || !pOpt || !pData)
+ return;
-void lcl_PrintPostIts( ViewShell* pPrtShell, const XubString& rJobName,
- BOOL& rStartJob, int& rJobStartError, BOOL bReverse)
+ // get default print options
+ const TypeId aSwWebDocShellTypeId = TYPE(SwWebDocShell);
+ BOOL bWeb = pDocShell->IsA( aSwWebDocShellTypeId );
+ rOptions.MakeOptions( bWeb );
+
+ // get print options to use from provided properties
+ rOptions.bPrintGraphic = pOpt->IsPrintGraphics();
+ rOptions.bPrintTable = pOpt->IsPrintTables();
+ rOptions.bPrintDraw = pOpt->IsPrintDrawings();
+ rOptions.bPrintControl = pOpt->IsPrintFormControls();
+ rOptions.bPrintLeftPages = pOpt->IsPrintLeftPages();
+ rOptions.bPrintRightPages = pOpt->IsPrintRightPages();
+ rOptions.bPrintPageBackground = pOpt->IsPrintPageBackground();
+ rOptions.bPrintEmptyPages = pOpt->IsPrintEmptyPages( bIsPDFExport );
+ // bUpdateFieldsInPrinting <-- not set here; mail merge only
+ rOptions.bPaperFromSetup = pOpt->IsPaperFromSetup();
+ rOptions.bPrintReverse = pOpt->IsPrintReverse();
+ rOptions.bPrintProspect = pOpt->IsPrintProspect();
+ rOptions.bPrintProspectRTL = pOpt->IsPrintProspectRTL();
+ // bPrintSingleJobs <-- not set here; mail merge and or configuration
+ // bModified <-- not set here; mail merge only
+ rOptions.bPrintBlackFont = pOpt->IsPrintWithBlackTextColor();
+ rOptions.bPrintHiddenText = pOpt->IsPrintHiddenText();
+ rOptions.bPrintTextPlaceholder = pOpt->IsPrintTextPlaceholders();
+ rOptions.nPrintPostIts = pOpt->GetPrintPostItsType();
+
+ //! needs to be set after MakeOptions since the assignment operation in that
+ //! function will destroy the pointers
+ rOptions.SetPrintUIOptions( pOpt );
+ rOptions.SetRenderData( pData );
+
+ // rOptions.aMulti is not used anymore in the XRenderable API
+ // Thus we set it to a dummy value here.
+ rOptions.aMulti = MultiSelection( Range( 1, 1 ) );
+
+ //! Note: Since for PDF export of (multi-)selection a temporary
+ //! document is created that contains only the selects parts,
+ //! and thus that document is to printed in whole the,
+ //! rOptions.bPrintSelection parameter will be false.
+ if (bIsPDFExport)
+ rOptions.bPrintSelection = FALSE;
+}
+
+
+/*****************************************************************************/
+
+SwPrintUIOptions::SwPrintUIOptions(
+ bool bWeb,
+ bool bSwSrcView,
+ bool bHasSelection,
+ bool bHasPostIts,
+ const SwPrintData &rDefaultPrintData ) :
+ m_pLast( NULL ),
+ m_rDefaultPrintData( rDefaultPrintData )
{
- // Formatieren und Ausdrucken
- pPrtShell->CalcLayout();
+ ResStringArray aLocalizedStrings( SW_RES( STR_PRINTOPTUI ) );
- SfxPrinter* pPrn = pPrtShell->getIDocumentDeviceAccess()->getPrinter( false );
+ DBG_ASSERT( aLocalizedStrings.Count() >= 44, "resource incomplete" );
+ if( aLocalizedStrings.Count() < 44 ) // bad resource ?
+ return;
- //Das Druckdokument ist ein default Dokument, mithin arbeitet es auf der
- //StandardSeite.
- SwFrm *pPage = pPrtShell->GetLayout()->Lower();
+ // printing HTML sources does not have any valid UI options.
+ // Its just the source code that gets printed ...
+ if (bSwSrcView)
+ {
+ m_aUIProperties.realloc( 0 );
+ return;
+ }
- SwPrtOptSave aPrtSave( pPrn );
+ // check if CTL is enabled
+ SvtLanguageOptions aLangOpt;
+ bool bCTL = aLangOpt.IsCTLFontEnabled();
+
+ // create sequence of print UI options
+ // (5 options are not available for Writer-Web)
+ const int nCTLOpts = bCTL ? 1 : 0;
+ const int nNumProps = nCTLOpts + (bWeb ? 14 : 20);
+ m_aUIProperties.realloc( nNumProps );
+ int nIdx = 0;
+
+ // create "writer" section (new tab page in dialog)
+ SvtModuleOptions aModOpt;
+ String aAppGroupname( aLocalizedStrings.GetString( 0 ) );
+ aAppGroupname.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%s" ) ),
+ aModOpt.GetModuleName( SvtModuleOptions::E_SWRITER ) );
+ m_aUIProperties[ nIdx++ ].Value = getGroupControlOpt( aAppGroupname, rtl::OUString() );
+
+ // create sub section for Contents
+ m_aUIProperties[ nIdx++ ].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 1 ), rtl::OUString() );
+
+ // create a bool option for background
+ bool bDefaultVal = rDefaultPrintData.IsPrintPageBackground();
+ m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 2 ),
+ aLocalizedStrings.GetString( 3 ),
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintPageBackground" ) ),
+ bDefaultVal );
+
+ // create a bool option for pictures/graphics AND OLE and drawing objects as well
+ bDefaultVal = rDefaultPrintData.IsPrintGraphic() || rDefaultPrintData.IsPrintDraw();
+ m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 4 ),
+ aLocalizedStrings.GetString( 5 ),
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintPicturesAndObjects" ) ),
+ bDefaultVal );
+ if (!bWeb)
+ {
+ // create a bool option for hidden text
+ bDefaultVal = rDefaultPrintData.IsPrintHiddenText();
+ m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 6 ),
+ aLocalizedStrings.GetString( 7 ),
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintHiddenText" ) ),
+ bDefaultVal );
+
+ // create a bool option for place holder
+ bDefaultVal = rDefaultPrintData.IsPrintTextPlaceholder();
+ m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 8 ),
+ aLocalizedStrings.GetString( 9 ),
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintTextPlaceholder" ) ),
+ bDefaultVal );
+ }
- pPrn->SetOrientation( ORIENTATION_PORTRAIT );
- pPrn->SetPaperBin( pPage->GetAttrSet()->GetPaperBin().GetValue() );
+ // create a bool option for controls
+ bDefaultVal = rDefaultPrintData.IsPrintControl();
+ m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 10 ),
+ aLocalizedStrings.GetString( 11 ),
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintControls" ) ),
+ bDefaultVal );
- if( !rStartJob && JOBSET_ERR_DEFAULT == rJobStartError &&
- rJobName.Len() )
+ // create sub section for Color
+ m_aUIProperties[ nIdx++ ].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 12 ), rtl::OUString() );
+
+ // create a bool option for printing text with black font color
+ bDefaultVal = rDefaultPrintData.IsPrintBlackFont();
+ m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 13 ),
+ aLocalizedStrings.GetString( 14 ),
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBlackFonts" ) ),
+ bDefaultVal );
+
+ if (!bWeb)
{
- if( !pPrn->IsJobActive() )
- {
- rStartJob = pPrn->StartJob( rJobName );
- if( !rStartJob )
- {
- rJobStartError = JOBSET_ERR_ERROR;
- return;
- }
- }
- pPrtShell->InitPrt( pPrn );
- rJobStartError = JOBSET_ERR_ISSTARTET;
+ // create subgroup for misc options
+ m_aUIProperties[ nIdx++ ].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 15 ) ), rtl::OUString() );
+
+ // create a bool option for printing automatically inserted blank pages
+ bDefaultVal = rDefaultPrintData.IsPrintEmptyPages();
+ m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 16 ),
+ aLocalizedStrings.GetString( 17 ),
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintEmptyPages" ) ),
+ bDefaultVal );
}
- // Wir koennen auch rueckwaerts:
- if ( bReverse )
- pPage = pPrtShell->GetLayout()->GetLastPage();
+ // create a bool option for paper tray
+ bDefaultVal = rDefaultPrintData.IsPaperFromSetup();
+ vcl::PrinterOptionsHelper::UIControlOptions aPaperTrayOpt;
+ aPaperTrayOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OptionsPageOptGroup" ) );
+ m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 18 ),
+ aLocalizedStrings.GetString( 19 ),
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintPaperFromSetup" ) ),
+ bDefaultVal,
+ aPaperTrayOpt
+ );
+
+ // print range selection
+ vcl::PrinterOptionsHelper::UIControlOptions aPrintRangeOpt;
+ aPrintRangeOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintRange" ) );
+ aPrintRangeOpt.mbInternalOnly = sal_True;
+ m_aUIProperties[nIdx++].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 37 ) ),
+ rtl::OUString(),
+ aPrintRangeOpt
+ );
+
+ // create a choice for the content to create
+ rtl::OUString aPrintRangeName( RTL_CONSTASCII_USTRINGPARAM( "PrintContent" ) );
+ uno::Sequence< rtl::OUString > aChoices( bHasSelection ? 3 : 2 );
+ uno::Sequence< rtl::OUString > aHelpText( bHasSelection ? 3 : 2 );
+ aChoices[0] = aLocalizedStrings.GetString( 38 );
+ aHelpText[0] = aLocalizedStrings.GetString( 39 );
+ aChoices[1] = aLocalizedStrings.GetString( 40 );
+ aHelpText[1] = aLocalizedStrings.GetString( 41 );
+ if (bHasSelection)
+ {
+ aChoices[2] = aLocalizedStrings.GetString( 42 );
+ aHelpText[2] = aLocalizedStrings.GetString( 43 );
+ }
+ m_aUIProperties[nIdx++].Value = getChoiceControlOpt( rtl::OUString(),
+ aHelpText,
+ aPrintRangeName,
+ aChoices,
+ bHasSelection ? 2 /*enable 'Selection' radio button*/ : 0 /* enable 'All pages' */);
+ // create a an Edit dependent on "Pages" selected
+ vcl::PrinterOptionsHelper::UIControlOptions aPageRangeOpt( aPrintRangeName, 1, sal_True );
+ m_aUIProperties[nIdx++].Value = getEditControlOpt( rtl::OUString(),
+ rtl::OUString(),
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PageRange" ) ),
+ rtl::OUString(),
+ aPageRangeOpt
+ );
+ // print content selection
+ vcl::PrinterOptionsHelper::UIControlOptions aContentsOpt;
+ aContentsOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "JobPage" ) );
+ m_aUIProperties[nIdx++].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 20 ) ),
+ rtl::OUString(),
+ aContentsOpt
+ );
+ // create a list box for notes content
+ const sal_Int16 nPrintPostIts = rDefaultPrintData.GetPrintPostIts();
+ aChoices.realloc( 4 );
+ aChoices[0] = aLocalizedStrings.GetString( 21 );
+ aChoices[1] = aLocalizedStrings.GetString( 22 );
+ aChoices[2] = aLocalizedStrings.GetString( 23 );
+ aChoices[3] = aLocalizedStrings.GetString( 24 );
+ aHelpText.realloc( 2 );
+ aHelpText[0] = aLocalizedStrings.GetString( 25 );
+ aHelpText[1] = aLocalizedStrings.GetString( 25 );
+ vcl::PrinterOptionsHelper::UIControlOptions aAnnotOpt( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintProspect" ) ), 0, sal_False );
+ aAnnotOpt.mbEnabled = bHasPostIts;
+ m_aUIProperties[ nIdx++ ].Value = getChoiceControlOpt( aLocalizedStrings.GetString( 26 ),
+ aHelpText,
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintAnnotationMode" ) ),
+ aChoices,
+ nPrintPostIts,
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) ),
+ aAnnotOpt
+ );
+
+ // create subsection for Page settings
+ vcl::PrinterOptionsHelper::UIControlOptions aPageSetOpt;
+ aPageSetOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutPage" ) );
+
+ if (!bWeb)
+ {
+ m_aUIProperties[nIdx++].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 27 ) ),
+ rtl::OUString(),
+ aPageSetOpt
+ );
+ uno::Sequence< rtl::OUString > aRLChoices( 3 );
+ aRLChoices[0] = aLocalizedStrings.GetString( 28 );
+ aRLChoices[1] = aLocalizedStrings.GetString( 29 );
+ aRLChoices[2] = aLocalizedStrings.GetString( 30 );
+ uno::Sequence< rtl::OUString > aRLHelp( 1 );
+ aRLHelp[0] = aLocalizedStrings.GetString( 31 );
+ // create a choice option for all/left/right pages
+ // 0 : all pages (left & right)
+ // 1 : left pages
+ // 2 : right pages
+ DBG_ASSERT( rDefaultPrintData.IsPrintLeftPage() || rDefaultPrintData.IsPrintRightPage(),
+ "unexpected value combination" );
+ sal_Int16 nPagesChoice = 0;
+ if (rDefaultPrintData.IsPrintLeftPage() && !rDefaultPrintData.IsPrintRightPage())
+ nPagesChoice = 1;
+ else if (!rDefaultPrintData.IsPrintLeftPage() && rDefaultPrintData.IsPrintRightPage())
+ nPagesChoice = 2;
+ m_aUIProperties[ nIdx++ ].Value = getChoiceControlOpt( aLocalizedStrings.GetString( 32 ),
+ aRLHelp,
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintLeftRightPages" ) ),
+ aRLChoices,
+ nPagesChoice,
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) )
+ );
+ }
- while( pPage )
+ // create a bool option for brochure
+ bDefaultVal = rDefaultPrintData.IsPrintProspect();
+ rtl::OUString aBrochurePropertyName( RTL_CONSTASCII_USTRINGPARAM( "PrintProspect" ) );
+ m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 33 ),
+ aLocalizedStrings.GetString( 34 ),
+ aBrochurePropertyName,
+ bDefaultVal,
+ aPageSetOpt
+ );
+
+ if (bCTL)
{
- //Mag der Anwender noch?, Abbruch erst in Prt()
- GetpApp()->Reschedule();
- ::SetSwVisArea( pPrtShell, pPage->Frm() );
- pPrn->StartPage();
- pPage->GetUpper()->Paint( pPage->Frm() );
-// SFX_APP()->SpoilDemoOutput( *pPrtShell->GetOut(), pPage->Frm().SVRect());
- SwPaintQueue::Repaint();
- pPrn->EndPage();
- pPage = bReverse ? pPage->GetPrev() : pPage->GetNext();
+ // create a bool option for brochure RTL dependent on brochure
+ uno::Sequence< rtl::OUString > aBRTLChoices( 2 );
+ aBRTLChoices[0] = aLocalizedStrings.GetString( 35 );
+ aBRTLChoices[1] = aLocalizedStrings.GetString( 36 );
+ vcl::PrinterOptionsHelper::UIControlOptions aBrochureRTLOpt( aBrochurePropertyName, -1, sal_True );
+ aBrochureRTLOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutPage" ) );
+ // RTL brochure choices
+ // 0 : left-to-right
+ // 1 : right-to-left
+ const sal_Int16 nBRTLChoice = rDefaultPrintData.IsPrintProspectRTL() ? 1 : 0;
+ m_aUIProperties[ nIdx++ ].Value = getChoiceControlOpt( rtl::OUString(),
+ uno::Sequence< rtl::OUString >(),
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintProspectRTL" ) ),
+ aBRTLChoices,
+ nBRTLChoice,
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) ),
+ aBrochureRTLOpt
+ );
}
+
+
+ DBG_ASSERT( nIdx == nNumProps, "number of added properties is not as expected" );
}
-/******************************************************************************
- * Methode : void lcl_PrintPostItsEndDoc( ViewShell* pPrtShell, ...
- * Beschreibung:
- * Erstellt : OK 07.11.94 10:21
- * Aenderung : MA 10. May. 95
- ******************************************************************************/
+SwPrintUIOptions::~SwPrintUIOptions()
+{
+}
-void lcl_PrintPostItsEndDoc( ViewShell* pPrtShell,
- _SetGetExpFlds& rPostItFields, MultiSelection &rMulti,
- const XubString& rJobName, BOOL& rStartJob, int& rJobStartError,
- BOOL bRgt, BOOL bLft, BOOL bRev )
+bool SwPrintUIOptions::IsPrintLeftPages() const
{
- USHORT nPostIts = rPostItFields.Count();
- if( !nPostIts )
- // Keine Arbeit
- return;
+ // take care of different property names for the option.
+ // for compatibility the old name should win (may still be used for PDF export or via Uno API)
+
+ // 0: left and right pages
+ // 1: left pages only
+ // 2: right pages only
+ sal_Int64 nLRPages = getIntValue( "PrintLeftRightPages", 0 /* default: all */ );
+ bool bRes = nLRPages == 0 || nLRPages == 1;
+ bRes = getBoolValue( "PrintLeftPages", bRes /* <- default value if property is not found */ );
+ return bRes;
+}
- SET_CURR_SHELL( pPrtShell );
+bool SwPrintUIOptions::IsPrintRightPages() const
+{
+ // take care of different property names for the option.
+ // for compatibility the old name should win (may still be used for PDF export or via Uno API)
- SwDoc* pPrtDoc = pPrtShell->GetDoc();
+ sal_Int64 nLRPages = getIntValue( "PrintLeftRightPages", 0 /* default: all */ );
+ bool bRes = nLRPages == 0 || nLRPages == 2;
+ bRes = getBoolValue( "PrintRightPages", bRes /* <- default value if property is not found */ );
+ return bRes;
+}
- // Dokument leeren und ans Dokumentende gehen
- SwPaM aPam( pPrtDoc->GetNodes().GetEndOfContent() );
- aPam.Move( fnMoveBackward, fnGoDoc );
- aPam.SetMark();
- aPam.Move( fnMoveForward, fnGoDoc );
- pPrtDoc->DeleteRange( aPam );
+bool SwPrintUIOptions::IsPrintEmptyPages( bool bIsPDFExport ) const
+{
+ // take care of different property names for the option.
- for( USHORT i = 0, nVirtPg, nLineNo; i < nPostIts; ++i )
- {
- _PostItFld& rPostIt = (_PostItFld&)*rPostItFields[ i ];
- if( rPostIt.GetPageNo( rMulti, bRgt, bLft, nVirtPg, nLineNo ) )
- lcl_FormatPostIt( pPrtShell->GetDoc(), aPam,
- rPostIt.GetPostIt(), nVirtPg, nLineNo );
- }
+ bool bRes = bIsPDFExport ?
+ !getBoolValue( "IsSkipEmptyPages", sal_True ) :
+ getBoolValue( "PrintEmptyPages", sal_True );
+ return bRes;
+}
- lcl_PrintPostIts( pPrtShell, rJobName, rStartJob, rJobStartError, bRev );
+bool SwPrintUIOptions::IsPrintTables() const
+{
+ // take care of different property names currently in use for this option.
+ // for compatibility the old name should win (may still be used for PDF export or via Uno API)
+
+// bool bRes = getBoolValue( "PrintTablesGraphicsAndDiagrams", sal_True );
+// bRes = getBoolValue( "PrintTables", bRes );
+// return bRes;
+ // for now it was decided that tables should always be printed
+ return true;
}
-/******************************************************************************
- * Methode : void lcl_PrintPostItsEndPage( ViewShell* pPrtShell, ...
- * Beschreibung:
- * Erstellt : OK 07.11.94 10:22
- * Aenderung :
- ******************************************************************************/
+bool SwPrintUIOptions::IsPrintGraphics() const
+{
+ // take care of different property names for the option.
+ // for compatibility the old name should win (may still be used for PDF export or via Uno API)
+ bool bRes = getBoolValue( "PrintPicturesAndObjects", sal_True );
+ bRes = getBoolValue( "PrintGraphics", bRes );
+ return bRes;
+}
-void lcl_PrintPostItsEndPage( ViewShell* pPrtShell,
- _SetGetExpFlds& rPostItFields, USHORT nPageNo, MultiSelection &rMulti,
- const XubString& rJobName, BOOL& rStartJob, int& rJobStartError,
- BOOL bRgt, BOOL bLft, BOOL bRev )
+bool SwPrintUIOptions::IsPrintDrawings() const
{
- USHORT nPostIts = rPostItFields.Count();
- if( !nPostIts )
- // Keine Arbeit
- return;
+ // take care of different property names for the option.
+ // for compatibility the old name should win (may still be used for PDF export or via Uno API)
- SET_CURR_SHELL( pPrtShell );
-
- USHORT i = 0, nVirtPg, nLineNo;
- while( ( i < nPostIts ) &&
- ( nPageNo != ((_PostItFld&)*rPostItFields[ i ]).
- GetPageNo( rMulti,bRgt, bLft, nVirtPg, nLineNo )))
- ++i;
- if(i == nPostIts)
- // Nix zu drucken
- return;
+ bool bRes = getBoolValue( "PrintPicturesAndObjects", sal_True );
+ bRes = getBoolValue( "PrintDrawings", bRes );
+ return bRes;
+}
- SwDoc* pPrtDoc = pPrtShell->GetDoc();
+bool SwPrintUIOptions::processPropertiesAndCheckFormat( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rNewProp )
+{
+ bool bChanged = processProperties( i_rNewProp );
- // Dokument leeren und ans Dokumentende gehen
- SwPaM aPam( pPrtDoc->GetNodes().GetEndOfContent() );
- aPam.Move( fnMoveBackward, fnGoDoc );
- aPam.SetMark();
- aPam.Move( fnMoveForward, fnGoDoc );
- pPrtDoc->DeleteRange( aPam );
+ uno::Reference< awt::XDevice > xRenderDevice;
+ uno::Any aVal( getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RenderDevice" ) ) ) );
+ aVal >>= xRenderDevice;
- while( i < nPostIts )
+ OutputDevice* pOut = 0;
+ if (xRenderDevice.is())
{
- _PostItFld& rPostIt = (_PostItFld&)*rPostItFields[ i ];
- if( nPageNo == rPostIt.GetPageNo( rMulti, bRgt, bLft, nVirtPg, nLineNo ) )
- lcl_FormatPostIt( pPrtShell->GetDoc(), aPam,
- rPostIt.GetPostIt(), nVirtPg, nLineNo );
- ++i;
+ VCLXDevice* pDevice = VCLXDevice::GetImplementation( xRenderDevice );
+ pOut = pDevice ? pDevice->GetOutputDevice() : 0;
}
- lcl_PrintPostIts( pPrtShell, rJobName, rStartJob, rJobStartError, bRev );
+ bChanged = bChanged || (pOut != m_pLast);
+ if( pOut )
+ m_pLast = pOut;
+
+ return bChanged;
}
+
/******************************************************************************
- * Methode : void ViewShell::InitPrt( SfxPrinter *pNew, OutputDevice *pPDFOut )
+ * Methode : void SetSwVisArea( ViewShell *pSh, Point aPrtOffset, ...
* Beschreibung:
- * Erstellt : OK 07.11.94 10:22
+ * Erstellt : OK 04.11.94 16:27
* Aenderung :
******************************************************************************/
-void ViewShell::InitPrt( SfxPrinter *pPrt, OutputDevice *pPDFOut )
+void SetSwVisArea( ViewShell *pSh, const SwRect &rRect, BOOL /*bPDFExport*/ )
+{
+ ASSERT( !pSh->GetWin(), "Drucken mit Window?" );
+ pSh->aVisArea = rRect;
+ pSh->Imp()->SetFirstVisPageInvalid();
+ Point aPt( rRect.Pos() );
+
+ // calculate an offset for the rectangle of the n-th page to
+ // move the start point of the output operation to a position
+ // such that in the output device all pages will be painted
+ // at the same position
+ aPt.X() = -aPt.X(); aPt.Y() = -aPt.Y();
+
+ OutputDevice *pOut = pSh->GetOut();
+
+ MapMode aMapMode( pOut->GetMapMode() );
+ aMapMode.SetOrigin( aPt );
+ pOut->SetMapMode( aMapMode );
+}
+
+/******************************************************************************/
+
+void ViewShell::InitPrt( OutputDevice *pOutDev )
{
//Fuer den Printer merken wir uns einen negativen Offset, der
//genau dem Offset de OutputSize entspricht. Das ist notwendig,
//weil unser Ursprung der linken ober Ecke der physikalischen
//Seite ist, die Ausgaben (SV) aber den Outputoffset als Urstprung
//betrachten.
- OutputDevice *pTmpDev = pPDFOut ? pPDFOut : (OutputDevice *) pPrt;
- if ( pTmpDev )
+ if ( pOutDev )
{
- aPrtOffst = pPrt ? pPrt->GetPageOffset() : Point();
+ aPrtOffst = Point();
- aPrtOffst += pTmpDev->GetMapMode().GetOrigin();
- MapMode aMapMode( pTmpDev->GetMapMode() );
+ aPrtOffst += pOutDev->GetMapMode().GetOrigin();
+ MapMode aMapMode( pOutDev->GetMapMode() );
aMapMode.SetMapUnit( MAP_TWIP );
- pTmpDev->SetMapMode( aMapMode );
- pTmpDev->SetLineColor();
- pTmpDev->SetFillColor();
+ pOutDev->SetMapMode( aMapMode );
+ pOutDev->SetLineColor();
+ pOutDev->SetFillColor();
}
else
aPrtOffst.X() = aPrtOffst.Y() = 0;
if ( !pWin )
- pOut = pTmpDev; //Oder was sonst?
+ pOut = pOutDev; //Oder was sonst?
}
/******************************************************************************
@@ -638,14 +850,6 @@ void ViewShell::ChgAllPageSize( Size &rSz )
}
}
-/******************************************************************************
- * Methode : void ViewShell::CalcPagesForPrint( short nMax, BOOL ...
- * Beschreibung:
- * Erstellt : OK 04.11.94 15:33
- * Aenderung : MA 07. Jun. 95
- ******************************************************************************/
-
-
void lcl_SetState( SfxProgress& rProgress, ULONG nPage, ULONG nMax,
const XubString *pStr, ULONG nAct, ULONG nCnt, ULONG nOffs, ULONG nPageNo )
@@ -674,50 +878,19 @@ void lcl_SetState( SfxProgress& rProgress, ULONG nPage, ULONG nMax,
-void ViewShell::CalcPagesForPrint( USHORT nMax, SfxProgress* pProgress,
- const XubString* pStr, ULONG nMergeAct, ULONG nMergeCnt )
+void ViewShell::CalcPagesForPrint( USHORT nMax )
{
SET_CURR_SHELL( this );
- //Seitenweise durchformatieren, by the way kann die Statusleiste
- //angetriggert werden, damit der Anwender sieht worauf er wartet.
- //Damit der Vorgang moeglichst transparent gestaltet werden kann
- //Versuchen wir mal eine Schaetzung.
- SfxPrinter* pPrt = getIDocumentDeviceAccess()->getPrinter( false );
- BOOL bPrtJob = pPrt ? pPrt->IsJobActive() : FALSE;
SwRootFrm* pLayout = GetLayout();
- ULONG nStatMax = pLayout->GetPageNum();
+ // ULONG nStatMax = pLayout->GetPageNum();
const SwFrm *pPage = pLayout->Lower();
SwLayAction aAction( pLayout, Imp() );
- if( pProgress )
- {
- // HACK, damit die Anzeige sich nicht verschluckt.
- const XubString aTmp( SW_RES( STR_STATSTR_FORMAT ) );
- pProgress->SetText( aTmp );
- lcl_SetState( *pProgress, 1, nStatMax, pStr, nMergeAct, nMergeCnt, 0, 1 );
- pProgress->Reschedule(); //Mag der Anwender noch oder hat er genug?
- aAction.SetProgress(pProgress);
- }
-
pLayout->StartAllAction();
for ( USHORT i = 1; pPage && i <= nMax; pPage = pPage->GetNext(), ++i )
{
- if ( ( bPrtJob && !pPrt->IsJobActive() ) || Imp()->IsStopPrt() )
- break;
-
- if( pProgress )
- {
- //HACK, damit die Anzeige sich nicht verschluckt.
- if ( i > nStatMax ) nStatMax = i;
- lcl_SetState( *pProgress, i, nStatMax, pStr, nMergeAct, nMergeCnt, 0, i );
- pProgress->Reschedule(); //Mag der Anwender noch oder hat er genug?
- }
-
- if ( ( bPrtJob && !pPrt->IsJobActive() ) || Imp()->IsStopPrt() )
- break;
-
pPage->Calc();
SwRect aOldVis( VisArea() );
aVisArea = pPage->Frm();
@@ -731,34 +904,23 @@ void ViewShell::CalcPagesForPrint( USHORT nMax, SfxProgress* pProgress,
aVisArea = aOldVis; //Zuruecksetzen wg. der Paints!
Imp()->SetFirstVisPageInvalid();
- SwPaintQueue::Repaint();
-
- if ( pProgress )
- pProgress->Reschedule(); //Mag der Anwender noch oder hat er genug?
+// SwPaintQueue::Repaint();
}
-
- if (pProgress)
- aAction.SetProgress( NULL );
-
pLayout->EndAllAction();
}
/******************************************************************************/
-SwDoc * ViewShell::CreatePrtDoc( SfxPrinter* pPrt, SfxObjectShellRef &rDocShellRef)
+SwDoc * ViewShell::CreatePrtDoc( SfxObjectShellRef &rDocShellRef)
{
ASSERT( this->IsA( TYPE(SwFEShell) ),"ViewShell::Prt for FEShell only");
SwFEShell* pFESh = (SwFEShell*)this;
// Wir bauen uns ein neues Dokument
SwDoc *pPrtDoc = new SwDoc;
pPrtDoc->acquire();
- pPrtDoc->SetRefForDocShell( boost::addressof(rDocShellRef) );
+ pPrtDoc->SetRefForDocShell( (SfxObjectShellRef*)&(long&)rDocShellRef );
pPrtDoc->LockExpFlds();
- // Der Drucker wird uebernommen
- if (pPrt)
- pPrtDoc->setPrinter( pPrt, true, true );
-
const SfxPoolItem* pCpyItem;
const SfxItemPool& rPool = GetAttrPool();
for( USHORT nWh = POOLATTR_BEGIN; nWh < POOLATTR_END; ++nWh )
@@ -849,6 +1011,7 @@ SwDoc * ViewShell::CreatePrtDoc( SfxPrinter* pPrt, SfxObjectShellRef &rDocShellR
}
return pPrtDoc;
}
+
SwDoc * ViewShell::FillPrtDoc( SwDoc *pPrtDoc, const SfxPrinter* pPrt)
{
ASSERT( this->IsA( TYPE(SwFEShell) ),"ViewShell::Prt for FEShell only");
@@ -856,7 +1019,7 @@ SwDoc * ViewShell::FillPrtDoc( SwDoc *pPrtDoc, const SfxPrinter* pPrt)
// Wir bauen uns ein neues Dokument
// SwDoc *pPrtDoc = new SwDoc;
// pPrtDoc->acquire();
-// pPrtDoc->SetRefForDocShell( boost::addressof(rDocShellRef) );
+// pPrtDoc->SetRefForDocShell( (SvEmbeddedObjectRef*)&(long&)rDocShellRef );
pPrtDoc->LockExpFlds();
// Der Drucker wird uebernommen
@@ -958,76 +1121,41 @@ SwDoc * ViewShell::FillPrtDoc( SwDoc *pPrtDoc, const SfxPrinter* pPrt)
return pPrtDoc;
}
-/******************************************************************************
- * Methode : void ViewShell::Prt( const SwPrtOptions& rOptions,
- * SfxProgress* pProgress,
- * OutputDevice* pPDFOut )
- * Beschreibung:
- * Erstellt : OK 04.11.94 15:33
- * Aenderung : MA 10. May. 95
- ******************************************************************************/
-
-BOOL ViewShell::Prt( SwPrtOptions& rOptions, SfxProgress* pProgress,
- OutputDevice* pPDFOut )
+sal_Bool ViewShell::PrintOrPDFExport(
+ OutputDevice *pOutDev,
+ const SwPrtOptions &rPrintData,
+ sal_Int32 nRenderer /* the index in the vector of pages to be printed */ )
{
-//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-//Immer die Druckroutine in viewpg.cxx (fuer Seitenvorschau) mitpflegen!!
-//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- ASSERT( pPDFOut || pProgress, "Printing without progress bar!" )
-
- BOOL bStartJob = FALSE;
-
- //! Note: Since for PDF export of (multi-)selection a temporary
- //! document is created that contains only the selects parts,
- //! and thus that document is to printed in whole the,
- //! rOptions.bPrintSelection parameter will be false.
- BOOL bSelection = rOptions.bPrintSelection;
-
- MultiSelection aMulti( rOptions.aMulti );
-
- if ( !aMulti.GetSelectCount() )
- return bStartJob;
-
- Range aPages( aMulti.FirstSelected(), aMulti.LastSelected() );
- if ( aPages.Max() > USHRT_MAX )
- aPages.Max() = USHRT_MAX;
+//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+//Immer die Druckroutinen in viewpg.cxx (PrintProspect) mitpflegen!!
+//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- ASSERT( aPages.Min() > 0,
- "Seite 0 Drucken?" );
- ASSERT( aPages.Min() <= aPages.Max(),
- "MinSeite groesser MaxSeite." );
-
- SfxPrinter* pPrt = 0; //!! will be 0 for PDF export !!
- if (pPDFOut)
- pPDFOut->Push();
- else
- {
- // wenn kein Drucker vorhanden ist, wird nicht gedruckt
- pPrt = getIDocumentDeviceAccess()->getPrinter( false );
- if( !pPrt || !pPrt->GetName().Len() )
- {
- ASSERT( FALSE, "Drucken ohne Drucker?" );
- return bStartJob;
- }
-
- if( !rOptions.GetJobName().Len() && !pPrt->IsJobActive() )
- return bStartJob;
- }
-
- // Einstellungen am Drucker merken
- SwPrtOptSave aPrtSave( pPrt );
+ const sal_Int32 nMaxRenderer = rPrintData.GetRenderData().GetPagesToPrint().size() - 1;
+#if OSL_DEBUG_LEVEL > 1
+ DBG_ASSERT( 0 <= nRenderer && nRenderer <= nMaxRenderer, "nRenderer out of bounds");
+#endif
+ if (!pOutDev || nMaxRenderer < 0 || nRenderer < 0 || nRenderer > nMaxRenderer)
+ return sal_False;
- OutputDevice *pPrtOrPDFOut = pPDFOut ? pPDFOut : (OutputDevice *) pPrt;
+ // save settings of OutputDevice (should be done always since the
+ // output device is now provided by a call from outside the Writer)
+ pOutDev->Push();
// eine neue Shell fuer den Printer erzeugen
ViewShell *pShell;
- SwDoc *pPrtDoc;
+ SwDoc *pOutDevDoc;
//!! muss warum auch immer hier in diesem scope existieren !!
//!! (h?ngt mit OLE Objekten im Dokument zusammen.)
SfxObjectShellRef aDocShellRef;
+ //! Note: Since for PDF export of (multi-)selection a temporary
+ //! document is created that contains only the selects parts,
+ //! and thus that document is to printed in whole the,
+ //! rPrintData.bPrintSelection parameter will be false.
+ BOOL bSelection = rPrintData.bPrintSelection;
+
// PDF export for (multi-)selection has already generated a temporary document
// with the selected text. (see XRenderable implementation in unotxdoc.cxx)
// Thus we like to go in the 'else' part here in that case.
@@ -1036,443 +1164,100 @@ BOOL ViewShell::Prt( SwPrtOptions& rOptions, SfxProgress* pProgress,
// to be created that often here in the 'then' part.
if ( bSelection )
{
- pPrtDoc = CreatePrtDoc( pPrt, aDocShellRef );
+ pOutDevDoc = CreatePrtDoc( aDocShellRef );
// eine ViewShell darauf
- OutputDevice *pTmpDev = pPDFOut ? pPDFOut : 0;
- pShell = new ViewShell( *pPrtDoc, 0, pOpt, pTmpDev );
- pPrtDoc->SetRefForDocShell( 0 );
+ pShell = new ViewShell( *pOutDevDoc, 0, pOpt, pOutDev );
+ pOutDevDoc->SetRefForDocShell( 0 );
}
else
{
- pPrtDoc = GetDoc();
- OutputDevice *pTmpDev = pPDFOut ? pPDFOut : 0;
- pShell = new ViewShell( *this, 0, pTmpDev );
+ pOutDevDoc = GetDoc();
+ pShell = new ViewShell( *this, 0, pOutDev );
+ }
+
+ SdrView *pDrawView = pShell->GetDrawView();
+ if (pDrawView)
+ {
+ pDrawView->SetBufferedOutputAllowed( false );
+ pDrawView->SetBufferedOverlayAllowed( false );
}
{ //Zusaetzlicher Scope, damit die CurrShell vor dem zerstoeren der
//Shell zurueckgesetzt wird.
- SET_CURR_SHELL( pShell );
-
- if ( pProgress )
- {
- Link aLnk = LINK(pShell->Imp(), SwViewImp, SetStopPrt);
- ((SfxPrintProgress *)pProgress)->SetCancelHdl(aLnk);
- }
+ SET_CURR_SHELL( pShell );
- //JP 01.02.99: das ReadOnly Flag wird NIE mitkopiert; Bug 61335
- if( pOpt->IsReadonly() )
- pShell->pOpt->SetReadonly( TRUE );
+ //JP 01.02.99: das ReadOnly Flag wird NIE mitkopiert; Bug 61335
+ if( pOpt->IsReadonly() )
+ pShell->pOpt->SetReadonly( TRUE );
- // save options at draw view:
- SwDrawViewSave aDrawViewSave( pShell->GetDrawView() );
+ // save options at draw view:
+ SwDrawViewSave aDrawViewSave( pShell->GetDrawView() );
- pShell->PrepareForPrint( rOptions );
+ pShell->PrepareForPrint( rPrintData );
- XubString* pStr = 0;
- ULONG nMergeAct = rOptions.nMergeAct, nMergeCnt = rOptions.nMergeCnt;
- if ( pProgress )
- {
- if( nMergeAct )
+ const sal_Int32 nPage = rPrintData.GetRenderData().GetPagesToPrint()[ nRenderer ];
+#if OSL_DEBUG_LEVEL > 1
+ DBG_ASSERT( nPage == 0 || rPrintData.GetRenderData().GetValidPagesSet().count( nPage ) == 1, "nPage not valid" );
+#endif
+ const SwPageFrm *pStPage = 0;
+ if (nPage > 0) // a 'regular' page, not one from the post-it document
{
- pStr = new SW_RESSTR(STR_STATSTR_LETTER);
- *pStr += ' ';
- *pStr += XubString::CreateFromInt64( nMergeAct );
- if( nMergeCnt )
- {
- *pStr += '/';
- *pStr += XubString::CreateFromInt64( nMergeCnt );
- }
+ const SwRenderData::ValidStartFramesMap_t &rFrms = rPrintData.GetRenderData().GetValidStartFrames();
+ SwRenderData::ValidStartFramesMap_t::const_iterator aIt( rFrms.find( nPage ) );
+ DBG_ASSERT( aIt != rFrms.end(), "failed to find start frame" );
+ if (aIt == rFrms.end())
+ return sal_False;
+ pStPage = aIt->second;
}
- else
+ else // a page from the post-its document ...
{
- ++nMergeAct;
+ DBG_ASSERT( nPage == 0, "unexpected page number. 0 for post-it pages expected" );
+ pStPage = rPrintData.GetRenderData().GetPostItStartFrames()[ nRenderer ];
}
- }
+ DBG_ASSERT( pStPage, "failed to get start page" );
- // Seiten fuers Drucken formatieren
- pShell->CalcPagesForPrint( (USHORT)aPages.Max(), pProgress, pStr,
- nMergeAct, nMergeCnt );
-
- // Some field types, can require a valid layout
- // (expression fields in tables). For these we do an UpdateFlds
- // here after calculation of the pages.
- // --> FME 2004-06-21 #i9684# For performance reasons, we do not update
- // the fields during pdf export.
- // #i56195# prevent update of fields (for mail merge)
- if ( !pPDFOut && rOptions.bUpdateFieldsInPrinting )
- // <--
- pShell->UpdateFlds(TRUE);
-
- if( !pShell->Imp()->IsStopPrt() &&
- ( pPDFOut || rOptions.GetJobName().Len() || pPrt->IsJobActive()) )
- {
- BOOL bStop = FALSE;
- int nJobStartError = JOBSET_ERR_DEFAULT;
+ //!! applying view options and formatting the dcoument should now only be done in getRendererCount!
- USHORT nCopyCnt = rOptions.bCollate ? rOptions.nCopyCount : 1;
+ ViewShell *pViewSh2 = nPage == 0 ? /* post-it page? */
+ rPrintData.GetRenderData().m_pPostItShell : pShell;
+ ::SetSwVisArea( pViewSh2, pStPage->Frm() );
- USHORT nPrintCount = 1;
- XubString sJobName( rOptions.GetJobName() );
-
- for ( USHORT nCnt = 0; !bStop && nCnt < nCopyCnt; nCnt++ )
+ // wenn wir einen Umschlag drucken wird ein Offset beachtet
+ if( pStPage->GetFmt()->GetPoolFmtId() == RES_POOLPAGE_JAKET )
{
- const SwPageFrm *pStPage = (SwPageFrm*)pShell->GetLayout()->Lower();
- const SwFrm *pEndPage = pStPage;
-
- USHORT nFirstPageNo = 0;
- USHORT nLastPageNo = 0;
- USHORT nPageNo = 1;
-
- if (pPrt)
- {
- if( rOptions.IsPrintSingleJobs() && sJobName.Len() &&
- ( bStartJob || rOptions.bJobStartet ) )
- {
- pPrt->EndJob();
- bStartJob = FALSE;
- rOptions.bJobStartet = TRUE;
-
- // Reschedule statt Yield, da Yield keine Events abarbeitet
- // und es sonst eine Endlosschleife gibt.
- while( pPrt->IsPrinting() && pProgress )
- pProgress->Reschedule();
-
- sJobName = rOptions.MakeNextJobName();
- nJobStartError = JOBSET_ERR_DEFAULT;
- }
- }
-
- for( USHORT i = 1; i <= (USHORT)aPages.Max(); ++i )
- {
- if( i < (USHORT)aPages.Min() )
- {
- if( !pStPage->GetNext() )
- break;
- pStPage = (SwPageFrm*)pStPage->GetNext();
- pEndPage= pStPage;
- }
- else if( i == (USHORT)aPages.Min() )
- {
- nFirstPageNo = i;
- nLastPageNo = nFirstPageNo;
- if( !pStPage->GetNext() || (i == (USHORT)aPages.Max()) )
- break;
- pEndPage = pStPage->GetNext();
- }
- else if( i > (USHORT)aPages.Min() )
- {
- nLastPageNo = i;
- if( !pEndPage->GetNext() || (i == (USHORT)aPages.Max()) )
- break;
- pEndPage = pEndPage->GetNext();
- }
- }
-
- if( !nFirstPageNo )
- {
- bStop = TRUE;
- break;
- }
-
-// HACK: Hier muss von der MultiSelection noch eine akzeptable Moeglichkeit
-// geschaffen werden, alle Seiten von Seite x an zu deselektieren.
-// Z.B. durch SetTotalRange ....
-
-// aMulti.Select( Range( nLastPageNo+1, SELECTION_MAX ), FALSE );
- MultiSelection aTmpMulti( Range( 1, nLastPageNo ) );
- long nTmpIdx = aMulti.FirstSelected();
- static long nEndOfSelection = SFX_ENDOFSELECTION;
- while ( nEndOfSelection != nTmpIdx && nTmpIdx <= long(nLastPageNo) )
- {
- aTmpMulti.Select( nTmpIdx );
- nTmpIdx = aMulti.NextSelected();
- }
- aMulti = aTmpMulti;
-// Ende des HACKs
-
- const USHORT nSelCount = USHORT(aMulti.GetSelectCount()
- /* * nCopyCnt*/);
-
- if ( pProgress )
- {
- pProgress->SetText( SW_RESSTR(STR_STATSTR_PRINT) );
- lcl_SetState( *pProgress, 1, nSelCount, pStr,
- nMergeAct, nMergeCnt, nSelCount, 1 );
- }
-
- if ( rOptions.bPrintReverse )
- {
- const SwFrm *pTmp = pStPage;
- pStPage = (SwPageFrm*)pEndPage;
- pEndPage = pTmp;
- nPageNo = nLastPageNo;
- }
- else
- nPageNo = nFirstPageNo;
-
- // PostitListe holen
- _SetGetExpFlds aPostItFields;
- SwDoc* pPostItDoc = 0;
- ViewShell* pPostItShell = 0;
- if( rOptions.nPrintPostIts != POSTITS_NONE )
- {
- lcl_GetPostIts( pDoc, aPostItFields );
- pPostItDoc = new SwDoc;
- if (pPrt)
- pPostItDoc->setPrinter( pPrt, true, true );
- pPostItShell = new ViewShell( *pPostItDoc, 0,
- pShell->GetViewOptions() );
- // Wenn PostIts am Dokumentenende gedruckt werden sollen,
- // die Druckreihenfolge allerdings umgekehrt ist, dann hier
- if ( ( rOptions.nPrintPostIts == POSTITS_ENDDOC ) &&
- rOptions.bPrintReverse )
- lcl_PrintPostItsEndDoc( pPostItShell, aPostItFields,
- aMulti, sJobName, bStartJob, nJobStartError,
- rOptions.bPrintRightPage, rOptions.bPrintLeftPage, TRUE );
-
- }
-
- // aOldMapMode wird fuer das Drucken von Umschlaegen gebraucht.
- MapMode aOldMapMode;
-
- const SwPageDesc *pLastPageDesc = NULL;
- BOOL bSetOrient = FALSE;
- BOOL bSetPaperSz = FALSE;
- BOOL bSetPaperBin = FALSE;
- BOOL bSetPrt = FALSE;
- if (pPrt)
- {
- bSetOrient = pPrt->HasSupport( SUPPORT_SET_ORIENTATION );
- bSetPaperSz = pPrt->HasSupport( SUPPORT_SET_PAPERSIZE );
- bSetPaperBin = !rOptions.bPaperFromSetup &&
- pPrt->HasSupport( SUPPORT_SET_PAPERBIN );
- bSetPrt = bSetOrient || bSetPaperSz || bSetPaperBin;
- }
-
- if ( rOptions.nPrintPostIts != POSTITS_ONLY )
- {
- // --> FME 2005-01-05 #110536# This valiable is used to track
- // the number of pages which actually have been printed.
- // If nPagesPrinted is odd, we have to send an additional
- // empty page to the printer if we are currently in collation
- // and duplex mode and there are still some more copies of the
- // document to print.
- USHORT nPagesPrinted = 0;
- // <--
-
- while( pStPage && !bStop )
- {
- // Mag der Anwender noch ?
- if ( pProgress )
- pProgress->Reschedule();
-
- if (pPrt)
- {
- if ( JOBSET_ERR_ERROR == nJobStartError ||
- ( !pPrt->IsJobActive() && ( !sJobName.Len() || bStartJob ) ) ||
- pShell->Imp()->IsStopPrt() )
- {
- bStop = TRUE;
- break;
- }
- }
-
- ::SetSwVisArea( pShell, pStPage->Frm(), 0 != pPDFOut );
-
- // wenn wir einen Umschlag drucken wird ein Offset beachtet
- if( pStPage->GetFmt()->GetPoolFmtId() == RES_POOLPAGE_JAKET )
- {
- aOldMapMode = pPrtOrPDFOut->GetMapMode();
- Point aNewOrigin = pPrtOrPDFOut->GetMapMode().GetOrigin();
- aNewOrigin += rOptions.aOffset;
- MapMode aTmp( pPrtOrPDFOut->GetMapMode() );
- aTmp.SetOrigin( aNewOrigin );
- pPrtOrPDFOut->SetMapMode( aTmp );
- }
-
- const BOOL bRightPg = pStPage->OnRightPage();
- if( aMulti.IsSelected( nPageNo ) &&
- ( (bRightPg && rOptions.bPrintRightPage) ||
- (!bRightPg && rOptions.bPrintLeftPage) ) )
- {
- if ( bSetPrt )
- {
- // check for empty page
- const SwPageFrm& rFormatPage = pStPage->GetFormatPage();
-
- if ( pLastPageDesc != rFormatPage.GetPageDesc() )
- {
- pLastPageDesc = rFormatPage.GetPageDesc();
-
- const BOOL bLandScp = rFormatPage.GetPageDesc()->GetLandscape();
-
- if( bSetPaperBin ) // Schacht einstellen.
- pPrt->SetPaperBin( rFormatPage.GetFmt()->
- GetPaperBin().GetValue() );
-
- if (bSetOrient )
- {
- // Orientation einstellen: Breiter als Hoch
- // -> Landscape, sonst -> Portrait.
- if( bLandScp )
- pPrt->SetOrientation(ORIENTATION_LANDSCAPE);
- else
- pPrt->SetOrientation(ORIENTATION_PORTRAIT);
- }
-
- if (bSetPaperSz )
- {
- Size aSize = pStPage->Frm().SSize();
- if ( bLandScp && bSetOrient )
- {
- // landscape is always interpreted as a rotation by 90 degrees !
- // this leads to non WYSIWIG but at least it prints!
- // #i21775#
- long nWidth = aSize.Width();
- aSize.Width() = aSize.Height();
- aSize.Height() = nWidth;
- }
- Paper ePaper = SvxPaperInfo::GetSvxPaper(aSize,MAP_TWIP,TRUE);
- if ( PAPER_USER == ePaper )
- pPrt->SetPaperSizeUser( aSize );
- else
- pPrt->SetPaper( ePaper );
- }
- }
- }
-
- // Wenn PostIts nach Seite gedruckt werden sollen,
- // jedoch Reverse eingestellt ist ...
- if( rOptions.bPrintReverse &&
- rOptions.nPrintPostIts == POSTITS_ENDPAGE )
- lcl_PrintPostItsEndPage( pPostItShell, aPostItFields,
- nPageNo, aMulti, sJobName, bStartJob, nJobStartError,
- rOptions.bPrintRightPage, rOptions.bPrintLeftPage,
- rOptions.bPrintReverse );
-
- if ( pProgress )
- lcl_SetState( *pProgress, nPrintCount++, nSelCount,
- pStr, nMergeAct, nMergeCnt,
- nSelCount, nPageNo );
-
- if( !bStartJob && JOBSET_ERR_DEFAULT == nJobStartError
- && sJobName.Len() )
- {
- if( pPrt && !pPrt->IsJobActive() )
- {
- bStartJob = pPrt->StartJob( sJobName );
- if( !bStartJob )
- {
- nJobStartError = JOBSET_ERR_ERROR;
- continue;
- }
- }
-
- pShell->InitPrt( pPrt, pPDFOut );
-
- ::SetSwVisArea( pShell, pStPage->Frm(), 0 != pPDFOut );
- nJobStartError = JOBSET_ERR_ISSTARTET;
- }
- // --> FME 2005-12-12 #b6354161# Feature - Print empty pages
- if ( rOptions.bPrintEmptyPages || pStPage->Frm().Height() )
- // <--
- {
- if (pPrt)
- pPrt->StartPage();
-
- pStPage->GetUpper()->Paint( pStPage->Frm() );
- ++nPagesPrinted;
-
- if (pPrt)
- pPrt->EndPage();
- }
- SwPaintQueue::Repaint();
-
- // Wenn PostIts nach Seite gedruckt werden sollen ...
- if( (!rOptions.bPrintReverse) &&
- rOptions.nPrintPostIts == POSTITS_ENDPAGE )
- lcl_PrintPostItsEndPage( pPostItShell, aPostItFields,
- nPageNo, aMulti, sJobName, bStartJob, nJobStartError,
- rOptions.bPrintRightPage, rOptions.bPrintLeftPage,
- rOptions.bPrintReverse );
- }
-
- // den eventl. fuer Umschlaege modifizierte OutDevOffset wieder
- // zuruecksetzen.
- if( pStPage->GetFmt()->GetPoolFmtId() == RES_POOLPAGE_JAKET )
- pPrtOrPDFOut->SetMapMode( aOldMapMode );
-
- if ( pStPage == pEndPage )
- {
- // --> FME 2005-01-05 #110536# Print emtpy page if
- // we are have an odd page count in collation/duplex
- // mode and there are still some copies to print:
- if ( pPrt && ( 1 == ( nPagesPrinted % 2 ) ) &&
- DUPLEX_ON == pPrt->GetDuplexMode() &&
- nCnt + 1 < nCopyCnt )
- {
- pPrt->StartPage();
- pPrt->EndPage();
- }
- // <--
-
- pStPage = 0;
- }
- else if ( rOptions.bPrintReverse )
- {
- --nPageNo;
- pStPage = (SwPageFrm*)pStPage->GetPrev();
- }
- else
- { ++nPageNo;
- pStPage = (SwPageFrm*)pStPage->GetNext();
- }
- }
- if ( bStop )
- break;
- }
+ Point aNewOrigin = pOutDev->GetMapMode().GetOrigin();
+ aNewOrigin += rPrintData.aOffset;
+ MapMode aTmp( pOutDev->GetMapMode() );
+ aTmp.SetOrigin( aNewOrigin );
+ pOutDev->SetMapMode( aTmp );
+ }
- // Wenn PostIts am Dokumentenende gedruckt werden sollen, dann hier machen
- if( ((rOptions.nPrintPostIts == POSTITS_ENDDOC) && !rOptions.bPrintReverse)
- || (rOptions.nPrintPostIts == POSTITS_ONLY) )
- lcl_PrintPostItsEndDoc( pPostItShell, aPostItFields, aMulti,
- sJobName, bStartJob, nJobStartError,
- rOptions.bPrintRightPage, rOptions.bPrintLeftPage,
- rOptions.bPrintReverse );
+ pShell->InitPrt( pOutDev );
- if( pPostItShell )
- {
- pPostItDoc->setPrinter( 0, false, false ); //damit am echten DOC der Drucker bleibt
- delete pPostItShell; //Nimmt das PostItDoc mit ins Grab.
- }
+ pViewSh2 = nPage == 0 ? /* post-it page? */
+ rPrintData.GetRenderData().m_pPostItShell : pShell;
+ ::SetSwVisArea( pViewSh2, pStPage->Frm() );
- if( bStartJob )
- rOptions.bJobStartet = TRUE;
- }
-
- }
- delete pStr;
+ pStPage->GetUpper()->Paint( pStPage->Frm(), &rPrintData );
+ SwPaintQueue::Repaint();
} //Zus. Scope wg. CurShell!
delete pShell;
if (bSelection )
{
- // damit das Dokument nicht den Drucker mit ins Grab nimmt
- pPrtDoc->setPrinter( 0, false, false );
-
- if ( !pPrtDoc->release() )
- delete pPrtDoc;
+ if ( !pOutDevDoc->release() )
+ delete pOutDevDoc;
}
- // restore settings of OutputDevicef
- if (pPDFOut)
- pPDFOut->Pop();
+ // restore settings of OutputDevice (should be done always now since the
+ // output device is now provided by a call from outside the Writer)
+ pOutDev->Pop();
- return bStartJob;
+ return sal_True;
}
/******************************************************************************
@@ -1484,7 +1269,7 @@ BOOL ViewShell::Prt( SwPrtOptions& rOptions, SfxProgress* pProgress,
-void ViewShell::PrtOle2( SwDoc *pDoc, const SwViewOption *pOpt, SwPrtOptions& rOptions,
+void ViewShell::PrtOle2( SwDoc *pDoc, const SwViewOption *pOpt, const SwPrintData& rOptions,
OutputDevice* pOleOut, const Rectangle& rRect )
{
//Wir brauchen eine Shell fuer das Drucken. Entweder hat das Doc schon
@@ -1562,52 +1347,6 @@ BOOL ViewShell::IsAnyFieldInDoc() const
/******************************************************************************
- * Klasse : SwPrtOptSave
- * Erstellt : AMA 12.07.95
- * Aenderung : AMA 12.07.95
- * Holt sich im Ctor folgende Einstellungen des Druckers, die im Dtor dann
- * wieder im Drucker gesetzt werden (falls sie sich ueberhaupt geaendert haben)
- * - PaperBin - Orientation - PaperSize -
- ******************************************************************************/
-
-
-
-SwPrtOptSave::SwPrtOptSave( Printer *pPrinter )
- : pPrt( pPrinter )
-{
- if ( pPrt )
- {
- ePaper = pPrt->GetPaper();
- if ( PAPER_USER == ePaper )
- aSize = pPrt->GetPaperSize();
- eOrientation = pPrt->GetOrientation();
- nPaperBin = pPrt->GetPaperBin();
-
- }
-}
-
-
-
-SwPrtOptSave::~SwPrtOptSave()
-{
- if ( pPrt )
- {
- if ( PAPER_USER == ePaper )
- {
- if( pPrt->GetPaperSize() != aSize )
- pPrt->SetPaperSizeUser( aSize );
- }
- else if ( pPrt->GetPaper() != ePaper )
- pPrt->SetPaper( ePaper );
- if ( pPrt->GetOrientation() != eOrientation)
- pPrt->SetOrientation( eOrientation );
- if ( pPrt->GetPaperBin() != nPaperBin )
- pPrt->SetPaperBin( nPaperBin );
- }
-}
-
-
-/******************************************************************************
* SwDrawViewSave
*
* Saves some settings at the draw view
@@ -1633,7 +1372,7 @@ SwDrawViewSave::~SwDrawViewSave()
// OD 09.01.2003 #i6467# - method also called for page preview
-void ViewShell::PrepareForPrint( const SwPrtOptions &rOptions )
+void ViewShell::PrepareForPrint( const SwPrintData &rOptions )
{
// Viewoptions fuer den Drucker setzen
pOpt->SetGraphic ( TRUE == rOptions.bPrintGraphic );