office-gobmx/sd/source/ui/view/viewshe3.cxx

1773 lines
64 KiB
C++
Raw Normal View History

2000-09-18 11:07:07 -05:00
/*************************************************************************
*
* $RCSfile: viewshe3.cxx,v $
*
* $Revision: 1.35 $
2000-09-18 11:07:07 -05:00
*
* last change: $Author: rt $ $Date: 2004-07-13 15:02:56 $
2000-09-18 11:07:07 -05:00
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#pragma hdrstop
#include "ViewShell.hxx"
#include "GraphicViewShell.hxx"
#ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_
#include <com/sun/star/lang/Locale.hpp>
#endif
2001-03-08 05:13:02 -06:00
#include <utility>
#include <vector>
2001-03-06 09:57:00 -06:00
2000-09-18 11:07:07 -05:00
#include "app.hrc"
#include "strings.hrc"
#include "res_bmp.hrc"
#include "glob.hrc"
#include "new_foil.hrc"
#include "sdabstdlg.hxx"
#include "new_foil.hxx"
#include "fupoor.hxx"
2000-09-18 11:07:07 -05:00
#ifndef _SV_PRINTDLG_HXX
#include <svtools/printdlg.hxx>
#endif
#ifndef _SFXDISPATCH_HXX
#include <sfx2/dispatch.hxx>
#endif
2000-09-18 11:07:07 -05:00
#ifndef _SVX_PRTQRY_HXX
#include <svx/prtqry.hxx>
#endif
#ifndef _SVDOPAGE_HXX //autogen
#include <svx/svdopage.hxx>
#endif
#ifndef _SFX_PROGRESS_HXX //autogen
#include <sfx2/progress.hxx>
#endif
2000-09-18 11:07:07 -05:00
#ifndef _SVDOBJ_HXX //autogen
#include <svx/svdobj.hxx>
#endif
#ifndef _SV_MSGBOX_HXX //autogen
#include <vcl/msgbox.hxx>
#endif
#ifndef _SFX_PRINTER_HXX //autogen
#include <sfx2/printer.hxx>
#endif
#ifndef _SFX_BINDINGS_HXX //autogen
#include <sfx2/bindings.hxx>
#endif
#ifndef _SVDPAGV_HXX //autogen
#include <svx/svdpagv.hxx>
#endif
2001-02-09 04:55:15 -06:00
#ifndef _SVDETC_HXX //autogen
#include <svx/svdetc.hxx>
#endif
2000-09-18 11:07:07 -05:00
#ifndef _OUTLINER_HXX //autogen
#include <svx/outliner.hxx>
#endif
2001-03-02 08:59:05 -06:00
#ifndef _SFX_MISCCFG_HXX
#include <svtools/misccfg.hxx>
2000-09-18 11:07:07 -05:00
#endif
#ifndef _EDITSTAT_HXX //autogen
#include <svx/editstat.hxx>
#endif
#ifndef _SV_MULTISEL_HXX //autogen
#include <tools/multisel.hxx>
#endif
#ifndef _SFXINTITEM_HXX
#include <svtools/intitem.hxx>
#endif
#ifndef _SFXSTYLE_HXX //autogen
#include <svtools/style.hxx>
#endif
2001-02-09 04:55:15 -06:00
#ifndef _UNOTOOLS_LOCALEDATAWRAPPER_HXX
#include <unotools/localedatawrapper.hxx>
#endif
#ifndef _COMPHELPER_PROCESSFACTORY_HXX_
#include <comphelper/processfactory.hxx>
#endif
#ifndef _ISOLANG_HXX
#include <tools/isolang.hxx>
#endif
#ifndef _RTL_USTRBUF_HXX_
#include <rtl/ustrbuf.hxx>
#endif
2000-09-18 11:07:07 -05:00
#ifndef _SD_STLSHEET_HXX
#include "stlsheet.hxx"
#endif
#ifndef SD_WINDOW_UPDATER_HXX
#include "WindowUpdater.hxx"
#endif
#ifndef SD_DRAW_VIEW_SHELL_HXX
#include "DrawViewShell.hxx"
#endif
#ifndef SD_OUTLINE_VIEW_SHELL_HXX
#include "OutlineViewShell.hxx"
#endif
#ifndef SD_PREVIEW_WINDOW_HXX
#include "PreviewWindow.hxx"
#endif
#ifndef SD_SLIDE_VIEW_SHELL_HXX
#include "SlideViewShell.hxx"
#endif
#ifndef SD_DRAW_VIEW_HXX
#include "drawview.hxx"
#endif
2000-09-18 11:07:07 -05:00
#include "sdattr.hxx"
#include "drawdoc.hxx"
#include "sdpage.hxx"
#include "unslprms.hxx"
#ifndef SD_SLIDE_CHANGE_CHILD_WINDOW_HXX
#include "SlideChangeChildWindow.hxx"
#endif
#ifndef SD_SLIDE_CHANGE_HXX
2000-09-18 11:07:07 -05:00
#include "slidechg.hxx"
#endif
2000-09-18 11:07:07 -05:00
#include "unoaprms.hxx" // Undo-Action
#include "sdundogr.hxx" // Undo Gruppe
#ifndef SD_PREVIEW_CHILD_WINDOW_HXX
#include "PreviewChildWindow.hxx"
#endif
#ifndef SD_WINDOW_HXX
#include "Window.hxx"
#endif
#include "DrawDocShell.hxx"
#ifndef SD_FRAME_VIEW_HXX
#include "FrameView.hxx"
#endif
//CHINA001 #include "prntopts.hxx"
//CHINA001 #include "printdlg.hxx"
2000-09-28 12:05:36 -05:00
#include "optsitem.hxx"
#ifndef SD_OUTLINER_HXX
#include "Outliner.hxx"
#endif
2000-09-18 11:07:07 -05:00
// #96090#
#ifndef _SVXIDS_HXX
#include <svx/svxids.hrc>
#endif
2000-09-18 11:07:07 -05:00
#ifndef _B3D_BASE3D_HXX
#include "goodies/base3d.hxx"
#endif
#include <sfx2/request.hxx>
#include <svtools/aeitem.hxx>
#include <basic/sbstar.hxx>
2000-09-18 11:07:07 -05:00
using namespace ::com::sun::star;
using namespace ::rtl;
2000-09-18 11:07:07 -05:00
namespace sd {
2000-09-18 11:07:07 -05:00
/*************************************************************************
|*
|* EffekteWindow updaten
|*
\************************************************************************/
void ViewShell::UpdateSlideChangeWindow()
2000-09-18 11:07:07 -05:00
{
USHORT nId = SlideChangeChildWindow::GetChildWindowId();
2000-09-18 11:07:07 -05:00
SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
if( pWindow )
{
SlideChangeWindow* pSlideChangeWin = static_cast<SlideChangeWindow*>(
pWindow->GetWindow());
2000-09-18 11:07:07 -05:00
if( pSlideChangeWin && pSlideChangeWin->IsUpdateMode() )
{
SdPage* pPage = NULL;
USHORT nNoOfPages = GetDoc()->GetSdPageCount(PK_STANDARD);
2000-09-18 11:07:07 -05:00
USHORT nPage;
BOOL bPageSelected = FALSE;
// falls nichts selektiert ist, machen wir das schnell selbst
for (USHORT i = 0; i < nNoOfPages; i++)
{
pPage = GetDoc()->GetSdPage(i, PK_STANDARD);
2000-09-18 11:07:07 -05:00
if (pPage->IsSelected())
{
bPageSelected = TRUE;
break;
}
}
// ItemSet fuer Dialog (jetzt Window) fuellen
SfxItemSet aSet(GetDoc()->GetPool(), ATTR_DIA_START, ATTR_DIA_END);
2000-09-18 11:07:07 -05:00
if( bPageSelected )
{
// jetzt werden die Seitenattribute "per Hand" gemerged
BOOL bSameEffect = TRUE; // Annahme: alle Seiten haben die
BOOL bSameSpeed = TRUE; // gleichen Attribute
BOOL bSameTime = TRUE;
BOOL bSameChange = TRUE;
BOOL bSameSoundOn = TRUE;
BOOL bSameSound = TRUE;
presentation::FadeEffect eLastEffect;
FadeSpeed eLastSpeed;
ULONG nLastTime;
PresChange eLastChange;
BOOL bLastSoundOn;
String aLastSound;
// Attribute der ersten selektierten Seite
for (nPage = 0; nPage < nNoOfPages; nPage++)
{
pPage = GetDoc()->GetSdPage(nPage, PK_STANDARD);
2000-09-18 11:07:07 -05:00
if (pPage->IsSelected())
{
eLastEffect = pPage->GetFadeEffect();
eLastSpeed = pPage->GetFadeSpeed();
nLastTime = pPage->GetTime();
eLastChange = pPage->GetPresChange();
bLastSoundOn = pPage->IsSoundOn();
aLastSound = pPage->GetSoundFile();
break;
}
}
// mit den anderen selektierten Seiten vergleichen
for (; nPage < nNoOfPages; nPage++)
{
pPage = GetDoc()->GetSdPage(nPage, PK_STANDARD);
2000-09-18 11:07:07 -05:00
if (pPage->IsSelected())
{
if (eLastEffect != pPage->GetFadeEffect()) bSameEffect = FALSE;
if (eLastSpeed != pPage->GetFadeSpeed()) bSameSpeed = FALSE;
if (nLastTime != pPage->GetTime()) bSameTime = FALSE;
if (eLastChange != pPage->GetPresChange()) bSameChange = FALSE;
if (bLastSoundOn != pPage->IsSoundOn()) bSameSoundOn = FALSE;
if (aLastSound != pPage->GetSoundFile()) bSameSound = FALSE;
}
}
// das Set besetzen
if (bSameEffect) aSet.Put( DiaEffectItem( eLastEffect ) );
else aSet.InvalidateItem( ATTR_DIA_EFFECT );
if (bSameSpeed) aSet.Put( DiaSpeedItem( eLastSpeed ) );
else aSet.InvalidateItem( ATTR_DIA_SPEED );
if (bSameChange) aSet.Put( DiaAutoItem( eLastChange ) );
else aSet.InvalidateItem( ATTR_DIA_AUTO );
if (bSameTime) aSet.Put( DiaTimeItem( nLastTime ) );
else aSet.InvalidateItem( ATTR_DIA_TIME );
if (bSameSoundOn) aSet.Put(SfxBoolItem(ATTR_DIA_SOUND, bLastSoundOn));
else aSet.InvalidateItem(ATTR_DIA_SOUND);
if (bSameSound && aLastSound.Len() > 0)
{
aSet.Put(SfxStringItem(ATTR_DIA_SOUNDFILE, aLastSound));
}
else
aSet.InvalidateItem(ATTR_DIA_SOUNDFILE);
pSlideChangeWin->EnableAssignButton();
}
else // keine selektierte Seite
{
aSet.InvalidateItem( ATTR_DIA_EFFECT );
aSet.InvalidateItem( ATTR_DIA_SPEED );
aSet.InvalidateItem( ATTR_DIA_AUTO );
aSet.InvalidateItem( ATTR_DIA_TIME );
aSet.InvalidateItem( ATTR_DIA_SOUND );
aSet.InvalidateItem( ATTR_DIA_SOUNDFILE );
pSlideChangeWin->EnableAssignButton( FALSE );
}
pSlideChangeWin->Update( aSet );
}
}
}
/*************************************************************************
|*
|* Vom EffekteWindow zuweisen
|*
\************************************************************************/
void ViewShell::AssignFromSlideChangeWindow()
2000-09-18 11:07:07 -05:00
{
USHORT nId = SlideChangeChildWindow::GetChildWindowId();
2000-09-18 11:07:07 -05:00
SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
if( pWindow )
{
SlideChangeWindow* pSlideChangeWin = static_cast<SlideChangeWindow*>(
pWindow->GetWindow());
2000-09-18 11:07:07 -05:00
if( pSlideChangeWin )
{
SdPage* pPage = NULL;
USHORT nNoOfPages = GetDoc()->GetSdPageCount(PK_STANDARD);
2000-09-18 11:07:07 -05:00
USHORT nPage;
SfxItemSet aSet(GetDoc()->GetPool(), ATTR_DIA_START, ATTR_DIA_END );
2000-09-18 11:07:07 -05:00
pSlideChangeWin->GetAttr( aSet );
// Auswertung des ItemSets
// Undo Gruppe erzeugen
SdUndoGroup* pUndoGroup = new SdUndoGroup(GetDoc());
2000-09-18 11:07:07 -05:00
String aComment(SdResId(STR_UNDO_SLIDE_PARAMS));
pUndoGroup->SetComment(aComment);
for (nPage = 0; nPage < nNoOfPages; nPage++)
{
pPage = GetDoc()->GetSdPage(nPage, PK_STANDARD);
2000-09-18 11:07:07 -05:00
if (pPage->IsSelected())
{
// alte Attribute fuer UndoAction merken
FadeSpeed eOldFadeSpeed = pPage->GetFadeSpeed();
presentation::FadeEffect eOldFadeEffect = pPage->GetFadeEffect();
PresChange eOldChange = pPage->GetPresChange();
UINT32 nOldTime = pPage->GetTime();
BOOL bOldSoundOn = pPage->IsSoundOn();
String aOldSoundFile = pPage->GetSoundFile();
if (aSet.GetItemState(ATTR_DIA_EFFECT) == SFX_ITEM_SET)
{
presentation::FadeEffect eOldEffect = pPage->GetFadeEffect();
presentation::FadeEffect eNewEffect = (presentation::FadeEffect)((const DiaEffectItem&)
aSet.Get(ATTR_DIA_EFFECT)).
GetValue();
pPage->SetFadeEffect((presentation::FadeEffect)((const DiaEffectItem&)
aSet.Get(ATTR_DIA_EFFECT)).GetValue());
// ist es eine Aenderung und kann man sie sehen?
if (((eOldEffect != presentation::FadeEffect_NONE &&
eNewEffect == presentation::FadeEffect_NONE) ||
(eOldEffect == presentation::FadeEffect_NONE &&
eNewEffect != presentation::FadeEffect_NONE)) &&
(this->ISA(SlideViewShell)))
2000-09-18 11:07:07 -05:00
{
GetView()->InvalidateAllWin (
static_cast<SlideView*>(GetView())
->GetFadeIconArea(nPage));
2000-09-18 11:07:07 -05:00
}
}
if (aSet.GetItemState(ATTR_DIA_SPEED) == SFX_ITEM_SET)
pPage->SetFadeSpeed((FadeSpeed)((const DiaSpeedItem&)
aSet.Get(ATTR_DIA_SPEED)).GetValue());
if (aSet.GetItemState(ATTR_DIA_TIME) == SFX_ITEM_SET)
pPage->SetTime(((DiaTimeItem&)
aSet.Get(ATTR_DIA_TIME)).GetValue());
if (aSet.GetItemState(ATTR_DIA_AUTO) == SFX_ITEM_SET)
pPage->SetPresChange(((DiaAutoItem&)
aSet.Get(ATTR_DIA_AUTO)).GetValue());
if (aSet.GetItemState(ATTR_DIA_SOUND) == SFX_ITEM_SET)
pPage->SetSound(((SfxBoolItem&)
aSet.Get(ATTR_DIA_SOUND)).GetValue());
if (aSet.GetItemState(ATTR_DIA_SOUNDFILE) == SFX_ITEM_SET)
{
String aTemp(((SfxStringItem&)aSet.Get(ATTR_DIA_SOUNDFILE)).GetValue());
pPage->SetSoundFile(aTemp);
}
// Undo-Action erzeugen und in Gruppe stellen
SdUndoAction* pUndoAction = new SlideParametersUndoAction
(GetDoc(), pPage,
2000-09-18 11:07:07 -05:00
eOldFadeSpeed, pPage->GetFadeSpeed(),
eOldFadeEffect, pPage->GetFadeEffect(),
eOldChange, pPage->GetPresChange(),
nOldTime, pPage->GetTime(),
bOldSoundOn, pPage->IsSoundOn(),
aOldSoundFile, pPage->GetSoundFile());
pUndoGroup->AddAction(pUndoAction);
}
}
// Undo Gruppe dem Undo Manager uebergeben
GetViewFrame()->GetObjectShell()->GetUndoManager()->
AddUndoAction(pUndoGroup);
/***************************************************************
|* ggfs. in Preview anzeigen
\**************************************************************/
SfxChildWindow* pPreviewChildWindow =
GetViewFrame()->GetChildWindow(
PreviewChildWindow::GetChildWindowId());
2000-09-18 11:07:07 -05:00
if (pPreviewChildWindow)
{
PreviewWindow* pPreviewWindow = static_cast<PreviewWindow*>(
pPreviewChildWindow->GetWindow());
if (pPreviewWindow!=NULL && pPreviewWindow->GetDoc()==GetDoc())
2000-09-18 11:07:07 -05:00
{
pPreviewWindow->AnimatePage();
2000-09-18 11:07:07 -05:00
}
}
static USHORT SidArray[] = {
SID_DIA_EFFECT,
SID_DIA_SPEED,
SID_DIA_AUTO,
SID_DIA_TIME,
0 };
GetViewFrame()->GetBindings().Invalidate( SidArray );
2000-09-18 11:07:07 -05:00
// Model geaendert
GetDoc()->SetChanged();
2000-09-18 11:07:07 -05:00
}
}
}
/*************************************************************************
|*
|* Drucken der Outlinerdaten
|*
\************************************************************************/
void ViewShell::PrintOutline(SfxPrinter& rPrinter,
2000-09-18 11:07:07 -05:00
SfxProgress& rProgress,
const MultiSelection& rSelPages,
const String& rTimeDateStr,
const Font& rTimeDateFont,
const SdOptionsPrintItem* pPrintOpts,
USHORT nPage, USHORT nPageMax,
USHORT nCopies, USHORT nProgressOffset, USHORT nTotal )
{
// Papierschacht
// Seiteneinstellungen koennen nicht fuer die Gliederung gemacht werden
// (also auch nicht der Druckerschacht), deswegen wird der Druckerschacht
// von der Seite PK_STANDARD genommen.
/*
if( pPrintOpts && !pPrintOpts->IsPaperbin() ) // Drucken NICHT aus Druckereinstellung
{
USHORT nPaperBin = GetDoc()->GetSdPage(nPage, PK_STANDARD)->GetPaperBin();
2000-09-18 11:07:07 -05:00
rPrinter.SetPaperBin( nPaperBin );
} */
// Es wird jetzt (vorlaeufig ?) der Druckerschacht vom Drucker genommen
const MapMode aOldMap( rPrinter.GetMapMode() );
MapMode aMap( aOldMap );
const Orientation eOldOrient = rPrinter.GetOrientation();
Point aPageOfs( rPrinter.GetPageOffset() );
Fraction aScale(1, 2);
BOOL bPrintExcluded = TRUE;
2000-09-18 11:07:07 -05:00
aMap.SetOrigin(Point() - aPageOfs);
aMap.SetScaleX(aScale);
aMap.SetScaleY(aScale);
rPrinter.SetMapMode(aMap);
rPrinter.SetOrientation(ORIENTATION_PORTRAIT);
if ( pPrintOpts )
bPrintExcluded = pPrintOpts->IsHiddenPages();
Rectangle aOutRect(aPageOfs, rPrinter.GetOutputSize());
Link aOldLink;
Outliner* pOutliner = GetDoc()->GetInternalOutliner();
2000-09-18 11:07:07 -05:00
pOutliner->Init( OUTLINERMODE_OUTLINEVIEW );
USHORT nOutlMode = pOutliner->GetMode();
BOOL bOldUpdateMode = pOutliner->GetUpdateMode();
if (this->ISA(OutlineViewShell))
2000-09-18 11:07:07 -05:00
pOutliner->SetMinDepth(0);
Size aPaperSize = pOutliner->GetPaperSize();
pOutliner->SetPaperSize(aOutRect.GetSize());
pOutliner->SetUpdateMode(TRUE);
long nPageH = aOutRect.GetHeight();
USHORT nPageCount = nProgressOffset;
while ( nPage < nPageMax )
{
Paragraph* pPara = NULL;
long nH = 0;
pOutliner->Clear();
pOutliner->SetFirstPageNumber(nPage+1);
while ( nH < nPageH && nPage < nPageMax )
{
if ( rSelPages.IsSelected(nPage+1) )
{
//rProgress.SetState( nPageCount, nTotal );
//rProgress.SetStateText( nPageCount, nPage+1, nTotal );
String aTmp = UniString::CreateFromInt32( nPage+1 );
aTmp += String( SdResId( STR_PRINT_OUTLINE ) );
rProgress.SetStateText( nPageCount, aTmp, nTotal );
nPageCount += nCopies;
SdPage* pPage = (SdPage*)
GetDoc()->GetSdPage(nPage, PK_STANDARD);
2000-09-18 11:07:07 -05:00
SdrTextObj* pTextObj = NULL;
ULONG nObj = 0;
if ( !pPage->IsExcluded() || bPrintExcluded )
{
while ( !pTextObj && nObj < pPage->GetObjCount() )
{
SdrObject* pObj = pPage->GetObj(nObj++);
if ( pObj->GetObjInventor() == SdrInventor &&
pObj->GetObjIdentifier() == OBJ_TITLETEXT )
pTextObj = (SdrTextObj*) pObj;
}
pPara = pOutliner->GetParagraph( pOutliner->GetParagraphCount() - 1 );
if ( pTextObj && !pTextObj->IsEmptyPresObj() &&
pTextObj->GetOutlinerParaObject() )
pOutliner->AddText( *(pTextObj->GetOutlinerParaObject()) );
else
pOutliner->Insert(String());
pTextObj = NULL;
nObj = 0;
while ( !pTextObj && nObj < pPage->GetObjCount() )
{
SdrObject* pObj = pPage->GetObj(nObj++);
if ( pObj->GetObjInventor() == SdrInventor &&
pObj->GetObjIdentifier() == OBJ_OUTLINETEXT )
pTextObj = (SdrTextObj*) pObj;
}
BOOL bSubTitle = FALSE;
if (!pTextObj)
{
bSubTitle = TRUE;
pTextObj = (SdrTextObj*) pPage->GetPresObj(PRESOBJ_TEXT); // Untertitel vorhanden?
}
ULONG nParaCount1 = pOutliner->GetParagraphCount();
if ( pTextObj && !pTextObj->IsEmptyPresObj() &&
pTextObj->GetOutlinerParaObject() )
pOutliner->AddText( *(pTextObj->GetOutlinerParaObject()) );
if ( bSubTitle )
{
ULONG nParaCount2 = pOutliner->GetParagraphCount();
Paragraph* pPara = NULL;
for (ULONG nPara = nParaCount1; nPara < nParaCount2; nPara++)
{
pPara = pOutliner->GetParagraph(nPara);
2001-03-06 09:57:00 -06:00
if(pPara && pOutliner->GetDepth( (USHORT) nPara ) !=1 )
2000-09-18 11:07:07 -05:00
pOutliner->SetDepth(pPara, 1);
}
}
nH = pOutliner->GetTextHeight();
}
}
nPage++;
}
if ( nH > nPageH && pPara )
{
ULONG nCnt = pOutliner->GetAbsPos( pOutliner->GetParagraph( pOutliner->GetParagraphCount() - 1 ) );
ULONG nParaPos = pOutliner->GetAbsPos( pPara );
nCnt -= nParaPos;
pPara = pOutliner->GetParagraph( ++nParaPos );
if ( nCnt && pPara )
{
pOutliner->Remove(pPara, nCnt);
nPage--;
}
}
rPrinter.StartPage();
pOutliner->Draw(&rPrinter, aOutRect);
if ( rTimeDateStr.Len() )
{
Font aOldFont = rPrinter.OutputDevice::GetFont();
rPrinter.SetFont(rTimeDateFont);
rPrinter.DrawText(aPageOfs, rTimeDateStr);
rPrinter.SetFont(aOldFont);
}
rPrinter.EndPage();
}
pOutliner->SetUpdateMode(bOldUpdateMode);
pOutliner->SetPaperSize(aPaperSize);
pOutliner->Init( nOutlMode );
rPrinter.SetOrientation(eOldOrient);
rPrinter.SetMapMode( aOldMap );
2000-09-18 11:07:07 -05:00
}
/*************************************************************************
|*
|* Drucken der Handouts
|*
\************************************************************************/
void ViewShell::PrintHandout (
SfxPrinter& rPrinter,
SfxProgress& rProgress,
const MultiSelection& rSelPages,
const String& rTimeDateStr,
const Font& rTimeDateFont,
const SdOptionsPrintItem* pPrintOpts,
USHORT nPage,
USHORT nPageMax,
USHORT nCopies,
USHORT nProgressOffset,
USHORT nTotal )
2000-09-18 11:07:07 -05:00
{
SdrObject* pObj;
SdPage* pPage = GetDoc()->GetSdPage(0, PK_HANDOUT);
SdPage& rMaster = (SdPage&)pPage->TRG_GetMasterPage();
2000-09-18 11:07:07 -05:00
BOOL bScalePage = TRUE;
if ( pPrintOpts )
{
bScalePage = pPrintOpts->IsPagesize();
}
2000-09-18 11:07:07 -05:00
// Papierschacht
if( pPrintOpts && !pPrintOpts->IsPaperbin() ) // Drucken NICHT aus Druckereinstellung
{
USHORT nPaperBin = pPage->GetPaperBin();
rPrinter.SetPaperBin( nPaperBin );
}
// Hoch/Querformat aendern?
Orientation eOrientation = rMaster.GetOrientation();
2000-09-18 11:07:07 -05:00
short nDlgResult = RET_OK;
if ( !rPrinter.SetOrientation(eOrientation) &&
(!pPrintOpts || pPrintOpts->IsWarningOrientation()) )
{
// eine Warnung anzeigen
WarningBox aWarnBox(GetActiveWindow(),(WinBits)(WB_OK_CANCEL | WB_DEF_CANCEL),
2000-09-18 11:07:07 -05:00
String(SdResId(STR_WARN_PRINTFORMAT_FAILURE)));
nDlgResult = aWarnBox.Execute();
}
if ( nDlgResult == RET_OK )
{
const MapMode aOldMap( rPrinter.GetMapMode() );
MapMode aMap( aOldMap );
Point aPageOfs( rPrinter.GetPageOffset() );
DrawView* pPrintView;
BOOL bPrintExcluded = TRUE;
2000-09-18 11:07:07 -05:00
aMap.SetOrigin(Point() - aPageOfs);
if ( bScalePage )
{
Size aPageSize(pPage->GetSize());
Size aPrintSize( rPrinter.GetOutputSize() );
double fHorz = (double) aPrintSize.Width() / aPageSize.Width();
double fVert = (double) aPrintSize.Height() / aPageSize.Height();
Fraction aFract;
if ( fHorz < fVert )
aFract = Fraction(aPrintSize.Width(), aPageSize.Width());
else
aFract = Fraction(aPrintSize.Height(), aPageSize.Height());
aMap.SetScaleX(aFract);
aMap.SetScaleY(aFract);
aMap.SetOrigin(Point());
}
2000-09-18 11:07:07 -05:00
rPrinter.SetMapMode(aMap);
if (this->ISA(DrawViewShell))
pPrintView = new DrawView (GetDocSh(), &rPrinter,
static_cast<DrawViewShell*>(this));
2000-09-18 11:07:07 -05:00
else
pPrintView = new DrawView (GetDocSh(), &rPrinter, NULL);
2000-09-18 11:07:07 -05:00
sd::PresentationObjectList::iterator aIter;
const sd::PresentationObjectList::iterator aEnd( rMaster.GetPresObjList().end() );
USHORT nPageCount = nProgressOffset;
2000-09-18 11:07:07 -05:00
WriteFrameViewData();
nPrintedHandoutPageNum = 0;
if ( pPrintOpts )
bPrintExcluded = pPrintOpts->IsHiddenPages();
while ( nPage < nPageMax )
{
aIter = rMaster.GetPresObjList().begin();
2000-09-18 11:07:07 -05:00
// Anzahl ALLER Seiten im Dokument:
USHORT nAbsPageCnt = GetDoc()->GetPageCount();
2000-09-18 11:07:07 -05:00
while( (aIter != aEnd) && (nPage < nPageMax) )
2000-09-18 11:07:07 -05:00
{
if( (*aIter).meKind == PRESOBJ_HANDOUT )
2000-09-18 11:07:07 -05:00
{
pObj = (*aIter).mpObject;
2000-09-18 11:07:07 -05:00
if ( rSelPages.IsSelected(nPage+1) )
{
//rProgress.SetState( nPageCount, nTotal );
//rProgress.SetStateText( nPageCount, nPage+1, nTotal );
2000-09-18 11:07:07 -05:00
String aTmp = UniString::CreateFromInt32( nPage+1 );
aTmp += String( SdResId( STR_PRINT_HANDOUT ) );
rProgress.SetStateText( nPageCount, aTmp, nTotal );
2000-09-18 11:07:07 -05:00
nPageCount += nCopies;
2000-09-18 11:07:07 -05:00
SdPage* pPg = GetDoc()->GetSdPage(nPage, PK_STANDARD);
if ( !pPg->IsExcluded() || bPrintExcluded )
2000-09-18 11:07:07 -05:00
{
if ( pObj->ISA(SdrPageObj) )
{
((SdrPageObj*) pObj)->SetReferencedPage(pPg);
}
else
{
DBG_ERROR("SdViewShell::PrintHandout() - PRESOBJ_HANDOUT is no SdrPageObj?" );
}
aIter++;
2000-09-18 11:07:07 -05:00
}
}
nPage++;
}
else
{
aIter++;
2000-09-18 11:07:07 -05:00
}
}
while ( aIter != aEnd )
{
if( (*aIter).meKind == PRESOBJ_HANDOUT )
{
pObj = (*aIter).mpObject;
// invalidate remaining SdrPageObjs with
// an invalid page number
if ( pObj->ISA(SdrPageObj) )
((SdrPageObj*) pObj)->SetReferencedPage(0L);
}
aIter++;
2000-09-18 11:07:07 -05:00
}
nPrintedHandoutPageNum++;
rPrinter.StartPage();
pPrintView->ShowPage(pPage, Point());
SdrPageView* pPageView = pPrintView->GetPageView(pPage);
pPageView->SetVisibleLayers( pFrameView->GetVisibleLayers() );
pPageView->SetPrintableLayers( pFrameView->GetPrintableLayers() );
pPrintView->CompleteRedraw(&rPrinter, Rectangle(Point(0,0),
2000-09-18 11:07:07 -05:00
pPage->GetSize()));
if ( rTimeDateStr.Len() )
{
Font aOldFont = rPrinter.OutputDevice::GetFont();
rPrinter.SetFont(rTimeDateFont);
rPrinter.DrawText(aPageOfs, rTimeDateStr);
rPrinter.SetFont(aOldFont);
}
rPrinter.EndPage();
pPrintView->HidePage(pPrintView->GetPageView(pPage));
}
USHORT nRealPage = GetDoc()->GetSdPage(0, PK_STANDARD)->GetPageNum();
2000-09-18 11:07:07 -05:00
aIter = rMaster.GetPresObjList().begin();
pObj = (aIter != aEnd) ? (*aIter++).mpObject : NULL;
while( aIter != aEnd )
{
if( (*aIter).meKind == PRESOBJ_HANDOUT )
2000-09-18 11:07:07 -05:00
{
pObj = (*aIter).mpObject;
// Seitenobjekte wieder auf erste Seite setzen
if ( pObj->ISA(SdrPageObj) )
{
((SdrPageObj*) pObj)->SetReferencedPage(GetDoc()->GetPage(nRealPage));
nRealPage += 2;
}
2000-09-18 11:07:07 -05:00
}
aIter++;
2000-09-18 11:07:07 -05:00
}
nPrintedHandoutPageNum = 1;
delete pPrintView;
rPrinter.SetMapMode(aOldMap);
}
}
/*************************************************************************
|*
|* Drucken der normalen Seiten oder der Notizseiten
|*
\************************************************************************/
void ViewShell::PrintStdOrNotes(SfxPrinter& rPrinter,
2000-09-18 11:07:07 -05:00
SfxProgress& rProgress,
const MultiSelection& rSelPages,
const String& rTimeDateStr,
const Font& rTimeDateFont,
const SdOptionsPrintItem* pPrintOpts,
USHORT nPage, USHORT nPageMax,
USHORT nCopies, USHORT nProgressOffset, USHORT nTotal,
PageKind ePageKind, BOOL bPrintMarkedOnly)
{
Fraction aFract;
BOOL bScalePage = TRUE;
BOOL bTilePage = FALSE;
BOOL bPrintExcluded = TRUE;
BOOL bPrintPageName = TRUE;
BOOL bPrintBooklet = FALSE;
BOOL bPrintFrontPage = FALSE;
BOOL bPrintBackPage = FALSE;
SdPage* pPage = GetDoc()->GetSdPage(nPage, ePageKind);
2000-09-18 11:07:07 -05:00
if ( pPrintOpts )
{
bScalePage = pPrintOpts->IsPagesize();
bTilePage = pPrintOpts->IsPagetile();
bPrintPageName = pPrintOpts->IsPagename();
bPrintExcluded = pPrintOpts->IsHiddenPages();
bPrintBooklet = pPrintOpts->IsBooklet();
bPrintFrontPage = pPrintOpts->IsFrontPage();
bPrintBackPage = pPrintOpts->IsBackPage();
// Papierschacht
if( !pPrintOpts->IsPaperbin() ) // Drucken NICHT aus Druckereinstellung
{
USHORT nPaperBin = GetDoc()->GetSdPage(nPage, ePageKind)->GetPaperBin();
2000-09-18 11:07:07 -05:00
rPrinter.SetPaperBin( nPaperBin );
}
}
// Hoch/Querformat aendern?
Size aPageSize(pPage->GetSize());
Orientation eOrientation = ORIENTATION_PORTRAIT;
short nDlgResult = RET_OK;
if( !bPrintBooklet )
{
eOrientation = pPage->GetOrientation();
}
else if( aPageSize.Width() < aPageSize.Height() )
eOrientation = ORIENTATION_LANDSCAPE;
2000-09-18 11:07:07 -05:00
if ( !rPrinter.SetOrientation(eOrientation) &&
(!pPrintOpts || pPrintOpts->IsWarningOrientation()) )
{
// eine Warnung anzeigen
WarningBox aWarnBox(GetActiveWindow(),(WinBits)(WB_OK_CANCEL | WB_DEF_CANCEL),
2000-09-18 11:07:07 -05:00
String(SdResId(STR_WARN_PRINTFORMAT_FAILURE)));
nDlgResult = aWarnBox.Execute();
}
if ( nDlgResult == RET_OK )
{
const MapMode aOldMap( rPrinter.GetMapMode() );
MapMode aMap( aOldMap );
Point aPageOfs( rPrinter.GetPageOffset() );
DrawView* pPrintView;
2000-09-18 11:07:07 -05:00
aMap.SetOrigin(Point() - aPageOfs);
rPrinter.SetMapMode(aMap);
Size aPrintSize( rPrinter.GetOutputSize() );
2000-09-18 11:07:07 -05:00
if (this->ISA(DrawViewShell))
pPrintView = new DrawView (GetDocSh(), &rPrinter,
static_cast<DrawViewShell*>(this));
2000-09-18 11:07:07 -05:00
else
pPrintView = new DrawView (GetDocSh(), &rPrinter, NULL);
2000-09-18 11:07:07 -05:00
USHORT nPageCount = nProgressOffset;
// Als Broschuere drucken ?
if( bPrintBooklet )
{
2001-03-06 09:57:00 -06:00
SdPage* pPage;
MapMode aStdMap( rPrinter.GetMapMode() );
::std::vector< USHORT > aPageVector;
::std::vector< ::std::pair< USHORT, USHORT > > aPairVector;
Point aOffset;
Size aPrintSize_2( aPrintSize );
Size aPageSize_2( aPageSize );
2001-03-06 09:57:00 -06:00
if( eOrientation == ORIENTATION_LANDSCAPE )
aPrintSize_2.Width() >>= 1;
2000-09-18 11:07:07 -05:00
else
aPrintSize_2.Height() >>= 1;
const double fPageWH = (double) aPageSize_2.Width() / aPageSize_2.Height();
const double fPrintWH = (double) aPrintSize_2.Width() / aPrintSize_2.Height();
if( fPageWH < fPrintWH )
{
aPageSize_2.Width() = (long) ( aPrintSize_2.Height() * fPageWH );
aPageSize_2.Height()= aPrintSize_2.Height();
}
else
{
aPageSize_2.Width() = aPrintSize_2.Width();
aPageSize_2.Height() = (long) ( aPrintSize_2.Width() / fPageWH );
}
aMap.SetScaleX( Fraction( aPageSize_2.Width(), aPageSize.Width() ) );
aMap.SetScaleY( Fraction( aPageSize_2.Height(), aPageSize.Height() ) );
2000-09-18 11:07:07 -05:00
// calculate adjusted print size
aPrintSize = OutputDevice::LogicToLogic( aPrintSize, aStdMap, aMap );
if( eOrientation == ORIENTATION_LANDSCAPE )
{
aOffset.X() = ( ( aPrintSize.Width() >> 1 ) - aPageSize.Width() ) >> 1;
aOffset.Y() = ( aPrintSize.Height() - aPageSize.Height() ) >> 1;
}
else
{
aOffset.X() = ( aPrintSize.Width() - aPageSize.Width() ) >> 1;
aOffset.Y() = ( ( aPrintSize.Height() >> 1 ) - aPageSize.Height() ) >> 1;
}
2000-09-18 11:07:07 -05:00
2001-03-06 09:57:00 -06:00
// create vector of pages to print
while( nPage < nPageMax )
2000-09-18 11:07:07 -05:00
{
2001-03-06 09:57:00 -06:00
if( rSelPages.IsSelected( nPage + 1 ) )
2000-09-18 11:07:07 -05:00
{
SdPage* pPage = GetDoc()->GetSdPage( nPage, ePageKind );
2000-09-18 11:07:07 -05:00
2001-03-06 09:57:00 -06:00
if( pPage && ( !pPage->IsExcluded() || bPrintExcluded ) )
aPageVector.push_back( nPage );
}
2000-09-18 11:07:07 -05:00
2001-03-06 09:57:00 -06:00
nPage++;
}
// create pairs of pages to print on each page
if( aPageVector.size() )
{
sal_uInt32 nFirstIndex = 0, nLastIndex = aPageVector.size() - 1;
if( aPageVector.size() & 1 )
2001-03-09 04:07:37 -06:00
aPairVector.push_back( ::std::make_pair( (USHORT) 65535, aPageVector[ nFirstIndex++ ] ) );
2001-03-06 09:57:00 -06:00
else
aPairVector.push_back( ::std::make_pair( aPageVector[ nLastIndex-- ], aPageVector[ nFirstIndex++ ] ) );
while( nFirstIndex < nLastIndex )
{
if( nFirstIndex & 1 )
aPairVector.push_back( ::std::make_pair( aPageVector[ nFirstIndex++ ], aPageVector[ nLastIndex-- ] ) );
else
aPairVector.push_back( ::std::make_pair( aPageVector[ nLastIndex-- ], aPageVector[ nFirstIndex++ ] ) );
2000-09-18 11:07:07 -05:00
}
2001-03-06 09:57:00 -06:00
}
for( sal_uInt32 i = 0; i < aPairVector.size(); i++ )
{
if( ( !( i & 1 ) && bPrintFrontPage ) || ( ( i & 1 ) && bPrintBackPage ) )
2000-09-18 11:07:07 -05:00
{
2001-03-06 09:57:00 -06:00
const ::std::pair< USHORT, USHORT > aPair( aPairVector[ i ] );
2000-09-18 11:07:07 -05:00
rPrinter.StartPage();
pPage = GetDoc()->GetSdPage( aPair.first, ePageKind );
2001-03-06 09:57:00 -06:00
if( pPage )
2000-09-18 11:07:07 -05:00
{
aMap.SetOrigin( aOffset );
2000-09-18 11:07:07 -05:00
rPrinter.SetMapMode( aMap );
PrintPage( rPrinter, pPrintView, pPage, bPrintMarkedOnly );
}
2001-03-06 09:57:00 -06:00
pPage = GetDoc()->GetSdPage( aPair.second, ePageKind );
2001-03-06 09:57:00 -06:00
if( pPage )
2000-09-18 11:07:07 -05:00
{
Point aSecondOffset( aOffset );
2000-09-18 11:07:07 -05:00
if( eOrientation == ORIENTATION_LANDSCAPE )
aSecondOffset.X() += ( aPrintSize.Width() >> 1 );
2000-09-18 11:07:07 -05:00
else
aSecondOffset.Y() += ( aPrintSize.Height() >> 1 );
2001-03-06 09:57:00 -06:00
aMap.SetOrigin( aSecondOffset );
2000-09-18 11:07:07 -05:00
rPrinter.SetMapMode( aMap );
PrintPage( rPrinter, pPrintView, pPage, bPrintMarkedOnly );
}
2001-03-06 09:57:00 -06:00
2000-09-18 11:07:07 -05:00
rPrinter.EndPage();
}
}
2001-03-06 09:57:00 -06:00
2000-09-18 11:07:07 -05:00
rPrinter.SetMapMode( aStdMap );
}
else
{
WriteFrameViewData();
Point aPtZero;
while ( nPage < nPageMax )
{
if ( rSelPages.IsSelected(nPage+1) )
{
SdPage* pPage = GetDoc()->GetSdPage(nPage, ePageKind);
2000-09-18 11:07:07 -05:00
// Kann sich die Seitengroesse geaendert haben?
aPageSize = pPage->GetSize();
rProgress.SetState( nPageCount, nTotal );
nPageCount += nCopies;
if ( bScalePage )
{
double fHorz = (double) aPrintSize.Width() / aPageSize.Width();
double fVert = (double) aPrintSize.Height() / aPageSize.Height();
if ( fHorz < fVert )
aFract = Fraction(aPrintSize.Width(), aPageSize.Width());
else
aFract = Fraction(aPrintSize.Height(), aPageSize.Height());
aMap.SetScaleX(aFract);
aMap.SetScaleY(aFract);
aMap.SetOrigin(Point());
}
if ( !pPage->IsExcluded() || bPrintExcluded )
{
String aTmp = UniString::CreateFromInt32( nPage+1 );
if(ePageKind == PK_NOTES)
aTmp += String( SdResId( STR_PRINT_NOTES ) );
else
aTmp += String( SdResId( STR_PRINT_DRAWING ) );
rProgress.SetStateText( nPageCount, aTmp, nTotal );
String aPageStr;
if ( bPrintPageName )
{
aPageStr = pPage->GetName();
aPageStr += (sal_Unicode)' ';
}
aPageStr += rTimeDateStr;
MapMode aStdMap = rPrinter.GetMapMode();
rPrinter.SetMapMode(aMap);
//
BOOL bPrint = TRUE;
Point aPageOrigin;
long aPageWidth = aPageSize.Width() - pPage->GetLftBorder() - pPage->GetRgtBorder();
long aPageHeight = aPageSize.Height() - pPage->GetUppBorder() - pPage->GetLwrBorder();
long aPrintWidth = aPrintSize.Width();
long aPrintHeight = aPrintSize.Height();
2000-09-18 11:07:07 -05:00
// Bugfix zu 44530:
// Falls implizit umgestellt wurde (Landscape/Portrait)
// wird dies beim Kacheln, bzw. aufteilen (Poster) beruecksichtigt
BOOL bSwitchPageSize = FALSE;
if( ( aPrintWidth > aPrintHeight && aPageWidth < aPageHeight ) ||
( aPrintWidth < aPrintHeight && aPageWidth > aPageHeight ) )
{
bSwitchPageSize = TRUE;
aPrintWidth = aPrintSize.Height();
aPrintHeight = aPrintSize.Width();
}
// Eine (kleine) Seite, die gekachelt ausgegeben werden soll
if( bTilePage &&
aPageWidth < aPrintWidth &&
aPageHeight < aPrintHeight )
{
aPageWidth += 500;
aPageHeight += 500;
Point aPrintOrigin;
rPrinter.StartPage();
pPrintView->ShowPage( pPage, aPtZero );
SdrPageView* pPageView = pPrintView->GetPageView(pPage);
pPageView->SetVisibleLayers( pFrameView->GetVisibleLayers() );
pPageView->SetPrintableLayers( pFrameView->GetPrintableLayers() );
long nPagesPrinted = 0; // Fuer Bedingung s.u.
BOOL bPrintPage; // Fuer Bedingung s.u.
while( bPrint )
{
BOOL bWidth = aPageWidth < aPrintWidth;
BOOL bHeight = aPageHeight < aPrintHeight;
if( !bWidth && !bHeight )
bPrint = FALSE;
// Etwas umstaendliche Abfrage, die ausdrueckt, ob eine Seite
// beim Kacheln abgeschnitten oder gar nicht dargestellt werden
// soll. Die Bedingung ist, dass eine 2. Seite (horz. oder vert.)
// immer gedruck wird, waehrend eine dritte Seite (oder hoeher)
// nur noch gedruckt wird, wenn diese auch noch vollstaendig
// aufs Papier passt.
if( nPagesPrinted < 4 && !( !bWidth && nPagesPrinted == 2 ) )
bPrintPage = TRUE;
else
bPrintPage = FALSE;
nPagesPrinted++;
if( ( bWidth && bHeight ) || bPrintPage )
{
aStdMap.SetOrigin( aPrintOrigin );
rPrinter.SetMapMode( aStdMap );
if (this->ISA(DrawViewShell) && bPrintMarkedOnly )
2000-09-18 11:07:07 -05:00
{
GetView()->DrawAllMarked( rPrinter, aPtZero );
2000-09-18 11:07:07 -05:00
}
else
pPrintView->CompleteRedraw( &rPrinter, Rectangle( aPtZero,
2000-09-18 11:07:07 -05:00
aPageSize ) );
}
if( bWidth )
{
aPrintOrigin.X() += aPageWidth;
aPrintWidth -= aPageWidth;
}
else if( bHeight )
{
aPrintOrigin.X() = 0;
aPrintWidth = bSwitchPageSize ? aPrintSize.Height() : aPrintSize.Width();
aPrintOrigin.Y() += aPageHeight;
aPrintHeight -= aPageHeight;
}
}
if ( aPageStr.Len() )
{
Font aOldFont = rPrinter.OutputDevice::GetFont();
rPrinter.SetFont(rTimeDateFont);
rPrinter.DrawText(aPageOfs, aPageStr);
rPrinter.SetFont(aOldFont);
}
rPrinter.EndPage();
pPrintView->HidePage(pPrintView->GetPageView(pPage));
bPrint = FALSE;
}
// Damit ein groessere Seite auch auf einem kleineren Drucker (Format)
// ausgegeben werden kann, wird folgende while-Schleife durchlaufen.
// Beim "Abschneiden" wird nur eine Seite gedruckt!
while( bPrint )
{
BOOL bWidth = aPageWidth > aPrintWidth;
BOOL bHeight = aPageHeight > aPrintHeight;
if( bScalePage ||
( !bWidth && !bHeight ) ||
( pPrintOpts && pPrintOpts->IsCutPage() ) )
bPrint = FALSE;
rPrinter.StartPage();
pPrintView->ShowPage(pPage, aPageOrigin);
if( bWidth )
{
aPageOrigin.X() -= aPrintWidth;
aPageWidth -= aPrintWidth;
}
else if( bHeight )
{
aPageOrigin.X() = 0;
aPageWidth = aPageSize.Width() - pPage->GetUppBorder() - pPage->GetLwrBorder();
aPageOrigin.Y() -= aPrintHeight;
aPageHeight -= aPrintHeight;
}
SdrPageView* pPageView = pPrintView->GetPageView(pPage);
pPageView->SetVisibleLayers( pFrameView->GetVisibleLayers() );
pPageView->SetPrintableLayers( pFrameView->GetPrintableLayers() );
if (this->ISA(DrawViewShell) && bPrintMarkedOnly)
GetView()->DrawAllMarked( rPrinter, aPtZero );
2000-09-18 11:07:07 -05:00
else
pPrintView->CompleteRedraw(&rPrinter, Rectangle(Point(0,0),
2000-09-18 11:07:07 -05:00
pPage->GetSize()));
rPrinter.SetMapMode(aStdMap);
if ( aPageStr.Len() )
{
Font aOldFont = rPrinter.OutputDevice::GetFont();
rPrinter.SetFont(rTimeDateFont);
rPrinter.DrawText(aPageOfs, aPageStr);
rPrinter.SetFont(aOldFont);
}
rPrinter.EndPage();
pPrintView->HidePage(pPrintView->GetPageView(pPage));
}
}
}
nPage++;
}
}
delete pPrintView;
rPrinter.SetMapMode( aOldMap );
2000-09-18 11:07:07 -05:00
}
}
/*************************************************************************
|*
|* Seite drucken
|*
\************************************************************************/
void ViewShell::PrintPage (
SfxPrinter& rPrinter,
::sd::View* pPrintView,
SdPage* pPage,
BOOL bPrintMarkedOnly )
2000-09-18 11:07:07 -05:00
{
Point aPtZero;
pPrintView->ShowPage( pPage, aPtZero );
SdrPageView* pPageView = pPrintView->GetPageView( pPage );
pPageView->SetVisibleLayers( pFrameView->GetVisibleLayers() );
pPageView->SetPrintableLayers( pFrameView->GetPrintableLayers() );
if (this->ISA(DrawViewShell) && bPrintMarkedOnly)
GetView()->DrawAllMarked( rPrinter, aPtZero );
2000-09-18 11:07:07 -05:00
else
pPrintView->CompleteRedraw( &rPrinter, Rectangle( aPtZero,
2000-09-18 11:07:07 -05:00
pPage->GetSize() ) );
pPrintView->HidePage( pPrintView->GetPageView( pPage ) );
/*
if ( aPageStr.Len() )
{
Font aOldFont = rPrinter.OutputDevice::GetFont();
rPrinter.SetFont( rTimeDateFont );
rPrinter.DrawText( aPageOfs, aPageStr );
rPrinter.SetFont( aOldFont );
}
*/
}
/*************************************************************************
|*
|* Status (Enabled/Disabled) von Menue-SfxSlots setzen
|*
\************************************************************************/
void ViewShell::GetMenuState( SfxItemSet &rSet )
2000-09-18 11:07:07 -05:00
{
if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_STYLE_FAMILY ) )
{
UINT16 nFamily = (SfxStyleFamily)GetDocSh()->GetStyleFamily();
2000-09-18 11:07:07 -05:00
SdrView* pDrView = GetDrawView();
if( pDrView->AreObjectsMarked() )
2000-09-18 11:07:07 -05:00
{
SfxStyleSheet* pStyleSheet = pDrView->GetStyleSheet();
if( pStyleSheet )
{
if (pStyleSheet->GetFamily() == SD_LT_FAMILY)
pStyleSheet = ((SdStyleSheet*)pStyleSheet)->GetPseudoStyleSheet();
if( pStyleSheet )
{
SfxStyleFamily eFamily = pStyleSheet->GetFamily();
if(eFamily == SFX_STYLE_FAMILY_PARA)
nFamily = 2;
else
nFamily = 5;
GetDocSh()->SetStyleFamily(nFamily);
2000-09-18 11:07:07 -05:00
}
}
}
rSet.Put(SfxUInt16Item(SID_STYLE_FAMILY, nFamily ));
}
// #96090#
if(SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_GETUNDOSTRINGS))
{
ImpGetUndoStrings(rSet);
}
// #96090#
if(SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_GETREDOSTRINGS))
{
ImpGetRedoStrings(rSet);
}
// #96090#
if(SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_UNDO))
{
SfxUndoManager* pUndoManager = ImpGetUndoManager();
sal_Bool bActivate(FALSE);
if(pUndoManager)
{
if(pUndoManager->GetUndoActionCount() != 0)
{
bActivate = TRUE;
}
}
if(bActivate)
{
// #87229# Set the necessary string like in
// sfx2/source/view/viewfrm.cxx ver 1.23 ln 1072 ff.
String aTmp(ResId(STR_UNDO, SFX_APP()->GetSfxResManager()));
aTmp += pUndoManager->GetUndoActionComment(0);
rSet.Put(SfxStringItem(SID_UNDO, aTmp));
}
else
{
rSet.DisableItem(SID_UNDO);
}
}
// #96090#
if(SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_REDO))
{
SfxUndoManager* pUndoManager = ImpGetUndoManager();
sal_Bool bActivate(FALSE);
if(pUndoManager)
{
if(pUndoManager->GetRedoActionCount() != 0)
{
bActivate = TRUE;
}
}
if(bActivate)
{
// #87229# Set the necessary string like in
// sfx2/source/view/viewfrm.cxx ver 1.23 ln 1081 ff.
String aTmp(ResId(STR_REDO, SFX_APP()->GetSfxResManager()));
aTmp += pUndoManager->GetRedoActionComment(0);
rSet.Put(SfxStringItem(SID_REDO, aTmp));
}
else
{
rSet.DisableItem(SID_REDO);
}
}
2000-09-18 11:07:07 -05:00
}
void ViewShell::SetPreview( bool bVisible )
{
DBG_ASSERT( GetViewFrame(), "FATAL: no viewframe?" );
DBG_ASSERT( GetActiveWindow(), "FATAL: no window?" );
if( GetViewFrame() && GetActiveWindow() )
{
if ( ! bVisible)
mpWindowUpdater->UnregisterPreview ();
if (GetViewFrame()->KnowsChildWindow(
PreviewChildWindow::GetChildWindowId()))
{
GetViewFrame()->SetChildWindow(
PreviewChildWindow::GetChildWindowId(), bVisible,false);
}
if (bVisible)
mpWindowUpdater->RegisterPreview ();
const StyleSettings& rStyleSettings = GetActiveWindow()->GetSettings().GetStyleSettings();
sal_uInt16 nPreviewSlot;
SvtAccessibilityOptions aAccOptions;
if( GetViewFrame()->GetDispatcher() )
{
if( rStyleSettings.GetHighContrastMode() && aAccOptions.GetIsForPagePreviews() )
{
nPreviewSlot = SID_PREVIEW_QUALITY_CONTRAST;
}
else
{
nPreviewSlot = SID_PREVIEW_QUALITY_COLOR;
}
GetViewFrame()->GetDispatcher()->Execute( nPreviewSlot, SFX_CALLMODE_ASYNCHRON );
}
if (bVisible)
UpdatePreview (GetActualPage());
SfxBindings& rBindings = GetViewFrame()->GetBindings();
rBindings.Invalidate(SID_PREVIEW_WIN);
rBindings.Invalidate(SID_PREVIEW_QUALITY_COLOR);
rBindings.Invalidate(SID_PREVIEW_QUALITY_GRAYSCALE);
rBindings.Invalidate(SID_PREVIEW_QUALITY_BLACKWHITE);
rBindings.Invalidate(SID_PREVIEW_QUALITY_CONTRAST);
}
}
/** This method consists basically of three parts:
1. Process the arguments of the SFX request.
2. Use the model to create a new page or duplicate an existing one.
3. Update the tab control and switch to the new page.
*/
void ViewShell::CreateOrDuplicatePage (
SfxRequest& rRequest,
PageKind ePageKind,
SdPage* pPage)
{
USHORT nSId = rRequest.GetSlot();
SdDrawDocument* pDocument = GetDoc();
USHORT nPageCount = pDocument->GetSdPageCount(ePageKind);
SdrLayerAdmin& rLayerAdmin = pDocument->GetLayerAdmin();
BYTE aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), FALSE);
BYTE aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), FALSE);
USHORT nPos = 0;
SetOfByte aVisibleLayers;
// Determine the page from which to copy some values, such as layers,
// size, master page, to the new page. This is usually the given page.
// When the given page is NULL then use the first page of the document.
SdPage* pTemplatePage = pPage;
if (pTemplatePage == NULL)
if (pDocument->GetSdPage(0, ePageKind) > 0)
pTemplatePage = pDocument->GetSdPage(0, ePageKind);
if (pTemplatePage != NULL)
aVisibleLayers = pTemplatePage->GetMasterPageVisibleLayers(nPos);
else
aVisibleLayers.SetAll();
String aStandardPageName;
String aNotesPageName;
AutoLayout eStandardLayout;
AutoLayout eNotesLayout;
BOOL bIsPageBack;
BOOL bIsPageObj;
// 1. Process the arguments.
const SfxItemSet* pArgs = rRequest.GetArgs();
if (! pArgs)
{
SfxItemSet aAttrSet( GetPool(), ATTR_PAGE_START, ATTR_PAGE_END );
String aStr;
aAttrSet.Put( SfxStringItem( ATTR_PAGE_NAME, aStr ) );
aAttrSet.Put( SfxBoolItem( ATTR_PAGE_BACKGROUND,
aVisibleLayers.IsSet(aBckgrnd) ) );
aAttrSet.Put( SfxBoolItem( ATTR_PAGE_OBJECTS,
aVisibleLayers.IsSet(aBckgrndObj) ) );
AutoLayout eAutoLayout = AUTOLAYOUT_NONE;
if (pTemplatePage != NULL)
eAutoLayout = pTemplatePage->GetAutoLayout();
if (eAutoLayout == AUTOLAYOUT_TITLE && pPage->GetPageNum() == 1)
{
// 1.Seite ist TitelDia
eAutoLayout = AUTOLAYOUT_ENUM;
}
aAttrSet.Put( SfxAllEnumItem( ATTR_PAGE_LAYOUT,
eAutoLayout ) );
AbstractSdNewFoilDlg* pDlg = NULL; //CHINA001 SdNewFoilDlg* pDlg = NULL;
SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();//CHINA001
DBG_ASSERT(pFact, "SdAbstractDialogFactory fail!");//CHINA001
if (nSId == SID_INSERTPAGE && !this->ISA(GraphicViewShell))
{ //add by CHINA001
//CHINA001 pDlg = new SdNewFoilDlg(GetActiveWindow(), aAttrSet, ePageKind, GetDocSh(), FALSE);
pDlg = pFact->CreateSdNewFoilDlg(ResId( DLG_NEW_FOIL ), GetActiveWindow(), aAttrSet, ePageKind, GetDocSh(), FALSE );
DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
}
if (pDlg && pDlg->Execute () != RET_OK)
{
Cancel();
if (pFuActual && pFuActual->GetSlotID() == SID_BEZIER_EDIT )
GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
delete pDlg;
rRequest.Ignore ();
return;
}
else
{
// AutoLayouts muessen fertig sein
pDocument->StopWorkStartupDelay();
if (pDlg)
{
pDlg->GetAttr( aAttrSet );
}
if (ePageKind == PK_NOTES)
{
aNotesPageName = ((const SfxStringItem &) aAttrSet.Get (ATTR_PAGE_NAME)).GetValue ();
eNotesLayout = (AutoLayout) ((const SfxAllEnumItem &)
aAttrSet.Get (ATTR_PAGE_LAYOUT)).GetValue ();
}
else
{
aStandardPageName = ((const SfxStringItem &) aAttrSet.Get (ATTR_PAGE_NAME)).GetValue ();
eStandardLayout = (AutoLayout) ((const SfxAllEnumItem &)
aAttrSet.Get (ATTR_PAGE_LAYOUT)).GetValue ();
}
bIsPageBack = ((const SfxBoolItem &) aAttrSet.Get (ATTR_PAGE_BACKGROUND)).GetValue ();
bIsPageObj = ((const SfxBoolItem &) aAttrSet.Get (ATTR_PAGE_OBJECTS)).GetValue();
pDocument->SetChanged(TRUE);
}
delete pDlg;
}
else if (pArgs->Count () != 4)
{
Cancel();
if (pFuActual && pFuActual->GetSlotID() == SID_BEZIER_EDIT )
GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
StarBASIC::FatalError (SbERR_WRONG_ARGS);
rRequest.Ignore ();
return;
}
else
{
// AutoLayouts muessen fertig sein
pDocument->StopWorkStartupDelay();
SFX_REQUEST_ARG (rRequest, pPageName, SfxStringItem, ID_VAL_PAGENAME, FALSE);
SFX_REQUEST_ARG (rRequest, pLayout, SfxUInt32Item, ID_VAL_WHATLAYOUT, FALSE);
SFX_REQUEST_ARG (rRequest, pIsPageBack, SfxBoolItem, ID_VAL_ISPAGEBACK, FALSE);
SFX_REQUEST_ARG (rRequest, pIsPageObj, SfxBoolItem, ID_VAL_ISPAGEOBJ, FALSE);
if (CHECK_RANGE (AUTOLAYOUT_TITLE, (AutoLayout) pLayout->GetValue (), AUTOLAYOUT_HANDOUT6))
{
if (ePageKind == PK_NOTES)
{
aNotesPageName = pPageName->GetValue ();
eNotesLayout = (AutoLayout) pLayout->GetValue ();
}
else
{
aStandardPageName = pPageName->GetValue ();
eStandardLayout = (AutoLayout) pLayout->GetValue ();
}
bIsPageBack = pIsPageBack->GetValue ();
bIsPageObj = pIsPageObj->GetValue ();
}
else
{
Cancel();
if (pFuActual && pFuActual->GetSlotID() == SID_BEZIER_EDIT )
GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
rRequest.Ignore ();
return;
}
}
// 2. Create a new page or duplicate an existing one.
View* pDrView = GetView();
pDrView->BegUndo( String( SdResId(STR_INSERTPAGE) ) );
USHORT nNewPageIndex;
switch (nSId)
{
case SID_INSERTPAGE:
case SID_INSERTPAGE_QUICK:
// There are three cases. a) pPage is not NULL: we use it as a
// template and create a new slide behind it. b) pPage is NULL
// but the document is not empty: we use the first slide/notes
// page as template, create a new slide after it and move it
// then to the head of the document. c) pPage is NULL and the
// document is empty: We use CreateFirstPages to create the
// first page of the document.
if (pPage == NULL)
if (pTemplatePage == NULL)
{
pDocument->CreateFirstPages();
nNewPageIndex = 0;
}
else
{
// Create a new page with the first page as template and
// insert it after the first page.
nNewPageIndex = pDocument->CreatePage (
pTemplatePage,
ePageKind,
aStandardPageName,
aNotesPageName,
eStandardLayout,
eNotesLayout,
bIsPageBack,
bIsPageObj);
// Select exactly the new page.
USHORT nPageCount (pDocument->GetSdPageCount(ePageKind));
for (USHORT i=0; i<nPageCount; i++)
{
pDocument->GetSdPage(i, PK_STANDARD)->SetSelected(
i == nNewPageIndex);
pDocument->GetSdPage(i, PK_NOTES)->SetSelected(
i == nNewPageIndex);
}
// Move the selected page to the head of the document
pDocument->MovePages ((USHORT)-1);
nNewPageIndex = 0;
}
else
nNewPageIndex = pDocument->CreatePage (
pPage,
ePageKind,
aStandardPageName,
aNotesPageName,
eStandardLayout,
eNotesLayout,
bIsPageBack,
bIsPageObj);
break;
case SID_DUPLICATE_PAGE:
// Duplication makes no sense when pPage is NULL.
if (pPage != NULL)
nNewPageIndex = pDocument->DuplicatePage (
pPage,
ePageKind,
aStandardPageName,
aNotesPageName,
eStandardLayout,
eNotesLayout,
bIsPageBack,
bIsPageObj);
break;
default:
DBG_WARNING("wrong slot id given to CreateOrDuplicatePage");
// Try to handle another slot id gracefully.
nNewPageIndex = 0xffff;
}
if (nNewPageIndex != 0xffff)
{
pDrView->AddUndo (new SdrUndoNewPage (
*pDocument->GetSdPage (nNewPageIndex, PK_STANDARD)));
pDrView->AddUndo (new SdrUndoNewPage (
*pDocument->GetSdPage (nNewPageIndex, PK_NOTES)));
}
pDrView->EndUndo();
#if 0
// 3. Update the tab control.
aTabControl.Clear();
SdPage* pPage;
String aPageName;
USHORT nPageCnt = pDocument->GetSdPageCount(ePageKind);
for (USHORT i = 0; i < nPageCnt; i++)
{
pPage = pDocument->GetSdPage(i, ePageKind);
aPageName = pPage->GetName();
aTabControl.InsertPage(i + 1, aPageName);
}
aTabControl.SetCurPageId (nNewPageIndex + 1);
GetViewFrame()->GetDispatcher()->Execute(SID_SWITCHPAGE,
(rRequest.IsSynchronCall() ? SFX_CALLMODE_SYNCHRON : SFX_CALLMODE_ASYNCHRON)
| SFX_CALLMODE_RECORD);
#endif
}
} // end of namespace sd