2000-09-18 11:07:07 -05:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 13:58:54 -05:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2010-02-12 08:01:35 -06:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2008-04-10 13:58:54 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2008-04-10 13:58:54 -05:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2008-04-10 13:58:54 -05:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2008-04-10 13:58:54 -05:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2008-04-10 13:58:54 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 12:44:42 -05:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_sd.hxx"
|
|
|
|
|
2004-01-20 03:52:40 -06:00
|
|
|
#include "DrawDocShell.hxx"
|
2001-02-13 05:17:06 -06:00
|
|
|
#include <vcl/msgbox.hxx>
|
2000-09-18 11:07:07 -05:00
|
|
|
#include <svx/svdpagv.hxx>
|
2006-12-12 10:11:47 -06:00
|
|
|
#include <svx/svxdlg.hxx>
|
|
|
|
#include <svx/dialogs.hrc>
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2002-10-17 10:31:49 -05:00
|
|
|
#include "helpids.h"
|
2004-01-20 03:52:40 -06:00
|
|
|
#include "ViewShell.hxx"
|
2000-09-18 11:07:07 -05:00
|
|
|
#include "drawview.hxx"
|
2004-01-20 03:52:40 -06:00
|
|
|
#ifndef SD_FRAMW_VIEW_HXX
|
|
|
|
#include "FrameView.hxx"
|
|
|
|
#endif
|
2000-09-18 11:07:07 -05:00
|
|
|
#include "drawdoc.hxx"
|
|
|
|
#include "sdpage.hxx"
|
2004-01-20 03:52:40 -06:00
|
|
|
#include "View.hxx"
|
|
|
|
#include "ClientView.hxx"
|
|
|
|
#ifndef SD_WINDOW_SHELL_HXX
|
|
|
|
#include "Window.hxx"
|
|
|
|
#endif
|
2000-09-18 11:07:07 -05:00
|
|
|
#include "strings.hrc"
|
|
|
|
#include "res_bmp.hrc"
|
|
|
|
#include "sdresid.hxx"
|
|
|
|
#include "strmname.h"
|
2002-11-29 07:23:07 -06:00
|
|
|
#include "fupoor.hxx"
|
2006-11-14 07:26:33 -06:00
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
#include <vcl/virdev.hxx>
|
|
|
|
|
2004-01-20 03:52:40 -06:00
|
|
|
namespace sd {
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* Zeichnen der DocShell (mittels der Hilfsklasse SdDrawViewShell)
|
|
|
|
|*
|
|
|
|
\************************************************************************/
|
|
|
|
|
2006-12-12 10:11:47 -06:00
|
|
|
void DrawDocShell::Draw(OutputDevice* pOut, const JobSetup&, USHORT nAspect)
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
|
|
|
if (nAspect == ASPECT_THUMBNAIL)
|
|
|
|
{
|
|
|
|
/**********************************************************************
|
|
|
|
* THUMBNAIL: Hier koennte ev. einmal der Draft-Mode gesetzt werden
|
|
|
|
**********************************************************************/
|
|
|
|
}
|
|
|
|
|
2004-01-20 03:52:40 -06:00
|
|
|
ClientView* pView = new ClientView(this, pOut, NULL);
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
pView->SetHlplVisible(FALSE);
|
|
|
|
pView->SetGridVisible(FALSE);
|
|
|
|
pView->SetBordVisible(FALSE);
|
|
|
|
pView->SetPageVisible(FALSE);
|
|
|
|
pView->SetGlueVisible(FALSE);
|
|
|
|
|
2002-07-30 08:11:59 -05:00
|
|
|
SdPage* pSelectedPage = NULL;
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2006-12-12 10:11:47 -06:00
|
|
|
List* pFrameViewList = mpDoc->GetFrameViewList();
|
2002-07-30 08:11:59 -05:00
|
|
|
if( pFrameViewList && pFrameViewList->Count() )
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
2002-07-30 08:11:59 -05:00
|
|
|
FrameView* pFrameView = (FrameView*)pFrameViewList->GetObject(0);
|
|
|
|
if( pFrameView && pFrameView->GetPageKind() == PK_STANDARD )
|
|
|
|
{
|
|
|
|
USHORT nSelectedPage = pFrameView->GetSelectedPage();
|
2006-12-12 10:11:47 -06:00
|
|
|
pSelectedPage = mpDoc->GetSdPage(nSelectedPage, PK_STANDARD);
|
2002-07-30 08:11:59 -05:00
|
|
|
}
|
|
|
|
}
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2002-07-30 08:11:59 -05:00
|
|
|
if( NULL == pSelectedPage )
|
|
|
|
{
|
|
|
|
SdPage* pPage = NULL;
|
|
|
|
USHORT nSelectedPage = 0;
|
2006-12-12 10:11:47 -06:00
|
|
|
USHORT nPageCnt = (USHORT) mpDoc->GetSdPageCount(PK_STANDARD);
|
2002-07-30 08:11:59 -05:00
|
|
|
|
|
|
|
for (USHORT i = 0; i < nPageCnt; i++)
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
2006-12-12 10:11:47 -06:00
|
|
|
pPage = mpDoc->GetSdPage(i, PK_STANDARD);
|
2002-07-30 08:11:59 -05:00
|
|
|
|
|
|
|
if ( pPage->IsSelected() )
|
|
|
|
{
|
|
|
|
nSelectedPage = i;
|
|
|
|
pSelectedPage = pPage;
|
|
|
|
}
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
2002-07-30 08:11:59 -05:00
|
|
|
|
|
|
|
if( NULL == pSelectedPage )
|
2006-12-12 10:11:47 -06:00
|
|
|
pSelectedPage = mpDoc->GetSdPage(0, PK_STANDARD);
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle aVisArea = GetVisArea(nAspect);
|
|
|
|
pOut->IntersectClipRegion(aVisArea);
|
2006-11-14 07:26:33 -06:00
|
|
|
pView->ShowSdrPage(pSelectedPage);
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
if (pOut->GetOutDevType() != OUTDEV_WINDOW)
|
|
|
|
{
|
|
|
|
MapMode aOldMapMode = pOut->GetMapMode();
|
|
|
|
|
|
|
|
if (pOut->GetOutDevType() == OUTDEV_PRINTER)
|
|
|
|
{
|
|
|
|
MapMode aMapMode = aOldMapMode;
|
|
|
|
Point aOrigin = aMapMode.GetOrigin();
|
|
|
|
aOrigin.X() += 1;
|
|
|
|
aOrigin.Y() += 1;
|
|
|
|
aMapMode.SetOrigin(aOrigin);
|
|
|
|
pOut->SetMapMode(aMapMode);
|
|
|
|
}
|
|
|
|
|
|
|
|
Region aRegion(aVisArea);
|
2004-07-12 09:00:42 -05:00
|
|
|
pView->CompleteRedraw(pOut, aRegion);
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
if (pOut->GetOutDevType() == OUTDEV_PRINTER)
|
|
|
|
{
|
|
|
|
pOut->SetMapMode(aOldMapMode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
delete pView;
|
|
|
|
|
2000-11-10 09:53:19 -06:00
|
|
|
// Fuer Testzwecke: Bitte nicht entfernen!
|
2000-09-18 11:07:07 -05:00
|
|
|
//
|
2000-11-10 09:53:19 -06:00
|
|
|
// GDIMetaFile* pMtf = pOut->GetConnectMetaFile();
|
2000-09-18 11:07:07 -05:00
|
|
|
//
|
2000-11-10 09:53:19 -06:00
|
|
|
// if( pMtf )
|
|
|
|
// {
|
|
|
|
// String aURLStr;
|
2000-09-18 11:07:07 -05:00
|
|
|
//
|
2000-11-10 09:53:19 -06:00
|
|
|
// if( ::utl::LocalFileHelper::ConvertPhysicalNameToURL( String( RTL_CONSTASCII_USTRINGPARAM( "d:\\gdi.mtf" ) ), aURLStr ) )
|
|
|
|
// {
|
|
|
|
// SvStream* pOStm = ::utl::UcbStreamHelper::CreateStream( aURLStr, STREAM_WRITE | STREAM_TRUNC );
|
2000-09-18 11:07:07 -05:00
|
|
|
//
|
2000-11-10 09:53:19 -06:00
|
|
|
// if( pOStm )
|
|
|
|
// {
|
|
|
|
// *pOStm << *pMtf;
|
|
|
|
// delete pOStm;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|*
|
|
|
|
|*
|
|
|
|
\************************************************************************/
|
|
|
|
|
2004-01-20 03:52:40 -06:00
|
|
|
Rectangle DrawDocShell::GetVisArea(USHORT nAspect) const
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
|
|
|
Rectangle aVisArea;
|
|
|
|
|
2002-08-13 05:46:36 -05:00
|
|
|
if( ( ASPECT_THUMBNAIL == nAspect ) || ( ASPECT_DOCPRINT == nAspect ) )
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
|
|
|
// Groesse der ersten Seite herausgeben
|
|
|
|
MapMode aSrcMapMode(MAP_PIXEL);
|
|
|
|
MapMode aDstMapMode(MAP_100TH_MM);
|
2006-12-12 10:11:47 -06:00
|
|
|
Size aSize = mpDoc->GetSdPage(0, PK_STANDARD)->GetSize();
|
2000-09-18 11:07:07 -05:00
|
|
|
aSrcMapMode.SetMapUnit(MAP_100TH_MM);
|
|
|
|
|
|
|
|
aSize = Application::GetDefaultDevice()->LogicToLogic(aSize, &aSrcMapMode, &aDstMapMode);
|
|
|
|
aVisArea.SetSize(aSize);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-10-04 12:30:17 -05:00
|
|
|
aVisArea = SfxObjectShell::GetVisArea(nAspect);
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
|
|
|
|
2006-12-12 10:11:47 -06:00
|
|
|
if (aVisArea.IsEmpty() && mpViewShell)
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
2006-12-12 10:11:47 -06:00
|
|
|
Window* pWin = mpViewShell->GetActiveWindow();
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
if (pWin)
|
|
|
|
{
|
|
|
|
aVisArea = pWin->PixelToLogic(Rectangle(Point(0,0), pWin->GetOutputSizePixel()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (aVisArea);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
2004-01-20 03:52:40 -06:00
|
|
|
|* ViewShell anmelden
|
2000-09-18 11:07:07 -05:00
|
|
|
|*
|
|
|
|
\************************************************************************/
|
|
|
|
|
2004-01-20 03:52:40 -06:00
|
|
|
void DrawDocShell::Connect(ViewShell* pViewSh)
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
2006-12-12 10:11:47 -06:00
|
|
|
mpViewShell = pViewSh;
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
2004-01-20 03:52:40 -06:00
|
|
|
|* ViewShell abmelden
|
2000-09-18 11:07:07 -05:00
|
|
|
|*
|
|
|
|
\************************************************************************/
|
|
|
|
|
2004-01-20 03:52:40 -06:00
|
|
|
void DrawDocShell::Disconnect(ViewShell* pViewSh)
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
2006-12-12 10:11:47 -06:00
|
|
|
if (mpViewShell == pViewSh)
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
2006-12-12 10:11:47 -06:00
|
|
|
mpViewShell = NULL;
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|*
|
|
|
|
|*
|
|
|
|
\************************************************************************/
|
|
|
|
|
2004-01-20 03:52:40 -06:00
|
|
|
FrameView* DrawDocShell::GetFrameView()
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
|
|
|
FrameView* pFrameView = NULL;
|
|
|
|
|
2006-12-12 10:11:47 -06:00
|
|
|
if (mpViewShell)
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
2006-12-12 10:11:47 -06:00
|
|
|
pFrameView = mpViewShell->GetFrameView();
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return(pFrameView);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* Groesse der ersten Seite zurueckgeben
|
|
|
|
|*
|
|
|
|
\************************************************************************/
|
|
|
|
|
2004-01-20 03:52:40 -06:00
|
|
|
Size DrawDocShell::GetFirstPageSize()
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
|
|
|
return SfxObjectShell::GetFirstPageSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* Bitmap einer beliebigen Seite erzeugen
|
|
|
|
|*
|
|
|
|
\************************************************************************/
|
|
|
|
|
2004-01-20 03:52:40 -06:00
|
|
|
Bitmap DrawDocShell::GetPagePreviewBitmap(SdPage* pPage, USHORT nMaxEdgePixel)
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
|
|
|
MapMode aMapMode( MAP_100TH_MM );
|
|
|
|
const Size aSize( pPage->GetSize() );
|
|
|
|
const Point aNullPt;
|
|
|
|
VirtualDevice aVDev( *Application::GetDefaultDevice() );
|
|
|
|
|
|
|
|
aVDev.SetMapMode( aMapMode );
|
|
|
|
|
|
|
|
const Size aPixSize( aVDev.LogicToPixel( aSize ) );
|
|
|
|
const ULONG nMaxEdgePix = Max( aPixSize.Width(), aPixSize.Height() );
|
|
|
|
Fraction aFrac( nMaxEdgePixel, nMaxEdgePix );
|
|
|
|
|
|
|
|
aMapMode.SetScaleX( aFrac );
|
|
|
|
aMapMode.SetScaleY( aFrac );
|
|
|
|
aVDev.SetMapMode( aMapMode );
|
|
|
|
aVDev.SetOutputSize( aSize );
|
|
|
|
|
|
|
|
// damit die dunklen Linien am rechten und unteren Seitenrans mitkommen
|
|
|
|
aFrac = Fraction( nMaxEdgePixel - 1, nMaxEdgePix );
|
|
|
|
aMapMode.SetScaleX( aFrac );
|
|
|
|
aMapMode.SetScaleY( aFrac );
|
|
|
|
aVDev.SetMapMode( aMapMode );
|
|
|
|
|
2004-01-20 03:52:40 -06:00
|
|
|
ClientView* pView = new ClientView( this, &aVDev, NULL );
|
2000-09-18 11:07:07 -05:00
|
|
|
FrameView* pFrameView = GetFrameView();
|
2006-11-14 07:26:33 -06:00
|
|
|
pView->ShowSdrPage( pPage );
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
if ( GetFrameView() )
|
|
|
|
{
|
|
|
|
// Initialisierungen der Zeichen-(Bildschirm-)Attribute
|
|
|
|
pView->SetGridCoarse( pFrameView->GetGridCoarse() );
|
|
|
|
pView->SetGridFine( pFrameView->GetGridFine() );
|
|
|
|
pView->SetSnapGridWidth(pFrameView->GetSnapGridWidthX(), pFrameView->GetSnapGridWidthY());
|
2002-05-07 04:17:08 -05:00
|
|
|
pView->SetGridVisible( pFrameView->IsGridVisible() );
|
2000-09-18 11:07:07 -05:00
|
|
|
pView->SetGridFront( pFrameView->IsGridFront() );
|
|
|
|
pView->SetSnapAngle( pFrameView->GetSnapAngle() );
|
|
|
|
pView->SetGridSnap( pFrameView->IsGridSnap() );
|
|
|
|
pView->SetBordSnap( pFrameView->IsBordSnap() );
|
|
|
|
pView->SetHlplSnap( pFrameView->IsHlplSnap() );
|
|
|
|
pView->SetOFrmSnap( pFrameView->IsOFrmSnap() );
|
|
|
|
pView->SetOPntSnap( pFrameView->IsOPntSnap() );
|
|
|
|
pView->SetOConSnap( pFrameView->IsOConSnap() );
|
|
|
|
pView->SetDragStripes( pFrameView->IsDragStripes() );
|
|
|
|
pView->SetFrameDragSingles( pFrameView->IsFrameDragSingles() );
|
|
|
|
pView->SetSnapMagneticPixel( pFrameView->GetSnapMagneticPixel() );
|
|
|
|
pView->SetMarkedHitMovesAlways( pFrameView->IsMarkedHitMovesAlways() );
|
|
|
|
pView->SetMoveOnlyDragging( pFrameView->IsMoveOnlyDragging() );
|
|
|
|
pView->SetSlantButShear( pFrameView->IsSlantButShear() );
|
|
|
|
pView->SetNoDragXorPolys( pFrameView->IsNoDragXorPolys() );
|
|
|
|
pView->SetCrookNoContortion( pFrameView->IsCrookNoContortion() );
|
|
|
|
pView->SetAngleSnapEnabled( pFrameView->IsAngleSnapEnabled() );
|
|
|
|
pView->SetBigOrtho( pFrameView->IsBigOrtho() );
|
|
|
|
pView->SetOrtho( pFrameView->IsOrtho() );
|
|
|
|
|
2006-11-14 07:26:33 -06:00
|
|
|
SdrPageView* pPageView = pView->GetSdrPageView();
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
if (pPageView)
|
|
|
|
{
|
|
|
|
if ( pPageView->GetVisibleLayers() != pFrameView->GetVisibleLayers() )
|
|
|
|
pPageView->SetVisibleLayers( pFrameView->GetVisibleLayers() );
|
|
|
|
|
|
|
|
if ( pPageView->GetPrintableLayers() != pFrameView->GetPrintableLayers() )
|
|
|
|
pPageView->SetPrintableLayers( pFrameView->GetPrintableLayers() );
|
|
|
|
|
|
|
|
if ( pPageView->GetLockedLayers() != pFrameView->GetLockedLayers() )
|
|
|
|
pPageView->SetLockedLayers( pFrameView->GetLockedLayers() );
|
|
|
|
|
|
|
|
// if ( pPageView->GetHelpLines() != pFrameView->GetHelpLines() )
|
|
|
|
pPageView->SetHelpLines( pFrameView->GetStandardHelpLines() );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( pView->GetActiveLayer() != pFrameView->GetActiveLayer() )
|
|
|
|
pView->SetActiveLayer( pFrameView->GetActiveLayer() );
|
|
|
|
}
|
|
|
|
|
2004-07-12 09:00:42 -05:00
|
|
|
pView->CompleteRedraw( &aVDev, Rectangle( aNullPt, aSize ) );
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2003-11-24 10:10:42 -06:00
|
|
|
// #111097# IsRedrawReady() always gives sal_True while ( !pView->IsRedrawReady() ) {}
|
2000-09-18 11:07:07 -05:00
|
|
|
delete pView;
|
|
|
|
|
|
|
|
aVDev.SetMapMode( MapMode() );
|
|
|
|
|
|
|
|
Bitmap aPreview( aVDev.GetBitmap( aNullPt, aVDev.GetOutputSizePixel() ) );
|
|
|
|
|
|
|
|
DBG_ASSERT(!!aPreview, "Vorschau-Bitmap konnte nicht erzeugt werden");
|
|
|
|
|
|
|
|
return aPreview;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-13 05:17:06 -06:00
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* Pruefen, ob die Seite vorhanden ist und dann den Anwender zwingen einen
|
|
|
|
|* noch nicht vorhandenen Namen einzugeben. Wird FALSE zurueckgegeben,
|
|
|
|
|* wurde die Aktion vom Anwender abgebrochen.
|
|
|
|
|*
|
|
|
|
\************************************************************************/
|
|
|
|
|
2004-01-20 03:52:40 -06:00
|
|
|
BOOL DrawDocShell::CheckPageName (::Window* pWin, String& rName )
|
2001-02-13 05:17:06 -06:00
|
|
|
{
|
2002-11-04 11:02:00 -06:00
|
|
|
const String aStrForDlg( rName );
|
2002-11-28 11:00:15 -06:00
|
|
|
bool bIsNameValid = IsNewPageNameValid( rName, true );
|
2001-02-13 05:17:06 -06:00
|
|
|
|
2002-11-04 11:02:00 -06:00
|
|
|
if( ! bIsNameValid )
|
2001-02-13 05:17:06 -06:00
|
|
|
{
|
2002-11-04 11:02:00 -06:00
|
|
|
String aDesc( SdResId( STR_WARN_PAGE_EXISTS ) );
|
2004-02-04 02:56:48 -06:00
|
|
|
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
|
2009-11-02 13:49:14 -06:00
|
|
|
AbstractSvxNameDialog* aNameDlg = pFact ? pFact->CreateSvxNameDialog( pWin, aStrForDlg, aDesc ) : 0;
|
2006-12-12 10:11:47 -06:00
|
|
|
if( aNameDlg )
|
|
|
|
{
|
|
|
|
aNameDlg->SetEditHelpId( HID_SD_NAMEDIALOG_PAGE );
|
2002-03-13 04:19:42 -06:00
|
|
|
|
2006-12-12 10:11:47 -06:00
|
|
|
if( mpViewShell )
|
|
|
|
aNameDlg->SetCheckNameHdl( LINK( this, DrawDocShell, RenameSlideHdl ) );
|
2002-03-13 04:19:42 -06:00
|
|
|
|
2006-12-12 10:11:47 -06:00
|
|
|
FunctionReference xFunc( mpViewShell->GetCurrentFunction() );
|
|
|
|
if( xFunc.is() )
|
|
|
|
xFunc->cancel();
|
2002-11-04 11:02:00 -06:00
|
|
|
|
2006-12-12 10:11:47 -06:00
|
|
|
if( aNameDlg->Execute() == RET_OK )
|
|
|
|
{
|
|
|
|
aNameDlg->GetName( rName );
|
|
|
|
bIsNameValid = IsNewPageNameValid( rName );
|
|
|
|
}
|
|
|
|
delete aNameDlg;
|
2002-03-13 04:19:42 -06:00
|
|
|
}
|
2002-11-04 11:02:00 -06:00
|
|
|
}
|
2001-02-13 05:17:06 -06:00
|
|
|
|
2002-11-04 11:02:00 -06:00
|
|
|
return ( bIsNameValid ? TRUE : FALSE );
|
|
|
|
}
|
2002-03-13 04:19:42 -06:00
|
|
|
|
2004-01-20 03:52:40 -06:00
|
|
|
bool DrawDocShell::IsNewPageNameValid( String & rInOutPageName, bool bResetStringIfStandardName /* = false */ )
|
2002-11-04 11:02:00 -06:00
|
|
|
{
|
2002-11-28 11:00:15 -06:00
|
|
|
bool bCanUseNewName = false;
|
2002-11-04 11:02:00 -06:00
|
|
|
|
|
|
|
// check if name is something like 'Slide n'
|
2002-12-10 09:37:43 -06:00
|
|
|
String aStrPage( SdResId( STR_SD_PAGE ) );
|
|
|
|
aStrPage += ' ';
|
|
|
|
|
2002-11-28 11:00:15 -06:00
|
|
|
bool bIsStandardName = false;
|
2002-11-04 11:02:00 -06:00
|
|
|
|
2002-11-28 11:00:15 -06:00
|
|
|
// prevent also _future_ slide names of the form "'STR_SD_PAGE' + ' ' + '[0-9]+|[a-z]|[A-Z]|[CDILMVX]+|[cdilmvx]+'"
|
|
|
|
// (arabic, lower- and upper case single letter, lower- and upper case roman numbers)
|
2002-12-10 09:37:43 -06:00
|
|
|
if( 0 == rInOutPageName.Search( aStrPage ) )
|
2002-11-28 11:00:15 -06:00
|
|
|
{
|
|
|
|
if( rInOutPageName.GetToken( 1, sal_Unicode(' ') ).GetChar(0) >= '0' &&
|
|
|
|
rInOutPageName.GetToken( 1, sal_Unicode(' ') ).GetChar(0) <= '9' )
|
2002-11-04 11:02:00 -06:00
|
|
|
{
|
2002-11-28 11:00:15 -06:00
|
|
|
// check for arabic numbering
|
|
|
|
|
|
|
|
// gobble up all following numbers
|
|
|
|
String sRemainder = rInOutPageName.GetToken( 1, sal_Unicode(' ') );
|
|
|
|
while( sRemainder.Len() &&
|
|
|
|
sRemainder.GetChar(0) >= '0' &&
|
|
|
|
sRemainder.GetChar(0) <= '9' )
|
2002-03-13 04:19:42 -06:00
|
|
|
{
|
2002-11-28 11:00:15 -06:00
|
|
|
// trim by one
|
|
|
|
sRemainder.Erase(0, 1);
|
2002-03-13 04:19:42 -06:00
|
|
|
}
|
2002-11-28 11:00:15 -06:00
|
|
|
|
|
|
|
// EOL? Reserved name!
|
|
|
|
if( !sRemainder.Len() )
|
2002-03-13 04:19:42 -06:00
|
|
|
{
|
2002-11-28 11:00:15 -06:00
|
|
|
bIsStandardName = true;
|
2002-11-04 11:02:00 -06:00
|
|
|
}
|
2002-11-28 11:00:15 -06:00
|
|
|
}
|
|
|
|
else if( rInOutPageName.GetToken( 1, sal_Unicode(' ') ).GetChar(0) >= 'a' &&
|
|
|
|
rInOutPageName.GetToken( 1, sal_Unicode(' ') ).GetChar(0) <= 'z' &&
|
|
|
|
rInOutPageName.GetToken( 1, sal_Unicode(' ') ).Len() == 1 )
|
|
|
|
{
|
|
|
|
// lower case, single character: reserved
|
|
|
|
bIsStandardName = true;
|
|
|
|
}
|
|
|
|
else if( rInOutPageName.GetToken( 1, sal_Unicode(' ') ).GetChar(0) >= 'A' &&
|
|
|
|
rInOutPageName.GetToken( 1, sal_Unicode(' ') ).GetChar(0) <= 'Z' &&
|
|
|
|
rInOutPageName.GetToken( 1, sal_Unicode(' ') ).Len() == 1 )
|
|
|
|
{
|
|
|
|
// upper case, single character: reserved
|
|
|
|
bIsStandardName = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// check for upper/lower case roman numbering
|
|
|
|
String sReserved( String::CreateFromAscii( "cdilmvx" ) );
|
|
|
|
|
|
|
|
// gobble up all following characters contained in one reserved class
|
|
|
|
String sRemainder = rInOutPageName.GetToken( 1, sal_Unicode(' ') );
|
|
|
|
if( sReserved.Search( sRemainder.GetChar(0) ) == STRING_NOTFOUND )
|
|
|
|
sReserved.ToUpperAscii();
|
|
|
|
|
|
|
|
while( sReserved.Search( sRemainder.GetChar(0) ) != STRING_NOTFOUND )
|
2002-11-04 11:02:00 -06:00
|
|
|
{
|
2002-11-28 11:00:15 -06:00
|
|
|
// trim by one
|
|
|
|
sRemainder.Erase(0, 1);
|
2002-11-04 11:02:00 -06:00
|
|
|
}
|
2002-11-28 11:00:15 -06:00
|
|
|
|
|
|
|
// EOL? Reserved name!
|
|
|
|
if( !sRemainder.Len() )
|
2002-11-04 11:02:00 -06:00
|
|
|
{
|
2002-11-28 11:00:15 -06:00
|
|
|
bIsStandardName = true;
|
2002-03-13 04:19:42 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-02-13 05:17:06 -06:00
|
|
|
|
2002-11-28 11:00:15 -06:00
|
|
|
if( bIsStandardName )
|
|
|
|
{
|
|
|
|
if( bResetStringIfStandardName )
|
|
|
|
{
|
|
|
|
// this is for insertion of slides from other files with standard
|
|
|
|
// name. They get a new standard name, if the string is set to an
|
|
|
|
// empty one.
|
|
|
|
rInOutPageName = String();
|
|
|
|
bCanUseNewName = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bCanUseNewName = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( rInOutPageName.Len() > 0 )
|
|
|
|
{
|
|
|
|
BOOL bOutDummy;
|
2006-12-12 10:11:47 -06:00
|
|
|
USHORT nExistingPageNum = mpDoc->GetPageByName( rInOutPageName, bOutDummy );
|
2002-11-28 11:00:15 -06:00
|
|
|
bCanUseNewName = ( nExistingPageNum == SDRPAGE_NOTFOUND );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bCanUseNewName = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return bCanUseNewName;
|
2002-11-04 11:02:00 -06:00
|
|
|
}
|
2001-02-13 05:17:06 -06:00
|
|
|
|
2004-02-04 02:56:48 -06:00
|
|
|
IMPL_LINK( DrawDocShell, RenameSlideHdl, AbstractSvxNameDialog*, pDialog )
|
2002-11-04 11:02:00 -06:00
|
|
|
{
|
|
|
|
if( ! pDialog )
|
|
|
|
return 0;
|
2001-02-13 05:17:06 -06:00
|
|
|
|
2002-11-04 11:02:00 -06:00
|
|
|
String aNewName;
|
|
|
|
pDialog->GetName( aNewName );
|
2001-02-13 05:17:06 -06:00
|
|
|
|
2002-11-04 11:02:00 -06:00
|
|
|
return IsNewPageNameValid( aNewName );
|
2001-02-13 05:17:06 -06:00
|
|
|
}
|
2004-01-20 03:52:40 -06:00
|
|
|
} // end of namespace sd
|