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 "fuprobjs.hxx" 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #ifndef _MSGBOX_HXX //autogen 34*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 35*cdf0e10cSrcweir #endif 36*cdf0e10cSrcweir #include <svl/style.hxx> 37*cdf0e10cSrcweir #include <editeng/outliner.hxx> 38*cdf0e10cSrcweir #include <svl/smplhint.hxx> 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir #include "app.hrc" 42*cdf0e10cSrcweir #include "res_bmp.hrc" 43*cdf0e10cSrcweir #include "strings.hrc" 44*cdf0e10cSrcweir #include "glob.hrc" 45*cdf0e10cSrcweir #include "prltempl.hrc" 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir #include "sdresid.hxx" 48*cdf0e10cSrcweir #include "drawdoc.hxx" 49*cdf0e10cSrcweir #ifndef SD_OUTLINE_VIEW_SHELL_HX 50*cdf0e10cSrcweir #include "OutlineViewShell.hxx" 51*cdf0e10cSrcweir #endif 52*cdf0e10cSrcweir #include "ViewShell.hxx" 53*cdf0e10cSrcweir #include "Window.hxx" 54*cdf0e10cSrcweir #include "glob.hxx" 55*cdf0e10cSrcweir #include "prlayout.hxx" 56*cdf0e10cSrcweir #include "unchss.hxx" 57*cdf0e10cSrcweir #include "sdabstdlg.hxx" 58*cdf0e10cSrcweir namespace sd { 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir TYPEINIT1( FuPresentationObjects, FuPoor ); 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir /************************************************************************* 64*cdf0e10cSrcweir |* 65*cdf0e10cSrcweir |* Konstruktor 66*cdf0e10cSrcweir |* 67*cdf0e10cSrcweir \************************************************************************/ 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir FuPresentationObjects::FuPresentationObjects ( 70*cdf0e10cSrcweir ViewShell* pViewSh, 71*cdf0e10cSrcweir ::sd::Window* pWin, 72*cdf0e10cSrcweir ::sd::View* pView, 73*cdf0e10cSrcweir SdDrawDocument* pDoc, 74*cdf0e10cSrcweir SfxRequest& rReq) 75*cdf0e10cSrcweir : FuPoor(pViewSh, pWin, pView, pDoc, rReq) 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir } 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir FunctionReference FuPresentationObjects::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq ) 80*cdf0e10cSrcweir { 81*cdf0e10cSrcweir FunctionReference xFunc( new FuPresentationObjects( pViewSh, pWin, pView, pDoc, rReq ) ); 82*cdf0e10cSrcweir xFunc->DoExecute(rReq); 83*cdf0e10cSrcweir return xFunc; 84*cdf0e10cSrcweir } 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir void FuPresentationObjects::DoExecute( SfxRequest& ) 87*cdf0e10cSrcweir { 88*cdf0e10cSrcweir OutlineViewShell* pOutlineViewShell = dynamic_cast< OutlineViewShell* >( mpViewShell ); 89*cdf0e10cSrcweir DBG_ASSERT( pOutlineViewShell, "sd::FuPresentationObjects::DoExecute(), does not work without an OutlineViewShell!"); 90*cdf0e10cSrcweir if( !pOutlineViewShell ) 91*cdf0e10cSrcweir return; 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir // ergibt die Selektion ein eindeutiges Praesentationslayout? 94*cdf0e10cSrcweir // wenn nicht, duerfen die Vorlagen nicht bearbeitet werden 95*cdf0e10cSrcweir SfxItemSet aSet(mpDoc->GetItemPool(), SID_STATUS_LAYOUT, SID_STATUS_LAYOUT); 96*cdf0e10cSrcweir pOutlineViewShell->GetStatusBarState( aSet ); 97*cdf0e10cSrcweir String aLayoutName = (((SfxStringItem&)aSet.Get(SID_STATUS_LAYOUT)).GetValue()); 98*cdf0e10cSrcweir DBG_ASSERT(aLayoutName.Len(), "Layout unbestimmt"); 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir sal_Bool bUnique = sal_False; 101*cdf0e10cSrcweir sal_Int16 nDepth, nTmp; 102*cdf0e10cSrcweir OutlineView* pOlView = static_cast<OutlineView*>(pOutlineViewShell->GetView()); 103*cdf0e10cSrcweir OutlinerView* pOutlinerView = pOlView->GetViewByWindow( (Window*) mpWindow ); 104*cdf0e10cSrcweir ::Outliner* pOutl = pOutlinerView->GetOutliner(); 105*cdf0e10cSrcweir List* pList = pOutlinerView->CreateSelectionList(); 106*cdf0e10cSrcweir Paragraph* pPara = (Paragraph*)pList->First(); 107*cdf0e10cSrcweir nDepth = pOutl->GetDepth((sal_uInt16)pOutl->GetAbsPos( pPara ) ); 108*cdf0e10cSrcweir bool bPage = pOutl->HasParaFlag( pPara, PARAFLAG_ISPAGE ); 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir while( pPara ) 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir nTmp = pOutl->GetDepth((sal_uInt16) pOutl->GetAbsPos( pPara ) ); 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir if( nDepth != nTmp ) 115*cdf0e10cSrcweir { 116*cdf0e10cSrcweir bUnique = sal_False; 117*cdf0e10cSrcweir break; 118*cdf0e10cSrcweir } 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir if( pOutl->HasParaFlag( pPara, PARAFLAG_ISPAGE ) != bPage ) 121*cdf0e10cSrcweir { 122*cdf0e10cSrcweir bUnique = sal_False; 123*cdf0e10cSrcweir break; 124*cdf0e10cSrcweir } 125*cdf0e10cSrcweir bUnique = sal_True; 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir pPara = (Paragraph*) pList->Next(); 128*cdf0e10cSrcweir } 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir if( bUnique ) 131*cdf0e10cSrcweir { 132*cdf0e10cSrcweir String aStyleName = aLayoutName; 133*cdf0e10cSrcweir aStyleName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( SD_LT_SEPARATOR ) ); 134*cdf0e10cSrcweir sal_uInt16 nDlgId = TAB_PRES_LAYOUT_TEMPLATE; 135*cdf0e10cSrcweir PresentationObjects ePO; 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir if( bPage ) 138*cdf0e10cSrcweir { 139*cdf0e10cSrcweir ePO = PO_TITLE; 140*cdf0e10cSrcweir String aStr(SdResId( STR_LAYOUT_TITLE )); 141*cdf0e10cSrcweir aStyleName.Append( aStr ); 142*cdf0e10cSrcweir } 143*cdf0e10cSrcweir else 144*cdf0e10cSrcweir { 145*cdf0e10cSrcweir ePO = (PresentationObjects) ( PO_OUTLINE_1 + nDepth - 1 ); 146*cdf0e10cSrcweir String aStr(SdResId( STR_LAYOUT_OUTLINE )); 147*cdf0e10cSrcweir aStyleName.Append( aStr ); 148*cdf0e10cSrcweir aStyleName.Append( sal_Unicode(' ') ); 149*cdf0e10cSrcweir aStyleName.Append( UniString::CreateFromInt32( nDepth ) ); 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir SfxStyleSheetBasePool* pStyleSheetPool = mpDocSh->GetStyleSheetPool(); 153*cdf0e10cSrcweir SfxStyleSheetBase* pStyleSheet = pStyleSheetPool->Find( aStyleName, SD_STYLE_FAMILY_MASTERPAGE ); 154*cdf0e10cSrcweir DBG_ASSERT(pStyleSheet, "StyleSheet nicht gefunden"); 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir if( pStyleSheet ) 157*cdf0e10cSrcweir { 158*cdf0e10cSrcweir SfxStyleSheetBase& rStyleSheet = *pStyleSheet; 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); 161*cdf0e10cSrcweir SfxAbstractTabDialog* pDlg = pFact ? pFact->CreateSdPresLayoutTemplateDlg( mpDocSh, NULL, SdResId( nDlgId ), rStyleSheet, ePO, pStyleSheetPool ) : 0; 162*cdf0e10cSrcweir if( pDlg && (pDlg->Execute() == RET_OK) ) 163*cdf0e10cSrcweir { 164*cdf0e10cSrcweir const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); 165*cdf0e10cSrcweir // Undo-Action 166*cdf0e10cSrcweir StyleSheetUndoAction* pAction = new StyleSheetUndoAction 167*cdf0e10cSrcweir (mpDoc, (SfxStyleSheet*)pStyleSheet, 168*cdf0e10cSrcweir pOutSet); 169*cdf0e10cSrcweir mpDocSh->GetUndoManager()->AddUndoAction(pAction); 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir pStyleSheet->GetItemSet().Put( *pOutSet ); 172*cdf0e10cSrcweir ( (SfxStyleSheet*) pStyleSheet )->Broadcast( SfxSimpleHint( SFX_HINT_DATACHANGED ) ); 173*cdf0e10cSrcweir } 174*cdf0e10cSrcweir delete( pDlg ); 175*cdf0e10cSrcweir } 176*cdf0e10cSrcweir } 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir } // end of namespace sd 180