1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sd.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "DrawDocShell.hxx" 32*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 33*cdf0e10cSrcweir #include <svx/svdpagv.hxx> 34*cdf0e10cSrcweir #include <svx/svxdlg.hxx> 35*cdf0e10cSrcweir #include <svx/dialogs.hrc> 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #include "helpids.h" 38*cdf0e10cSrcweir #include "ViewShell.hxx" 39*cdf0e10cSrcweir #include "drawview.hxx" 40*cdf0e10cSrcweir #ifndef SD_FRAMW_VIEW_HXX 41*cdf0e10cSrcweir #include "FrameView.hxx" 42*cdf0e10cSrcweir #endif 43*cdf0e10cSrcweir #include "drawdoc.hxx" 44*cdf0e10cSrcweir #include "sdpage.hxx" 45*cdf0e10cSrcweir #include "View.hxx" 46*cdf0e10cSrcweir #include "ClientView.hxx" 47*cdf0e10cSrcweir #ifndef SD_WINDOW_SHELL_HXX 48*cdf0e10cSrcweir #include "Window.hxx" 49*cdf0e10cSrcweir #endif 50*cdf0e10cSrcweir #include "strings.hrc" 51*cdf0e10cSrcweir #include "res_bmp.hrc" 52*cdf0e10cSrcweir #include "sdresid.hxx" 53*cdf0e10cSrcweir #include "strmname.h" 54*cdf0e10cSrcweir #include "fupoor.hxx" 55*cdf0e10cSrcweir #include <vcl/svapp.hxx> 56*cdf0e10cSrcweir #include <vcl/virdev.hxx> 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir namespace sd { 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir /************************************************************************* 61*cdf0e10cSrcweir |* 62*cdf0e10cSrcweir |* Zeichnen der DocShell (mittels der Hilfsklasse SdDrawViewShell) 63*cdf0e10cSrcweir |* 64*cdf0e10cSrcweir \************************************************************************/ 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir void DrawDocShell::Draw(OutputDevice* pOut, const JobSetup&, sal_uInt16 nAspect) 67*cdf0e10cSrcweir { 68*cdf0e10cSrcweir if (nAspect == ASPECT_THUMBNAIL) 69*cdf0e10cSrcweir { 70*cdf0e10cSrcweir /********************************************************************** 71*cdf0e10cSrcweir * THUMBNAIL: Hier koennte ev. einmal der Draft-Mode gesetzt werden 72*cdf0e10cSrcweir **********************************************************************/ 73*cdf0e10cSrcweir } 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir ClientView* pView = new ClientView(this, pOut, NULL); 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir pView->SetHlplVisible(sal_False); 78*cdf0e10cSrcweir pView->SetGridVisible(sal_False); 79*cdf0e10cSrcweir pView->SetBordVisible(sal_False); 80*cdf0e10cSrcweir pView->SetPageVisible(sal_False); 81*cdf0e10cSrcweir pView->SetGlueVisible(sal_False); 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir SdPage* pSelectedPage = NULL; 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir List* pFrameViewList = mpDoc->GetFrameViewList(); 86*cdf0e10cSrcweir if( pFrameViewList && pFrameViewList->Count() ) 87*cdf0e10cSrcweir { 88*cdf0e10cSrcweir FrameView* pFrameView = (FrameView*)pFrameViewList->GetObject(0); 89*cdf0e10cSrcweir if( pFrameView && pFrameView->GetPageKind() == PK_STANDARD ) 90*cdf0e10cSrcweir { 91*cdf0e10cSrcweir sal_uInt16 nSelectedPage = pFrameView->GetSelectedPage(); 92*cdf0e10cSrcweir pSelectedPage = mpDoc->GetSdPage(nSelectedPage, PK_STANDARD); 93*cdf0e10cSrcweir } 94*cdf0e10cSrcweir } 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir if( NULL == pSelectedPage ) 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir SdPage* pPage = NULL; 99*cdf0e10cSrcweir sal_uInt16 nSelectedPage = 0; 100*cdf0e10cSrcweir sal_uInt16 nPageCnt = (sal_uInt16) mpDoc->GetSdPageCount(PK_STANDARD); 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir for (sal_uInt16 i = 0; i < nPageCnt; i++) 103*cdf0e10cSrcweir { 104*cdf0e10cSrcweir pPage = mpDoc->GetSdPage(i, PK_STANDARD); 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir if ( pPage->IsSelected() ) 107*cdf0e10cSrcweir { 108*cdf0e10cSrcweir nSelectedPage = i; 109*cdf0e10cSrcweir pSelectedPage = pPage; 110*cdf0e10cSrcweir } 111*cdf0e10cSrcweir } 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir if( NULL == pSelectedPage ) 114*cdf0e10cSrcweir pSelectedPage = mpDoc->GetSdPage(0, PK_STANDARD); 115*cdf0e10cSrcweir } 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir Rectangle aVisArea = GetVisArea(nAspect); 118*cdf0e10cSrcweir pOut->IntersectClipRegion(aVisArea); 119*cdf0e10cSrcweir pView->ShowSdrPage(pSelectedPage); 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir if (pOut->GetOutDevType() != OUTDEV_WINDOW) 122*cdf0e10cSrcweir { 123*cdf0e10cSrcweir MapMode aOldMapMode = pOut->GetMapMode(); 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir if (pOut->GetOutDevType() == OUTDEV_PRINTER) 126*cdf0e10cSrcweir { 127*cdf0e10cSrcweir MapMode aMapMode = aOldMapMode; 128*cdf0e10cSrcweir Point aOrigin = aMapMode.GetOrigin(); 129*cdf0e10cSrcweir aOrigin.X() += 1; 130*cdf0e10cSrcweir aOrigin.Y() += 1; 131*cdf0e10cSrcweir aMapMode.SetOrigin(aOrigin); 132*cdf0e10cSrcweir pOut->SetMapMode(aMapMode); 133*cdf0e10cSrcweir } 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir Region aRegion(aVisArea); 136*cdf0e10cSrcweir pView->CompleteRedraw(pOut, aRegion); 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir if (pOut->GetOutDevType() == OUTDEV_PRINTER) 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir pOut->SetMapMode(aOldMapMode); 141*cdf0e10cSrcweir } 142*cdf0e10cSrcweir } 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir delete pView; 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir // Fuer Testzwecke: Bitte nicht entfernen! 147*cdf0e10cSrcweir // 148*cdf0e10cSrcweir // GDIMetaFile* pMtf = pOut->GetConnectMetaFile(); 149*cdf0e10cSrcweir // 150*cdf0e10cSrcweir // if( pMtf ) 151*cdf0e10cSrcweir // { 152*cdf0e10cSrcweir // String aURLStr; 153*cdf0e10cSrcweir // 154*cdf0e10cSrcweir // if( ::utl::LocalFileHelper::ConvertPhysicalNameToURL( String( RTL_CONSTASCII_USTRINGPARAM( "d:\\gdi.mtf" ) ), aURLStr ) ) 155*cdf0e10cSrcweir // { 156*cdf0e10cSrcweir // SvStream* pOStm = ::utl::UcbStreamHelper::CreateStream( aURLStr, STREAM_WRITE | STREAM_TRUNC ); 157*cdf0e10cSrcweir // 158*cdf0e10cSrcweir // if( pOStm ) 159*cdf0e10cSrcweir // { 160*cdf0e10cSrcweir // *pOStm << *pMtf; 161*cdf0e10cSrcweir // delete pOStm; 162*cdf0e10cSrcweir // } 163*cdf0e10cSrcweir // } 164*cdf0e10cSrcweir // } 165*cdf0e10cSrcweir } 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir /************************************************************************* 168*cdf0e10cSrcweir |* 169*cdf0e10cSrcweir |* 170*cdf0e10cSrcweir |* 171*cdf0e10cSrcweir \************************************************************************/ 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir Rectangle DrawDocShell::GetVisArea(sal_uInt16 nAspect) const 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir Rectangle aVisArea; 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir if( ( ASPECT_THUMBNAIL == nAspect ) || ( ASPECT_DOCPRINT == nAspect ) ) 178*cdf0e10cSrcweir { 179*cdf0e10cSrcweir // Groesse der ersten Seite herausgeben 180*cdf0e10cSrcweir MapMode aSrcMapMode(MAP_PIXEL); 181*cdf0e10cSrcweir MapMode aDstMapMode(MAP_100TH_MM); 182*cdf0e10cSrcweir Size aSize = mpDoc->GetSdPage(0, PK_STANDARD)->GetSize(); 183*cdf0e10cSrcweir aSrcMapMode.SetMapUnit(MAP_100TH_MM); 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir aSize = Application::GetDefaultDevice()->LogicToLogic(aSize, &aSrcMapMode, &aDstMapMode); 186*cdf0e10cSrcweir aVisArea.SetSize(aSize); 187*cdf0e10cSrcweir } 188*cdf0e10cSrcweir else 189*cdf0e10cSrcweir { 190*cdf0e10cSrcweir aVisArea = SfxObjectShell::GetVisArea(nAspect); 191*cdf0e10cSrcweir } 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir if (aVisArea.IsEmpty() && mpViewShell) 194*cdf0e10cSrcweir { 195*cdf0e10cSrcweir Window* pWin = mpViewShell->GetActiveWindow(); 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir if (pWin) 198*cdf0e10cSrcweir { 199*cdf0e10cSrcweir aVisArea = pWin->PixelToLogic(Rectangle(Point(0,0), pWin->GetOutputSizePixel())); 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir } 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir return (aVisArea); 204*cdf0e10cSrcweir } 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir /************************************************************************* 207*cdf0e10cSrcweir |* 208*cdf0e10cSrcweir |* ViewShell anmelden 209*cdf0e10cSrcweir |* 210*cdf0e10cSrcweir \************************************************************************/ 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir void DrawDocShell::Connect(ViewShell* pViewSh) 213*cdf0e10cSrcweir { 214*cdf0e10cSrcweir mpViewShell = pViewSh; 215*cdf0e10cSrcweir } 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir /************************************************************************* 218*cdf0e10cSrcweir |* 219*cdf0e10cSrcweir |* ViewShell abmelden 220*cdf0e10cSrcweir |* 221*cdf0e10cSrcweir \************************************************************************/ 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir void DrawDocShell::Disconnect(ViewShell* pViewSh) 224*cdf0e10cSrcweir { 225*cdf0e10cSrcweir if (mpViewShell == pViewSh) 226*cdf0e10cSrcweir { 227*cdf0e10cSrcweir mpViewShell = NULL; 228*cdf0e10cSrcweir } 229*cdf0e10cSrcweir } 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir /************************************************************************* 232*cdf0e10cSrcweir |* 233*cdf0e10cSrcweir |* 234*cdf0e10cSrcweir |* 235*cdf0e10cSrcweir \************************************************************************/ 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir FrameView* DrawDocShell::GetFrameView() 238*cdf0e10cSrcweir { 239*cdf0e10cSrcweir FrameView* pFrameView = NULL; 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir if (mpViewShell) 242*cdf0e10cSrcweir { 243*cdf0e10cSrcweir pFrameView = mpViewShell->GetFrameView(); 244*cdf0e10cSrcweir } 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir return(pFrameView); 247*cdf0e10cSrcweir } 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir /************************************************************************* 250*cdf0e10cSrcweir |* 251*cdf0e10cSrcweir |* Groesse der ersten Seite zurueckgeben 252*cdf0e10cSrcweir |* 253*cdf0e10cSrcweir \************************************************************************/ 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir Size DrawDocShell::GetFirstPageSize() 256*cdf0e10cSrcweir { 257*cdf0e10cSrcweir return SfxObjectShell::GetFirstPageSize(); 258*cdf0e10cSrcweir } 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir /************************************************************************* 261*cdf0e10cSrcweir |* 262*cdf0e10cSrcweir |* Bitmap einer beliebigen Seite erzeugen 263*cdf0e10cSrcweir |* 264*cdf0e10cSrcweir \************************************************************************/ 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir Bitmap DrawDocShell::GetPagePreviewBitmap(SdPage* pPage, sal_uInt16 nMaxEdgePixel) 267*cdf0e10cSrcweir { 268*cdf0e10cSrcweir MapMode aMapMode( MAP_100TH_MM ); 269*cdf0e10cSrcweir const Size aSize( pPage->GetSize() ); 270*cdf0e10cSrcweir const Point aNullPt; 271*cdf0e10cSrcweir VirtualDevice aVDev( *Application::GetDefaultDevice() ); 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir aVDev.SetMapMode( aMapMode ); 274*cdf0e10cSrcweir 275*cdf0e10cSrcweir const Size aPixSize( aVDev.LogicToPixel( aSize ) ); 276*cdf0e10cSrcweir const sal_uLong nMaxEdgePix = Max( aPixSize.Width(), aPixSize.Height() ); 277*cdf0e10cSrcweir Fraction aFrac( nMaxEdgePixel, nMaxEdgePix ); 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir aMapMode.SetScaleX( aFrac ); 280*cdf0e10cSrcweir aMapMode.SetScaleY( aFrac ); 281*cdf0e10cSrcweir aVDev.SetMapMode( aMapMode ); 282*cdf0e10cSrcweir aVDev.SetOutputSize( aSize ); 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir // damit die dunklen Linien am rechten und unteren Seitenrans mitkommen 285*cdf0e10cSrcweir aFrac = Fraction( nMaxEdgePixel - 1, nMaxEdgePix ); 286*cdf0e10cSrcweir aMapMode.SetScaleX( aFrac ); 287*cdf0e10cSrcweir aMapMode.SetScaleY( aFrac ); 288*cdf0e10cSrcweir aVDev.SetMapMode( aMapMode ); 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir ClientView* pView = new ClientView( this, &aVDev, NULL ); 291*cdf0e10cSrcweir FrameView* pFrameView = GetFrameView(); 292*cdf0e10cSrcweir pView->ShowSdrPage( pPage ); 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir if ( GetFrameView() ) 295*cdf0e10cSrcweir { 296*cdf0e10cSrcweir // Initialisierungen der Zeichen-(Bildschirm-)Attribute 297*cdf0e10cSrcweir pView->SetGridCoarse( pFrameView->GetGridCoarse() ); 298*cdf0e10cSrcweir pView->SetGridFine( pFrameView->GetGridFine() ); 299*cdf0e10cSrcweir pView->SetSnapGridWidth(pFrameView->GetSnapGridWidthX(), pFrameView->GetSnapGridWidthY()); 300*cdf0e10cSrcweir pView->SetGridVisible( pFrameView->IsGridVisible() ); 301*cdf0e10cSrcweir pView->SetGridFront( pFrameView->IsGridFront() ); 302*cdf0e10cSrcweir pView->SetSnapAngle( pFrameView->GetSnapAngle() ); 303*cdf0e10cSrcweir pView->SetGridSnap( pFrameView->IsGridSnap() ); 304*cdf0e10cSrcweir pView->SetBordSnap( pFrameView->IsBordSnap() ); 305*cdf0e10cSrcweir pView->SetHlplSnap( pFrameView->IsHlplSnap() ); 306*cdf0e10cSrcweir pView->SetOFrmSnap( pFrameView->IsOFrmSnap() ); 307*cdf0e10cSrcweir pView->SetOPntSnap( pFrameView->IsOPntSnap() ); 308*cdf0e10cSrcweir pView->SetOConSnap( pFrameView->IsOConSnap() ); 309*cdf0e10cSrcweir pView->SetDragStripes( pFrameView->IsDragStripes() ); 310*cdf0e10cSrcweir pView->SetFrameDragSingles( pFrameView->IsFrameDragSingles() ); 311*cdf0e10cSrcweir pView->SetSnapMagneticPixel( pFrameView->GetSnapMagneticPixel() ); 312*cdf0e10cSrcweir pView->SetMarkedHitMovesAlways( pFrameView->IsMarkedHitMovesAlways() ); 313*cdf0e10cSrcweir pView->SetMoveOnlyDragging( pFrameView->IsMoveOnlyDragging() ); 314*cdf0e10cSrcweir pView->SetSlantButShear( pFrameView->IsSlantButShear() ); 315*cdf0e10cSrcweir pView->SetNoDragXorPolys( pFrameView->IsNoDragXorPolys() ); 316*cdf0e10cSrcweir pView->SetCrookNoContortion( pFrameView->IsCrookNoContortion() ); 317*cdf0e10cSrcweir pView->SetAngleSnapEnabled( pFrameView->IsAngleSnapEnabled() ); 318*cdf0e10cSrcweir pView->SetBigOrtho( pFrameView->IsBigOrtho() ); 319*cdf0e10cSrcweir pView->SetOrtho( pFrameView->IsOrtho() ); 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir SdrPageView* pPageView = pView->GetSdrPageView(); 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir if (pPageView) 324*cdf0e10cSrcweir { 325*cdf0e10cSrcweir if ( pPageView->GetVisibleLayers() != pFrameView->GetVisibleLayers() ) 326*cdf0e10cSrcweir pPageView->SetVisibleLayers( pFrameView->GetVisibleLayers() ); 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir if ( pPageView->GetPrintableLayers() != pFrameView->GetPrintableLayers() ) 329*cdf0e10cSrcweir pPageView->SetPrintableLayers( pFrameView->GetPrintableLayers() ); 330*cdf0e10cSrcweir 331*cdf0e10cSrcweir if ( pPageView->GetLockedLayers() != pFrameView->GetLockedLayers() ) 332*cdf0e10cSrcweir pPageView->SetLockedLayers( pFrameView->GetLockedLayers() ); 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir // if ( pPageView->GetHelpLines() != pFrameView->GetHelpLines() ) 335*cdf0e10cSrcweir pPageView->SetHelpLines( pFrameView->GetStandardHelpLines() ); 336*cdf0e10cSrcweir } 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir if ( pView->GetActiveLayer() != pFrameView->GetActiveLayer() ) 339*cdf0e10cSrcweir pView->SetActiveLayer( pFrameView->GetActiveLayer() ); 340*cdf0e10cSrcweir } 341*cdf0e10cSrcweir 342*cdf0e10cSrcweir pView->CompleteRedraw( &aVDev, Rectangle( aNullPt, aSize ) ); 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir // #111097# IsRedrawReady() always gives sal_True while ( !pView->IsRedrawReady() ) {} 345*cdf0e10cSrcweir delete pView; 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir aVDev.SetMapMode( MapMode() ); 348*cdf0e10cSrcweir 349*cdf0e10cSrcweir Bitmap aPreview( aVDev.GetBitmap( aNullPt, aVDev.GetOutputSizePixel() ) ); 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir DBG_ASSERT(!!aPreview, "Vorschau-Bitmap konnte nicht erzeugt werden"); 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir return aPreview; 354*cdf0e10cSrcweir } 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir /************************************************************************* 358*cdf0e10cSrcweir |* 359*cdf0e10cSrcweir |* Pruefen, ob die Seite vorhanden ist und dann den Anwender zwingen einen 360*cdf0e10cSrcweir |* noch nicht vorhandenen Namen einzugeben. Wird sal_False zurueckgegeben, 361*cdf0e10cSrcweir |* wurde die Aktion vom Anwender abgebrochen. 362*cdf0e10cSrcweir |* 363*cdf0e10cSrcweir \************************************************************************/ 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir sal_Bool DrawDocShell::CheckPageName (::Window* pWin, String& rName ) 366*cdf0e10cSrcweir { 367*cdf0e10cSrcweir const String aStrForDlg( rName ); 368*cdf0e10cSrcweir bool bIsNameValid = IsNewPageNameValid( rName, true ); 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir if( ! bIsNameValid ) 371*cdf0e10cSrcweir { 372*cdf0e10cSrcweir String aDesc( SdResId( STR_WARN_PAGE_EXISTS ) ); 373*cdf0e10cSrcweir SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 374*cdf0e10cSrcweir AbstractSvxNameDialog* aNameDlg = pFact ? pFact->CreateSvxNameDialog( pWin, aStrForDlg, aDesc ) : 0; 375*cdf0e10cSrcweir if( aNameDlg ) 376*cdf0e10cSrcweir { 377*cdf0e10cSrcweir aNameDlg->SetEditHelpId( HID_SD_NAMEDIALOG_PAGE ); 378*cdf0e10cSrcweir 379*cdf0e10cSrcweir if( mpViewShell ) 380*cdf0e10cSrcweir aNameDlg->SetCheckNameHdl( LINK( this, DrawDocShell, RenameSlideHdl ) ); 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir FunctionReference xFunc( mpViewShell->GetCurrentFunction() ); 383*cdf0e10cSrcweir if( xFunc.is() ) 384*cdf0e10cSrcweir xFunc->cancel(); 385*cdf0e10cSrcweir 386*cdf0e10cSrcweir if( aNameDlg->Execute() == RET_OK ) 387*cdf0e10cSrcweir { 388*cdf0e10cSrcweir aNameDlg->GetName( rName ); 389*cdf0e10cSrcweir bIsNameValid = IsNewPageNameValid( rName ); 390*cdf0e10cSrcweir } 391*cdf0e10cSrcweir delete aNameDlg; 392*cdf0e10cSrcweir } 393*cdf0e10cSrcweir } 394*cdf0e10cSrcweir 395*cdf0e10cSrcweir return ( bIsNameValid ? sal_True : sal_False ); 396*cdf0e10cSrcweir } 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir bool DrawDocShell::IsNewPageNameValid( String & rInOutPageName, bool bResetStringIfStandardName /* = false */ ) 399*cdf0e10cSrcweir { 400*cdf0e10cSrcweir bool bCanUseNewName = false; 401*cdf0e10cSrcweir 402*cdf0e10cSrcweir // check if name is something like 'Slide n' 403*cdf0e10cSrcweir String aStrPage( SdResId( STR_SD_PAGE ) ); 404*cdf0e10cSrcweir aStrPage += ' '; 405*cdf0e10cSrcweir 406*cdf0e10cSrcweir bool bIsStandardName = false; 407*cdf0e10cSrcweir 408*cdf0e10cSrcweir // prevent also _future_ slide names of the form "'STR_SD_PAGE' + ' ' + '[0-9]+|[a-z]|[A-Z]|[CDILMVX]+|[cdilmvx]+'" 409*cdf0e10cSrcweir // (arabic, lower- and upper case single letter, lower- and upper case roman numbers) 410*cdf0e10cSrcweir if( 0 == rInOutPageName.Search( aStrPage ) ) 411*cdf0e10cSrcweir { 412*cdf0e10cSrcweir if( rInOutPageName.GetToken( 1, sal_Unicode(' ') ).GetChar(0) >= '0' && 413*cdf0e10cSrcweir rInOutPageName.GetToken( 1, sal_Unicode(' ') ).GetChar(0) <= '9' ) 414*cdf0e10cSrcweir { 415*cdf0e10cSrcweir // check for arabic numbering 416*cdf0e10cSrcweir 417*cdf0e10cSrcweir // gobble up all following numbers 418*cdf0e10cSrcweir String sRemainder = rInOutPageName.GetToken( 1, sal_Unicode(' ') ); 419*cdf0e10cSrcweir while( sRemainder.Len() && 420*cdf0e10cSrcweir sRemainder.GetChar(0) >= '0' && 421*cdf0e10cSrcweir sRemainder.GetChar(0) <= '9' ) 422*cdf0e10cSrcweir { 423*cdf0e10cSrcweir // trim by one 424*cdf0e10cSrcweir sRemainder.Erase(0, 1); 425*cdf0e10cSrcweir } 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir // EOL? Reserved name! 428*cdf0e10cSrcweir if( !sRemainder.Len() ) 429*cdf0e10cSrcweir { 430*cdf0e10cSrcweir bIsStandardName = true; 431*cdf0e10cSrcweir } 432*cdf0e10cSrcweir } 433*cdf0e10cSrcweir else if( rInOutPageName.GetToken( 1, sal_Unicode(' ') ).GetChar(0) >= 'a' && 434*cdf0e10cSrcweir rInOutPageName.GetToken( 1, sal_Unicode(' ') ).GetChar(0) <= 'z' && 435*cdf0e10cSrcweir rInOutPageName.GetToken( 1, sal_Unicode(' ') ).Len() == 1 ) 436*cdf0e10cSrcweir { 437*cdf0e10cSrcweir // lower case, single character: reserved 438*cdf0e10cSrcweir bIsStandardName = true; 439*cdf0e10cSrcweir } 440*cdf0e10cSrcweir else if( rInOutPageName.GetToken( 1, sal_Unicode(' ') ).GetChar(0) >= 'A' && 441*cdf0e10cSrcweir rInOutPageName.GetToken( 1, sal_Unicode(' ') ).GetChar(0) <= 'Z' && 442*cdf0e10cSrcweir rInOutPageName.GetToken( 1, sal_Unicode(' ') ).Len() == 1 ) 443*cdf0e10cSrcweir { 444*cdf0e10cSrcweir // upper case, single character: reserved 445*cdf0e10cSrcweir bIsStandardName = true; 446*cdf0e10cSrcweir } 447*cdf0e10cSrcweir else 448*cdf0e10cSrcweir { 449*cdf0e10cSrcweir // check for upper/lower case roman numbering 450*cdf0e10cSrcweir String sReserved( String::CreateFromAscii( "cdilmvx" ) ); 451*cdf0e10cSrcweir 452*cdf0e10cSrcweir // gobble up all following characters contained in one reserved class 453*cdf0e10cSrcweir String sRemainder = rInOutPageName.GetToken( 1, sal_Unicode(' ') ); 454*cdf0e10cSrcweir if( sReserved.Search( sRemainder.GetChar(0) ) == STRING_NOTFOUND ) 455*cdf0e10cSrcweir sReserved.ToUpperAscii(); 456*cdf0e10cSrcweir 457*cdf0e10cSrcweir while( sReserved.Search( sRemainder.GetChar(0) ) != STRING_NOTFOUND ) 458*cdf0e10cSrcweir { 459*cdf0e10cSrcweir // trim by one 460*cdf0e10cSrcweir sRemainder.Erase(0, 1); 461*cdf0e10cSrcweir } 462*cdf0e10cSrcweir 463*cdf0e10cSrcweir // EOL? Reserved name! 464*cdf0e10cSrcweir if( !sRemainder.Len() ) 465*cdf0e10cSrcweir { 466*cdf0e10cSrcweir bIsStandardName = true; 467*cdf0e10cSrcweir } 468*cdf0e10cSrcweir } 469*cdf0e10cSrcweir } 470*cdf0e10cSrcweir 471*cdf0e10cSrcweir if( bIsStandardName ) 472*cdf0e10cSrcweir { 473*cdf0e10cSrcweir if( bResetStringIfStandardName ) 474*cdf0e10cSrcweir { 475*cdf0e10cSrcweir // this is for insertion of slides from other files with standard 476*cdf0e10cSrcweir // name. They get a new standard name, if the string is set to an 477*cdf0e10cSrcweir // empty one. 478*cdf0e10cSrcweir rInOutPageName = String(); 479*cdf0e10cSrcweir bCanUseNewName = true; 480*cdf0e10cSrcweir } 481*cdf0e10cSrcweir else 482*cdf0e10cSrcweir bCanUseNewName = false; 483*cdf0e10cSrcweir } 484*cdf0e10cSrcweir else 485*cdf0e10cSrcweir { 486*cdf0e10cSrcweir if( rInOutPageName.Len() > 0 ) 487*cdf0e10cSrcweir { 488*cdf0e10cSrcweir sal_Bool bOutDummy; 489*cdf0e10cSrcweir sal_uInt16 nExistingPageNum = mpDoc->GetPageByName( rInOutPageName, bOutDummy ); 490*cdf0e10cSrcweir bCanUseNewName = ( nExistingPageNum == SDRPAGE_NOTFOUND ); 491*cdf0e10cSrcweir } 492*cdf0e10cSrcweir else 493*cdf0e10cSrcweir bCanUseNewName = false; 494*cdf0e10cSrcweir } 495*cdf0e10cSrcweir 496*cdf0e10cSrcweir return bCanUseNewName; 497*cdf0e10cSrcweir } 498*cdf0e10cSrcweir 499*cdf0e10cSrcweir IMPL_LINK( DrawDocShell, RenameSlideHdl, AbstractSvxNameDialog*, pDialog ) 500*cdf0e10cSrcweir { 501*cdf0e10cSrcweir if( ! pDialog ) 502*cdf0e10cSrcweir return 0; 503*cdf0e10cSrcweir 504*cdf0e10cSrcweir String aNewName; 505*cdf0e10cSrcweir pDialog->GetName( aNewName ); 506*cdf0e10cSrcweir 507*cdf0e10cSrcweir return IsNewPageNameValid( aNewName ); 508*cdf0e10cSrcweir } 509*cdf0e10cSrcweir } // end of namespace sd 510