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