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 #ifdef SD_DLLIMPLEMENTATION 32*cdf0e10cSrcweir #undef SD_DLLIMPLEMENTATION 33*cdf0e10cSrcweir #endif 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir #include <svl/itemset.hxx> 37*cdf0e10cSrcweir #include <sfx2/new.hxx> 38*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir #include "strings.hrc" 41*cdf0e10cSrcweir #include "res_bmp.hrc" 42*cdf0e10cSrcweir #include "sdpreslt.hxx" 43*cdf0e10cSrcweir #include "sdpreslt.hrc" 44*cdf0e10cSrcweir #include "sdattr.hxx" 45*cdf0e10cSrcweir #include "sdresid.hxx" 46*cdf0e10cSrcweir #include "drawdoc.hxx" 47*cdf0e10cSrcweir #include "sdpage.hxx" 48*cdf0e10cSrcweir #include "DrawDocShell.hxx" 49*cdf0e10cSrcweir #include "ViewShell.hxx" 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir #define DOCUMENT_TOKEN (sal_Unicode('#')) 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir /************************************************************************* 54*cdf0e10cSrcweir |* 55*cdf0e10cSrcweir |* Konstruktor 56*cdf0e10cSrcweir |* 57*cdf0e10cSrcweir \************************************************************************/ 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir SdPresLayoutDlg::SdPresLayoutDlg( 60*cdf0e10cSrcweir ::sd::DrawDocShell* pDocShell, 61*cdf0e10cSrcweir ::sd::ViewShell* pViewShell, 62*cdf0e10cSrcweir ::Window* pWindow, 63*cdf0e10cSrcweir const SfxItemSet& rInAttrs ): 64*cdf0e10cSrcweir ModalDialog (pWindow, SdResId(DLG_PRESLT)), 65*cdf0e10cSrcweir mpDocSh ( pDocShell ), 66*cdf0e10cSrcweir mpViewSh ( pViewShell ), 67*cdf0e10cSrcweir maFtLayout (this, SdResId(FT_LAYOUT)), 68*cdf0e10cSrcweir maVS (this, SdResId(VS_LAYOUT)), 69*cdf0e10cSrcweir maBtnOK (this, SdResId(BTN_OK)), 70*cdf0e10cSrcweir maBtnCancel (this, SdResId(BTN_CANCEL)), 71*cdf0e10cSrcweir maBtnHelp (this, SdResId(BTN_HELP)), 72*cdf0e10cSrcweir maCbxMasterPage (this, SdResId(CBX_MASTER_PAGE)), 73*cdf0e10cSrcweir maCbxCheckMasters (this, SdResId(CBX_CHECK_MASTERS)), 74*cdf0e10cSrcweir maBtnLoad (this, SdResId(BTN_LOAD)), 75*cdf0e10cSrcweir mrOutAttrs (rInAttrs), 76*cdf0e10cSrcweir maStrNone ( SdResId( STR_NULL ) ) 77*cdf0e10cSrcweir { 78*cdf0e10cSrcweir FreeResource(); 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir mpLayoutNames = new List; 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir maVS.SetDoubleClickHdl(LINK(this, SdPresLayoutDlg, ClickLayoutHdl)); 83*cdf0e10cSrcweir maBtnLoad.SetClickHdl(LINK(this, SdPresLayoutDlg, ClickLoadHdl)); 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir Reset(); 86*cdf0e10cSrcweir } 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir /************************************************************************* 89*cdf0e10cSrcweir |* 90*cdf0e10cSrcweir |* Dtor 91*cdf0e10cSrcweir |* 92*cdf0e10cSrcweir *************************************************************************/ 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir SdPresLayoutDlg::~SdPresLayoutDlg() 95*cdf0e10cSrcweir { 96*cdf0e10cSrcweir String* pName = (String*)mpLayoutNames->First(); 97*cdf0e10cSrcweir while (pName) 98*cdf0e10cSrcweir { 99*cdf0e10cSrcweir delete pName; 100*cdf0e10cSrcweir pName = (String*)mpLayoutNames->Next(); 101*cdf0e10cSrcweir } 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir delete mpLayoutNames; 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir /************************************************************************* 107*cdf0e10cSrcweir |* 108*cdf0e10cSrcweir |* Initialisierung 109*cdf0e10cSrcweir |* 110*cdf0e10cSrcweir *************************************************************************/ 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir void SdPresLayoutDlg::Reset() 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir const SfxPoolItem *pPoolItem = NULL; 115*cdf0e10cSrcweir long nName; 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir // MasterPage austauschen 118*cdf0e10cSrcweir if( mrOutAttrs.GetItemState( ATTR_PRESLAYOUT_MASTER_PAGE, sal_False, &pPoolItem ) == SFX_ITEM_SET ) 119*cdf0e10cSrcweir { 120*cdf0e10cSrcweir sal_Bool bMasterPage = ( (const SfxBoolItem*) pPoolItem)->GetValue(); 121*cdf0e10cSrcweir maCbxMasterPage.Enable( !bMasterPage ); 122*cdf0e10cSrcweir maCbxMasterPage.Check( bMasterPage ); 123*cdf0e10cSrcweir } 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir // Nicht verwendete MasterPages entfernen 126*cdf0e10cSrcweir maCbxCheckMasters.Check(sal_False); 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir if(mrOutAttrs.GetItemState(ATTR_PRESLAYOUT_NAME, sal_True, &pPoolItem) == SFX_ITEM_SET) 129*cdf0e10cSrcweir maName = ((const SfxStringItem*)pPoolItem)->GetValue(); 130*cdf0e10cSrcweir else 131*cdf0e10cSrcweir maName.Erase(); 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir FillValueSet(); 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir mnLayoutCount = mpLayoutNames->Count(); 136*cdf0e10cSrcweir for( nName = 0; nName < mnLayoutCount; nName++ ) 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir if (*((String*)mpLayoutNames->GetObject(nName)) == maName) 139*cdf0e10cSrcweir break; 140*cdf0e10cSrcweir } 141*cdf0e10cSrcweir DBG_ASSERT(nName < mnLayoutCount, "Layout nicht gefunden"); 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir maVS.SelectItem((sal_uInt16)nName + 1); // Inizes des ValueSets beginnen bei 1 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir } 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir /************************************************************************* 148*cdf0e10cSrcweir |* 149*cdf0e10cSrcweir |* Fuellt uebergebenen Item-Set mit Dialogbox-Attributen 150*cdf0e10cSrcweir |* 151*cdf0e10cSrcweir *************************************************************************/ 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir void SdPresLayoutDlg::GetAttr(SfxItemSet& rOutAttrs) 154*cdf0e10cSrcweir { 155*cdf0e10cSrcweir short nId = maVS.GetSelectItemId(); 156*cdf0e10cSrcweir sal_Bool bLoad = nId > mnLayoutCount; 157*cdf0e10cSrcweir rOutAttrs.Put( SfxBoolItem( ATTR_PRESLAYOUT_LOAD, bLoad ) ); 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir String aLayoutName; 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir if( bLoad ) 162*cdf0e10cSrcweir { 163*cdf0e10cSrcweir aLayoutName = maName; 164*cdf0e10cSrcweir aLayoutName.Append( DOCUMENT_TOKEN ); 165*cdf0e10cSrcweir aLayoutName.Append( *(String*)mpLayoutNames->GetObject( nId - 1 ) ); 166*cdf0e10cSrcweir } 167*cdf0e10cSrcweir else 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir aLayoutName = *(String*)mpLayoutNames->GetObject( nId - 1 ); 170*cdf0e10cSrcweir if( aLayoutName == maStrNone ) 171*cdf0e10cSrcweir aLayoutName.Erase(); // so wird "- keine -" codiert (s.u.) 172*cdf0e10cSrcweir } 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir rOutAttrs.Put( SfxStringItem( ATTR_PRESLAYOUT_NAME, aLayoutName ) ); 175*cdf0e10cSrcweir rOutAttrs.Put( SfxBoolItem( ATTR_PRESLAYOUT_MASTER_PAGE, maCbxMasterPage.IsChecked() ) ); 176*cdf0e10cSrcweir rOutAttrs.Put( SfxBoolItem( ATTR_PRESLAYOUT_CHECK_MASTERS, maCbxCheckMasters.IsChecked() ) ); 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir /************************************************************************* 181*cdf0e10cSrcweir |* 182*cdf0e10cSrcweir |* Fuellt das ValueSet mit Bitmaps 183*cdf0e10cSrcweir |* 184*cdf0e10cSrcweir \************************************************************************/ 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir void SdPresLayoutDlg::FillValueSet() 187*cdf0e10cSrcweir { 188*cdf0e10cSrcweir maVS.SetStyle(maVS.GetStyle() | WB_ITEMBORDER | WB_DOUBLEBORDER 189*cdf0e10cSrcweir | WB_VSCROLL | WB_NAMEFIELD); 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir maVS.SetColCount(2); 192*cdf0e10cSrcweir maVS.SetLineCount(2); 193*cdf0e10cSrcweir maVS.SetExtraSpacing(2); 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir SdDrawDocument* pDoc = mpDocSh->GetDoc(); 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir sal_uInt16 nCount = pDoc->GetMasterPageCount(); 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir for (sal_uInt16 nLayout = 0; nLayout < nCount; nLayout++) 200*cdf0e10cSrcweir { 201*cdf0e10cSrcweir SdPage* pMaster = (SdPage*)pDoc->GetMasterPage(nLayout); 202*cdf0e10cSrcweir if (pMaster->GetPageKind() == PK_STANDARD) 203*cdf0e10cSrcweir { 204*cdf0e10cSrcweir String aLayoutName(pMaster->GetLayoutName()); 205*cdf0e10cSrcweir aLayoutName.Erase( aLayoutName.SearchAscii( SD_LT_SEPARATOR ) ); 206*cdf0e10cSrcweir mpLayoutNames->Insert(new String(aLayoutName), LIST_APPEND); 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir Bitmap aBitmap(mpDocSh->GetPagePreviewBitmap(pMaster, 90)); 209*cdf0e10cSrcweir maVS.InsertItem((sal_uInt16)mpLayoutNames->Count(), aBitmap, aLayoutName); 210*cdf0e10cSrcweir } 211*cdf0e10cSrcweir } 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir maVS.Show(); 214*cdf0e10cSrcweir } 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir /************************************************************************* 218*cdf0e10cSrcweir |* 219*cdf0e10cSrcweir |* Doppelklick-Handler 220*cdf0e10cSrcweir |* 221*cdf0e10cSrcweir \************************************************************************/ 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir IMPL_LINK(SdPresLayoutDlg, ClickLayoutHdl, void *, EMPTYARG) 224*cdf0e10cSrcweir { 225*cdf0e10cSrcweir EndDialog(RET_OK); 226*cdf0e10cSrcweir return 0; 227*cdf0e10cSrcweir } 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir /************************************************************************* 230*cdf0e10cSrcweir |* 231*cdf0e10cSrcweir |* Klick-Handler fuer Laden-Button 232*cdf0e10cSrcweir |* 233*cdf0e10cSrcweir \************************************************************************/ 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir IMPL_LINK(SdPresLayoutDlg, ClickLoadHdl, void *, EMPTYARG) 236*cdf0e10cSrcweir { 237*cdf0e10cSrcweir SfxNewFileDialog* pDlg = new SfxNewFileDialog(this, SFXWB_PREVIEW); 238*cdf0e10cSrcweir pDlg->SetText(String(SdResId(STR_LOAD_PRESENTATION_LAYOUT))); 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir if(!IsReallyVisible()) 241*cdf0e10cSrcweir { 242*cdf0e10cSrcweir delete pDlg; 243*cdf0e10cSrcweir return 0; 244*cdf0e10cSrcweir } 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir sal_uInt16 nResult = pDlg->Execute(); 247*cdf0e10cSrcweir // #96072# OJ: Inserted update to force repaint 248*cdf0e10cSrcweir Update(); 249*cdf0e10cSrcweir 250*cdf0e10cSrcweir String aFile; 251*cdf0e10cSrcweir sal_Bool bCancel = sal_False; 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir switch (nResult) 254*cdf0e10cSrcweir { 255*cdf0e10cSrcweir case RET_OK: 256*cdf0e10cSrcweir { 257*cdf0e10cSrcweir if (pDlg->IsTemplate()) 258*cdf0e10cSrcweir { 259*cdf0e10cSrcweir maName = pDlg->GetTemplateFileName(); 260*cdf0e10cSrcweir } 261*cdf0e10cSrcweir else 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir // so wird "- keine -" codiert 264*cdf0e10cSrcweir maName.Erase(); 265*cdf0e10cSrcweir } 266*cdf0e10cSrcweir } 267*cdf0e10cSrcweir break; 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir default: 270*cdf0e10cSrcweir bCancel = sal_True; 271*cdf0e10cSrcweir } 272*cdf0e10cSrcweir delete pDlg; 273*cdf0e10cSrcweir 274*cdf0e10cSrcweir // if (!bCancel) 275*cdf0e10cSrcweir // EndDialog(RET_OK); 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir if( !bCancel ) 278*cdf0e10cSrcweir { 279*cdf0e10cSrcweir // Pruefen, ob Vorlage schon vorhanden 280*cdf0e10cSrcweir sal_Bool bExists = sal_False; 281*cdf0e10cSrcweir String* pName = (String*)mpLayoutNames->First(); 282*cdf0e10cSrcweir String aCompareStr( maName ); 283*cdf0e10cSrcweir if( maName.Len() == 0 ) 284*cdf0e10cSrcweir aCompareStr = maStrNone; 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir while( pName && !bExists ) 287*cdf0e10cSrcweir { 288*cdf0e10cSrcweir if( aCompareStr == *pName ) 289*cdf0e10cSrcweir { 290*cdf0e10cSrcweir bExists = sal_True; 291*cdf0e10cSrcweir // Vorlage selektieren 292*cdf0e10cSrcweir sal_uInt16 nId = (sal_uInt16) mpLayoutNames->GetCurPos() + 1; 293*cdf0e10cSrcweir maVS.SelectItem( nId ); 294*cdf0e10cSrcweir } 295*cdf0e10cSrcweir pName = (String*)mpLayoutNames->Next(); 296*cdf0e10cSrcweir } 297*cdf0e10cSrcweir 298*cdf0e10cSrcweir if( !bExists ) 299*cdf0e10cSrcweir { 300*cdf0e10cSrcweir // Dokument laden um Preview-Bitmap zu ermitteln (wenn Vorlage ausgewaehlt) 301*cdf0e10cSrcweir if( maName.Len() ) 302*cdf0e10cSrcweir { 303*cdf0e10cSrcweir // Dokument ermitteln, um OpenBookmarkDoc rufen zu koennen 304*cdf0e10cSrcweir SdDrawDocument* pDoc = mpDocSh->GetDoc(); 305*cdf0e10cSrcweir SdDrawDocument* pTemplDoc = pDoc->OpenBookmarkDoc( maName ); 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir if (pTemplDoc) 308*cdf0e10cSrcweir { 309*cdf0e10cSrcweir ::sd::DrawDocShell* pTemplDocSh= pTemplDoc->GetDocSh(); 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir /* SdPage* pMaster = pTemplDoc->GetMasterSdPage( 0, PK_STANDARD ); 312*cdf0e10cSrcweir mpLayoutNames->Insert( new String( maName ), LIST_APPEND ); 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir Bitmap aBitmap( pTemplDocSh->GetPagePreviewBitmap( pMaster, 90 ) ); 315*cdf0e10cSrcweir maVS.InsertItem( (sal_uInt16) mpLayoutNames->Count(), aBitmap, maName); 316*cdf0e10cSrcweir */ 317*cdf0e10cSrcweir sal_uInt16 nCount = pTemplDoc->GetMasterPageCount(); 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir for (sal_uInt16 nLayout = 0; nLayout < nCount; nLayout++) 320*cdf0e10cSrcweir { 321*cdf0e10cSrcweir SdPage* pMaster = (SdPage*) pTemplDoc->GetMasterPage(nLayout); 322*cdf0e10cSrcweir if (pMaster->GetPageKind() == PK_STANDARD) 323*cdf0e10cSrcweir { 324*cdf0e10cSrcweir String aLayoutName(pMaster->GetLayoutName()); 325*cdf0e10cSrcweir aLayoutName.Erase( aLayoutName.SearchAscii( SD_LT_SEPARATOR ) ); 326*cdf0e10cSrcweir mpLayoutNames->Insert(new String(aLayoutName), LIST_APPEND); 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir Bitmap aBitmap(pTemplDocSh->GetPagePreviewBitmap(pMaster, 90)); 329*cdf0e10cSrcweir maVS.InsertItem((sal_uInt16)mpLayoutNames->Count(), aBitmap, aLayoutName); 330*cdf0e10cSrcweir } 331*cdf0e10cSrcweir } 332*cdf0e10cSrcweir } 333*cdf0e10cSrcweir else 334*cdf0e10cSrcweir { 335*cdf0e10cSrcweir bCancel = sal_True; 336*cdf0e10cSrcweir } 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir pDoc->CloseBookmarkDoc(); 339*cdf0e10cSrcweir } 340*cdf0e10cSrcweir else 341*cdf0e10cSrcweir { 342*cdf0e10cSrcweir // leeres Layout 343*cdf0e10cSrcweir mpLayoutNames->Insert( new String( maStrNone ), LIST_APPEND ); 344*cdf0e10cSrcweir maVS.InsertItem( (sal_uInt16) mpLayoutNames->Count(), 345*cdf0e10cSrcweir Bitmap( SdResId( BMP_FOIL_NONE ) ), maStrNone ); 346*cdf0e10cSrcweir } 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir if (!bCancel) 349*cdf0e10cSrcweir { 350*cdf0e10cSrcweir // Vorlage selektieren 351*cdf0e10cSrcweir maVS.SelectItem( (sal_uInt16) mpLayoutNames->Count() ); 352*cdf0e10cSrcweir } 353*cdf0e10cSrcweir } 354*cdf0e10cSrcweir } 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir return( 0 ); 357*cdf0e10cSrcweir } 358