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