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 10*5b190011SAndrew Rist * 11*5b190011SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*5b190011SAndrew Rist * 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. 19*5b190011SAndrew Rist * 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 28cdf0e10cSrcweir #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> 29cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 30cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp> 31cdf0e10cSrcweir 32cdf0e10cSrcweir #include "futempl.hxx" 33cdf0e10cSrcweir 34cdf0e10cSrcweir #include <editeng/editdata.hxx> 35cdf0e10cSrcweir #include <editeng/bulitem.hxx> 36cdf0e10cSrcweir #include <svx/svxids.hrc> // fuer SID_OBJECT_SELECT 37cdf0e10cSrcweir #include <sfx2/bindings.hxx> 38cdf0e10cSrcweir #include <svl/aeitem.hxx> 39cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 40cdf0e10cSrcweir #include <vcl/msgbox.hxx> 41cdf0e10cSrcweir #include <editeng/eeitem.hxx> 42cdf0e10cSrcweir #include <sfx2/request.hxx> 43cdf0e10cSrcweir #include <editeng/numitem.hxx> 44cdf0e10cSrcweir #include <editeng/editeng.hxx> 45cdf0e10cSrcweir #include <editeng/lrspitem.hxx> 46cdf0e10cSrcweir #include <svx/svdopage.hxx> 47cdf0e10cSrcweir #include <svx/svditer.hxx> 48cdf0e10cSrcweir #include <svx/sdr/properties/properties.hxx> 49cdf0e10cSrcweir 50cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 51cdf0e10cSrcweir #include <svx/xlndsit.hxx> 52cdf0e10cSrcweir #include <svx/xlnstit.hxx> 53cdf0e10cSrcweir #include <svx/xlnedit.hxx> 54cdf0e10cSrcweir #include "app.hrc" 55cdf0e10cSrcweir #include "stlsheet.hxx" 56cdf0e10cSrcweir #include "sdpage.hxx" 57cdf0e10cSrcweir #include "stlpool.hxx" 58cdf0e10cSrcweir #include "app.hxx" 59cdf0e10cSrcweir #include "View.hxx" 60cdf0e10cSrcweir #ifndef SD_WINDOW_SHELL_HXX 61cdf0e10cSrcweir #include "Window.hxx" 62cdf0e10cSrcweir #endif 63cdf0e10cSrcweir #include "drawview.hxx" 64cdf0e10cSrcweir #include "drawdoc.hxx" 65cdf0e10cSrcweir #include "DrawDocShell.hxx" 66cdf0e10cSrcweir #include "DrawViewShell.hxx" 67cdf0e10cSrcweir #include "ViewShell.hxx" 68cdf0e10cSrcweir #include "res_bmp.hrc" 69cdf0e10cSrcweir #include "glob.hrc" 70cdf0e10cSrcweir #include "prlayout.hxx" // enum PresentationObjects 71cdf0e10cSrcweir #include "prltempl.hrc" // TAB_PRES_LAYOUT_TEMPLATE_x 72cdf0e10cSrcweir #include <svx/tabarea.hxx> 73cdf0e10cSrcweir #include "sdresid.hxx" 74cdf0e10cSrcweir #include "OutlineViewShell.hxx" 75cdf0e10cSrcweir #include "strings.hrc" 76cdf0e10cSrcweir #include "helpids.h" 77cdf0e10cSrcweir #include "sdabstdlg.hxx" 78cdf0e10cSrcweir 79cdf0e10cSrcweir using rtl::OUString; 80cdf0e10cSrcweir using namespace com::sun::star::uno; 81cdf0e10cSrcweir using namespace com::sun::star::container; 82cdf0e10cSrcweir using namespace com::sun::star::beans; 83cdf0e10cSrcweir using namespace com::sun::star::style; 84cdf0e10cSrcweir 85cdf0e10cSrcweir namespace sd 86cdf0e10cSrcweir { 87cdf0e10cSrcweir 88cdf0e10cSrcweir TYPEINIT1( FuTemplate, FuPoor ); 89cdf0e10cSrcweir 90cdf0e10cSrcweir /************************************************************************* 91cdf0e10cSrcweir |* 92cdf0e10cSrcweir |* Konstruktor 93cdf0e10cSrcweir |* 94cdf0e10cSrcweir \************************************************************************/ 95cdf0e10cSrcweir 96cdf0e10cSrcweir FuTemplate::FuTemplate ( 97cdf0e10cSrcweir ViewShell* pViewSh, 98cdf0e10cSrcweir ::sd::Window* pWin, 99cdf0e10cSrcweir ::sd::View* pView, 100cdf0e10cSrcweir SdDrawDocument* pDoc, 101cdf0e10cSrcweir SfxRequest& rReq ) 102cdf0e10cSrcweir : FuPoor( pViewSh, pWin, pView, pDoc, rReq ) 103cdf0e10cSrcweir { 104cdf0e10cSrcweir } 105cdf0e10cSrcweir 106cdf0e10cSrcweir FunctionReference FuTemplate::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq ) 107cdf0e10cSrcweir { 108cdf0e10cSrcweir FunctionReference xFunc( new FuTemplate( pViewSh, pWin, pView, pDoc, rReq ) ); 109cdf0e10cSrcweir xFunc->DoExecute(rReq); 110cdf0e10cSrcweir return xFunc; 111cdf0e10cSrcweir } 112cdf0e10cSrcweir 113cdf0e10cSrcweir void FuTemplate::DoExecute( SfxRequest& rReq ) 114cdf0e10cSrcweir { 115cdf0e10cSrcweir const SfxItemSet* pArgs = rReq.GetArgs(); 116cdf0e10cSrcweir sal_uInt16 nSId = rReq.GetSlot(); 117cdf0e10cSrcweir 118cdf0e10cSrcweir // StyleSheet-Parameter holen 119cdf0e10cSrcweir SfxStyleSheetBasePool* pSSPool = mpDoc->GetDocSh()->GetStyleSheetPool(); 120cdf0e10cSrcweir SfxStyleSheetBase* pStyleSheet = NULL; 121cdf0e10cSrcweir 122cdf0e10cSrcweir const SfxPoolItem* pItem; 123cdf0e10cSrcweir sal_uInt16 nFamily = USHRT_MAX; 124cdf0e10cSrcweir if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_FAMILY, 125cdf0e10cSrcweir sal_False, &pItem )) 126cdf0e10cSrcweir { 127cdf0e10cSrcweir nFamily = ( (const SfxUInt16Item &) pArgs->Get( SID_STYLE_FAMILY ) ).GetValue(); 128cdf0e10cSrcweir } 129cdf0e10cSrcweir else 130cdf0e10cSrcweir if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_FAMILYNAME, 131cdf0e10cSrcweir sal_False, &pItem )) 132cdf0e10cSrcweir { 133cdf0e10cSrcweir String sFamily = ( (const SfxStringItem &) pArgs->Get( SID_STYLE_FAMILYNAME ) ).GetValue(); 134cdf0e10cSrcweir if (sFamily.CompareToAscii("graphics") == COMPARE_EQUAL) 135cdf0e10cSrcweir nFamily = SD_STYLE_FAMILY_GRAPHICS; 136cdf0e10cSrcweir else 137cdf0e10cSrcweir nFamily = SD_STYLE_FAMILY_PSEUDO; 138cdf0e10cSrcweir } 139cdf0e10cSrcweir 140cdf0e10cSrcweir String aStyleName; 141cdf0e10cSrcweir sal_uInt16 nRetMask = 0xffff; 142cdf0e10cSrcweir 143cdf0e10cSrcweir switch( nSId ) 144cdf0e10cSrcweir { 145cdf0e10cSrcweir case SID_STYLE_APPLY: 146cdf0e10cSrcweir case SID_STYLE_EDIT: 147cdf0e10cSrcweir case SID_STYLE_DELETE: 148cdf0e10cSrcweir case SID_STYLE_FAMILY: 149cdf0e10cSrcweir case SID_STYLE_NEW_BY_EXAMPLE: 150cdf0e10cSrcweir { 151cdf0e10cSrcweir SFX_REQUEST_ARG( rReq, pNameItem, SfxStringItem, SID_APPLY_STYLE, sal_False ); 152cdf0e10cSrcweir SFX_REQUEST_ARG( rReq, pFamilyItem, SfxStringItem, SID_STYLE_FAMILYNAME, sal_False ); 153cdf0e10cSrcweir if ( pFamilyItem && pNameItem ) 154cdf0e10cSrcweir { 155cdf0e10cSrcweir try 156cdf0e10cSrcweir { 157cdf0e10cSrcweir Reference< XStyleFamiliesSupplier > xModel(mpDoc->GetDocSh()->GetModel(), UNO_QUERY_THROW ); 158cdf0e10cSrcweir Reference< XNameAccess > xCont( xModel->getStyleFamilies() ); 159cdf0e10cSrcweir Reference< XNameAccess > xStyles( xCont->getByName(pFamilyItem->GetValue()), UNO_QUERY_THROW ); 160cdf0e10cSrcweir Reference< XPropertySet > xInfo( xStyles->getByName( pNameItem->GetValue() ), UNO_QUERY_THROW ); 161cdf0e10cSrcweir 162cdf0e10cSrcweir OUString aUIName; 163cdf0e10cSrcweir xInfo->getPropertyValue( ::rtl::OUString::createFromAscii("DisplayName") ) >>= aUIName; 164cdf0e10cSrcweir if ( aUIName.getLength() ) 165cdf0e10cSrcweir rReq.AppendItem( SfxStringItem( nSId, aUIName ) ); 166cdf0e10cSrcweir } 167cdf0e10cSrcweir catch( Exception& ) 168cdf0e10cSrcweir { 169cdf0e10cSrcweir } 170cdf0e10cSrcweir } 171cdf0e10cSrcweir 172cdf0e10cSrcweir if (pArgs->GetItemState(nSId) == SFX_ITEM_SET) 173cdf0e10cSrcweir aStyleName = ( ( (const SfxStringItem &) pArgs->Get( nSId ) ).GetValue() ); 174cdf0e10cSrcweir } 175cdf0e10cSrcweir } 176cdf0e10cSrcweir 177cdf0e10cSrcweir switch( nSId ) 178cdf0e10cSrcweir { 179cdf0e10cSrcweir case SID_STYLE_NEW: 180cdf0e10cSrcweir { 181cdf0e10cSrcweir SfxStyleSheetBase *p = pSSPool->Find(aStyleName, (SfxStyleFamily) nFamily, SFXSTYLEBIT_ALL ); 182cdf0e10cSrcweir if(p) 183cdf0e10cSrcweir { 184cdf0e10cSrcweir pSSPool->Remove(p); 185cdf0e10cSrcweir p = 0; 186cdf0e10cSrcweir } 187cdf0e10cSrcweir pStyleSheet = &pSSPool->Make( aStyleName, (SfxStyleFamily) nFamily, SFXSTYLEBIT_USERDEF ); 188cdf0e10cSrcweir 189cdf0e10cSrcweir if (pArgs->GetItemState(SID_STYLE_REFERENCE) == SFX_ITEM_ON) 190cdf0e10cSrcweir { 191cdf0e10cSrcweir String aParentName(((const SfxStringItem&) pArgs->Get(SID_STYLE_REFERENCE)).GetValue()); 192cdf0e10cSrcweir pStyleSheet->SetParent(aParentName); 193cdf0e10cSrcweir } 194cdf0e10cSrcweir else 195cdf0e10cSrcweir { 196cdf0e10cSrcweir pStyleSheet->SetParent(String(SdResId(STR_STANDARD_STYLESHEET_NAME))); 197cdf0e10cSrcweir } 198cdf0e10cSrcweir } 199cdf0e10cSrcweir break; 200cdf0e10cSrcweir 201cdf0e10cSrcweir case SID_STYLE_NEW_BY_EXAMPLE: 202cdf0e10cSrcweir { 203cdf0e10cSrcweir // Z.Z. geht immer noch der Dialog auf, um den Namen 204cdf0e10cSrcweir // der Vorlage einzugeben. 205cdf0e10cSrcweir if( mpView->AreObjectsMarked() || sal_True ) 206cdf0e10cSrcweir { 207cdf0e10cSrcweir SfxStyleSheetBase *p = pSSPool->Find(aStyleName, (SfxStyleFamily) nFamily, SFXSTYLEBIT_ALL ); 208cdf0e10cSrcweir if(p) 209cdf0e10cSrcweir { 210cdf0e10cSrcweir pSSPool->Remove(p); 211cdf0e10cSrcweir p = 0; 212cdf0e10cSrcweir } 213cdf0e10cSrcweir pStyleSheet = &pSSPool->Make( aStyleName, (SfxStyleFamily) nFamily, SFXSTYLEBIT_USERDEF ); 214cdf0e10cSrcweir pStyleSheet->SetParent(String(SdResId(STR_STANDARD_STYLESHEET_NAME))); 215cdf0e10cSrcweir } 216cdf0e10cSrcweir } 217cdf0e10cSrcweir break; 218cdf0e10cSrcweir 219cdf0e10cSrcweir case SID_STYLE_EDIT: 220cdf0e10cSrcweir pStyleSheet = pSSPool->Find( aStyleName, (SfxStyleFamily) nFamily); 221cdf0e10cSrcweir break; 222cdf0e10cSrcweir 223cdf0e10cSrcweir case SID_STYLE_DELETE: 224cdf0e10cSrcweir pStyleSheet = pSSPool->Find( aStyleName, (SfxStyleFamily) nFamily); 225cdf0e10cSrcweir if( pStyleSheet ) 226cdf0e10cSrcweir { 227cdf0e10cSrcweir pSSPool->Remove( pStyleSheet ); 228cdf0e10cSrcweir nRetMask = sal_True; 229cdf0e10cSrcweir mpDoc->SetChanged(sal_True); 230cdf0e10cSrcweir } 231cdf0e10cSrcweir else 232cdf0e10cSrcweir { 233cdf0e10cSrcweir nRetMask = sal_False; 234cdf0e10cSrcweir } 235cdf0e10cSrcweir break; 236cdf0e10cSrcweir 237cdf0e10cSrcweir case SID_STYLE_APPLY: 238cdf0e10cSrcweir // Anwenden der Vorlage auf das Dokument 239cdf0e10cSrcweir pStyleSheet = pSSPool->Find( aStyleName, (SfxStyleFamily) nFamily); 240cdf0e10cSrcweir 241cdf0e10cSrcweir // do not set presentation styles, they will be set implicit 242cdf0e10cSrcweir if ( pStyleSheet && pStyleSheet->GetFamily() != SD_STYLE_FAMILY_PSEUDO ) 243cdf0e10cSrcweir { 244cdf0e10cSrcweir SfxStyleSheet* pOldStyleSheet = mpView->GetStyleSheet(); 245cdf0e10cSrcweir String aStr; 246cdf0e10cSrcweir 247cdf0e10cSrcweir if( // if the object had no style sheet, allow all 248cdf0e10cSrcweir !pOldStyleSheet || 249cdf0e10cSrcweir 250cdf0e10cSrcweir // allow if old and new style sheet has same family 251cdf0e10cSrcweir pStyleSheet->GetFamily() == pOldStyleSheet->GetFamily() || 252cdf0e10cSrcweir 253cdf0e10cSrcweir // allow if old was background objects and new is graphics 254cdf0e10cSrcweir pStyleSheet->GetFamily() == (SD_STYLE_FAMILY_GRAPHICS && pOldStyleSheet->GetHelpId( aStr ) == HID_PSEUDOSHEET_BACKGROUNDOBJECTS) || 255cdf0e10cSrcweir 256cdf0e10cSrcweir // allow if old was presentation and we are a drawing document 257cdf0e10cSrcweir (pOldStyleSheet->GetFamily() == SD_STYLE_FAMILY_MASTERPAGE && mpDoc->GetDocumentType() == DOCUMENT_TYPE_DRAW) ) 258cdf0e10cSrcweir { 259cdf0e10cSrcweir mpView->SetStyleSheet( (SfxStyleSheet*) pStyleSheet); 260cdf0e10cSrcweir mpDoc->SetChanged(sal_True); 261cdf0e10cSrcweir mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_STYLE_FAMILY2 ); 262cdf0e10cSrcweir } 263cdf0e10cSrcweir } 264cdf0e10cSrcweir /* #96983# GrabFocus moved to stylist 265cdf0e10cSrcweir pWin->GrabFocus(); 266cdf0e10cSrcweir */ 267cdf0e10cSrcweir break; 268cdf0e10cSrcweir 269cdf0e10cSrcweir case SID_STYLE_WATERCAN: 270cdf0e10cSrcweir { 271cdf0e10cSrcweir if( !SD_MOD()->GetWaterCan() ) 272cdf0e10cSrcweir { 273cdf0e10cSrcweir if( pArgs->GetItemState( nSId ) == SFX_ITEM_SET ) 274cdf0e10cSrcweir { 275cdf0e10cSrcweir aStyleName = ( ( (const SfxStringItem &) pArgs->Get( nSId ) ).GetValue() ); 276cdf0e10cSrcweir SD_MOD()->SetWaterCan( sal_True ); 277cdf0e10cSrcweir pStyleSheet = pSSPool->Find( aStyleName, (SfxStyleFamily) nFamily); 278cdf0e10cSrcweir } 279cdf0e10cSrcweir // keine Praesentationsobjektvorlagen, die werden nur 280cdf0e10cSrcweir // implizit zugewiesen 281cdf0e10cSrcweir if( pStyleSheet && pStyleSheet->GetFamily() != SD_STYLE_FAMILY_PSEUDO ) 282cdf0e10cSrcweir { 283cdf0e10cSrcweir ( (SdStyleSheetPool*) pSSPool )->SetActualStyleSheet( pStyleSheet ); 284cdf0e10cSrcweir 285cdf0e10cSrcweir // Es wird explizit in den Selektionsmodus geschaltet 286cdf0e10cSrcweir mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_OBJECT_SELECT, 287cdf0e10cSrcweir SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD ); 288cdf0e10cSrcweir 289cdf0e10cSrcweir } 290cdf0e10cSrcweir else 291cdf0e10cSrcweir SD_MOD()->SetWaterCan( sal_False ); 292cdf0e10cSrcweir } 293cdf0e10cSrcweir else 294cdf0e10cSrcweir { 295cdf0e10cSrcweir SD_MOD()->SetWaterCan( sal_False ); 296cdf0e10cSrcweir // Werkzeugleiste muss wieder enabled werden 297cdf0e10cSrcweir mpViewShell->Invalidate(); 298cdf0e10cSrcweir } 299cdf0e10cSrcweir } 300cdf0e10cSrcweir break; 301cdf0e10cSrcweir 302cdf0e10cSrcweir default: 303cdf0e10cSrcweir break; 304cdf0e10cSrcweir } 305cdf0e10cSrcweir 306cdf0e10cSrcweir switch( nSId ) 307cdf0e10cSrcweir { 308cdf0e10cSrcweir case SID_STYLE_NEW: 309cdf0e10cSrcweir case SID_STYLE_EDIT: 310cdf0e10cSrcweir { 311cdf0e10cSrcweir PresentationObjects ePO = PO_OUTLINE_1; 312cdf0e10cSrcweir 313cdf0e10cSrcweir if( pStyleSheet ) 314cdf0e10cSrcweir { 315cdf0e10cSrcweir SfxAbstractTabDialog* pStdDlg = NULL; 316cdf0e10cSrcweir SfxAbstractTabDialog* pPresDlg = NULL; 317cdf0e10cSrcweir SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); 318cdf0e10cSrcweir sal_Bool bOldDocInOtherLanguage = sal_False; 319cdf0e10cSrcweir SfxItemSet aOriSet( pStyleSheet->GetItemSet() ); 320cdf0e10cSrcweir 321cdf0e10cSrcweir SfxStyleFamily eFamily = pStyleSheet->GetFamily(); 322cdf0e10cSrcweir 323cdf0e10cSrcweir if (eFamily == SD_STYLE_FAMILY_GRAPHICS) 324cdf0e10cSrcweir { 325cdf0e10cSrcweir pStdDlg = pFact ? pFact->CreateSdTabTemplateDlg( 0, mpDoc->GetDocSh(), *pStyleSheet, mpDoc, mpView ) : 0; 326cdf0e10cSrcweir } 327cdf0e10cSrcweir else if (eFamily == SD_STYLE_FAMILY_PSEUDO) 328cdf0e10cSrcweir { 329cdf0e10cSrcweir String aName(pStyleSheet->GetName()); 330cdf0e10cSrcweir sal_uInt16 nDlgId = 0; 331cdf0e10cSrcweir 332cdf0e10cSrcweir if (aName == String(SdResId(STR_PSEUDOSHEET_TITLE))) 333cdf0e10cSrcweir { 334cdf0e10cSrcweir nDlgId = TAB_PRES_LAYOUT_TEMPLATE; 335cdf0e10cSrcweir ePO = PO_TITLE; 336cdf0e10cSrcweir } 337cdf0e10cSrcweir else if (aName == String(SdResId(STR_PSEUDOSHEET_SUBTITLE))) 338cdf0e10cSrcweir { 339cdf0e10cSrcweir nDlgId = TAB_PRES_LAYOUT_TEMPLATE; 340cdf0e10cSrcweir ePO = PO_SUBTITLE; 341cdf0e10cSrcweir } 342cdf0e10cSrcweir else if (aName == 343cdf0e10cSrcweir String(SdResId(STR_PSEUDOSHEET_BACKGROUND))) 344cdf0e10cSrcweir { 345cdf0e10cSrcweir nDlgId = TAB_PRES_LAYOUT_TEMPLATE_BACKGROUND; 346cdf0e10cSrcweir ePO = PO_BACKGROUND; 347cdf0e10cSrcweir } 348cdf0e10cSrcweir else if (aName == 349cdf0e10cSrcweir String(SdResId(STR_PSEUDOSHEET_BACKGROUNDOBJECTS))) 350cdf0e10cSrcweir { 351cdf0e10cSrcweir nDlgId = TAB_PRES_LAYOUT_TEMPLATE; 352cdf0e10cSrcweir ePO = PO_BACKGROUNDOBJECTS; 353cdf0e10cSrcweir } 354cdf0e10cSrcweir else if (aName == 355cdf0e10cSrcweir String(SdResId(STR_PSEUDOSHEET_NOTES))) 356cdf0e10cSrcweir { 357cdf0e10cSrcweir nDlgId = TAB_PRES_LAYOUT_TEMPLATE; 358cdf0e10cSrcweir ePO = PO_NOTES; 359cdf0e10cSrcweir } 360cdf0e10cSrcweir else if(aName.Search(String(SdResId(STR_PSEUDOSHEET_OUTLINE))) != 361cdf0e10cSrcweir STRING_NOTFOUND) 362cdf0e10cSrcweir { 363cdf0e10cSrcweir nDlgId = TAB_PRES_LAYOUT_TEMPLATE; 364cdf0e10cSrcweir 365cdf0e10cSrcweir String aOutlineStr((SdResId(STR_PSEUDOSHEET_OUTLINE))); 366cdf0e10cSrcweir // die Nummer ermitteln; ein Leerzeichen zwischen 367cdf0e10cSrcweir // Name und Nummer beachten 368cdf0e10cSrcweir String aNumStr(aName.Copy(aOutlineStr.Len() + 1)); 369cdf0e10cSrcweir sal_uInt16 nLevel = (sal_uInt16)aNumStr.ToInt32(); 370cdf0e10cSrcweir switch (nLevel) 371cdf0e10cSrcweir { 372cdf0e10cSrcweir case 1: ePO = PO_OUTLINE_1; break; 373cdf0e10cSrcweir case 2: ePO = PO_OUTLINE_2; break; 374cdf0e10cSrcweir case 3: ePO = PO_OUTLINE_3; break; 375cdf0e10cSrcweir case 4: ePO = PO_OUTLINE_4; break; 376cdf0e10cSrcweir case 5: ePO = PO_OUTLINE_5; break; 377cdf0e10cSrcweir case 6: ePO = PO_OUTLINE_6; break; 378cdf0e10cSrcweir case 7: ePO = PO_OUTLINE_7; break; 379cdf0e10cSrcweir case 8: ePO = PO_OUTLINE_8; break; 380cdf0e10cSrcweir case 9: ePO = PO_OUTLINE_9; break; 381cdf0e10cSrcweir } 382cdf0e10cSrcweir } 383cdf0e10cSrcweir else 384cdf0e10cSrcweir { 385cdf0e10cSrcweir DBG_ERROR("Vorlage aus aelterer anderssprachiger Version"); 386cdf0e10cSrcweir bOldDocInOtherLanguage = sal_True; 387cdf0e10cSrcweir } 388cdf0e10cSrcweir 389cdf0e10cSrcweir if( !bOldDocInOtherLanguage ) 390cdf0e10cSrcweir { 391cdf0e10cSrcweir pPresDlg = pFact ? pFact->CreateSdPresLayoutTemplateDlg( mpDocSh, NULL, SdResId(nDlgId), *pStyleSheet, ePO, pSSPool ) : 0; 392cdf0e10cSrcweir } 393cdf0e10cSrcweir } 394cdf0e10cSrcweir else if (eFamily == SD_STYLE_FAMILY_CELL) 395cdf0e10cSrcweir { 396cdf0e10cSrcweir } 397cdf0e10cSrcweir 398cdf0e10cSrcweir sal_uInt16 nResult = RET_CANCEL; 399cdf0e10cSrcweir const SfxItemSet* pOutSet = NULL; 400cdf0e10cSrcweir if (pStdDlg) 401cdf0e10cSrcweir { 402cdf0e10cSrcweir nResult = pStdDlg->Execute(); 403cdf0e10cSrcweir pOutSet = pStdDlg->GetOutputItemSet(); 404cdf0e10cSrcweir } 405cdf0e10cSrcweir else if( pPresDlg ) 406cdf0e10cSrcweir { 407cdf0e10cSrcweir nResult = pPresDlg->Execute(); 408cdf0e10cSrcweir pOutSet = pPresDlg->GetOutputItemSet(); 409cdf0e10cSrcweir } 410cdf0e10cSrcweir 411cdf0e10cSrcweir switch( nResult ) 412cdf0e10cSrcweir { 413cdf0e10cSrcweir case RET_OK: 414cdf0e10cSrcweir { 415cdf0e10cSrcweir nRetMask = pStyleSheet->GetMask(); 416cdf0e10cSrcweir 417cdf0e10cSrcweir if (eFamily == SD_STYLE_FAMILY_PSEUDO) 418cdf0e10cSrcweir { 419cdf0e10cSrcweir SfxItemSet aTempSet(*pOutSet); 420cdf0e10cSrcweir ((SdStyleSheet*)pStyleSheet)->AdjustToFontHeight(aTempSet); 421cdf0e10cSrcweir 422cdf0e10cSrcweir // Sonderbehandlung: die INVALIDS auf NULL-Pointer 423cdf0e10cSrcweir // zurueckgesetzen (sonst landen INVALIDs oder 424cdf0e10cSrcweir // Pointer auf die DefaultItems in der Vorlage; 425cdf0e10cSrcweir // beides wuerde die Attribut-Vererbung unterbinden) 426cdf0e10cSrcweir aTempSet.ClearInvalidItems(); 427cdf0e10cSrcweir 428cdf0e10cSrcweir // EE_PARA_NUMBULLET item is only valid in first outline template 429cdf0e10cSrcweir if( (ePO >= PO_OUTLINE_2) && (ePO <= PO_OUTLINE_9) ) 430cdf0e10cSrcweir { 431cdf0e10cSrcweir if (aTempSet.GetItemState(EE_PARA_NUMBULLET) == SFX_ITEM_SET) 432cdf0e10cSrcweir { 433cdf0e10cSrcweir SvxNumRule aRule(*((SvxNumBulletItem*)aTempSet.GetItem(EE_PARA_NUMBULLET))->GetNumRule()); 434cdf0e10cSrcweir 435cdf0e10cSrcweir String sStyleName((SdResId(STR_PSEUDOSHEET_OUTLINE))); 436cdf0e10cSrcweir sStyleName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " 1" ) ); 437cdf0e10cSrcweir SfxStyleSheetBase* pFirstStyleSheet = pSSPool->Find( sStyleName, SD_STYLE_FAMILY_PSEUDO); 438cdf0e10cSrcweir 439cdf0e10cSrcweir if(pFirstStyleSheet) 440cdf0e10cSrcweir { 441cdf0e10cSrcweir pFirstStyleSheet->GetItemSet().Put( SvxNumBulletItem( aRule, EE_PARA_NUMBULLET )); 442cdf0e10cSrcweir SdStyleSheet* pRealSheet = ((SdStyleSheet*)pFirstStyleSheet)->GetRealStyleSheet(); 443cdf0e10cSrcweir pRealSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED)); 444cdf0e10cSrcweir } 445cdf0e10cSrcweir 446cdf0e10cSrcweir aTempSet.ClearItem( EE_PARA_NUMBULLET ); 447cdf0e10cSrcweir } 448cdf0e10cSrcweir } 449cdf0e10cSrcweir 450cdf0e10cSrcweir String sStyleName((SdResId(STR_PSEUDOSHEET_OUTLINE))); 451cdf0e10cSrcweir sStyleName.Append( sal_Unicode( ' ' )); 452cdf0e10cSrcweir 453cdf0e10cSrcweir pStyleSheet->GetItemSet().Put(aTempSet); 454cdf0e10cSrcweir 455cdf0e10cSrcweir SdStyleSheet* pRealSheet =((SdStyleSheet*)pStyleSheet)->GetRealStyleSheet(); 456cdf0e10cSrcweir pRealSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED)); 457cdf0e10cSrcweir 458cdf0e10cSrcweir if( (ePO >= PO_OUTLINE_1) && (ePO <= PO_OUTLINE_8) ) 459cdf0e10cSrcweir { 460cdf0e10cSrcweir for( sal_uInt16 n = (sal_uInt16)(ePO - PO_OUTLINE_1 + 2); n < 10; n++ ) 461cdf0e10cSrcweir { 462cdf0e10cSrcweir String aName( sStyleName ); 463cdf0e10cSrcweir aName.Append( String::CreateFromInt32( (sal_Int32) n )); 464cdf0e10cSrcweir 465cdf0e10cSrcweir SfxStyleSheetBase* pSheet = pSSPool->Find( aName, SD_STYLE_FAMILY_PSEUDO); 466cdf0e10cSrcweir 467cdf0e10cSrcweir if(pSheet) 468cdf0e10cSrcweir { 469cdf0e10cSrcweir SdStyleSheet* pRealStyleSheet = ((SdStyleSheet*)pSheet)->GetRealStyleSheet(); 470cdf0e10cSrcweir pRealStyleSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED)); 471cdf0e10cSrcweir } 472cdf0e10cSrcweir } 473cdf0e10cSrcweir } 474cdf0e10cSrcweir } 475cdf0e10cSrcweir 476cdf0e10cSrcweir SfxItemSet& rAttr = pStyleSheet->GetItemSet(); 477cdf0e10cSrcweir 478cdf0e10cSrcweir sdr::properties::CleanupFillProperties( rAttr ); 479cdf0e10cSrcweir 480cdf0e10cSrcweir // check for unique names of named items for xml 481cdf0e10cSrcweir if( rAttr.GetItemState( XATTR_FILLBITMAP ) == SFX_ITEM_SET ) 482cdf0e10cSrcweir { 483cdf0e10cSrcweir const SfxPoolItem* pOldItem = rAttr.GetItem( XATTR_FILLBITMAP ); 484cdf0e10cSrcweir SfxPoolItem* pNewItem = ((XFillBitmapItem*)pOldItem)->checkForUniqueItem( mpDoc ); 485cdf0e10cSrcweir if( pOldItem != pNewItem ) 486cdf0e10cSrcweir { 487cdf0e10cSrcweir rAttr.Put( *pNewItem ); 488cdf0e10cSrcweir delete pNewItem; 489cdf0e10cSrcweir } 490cdf0e10cSrcweir } 491cdf0e10cSrcweir if( rAttr.GetItemState( XATTR_LINEDASH ) == SFX_ITEM_SET ) 492cdf0e10cSrcweir { 493cdf0e10cSrcweir const SfxPoolItem* pOldItem = rAttr.GetItem( XATTR_LINEDASH ); 494cdf0e10cSrcweir SfxPoolItem* pNewItem = ((XLineDashItem*)pOldItem)->checkForUniqueItem( mpDoc ); 495cdf0e10cSrcweir if( pOldItem != pNewItem ) 496cdf0e10cSrcweir { 497cdf0e10cSrcweir rAttr.Put( *pNewItem ); 498cdf0e10cSrcweir delete pNewItem; 499cdf0e10cSrcweir } 500cdf0e10cSrcweir } 501cdf0e10cSrcweir if( rAttr.GetItemState( XATTR_LINESTART ) == SFX_ITEM_SET ) 502cdf0e10cSrcweir { 503cdf0e10cSrcweir const SfxPoolItem* pOldItem = rAttr.GetItem( XATTR_LINESTART ); 504cdf0e10cSrcweir SfxPoolItem* pNewItem = ((XLineStartItem*)pOldItem)->checkForUniqueItem( mpDoc ); 505cdf0e10cSrcweir if( pOldItem != pNewItem ) 506cdf0e10cSrcweir { 507cdf0e10cSrcweir rAttr.Put( *pNewItem ); 508cdf0e10cSrcweir delete pNewItem; 509cdf0e10cSrcweir } 510cdf0e10cSrcweir } 511cdf0e10cSrcweir if( rAttr.GetItemState( XATTR_LINEEND ) == SFX_ITEM_SET ) 512cdf0e10cSrcweir { 513cdf0e10cSrcweir const SfxPoolItem* pOldItem = rAttr.GetItem( XATTR_LINEEND ); 514cdf0e10cSrcweir SfxPoolItem* pNewItem = ((XLineEndItem*)pOldItem)->checkForUniqueItem( mpDoc ); 515cdf0e10cSrcweir if( pOldItem != pNewItem ) 516cdf0e10cSrcweir { 517cdf0e10cSrcweir rAttr.Put( *pNewItem ); 518cdf0e10cSrcweir delete pNewItem; 519cdf0e10cSrcweir } 520cdf0e10cSrcweir } 521cdf0e10cSrcweir if( rAttr.GetItemState( XATTR_FILLGRADIENT ) == SFX_ITEM_SET ) 522cdf0e10cSrcweir { 523cdf0e10cSrcweir const SfxPoolItem* pOldItem = rAttr.GetItem( XATTR_FILLGRADIENT ); 524cdf0e10cSrcweir SfxPoolItem* pNewItem = ((XFillGradientItem*)pOldItem)->checkForUniqueItem( mpDoc ); 525cdf0e10cSrcweir if( pOldItem != pNewItem ) 526cdf0e10cSrcweir { 527cdf0e10cSrcweir rAttr.Put( *pNewItem ); 528cdf0e10cSrcweir delete pNewItem; 529cdf0e10cSrcweir } 530cdf0e10cSrcweir } 531cdf0e10cSrcweir if( rAttr.GetItemState( XATTR_FILLFLOATTRANSPARENCE ) == SFX_ITEM_SET ) 532cdf0e10cSrcweir { 533cdf0e10cSrcweir const SfxPoolItem* pOldItem = rAttr.GetItem( XATTR_FILLFLOATTRANSPARENCE ); 534cdf0e10cSrcweir SfxPoolItem* pNewItem = ((XFillFloatTransparenceItem*)pOldItem)->checkForUniqueItem( mpDoc ); 535cdf0e10cSrcweir if( pOldItem != pNewItem ) 536cdf0e10cSrcweir { 537cdf0e10cSrcweir rAttr.Put( *pNewItem ); 538cdf0e10cSrcweir delete pNewItem; 539cdf0e10cSrcweir } 540cdf0e10cSrcweir } 541cdf0e10cSrcweir if( rAttr.GetItemState( XATTR_FILLHATCH ) == SFX_ITEM_SET ) 542cdf0e10cSrcweir { 543cdf0e10cSrcweir const SfxPoolItem* pOldItem = rAttr.GetItem( XATTR_FILLHATCH ); 544cdf0e10cSrcweir SfxPoolItem* pNewItem = ((XFillHatchItem*)pOldItem)->checkForUniqueItem( mpDoc ); 545cdf0e10cSrcweir if( pOldItem != pNewItem ) 546cdf0e10cSrcweir { 547cdf0e10cSrcweir rAttr.Put( *pNewItem ); 548cdf0e10cSrcweir delete pNewItem; 549cdf0e10cSrcweir } 550cdf0e10cSrcweir } 551cdf0e10cSrcweir 552cdf0e10cSrcweir ( (SfxStyleSheet*) pStyleSheet )->Broadcast( SfxSimpleHint( SFX_HINT_DATACHANGED ) ); 553cdf0e10cSrcweir 554cdf0e10cSrcweir DrawViewShell* pDrawViewShell = dynamic_cast< DrawViewShell* >( mpViewShell ); 555cdf0e10cSrcweir if( pDrawViewShell ) 556cdf0e10cSrcweir { 557cdf0e10cSrcweir PageKind ePageKind = pDrawViewShell->GetPageKind(); 558cdf0e10cSrcweir if( ePageKind == PK_NOTES || ePageKind == PK_HANDOUT ) 559cdf0e10cSrcweir { 560cdf0e10cSrcweir SdPage* pPage = mpViewShell->GetActualPage(); 561cdf0e10cSrcweir 562cdf0e10cSrcweir if(pDrawViewShell->GetEditMode() == EM_MASTERPAGE) 563cdf0e10cSrcweir { 564cdf0e10cSrcweir pPage = static_cast<SdPage*>((&(pPage->TRG_GetMasterPage()))); 565cdf0e10cSrcweir } 566cdf0e10cSrcweir 567cdf0e10cSrcweir if( pPage ) 568cdf0e10cSrcweir { 569cdf0e10cSrcweir SdrObjListIter aIter( *pPage ); 570cdf0e10cSrcweir while( aIter.IsMore() ) 571cdf0e10cSrcweir { 572cdf0e10cSrcweir SdrObject* pObj = aIter.Next(); 573cdf0e10cSrcweir if( pObj->ISA(SdrPageObj) ) 574cdf0e10cSrcweir { 575cdf0e10cSrcweir // repaint only 576cdf0e10cSrcweir pObj->ActionChanged(); 577cdf0e10cSrcweir // pObj->SendRepaintBroadcast(); 578cdf0e10cSrcweir } 579cdf0e10cSrcweir } 580cdf0e10cSrcweir } 581cdf0e10cSrcweir } 582cdf0e10cSrcweir } 583cdf0e10cSrcweir 584cdf0e10cSrcweir if( mpDoc->GetOnlineSpell() ) 585cdf0e10cSrcweir { 586cdf0e10cSrcweir const SfxPoolItem* pTempItem; 587cdf0e10cSrcweir if( SFX_ITEM_SET == rAttr.GetItemState(EE_CHAR_LANGUAGE, sal_False, &pTempItem ) || 588cdf0e10cSrcweir SFX_ITEM_SET == rAttr.GetItemState(EE_CHAR_LANGUAGE_CJK, sal_False, &pTempItem ) || 589cdf0e10cSrcweir SFX_ITEM_SET == rAttr.GetItemState(EE_CHAR_LANGUAGE_CTL, sal_False, &pTempItem ) ) 590cdf0e10cSrcweir { 591cdf0e10cSrcweir mpDoc->StopOnlineSpelling(); 592cdf0e10cSrcweir mpDoc->StartOnlineSpelling(); 593cdf0e10cSrcweir } 594cdf0e10cSrcweir } 595cdf0e10cSrcweir 596cdf0e10cSrcweir mpDoc->SetChanged(sal_True); 597cdf0e10cSrcweir } 598cdf0e10cSrcweir break; 599cdf0e10cSrcweir 600cdf0e10cSrcweir default: 601cdf0e10cSrcweir { 602cdf0e10cSrcweir if( nSId == SID_STYLE_NEW ) 603cdf0e10cSrcweir pSSPool->Remove( pStyleSheet ); 604cdf0e10cSrcweir delete pStdDlg; 605cdf0e10cSrcweir delete pPresDlg; 606cdf0e10cSrcweir } 607cdf0e10cSrcweir return; // Abbruch 608cdf0e10cSrcweir } 609cdf0e10cSrcweir delete pStdDlg; 610cdf0e10cSrcweir delete pPresDlg; 611cdf0e10cSrcweir } 612cdf0e10cSrcweir } 613cdf0e10cSrcweir break; 614cdf0e10cSrcweir 615cdf0e10cSrcweir case SID_STYLE_NEW_BY_EXAMPLE: 616cdf0e10cSrcweir { 617cdf0e10cSrcweir if( pStyleSheet ) 618cdf0e10cSrcweir { 619cdf0e10cSrcweir nRetMask = pStyleSheet->GetMask(); 620cdf0e10cSrcweir SfxItemSet aCoreSet( mpDoc->GetPool() ); 621cdf0e10cSrcweir mpView->GetAttributes( aCoreSet, sal_True ); 622cdf0e10cSrcweir 623cdf0e10cSrcweir // wenn das Objekt eine Vorlage hatte, wird diese Parent 624cdf0e10cSrcweir // der neuen Vorlage 625cdf0e10cSrcweir SfxStyleSheet* pOldStyle = mpView->GetStyleSheet(); 626cdf0e10cSrcweir 627cdf0e10cSrcweir // Wenn pOldStyle == pStyleSheet -> Rekursion 628cdf0e10cSrcweir if( pOldStyle != pStyleSheet ) 629cdf0e10cSrcweir { 630cdf0e10cSrcweir if (pOldStyle) 631cdf0e10cSrcweir { 632cdf0e10cSrcweir pStyleSheet->SetParent(pOldStyle->GetName()); 633cdf0e10cSrcweir } 634cdf0e10cSrcweir 635cdf0e10cSrcweir SfxItemSet* pStyleSet = &pStyleSheet->GetItemSet(); 636cdf0e10cSrcweir pStyleSet->Put(aCoreSet); 637cdf0e10cSrcweir 638cdf0e10cSrcweir // Vorlage anwenden (Aber nicht, wenn gerade ein Text 639cdf0e10cSrcweir // editiert wird, denn dazu muesste die Edit Engine 640cdf0e10cSrcweir // Vorlagen auf Zeichenebene beherrschen.) 641cdf0e10cSrcweir if (!mpView->GetTextEditObject()) 642cdf0e10cSrcweir { 643cdf0e10cSrcweir mpView->SetStyleSheet( (SfxStyleSheet*) pStyleSheet); 644cdf0e10cSrcweir } 645cdf0e10cSrcweir 646cdf0e10cSrcweir ( (SfxStyleSheet*) pStyleSheet )->Broadcast( SfxSimpleHint( SFX_HINT_DATACHANGED ) ); 647cdf0e10cSrcweir mpDoc->SetChanged(sal_True); 648cdf0e10cSrcweir 649cdf0e10cSrcweir mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_STYLE_FAMILY2 ); 650cdf0e10cSrcweir } 651cdf0e10cSrcweir } 652cdf0e10cSrcweir } 653cdf0e10cSrcweir break; 654cdf0e10cSrcweir 655cdf0e10cSrcweir case SID_STYLE_UPDATE_BY_EXAMPLE: 656cdf0e10cSrcweir { 657cdf0e10cSrcweir if ((mpView->AreObjectsMarked() && mpView->GetMarkedObjectList().GetMarkCount() == 1) || 658cdf0e10cSrcweir mpView->ISA(OutlineView)) 659cdf0e10cSrcweir { 660cdf0e10cSrcweir pStyleSheet = mpView->GetStyleSheet(); 661cdf0e10cSrcweir 662cdf0e10cSrcweir if( pStyleSheet ) 663cdf0e10cSrcweir { 664cdf0e10cSrcweir nRetMask = pStyleSheet->GetMask(); 665cdf0e10cSrcweir SfxItemSet aCoreSet( mpDoc->GetPool() ); 666cdf0e10cSrcweir mpView->GetAttributes( aCoreSet ); 667cdf0e10cSrcweir 668cdf0e10cSrcweir SfxItemSet* pStyleSet = &pStyleSheet->GetItemSet(); 669cdf0e10cSrcweir pStyleSet->Put( aCoreSet ); 670cdf0e10cSrcweir 671cdf0e10cSrcweir mpView->SetStyleSheet( (SfxStyleSheet*) pStyleSheet); 672cdf0e10cSrcweir 673cdf0e10cSrcweir ( (SfxStyleSheet*) pStyleSheet )->Broadcast( SfxSimpleHint( SFX_HINT_DATACHANGED ) ); 674cdf0e10cSrcweir mpDoc->SetChanged(sal_True); 675cdf0e10cSrcweir mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_STYLE_FAMILY2 ); 676cdf0e10cSrcweir } 677cdf0e10cSrcweir } 678cdf0e10cSrcweir } 679cdf0e10cSrcweir break; 680cdf0e10cSrcweir 681cdf0e10cSrcweir } 682cdf0e10cSrcweir if( nRetMask != 0xffff ) 683cdf0e10cSrcweir rReq.SetReturnValue( SfxUInt16Item( nSId, nRetMask ) ); 684cdf0e10cSrcweir } 685cdf0e10cSrcweir 686cdf0e10cSrcweir void FuTemplate::Activate() 687cdf0e10cSrcweir { 688cdf0e10cSrcweir } 689cdf0e10cSrcweir 690cdf0e10cSrcweir void FuTemplate::Deactivate() 691cdf0e10cSrcweir { 692cdf0e10cSrcweir } 693cdf0e10cSrcweir 694cdf0e10cSrcweir } // end of namespace sd 695