1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: templdlg.cxx,v $
10 * $Revision: 1.58.46.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sfx2.hxx"
34 #ifndef _MENU_HXX //autogen
35 #include <vcl/menu.hxx>
37 #include <svtools/intitem.hxx>
38 #include <svtools/stritem.hxx>
39 #include <svtools/style.hxx>
43 #define _SVSTDARR_STRINGSDTOR
44 #include <svtools/svstdarr.hxx>
45 #include <comphelper/processfactory.hxx>
46 #include <comphelper/sequenceashashmap.hxx>
47 #include <unotools/intlwrapper.hxx>
48 #include <comphelper/processfactory.hxx>
49 #include <com/sun/star/container/XNameAccess.hpp>
50 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
51 #include <com/sun/star/beans/PropertyValue.hpp>
52 #include <com/sun/star/frame/XModuleManager.hpp>
54 #include "sfxhelp.hxx"
55 #include <sfx2/app.hxx>
56 #include <sfx2/dispatch.hxx>
57 #include <sfx2/bindings.hxx>
58 #include <sfx2/templdlg.hxx>
59 #include "templdgi.hxx"
60 #include "tplcitem.hxx"
61 #include "sfxtypes.hxx"
62 #include <sfx2/styfitem.hxx>
63 #include <sfx2/objsh.hxx>
64 #include <sfx2/viewsh.hxx>
65 #include <sfx2/newstyle.hxx>
66 #include "tplpitem.hxx"
67 #include "sfxresid.hxx"
69 #include "templdlg.hrc"
70 #include <sfx2/sfx.hrc>
72 #include "arrdecl.hxx"
74 #include <sfx2/docfilt.hxx>
75 #include <sfx2/docfac.hxx>
77 #include <sfx2/doctempl.hxx>
78 #include <sfx2/module.hxx>
81 #include "appdata.hxx"
82 #include <sfx2/viewfrm.hxx>
84 #include <comphelper/configurationhelper.hxx>
86 using namespace ::com::sun::star
;
87 using namespace ::com::sun::star::beans
;
88 using namespace ::com::sun::star::frame
;
89 using namespace ::com::sun::star::uno
;
91 //=========================================================================
93 // Fenster wird ab jetzt dynamisch erstellt. Daher hier R"ander usw.
95 #define SFX_TEMPLDLG_HFRAME 3
96 #define SFX_TEMPLDLG_VTOPFRAME 3
98 #define SFX_TEMPLDLG_VBOTFRAME 3
99 #define SFX_TEMPLDLG_MIDHSPACE 3
100 #define SFX_TEMPLDLG_MIDVSPACE 3
101 #define SFX_TEMPLDLG_FILTERHEIGHT 100
103 static USHORT nLastItemId
= USHRT_MAX
;
105 // filter box has maximum 12 entries visible
106 #define MAX_FILTER_ENTRIES 12
108 //=========================================================================
110 TYPEINIT0(SfxCommonTemplateDialog_Impl
);
111 TYPEINIT1(SfxTemplateDialog_Impl
,SfxCommonTemplateDialog_Impl
);
112 TYPEINIT1(SfxTemplateCatalog_Impl
,SfxCommonTemplateDialog_Impl
);
114 SFX_IMPL_DOCKINGWINDOW(SfxTemplateDialogWrapper
, SID_STYLE_DESIGNER
)
116 //-------------------------------------------------------------------------
118 // Redirektionsfunktionen
120 SfxTemplateDialog::SfxTemplateDialog
130 : SfxDockingWindow( pBind
, pCW
, pParent
, SfxResId(DLG_STYLE_DESIGNER
) ),
132 pImpl( new SfxTemplateDialog_Impl( pParent
, pBind
, this ) )
135 pImpl
->updateNonFamilyImages();
138 //-------------------------------------------------------------------------
140 SfxTemplateDialog::~SfxTemplateDialog()
145 ISfxTemplateCommon
* SfxTemplateDialog::GetISfxTemplateCommon()
147 return pImpl
->GetISfxTemplateCommon();
150 void SfxTemplateDialog::SetParagraphFamily()
152 // first select the paragraph family
153 pImpl
->FamilySelect( SFX_STYLE_FAMILY_PARA
);
154 // then select the automatic filter
155 pImpl
->SetAutomaticFilter();
158 // ------------------------------------------------------------------------
160 void SfxTemplateDialog::DataChanged( const DataChangedEvent
& _rDCEvt
)
162 if ( ( DATACHANGED_SETTINGS
== _rDCEvt
.GetType() ) &&
163 ( 0 != ( SETTINGS_STYLE
& _rDCEvt
.GetFlags() ) ) )
165 pImpl
->updateFamilyImages();
166 pImpl
->updateNonFamilyImages();
169 SfxDockingWindow::DataChanged( _rDCEvt
);
172 //-------------------------------------------------------------------------
174 void SfxTemplateDialog::Update()
179 //-------------------------------------------------------------------------
181 void SfxTemplateDialog::Resize()
185 SfxDockingWindow::Resize();
189 //-------------------------------------------------------------------------
191 SfxChildAlignment
SfxTemplateDialog::CheckAlignment(SfxChildAlignment eActAlign
,SfxChildAlignment eAlign
)
196 case SFX_ALIGN_HIGHESTTOP
:
197 case SFX_ALIGN_LOWESTTOP
:
198 case SFX_ALIGN_BOTTOM
:
199 case SFX_ALIGN_LOWESTBOTTOM
:
200 case SFX_ALIGN_HIGHESTBOTTOM
:
204 case SFX_ALIGN_RIGHT
:
205 case SFX_ALIGN_FIRSTLEFT
:
206 case SFX_ALIGN_LASTLEFT
:
207 case SFX_ALIGN_FIRSTRIGHT
:
208 case SFX_ALIGN_LASTRIGHT
:
216 //-------------------------------------------------------------------------
218 SfxTemplateCatalog::SfxTemplateCatalog(Window
*pParent
, SfxBindings
*pBindings
)
219 : SfxModalDialog(pParent
,SfxResId(RID_STYLECATALOG
))
221 pImpl
= new SfxTemplateCatalog_Impl(pParent
, pBindings
, this);
224 //-------------------------------------------------------------------------
226 SfxTemplateCatalog::~SfxTemplateCatalog()
231 //-------------------------------------------------------------------------
233 void DropListBox_Impl::MouseButtonDown( const MouseEvent
& rMEvt
)
235 nModifier
= rMEvt
.GetModifier();
237 BOOL bHitEmptySpace
= ( NULL
== GetEntry( rMEvt
.GetPosPixel(), TRUE
) );
238 if( bHitEmptySpace
&& ( rMEvt
.GetClicks() == 2 ) && rMEvt
.IsMod1() )
239 Control::MouseButtonDown( rMEvt
);
241 SvTreeListBox::MouseButtonDown( rMEvt
);
244 sal_Int8
DropListBox_Impl::AcceptDrop( const AcceptDropEvent
& rEvt
)
247 Drop is enabled as long as it is allowed to create a new style by example, i.e. to
248 create a style out of the current selection.
252 if ( IsDropFormatSupported( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR
) )
254 // special case: page styles are allowed to create new styles by example
255 // but not allowed to be created by drag and drop
256 if( pDialog
->nActFamily
== SfxCommonTemplateDialog_Impl::SfxFamilyIdToNId( SFX_STYLE_FAMILY_PAGE
) ||
257 pDialog
->bNewByExampleDisabled
)
258 return DND_ACTION_NONE
;
260 return DND_ACTION_COPY
;
262 return SvTreeListBox::AcceptDrop( rEvt
);
265 //-------------------------------------------------------------------------
267 sal_Int8
DropListBox_Impl::ExecuteDrop( const ExecuteDropEvent
& rEvt
)
269 // rEvt.maDropEvent.Context->acceptDrop( DND_ACTION_NONE );
270 // rEvt.maDropEvent.Context->dropComplete( TRUE );
272 sal_Int8 nRet
= DND_ACTION_NONE
;
273 SfxObjectShell
* pDocShell
= pDialog
->GetObjectShell();
274 TransferableDataHelper
aHelper( rEvt
.maDropEvent
.Transferable
);
275 sal_uInt32 nFormatCount
= aHelper
.GetFormatCount();
278 sal_Bool bFormatFound
= sal_False
;
280 for ( sal_uInt32 i
= 0; i
< nFormatCount
; ++i
)
282 SotFormatStringId nId
= aHelper
.GetFormat(i
);
283 TransferableObjectDescriptor aDesc
;
285 if ( aHelper
.GetTransferableObjectDescriptor( nId
, aDesc
) )
287 if ( aDesc
.maClassName
== pDocShell
->GetFactory().GetClassId() )
289 PostUserEvent( LINK( this, DropListBox_Impl
, OnAsyncExecuteDrop
), 0 );
291 bFormatFound
= sal_True
;
292 nRet
= rEvt
.mnAction
;
299 return SvTreeListBox::ExecuteDrop( rEvt
);
306 IMPL_LINK( DropListBox_Impl
, OnAsyncExecuteDrop
, SvLBoxEntry
*, EMPTYARG
)
308 pDialog
->ActionSelect( SID_STYLE_NEW_BY_EXAMPLE
);
313 IMPL_LINK( DropListBox_Impl
, OnAsyncExecuteError
, void*, NOTINTERESTEDIN
)
315 (void)NOTINTERESTEDIN
; // unused
316 ErrorHandler::HandleError( ERRCODE_IO_WRONGFORMAT
);
322 long DropListBox_Impl::Notify( NotifyEvent
& rNEvt
)
325 if( rNEvt
.GetType() == EVENT_KEYINPUT
)
327 const KeyCode
& rKeyCode
= rNEvt
.GetKeyEvent()->GetKeyCode();
328 if(!rKeyCode
.GetModifier())
330 if( pDialog
->bCanDel
&& KEY_DELETE
== rKeyCode
.GetCode())
332 pDialog
->DeleteHdl( NULL
);
335 else if( KEY_RETURN
== rKeyCode
.GetCode())
337 GetDoubleClickHdl().Call(this);
343 nRet
= SvTreeListBox::Notify( rNEvt
);
348 //-------------------------------------------------------------------------
351 SfxActionListBox::SfxActionListBox
353 SfxCommonTemplateDialog_Impl
* pParent
,
359 ListBox- Klasse, die im Command-Handler ein PopupMenu (Gestalter
364 : DropListBox_Impl(pParent
->GetWindow(), nWinBits
, pParent
)
367 EnableContextMenuHandling();
370 //-------------------------------------------------------------------------
372 SfxActionListBox::SfxActionListBox( SfxCommonTemplateDialog_Impl
* pParent
,
373 const ResId
&rResId
) :
374 DropListBox_Impl(pParent
->GetWindow(), rResId
, pParent
)
376 EnableContextMenuHandling();
379 //-------------------------------------------------------------------------
381 PopupMenu
* SfxActionListBox::CreateContextMenu( void )
383 //added by BerryJia for fixing Bug102739 2002-9-9 17:00(Beijing Time)
384 if( !( GetSelectionCount() > 0 ) )
386 pDialog
->EnableEdit( FALSE
);
387 pDialog
->EnableDel( FALSE
);
389 return pDialog
->CreateContextMenu();
392 //-------------------------------------------------------------------------
394 SfxTemplateDialogWrapper::SfxTemplateDialogWrapper(Window
*pParentWnd
,
395 USHORT nId
, SfxBindings
*p
, SfxChildWinInfo
*pInfo
) :
396 SfxChildWindow(pParentWnd
, nId
)
398 SfxTemplateDialog
*pWin
= new SfxTemplateDialog(p
, this, pParentWnd
);
400 eChildAlignment
= SFX_ALIGN_NOALIGNMENT
;
402 pWin
->Initialize( pInfo
);
403 pWin
->SetMinOutputSizePixel(pWin
->pImpl
->GetMinOutputSizePixel());
406 void SfxTemplateDialogWrapper::SetParagraphFamily()
408 // forward to SfxTemplateDialog, because SfxTemplateDialog isn't exported
409 static_cast< SfxTemplateDialog
* >( GetWindow() )->SetParagraphFamily();
412 //=========================================================================
413 SV_DECL_PTRARR_DEL(ExpandedEntries
, StringPtr
,16,8)
414 SV_IMPL_PTRARR(ExpandedEntries
, StringPtr
)
418 TreeListBox- Klasse f"ur die Anzeige der hierarchischen View
423 class StyleTreeListBox_Impl
: public DropListBox_Impl
426 SvLBoxEntry
* pCurEntry
;
427 SfxCommonTemplateDialog_Impl
* pCommon
;
428 Link aDoubleClickLink
;
434 virtual void Command( const CommandEvent
& rMEvt
);
435 virtual long Notify( NotifyEvent
& rNEvt
);
436 virtual BOOL
DoubleClickHdl();
437 virtual long ExpandingHdl();
438 virtual void ExpandedHdl();
439 virtual BOOL
NotifyMoving(SvLBoxEntry
* pTarget
,
441 SvLBoxEntry
*& rpNewParent
,
442 ULONG
& rNewChildPos
);
444 StyleTreeListBox_Impl( SfxCommonTemplateDialog_Impl
* pParent
, WinBits nWinStyle
= 0);
446 void SetDoubleClickHdl(const Link
&rLink
) { aDoubleClickLink
= rLink
; }
447 void SetDropHdl(const Link
&rLink
) { aDropLink
= rLink
; }
448 using SvLBox::GetParent
;
449 const String
& GetParent() const { return aParent
; }
450 const String
& GetStyle() const { return aStyle
; }
451 void MakeExpanded_Impl(ExpandedEntries
& rEntries
) const;
453 virtual PopupMenu
* CreateContextMenu( void );
456 //-------------------------------------------------------------------------
459 void StyleTreeListBox_Impl::MakeExpanded_Impl(ExpandedEntries
& rEntries
) const
463 for(pEntry
=(SvLBoxEntry
*)FirstVisible();pEntry
;pEntry
=(SvLBoxEntry
*)NextVisible(pEntry
))
465 if(IsExpanded(pEntry
))
467 StringPtr pString
=new String(GetEntryText(pEntry
));
468 rEntries
.Insert(pString
,nCount
++);
473 PopupMenu
* StyleTreeListBox_Impl::CreateContextMenu()
475 return pDialog
->CreateContextMenu();
478 BOOL
StyleTreeListBox_Impl::DoubleClickHdl()
483 DoubleClick-Handler; ruft entsprechenden Link.
484 Virtuelle Methode aus SV.
488 aDoubleClickLink
.Call(this);
492 //-------------------------------------------------------------------------
494 void StyleTreeListBox_Impl::Command( const CommandEvent
& rCEvt
)
498 Command Handler; dieser executed ein PopupMenu (Gestalter
500 Virtuelle Methode aus SV.
504 SvTreeListBox::Command(rCEvt
);
507 //-------------------------------------------------------------------------
509 long StyleTreeListBox_Impl::Notify( NotifyEvent
& rNEvt
)
511 // handle <RETURN> as double click
514 if ( rNEvt
.GetType() == EVENT_KEYINPUT
)
516 const KeyCode
& rKeyCode
= rNEvt
.GetKeyEvent()->GetKeyCode();
517 if ( !rKeyCode
.GetModifier() && KEY_RETURN
== rKeyCode
.GetCode() )
519 aDoubleClickLink
.Call( this );
525 nRet
= DropListBox_Impl::Notify( rNEvt
);
530 //-------------------------------------------------------------------------
532 BOOL
StyleTreeListBox_Impl::NotifyMoving(SvLBoxEntry
* pTarget
,
534 SvLBoxEntry
*& rpNewParent
,
538 NotifyMoving Handler; dieser leitet per Link das Event an den Dialog
540 Virtuelle Methode aus SV.
544 if(!pTarget
|| !pEntry
)
546 aParent
= GetEntryText(pTarget
);
547 aStyle
= GetEntryText(pEntry
);
548 const BOOL bRet
= (BOOL
)aDropLink
.Call(this);
549 rpNewParent
= pTarget
;
551 IntlWrapper
aIntlWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
552 const CollatorWrapper
* pCollator
= aIntlWrapper
.getCaseCollator();
553 for(SvLBoxEntry
*pTmpEntry
=FirstChild(pTarget
);
554 pTmpEntry
&& COMPARE_LESS
==pCollator
->compareString(
555 GetEntryText(pTmpEntry
),GetEntryText(pEntry
));
556 pTmpEntry
=NextSibling(pTmpEntry
),lPos
++) ;
558 return bRet
? (BOOL
)2: FALSE
;
561 //-------------------------------------------------------------------------
563 long StyleTreeListBox_Impl::ExpandingHdl()
567 ExpandingHdl Handler; der aktuelle Eintrag wird gemerkt.
568 Virtuelle Methode aus SV.
571 <StyleTreeListBox_Impl::ExpandedHdl()>
575 pCurEntry
= GetCurEntry();
579 //-------------------------------------------------------------------------
581 void StyleTreeListBox_Impl::ExpandedHdl()
586 Virtuelle Methode aus SV.
589 <StyleTreeListBox_Impl::ExpandingHdl()>
594 SvLBoxEntry
*pEntry
= GetHdlEntry();
595 if(!IsExpanded(pEntry
) && pCurEntry
!= GetCurEntry())
600 //-------------------------------------------------------------------------
602 StyleTreeListBox_Impl::StyleTreeListBox_Impl(
603 SfxCommonTemplateDialog_Impl
* pParent
, WinBits nWinStyle
) :
604 DropListBox_Impl(pParent
->GetWindow(), nWinStyle
, pParent
),
610 Konstruktor StyleTreeListBox_Impl
614 EnableContextMenuHandling();
617 //-------------------------------------------------------------------------
618 //-------------------------------------------------------------------------
620 class StyleTreeArr_Impl
;
625 Interne Struktur f"ur den Aufbau der hierarchischen View
629 struct StyleTree_Impl
633 StyleTreeArr_Impl
*pChilds
;
635 BOOL
HasParent() const { return aParent
.Len() != 0; }
637 StyleTree_Impl(const String
&rName
, const String
&rParent
):
638 aName(rName
), aParent(rParent
), pChilds(0), bIsExpanded(0) {}
640 void Put(StyleTree_Impl
* pIns
, ULONG lPos
=ULONG_MAX
);
644 typedef StyleTree_Impl
* StyleTree_ImplPtr
;
645 SV_DECL_PTRARR_DEL(StyleTreeArr_Impl
, StyleTree_ImplPtr
, 16, 8)
646 SV_IMPL_PTRARR(StyleTreeArr_Impl
, StyleTree_ImplPtr
)
649 ULONG
StyleTree_Impl::Count()
651 return pChilds
? pChilds
->Count() : 0L;
654 //-------------------------------------------------------------------------
656 StyleTree_Impl::~StyleTree_Impl()
661 //-------------------------------------------------------------------------
663 void StyleTree_Impl::Put(StyleTree_Impl
* pIns
, ULONG lPos
)
666 pChilds
= new StyleTreeArr_Impl
;
668 if ( ULONG_MAX
== lPos
)
669 lPos
= pChilds
->Count();
670 pChilds
->Insert( pIns
, (USHORT
)lPos
);
673 //-------------------------------------------------------------------------
675 StyleTreeArr_Impl
&MakeTree_Impl(StyleTreeArr_Impl
&rArr
)
677 const USHORT nCount
= rArr
.Count();
678 // Alle unter ihren Parents einordnen
680 for(i
= 0; i
< nCount
; ++i
)
682 StyleTree_ImplPtr pEntry
= rArr
[i
];
683 if(pEntry
->HasParent())
685 for(USHORT j
= 0; j
< nCount
; ++j
)
687 StyleTree_ImplPtr pCmp
= rArr
[j
];
688 if(pCmp
->aName
== pEntry
->aParent
)
690 // initial sortiert einfuegen
692 IntlWrapper
aIntlWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
693 const CollatorWrapper
* pCollator
= aIntlWrapper
.getCaseCollator();
695 ii
< pCmp
->Count() && COMPARE_LESS
==
696 pCollator
->compareString( (*pCmp
->pChilds
)[ii
]->aName
,
697 pEntry
->aName
);++ii
) ;
698 pCmp
->Put(pEntry
,ii
);
704 // alle, die schon unter ihrem Parent eingeordnet wurden
706 for(i
= 0; i
< rArr
.Count(); )
708 if(rArr
[i
]->HasParent())
716 //-------------------------------------------------------------------------
719 inline BOOL
IsExpanded_Impl( const ExpandedEntries
& rEntries
,
722 USHORT nCount
=rEntries
.Count();
723 for(USHORT n
=0;n
<nCount
;n
++)
724 if(*rEntries
[n
]==rStr
)
731 SvLBoxEntry
* FillBox_Impl(SvTreeListBox
*pBox
,
732 StyleTree_ImplPtr pEntry
,
733 const ExpandedEntries
& rEntries
,
734 SvLBoxEntry
* pParent
= 0)
736 SvLBoxEntry
* pNewEntry
= pBox
->InsertEntry(pEntry
->aName
, pParent
);
737 const USHORT nCount
= pEntry
->pChilds
? pEntry
->pChilds
->Count(): 0;
738 for(USHORT i
= 0; i
< nCount
; ++i
)
739 FillBox_Impl(pBox
, (*pEntry
->pChilds
)[i
], rEntries
, pNewEntry
);
743 //-------------------------------------------------------------------------
747 SfxCommonTemplateDialog_Impl::SfxCommonTemplateDialog_Impl( SfxBindings
* pB
, SfxDockingWindow
* pW
) :
749 aISfxTemplateCommon ( this ),
754 m_pStyleFamiliesId ( NULL
),
755 pStyleSheetPool ( NULL
),
757 pCurObjShell ( NULL
),
758 xModuleManager ( ::comphelper::getProcessServiceFactory()->createInstance(
759 DEFINE_CONST_UNICODE("com.sun.star.frame.ModuleManager") ), UNO_QUERY
),
762 aFmtLb ( this, WB_BORDER
| WB_TABSTOP
| WB_SORT
),
763 aFilterLb ( pW
, WB_BORDER
| WB_DROPDOWN
| WB_TABSTOP
),
765 nActFamily ( 0xffff ),
769 bDontUpdate ( FALSE
),
773 bUpdateFamily ( FALSE
),
777 bWaterDisabled ( FALSE
),
778 bNewByExampleDisabled ( FALSE
),
779 bUpdateByExampleDisabled( FALSE
),
781 bHierarchical ( FALSE
),
782 bBindingUpdate ( TRUE
)
784 aFmtLb
.SetHelpId( HID_TEMPLATE_FMT
);
785 aFilterLb
.SetHelpId( HID_TEMPLATE_FILTER
);
786 aFmtLb
.SetWindowBits( WB_SORT
| WB_HIDESELECTION
);
787 Font aFont
= aFmtLb
.GetFont();
788 aFont
.SetWeight( WEIGHT_NORMAL
);
789 aFmtLb
.SetFont( aFont
);
792 //-------------------------------------------------------------------------
794 SfxCommonTemplateDialog_Impl::SfxCommonTemplateDialog_Impl( SfxBindings
* pB
, ModalDialog
* pW
) :
796 aISfxTemplateCommon ( this ),
801 pStyleSheetPool ( NULL
),
803 pCurObjShell ( NULL
),
806 aFmtLb ( this, SfxResId( BT_VLIST
) ),
807 aFilterLb ( pW
, SfxResId( BT_FLIST
) ),
809 nActFamily ( 0xffff ),
813 bDontUpdate ( FALSE
),
817 bUpdateFamily ( FALSE
),
821 bWaterDisabled ( FALSE
),
822 bNewByExampleDisabled ( FALSE
),
823 bUpdateByExampleDisabled( FALSE
),
825 bHierarchical ( FALSE
),
826 bBindingUpdate ( TRUE
)
829 aFmtLb
.SetWindowBits( WB_SORT
);
832 //-------------------------------------------------------------------------
834 USHORT
SfxCommonTemplateDialog_Impl::StyleNrToInfoOffset(USHORT nId
)
836 const SfxStyleFamilyItem
*pItem
=pStyleFamilies
->GetObject(nId
);
837 return SfxFamilyIdToNId(pItem
->GetFamily())-1;
840 //-------------------------------------------------------------------------
842 void SfxTemplateDialog_Impl::EnableEdit(BOOL bEnable
)
844 SfxCommonTemplateDialog_Impl::EnableEdit( bEnable
);
845 if( !bEnable
|| !bUpdateByExampleDisabled
)
846 EnableItem( SID_STYLE_UPDATE_BY_EXAMPLE
, bEnable
);
849 //-------------------------------------------------------------------------
852 USHORT
SfxCommonTemplateDialog_Impl::InfoOffsetToStyleNr(USHORT nId
)
854 for ( USHORT i
=0;i
<pStyleFamilies
->Count();i
++ )
855 if ( SfxFamilyIdToNId(pStyleFamilies
->GetObject(i
)->GetFamily()) == nId
+1 )
857 DBG_ERROR("Style Nummer nicht gefunden");
862 //-------------------------------------------------------------------------
864 void SfxCommonTemplateDialog_Impl::ReadResource()
866 // globale Benutzer-Resource auslesen
868 for(i
= 0; i
< MAX_FAMILIES
; ++i
)
871 SfxViewFrame
* pViewFrame
= pBindings
->GetDispatcher_Impl()->GetFrame();
872 pCurObjShell
= pViewFrame
->GetObjectShell();
873 ResMgr
* pMgr
= pCurObjShell
? pCurObjShell
->GetResMgr() : NULL
;
874 ResId
aFamId( DLG_STYLE_DESIGNER
, *pMgr
);
875 aFamId
.SetRT(RSC_SFX_STYLE_FAMILIES
);
876 m_pStyleFamiliesId
= new ResId( aFamId
.GetId(), *pMgr
);
877 m_pStyleFamiliesId
->SetRT(RSC_SFX_STYLE_FAMILIES
);
878 if( !pMgr
|| !pMgr
->IsAvailable( aFamId
) )
879 pStyleFamilies
= new SfxStyleFamilies
;
881 pStyleFamilies
= new SfxStyleFamilies( aFamId
);
883 nActFilter
= pCurObjShell
? static_cast< USHORT
>( LoadFactoryStyleFilter( pCurObjShell
) ) : 0xFFFF;
884 if ( pCurObjShell
&& 0xFFFF == nActFilter
)
885 nActFilter
= pCurObjShell
->GetAutoStyleFilterIndex();
887 // Einfuegen in die Toolbox
888 // umgekehrte Reihenfolge, da immer vorne eingefuegt wird.
889 USHORT nCount
= pStyleFamilies
->Count();
891 pBindings
->ENTERREGISTRATIONS();
893 for(i
= 0; i
< nCount
; ++i
)
896 switch((USHORT
)pStyleFamilies
->GetObject(i
)->GetFamily())
898 case SFX_STYLE_FAMILY_CHAR
: nSlot
= SID_STYLE_FAMILY1
; break;
899 case SFX_STYLE_FAMILY_PARA
: nSlot
= SID_STYLE_FAMILY2
; break;
900 case SFX_STYLE_FAMILY_FRAME
:nSlot
= SID_STYLE_FAMILY3
; break;
901 case SFX_STYLE_FAMILY_PAGE
: nSlot
= SID_STYLE_FAMILY4
; break;
902 case SFX_STYLE_FAMILY_PSEUDO
: nSlot
= SID_STYLE_FAMILY5
; break;
903 default: DBG_ERROR("unbekannte StyleFamily"); break;
906 new SfxTemplateControllerItem(nSlot
, *this, *pBindings
);
908 pBoundItems
[i
++] = new SfxTemplateControllerItem(
909 SID_STYLE_WATERCAN
, *this, *pBindings
);
910 pBoundItems
[i
++] = new SfxTemplateControllerItem(
911 SID_STYLE_NEW_BY_EXAMPLE
, *this, *pBindings
);
912 pBoundItems
[i
++] = new SfxTemplateControllerItem(
913 SID_STYLE_UPDATE_BY_EXAMPLE
, *this, *pBindings
);
914 pBoundItems
[i
++] = new SfxTemplateControllerItem(
915 SID_STYLE_NEW
, *this, *pBindings
);
916 pBoundItems
[i
++] = new SfxTemplateControllerItem(
917 SID_STYLE_DRAGHIERARCHIE
, *this, *pBindings
);
918 pBoundItems
[i
++] = new SfxTemplateControllerItem(
919 SID_STYLE_EDIT
, *this, *pBindings
);
920 pBoundItems
[i
++] = new SfxTemplateControllerItem(
921 SID_STYLE_DELETE
, *this, *pBindings
);
922 pBoundItems
[i
++] = new SfxTemplateControllerItem(
923 SID_STYLE_FAMILY
, *this, *pBindings
);
924 pBindings
->LEAVEREGISTRATIONS();
926 for(; i
< COUNT_BOUND_FUNC
; ++i
)
929 StartListening(*pBindings
);
931 //In umgekehrter Reihenfolge des Auftretens in den Stylefamilies einfuegen.
932 //Das ist fuer den Toolbar des Gestalters. Die Listbox des Kataloges achtet
933 //selbst auf korrekte Reihenfolge.
935 //Reihenfolgen: Reihenfolge in der Resource = Reihenfolge in Toolbar bzw.
937 //Reihenfolge aufsteigender SIDs: Niedrige SIDs werden als erstes angezeigt,
938 //wenn Vorlagen mehrerer Familien aktiv sind.
940 // in the Writer the UpdateStyleByExample Toolbox button is removed and
941 // the NewStyle button gets a PopupMenu
943 ReplaceUpdateButtonByMenu();
947 const SfxStyleFamilyItem
*pItem
= pStyleFamilies
->GetObject( nCount
);
948 USHORT nId
= SfxFamilyIdToNId( pItem
->GetFamily() );
949 InsertFamilyItem( nId
, pItem
);
954 USHORT nStart
= SID_STYLE_FAMILY1
;
955 USHORT nEnd
= SID_STYLE_FAMILY4
;
957 for ( i
= nStart
; i
<= nEnd
; i
++ )
958 pBindings
->Update(i
);
960 pModule
= pCurObjShell
? pCurObjShell
->GetModule() : NULL
;
963 //-------------------------------------------------------------------------
965 void SfxCommonTemplateDialog_Impl::ClearResource()
968 DELETEX(pStyleFamilies
);
970 for ( i
= 0; i
< MAX_FAMILIES
; ++i
)
971 DELETEX(pFamilyState
[i
]);
972 for ( i
= 0; i
< COUNT_BOUND_FUNC
; ++i
)
973 delete pBoundItems
[i
];
976 DELETEZ( m_pStyleFamiliesId
);
979 //-------------------------------------------------------------------------
981 void SfxCommonTemplateDialog_Impl::Initialize()
983 // globale Benutzer-Resource auslesen
985 pBindings
->Invalidate( SID_STYLE_FAMILY
);
986 pBindings
->Update( SID_STYLE_FAMILY
);
989 aFilterLb
.SetSelectHdl( LINK( this, SfxCommonTemplateDialog_Impl
, FilterSelectHdl
) );
990 aFmtLb
.SetDoubleClickHdl( LINK( this, SfxCommonTemplateDialog_Impl
, ApplyHdl
) );
991 aFmtLb
.SetSelectHdl( LINK( this, SfxCommonTemplateDialog_Impl
, FmtSelectHdl
) );
997 //-------------------------------------------------------------------------
999 SfxCommonTemplateDialog_Impl::~SfxCommonTemplateDialog_Impl()
1003 Execute_Impl(SID_STYLE_WATERCAN
, aEmpty
, aEmpty
, 0);
1004 GetWindow()->Hide();
1005 DELETEX(pStyleFamilies
);
1006 DELETEZ( m_pStyleFamiliesId
);
1008 for ( i
= 0; i
< MAX_FAMILIES
; ++i
)
1009 DELETEX(pFamilyState
[i
]);
1010 for ( i
= 0; i
< COUNT_BOUND_FUNC
; ++i
)
1011 delete pBoundItems
[i
];
1012 if ( pStyleSheetPool
)
1013 EndListening(*pStyleSheetPool
);
1014 pStyleSheetPool
= NULL
;
1019 pbDeleted
->bDead
= true;
1024 //-------------------------------------------------------------------------
1026 USHORT
SfxCommonTemplateDialog_Impl::SfxFamilyIdToNId( SfxStyleFamily nFamily
)
1030 case SFX_STYLE_FAMILY_CHAR
: return 1;
1031 case SFX_STYLE_FAMILY_PARA
: return 2;
1032 case SFX_STYLE_FAMILY_FRAME
: return 3;
1033 case SFX_STYLE_FAMILY_PAGE
: return 4;
1034 case SFX_STYLE_FAMILY_PSEUDO
: return 5;
1039 void SfxCommonTemplateDialog_Impl::SetAutomaticFilter()
1041 USHORT nCount
= aFilterLb
.GetEntryCount();
1042 for ( USHORT i
= 0; i
< nCount
; ++i
)
1044 ULONG nFlags
= (ULONG
)aFilterLb
.GetEntryData(i
);
1045 if ( SFXSTYLEBIT_AUTO
== nFlags
)
1047 // automatic entry found -> select it
1048 aFilterLb
.SelectEntryPos(i
);
1049 // then call the handler to filter the styles
1050 FilterSelect( i
- 1 );
1056 //-------------------------------------------------------------------------
1058 // Hilfsfunktion: Zugriff auf aktuelles Family-Item
1059 const SfxStyleFamilyItem
*SfxCommonTemplateDialog_Impl::GetFamilyItem_Impl() const
1061 const USHORT nCount
= pStyleFamilies
->Count();
1062 for(USHORT i
= 0; i
< nCount
; ++i
)
1064 const SfxStyleFamilyItem
*pItem
= pStyleFamilies
->GetObject(i
);
1065 // if(!pItem)continue;
1066 USHORT nId
= SfxFamilyIdToNId(pItem
->GetFamily());
1067 if(nId
== nActFamily
)
1073 //-------------------------------------------------------------------------
1075 void SfxCommonTemplateDialog_Impl::SelectStyle(const String
&rStr
)
1077 const SfxStyleFamilyItem
* pItem
= GetFamilyItem_Impl();
1080 const SfxStyleFamily eFam
= pItem
->GetFamily();
1081 SfxStyleSheetBase
* pStyle
= pStyleSheetPool
->Find( rStr
, eFam
, SFXSTYLEBIT_ALL
);
1083 EnableEdit( !(pStyle
->GetMask() & SFXSTYLEBIT_READONLY
) );
1091 SvLBoxEntry
* pEntry
= pTreeBox
->First();
1094 if ( pTreeBox
->GetEntryText( pEntry
) == rStr
)
1096 pTreeBox
->MakeVisible( pEntry
);
1097 pTreeBox
->Select( pEntry
);
1100 pEntry
= pTreeBox
->Next( pEntry
);
1104 pTreeBox
->SelectAll( FALSE
);
1108 BOOL bSelect
= ( rStr
.Len() > 0 );
1111 SvLBoxEntry
* pEntry
= (SvLBoxEntry
*)aFmtLb
.FirstVisible();
1112 while ( pEntry
&& aFmtLb
.GetEntryText( pEntry
) != rStr
)
1113 pEntry
= (SvLBoxEntry
*)aFmtLb
.NextVisible( pEntry
);
1118 aFmtLb
.MakeVisible( pEntry
);
1119 aFmtLb
.Select( pEntry
);
1120 bWaterDisabled
= !HasSelectedStyle(); //added by BerryJia for fixing Bug76391 2003-1-22
1121 FmtSelectHdl( NULL
);
1127 aFmtLb
.SelectAll( FALSE
);
1133 //-------------------------------------------------------------------------
1135 String
SfxCommonTemplateDialog_Impl::GetSelectedEntry() const
1140 SvLBoxEntry
* pEntry
= pTreeBox
->FirstSelected();
1142 aRet
= pTreeBox
->GetEntryText( pEntry
);
1146 SvLBoxEntry
* pEntry
= aFmtLb
.FirstSelected();
1148 aRet
= aFmtLb
.GetEntryText( pEntry
);
1153 //-------------------------------------------------------------------------
1155 void SfxCommonTemplateDialog_Impl::EnableTreeDrag( BOOL bEnable
)
1157 if ( pStyleSheetPool
)
1159 SfxStyleSheetBase
* pStyle
= pStyleSheetPool
->First();
1162 if ( pStyle
&& pStyle
->HasParentSupport() && bEnable
)
1163 pTreeBox
->SetDragDropMode(SV_DRAGDROP_CTRL_MOVE
);
1165 pTreeBox
->SetDragDropMode(SV_DRAGDROP_NONE
);
1168 bTreeDrag
= bEnable
;
1171 //-------------------------------------------------------------------------
1173 void SfxCommonTemplateDialog_Impl::FillTreeBox()
1175 DBG_ASSERT( pTreeBox
, "FillTreeBox() without treebox");
1176 if(pStyleSheetPool
&& nActFamily
!= 0xffff)
1178 const SfxStyleFamilyItem
*pItem
= GetFamilyItem_Impl();
1179 pStyleSheetPool
->SetSearchMask(pItem
->GetFamily(), SFXSTYLEBIT_ALL
);
1180 StyleTreeArr_Impl aArr
;
1181 SfxStyleSheetBase
*pStyle
= pStyleSheetPool
->First();
1182 if(pStyle
&& pStyle
->HasParentSupport() && bTreeDrag
)
1183 pTreeBox
->SetDragDropMode(SV_DRAGDROP_CTRL_MOVE
);
1185 pTreeBox
->SetDragDropMode(SV_DRAGDROP_NONE
);
1188 StyleTree_ImplPtr pNew
=
1189 new StyleTree_Impl(pStyle
->GetName(), pStyle
->GetParent());
1190 aArr
.Insert(pNew
, aArr
.Count());
1191 pStyle
= pStyleSheetPool
->Next();
1193 MakeTree_Impl(aArr
);
1194 ExpandedEntries aEntries
;
1196 ((const StyleTreeListBox_Impl
*)pTreeBox
)->
1197 MakeExpanded_Impl( aEntries
);
1198 pTreeBox
->SetUpdateMode( FALSE
);
1200 const USHORT nCount
= aArr
.Count();
1201 for(USHORT i
= 0; i
< nCount
; ++i
)
1202 FillBox_Impl(pTreeBox
, aArr
[i
], aEntries
);
1204 // EnableEdit(FALSE);
1205 EnableItem(SID_STYLE_WATERCAN
,FALSE
);
1207 SfxTemplateItem
* pState
= pFamilyState
[nActFamily
-1];
1210 pTreeBox
->Expand( pTreeBox
->First() );
1212 for ( SvLBoxEntry
* pEntry
= pTreeBox
->First(); pEntry
; pEntry
= pTreeBox
->Next( pEntry
) )
1214 if ( IsExpanded_Impl( aEntries
, pTreeBox
->GetEntryText( pEntry
) ) )
1215 pTreeBox
->Expand( pEntry
);
1218 pTreeBox
->SetUpdateMode( TRUE
);
1221 if(pState
) //Aktuellen Eintrag selektieren
1222 aStyle
= pState
->GetStyleName();
1223 SelectStyle(aStyle
);
1228 //-------------------------------------------------------------------------
1229 BOOL
SfxCommonTemplateDialog_Impl::HasSelectedStyle() const
1231 return pTreeBox
? pTreeBox
->FirstSelected() != 0:
1232 aFmtLb
.GetSelectionCount() != 0;
1236 //-------------------------------------------------------------------------
1238 // intern: Aktualisierung der Anzeige
1239 void SfxCommonTemplateDialog_Impl::UpdateStyles_Impl(USHORT nFlags
) // Flags, was aktualisiert werden soll (s.o.)
1241 DBG_ASSERT(nFlags
, "nichts zu tun");
1242 const SfxStyleFamilyItem
*pItem
= GetFamilyItem_Impl();
1245 // Ist beim Vorlagenkatalog der Fall
1246 SfxTemplateItem
**ppItem
= pFamilyState
;
1247 const USHORT nFamilyCount
= pStyleFamilies
->Count();
1249 for(n
=0;n
<nFamilyCount
;n
++)
1250 if(ppItem
[StyleNrToInfoOffset(n
)])break;
1251 if ( n
== nFamilyCount
)
1252 // passiert gelegentlich bei Beichten, Formularen etc.; weiss der Teufel warum
1254 ppItem
+=StyleNrToInfoOffset(n
);
1255 nAppFilter
= (*ppItem
)->GetValue();
1256 FamilySelect( StyleNrToInfoOffset(n
)+1 );
1257 pItem
= GetFamilyItem_Impl();
1260 const SfxStyleFamily eFam
= pItem
->GetFamily();
1262 SfxFilterTupel
*pT
= pItem
->GetFilterList().GetObject(nActFilter
);
1263 USHORT nFilter
= pT
? pItem
->GetFilterList().GetObject(nActFilter
)->nFlags
: 0;
1264 if(!nFilter
) // automatisch
1265 nFilter
= nAppFilter
;
1267 DBG_ASSERT(pStyleSheetPool
, "kein StyleSheetPool");
1270 pStyleSheetPool
->SetSearchMask(eFam
, nFilter
);
1271 pItem
= GetFamilyItem_Impl();
1272 if((nFlags
& UPDATE_FAMILY
) == UPDATE_FAMILY
)
1274 CheckItem(nActFamily
, TRUE
); // Button in Toolbox checken
1275 aFilterLb
.SetUpdateMode(FALSE
);
1277 //insert hierarchical at the beginning
1278 USHORT nPos
= aFilterLb
.InsertEntry(String(SfxResId(STR_STYLE_FILTER_HIERARCHICAL
)), 0);
1279 aFilterLb
.SetEntryData( nPos
, (void*)(ULONG
)SFXSTYLEBIT_ALL
);
1280 const SfxStyleFilter
& rFilter
= pItem
->GetFilterList();
1281 for(USHORT i
= 0; i
< rFilter
.Count(); ++i
)
1283 ULONG nFilterFlags
= rFilter
.GetObject(i
)->nFlags
;
1284 nPos
= aFilterLb
.InsertEntry( rFilter
.GetObject(i
)->aName
);
1285 aFilterLb
.SetEntryData( nPos
, (void*)nFilterFlags
);
1287 if(nActFilter
< aFilterLb
.GetEntryCount() - 1)
1288 aFilterLb
.SelectEntryPos(nActFilter
+ 1);
1292 aFilterLb
.SelectEntryPos(1);
1293 SfxFilterTupel
*pActT
= rFilter
.GetObject(nActFilter
);
1294 USHORT nFilterFlags
= pActT
? rFilter
.GetObject(nActFilter
)->nFlags
: 0;
1295 pStyleSheetPool
->SetSearchMask(eFam
, nFilterFlags
);
1298 //Falls in Treedarstellung wieder Family Hierarchie selektieren
1300 aFilterLb
.SelectEntry(String(SfxResId(STR_STYLE_FILTER_HIERARCHICAL
)));
1302 // show maximum 12 entries
1303 aFilterLb
.SetDropDownLineCount( MAX_FILTER_ENTRIES
);
1304 aFilterLb
.SetUpdateMode(TRUE
);
1308 if( nActFilter
< aFilterLb
.GetEntryCount() - 1)
1309 aFilterLb
.SelectEntryPos(nActFilter
+ 1);
1313 aFilterLb
.SelectEntryPos(1);
1317 if(nFlags
& UPDATE_FAMILY_LIST
)
1319 // EnableEdit(FALSE);
1320 EnableItem(SID_STYLE_WATERCAN
,FALSE
);
1322 SfxStyleSheetBase
*pStyle
= pStyleSheetPool
->First();
1323 SvLBoxEntry
* pEntry
= aFmtLb
.First();
1324 SvStringsDtor aStrings
;
1329 for( USHORT nPos
= aStrings
.Count() + 1 ; nPos
-- ;)
1331 if( !nPos
|| *aStrings
[nPos
-1] < pStyle
->GetName() )
1333 // Die Namen stehen in den Styles, also nicht kopieren
1334 // Reingefallen!: Writer hat insgesamt nur 1 Style
1336 new String( pStyle
->GetName() ), nPos
);
1340 pStyle
= pStyleSheetPool
->Next();
1344 USHORT nCount
= aStrings
.Count();
1346 while( nPos
< nCount
&& pEntry
&&
1347 *aStrings
[ nPos
] == aFmtLb
.GetEntryText( pEntry
) )
1350 pEntry
= aFmtLb
.Next( pEntry
);
1353 if( nPos
< nCount
|| pEntry
)
1355 // Box mit den Vorlagen fuellen
1356 aFmtLb
.SetUpdateMode(FALSE
);
1360 while( nPos
< nCount
)
1361 aFmtLb
.InsertEntry( *aStrings
.GetObject( nPos
++ ));
1362 aFmtLb
.SetUpdateMode(TRUE
);
1364 // aktuelle Vorlage anzeigen
1365 SfxTemplateItem
*pState
= pFamilyState
[nActFamily
-1];
1367 if(pState
) //Aktuellen Eintrag selektieren
1368 aStyle
= pState
->GetStyleName();
1369 SelectStyle(aStyle
);
1375 //-------------------------------------------------------------------------
1377 // Aktualisierung Anzeige: Gie\skanne an/aus
1378 void SfxCommonTemplateDialog_Impl::SetWaterCanState(const SfxBoolItem
*pItem
)
1380 // EnableItem(SID_STYLE_WATERCAN, pItem != 0);
1381 bWaterDisabled
= pItem
== 0;
1382 //added by BerryJia for fixing Bug76391 2003-1-7
1384 bWaterDisabled
= !HasSelectedStyle();
1386 if(pItem
&& !bWaterDisabled
)
1388 CheckItem(SID_STYLE_WATERCAN
, pItem
->GetValue());
1389 EnableItem( SID_STYLE_WATERCAN
, TRUE
);
1393 EnableItem(SID_STYLE_WATERCAN
, TRUE
);
1395 EnableItem(SID_STYLE_WATERCAN
, FALSE
);
1397 //Waehrend Giesskannenmodus Statusupdates ignorieren.
1399 USHORT nCount
=pStyleFamilies
->Count();
1400 pBindings
->EnterRegistrations();
1401 for(USHORT n
=0; n
<nCount
; n
++)
1403 SfxControllerItem
*pCItem
=pBoundItems
[n
];
1404 BOOL bChecked
= pItem
&& pItem
->GetValue();
1405 if( pCItem
->IsBound() == bChecked
)
1413 pBindings
->LeaveRegistrations();
1416 //-------------------------------------------------------------------------
1418 // Item mit dem Status einer Family wird kopiert und gemerkt
1419 // (Aktualisierung erfolgt, wenn alle Stati aktualisiert worden sind.
1420 // Siehe auch: <SfxBindings::AddDoneHdl(const Link &)>
1422 void SfxCommonTemplateDialog_Impl::SetFamilyState( USHORT nSlotId
, const SfxTemplateItem
* pItem
)
1424 USHORT nIdx
= nSlotId
- SID_STYLE_FAMILY_START
;
1425 DELETEZ(pFamilyState
[nIdx
]);
1427 pFamilyState
[nIdx
] = new SfxTemplateItem(*pItem
);
1430 // Wenn verwendete Vorlagen ( wie zum Teufel findet man das heraus ?? )
1431 bUpdateFamily
= TRUE
;
1434 //-------------------------------------------------------------------------
1436 // Benachrichtigung durch SfxBindings, da"s die Aktualisierung
1437 // beendet ist. St"o\st die Aktualisierung der Anzeige an.
1439 void SfxCommonTemplateDialog_Impl::Update_Impl()
1441 BOOL bDocChanged
=FALSE
;
1442 SfxStyleSheetBasePool
* pNewPool
= NULL
;
1443 SfxViewFrame
* pViewFrame
= pBindings
->GetDispatcher_Impl()->GetFrame();
1444 SfxObjectShell
* pDocShell
= pViewFrame
->GetObjectShell();
1446 pNewPool
= pDocShell
->GetStyleSheetPool();
1448 if ( pNewPool
!= pStyleSheetPool
&& pDocShell
)
1450 SfxModule
* pNewModule
= pDocShell
->GetModule();
1451 if( pNewModule
&& pNewModule
!= pModule
)
1456 if ( pStyleSheetPool
)
1458 EndListening(*pStyleSheetPool
);
1459 pStyleSheetPool
= 0;
1464 StartListening(*pNewPool
);
1465 pStyleSheetPool
= pNewPool
;
1468 // InvalidateBindings();
1472 UpdateFamily_Impl();
1475 for(i
= 0; i
< MAX_FAMILIES
; ++i
)
1478 if(i
== MAX_FAMILIES
|| !pNewPool
)
1482 SfxTemplateItem
*pItem
= 0;
1483 // aktueller Bereich nicht innerhalb der erlaubten Bereiche
1485 if(nActFamily
== 0xffff || 0 == (pItem
= pFamilyState
[nActFamily
-1] ) )
1487 CheckItem(nActFamily
, FALSE
);
1488 SfxTemplateItem
**ppItem
= pFamilyState
;
1489 const USHORT nFamilyCount
= pStyleFamilies
->Count();
1491 for(n
=0;n
<nFamilyCount
;n
++)
1492 if(ppItem
[StyleNrToInfoOffset(n
)])break;
1493 ppItem
+=StyleNrToInfoOffset(n
);
1495 nAppFilter
= (*ppItem
)->GetValue();
1496 FamilySelect( StyleNrToInfoOffset(n
)+1 );
1500 else if( bDocChanged
)
1502 // andere DocShell -> alles neu
1503 CheckItem( nActFamily
, TRUE
);
1504 nActFilter
= static_cast< USHORT
>( LoadFactoryStyleFilter( pDocShell
) );
1505 if ( 0xFFFF == nActFilter
)
1506 nActFilter
= pDocShell
->GetAutoStyleFilterIndex();
1508 nAppFilter
= pItem
->GetValue();
1511 UpdateStyles_Impl(UPDATE_FAMILY_LIST
);
1518 // anderer Filter fuer automatisch
1519 CheckItem( nActFamily
, TRUE
);
1520 const SfxStyleFamilyItem
*pStyleItem
= GetFamilyItem_Impl();
1521 #if OSL_DEBUG_LEVEL > 1
1523 pT
= pStyleItem
->GetFilterList().GetObject(nActFilter
);
1525 if(0 == pStyleItem
->GetFilterList().GetObject(nActFilter
)->nFlags
1526 && nAppFilter
!= pItem
->GetValue())
1528 nAppFilter
= pItem
->GetValue();
1530 UpdateStyles_Impl(UPDATE_FAMILY_LIST
);
1535 nAppFilter
= pItem
->GetValue();
1537 const String
aStyle(pItem
->GetStyleName());
1538 SelectStyle(aStyle
);
1540 EnableNew( bCanNew
);
1543 //-------------------------------------------------------------------------
1545 IMPL_LINK( SfxCommonTemplateDialog_Impl
, TimeOut
, Timer
*, pTim
)
1547 (void)pTim
; // unused
1552 UpdateStyles_Impl(UPDATE_FAMILY_LIST
);
1556 SfxTemplateItem
*pState
= pFamilyState
[nActFamily
-1];
1559 const String
aStyle(pState
->GetStyleName());
1560 SelectStyle(aStyle
);
1573 //-------------------------------------------------------------------------
1574 void SfxCommonTemplateDialog_Impl::Notify(SfxBroadcaster
& /*rBC*/, const SfxHint
& rHint
)
1576 // Aktualisierung anstossen
1577 if(rHint
.Type() == TYPE(SfxSimpleHint
))
1579 switch(((SfxSimpleHint
&) rHint
).GetId())
1581 case SFX_HINT_UPDATEDONE
:
1583 SfxViewFrame
*pViewFrame
= pBindings
->GetDispatcher_Impl()->GetFrame();
1584 SfxObjectShell
*pDocShell
= pViewFrame
->GetObjectShell();
1588 !IsCheckedItem(SID_STYLE_WATERCAN
) ||
1589 (pDocShell
&& pDocShell
->GetStyleSheetPool() != pStyleSheetPool
)
1596 else if ( bUpdateFamily
)
1598 UpdateFamily_Impl();
1601 if( pStyleSheetPool
)
1603 String aStr
= GetSelectedEntry();
1604 if( aStr
.Len() && pStyleSheetPool
)
1606 const SfxStyleFamilyItem
*pItem
= GetFamilyItem_Impl();
1608 const SfxStyleFamily eFam
= pItem
->GetFamily();
1609 SfxStyleSheetBase
*pStyle
=
1610 pStyleSheetPool
->Find(
1611 aStr
, eFam
, SFXSTYLEBIT_ALL
);
1614 !(pStyle
->GetMask() & SFXSTYLEBIT_READONLY
) );
1621 // noetig, wenn zwichen Dokumenten umgeschaltet wird,
1622 // aber in beiden Dokumenten die gleiche Vorlage gilt.
1623 // Nicht sofort Update_Impl rufen, fuer den Fall da\s eines
1624 // der Dokumente ein internes InPlaceObjekt ist!
1625 case SFX_HINT_DOCCHANGED
:
1628 case SFX_HINT_DYING
:
1630 EndListening(*pStyleSheetPool
);
1637 // Timer nicht aufsetzen, wenn der StyleSheetPool in die Kiste geht, denn
1638 // es kann sein, da\s sich ein neuer erst anmeldet, nachdem der Timer
1639 // abgelaufen ist - macht sich schlecht in UpdateStyles_Impl() !
1641 ULONG nId
= rHint
.ISA(SfxSimpleHint
) ? ( (SfxSimpleHint
&)rHint
).GetId() : 0;
1643 if(!bDontUpdate
&& nId
!= SFX_HINT_DYING
&&
1644 (rHint
.Type() == TYPE(SfxStyleSheetPoolHint
)||
1645 rHint
.Type() == TYPE(SfxStyleSheetHint
) ||
1646 rHint
.Type() == TYPE( SfxStyleSheetHintExtended
)))
1651 pTimer
->SetTimeout(500);
1652 pTimer
->SetTimeoutHdl(LINK(this,SfxCommonTemplateDialog_Impl
,TimeOut
));
1660 //-------------------------------------------------------------------------
1662 // Anderer Filter; kann durch den Benutzer umgeschaltet werden
1663 // oder als Folge von Neu oder Bearbeiten, wenn die aktuelle
1664 // Vorlage einem anderen Filter zugewiesen wurde.
1665 void SfxCommonTemplateDialog_Impl::FilterSelect(
1666 USHORT nEntry
, // Idx des neuen Filters
1667 BOOL bForce
) // Aktualisierung erzwingen, auch wenn der neue Filter gleich dem aktuellen ist
1669 if( nEntry
!= nActFilter
|| bForce
)
1671 nActFilter
= nEntry
;
1672 SfxViewFrame
*pViewFrame
= pBindings
->GetDispatcher_Impl()->GetFrame();
1673 SfxObjectShell
*pDocShell
= pViewFrame
->GetObjectShell();
1676 pDocShell
->SetAutoStyleFilterIndex(nActFilter
);
1677 SaveFactoryStyleFilter( pDocShell
, nActFilter
);
1680 SfxStyleSheetBasePool
*pOldStyleSheetPool
= pStyleSheetPool
;
1681 pStyleSheetPool
= pDocShell
? pDocShell
->GetStyleSheetPool(): 0;
1682 if ( pOldStyleSheetPool
!= pStyleSheetPool
)
1684 if ( pOldStyleSheetPool
)
1685 EndListening(*pOldStyleSheetPool
);
1686 if ( pStyleSheetPool
)
1687 StartListening(*pOldStyleSheetPool
);
1690 UpdateStyles_Impl(UPDATE_FAMILY_LIST
);
1694 //-------------------------------------------------------------------------
1696 // Intern: Ausf"uhren von Funktionen "uber den Dispatcher
1697 BOOL
SfxCommonTemplateDialog_Impl::Execute_Impl(
1698 USHORT nId
, const String
&rStr
, const String
& rRefStr
, USHORT nFamily
,
1699 USHORT nMask
, USHORT
*pIdx
, const USHORT
* pModifier
)
1701 SfxDispatcher
&rDispatcher
= *SFX_APP()->GetDispatcher_Impl();
1702 SfxStringItem
aItem(nId
, rStr
);
1703 SfxUInt16Item
aFamily(SID_STYLE_FAMILY
, nFamily
);
1704 SfxUInt16Item
aMask( SID_STYLE_MASK
, nMask
);
1705 SfxStringItem
aUpdName(SID_STYLE_UPD_BY_EX_NAME
, rStr
);
1706 SfxStringItem
aRefName( SID_STYLE_REFERENCE
, rRefStr
);
1707 const SfxPoolItem
* pItems
[ 6 ];
1710 pItems
[ nCount
++ ] = &aItem
;
1711 pItems
[ nCount
++ ] = &aFamily
;
1713 pItems
[ nCount
++ ] = &aMask
;
1714 if(SID_STYLE_UPDATE_BY_EXAMPLE
== nId
)
1716 //Sonderloesung fuer Numerierungsupdate im Writer
1717 const String
aTemplName(GetSelectedEntry());
1718 aUpdName
.SetValue(aTemplName
);
1719 pItems
[ nCount
++ ] = &aUpdName
;
1721 if ( rRefStr
.Len() )
1722 pItems
[ nCount
++ ] = &aRefName
;
1724 pItems
[ nCount
++ ] = 0;
1727 pbDeleted
= &aDeleted
;
1728 USHORT nModi
= pModifier
? *pModifier
: 0;
1729 const SfxPoolItem
* pItem
= rDispatcher
.Execute(
1730 nId
, SFX_CALLMODE_SYNCHRON
| SFX_CALLMODE_RECORD
| SFX_CALLMODE_MODAL
,
1733 // FIXME: Dialog can be destroyed while in Execute() check stack variable for dtor flag!
1734 if ( !pItem
|| aDeleted() )
1737 if ( nId
== SID_STYLE_NEW
|| SID_STYLE_EDIT
== nId
)
1739 SfxUInt16Item
*pFilterItem
= PTR_CAST(SfxUInt16Item
, pItem
);
1740 DBG_ASSERT(pFilterItem
, "SfxUINT16Item erwartet");
1741 USHORT nFilterFlags
= pFilterItem
->GetValue() & ~SFXSTYLEBIT_USERDEF
;
1742 if(!nFilterFlags
) // Benutzervorlage?
1743 nFilterFlags
= pFilterItem
->GetValue();
1744 const SfxStyleFamilyItem
*pFamilyItem
= GetFamilyItem_Impl();
1745 const USHORT nFilterCount
= (USHORT
) pFamilyItem
->GetFilterList().Count();
1747 for ( USHORT i
= 0; i
< nFilterCount
; ++i
)
1749 const SfxFilterTupel
*pTupel
=
1750 pFamilyItem
->GetFilterList().GetObject(i
);
1752 if ( ( pTupel
->nFlags
& nFilterFlags
) == nFilterFlags
&& pIdx
)
1757 // Reset destroyed flag otherwise we use the pointer in the dtor
1758 // where the local stack object is already destroyed. This would
1759 // overwrite objects on the stack!! See #i100110
1764 //-------------------------------------------------------------------------
1766 // Handler der Listbox der Filter
1767 IMPL_LINK( SfxCommonTemplateDialog_Impl
, FilterSelectHdl
, ListBox
*, pBox
)
1769 if ( pBox
->GetSelectEntry() == String(SfxResId(STR_STYLE_FILTER_HIERARCHICAL
)) )
1771 if ( !bHierarchical
)
1773 // TreeView einschalten
1775 const String
aSelectEntry( GetSelectedEntry());
1777 // aFilterLb.Disable();
1779 pTreeBox
= new StyleTreeListBox_Impl(
1780 this, WB_HASBUTTONS
| WB_HASLINES
|
1781 WB_BORDER
| WB_TABSTOP
| WB_HASLINESATROOT
|
1782 WB_HASBUTTONSATROOT
| WB_HIDESELECTION
);
1783 pTreeBox
->SetFont( aFmtLb
.GetFont() );
1785 pTreeBox
->SetPosSizePixel(aFmtLb
.GetPosPixel(), aFmtLb
.GetSizePixel());
1786 pTreeBox
->SetNodeDefaultImages();
1787 pTreeBox
->SetSelectHdl(
1788 LINK(this, SfxCommonTemplateDialog_Impl
, FmtSelectHdl
));
1789 ((StyleTreeListBox_Impl
*)pTreeBox
)->
1791 LINK(this, SfxCommonTemplateDialog_Impl
, ApplyHdl
));
1792 ((StyleTreeListBox_Impl
*)pTreeBox
)->
1793 SetDropHdl(LINK(this, SfxCommonTemplateDialog_Impl
, DropHdl
));
1794 pTreeBox
->SetIndent(10);
1797 SelectStyle(aSelectEntry
);
1806 // aFilterLb.Enable();
1807 // Falls bHierarchical, kann sich die Familie geaendert haben
1808 // minus one since hierarchical is inserted at the start
1809 FilterSelect(pBox
->GetSelectEntryPos() - 1, bHierarchical
);
1810 bHierarchical
=FALSE
;
1811 // UpdateStyles_Impl(UPDATE_FAMILY_LIST); // Anzeige aktualisieren
1817 //-------------------------------------------------------------------------
1819 // Select-Handler der Toolbox
1820 void SfxCommonTemplateDialog_Impl::FamilySelect(USHORT nEntry
)
1822 if( nEntry
!= nActFamily
)
1824 CheckItem( nActFamily
, FALSE
);
1825 nActFamily
= nEntry
;
1826 SfxDispatcher
* pDispat
= pBindings
->GetDispatcher_Impl();
1827 SfxUInt16Item
aItem( SID_STYLE_FAMILY
, nEntry
);
1828 pDispat
->Execute( SID_STYLE_FAMILY
, SFX_CALLMODE_SYNCHRON
, &aItem
, 0L );
1829 pBindings
->Invalidate( SID_STYLE_FAMILY
);
1830 pBindings
->Update( SID_STYLE_FAMILY
);
1831 UpdateFamily_Impl();
1835 //-------------------------------------------------------------------------
1837 void SfxCommonTemplateDialog_Impl::ActionSelect(USHORT nEntry
)
1842 case SID_STYLE_WATERCAN
:
1844 const BOOL bState
= IsCheckedItem(nEntry
);
1847 // wenn eine Vorlage ausgewaehlt ist.
1848 if(!bState
&& aFmtLb
.GetSelectionCount())
1850 const String
aTemplName(
1851 GetSelectedEntry());
1853 SID_STYLE_WATERCAN
, aTemplName
, aEmpty
,
1854 (USHORT
)GetFamilyItem_Impl()->GetFamily() );
1859 Execute_Impl(SID_STYLE_WATERCAN
, aEmpty
, aEmpty
, 0);
1862 CheckItem(nEntry
, bCheck
);
1863 aBool
.SetValue(bCheck
);
1864 SetWaterCanState(&aBool
);
1867 case SID_STYLE_NEW_BY_EXAMPLE
:
1869 if(pStyleSheetPool
&& nActFamily
!= 0xffff)
1871 const SfxStyleFamily eFam
=GetFamilyItem_Impl()->GetFamily();
1872 //pStyleSheetPool->GetSearchFamily();
1873 const SfxStyleFamilyItem
*pItem
= GetFamilyItem_Impl();
1875 if(pItem
&&nActFilter
!=0xffff)
1877 nFilter
= pItem
->GetFilterList().GetObject(
1878 nActFilter
)->nFlags
;
1879 if(!nFilter
) // automatisch
1880 nFilter
= nAppFilter
;
1883 nFilter
=pStyleSheetPool
->GetSearchMask();
1884 pStyleSheetPool
->SetSearchMask( eFam
, SFXSTYLEBIT_USERDEF
);
1886 SfxNewStyleDlg
*pDlg
=
1887 // why? : FloatingWindow must not be parent of a modal dialog
1888 new SfxNewStyleDlg(pWindow
, *pStyleSheetPool
);
1889 if(RET_OK
== pDlg
->Execute())
1891 pStyleSheetPool
->SetSearchMask(eFam
, nFilter
);
1892 const String
aTemplName(pDlg
->GetName());
1893 Execute_Impl(SID_STYLE_NEW_BY_EXAMPLE
,
1895 (USHORT
)GetFamilyItem_Impl()->GetFamily(),
1898 pStyleSheetPool
->SetSearchMask( eFam
, nFilter
);
1903 case SID_STYLE_UPDATE_BY_EXAMPLE
:
1905 Execute_Impl(SID_STYLE_UPDATE_BY_EXAMPLE
,
1907 (USHORT
)GetFamilyItem_Impl()->GetFamily());
1910 case SID_TEMPLATE_LOAD
:
1911 SFX_APP()->GetDispatcher_Impl()->Execute(nEntry
);
1913 default: DBG_ERROR("not implemented"); break;
1917 //-------------------------------------------------------------------------
1919 static rtl::OUString
getModuleIdentifier( const Reference
< XModuleManager
>& i_xModMgr
, SfxObjectShell
* i_pObjSh
)
1921 DBG_ASSERT( i_xModMgr
.is(), "getModuleIdentifier(): no XModuleManager" );
1922 DBG_ASSERT( i_pObjSh
, "getModuleIdentifier(): no ObjectShell" );
1924 ::rtl::OUString sIdentifier
;
1928 sIdentifier
= i_xModMgr
->identify( i_pObjSh
->GetModel() );
1930 catch ( ::com::sun::star::frame::UnknownModuleException
& )
1932 DBG_WARNING( "getModuleIdentifier(): unknown module" );
1934 catch ( Exception
& )
1936 DBG_ERRORFILE( "getModuleIdentifier(): exception of XModuleManager::identify()" );
1942 //-------------------------------------------------------------------------
1944 sal_Int32
SfxCommonTemplateDialog_Impl::LoadFactoryStyleFilter( SfxObjectShell
* i_pObjSh
)
1946 DBG_ASSERT( i_pObjSh
, "SfxCommonTemplateDialog_Impl::LoadFactoryStyleFilter(): no ObjectShell" );
1947 sal_Int32 nFilter
= -1;
1949 Sequence
< PropertyValue
> lProps
;
1950 Reference
< ::com::sun::star::container::XNameAccess
> xContainer( xModuleManager
, UNO_QUERY
);
1951 if ( xContainer
.is() )
1953 ::comphelper::SequenceAsHashMap
aFactoryProps(
1954 xContainer
->getByName( getModuleIdentifier( xModuleManager
, i_pObjSh
) ) );
1955 sal_Int32 nDefault
= -1;
1956 nFilter
= aFactoryProps
.getUnpackedValueOrDefault( DEFINE_CONST_UNICODE("ooSetupFactoryStyleFilter"), nDefault
);
1962 //-------------------------------------------------------------------------
1964 void SfxCommonTemplateDialog_Impl::SaveFactoryStyleFilter( SfxObjectShell
* i_pObjSh
, sal_Int32 i_nFilter
)
1966 DBG_ASSERT( i_pObjSh
, "SfxCommonTemplateDialog_Impl::LoadFactoryStyleFilter(): no ObjectShell" );
1967 Reference
< ::com::sun::star::container::XNameReplace
> xContainer( xModuleManager
, UNO_QUERY
);
1968 if ( xContainer
.is() )
1970 Sequence
< PropertyValue
> lProps(1);
1971 lProps
[0].Name
= DEFINE_CONST_UNICODE("ooSetupFactoryStyleFilter");
1972 lProps
[0].Value
= makeAny( i_nFilter
);;
1973 xContainer
->replaceByName( getModuleIdentifier( xModuleManager
, i_pObjSh
), makeAny( lProps
) );
1977 //-------------------------------------------------------------------------
1979 IMPL_LINK( SfxCommonTemplateDialog_Impl
, DropHdl
, StyleTreeListBox_Impl
*, pBox
)
1982 const SfxStyleFamilyItem
*pItem
= GetFamilyItem_Impl();
1983 const SfxStyleFamily eFam
= pItem
->GetFamily();
1984 long ret
= pStyleSheetPool
->SetParent(eFam
,pBox
->GetStyle(), pBox
->GetParent())? 1L: 0L;
1989 //-------------------------------------------------------------------------
1991 // Handler des Neu-Buttons
1992 void SfxCommonTemplateDialog_Impl::NewHdl(void *)
1995 if ( nActFamily
!= 0xffff )
1998 pTmp
= Application::GetDefDialogParent();
1999 if ( ISA(SfxTemplateDialog_Impl
) )
2000 Application::SetDefDialogParent( pWindow
->GetParent() );
2002 Application::SetDefDialogParent( pWindow
);
2004 const SfxStyleFamilyItem
*pItem
= GetFamilyItem_Impl();
2005 const SfxStyleFamily eFam
=pItem
->GetFamily();
2007 if(pItem
&&nActFilter
!=0xffff)
2009 nMask
= pItem
->GetFilterList().GetObject(
2010 nActFilter
)->nFlags
;
2011 if(!nMask
) // automatisch
2015 nMask
=pStyleSheetPool
->GetSearchMask();
2017 pStyleSheetPool
->SetSearchMask(eFam
,nMask
);
2019 Execute_Impl(SID_STYLE_NEW
,
2020 aEmpty
, GetSelectedEntry(),
2021 ( USHORT
)GetFamilyItem_Impl()->GetFamily(),
2024 Application::SetDefDialogParent( pTmp
);
2027 DBG_ASSERT(nFilter < aFilterLb.GetEntryCount(),
2028 "Filter ueberindiziert");
2032 // aFilterLb.SelectEntryPos(nFilter);
2033 FilterSelect(nActFilter, TRUE);
2038 SfxTemplateItem *pState = pFamilyState[nActFamily-1];
2041 const String aStyle(pState->GetStyleName());
2042 SelectStyle(aStyle);
2050 //-------------------------------------------------------------------------
2052 // Handler des Bearbeiten-Buttons
2053 void SfxCommonTemplateDialog_Impl::EditHdl(void *)
2055 if(IsInitialized() && HasSelectedStyle())
2057 USHORT nFilter
= nActFilter
;
2058 String
aTemplName(GetSelectedEntry());
2059 const SfxStyleFamilyItem
*pItem
= GetFamilyItem_Impl();
2060 const SfxStyleFamily eFam
= pItem
->GetFamily();
2061 pStyleSheetPool
->Find(aTemplName
,eFam
,SFXSTYLEBIT_ALL
); // -Wall required??
2063 //DefModalDialogParent setzen fuer
2064 //Modalitaet der nachfolgenden Dialoge
2065 pTmp
= Application::GetDefDialogParent();
2066 if ( ISA(SfxTemplateDialog_Impl
) )
2067 Application::SetDefDialogParent( pWindow
->GetParent() );
2069 Application::SetDefDialogParent( pWindow
);
2070 if ( Execute_Impl( SID_STYLE_EDIT
, aTemplName
, String(),
2071 (USHORT
)GetFamilyItem_Impl()->GetFamily(), 0, &nFilter
) )
2073 // DBG_ASSERT(nFilter < aFilterLb.GetEntryCount(), "Filter ueberindiziert");
2074 // aTemplName = pStyle->GetName();
2075 // kann durch Bearbeiten umbenannt worden sein
2078 // aFilterLb.SelectEntryPos(nFilter);
2079 // FilterSelect(nFilter, TRUE);
2084 Application::SetDefDialogParent( pTmp
);
2088 //-------------------------------------------------------------------------
2090 // Handler des L"oschen-Buttons
2091 void SfxCommonTemplateDialog_Impl::DeleteHdl(void *)
2093 if ( IsInitialized() && HasSelectedStyle() )
2095 const String
aTemplName( GetSelectedEntry() );
2096 const SfxStyleFamilyItem
* pItem
= GetFamilyItem_Impl();
2097 SfxStyleSheetBase
* pStyle
=
2098 pStyleSheetPool
->Find( aTemplName
, pItem
->GetFamily(), SFXSTYLEBIT_ALL
);
2102 if ( pStyle
->IsUsed() )
2103 aMsg
= String( SfxResId( STR_DELETE_STYLE_USED
) );
2104 aMsg
+= String ( SfxResId( STR_DELETE_STYLE
) );
2105 aMsg
.SearchAndReplaceAscii( "$1", aTemplName
);
2107 QueryBox
aBox( SFX_APP()->GetTopWindow(), WB_YES_NO
| WB_DEF_NO
, aMsg
);
2109 QueryBox
aBox( GetWindow(), WB_YES_NO
| WB_DEF_NO
, aMsg
);
2111 if ( RET_YES
== aBox
.Execute() )
2113 PrepareDeleteAction();
2115 if ( pTreeBox
) // Damit die Treelistbox beim L"oschen nicht zuklappt
2119 Execute_Impl( SID_STYLE_DELETE
, aTemplName
,
2120 String(), (USHORT
)GetFamilyItem_Impl()->GetFamily() );
2124 pTreeBox
->RemoveParentKeepChilds( pTreeBox
->FirstSelected() );
2125 bDontUpdate
= FALSE
;
2132 //-------------------------------------------------------------------------
2134 void SfxCommonTemplateDialog_Impl::EnableDelete()
2136 if(IsInitialized() && HasSelectedStyle())
2138 DBG_ASSERT(pStyleSheetPool
, "Kein StyleSheetPool");
2139 const String
aTemplName(GetSelectedEntry());
2140 const SfxStyleFamilyItem
*pItem
= GetFamilyItem_Impl();
2141 const SfxStyleFamily eFam
= pItem
->GetFamily();
2143 if(pItem
->GetFilterList().Count() > nActFilter
)
2144 nFilter
= pItem
->GetFilterList().GetObject(nActFilter
)->nFlags
;
2145 if(!nFilter
) // automatisch
2146 nFilter
= nAppFilter
;
2147 const SfxStyleSheetBase
*pStyle
=
2148 pStyleSheetPool
->Find(aTemplName
,eFam
,
2149 pTreeBox
? SFXSTYLEBIT_ALL
: nFilter
);
2150 DBG_ASSERT(pStyle
, "Style nicht gefunden");
2151 if(pStyle
&& pStyle
->IsUserDefined())
2164 // rBindings.Invalidate( SID_STYLE_DELETE );
2165 // rBindings.Update( SID_STYLE_DELETE );
2168 //-------------------------------------------------------------------------
2170 // nach Selektion eines Eintrags den Focus gfs. wieder auf das App-Fenster
2172 void SfxCommonTemplateDialog_Impl::ResetFocus()
2174 if(ISA(SfxTemplateDialog_Impl
))
2176 SfxViewFrame
*pViewFrame
= pBindings
->GetDispatcher_Impl()->GetFrame();
2177 SfxViewShell
*pVu
= pViewFrame
->GetViewShell();
2178 Window
*pAppWin
= pVu
? pVu
->GetWindow(): 0;
2180 pAppWin
->GrabFocus();
2184 //-------------------------------------------------------------------------
2186 // Doppelclick auf ein StyleSheet in der ListBox, wird angewendet.
2187 IMPL_LINK( SfxCommonTemplateDialog_Impl
, ApplyHdl
, Control
*, pControl
)
2189 (void)pControl
; //unused
2190 // nur, wenn dieser Bereich erlaubt ist
2191 if ( IsInitialized() && 0 != pFamilyState
[nActFamily
-1] &&
2192 GetSelectedEntry().Len() )
2194 USHORT nModifier
= aFmtLb
.GetModifier();
2195 Execute_Impl(SID_STYLE_APPLY
,
2196 GetSelectedEntry(), String(),
2197 ( USHORT
)GetFamilyItem_Impl()->GetFamily(),
2199 if(ISA(SfxTemplateCatalog_Impl
))
2200 ((SfxTemplateCatalog_Impl
*) this)->pReal
->EndDialog(RET_OK
);
2206 //-------------------------------------------------------------------------
2208 // Selektion einer Vorlage w"ahrend des Watercan-Status
2209 IMPL_LINK( SfxCommonTemplateDialog_Impl
, FmtSelectHdl
, SvTreeListBox
*, pListBox
)
2211 // HilfePI antriggern, wenn von Call als Handler und Bereich erlaubt ist
2212 if( !pListBox
|| pListBox
->IsSelected( pListBox
->GetHdlEntry() ) )
2214 #ifdef WIR_KOENNEN_WIEDER_HILFE_FUER_STYLESHEETS
2215 SfxHelpPI
* pHelpPI
= SFX_APP()->GetHelpPI();
2216 if ( pHelpPI
&& pListBox
&& IsInitialized() &&
2217 GetSelectedEntry().Len() )
2219 const SfxStyleFamilyItem
*pItem
= GetFamilyItem_Impl();
2220 const SfxStyleFamily eFam
= pItem
->GetFamily();
2221 DBG_ASSERT(pStyleSheetPool
, "Kein Pool");
2222 // SfxStyleSheetBase* pStyle = pStyleSheetPool
2223 // ? pStyleSheetPool->Find( GetSelectedEntry(), eFam ) : 0;
2224 SfxStyleSheetBase
*pStyle
;
2225 if ( pStyleSheetPool
)
2226 pStyle
= pStyleSheetPool
->Find ( GetSelectedEntry(), eFam
);
2233 ULONG nHelpId
=pStyle
->GetHelpId(aHelpFile
);
2235 pHelpPI
->LoadTopic( nHelpId
);
2240 // nur, wenn Giesskanne an ist
2241 if ( IsInitialized() &&
2242 IsCheckedItem(SID_STYLE_WATERCAN
) &&
2243 // nur, wenn dieser Bereich erlaubt ist
2244 0 != pFamilyState
[nActFamily
-1] )
2247 Execute_Impl(SID_STYLE_WATERCAN
,
2249 Execute_Impl(SID_STYLE_WATERCAN
,
2250 GetSelectedEntry(), aEmpty
,
2251 ( USHORT
)GetFamilyItem_Impl()->GetFamily());
2253 // EnableEdit(TRUE);
2254 EnableItem(SID_STYLE_WATERCAN
, !bWaterDisabled
);
2258 SelectStyle( pListBox
->GetEntryText( pListBox
->GetHdlEntry() ));
2263 //-------------------------------------------------------------------------
2265 IMPL_LINK( SfxCommonTemplateDialog_Impl
, MenuSelectHdl
, Menu
*, pMenu
)
2269 nLastItemId
= pMenu
->GetCurItemId();
2270 Application::PostUserEvent(
2271 LINK( this, SfxCommonTemplateDialog_Impl
, MenuSelectHdl
), 0 );
2275 switch(nLastItemId
) {
2276 case ID_NEW
: NewHdl(0); break;
2277 case ID_EDIT
: EditHdl(0); break;
2278 case ID_DELETE
: DeleteHdl(0); break;
2279 default: return FALSE
;
2284 // -----------------------------------------------------------------------
2286 void SfxCommonTemplateDialog_Impl::ExecuteContextMenu_Impl( const Point
& rPos
, Window
* pWin
)
2288 // Bug# 94152: This part should never be called, because before this happens, the TreeListBox should captured this!
2289 DBG_ASSERT( FALSE
, "+SfxCommonTemplateDialog_Impl::ExecuteContextMenu_Impl(): How could this happen? Please infirm developer ASAP!" );
2291 PopupMenu
* pMenu
= CreateContextMenu();
2292 pMenu
->Execute( pWin
, rPos
);
2296 // -----------------------------------------------------------------------
2298 SfxStyleFamily
SfxCommonTemplateDialog_Impl::GetActualFamily() const
2300 const SfxStyleFamilyItem
*pFamilyItem
= GetFamilyItem_Impl();
2301 if( !pFamilyItem
|| nActFamily
== 0xffff )
2302 return SFX_STYLE_FAMILY_PARA
;
2304 return pFamilyItem
->GetFamily();
2307 // -----------------------------------------------------------------------
2309 void SfxCommonTemplateDialog_Impl::EnableExample_Impl(USHORT nId
, BOOL bEnable
)
2311 if( nId
== SID_STYLE_NEW_BY_EXAMPLE
)
2312 bNewByExampleDisabled
= !bEnable
;
2313 else if( nId
== SID_STYLE_UPDATE_BY_EXAMPLE
)
2314 bUpdateByExampleDisabled
= !bEnable
;
2315 EnableItem(nId
, bEnable
);
2318 void SfxCommonTemplateDialog_Impl::PrepareDeleteAction()
2322 // -----------------------------------------------------------------------
2324 PopupMenu
* SfxCommonTemplateDialog_Impl::CreateContextMenu( void )
2326 if ( bBindingUpdate
)
2328 pBindings
->Invalidate( SID_STYLE_NEW
, TRUE
, FALSE
);
2329 pBindings
->Update( SID_STYLE_NEW
);
2330 bBindingUpdate
= FALSE
;
2332 PopupMenu
* pMenu
= new PopupMenu( SfxResId( MN_CONTEXT_TEMPLDLG
) );
2333 pMenu
->SetSelectHdl( LINK( this, SfxCommonTemplateDialog_Impl
, MenuSelectHdl
) );
2334 pMenu
->EnableItem( ID_EDIT
, bCanEdit
);
2335 pMenu
->EnableItem( ID_DELETE
, bCanDel
);
2336 pMenu
->EnableItem( ID_NEW
, bCanNew
);
2341 // ------------------------------------------------------------------------
2343 SfxTemplateDialog_Impl::SfxTemplateDialog_Impl(
2344 Window
* /*pParent*/, SfxBindings
* pB
, SfxTemplateDialog
* pDlgWindow
) :
2346 SfxCommonTemplateDialog_Impl( pB
, pDlgWindow
),
2348 m_pFloat ( pDlgWindow
),
2349 m_bZoomIn ( FALSE
),
2350 m_aActionTbL ( pDlgWindow
, this ),
2351 m_aActionTbR ( pDlgWindow
, SfxResId( TB_ACTION
) )
2354 pDlgWindow
->FreeResource();
2357 m_aActionTbL
.SetSelectHdl(LINK(this, SfxTemplateDialog_Impl
, ToolBoxLSelect
));
2358 m_aActionTbR
.SetSelectHdl(LINK(this, SfxTemplateDialog_Impl
, ToolBoxRSelect
));
2359 m_aActionTbR
.SetDropdownClickHdl(LINK(this, SfxTemplateDialog_Impl
, ToolBoxRClick
));
2360 m_aActionTbL
.Show();
2361 m_aActionTbR
.Show();
2362 Font aFont
=aFilterLb
.GetFont();
2363 aFont
.SetWeight( WEIGHT_NORMAL
);
2364 aFilterLb
.SetFont( aFont
);
2365 m_aActionTbL
.SetHelpId( HID_TEMPLDLG_TOOLBOX_LEFT
);
2368 // ------------------------------------------------------------------------
2370 void SfxTemplateDialog_Impl::EnableFamilyItem( USHORT nId
, BOOL bEnable
)
2372 m_aActionTbL
.EnableItem( nId
, bEnable
);
2375 //-------------------------------------------------------------------------
2377 void SfxTemplateDialog_Impl::InsertFamilyItem(USHORT nId
,const SfxStyleFamilyItem
*pItem
)
2380 switch( (USHORT
) pItem
->GetFamily() )
2382 case SFX_STYLE_FAMILY_CHAR
: nHelpId
= SID_STYLE_FAMILY1
; break;
2383 case SFX_STYLE_FAMILY_PARA
: nHelpId
= SID_STYLE_FAMILY2
; break;
2384 case SFX_STYLE_FAMILY_FRAME
:nHelpId
= SID_STYLE_FAMILY3
; break;
2385 case SFX_STYLE_FAMILY_PAGE
: nHelpId
= SID_STYLE_FAMILY4
; break;
2386 case SFX_STYLE_FAMILY_PSEUDO
: nHelpId
= SID_STYLE_FAMILY5
; break;
2387 default: DBG_ERROR("unbekannte StyleFamily"); break;
2389 m_aActionTbL
.InsertItem( nId
, pItem
->GetImage(), pItem
->GetText(), 0, 0);
2390 m_aActionTbL
.SetHelpId( nId
, nHelpId
);
2393 // ------------------------------------------------------------------------
2395 void SfxTemplateDialog_Impl::ReplaceUpdateButtonByMenu()
2397 m_aActionTbR
.HideItem(SID_STYLE_UPDATE_BY_EXAMPLE
);
2398 m_aActionTbR
.SetItemBits( SID_STYLE_NEW_BY_EXAMPLE
,
2399 TIB_DROPDOWNONLY
|m_aActionTbR
.GetItemBits( SID_STYLE_NEW_BY_EXAMPLE
));
2402 // ------------------------------------------------------------------------
2403 void SfxTemplateDialog_Impl::updateFamilyImages()
2405 if ( !m_pStyleFamiliesId
)
2406 // we do not have a resource id to load the new images from
2409 // let the families collection update the images
2410 sal_Bool bIsHighContrast
= m_pFloat
->GetDisplayBackground().GetColor().IsDark();
2411 pStyleFamilies
->updateImages( *m_pStyleFamiliesId
, bIsHighContrast
? BMP_COLOR_HIGHCONTRAST
: BMP_COLOR_NORMAL
);
2413 // and set the new images on our toolbox
2414 USHORT nLoop
= pStyleFamilies
->Count();
2417 const SfxStyleFamilyItem
*pItem
= pStyleFamilies
->GetObject( nLoop
);
2418 USHORT nId
= SfxFamilyIdToNId( pItem
->GetFamily() );
2419 m_aActionTbL
.SetItemImage( nId
, pItem
->GetImage() );
2423 // ------------------------------------------------------------------------
2424 void SfxTemplateDialog_Impl::updateNonFamilyImages()
2426 m_aActionTbR
.SetImageList( ImageList( SfxResId(
2427 m_pFloat
->GetDisplayBackground().GetColor().IsDark() ? IMG_LST_STYLE_DESIGNER_HC
2428 : DLG_STYLE_DESIGNER
) ) );
2431 // ------------------------------------------------------------------------
2433 void SfxTemplateDialog_Impl::ClearFamilyList()
2435 m_aActionTbL
.Clear();
2438 //-------------------------------------------------------------------------
2440 void SfxCommonTemplateDialog_Impl::InvalidateBindings()
2442 pBindings
->Invalidate(SID_STYLE_NEW_BY_EXAMPLE
, TRUE
, FALSE
);
2443 pBindings
->Update( SID_STYLE_NEW_BY_EXAMPLE
);
2444 pBindings
->Invalidate(SID_STYLE_UPDATE_BY_EXAMPLE
, TRUE
, FALSE
);
2445 pBindings
->Update( SID_STYLE_UPDATE_BY_EXAMPLE
);
2446 pBindings
->Invalidate( SID_STYLE_WATERCAN
, TRUE
, FALSE
);
2447 pBindings
->Update( SID_STYLE_WATERCAN
);
2448 pBindings
->Invalidate( SID_STYLE_NEW
, TRUE
, FALSE
);
2449 pBindings
->Update( SID_STYLE_NEW
);
2450 pBindings
->Invalidate( SID_STYLE_DRAGHIERARCHIE
, TRUE
, FALSE
);
2451 pBindings
->Update( SID_STYLE_DRAGHIERARCHIE
);
2454 //-------------------------------------------------------------------------
2456 SfxTemplateDialog_Impl::~SfxTemplateDialog_Impl()
2459 SfxImageManager* pImgMgr = pBindings->GetImageManager();
2462 pImgMgr->ReleaseToolBox( &m_aActionTbL );
2463 pImgMgr->ReleaseToolBox( &m_aActionTbR );
2468 //-------------------------------------------------------------------------
2470 void SfxTemplateDialog_Impl::LoadedFamilies()
2472 updateFamilyImages();
2476 //-------------------------------------------------------------------------
2478 // "Uberladener Resize-Handler ( StarView )
2479 // Die Groesse der Listboxen wird angepasst
2480 void SfxTemplateDialog_Impl::Resize()
2482 FloatingWindow
*pF
= m_pFloat
->GetFloatingWindow();
2485 // if(pF->IsZoomedIn() && m_bZoomIn==FALSE)
2486 // pF->SetText(String(SfxResId( DLG_STYLE_DESIGNER )));
2487 // if(!pF->IsZoomedIn() && m_bZoomIn==TRUE && GetFamilyItem_Impl())
2488 // UpdateStyles_Impl(UPDATE_FAMILY); //Bereich wieder in Titel schreiben
2489 m_bZoomIn
= pF
->IsRollUp();
2494 Size aDlgSize
=m_pFloat
->PixelToLogic(m_pFloat
->GetOutputSizePixel());
2495 Size aSizeATL
=m_pFloat
->PixelToLogic(m_aActionTbL
.CalcWindowSizePixel());
2496 Size aSizeATR
=m_pFloat
->PixelToLogic(m_aActionTbR
.CalcWindowSizePixel());
2497 Size aMinSize
= GetMinOutputSizePixel();
2499 long nListHeight
= m_pFloat
->PixelToLogic( aFilterLb
.GetSizePixel() ).Height();
2500 long nWidth
= aDlgSize
.Width()- 2 * SFX_TEMPLDLG_HFRAME
;
2502 m_aActionTbL
.SetPosSizePixel(m_pFloat
->LogicToPixel(Point(SFX_TEMPLDLG_HFRAME
,SFX_TEMPLDLG_VTOPFRAME
)),
2503 m_pFloat
->LogicToPixel(aSizeATL
));
2505 // Die Position der rechten Toolbox nur ver"andern, wenn das Fenster
2507 Point
aPosATR(aDlgSize
.Width()-SFX_TEMPLDLG_HFRAME
-aSizeATR
.Width(),SFX_TEMPLDLG_VTOPFRAME
);
2508 if(aDlgSize
.Width() >= aMinSize
.Width())
2509 m_aActionTbR
.SetPosPixel(m_pFloat
->LogicToPixel(aPosATR
));
2511 m_aActionTbR
.SetPosPixel( m_pFloat
->LogicToPixel(
2512 Point( SFX_TEMPLDLG_HFRAME
+ aSizeATL
.Width() + SFX_TEMPLDLG_MIDHSPACE
,
2513 SFX_TEMPLDLG_VTOPFRAME
) ) );
2515 m_aActionTbR
.SetSizePixel(m_pFloat
->LogicToPixel(aSizeATR
));
2518 m_pFloat
->LogicToPixel(Point(SFX_TEMPLDLG_HFRAME
,
2519 aDlgSize
.Height()-SFX_TEMPLDLG_VBOTFRAME
-nListHeight
)) );
2522 m_pFloat
->LogicToPixel(Size(nWidth
,SFX_TEMPLDLG_FILTERHEIGHT
)) );
2525 m_pFloat
->LogicToPixel(Point(SFX_TEMPLDLG_HFRAME
, SFX_TEMPLDLG_VTOPFRAME
+
2526 SFX_TEMPLDLG_MIDVSPACE
+aSizeATL
.Height())) );
2528 m_pFloat
->LogicToPixel(Size(nWidth
,
2529 aDlgSize
.Height() - SFX_TEMPLDLG_VBOTFRAME
-
2530 SFX_TEMPLDLG_VTOPFRAME
- 2*SFX_TEMPLDLG_MIDVSPACE
-
2531 nListHeight
-aSizeATL
.Height())) );
2533 // Die Position der Listboxen nur ver"andern, wenn das Fenster
2535 if(aDlgSize
.Height() >= aMinSize
.Height())
2537 aFilterLb
.SetPosPixel(aFilterPos
);
2538 aFmtLb
.SetPosPixel( aFmtPos
);
2540 pTreeBox
->SetPosPixel(aFmtPos
);
2543 aFmtSize
.Height() += aFilterSize
.Height();
2545 aFilterLb
.SetSizePixel(aFilterSize
);
2546 aFmtLb
.SetSizePixel( aFmtSize
);
2548 pTreeBox
->SetSizePixel(aFmtSize
);
2551 // -----------------------------------------------------------------------
2554 Size
SfxTemplateDialog_Impl::GetMinOutputSizePixel()
2556 Size aSizeATL
=m_pFloat
->PixelToLogic(m_aActionTbL
.CalcWindowSizePixel());
2557 Size aSizeATR
=m_pFloat
->PixelToLogic(m_aActionTbR
.CalcWindowSizePixel());
2559 aSizeATL
.Width()+aSizeATR
.Width()+
2560 2*SFX_TEMPLDLG_HFRAME
+ SFX_TEMPLDLG_MIDHSPACE
,
2561 4*aSizeATL
.Height()+2*SFX_TEMPLDLG_MIDVSPACE
);
2565 //-------------------------------------------------------------------------
2567 void SfxTemplateDialog_Impl::Command( const CommandEvent
& rCEvt
)
2569 if(COMMAND_CONTEXTMENU
== rCEvt
.GetCommand())
2570 ExecuteContextMenu_Impl( rCEvt
.GetMousePosPixel(), m_pFloat
);
2572 m_pFloat
->Command(rCEvt
);
2575 //-------------------------------------------------------------------------
2577 void SfxTemplateDialog_Impl::EnableItem(USHORT nMesId
, BOOL bCheck
)
2582 case SID_STYLE_WATERCAN
:
2583 if(!bCheck
&& IsCheckedItem(SID_STYLE_WATERCAN
))
2584 Execute_Impl(SID_STYLE_WATERCAN
, aEmpty
, aEmpty
, 0);
2585 case SID_STYLE_NEW_BY_EXAMPLE
:
2586 case SID_STYLE_UPDATE_BY_EXAMPLE
:
2587 m_aActionTbR
.EnableItem(nMesId
,bCheck
);
2592 //-------------------------------------------------------------------------
2594 void SfxTemplateDialog_Impl::CheckItem(USHORT nMesId
, BOOL bCheck
)
2598 case SID_STYLE_WATERCAN
:
2600 m_aActionTbR
.CheckItem(SID_STYLE_WATERCAN
,bCheck
);
2603 m_aActionTbL
.CheckItem(nMesId
,bCheck
); break;
2607 //-------------------------------------------------------------------------
2609 BOOL
SfxTemplateDialog_Impl::IsCheckedItem(USHORT nMesId
)
2613 case SID_STYLE_WATERCAN
:
2614 return m_aActionTbR
.GetItemState(SID_STYLE_WATERCAN
)==STATE_CHECK
;
2616 return m_aActionTbL
.GetItemState(nMesId
)==STATE_CHECK
;
2620 //-------------------------------------------------------------------------
2622 IMPL_LINK_INLINE_START( SfxTemplateDialog_Impl
, ToolBoxLSelect
, ToolBox
*, pBox
)
2624 const USHORT nEntry
= pBox
->GetCurItemId();
2625 FamilySelect(nEntry
);
2628 IMPL_LINK_INLINE_END( SfxTemplateDialog_Impl
, ToolBoxLSelect
, ToolBox
*, pBox
)
2630 //-------------------------------------------------------------------------
2631 ::rtl::OUString
lcl_GetLabel(uno::Any
& rAny
)
2633 ::rtl::OUString sRet
;
2634 uno::Sequence
< beans::PropertyValue
>aPropSeq
;
2635 if ( rAny
>>= aPropSeq
)
2637 for( sal_Int32 i
= 0; i
< aPropSeq
.getLength(); i
++ )
2639 if ( aPropSeq
[i
].Name
.equalsAscii( "Label" ))
2641 aPropSeq
[i
].Value
>>= sRet
;
2648 //-------------------------------------------------------------------------
2650 IMPL_LINK( SfxTemplateDialog_Impl
, ToolBoxRSelect
, ToolBox
*, pBox
)
2652 const USHORT nEntry
= pBox
->GetCurItemId();
2653 if(nEntry
!= SID_STYLE_NEW_BY_EXAMPLE
||
2654 TIB_DROPDOWN
!= (pBox
->GetItemBits(nEntry
)&TIB_DROPDOWN
))
2655 ActionSelect(nEntry
);
2658 //-------------------------------------------------------------------------
2659 IMPL_LINK( SfxTemplateDialog_Impl
, ToolBoxRClick
, ToolBox
*, pBox
)
2661 const USHORT nEntry
= pBox
->GetCurItemId();
2662 if(nEntry
== SID_STYLE_NEW_BY_EXAMPLE
&&
2663 TIB_DROPDOWN
== (pBox
->GetItemBits(nEntry
)&TIB_DROPDOWN
))
2665 //create a popup menu in Writer
2666 PopupMenu
*pMenu
= new PopupMenu
;
2667 uno::Reference
< container::XNameAccess
> xNameAccess(
2668 ::comphelper::getProcessServiceFactory()->
2669 createInstance( ::rtl::OUString::createFromAscii(
2670 "com.sun.star.frame.UICommandDescription") ), uno::UNO_QUERY
);
2671 uno::Reference
< container::XNameAccess
> xUICommands
;
2672 if ( xNameAccess
.is() )
2674 rtl::OUString sTextDoc
= ::rtl::OUString::createFromAscii("com.sun.star.text.TextDocument");
2675 if(xNameAccess
->hasByName(sTextDoc
))
2677 uno::Any a
= xNameAccess
->getByName( sTextDoc
);
2681 if(!xUICommands
.is())
2685 uno::Sequence
< beans::PropertyValue
> aPropSeq
;
2686 uno::Any aCommand
= xUICommands
->getByName(::rtl::OUString::createFromAscii(".uno:StyleNewByExample"));
2687 ::rtl::OUString sLabel
= lcl_GetLabel( aCommand
);
2688 pMenu
->InsertItem( SID_STYLE_NEW_BY_EXAMPLE
, sLabel
);
2689 pMenu
->SetHelpId(SID_STYLE_NEW_BY_EXAMPLE
, HID_TEMPLDLG_NEWBYEXAMPLE
);
2691 aCommand
= xUICommands
->getByName(::rtl::OUString::createFromAscii(".uno:StyleUpdateByExample"));
2692 sLabel
= lcl_GetLabel( aCommand
);
2694 pMenu
->InsertItem( SID_STYLE_UPDATE_BY_EXAMPLE
, sLabel
);
2695 pMenu
->SetHelpId(SID_STYLE_UPDATE_BY_EXAMPLE
, HID_TEMPLDLG_UPDATEBYEXAMPLE
);
2697 aCommand
= xUICommands
->getByName(::rtl::OUString::createFromAscii(".uno:LoadStyles"));
2698 sLabel
= lcl_GetLabel( aCommand
);
2699 pMenu
->InsertItem( SID_TEMPLATE_LOAD
, sLabel
);
2700 pMenu
->SetHelpId(SID_TEMPLATE_LOAD
, SID_TEMPLATE_LOAD
);
2702 pMenu
->SetSelectHdl(LINK(this, SfxTemplateDialog_Impl
, MenuSelectHdl
));
2703 pMenu
->Execute( pBox
,
2704 pBox
->GetItemRect(nEntry
),
2705 POPUPMENU_EXECUTE_DOWN
);
2706 pBox
->EndSelection();
2708 catch(uno::Exception
&)
2716 //-------------------------------------------------------------------------
2717 IMPL_LINK( SfxTemplateDialog_Impl
, MenuSelectHdl
, Menu
*, pMenu
)
2719 USHORT nMenuId
= pMenu
->GetCurItemId();
2720 ActionSelect(nMenuId
);
2723 //-------------------------------------------------------------------------
2725 SfxTemplateCatalog_Impl::SfxTemplateCatalog_Impl( Window
* /*pParent*/, SfxBindings
* pB
,
2726 SfxTemplateCatalog
* pTmpWindow
) :
2728 SfxCommonTemplateDialog_Impl( pB
, pTmpWindow
),
2730 aFamList ( pTmpWindow
, SfxResId( BT_TOOL
) ),
2731 aOkBtn ( pTmpWindow
, SfxResId( BT_OK
) ),
2732 aCancelBtn ( pTmpWindow
, SfxResId( BT_CANCEL
) ),
2733 aNewBtn ( pTmpWindow
, SfxResId( BT_NEW
) ),
2734 aChangeBtn ( pTmpWindow
, SfxResId( BT_EDIT
) ),
2735 aDelBtn ( pTmpWindow
, SfxResId( BT_DEL
) ),
2736 aOrgBtn ( pTmpWindow
, SfxResId( BT_ORG
) ),
2737 aHelpBtn ( pTmpWindow
, SfxResId( BT_HELP
) ),
2738 pReal ( pTmpWindow
),
2739 aHelper ( pTmpWindow
)
2744 aChangeBtn
.Disable();
2746 SFX_APP()->Get_Impl()->pTemplateCommon
= GetISfxTemplateCommon();
2747 pTmpWindow
->FreeResource();
2751 aFamList
.SetSelectHdl( LINK( this, SfxTemplateCatalog_Impl
, FamListSelect
) );
2752 aOkBtn
.SetClickHdl( LINK( this, SfxTemplateCatalog_Impl
, OkHdl
) );
2753 aCancelBtn
.SetClickHdl( LINK( this, SfxTemplateCatalog_Impl
, CancelHdl
) );
2754 aNewBtn
.SetClickHdl( LINK( this, SfxTemplateCatalog_Impl
, NewHdl
) );
2755 aDelBtn
.SetClickHdl( LINK( this, SfxTemplateCatalog_Impl
, DelHdl
) );
2756 aChangeBtn
.SetClickHdl( LINK( this, SfxTemplateCatalog_Impl
, ChangeHdl
) );
2757 aOrgBtn
.SetClickHdl( LINK( this, SfxTemplateCatalog_Impl
, OrgHdl
) );
2760 //-------------------------------------------------------------------------
2762 SfxTemplateCatalog_Impl::~SfxTemplateCatalog_Impl()
2764 SFX_APP()->Get_Impl()->pTemplateCommon
= 0;
2767 //-------------------------------------------------------------------------
2769 IMPL_LINK_INLINE_START( SfxTemplateCatalog_Impl
, OkHdl
, Button
*, pButton
)
2771 (void)pButton
; //unused
2773 pReal
->EndDialog( RET_OK
);
2776 IMPL_LINK_INLINE_END( SfxTemplateCatalog_Impl
, OkHdl
, Button
*, pButton
)
2778 //-------------------------------------------------------------------------
2780 IMPL_LINK_INLINE_START( SfxTemplateCatalog_Impl
, CancelHdl
, Button
*, pButton
)
2782 (void)pButton
; //unused
2783 pReal
->EndDialog( RET_CANCEL
);
2786 IMPL_LINK_INLINE_END( SfxTemplateCatalog_Impl
, CancelHdl
, Button
*, pButton
)
2788 //-------------------------------------------------------------------------
2790 IMPL_LINK_INLINE_START( SfxTemplateCatalog_Impl
, NewHdl
, Button
*, pButton
)
2792 (void)pButton
; //unused
2793 aCancelBtn
.SetText( String( SfxResId( STR_CLOSE
) ) );
2794 SfxCommonTemplateDialog_Impl::NewHdl( NULL
);
2797 IMPL_LINK_INLINE_END( SfxTemplateCatalog_Impl
, NewHdl
, Button
*, pButton
)
2799 //-------------------------------------------------------------------------
2801 IMPL_LINK_INLINE_START( SfxTemplateCatalog_Impl
, ChangeHdl
, Button
*, pButton
)
2803 (void)pButton
; //unused
2804 aCancelBtn
.SetText( String( SfxResId( STR_CLOSE
) ) );
2805 SfxCommonTemplateDialog_Impl::EditHdl( NULL
);
2808 IMPL_LINK_INLINE_END( SfxTemplateCatalog_Impl
, ChangeHdl
, Button
*, pButton
)
2810 //-------------------------------------------------------------------------
2812 IMPL_LINK_INLINE_START( SfxTemplateCatalog_Impl
, DelHdl
, Button
*, pButton
)
2814 (void)pButton
; //unused
2815 SfxCommonTemplateDialog_Impl::DeleteHdl( NULL
);
2818 IMPL_LINK_INLINE_END( SfxTemplateCatalog_Impl
, DelHdl
, Button
*, pButton
)
2820 //-------------------------------------------------------------------------
2822 IMPL_LINK( SfxTemplateCatalog_Impl
, OrgHdl
, Button
*, pButton
)
2824 (void)pButton
; //unused
2825 aCancelBtn
.SetText( String( SfxResId( STR_CLOSE
) ) );
2826 SfxDocumentTemplates aTemplates
;
2827 aTemplates
.Construct();
2828 SfxTemplateOrganizeDlg
* pDlg
= new SfxTemplateOrganizeDlg( pReal
, &aTemplates
);
2829 const short nRet
= pDlg
->Execute();
2831 if ( RET_OK
== nRet
)
2833 else if ( RET_EDIT_STYLE
== nRet
)
2834 pReal
->EndDialog( RET_CANCEL
);
2838 //-------------------------------------------------------------------------
2840 void SfxTemplateCatalog_Impl::EnableEdit( BOOL bEnable
)
2842 SfxCommonTemplateDialog_Impl::EnableEdit( bEnable
);
2843 aChangeBtn
.Enable( bEnable
);
2846 //-------------------------------------------------------------------------
2848 void SfxTemplateCatalog_Impl::EnableDel( BOOL bEnable
)
2850 SfxCommonTemplateDialog_Impl::EnableDel( bEnable
);
2851 aDelBtn
.Enable( bEnable
);
2854 void SfxTemplateCatalog_Impl::EnableNew(BOOL bEnable
)
2856 SfxCommonTemplateDialog_Impl::EnableNew( bEnable
);
2857 aNewBtn
.Enable( bEnable
);
2860 //-------------------------------------------------------------------------
2862 IMPL_LINK_INLINE_START( SfxTemplateCatalog_Impl
, FamListSelect
, ListBox
*, pList
)
2864 const USHORT nEntry
= aFamIds
[pList
->GetSelectEntryPos()];
2865 FamilySelect(nEntry
);
2868 IMPL_LINK_INLINE_END( SfxTemplateCatalog_Impl
, FamListSelect
, ListBox
*, pList
)
2870 //-------------------------------------------------------------------------
2872 void SfxTemplateCatalog_Impl::EnableItem( USHORT nMesId
, BOOL bCheck
)
2874 if ( nMesId
== SID_STYLE_WATERCAN
)
2875 aOkBtn
.Enable( bCheck
);
2876 if ( nMesId
> SFX_STYLE_FAMILY_PSEUDO
|| nMesId
< SFX_STYLE_FAMILY_CHAR
)
2879 /* for(USHORT i=0;i<aFamIds.Count&&aFamIds[i]!=nMesId;i++);
2880 if(i!=aFamIds.Count())
2881 aFamList.SelectEntry(aFamIds[i]);
2883 DBG_ERROR("Entry nicht gefunden");*/
2887 //-------------------------------------------------------------------------
2889 void SfxTemplateCatalog_Impl::CheckItem(USHORT nMesId
, BOOL
/*bCheck*/)
2891 if ( nMesId
> SFX_STYLE_FAMILY_PSEUDO
|| nMesId
< SFX_STYLE_FAMILY_CHAR
)
2894 for ( i
= 0; i
< aFamIds
.Count() && aFamIds
[i
] != nMesId
; i
++ ) ;
2895 aFamList
.SelectEntryPos(i
);
2898 //-------------------------------------------------------------------------
2900 BOOL
SfxTemplateCatalog_Impl::IsCheckedItem(USHORT nMesId
)
2902 if ( nMesId
> SFX_STYLE_FAMILY_PSEUDO
|| nMesId
< SFX_STYLE_FAMILY_CHAR
)
2905 for ( i
= 0; i
< aFamIds
.Count() && aFamIds
[i
] != nMesId
; i
++ )
2907 return aFamList
.IsEntrySelected( String::CreateFromInt32(i
) );
2910 //-------------------------------------------------------------------------
2912 // Der Katalog muss nur das Disablen beherrschen, da waehrend seiner
2913 // Lebenszeit keine Selektionsaenderungen vorgenommen werden koennen
2914 void SfxTemplateCatalog_Impl::EnableFamilyItem( USHORT nId
, BOOL bEnable
)
2917 for ( USHORT nPos
= aFamIds
.Count(); nPos
--; )
2918 if ( aFamIds
[ nPos
] == nId
)
2920 aFamIds
.Remove( nPos
);
2921 aFamList
.RemoveEntry( nPos
);
2925 void SfxTemplateCatalog_Impl::InsertFamilyItem( USHORT nId
, const SfxStyleFamilyItem
* pItem
)
2927 if ( nId
> SFX_STYLE_FAMILY_PSEUDO
|| nId
< SFX_STYLE_FAMILY_CHAR
)
2929 aFamList
.InsertEntry( pItem
->GetText(), 0 );
2930 aFamIds
.Insert( nId
, 0 );
2933 void SfxTemplateCatalog_Impl::ClearFamilyList()
2936 aFamIds
.Remove( 0, aFamIds
.Count() );
2939 void SfxTemplateCatalog_Impl::PrepareDeleteAction()
2942 aCancelBtn
.SetText( String( SfxResId( STR_CLOSE
) ) );
2946 void SfxCommonTemplateDialog_Impl::SetFamily( USHORT nId
)
2948 if ( nId
!= nActFamily
)
2950 if ( nActFamily
!= 0xFFFF )
2951 CheckItem( nActFamily
, FALSE
);
2953 if ( nId
!= 0xFFFF )
2954 bUpdateFamily
= TRUE
;
2958 void SfxCommonTemplateDialog_Impl::UpdateFamily_Impl()
2960 bUpdateFamily
= FALSE
;
2962 SfxDispatcher
* pDispat
= pBindings
->GetDispatcher_Impl();
2963 SfxViewFrame
*pViewFrame
= pDispat
->GetFrame();
2964 SfxObjectShell
*pDocShell
= pViewFrame
->GetObjectShell();
2966 SfxStyleSheetBasePool
*pOldStyleSheetPool
= pStyleSheetPool
;
2967 pStyleSheetPool
= pDocShell
? pDocShell
->GetStyleSheetPool(): 0;
2968 if ( pOldStyleSheetPool
!= pStyleSheetPool
)
2970 if ( pOldStyleSheetPool
)
2971 EndListening(*pOldStyleSheetPool
);
2972 if ( pStyleSheetPool
)
2973 StartListening(*pOldStyleSheetPool
);
2976 bWaterDisabled
= FALSE
;
2979 bUpdateByExampleDisabled
= FALSE
;
2981 if ( pStyleSheetPool
)
2984 UpdateStyles_Impl(UPDATE_FAMILY
| UPDATE_FAMILY_LIST
);
2987 UpdateStyles_Impl(UPDATE_FAMILY
);
2992 InvalidateBindings();
2994 if ( IsCheckedItem( SID_STYLE_WATERCAN
) &&
2995 // nur, wenn dieser Bereich erlaubt ist
2996 0 != pFamilyState
[ nActFamily
- 1 ] )
2997 Execute_Impl( SID_STYLE_APPLY
, GetSelectedEntry(),
2998 String(), (USHORT
)GetFamilyItem_Impl()->GetFamily() );
3000 void SfxCommonTemplateDialog_Impl::ReplaceUpdateButtonByMenu()
3005 void SfxTemplateDialog::StateChanged( StateChangedType nStateChange
)
3007 if ( nStateChange
== STATE_CHANGE_INITSHOW
)
3009 SfxViewFrame
*pFrame
= GetBindings().GetDispatcher_Impl()->GetFrame();
3010 Window
* pEditWin
= pFrame
->GetViewShell()->GetWindow();
3012 Size aSize
= pEditWin
->GetSizePixel();
3013 Point aPoint
= pEditWin
->OutputToScreenPixel( pEditWin
->GetPosPixel() );
3014 aPoint
= GetParent()->ScreenToOutputPixel( aPoint
);
3015 Size aWinSize
= GetSizePixel();
3016 aPoint
.X() += aSize
.Width() - aWinSize
.Width() - 20;
3017 aPoint
.Y() += aSize
.Height() / 2 - aWinSize
.Height() / 2;
3018 SetFloatingPos( aPoint
);
3021 SfxDockingWindow::StateChanged( nStateChange
);
3024 /*-- 10.12.2003 11:44:35---------------------------------------------------
3026 -----------------------------------------------------------------------*/
3027 DropToolBox_Impl::DropToolBox_Impl(Window
* pParent
, SfxTemplateDialog_Impl
* pTemplateDialog
) :
3029 DropTargetHelper(this),
3030 rParent(*pTemplateDialog
)
3033 /*-- 10.12.2003 11:44:35---------------------------------------------------
3035 -----------------------------------------------------------------------*/
3036 DropToolBox_Impl::~DropToolBox_Impl()
3039 /*-- 10.12.2003 11:44:35---------------------------------------------------
3041 -----------------------------------------------------------------------*/
3042 sal_Int8
DropToolBox_Impl::AcceptDrop( const AcceptDropEvent
& rEvt
)
3044 sal_Int8 nReturn
= DND_ACTION_NONE
;
3045 USHORT nItemId
= GetItemId( rEvt
.maPosPixel
);
3046 if(USHRT_MAX
!= nItemId
&& !IsItemChecked( nItemId
))
3048 SetCurItemId(nItemId
);
3049 GetSelectHdl().Call(this);
3051 // special case: page styles are allowed to create new styles by example
3052 // but not allowed to be created by drag and drop
3053 if ( nItemId
!= SfxCommonTemplateDialog_Impl::SfxFamilyIdToNId( SFX_STYLE_FAMILY_PAGE
)&&
3054 IsDropFormatSupported( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR
) &&
3055 !rParent
.bNewByExampleDisabled
)
3057 nReturn
= DND_ACTION_COPY
;
3061 /*-- 10.12.2003 11:44:35---------------------------------------------------
3063 -----------------------------------------------------------------------*/
3064 sal_Int8
DropToolBox_Impl::ExecuteDrop( const ExecuteDropEvent
& rEvt
)
3066 return rParent
.aFmtLb
.ExecuteDrop(rEvt
);