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 #ifndef _MENU_HXX //autogen 32*cdf0e10cSrcweir #include <vcl/menu.hxx> 33*cdf0e10cSrcweir #endif 34*cdf0e10cSrcweir #include <svl/intitem.hxx> 35*cdf0e10cSrcweir #include <svl/stritem.hxx> 36*cdf0e10cSrcweir #include <svl/style.hxx> 37*cdf0e10cSrcweir #ifndef GCC 38*cdf0e10cSrcweir #endif 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir #define _SVSTDARR_STRINGSDTOR 41*cdf0e10cSrcweir #include <svl/svstdarr.hxx> 42*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 43*cdf0e10cSrcweir #include <comphelper/sequenceashashmap.hxx> 44*cdf0e10cSrcweir #include <unotools/intlwrapper.hxx> 45*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 46*cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp> 47*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 48*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 49*cdf0e10cSrcweir #include <com/sun/star/frame/XModuleManager.hpp> 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir #include "sfx2/sfxhelp.hxx" 52*cdf0e10cSrcweir #include <sfx2/app.hxx> 53*cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 54*cdf0e10cSrcweir #include <sfx2/bindings.hxx> 55*cdf0e10cSrcweir #include <sfx2/templdlg.hxx> 56*cdf0e10cSrcweir #include "templdgi.hxx" 57*cdf0e10cSrcweir #include "tplcitem.hxx" 58*cdf0e10cSrcweir #include "sfxtypes.hxx" 59*cdf0e10cSrcweir #include <sfx2/styfitem.hxx> 60*cdf0e10cSrcweir #include <sfx2/objsh.hxx> 61*cdf0e10cSrcweir #include <sfx2/viewsh.hxx> 62*cdf0e10cSrcweir #include <sfx2/newstyle.hxx> 63*cdf0e10cSrcweir #include "sfx2/tplpitem.hxx" 64*cdf0e10cSrcweir #include "sfx2/sfxresid.hxx" 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir #include "templdlg.hrc" 67*cdf0e10cSrcweir #include <sfx2/sfx.hrc> 68*cdf0e10cSrcweir #include "dialog.hrc" 69*cdf0e10cSrcweir #include "arrdecl.hxx" 70*cdf0e10cSrcweir #include "fltfnc.hxx" 71*cdf0e10cSrcweir #include <sfx2/docfilt.hxx> 72*cdf0e10cSrcweir #include <sfx2/docfac.hxx> 73*cdf0e10cSrcweir #include "docvor.hxx" 74*cdf0e10cSrcweir #include <sfx2/doctempl.hxx> 75*cdf0e10cSrcweir #include <sfx2/module.hxx> 76*cdf0e10cSrcweir #include "sfx2/imgmgr.hxx" 77*cdf0e10cSrcweir #include "helpid.hrc" 78*cdf0e10cSrcweir #include "appdata.hxx" 79*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir #include <comphelper/configurationhelper.hxx> 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir using namespace ::com::sun::star; 84*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 85*cdf0e10cSrcweir using namespace ::com::sun::star::frame; 86*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir //========================================================================= 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir // Fenster wird ab jetzt dynamisch erstellt. Daher hier R"ander usw. 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir #define SFX_TEMPLDLG_HFRAME 3 93*cdf0e10cSrcweir #define SFX_TEMPLDLG_VTOPFRAME 3 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir #define SFX_TEMPLDLG_VBOTFRAME 3 96*cdf0e10cSrcweir #define SFX_TEMPLDLG_MIDHSPACE 3 97*cdf0e10cSrcweir #define SFX_TEMPLDLG_MIDVSPACE 3 98*cdf0e10cSrcweir #define SFX_TEMPLDLG_FILTERHEIGHT 100 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir static sal_uInt16 nLastItemId = USHRT_MAX; 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir // filter box has maximum 12 entries visible 103*cdf0e10cSrcweir #define MAX_FILTER_ENTRIES 12 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir //========================================================================= 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir TYPEINIT0(SfxCommonTemplateDialog_Impl); 108*cdf0e10cSrcweir TYPEINIT1(SfxTemplateDialog_Impl,SfxCommonTemplateDialog_Impl); 109*cdf0e10cSrcweir TYPEINIT1(SfxTemplateCatalog_Impl,SfxCommonTemplateDialog_Impl); 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir SFX_IMPL_DOCKINGWINDOW(SfxTemplateDialogWrapper, SID_STYLE_DESIGNER) 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir //------------------------------------------------------------------------- 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir // Redirektionsfunktionen 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir SfxTemplateDialog::SfxTemplateDialog 118*cdf0e10cSrcweir ( 119*cdf0e10cSrcweir SfxBindings *pBind, 120*cdf0e10cSrcweir SfxChildWindow *pCW, 121*cdf0e10cSrcweir Window *pParent 122*cdf0e10cSrcweir ) 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir /* [Beschreibung] 125*cdf0e10cSrcweir Gestalterklasse. 126*cdf0e10cSrcweir */ 127*cdf0e10cSrcweir : SfxDockingWindow( pBind, pCW, pParent, SfxResId(DLG_STYLE_DESIGNER) ), 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir pImpl( new SfxTemplateDialog_Impl( pParent, pBind, this ) ) 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir { 132*cdf0e10cSrcweir pImpl->updateNonFamilyImages(); 133*cdf0e10cSrcweir } 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir //------------------------------------------------------------------------- 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir SfxTemplateDialog::~SfxTemplateDialog() 138*cdf0e10cSrcweir { 139*cdf0e10cSrcweir delete pImpl; 140*cdf0e10cSrcweir } 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir ISfxTemplateCommon* SfxTemplateDialog::GetISfxTemplateCommon() 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir return pImpl->GetISfxTemplateCommon(); 145*cdf0e10cSrcweir } 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir void SfxTemplateDialog::SetParagraphFamily() 148*cdf0e10cSrcweir { 149*cdf0e10cSrcweir // first select the paragraph family 150*cdf0e10cSrcweir pImpl->FamilySelect( SFX_STYLE_FAMILY_PARA ); 151*cdf0e10cSrcweir // then select the automatic filter 152*cdf0e10cSrcweir pImpl->SetAutomaticFilter(); 153*cdf0e10cSrcweir } 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir // ------------------------------------------------------------------------ 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir void SfxTemplateDialog::DataChanged( const DataChangedEvent& _rDCEvt ) 158*cdf0e10cSrcweir { 159*cdf0e10cSrcweir if ( ( DATACHANGED_SETTINGS == _rDCEvt.GetType() ) && 160*cdf0e10cSrcweir ( 0 != ( SETTINGS_STYLE & _rDCEvt.GetFlags() ) ) ) 161*cdf0e10cSrcweir { 162*cdf0e10cSrcweir pImpl->updateFamilyImages(); 163*cdf0e10cSrcweir pImpl->updateNonFamilyImages(); 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir SfxDockingWindow::DataChanged( _rDCEvt ); 167*cdf0e10cSrcweir } 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir //------------------------------------------------------------------------- 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir void SfxTemplateDialog::Update() 172*cdf0e10cSrcweir { 173*cdf0e10cSrcweir pImpl->Update(); 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir //------------------------------------------------------------------------- 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir void SfxTemplateDialog::Resize() 179*cdf0e10cSrcweir { 180*cdf0e10cSrcweir if(pImpl) 181*cdf0e10cSrcweir pImpl->Resize(); 182*cdf0e10cSrcweir SfxDockingWindow::Resize(); 183*cdf0e10cSrcweir } 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir //------------------------------------------------------------------------- 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir SfxChildAlignment SfxTemplateDialog::CheckAlignment(SfxChildAlignment eActAlign,SfxChildAlignment eAlign) 189*cdf0e10cSrcweir { 190*cdf0e10cSrcweir switch (eAlign) 191*cdf0e10cSrcweir { 192*cdf0e10cSrcweir case SFX_ALIGN_TOP: 193*cdf0e10cSrcweir case SFX_ALIGN_HIGHESTTOP: 194*cdf0e10cSrcweir case SFX_ALIGN_LOWESTTOP: 195*cdf0e10cSrcweir case SFX_ALIGN_BOTTOM: 196*cdf0e10cSrcweir case SFX_ALIGN_LOWESTBOTTOM: 197*cdf0e10cSrcweir case SFX_ALIGN_HIGHESTBOTTOM: 198*cdf0e10cSrcweir return eActAlign; 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir case SFX_ALIGN_LEFT: 201*cdf0e10cSrcweir case SFX_ALIGN_RIGHT: 202*cdf0e10cSrcweir case SFX_ALIGN_FIRSTLEFT: 203*cdf0e10cSrcweir case SFX_ALIGN_LASTLEFT: 204*cdf0e10cSrcweir case SFX_ALIGN_FIRSTRIGHT: 205*cdf0e10cSrcweir case SFX_ALIGN_LASTRIGHT: 206*cdf0e10cSrcweir return eAlign; 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir default: 209*cdf0e10cSrcweir return eAlign; 210*cdf0e10cSrcweir } 211*cdf0e10cSrcweir } 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir //------------------------------------------------------------------------- 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir SfxTemplateCatalog::SfxTemplateCatalog(Window *pParent, SfxBindings *pBindings) 216*cdf0e10cSrcweir : SfxModalDialog(pParent,SfxResId(RID_STYLECATALOG)) 217*cdf0e10cSrcweir { 218*cdf0e10cSrcweir pImpl = new SfxTemplateCatalog_Impl(pParent, pBindings, this); 219*cdf0e10cSrcweir } 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir //------------------------------------------------------------------------- 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir SfxTemplateCatalog::~SfxTemplateCatalog() 224*cdf0e10cSrcweir { 225*cdf0e10cSrcweir delete pImpl; 226*cdf0e10cSrcweir } 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir //------------------------------------------------------------------------- 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir void DropListBox_Impl::MouseButtonDown( const MouseEvent& rMEvt ) 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir nModifier = rMEvt.GetModifier(); 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir sal_Bool bHitEmptySpace = ( NULL == GetEntry( rMEvt.GetPosPixel(), sal_True ) ); 235*cdf0e10cSrcweir if( bHitEmptySpace && ( rMEvt.GetClicks() == 2 ) && rMEvt.IsMod1() ) 236*cdf0e10cSrcweir Control::MouseButtonDown( rMEvt ); 237*cdf0e10cSrcweir else 238*cdf0e10cSrcweir SvTreeListBox::MouseButtonDown( rMEvt ); 239*cdf0e10cSrcweir } 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir sal_Int8 DropListBox_Impl::AcceptDrop( const AcceptDropEvent& rEvt ) 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir /* [Description: ] 244*cdf0e10cSrcweir Drop is enabled as long as it is allowed to create a new style by example, i.e. to 245*cdf0e10cSrcweir create a style out of the current selection. 246*cdf0e10cSrcweir */ 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir { 249*cdf0e10cSrcweir if ( IsDropFormatSupported( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ) ) 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir // special case: page styles are allowed to create new styles by example 252*cdf0e10cSrcweir // but not allowed to be created by drag and drop 253*cdf0e10cSrcweir if( pDialog->nActFamily == SfxCommonTemplateDialog_Impl::SfxFamilyIdToNId( SFX_STYLE_FAMILY_PAGE ) || 254*cdf0e10cSrcweir pDialog->bNewByExampleDisabled ) 255*cdf0e10cSrcweir return DND_ACTION_NONE; 256*cdf0e10cSrcweir else 257*cdf0e10cSrcweir return DND_ACTION_COPY; 258*cdf0e10cSrcweir } 259*cdf0e10cSrcweir return SvTreeListBox::AcceptDrop( rEvt ); 260*cdf0e10cSrcweir } 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir //------------------------------------------------------------------------- 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir sal_Int8 DropListBox_Impl::ExecuteDrop( const ExecuteDropEvent& rEvt ) 265*cdf0e10cSrcweir { 266*cdf0e10cSrcweir // rEvt.maDropEvent.Context->acceptDrop( DND_ACTION_NONE ); 267*cdf0e10cSrcweir // rEvt.maDropEvent.Context->dropComplete( sal_True ); 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir sal_Int8 nRet = DND_ACTION_NONE; 270*cdf0e10cSrcweir SfxObjectShell* pDocShell = pDialog->GetObjectShell(); 271*cdf0e10cSrcweir TransferableDataHelper aHelper( rEvt.maDropEvent.Transferable ); 272*cdf0e10cSrcweir sal_uInt32 nFormatCount = aHelper.GetFormatCount(); 273*cdf0e10cSrcweir if ( pDocShell ) 274*cdf0e10cSrcweir { 275*cdf0e10cSrcweir sal_Bool bFormatFound = sal_False; 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir for ( sal_uInt32 i = 0; i < nFormatCount; ++i ) 278*cdf0e10cSrcweir { 279*cdf0e10cSrcweir SotFormatStringId nId = aHelper.GetFormat(i); 280*cdf0e10cSrcweir TransferableObjectDescriptor aDesc; 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir if ( aHelper.GetTransferableObjectDescriptor( nId, aDesc ) ) 283*cdf0e10cSrcweir { 284*cdf0e10cSrcweir if ( aDesc.maClassName == pDocShell->GetFactory().GetClassId() ) 285*cdf0e10cSrcweir { 286*cdf0e10cSrcweir PostUserEvent( LINK( this, DropListBox_Impl, OnAsyncExecuteDrop ), 0 ); 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir bFormatFound = sal_True; 289*cdf0e10cSrcweir nRet = rEvt.mnAction; 290*cdf0e10cSrcweir break; 291*cdf0e10cSrcweir } 292*cdf0e10cSrcweir } 293*cdf0e10cSrcweir } 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir if ( !bFormatFound ) 296*cdf0e10cSrcweir return SvTreeListBox::ExecuteDrop( rEvt ); 297*cdf0e10cSrcweir } 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir return nRet; 300*cdf0e10cSrcweir } 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir IMPL_LINK( DropListBox_Impl, OnAsyncExecuteDrop, SvLBoxEntry*, EMPTYARG ) 304*cdf0e10cSrcweir { 305*cdf0e10cSrcweir pDialog->ActionSelect( SID_STYLE_NEW_BY_EXAMPLE ); 306*cdf0e10cSrcweir return 0; 307*cdf0e10cSrcweir } 308*cdf0e10cSrcweir 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir IMPL_LINK( DropListBox_Impl, OnAsyncExecuteError, void*, NOTINTERESTEDIN ) 311*cdf0e10cSrcweir { 312*cdf0e10cSrcweir (void)NOTINTERESTEDIN; // unused 313*cdf0e10cSrcweir ErrorHandler::HandleError( ERRCODE_IO_WRONGFORMAT ); 314*cdf0e10cSrcweir 315*cdf0e10cSrcweir return 0; 316*cdf0e10cSrcweir } 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir long DropListBox_Impl::Notify( NotifyEvent& rNEvt ) 320*cdf0e10cSrcweir { 321*cdf0e10cSrcweir long nRet = 0; 322*cdf0e10cSrcweir if( rNEvt.GetType() == EVENT_KEYINPUT ) 323*cdf0e10cSrcweir { 324*cdf0e10cSrcweir const KeyCode& rKeyCode = rNEvt.GetKeyEvent()->GetKeyCode(); 325*cdf0e10cSrcweir if(!rKeyCode.GetModifier()) 326*cdf0e10cSrcweir { 327*cdf0e10cSrcweir if( pDialog->bCanDel && KEY_DELETE == rKeyCode.GetCode()) 328*cdf0e10cSrcweir { 329*cdf0e10cSrcweir pDialog->DeleteHdl( NULL ); 330*cdf0e10cSrcweir nRet = 1; 331*cdf0e10cSrcweir } 332*cdf0e10cSrcweir else if( KEY_RETURN == rKeyCode.GetCode()) 333*cdf0e10cSrcweir { 334*cdf0e10cSrcweir GetDoubleClickHdl().Call(this); 335*cdf0e10cSrcweir nRet = 1; 336*cdf0e10cSrcweir } 337*cdf0e10cSrcweir } 338*cdf0e10cSrcweir } 339*cdf0e10cSrcweir if(!nRet) 340*cdf0e10cSrcweir nRet = SvTreeListBox::Notify( rNEvt ); 341*cdf0e10cSrcweir return nRet; 342*cdf0e10cSrcweir } 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir 345*cdf0e10cSrcweir //------------------------------------------------------------------------- 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir SfxActionListBox::SfxActionListBox 349*cdf0e10cSrcweir ( 350*cdf0e10cSrcweir SfxCommonTemplateDialog_Impl* pParent, 351*cdf0e10cSrcweir WinBits nWinBits 352*cdf0e10cSrcweir ) 353*cdf0e10cSrcweir 354*cdf0e10cSrcweir /* [Beschreibung] 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir ListBox- Klasse, die im Command-Handler ein PopupMenu (Gestalter 357*cdf0e10cSrcweir spezifisch) startet. 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir */ 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir : DropListBox_Impl(pParent->GetWindow(), nWinBits, pParent) 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir { 364*cdf0e10cSrcweir EnableContextMenuHandling(); 365*cdf0e10cSrcweir } 366*cdf0e10cSrcweir 367*cdf0e10cSrcweir //------------------------------------------------------------------------- 368*cdf0e10cSrcweir 369*cdf0e10cSrcweir SfxActionListBox::SfxActionListBox( SfxCommonTemplateDialog_Impl* pParent, 370*cdf0e10cSrcweir const ResId &rResId) : 371*cdf0e10cSrcweir DropListBox_Impl(pParent->GetWindow(), rResId, pParent) 372*cdf0e10cSrcweir { 373*cdf0e10cSrcweir EnableContextMenuHandling(); 374*cdf0e10cSrcweir } 375*cdf0e10cSrcweir 376*cdf0e10cSrcweir //------------------------------------------------------------------------- 377*cdf0e10cSrcweir 378*cdf0e10cSrcweir PopupMenu* SfxActionListBox::CreateContextMenu( void ) 379*cdf0e10cSrcweir { 380*cdf0e10cSrcweir //added by BerryJia for fixing Bug102739 2002-9-9 17:00(Beijing Time) 381*cdf0e10cSrcweir if( !( GetSelectionCount() > 0 ) ) 382*cdf0e10cSrcweir { 383*cdf0e10cSrcweir pDialog->EnableEdit( sal_False ); 384*cdf0e10cSrcweir pDialog->EnableDel( sal_False ); 385*cdf0e10cSrcweir } 386*cdf0e10cSrcweir return pDialog->CreateContextMenu(); 387*cdf0e10cSrcweir } 388*cdf0e10cSrcweir 389*cdf0e10cSrcweir //------------------------------------------------------------------------- 390*cdf0e10cSrcweir 391*cdf0e10cSrcweir SfxTemplateDialogWrapper::SfxTemplateDialogWrapper(Window *pParentWnd, 392*cdf0e10cSrcweir sal_uInt16 nId, SfxBindings *p, SfxChildWinInfo *pInfo) : 393*cdf0e10cSrcweir SfxChildWindow(pParentWnd, nId) 394*cdf0e10cSrcweir { 395*cdf0e10cSrcweir SfxTemplateDialog *pWin = new SfxTemplateDialog(p, this, pParentWnd); 396*cdf0e10cSrcweir pWindow = pWin; 397*cdf0e10cSrcweir eChildAlignment = SFX_ALIGN_NOALIGNMENT; 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir pWin->Initialize( pInfo ); 400*cdf0e10cSrcweir pWin->SetMinOutputSizePixel(pWin->pImpl->GetMinOutputSizePixel()); 401*cdf0e10cSrcweir } 402*cdf0e10cSrcweir 403*cdf0e10cSrcweir void SfxTemplateDialogWrapper::SetParagraphFamily() 404*cdf0e10cSrcweir { 405*cdf0e10cSrcweir // forward to SfxTemplateDialog, because SfxTemplateDialog isn't exported 406*cdf0e10cSrcweir static_cast< SfxTemplateDialog* >( GetWindow() )->SetParagraphFamily(); 407*cdf0e10cSrcweir } 408*cdf0e10cSrcweir 409*cdf0e10cSrcweir //========================================================================= 410*cdf0e10cSrcweir SV_DECL_PTRARR_DEL(ExpandedEntries, StringPtr,16,8) 411*cdf0e10cSrcweir SV_IMPL_PTRARR(ExpandedEntries, StringPtr) 412*cdf0e10cSrcweir 413*cdf0e10cSrcweir /* [Beschreibung] 414*cdf0e10cSrcweir 415*cdf0e10cSrcweir TreeListBox- Klasse f"ur die Anzeige der hierarchischen View 416*cdf0e10cSrcweir der Vorlagen 417*cdf0e10cSrcweir 418*cdf0e10cSrcweir */ 419*cdf0e10cSrcweir 420*cdf0e10cSrcweir class StyleTreeListBox_Impl : public DropListBox_Impl 421*cdf0e10cSrcweir { 422*cdf0e10cSrcweir private: 423*cdf0e10cSrcweir SvLBoxEntry* pCurEntry; 424*cdf0e10cSrcweir SfxCommonTemplateDialog_Impl* pCommon; 425*cdf0e10cSrcweir Link aDoubleClickLink; 426*cdf0e10cSrcweir Link aDropLink; 427*cdf0e10cSrcweir String aParent; 428*cdf0e10cSrcweir String aStyle; 429*cdf0e10cSrcweir 430*cdf0e10cSrcweir protected: 431*cdf0e10cSrcweir virtual void Command( const CommandEvent& rMEvt ); 432*cdf0e10cSrcweir virtual long Notify( NotifyEvent& rNEvt ); 433*cdf0e10cSrcweir virtual sal_Bool DoubleClickHdl(); 434*cdf0e10cSrcweir virtual long ExpandingHdl(); 435*cdf0e10cSrcweir virtual void ExpandedHdl(); 436*cdf0e10cSrcweir virtual sal_Bool NotifyMoving(SvLBoxEntry* pTarget, 437*cdf0e10cSrcweir SvLBoxEntry* pEntry, 438*cdf0e10cSrcweir SvLBoxEntry*& rpNewParent, 439*cdf0e10cSrcweir sal_uIntPtr& rNewChildPos); 440*cdf0e10cSrcweir public: 441*cdf0e10cSrcweir StyleTreeListBox_Impl( SfxCommonTemplateDialog_Impl* pParent, WinBits nWinStyle = 0); 442*cdf0e10cSrcweir 443*cdf0e10cSrcweir void SetDoubleClickHdl(const Link &rLink) { aDoubleClickLink = rLink; } 444*cdf0e10cSrcweir void SetDropHdl(const Link &rLink) { aDropLink = rLink; } 445*cdf0e10cSrcweir using SvLBox::GetParent; 446*cdf0e10cSrcweir const String& GetParent() const { return aParent; } 447*cdf0e10cSrcweir const String& GetStyle() const { return aStyle; } 448*cdf0e10cSrcweir void MakeExpanded_Impl(ExpandedEntries& rEntries) const; 449*cdf0e10cSrcweir 450*cdf0e10cSrcweir virtual PopupMenu* CreateContextMenu( void ); 451*cdf0e10cSrcweir }; 452*cdf0e10cSrcweir 453*cdf0e10cSrcweir //------------------------------------------------------------------------- 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir 456*cdf0e10cSrcweir void StyleTreeListBox_Impl::MakeExpanded_Impl(ExpandedEntries& rEntries) const 457*cdf0e10cSrcweir { 458*cdf0e10cSrcweir SvLBoxEntry *pEntry; 459*cdf0e10cSrcweir sal_uInt16 nCount=0; 460*cdf0e10cSrcweir for(pEntry=(SvLBoxEntry*)FirstVisible();pEntry;pEntry=(SvLBoxEntry*)NextVisible(pEntry)) 461*cdf0e10cSrcweir { 462*cdf0e10cSrcweir if(IsExpanded(pEntry)) 463*cdf0e10cSrcweir { 464*cdf0e10cSrcweir StringPtr pString=new String(GetEntryText(pEntry)); 465*cdf0e10cSrcweir rEntries.Insert(pString,nCount++); 466*cdf0e10cSrcweir } 467*cdf0e10cSrcweir } 468*cdf0e10cSrcweir } 469*cdf0e10cSrcweir 470*cdf0e10cSrcweir PopupMenu* StyleTreeListBox_Impl::CreateContextMenu() 471*cdf0e10cSrcweir { 472*cdf0e10cSrcweir return pDialog->CreateContextMenu(); 473*cdf0e10cSrcweir } 474*cdf0e10cSrcweir 475*cdf0e10cSrcweir sal_Bool StyleTreeListBox_Impl::DoubleClickHdl() 476*cdf0e10cSrcweir 477*cdf0e10cSrcweir /* [Beschreibung] 478*cdf0e10cSrcweir 479*cdf0e10cSrcweir 480*cdf0e10cSrcweir DoubleClick-Handler; ruft entsprechenden Link. 481*cdf0e10cSrcweir Virtuelle Methode aus SV. 482*cdf0e10cSrcweir 483*cdf0e10cSrcweir */ 484*cdf0e10cSrcweir { 485*cdf0e10cSrcweir aDoubleClickLink.Call(this); 486*cdf0e10cSrcweir return sal_False; 487*cdf0e10cSrcweir } 488*cdf0e10cSrcweir 489*cdf0e10cSrcweir //------------------------------------------------------------------------- 490*cdf0e10cSrcweir 491*cdf0e10cSrcweir void StyleTreeListBox_Impl::Command( const CommandEvent& rCEvt ) 492*cdf0e10cSrcweir 493*cdf0e10cSrcweir /* [Beschreibung] 494*cdf0e10cSrcweir 495*cdf0e10cSrcweir Command Handler; dieser executed ein PopupMenu (Gestalter 496*cdf0e10cSrcweir spezifisch). 497*cdf0e10cSrcweir Virtuelle Methode aus SV. 498*cdf0e10cSrcweir 499*cdf0e10cSrcweir */ 500*cdf0e10cSrcweir { 501*cdf0e10cSrcweir SvTreeListBox::Command(rCEvt); 502*cdf0e10cSrcweir } 503*cdf0e10cSrcweir 504*cdf0e10cSrcweir //------------------------------------------------------------------------- 505*cdf0e10cSrcweir 506*cdf0e10cSrcweir long StyleTreeListBox_Impl::Notify( NotifyEvent& rNEvt ) 507*cdf0e10cSrcweir { 508*cdf0e10cSrcweir // handle <RETURN> as double click 509*cdf0e10cSrcweir 510*cdf0e10cSrcweir long nRet = 0; 511*cdf0e10cSrcweir if ( rNEvt.GetType() == EVENT_KEYINPUT ) 512*cdf0e10cSrcweir { 513*cdf0e10cSrcweir const KeyCode& rKeyCode = rNEvt.GetKeyEvent()->GetKeyCode(); 514*cdf0e10cSrcweir if ( !rKeyCode.GetModifier() && KEY_RETURN == rKeyCode.GetCode() ) 515*cdf0e10cSrcweir { 516*cdf0e10cSrcweir aDoubleClickLink.Call( this ); 517*cdf0e10cSrcweir nRet = 1; 518*cdf0e10cSrcweir } 519*cdf0e10cSrcweir } 520*cdf0e10cSrcweir 521*cdf0e10cSrcweir if ( !nRet ) 522*cdf0e10cSrcweir nRet = DropListBox_Impl::Notify( rNEvt ); 523*cdf0e10cSrcweir 524*cdf0e10cSrcweir return nRet; 525*cdf0e10cSrcweir } 526*cdf0e10cSrcweir 527*cdf0e10cSrcweir //------------------------------------------------------------------------- 528*cdf0e10cSrcweir 529*cdf0e10cSrcweir sal_Bool StyleTreeListBox_Impl::NotifyMoving(SvLBoxEntry* pTarget, 530*cdf0e10cSrcweir SvLBoxEntry* pEntry, 531*cdf0e10cSrcweir SvLBoxEntry*& rpNewParent, 532*cdf0e10cSrcweir sal_uIntPtr& lPos) 533*cdf0e10cSrcweir /* [Beschreibung] 534*cdf0e10cSrcweir 535*cdf0e10cSrcweir NotifyMoving Handler; dieser leitet per Link das Event an den Dialog 536*cdf0e10cSrcweir weiter. 537*cdf0e10cSrcweir Virtuelle Methode aus SV. 538*cdf0e10cSrcweir 539*cdf0e10cSrcweir */ 540*cdf0e10cSrcweir { 541*cdf0e10cSrcweir if(!pTarget || !pEntry) 542*cdf0e10cSrcweir return sal_False; 543*cdf0e10cSrcweir aParent = GetEntryText(pTarget); 544*cdf0e10cSrcweir aStyle = GetEntryText(pEntry); 545*cdf0e10cSrcweir const sal_Bool bRet = (sal_Bool)aDropLink.Call(this); 546*cdf0e10cSrcweir rpNewParent = pTarget; 547*cdf0e10cSrcweir lPos=0; 548*cdf0e10cSrcweir IntlWrapper aIntlWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() ); 549*cdf0e10cSrcweir const CollatorWrapper* pCollator = aIntlWrapper.getCaseCollator(); 550*cdf0e10cSrcweir for(SvLBoxEntry *pTmpEntry=FirstChild(pTarget); 551*cdf0e10cSrcweir pTmpEntry && COMPARE_LESS==pCollator->compareString( 552*cdf0e10cSrcweir GetEntryText(pTmpEntry),GetEntryText(pEntry)); 553*cdf0e10cSrcweir pTmpEntry=NextSibling(pTmpEntry),lPos++) ; 554*cdf0e10cSrcweir 555*cdf0e10cSrcweir return bRet? (sal_Bool)2: sal_False; 556*cdf0e10cSrcweir } 557*cdf0e10cSrcweir 558*cdf0e10cSrcweir //------------------------------------------------------------------------- 559*cdf0e10cSrcweir 560*cdf0e10cSrcweir long StyleTreeListBox_Impl::ExpandingHdl() 561*cdf0e10cSrcweir 562*cdf0e10cSrcweir /* [Beschreibung] 563*cdf0e10cSrcweir 564*cdf0e10cSrcweir ExpandingHdl Handler; der aktuelle Eintrag wird gemerkt. 565*cdf0e10cSrcweir Virtuelle Methode aus SV. 566*cdf0e10cSrcweir 567*cdf0e10cSrcweir [Querverweise] 568*cdf0e10cSrcweir <StyleTreeListBox_Impl::ExpandedHdl()> 569*cdf0e10cSrcweir 570*cdf0e10cSrcweir */ 571*cdf0e10cSrcweir { 572*cdf0e10cSrcweir pCurEntry = GetCurEntry(); 573*cdf0e10cSrcweir return sal_True; 574*cdf0e10cSrcweir } 575*cdf0e10cSrcweir 576*cdf0e10cSrcweir //------------------------------------------------------------------------- 577*cdf0e10cSrcweir 578*cdf0e10cSrcweir void StyleTreeListBox_Impl::ExpandedHdl() 579*cdf0e10cSrcweir 580*cdf0e10cSrcweir /* [Beschreibung] 581*cdf0e10cSrcweir 582*cdf0e10cSrcweir ExpandedHdl Handler; 583*cdf0e10cSrcweir Virtuelle Methode aus SV. 584*cdf0e10cSrcweir 585*cdf0e10cSrcweir [Querverweise] 586*cdf0e10cSrcweir <StyleTreeListBox_Impl::ExpandingHdl()> 587*cdf0e10cSrcweir 588*cdf0e10cSrcweir */ 589*cdf0e10cSrcweir 590*cdf0e10cSrcweir { 591*cdf0e10cSrcweir SvLBoxEntry *pEntry = GetHdlEntry(); 592*cdf0e10cSrcweir if(!IsExpanded(pEntry) && pCurEntry != GetCurEntry()) 593*cdf0e10cSrcweir SelectAll( sal_False ); 594*cdf0e10cSrcweir pCurEntry = 0; 595*cdf0e10cSrcweir } 596*cdf0e10cSrcweir 597*cdf0e10cSrcweir //------------------------------------------------------------------------- 598*cdf0e10cSrcweir 599*cdf0e10cSrcweir StyleTreeListBox_Impl::StyleTreeListBox_Impl( 600*cdf0e10cSrcweir SfxCommonTemplateDialog_Impl* pParent, WinBits nWinStyle) : 601*cdf0e10cSrcweir DropListBox_Impl(pParent->GetWindow(), nWinStyle, pParent), 602*cdf0e10cSrcweir pCurEntry(0), 603*cdf0e10cSrcweir pCommon(pParent) 604*cdf0e10cSrcweir 605*cdf0e10cSrcweir /* [Beschreibung] 606*cdf0e10cSrcweir 607*cdf0e10cSrcweir Konstruktor StyleTreeListBox_Impl 608*cdf0e10cSrcweir 609*cdf0e10cSrcweir */ 610*cdf0e10cSrcweir { 611*cdf0e10cSrcweir EnableContextMenuHandling(); 612*cdf0e10cSrcweir } 613*cdf0e10cSrcweir 614*cdf0e10cSrcweir //------------------------------------------------------------------------- 615*cdf0e10cSrcweir //------------------------------------------------------------------------- 616*cdf0e10cSrcweir 617*cdf0e10cSrcweir class StyleTreeArr_Impl; 618*cdf0e10cSrcweir 619*cdf0e10cSrcweir 620*cdf0e10cSrcweir /* [Beschreibung] 621*cdf0e10cSrcweir 622*cdf0e10cSrcweir Interne Struktur f"ur den Aufbau der hierarchischen View 623*cdf0e10cSrcweir 624*cdf0e10cSrcweir */ 625*cdf0e10cSrcweir 626*cdf0e10cSrcweir struct StyleTree_Impl 627*cdf0e10cSrcweir { 628*cdf0e10cSrcweir String aName; 629*cdf0e10cSrcweir String aParent; 630*cdf0e10cSrcweir StyleTreeArr_Impl *pChilds; 631*cdf0e10cSrcweir sal_Bool bIsExpanded; 632*cdf0e10cSrcweir sal_Bool HasParent() const { return aParent.Len() != 0; } 633*cdf0e10cSrcweir 634*cdf0e10cSrcweir StyleTree_Impl(const String &rName, const String &rParent): 635*cdf0e10cSrcweir aName(rName), aParent(rParent), pChilds(0), bIsExpanded(0) {} 636*cdf0e10cSrcweir ~StyleTree_Impl(); 637*cdf0e10cSrcweir void Put(StyleTree_Impl* pIns, sal_uIntPtr lPos=ULONG_MAX); 638*cdf0e10cSrcweir sal_uIntPtr Count(); 639*cdf0e10cSrcweir }; 640*cdf0e10cSrcweir 641*cdf0e10cSrcweir typedef StyleTree_Impl* StyleTree_ImplPtr; 642*cdf0e10cSrcweir SV_DECL_PTRARR_DEL(StyleTreeArr_Impl, StyleTree_ImplPtr, 16, 8) 643*cdf0e10cSrcweir SV_IMPL_PTRARR(StyleTreeArr_Impl, StyleTree_ImplPtr) 644*cdf0e10cSrcweir 645*cdf0e10cSrcweir 646*cdf0e10cSrcweir sal_uIntPtr StyleTree_Impl::Count() 647*cdf0e10cSrcweir { 648*cdf0e10cSrcweir return pChilds ? pChilds->Count() : 0L; 649*cdf0e10cSrcweir } 650*cdf0e10cSrcweir 651*cdf0e10cSrcweir //------------------------------------------------------------------------- 652*cdf0e10cSrcweir 653*cdf0e10cSrcweir StyleTree_Impl::~StyleTree_Impl() 654*cdf0e10cSrcweir { 655*cdf0e10cSrcweir delete pChilds; 656*cdf0e10cSrcweir } 657*cdf0e10cSrcweir 658*cdf0e10cSrcweir //------------------------------------------------------------------------- 659*cdf0e10cSrcweir 660*cdf0e10cSrcweir void StyleTree_Impl::Put(StyleTree_Impl* pIns, sal_uIntPtr lPos) 661*cdf0e10cSrcweir { 662*cdf0e10cSrcweir if ( !pChilds ) 663*cdf0e10cSrcweir pChilds = new StyleTreeArr_Impl; 664*cdf0e10cSrcweir 665*cdf0e10cSrcweir if ( ULONG_MAX == lPos ) 666*cdf0e10cSrcweir lPos = pChilds->Count(); 667*cdf0e10cSrcweir pChilds->Insert( pIns, (sal_uInt16)lPos ); 668*cdf0e10cSrcweir } 669*cdf0e10cSrcweir 670*cdf0e10cSrcweir //------------------------------------------------------------------------- 671*cdf0e10cSrcweir 672*cdf0e10cSrcweir StyleTreeArr_Impl &MakeTree_Impl(StyleTreeArr_Impl &rArr) 673*cdf0e10cSrcweir { 674*cdf0e10cSrcweir const sal_uInt16 nCount = rArr.Count(); 675*cdf0e10cSrcweir // Alle unter ihren Parents einordnen 676*cdf0e10cSrcweir sal_uInt16 i; 677*cdf0e10cSrcweir for(i = 0; i < nCount; ++i) 678*cdf0e10cSrcweir { 679*cdf0e10cSrcweir StyleTree_ImplPtr pEntry = rArr[i]; 680*cdf0e10cSrcweir if(pEntry->HasParent()) 681*cdf0e10cSrcweir { 682*cdf0e10cSrcweir for(sal_uInt16 j = 0; j < nCount; ++j) 683*cdf0e10cSrcweir { 684*cdf0e10cSrcweir StyleTree_ImplPtr pCmp = rArr[j]; 685*cdf0e10cSrcweir if(pCmp->aName == pEntry->aParent) 686*cdf0e10cSrcweir { 687*cdf0e10cSrcweir // initial sortiert einfuegen 688*cdf0e10cSrcweir sal_uInt16 ii; 689*cdf0e10cSrcweir IntlWrapper aIntlWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() ); 690*cdf0e10cSrcweir const CollatorWrapper* pCollator = aIntlWrapper.getCaseCollator(); 691*cdf0e10cSrcweir for ( ii = 0; 692*cdf0e10cSrcweir ii < pCmp->Count() && COMPARE_LESS == 693*cdf0e10cSrcweir pCollator->compareString( (*pCmp->pChilds)[ii]->aName, 694*cdf0e10cSrcweir pEntry->aName);++ii) ; 695*cdf0e10cSrcweir pCmp->Put(pEntry,ii); 696*cdf0e10cSrcweir break; 697*cdf0e10cSrcweir } 698*cdf0e10cSrcweir } 699*cdf0e10cSrcweir } 700*cdf0e10cSrcweir } 701*cdf0e10cSrcweir // alle, die schon unter ihrem Parent eingeordnet wurden 702*cdf0e10cSrcweir // entfernen 703*cdf0e10cSrcweir for(i = 0; i < rArr.Count(); ) 704*cdf0e10cSrcweir { 705*cdf0e10cSrcweir if(rArr[i]->HasParent()) 706*cdf0e10cSrcweir rArr.Remove(i); 707*cdf0e10cSrcweir else 708*cdf0e10cSrcweir ++i; 709*cdf0e10cSrcweir } 710*cdf0e10cSrcweir return rArr; 711*cdf0e10cSrcweir } 712*cdf0e10cSrcweir 713*cdf0e10cSrcweir //------------------------------------------------------------------------- 714*cdf0e10cSrcweir 715*cdf0e10cSrcweir 716*cdf0e10cSrcweir inline sal_Bool IsExpanded_Impl( const ExpandedEntries& rEntries, 717*cdf0e10cSrcweir const String &rStr) 718*cdf0e10cSrcweir { 719*cdf0e10cSrcweir sal_uInt16 nCount=rEntries.Count(); 720*cdf0e10cSrcweir for(sal_uInt16 n=0;n<nCount;n++) 721*cdf0e10cSrcweir if(*rEntries[n]==rStr) 722*cdf0e10cSrcweir return sal_True; 723*cdf0e10cSrcweir return sal_False; 724*cdf0e10cSrcweir } 725*cdf0e10cSrcweir 726*cdf0e10cSrcweir 727*cdf0e10cSrcweir 728*cdf0e10cSrcweir SvLBoxEntry* FillBox_Impl(SvTreeListBox *pBox, 729*cdf0e10cSrcweir StyleTree_ImplPtr pEntry, 730*cdf0e10cSrcweir const ExpandedEntries& rEntries, 731*cdf0e10cSrcweir SvLBoxEntry* pParent = 0) 732*cdf0e10cSrcweir { 733*cdf0e10cSrcweir SvLBoxEntry* pNewEntry = pBox->InsertEntry(pEntry->aName, pParent); 734*cdf0e10cSrcweir const sal_uInt16 nCount = pEntry->pChilds? pEntry->pChilds->Count(): 0; 735*cdf0e10cSrcweir for(sal_uInt16 i = 0; i < nCount; ++i) 736*cdf0e10cSrcweir FillBox_Impl(pBox, (*pEntry->pChilds)[i], rEntries, pNewEntry); 737*cdf0e10cSrcweir return pNewEntry; 738*cdf0e10cSrcweir } 739*cdf0e10cSrcweir 740*cdf0e10cSrcweir //------------------------------------------------------------------------- 741*cdf0e10cSrcweir 742*cdf0e10cSrcweir // Konstruktor 743*cdf0e10cSrcweir 744*cdf0e10cSrcweir SfxCommonTemplateDialog_Impl::SfxCommonTemplateDialog_Impl( SfxBindings* pB, SfxDockingWindow* pW ) : 745*cdf0e10cSrcweir 746*cdf0e10cSrcweir aISfxTemplateCommon ( this ), 747*cdf0e10cSrcweir pBindings ( pB ), 748*cdf0e10cSrcweir pWindow ( pW ), 749*cdf0e10cSrcweir pModule ( NULL ), 750*cdf0e10cSrcweir pTimer ( NULL ), 751*cdf0e10cSrcweir m_pStyleFamiliesId ( NULL ), 752*cdf0e10cSrcweir pStyleSheetPool ( NULL ), 753*cdf0e10cSrcweir pTreeBox ( NULL ), 754*cdf0e10cSrcweir pCurObjShell ( NULL ), 755*cdf0e10cSrcweir xModuleManager ( ::comphelper::getProcessServiceFactory()->createInstance( 756*cdf0e10cSrcweir DEFINE_CONST_UNICODE("com.sun.star.frame.ModuleManager") ), UNO_QUERY ), 757*cdf0e10cSrcweir pbDeleted ( NULL ), 758*cdf0e10cSrcweir 759*cdf0e10cSrcweir aFmtLb ( this, WB_BORDER | WB_TABSTOP | WB_SORT | WB_QUICK_SEARCH ), 760*cdf0e10cSrcweir aFilterLb ( pW, WB_BORDER | WB_DROPDOWN | WB_TABSTOP ), 761*cdf0e10cSrcweir 762*cdf0e10cSrcweir nActFamily ( 0xffff ), 763*cdf0e10cSrcweir nActFilter ( 0 ), 764*cdf0e10cSrcweir nAppFilter ( 0 ), 765*cdf0e10cSrcweir 766*cdf0e10cSrcweir bDontUpdate ( sal_False ), 767*cdf0e10cSrcweir bIsWater ( sal_False ), 768*cdf0e10cSrcweir bEnabled ( sal_True ), 769*cdf0e10cSrcweir bUpdate ( sal_False ), 770*cdf0e10cSrcweir bUpdateFamily ( sal_False ), 771*cdf0e10cSrcweir bCanEdit ( sal_False ), 772*cdf0e10cSrcweir bCanDel ( sal_False ), 773*cdf0e10cSrcweir bCanNew ( sal_True ), 774*cdf0e10cSrcweir bWaterDisabled ( sal_False ), 775*cdf0e10cSrcweir bNewByExampleDisabled ( sal_False ), 776*cdf0e10cSrcweir bUpdateByExampleDisabled( sal_False ), 777*cdf0e10cSrcweir bTreeDrag ( sal_True ), 778*cdf0e10cSrcweir bHierarchical ( sal_False ), 779*cdf0e10cSrcweir bBindingUpdate ( sal_True ) 780*cdf0e10cSrcweir { 781*cdf0e10cSrcweir aFmtLb.SetAccessibleName(SfxResId(STR_STYLE_ELEMTLIST)); 782*cdf0e10cSrcweir aFmtLb.SetHelpId( HID_TEMPLATE_FMT ); 783*cdf0e10cSrcweir aFilterLb.SetHelpId( HID_TEMPLATE_FILTER ); 784*cdf0e10cSrcweir aFmtLb.SetStyle( aFmtLb.GetStyle() | WB_SORT | WB_HIDESELECTION ); 785*cdf0e10cSrcweir Font aFont = aFmtLb.GetFont(); 786*cdf0e10cSrcweir aFont.SetWeight( WEIGHT_NORMAL ); 787*cdf0e10cSrcweir aFmtLb.SetFont( aFont ); 788*cdf0e10cSrcweir } 789*cdf0e10cSrcweir 790*cdf0e10cSrcweir //------------------------------------------------------------------------- 791*cdf0e10cSrcweir 792*cdf0e10cSrcweir SfxCommonTemplateDialog_Impl::SfxCommonTemplateDialog_Impl( SfxBindings* pB, ModalDialog* pW ) : 793*cdf0e10cSrcweir 794*cdf0e10cSrcweir aISfxTemplateCommon ( this ), 795*cdf0e10cSrcweir pBindings ( pB ), 796*cdf0e10cSrcweir pWindow ( pW ), 797*cdf0e10cSrcweir pModule ( NULL ), 798*cdf0e10cSrcweir pTimer ( NULL ), 799*cdf0e10cSrcweir pStyleSheetPool ( NULL ), 800*cdf0e10cSrcweir pTreeBox ( NULL ), 801*cdf0e10cSrcweir pCurObjShell ( NULL ), 802*cdf0e10cSrcweir pbDeleted ( NULL ), 803*cdf0e10cSrcweir 804*cdf0e10cSrcweir aFmtLb ( this, SfxResId( BT_VLIST ) ), 805*cdf0e10cSrcweir aFilterLb ( pW, SfxResId( BT_FLIST ) ), 806*cdf0e10cSrcweir 807*cdf0e10cSrcweir nActFamily ( 0xffff ), 808*cdf0e10cSrcweir nActFilter ( 0 ), 809*cdf0e10cSrcweir nAppFilter ( 0 ), 810*cdf0e10cSrcweir 811*cdf0e10cSrcweir bDontUpdate ( sal_False ), 812*cdf0e10cSrcweir bIsWater ( sal_False ), 813*cdf0e10cSrcweir bEnabled ( sal_True ), 814*cdf0e10cSrcweir bUpdate ( sal_False ), 815*cdf0e10cSrcweir bUpdateFamily ( sal_False ), 816*cdf0e10cSrcweir bCanEdit ( sal_False ), 817*cdf0e10cSrcweir bCanDel ( sal_False ), 818*cdf0e10cSrcweir bCanNew ( sal_True ), 819*cdf0e10cSrcweir bWaterDisabled ( sal_False ), 820*cdf0e10cSrcweir bNewByExampleDisabled ( sal_False ), 821*cdf0e10cSrcweir bUpdateByExampleDisabled( sal_False ), 822*cdf0e10cSrcweir bTreeDrag ( sal_True ), 823*cdf0e10cSrcweir bHierarchical ( sal_False ), 824*cdf0e10cSrcweir bBindingUpdate ( sal_True ) 825*cdf0e10cSrcweir 826*cdf0e10cSrcweir { 827*cdf0e10cSrcweir aFmtLb.SetStyle( aFmtLb.GetStyle() | WB_SORT ); 828*cdf0e10cSrcweir } 829*cdf0e10cSrcweir 830*cdf0e10cSrcweir //------------------------------------------------------------------------- 831*cdf0e10cSrcweir 832*cdf0e10cSrcweir sal_uInt16 SfxCommonTemplateDialog_Impl::StyleNrToInfoOffset(sal_uInt16 nId) 833*cdf0e10cSrcweir { 834*cdf0e10cSrcweir const SfxStyleFamilyItem *pItem=pStyleFamilies->GetObject(nId); 835*cdf0e10cSrcweir return SfxFamilyIdToNId(pItem->GetFamily())-1; 836*cdf0e10cSrcweir } 837*cdf0e10cSrcweir 838*cdf0e10cSrcweir //------------------------------------------------------------------------- 839*cdf0e10cSrcweir 840*cdf0e10cSrcweir void SfxTemplateDialog_Impl::EnableEdit(sal_Bool bEnable) 841*cdf0e10cSrcweir { 842*cdf0e10cSrcweir SfxCommonTemplateDialog_Impl::EnableEdit( bEnable ); 843*cdf0e10cSrcweir if( !bEnable || !bUpdateByExampleDisabled ) 844*cdf0e10cSrcweir EnableItem( SID_STYLE_UPDATE_BY_EXAMPLE, bEnable); 845*cdf0e10cSrcweir } 846*cdf0e10cSrcweir 847*cdf0e10cSrcweir //------------------------------------------------------------------------- 848*cdf0e10cSrcweir 849*cdf0e10cSrcweir 850*cdf0e10cSrcweir sal_uInt16 SfxCommonTemplateDialog_Impl::InfoOffsetToStyleNr(sal_uInt16 nId) 851*cdf0e10cSrcweir { 852*cdf0e10cSrcweir for ( sal_uInt16 i=0;i<pStyleFamilies->Count();i++ ) 853*cdf0e10cSrcweir if ( SfxFamilyIdToNId(pStyleFamilies->GetObject(i)->GetFamily()) == nId+1 ) 854*cdf0e10cSrcweir return i; 855*cdf0e10cSrcweir DBG_ERROR("Style Nummer nicht gefunden"); 856*cdf0e10cSrcweir return 0; 857*cdf0e10cSrcweir } 858*cdf0e10cSrcweir 859*cdf0e10cSrcweir 860*cdf0e10cSrcweir //------------------------------------------------------------------------- 861*cdf0e10cSrcweir 862*cdf0e10cSrcweir void SfxCommonTemplateDialog_Impl::ReadResource() 863*cdf0e10cSrcweir { 864*cdf0e10cSrcweir // globale Benutzer-Resource auslesen 865*cdf0e10cSrcweir sal_uInt16 i; 866*cdf0e10cSrcweir for(i = 0; i < MAX_FAMILIES; ++i) 867*cdf0e10cSrcweir pFamilyState[i] = 0; 868*cdf0e10cSrcweir 869*cdf0e10cSrcweir SfxViewFrame* pViewFrame = pBindings->GetDispatcher_Impl()->GetFrame(); 870*cdf0e10cSrcweir pCurObjShell = pViewFrame->GetObjectShell(); 871*cdf0e10cSrcweir ResMgr* pMgr = pCurObjShell ? pCurObjShell->GetResMgr() : NULL; 872*cdf0e10cSrcweir ResId aFamId( DLG_STYLE_DESIGNER, *pMgr ); 873*cdf0e10cSrcweir aFamId.SetRT(RSC_SFX_STYLE_FAMILIES); 874*cdf0e10cSrcweir m_pStyleFamiliesId = new ResId( aFamId.GetId(), *pMgr ); 875*cdf0e10cSrcweir m_pStyleFamiliesId->SetRT(RSC_SFX_STYLE_FAMILIES); 876*cdf0e10cSrcweir if( !pMgr || !pMgr->IsAvailable( aFamId ) ) 877*cdf0e10cSrcweir pStyleFamilies = new SfxStyleFamilies; 878*cdf0e10cSrcweir else 879*cdf0e10cSrcweir pStyleFamilies = new SfxStyleFamilies( aFamId ); 880*cdf0e10cSrcweir 881*cdf0e10cSrcweir nActFilter = pCurObjShell ? static_cast< sal_uInt16 >( LoadFactoryStyleFilter( pCurObjShell ) ) : 0xFFFF; 882*cdf0e10cSrcweir if ( pCurObjShell && 0xFFFF == nActFilter ) 883*cdf0e10cSrcweir nActFilter = pCurObjShell->GetAutoStyleFilterIndex(); 884*cdf0e10cSrcweir 885*cdf0e10cSrcweir // Einfuegen in die Toolbox 886*cdf0e10cSrcweir // umgekehrte Reihenfolge, da immer vorne eingefuegt wird. 887*cdf0e10cSrcweir sal_uInt16 nCount = pStyleFamilies->Count(); 888*cdf0e10cSrcweir 889*cdf0e10cSrcweir pBindings->ENTERREGISTRATIONS(); 890*cdf0e10cSrcweir 891*cdf0e10cSrcweir for(i = 0; i < nCount; ++i) 892*cdf0e10cSrcweir { 893*cdf0e10cSrcweir sal_uInt16 nSlot = 0; 894*cdf0e10cSrcweir switch((sal_uInt16)pStyleFamilies->GetObject(i)->GetFamily()) 895*cdf0e10cSrcweir { 896*cdf0e10cSrcweir case SFX_STYLE_FAMILY_CHAR: nSlot = SID_STYLE_FAMILY1; break; 897*cdf0e10cSrcweir case SFX_STYLE_FAMILY_PARA: nSlot = SID_STYLE_FAMILY2; break; 898*cdf0e10cSrcweir case SFX_STYLE_FAMILY_FRAME:nSlot = SID_STYLE_FAMILY3; break; 899*cdf0e10cSrcweir case SFX_STYLE_FAMILY_PAGE: nSlot = SID_STYLE_FAMILY4; break; 900*cdf0e10cSrcweir case SFX_STYLE_FAMILY_PSEUDO: nSlot = SID_STYLE_FAMILY5; break; 901*cdf0e10cSrcweir default: DBG_ERROR("unbekannte StyleFamily"); break; 902*cdf0e10cSrcweir } 903*cdf0e10cSrcweir pBoundItems[i] = 904*cdf0e10cSrcweir new SfxTemplateControllerItem(nSlot, *this, *pBindings); 905*cdf0e10cSrcweir } 906*cdf0e10cSrcweir pBoundItems[i++] = new SfxTemplateControllerItem( 907*cdf0e10cSrcweir SID_STYLE_WATERCAN, *this, *pBindings); 908*cdf0e10cSrcweir pBoundItems[i++] = new SfxTemplateControllerItem( 909*cdf0e10cSrcweir SID_STYLE_NEW_BY_EXAMPLE, *this, *pBindings); 910*cdf0e10cSrcweir pBoundItems[i++] = new SfxTemplateControllerItem( 911*cdf0e10cSrcweir SID_STYLE_UPDATE_BY_EXAMPLE, *this, *pBindings); 912*cdf0e10cSrcweir pBoundItems[i++] = new SfxTemplateControllerItem( 913*cdf0e10cSrcweir SID_STYLE_NEW, *this, *pBindings); 914*cdf0e10cSrcweir pBoundItems[i++] = new SfxTemplateControllerItem( 915*cdf0e10cSrcweir SID_STYLE_DRAGHIERARCHIE, *this, *pBindings); 916*cdf0e10cSrcweir pBoundItems[i++] = new SfxTemplateControllerItem( 917*cdf0e10cSrcweir SID_STYLE_EDIT, *this, *pBindings); 918*cdf0e10cSrcweir pBoundItems[i++] = new SfxTemplateControllerItem( 919*cdf0e10cSrcweir SID_STYLE_DELETE, *this, *pBindings); 920*cdf0e10cSrcweir pBoundItems[i++] = new SfxTemplateControllerItem( 921*cdf0e10cSrcweir SID_STYLE_FAMILY, *this, *pBindings); 922*cdf0e10cSrcweir pBindings->LEAVEREGISTRATIONS(); 923*cdf0e10cSrcweir 924*cdf0e10cSrcweir for(; i < COUNT_BOUND_FUNC; ++i) 925*cdf0e10cSrcweir pBoundItems[i] = 0; 926*cdf0e10cSrcweir 927*cdf0e10cSrcweir StartListening(*pBindings); 928*cdf0e10cSrcweir 929*cdf0e10cSrcweir //In umgekehrter Reihenfolge des Auftretens in den Stylefamilies einfuegen. 930*cdf0e10cSrcweir //Das ist fuer den Toolbar des Gestalters. Die Listbox des Kataloges achtet 931*cdf0e10cSrcweir //selbst auf korrekte Reihenfolge. 932*cdf0e10cSrcweir 933*cdf0e10cSrcweir //Reihenfolgen: Reihenfolge in der Resource = Reihenfolge in Toolbar bzw. 934*cdf0e10cSrcweir //Listbox. 935*cdf0e10cSrcweir //Reihenfolge aufsteigender SIDs: Niedrige SIDs werden als erstes angezeigt, 936*cdf0e10cSrcweir //wenn Vorlagen mehrerer Familien aktiv sind. 937*cdf0e10cSrcweir 938*cdf0e10cSrcweir // in the Writer the UpdateStyleByExample Toolbox button is removed and 939*cdf0e10cSrcweir // the NewStyle button gets a PopupMenu 940*cdf0e10cSrcweir if(nCount > 4) 941*cdf0e10cSrcweir ReplaceUpdateButtonByMenu(); 942*cdf0e10cSrcweir 943*cdf0e10cSrcweir for( ; nCount--; ) 944*cdf0e10cSrcweir { 945*cdf0e10cSrcweir const SfxStyleFamilyItem *pItem = pStyleFamilies->GetObject( nCount ); 946*cdf0e10cSrcweir sal_uInt16 nId = SfxFamilyIdToNId( pItem->GetFamily() ); 947*cdf0e10cSrcweir InsertFamilyItem( nId, pItem ); 948*cdf0e10cSrcweir } 949*cdf0e10cSrcweir 950*cdf0e10cSrcweir LoadedFamilies(); 951*cdf0e10cSrcweir 952*cdf0e10cSrcweir sal_uInt16 nStart = SID_STYLE_FAMILY1; 953*cdf0e10cSrcweir sal_uInt16 nEnd = SID_STYLE_FAMILY4; 954*cdf0e10cSrcweir 955*cdf0e10cSrcweir for ( i = nStart; i <= nEnd; i++ ) 956*cdf0e10cSrcweir pBindings->Update(i); 957*cdf0e10cSrcweir 958*cdf0e10cSrcweir pModule = pCurObjShell ? pCurObjShell->GetModule() : NULL; 959*cdf0e10cSrcweir } 960*cdf0e10cSrcweir 961*cdf0e10cSrcweir //------------------------------------------------------------------------- 962*cdf0e10cSrcweir 963*cdf0e10cSrcweir void SfxCommonTemplateDialog_Impl::ClearResource() 964*cdf0e10cSrcweir { 965*cdf0e10cSrcweir ClearFamilyList(); 966*cdf0e10cSrcweir DELETEX(pStyleFamilies); 967*cdf0e10cSrcweir sal_uInt16 i; 968*cdf0e10cSrcweir for ( i = 0; i < MAX_FAMILIES; ++i ) 969*cdf0e10cSrcweir DELETEX(pFamilyState[i]); 970*cdf0e10cSrcweir for ( i = 0; i < COUNT_BOUND_FUNC; ++i ) 971*cdf0e10cSrcweir delete pBoundItems[i]; 972*cdf0e10cSrcweir pCurObjShell = NULL; 973*cdf0e10cSrcweir 974*cdf0e10cSrcweir DELETEZ( m_pStyleFamiliesId ); 975*cdf0e10cSrcweir } 976*cdf0e10cSrcweir 977*cdf0e10cSrcweir //------------------------------------------------------------------------- 978*cdf0e10cSrcweir 979*cdf0e10cSrcweir void SfxCommonTemplateDialog_Impl::Initialize() 980*cdf0e10cSrcweir { 981*cdf0e10cSrcweir // globale Benutzer-Resource auslesen 982*cdf0e10cSrcweir ReadResource(); 983*cdf0e10cSrcweir pBindings->Invalidate( SID_STYLE_FAMILY ); 984*cdf0e10cSrcweir pBindings->Update( SID_STYLE_FAMILY ); 985*cdf0e10cSrcweir Update_Impl(); 986*cdf0e10cSrcweir 987*cdf0e10cSrcweir aFilterLb.SetSelectHdl( LINK( this, SfxCommonTemplateDialog_Impl, FilterSelectHdl ) ); 988*cdf0e10cSrcweir aFmtLb.SetDoubleClickHdl( LINK( this, SfxCommonTemplateDialog_Impl, ApplyHdl ) ); 989*cdf0e10cSrcweir aFmtLb.SetSelectHdl( LINK( this, SfxCommonTemplateDialog_Impl, FmtSelectHdl ) ); 990*cdf0e10cSrcweir 991*cdf0e10cSrcweir aFilterLb.Show(); 992*cdf0e10cSrcweir aFmtLb.Show(); 993*cdf0e10cSrcweir } 994*cdf0e10cSrcweir 995*cdf0e10cSrcweir //------------------------------------------------------------------------- 996*cdf0e10cSrcweir 997*cdf0e10cSrcweir SfxCommonTemplateDialog_Impl::~SfxCommonTemplateDialog_Impl() 998*cdf0e10cSrcweir { 999*cdf0e10cSrcweir String aEmpty; 1000*cdf0e10cSrcweir if ( bIsWater ) 1001*cdf0e10cSrcweir Execute_Impl(SID_STYLE_WATERCAN, aEmpty, aEmpty, 0); 1002*cdf0e10cSrcweir GetWindow()->Hide(); 1003*cdf0e10cSrcweir DELETEX(pStyleFamilies); 1004*cdf0e10cSrcweir DELETEZ( m_pStyleFamiliesId ); 1005*cdf0e10cSrcweir sal_uInt16 i; 1006*cdf0e10cSrcweir for ( i = 0; i < MAX_FAMILIES; ++i ) 1007*cdf0e10cSrcweir DELETEX(pFamilyState[i]); 1008*cdf0e10cSrcweir for ( i = 0; i < COUNT_BOUND_FUNC; ++i ) 1009*cdf0e10cSrcweir delete pBoundItems[i]; 1010*cdf0e10cSrcweir if ( pStyleSheetPool ) 1011*cdf0e10cSrcweir EndListening(*pStyleSheetPool); 1012*cdf0e10cSrcweir pStyleSheetPool = NULL; 1013*cdf0e10cSrcweir delete pTreeBox; 1014*cdf0e10cSrcweir delete pTimer; 1015*cdf0e10cSrcweir if ( pbDeleted ) 1016*cdf0e10cSrcweir { 1017*cdf0e10cSrcweir pbDeleted->bDead = true; 1018*cdf0e10cSrcweir pbDeleted = NULL; 1019*cdf0e10cSrcweir } 1020*cdf0e10cSrcweir } 1021*cdf0e10cSrcweir 1022*cdf0e10cSrcweir //------------------------------------------------------------------------- 1023*cdf0e10cSrcweir 1024*cdf0e10cSrcweir sal_uInt16 SfxCommonTemplateDialog_Impl::SfxFamilyIdToNId( SfxStyleFamily nFamily ) 1025*cdf0e10cSrcweir { 1026*cdf0e10cSrcweir switch ( nFamily ) 1027*cdf0e10cSrcweir { 1028*cdf0e10cSrcweir case SFX_STYLE_FAMILY_CHAR: return 1; 1029*cdf0e10cSrcweir case SFX_STYLE_FAMILY_PARA: return 2; 1030*cdf0e10cSrcweir case SFX_STYLE_FAMILY_FRAME: return 3; 1031*cdf0e10cSrcweir case SFX_STYLE_FAMILY_PAGE: return 4; 1032*cdf0e10cSrcweir case SFX_STYLE_FAMILY_PSEUDO: return 5; 1033*cdf0e10cSrcweir default: return 0; 1034*cdf0e10cSrcweir } 1035*cdf0e10cSrcweir } 1036*cdf0e10cSrcweir 1037*cdf0e10cSrcweir void SfxCommonTemplateDialog_Impl::SetAutomaticFilter() 1038*cdf0e10cSrcweir { 1039*cdf0e10cSrcweir sal_uInt16 nCount = aFilterLb.GetEntryCount(); 1040*cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < nCount; ++i ) 1041*cdf0e10cSrcweir { 1042*cdf0e10cSrcweir sal_uIntPtr nFlags = (sal_uIntPtr)aFilterLb.GetEntryData(i); 1043*cdf0e10cSrcweir if ( SFXSTYLEBIT_AUTO == nFlags ) 1044*cdf0e10cSrcweir { 1045*cdf0e10cSrcweir // automatic entry found -> select it 1046*cdf0e10cSrcweir aFilterLb.SelectEntryPos(i); 1047*cdf0e10cSrcweir // then call the handler to filter the styles 1048*cdf0e10cSrcweir FilterSelect( i - 1 ); 1049*cdf0e10cSrcweir break; 1050*cdf0e10cSrcweir } 1051*cdf0e10cSrcweir } 1052*cdf0e10cSrcweir } 1053*cdf0e10cSrcweir 1054*cdf0e10cSrcweir //------------------------------------------------------------------------- 1055*cdf0e10cSrcweir 1056*cdf0e10cSrcweir // Hilfsfunktion: Zugriff auf aktuelles Family-Item 1057*cdf0e10cSrcweir const SfxStyleFamilyItem *SfxCommonTemplateDialog_Impl::GetFamilyItem_Impl() const 1058*cdf0e10cSrcweir { 1059*cdf0e10cSrcweir const sal_uInt16 nCount = pStyleFamilies->Count(); 1060*cdf0e10cSrcweir for(sal_uInt16 i = 0; i < nCount; ++i) 1061*cdf0e10cSrcweir { 1062*cdf0e10cSrcweir const SfxStyleFamilyItem *pItem = pStyleFamilies->GetObject(i); 1063*cdf0e10cSrcweir // if(!pItem)continue; 1064*cdf0e10cSrcweir sal_uInt16 nId = SfxFamilyIdToNId(pItem->GetFamily()); 1065*cdf0e10cSrcweir if(nId == nActFamily) 1066*cdf0e10cSrcweir return pItem; 1067*cdf0e10cSrcweir } 1068*cdf0e10cSrcweir return 0; 1069*cdf0e10cSrcweir } 1070*cdf0e10cSrcweir 1071*cdf0e10cSrcweir //------------------------------------------------------------------------- 1072*cdf0e10cSrcweir 1073*cdf0e10cSrcweir void SfxCommonTemplateDialog_Impl::SelectStyle(const String &rStr) 1074*cdf0e10cSrcweir { 1075*cdf0e10cSrcweir const SfxStyleFamilyItem* pItem = GetFamilyItem_Impl(); 1076*cdf0e10cSrcweir if ( !pItem ) 1077*cdf0e10cSrcweir return; 1078*cdf0e10cSrcweir const SfxStyleFamily eFam = pItem->GetFamily(); 1079*cdf0e10cSrcweir SfxStyleSheetBase* pStyle = pStyleSheetPool->Find( rStr, eFam, SFXSTYLEBIT_ALL ); 1080*cdf0e10cSrcweir if( pStyle ) 1081*cdf0e10cSrcweir EnableEdit( !(pStyle->GetMask() & SFXSTYLEBIT_READONLY) ); 1082*cdf0e10cSrcweir else 1083*cdf0e10cSrcweir EnableEdit(sal_False); 1084*cdf0e10cSrcweir 1085*cdf0e10cSrcweir if ( pTreeBox ) 1086*cdf0e10cSrcweir { 1087*cdf0e10cSrcweir if ( rStr.Len() ) 1088*cdf0e10cSrcweir { 1089*cdf0e10cSrcweir SvLBoxEntry* pEntry = pTreeBox->First(); 1090*cdf0e10cSrcweir while ( pEntry ) 1091*cdf0e10cSrcweir { 1092*cdf0e10cSrcweir if ( pTreeBox->GetEntryText( pEntry ) == rStr ) 1093*cdf0e10cSrcweir { 1094*cdf0e10cSrcweir pTreeBox->MakeVisible( pEntry ); 1095*cdf0e10cSrcweir pTreeBox->Select( pEntry ); 1096*cdf0e10cSrcweir return; 1097*cdf0e10cSrcweir } 1098*cdf0e10cSrcweir pEntry = pTreeBox->Next( pEntry ); 1099*cdf0e10cSrcweir } 1100*cdf0e10cSrcweir } 1101*cdf0e10cSrcweir else 1102*cdf0e10cSrcweir pTreeBox->SelectAll( sal_False ); 1103*cdf0e10cSrcweir } 1104*cdf0e10cSrcweir else 1105*cdf0e10cSrcweir { 1106*cdf0e10cSrcweir sal_Bool bSelect = ( rStr.Len() > 0 ); 1107*cdf0e10cSrcweir if ( bSelect ) 1108*cdf0e10cSrcweir { 1109*cdf0e10cSrcweir SvLBoxEntry* pEntry = (SvLBoxEntry*)aFmtLb.FirstVisible(); 1110*cdf0e10cSrcweir while ( pEntry && aFmtLb.GetEntryText( pEntry ) != rStr ) 1111*cdf0e10cSrcweir pEntry = (SvLBoxEntry*)aFmtLb.NextVisible( pEntry ); 1112*cdf0e10cSrcweir if ( !pEntry ) 1113*cdf0e10cSrcweir bSelect = sal_False; 1114*cdf0e10cSrcweir else 1115*cdf0e10cSrcweir { 1116*cdf0e10cSrcweir aFmtLb.MakeVisible( pEntry ); 1117*cdf0e10cSrcweir aFmtLb.Select( pEntry ); 1118*cdf0e10cSrcweir bWaterDisabled = !HasSelectedStyle(); //added by BerryJia for fixing Bug76391 2003-1-22 1119*cdf0e10cSrcweir FmtSelectHdl( NULL ); 1120*cdf0e10cSrcweir } 1121*cdf0e10cSrcweir } 1122*cdf0e10cSrcweir 1123*cdf0e10cSrcweir if ( !bSelect ) 1124*cdf0e10cSrcweir { 1125*cdf0e10cSrcweir aFmtLb.SelectAll( sal_False ); 1126*cdf0e10cSrcweir EnableEdit(sal_False); 1127*cdf0e10cSrcweir } 1128*cdf0e10cSrcweir } 1129*cdf0e10cSrcweir } 1130*cdf0e10cSrcweir 1131*cdf0e10cSrcweir //------------------------------------------------------------------------- 1132*cdf0e10cSrcweir 1133*cdf0e10cSrcweir String SfxCommonTemplateDialog_Impl::GetSelectedEntry() const 1134*cdf0e10cSrcweir { 1135*cdf0e10cSrcweir String aRet; 1136*cdf0e10cSrcweir if ( pTreeBox ) 1137*cdf0e10cSrcweir { 1138*cdf0e10cSrcweir SvLBoxEntry* pEntry = pTreeBox->FirstSelected(); 1139*cdf0e10cSrcweir if ( pEntry ) 1140*cdf0e10cSrcweir aRet = pTreeBox->GetEntryText( pEntry ); 1141*cdf0e10cSrcweir } 1142*cdf0e10cSrcweir else 1143*cdf0e10cSrcweir { 1144*cdf0e10cSrcweir SvLBoxEntry* pEntry = aFmtLb.FirstSelected(); 1145*cdf0e10cSrcweir if ( pEntry ) 1146*cdf0e10cSrcweir aRet = aFmtLb.GetEntryText( pEntry ); 1147*cdf0e10cSrcweir } 1148*cdf0e10cSrcweir return aRet; 1149*cdf0e10cSrcweir } 1150*cdf0e10cSrcweir 1151*cdf0e10cSrcweir //------------------------------------------------------------------------- 1152*cdf0e10cSrcweir 1153*cdf0e10cSrcweir void SfxCommonTemplateDialog_Impl::EnableTreeDrag( sal_Bool bEnable ) 1154*cdf0e10cSrcweir { 1155*cdf0e10cSrcweir if ( pStyleSheetPool ) 1156*cdf0e10cSrcweir { 1157*cdf0e10cSrcweir SfxStyleSheetBase* pStyle = pStyleSheetPool->First(); 1158*cdf0e10cSrcweir if ( pTreeBox ) 1159*cdf0e10cSrcweir { 1160*cdf0e10cSrcweir if ( pStyle && pStyle->HasParentSupport() && bEnable ) 1161*cdf0e10cSrcweir pTreeBox->SetDragDropMode(SV_DRAGDROP_CTRL_MOVE); 1162*cdf0e10cSrcweir else 1163*cdf0e10cSrcweir pTreeBox->SetDragDropMode(SV_DRAGDROP_NONE); 1164*cdf0e10cSrcweir } 1165*cdf0e10cSrcweir } 1166*cdf0e10cSrcweir bTreeDrag = bEnable; 1167*cdf0e10cSrcweir } 1168*cdf0e10cSrcweir 1169*cdf0e10cSrcweir //------------------------------------------------------------------------- 1170*cdf0e10cSrcweir 1171*cdf0e10cSrcweir void SfxCommonTemplateDialog_Impl::FillTreeBox() 1172*cdf0e10cSrcweir { 1173*cdf0e10cSrcweir DBG_ASSERT( pTreeBox, "FillTreeBox() without treebox"); 1174*cdf0e10cSrcweir if(pStyleSheetPool && nActFamily != 0xffff) 1175*cdf0e10cSrcweir { 1176*cdf0e10cSrcweir const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl(); 1177*cdf0e10cSrcweir pStyleSheetPool->SetSearchMask(pItem->GetFamily(), SFXSTYLEBIT_ALL); 1178*cdf0e10cSrcweir StyleTreeArr_Impl aArr; 1179*cdf0e10cSrcweir SfxStyleSheetBase *pStyle = pStyleSheetPool->First(); 1180*cdf0e10cSrcweir if(pStyle && pStyle->HasParentSupport() && bTreeDrag ) 1181*cdf0e10cSrcweir pTreeBox->SetDragDropMode(SV_DRAGDROP_CTRL_MOVE); 1182*cdf0e10cSrcweir else 1183*cdf0e10cSrcweir pTreeBox->SetDragDropMode(SV_DRAGDROP_NONE); 1184*cdf0e10cSrcweir while(pStyle) 1185*cdf0e10cSrcweir { 1186*cdf0e10cSrcweir StyleTree_ImplPtr pNew = 1187*cdf0e10cSrcweir new StyleTree_Impl(pStyle->GetName(), pStyle->GetParent()); 1188*cdf0e10cSrcweir aArr.Insert(pNew, aArr.Count()); 1189*cdf0e10cSrcweir pStyle = pStyleSheetPool->Next(); 1190*cdf0e10cSrcweir } 1191*cdf0e10cSrcweir MakeTree_Impl(aArr); 1192*cdf0e10cSrcweir ExpandedEntries aEntries; 1193*cdf0e10cSrcweir if(pTreeBox) 1194*cdf0e10cSrcweir ((const StyleTreeListBox_Impl *)pTreeBox)-> 1195*cdf0e10cSrcweir MakeExpanded_Impl( aEntries); 1196*cdf0e10cSrcweir pTreeBox->SetUpdateMode( sal_False ); 1197*cdf0e10cSrcweir pTreeBox->Clear(); 1198*cdf0e10cSrcweir const sal_uInt16 nCount = aArr.Count(); 1199*cdf0e10cSrcweir for(sal_uInt16 i = 0; i < nCount; ++i) 1200*cdf0e10cSrcweir FillBox_Impl(pTreeBox, aArr[i], aEntries); 1201*cdf0e10cSrcweir 1202*cdf0e10cSrcweir // EnableEdit(sal_False); 1203*cdf0e10cSrcweir EnableItem(SID_STYLE_WATERCAN,sal_False); 1204*cdf0e10cSrcweir 1205*cdf0e10cSrcweir SfxTemplateItem* pState = pFamilyState[nActFamily-1]; 1206*cdf0e10cSrcweir 1207*cdf0e10cSrcweir if ( nCount ) 1208*cdf0e10cSrcweir pTreeBox->Expand( pTreeBox->First() ); 1209*cdf0e10cSrcweir 1210*cdf0e10cSrcweir for ( SvLBoxEntry* pEntry = pTreeBox->First(); pEntry; pEntry = pTreeBox->Next( pEntry ) ) 1211*cdf0e10cSrcweir { 1212*cdf0e10cSrcweir if ( IsExpanded_Impl( aEntries, pTreeBox->GetEntryText( pEntry ) ) ) 1213*cdf0e10cSrcweir pTreeBox->Expand( pEntry ); 1214*cdf0e10cSrcweir } 1215*cdf0e10cSrcweir 1216*cdf0e10cSrcweir pTreeBox->SetUpdateMode( sal_True ); 1217*cdf0e10cSrcweir 1218*cdf0e10cSrcweir String aStyle; 1219*cdf0e10cSrcweir if(pState) //Aktuellen Eintrag selektieren 1220*cdf0e10cSrcweir aStyle = pState->GetStyleName(); 1221*cdf0e10cSrcweir SelectStyle(aStyle); 1222*cdf0e10cSrcweir EnableDelete(); 1223*cdf0e10cSrcweir } 1224*cdf0e10cSrcweir } 1225*cdf0e10cSrcweir 1226*cdf0e10cSrcweir //------------------------------------------------------------------------- 1227*cdf0e10cSrcweir sal_Bool SfxCommonTemplateDialog_Impl::HasSelectedStyle() const 1228*cdf0e10cSrcweir { 1229*cdf0e10cSrcweir return pTreeBox? pTreeBox->FirstSelected() != 0: 1230*cdf0e10cSrcweir aFmtLb.GetSelectionCount() != 0; 1231*cdf0e10cSrcweir } 1232*cdf0e10cSrcweir 1233*cdf0e10cSrcweir 1234*cdf0e10cSrcweir //------------------------------------------------------------------------- 1235*cdf0e10cSrcweir 1236*cdf0e10cSrcweir // intern: Aktualisierung der Anzeige 1237*cdf0e10cSrcweir void SfxCommonTemplateDialog_Impl::UpdateStyles_Impl(sal_uInt16 nFlags) // Flags, was aktualisiert werden soll (s.o.) 1238*cdf0e10cSrcweir { 1239*cdf0e10cSrcweir DBG_ASSERT(nFlags, "nichts zu tun"); 1240*cdf0e10cSrcweir const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl(); 1241*cdf0e10cSrcweir if (!pItem) 1242*cdf0e10cSrcweir { 1243*cdf0e10cSrcweir // Ist beim Vorlagenkatalog der Fall 1244*cdf0e10cSrcweir SfxTemplateItem **ppItem = pFamilyState; 1245*cdf0e10cSrcweir const sal_uInt16 nFamilyCount = pStyleFamilies->Count(); 1246*cdf0e10cSrcweir sal_uInt16 n; 1247*cdf0e10cSrcweir for(n=0;n<nFamilyCount;n++) 1248*cdf0e10cSrcweir if(ppItem[StyleNrToInfoOffset(n)])break; 1249*cdf0e10cSrcweir if ( n == nFamilyCount ) 1250*cdf0e10cSrcweir // passiert gelegentlich bei Beichten, Formularen etc.; weiss der Teufel warum 1251*cdf0e10cSrcweir return; 1252*cdf0e10cSrcweir ppItem+=StyleNrToInfoOffset(n); 1253*cdf0e10cSrcweir nAppFilter = (*ppItem)->GetValue(); 1254*cdf0e10cSrcweir FamilySelect( StyleNrToInfoOffset(n)+1 ); 1255*cdf0e10cSrcweir pItem = GetFamilyItem_Impl(); 1256*cdf0e10cSrcweir } 1257*cdf0e10cSrcweir 1258*cdf0e10cSrcweir const SfxStyleFamily eFam = pItem->GetFamily(); 1259*cdf0e10cSrcweir 1260*cdf0e10cSrcweir SfxFilterTupel *pT = pItem->GetFilterList().GetObject(nActFilter); 1261*cdf0e10cSrcweir sal_uInt16 nFilter = pT ? pItem->GetFilterList().GetObject(nActFilter)->nFlags : 0; 1262*cdf0e10cSrcweir if(!nFilter) // automatisch 1263*cdf0e10cSrcweir nFilter = nAppFilter; 1264*cdf0e10cSrcweir 1265*cdf0e10cSrcweir DBG_ASSERT(pStyleSheetPool, "kein StyleSheetPool"); 1266*cdf0e10cSrcweir if(pStyleSheetPool) 1267*cdf0e10cSrcweir { 1268*cdf0e10cSrcweir pStyleSheetPool->SetSearchMask(eFam, nFilter); 1269*cdf0e10cSrcweir pItem = GetFamilyItem_Impl(); 1270*cdf0e10cSrcweir if((nFlags & UPDATE_FAMILY) == UPDATE_FAMILY) 1271*cdf0e10cSrcweir { 1272*cdf0e10cSrcweir CheckItem(nActFamily, sal_True); // Button in Toolbox checken 1273*cdf0e10cSrcweir aFilterLb.SetUpdateMode(sal_False); 1274*cdf0e10cSrcweir aFilterLb.Clear(); 1275*cdf0e10cSrcweir //insert hierarchical at the beginning 1276*cdf0e10cSrcweir sal_uInt16 nPos = aFilterLb.InsertEntry(String(SfxResId(STR_STYLE_FILTER_HIERARCHICAL)), 0); 1277*cdf0e10cSrcweir aFilterLb.SetEntryData( nPos, (void*)(sal_uIntPtr)SFXSTYLEBIT_ALL ); 1278*cdf0e10cSrcweir const SfxStyleFilter& rFilter = pItem->GetFilterList(); 1279*cdf0e10cSrcweir for(sal_uInt16 i = 0; i < rFilter.Count(); ++i) 1280*cdf0e10cSrcweir { 1281*cdf0e10cSrcweir sal_uIntPtr nFilterFlags = rFilter.GetObject(i)->nFlags; 1282*cdf0e10cSrcweir nPos = aFilterLb.InsertEntry( rFilter.GetObject(i)->aName ); 1283*cdf0e10cSrcweir aFilterLb.SetEntryData( nPos, (void*)nFilterFlags ); 1284*cdf0e10cSrcweir } 1285*cdf0e10cSrcweir if(nActFilter < aFilterLb.GetEntryCount() - 1) 1286*cdf0e10cSrcweir aFilterLb.SelectEntryPos(nActFilter + 1); 1287*cdf0e10cSrcweir else 1288*cdf0e10cSrcweir { 1289*cdf0e10cSrcweir nActFilter = 0; 1290*cdf0e10cSrcweir aFilterLb.SelectEntryPos(1); 1291*cdf0e10cSrcweir SfxFilterTupel *pActT = rFilter.GetObject(nActFilter); 1292*cdf0e10cSrcweir sal_uInt16 nFilterFlags = pActT ? rFilter.GetObject(nActFilter)->nFlags : 0; 1293*cdf0e10cSrcweir pStyleSheetPool->SetSearchMask(eFam, nFilterFlags); 1294*cdf0e10cSrcweir } 1295*cdf0e10cSrcweir 1296*cdf0e10cSrcweir //Falls in Treedarstellung wieder Family Hierarchie selektieren 1297*cdf0e10cSrcweir if(pTreeBox) 1298*cdf0e10cSrcweir aFilterLb.SelectEntry(String(SfxResId(STR_STYLE_FILTER_HIERARCHICAL))); 1299*cdf0e10cSrcweir 1300*cdf0e10cSrcweir // show maximum 12 entries 1301*cdf0e10cSrcweir aFilterLb.SetDropDownLineCount( MAX_FILTER_ENTRIES ); 1302*cdf0e10cSrcweir aFilterLb.SetUpdateMode(sal_True); 1303*cdf0e10cSrcweir } 1304*cdf0e10cSrcweir else 1305*cdf0e10cSrcweir { 1306*cdf0e10cSrcweir if( nActFilter < aFilterLb.GetEntryCount() - 1) 1307*cdf0e10cSrcweir aFilterLb.SelectEntryPos(nActFilter + 1); 1308*cdf0e10cSrcweir else 1309*cdf0e10cSrcweir { 1310*cdf0e10cSrcweir nActFilter = 0; 1311*cdf0e10cSrcweir aFilterLb.SelectEntryPos(1); 1312*cdf0e10cSrcweir } 1313*cdf0e10cSrcweir } 1314*cdf0e10cSrcweir 1315*cdf0e10cSrcweir if(nFlags & UPDATE_FAMILY_LIST) 1316*cdf0e10cSrcweir { 1317*cdf0e10cSrcweir // EnableEdit(sal_False); 1318*cdf0e10cSrcweir EnableItem(SID_STYLE_WATERCAN,sal_False); 1319*cdf0e10cSrcweir 1320*cdf0e10cSrcweir SfxStyleSheetBase *pStyle = pStyleSheetPool->First(); 1321*cdf0e10cSrcweir SvLBoxEntry* pEntry = aFmtLb.First(); 1322*cdf0e10cSrcweir SvStringsDtor aStrings; 1323*cdf0e10cSrcweir 1324*cdf0e10cSrcweir while( pStyle ) 1325*cdf0e10cSrcweir { 1326*cdf0e10cSrcweir //Bubblesort 1327*cdf0e10cSrcweir for( sal_uInt16 nPos = aStrings.Count() + 1 ; nPos-- ;) 1328*cdf0e10cSrcweir { 1329*cdf0e10cSrcweir if( !nPos || *aStrings[nPos-1] < pStyle->GetName() ) 1330*cdf0e10cSrcweir { 1331*cdf0e10cSrcweir // Die Namen stehen in den Styles, also nicht kopieren 1332*cdf0e10cSrcweir // Reingefallen!: Writer hat insgesamt nur 1 Style 1333*cdf0e10cSrcweir aStrings.Insert( 1334*cdf0e10cSrcweir new String( pStyle->GetName() ), nPos ); 1335*cdf0e10cSrcweir break; 1336*cdf0e10cSrcweir } 1337*cdf0e10cSrcweir } 1338*cdf0e10cSrcweir pStyle = pStyleSheetPool->Next(); 1339*cdf0e10cSrcweir } 1340*cdf0e10cSrcweir 1341*cdf0e10cSrcweir 1342*cdf0e10cSrcweir sal_uInt16 nCount = aStrings.Count(); 1343*cdf0e10cSrcweir sal_uInt16 nPos = 0; 1344*cdf0e10cSrcweir while( nPos < nCount && pEntry && 1345*cdf0e10cSrcweir *aStrings[ nPos ] == aFmtLb.GetEntryText( pEntry ) ) 1346*cdf0e10cSrcweir { 1347*cdf0e10cSrcweir nPos++; 1348*cdf0e10cSrcweir pEntry = aFmtLb.Next( pEntry ); 1349*cdf0e10cSrcweir } 1350*cdf0e10cSrcweir 1351*cdf0e10cSrcweir if( nPos < nCount || pEntry ) 1352*cdf0e10cSrcweir { 1353*cdf0e10cSrcweir // Box mit den Vorlagen fuellen 1354*cdf0e10cSrcweir aFmtLb.SetUpdateMode(sal_False); 1355*cdf0e10cSrcweir aFmtLb.Clear(); 1356*cdf0e10cSrcweir 1357*cdf0e10cSrcweir nPos = 0; 1358*cdf0e10cSrcweir while( nPos < nCount ) 1359*cdf0e10cSrcweir aFmtLb.InsertEntry( *aStrings.GetObject( nPos++ )); 1360*cdf0e10cSrcweir aFmtLb.SetUpdateMode(sal_True); 1361*cdf0e10cSrcweir } 1362*cdf0e10cSrcweir // aktuelle Vorlage anzeigen 1363*cdf0e10cSrcweir SfxTemplateItem *pState = pFamilyState[nActFamily-1]; 1364*cdf0e10cSrcweir String aStyle; 1365*cdf0e10cSrcweir if(pState) //Aktuellen Eintrag selektieren 1366*cdf0e10cSrcweir aStyle = pState->GetStyleName(); 1367*cdf0e10cSrcweir SelectStyle(aStyle); 1368*cdf0e10cSrcweir EnableDelete(); 1369*cdf0e10cSrcweir } 1370*cdf0e10cSrcweir } 1371*cdf0e10cSrcweir } 1372*cdf0e10cSrcweir 1373*cdf0e10cSrcweir //------------------------------------------------------------------------- 1374*cdf0e10cSrcweir 1375*cdf0e10cSrcweir // Aktualisierung Anzeige: Gie\skanne an/aus 1376*cdf0e10cSrcweir void SfxCommonTemplateDialog_Impl::SetWaterCanState(const SfxBoolItem *pItem) 1377*cdf0e10cSrcweir { 1378*cdf0e10cSrcweir // EnableItem(SID_STYLE_WATERCAN, pItem != 0); 1379*cdf0e10cSrcweir bWaterDisabled = pItem == 0; 1380*cdf0e10cSrcweir //added by BerryJia for fixing Bug76391 2003-1-7 1381*cdf0e10cSrcweir if(!bWaterDisabled) 1382*cdf0e10cSrcweir bWaterDisabled = !HasSelectedStyle(); 1383*cdf0e10cSrcweir 1384*cdf0e10cSrcweir if(pItem && !bWaterDisabled) 1385*cdf0e10cSrcweir { 1386*cdf0e10cSrcweir CheckItem(SID_STYLE_WATERCAN, pItem->GetValue()); 1387*cdf0e10cSrcweir EnableItem( SID_STYLE_WATERCAN, sal_True ); 1388*cdf0e10cSrcweir } 1389*cdf0e10cSrcweir else 1390*cdf0e10cSrcweir if(!bWaterDisabled) 1391*cdf0e10cSrcweir EnableItem(SID_STYLE_WATERCAN, sal_True); 1392*cdf0e10cSrcweir else 1393*cdf0e10cSrcweir EnableItem(SID_STYLE_WATERCAN, sal_False); 1394*cdf0e10cSrcweir 1395*cdf0e10cSrcweir //Waehrend Giesskannenmodus Statusupdates ignorieren. 1396*cdf0e10cSrcweir 1397*cdf0e10cSrcweir sal_uInt16 nCount=pStyleFamilies->Count(); 1398*cdf0e10cSrcweir pBindings->EnterRegistrations(); 1399*cdf0e10cSrcweir for(sal_uInt16 n=0; n<nCount; n++) 1400*cdf0e10cSrcweir { 1401*cdf0e10cSrcweir SfxControllerItem *pCItem=pBoundItems[n]; 1402*cdf0e10cSrcweir sal_Bool bChecked = pItem && pItem->GetValue(); 1403*cdf0e10cSrcweir if( pCItem->IsBound() == bChecked ) 1404*cdf0e10cSrcweir { 1405*cdf0e10cSrcweir if( !bChecked ) 1406*cdf0e10cSrcweir pCItem->ReBind(); 1407*cdf0e10cSrcweir else 1408*cdf0e10cSrcweir pCItem->UnBind(); 1409*cdf0e10cSrcweir } 1410*cdf0e10cSrcweir } 1411*cdf0e10cSrcweir pBindings->LeaveRegistrations(); 1412*cdf0e10cSrcweir } 1413*cdf0e10cSrcweir 1414*cdf0e10cSrcweir //------------------------------------------------------------------------- 1415*cdf0e10cSrcweir 1416*cdf0e10cSrcweir // Item mit dem Status einer Family wird kopiert und gemerkt 1417*cdf0e10cSrcweir // (Aktualisierung erfolgt, wenn alle Stati aktualisiert worden sind. 1418*cdf0e10cSrcweir // Siehe auch: <SfxBindings::AddDoneHdl(const Link &)> 1419*cdf0e10cSrcweir 1420*cdf0e10cSrcweir void SfxCommonTemplateDialog_Impl::SetFamilyState( sal_uInt16 nSlotId, const SfxTemplateItem* pItem ) 1421*cdf0e10cSrcweir { 1422*cdf0e10cSrcweir sal_uInt16 nIdx = nSlotId - SID_STYLE_FAMILY_START; 1423*cdf0e10cSrcweir DELETEZ(pFamilyState[nIdx]); 1424*cdf0e10cSrcweir if ( pItem ) 1425*cdf0e10cSrcweir pFamilyState[nIdx] = new SfxTemplateItem(*pItem); 1426*cdf0e10cSrcweir bUpdate = sal_True; 1427*cdf0e10cSrcweir 1428*cdf0e10cSrcweir // Wenn verwendete Vorlagen ( wie zum Teufel findet man das heraus ?? ) 1429*cdf0e10cSrcweir bUpdateFamily = sal_True; 1430*cdf0e10cSrcweir } 1431*cdf0e10cSrcweir 1432*cdf0e10cSrcweir //------------------------------------------------------------------------- 1433*cdf0e10cSrcweir 1434*cdf0e10cSrcweir // Benachrichtigung durch SfxBindings, da"s die Aktualisierung 1435*cdf0e10cSrcweir // beendet ist. St"o\st die Aktualisierung der Anzeige an. 1436*cdf0e10cSrcweir 1437*cdf0e10cSrcweir void SfxCommonTemplateDialog_Impl::Update_Impl() 1438*cdf0e10cSrcweir { 1439*cdf0e10cSrcweir sal_Bool bDocChanged=sal_False; 1440*cdf0e10cSrcweir SfxStyleSheetBasePool* pNewPool = NULL; 1441*cdf0e10cSrcweir SfxViewFrame* pViewFrame = pBindings->GetDispatcher_Impl()->GetFrame(); 1442*cdf0e10cSrcweir SfxObjectShell* pDocShell = pViewFrame->GetObjectShell(); 1443*cdf0e10cSrcweir if( pDocShell ) 1444*cdf0e10cSrcweir pNewPool = pDocShell->GetStyleSheetPool(); 1445*cdf0e10cSrcweir 1446*cdf0e10cSrcweir if ( pNewPool != pStyleSheetPool && pDocShell ) 1447*cdf0e10cSrcweir { 1448*cdf0e10cSrcweir SfxModule* pNewModule = pDocShell->GetModule(); 1449*cdf0e10cSrcweir if( pNewModule && pNewModule != pModule ) 1450*cdf0e10cSrcweir { 1451*cdf0e10cSrcweir ClearResource(); 1452*cdf0e10cSrcweir ReadResource(); 1453*cdf0e10cSrcweir } 1454*cdf0e10cSrcweir if ( pStyleSheetPool ) 1455*cdf0e10cSrcweir { 1456*cdf0e10cSrcweir EndListening(*pStyleSheetPool); 1457*cdf0e10cSrcweir pStyleSheetPool = 0; 1458*cdf0e10cSrcweir } 1459*cdf0e10cSrcweir 1460*cdf0e10cSrcweir if ( pNewPool ) 1461*cdf0e10cSrcweir { 1462*cdf0e10cSrcweir StartListening(*pNewPool); 1463*cdf0e10cSrcweir pStyleSheetPool = pNewPool; 1464*cdf0e10cSrcweir bDocChanged=sal_True; 1465*cdf0e10cSrcweir } 1466*cdf0e10cSrcweir // InvalidateBindings(); 1467*cdf0e10cSrcweir } 1468*cdf0e10cSrcweir 1469*cdf0e10cSrcweir if (bUpdateFamily) 1470*cdf0e10cSrcweir UpdateFamily_Impl(); 1471*cdf0e10cSrcweir 1472*cdf0e10cSrcweir sal_uInt16 i; 1473*cdf0e10cSrcweir for(i = 0; i < MAX_FAMILIES; ++i) 1474*cdf0e10cSrcweir if(pFamilyState[i]) 1475*cdf0e10cSrcweir break; 1476*cdf0e10cSrcweir if(i == MAX_FAMILIES || !pNewPool) 1477*cdf0e10cSrcweir // nichts erlaubt 1478*cdf0e10cSrcweir return; 1479*cdf0e10cSrcweir 1480*cdf0e10cSrcweir SfxTemplateItem *pItem = 0; 1481*cdf0e10cSrcweir // aktueller Bereich nicht innerhalb der erlaubten Bereiche 1482*cdf0e10cSrcweir // oder Default 1483*cdf0e10cSrcweir if(nActFamily == 0xffff || 0 == (pItem = pFamilyState[nActFamily-1] ) ) 1484*cdf0e10cSrcweir { 1485*cdf0e10cSrcweir CheckItem(nActFamily, sal_False); 1486*cdf0e10cSrcweir SfxTemplateItem **ppItem = pFamilyState; 1487*cdf0e10cSrcweir const sal_uInt16 nFamilyCount = pStyleFamilies->Count(); 1488*cdf0e10cSrcweir sal_uInt16 n; 1489*cdf0e10cSrcweir for(n=0;n<nFamilyCount;n++) 1490*cdf0e10cSrcweir if(ppItem[StyleNrToInfoOffset(n)])break; 1491*cdf0e10cSrcweir ppItem+=StyleNrToInfoOffset(n); 1492*cdf0e10cSrcweir 1493*cdf0e10cSrcweir nAppFilter = (*ppItem)->GetValue(); 1494*cdf0e10cSrcweir FamilySelect( StyleNrToInfoOffset(n)+1 ); 1495*cdf0e10cSrcweir 1496*cdf0e10cSrcweir pItem = *ppItem; 1497*cdf0e10cSrcweir } 1498*cdf0e10cSrcweir else if( bDocChanged ) 1499*cdf0e10cSrcweir { 1500*cdf0e10cSrcweir // andere DocShell -> alles neu 1501*cdf0e10cSrcweir CheckItem( nActFamily, sal_True ); 1502*cdf0e10cSrcweir nActFilter = static_cast< sal_uInt16 >( LoadFactoryStyleFilter( pDocShell ) ); 1503*cdf0e10cSrcweir if ( 0xFFFF == nActFilter ) 1504*cdf0e10cSrcweir nActFilter = pDocShell->GetAutoStyleFilterIndex(); 1505*cdf0e10cSrcweir 1506*cdf0e10cSrcweir nAppFilter = pItem->GetValue(); 1507*cdf0e10cSrcweir if(!pTreeBox) 1508*cdf0e10cSrcweir { 1509*cdf0e10cSrcweir UpdateStyles_Impl(UPDATE_FAMILY_LIST); 1510*cdf0e10cSrcweir } 1511*cdf0e10cSrcweir else 1512*cdf0e10cSrcweir FillTreeBox(); 1513*cdf0e10cSrcweir } 1514*cdf0e10cSrcweir else 1515*cdf0e10cSrcweir { 1516*cdf0e10cSrcweir // anderer Filter fuer automatisch 1517*cdf0e10cSrcweir CheckItem( nActFamily, sal_True ); 1518*cdf0e10cSrcweir const SfxStyleFamilyItem *pStyleItem = GetFamilyItem_Impl(); 1519*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 1520*cdf0e10cSrcweir SfxFilterTupel *pT; 1521*cdf0e10cSrcweir pT = pStyleItem->GetFilterList().GetObject(nActFilter); 1522*cdf0e10cSrcweir #endif 1523*cdf0e10cSrcweir if(0 == pStyleItem->GetFilterList().GetObject(nActFilter)->nFlags 1524*cdf0e10cSrcweir && nAppFilter != pItem->GetValue()) 1525*cdf0e10cSrcweir { 1526*cdf0e10cSrcweir nAppFilter = pItem->GetValue(); 1527*cdf0e10cSrcweir if(!pTreeBox) 1528*cdf0e10cSrcweir UpdateStyles_Impl(UPDATE_FAMILY_LIST); 1529*cdf0e10cSrcweir else 1530*cdf0e10cSrcweir FillTreeBox(); 1531*cdf0e10cSrcweir } 1532*cdf0e10cSrcweir else 1533*cdf0e10cSrcweir nAppFilter = pItem->GetValue(); 1534*cdf0e10cSrcweir } 1535*cdf0e10cSrcweir const String aStyle(pItem->GetStyleName()); 1536*cdf0e10cSrcweir SelectStyle(aStyle); 1537*cdf0e10cSrcweir EnableDelete(); 1538*cdf0e10cSrcweir EnableNew( bCanNew ); 1539*cdf0e10cSrcweir } 1540*cdf0e10cSrcweir 1541*cdf0e10cSrcweir //------------------------------------------------------------------------- 1542*cdf0e10cSrcweir 1543*cdf0e10cSrcweir IMPL_LINK( SfxCommonTemplateDialog_Impl, TimeOut, Timer *, pTim ) 1544*cdf0e10cSrcweir { 1545*cdf0e10cSrcweir (void)pTim; // unused 1546*cdf0e10cSrcweir if(!bDontUpdate) 1547*cdf0e10cSrcweir { 1548*cdf0e10cSrcweir bDontUpdate=sal_True; 1549*cdf0e10cSrcweir if(!pTreeBox) 1550*cdf0e10cSrcweir UpdateStyles_Impl(UPDATE_FAMILY_LIST); 1551*cdf0e10cSrcweir else 1552*cdf0e10cSrcweir { 1553*cdf0e10cSrcweir FillTreeBox(); 1554*cdf0e10cSrcweir SfxTemplateItem *pState = pFamilyState[nActFamily-1]; 1555*cdf0e10cSrcweir if(pState) 1556*cdf0e10cSrcweir { 1557*cdf0e10cSrcweir const String aStyle(pState->GetStyleName()); 1558*cdf0e10cSrcweir SelectStyle(aStyle); 1559*cdf0e10cSrcweir EnableDelete(); 1560*cdf0e10cSrcweir } 1561*cdf0e10cSrcweir } 1562*cdf0e10cSrcweir bDontUpdate=sal_False; 1563*cdf0e10cSrcweir DELETEZ(pTimer); 1564*cdf0e10cSrcweir } 1565*cdf0e10cSrcweir else 1566*cdf0e10cSrcweir pTimer->Start(); 1567*cdf0e10cSrcweir return 0; 1568*cdf0e10cSrcweir } 1569*cdf0e10cSrcweir 1570*cdf0e10cSrcweir 1571*cdf0e10cSrcweir //------------------------------------------------------------------------- 1572*cdf0e10cSrcweir void SfxCommonTemplateDialog_Impl::Notify(SfxBroadcaster& /*rBC*/, const SfxHint& rHint) 1573*cdf0e10cSrcweir { 1574*cdf0e10cSrcweir // Aktualisierung anstossen 1575*cdf0e10cSrcweir if(rHint.Type() == TYPE(SfxSimpleHint)) 1576*cdf0e10cSrcweir { 1577*cdf0e10cSrcweir switch(((SfxSimpleHint&) rHint ).GetId()) 1578*cdf0e10cSrcweir { 1579*cdf0e10cSrcweir case SFX_HINT_UPDATEDONE: 1580*cdf0e10cSrcweir { 1581*cdf0e10cSrcweir SfxViewFrame *pViewFrame = pBindings->GetDispatcher_Impl()->GetFrame(); 1582*cdf0e10cSrcweir SfxObjectShell *pDocShell = pViewFrame->GetObjectShell(); 1583*cdf0e10cSrcweir if ( 1584*cdf0e10cSrcweir bUpdate && 1585*cdf0e10cSrcweir ( 1586*cdf0e10cSrcweir !IsCheckedItem(SID_STYLE_WATERCAN) || 1587*cdf0e10cSrcweir (pDocShell && pDocShell->GetStyleSheetPool() != pStyleSheetPool) 1588*cdf0e10cSrcweir ) 1589*cdf0e10cSrcweir ) 1590*cdf0e10cSrcweir { 1591*cdf0e10cSrcweir bUpdate = sal_False; 1592*cdf0e10cSrcweir Update_Impl(); 1593*cdf0e10cSrcweir } 1594*cdf0e10cSrcweir else if ( bUpdateFamily ) 1595*cdf0e10cSrcweir { 1596*cdf0e10cSrcweir UpdateFamily_Impl(); 1597*cdf0e10cSrcweir } 1598*cdf0e10cSrcweir 1599*cdf0e10cSrcweir if( pStyleSheetPool ) 1600*cdf0e10cSrcweir { 1601*cdf0e10cSrcweir String aStr = GetSelectedEntry(); 1602*cdf0e10cSrcweir if( aStr.Len() && pStyleSheetPool ) 1603*cdf0e10cSrcweir { 1604*cdf0e10cSrcweir const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl(); 1605*cdf0e10cSrcweir if( !pItem ) break; 1606*cdf0e10cSrcweir const SfxStyleFamily eFam = pItem->GetFamily(); 1607*cdf0e10cSrcweir SfxStyleSheetBase *pStyle = 1608*cdf0e10cSrcweir pStyleSheetPool->Find( 1609*cdf0e10cSrcweir aStr, eFam, SFXSTYLEBIT_ALL ); 1610*cdf0e10cSrcweir if( pStyle ) 1611*cdf0e10cSrcweir EnableEdit( 1612*cdf0e10cSrcweir !(pStyle->GetMask() & SFXSTYLEBIT_READONLY) ); 1613*cdf0e10cSrcweir else 1614*cdf0e10cSrcweir EnableEdit(sal_False); 1615*cdf0e10cSrcweir } 1616*cdf0e10cSrcweir } 1617*cdf0e10cSrcweir break; 1618*cdf0e10cSrcweir } 1619*cdf0e10cSrcweir // noetig, wenn zwichen Dokumenten umgeschaltet wird, 1620*cdf0e10cSrcweir // aber in beiden Dokumenten die gleiche Vorlage gilt. 1621*cdf0e10cSrcweir // Nicht sofort Update_Impl rufen, fuer den Fall da\s eines 1622*cdf0e10cSrcweir // der Dokumente ein internes InPlaceObjekt ist! 1623*cdf0e10cSrcweir case SFX_HINT_DOCCHANGED: 1624*cdf0e10cSrcweir bUpdate = sal_True; 1625*cdf0e10cSrcweir break; 1626*cdf0e10cSrcweir case SFX_HINT_DYING: 1627*cdf0e10cSrcweir { 1628*cdf0e10cSrcweir EndListening(*pStyleSheetPool); 1629*cdf0e10cSrcweir pStyleSheetPool=0; 1630*cdf0e10cSrcweir break; 1631*cdf0e10cSrcweir } 1632*cdf0e10cSrcweir } 1633*cdf0e10cSrcweir } 1634*cdf0e10cSrcweir 1635*cdf0e10cSrcweir // Timer nicht aufsetzen, wenn der StyleSheetPool in die Kiste geht, denn 1636*cdf0e10cSrcweir // es kann sein, da\s sich ein neuer erst anmeldet, nachdem der Timer 1637*cdf0e10cSrcweir // abgelaufen ist - macht sich schlecht in UpdateStyles_Impl() ! 1638*cdf0e10cSrcweir 1639*cdf0e10cSrcweir sal_uIntPtr nId = rHint.ISA(SfxSimpleHint) ? ( (SfxSimpleHint&)rHint ).GetId() : 0; 1640*cdf0e10cSrcweir 1641*cdf0e10cSrcweir if(!bDontUpdate && nId != SFX_HINT_DYING && 1642*cdf0e10cSrcweir (rHint.Type() == TYPE(SfxStyleSheetPoolHint)|| 1643*cdf0e10cSrcweir rHint.Type() == TYPE(SfxStyleSheetHint) || 1644*cdf0e10cSrcweir rHint.Type() == TYPE( SfxStyleSheetHintExtended ))) 1645*cdf0e10cSrcweir { 1646*cdf0e10cSrcweir if(!pTimer) 1647*cdf0e10cSrcweir { 1648*cdf0e10cSrcweir pTimer=new Timer; 1649*cdf0e10cSrcweir pTimer->SetTimeout(500); 1650*cdf0e10cSrcweir pTimer->SetTimeoutHdl(LINK(this,SfxCommonTemplateDialog_Impl,TimeOut)); 1651*cdf0e10cSrcweir } 1652*cdf0e10cSrcweir pTimer->Start(); 1653*cdf0e10cSrcweir 1654*cdf0e10cSrcweir } 1655*cdf0e10cSrcweir } 1656*cdf0e10cSrcweir 1657*cdf0e10cSrcweir 1658*cdf0e10cSrcweir //------------------------------------------------------------------------- 1659*cdf0e10cSrcweir 1660*cdf0e10cSrcweir // Anderer Filter; kann durch den Benutzer umgeschaltet werden 1661*cdf0e10cSrcweir // oder als Folge von Neu oder Bearbeiten, wenn die aktuelle 1662*cdf0e10cSrcweir // Vorlage einem anderen Filter zugewiesen wurde. 1663*cdf0e10cSrcweir void SfxCommonTemplateDialog_Impl::FilterSelect( 1664*cdf0e10cSrcweir sal_uInt16 nEntry, // Idx des neuen Filters 1665*cdf0e10cSrcweir sal_Bool bForce ) // Aktualisierung erzwingen, auch wenn der neue Filter gleich dem aktuellen ist 1666*cdf0e10cSrcweir { 1667*cdf0e10cSrcweir if( nEntry != nActFilter || bForce ) 1668*cdf0e10cSrcweir { 1669*cdf0e10cSrcweir nActFilter = nEntry; 1670*cdf0e10cSrcweir SfxViewFrame *pViewFrame = pBindings->GetDispatcher_Impl()->GetFrame(); 1671*cdf0e10cSrcweir SfxObjectShell *pDocShell = pViewFrame->GetObjectShell(); 1672*cdf0e10cSrcweir if (pDocShell) 1673*cdf0e10cSrcweir { 1674*cdf0e10cSrcweir pDocShell->SetAutoStyleFilterIndex(nActFilter); 1675*cdf0e10cSrcweir SaveFactoryStyleFilter( pDocShell, nActFilter ); 1676*cdf0e10cSrcweir } 1677*cdf0e10cSrcweir 1678*cdf0e10cSrcweir SfxStyleSheetBasePool *pOldStyleSheetPool = pStyleSheetPool; 1679*cdf0e10cSrcweir pStyleSheetPool = pDocShell? pDocShell->GetStyleSheetPool(): 0; 1680*cdf0e10cSrcweir if ( pOldStyleSheetPool != pStyleSheetPool ) 1681*cdf0e10cSrcweir { 1682*cdf0e10cSrcweir if ( pOldStyleSheetPool ) 1683*cdf0e10cSrcweir EndListening(*pOldStyleSheetPool); 1684*cdf0e10cSrcweir if ( pStyleSheetPool ) 1685*cdf0e10cSrcweir StartListening(*pOldStyleSheetPool); 1686*cdf0e10cSrcweir } 1687*cdf0e10cSrcweir 1688*cdf0e10cSrcweir UpdateStyles_Impl(UPDATE_FAMILY_LIST); 1689*cdf0e10cSrcweir } 1690*cdf0e10cSrcweir } 1691*cdf0e10cSrcweir 1692*cdf0e10cSrcweir //------------------------------------------------------------------------- 1693*cdf0e10cSrcweir 1694*cdf0e10cSrcweir // Intern: Ausf"uhren von Funktionen "uber den Dispatcher 1695*cdf0e10cSrcweir sal_Bool SfxCommonTemplateDialog_Impl::Execute_Impl( 1696*cdf0e10cSrcweir sal_uInt16 nId, const String &rStr, const String& rRefStr, sal_uInt16 nFamily, 1697*cdf0e10cSrcweir sal_uInt16 nMask, sal_uInt16 *pIdx, const sal_uInt16* pModifier) 1698*cdf0e10cSrcweir { 1699*cdf0e10cSrcweir SfxDispatcher &rDispatcher = *SFX_APP()->GetDispatcher_Impl(); 1700*cdf0e10cSrcweir SfxStringItem aItem(nId, rStr); 1701*cdf0e10cSrcweir SfxUInt16Item aFamily(SID_STYLE_FAMILY, nFamily); 1702*cdf0e10cSrcweir SfxUInt16Item aMask( SID_STYLE_MASK, nMask ); 1703*cdf0e10cSrcweir SfxStringItem aUpdName(SID_STYLE_UPD_BY_EX_NAME, rStr); 1704*cdf0e10cSrcweir SfxStringItem aRefName( SID_STYLE_REFERENCE, rRefStr ); 1705*cdf0e10cSrcweir const SfxPoolItem* pItems[ 6 ]; 1706*cdf0e10cSrcweir sal_uInt16 nCount = 0; 1707*cdf0e10cSrcweir if( rStr.Len() ) 1708*cdf0e10cSrcweir pItems[ nCount++ ] = &aItem; 1709*cdf0e10cSrcweir pItems[ nCount++ ] = &aFamily; 1710*cdf0e10cSrcweir if( nMask ) 1711*cdf0e10cSrcweir pItems[ nCount++ ] = &aMask; 1712*cdf0e10cSrcweir if(SID_STYLE_UPDATE_BY_EXAMPLE == nId) 1713*cdf0e10cSrcweir { 1714*cdf0e10cSrcweir //Sonderloesung fuer Numerierungsupdate im Writer 1715*cdf0e10cSrcweir const String aTemplName(GetSelectedEntry()); 1716*cdf0e10cSrcweir aUpdName.SetValue(aTemplName); 1717*cdf0e10cSrcweir pItems[ nCount++ ] = &aUpdName; 1718*cdf0e10cSrcweir } 1719*cdf0e10cSrcweir if ( rRefStr.Len() ) 1720*cdf0e10cSrcweir pItems[ nCount++ ] = &aRefName; 1721*cdf0e10cSrcweir 1722*cdf0e10cSrcweir pItems[ nCount++ ] = 0; 1723*cdf0e10cSrcweir 1724*cdf0e10cSrcweir Deleted aDeleted; 1725*cdf0e10cSrcweir pbDeleted = &aDeleted; 1726*cdf0e10cSrcweir sal_uInt16 nModi = pModifier ? *pModifier : 0; 1727*cdf0e10cSrcweir const SfxPoolItem* pItem = rDispatcher.Execute( 1728*cdf0e10cSrcweir nId, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD | SFX_CALLMODE_MODAL, 1729*cdf0e10cSrcweir pItems, nModi ); 1730*cdf0e10cSrcweir 1731*cdf0e10cSrcweir // FIXME: Dialog can be destroyed while in Execute() check stack variable for dtor flag! 1732*cdf0e10cSrcweir if ( !pItem || aDeleted() ) 1733*cdf0e10cSrcweir return sal_False; 1734*cdf0e10cSrcweir 1735*cdf0e10cSrcweir if ( nId == SID_STYLE_NEW || SID_STYLE_EDIT == nId ) 1736*cdf0e10cSrcweir { 1737*cdf0e10cSrcweir SfxUInt16Item *pFilterItem = PTR_CAST(SfxUInt16Item, pItem); 1738*cdf0e10cSrcweir DBG_ASSERT(pFilterItem, "SfxUINT16Item erwartet"); 1739*cdf0e10cSrcweir sal_uInt16 nFilterFlags = pFilterItem->GetValue() & ~SFXSTYLEBIT_USERDEF; 1740*cdf0e10cSrcweir if(!nFilterFlags) // Benutzervorlage? 1741*cdf0e10cSrcweir nFilterFlags = pFilterItem->GetValue(); 1742*cdf0e10cSrcweir const SfxStyleFamilyItem *pFamilyItem = GetFamilyItem_Impl(); 1743*cdf0e10cSrcweir const sal_uInt16 nFilterCount = (sal_uInt16) pFamilyItem->GetFilterList().Count(); 1744*cdf0e10cSrcweir 1745*cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < nFilterCount; ++i ) 1746*cdf0e10cSrcweir { 1747*cdf0e10cSrcweir const SfxFilterTupel *pTupel = 1748*cdf0e10cSrcweir pFamilyItem->GetFilterList().GetObject(i); 1749*cdf0e10cSrcweir 1750*cdf0e10cSrcweir if ( ( pTupel->nFlags & nFilterFlags ) == nFilterFlags && pIdx ) 1751*cdf0e10cSrcweir *pIdx = i; 1752*cdf0e10cSrcweir } 1753*cdf0e10cSrcweir } 1754*cdf0e10cSrcweir 1755*cdf0e10cSrcweir // Reset destroyed flag otherwise we use the pointer in the dtor 1756*cdf0e10cSrcweir // where the local stack object is already destroyed. This would 1757*cdf0e10cSrcweir // overwrite objects on the stack!! See #i100110 1758*cdf0e10cSrcweir pbDeleted = NULL; 1759*cdf0e10cSrcweir return sal_True; 1760*cdf0e10cSrcweir } 1761*cdf0e10cSrcweir 1762*cdf0e10cSrcweir //------------------------------------------------------------------------- 1763*cdf0e10cSrcweir 1764*cdf0e10cSrcweir // Handler der Listbox der Filter 1765*cdf0e10cSrcweir IMPL_LINK( SfxCommonTemplateDialog_Impl, FilterSelectHdl, ListBox *, pBox ) 1766*cdf0e10cSrcweir { 1767*cdf0e10cSrcweir if ( pBox->GetSelectEntry() == String(SfxResId(STR_STYLE_FILTER_HIERARCHICAL)) ) 1768*cdf0e10cSrcweir { 1769*cdf0e10cSrcweir if ( !bHierarchical ) 1770*cdf0e10cSrcweir { 1771*cdf0e10cSrcweir // TreeView einschalten 1772*cdf0e10cSrcweir bHierarchical=sal_True; 1773*cdf0e10cSrcweir const String aSelectEntry( GetSelectedEntry()); 1774*cdf0e10cSrcweir aFmtLb.Hide(); 1775*cdf0e10cSrcweir // aFilterLb.Disable(); 1776*cdf0e10cSrcweir 1777*cdf0e10cSrcweir pTreeBox = new StyleTreeListBox_Impl( 1778*cdf0e10cSrcweir this, WB_HASBUTTONS | WB_HASLINES | 1779*cdf0e10cSrcweir WB_BORDER | WB_TABSTOP | WB_HASLINESATROOT | 1780*cdf0e10cSrcweir WB_HASBUTTONSATROOT | WB_HIDESELECTION | WB_QUICK_SEARCH ); 1781*cdf0e10cSrcweir pTreeBox->SetFont( aFmtLb.GetFont() ); 1782*cdf0e10cSrcweir 1783*cdf0e10cSrcweir pTreeBox->SetPosSizePixel(aFmtLb.GetPosPixel(), aFmtLb.GetSizePixel()); 1784*cdf0e10cSrcweir pTreeBox->SetNodeDefaultImages(); 1785*cdf0e10cSrcweir pTreeBox->SetSelectHdl( 1786*cdf0e10cSrcweir LINK(this, SfxCommonTemplateDialog_Impl, FmtSelectHdl)); 1787*cdf0e10cSrcweir ((StyleTreeListBox_Impl*)pTreeBox)-> 1788*cdf0e10cSrcweir SetDoubleClickHdl( 1789*cdf0e10cSrcweir LINK(this, SfxCommonTemplateDialog_Impl, ApplyHdl)); 1790*cdf0e10cSrcweir ((StyleTreeListBox_Impl*)pTreeBox)-> 1791*cdf0e10cSrcweir SetDropHdl(LINK(this, SfxCommonTemplateDialog_Impl, DropHdl)); 1792*cdf0e10cSrcweir pTreeBox->SetIndent(10); 1793*cdf0e10cSrcweir 1794*cdf0e10cSrcweir FillTreeBox(); 1795*cdf0e10cSrcweir SelectStyle(aSelectEntry); 1796*cdf0e10cSrcweir pTreeBox->SetAccessibleName(SfxResId(STR_STYLE_ELEMTLIST)); 1797*cdf0e10cSrcweir pTreeBox->Show(); 1798*cdf0e10cSrcweir } 1799*cdf0e10cSrcweir } 1800*cdf0e10cSrcweir 1801*cdf0e10cSrcweir else 1802*cdf0e10cSrcweir { 1803*cdf0e10cSrcweir DELETEZ(pTreeBox); 1804*cdf0e10cSrcweir aFmtLb.Show(); 1805*cdf0e10cSrcweir // aFilterLb.Enable(); 1806*cdf0e10cSrcweir // Falls bHierarchical, kann sich die Familie geaendert haben 1807*cdf0e10cSrcweir // minus one since hierarchical is inserted at the start 1808*cdf0e10cSrcweir FilterSelect(pBox->GetSelectEntryPos() - 1, bHierarchical ); 1809*cdf0e10cSrcweir bHierarchical=sal_False; 1810*cdf0e10cSrcweir // UpdateStyles_Impl(UPDATE_FAMILY_LIST); // Anzeige aktualisieren 1811*cdf0e10cSrcweir } 1812*cdf0e10cSrcweir 1813*cdf0e10cSrcweir return 0; 1814*cdf0e10cSrcweir } 1815*cdf0e10cSrcweir 1816*cdf0e10cSrcweir //------------------------------------------------------------------------- 1817*cdf0e10cSrcweir 1818*cdf0e10cSrcweir // Select-Handler der Toolbox 1819*cdf0e10cSrcweir void SfxCommonTemplateDialog_Impl::FamilySelect(sal_uInt16 nEntry) 1820*cdf0e10cSrcweir { 1821*cdf0e10cSrcweir if( nEntry != nActFamily ) 1822*cdf0e10cSrcweir { 1823*cdf0e10cSrcweir CheckItem( nActFamily, sal_False ); 1824*cdf0e10cSrcweir nActFamily = nEntry; 1825*cdf0e10cSrcweir SfxDispatcher* pDispat = pBindings->GetDispatcher_Impl(); 1826*cdf0e10cSrcweir SfxUInt16Item aItem( SID_STYLE_FAMILY, nEntry ); 1827*cdf0e10cSrcweir pDispat->Execute( SID_STYLE_FAMILY, SFX_CALLMODE_SYNCHRON, &aItem, 0L ); 1828*cdf0e10cSrcweir pBindings->Invalidate( SID_STYLE_FAMILY ); 1829*cdf0e10cSrcweir pBindings->Update( SID_STYLE_FAMILY ); 1830*cdf0e10cSrcweir UpdateFamily_Impl(); 1831*cdf0e10cSrcweir } 1832*cdf0e10cSrcweir } 1833*cdf0e10cSrcweir 1834*cdf0e10cSrcweir //------------------------------------------------------------------------- 1835*cdf0e10cSrcweir 1836*cdf0e10cSrcweir void SfxCommonTemplateDialog_Impl::ActionSelect(sal_uInt16 nEntry) 1837*cdf0e10cSrcweir { 1838*cdf0e10cSrcweir String aEmpty; 1839*cdf0e10cSrcweir switch(nEntry) 1840*cdf0e10cSrcweir { 1841*cdf0e10cSrcweir case SID_STYLE_WATERCAN: 1842*cdf0e10cSrcweir { 1843*cdf0e10cSrcweir const sal_Bool bState = IsCheckedItem(nEntry); 1844*cdf0e10cSrcweir sal_Bool bCheck; 1845*cdf0e10cSrcweir SfxBoolItem aBool; 1846*cdf0e10cSrcweir // wenn eine Vorlage ausgewaehlt ist. 1847*cdf0e10cSrcweir if(!bState && aFmtLb.GetSelectionCount()) 1848*cdf0e10cSrcweir { 1849*cdf0e10cSrcweir const String aTemplName( 1850*cdf0e10cSrcweir GetSelectedEntry()); 1851*cdf0e10cSrcweir Execute_Impl( 1852*cdf0e10cSrcweir SID_STYLE_WATERCAN, aTemplName, aEmpty, 1853*cdf0e10cSrcweir (sal_uInt16)GetFamilyItem_Impl()->GetFamily() ); 1854*cdf0e10cSrcweir bCheck = sal_True; 1855*cdf0e10cSrcweir } 1856*cdf0e10cSrcweir else 1857*cdf0e10cSrcweir { 1858*cdf0e10cSrcweir Execute_Impl(SID_STYLE_WATERCAN, aEmpty, aEmpty, 0); 1859*cdf0e10cSrcweir bCheck = sal_False; 1860*cdf0e10cSrcweir } 1861*cdf0e10cSrcweir CheckItem(nEntry, bCheck); 1862*cdf0e10cSrcweir aBool.SetValue(bCheck); 1863*cdf0e10cSrcweir SetWaterCanState(&aBool); 1864*cdf0e10cSrcweir break; 1865*cdf0e10cSrcweir } 1866*cdf0e10cSrcweir case SID_STYLE_NEW_BY_EXAMPLE: 1867*cdf0e10cSrcweir { 1868*cdf0e10cSrcweir if(pStyleSheetPool && nActFamily != 0xffff) 1869*cdf0e10cSrcweir { 1870*cdf0e10cSrcweir const SfxStyleFamily eFam=GetFamilyItem_Impl()->GetFamily(); 1871*cdf0e10cSrcweir //pStyleSheetPool->GetSearchFamily(); 1872*cdf0e10cSrcweir const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl(); 1873*cdf0e10cSrcweir sal_uInt16 nFilter; 1874*cdf0e10cSrcweir if(pItem&&nActFilter!=0xffff) 1875*cdf0e10cSrcweir { 1876*cdf0e10cSrcweir nFilter = pItem->GetFilterList().GetObject( 1877*cdf0e10cSrcweir nActFilter)->nFlags; 1878*cdf0e10cSrcweir if(!nFilter) // automatisch 1879*cdf0e10cSrcweir nFilter = nAppFilter; 1880*cdf0e10cSrcweir } 1881*cdf0e10cSrcweir else 1882*cdf0e10cSrcweir nFilter=pStyleSheetPool->GetSearchMask(); 1883*cdf0e10cSrcweir pStyleSheetPool->SetSearchMask( eFam, SFXSTYLEBIT_USERDEF ); 1884*cdf0e10cSrcweir 1885*cdf0e10cSrcweir SfxNewStyleDlg *pDlg = 1886*cdf0e10cSrcweir // why? : FloatingWindow must not be parent of a modal dialog 1887*cdf0e10cSrcweir new SfxNewStyleDlg(pWindow, *pStyleSheetPool); 1888*cdf0e10cSrcweir if(RET_OK == pDlg->Execute()) 1889*cdf0e10cSrcweir { 1890*cdf0e10cSrcweir pStyleSheetPool->SetSearchMask(eFam, nFilter); 1891*cdf0e10cSrcweir const String aTemplName(pDlg->GetName()); 1892*cdf0e10cSrcweir Execute_Impl(SID_STYLE_NEW_BY_EXAMPLE, 1893*cdf0e10cSrcweir aTemplName, aEmpty, 1894*cdf0e10cSrcweir (sal_uInt16)GetFamilyItem_Impl()->GetFamily(), 1895*cdf0e10cSrcweir nFilter); 1896*cdf0e10cSrcweir } 1897*cdf0e10cSrcweir pStyleSheetPool->SetSearchMask( eFam, nFilter ); 1898*cdf0e10cSrcweir delete pDlg; 1899*cdf0e10cSrcweir } 1900*cdf0e10cSrcweir break; 1901*cdf0e10cSrcweir } 1902*cdf0e10cSrcweir case SID_STYLE_UPDATE_BY_EXAMPLE: 1903*cdf0e10cSrcweir { 1904*cdf0e10cSrcweir Execute_Impl(SID_STYLE_UPDATE_BY_EXAMPLE, 1905*cdf0e10cSrcweir aEmpty, aEmpty, 1906*cdf0e10cSrcweir (sal_uInt16)GetFamilyItem_Impl()->GetFamily()); 1907*cdf0e10cSrcweir break; 1908*cdf0e10cSrcweir } 1909*cdf0e10cSrcweir case SID_TEMPLATE_LOAD: 1910*cdf0e10cSrcweir SFX_APP()->GetDispatcher_Impl()->Execute(nEntry); 1911*cdf0e10cSrcweir break; 1912*cdf0e10cSrcweir default: DBG_ERROR("not implemented"); break; 1913*cdf0e10cSrcweir } 1914*cdf0e10cSrcweir } 1915*cdf0e10cSrcweir 1916*cdf0e10cSrcweir //------------------------------------------------------------------------- 1917*cdf0e10cSrcweir 1918*cdf0e10cSrcweir static rtl::OUString getModuleIdentifier( const Reference< XModuleManager >& i_xModMgr, SfxObjectShell* i_pObjSh ) 1919*cdf0e10cSrcweir { 1920*cdf0e10cSrcweir DBG_ASSERT( i_xModMgr.is(), "getModuleIdentifier(): no XModuleManager" ); 1921*cdf0e10cSrcweir DBG_ASSERT( i_pObjSh, "getModuleIdentifier(): no ObjectShell" ); 1922*cdf0e10cSrcweir 1923*cdf0e10cSrcweir ::rtl::OUString sIdentifier; 1924*cdf0e10cSrcweir 1925*cdf0e10cSrcweir try 1926*cdf0e10cSrcweir { 1927*cdf0e10cSrcweir sIdentifier = i_xModMgr->identify( i_pObjSh->GetModel() ); 1928*cdf0e10cSrcweir } 1929*cdf0e10cSrcweir catch ( ::com::sun::star::frame::UnknownModuleException& ) 1930*cdf0e10cSrcweir { 1931*cdf0e10cSrcweir DBG_WARNING( "getModuleIdentifier(): unknown module" ); 1932*cdf0e10cSrcweir } 1933*cdf0e10cSrcweir catch ( Exception& ) 1934*cdf0e10cSrcweir { 1935*cdf0e10cSrcweir DBG_ERRORFILE( "getModuleIdentifier(): exception of XModuleManager::identify()" ); 1936*cdf0e10cSrcweir } 1937*cdf0e10cSrcweir 1938*cdf0e10cSrcweir return sIdentifier; 1939*cdf0e10cSrcweir } 1940*cdf0e10cSrcweir 1941*cdf0e10cSrcweir //------------------------------------------------------------------------- 1942*cdf0e10cSrcweir 1943*cdf0e10cSrcweir sal_Int32 SfxCommonTemplateDialog_Impl::LoadFactoryStyleFilter( SfxObjectShell* i_pObjSh ) 1944*cdf0e10cSrcweir { 1945*cdf0e10cSrcweir DBG_ASSERT( i_pObjSh, "SfxCommonTemplateDialog_Impl::LoadFactoryStyleFilter(): no ObjectShell" ); 1946*cdf0e10cSrcweir sal_Int32 nFilter = -1; 1947*cdf0e10cSrcweir 1948*cdf0e10cSrcweir Sequence< PropertyValue > lProps; 1949*cdf0e10cSrcweir Reference< ::com::sun::star::container::XNameAccess > xContainer( xModuleManager, UNO_QUERY ); 1950*cdf0e10cSrcweir if ( xContainer.is() ) 1951*cdf0e10cSrcweir { 1952*cdf0e10cSrcweir ::comphelper::SequenceAsHashMap aFactoryProps( 1953*cdf0e10cSrcweir xContainer->getByName( getModuleIdentifier( xModuleManager, i_pObjSh ) ) ); 1954*cdf0e10cSrcweir sal_Int32 nDefault = -1; 1955*cdf0e10cSrcweir nFilter = aFactoryProps.getUnpackedValueOrDefault( DEFINE_CONST_UNICODE("ooSetupFactoryStyleFilter"), nDefault ); 1956*cdf0e10cSrcweir } 1957*cdf0e10cSrcweir 1958*cdf0e10cSrcweir return nFilter; 1959*cdf0e10cSrcweir } 1960*cdf0e10cSrcweir 1961*cdf0e10cSrcweir //------------------------------------------------------------------------- 1962*cdf0e10cSrcweir 1963*cdf0e10cSrcweir void SfxCommonTemplateDialog_Impl::SaveFactoryStyleFilter( SfxObjectShell* i_pObjSh, sal_Int32 i_nFilter ) 1964*cdf0e10cSrcweir { 1965*cdf0e10cSrcweir DBG_ASSERT( i_pObjSh, "SfxCommonTemplateDialog_Impl::LoadFactoryStyleFilter(): no ObjectShell" ); 1966*cdf0e10cSrcweir Reference< ::com::sun::star::container::XNameReplace > xContainer( xModuleManager, UNO_QUERY ); 1967*cdf0e10cSrcweir if ( xContainer.is() ) 1968*cdf0e10cSrcweir { 1969*cdf0e10cSrcweir Sequence< PropertyValue > lProps(1); 1970*cdf0e10cSrcweir lProps[0].Name = DEFINE_CONST_UNICODE("ooSetupFactoryStyleFilter"); 1971*cdf0e10cSrcweir lProps[0].Value = makeAny( i_nFilter );; 1972*cdf0e10cSrcweir xContainer->replaceByName( getModuleIdentifier( xModuleManager, i_pObjSh ), makeAny( lProps ) ); 1973*cdf0e10cSrcweir } 1974*cdf0e10cSrcweir } 1975*cdf0e10cSrcweir 1976*cdf0e10cSrcweir //------------------------------------------------------------------------- 1977*cdf0e10cSrcweir 1978*cdf0e10cSrcweir IMPL_LINK( SfxCommonTemplateDialog_Impl, DropHdl, StyleTreeListBox_Impl *, pBox ) 1979*cdf0e10cSrcweir { 1980*cdf0e10cSrcweir bDontUpdate=sal_True; 1981*cdf0e10cSrcweir const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl(); 1982*cdf0e10cSrcweir const SfxStyleFamily eFam = pItem->GetFamily(); 1983*cdf0e10cSrcweir long ret= pStyleSheetPool->SetParent(eFam,pBox->GetStyle(), pBox->GetParent())? 1L: 0L; 1984*cdf0e10cSrcweir bDontUpdate=sal_False; 1985*cdf0e10cSrcweir return ret; 1986*cdf0e10cSrcweir } 1987*cdf0e10cSrcweir 1988*cdf0e10cSrcweir //------------------------------------------------------------------------- 1989*cdf0e10cSrcweir 1990*cdf0e10cSrcweir // Handler des Neu-Buttons 1991*cdf0e10cSrcweir void SfxCommonTemplateDialog_Impl::NewHdl(void *) 1992*cdf0e10cSrcweir { 1993*cdf0e10cSrcweir String aEmpty; 1994*cdf0e10cSrcweir if ( nActFamily != 0xffff ) 1995*cdf0e10cSrcweir { 1996*cdf0e10cSrcweir Window* pTmp; 1997*cdf0e10cSrcweir pTmp = Application::GetDefDialogParent(); 1998*cdf0e10cSrcweir if ( ISA(SfxTemplateDialog_Impl) ) 1999*cdf0e10cSrcweir Application::SetDefDialogParent( pWindow->GetParent() ); 2000*cdf0e10cSrcweir else 2001*cdf0e10cSrcweir Application::SetDefDialogParent( pWindow ); 2002*cdf0e10cSrcweir 2003*cdf0e10cSrcweir const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl(); 2004*cdf0e10cSrcweir const SfxStyleFamily eFam=pItem->GetFamily(); 2005*cdf0e10cSrcweir sal_uInt16 nMask; 2006*cdf0e10cSrcweir if(pItem&&nActFilter!=0xffff) 2007*cdf0e10cSrcweir { 2008*cdf0e10cSrcweir nMask = pItem->GetFilterList().GetObject( 2009*cdf0e10cSrcweir nActFilter)->nFlags; 2010*cdf0e10cSrcweir if(!nMask) // automatisch 2011*cdf0e10cSrcweir nMask = nAppFilter; 2012*cdf0e10cSrcweir } 2013*cdf0e10cSrcweir else 2014*cdf0e10cSrcweir nMask=pStyleSheetPool->GetSearchMask(); 2015*cdf0e10cSrcweir 2016*cdf0e10cSrcweir pStyleSheetPool->SetSearchMask(eFam,nMask); 2017*cdf0e10cSrcweir 2018*cdf0e10cSrcweir Execute_Impl(SID_STYLE_NEW, 2019*cdf0e10cSrcweir aEmpty, GetSelectedEntry(), 2020*cdf0e10cSrcweir ( sal_uInt16 )GetFamilyItem_Impl()->GetFamily(), 2021*cdf0e10cSrcweir nMask); 2022*cdf0e10cSrcweir 2023*cdf0e10cSrcweir Application::SetDefDialogParent( pTmp ); 2024*cdf0e10cSrcweir 2025*cdf0e10cSrcweir /* { 2026*cdf0e10cSrcweir DBG_ASSERT(nFilter < aFilterLb.GetEntryCount(), 2027*cdf0e10cSrcweir "Filter ueberindiziert"); 2028*cdf0e10cSrcweir 2029*cdf0e10cSrcweir if(!pTreeBox) 2030*cdf0e10cSrcweir { 2031*cdf0e10cSrcweir // aFilterLb.SelectEntryPos(nFilter); 2032*cdf0e10cSrcweir FilterSelect(nActFilter, sal_True); 2033*cdf0e10cSrcweir } 2034*cdf0e10cSrcweir else 2035*cdf0e10cSrcweir { 2036*cdf0e10cSrcweir FillTreeBox(); 2037*cdf0e10cSrcweir SfxTemplateItem *pState = pFamilyState[nActFamily-1]; 2038*cdf0e10cSrcweir if(pState) 2039*cdf0e10cSrcweir { 2040*cdf0e10cSrcweir const String aStyle(pState->GetStyleName()); 2041*cdf0e10cSrcweir SelectStyle(aStyle); 2042*cdf0e10cSrcweir } 2043*cdf0e10cSrcweir EnableDelete(); 2044*cdf0e10cSrcweir }*/ 2045*cdf0e10cSrcweir // } 2046*cdf0e10cSrcweir } 2047*cdf0e10cSrcweir } 2048*cdf0e10cSrcweir 2049*cdf0e10cSrcweir //------------------------------------------------------------------------- 2050*cdf0e10cSrcweir 2051*cdf0e10cSrcweir // Handler des Bearbeiten-Buttons 2052*cdf0e10cSrcweir void SfxCommonTemplateDialog_Impl::EditHdl(void *) 2053*cdf0e10cSrcweir { 2054*cdf0e10cSrcweir if(IsInitialized() && HasSelectedStyle()) 2055*cdf0e10cSrcweir { 2056*cdf0e10cSrcweir sal_uInt16 nFilter = nActFilter; 2057*cdf0e10cSrcweir String aTemplName(GetSelectedEntry()); 2058*cdf0e10cSrcweir const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl(); 2059*cdf0e10cSrcweir const SfxStyleFamily eFam = pItem->GetFamily(); 2060*cdf0e10cSrcweir pStyleSheetPool->Find(aTemplName,eFam,SFXSTYLEBIT_ALL); // -Wall required?? 2061*cdf0e10cSrcweir Window* pTmp; 2062*cdf0e10cSrcweir //DefModalDialogParent setzen fuer 2063*cdf0e10cSrcweir //Modalitaet der nachfolgenden Dialoge 2064*cdf0e10cSrcweir pTmp = Application::GetDefDialogParent(); 2065*cdf0e10cSrcweir if ( ISA(SfxTemplateDialog_Impl) ) 2066*cdf0e10cSrcweir Application::SetDefDialogParent( pWindow->GetParent() ); 2067*cdf0e10cSrcweir else 2068*cdf0e10cSrcweir Application::SetDefDialogParent( pWindow ); 2069*cdf0e10cSrcweir if ( Execute_Impl( SID_STYLE_EDIT, aTemplName, String(), 2070*cdf0e10cSrcweir (sal_uInt16)GetFamilyItem_Impl()->GetFamily(), 0, &nFilter ) ) 2071*cdf0e10cSrcweir { 2072*cdf0e10cSrcweir // DBG_ASSERT(nFilter < aFilterLb.GetEntryCount(), "Filter ueberindiziert"); 2073*cdf0e10cSrcweir // aTemplName = pStyle->GetName(); 2074*cdf0e10cSrcweir // kann durch Bearbeiten umbenannt worden sein 2075*cdf0e10cSrcweir /* if(!pTreeBox) 2076*cdf0e10cSrcweir { 2077*cdf0e10cSrcweir // aFilterLb.SelectEntryPos(nFilter); 2078*cdf0e10cSrcweir // FilterSelect(nFilter, sal_True); 2079*cdf0e10cSrcweir } 2080*cdf0e10cSrcweir else 2081*cdf0e10cSrcweir FillTreeBox();*/ 2082*cdf0e10cSrcweir } 2083*cdf0e10cSrcweir Application::SetDefDialogParent( pTmp ); 2084*cdf0e10cSrcweir } 2085*cdf0e10cSrcweir } 2086*cdf0e10cSrcweir 2087*cdf0e10cSrcweir //------------------------------------------------------------------------- 2088*cdf0e10cSrcweir 2089*cdf0e10cSrcweir // Handler des L"oschen-Buttons 2090*cdf0e10cSrcweir void SfxCommonTemplateDialog_Impl::DeleteHdl(void *) 2091*cdf0e10cSrcweir { 2092*cdf0e10cSrcweir if ( IsInitialized() && HasSelectedStyle() ) 2093*cdf0e10cSrcweir { 2094*cdf0e10cSrcweir const String aTemplName( GetSelectedEntry() ); 2095*cdf0e10cSrcweir const SfxStyleFamilyItem* pItem = GetFamilyItem_Impl(); 2096*cdf0e10cSrcweir SfxStyleSheetBase* pStyle = 2097*cdf0e10cSrcweir pStyleSheetPool->Find( aTemplName, pItem->GetFamily(), SFXSTYLEBIT_ALL ); 2098*cdf0e10cSrcweir if ( pStyle ) 2099*cdf0e10cSrcweir { 2100*cdf0e10cSrcweir String aMsg; 2101*cdf0e10cSrcweir if ( pStyle->IsUsed() ) 2102*cdf0e10cSrcweir aMsg = String( SfxResId( STR_DELETE_STYLE_USED ) ); 2103*cdf0e10cSrcweir aMsg += String ( SfxResId( STR_DELETE_STYLE ) ); 2104*cdf0e10cSrcweir aMsg.SearchAndReplaceAscii( "$1", aTemplName ); 2105*cdf0e10cSrcweir #if defined UNX 2106*cdf0e10cSrcweir QueryBox aBox( SFX_APP()->GetTopWindow(), WB_YES_NO | WB_DEF_NO, aMsg ); 2107*cdf0e10cSrcweir #else 2108*cdf0e10cSrcweir QueryBox aBox( GetWindow(), WB_YES_NO | WB_DEF_NO , aMsg ); 2109*cdf0e10cSrcweir #endif 2110*cdf0e10cSrcweir if ( RET_YES == aBox.Execute() ) 2111*cdf0e10cSrcweir { 2112*cdf0e10cSrcweir PrepareDeleteAction(); 2113*cdf0e10cSrcweir 2114*cdf0e10cSrcweir if ( pTreeBox ) // Damit die Treelistbox beim L"oschen nicht zuklappt 2115*cdf0e10cSrcweir { 2116*cdf0e10cSrcweir bDontUpdate = sal_True; 2117*cdf0e10cSrcweir } 2118*cdf0e10cSrcweir Execute_Impl( SID_STYLE_DELETE, aTemplName, 2119*cdf0e10cSrcweir String(), (sal_uInt16)GetFamilyItem_Impl()->GetFamily() ); 2120*cdf0e10cSrcweir 2121*cdf0e10cSrcweir if ( pTreeBox ) 2122*cdf0e10cSrcweir { 2123*cdf0e10cSrcweir pTreeBox->RemoveParentKeepChilds( pTreeBox->FirstSelected() ); 2124*cdf0e10cSrcweir bDontUpdate = sal_False; 2125*cdf0e10cSrcweir } 2126*cdf0e10cSrcweir } 2127*cdf0e10cSrcweir } 2128*cdf0e10cSrcweir } 2129*cdf0e10cSrcweir } 2130*cdf0e10cSrcweir 2131*cdf0e10cSrcweir //------------------------------------------------------------------------- 2132*cdf0e10cSrcweir 2133*cdf0e10cSrcweir void SfxCommonTemplateDialog_Impl::EnableDelete() 2134*cdf0e10cSrcweir { 2135*cdf0e10cSrcweir if(IsInitialized() && HasSelectedStyle()) 2136*cdf0e10cSrcweir { 2137*cdf0e10cSrcweir DBG_ASSERT(pStyleSheetPool, "Kein StyleSheetPool"); 2138*cdf0e10cSrcweir const String aTemplName(GetSelectedEntry()); 2139*cdf0e10cSrcweir const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl(); 2140*cdf0e10cSrcweir const SfxStyleFamily eFam = pItem->GetFamily(); 2141*cdf0e10cSrcweir sal_uInt16 nFilter = 0; 2142*cdf0e10cSrcweir if(pItem->GetFilterList().Count() > nActFilter) 2143*cdf0e10cSrcweir nFilter = pItem->GetFilterList().GetObject(nActFilter)->nFlags; 2144*cdf0e10cSrcweir if(!nFilter) // automatisch 2145*cdf0e10cSrcweir nFilter = nAppFilter; 2146*cdf0e10cSrcweir const SfxStyleSheetBase *pStyle = 2147*cdf0e10cSrcweir pStyleSheetPool->Find(aTemplName,eFam, 2148*cdf0e10cSrcweir pTreeBox? SFXSTYLEBIT_ALL: nFilter); 2149*cdf0e10cSrcweir DBG_ASSERT(pStyle, "Style nicht gefunden"); 2150*cdf0e10cSrcweir if(pStyle && pStyle->IsUserDefined()) 2151*cdf0e10cSrcweir { 2152*cdf0e10cSrcweir EnableDel(sal_True); 2153*cdf0e10cSrcweir } 2154*cdf0e10cSrcweir else 2155*cdf0e10cSrcweir { 2156*cdf0e10cSrcweir EnableDel(sal_False); 2157*cdf0e10cSrcweir } 2158*cdf0e10cSrcweir } 2159*cdf0e10cSrcweir else 2160*cdf0e10cSrcweir { 2161*cdf0e10cSrcweir EnableDel(sal_False); 2162*cdf0e10cSrcweir } 2163*cdf0e10cSrcweir // rBindings.Invalidate( SID_STYLE_DELETE ); 2164*cdf0e10cSrcweir // rBindings.Update( SID_STYLE_DELETE ); 2165*cdf0e10cSrcweir } 2166*cdf0e10cSrcweir 2167*cdf0e10cSrcweir //------------------------------------------------------------------------- 2168*cdf0e10cSrcweir 2169*cdf0e10cSrcweir // nach Selektion eines Eintrags den Focus gfs. wieder auf das App-Fenster 2170*cdf0e10cSrcweir // setzen 2171*cdf0e10cSrcweir void SfxCommonTemplateDialog_Impl::ResetFocus() 2172*cdf0e10cSrcweir { 2173*cdf0e10cSrcweir if(ISA(SfxTemplateDialog_Impl)) 2174*cdf0e10cSrcweir { 2175*cdf0e10cSrcweir SfxViewFrame *pViewFrame = pBindings->GetDispatcher_Impl()->GetFrame(); 2176*cdf0e10cSrcweir SfxViewShell *pVu = pViewFrame->GetViewShell(); 2177*cdf0e10cSrcweir Window *pAppWin = pVu ? pVu->GetWindow(): 0; 2178*cdf0e10cSrcweir if(pAppWin) 2179*cdf0e10cSrcweir pAppWin->GrabFocus(); 2180*cdf0e10cSrcweir } 2181*cdf0e10cSrcweir } 2182*cdf0e10cSrcweir 2183*cdf0e10cSrcweir //------------------------------------------------------------------------- 2184*cdf0e10cSrcweir 2185*cdf0e10cSrcweir // Doppelclick auf ein StyleSheet in der ListBox, wird angewendet. 2186*cdf0e10cSrcweir IMPL_LINK( SfxCommonTemplateDialog_Impl, ApplyHdl, Control *, pControl ) 2187*cdf0e10cSrcweir { 2188*cdf0e10cSrcweir (void)pControl; //unused 2189*cdf0e10cSrcweir // nur, wenn dieser Bereich erlaubt ist 2190*cdf0e10cSrcweir if ( IsInitialized() && 0 != pFamilyState[nActFamily-1] && 2191*cdf0e10cSrcweir GetSelectedEntry().Len() ) 2192*cdf0e10cSrcweir { 2193*cdf0e10cSrcweir sal_uInt16 nModifier = aFmtLb.GetModifier(); 2194*cdf0e10cSrcweir Execute_Impl(SID_STYLE_APPLY, 2195*cdf0e10cSrcweir GetSelectedEntry(), String(), 2196*cdf0e10cSrcweir ( sal_uInt16 )GetFamilyItem_Impl()->GetFamily(), 2197*cdf0e10cSrcweir 0, 0, &nModifier ); 2198*cdf0e10cSrcweir if(ISA(SfxTemplateCatalog_Impl)) 2199*cdf0e10cSrcweir ((SfxTemplateCatalog_Impl*) this)->pReal->EndDialog(RET_OK); 2200*cdf0e10cSrcweir } 2201*cdf0e10cSrcweir ResetFocus(); 2202*cdf0e10cSrcweir return 0; 2203*cdf0e10cSrcweir } 2204*cdf0e10cSrcweir 2205*cdf0e10cSrcweir //------------------------------------------------------------------------- 2206*cdf0e10cSrcweir 2207*cdf0e10cSrcweir // Selektion einer Vorlage w"ahrend des Watercan-Status 2208*cdf0e10cSrcweir IMPL_LINK( SfxCommonTemplateDialog_Impl, FmtSelectHdl, SvTreeListBox *, pListBox ) 2209*cdf0e10cSrcweir { 2210*cdf0e10cSrcweir // HilfePI antriggern, wenn von Call als Handler und Bereich erlaubt ist 2211*cdf0e10cSrcweir if( !pListBox || pListBox->IsSelected( pListBox->GetHdlEntry() ) ) 2212*cdf0e10cSrcweir { 2213*cdf0e10cSrcweir // nur, wenn Giesskanne an ist 2214*cdf0e10cSrcweir if ( IsInitialized() && 2215*cdf0e10cSrcweir IsCheckedItem(SID_STYLE_WATERCAN) && 2216*cdf0e10cSrcweir // nur, wenn dieser Bereich erlaubt ist 2217*cdf0e10cSrcweir 0 != pFamilyState[nActFamily-1] ) 2218*cdf0e10cSrcweir { 2219*cdf0e10cSrcweir String aEmpty; 2220*cdf0e10cSrcweir Execute_Impl(SID_STYLE_WATERCAN, 2221*cdf0e10cSrcweir aEmpty, aEmpty, 0); 2222*cdf0e10cSrcweir Execute_Impl(SID_STYLE_WATERCAN, 2223*cdf0e10cSrcweir GetSelectedEntry(), aEmpty, 2224*cdf0e10cSrcweir ( sal_uInt16 )GetFamilyItem_Impl()->GetFamily()); 2225*cdf0e10cSrcweir } 2226*cdf0e10cSrcweir // EnableEdit(sal_True); 2227*cdf0e10cSrcweir EnableItem(SID_STYLE_WATERCAN, !bWaterDisabled); 2228*cdf0e10cSrcweir EnableDelete(); 2229*cdf0e10cSrcweir } 2230*cdf0e10cSrcweir if( pListBox ) 2231*cdf0e10cSrcweir SelectStyle( pListBox->GetEntryText( pListBox->GetHdlEntry() )); 2232*cdf0e10cSrcweir 2233*cdf0e10cSrcweir return 0; 2234*cdf0e10cSrcweir } 2235*cdf0e10cSrcweir 2236*cdf0e10cSrcweir //------------------------------------------------------------------------- 2237*cdf0e10cSrcweir 2238*cdf0e10cSrcweir IMPL_LINK( SfxCommonTemplateDialog_Impl, MenuSelectHdl, Menu *, pMenu ) 2239*cdf0e10cSrcweir { 2240*cdf0e10cSrcweir if( pMenu ) 2241*cdf0e10cSrcweir { 2242*cdf0e10cSrcweir nLastItemId = pMenu->GetCurItemId(); 2243*cdf0e10cSrcweir Application::PostUserEvent( 2244*cdf0e10cSrcweir LINK( this, SfxCommonTemplateDialog_Impl, MenuSelectHdl ), 0 ); 2245*cdf0e10cSrcweir return sal_True; 2246*cdf0e10cSrcweir } 2247*cdf0e10cSrcweir 2248*cdf0e10cSrcweir switch(nLastItemId) { 2249*cdf0e10cSrcweir case ID_NEW: NewHdl(0); break; 2250*cdf0e10cSrcweir case ID_EDIT: EditHdl(0); break; 2251*cdf0e10cSrcweir case ID_DELETE: DeleteHdl(0); break; 2252*cdf0e10cSrcweir default: return sal_False; 2253*cdf0e10cSrcweir } 2254*cdf0e10cSrcweir return sal_True; 2255*cdf0e10cSrcweir } 2256*cdf0e10cSrcweir 2257*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2258*cdf0e10cSrcweir 2259*cdf0e10cSrcweir void SfxCommonTemplateDialog_Impl::ExecuteContextMenu_Impl( const Point& rPos, Window* pWin ) 2260*cdf0e10cSrcweir { 2261*cdf0e10cSrcweir // Bug# 94152: This part should never be called, because before this happens, the TreeListBox should captured this! 2262*cdf0e10cSrcweir DBG_ASSERT( sal_False, "+SfxCommonTemplateDialog_Impl::ExecuteContextMenu_Impl(): How could this happen? Please infirm developer ASAP!" ); 2263*cdf0e10cSrcweir 2264*cdf0e10cSrcweir PopupMenu* pMenu = CreateContextMenu(); 2265*cdf0e10cSrcweir pMenu->Execute( pWin, rPos ); 2266*cdf0e10cSrcweir delete pMenu; 2267*cdf0e10cSrcweir } 2268*cdf0e10cSrcweir 2269*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2270*cdf0e10cSrcweir 2271*cdf0e10cSrcweir SfxStyleFamily SfxCommonTemplateDialog_Impl::GetActualFamily() const 2272*cdf0e10cSrcweir { 2273*cdf0e10cSrcweir const SfxStyleFamilyItem *pFamilyItem = GetFamilyItem_Impl(); 2274*cdf0e10cSrcweir if( !pFamilyItem || nActFamily == 0xffff ) 2275*cdf0e10cSrcweir return SFX_STYLE_FAMILY_PARA; 2276*cdf0e10cSrcweir else 2277*cdf0e10cSrcweir return pFamilyItem->GetFamily(); 2278*cdf0e10cSrcweir } 2279*cdf0e10cSrcweir 2280*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2281*cdf0e10cSrcweir 2282*cdf0e10cSrcweir void SfxCommonTemplateDialog_Impl::EnableExample_Impl(sal_uInt16 nId, sal_Bool bEnable) 2283*cdf0e10cSrcweir { 2284*cdf0e10cSrcweir if( nId == SID_STYLE_NEW_BY_EXAMPLE ) 2285*cdf0e10cSrcweir bNewByExampleDisabled = !bEnable; 2286*cdf0e10cSrcweir else if( nId == SID_STYLE_UPDATE_BY_EXAMPLE ) 2287*cdf0e10cSrcweir bUpdateByExampleDisabled = !bEnable; 2288*cdf0e10cSrcweir EnableItem(nId, bEnable); 2289*cdf0e10cSrcweir } 2290*cdf0e10cSrcweir 2291*cdf0e10cSrcweir void SfxCommonTemplateDialog_Impl::PrepareDeleteAction() 2292*cdf0e10cSrcweir { 2293*cdf0e10cSrcweir } 2294*cdf0e10cSrcweir 2295*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2296*cdf0e10cSrcweir 2297*cdf0e10cSrcweir PopupMenu* SfxCommonTemplateDialog_Impl::CreateContextMenu( void ) 2298*cdf0e10cSrcweir { 2299*cdf0e10cSrcweir if ( bBindingUpdate ) 2300*cdf0e10cSrcweir { 2301*cdf0e10cSrcweir pBindings->Invalidate( SID_STYLE_NEW, sal_True, sal_False ); 2302*cdf0e10cSrcweir pBindings->Update( SID_STYLE_NEW ); 2303*cdf0e10cSrcweir bBindingUpdate = sal_False; 2304*cdf0e10cSrcweir } 2305*cdf0e10cSrcweir PopupMenu* pMenu = new PopupMenu( SfxResId( MN_CONTEXT_TEMPLDLG ) ); 2306*cdf0e10cSrcweir pMenu->SetSelectHdl( LINK( this, SfxCommonTemplateDialog_Impl, MenuSelectHdl ) ); 2307*cdf0e10cSrcweir pMenu->EnableItem( ID_EDIT, bCanEdit ); 2308*cdf0e10cSrcweir pMenu->EnableItem( ID_DELETE, bCanDel ); 2309*cdf0e10cSrcweir pMenu->EnableItem( ID_NEW, bCanNew ); 2310*cdf0e10cSrcweir 2311*cdf0e10cSrcweir return pMenu; 2312*cdf0e10cSrcweir } 2313*cdf0e10cSrcweir 2314*cdf0e10cSrcweir // ------------------------------------------------------------------------ 2315*cdf0e10cSrcweir 2316*cdf0e10cSrcweir SfxTemplateDialog_Impl::SfxTemplateDialog_Impl( 2317*cdf0e10cSrcweir Window* /*pParent*/, SfxBindings* pB, SfxTemplateDialog* pDlgWindow ) : 2318*cdf0e10cSrcweir 2319*cdf0e10cSrcweir SfxCommonTemplateDialog_Impl( pB, pDlgWindow ), 2320*cdf0e10cSrcweir 2321*cdf0e10cSrcweir m_pFloat ( pDlgWindow ), 2322*cdf0e10cSrcweir m_bZoomIn ( sal_False ), 2323*cdf0e10cSrcweir m_aActionTbL ( pDlgWindow, this ), 2324*cdf0e10cSrcweir m_aActionTbR ( pDlgWindow, SfxResId( TB_ACTION ) ) 2325*cdf0e10cSrcweir 2326*cdf0e10cSrcweir { 2327*cdf0e10cSrcweir pDlgWindow->FreeResource(); 2328*cdf0e10cSrcweir Initialize(); 2329*cdf0e10cSrcweir 2330*cdf0e10cSrcweir m_aActionTbL.SetSelectHdl(LINK(this, SfxTemplateDialog_Impl, ToolBoxLSelect)); 2331*cdf0e10cSrcweir m_aActionTbR.SetSelectHdl(LINK(this, SfxTemplateDialog_Impl, ToolBoxRSelect)); 2332*cdf0e10cSrcweir m_aActionTbR.SetDropdownClickHdl(LINK(this, SfxTemplateDialog_Impl, ToolBoxRClick)); 2333*cdf0e10cSrcweir m_aActionTbL.Show(); 2334*cdf0e10cSrcweir m_aActionTbR.Show(); 2335*cdf0e10cSrcweir Font aFont=aFilterLb.GetFont(); 2336*cdf0e10cSrcweir aFont.SetWeight( WEIGHT_NORMAL ); 2337*cdf0e10cSrcweir aFilterLb.SetFont( aFont ); 2338*cdf0e10cSrcweir m_aActionTbL.SetHelpId( HID_TEMPLDLG_TOOLBOX_LEFT ); 2339*cdf0e10cSrcweir } 2340*cdf0e10cSrcweir 2341*cdf0e10cSrcweir // ------------------------------------------------------------------------ 2342*cdf0e10cSrcweir 2343*cdf0e10cSrcweir void SfxTemplateDialog_Impl::EnableFamilyItem( sal_uInt16 nId, sal_Bool bEnable ) 2344*cdf0e10cSrcweir { 2345*cdf0e10cSrcweir m_aActionTbL.EnableItem( nId, bEnable ); 2346*cdf0e10cSrcweir } 2347*cdf0e10cSrcweir 2348*cdf0e10cSrcweir //------------------------------------------------------------------------- 2349*cdf0e10cSrcweir 2350*cdf0e10cSrcweir void SfxTemplateDialog_Impl::InsertFamilyItem(sal_uInt16 nId,const SfxStyleFamilyItem *pItem) 2351*cdf0e10cSrcweir { 2352*cdf0e10cSrcweir rtl::OString sHelpId; 2353*cdf0e10cSrcweir switch( (sal_uInt16) pItem->GetFamily() ) 2354*cdf0e10cSrcweir { 2355*cdf0e10cSrcweir case SFX_STYLE_FAMILY_CHAR: sHelpId = ".uno:CharStyle"; break; 2356*cdf0e10cSrcweir case SFX_STYLE_FAMILY_PARA: sHelpId = ".uno:ParaStyle"; break; 2357*cdf0e10cSrcweir case SFX_STYLE_FAMILY_FRAME: sHelpId = ".uno:FrameStyle"; break; 2358*cdf0e10cSrcweir case SFX_STYLE_FAMILY_PAGE: sHelpId = ".uno:PageStyle"; break; 2359*cdf0e10cSrcweir case SFX_STYLE_FAMILY_PSEUDO: sHelpId = ".uno:ListStyle"; break; 2360*cdf0e10cSrcweir default: DBG_ERROR("unknown StyleFamily"); break; 2361*cdf0e10cSrcweir } 2362*cdf0e10cSrcweir m_aActionTbL.InsertItem( nId, pItem->GetImage(), pItem->GetText(), 0, 0); 2363*cdf0e10cSrcweir m_aActionTbL.SetHelpId( nId, sHelpId ); 2364*cdf0e10cSrcweir } 2365*cdf0e10cSrcweir 2366*cdf0e10cSrcweir // ------------------------------------------------------------------------ 2367*cdf0e10cSrcweir 2368*cdf0e10cSrcweir void SfxTemplateDialog_Impl::ReplaceUpdateButtonByMenu() 2369*cdf0e10cSrcweir { 2370*cdf0e10cSrcweir m_aActionTbR.HideItem(SID_STYLE_UPDATE_BY_EXAMPLE); 2371*cdf0e10cSrcweir m_aActionTbR.SetItemBits( SID_STYLE_NEW_BY_EXAMPLE, 2372*cdf0e10cSrcweir TIB_DROPDOWNONLY|m_aActionTbR.GetItemBits( SID_STYLE_NEW_BY_EXAMPLE )); 2373*cdf0e10cSrcweir } 2374*cdf0e10cSrcweir 2375*cdf0e10cSrcweir // ------------------------------------------------------------------------ 2376*cdf0e10cSrcweir void SfxTemplateDialog_Impl::updateFamilyImages() 2377*cdf0e10cSrcweir { 2378*cdf0e10cSrcweir if ( !m_pStyleFamiliesId ) 2379*cdf0e10cSrcweir // we do not have a resource id to load the new images from 2380*cdf0e10cSrcweir return; 2381*cdf0e10cSrcweir 2382*cdf0e10cSrcweir // let the families collection update the images 2383*cdf0e10cSrcweir sal_Bool bIsHighContrast = m_pFloat->GetSettings().GetStyleSettings().GetHighContrastMode(); 2384*cdf0e10cSrcweir pStyleFamilies->updateImages( *m_pStyleFamiliesId, bIsHighContrast ? BMP_COLOR_HIGHCONTRAST : BMP_COLOR_NORMAL ); 2385*cdf0e10cSrcweir 2386*cdf0e10cSrcweir // and set the new images on our toolbox 2387*cdf0e10cSrcweir sal_uInt16 nLoop = pStyleFamilies->Count(); 2388*cdf0e10cSrcweir for( ; nLoop--; ) 2389*cdf0e10cSrcweir { 2390*cdf0e10cSrcweir const SfxStyleFamilyItem *pItem = pStyleFamilies->GetObject( nLoop ); 2391*cdf0e10cSrcweir sal_uInt16 nId = SfxFamilyIdToNId( pItem->GetFamily() ); 2392*cdf0e10cSrcweir m_aActionTbL.SetItemImage( nId, pItem->GetImage() ); 2393*cdf0e10cSrcweir } 2394*cdf0e10cSrcweir } 2395*cdf0e10cSrcweir 2396*cdf0e10cSrcweir // ------------------------------------------------------------------------ 2397*cdf0e10cSrcweir void SfxTemplateDialog_Impl::updateNonFamilyImages() 2398*cdf0e10cSrcweir { 2399*cdf0e10cSrcweir m_aActionTbR.SetImageList( ImageList( SfxResId( 2400*cdf0e10cSrcweir m_pFloat->GetSettings().GetStyleSettings().GetHighContrastMode() ? IMG_LST_STYLE_DESIGNER_HC 2401*cdf0e10cSrcweir : DLG_STYLE_DESIGNER ) ) ); 2402*cdf0e10cSrcweir } 2403*cdf0e10cSrcweir 2404*cdf0e10cSrcweir // ------------------------------------------------------------------------ 2405*cdf0e10cSrcweir 2406*cdf0e10cSrcweir void SfxTemplateDialog_Impl::ClearFamilyList() 2407*cdf0e10cSrcweir { 2408*cdf0e10cSrcweir m_aActionTbL.Clear(); 2409*cdf0e10cSrcweir } 2410*cdf0e10cSrcweir 2411*cdf0e10cSrcweir //------------------------------------------------------------------------- 2412*cdf0e10cSrcweir 2413*cdf0e10cSrcweir void SfxCommonTemplateDialog_Impl::InvalidateBindings() 2414*cdf0e10cSrcweir { 2415*cdf0e10cSrcweir pBindings->Invalidate(SID_STYLE_NEW_BY_EXAMPLE, sal_True, sal_False); 2416*cdf0e10cSrcweir pBindings->Update( SID_STYLE_NEW_BY_EXAMPLE ); 2417*cdf0e10cSrcweir pBindings->Invalidate(SID_STYLE_UPDATE_BY_EXAMPLE, sal_True, sal_False); 2418*cdf0e10cSrcweir pBindings->Update( SID_STYLE_UPDATE_BY_EXAMPLE ); 2419*cdf0e10cSrcweir pBindings->Invalidate( SID_STYLE_WATERCAN, sal_True, sal_False); 2420*cdf0e10cSrcweir pBindings->Update( SID_STYLE_WATERCAN ); 2421*cdf0e10cSrcweir pBindings->Invalidate( SID_STYLE_NEW, sal_True, sal_False ); 2422*cdf0e10cSrcweir pBindings->Update( SID_STYLE_NEW ); 2423*cdf0e10cSrcweir pBindings->Invalidate( SID_STYLE_DRAGHIERARCHIE, sal_True, sal_False ); 2424*cdf0e10cSrcweir pBindings->Update( SID_STYLE_DRAGHIERARCHIE ); 2425*cdf0e10cSrcweir } 2426*cdf0e10cSrcweir 2427*cdf0e10cSrcweir //------------------------------------------------------------------------- 2428*cdf0e10cSrcweir 2429*cdf0e10cSrcweir SfxTemplateDialog_Impl::~SfxTemplateDialog_Impl() 2430*cdf0e10cSrcweir { 2431*cdf0e10cSrcweir /* 2432*cdf0e10cSrcweir SfxImageManager* pImgMgr = pBindings->GetImageManager(); 2433*cdf0e10cSrcweir if ( pImgMgr ) 2434*cdf0e10cSrcweir { 2435*cdf0e10cSrcweir pImgMgr->ReleaseToolBox( &m_aActionTbL ); 2436*cdf0e10cSrcweir pImgMgr->ReleaseToolBox( &m_aActionTbR ); 2437*cdf0e10cSrcweir } 2438*cdf0e10cSrcweir */ 2439*cdf0e10cSrcweir } 2440*cdf0e10cSrcweir 2441*cdf0e10cSrcweir //------------------------------------------------------------------------- 2442*cdf0e10cSrcweir 2443*cdf0e10cSrcweir void SfxTemplateDialog_Impl::LoadedFamilies() 2444*cdf0e10cSrcweir { 2445*cdf0e10cSrcweir updateFamilyImages(); 2446*cdf0e10cSrcweir Resize(); 2447*cdf0e10cSrcweir } 2448*cdf0e10cSrcweir 2449*cdf0e10cSrcweir //------------------------------------------------------------------------- 2450*cdf0e10cSrcweir 2451*cdf0e10cSrcweir // "Uberladener Resize-Handler ( StarView ) 2452*cdf0e10cSrcweir // Die Groesse der Listboxen wird angepasst 2453*cdf0e10cSrcweir void SfxTemplateDialog_Impl::Resize() 2454*cdf0e10cSrcweir { 2455*cdf0e10cSrcweir FloatingWindow *pF = m_pFloat->GetFloatingWindow(); 2456*cdf0e10cSrcweir if ( pF ) 2457*cdf0e10cSrcweir { 2458*cdf0e10cSrcweir // if(pF->IsZoomedIn() && m_bZoomIn==sal_False) 2459*cdf0e10cSrcweir // pF->SetText(String(SfxResId( DLG_STYLE_DESIGNER ))); 2460*cdf0e10cSrcweir // if(!pF->IsZoomedIn() && m_bZoomIn==sal_True && GetFamilyItem_Impl()) 2461*cdf0e10cSrcweir // UpdateStyles_Impl(UPDATE_FAMILY); //Bereich wieder in Titel schreiben 2462*cdf0e10cSrcweir m_bZoomIn = pF->IsRollUp(); 2463*cdf0e10cSrcweir if ( m_bZoomIn ) 2464*cdf0e10cSrcweir return; 2465*cdf0e10cSrcweir } 2466*cdf0e10cSrcweir 2467*cdf0e10cSrcweir Size aDlgSize=m_pFloat->PixelToLogic(m_pFloat->GetOutputSizePixel()); 2468*cdf0e10cSrcweir Size aSizeATL=m_pFloat->PixelToLogic(m_aActionTbL.CalcWindowSizePixel()); 2469*cdf0e10cSrcweir Size aSizeATR=m_pFloat->PixelToLogic(m_aActionTbR.CalcWindowSizePixel()); 2470*cdf0e10cSrcweir Size aMinSize = GetMinOutputSizePixel(); 2471*cdf0e10cSrcweir 2472*cdf0e10cSrcweir long nListHeight = m_pFloat->PixelToLogic( aFilterLb.GetSizePixel() ).Height(); 2473*cdf0e10cSrcweir long nWidth = aDlgSize.Width()- 2 * SFX_TEMPLDLG_HFRAME; 2474*cdf0e10cSrcweir 2475*cdf0e10cSrcweir m_aActionTbL.SetPosSizePixel(m_pFloat->LogicToPixel(Point(SFX_TEMPLDLG_HFRAME,SFX_TEMPLDLG_VTOPFRAME)), 2476*cdf0e10cSrcweir m_pFloat->LogicToPixel(aSizeATL)); 2477*cdf0e10cSrcweir 2478*cdf0e10cSrcweir // Die Position der rechten Toolbox nur ver"andern, wenn das Fenster 2479*cdf0e10cSrcweir // breit genug ist 2480*cdf0e10cSrcweir Point aPosATR(aDlgSize.Width()-SFX_TEMPLDLG_HFRAME-aSizeATR.Width(),SFX_TEMPLDLG_VTOPFRAME); 2481*cdf0e10cSrcweir if(aDlgSize.Width() >= aMinSize.Width()) 2482*cdf0e10cSrcweir m_aActionTbR.SetPosPixel(m_pFloat->LogicToPixel(aPosATR)); 2483*cdf0e10cSrcweir else 2484*cdf0e10cSrcweir m_aActionTbR.SetPosPixel( m_pFloat->LogicToPixel( 2485*cdf0e10cSrcweir Point( SFX_TEMPLDLG_HFRAME + aSizeATL.Width() + SFX_TEMPLDLG_MIDHSPACE, 2486*cdf0e10cSrcweir SFX_TEMPLDLG_VTOPFRAME ) ) ); 2487*cdf0e10cSrcweir 2488*cdf0e10cSrcweir m_aActionTbR.SetSizePixel(m_pFloat->LogicToPixel(aSizeATR)); 2489*cdf0e10cSrcweir 2490*cdf0e10cSrcweir Point aFilterPos( 2491*cdf0e10cSrcweir m_pFloat->LogicToPixel(Point(SFX_TEMPLDLG_HFRAME, 2492*cdf0e10cSrcweir aDlgSize.Height()-SFX_TEMPLDLG_VBOTFRAME-nListHeight)) ); 2493*cdf0e10cSrcweir 2494*cdf0e10cSrcweir Size aFilterSize( 2495*cdf0e10cSrcweir m_pFloat->LogicToPixel(Size(nWidth,SFX_TEMPLDLG_FILTERHEIGHT)) ); 2496*cdf0e10cSrcweir 2497*cdf0e10cSrcweir Point aFmtPos( 2498*cdf0e10cSrcweir m_pFloat->LogicToPixel(Point(SFX_TEMPLDLG_HFRAME, SFX_TEMPLDLG_VTOPFRAME + 2499*cdf0e10cSrcweir SFX_TEMPLDLG_MIDVSPACE+aSizeATL.Height())) ); 2500*cdf0e10cSrcweir Size aFmtSize( 2501*cdf0e10cSrcweir m_pFloat->LogicToPixel(Size(nWidth, 2502*cdf0e10cSrcweir aDlgSize.Height() - SFX_TEMPLDLG_VBOTFRAME - 2503*cdf0e10cSrcweir SFX_TEMPLDLG_VTOPFRAME - 2*SFX_TEMPLDLG_MIDVSPACE- 2504*cdf0e10cSrcweir nListHeight-aSizeATL.Height())) ); 2505*cdf0e10cSrcweir 2506*cdf0e10cSrcweir // Die Position der Listboxen nur ver"andern, wenn das Fenster 2507*cdf0e10cSrcweir // hoch genug ist 2508*cdf0e10cSrcweir if(aDlgSize.Height() >= aMinSize.Height()) 2509*cdf0e10cSrcweir { 2510*cdf0e10cSrcweir aFilterLb.SetPosPixel(aFilterPos); 2511*cdf0e10cSrcweir aFmtLb.SetPosPixel( aFmtPos ); 2512*cdf0e10cSrcweir if(pTreeBox) 2513*cdf0e10cSrcweir pTreeBox->SetPosPixel(aFmtPos); 2514*cdf0e10cSrcweir } 2515*cdf0e10cSrcweir else 2516*cdf0e10cSrcweir aFmtSize.Height() += aFilterSize.Height(); 2517*cdf0e10cSrcweir 2518*cdf0e10cSrcweir aFilterLb.SetSizePixel(aFilterSize); 2519*cdf0e10cSrcweir aFmtLb.SetSizePixel( aFmtSize ); 2520*cdf0e10cSrcweir if(pTreeBox) 2521*cdf0e10cSrcweir pTreeBox->SetSizePixel(aFmtSize); 2522*cdf0e10cSrcweir } 2523*cdf0e10cSrcweir 2524*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2525*cdf0e10cSrcweir 2526*cdf0e10cSrcweir 2527*cdf0e10cSrcweir Size SfxTemplateDialog_Impl::GetMinOutputSizePixel() 2528*cdf0e10cSrcweir { 2529*cdf0e10cSrcweir Size aSizeATL=m_pFloat->PixelToLogic(m_aActionTbL.CalcWindowSizePixel()); 2530*cdf0e10cSrcweir Size aSizeATR=m_pFloat->PixelToLogic(m_aActionTbR.CalcWindowSizePixel()); 2531*cdf0e10cSrcweir Size aMinSize=Size( 2532*cdf0e10cSrcweir aSizeATL.Width()+aSizeATR.Width()+ 2533*cdf0e10cSrcweir 2*SFX_TEMPLDLG_HFRAME + SFX_TEMPLDLG_MIDHSPACE, 2534*cdf0e10cSrcweir 4*aSizeATL.Height()+2*SFX_TEMPLDLG_MIDVSPACE); 2535*cdf0e10cSrcweir return aMinSize; 2536*cdf0e10cSrcweir } 2537*cdf0e10cSrcweir 2538*cdf0e10cSrcweir //------------------------------------------------------------------------- 2539*cdf0e10cSrcweir 2540*cdf0e10cSrcweir void SfxTemplateDialog_Impl::Command( const CommandEvent& rCEvt ) 2541*cdf0e10cSrcweir { 2542*cdf0e10cSrcweir if(COMMAND_CONTEXTMENU == rCEvt.GetCommand()) 2543*cdf0e10cSrcweir ExecuteContextMenu_Impl( rCEvt.GetMousePosPixel(), m_pFloat ); 2544*cdf0e10cSrcweir else 2545*cdf0e10cSrcweir m_pFloat->Command(rCEvt); 2546*cdf0e10cSrcweir } 2547*cdf0e10cSrcweir 2548*cdf0e10cSrcweir //------------------------------------------------------------------------- 2549*cdf0e10cSrcweir 2550*cdf0e10cSrcweir void SfxTemplateDialog_Impl::EnableItem(sal_uInt16 nMesId, sal_Bool bCheck) 2551*cdf0e10cSrcweir { 2552*cdf0e10cSrcweir String aEmpty; 2553*cdf0e10cSrcweir switch(nMesId) 2554*cdf0e10cSrcweir { 2555*cdf0e10cSrcweir case SID_STYLE_WATERCAN : 2556*cdf0e10cSrcweir if(!bCheck && IsCheckedItem(SID_STYLE_WATERCAN)) 2557*cdf0e10cSrcweir Execute_Impl(SID_STYLE_WATERCAN, aEmpty, aEmpty, 0); 2558*cdf0e10cSrcweir case SID_STYLE_NEW_BY_EXAMPLE: 2559*cdf0e10cSrcweir case SID_STYLE_UPDATE_BY_EXAMPLE: 2560*cdf0e10cSrcweir m_aActionTbR.EnableItem(nMesId,bCheck); 2561*cdf0e10cSrcweir break; 2562*cdf0e10cSrcweir } 2563*cdf0e10cSrcweir } 2564*cdf0e10cSrcweir 2565*cdf0e10cSrcweir //------------------------------------------------------------------------- 2566*cdf0e10cSrcweir 2567*cdf0e10cSrcweir void SfxTemplateDialog_Impl::CheckItem(sal_uInt16 nMesId, sal_Bool bCheck) 2568*cdf0e10cSrcweir { 2569*cdf0e10cSrcweir switch(nMesId) 2570*cdf0e10cSrcweir { 2571*cdf0e10cSrcweir case SID_STYLE_WATERCAN : 2572*cdf0e10cSrcweir bIsWater=bCheck; 2573*cdf0e10cSrcweir m_aActionTbR.CheckItem(SID_STYLE_WATERCAN,bCheck); 2574*cdf0e10cSrcweir break; 2575*cdf0e10cSrcweir default: 2576*cdf0e10cSrcweir m_aActionTbL.CheckItem(nMesId,bCheck); break; 2577*cdf0e10cSrcweir } 2578*cdf0e10cSrcweir } 2579*cdf0e10cSrcweir 2580*cdf0e10cSrcweir //------------------------------------------------------------------------- 2581*cdf0e10cSrcweir 2582*cdf0e10cSrcweir sal_Bool SfxTemplateDialog_Impl::IsCheckedItem(sal_uInt16 nMesId) 2583*cdf0e10cSrcweir { 2584*cdf0e10cSrcweir switch(nMesId) 2585*cdf0e10cSrcweir { 2586*cdf0e10cSrcweir case SID_STYLE_WATERCAN : 2587*cdf0e10cSrcweir return m_aActionTbR.GetItemState(SID_STYLE_WATERCAN)==STATE_CHECK; 2588*cdf0e10cSrcweir default: 2589*cdf0e10cSrcweir return m_aActionTbL.GetItemState(nMesId)==STATE_CHECK; 2590*cdf0e10cSrcweir } 2591*cdf0e10cSrcweir } 2592*cdf0e10cSrcweir 2593*cdf0e10cSrcweir //------------------------------------------------------------------------- 2594*cdf0e10cSrcweir 2595*cdf0e10cSrcweir IMPL_LINK_INLINE_START( SfxTemplateDialog_Impl, ToolBoxLSelect, ToolBox *, pBox ) 2596*cdf0e10cSrcweir { 2597*cdf0e10cSrcweir const sal_uInt16 nEntry = pBox->GetCurItemId(); 2598*cdf0e10cSrcweir FamilySelect(nEntry); 2599*cdf0e10cSrcweir return 0; 2600*cdf0e10cSrcweir } 2601*cdf0e10cSrcweir IMPL_LINK_INLINE_END( SfxTemplateDialog_Impl, ToolBoxLSelect, ToolBox *, pBox ) 2602*cdf0e10cSrcweir 2603*cdf0e10cSrcweir //------------------------------------------------------------------------- 2604*cdf0e10cSrcweir ::rtl::OUString lcl_GetLabel(uno::Any& rAny) 2605*cdf0e10cSrcweir { 2606*cdf0e10cSrcweir ::rtl::OUString sRet; 2607*cdf0e10cSrcweir uno::Sequence< beans::PropertyValue >aPropSeq; 2608*cdf0e10cSrcweir if ( rAny >>= aPropSeq ) 2609*cdf0e10cSrcweir { 2610*cdf0e10cSrcweir for( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ ) 2611*cdf0e10cSrcweir { 2612*cdf0e10cSrcweir if ( aPropSeq[i].Name.equalsAscii( "Label" )) 2613*cdf0e10cSrcweir { 2614*cdf0e10cSrcweir aPropSeq[i].Value >>= sRet; 2615*cdf0e10cSrcweir break; 2616*cdf0e10cSrcweir } 2617*cdf0e10cSrcweir } 2618*cdf0e10cSrcweir } 2619*cdf0e10cSrcweir return sRet; 2620*cdf0e10cSrcweir } 2621*cdf0e10cSrcweir //------------------------------------------------------------------------- 2622*cdf0e10cSrcweir 2623*cdf0e10cSrcweir IMPL_LINK( SfxTemplateDialog_Impl, ToolBoxRSelect, ToolBox *, pBox ) 2624*cdf0e10cSrcweir { 2625*cdf0e10cSrcweir const sal_uInt16 nEntry = pBox->GetCurItemId(); 2626*cdf0e10cSrcweir if(nEntry != SID_STYLE_NEW_BY_EXAMPLE || 2627*cdf0e10cSrcweir TIB_DROPDOWN != (pBox->GetItemBits(nEntry)&TIB_DROPDOWN)) 2628*cdf0e10cSrcweir ActionSelect(nEntry); 2629*cdf0e10cSrcweir return 0; 2630*cdf0e10cSrcweir } 2631*cdf0e10cSrcweir //------------------------------------------------------------------------- 2632*cdf0e10cSrcweir IMPL_LINK( SfxTemplateDialog_Impl, ToolBoxRClick, ToolBox *, pBox ) 2633*cdf0e10cSrcweir { 2634*cdf0e10cSrcweir const sal_uInt16 nEntry = pBox->GetCurItemId(); 2635*cdf0e10cSrcweir if(nEntry == SID_STYLE_NEW_BY_EXAMPLE && 2636*cdf0e10cSrcweir TIB_DROPDOWN == (pBox->GetItemBits(nEntry)&TIB_DROPDOWN)) 2637*cdf0e10cSrcweir { 2638*cdf0e10cSrcweir //create a popup menu in Writer 2639*cdf0e10cSrcweir PopupMenu *pMenu = new PopupMenu; 2640*cdf0e10cSrcweir uno::Reference< container::XNameAccess > xNameAccess( 2641*cdf0e10cSrcweir ::comphelper::getProcessServiceFactory()-> 2642*cdf0e10cSrcweir createInstance( ::rtl::OUString::createFromAscii( 2643*cdf0e10cSrcweir "com.sun.star.frame.UICommandDescription") ), uno::UNO_QUERY ); 2644*cdf0e10cSrcweir uno::Reference< container::XNameAccess > xUICommands; 2645*cdf0e10cSrcweir if ( xNameAccess.is() ) 2646*cdf0e10cSrcweir { 2647*cdf0e10cSrcweir rtl::OUString sTextDoc = ::rtl::OUString::createFromAscii("com.sun.star.text.TextDocument"); 2648*cdf0e10cSrcweir if(xNameAccess->hasByName(sTextDoc)) 2649*cdf0e10cSrcweir { 2650*cdf0e10cSrcweir uno::Any a = xNameAccess->getByName( sTextDoc ); 2651*cdf0e10cSrcweir a >>= xUICommands; 2652*cdf0e10cSrcweir } 2653*cdf0e10cSrcweir } 2654*cdf0e10cSrcweir if(!xUICommands.is()) 2655*cdf0e10cSrcweir return 0; 2656*cdf0e10cSrcweir try 2657*cdf0e10cSrcweir { 2658*cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aPropSeq; 2659*cdf0e10cSrcweir uno::Any aCommand = xUICommands->getByName(::rtl::OUString::createFromAscii(".uno:StyleNewByExample")); 2660*cdf0e10cSrcweir ::rtl::OUString sLabel = lcl_GetLabel( aCommand ); 2661*cdf0e10cSrcweir pMenu->InsertItem( SID_STYLE_NEW_BY_EXAMPLE, sLabel ); 2662*cdf0e10cSrcweir pMenu->SetHelpId(SID_STYLE_NEW_BY_EXAMPLE, HID_TEMPLDLG_NEWBYEXAMPLE); 2663*cdf0e10cSrcweir 2664*cdf0e10cSrcweir aCommand = xUICommands->getByName(::rtl::OUString::createFromAscii(".uno:StyleUpdateByExample")); 2665*cdf0e10cSrcweir sLabel = lcl_GetLabel( aCommand ); 2666*cdf0e10cSrcweir 2667*cdf0e10cSrcweir pMenu->InsertItem( SID_STYLE_UPDATE_BY_EXAMPLE, sLabel ); 2668*cdf0e10cSrcweir pMenu->SetHelpId(SID_STYLE_UPDATE_BY_EXAMPLE, HID_TEMPLDLG_UPDATEBYEXAMPLE); 2669*cdf0e10cSrcweir 2670*cdf0e10cSrcweir aCommand = xUICommands->getByName(::rtl::OUString::createFromAscii(".uno:LoadStyles")); 2671*cdf0e10cSrcweir sLabel = lcl_GetLabel( aCommand ); 2672*cdf0e10cSrcweir pMenu->InsertItem( SID_TEMPLATE_LOAD, sLabel ); 2673*cdf0e10cSrcweir pMenu->SetHelpId(SID_TEMPLATE_LOAD, ".uno:LoadStyles"); 2674*cdf0e10cSrcweir 2675*cdf0e10cSrcweir pMenu->SetSelectHdl(LINK(this, SfxTemplateDialog_Impl, MenuSelectHdl)); 2676*cdf0e10cSrcweir pMenu->Execute( pBox, 2677*cdf0e10cSrcweir pBox->GetItemRect(nEntry), 2678*cdf0e10cSrcweir POPUPMENU_EXECUTE_DOWN ); 2679*cdf0e10cSrcweir pBox->EndSelection(); 2680*cdf0e10cSrcweir } 2681*cdf0e10cSrcweir catch(uno::Exception&) 2682*cdf0e10cSrcweir { 2683*cdf0e10cSrcweir } 2684*cdf0e10cSrcweir delete pMenu; 2685*cdf0e10cSrcweir pBox->Invalidate(); 2686*cdf0e10cSrcweir } 2687*cdf0e10cSrcweir return 0; 2688*cdf0e10cSrcweir } 2689*cdf0e10cSrcweir //------------------------------------------------------------------------- 2690*cdf0e10cSrcweir IMPL_LINK( SfxTemplateDialog_Impl, MenuSelectHdl, Menu*, pMenu) 2691*cdf0e10cSrcweir { 2692*cdf0e10cSrcweir sal_uInt16 nMenuId = pMenu->GetCurItemId(); 2693*cdf0e10cSrcweir ActionSelect(nMenuId); 2694*cdf0e10cSrcweir return 0; 2695*cdf0e10cSrcweir } 2696*cdf0e10cSrcweir //------------------------------------------------------------------------- 2697*cdf0e10cSrcweir 2698*cdf0e10cSrcweir SfxTemplateCatalog_Impl::SfxTemplateCatalog_Impl( Window* /*pParent*/, SfxBindings* pB, 2699*cdf0e10cSrcweir SfxTemplateCatalog* pTmpWindow ) : 2700*cdf0e10cSrcweir 2701*cdf0e10cSrcweir SfxCommonTemplateDialog_Impl( pB, pTmpWindow ), 2702*cdf0e10cSrcweir 2703*cdf0e10cSrcweir aFamList ( pTmpWindow, SfxResId( BT_TOOL ) ), 2704*cdf0e10cSrcweir aOkBtn ( pTmpWindow, SfxResId( BT_OK ) ), 2705*cdf0e10cSrcweir aCancelBtn ( pTmpWindow, SfxResId( BT_CANCEL ) ), 2706*cdf0e10cSrcweir aNewBtn ( pTmpWindow, SfxResId( BT_NEW ) ), 2707*cdf0e10cSrcweir aChangeBtn ( pTmpWindow, SfxResId( BT_EDIT ) ), 2708*cdf0e10cSrcweir aDelBtn ( pTmpWindow, SfxResId( BT_DEL ) ), 2709*cdf0e10cSrcweir aOrgBtn ( pTmpWindow, SfxResId( BT_ORG ) ), 2710*cdf0e10cSrcweir aHelpBtn ( pTmpWindow, SfxResId( BT_HELP ) ), 2711*cdf0e10cSrcweir pReal ( pTmpWindow ), 2712*cdf0e10cSrcweir aHelper ( pTmpWindow ) 2713*cdf0e10cSrcweir 2714*cdf0e10cSrcweir { 2715*cdf0e10cSrcweir aNewBtn.Disable(); 2716*cdf0e10cSrcweir aDelBtn.Disable(); 2717*cdf0e10cSrcweir aChangeBtn.Disable(); 2718*cdf0e10cSrcweir 2719*cdf0e10cSrcweir SFX_APP()->Get_Impl()->pTemplateCommon = GetISfxTemplateCommon(); 2720*cdf0e10cSrcweir pTmpWindow->FreeResource(); 2721*cdf0e10cSrcweir 2722*cdf0e10cSrcweir Initialize(); 2723*cdf0e10cSrcweir 2724*cdf0e10cSrcweir aFamList.SetSelectHdl( LINK( this, SfxTemplateCatalog_Impl, FamListSelect ) ); 2725*cdf0e10cSrcweir aOkBtn.SetClickHdl( LINK( this, SfxTemplateCatalog_Impl, OkHdl ) ); 2726*cdf0e10cSrcweir aCancelBtn.SetClickHdl( LINK( this, SfxTemplateCatalog_Impl, CancelHdl ) ); 2727*cdf0e10cSrcweir aNewBtn.SetClickHdl( LINK( this, SfxTemplateCatalog_Impl, NewHdl ) ); 2728*cdf0e10cSrcweir aDelBtn.SetClickHdl( LINK( this, SfxTemplateCatalog_Impl, DelHdl ) ); 2729*cdf0e10cSrcweir aChangeBtn.SetClickHdl( LINK( this, SfxTemplateCatalog_Impl, ChangeHdl ) ); 2730*cdf0e10cSrcweir aOrgBtn.SetClickHdl( LINK( this, SfxTemplateCatalog_Impl, OrgHdl ) ); 2731*cdf0e10cSrcweir } 2732*cdf0e10cSrcweir 2733*cdf0e10cSrcweir //------------------------------------------------------------------------- 2734*cdf0e10cSrcweir 2735*cdf0e10cSrcweir SfxTemplateCatalog_Impl::~SfxTemplateCatalog_Impl() 2736*cdf0e10cSrcweir { 2737*cdf0e10cSrcweir SFX_APP()->Get_Impl()->pTemplateCommon = 0; 2738*cdf0e10cSrcweir } 2739*cdf0e10cSrcweir 2740*cdf0e10cSrcweir //------------------------------------------------------------------------- 2741*cdf0e10cSrcweir 2742*cdf0e10cSrcweir IMPL_LINK_INLINE_START( SfxTemplateCatalog_Impl, OkHdl, Button *, pButton ) 2743*cdf0e10cSrcweir { 2744*cdf0e10cSrcweir (void)pButton; //unused 2745*cdf0e10cSrcweir ApplyHdl( NULL ); 2746*cdf0e10cSrcweir pReal->EndDialog( RET_OK ); 2747*cdf0e10cSrcweir return 0; 2748*cdf0e10cSrcweir } 2749*cdf0e10cSrcweir IMPL_LINK_INLINE_END( SfxTemplateCatalog_Impl, OkHdl, Button *, pButton ) 2750*cdf0e10cSrcweir 2751*cdf0e10cSrcweir //------------------------------------------------------------------------- 2752*cdf0e10cSrcweir 2753*cdf0e10cSrcweir IMPL_LINK_INLINE_START( SfxTemplateCatalog_Impl, CancelHdl, Button *, pButton ) 2754*cdf0e10cSrcweir { 2755*cdf0e10cSrcweir (void)pButton; //unused 2756*cdf0e10cSrcweir pReal->EndDialog( RET_CANCEL ); 2757*cdf0e10cSrcweir return 0; 2758*cdf0e10cSrcweir } 2759*cdf0e10cSrcweir IMPL_LINK_INLINE_END( SfxTemplateCatalog_Impl, CancelHdl, Button *, pButton ) 2760*cdf0e10cSrcweir 2761*cdf0e10cSrcweir //------------------------------------------------------------------------- 2762*cdf0e10cSrcweir 2763*cdf0e10cSrcweir IMPL_LINK_INLINE_START( SfxTemplateCatalog_Impl, NewHdl, Button *, pButton ) 2764*cdf0e10cSrcweir { 2765*cdf0e10cSrcweir (void)pButton; //unused 2766*cdf0e10cSrcweir aCancelBtn.SetText( String( SfxResId( STR_CLOSE ) ) ); 2767*cdf0e10cSrcweir SfxCommonTemplateDialog_Impl::NewHdl( NULL ); 2768*cdf0e10cSrcweir return 0; 2769*cdf0e10cSrcweir } 2770*cdf0e10cSrcweir IMPL_LINK_INLINE_END( SfxTemplateCatalog_Impl, NewHdl, Button *, pButton ) 2771*cdf0e10cSrcweir 2772*cdf0e10cSrcweir //------------------------------------------------------------------------- 2773*cdf0e10cSrcweir 2774*cdf0e10cSrcweir IMPL_LINK_INLINE_START( SfxTemplateCatalog_Impl, ChangeHdl, Button *, pButton ) 2775*cdf0e10cSrcweir { 2776*cdf0e10cSrcweir (void)pButton; //unused 2777*cdf0e10cSrcweir aCancelBtn.SetText( String( SfxResId( STR_CLOSE ) ) ); 2778*cdf0e10cSrcweir SfxCommonTemplateDialog_Impl::EditHdl( NULL ); 2779*cdf0e10cSrcweir return 0; 2780*cdf0e10cSrcweir } 2781*cdf0e10cSrcweir IMPL_LINK_INLINE_END( SfxTemplateCatalog_Impl, ChangeHdl, Button *, pButton ) 2782*cdf0e10cSrcweir 2783*cdf0e10cSrcweir //------------------------------------------------------------------------- 2784*cdf0e10cSrcweir 2785*cdf0e10cSrcweir IMPL_LINK_INLINE_START( SfxTemplateCatalog_Impl, DelHdl, Button *, pButton ) 2786*cdf0e10cSrcweir { 2787*cdf0e10cSrcweir (void)pButton; //unused 2788*cdf0e10cSrcweir SfxCommonTemplateDialog_Impl::DeleteHdl( NULL ); 2789*cdf0e10cSrcweir return 0; 2790*cdf0e10cSrcweir } 2791*cdf0e10cSrcweir IMPL_LINK_INLINE_END( SfxTemplateCatalog_Impl, DelHdl, Button *, pButton ) 2792*cdf0e10cSrcweir 2793*cdf0e10cSrcweir //------------------------------------------------------------------------- 2794*cdf0e10cSrcweir 2795*cdf0e10cSrcweir IMPL_LINK( SfxTemplateCatalog_Impl, OrgHdl, Button *, pButton ) 2796*cdf0e10cSrcweir { 2797*cdf0e10cSrcweir (void)pButton; //unused 2798*cdf0e10cSrcweir aCancelBtn.SetText( String( SfxResId( STR_CLOSE ) ) ); 2799*cdf0e10cSrcweir SfxDocumentTemplates aTemplates; 2800*cdf0e10cSrcweir aTemplates.Construct(); 2801*cdf0e10cSrcweir SfxTemplateOrganizeDlg* pDlg = new SfxTemplateOrganizeDlg( pReal, &aTemplates ); 2802*cdf0e10cSrcweir const short nRet = pDlg->Execute(); 2803*cdf0e10cSrcweir delete pDlg; 2804*cdf0e10cSrcweir if ( RET_OK == nRet ) 2805*cdf0e10cSrcweir Update_Impl(); 2806*cdf0e10cSrcweir else if ( RET_EDIT_STYLE == nRet ) 2807*cdf0e10cSrcweir pReal->EndDialog( RET_CANCEL ); 2808*cdf0e10cSrcweir return 0; 2809*cdf0e10cSrcweir } 2810*cdf0e10cSrcweir 2811*cdf0e10cSrcweir //------------------------------------------------------------------------- 2812*cdf0e10cSrcweir 2813*cdf0e10cSrcweir void SfxTemplateCatalog_Impl::EnableEdit( sal_Bool bEnable ) 2814*cdf0e10cSrcweir { 2815*cdf0e10cSrcweir SfxCommonTemplateDialog_Impl::EnableEdit( bEnable ); 2816*cdf0e10cSrcweir aChangeBtn.Enable( bEnable ); 2817*cdf0e10cSrcweir } 2818*cdf0e10cSrcweir 2819*cdf0e10cSrcweir //------------------------------------------------------------------------- 2820*cdf0e10cSrcweir 2821*cdf0e10cSrcweir void SfxTemplateCatalog_Impl::EnableDel( sal_Bool bEnable ) 2822*cdf0e10cSrcweir { 2823*cdf0e10cSrcweir SfxCommonTemplateDialog_Impl::EnableDel( bEnable ); 2824*cdf0e10cSrcweir aDelBtn.Enable( bEnable ); 2825*cdf0e10cSrcweir } 2826*cdf0e10cSrcweir 2827*cdf0e10cSrcweir void SfxTemplateCatalog_Impl::EnableNew(sal_Bool bEnable) 2828*cdf0e10cSrcweir { 2829*cdf0e10cSrcweir SfxCommonTemplateDialog_Impl::EnableNew( bEnable ); 2830*cdf0e10cSrcweir aNewBtn.Enable( bEnable ); 2831*cdf0e10cSrcweir } 2832*cdf0e10cSrcweir 2833*cdf0e10cSrcweir //------------------------------------------------------------------------- 2834*cdf0e10cSrcweir 2835*cdf0e10cSrcweir IMPL_LINK_INLINE_START( SfxTemplateCatalog_Impl, FamListSelect, ListBox *, pList ) 2836*cdf0e10cSrcweir { 2837*cdf0e10cSrcweir const sal_uInt16 nEntry = aFamIds[pList->GetSelectEntryPos()]; 2838*cdf0e10cSrcweir FamilySelect(nEntry); 2839*cdf0e10cSrcweir return 0; 2840*cdf0e10cSrcweir } 2841*cdf0e10cSrcweir IMPL_LINK_INLINE_END( SfxTemplateCatalog_Impl, FamListSelect, ListBox *, pList ) 2842*cdf0e10cSrcweir 2843*cdf0e10cSrcweir //------------------------------------------------------------------------- 2844*cdf0e10cSrcweir 2845*cdf0e10cSrcweir void SfxTemplateCatalog_Impl::EnableItem( sal_uInt16 nMesId, sal_Bool bCheck ) 2846*cdf0e10cSrcweir { 2847*cdf0e10cSrcweir if ( nMesId == SID_STYLE_WATERCAN ) 2848*cdf0e10cSrcweir aOkBtn.Enable( bCheck ); 2849*cdf0e10cSrcweir if ( nMesId > SFX_STYLE_FAMILY_PSEUDO || nMesId < SFX_STYLE_FAMILY_CHAR ) 2850*cdf0e10cSrcweir return; 2851*cdf0e10cSrcweir 2852*cdf0e10cSrcweir /* for(sal_uInt16 i=0;i<aFamIds.Count&&aFamIds[i]!=nMesId;i++); 2853*cdf0e10cSrcweir if(i!=aFamIds.Count()) 2854*cdf0e10cSrcweir aFamList.SelectEntry(aFamIds[i]); 2855*cdf0e10cSrcweir else 2856*cdf0e10cSrcweir DBG_ERROR("Entry nicht gefunden");*/ 2857*cdf0e10cSrcweir 2858*cdf0e10cSrcweir } 2859*cdf0e10cSrcweir 2860*cdf0e10cSrcweir //------------------------------------------------------------------------- 2861*cdf0e10cSrcweir 2862*cdf0e10cSrcweir void SfxTemplateCatalog_Impl::CheckItem(sal_uInt16 nMesId, sal_Bool /*bCheck*/) 2863*cdf0e10cSrcweir { 2864*cdf0e10cSrcweir if ( nMesId > SFX_STYLE_FAMILY_PSEUDO || nMesId < SFX_STYLE_FAMILY_CHAR ) 2865*cdf0e10cSrcweir return; 2866*cdf0e10cSrcweir sal_uInt16 i; 2867*cdf0e10cSrcweir for ( i = 0; i < aFamIds.Count() && aFamIds[i] != nMesId; i++ ) ; 2868*cdf0e10cSrcweir aFamList.SelectEntryPos(i); 2869*cdf0e10cSrcweir } 2870*cdf0e10cSrcweir 2871*cdf0e10cSrcweir //------------------------------------------------------------------------- 2872*cdf0e10cSrcweir 2873*cdf0e10cSrcweir sal_Bool SfxTemplateCatalog_Impl::IsCheckedItem(sal_uInt16 nMesId) 2874*cdf0e10cSrcweir { 2875*cdf0e10cSrcweir if ( nMesId > SFX_STYLE_FAMILY_PSEUDO || nMesId < SFX_STYLE_FAMILY_CHAR ) 2876*cdf0e10cSrcweir return sal_False; 2877*cdf0e10cSrcweir sal_uInt16 i; 2878*cdf0e10cSrcweir for ( i = 0; i < aFamIds.Count() && aFamIds[i] != nMesId; i++ ) 2879*cdf0e10cSrcweir ; 2880*cdf0e10cSrcweir return aFamList.IsEntrySelected( String::CreateFromInt32(i) ); 2881*cdf0e10cSrcweir } 2882*cdf0e10cSrcweir 2883*cdf0e10cSrcweir //------------------------------------------------------------------------- 2884*cdf0e10cSrcweir 2885*cdf0e10cSrcweir // Der Katalog muss nur das Disablen beherrschen, da waehrend seiner 2886*cdf0e10cSrcweir // Lebenszeit keine Selektionsaenderungen vorgenommen werden koennen 2887*cdf0e10cSrcweir void SfxTemplateCatalog_Impl::EnableFamilyItem( sal_uInt16 nId, sal_Bool bEnable ) 2888*cdf0e10cSrcweir { 2889*cdf0e10cSrcweir if ( !bEnable ) 2890*cdf0e10cSrcweir for ( sal_uInt16 nPos = aFamIds.Count(); nPos--; ) 2891*cdf0e10cSrcweir if ( aFamIds[ nPos ] == nId ) 2892*cdf0e10cSrcweir { 2893*cdf0e10cSrcweir aFamIds.Remove( nPos ); 2894*cdf0e10cSrcweir aFamList.RemoveEntry( nPos ); 2895*cdf0e10cSrcweir } 2896*cdf0e10cSrcweir } 2897*cdf0e10cSrcweir 2898*cdf0e10cSrcweir void SfxTemplateCatalog_Impl::InsertFamilyItem( sal_uInt16 nId, const SfxStyleFamilyItem* pItem ) 2899*cdf0e10cSrcweir { 2900*cdf0e10cSrcweir if ( nId > SFX_STYLE_FAMILY_PSEUDO || nId < SFX_STYLE_FAMILY_CHAR ) 2901*cdf0e10cSrcweir return; 2902*cdf0e10cSrcweir aFamList.InsertEntry( pItem->GetText(), 0 ); 2903*cdf0e10cSrcweir aFamIds.Insert( nId, 0 ); 2904*cdf0e10cSrcweir } 2905*cdf0e10cSrcweir 2906*cdf0e10cSrcweir void SfxTemplateCatalog_Impl::ClearFamilyList() 2907*cdf0e10cSrcweir { 2908*cdf0e10cSrcweir aFamList.Clear(); 2909*cdf0e10cSrcweir aFamIds.Remove( 0, aFamIds.Count() ); 2910*cdf0e10cSrcweir } 2911*cdf0e10cSrcweir 2912*cdf0e10cSrcweir void SfxTemplateCatalog_Impl::PrepareDeleteAction() 2913*cdf0e10cSrcweir { 2914*cdf0e10cSrcweir aDelBtn.Disable(); 2915*cdf0e10cSrcweir aCancelBtn.SetText( String( SfxResId( STR_CLOSE ) ) ); 2916*cdf0e10cSrcweir } 2917*cdf0e10cSrcweir 2918*cdf0e10cSrcweir 2919*cdf0e10cSrcweir void SfxCommonTemplateDialog_Impl::SetFamily( sal_uInt16 nId ) 2920*cdf0e10cSrcweir { 2921*cdf0e10cSrcweir if ( nId != nActFamily ) 2922*cdf0e10cSrcweir { 2923*cdf0e10cSrcweir if ( nActFamily != 0xFFFF ) 2924*cdf0e10cSrcweir CheckItem( nActFamily, sal_False ); 2925*cdf0e10cSrcweir nActFamily = nId; 2926*cdf0e10cSrcweir if ( nId != 0xFFFF ) 2927*cdf0e10cSrcweir bUpdateFamily = sal_True; 2928*cdf0e10cSrcweir } 2929*cdf0e10cSrcweir } 2930*cdf0e10cSrcweir 2931*cdf0e10cSrcweir void SfxCommonTemplateDialog_Impl::UpdateFamily_Impl() 2932*cdf0e10cSrcweir { 2933*cdf0e10cSrcweir bUpdateFamily = sal_False; 2934*cdf0e10cSrcweir 2935*cdf0e10cSrcweir SfxDispatcher* pDispat = pBindings->GetDispatcher_Impl(); 2936*cdf0e10cSrcweir SfxViewFrame *pViewFrame = pDispat->GetFrame(); 2937*cdf0e10cSrcweir SfxObjectShell *pDocShell = pViewFrame->GetObjectShell(); 2938*cdf0e10cSrcweir 2939*cdf0e10cSrcweir SfxStyleSheetBasePool *pOldStyleSheetPool = pStyleSheetPool; 2940*cdf0e10cSrcweir pStyleSheetPool = pDocShell? pDocShell->GetStyleSheetPool(): 0; 2941*cdf0e10cSrcweir if ( pOldStyleSheetPool != pStyleSheetPool ) 2942*cdf0e10cSrcweir { 2943*cdf0e10cSrcweir if ( pOldStyleSheetPool ) 2944*cdf0e10cSrcweir EndListening(*pOldStyleSheetPool); 2945*cdf0e10cSrcweir if ( pStyleSheetPool ) 2946*cdf0e10cSrcweir StartListening(*pOldStyleSheetPool); 2947*cdf0e10cSrcweir } 2948*cdf0e10cSrcweir 2949*cdf0e10cSrcweir bWaterDisabled = sal_False; 2950*cdf0e10cSrcweir bCanNew = sal_True; 2951*cdf0e10cSrcweir bTreeDrag = sal_True; 2952*cdf0e10cSrcweir bUpdateByExampleDisabled = sal_False; 2953*cdf0e10cSrcweir 2954*cdf0e10cSrcweir if ( pStyleSheetPool ) 2955*cdf0e10cSrcweir { 2956*cdf0e10cSrcweir if(!pTreeBox) 2957*cdf0e10cSrcweir UpdateStyles_Impl(UPDATE_FAMILY | UPDATE_FAMILY_LIST); 2958*cdf0e10cSrcweir else 2959*cdf0e10cSrcweir { 2960*cdf0e10cSrcweir UpdateStyles_Impl(UPDATE_FAMILY); 2961*cdf0e10cSrcweir FillTreeBox(); 2962*cdf0e10cSrcweir } 2963*cdf0e10cSrcweir } 2964*cdf0e10cSrcweir 2965*cdf0e10cSrcweir InvalidateBindings(); 2966*cdf0e10cSrcweir 2967*cdf0e10cSrcweir if ( IsCheckedItem( SID_STYLE_WATERCAN ) && 2968*cdf0e10cSrcweir // nur, wenn dieser Bereich erlaubt ist 2969*cdf0e10cSrcweir 0 != pFamilyState[ nActFamily - 1 ] ) 2970*cdf0e10cSrcweir Execute_Impl( SID_STYLE_APPLY, GetSelectedEntry(), 2971*cdf0e10cSrcweir String(), (sal_uInt16)GetFamilyItem_Impl()->GetFamily() ); 2972*cdf0e10cSrcweir } 2973*cdf0e10cSrcweir void SfxCommonTemplateDialog_Impl::ReplaceUpdateButtonByMenu() 2974*cdf0e10cSrcweir { 2975*cdf0e10cSrcweir //does nothing 2976*cdf0e10cSrcweir } 2977*cdf0e10cSrcweir 2978*cdf0e10cSrcweir void SfxTemplateDialog::StateChanged( StateChangedType nStateChange ) 2979*cdf0e10cSrcweir { 2980*cdf0e10cSrcweir if ( nStateChange == STATE_CHANGE_INITSHOW ) 2981*cdf0e10cSrcweir { 2982*cdf0e10cSrcweir SfxViewFrame *pFrame = GetBindings().GetDispatcher_Impl()->GetFrame(); 2983*cdf0e10cSrcweir Window* pEditWin = pFrame->GetViewShell()->GetWindow(); 2984*cdf0e10cSrcweir 2985*cdf0e10cSrcweir Size aSize = pEditWin->GetSizePixel(); 2986*cdf0e10cSrcweir Point aPoint = pEditWin->OutputToScreenPixel( pEditWin->GetPosPixel() ); 2987*cdf0e10cSrcweir aPoint = GetParent()->ScreenToOutputPixel( aPoint ); 2988*cdf0e10cSrcweir Size aWinSize = GetSizePixel(); 2989*cdf0e10cSrcweir aPoint.X() += aSize.Width() - aWinSize.Width() - 20; 2990*cdf0e10cSrcweir aPoint.Y() += aSize.Height() / 2 - aWinSize.Height() / 2; 2991*cdf0e10cSrcweir SetFloatingPos( aPoint ); 2992*cdf0e10cSrcweir } 2993*cdf0e10cSrcweir 2994*cdf0e10cSrcweir SfxDockingWindow::StateChanged( nStateChange ); 2995*cdf0e10cSrcweir } 2996*cdf0e10cSrcweir 2997*cdf0e10cSrcweir /*-- 10.12.2003 11:44:35--------------------------------------------------- 2998*cdf0e10cSrcweir 2999*cdf0e10cSrcweir -----------------------------------------------------------------------*/ 3000*cdf0e10cSrcweir DropToolBox_Impl::DropToolBox_Impl(Window* pParent, SfxTemplateDialog_Impl* pTemplateDialog) : 3001*cdf0e10cSrcweir ToolBox(pParent), 3002*cdf0e10cSrcweir DropTargetHelper(this), 3003*cdf0e10cSrcweir rParent(*pTemplateDialog) 3004*cdf0e10cSrcweir { 3005*cdf0e10cSrcweir } 3006*cdf0e10cSrcweir /*-- 10.12.2003 11:44:35--------------------------------------------------- 3007*cdf0e10cSrcweir 3008*cdf0e10cSrcweir -----------------------------------------------------------------------*/ 3009*cdf0e10cSrcweir DropToolBox_Impl::~DropToolBox_Impl() 3010*cdf0e10cSrcweir { 3011*cdf0e10cSrcweir } 3012*cdf0e10cSrcweir /*-- 10.12.2003 11:44:35--------------------------------------------------- 3013*cdf0e10cSrcweir 3014*cdf0e10cSrcweir -----------------------------------------------------------------------*/ 3015*cdf0e10cSrcweir sal_Int8 DropToolBox_Impl::AcceptDrop( const AcceptDropEvent& rEvt ) 3016*cdf0e10cSrcweir { 3017*cdf0e10cSrcweir sal_Int8 nReturn = DND_ACTION_NONE; 3018*cdf0e10cSrcweir sal_uInt16 nItemId = GetItemId( rEvt.maPosPixel ); 3019*cdf0e10cSrcweir if(USHRT_MAX != nItemId && !IsItemChecked( nItemId )) 3020*cdf0e10cSrcweir { 3021*cdf0e10cSrcweir SetCurItemId(nItemId); 3022*cdf0e10cSrcweir GetSelectHdl().Call(this); 3023*cdf0e10cSrcweir } 3024*cdf0e10cSrcweir // special case: page styles are allowed to create new styles by example 3025*cdf0e10cSrcweir // but not allowed to be created by drag and drop 3026*cdf0e10cSrcweir if ( nItemId != SfxCommonTemplateDialog_Impl::SfxFamilyIdToNId( SFX_STYLE_FAMILY_PAGE )&& 3027*cdf0e10cSrcweir IsDropFormatSupported( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ) && 3028*cdf0e10cSrcweir !rParent.bNewByExampleDisabled ) 3029*cdf0e10cSrcweir { 3030*cdf0e10cSrcweir nReturn = DND_ACTION_COPY; 3031*cdf0e10cSrcweir } 3032*cdf0e10cSrcweir return nReturn; 3033*cdf0e10cSrcweir } 3034*cdf0e10cSrcweir /*-- 10.12.2003 11:44:35--------------------------------------------------- 3035*cdf0e10cSrcweir 3036*cdf0e10cSrcweir -----------------------------------------------------------------------*/ 3037*cdf0e10cSrcweir sal_Int8 DropToolBox_Impl::ExecuteDrop( const ExecuteDropEvent& rEvt ) 3038*cdf0e10cSrcweir { 3039*cdf0e10cSrcweir return rParent.aFmtLb.ExecuteDrop(rEvt); 3040*cdf0e10cSrcweir } 3041*cdf0e10cSrcweir 3042