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