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_sfx2.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir // include --------------------------------------------------------------- 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #ifndef _MSGBOX_HXX //autogen 34*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 35*cdf0e10cSrcweir #endif 36*cdf0e10cSrcweir #include <vcl/field.hxx> 37*cdf0e10cSrcweir #include <svl/eitem.hxx> 38*cdf0e10cSrcweir #include <svl/intitem.hxx> 39*cdf0e10cSrcweir #include <svl/style.hxx> 40*cdf0e10cSrcweir #ifndef GCC 41*cdf0e10cSrcweir #endif 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir #include <sfx2/styfitem.hxx> 44*cdf0e10cSrcweir #include <sfx2/styledlg.hxx> 45*cdf0e10cSrcweir #include <sfx2/app.hxx> 46*cdf0e10cSrcweir #include <sfx2/mgetempl.hxx> 47*cdf0e10cSrcweir #include <sfx2/objsh.hxx> 48*cdf0e10cSrcweir #include "sfxtypes.hxx" 49*cdf0e10cSrcweir #include "sfx2/sfxresid.hxx" 50*cdf0e10cSrcweir #include <sfx2/module.hxx> 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir #include <sfx2/sfx.hrc> 53*cdf0e10cSrcweir #include "dialog.hrc" 54*cdf0e10cSrcweir #include "mgetempl.hrc" 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir #ifndef _SFX_STYLE_HRC 57*cdf0e10cSrcweir #include <svl/style.hrc> 58*cdf0e10cSrcweir #endif 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir // SfxManageStyleSheetPage ----------------------------------------------- 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir SfxManageStyleSheetPage::SfxManageStyleSheetPage( Window* pParent, const SfxItemSet& rAttrSet ) : 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir SfxTabPage( pParent, SfxResId( TP_MANAGE_STYLES ), rAttrSet ), 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir aNameFt ( this, SfxResId( FT_NAME ) ), 67*cdf0e10cSrcweir aNameEd ( this, SfxResId( ED_NAME ) ), 68*cdf0e10cSrcweir aNameMLE ( this, SfxResId( MLE_NAME ) ), 69*cdf0e10cSrcweir aAutoCB ( this, SfxResId( CB_AUTO ) ), 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir aFollowFt ( this, SfxResId( FT_NEXT ) ), 72*cdf0e10cSrcweir aFollowLb ( this, SfxResId( LB_NEXT ) ), 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir aBaseFt ( this, SfxResId( FT_BASE ) ), 75*cdf0e10cSrcweir aBaseLb ( this, SfxResId( LB_BASE ) ), 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir aFilterFt ( this, SfxResId( FT_REGION ) ), 78*cdf0e10cSrcweir aFilterLb ( this, SfxResId( LB_REGION ) ), 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir aDescGb ( this, SfxResId( GB_DESC ) ), 81*cdf0e10cSrcweir aDescFt ( this, SfxResId( FT_DESC ) ), 82*cdf0e10cSrcweir aDescED ( this, SfxResId( ED_DESC ) ), 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir pStyle( &( (SfxStyleDialog*)pParent->GetParent() )->GetStyleSheet() ), 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir pItem ( 0 ), 87*cdf0e10cSrcweir bModified ( sal_False ), 88*cdf0e10cSrcweir aName ( pStyle->GetName() ), 89*cdf0e10cSrcweir aFollow ( pStyle->GetFollow() ), 90*cdf0e10cSrcweir aParent ( pStyle->GetParent() ), 91*cdf0e10cSrcweir nFlags ( pStyle->GetMask() ) 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir /* [Beschreibung] 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir Konstruktor; initialisiert die ListBoxen mit den Vorlagen 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir */ 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir { 100*cdf0e10cSrcweir FreeResource(); 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir if ( IsBackground() ) 103*cdf0e10cSrcweir aDescED.SetBackground( GetBackground() ); 104*cdf0e10cSrcweir FixedInfo* pInfo = new FixedInfo( this ); 105*cdf0e10cSrcweir aDescED.SetFont( pInfo->GetFont() ); 106*cdf0e10cSrcweir delete pInfo; 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir aDescED.Hide(); 109*cdf0e10cSrcweir aDescFt.Show(); 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir // diese Page braucht ExchangeSupport 112*cdf0e10cSrcweir SetExchangeSupport(); 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir ResMgr* pResMgr = SFX_APP()->GetModule_Impl()->GetResMgr(); 115*cdf0e10cSrcweir DBG_ASSERT( pResMgr, "kein ResMgr am Modul" ); 116*cdf0e10cSrcweir pFamilies = new SfxStyleFamilies( ResId( DLG_STYLE_DESIGNER, *pResMgr ) ); 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir SfxStyleSheetBasePool* pPool = 0; 119*cdf0e10cSrcweir SfxObjectShell* pDocShell = SfxObjectShell::Current(); 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir if ( pDocShell ) 122*cdf0e10cSrcweir pPool = pDocShell->GetStyleSheetPool(); 123*cdf0e10cSrcweir DBG_ASSERT( pPool, "kein Pool oder keine DocShell" ); 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir if ( pPool ) 126*cdf0e10cSrcweir { 127*cdf0e10cSrcweir pPool->SetSearchMask( pStyle->GetFamily() ); 128*cdf0e10cSrcweir pPool->First(); // fuer SW - interne Liste updaten 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir if ( !pStyle->GetName().Len() && pPool ) 132*cdf0e10cSrcweir { 133*cdf0e10cSrcweir // NullString als Name -> Name generieren 134*cdf0e10cSrcweir String aNoName( SfxResId( STR_NONAME ) ); 135*cdf0e10cSrcweir sal_uInt16 nNo = 1; 136*cdf0e10cSrcweir String aNo( aNoName ); 137*cdf0e10cSrcweir aNoName += String::CreateFromInt32( nNo ); 138*cdf0e10cSrcweir while ( pPool->Find( aNoName ) ) 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir ++nNo; 141*cdf0e10cSrcweir aNoName = aNo; 142*cdf0e10cSrcweir aNoName += String::CreateFromInt32( nNo ); 143*cdf0e10cSrcweir } 144*cdf0e10cSrcweir pStyle->SetName( aNoName ); 145*cdf0e10cSrcweir aName = aNoName; 146*cdf0e10cSrcweir aFollow = pStyle->GetFollow(); 147*cdf0e10cSrcweir aParent = pStyle->GetParent(); 148*cdf0e10cSrcweir } 149*cdf0e10cSrcweir aNameEd.SetText(pStyle->GetName()); 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir // Set the field read-only if it is NOT an user-defined style 152*cdf0e10cSrcweir // but allow selecting and copying 153*cdf0e10cSrcweir if ( !pStyle->IsUserDefined() ) { 154*cdf0e10cSrcweir aNameEd.SetReadOnly(); 155*cdf0e10cSrcweir aNameEd.Hide(); 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir aNameMLE.SetControlBackground( GetSettings().GetStyleSettings().GetDialogColor() ); 158*cdf0e10cSrcweir aNameMLE.SetText( pStyle->GetName() ); 159*cdf0e10cSrcweir aNameMLE.EnableCursor( sal_False ); 160*cdf0e10cSrcweir aNameMLE.Show(); 161*cdf0e10cSrcweir } 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir if ( pStyle->HasFollowSupport() && pPool ) 164*cdf0e10cSrcweir { 165*cdf0e10cSrcweir SfxStyleSheetBase* pPoolStyle = pPool->First(); 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir while ( pPoolStyle ) 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir aFollowLb.InsertEntry( pPoolStyle->GetName() ); 170*cdf0e10cSrcweir pPoolStyle = pPool->Next(); 171*cdf0e10cSrcweir } 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir // eine neue Vorlage ist noch nicht im Pool 174*cdf0e10cSrcweir if ( LISTBOX_ENTRY_NOTFOUND == aFollowLb.GetEntryPos( pStyle->GetName() ) ) 175*cdf0e10cSrcweir aFollowLb.InsertEntry( pStyle->GetName() ); 176*cdf0e10cSrcweir } 177*cdf0e10cSrcweir else 178*cdf0e10cSrcweir { 179*cdf0e10cSrcweir aFollowFt.Hide(); 180*cdf0e10cSrcweir aFollowLb.Hide(); 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir aFilterFt.SetPosPixel( aBaseFt.GetPosPixel() ); 183*cdf0e10cSrcweir aFilterLb.SetPosPixel( aBaseLb.GetPosPixel() ); 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir aBaseFt.SetPosPixel( aFollowFt.GetPosPixel() ); 186*cdf0e10cSrcweir aBaseLb.SetPosPixel( aFollowLb.GetPosPixel() ); 187*cdf0e10cSrcweir } 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir if ( pStyle->HasParentSupport() && pPool ) 190*cdf0e10cSrcweir { 191*cdf0e10cSrcweir if ( pStyle->HasClearParentSupport() ) 192*cdf0e10cSrcweir // die Basisvorlage darf auf NULL gesetzt werden 193*cdf0e10cSrcweir aBaseLb.InsertEntry( String( SfxResId( STR_NONE ) ) ); 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir SfxStyleSheetBase* pPoolStyle = pPool->First(); 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir while ( pPoolStyle ) 198*cdf0e10cSrcweir { 199*cdf0e10cSrcweir const String aStr( pPoolStyle->GetName() ); 200*cdf0e10cSrcweir // eigener Namen nicht als Basisvorlage 201*cdf0e10cSrcweir if ( aStr != aName ) 202*cdf0e10cSrcweir aBaseLb.InsertEntry( aStr ); 203*cdf0e10cSrcweir pPoolStyle = pPool->Next(); 204*cdf0e10cSrcweir } 205*cdf0e10cSrcweir } 206*cdf0e10cSrcweir else 207*cdf0e10cSrcweir { 208*cdf0e10cSrcweir aBaseFt.Disable(); 209*cdf0e10cSrcweir aBaseLb.Disable(); 210*cdf0e10cSrcweir } 211*cdf0e10cSrcweir sal_uInt16 nCount = pFamilies->Count(); 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir sal_uInt16 i; 214*cdf0e10cSrcweir for ( i = 0; i < nCount; ++i ) 215*cdf0e10cSrcweir { 216*cdf0e10cSrcweir pItem = pFamilies->GetObject(i); 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir if ( pItem->GetFamily() == pStyle->GetFamily() ) 219*cdf0e10cSrcweir break; 220*cdf0e10cSrcweir } 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir sal_uInt16 nStyleFilterIdx = 0xffff; 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir if ( i < nCount ) 225*cdf0e10cSrcweir { 226*cdf0e10cSrcweir // Filterflags 227*cdf0e10cSrcweir const SfxStyleFilter& rList = pItem->GetFilterList(); 228*cdf0e10cSrcweir nCount = (sal_uInt16)rList.Count(); 229*cdf0e10cSrcweir sal_uInt16 nIdx = 0; 230*cdf0e10cSrcweir sal_uInt16 nMask = pStyle->GetMask() & ~SFXSTYLEBIT_USERDEF; 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir if ( !nMask ) // Benutzervorlage? 233*cdf0e10cSrcweir nMask = pStyle->GetMask(); 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir for ( i = 0; i < nCount; ++i ) 236*cdf0e10cSrcweir { 237*cdf0e10cSrcweir SfxFilterTupel* pTupel = rList.GetObject(i); 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir if ( pTupel->nFlags != SFXSTYLEBIT_AUTO && 240*cdf0e10cSrcweir pTupel->nFlags != SFXSTYLEBIT_USED && 241*cdf0e10cSrcweir // pTupel->nFlags != SFXSTYLEBIT_USERDEF && 242*cdf0e10cSrcweir pTupel->nFlags != SFXSTYLEBIT_ALL ) 243*cdf0e10cSrcweir { 244*cdf0e10cSrcweir aFilterLb.InsertEntry( pTupel->aName, nIdx ); 245*cdf0e10cSrcweir aFilterLb.SetEntryData(nIdx, (void*)(long)i); 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir if ( ( pTupel->nFlags & nMask ) == nMask ) 248*cdf0e10cSrcweir nStyleFilterIdx = nIdx; 249*cdf0e10cSrcweir ++nIdx; 250*cdf0e10cSrcweir } 251*cdf0e10cSrcweir } 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir if ( nStyleFilterIdx != 0xFFFF ) 254*cdf0e10cSrcweir aFilterLb.SelectEntryPos( nStyleFilterIdx ); 255*cdf0e10cSrcweir } 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir if ( !aFilterLb.GetEntryCount() || !pStyle->IsUserDefined() ) 258*cdf0e10cSrcweir { 259*cdf0e10cSrcweir pItem = 0; 260*cdf0e10cSrcweir aFilterFt.Disable(); 261*cdf0e10cSrcweir aFilterLb.Disable(); 262*cdf0e10cSrcweir } 263*cdf0e10cSrcweir else 264*cdf0e10cSrcweir aFilterLb.SaveValue(); 265*cdf0e10cSrcweir SetDescriptionText_Impl(); 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir if ( aFollowLb.IsEnabled() || aBaseLb.IsEnabled() ) 268*cdf0e10cSrcweir { 269*cdf0e10cSrcweir aNameEd.SetGetFocusHdl( 270*cdf0e10cSrcweir LINK( this, SfxManageStyleSheetPage, GetFocusHdl ) ); 271*cdf0e10cSrcweir aNameEd.SetLoseFocusHdl( 272*cdf0e10cSrcweir LINK( this, SfxManageStyleSheetPage, LoseFocusHdl ) ); 273*cdf0e10cSrcweir } 274*cdf0e10cSrcweir // ist es ein Style mit automatischem Update? (nur SW) 275*cdf0e10cSrcweir if(SFX_ITEM_SET == rAttrSet.GetItemState(SID_ATTR_AUTO_STYLE_UPDATE)) 276*cdf0e10cSrcweir { 277*cdf0e10cSrcweir Size aSize = aNameEd.GetSizePixel(); 278*cdf0e10cSrcweir aSize.Width() /= 2; 279*cdf0e10cSrcweir aNameEd.SetSizePixel(aSize); 280*cdf0e10cSrcweir aAutoCB.Show(); 281*cdf0e10cSrcweir } 282*cdf0e10cSrcweir } 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir //------------------------------------------------------------------------- 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir SfxManageStyleSheetPage::~SfxManageStyleSheetPage() 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir /* [Beschreibung] 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir Destruktor; Freigabe der Daten 291*cdf0e10cSrcweir 292*cdf0e10cSrcweir */ 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir { 295*cdf0e10cSrcweir aNameEd.SetGetFocusHdl( Link() ); 296*cdf0e10cSrcweir aNameEd.SetLoseFocusHdl( Link() ); 297*cdf0e10cSrcweir delete pFamilies; 298*cdf0e10cSrcweir pItem = 0; 299*cdf0e10cSrcweir pStyle = 0; 300*cdf0e10cSrcweir 301*cdf0e10cSrcweir } 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir //------------------------------------------------------------------------- 304*cdf0e10cSrcweir 305*cdf0e10cSrcweir void SfxManageStyleSheetPage::UpdateName_Impl( ListBox* pBox, 306*cdf0e10cSrcweir const String& rNew ) 307*cdf0e10cSrcweir 308*cdf0e10cSrcweir /* [Beschreibung] 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir Nach der "Anderung eines Vorlagennamens die ListBox pBox 311*cdf0e10cSrcweir aktualisieren 312*cdf0e10cSrcweir 313*cdf0e10cSrcweir [Parameter] 314*cdf0e10cSrcweir 315*cdf0e10cSrcweir ListBox* pBox ListBox, deren Eintr"age aktualisiert 316*cdf0e10cSrcweir werden sollen 317*cdf0e10cSrcweir const String& rNew der neue Name 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir */ 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir { 322*cdf0e10cSrcweir if ( pBox->IsEnabled() ) 323*cdf0e10cSrcweir { 324*cdf0e10cSrcweir // ist der aktuelle Eintrag, dessen Namen modifizieren wurde 325*cdf0e10cSrcweir const sal_Bool bSelect = pBox->GetSelectEntry() == aBuf; 326*cdf0e10cSrcweir pBox->RemoveEntry( aBuf ); 327*cdf0e10cSrcweir pBox->InsertEntry( rNew ); 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir if ( bSelect ) 330*cdf0e10cSrcweir pBox->SelectEntry( rNew ); 331*cdf0e10cSrcweir } 332*cdf0e10cSrcweir } 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir //------------------------------------------------------------------------- 335*cdf0e10cSrcweir 336*cdf0e10cSrcweir void SfxManageStyleSheetPage::SetDescriptionText_Impl() 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir /* [Beschreibung] 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir Attributbeschreibung setzen. daf"ur die eingestellte Metrik besorgen. 341*cdf0e10cSrcweir */ 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir { 344*cdf0e10cSrcweir SfxMapUnit eUnit = SFX_MAPUNIT_CM; 345*cdf0e10cSrcweir // FieldUnit eFieldUnit = pSfxApp->GetOptions().GetMetric(); 346*cdf0e10cSrcweir FieldUnit eFieldUnit( FUNIT_CM ); 347*cdf0e10cSrcweir SfxModule* pModule = SfxModule::GetActiveModule(); 348*cdf0e10cSrcweir if ( pModule ) 349*cdf0e10cSrcweir { 350*cdf0e10cSrcweir const SfxPoolItem* pPoolItem = pModule->GetItem( SID_ATTR_METRIC ); 351*cdf0e10cSrcweir if ( pPoolItem ) 352*cdf0e10cSrcweir eFieldUnit = (FieldUnit)( (SfxUInt16Item*)pPoolItem )->GetValue(); 353*cdf0e10cSrcweir } 354*cdf0e10cSrcweir 355*cdf0e10cSrcweir switch ( eFieldUnit ) 356*cdf0e10cSrcweir { 357*cdf0e10cSrcweir case FUNIT_MM: eUnit = SFX_MAPUNIT_MM; break; 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir case FUNIT_CM: 360*cdf0e10cSrcweir case FUNIT_M: 361*cdf0e10cSrcweir case FUNIT_KM: eUnit = SFX_MAPUNIT_CM; break; 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir case FUNIT_POINT: 364*cdf0e10cSrcweir case FUNIT_PICA: eUnit = SFX_MAPUNIT_POINT; break; 365*cdf0e10cSrcweir 366*cdf0e10cSrcweir case FUNIT_INCH: 367*cdf0e10cSrcweir case FUNIT_FOOT: 368*cdf0e10cSrcweir case FUNIT_MILE: eUnit = SFX_MAPUNIT_INCH; break; 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir default: 371*cdf0e10cSrcweir DBG_ERRORFILE( "not supported fieldunit" ); 372*cdf0e10cSrcweir } 373*cdf0e10cSrcweir aDescFt.SetText( pStyle->GetDescription( eUnit ) ); 374*cdf0e10cSrcweir } 375*cdf0e10cSrcweir 376*cdf0e10cSrcweir //------------------------------------------------------------------------- 377*cdf0e10cSrcweir 378*cdf0e10cSrcweir IMPL_LINK_INLINE_START( SfxManageStyleSheetPage, GetFocusHdl, Edit *, pEdit ) 379*cdf0e10cSrcweir 380*cdf0e10cSrcweir /* [Beschreibung] 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir StarView Handler; GetFocus-Handler des Edits mit dem Vorlagennamen. 383*cdf0e10cSrcweir 384*cdf0e10cSrcweir */ 385*cdf0e10cSrcweir 386*cdf0e10cSrcweir { 387*cdf0e10cSrcweir aBuf = pEdit->GetText().EraseLeadingChars(); 388*cdf0e10cSrcweir return 0; 389*cdf0e10cSrcweir } 390*cdf0e10cSrcweir IMPL_LINK_INLINE_END( SfxManageStyleSheetPage, GetFocusHdl, Edit *, pEdit ) 391*cdf0e10cSrcweir 392*cdf0e10cSrcweir //------------------------------------------------------------------------- 393*cdf0e10cSrcweir 394*cdf0e10cSrcweir IMPL_LINK_INLINE_START( SfxManageStyleSheetPage, LoseFocusHdl, Edit *, pEdit ) 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir /* [Beschreibung] 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir StarView Handler; LoseFocus-Handler des Edits mit dem Vorlagennamen. 399*cdf0e10cSrcweir Dieser aktualisiert ggf. die Listbox mit den Folgevorlagen. 400*cdf0e10cSrcweir In der Listbox mit den Basisvorlagen ist die aktuelle Vorlage 401*cdf0e10cSrcweir selbst nicht enthalten. 402*cdf0e10cSrcweir 403*cdf0e10cSrcweir */ 404*cdf0e10cSrcweir 405*cdf0e10cSrcweir { 406*cdf0e10cSrcweir const String aStr( pEdit->GetText().EraseLeadingChars() ); 407*cdf0e10cSrcweir pEdit->SetText( aStr ); 408*cdf0e10cSrcweir // ggf. Listbox der Basisvorlagen aktualisieren 409*cdf0e10cSrcweir if ( aStr != aBuf ) 410*cdf0e10cSrcweir UpdateName_Impl( &aFollowLb, aStr ); 411*cdf0e10cSrcweir return 0; 412*cdf0e10cSrcweir } 413*cdf0e10cSrcweir IMPL_LINK_INLINE_END( SfxManageStyleSheetPage, LoseFocusHdl, Edit *, pEdit ) 414*cdf0e10cSrcweir 415*cdf0e10cSrcweir //------------------------------------------------------------------------- 416*cdf0e10cSrcweir 417*cdf0e10cSrcweir sal_Bool SfxManageStyleSheetPage::FillItemSet( SfxItemSet& rSet ) 418*cdf0e10cSrcweir 419*cdf0e10cSrcweir /* [Beschreibung] 420*cdf0e10cSrcweir 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir Handler f"ur das Setzen der (modifizierten) Daten. Wird aus 423*cdf0e10cSrcweir dem Ok des SfxTabDialog gerufen. 424*cdf0e10cSrcweir 425*cdf0e10cSrcweir [Parameter] 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir SfxItemSet &rAttrSet das Set, das die Daten entgegennimmt. 428*cdf0e10cSrcweir 429*cdf0e10cSrcweir 430*cdf0e10cSrcweir [R"uckgabewert] 431*cdf0e10cSrcweir 432*cdf0e10cSrcweir sal_Bool sal_True: es hat eine "Anderung der Daten 433*cdf0e10cSrcweir stattgefunden 434*cdf0e10cSrcweir sal_False: es hat keine "Anderung der Daten 435*cdf0e10cSrcweir stattgefunden 436*cdf0e10cSrcweir 437*cdf0e10cSrcweir [Querverweise] 438*cdf0e10cSrcweir 439*cdf0e10cSrcweir <class SfxTabDialog> 440*cdf0e10cSrcweir 441*cdf0e10cSrcweir */ 442*cdf0e10cSrcweir 443*cdf0e10cSrcweir { 444*cdf0e10cSrcweir const sal_uInt16 nFilterIdx = aFilterLb.GetSelectEntryPos(); 445*cdf0e10cSrcweir 446*cdf0e10cSrcweir // Filter setzen 447*cdf0e10cSrcweir 448*cdf0e10cSrcweir if ( LISTBOX_ENTRY_NOTFOUND != nFilterIdx && 449*cdf0e10cSrcweir nFilterIdx != aFilterLb.GetSavedValue() && 450*cdf0e10cSrcweir aFilterLb.IsEnabled() ) 451*cdf0e10cSrcweir { 452*cdf0e10cSrcweir bModified = sal_True; 453*cdf0e10cSrcweir DBG_ASSERT( pItem, "kein Item" ); 454*cdf0e10cSrcweir // geht nur bei Benutzervorlagen 455*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 456*cdf0e10cSrcweir sal_uInt16 nIdx = (sal_uInt16)(long)aFilterLb.GetEntryData( nFilterIdx ); 457*cdf0e10cSrcweir SfxFilterTupel* p; 458*cdf0e10cSrcweir p = pItem->GetFilterList().GetObject( nIdx ); 459*cdf0e10cSrcweir #endif 460*cdf0e10cSrcweir sal_uInt16 nMask = pItem->GetFilterList().GetObject( 461*cdf0e10cSrcweir (sal_uInt16)(long)aFilterLb.GetEntryData( nFilterIdx ) )->nFlags | 462*cdf0e10cSrcweir SFXSTYLEBIT_USERDEF; 463*cdf0e10cSrcweir pStyle->SetMask( nMask ); 464*cdf0e10cSrcweir } 465*cdf0e10cSrcweir if(aAutoCB.IsVisible() && 466*cdf0e10cSrcweir aAutoCB.IsChecked() != aAutoCB.GetSavedValue()) 467*cdf0e10cSrcweir { 468*cdf0e10cSrcweir rSet.Put(SfxBoolItem(SID_ATTR_AUTO_STYLE_UPDATE, aAutoCB.IsChecked())); 469*cdf0e10cSrcweir } 470*cdf0e10cSrcweir 471*cdf0e10cSrcweir return bModified; 472*cdf0e10cSrcweir } 473*cdf0e10cSrcweir 474*cdf0e10cSrcweir //------------------------------------------------------------------------- 475*cdf0e10cSrcweir 476*cdf0e10cSrcweir void SfxManageStyleSheetPage::Reset( const SfxItemSet& /*rAttrSet*/ ) 477*cdf0e10cSrcweir 478*cdf0e10cSrcweir /* [Beschreibung] 479*cdf0e10cSrcweir 480*cdf0e10cSrcweir 481*cdf0e10cSrcweir Handler f"ur das Initialisieren der Seite mit den initialen Daten. 482*cdf0e10cSrcweir 483*cdf0e10cSrcweir [Parameter] 484*cdf0e10cSrcweir 485*cdf0e10cSrcweir const SfxItemSet &rAttrSet das Set mit den Daten 486*cdf0e10cSrcweir 487*cdf0e10cSrcweir 488*cdf0e10cSrcweir [Querverweise] 489*cdf0e10cSrcweir 490*cdf0e10cSrcweir <class SfxTabDialog> 491*cdf0e10cSrcweir 492*cdf0e10cSrcweir */ 493*cdf0e10cSrcweir 494*cdf0e10cSrcweir { 495*cdf0e10cSrcweir bModified = sal_False; 496*cdf0e10cSrcweir String sCmp( pStyle->GetName() ); 497*cdf0e10cSrcweir 498*cdf0e10cSrcweir if ( sCmp != aName ) 499*cdf0e10cSrcweir pStyle->SetName( aName ); 500*cdf0e10cSrcweir aNameEd.SetText( aName ); 501*cdf0e10cSrcweir 502*cdf0e10cSrcweir if ( aFollowLb.IsEnabled() ) 503*cdf0e10cSrcweir { 504*cdf0e10cSrcweir sCmp = pStyle->GetFollow(); 505*cdf0e10cSrcweir 506*cdf0e10cSrcweir if ( sCmp != aFollow ) 507*cdf0e10cSrcweir pStyle->SetFollow( aFollow ); 508*cdf0e10cSrcweir 509*cdf0e10cSrcweir if ( !aFollow.Len() ) 510*cdf0e10cSrcweir aFollowLb.SelectEntry( aName ); 511*cdf0e10cSrcweir else 512*cdf0e10cSrcweir aFollowLb.SelectEntry( aFollow ); 513*cdf0e10cSrcweir } 514*cdf0e10cSrcweir 515*cdf0e10cSrcweir if ( aBaseLb.IsEnabled() ) 516*cdf0e10cSrcweir { 517*cdf0e10cSrcweir sCmp = pStyle->GetParent(); 518*cdf0e10cSrcweir 519*cdf0e10cSrcweir if ( sCmp != aParent ) 520*cdf0e10cSrcweir pStyle->SetParent( aParent ); 521*cdf0e10cSrcweir 522*cdf0e10cSrcweir if ( !aParent.Len() ) 523*cdf0e10cSrcweir aBaseLb.SelectEntry( String( SfxResId( STR_NONE ) ) ); 524*cdf0e10cSrcweir else 525*cdf0e10cSrcweir aBaseLb.SelectEntry( aParent ); 526*cdf0e10cSrcweir 527*cdf0e10cSrcweir if ( String( SfxResId( STR_STANDARD ) ) == aName ) 528*cdf0e10cSrcweir { 529*cdf0e10cSrcweir // die Standardvorlage kann nicht verkn"upft werden 530*cdf0e10cSrcweir aBaseFt.Disable(); 531*cdf0e10cSrcweir aBaseLb.Disable(); 532*cdf0e10cSrcweir } 533*cdf0e10cSrcweir } 534*cdf0e10cSrcweir 535*cdf0e10cSrcweir if ( aFilterLb.IsEnabled() ) 536*cdf0e10cSrcweir { 537*cdf0e10cSrcweir sal_uInt16 nCmp = pStyle->GetMask(); 538*cdf0e10cSrcweir 539*cdf0e10cSrcweir if ( nCmp != nFlags ) 540*cdf0e10cSrcweir pStyle->SetMask( nFlags ); 541*cdf0e10cSrcweir aFilterLb.SelectEntryPos( aFilterLb.GetSavedValue() ); 542*cdf0e10cSrcweir } 543*cdf0e10cSrcweir } 544*cdf0e10cSrcweir 545*cdf0e10cSrcweir //------------------------------------------------------------------------- 546*cdf0e10cSrcweir 547*cdf0e10cSrcweir SfxTabPage* SfxManageStyleSheetPage::Create( Window* pParent, 548*cdf0e10cSrcweir const SfxItemSet &rAttrSet ) 549*cdf0e10cSrcweir 550*cdf0e10cSrcweir /* [Beschreibung] 551*cdf0e10cSrcweir 552*cdf0e10cSrcweir 553*cdf0e10cSrcweir Factory f"ur das Erzeugen der Seite 554*cdf0e10cSrcweir 555*cdf0e10cSrcweir [Querverweise] 556*cdf0e10cSrcweir 557*cdf0e10cSrcweir <class SfxTabDialog> 558*cdf0e10cSrcweir 559*cdf0e10cSrcweir */ 560*cdf0e10cSrcweir 561*cdf0e10cSrcweir { 562*cdf0e10cSrcweir return new SfxManageStyleSheetPage( pParent, rAttrSet ); 563*cdf0e10cSrcweir } 564*cdf0e10cSrcweir 565*cdf0e10cSrcweir //------------------------------------------------------------------------- 566*cdf0e10cSrcweir 567*cdf0e10cSrcweir void SfxManageStyleSheetPage::ActivatePage( const SfxItemSet& rSet) 568*cdf0e10cSrcweir 569*cdf0e10cSrcweir /* [Beschreibung] 570*cdf0e10cSrcweir 571*cdf0e10cSrcweir ActivatePage- Handler des SfxTabDialog; wird f"ur die Aktualisierung 572*cdf0e10cSrcweir des beschreibenden Textes verwendet, da sich dieser durch "Anderungen 573*cdf0e10cSrcweir der Daten anderer Seiten ge"andert haben kann. 574*cdf0e10cSrcweir 575*cdf0e10cSrcweir [Parameter] 576*cdf0e10cSrcweir 577*cdf0e10cSrcweir const SfxItemSet& das Set f"ur den Datenaustausch; wird 578*cdf0e10cSrcweir hier nicht verwendet. 579*cdf0e10cSrcweir 580*cdf0e10cSrcweir [Querverweise] 581*cdf0e10cSrcweir 582*cdf0e10cSrcweir <SfxTabDialog::ActivatePage(const SfxItemSet &)> 583*cdf0e10cSrcweir 584*cdf0e10cSrcweir */ 585*cdf0e10cSrcweir 586*cdf0e10cSrcweir { 587*cdf0e10cSrcweir SetDescriptionText_Impl(); 588*cdf0e10cSrcweir 589*cdf0e10cSrcweir // ist es ein Style mit automatischem Update? (nur SW) 590*cdf0e10cSrcweir const SfxPoolItem* pPoolItem; 591*cdf0e10cSrcweir 592*cdf0e10cSrcweir if ( SFX_ITEM_SET == 593*cdf0e10cSrcweir rSet.GetItemState( SID_ATTR_AUTO_STYLE_UPDATE, sal_False, &pPoolItem ) ) 594*cdf0e10cSrcweir aAutoCB.Check( ( (const SfxBoolItem*)pPoolItem )->GetValue() ); 595*cdf0e10cSrcweir aAutoCB.SaveValue(); 596*cdf0e10cSrcweir } 597*cdf0e10cSrcweir 598*cdf0e10cSrcweir //------------------------------------------------------------------------- 599*cdf0e10cSrcweir 600*cdf0e10cSrcweir int SfxManageStyleSheetPage::DeactivatePage( SfxItemSet* pItemSet ) 601*cdf0e10cSrcweir 602*cdf0e10cSrcweir /* [Beschreibung] 603*cdf0e10cSrcweir 604*cdf0e10cSrcweir DeactivatePage- Handler des SfxTabDialog; die Daten werden 605*cdf0e10cSrcweir an der Vorlage eingestellt, damit die richtige Vererbung 606*cdf0e10cSrcweir f"ur die anderen Seiten des Dialoges vorliegt. 607*cdf0e10cSrcweir Im Fehlerfall wird das Verlassen der Seite unterbunden. 608*cdf0e10cSrcweir 609*cdf0e10cSrcweir [Parameter] 610*cdf0e10cSrcweir 611*cdf0e10cSrcweir SfxItemSet* das Set f"ur den Datenaustausch; wird hier nicht verwendet. 612*cdf0e10cSrcweir 613*cdf0e10cSrcweir [Querverweise] 614*cdf0e10cSrcweir 615*cdf0e10cSrcweir <SfxTabDialog::DeactivatePage(SfxItemSet*)> 616*cdf0e10cSrcweir 617*cdf0e10cSrcweir */ 618*cdf0e10cSrcweir 619*cdf0e10cSrcweir { 620*cdf0e10cSrcweir int nRet = SfxTabPage::LEAVE_PAGE; 621*cdf0e10cSrcweir 622*cdf0e10cSrcweir if ( aNameEd.IsModified() ) 623*cdf0e10cSrcweir { 624*cdf0e10cSrcweir // bei <Enter> wird kein LoseFocus() durch StarView ausgel"ost 625*cdf0e10cSrcweir if ( aNameEd.HasFocus() ) 626*cdf0e10cSrcweir LoseFocusHdl( &aNameEd ); 627*cdf0e10cSrcweir 628*cdf0e10cSrcweir if ( !pStyle->SetName( aNameEd.GetText().EraseLeadingChars() ) ) 629*cdf0e10cSrcweir { 630*cdf0e10cSrcweir InfoBox aBox( this, SfxResId( MSG_TABPAGE_INVALIDNAME ) ); 631*cdf0e10cSrcweir aBox.Execute(); 632*cdf0e10cSrcweir aNameEd.GrabFocus(); 633*cdf0e10cSrcweir aNameEd.SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) ); 634*cdf0e10cSrcweir return SfxTabPage::KEEP_PAGE; 635*cdf0e10cSrcweir } 636*cdf0e10cSrcweir bModified = sal_True; 637*cdf0e10cSrcweir } 638*cdf0e10cSrcweir 639*cdf0e10cSrcweir if ( pStyle->HasFollowSupport() && aFollowLb.IsEnabled() ) 640*cdf0e10cSrcweir { 641*cdf0e10cSrcweir const String aFollowEntry( aFollowLb.GetSelectEntry() ); 642*cdf0e10cSrcweir 643*cdf0e10cSrcweir if ( pStyle->GetFollow() != aFollowEntry ) 644*cdf0e10cSrcweir { 645*cdf0e10cSrcweir if ( !pStyle->SetFollow( aFollowEntry ) ) 646*cdf0e10cSrcweir { 647*cdf0e10cSrcweir InfoBox aBox( this, SfxResId( MSG_TABPAGE_INVALIDSTYLE ) ); 648*cdf0e10cSrcweir aBox.Execute(); 649*cdf0e10cSrcweir aFollowLb.GrabFocus(); 650*cdf0e10cSrcweir return SfxTabPage::KEEP_PAGE; 651*cdf0e10cSrcweir } 652*cdf0e10cSrcweir bModified = sal_True; 653*cdf0e10cSrcweir } 654*cdf0e10cSrcweir } 655*cdf0e10cSrcweir 656*cdf0e10cSrcweir if ( aBaseLb.IsEnabled() ) 657*cdf0e10cSrcweir { 658*cdf0e10cSrcweir String aParentEntry( aBaseLb.GetSelectEntry() ); 659*cdf0e10cSrcweir 660*cdf0e10cSrcweir if ( String( SfxResId( STR_NONE ) ) == aParentEntry || aParentEntry == pStyle->GetName() ) 661*cdf0e10cSrcweir aParentEntry.Erase(); 662*cdf0e10cSrcweir 663*cdf0e10cSrcweir if ( pStyle->GetParent() != aParentEntry ) 664*cdf0e10cSrcweir { 665*cdf0e10cSrcweir if ( !pStyle->SetParent( aParentEntry ) ) 666*cdf0e10cSrcweir { 667*cdf0e10cSrcweir InfoBox aBox( this, SfxResId( MSG_TABPAGE_INVALIDPARENT ) ); 668*cdf0e10cSrcweir aBox.Execute(); 669*cdf0e10cSrcweir aBaseLb.GrabFocus(); 670*cdf0e10cSrcweir return SfxTabPage::KEEP_PAGE; 671*cdf0e10cSrcweir } 672*cdf0e10cSrcweir bModified = sal_True; 673*cdf0e10cSrcweir nRet |= (int)SfxTabPage::REFRESH_SET; 674*cdf0e10cSrcweir } 675*cdf0e10cSrcweir } 676*cdf0e10cSrcweir 677*cdf0e10cSrcweir if ( pItemSet ) 678*cdf0e10cSrcweir FillItemSet( *pItemSet ); 679*cdf0e10cSrcweir 680*cdf0e10cSrcweir return nRet; 681*cdf0e10cSrcweir } 682*cdf0e10cSrcweir 683