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: apphdl.cxx,v $
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_sw.hxx"
33 #include <hintids.hxx>
34 #include <tools/urlobj.hxx>
36 #include <tools/debug.hxx>
37 #include <tools/link.hxx>
39 #define _SVSTDARR_STRINGSDTOR
40 #include <svtools/svstdarr.hxx>
41 #include <svtools/urihelper.hxx>
42 #include <svtools/undoopt.hxx>
43 #include <svtools/pathoptions.hxx>
44 #include <svtools/accessibilityoptions.hxx>
45 #include <sfx2/dispatch.hxx>
46 #include <sfx2/event.hxx>
47 #include <sfx2/objitem.hxx>
48 #include <svx/dataaccessdescriptor.hxx>
49 #include <svx/srchitem.hxx>
50 #include <svtools/colorcfg.hxx>
51 #include <svtools/eitem.hxx>
52 #include <svtools/whiter.hxx>
53 #include <svtools/isethint.hxx>
54 #include <svx/hyprlink.hxx>
55 #include <sfx2/request.hxx>
56 #include <sfx2/fcontnr.hxx>
57 #include <svtools/stritem.hxx>
58 #include <svtools/ctloptions.hxx>
59 #include <svtools/useroptions.hxx>
60 #include <vcl/msgbox.hxx>
61 #include <vcl/wrkwin.hxx>
62 #include <svx/insctrl.hxx>
63 #include <svx/selctrl.hxx>
64 #include <com/sun/star/document/UpdateDocMode.hpp>
65 #include <sfx2/docfile.hxx>
66 #include <svx/xmlsecctrl.hxx>
67 #include <navicfg.hxx>
69 #include <sfx2/objface.hxx>
70 #include <sfx2/app.hxx>
74 #include <srcview.hxx>
78 #include <cmdid.h> // Funktion-Ids
82 #include <swmodule.hxx>
85 #include <usrpref.hxx>
86 #include <gloslst.hxx> // SwGlossaryList
87 #include <glosdoc.hxx> // SwGlossaryList
89 #include <cfgitems.hxx>
92 #include <globals.h> // globale Konstanten z.B.
96 #include <fontcfg.hxx>
99 #include <dbconfig.hxx>
100 #include <mmconfigitem.hxx>
101 #include <mailmergechildwindow.hxx>
102 #include <linguistic/lngprops.hxx>
103 #include <svx/unolingu.hxx>
104 #include <com/sun/star/beans/XMultiPropertySet.hpp>
105 #include <com/sun/star/beans/XFastPropertySet.hpp>
106 #include <com/sun/star/beans/XPropertyState.hpp>
107 #include <com/sun/star/beans/XPropertyStateChangeListener.hpp>
108 #include <com/sun/star/beans/PropertyAttribute.hpp>
109 #include <com/sun/star/beans/XPropertyAccess.hpp>
110 #include <com/sun/star/beans/XPropertyContainer.hpp>
111 #include <com/sun/star/container/XChild.hpp>
112 #include <com/sun/star/sdbc/XConnection.hpp>
113 #include <com/sun/star/sdbc/XDataSource.hpp>
114 #include <swabstdlg.hxx>
117 #include <vcl/status.hxx>
119 #include "salhelper/simplereferenceobject.hxx"
120 #include "rtl/ref.hxx"
124 using namespace ::com::sun::star
;
126 /*--------------------------------------------------------------------
127 Beschreibung: Slotmaps fuer Methoden der Applikation
128 --------------------------------------------------------------------*/
131 // hier werden die SlotID's included
136 #define WebViewSettings
137 #define PrintSettings
138 #define _ExecAddress ExecOther
139 #define _StateAddress StateOther
140 #include <sfx2/msg.hxx>
141 #include <svx/svxslots.hxx>
142 #include "swslots.hxx"
145 #include <shells.hrc>
147 SFX_IMPL_INTERFACE( SwModule
, SfxModule
, SW_RES(RID_SW_NAME
) )
149 SFX_CHILDWINDOW_REGISTRATION(SvxHyperlinkDlgWrapper::GetChildWindowId());
150 SFX_STATUSBAR_REGISTRATION(SW_RES(CFG_STATUSBAR
));
151 SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_APPLICATION
|
152 SFX_VISIBILITY_DESKTOP
| SFX_VISIBILITY_STANDARD
| SFX_VISIBILITY_CLIENT
| SFX_VISIBILITY_VIEWER
,
153 SW_RES(RID_MODULE_TOOLBOX
) );
157 /*--------------------------------------------------------------------
158 Beschreibung: Andere States
159 --------------------------------------------------------------------*/
162 void SwModule::StateOther(SfxItemSet
&rSet
)
164 SfxWhichIter
aIter(rSet
);
165 sal_uInt16 nWhich
= aIter
.FirstWhich();
167 SwView
* pActView
= ::GetActiveView();
168 sal_Bool bWebView
= 0 != PTR_CAST(SwWebView
, pActView
);
174 case FN_BUSINESS_CARD
:
178 sal_Bool bDisable
= sal_False
;
179 SfxViewShell
* pCurrView
= SfxViewShell::Current();
180 if( !pCurrView
|| (pCurrView
&& !pCurrView
->ISA(SwView
)) )
182 SwDocShell
*pDocSh
= (SwDocShell
*) SfxObjectShell::Current();
184 (pDocSh
&& (pDocSh
->IsReadOnly() ||
185 pDocSh
->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED
)) )
186 rSet
.DisableItem( nWhich
);
191 // slot is always active!
193 case FN_EDIT_FORMULA
:
198 pSh
= &pActView
->GetWrtShell();
200 nSelection
= pSh
->GetSelectionType();
202 if( (pSh
&& pSh
->HasSelection()) ||
203 !(nSelection
& (nsSelectionType::SEL_TXT
| nsSelectionType::SEL_TBL
)))
204 rSet
.DisableItem(nWhich
);
207 case SID_ATTR_METRIC
:
208 rSet
.Put( SfxUInt16Item( SID_ATTR_METRIC
, static_cast< UINT16
>(::GetDfltMetric(bWebView
))));
210 case FN_SET_MODOPT_TBLNUMFMT
:
211 rSet
.Put( SfxBoolItem( nWhich
, pModuleConfig
->
212 IsInsTblFormatNum( bWebView
)));
215 DBG_ERROR("::StateOther: default");
217 nWhich
= aIter
.NextWhich();
221 /*-- 06.04.2004 15:21:43---------------------------------------------------
223 -----------------------------------------------------------------------*/
224 SwView
* lcl_LoadDoc(SwView
* pView
, const String
& rURL
)
226 SwView
* pNewView
= 0;
229 SfxStringItem
aURL(SID_FILE_NAME
, rURL
);
230 SfxStringItem
aTargetFrameName( SID_TARGETNAME
, String::CreateFromAscii("_blank") );
231 SfxBoolItem
aHidden( SID_HIDDEN
, TRUE
);
232 SfxStringItem
aReferer(SID_REFERER
, pView
->GetDocShell()->GetTitle());
233 SfxObjectItem
* pItem
= (SfxObjectItem
*)pView
->GetViewFrame()->GetDispatcher()->
234 Execute(SID_OPENDOC
, SFX_CALLMODE_SYNCHRON
,
235 &aURL
, &aHidden
, &aReferer
, &aTargetFrameName
, 0L);
236 SfxShell
* pShell
= pItem
? pItem
->GetShell() : 0;
240 SfxViewShell
* pViewShell
= pShell
->GetViewShell();
243 if( pViewShell
->ISA(SwView
) )
245 pNewView
= PTR_CAST(SwView
,pViewShell
);
246 pNewView
->GetViewFrame()->GetFrame()->Appear();
250 pViewShell
->GetViewFrame()->DoClose();
257 SfxStringItem
aFactory(SID_NEWDOCDIRECT
, SwDocShell::Factory().GetFilterContainer()->GetName());
258 const SfxFrameItem
* pItem
= (SfxFrameItem
*)
259 pView
->GetViewFrame()->GetDispatcher()->Execute(SID_NEWDOCDIRECT
,
260 SFX_CALLMODE_SYNCHRON
, &aFactory
, 0L);
261 SfxFrame
* pFrm
= pItem
? pItem
->GetFrame() : 0;
262 SfxViewFrame
* pFrame
= pFrm
? pFrm
->GetCurrentViewFrame() : 0;
263 pNewView
= pFrame
? PTR_CAST(SwView
, pFrame
->GetViewShell()) : 0;
268 /*--------------------------------------------------------------------
269 Beschreibung: Felddialog starten
270 --------------------------------------------------------------------*/
272 void NewXForms( SfxRequest
& rReq
); // implementation: below
277 class SwMailMergeWizardExecutor
: public salhelper::SimpleReferenceObject
279 SwView
* m_pView
; // never owner
280 SwView
* m_pView2Close
; // never owner
281 SwMailMergeConfigItem
* m_pMMConfig
; // sometimes owner
282 AbstractMailMergeWizard
* m_pWizard
; // always owner
284 DECL_LINK( EndDialogHdl
, AbstractMailMergeWizard
* );
285 DECL_LINK( DestroyDialogHdl
, AbstractMailMergeWizard
* );
286 DECL_LINK( DestroyWizardHdl
, AbstractMailMergeWizard
* );
287 DECL_LINK( CancelHdl
, AbstractMailMergeWizard
* );
288 DECL_LINK( CloseFrameHdl
, AbstractMailMergeWizard
* );
290 void ExecutionFinished( bool bDeleteConfigItem
);
291 void ExecuteWizard();
294 SwMailMergeWizardExecutor();
295 ~SwMailMergeWizardExecutor();
297 void ExecuteMailMergeWizard( const SfxItemSet
* pArgs
);
300 SwMailMergeWizardExecutor::SwMailMergeWizardExecutor()
302 m_pView2Close( NULL
),
308 SwMailMergeWizardExecutor::~SwMailMergeWizardExecutor()
310 DBG_ASSERT( m_pWizard
== 0, "SwMailMergeWizardExecutor: m_pWizard must be Null!" );
311 DBG_ASSERT( m_pMMConfig
== 0, "SwMailMergeWizardExecutor: m_pMMConfig must be Null!" );
314 void SwMailMergeWizardExecutor::ExecuteMailMergeWizard( const SfxItemSet
* pArgs
)
318 DBG_ERROR( "SwMailMergeWizardExecutor::ExecuteMailMergeWizard: Already executing the wizard!" );
322 m_pView
= ::GetActiveView(); // not owner!
323 DBG_ASSERT(m_pView
, "no current view?");
326 // keep self alive until done.
329 // if called from the child window - get the config item and close the ChildWindow, then restore
331 SwMailMergeChildWindow
* pChildWin
=
332 static_cast<SwMailMergeChildWindow
*>(m_pView
->GetViewFrame()->GetChildWindow(FN_MAILMERGE_CHILDWINDOW
));
333 bool bRestoreWizard
= false;
334 sal_uInt16 nRestartPage
= 0;
335 if(pChildWin
&& pChildWin
->IsVisible())
337 m_pMMConfig
= m_pView
->GetMailMergeConfigItem();
338 nRestartPage
= m_pView
->GetMailMergeRestartPage();
339 if(m_pView
->IsMailMergeSourceView())
340 m_pMMConfig
->SetSourceView( m_pView
);
341 m_pView
->SetMailMergeConfigItem(0, 0, sal_True
);
342 SfxViewFrame
* pViewFrame
= m_pView
->GetViewFrame();
343 pViewFrame
->ShowChildWindow(FN_MAILMERGE_CHILDWINDOW
, FALSE
);
344 DBG_ASSERT(m_pMMConfig
, "no MailMergeConfigItem available");
345 bRestoreWizard
= true;
347 // to make it bullet proof ;-)
350 m_pMMConfig
= new SwMailMergeConfigItem
;
351 m_pMMConfig
->SetSourceView(m_pView
);
353 //set the first used database as default source on the config item
354 const SfxPoolItem
* pItem
= 0;
355 if(pArgs
&& SFX_ITEM_SET
== pArgs
->GetItemState(
356 FN_PARAM_DATABASE_PROPERTIES
, sal_False
, &pItem
))
358 //mailmerge has been called from the database beamer
359 uno::Sequence
< beans::PropertyValue
> aDBValues
;
360 if(static_cast<const SfxUsrAnyItem
*>(pItem
)->GetValue() >>= aDBValues
)
363 svx::ODataAccessDescriptor
aDescriptor(aDBValues
);
364 aDescriptor
[svx::daDataSource
] >>= aDBData
.sDataSource
;
365 aDescriptor
[svx::daCommand
] >>= aDBData
.sCommand
;
366 aDescriptor
[svx::daCommandType
] >>= aDBData
.nCommandType
;
368 uno::Sequence
< uno::Any
> aSelection
;
369 uno::Reference
< sdbc::XConnection
> xConnection
;
370 uno::Reference
< sdbc::XDataSource
> xSource
;
371 uno::Reference
< sdbcx::XColumnsSupplier
> xColumnsSupplier
;
372 if ( aDescriptor
.has(svx::daSelection
) )
373 aDescriptor
[svx::daSelection
] >>= aSelection
;
374 if ( aDescriptor
.has(svx::daConnection
) )
375 aDescriptor
[svx::daConnection
] >>= xConnection
;
376 uno::Reference
<container::XChild
> xChild(xConnection
, uno::UNO_QUERY
);
378 xSource
= uno::Reference
<sdbc::XDataSource
>(
379 xChild
->getParent(), uno::UNO_QUERY
);
380 m_pMMConfig
->SetCurrentConnection(
381 xSource
, SharedConnection( xConnection
, SharedConnection::NoTakeOwnership
),
382 xColumnsSupplier
, aDBData
);
387 SvStringsDtor
aDBNameList(5, 1);
388 SvStringsDtor
aAllDBNames(5, 5);
389 m_pView
->GetWrtShell().GetAllUsedDB( aDBNameList
, &aAllDBNames
);
390 if(aDBNameList
.Count())
392 String sDBName
= *aDBNameList
[0];
394 aDBData
.sDataSource
= sDBName
.GetToken(0, DB_DELIM
);
395 aDBData
.sCommand
= sDBName
.GetToken(1, DB_DELIM
);
396 aDBData
.nCommandType
= sDBName
.GetToken(2, DB_DELIM
).ToInt32();
397 //set the currently used database for the wizard
398 m_pMMConfig
->SetCurrentDBData( aDBData
);
403 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
404 m_pWizard
= pFact
->CreateMailMergeWizard(*m_pView
, *m_pMMConfig
);
408 m_pWizard
->ShowPage( nRestartPage
);
415 void SwMailMergeWizardExecutor::ExecutionFinished( bool bDeleteConfigItem
)
417 m_pMMConfig
->Commit();
418 if ( bDeleteConfigItem
) // owner?
423 // release/destroy asynchronously
424 Application::PostUserEvent( LINK( this, SwMailMergeWizardExecutor
, DestroyDialogHdl
) );
427 void SwMailMergeWizardExecutor::ExecuteWizard()
429 m_pWizard
->StartExecuteModal(
430 LINK( this, SwMailMergeWizardExecutor
, EndDialogHdl
) );
433 #if OSL_DEBUG_LEVEL > 1
434 IMPL_LINK( SwMailMergeWizardExecutor
, EndDialogHdl
, AbstractMailMergeWizard
*, pDialog
)
436 IMPL_LINK( SwMailMergeWizardExecutor
, EndDialogHdl
, AbstractMailMergeWizard
*, EMPTYARG
)
439 #if OSL_DEBUG_LEVEL > 1
440 DBG_ASSERT( pDialog
== m_pWizard
, "wrong dialog passed to EndDialogHdl!" );
444 long nRet
= m_pWizard
->GetResult();
445 sal_uInt16 nRestartPage
= m_pWizard
->GetRestartPage();
451 SwView
* pNewView
= lcl_LoadDoc(m_pView
, m_pWizard
->GetReloadDocument());
453 // destroy wizard asynchronously
454 Application::PostUserEvent(
455 LINK( this, SwMailMergeWizardExecutor
, DestroyWizardHdl
), m_pWizard
);
457 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
461 m_pMMConfig
->DocumentReloaded();
463 m_pMMConfig
->SetSourceView( m_pView
);
464 m_pWizard
= pFact
->CreateMailMergeWizard(*m_pView
, *m_pMMConfig
);
465 m_pWizard
->ShowPage( nRestartPage
);
469 m_pWizard
= pFact
->CreateMailMergeWizard(*m_pView
, *m_pMMConfig
);
472 // execute the wizard again
476 case RET_TARGET_CREATED
:
478 SwView
* pTargetView
= m_pMMConfig
->GetTargetView();
479 uno::Reference
< frame::XFrame
> xFrame
=
480 m_pView
->GetViewFrame()->GetFrame()->GetFrameInterface();
481 xFrame
->getContainerWindow()->setVisible(sal_False
);
482 DBG_ASSERT(pTargetView
, "No target view has been created");
485 // destroy wizard asynchronously
486 Application::PostUserEvent(
487 LINK( this, SwMailMergeWizardExecutor
, DestroyWizardHdl
), m_pWizard
);
489 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
490 m_pWizard
= pFact
->CreateMailMergeWizard(*pTargetView
, *m_pMMConfig
);
491 m_pWizard
->ShowPage( nRestartPage
);
493 // execute the wizard again
498 //should not happen - just in case no target view has been created
499 ExecutionFinished( true );
504 case RET_EDIT_RESULT_DOC
:
506 //create a non-modal dialog that allows to return to the wizard
507 //the ConfigItem ownership moves to this dialog
508 bool bResult
= nRet
== RET_EDIT_RESULT_DOC
&& m_pMMConfig
->GetTargetView();
509 SwView
* pTempView
= bResult
? m_pMMConfig
->GetTargetView() : m_pMMConfig
->GetSourceView();
510 pTempView
->SetMailMergeConfigItem(m_pMMConfig
, m_pWizard
->GetRestartPage(), !bResult
);
511 SfxViewFrame
* pViewFrame
= pTempView
->GetViewFrame();
512 pViewFrame
->GetDispatcher()->Execute(
513 FN_MAILMERGE_CHILDWINDOW
, SFX_CALLMODE_SYNCHRON
);
514 ExecutionFinished( false );
517 case RET_REMOVE_TARGET
:
519 SwView
* pTargetView
= m_pMMConfig
->GetTargetView();
520 SwView
* pSourceView
= m_pMMConfig
->GetSourceView();
521 DBG_ASSERT(pTargetView
&& pSourceView
, "source or target view not available" );
522 if(pTargetView
&& pSourceView
)
524 m_pView2Close
= pTargetView
;
525 pTargetView
->GetViewFrame()->GetTopViewFrame()->GetWindow().Hide();
526 pSourceView
->GetViewFrame()->GetFrame()->AppearWithUpdate();
527 // the current view has be be set when the target is destroyed
528 m_pView
= pSourceView
;
529 m_pMMConfig
->SetTargetView(0);
531 // destroy wizard asynchronously
532 Application::PostUserEvent(
533 LINK( this, SwMailMergeWizardExecutor
, CloseFrameHdl
), m_pWizard
);
535 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
536 m_pWizard
= pFact
->CreateMailMergeWizard(*pSourceView
, *m_pMMConfig
);
537 m_pWizard
->ShowPage( nRestartPage
);
539 // execute the wizard again
544 //should not happen - just in case no target view has been created
545 ExecutionFinished( true );
551 // close frame and destroy wizard asynchronously
552 Application::PostUserEvent(
553 LINK( this, SwMailMergeWizardExecutor
, CancelHdl
), m_pWizard
);
558 SwView
* pSourceView
= m_pMMConfig
->GetSourceView();
561 SwDocShell
* pDocShell
= pSourceView
->GetDocShell();
562 if(pDocShell
->HasName() && !pDocShell
->IsModified())
563 m_pMMConfig
->GetSourceView()->GetViewFrame()->DoClose();
565 m_pMMConfig
->GetSourceView()->GetViewFrame()->GetFrame()->Appear();
567 ExecutionFinished( true );
576 IMPL_LINK( SwMailMergeWizardExecutor
, DestroyDialogHdl
, AbstractMailMergeWizard
*, EMPTYARG
)
585 IMPL_LINK( SwMailMergeWizardExecutor
, DestroyWizardHdl
, AbstractMailMergeWizard
*, pDialog
)
591 IMPL_LINK( SwMailMergeWizardExecutor
, CancelHdl
, AbstractMailMergeWizard
*, EMPTYARG
)
593 if(m_pMMConfig
->GetTargetView())
595 m_pMMConfig
->GetTargetView()->GetViewFrame()->DoClose();
596 m_pMMConfig
->SetTargetView(0);
598 if(m_pMMConfig
->GetSourceView())
599 m_pMMConfig
->GetSourceView()->GetViewFrame()->GetFrame()->AppearWithUpdate();
601 m_pMMConfig
->Commit();
604 // m_pWizard already deleted by closing the target view
611 IMPL_LINK( SwMailMergeWizardExecutor
, CloseFrameHdl
, AbstractMailMergeWizard
*, EMPTYARG
)
615 m_pView2Close
->GetViewFrame()->DoClose();
616 m_pView2Close
= NULL
;
624 void SwModule::ExecOther(SfxRequest
& rReq
)
626 const SfxItemSet
*pArgs
= rReq
.GetArgs();
627 const SfxPoolItem
* pItem
= 0;
629 sal_uInt16 nWhich
= rReq
.GetSlot();
636 case FN_BUSINESS_CARD
:
638 InsertLab(rReq
, nWhich
== FN_LABEL
);
645 case SID_ATTR_METRIC
:
646 if(pArgs
&& SFX_ITEM_SET
== pArgs
->GetItemState(nWhich
, sal_False
, &pItem
))
648 FieldUnit eUnit
= (FieldUnit
)((const SfxUInt16Item
*)pItem
)->GetValue();
657 SwView
* pActView
= ::GetActiveView();
658 sal_Bool bWebView
= 0 != PTR_CAST(SwWebView
, pActView
);
659 ::SetDfltMetric(eUnit
, bWebView
);
662 default:;//prevent warning
667 case FN_SET_MODOPT_TBLNUMFMT
:
669 sal_Bool bWebView
= 0 != PTR_CAST(SwWebView
, ::GetActiveView() ),
672 if( pArgs
&& SFX_ITEM_SET
== pArgs
->GetItemState(
673 nWhich
, sal_False
, &pItem
))
674 bSet
= ((SfxBoolItem
*)pItem
)->GetValue();
676 bSet
= !pModuleConfig
->IsInsTblFormatNum( bWebView
);
678 pModuleConfig
->SetInsTblFormatNum( bWebView
, bSet
);
681 case FN_MAILMERGE_WIZARD
:
683 rtl::Reference
< SwMailMergeWizardExecutor
> xEx( new SwMailMergeWizardExecutor
);
684 xEx
->ExecuteMailMergeWizard( pArgs
);
690 /*--------------------------------------------------------------------
691 Beschreibung: Notifies abfangen
692 --------------------------------------------------------------------*/
695 // Hint abfangen fuer DocInfo
696 void SwModule::Notify( SfxBroadcaster
& /*rBC*/, const SfxHint
& rHint
)
698 if( rHint
.ISA( SfxEventHint
) )
700 SfxEventHint
& rEvHint
= (SfxEventHint
&) rHint
;
701 SwDocShell
* pDocSh
= PTR_CAST( SwDocShell
, rEvHint
.GetObjShell() );
704 SwWrtShell
* pWrtSh
= pDocSh
? pDocSh
->GetWrtShell() : 0;
705 switch( rEvHint
.GetEventId() )
707 /* MA 07. Mar. 96: UpdateInputFlds() nur noch bei Dokument neu.
708 (Und bei Einfuegen Textbaust.)
709 case SFX_EVENT_OPENDOC:
710 // dann am aktuellen Dokument die Input-Fedler updaten
712 pWrtSh->UpdateInputFlds();
715 case SFX_EVENT_CREATEDOC
:
716 // alle FIX-Date/Time Felder auf akt. setzen
719 SFX_ITEMSET_ARG( pDocSh
->GetMedium()->GetItemSet(), pUpdateDocItem
, SfxUInt16Item
, SID_UPDATEDOCMODE
, sal_False
);
720 sal_Bool bUpdateFields
= sal_True
;
721 if( pUpdateDocItem
&& pUpdateDocItem
->GetValue() == document::UpdateDocMode::NO_UPDATE
)
722 bUpdateFields
= sal_False
;
723 pWrtSh
->SetFixFields();
726 pWrtSh
->UpdateInputFlds();
728 // Sind Datenbankfelder enthalten?
729 // Erstmal alle verwendeten Datenbanken holen
730 SwDoc
*pDoc
= pDocSh
->GetDoc();
731 SvStringsDtor aDBNameList
;
732 pDoc
->GetAllUsedDB( aDBNameList
);
733 sal_uInt16 nCount
= aDBNameList
.Count();
735 { // Datenbankbeamer oeffnen
736 ShowDBObj(pWrtSh
->GetView(), pDoc
->GetDBData());
744 else if(rHint
.ISA(SfxItemSetHint
))
746 if( SFX_ITEM_SET
== ((SfxItemSetHint
&)rHint
).GetItemSet().GetItemState(SID_ATTR_PATHNAME
))
748 ::GetGlossaries()->UpdateGlosPath( sal_False
);
749 SwGlossaryList
* pList
= ::GetGlossaryList();
750 if(pList
->IsActive())
754 else if(rHint
.ISA(SfxSimpleHint
))
756 ULONG nHintId
= ((SfxSimpleHint
&)rHint
).GetId();
757 if(SFX_HINT_COLORS_CHANGED
== nHintId
||
758 SFX_HINT_ACCESSIBILITY_CHANGED
== nHintId
)
760 sal_Bool bAccessibility
= sal_False
;
761 if(SFX_HINT_COLORS_CHANGED
== nHintId
)
762 SwViewOption::ApplyColorConfigValues(*pColorConfig
);
764 bAccessibility
= sal_True
;
766 //invalidate all edit windows
767 const TypeId aSwViewTypeId
= TYPE(SwView
);
768 const TypeId aSwPreViewTypeId
= TYPE(SwPagePreView
);
769 const TypeId aSwSrcViewTypeId
= TYPE(SwSrcView
);
770 SfxViewShell
* pViewShell
= SfxViewShell::GetFirst();
773 if(pViewShell
->GetWindow())
775 if((pViewShell
->IsA(aSwViewTypeId
) ||
776 pViewShell
->IsA(aSwPreViewTypeId
) ||
777 pViewShell
->IsA(aSwSrcViewTypeId
)))
781 if(pViewShell
->IsA(aSwViewTypeId
))
782 ((SwView
*)pViewShell
)->ApplyAccessiblityOptions(*pAccessibilityOptions
);
783 else if(pViewShell
->IsA(aSwPreViewTypeId
))
784 ((SwPagePreView
*)pViewShell
)->ApplyAccessiblityOptions(*pAccessibilityOptions
);
786 pViewShell
->GetWindow()->Invalidate();
789 pViewShell
= SfxViewShell::GetNext( *pViewShell
);
792 else if( SFX_HINT_CTL_SETTINGS_CHANGED
== nHintId
)
794 const SfxObjectShell
* pObjSh
= SfxObjectShell::GetFirst();
797 if( pObjSh
->IsA(TYPE(SwDocShell
)) )
799 const SwDoc
* pDoc
= ((SwDocShell
*)pObjSh
)->GetDoc();
801 pDoc
->GetEditShell( &pVSh
);
803 pVSh
->ChgNumberDigits();
805 pObjSh
= SfxObjectShell::GetNext(*pObjSh
);
808 else if(SFX_HINT_USER_OPTIONS_CHANGED
== nHintId
)
810 bAuthorInitialised
= FALSE
;
812 else if(SFX_HINT_UNDO_OPTIONS_CHANGED
== nHintId
)
814 const int nNew
= GetUndoOptions().GetUndoCount();
815 const int nOld
= SwEditShell::GetUndoActionCount();
818 sal_Bool bUndo
= nNew
!= 0;
819 //ueber DocShells iterieren und Undo umschalten
821 TypeId
aType(TYPE(SwDocShell
));
822 SwDocShell
* pDocShell
= (SwDocShell
*)SfxObjectShell::GetFirst(&aType
);
825 pDocShell
->GetDoc()->DoUndo( bUndo
);
826 pDocShell
= (SwDocShell
*)SfxObjectShell::GetNext(*pDocShell
, &aType
);
829 SwEditShell::SetUndoActionCount( static_cast< USHORT
>(nNew
));
831 else if(SFX_HINT_DEINITIALIZING
== nHintId
)
833 DELETEZ(pWebUsrPref
);
835 DELETEZ(pModuleConfig
);
837 DELETEZ(pWebPrtOpt
) ;
838 DELETEZ(pChapterNumRules
);
839 DELETEZ(pStdFontConfig
) ;
840 DELETEZ(pNavigationConfig
) ;
841 DELETEZ(pToolbarConfig
) ;
842 DELETEZ(pWebToolbarConfig
) ;
843 DELETEZ(pAuthorNames
) ;
845 EndListening(*pColorConfig
);
846 DELETEZ(pColorConfig
);
847 EndListening(*pAccessibilityOptions
);
848 DELETEZ(pAccessibilityOptions
);
849 EndListening(*pCTLOptions
);
850 DELETEZ(pCTLOptions
);
851 EndListening(*pUserOptions
);
852 DELETEZ(pUserOptions
);
853 EndListening(*pUndoOptions
);
854 DELETEZ(pUndoOptions
);
859 /* -----------------------------20.02.01 12:43--------------------------------
861 ---------------------------------------------------------------------------*/
862 SwDBConfig
* SwModule::GetDBConfig()
865 pDBConfig
= new SwDBConfig
;
868 /* -----------------------------11.04.2002 15:27------------------------------
870 ---------------------------------------------------------------------------*/
871 svtools::ColorConfig
& SwModule::GetColorConfig()
875 pColorConfig
= new svtools::ColorConfig
;
876 SwViewOption::ApplyColorConfigValues(*pColorConfig
);
877 StartListening(*pColorConfig
);
879 return *pColorConfig
;
881 /* -----------------------------06.05.2002 09:42------------------------------
883 ---------------------------------------------------------------------------*/
884 SvtAccessibilityOptions
& SwModule::GetAccessibilityOptions()
886 if(!pAccessibilityOptions
)
888 pAccessibilityOptions
= new SvtAccessibilityOptions
;
889 StartListening(*pAccessibilityOptions
);
891 return *pAccessibilityOptions
;
893 /* -----------------06.05.2003 14:52-----------------
895 --------------------------------------------------*/
896 SvtCTLOptions
& SwModule::GetCTLOptions()
900 pCTLOptions
= new SvtCTLOptions
;
901 StartListening(*pCTLOptions
);
905 /* -----------------07.07.2003 09:31-----------------
907 --------------------------------------------------*/
908 SvtUserOptions
& SwModule::GetUserOptions()
912 pUserOptions
= new SvtUserOptions
;
913 StartListening(*pUserOptions
);
915 return *pUserOptions
;
917 /* -----------------18.07.2003 13:31-----------------
919 --------------------------------------------------*/
920 SvtUndoOptions
& SwModule::GetUndoOptions()
924 pUndoOptions
= new SvtUndoOptions
;
925 StartListening(*pUndoOptions
);
927 return *pUndoOptions
;
929 /*-----------------30.01.97 08.30-------------------
931 --------------------------------------------------*/
932 const SwMasterUsrPref
*SwModule::GetUsrPref(sal_Bool bWeb
) const
934 SwModule
* pNonConstModule
= (SwModule
*)this;
935 if(bWeb
&& !pWebUsrPref
)
937 // im Load der SwMasterUsrPref wird der SpellChecker gebraucht, dort darf
938 // er aber nicht angelegt werden #58256#
939 pNonConstModule
->pWebUsrPref
= new SwMasterUsrPref(TRUE
);
941 else if(!bWeb
&& !pUsrPref
)
943 pNonConstModule
->pUsrPref
= new SwMasterUsrPref(FALSE
);
945 return bWeb
? pWebUsrPref
: pUsrPref
;
950 void NewXForms( SfxRequest
& rReq
)
952 // copied & excerpted from SwModule::InsertLab(..)
954 // create new document
955 SfxObjectShellRef
xDocSh( new SwDocShell( SFX_CREATE_MODE_STANDARD
) );
956 xDocSh
->DoInitNew( 0 );
959 static_cast<SwDocShell
*>( &xDocSh
)->GetDoc()->initXForms( true );
961 // put document into frame
962 const SfxItemSet
* pArgs
= rReq
.GetArgs();
963 DBG_ASSERT( pArgs
, "no arguments in SfxRequest");
966 const SfxPoolItem
* pFrameItem
= NULL
;
967 pArgs
->GetItemState( SID_DOCFRAME
, FALSE
, &pFrameItem
);
968 if( pFrameItem
!= NULL
)
971 static_cast<const SfxFrameItem
*>( pFrameItem
)->GetFrame();
972 DBG_ASSERT( pFrame
!= NULL
, "no frame?" );
973 pFrame
->InsertDocument( xDocSh
);
978 rReq
.SetReturnValue( SfxVoidItem( rReq
.GetSlot() ) );