update dev300-m58
[ooovba.git] / sw / source / ui / shells / basesh.cxx
blob168441d47977c7d5ea1541eef1b289937dad822e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: basesh.cxx,v $
10 * $Revision: 1.87 $
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 <sot/factory.hxx>
34 #include <hintids.hxx>
35 #include <svtools/urihelper.hxx>
36 #include <svtools/languageoptions.hxx>
38 #ifndef _SVX_SVXIDS_HRC
39 #include <svx/svxids.hrc>
40 #endif
41 #include <svx/linkmgr.hxx>
42 #include <svx/htmlmode.hxx>
43 #include <svx/imapdlg.hxx>
44 #include <sfx2/dispatch.hxx>
45 #include <sfx2/docfile.hxx>
46 #include <sfx2/viewfrm.hxx>
47 #include <sfx2/request.hxx>
48 #include <svtools/whiter.hxx>
49 #include <svtools/visitem.hxx>
50 #include <sfx2/objitem.hxx>
51 #include <svtools/filter.hxx>
52 #include <svx/gallery.hxx>
53 #include <svx/langitem.hxx>
54 #include <svx/clipfmtitem.hxx>
55 #include <svx/contdlg.hxx>
56 #include <vcl/graph.hxx>
57 #include <svx/impgrf.hxx>
58 #include <svtools/slstitm.hxx>
59 #include <vcl/msgbox.hxx>
60 #include <svtools/ptitem.hxx>
61 #include <svtools/itemiter.hxx>
62 #include <svtools/stritem.hxx>
63 #include <svx/colritem.hxx>
64 #include <svx/shaditem.hxx>
65 #include <svx/boxitem.hxx>
66 #include <svx/srchitem.hxx>
67 #include <svx/ulspitem.hxx>
68 #include <svx/lrspitem.hxx>
69 #include <svx/brshitem.hxx>
70 #include <svx/opaqitem.hxx>
71 #include <svx/sizeitem.hxx>
72 #include <svx/flagsdef.hxx>
73 #include <svx/scripttypeitem.hxx>
74 #include <sfx2/objface.hxx>
75 #include <fmturl.hxx>
76 #include <fmthdft.hxx>
77 #include <fmtclds.hxx>
78 #include <docsh.hxx>
79 #include <wrtsh.hxx>
80 #include <view.hxx>
81 #include <swmodule.hxx>
82 #include <swundo.hxx>
83 #include <fldbas.hxx>
84 #include <uitool.hxx>
85 #include <basesh.hxx>
86 #include <viewopt.hxx>
87 #include <fontcfg.hxx>
88 #include <docstat.hxx>
89 #include <usrfld.hxx>
90 #include <expfld.hxx>
91 #include <fldmgr.hxx>
92 #include <frmmgr.hxx>
93 #include <tablemgr.hxx>
94 #include <mdiexp.hxx>
95 #include <swdtflvr.hxx>
96 #include <pagedesc.hxx>
97 #include <convert.hxx>
98 #include <fmtcol.hxx>
99 #include <edtwin.hxx>
100 #include <tblafmt.hxx>
101 #include <caption.hxx>
102 #include <swwait.hxx>
103 #ifndef _CMDID_H
104 #include <cmdid.h>
105 #endif
106 #ifndef _GLOBALS_HRC
107 #include <globals.hrc>
108 #endif
109 #ifndef _SHELLS_HRC
110 #include <shells.hrc>
111 #endif
112 #ifndef _STATSTR_HRC
113 #include <statstr.hrc>
114 #endif
115 #include <globals.h>
116 #include <unotxdoc.hxx>
117 #include <crsskip.hxx>
118 #include <fmtinfmt.hxx>
119 #include <doc.hxx>
121 #include "swabstdlg.hxx"
122 #include "dialog.hrc"
123 #include "fldui.hrc"
124 #include "table.hrc"
125 #include <modcfg.hxx>
126 #include <instable.hxx>
127 #include <svx/fmshell.hxx> // for FN_XFORMS_DESIGN_MODE
128 #include <SwRewriter.hxx>
129 #include <undobj.hxx>
130 #ifndef _COMCORE_HRC
131 #include <comcore.hrc>
132 #endif
134 #include <unomid.h>
136 FlyMode SwBaseShell::eFrameMode = FLY_DRAG_END;
139 //Fuer die Erkennung der Id, die variable von Gallery mit SID_GALLERY_BG_BRUSH
140 //ankommt.
141 static BYTE nParagraphPos;
142 static BYTE nGraphicPos;
143 static BYTE nOlePos;
144 static BYTE nFramePos;
145 static BYTE nTablePos;
146 static BYTE nTableRowPos;
147 static BYTE nTableCellPos;
148 static BYTE nPagePos;
149 static BYTE nHeaderPos;
150 static BYTE nFooterPos;
152 #define Interior
153 #include <svx/svxslots.hxx>
155 #define SwBaseShell
156 #define Shadow
157 #include <sfx2/msg.hxx>
158 #include "swslots.hxx"
160 #define SWCONTOURDLG(rView) ( (SvxContourDlg*) ( rView.GetViewFrame()->GetChildWindow( \
161 SvxContourDlgChildWindow::GetChildWindowId() )-> \
162 GetWindow() ) )
164 #define SWIMAPDLG(rView) ( (SvxIMapDlg*) ( rView.GetViewFrame()->GetChildWindow( \
165 SvxIMapDlgChildWindow::GetChildWindowId() )-> \
166 GetWindow() ) )
169 using namespace ::com::sun::star;
170 using namespace ::com::sun::star::uno;
171 using namespace ::com::sun::star::frame;
172 using namespace ::com::sun::star::lang;
175 SFX_IMPL_INTERFACE(SwBaseShell, SfxShell, SW_RES(0))
177 SFX_CHILDWINDOW_REGISTRATION(SvxIMapDlgChildWindow::GetChildWindowId());
178 SFX_CHILDWINDOW_REGISTRATION(SvxContourDlgChildWindow::GetChildWindowId());
181 TYPEINIT1(SwBaseShell,SfxShell)
183 /*--------------------------------------------------------------------
184 Beschreibung: statics
185 --------------------------------------------------------------------*/
188 void lcl_UpdateIMapDlg( SwWrtShell& rSh )
190 Graphic aGrf( rSh.GetIMapGraphic() );
191 GraphicType nGrfType = aGrf.GetType();
192 void* pEditObj = GRAPHIC_NONE != nGrfType && GRAPHIC_DEFAULT != nGrfType
193 ? rSh.GetIMapInventor() : 0;
194 TargetList* pList = new TargetList;
195 rSh.GetView().GetViewFrame()->GetTopFrame()->GetTargetList(*pList);
197 SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL );
198 rSh.GetFlyFrmAttr( aSet );
199 const SwFmtURL &rURL = (SwFmtURL&)aSet.Get( RES_URL );
200 SvxIMapDlgChildWindow::UpdateIMapDlg(
201 aGrf, rURL.GetMap(), pList, pEditObj );
203 USHORT nCount = (USHORT)pList->Count();
204 if(nCount)
205 for( USHORT i = nCount; i; i-- )
207 delete pList->GetObject(i-1);
209 delete pList;
213 BOOL lcl_UpdateContourDlg( SwWrtShell &rSh, int nSel )
215 Graphic aGraf( rSh.GetIMapGraphic() );
216 GraphicType nGrfType = aGraf.GetType();
217 BOOL bRet = GRAPHIC_NONE != nGrfType && GRAPHIC_DEFAULT != nGrfType;
218 if( bRet )
220 String aGrfName;
221 if ( nSel & nsSelectionType::SEL_GRF )
222 rSh.GetGrfNms( &aGrfName, 0 );
224 SvxContourDlg *pDlg = SWCONTOURDLG(rSh.GetView());
225 pDlg->Update( aGraf, aGrfName.Len() > 0,
226 rSh.GetGraphicPolygon(), rSh.GetIMapInventor() );
228 return bRet;
231 /*--------------------------------------------------------------------
232 Beschreibung: loeschen
233 --------------------------------------------------------------------*/
235 void SwBaseShell::ExecDelete(SfxRequest &rReq)
237 SwWrtShell &rSh = GetShell();
238 SwEditWin& rTmpEditWin = GetView().GetEditWin();
239 switch(rReq.GetSlot())
241 case SID_DELETE:
242 rSh.DelRight();
243 break;
245 case FN_BACKSPACE:
247 if( rSh.IsNoNum() )
249 rSh.SttCrsrMove();
250 BOOL bLeft = rSh.Left( CRSR_SKIP_CHARS, TRUE, 1, FALSE );
251 if( bLeft )
253 // JP 28.03.96: ein Backspace im Absatz ohne Nummer wird zum Delete
254 //rSh.SwapPam();
255 //rSh.DelRight( FALSE );
257 rSh.DelLeft();
259 else
260 // JP 15.07.96: wenns nicht mehr nach vorne geht, die
261 // Numerierung aufheben. Z.B. am Doc-/
262 // Rahmen-/Tabellen-/Bereichs-Anfang
263 rSh.DelNumRules();
265 rSh.EndCrsrMove();
266 break;
269 // ansonsten DelLeft rufen
270 case FN_SHIFT_BACKSPACE:
271 rSh.DelLeft();
272 break;
273 default:
274 DBG_ERROR("falscher Dispatcher");
275 return;
277 rReq.Done();
279 //#i42732# - notify the edit window that from now on we do not use the input language
280 rTmpEditWin.SetUseInputLanguage( sal_False );
283 /*--------------------------------------------------------------------
284 Beschreibung:
285 --------------------------------------------------------------------*/
287 void SwBaseShell::ExecClpbrd(SfxRequest &rReq)
289 //Achtung: Suizid gefaehrdet! Nach Paste, Paste special kann der die
290 //Shell zerstoert sein.
293 SwWrtShell &rSh = GetShell();
294 USHORT nId = rReq.GetSlot();
295 sal_Bool bIgnore = sal_False;
296 switch( nId )
298 case SID_CUT:
299 case SID_COPY:
300 rView.GetEditWin().FlushInBuffer();
301 if ( rSh.HasSelection() )
303 SwTransferable* pTransfer = new SwTransferable( rSh );
304 /*??*/ uno::Reference<
305 datatransfer::XTransferable > xRef(
306 pTransfer );
308 if ( nId == SID_CUT )
309 pTransfer->Cut();
310 else
312 const BOOL bLockedView = rSh.IsViewLocked();
313 rSh.LockView( TRUE ); //lock visible section
314 pTransfer->Copy();
315 rSh.LockView( bLockedView );
317 break;
319 return;
321 case SID_PASTE:
323 TransferableDataHelper aDataHelper(
324 TransferableDataHelper::CreateFromSystemClipboard(
325 &rSh.GetView().GetEditWin() ) );
327 if( aDataHelper.GetXTransferable().is() &&
328 SwTransferable::IsPaste( rSh, aDataHelper ))
330 // temp. Variablen, da die Shell nach dem Paste schon
331 // zerstoert sein kann
332 SwView* pView = &rView;
333 SwTransferable::Paste( rSh, aDataHelper );
334 if( rSh.IsFrmSelected() || rSh.IsObjSelected() )
335 rSh.EnterSelFrmMode();
336 pView->AttrChangedNotify( &rSh );
338 else
339 return;
341 break;
343 case SID_CLIPBOARD_FORMAT_ITEMS:
345 const SfxItemSet* pArgs = rReq.GetArgs();
346 const SfxPoolItem* pFmt;
347 if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( nId, FALSE, &pFmt ) )
349 TransferableDataHelper aDataHelper(
350 TransferableDataHelper::CreateFromSystemClipboard(
351 &rSh.GetView().GetEditWin()) );
352 if( aDataHelper.GetXTransferable().is()
353 /*&& SwTransferable::IsPaste( rSh, aDataHelper )*/ )
355 // temp. Variablen, da die Shell nach dem Paste schon
356 // zerstoert sein kann
357 SwView* pView = &rView;
359 SwTransferable::PasteFormat( rSh, aDataHelper,
360 ((SfxUInt32Item*)pFmt)->GetValue() );
362 //Done() has to be called before the shell has been removed
363 rReq.Done();
364 bIgnore = sal_True;
365 if( rSh.IsFrmSelected() || rSh.IsObjSelected())
366 rSh.EnterSelFrmMode();
367 pView->AttrChangedNotify( &rSh );
371 break;
373 case SID_PASTE_UNFORMATTED:
375 TransferableDataHelper aDataHelper(
376 TransferableDataHelper::CreateFromSystemClipboard(
377 &rSh.GetView().GetEditWin()) );
378 if( aDataHelper.GetXTransferable().is() &&
379 SwTransferable::IsPaste( rSh, aDataHelper ))
381 // temp. Variablen, da die Shell nach dem Paste schon
382 // zerstoert sein kann
383 SwView* pView = &rView;
384 rReq.Ignore();
385 bIgnore = sal_True;
386 int nRet = SwTransferable::PasteUnformatted( rSh, aDataHelper );
387 if(nRet)// && rReq.IsRecording() )
389 SfxViewFrame* pViewFrame = pView->GetViewFrame();
390 uno::Reference< frame::XDispatchRecorder > xRecorder =
391 pViewFrame->GetBindings().GetRecorder();
392 if(xRecorder.is()) {
393 SfxRequest aReq( pViewFrame, SID_CLIPBOARD_FORMAT_ITEMS );
394 aReq.AppendItem( SfxUInt32Item( SID_CLIPBOARD_FORMAT_ITEMS, SOT_FORMAT_STRING ) );
395 aReq.Done();
399 if (rSh.IsFrmSelected() || rSh.IsObjSelected())
400 rSh.EnterSelFrmMode();
401 pView->AttrChangedNotify( &rSh );
403 else
404 return;
406 break;
408 case FN_PASTESPECIAL:
410 TransferableDataHelper aDataHelper(
411 TransferableDataHelper::CreateFromSystemClipboard(
412 &rSh.GetView().GetEditWin()) );
413 if( aDataHelper.GetXTransferable().is() &&
414 SwTransferable::IsPaste( rSh, aDataHelper ))
416 // temp. Variablen, da die Shell nach dem Paste schon
417 // zerstoert sein kann
418 SwView* pView = &rView;
419 ULONG nFormatId = 0;
420 rReq.Ignore();
421 bIgnore = sal_True;
422 int nRet = SwTransferable::PasteSpecial( rSh, aDataHelper, nFormatId );
423 if(nRet)// && rReq.IsRecording() )
425 SfxViewFrame* pViewFrame = pView->GetViewFrame();
426 uno::Reference< frame::XDispatchRecorder > xRecorder =
427 pViewFrame->GetBindings().GetRecorder();
428 if(xRecorder.is()) {
429 SfxRequest aReq( pViewFrame, SID_CLIPBOARD_FORMAT_ITEMS );
430 aReq.AppendItem( SfxUInt32Item( SID_CLIPBOARD_FORMAT_ITEMS, nFormatId ) );
431 aReq.Done();
435 if (rSh.IsFrmSelected() || rSh.IsObjSelected())
436 rSh.EnterSelFrmMode();
437 pView->AttrChangedNotify( &rSh );
439 else
440 return;
442 break;
443 default:
444 DBG_ERROR("falscher Dispatcher");
445 return;
447 if(!bIgnore)
448 rReq.Done();
451 /*--------------------------------------------------------------------
452 Beschreibung: ClipBoard-Status
453 --------------------------------------------------------------------*/
455 void SwBaseShell::StateClpbrd(SfxItemSet &rSet)
457 SwWrtShell &rSh = GetShell();
458 SfxWhichIter aIter(rSet);
460 const BOOL bCopy = rSh.HasSelection();
462 USHORT nWhich = aIter.FirstWhich();
464 while(nWhich)
466 switch(nWhich)
468 case SID_CUT:
469 if( 0 != rSh.IsSelObjProtected(FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) )
471 rSet.DisableItem( nWhich );
472 break;
474 case SID_COPY:
475 if( !bCopy )
476 rSet.DisableItem( nWhich );
477 break;
479 case SID_PASTE:
480 if( !GetView().IsPasteAllowed() )
481 rSet.DisableItem( SID_PASTE );
482 break;
484 case FN_PASTESPECIAL:
485 if( !GetView().IsPasteSpecialAllowed() )
487 rSet.DisableItem( FN_PASTESPECIAL );
488 rSet.DisableItem( SID_PASTE_UNFORMATTED );
490 break;
492 case SID_CLIPBOARD_FORMAT_ITEMS:
494 TransferableDataHelper aDataHelper(
495 TransferableDataHelper::CreateFromSystemClipboard(
496 &rSh.GetView().GetEditWin()) );
498 SvxClipboardFmtItem aFmtItem( nWhich );
499 SwTransferable::FillClipFmtItem( rSh, aDataHelper, aFmtItem );
500 rSet.Put( aFmtItem );
502 break;
504 nWhich = aIter.NextWhich();
508 /*--------------------------------------------------------------------
509 Beschreibung: Undo ausfuehren
510 --------------------------------------------------------------------*/
512 void SwBaseShell::ExecUndo(SfxRequest &rReq)
514 SwWrtShell &rSh = GetShell();
516 USHORT nId = rReq.GetSlot(), nCnt = 1;
517 const SfxItemSet* pArgs = rReq.GetArgs();
518 const SfxPoolItem* pItem;
519 if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( nId, FALSE, &pItem ))
520 nCnt = ((SfxUInt16Item*)pItem)->GetValue();
522 switch( nId )
524 case SID_UNDO:
525 rSh.LockPaint();
526 rSh.Do( SwWrtShell::UNDO, nCnt );
527 rSh.UnlockPaint();
528 break;
530 case SID_REDO:
531 rSh.LockPaint();
532 rSh.Do( SwWrtShell::REDO, nCnt );
533 rSh.UnlockPaint();
534 break;
536 case SID_REPEAT:
537 rSh.Do( SwWrtShell::REPEAT );
538 break;
539 default:
540 DBG_ERROR("falscher Dispatcher");
544 /*--------------------------------------------------------------------
545 Beschreibung: Zustand Undo
546 --------------------------------------------------------------------*/
548 void SwBaseShell::StateUndo(SfxItemSet &rSet)
550 SwWrtShell &rSh = GetShell();
551 SfxWhichIter aIter(rSet);
552 USHORT nWhich = aIter.FirstWhich();
553 while(nWhich)
555 switch(nWhich)
557 case SID_UNDO:
559 if( rSh.GetUndoIds() )
560 rSet.Put( SfxStringItem(nWhich,
561 rSh.GetDoString(SwWrtShell::UNDO)));
562 else
563 rSet.DisableItem(nWhich);
564 break;
566 case SID_REDO:
568 if(rSh.GetRedoIds())
569 rSet.Put(SfxStringItem(nWhich,
570 rSh.GetDoString(SwWrtShell::REDO)));
571 else
572 rSet.DisableItem(nWhich);
573 break;
575 case SID_REPEAT:
576 { // Repeat nur moeglich wenn kein REDO moeglich - UI-Restriktion
577 if(rSh.GetRedoIds() == UNDO_EMPTY &&
578 !rSh.IsSelFrmMode() &&
579 rSh.GetRepeatIds() )
580 rSet.Put(SfxStringItem(nWhich, rSh.GetRepeatString()));
581 else
582 rSet.DisableItem(nWhich);
583 break;
586 case SID_GETUNDOSTRINGS:
587 if( rSh.GetUndoIds() )
589 SfxStringListItem aStrLst( nWhich );
590 rSh.GetDoStrings( SwWrtShell::UNDO, aStrLst );
591 rSet.Put( aStrLst );
593 else
594 rSet.DisableItem( nWhich );
595 break;
597 case SID_GETREDOSTRINGS:
598 if( rSh.GetRedoIds() )
600 SfxStringListItem aStrLst( nWhich );
601 rSh.GetDoStrings( SwWrtShell::REDO, aStrLst );
602 rSet.Put( aStrLst );
604 else
605 rSet.DisableItem( nWhich );
606 break;
608 nWhich = aIter.NextWhich();
612 /*--------------------------------------------------------------------
613 Beschreibung: Slot-Id auswerten bzw. Dispatchen
614 --------------------------------------------------------------------*/
616 void SwBaseShell::Execute(SfxRequest &rReq)
618 const SfxPoolItem *pItem;
619 SwWrtShell &rSh = GetShell();
620 const SfxItemSet* pArgs = rReq.GetArgs();
621 BOOL bMore = FALSE;
623 USHORT nSlot = rReq.GetSlot();
624 switch(nSlot)
626 case FN_REPAGINATE:
628 Reference < XModel > xModel = GetView().GetDocShell()->GetModel();
629 Reference < XUnoTunnel > xDocTunnel ( xModel, UNO_QUERY );
630 SwXTextDocument *pDoc = reinterpret_cast < SwXTextDocument * > ( xDocTunnel->getSomething ( SwXTextDocument::getUnoTunnelId() ) );
631 pDoc->notifyRefreshListeners();
632 rSh.CalcLayout();
634 break;
635 case FN_UPDATE_FIELDS:
637 SwDocStat aDocStat;
638 rSh.UpdateDocStat(aDocStat);
639 rSh.EndAllTblBoxEdit();
640 rSh.ViewShell::UpdateFlds(TRUE);
642 if( rSh.IsCrsrInTbl() )
644 if( !rSh.IsTblComplexForChart() )
645 SwTableFUNC( &rSh, FALSE).UpdateChart();
646 rSh.ClearTblBoxCntnt();
647 rSh.SaveTblBoxCntnt();
650 break;
651 case FN_UPDATE_CHARTS:
653 SwWait aWait( *rView.GetDocShell(), TRUE );
654 rSh.UpdateAllCharts();
656 break;
658 case FN_UPDATE_ALL:
660 SwView& rTempView = GetView();
661 rSh.EnterStdMode();
662 if( rSh.GetLinkManager().GetLinks().Count() )
664 rSh.StartAllAction();
665 rSh.GetLinkManager().UpdateAllLinks( FALSE, TRUE, TRUE );
666 rSh.EndAllAction();
668 SfxDispatcher &rDis = *rTempView.GetViewFrame()->GetDispatcher();
669 rDis.Execute( FN_UPDATE_FIELDS );
670 rDis.Execute( FN_UPDATE_TOX );
671 rDis.Execute( FN_UPDATE_CHARTS );
672 rSh.CalcLayout();
674 break;
676 case FN_UPDATE_INPUTFIELDS:
677 rSh.UpdateInputFlds(NULL, FALSE);
678 break;
679 case FN_PREV_BOOKMARK:
680 rReq.SetReturnValue(SfxBoolItem( nSlot, rSh.GoPrevBookmark()));
681 break;
682 case FN_NEXT_BOOKMARK:
683 rReq.SetReturnValue(SfxBoolItem( nSlot, rSh.GoNextBookmark()));
684 break;
686 case FN_GOTO_NEXT_MARK:
687 case FN_GOTO_PREV_MARK:
689 SwFldMgr aFldMgr;
690 SwFieldType* pFldType = aFldMgr.GetFldType(RES_JUMPEDITFLD);
692 if (pFldType)
694 if (rSh.IsSelFrmMode())
696 rSh.UnSelectFrm();
697 rSh.LeaveSelFrmMode();
700 if (rSh.HasMark())
702 MV_KONTEXT(&rSh);
703 if (rSh.IsCrsrPtAtEnd())
704 rSh.SwapPam();
705 rSh.ClearMark();
706 rSh.EndSelect();
708 BOOL bRet = rSh.MoveFldType(pFldType, nSlot == FN_GOTO_NEXT_MARK);
709 if (bRet)
710 rSh.ClickToField(*rSh.GetCurFld());
711 rReq.SetReturnValue(SfxBoolItem( nSlot, bRet));
714 break;
716 case FN_START_DOC_DIRECT:
717 case FN_END_DOC_DIRECT:
719 if (rSh.IsSelFrmMode())
721 rSh.UnSelectFrm();
722 rSh.LeaveSelFrmMode();
724 rSh.EnterStdMode();
725 nSlot == FN_START_DOC_DIRECT ?
726 rSh.SttEndDoc(TRUE) :
727 rSh.SttEndDoc(FALSE);
729 break;
730 case FN_GOTO_PREV_OBJ:
731 case FN_GOTO_NEXT_OBJ:
733 BOOL bSuccess = rSh.GotoObj(
734 nSlot == FN_GOTO_NEXT_OBJ ? TRUE : FALSE);
735 rReq.SetReturnValue(SfxBoolItem(nSlot, bSuccess));
736 if (bSuccess && !rSh.IsSelFrmMode())
738 rSh.HideCrsr();
739 rSh.EnterSelFrmMode();
740 GetView().AttrChangedNotify( &rSh );
743 break;
744 case SID_GALLERY_FORMATS:
746 const int nSelType = rSh.GetSelectionType();
747 if(SFX_ITEM_SET == pArgs->GetItemState( nSlot, TRUE, &pItem))
749 GalleryExplorer* pGal = 0;
750 if ( (!rSh.IsSelFrmMode() || nSelType & nsSelectionType::SEL_GRF) &&
751 0!= (pGal = SVX_GALLERY())&&
752 0 != (SGA_FORMAT_GRAPHIC & ((SfxUInt32Item*)pItem)->GetValue()))
754 SwWait aWait( *rView.GetDocShell(), TRUE );
756 String aGrfName, aFltName;
757 const Graphic aGrf( pGal->GetGraphic() );
759 if( pGal->IsLinkage() )
761 // Verknuepft
762 aGrfName = pGal->GetURL().GetMainURL(INetURLObject::NO_DECODE);
763 aFltName = pGal->GetFilterName();
766 if ( nSelType & nsSelectionType::SEL_GRF )
767 rSh.ReRead( aGrfName, aFltName, &aGrf );
768 else
769 rSh.Insert( aGrfName, aFltName, aGrf );
771 GetView().GetEditWin().GrabFocus();
773 else if(!rSh.IsSelFrmMode() && SGA_FORMAT_SOUND & ((SfxUInt32Item*)pItem)->GetValue())
775 const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, pGal->GetURL().GetMainURL( INetURLObject::NO_DECODE ) );
776 GetView().GetViewFrame()->GetDispatcher()->Execute( SID_INSERT_AVMEDIA, SFX_CALLMODE_SYNCHRON, &aMediaURLItem, 0L );
778 String sURL( pGal->GetURL().GetMainURL( INetURLObject::NO_DECODE ) );
779 String sLabel( pGal->GetURL().getBase() );
780 String sTarget; // empty string!
782 bool bIsHTMLMode =
783 0 == ( HTMLMODE_ON &
784 ::GetHtmlMode( GetView().GetDocShell() ) );
786 // in Writer, we insert a button which plays the
787 // sound. In Writer/Web, we just insert a (text) link.
788 if( bIsHTMLMode )
789 InsertURLButton( sURL, sTarget, sLabel );
790 else
791 rSh.InsertURL( SwFmtINetFmt( sURL, sTarget ), sLabel );
796 break;
797 case FN_PAGE_STYLE_SET_COLS:
799 if (pArgs)
801 // aktuellen PageDescriptor ermitteln und damit den Set fuellen
802 const USHORT nCurIdx = rSh.GetCurPageDesc();
803 SwPageDesc aPageDesc(rSh.GetPageDesc(nCurIdx));
805 SwFrmFmt &rFmt = aPageDesc.GetMaster();
807 SwFmtCol aFmtCol = rFmt.GetCol();
809 USHORT nCount;
810 if(SFX_ITEM_SET == pArgs->GetItemState(nSlot))
811 nCount = ((SfxUInt16Item &)pArgs->Get(nSlot)).GetValue();
812 else
813 nCount = ((SfxUInt16Item &)pArgs->Get(SID_ATTR_COLUMNS)).GetValue();
814 USHORT nGutterWidth = DEF_GUTTER_WIDTH;
816 aFmtCol.Init(nCount ? nCount : 1, nGutterWidth, USHRT_MAX);
817 aFmtCol.SetWishWidth(USHRT_MAX);
818 aFmtCol.SetGutterWidth(nGutterWidth, USHRT_MAX);
820 rFmt.SetFmtAttr(aFmtCol);
822 rSh.ChgPageDesc(nCurIdx, aPageDesc);
824 else
825 GetView().GetViewFrame()->GetDispatcher()->Execute(FN_FORMAT_PAGE_COLUMN_DLG, FALSE);
827 break;
828 case FN_CONVERT_TABLE_TO_TEXT:
829 case FN_CONVERT_TEXT_TO_TABLE:
830 case FN_CONVERT_TEXT_TABLE:
832 sal_Unicode cDelim = 0;
833 bool bToTable = false;
834 if( nSlot == FN_CONVERT_TEXT_TO_TABLE ||
835 ( nSlot == FN_CONVERT_TEXT_TABLE && 0 == rSh.GetTableFmt() ))
836 bToTable = true;
837 SwInsertTableOptions aInsTblOpts( tabopts::ALL_TBL_INS_ATTR, 1 );
838 SwTableAutoFmt* pTAFmt = 0;
839 SwTableAutoFmtTbl* pAutoFmtTbl = 0;
840 bool bDeleteFormat = true;
841 if(pArgs && SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_1, TRUE, &pItem))
843 aInsTblOpts.mnInsMode = 0;
844 //Delimiter
845 String sDelim = static_cast< const SfxStringItem* >(pItem)->GetValue();
846 if(sDelim.Len())
847 cDelim = sDelim.GetChar(0);
848 //AutoFormat
849 if(SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_2, TRUE, &pItem))
851 String sAutoFmt = static_cast< const SfxStringItem* >(pItem)->GetValue();
853 pAutoFmtTbl = new SwTableAutoFmtTbl;
854 pAutoFmtTbl->Load();
856 for( USHORT i = 0, nCount = pAutoFmtTbl->Count(); i < nCount; i++ )
858 SwTableAutoFmt* pFmt = (*pAutoFmtTbl)[ i ];
859 if( pFmt->GetName() == sAutoFmt )
861 pTAFmt = pFmt;
862 bDeleteFormat = false;
863 break;
867 //WithHeader
868 if(SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_3, TRUE, &pItem) &&
869 static_cast< const SfxBoolItem* >(pItem)->GetValue())
870 aInsTblOpts.mnInsMode |= tabopts::HEADLINE;
871 // RepeatHeaderLines
872 if(SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_4, TRUE, &pItem))
873 aInsTblOpts.mnRowsToRepeat =
874 (USHORT)static_cast< const SfxInt16Item* >(pItem)->GetValue();
875 //WithBorder
876 if(SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_5, TRUE, &pItem) &&
877 static_cast< const SfxBoolItem* >(pItem)->GetValue())
878 aInsTblOpts.mnInsMode |= tabopts::DEFAULT_BORDER;
879 //DontSplitTable
880 if(SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_6, TRUE, &pItem) &&
881 !static_cast< const SfxBoolItem* >(pItem)->GetValue() )
882 aInsTblOpts.mnInsMode |= tabopts::SPLIT_LAYOUT;
884 else
886 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
887 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
889 AbstractSwConvertTableDlg* pDlg = pFact->CreateSwConvertTableDlg(
890 GetView(),DLG_CONV_TEXT_TABLE , bToTable);
891 DBG_ASSERT(pDlg, "Dialogdiet fail!");
892 if( RET_OK == pDlg->Execute() )
894 pDlg->GetValues( cDelim, aInsTblOpts, pTAFmt );
897 delete pDlg;
900 if( cDelim )
902 //Shellwechsel!
903 SwView& rSaveView = rView;
904 BOOL bInserted = FALSE;
905 //recording:
907 SfxViewFrame* pViewFrame = GetView().GetViewFrame();
908 if( SfxRequest::HasMacroRecorder(pViewFrame) )
910 SfxRequest aReq( pViewFrame, nSlot);
911 aReq.AppendItem( SfxStringItem( FN_PARAM_1, String(cDelim) ));
912 if(bToTable)
914 if(pTAFmt)
915 aReq.AppendItem( SfxStringItem( FN_PARAM_2, pTAFmt->GetName()));
916 aReq.AppendItem( SfxBoolItem ( FN_PARAM_3, 0 != (aInsTblOpts.mnInsMode & tabopts::HEADLINE)));
917 aReq.AppendItem( SfxInt16Item( FN_PARAM_4, (short)aInsTblOpts.mnRowsToRepeat ));
918 aReq.AppendItem( SfxBoolItem ( FN_PARAM_5, 0 != (aInsTblOpts.mnInsMode & tabopts::DEFAULT_BORDER) ));
919 aReq.AppendItem( SfxBoolItem ( FN_PARAM_6, !(aInsTblOpts.mnInsMode & tabopts::SPLIT_LAYOUT)));
921 aReq.Done();
924 if( !bToTable )
925 rSh.TableToText( cDelim );
926 else
928 bInserted = rSh.TextToTable( aInsTblOpts, cDelim, text::HoriOrientation::FULL, pTAFmt );
930 rSh.EnterStdMode();
932 if( bInserted )
933 rSaveView.AutoCaption( TABLE_CAP );
935 if(bDeleteFormat)
936 delete pTAFmt;
937 delete pAutoFmtTbl;
939 break;
940 case SID_STYLE_WATERCAN:
941 case SID_STYLE_UPDATE_BY_EXAMPLE:
942 case SID_STYLE_NEW_BY_EXAMPLE:
943 case SID_STYLE_APPLY:
945 ShellModes eMode = GetView().GetShellMode();
946 if ( SHELL_MODE_DRAW != eMode &&
947 SHELL_MODE_DRAW_CTRL != eMode &&
948 SHELL_MODE_DRAW_FORM != eMode &&
949 SHELL_MODE_DRAWTEXT != eMode &&
950 SHELL_MODE_BEZIER != eMode )
952 // oj #107754#
953 if ( SID_STYLE_WATERCAN == nSlot )
955 const BOOL bLockedView = rSh.IsViewLocked();
956 rSh.LockView( TRUE ); //lock visible section
958 GetView().GetDocShell()->ExecStyleSheet(rReq);
960 rSh.LockView( bLockedView );
962 else
963 // wird von der DocShell aufgezeichnet
964 GetView().GetDocShell()->ExecStyleSheet(rReq);
967 break;
968 case FN_ESCAPE:
969 GetView().ExecuteSlot(rReq);
970 break;
971 case SID_IMAP:
973 USHORT nId = SvxIMapDlgChildWindow::GetChildWindowId();
975 SfxViewFrame* pVFrame = GetView().GetViewFrame();
976 pVFrame->ToggleChildWindow( nId );
977 pVFrame->GetBindings().Invalidate( SID_IMAP );
979 if ( pVFrame->HasChildWindow( nId ) && rSh.IsFrmSelected() )
980 lcl_UpdateIMapDlg( rSh );
982 break;
983 case SID_IMAP_EXEC:
985 SvxIMapDlg* pDlg = SWIMAPDLG(GetView());
987 // Kontrolle, ob Zuweisung ueberhaupt sinnvoll/erlaubt
988 if ( rSh.IsFrmSelected() &&
989 pDlg->GetEditingObject() == rSh.GetIMapInventor() )
991 SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL );
992 rSh.GetFlyFrmAttr( aSet );
993 SwFmtURL aURL( (SwFmtURL&)aSet.Get( RES_URL ) );
994 aURL.SetMap( &pDlg->GetImageMap() );
995 aSet.Put( aURL );
996 rSh.SetFlyFrmAttr( aSet );
999 break;
1000 case SID_CONTOUR_DLG:
1002 USHORT nId = SvxContourDlgChildWindow::GetChildWindowId();
1004 SfxViewFrame* pVFrame = GetView().GetViewFrame();
1005 pVFrame->ToggleChildWindow( nId );
1006 pVFrame->GetBindings().Invalidate( SID_CONTOUR_DLG );
1008 int nSel = rSh.GetSelectionType();
1009 if ( pVFrame->HasChildWindow( nId ) &&
1010 (nSel & (nsSelectionType::SEL_GRF|nsSelectionType::SEL_OLE)) )
1012 lcl_UpdateContourDlg( rSh, nSel );
1015 break;
1016 case SID_CONTOUR_EXEC:
1018 SvxContourDlg *pDlg = SWCONTOURDLG(GetView());
1020 // Kontrolle, ob Zuweisung ueberhaupt sinnvoll/erlaubt
1021 int nSel = rSh.GetSelectionType();
1022 if ( nSel & (nsSelectionType::SEL_GRF|nsSelectionType::SEL_OLE) )
1024 if ( pDlg->GetEditingObject() == rSh.GetIMapInventor() )
1026 rSh.StartAction();
1027 SfxItemSet aSet( rSh.GetAttrPool(), RES_SURROUND, RES_SURROUND);
1028 rSh.GetFlyFrmAttr( aSet );
1029 SwFmtSurround aSur( (SwFmtSurround&)aSet.Get( RES_SURROUND ) );
1030 if ( !aSur.IsContour() )
1032 aSur.SetContour( TRUE );
1033 if ( aSur.GetSurround() == SURROUND_NONE )
1034 aSur.SetSurround( SURROUND_PARALLEL );
1035 aSet.Put( aSur );
1036 rSh.SetFlyFrmAttr( aSet );
1038 const PolyPolygon aPoly( pDlg->GetPolyPolygon() );
1039 rSh.SetGraphicPolygon( &aPoly );
1040 if ( pDlg->IsGraphicChanged() )
1041 rSh.ReRead( aEmptyStr, aEmptyStr, &pDlg->GetGraphic());
1042 rSh.EndAction();
1046 break;
1047 case FN_FRAME_TO_ANCHOR:
1049 rSh.GotoFlyAnchor();
1050 rSh.EnterStdMode();
1051 rSh.CallChgLnk();
1053 break;
1054 case FN_TOOL_ANKER:
1055 break;
1056 case FN_TOOL_ANKER_PAGE:
1057 case FN_TOOL_ANKER_PARAGRAPH:
1058 case FN_TOOL_ANKER_CHAR:
1059 case FN_TOOL_ANKER_AT_CHAR:
1060 case FN_TOOL_ANKER_FRAME:
1062 RndStdIds eSet = nSlot == FN_TOOL_ANKER_PAGE
1063 ? FLY_PAGE
1064 : nSlot == FN_TOOL_ANKER_PARAGRAPH
1065 ? FLY_AT_CNTNT
1066 : nSlot == FN_TOOL_ANKER_FRAME
1067 ? FLY_AT_FLY
1068 : nSlot == FN_TOOL_ANKER_CHAR
1069 ? FLY_IN_CNTNT
1070 : FLY_AUTO_CNTNT;
1071 rSh.StartUndo();
1072 if( rSh.IsObjSelected() )
1073 rSh.ChgAnchor( eSet );
1074 else if( rSh.IsFrmSelected() )
1076 // Der Set beinhaltet auch VERT/HORI_ORIENT, da in FEShell::
1077 // SetFlyFrmAttr/SetFlyFrmAnchor ggf. als Folge des Umankerns
1078 // die Ausrichtungen veraendert werden sollen.
1079 SfxItemSet aSet( GetPool(), RES_VERT_ORIENT, RES_ANCHOR );
1080 SwFmtAnchor aAnc( eSet, rSh.GetPhyPageNum() );
1081 aSet.Put( aAnc );
1082 rSh.SetFlyFrmAttr(aSet);
1085 USHORT nHtmlMode = ::GetHtmlMode(GetView().GetDocShell());
1086 if( nHtmlMode )
1088 SfxItemSet aSet(GetPool(), RES_SURROUND, RES_HORI_ORIENT);
1089 rSh.GetFlyFrmAttr(aSet);
1091 const SwFmtSurround& rSurround = (const SwFmtSurround&)aSet.Get(RES_SURROUND);
1092 const SwFmtVertOrient& rVert = (const SwFmtVertOrient&)aSet.Get(RES_VERT_ORIENT);
1093 const SwFmtHoriOrient& rHori = (const SwFmtHoriOrient&)aSet.Get(RES_HORI_ORIENT);
1094 sal_Int16 eVOrient = rVert.GetVertOrient();
1095 sal_Int16 eHOrient = rHori.GetHoriOrient();
1096 SwSurround eSurround = rSurround.GetSurround();
1098 switch( eSet )
1100 case FLY_AT_FLY:
1101 case FLY_PAGE:
1103 //Durchlauf, links oder von links, oben, von oben
1104 if(eSurround != SURROUND_THROUGHT)
1105 aSet.Put(SwFmtSurround(SURROUND_THROUGHT));
1107 if( eVOrient != text::VertOrientation::TOP && eVOrient != text::VertOrientation::NONE)
1108 aSet.Put(SwFmtVertOrient(0, text::VertOrientation::TOP));
1110 if(eHOrient != text::HoriOrientation::NONE || eHOrient != text::HoriOrientation::LEFT)
1111 aSet.Put(SwFmtHoriOrient(0, text::HoriOrientation::LEFT));
1112 break;
1114 case FLY_AT_CNTNT:
1115 //links, von links, rechts, oben, kein Uml, li+re Umlauf,
1116 if(eSurround != SURROUND_LEFT || eSurround != SURROUND_RIGHT)
1117 aSet.Put(SwFmtSurround(SURROUND_LEFT));
1119 if( eVOrient != text::VertOrientation::TOP)
1120 aSet.Put(SwFmtVertOrient(0, text::VertOrientation::TOP));
1122 if(eHOrient != text::HoriOrientation::NONE || eHOrient != text::HoriOrientation::LEFT || eHOrient != text::HoriOrientation::RIGHT)
1123 aSet.Put(SwFmtHoriOrient(0, text::HoriOrientation::LEFT));
1124 break;
1126 case FLY_AUTO_CNTNT:
1127 //links, von links, rechts, oben, Durchlauf
1128 if(eSurround != SURROUND_THROUGHT)
1129 aSet.Put(SwFmtSurround(SURROUND_THROUGHT));
1131 if( eVOrient != text::VertOrientation::TOP)
1132 aSet.Put(SwFmtVertOrient(0, text::VertOrientation::TOP));
1134 if(eHOrient != text::HoriOrientation::NONE || eHOrient != text::HoriOrientation::LEFT || eHOrient != text::HoriOrientation::RIGHT)
1135 aSet.Put(SwFmtHoriOrient(0, text::HoriOrientation::LEFT));
1136 break;
1138 default:
1142 if( aSet.Count() )
1143 rSh.SetFlyFrmAttr( aSet );
1145 rSh.EndUndo();
1147 GetView().GetViewFrame()->GetBindings().Invalidate( FN_TOOL_ANKER );
1149 break;
1151 case FN_FRAME_NOWRAP:
1152 case FN_FRAME_WRAP:
1153 case FN_FRAME_WRAP_IDEAL:
1154 case FN_FRAME_WRAPTHRU:
1155 case FN_FRAME_WRAPTHRU_TRANSP:
1156 case FN_FRAME_WRAP_CONTOUR:
1157 case FN_WRAP_ANCHOR_ONLY:
1158 case FN_FRAME_WRAP_LEFT:
1159 case FN_FRAME_WRAP_RIGHT:
1160 SetWrapMode( nSlot );
1161 break;
1163 case FN_UPDATE_ALL_LINKS:
1165 if( rSh.GetLinkManager().GetLinks().Count() )
1167 BOOL bUpdateGrf = FALSE, bCallErrHdl = FALSE;
1168 rSh.EnterStdMode();
1169 rSh.StartAllAction();
1170 rSh.GetLinkManager().UpdateAllLinks( FALSE, bCallErrHdl, bUpdateGrf );
1171 rSh.EndAllAction();
1174 break;
1176 case FN_XFORMS_DESIGN_MODE:
1177 if( pArgs != NULL
1178 && pArgs->GetItemState( nSlot, TRUE, &pItem ) == SFX_ITEM_SET
1179 && pItem != NULL
1180 && pItem->ISA( SfxBoolItem ) )
1182 BOOL bDesignMode =
1183 static_cast<const SfxBoolItem*>( pItem )->GetValue();
1185 // set form design mode
1186 DBG_ASSERT( GetView().GetFormShell() != NULL, "form shell?" );
1187 SfxRequest aReq( GetView().GetViewFrame(), SID_FM_DESIGN_MODE );
1188 aReq.AppendItem( SfxBoolItem( SID_FM_DESIGN_MODE, bDesignMode ) );
1189 GetView().GetFormShell()->Execute( aReq );
1190 aReq.Done();
1192 // also set suitable view options
1193 SwViewOption aViewOption = *rSh.GetViewOptions();
1194 aViewOption.SetFormView( ! bDesignMode );
1195 rSh.ApplyViewOptions( aViewOption );
1197 break;
1199 default:
1200 bMore = TRUE;
1202 if(bMore && pArgs)
1204 pItem = 0;
1205 pArgs->GetItemState(GetPool().GetWhich(nSlot), FALSE, &pItem);
1206 if(pItem)
1207 switch(nSlot)
1209 case SID_ATTR_BRUSH:
1210 case SID_ATTR_BORDER_SHADOW:
1211 case RES_SHADOW:
1213 rSh.StartAllAction();
1214 SfxItemSet aSet( rSh.GetAttrPool(),
1215 RES_SHADOW, RES_SHADOW,
1216 RES_BACKGROUND, RES_BACKGROUND, 0 );
1218 aSet.Put(*pItem);
1219 // Tabellenzelle(n) selektiert?
1220 if ( rSh.IsTableMode() )
1222 SwFrmFmt *pFmt = rSh.GetTableFmt();
1223 pFmt->SetFmtAttr( *pItem );
1225 else if ( rSh.IsFrmSelected() )
1227 // Umrandungsattribute ueber Frame-Manager setzen
1228 SwFlyFrmAttrMgr aMgr( FALSE, &rSh, FRMMGR_TYPE_NONE );
1229 aMgr.SetAttrSet( *pArgs );
1230 aMgr.UpdateFlyFrm();
1232 else
1234 rSh.SetAttr( *pArgs );
1236 rSh.EndAllAction();
1238 break;
1239 case FN_PAGE_STYLE_SET_LR_MARGIN:
1240 case FN_PAGE_STYLE_SET_UL_MARGIN:
1241 case FN_PAGE_STYLE_SET_NUMBER_FORMAT:
1242 case FN_PAGE_STYLE_SET_PAPER_SIZE:
1243 case FN_PAGE_STYLE_SET_PAPER_BIN:
1245 DBG_ERROR("not implemented");
1247 break;
1249 case SID_ATTR_BORDER_OUTER:
1251 // Tabellenzelle(n) selektiert?
1252 if ( rSh.IsTableMode() )
1254 // Umrandungattribute Get/SetTabBorders() setzen
1255 rSh.SetTabBorders(*pArgs);
1257 else if ( rSh.IsFrmSelected() )
1259 // Umrandungsattribute ueber Frame-Manager setzen
1260 SwFlyFrmAttrMgr aMgr( FALSE, &rSh, FRMMGR_TYPE_NONE );
1261 aMgr.SetAttrSet(*pArgs);
1262 aMgr.UpdateFlyFrm();
1264 else
1266 // Umrandungsattribute ganz normal ueber Shell setzen
1267 rSh.SetAttr( *pItem );
1270 break;
1271 default:
1272 DBG_ERROR("falscher Dispatcher");
1278 /* -----------------14.04.99 15:10-------------------
1279 * Hier wird der State fuer SID_IMAP / SID_CONTOUR behandelt,
1280 * wenn die Grafik ausgeswappt ist
1281 * --------------------------------------------------*/
1282 IMPL_LINK(SwBaseShell, GraphicArrivedHdl, SwCrsrShell* , EMPTYARG )
1284 USHORT nGrfType;
1285 SwWrtShell &rSh = GetShell();
1286 if( CNT_GRF == rSh.SwEditShell::GetCntType() &&
1287 GRAPHIC_NONE != ( nGrfType = rSh.GetGraphicType() ) &&
1288 aGrfUpdateSlots.Count() )
1290 BOOL bProtect = 0 != rSh.IsSelObjProtected(FLYPROTECT_CONTENT|FLYPROTECT_PARENT);
1291 SfxViewFrame* pVFrame = GetView().GetViewFrame();
1292 USHORT nSlot;
1293 for( USHORT n = 0; n < aGrfUpdateSlots.Count(); ++n )
1295 BOOL bSetState = FALSE;
1296 BOOL bState = FALSE;
1297 switch( nSlot = aGrfUpdateSlots[ n ] )
1299 case SID_IMAP:
1300 case SID_IMAP_EXEC:
1302 USHORT nId = SvxIMapDlgChildWindow::GetChildWindowId();
1303 SvxIMapDlg *pDlg = pVFrame->HasChildWindow( nId ) ?
1304 (SvxIMapDlg*) ( pVFrame->GetChildWindow( nId )
1305 ->GetWindow()) : 0;
1307 if( pDlg && ( SID_IMAP_EXEC == nSlot ||
1308 ( SID_IMAP == nSlot && !bProtect)) &&
1309 pDlg->GetEditingObject() != rSh.GetIMapInventor())
1310 lcl_UpdateIMapDlg( rSh );
1312 if( !bProtect && SID_IMAP == nSlot )
1313 bSetState = TRUE, bState = 0 != pDlg;
1315 break;
1317 case SID_CONTOUR_DLG:
1318 if( !bProtect )
1320 USHORT nId = SvxContourDlgChildWindow::GetChildWindowId();
1321 SvxIMapDlg *pDlg = pVFrame->HasChildWindow( nId ) ?
1322 (SvxIMapDlg*) ( pVFrame->GetChildWindow( nId )
1323 ->GetWindow()) : 0;
1324 if( pDlg && pDlg->GetEditingObject() !=
1325 rSh.GetIMapInventor() )
1326 lcl_UpdateContourDlg( rSh, nsSelectionType::SEL_GRF );
1328 bSetState = TRUE;
1329 bState = 0 != pDlg;
1331 break;
1333 case FN_FRAME_WRAP_CONTOUR:
1334 if( !bProtect )
1336 SfxItemSet aSet(GetPool(), RES_SURROUND, RES_SURROUND);
1337 rSh.GetFlyFrmAttr(aSet);
1338 const SwFmtSurround& rWrap = (const SwFmtSurround&)aSet.Get(RES_SURROUND);
1339 bSetState = TRUE;
1340 bState = rWrap.IsContour();
1342 break;
1344 case SID_GRFFILTER:
1345 case SID_GRFFILTER_INVERT:
1346 case SID_GRFFILTER_SMOOTH:
1347 case SID_GRFFILTER_SHARPEN:
1348 case SID_GRFFILTER_REMOVENOISE:
1349 case SID_GRFFILTER_SOBEL:
1350 case SID_GRFFILTER_MOSAIC:
1351 case SID_GRFFILTER_EMBOSS:
1352 case SID_GRFFILTER_POSTER:
1353 case SID_GRFFILTER_POPART:
1354 case SID_GRFFILTER_SEPIA:
1355 case SID_GRFFILTER_SOLARIZE:
1356 bSetState = bState = GRAPHIC_BITMAP == nGrfType;
1357 break;
1360 if( bSetState )
1362 SfxBoolItem aBool( nSlot, bState );
1363 if( pGetStateSet )
1364 pGetStateSet->Put( aBool );
1365 else
1366 pVFrame->GetBindings().SetState( aBool );
1369 aGrfUpdateSlots.RemoveAt( 0, aGrfUpdateSlots.Count() );
1371 return 0;
1374 void SwBaseShell::GetState( SfxItemSet &rSet )
1376 SwWrtShell &rSh = GetShell();
1377 SfxViewFrame* pVFrame = GetView().GetViewFrame();
1378 SfxWhichIter aIter( rSet );
1379 USHORT nWhich = aIter.FirstWhich();
1380 pGetStateSet = &rSet;
1381 while ( nWhich )
1383 switch ( nWhich )
1385 case SID_GALLERY_FORMATS:
1386 if ( rSh.IsObjSelected() ||
1387 (rSh.IsSelFrmMode() &&
1388 !(rSh.GetSelectionType() & nsSelectionType::SEL_GRF)) )
1389 rSet.DisableItem( nWhich );
1390 break;
1391 case SID_GALLERY_ENABLE_ADDCOPY:
1392 // #108230# allow copy from gallery in Writer AND Writer/Web!
1393 rSet.Put( SfxBoolItem( SID_GALLERY_ENABLE_ADDCOPY, TRUE ) );
1394 break;
1395 case FN_EDIT_REGION:
1396 if( !rSh.IsAnySectionInDoc() )
1397 rSet.DisableItem(nWhich);
1398 break;
1400 case FN_INSERT_REGION:
1401 if( rSh.IsSelFrmMode() ||
1402 !rSh.IsInsRegionAvailable() )
1403 rSet.DisableItem( nWhich );
1404 break;
1405 case FN_CONVERT_TABLE_TO_TEXT:
1407 USHORT eFrmType = rSh.GetFrmType(0,TRUE);
1408 if( (eFrmType & FRMTYPE_FOOTNOTE) ||
1409 !rSh.GetTableFmt() )
1410 rSet.DisableItem( nWhich );
1412 break;
1413 case FN_CONVERT_TEXT_TO_TABLE:
1415 USHORT eFrmType = rSh.GetFrmType(0,TRUE);
1416 if( (eFrmType & FRMTYPE_FOOTNOTE) ||
1417 !rSh.IsTextToTableAvailable() )
1418 rSet.DisableItem( nWhich );
1420 break;
1421 case FN_CONVERT_TEXT_TABLE:
1423 USHORT eFrmType = rSh.GetFrmType(0,TRUE);
1424 if( (eFrmType & FRMTYPE_FOOTNOTE) ||
1425 (!rSh.GetTableFmt() && !rSh.IsTextToTableAvailable() ) )
1426 rSet.DisableItem( nWhich );
1428 break;
1429 case RES_SHADOW:
1431 SfxItemSet aSet( rSh.GetAttrPool(),
1432 RES_SHADOW, RES_SHADOW );
1434 // Tabellenzelle(n) selektiert?
1435 if ( rSh.IsTableMode() )
1437 SwFrmFmt *pFmt = rSh.GetTableFmt();
1438 aSet.Put(pFmt->GetFmtAttr( nWhich, TRUE ));
1440 else if( rSh.IsFrmSelected() )
1442 SwFlyFrmAttrMgr aMgr( FALSE, &rSh, FRMMGR_TYPE_NONE );
1443 aSet.Put( aMgr.GetAttrSet() );
1445 else
1446 rSh.GetCurAttr( aSet );
1447 #if OSL_DEBUG_LEVEL > 1
1449 const SvxShadowItem& rShItem = (const SvxShadowItem&)aSet.Get(nWhich);
1450 rSet.Put(rShItem);
1451 #else
1452 rSet.Put((const SvxShadowItem&)aSet.Get(nWhich));
1453 #endif
1455 break;
1456 case SID_IMAP:
1458 // --> OD 2006-11-08 #i59688#
1459 // improve efficiency:
1460 // If selected object is protected, item has to disabled.
1461 const BOOL bProtect = 0 != rSh.IsSelObjProtected(FLYPROTECT_CONTENT|FLYPROTECT_PARENT);
1462 if ( bProtect )
1464 rSet.DisableItem( nWhich );
1466 else
1468 const USHORT nId = SvxIMapDlgChildWindow::GetChildWindowId();
1469 const BOOL bHas = pVFrame->HasChildWindow( nId );
1470 const BOOL bFrmSel = rSh.IsFrmSelected();
1471 const BOOL bIsGraphicSelection =
1472 rSh.GetSelectionType() == nsSelectionType::SEL_GRF;
1474 // --> OD 2006-11-08 #i59688#
1475 // avoid unnecessary loading of selected graphic.
1476 // The graphic is only needed, if the dialog is open.
1477 //wenn die Grafik ausgeswappt ist, dann muss der
1478 //Status asynchron ermittelt werden
1479 //bis dahin wird der Slot disabled
1480 if ( bHas && bIsGraphicSelection && rSh.IsGrfSwapOut( TRUE ) )
1482 if( AddGrfUpdateSlot( nWhich ))
1483 rSh.GetGraphic(FALSE); // start the loading
1485 else
1487 if ( !bHas &&
1488 ( !bFrmSel ||
1489 ( bIsGraphicSelection &&
1490 rSh.GetGraphicType() == GRAPHIC_NONE ) ) )
1492 rSet.DisableItem( nWhich );
1494 else
1496 SfxBoolItem aBool(nWhich, bHas);
1497 if ( bHas && bFrmSel )
1498 lcl_UpdateIMapDlg( rSh );
1499 rSet.Put(aBool);
1502 // <--
1504 // <--
1506 break;
1507 case SID_IMAP_EXEC:
1509 BOOL bDisable = FALSE;
1510 if( !rSh.IsFrmSelected())
1511 bDisable = TRUE;
1512 USHORT nId = SvxIMapDlgChildWindow::GetChildWindowId();
1513 if(!bDisable && pVFrame->HasChildWindow( nId ))
1515 if(rSh.GetSelectionType() == nsSelectionType::SEL_GRF
1516 && rSh.IsGrfSwapOut(TRUE))
1518 if( AddGrfUpdateSlot( nWhich ))
1519 rSh.GetGraphic(FALSE); // start the loading
1521 else
1523 SvxIMapDlg *pDlg = SWIMAPDLG(GetView());
1524 if( pDlg->GetEditingObject() != rSh.GetIMapInventor() )
1525 lcl_UpdateIMapDlg( rSh );
1528 rSet.Put(SfxBoolItem(nWhich, bDisable));
1530 break;
1531 case FN_BACKSPACE:
1532 case SID_DELETE:
1533 if (rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0)
1534 rSet.DisableItem( nWhich );
1535 break;
1536 case SID_CONTOUR_DLG:
1538 BOOL bParentCntProt = 0 != rSh.IsSelObjProtected(FLYPROTECT_CONTENT|FLYPROTECT_PARENT );
1540 if( bParentCntProt || 0 != (HTMLMODE_ON & ::GetHtmlMode(
1541 GetView().GetDocShell() )) )
1542 rSet.DisableItem( nWhich );
1543 else
1545 USHORT nId = SvxContourDlgChildWindow::GetChildWindowId();
1546 BOOL bHas = GetView().GetViewFrame()->HasChildWindow( nId );
1547 int nSel = rSh.GetSelectionType();
1548 BOOL bOk = 0 != (nSel & (nsSelectionType::SEL_GRF|nsSelectionType::SEL_OLE));
1550 BOOL bDisable = FALSE;
1551 if( !bHas && !bOk )
1552 bDisable = TRUE;
1553 // --> OD 2006-11-08 #i59688#
1554 // avoid unnecessary loading of selected graphic.
1555 // The graphic is only needed, if the dialog is open.
1556 // wenn die Grafik ausgeswappt ist, dann muss der Status
1557 // asynchron ermittelt werden bis dahin wird der Slot
1558 // disabled
1559 else if ( bHas && (nSel & nsSelectionType::SEL_GRF) &&
1560 rSh.IsGrfSwapOut(TRUE) )
1562 if( AddGrfUpdateSlot( nWhich ))
1563 rSh.GetGraphic(FALSE); // start the loading
1564 // --> OD 2007-07-04 #i75481#
1565 bDisable = TRUE;
1566 // <--
1568 else if( bHas && bOk )
1569 bDisable = !lcl_UpdateContourDlg( rSh, nSel );
1570 else if( bOk )
1572 // --> OD 2007-07-04 #i75481#
1573 // apply fix #i59688# only for selected graphics
1574 if ( nSel & nsSelectionType::SEL_GRF )
1575 bDisable = GRAPHIC_NONE == rSh.GetGraphicType();
1576 else
1577 bDisable = GRAPHIC_NONE == rSh.GetIMapGraphic().GetType();
1578 // <--
1580 // <--
1582 if( bDisable )
1583 rSet.DisableItem( nWhich );
1584 else
1585 rSet.Put( SfxBoolItem(nWhich, bHas) );
1588 break;
1589 case SID_CONTOUR_EXEC:
1591 BOOL bDisable = FALSE;
1592 int nSel = rSh.GetSelectionType();
1593 if( !(nSel & (nsSelectionType::SEL_GRF|nsSelectionType::SEL_OLE)) )
1594 bDisable = TRUE;
1595 USHORT nId = SvxContourDlgChildWindow::GetChildWindowId();
1596 if( !bDisable && GetView().GetViewFrame()->HasChildWindow( nId ))
1598 SvxContourDlg *pDlg = SWCONTOURDLG(GetView());
1599 if( pDlg->GetEditingObject() != rSh.GetIMapInventor() )
1600 bDisable = TRUE;
1602 rSet.Put(SfxBoolItem(nWhich, bDisable));
1604 break;
1606 case FN_TOOL_ANKER:
1607 case FN_TOOL_ANKER_PAGE:
1608 case FN_TOOL_ANKER_PARAGRAPH:
1609 case FN_TOOL_ANKER_CHAR:
1610 case FN_TOOL_ANKER_AT_CHAR:
1611 case FN_TOOL_ANKER_FRAME:
1613 BOOL bObj = 0 != rSh.IsObjSelected();
1614 BOOL bParentCntProt = rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0;
1616 if( !bParentCntProt && (bObj || rSh.IsFrmSelected()))
1618 SfxItemSet aSet(GetPool(), RES_ANCHOR, RES_ANCHOR);
1619 if(bObj)
1620 rSh.GetObjAttr(aSet);
1621 else
1622 rSh.GetFlyFrmAttr(aSet);
1623 RndStdIds eSet = ((SwFmtAnchor&)aSet.Get(RES_ANCHOR)).GetAnchorId();
1624 BOOL bSet;
1625 bSet = (nWhich == FN_TOOL_ANKER_PAGE && eSet == FLY_PAGE) ||
1626 (nWhich == FN_TOOL_ANKER_PARAGRAPH && eSet == FLY_AT_CNTNT) ||
1627 (nWhich == FN_TOOL_ANKER_FRAME && eSet == FLY_AT_FLY) ||
1628 (nWhich == FN_TOOL_ANKER_AT_CHAR && eSet == FLY_AUTO_CNTNT) ||
1629 (nWhich == FN_TOOL_ANKER_CHAR && eSet == FLY_IN_CNTNT);
1630 if(nWhich != FN_TOOL_ANKER)
1632 USHORT nHtmlMode = ::GetHtmlMode(GetView().GetDocShell());
1633 if( ( nWhich == FN_TOOL_ANKER_PAGE &&
1634 ((HTMLMODE_ON & nHtmlMode) && (0 == (nHtmlMode & HTMLMODE_SOME_ABS_POS)))) ||
1635 ( nWhich == FN_TOOL_ANKER_FRAME && !rSh.IsFlyInFly() ) )
1636 rSet.DisableItem(nWhich);
1637 else
1638 rSet.Put(SfxBoolItem(nWhich, bSet));
1640 else
1642 USHORT nSlotId = 0;
1644 switch (eSet)
1646 case FLY_PAGE:
1647 nSlotId = FN_TOOL_ANKER_PAGE;
1648 break;
1649 case FLY_AT_CNTNT:
1650 nSlotId = FN_TOOL_ANKER_PARAGRAPH;
1651 break;
1652 case FLY_IN_CNTNT:
1653 nSlotId = FN_TOOL_ANKER_CHAR;
1654 break;
1655 case FLY_AUTO_CNTNT:
1656 nSlotId = FN_TOOL_ANKER_AT_CHAR;
1657 break;
1658 case FLY_AT_FLY:
1659 nSlotId = FN_TOOL_ANKER_FRAME;
1660 break;
1661 default:
1664 rSet.Put(SfxUInt16Item(nWhich, nSlotId));
1667 else
1668 rSet.DisableItem( nWhich );
1670 break;
1671 case FN_FRAME_NOWRAP:
1672 case FN_FRAME_WRAP:
1673 case FN_FRAME_WRAP_IDEAL:
1674 case FN_FRAME_WRAPTHRU:
1675 case FN_FRAME_WRAPTHRU_TRANSP:
1676 case FN_FRAME_WRAP_CONTOUR:
1677 case FN_WRAP_ANCHOR_ONLY:
1678 case FN_FRAME_WRAP_LEFT:
1679 case FN_FRAME_WRAP_RIGHT:
1681 BOOL bObj = 0 != rSh.IsObjSelected();
1682 BOOL bParentCntProt = rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0;
1684 if( !bParentCntProt && (bObj || rSh.IsFrmSelected()))
1686 SfxItemSet aSet(GetPool(), RES_OPAQUE, RES_ANCHOR);
1687 int nAnchorType;
1688 if(bObj)
1690 rSh.GetObjAttr(aSet);
1691 nAnchorType = rSh.GetAnchorId();
1693 else
1695 rSh.GetFlyFrmAttr(aSet);
1696 nAnchorType = ((SwFmtAnchor&)aSet.Get(RES_ANCHOR)).GetAnchorId();
1698 const SwFmtSurround& rWrap = (const SwFmtSurround&)aSet.Get(RES_SURROUND);
1700 const SvxOpaqueItem& rOpaque = (const SvxOpaqueItem&)aSet.Get(RES_OPAQUE);
1701 BOOL bOpaque = rOpaque.GetValue();
1702 SwSurround nSurround = rWrap.GetSurround();
1703 BOOL bSet = FALSE;
1705 BOOL bDisable = nAnchorType == - 1 || nAnchorType == FLY_IN_CNTNT;
1706 BOOL bHtmlMode = 0 != ::GetHtmlMode(GetView().GetDocShell());
1708 switch( nWhich )
1710 case FN_FRAME_NOWRAP:
1711 bDisable |=
1712 ( nAnchorType != FLY_AT_CNTNT &&
1713 nAnchorType != FLY_AUTO_CNTNT && nAnchorType != FLY_PAGE);
1714 bSet = nSurround == SURROUND_NONE;
1715 break;
1716 case FN_FRAME_WRAP:
1717 bDisable |= bHtmlMode;
1718 bSet = nSurround == SURROUND_PARALLEL;
1719 break;
1720 case FN_FRAME_WRAP_IDEAL:
1721 bDisable |= bHtmlMode;
1722 bSet = nSurround == SURROUND_IDEAL;
1723 break;
1724 case FN_FRAME_WRAPTHRU:
1725 bDisable |= (bHtmlMode ||
1726 (nAnchorType != FLY_AT_CNTNT&& nAnchorType != FLY_AUTO_CNTNT && nAnchorType != FLY_PAGE));
1727 if(bObj)
1728 bSet = nSurround == SURROUND_THROUGHT && rSh.GetLayerId();
1729 else
1730 bSet = nSurround == SURROUND_THROUGHT && bOpaque;
1731 break;
1732 case FN_FRAME_WRAPTHRU_TRANSP:
1733 bDisable |= bHtmlMode;
1734 if(bObj)
1735 bSet = nSurround == SURROUND_THROUGHT && !rSh.GetLayerId();
1736 else
1737 bSet = nSurround == SURROUND_THROUGHT && !bOpaque;
1738 break;
1739 case FN_FRAME_WRAP_CONTOUR:
1740 bDisable |= bHtmlMode;
1741 //no contour available whenn no wrap or wrap through is set
1742 bDisable |= (nSurround == SURROUND_NONE || nSurround == SURROUND_THROUGHT);
1743 bSet = rWrap.IsContour();
1744 if( !bDisable )
1746 int nSel = rSh.GetSelectionType();
1747 if( (nSel & nsSelectionType::SEL_GRF) &&
1748 rSh.IsGrfSwapOut(TRUE))
1750 if( AddGrfUpdateSlot( nWhich ))
1751 rSh.GetGraphic(FALSE); // start the loading
1753 else if( rSh.IsFrmSelected() )
1755 // #i102253# applied patch from OD (see task)
1756 bDisable =
1757 nSel & nsSelectionType::SEL_FRM ||
1758 GRAPHIC_NONE == rSh.GetIMapGraphic().GetType();
1761 bSet = bDisable ? FALSE : rWrap.IsContour();
1763 break;
1764 case FN_WRAP_ANCHOR_ONLY:
1765 bDisable |= (bHtmlMode ||
1766 (nAnchorType != FLY_AT_CNTNT));
1767 bSet = rWrap.IsAnchorOnly();
1768 break;
1769 case FN_FRAME_WRAP_LEFT:
1770 bSet = nSurround == SURROUND_LEFT;
1771 break;
1772 case FN_FRAME_WRAP_RIGHT:
1773 bSet = nSurround == SURROUND_RIGHT;
1774 break;
1777 if(bDisable)
1778 rSet.DisableItem(nWhich);
1779 else
1780 rSet.Put(SfxBoolItem(nWhich, bSet));
1782 else
1783 rSet.DisableItem(nWhich);
1785 break;
1786 case FN_UPDATE_CHARTS:
1787 if( !rSh.HasCharts() )
1788 rSet.DisableItem( nWhich );
1789 break;
1790 case FN_UPDATE_ALL_LINKS:
1791 if ( !rSh.GetLinkManager().GetLinks().Count() )
1792 rSet.DisableItem(nWhich);
1793 break;
1794 case FN_XFORMS_DESIGN_MODE:
1795 // enable if in XForms document
1796 if( rSh.GetDoc()->isXForms() )
1798 // determine current state from view options
1799 sal_Bool bValue = ! rSh.GetViewOptions()->IsFormView();
1800 rSet.Put( SfxBoolItem( nWhich, bValue ) );
1802 else
1803 rSet.Put( SfxVisibilityItem( nWhich, sal_False ) );
1804 break;
1806 nWhich = aIter.NextWhich();
1808 pGetStateSet = 0;
1811 /*--------------------------------------------------------------------
1812 Beschreibung: Slots mit dieser Statusmethode disablen
1813 --------------------------------------------------------------------*/
1816 void SwBaseShell::StateDisableItems( SfxItemSet &rSet )
1818 SfxWhichIter aIter(rSet);
1819 USHORT nWhich = aIter.FirstWhich();
1821 while (nWhich)
1823 rSet.DisableItem( nWhich );
1824 nWhich = aIter.NextWhich();
1828 /*--------------------------------------------------------------------
1829 Beschreibung: Slots mit dieser Statusmethode disablen
1830 --------------------------------------------------------------------*/
1833 void SwBaseShell::StateStyle( SfxItemSet &rSet )
1835 BOOL bParentCntProt = GetShell().IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0;
1836 ShellModes eMode = GetView().GetShellMode();
1838 if ( bParentCntProt ||
1839 SHELL_MODE_DRAW == eMode ||
1840 SHELL_MODE_DRAW_CTRL == eMode ||
1841 SHELL_MODE_DRAW_FORM == eMode ||
1842 SHELL_MODE_DRAWTEXT == eMode ||
1843 SHELL_MODE_BEZIER == eMode )
1845 SfxWhichIter aIter( rSet );
1846 USHORT nWhich = aIter.FirstWhich();
1847 while ( nWhich )
1849 rSet.DisableItem( nWhich );
1850 nWhich = aIter.NextWhich();
1853 else
1854 GetView().GetDocShell()->StateStyleSheet(rSet, &GetShell());
1857 /*--------------------------------------------------------------------
1858 Beschreibung:
1859 --------------------------------------------------------------------*/
1862 void SwBaseShell::SetWrapMode( USHORT nSlot )
1864 SwWrtShell &rSh = GetShell();
1865 BOOL bObj = 0 != rSh.IsObjSelected();
1866 if( bObj || rSh.IsFrmSelected())
1868 SfxItemSet aSet(GetPool(), RES_OPAQUE, RES_SURROUND);
1869 if(bObj)
1870 rSh.GetObjAttr(aSet);
1871 else
1872 rSh.GetFlyFrmAttr(aSet);
1873 SwFmtSurround aWrap( (SwFmtSurround&)aSet.Get(RES_SURROUND) );
1874 SwSurround nOldSurround(aWrap.GetSurround());
1875 SwSurround nSurround = SURROUND_PARALLEL;
1877 switch (nSlot)
1879 case FN_FRAME_NOWRAP:
1880 nSurround = SURROUND_NONE;
1881 if (aWrap.IsContour())
1882 aWrap.SetContour(FALSE);
1883 break;
1884 case FN_FRAME_WRAP_IDEAL:
1885 nSurround = SURROUND_IDEAL;
1886 break;
1887 case FN_WRAP_ANCHOR_ONLY:
1888 aWrap.SetAnchorOnly(!aWrap.IsAnchorOnly());
1889 // --> OD 2006-06-02 #b6432130#
1890 // keep previous wrapping
1891 // --> OD 2006-09-21 #138144# - adjust fix #b6432130#
1892 // switch to wrap SURROUND_PARALLEL, if previous wrap is SURROUND_NONE
1893 if ( nOldSurround != SURROUND_NONE )
1895 nSurround = nOldSurround;
1897 // <--
1898 break;
1899 case FN_FRAME_WRAP_CONTOUR:
1900 aWrap.SetContour(!aWrap.IsContour());
1901 if (nSurround == SURROUND_THROUGHT)
1902 nSurround = SURROUND_PARALLEL;
1903 break;
1904 case FN_FRAME_WRAPTHRU_TRANSP:
1905 if (aWrap.IsContour())
1906 aWrap.SetContour(FALSE);
1907 // kein break!!!
1908 case FN_FRAME_WRAPTHRU:
1909 nSurround = SURROUND_THROUGHT;
1910 break;
1912 case FN_FRAME_WRAP_LEFT:
1913 nSurround = SURROUND_LEFT;
1914 break;
1916 case FN_FRAME_WRAP_RIGHT:
1917 nSurround = SURROUND_RIGHT;
1918 break;
1920 default:
1921 break;
1923 aWrap.SetSurround(nSurround);
1925 if (nSlot != FN_FRAME_WRAP_CONTOUR)
1927 // Konturumfluss bei Draw-Objekten defaulten
1928 if (bObj && nOldSurround != nSurround &&
1929 (nOldSurround == SURROUND_NONE || nOldSurround == SURROUND_THROUGHT))
1931 aWrap.SetContour(TRUE);
1935 aSet.Put( aWrap );
1936 aSet.Put(SvxOpaqueItem(RES_OPAQUE, nSlot != FN_FRAME_WRAPTHRU_TRANSP));
1937 if(bObj)
1939 rSh.SetObjAttr(aSet);
1940 if (nSlot != FN_FRAME_WRAPTHRU_TRANSP)
1941 rSh.SelectionToHeaven();
1942 else
1943 rSh.SelectionToHell();
1945 else
1946 rSh.SetFlyFrmAttr(aSet);
1950 /*--------------------------------------------------------------------
1951 Beschreibung: Update der Statuszeile erzwingen
1952 --------------------------------------------------------------------*/
1954 void SwBaseShell::SetFrmMode(FlyMode eMode, SwWrtShell *pSh )
1956 eFrameMode = eMode;
1957 SfxBindings &rBnd = pSh->GetView().GetViewFrame()->GetBindings();
1959 if( eMode == FLY_DRAG ||
1960 (pSh && (pSh->IsFrmSelected() || pSh->IsObjSelected())) )
1962 const SfxPointItem aTmp1( SID_ATTR_POSITION, pSh->GetAnchorObjDiff());
1963 const SvxSizeItem aTmp2( SID_ATTR_SIZE, pSh->GetObjSize());
1964 rBnd.SetState( aTmp1 );
1965 rBnd.SetState( aTmp2 );
1967 else if( eMode == FLY_DRAG_END )
1969 static USHORT __READONLY_DATA aInval[] =
1971 SID_ATTR_POSITION, SID_ATTR_SIZE, 0
1973 rBnd.Invalidate(aInval);
1977 /*--------------------------------------------------------------------
1978 Beschreibung: Ctor
1979 --------------------------------------------------------------------*/
1981 SwBaseShell::SwBaseShell(SwView& rVw) :
1982 SfxShell( &rVw ),
1983 rView(rVw),
1984 pGetStateSet(0)
1986 SwWrtShell& rWrtSh = rView.GetWrtShell();
1988 SetPool(&rWrtSh.GetAttrPool());
1989 SetName(C2S("Base"));
1990 rWrtSh.SetGrfArrivedLnk( LINK( this, SwBaseShell, GraphicArrivedHdl));
1994 SwBaseShell::~SwBaseShell()
1996 if( rView.GetCurShell() == this )
1997 rView.ResetSubShell();
1999 Link aTmp( LINK( this, SwBaseShell, GraphicArrivedHdl));
2000 if( aTmp == rView.GetWrtShell().GetGrfArrivedLnk() )
2001 rView.GetWrtShell().SetGrfArrivedLnk( Link() );
2004 /*--------------------------------------------------------------------
2005 Beschreibung:
2006 --------------------------------------------------------------------*/
2008 void SwBaseShell::ExecTxtCtrl( SfxRequest& rReq )
2010 const SfxItemSet *pArgs = rReq.GetArgs();
2012 if( pArgs)
2014 SwWrtShell &rSh = GetShell();
2015 SvxScriptSetItem* pSSetItem = 0;
2016 USHORT nSlot = rReq.GetSlot();
2017 SfxItemPool& rPool = rSh.GetAttrPool();
2018 USHORT nWhich = rPool.GetWhich( nSlot );
2019 USHORT nScripts = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
2020 SfxItemSet aHeightSet( GetPool(), RES_CHRATR_FONTSIZE, RES_CHRATR_FONTSIZE,
2021 RES_CHRATR_CJK_FONTSIZE, RES_CHRATR_CJK_FONTSIZE,
2022 RES_CHRATR_CTL_FONTSIZE, RES_CHRATR_CTL_FONTSIZE,
2023 0L);
2025 switch( nSlot )
2027 case SID_ATTR_CHAR_FONT:
2029 nScripts = rSh.GetScriptType();
2030 // #i42732# input language should be preferred over
2031 // current cursor position to detect script type
2032 if(!rSh.HasSelection())
2034 LanguageType nInputLang = GetView().GetEditWin().GetInputLanguage();
2035 if(nInputLang != LANGUAGE_DONTKNOW && nInputLang != LANGUAGE_SYSTEM)
2036 nScripts = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang );
2039 case SID_ATTR_CHAR_POSTURE:
2040 case SID_ATTR_CHAR_WEIGHT:
2042 pSSetItem = new SvxScriptSetItem( nSlot, rPool );
2043 pSSetItem->PutItemForScriptType( nScripts, pArgs->Get( nWhich ));
2044 pArgs = &pSSetItem->GetItemSet();
2046 break;
2047 case SID_ATTR_CHAR_FONTHEIGHT:
2049 if(rSh.HasSelection())
2051 pSSetItem = new SvxScriptSetItem( nSlot, rPool );
2052 pSSetItem->PutItemForScriptType( nScripts, pArgs->Get( nWhich ));
2053 pArgs = &pSSetItem->GetItemSet();
2055 else
2057 nScripts = rSh.GetScriptType();
2058 LanguageType nInputLang = GetView().GetEditWin().GetInputLanguage();
2059 if(nInputLang != LANGUAGE_DONTKNOW && nInputLang != LANGUAGE_SYSTEM)
2060 nScripts = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang );
2061 UINT32 nHeight = static_cast< const SvxFontHeightItem& >(pArgs->Get( nWhich )).GetHeight();
2062 SwStdFontConfig* pStdFont = SW_MOD()->GetStdFontConfig();
2064 SfxItemSet aLangSet( GetPool(), RES_CHRATR_LANGUAGE, RES_CHRATR_LANGUAGE,
2065 RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CJK_LANGUAGE,
2066 RES_CHRATR_CTL_LANGUAGE, RES_CHRATR_CTL_LANGUAGE,
2067 0L);
2068 rSh.GetCurAttr( aLangSet );
2070 sal_Int32 nWesternSize =
2071 pStdFont->GetFontHeight(FONT_STANDARD, FONT_GROUP_DEFAULT,
2072 static_cast<const SvxLanguageItem&>(aLangSet.Get( RES_CHRATR_LANGUAGE)).GetLanguage());
2073 sal_Int32 nCJKSize =
2074 pStdFont->GetFontHeight(FONT_STANDARD, FONT_GROUP_CJK,
2075 static_cast<const SvxLanguageItem&>(aLangSet.Get( RES_CHRATR_CJK_LANGUAGE)).GetLanguage());
2076 sal_Int32 nCTLSize =
2077 pStdFont->GetFontHeight(FONT_STANDARD, FONT_GROUP_CTL,
2078 static_cast<const SvxLanguageItem&>(aLangSet.Get( RES_CHRATR_CTL_LANGUAGE)).GetLanguage());
2080 switch(nScripts)
2082 case SCRIPTTYPE_LATIN:
2083 nCJKSize = nHeight * nCJKSize / nWesternSize;
2084 nCTLSize = nHeight * nCTLSize / nWesternSize;
2085 nWesternSize = (sal_Int32) nHeight;
2086 break;
2087 case SCRIPTTYPE_ASIAN:
2088 nCTLSize = nHeight* nCTLSize / nCJKSize;
2089 nWesternSize = nHeight * nWesternSize / nCJKSize;
2090 nCJKSize = (sal_Int32) nHeight;
2091 break;
2092 case SCRIPTTYPE_COMPLEX:
2093 nCJKSize = nHeight * nCJKSize / nCTLSize;
2094 nWesternSize = nHeight * nWesternSize / nCTLSize;
2095 nCTLSize = (sal_Int32) nHeight;
2096 break;
2098 aHeightSet.Put( SvxFontHeightItem( (UINT32)nWesternSize, 100, RES_CHRATR_FONTSIZE ));
2099 aHeightSet.Put( SvxFontHeightItem( (UINT32)nCJKSize, 100, RES_CHRATR_CJK_FONTSIZE ));
2100 aHeightSet.Put( SvxFontHeightItem( (UINT32)nCTLSize, 100, RES_CHRATR_CTL_FONTSIZE ));
2101 pArgs = &aHeightSet;
2104 break;
2107 if( pArgs )
2109 bool bAuto = false;
2110 if ( !isCHRATR(nWhich) ||
2111 ( rSh.HasSelection() && rSh.IsSelFullPara() ) )
2113 SwTxtFmtColl * pColl = rSh.GetCurTxtFmtColl();
2114 if ( pColl && pColl->IsAutoUpdateFmt() )
2116 rSh.AutoUpdatePara( pColl, *pArgs );
2117 bAuto = true;
2121 if (!bAuto)
2123 rSh.SetAttr( *pArgs );
2126 delete pSSetItem;
2128 else
2129 GetView().GetViewFrame()->GetDispatcher()->Execute( SID_CHAR_DLG, FALSE);
2130 rReq.Done();
2133 /*--------------------------------------------------------------------
2134 Beschreibung:
2135 --------------------------------------------------------------------*/
2137 void SwBaseShell::GetTxtCtrlState( SfxItemSet& rSet )
2139 SwWrtShell &rSh = GetShell();
2140 rSh.GetCurAttr( rSet );
2143 void SwBaseShell::GetTxtFontCtrlState( SfxItemSet& rSet )
2145 SwWrtShell &rSh = GetShell();
2146 BOOL bFirst = TRUE;
2147 SfxItemSet* pFntCoreSet = 0;
2148 USHORT nScriptType = SCRIPTTYPE_LATIN;
2149 SfxWhichIter aIter( rSet );
2150 USHORT nWhich = aIter.FirstWhich();
2151 while( nWhich )
2153 switch( nWhich )
2155 case RES_CHRATR_FONT:
2156 case RES_CHRATR_FONTSIZE:
2157 case RES_CHRATR_WEIGHT:
2158 case RES_CHRATR_POSTURE:
2160 if( !pFntCoreSet )
2162 pFntCoreSet = new SfxItemSet( *rSet.GetPool(),
2163 RES_CHRATR_BEGIN, RES_CHRATR_END-1 );
2164 rSh.GetCurAttr( *pFntCoreSet );
2165 nScriptType = rSh.GetScriptType();
2166 // #i42732# input language should be preferred over
2167 // current cursor position to detect script type
2168 SwEditWin& rEditWin = GetView().GetEditWin();
2169 if( rEditWin.IsUseInputLanguage() )
2171 if(!rSh.HasSelection() && (
2172 nWhich == RES_CHRATR_FONT ||
2173 nWhich == RES_CHRATR_FONTSIZE ))
2175 LanguageType nInputLang = rEditWin.GetInputLanguage();
2176 if(nInputLang != LANGUAGE_DONTKNOW && nInputLang != LANGUAGE_SYSTEM)
2177 nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang );
2181 SfxItemPool& rPool = *rSet.GetPool();
2182 SvxScriptSetItem aSetItem( rPool.GetSlotId( nWhich ), rPool );
2183 aSetItem.GetItemSet().Put( *pFntCoreSet, FALSE );
2184 const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScriptType );
2185 if( pI )
2186 rSet.Put( *pI, nWhich );
2187 else
2188 rSet.InvalidateItem( nWhich );
2189 //set input context of the SwEditWin according to the selected font and script type
2190 if(RES_CHRATR_FONT == nWhich)
2192 Font aFont;
2193 if(pI && pI->ISA(SvxFontItem))
2195 aFont.SetName( ((const SvxFontItem*)pI)->GetFamilyName());
2196 aFont.SetStyleName(((const SvxFontItem*)pI)->GetStyleName());
2197 aFont.SetFamily(((const SvxFontItem*)pI)->GetFamily());
2198 aFont.SetPitch(((const SvxFontItem*)pI)->GetPitch());
2199 aFont.SetCharSet(((const SvxFontItem*)pI)->GetCharSet());
2202 BOOL bVertical = rSh.IsInVerticalText();
2203 aFont.SetOrientation(bVertical ? 2700 : 0);
2204 aFont.SetVertical(bVertical);
2205 GetView().GetEditWin().SetInputContext( InputContext( aFont, INPUTCONTEXT_TEXT |
2206 INPUTCONTEXT_EXTTEXTINPUT ) );
2209 break;
2211 default:
2212 if( bFirst )
2214 rSh.GetCurAttr( rSet );
2215 bFirst = FALSE;
2218 nWhich = aIter.NextWhich();
2220 delete pFntCoreSet;
2223 /*--------------------------------------------------------------------
2224 Beschreibung:
2225 --------------------------------------------------------------------*/
2227 void SwBaseShell::GetBckColState(SfxItemSet &rSet)
2229 SwWrtShell &rSh = GetShell();
2230 SfxWhichIter aIter( rSet );
2231 USHORT nWhich = aIter.FirstWhich();
2232 int nSelType = rSh.GetSelectionType();
2234 // if ( nSelType & nsSelectionType::SEL_GRF ||
2235 if( nSelType & nsSelectionType::SEL_OLE )
2237 rSet.DisableItem( SID_BACKGROUND_COLOR );
2238 return;
2241 if ( nSelType & nsSelectionType::SEL_FRM )
2243 BOOL bParentCntProt = rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0;
2244 if (bParentCntProt)
2246 rSet.DisableItem( SID_BACKGROUND_COLOR );
2247 return;
2251 SvxBrushItem aBrushItem( RES_BACKGROUND );
2253 if( nsSelectionType::SEL_TBL_CELLS & nSelType )
2254 rSh.GetBoxBackground( aBrushItem );
2255 else
2257 SfxItemSet aCoreSet(GetPool(), RES_BACKGROUND, RES_BACKGROUND);
2258 if( nSelType & nsSelectionType::SEL_GRF || nsSelectionType::SEL_FRM & nSelType )
2259 rSh.GetFlyFrmAttr( aCoreSet );
2260 else
2261 rSh.GetCurAttr( aCoreSet );
2262 aBrushItem = (const SvxBrushItem&)aCoreSet.Get(RES_BACKGROUND);
2265 while ( nWhich )
2267 switch(nWhich)
2269 case SID_BACKGROUND_COLOR :
2271 SvxColorItem aColorItem(aBrushItem.GetColor(), SID_BACKGROUND_COLOR);
2272 rSet.Put( aColorItem, SID_BACKGROUND_COLOR );
2274 break;
2275 case SID_ATTR_BRUSH:
2276 case RES_BACKGROUND:
2277 rSet.Put( aBrushItem, GetPool().GetWhich(nWhich) );
2278 break;
2280 nWhich = aIter.NextWhich();
2284 /*--------------------------------------------------------------------
2285 Beschreibung:
2286 --------------------------------------------------------------------*/
2288 void SwBaseShell::ExecBckCol(SfxRequest& rReq)
2290 SwWrtShell &rSh = GetShell();
2291 int nSelType = rSh.GetSelectionType();
2292 if ( nSelType & nsSelectionType::SEL_OLE )
2294 return;
2297 const SfxItemSet* pArgs = rReq.GetArgs();
2298 USHORT nSlot = rReq.GetSlot();
2299 if( !pArgs && nSlot != SID_BACKGROUND_COLOR)
2300 return ;
2302 SvxBrushItem aBrushItem( RES_BACKGROUND );
2304 if( nsSelectionType::SEL_TBL_CELLS & nSelType )
2306 rSh.GetBoxBackground( aBrushItem );
2308 else
2310 SfxItemSet aCoreSet(GetPool(), RES_BACKGROUND, RES_BACKGROUND);
2311 if( (nsSelectionType::SEL_FRM & nSelType) || (nsSelectionType::SEL_GRF & nSelType) )
2312 rSh.GetFlyFrmAttr( aCoreSet );
2313 else
2314 rSh.GetCurAttr( aCoreSet );
2315 aBrushItem = (const SvxBrushItem&)aCoreSet.Get(RES_BACKGROUND);
2318 // BOOL bMsgOk = FALSE;
2320 switch (nSlot)
2322 // RES_BACKGROUND (=SID_ATTR_BRUSH) muss ueber zwei IDs
2323 // gesetzt werden:
2324 case SID_BACKGROUND_COLOR:
2326 aBrushItem.SetGraphicPos(GPOS_NONE);
2328 //Brush &rBrush = aBrushItem.GetBrush();
2329 if(pArgs)
2331 const SvxColorItem& rNewColorItem = (const SvxColorItem&)
2332 pArgs->Get(SID_BACKGROUND_COLOR);
2333 const Color& rNewColor = rNewColorItem.GetValue();
2334 aBrushItem.SetColor( rNewColor );
2335 GetView().GetViewFrame()->GetBindings().SetState(rNewColorItem);
2337 else
2339 aBrushItem.SetColor( COL_TRANSPARENT );
2340 rReq.AppendItem( SvxColorItem( Color( COL_TRANSPARENT ), nSlot ) );
2343 break;
2345 case SID_ATTR_BRUSH:
2346 case RES_BACKGROUND:
2348 const SvxBrushItem& rNewBrushItem = (const SvxBrushItem&)
2349 pArgs->Get( GetPool().GetWhich(nSlot) );
2350 aBrushItem = rNewBrushItem;
2352 break;
2353 default:
2354 // bMsgOk = FALSE;
2355 rReq.Ignore();
2356 DBG_ERROR( "Unbekannte Message bei ExecuteAttr!" );
2357 return;
2360 if( nsSelectionType::SEL_TBL_CELLS & nSelType )
2362 rSh.SetBoxBackground( aBrushItem );
2364 else if( (nsSelectionType::SEL_FRM & nSelType) ||
2365 (nsSelectionType::SEL_GRF & nSelType) )
2367 SfxItemSet aCoreSet(GetPool(), RES_BACKGROUND, RES_BACKGROUND);
2368 aCoreSet.Put( aBrushItem );
2369 // Vorlagen-AutoUpdate
2370 SwFrmFmt* pFmt = rSh.GetCurFrmFmt();
2371 if(pFmt && pFmt->IsAutoUpdateFmt())
2372 rSh.AutoUpdateFrame( pFmt, aCoreSet);
2373 else
2374 rSh.SetFlyFrmAttr( aCoreSet );
2376 else
2378 SwTxtFmtColl* pColl = rSh.GetCurTxtFmtColl();
2379 if( pColl && pColl->IsAutoUpdateFmt())
2381 SfxItemSet aSet(GetPool(), RES_BACKGROUND, RES_BACKGROUND );
2382 aSet.Put(aBrushItem);
2383 rSh.AutoUpdatePara( pColl, aSet);
2385 else
2386 rSh.SetAttr( aBrushItem );
2389 rReq.Done();
2392 /*--------------------------------------------------------------------
2393 Beschreibung:
2394 --------------------------------------------------------------------*/
2397 void SwBaseShell::GetBorderState(SfxItemSet &rSet)
2399 SwWrtShell &rSh = GetShell();
2400 // Tabellenzelle(n) selektiert?
2401 BOOL bPrepare = TRUE;
2402 BOOL bTableMode = rSh.IsTableMode();
2403 if ( bTableMode )
2405 SfxItemSet aCoreSet( GetPool(),
2406 RES_BOX, RES_BOX,
2407 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 );
2408 SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
2409 aCoreSet.Put( aBoxInfo );
2410 rSh.GetTabBorders( aCoreSet );
2411 rSet.Put( aCoreSet );
2413 else if ( rSh.IsFrmSelected() )
2415 SwFlyFrmAttrMgr aMgr( FALSE, &rSh, FRMMGR_TYPE_NONE );
2416 rSet.Put( aMgr.GetAttrSet() );
2417 bPrepare = FALSE;
2419 else
2420 // Umrandungsattribute ganz normal ueber Shell holen
2421 rSh.GetCurAttr( rSet );
2422 if ( bPrepare )
2423 ::PrepareBoxInfo( rSet, rSh );
2424 // switch the border toolbox controller mode
2425 rSet.Put( SfxBoolItem( SID_BORDER_REDUCED_MODE, !bTableMode ));
2428 /*--------------------------------------------------------------------
2429 Beschreibung:
2430 --------------------------------------------------------------------*/
2433 void SwBaseShell::ExecDlg(SfxRequest &rReq)
2435 SwWrtShell &rSh = GetShell();
2436 Window *pMDI = &GetView().GetViewFrame()->GetWindow();
2437 //Damit aus dem Basic keine Dialoge fuer Hintergrund-Views aufgerufen werden:
2438 BOOL bBackground = (&GetView() != GetActiveView());
2439 const SfxPoolItem* pItem = 0;
2440 const SfxItemSet* pArgs = rReq.GetArgs();
2442 USHORT nSlot = rReq.GetSlot();
2443 const SfxItemSet* pOutSet = 0;
2444 bool bDone = false;
2445 if(pArgs)
2446 pArgs->GetItemState( GetPool().GetWhich(nSlot), FALSE, &pItem );
2448 switch ( nSlot )
2450 case FN_FORMAT_PAGE_COLUMN_DLG:
2451 case FN_FORMAT_PAGE_DLG:
2453 if( !bBackground )
2455 const USHORT nCurIdx = rSh.GetCurPageDesc();
2456 const SwPageDesc& rPageDesc = rSh.GetPageDesc( nCurIdx );
2457 //temp. View, weil die Shell nach dem Dialog nicht mehr gueltig sein muss
2458 //z.B. Kopfzeile ausschalten
2459 SwView& rTempView = GetView();
2460 rTempView.GetDocShell()->FormatPage(rPageDesc.GetName(),
2461 nSlot == FN_FORMAT_PAGE_COLUMN_DLG,
2462 &rSh );
2463 rTempView.InvalidateRulerPos();
2466 break;
2467 case FN_FORMAT_BORDER_DLG:
2469 SfxItemSet aSet( rSh.GetAttrPool(),
2470 RES_BOX , RES_SHADOW,
2471 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
2472 0 );
2473 SfxAbstractDialog * pDlg = 0;
2474 // Tabellenzelle(n) selektiert?
2475 if ( rSh.IsTableMode() )
2477 // Umrandungattribute Get/SetTabBorders() setzen
2478 ::PrepareBoxInfo( aSet, rSh );
2479 rSh.GetTabBorders( aSet );
2480 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
2481 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
2483 pDlg = pFact->CreateSwBorderDlg( pMDI, aSet, SW_BORDER_MODE_TABLE, RC_DLG_SWBORDERDLG );
2484 DBG_ASSERT(pDlg, "Dialogdiet fail!");
2485 if ( pDlg->Execute() == RET_OK )
2487 rSh.SetTabBorders( *pDlg->GetOutputItemSet() );
2488 pOutSet = pDlg->GetOutputItemSet();
2491 else if ( rSh.IsFrmSelected() )
2493 // Umrandungsattribute ueber Frame-Manager setzen
2494 SwFlyFrmAttrMgr aMgr( FALSE, &rSh, FRMMGR_TYPE_NONE );
2495 aSet.Put( aMgr.GetAttrSet() );
2497 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
2498 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
2500 pDlg = pFact->CreateSwBorderDlg( pMDI, aSet, SW_BORDER_MODE_FRAME, RC_DLG_SWBORDERDLG );
2501 DBG_ASSERT(pDlg, "Dialogdiet fail!");
2502 if ( pDlg->Execute() == RET_OK )
2504 aMgr.SetAttrSet( *pDlg->GetOutputItemSet() );
2505 aMgr.UpdateFlyFrm();
2506 pOutSet = pDlg->GetOutputItemSet();
2509 else
2511 // Umrandungsattribute ganz normal ueber Shell setzen
2512 rSh.GetCurAttr( aSet );
2513 ::PrepareBoxInfo( aSet, rSh );
2515 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
2516 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
2518 pDlg = pFact->CreateSwBorderDlg( pMDI, aSet, SW_BORDER_MODE_PARA, RC_DLG_SWBORDERDLG );
2519 DBG_ASSERT(pDlg, "Dialogdiet fail!");
2520 if ( pDlg->Execute() == RET_OK )
2522 rSh.SetAttr( *pDlg->GetOutputItemSet() );
2523 pOutSet = pDlg->GetOutputItemSet();
2526 if(pOutSet)
2528 rReq.Done(*pOutSet);
2529 bDone = true;
2531 delete pDlg;
2533 break;
2534 case FN_FORMAT_BACKGROUND_DLG:
2536 SfxItemSet aSet( rSh.GetAttrPool(),
2537 RES_BACKGROUND, RES_BACKGROUND );
2539 SfxAbstractDialog * pDlg = 0;
2540 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
2541 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
2544 // Tabellenzelle(n) selektiert?
2545 if ( rSh.IsTableMode() )
2547 //Hintergrundattribute der Tabelle holen und in den Set packen
2548 SvxBrushItem aBrush(RES_BACKGROUND);
2549 rSh.GetBoxBackground( aBrush );
2550 pDlg = pFact->CreateSfxDialog( pMDI, aSet,
2551 rView.GetViewFrame()->GetFrame()->GetFrameInterface(),
2552 RC_SWDLG_BACKGROUND );
2553 DBG_ASSERT(pDlg, "Dialogdiet fail!");
2554 aSet.Put( aBrush );
2555 if ( pDlg->Execute() == RET_OK )
2557 //aBrush = (SvxBrushItem) pDlg->GetOutputItemSet()->Get( RES_BACKGROUND );
2559 rSh.SetBoxBackground( (SvxBrushItem&)
2560 pDlg->GetOutputItemSet()->Get( RES_BACKGROUND ));
2561 pOutSet = pDlg->GetOutputItemSet();
2564 else if ( rSh.IsFrmSelected() )
2567 rSh.GetFlyFrmAttr( aSet );
2569 pDlg = pFact->CreateSfxDialog( pMDI, aSet,
2570 rView.GetViewFrame()->GetFrame()->GetFrameInterface(),
2571 RC_SWDLG_BACKGROUND );
2572 DBG_ASSERT(pDlg, "Dialogdiet fail!");
2573 if ( pDlg->Execute() == RET_OK )
2575 rSh.SetFlyFrmAttr((SfxItemSet &) *pDlg->GetOutputItemSet() );
2576 pOutSet = pDlg->GetOutputItemSet();
2579 else
2581 // Umrandungsattribute ganz normal ueber Shell setzen
2582 rSh.GetCurAttr( aSet );
2584 pDlg = pFact->CreateSfxDialog( pMDI, aSet,
2585 rView.GetViewFrame()->GetFrame()->GetFrameInterface(),
2586 RC_SWDLG_BACKGROUND );
2587 DBG_ASSERT(pDlg, "Dialogdiet fail!");
2588 if ( pDlg->Execute() == RET_OK )
2590 rSh.SetAttr( *pDlg->GetOutputItemSet() );
2591 pOutSet = pDlg->GetOutputItemSet();
2594 if(pOutSet)
2596 rReq.Done(*pOutSet);
2597 bDone = true;
2599 delete pDlg;
2602 break;
2603 default:DBG_ERROR("falscher Dispatcher (basesh.cxx)");
2605 if(!bDone)
2606 rReq.Done();
2609 // ----------------------------------------------------------------------------
2612 SwWrtShell& SwBaseShell::GetShell()
2614 return rView.GetWrtShell();
2617 // ----------------------------------------------------------------------------
2619 SwWrtShell* SwBaseShell::GetShellPtr()
2621 return rView.GetWrtShellPtr();
2624 // ----------------------------------------------------------------------------
2626 void SwBaseShell::InsertTable( SfxRequest& _rRequest )
2628 const SfxItemSet* pArgs = _rRequest.GetArgs();
2629 SwWrtShell& rSh = GetShell();
2631 if ( !( rSh.GetFrmType( 0, TRUE ) & FRMTYPE_FOOTNOTE ) )
2633 SwView &rTempView = GetView(); // Da GetView() nach Shellwechsel nicht mehr geht
2634 BOOL bHTMLMode = 0 != (::GetHtmlMode(rTempView.GetDocShell())&HTMLMODE_ON);
2635 BOOL bCallEndUndo = FALSE;
2637 if( !pArgs && rSh.IsSelection() && !rSh.IsInClickToEdit() &&
2638 !rSh.IsTableMode() )
2640 const SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
2641 SwInsertTableOptions aInsTblOpts = pModOpt->GetInsTblFlags(bHTMLMode);
2643 rSh.StartUndo(UNDO_INSTABLE);
2644 bCallEndUndo = TRUE;
2646 BOOL bInserted = rSh.TextToTable( aInsTblOpts, '\t', text::HoriOrientation::FULL );
2647 rSh.EnterStdMode();
2648 if (bInserted)
2649 rTempView.AutoCaption(TABLE_CAP);
2650 _rRequest.Done();
2652 else
2654 USHORT nCols = 0;
2655 USHORT nRows = 0;
2656 SwInsertTableOptions aInsTblOpts( tabopts::ALL_TBL_INS_ATTR, 1 );
2657 String aTableName, aAutoName;
2658 SwTableAutoFmt* pTAFmt = 0;
2660 if( pArgs && pArgs->Count() >= 2 )
2662 SFX_REQUEST_ARG( _rRequest, pName, SfxStringItem, FN_INSERT_TABLE, sal_False );
2663 SFX_REQUEST_ARG( _rRequest, pCols, SfxUInt16Item, SID_ATTR_TABLE_COLUMN, sal_False );
2664 SFX_REQUEST_ARG( _rRequest, pRows, SfxUInt16Item, SID_ATTR_TABLE_ROW, sal_False );
2665 SFX_REQUEST_ARG( _rRequest, pFlags, SfxInt32Item, FN_PARAM_1, sal_False );
2666 SFX_REQUEST_ARG( _rRequest, pAuto, SfxStringItem, FN_PARAM_2, sal_False );
2668 if ( pName )
2669 aTableName = pName->GetValue();
2670 if ( pCols )
2671 nCols = pCols->GetValue();
2672 if ( pRows )
2673 nRows = pRows->GetValue();
2674 if ( pAuto )
2676 aAutoName = pAuto->GetValue();
2677 if ( aAutoName.Len() )
2679 SwTableAutoFmtTbl aTableTbl;
2680 aTableTbl.Load();
2681 for ( USHORT n=0; n<aTableTbl.Count(); n++ )
2683 if ( aTableTbl[n]->GetName() == aAutoName )
2685 pTAFmt = new SwTableAutoFmt( *aTableTbl[n] );
2686 break;
2692 if ( pFlags )
2693 aInsTblOpts.mnInsMode = (USHORT) pFlags->GetValue();
2694 else
2696 const SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
2697 aInsTblOpts = pModOpt->GetInsTblFlags(bHTMLMode);
2701 if( !nCols || !nRows )
2703 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
2704 DBG_ASSERT(pFact, "Dialogdiet fail!");
2705 AbstractInsTableDlg* pDlg = pFact->CreateInsTableDlg( DLG_INSERT_TABLE, rTempView );
2706 DBG_ASSERT(pDlg, "Dialogdiet fail!");
2707 if( RET_OK == pDlg->Execute() )
2709 pDlg->GetValues( aTableName, nRows, nCols, aInsTblOpts, aAutoName, pTAFmt );
2711 else
2712 _rRequest.Ignore();
2713 delete pDlg;
2716 if( nCols && nRows )
2718 // record before shell change
2719 _rRequest.AppendItem( SfxStringItem( FN_INSERT_TABLE, aTableName ) );
2720 if ( aAutoName.Len() )
2721 _rRequest.AppendItem( SfxStringItem( FN_PARAM_2, aAutoName ) );
2722 _rRequest.AppendItem( SfxUInt16Item( SID_ATTR_TABLE_COLUMN, nCols ) );
2723 _rRequest.AppendItem( SfxUInt16Item( SID_ATTR_TABLE_ROW, nRows ) );
2724 _rRequest.AppendItem( SfxInt32Item( FN_PARAM_1, (sal_Int32) aInsTblOpts.mnInsMode ) );
2725 _rRequest.Done();
2727 rSh.StartUndo(UNDO_INSTABLE);
2728 bCallEndUndo = TRUE;
2730 rSh.StartAllAction();
2731 if( rSh.HasSelection() )
2732 rSh.DelRight();
2734 rSh.InsertTable( aInsTblOpts, nRows, nCols, text::HoriOrientation::FULL, pTAFmt );
2735 rSh.MoveTable( fnTablePrev, fnTableStart );
2737 if( aTableName.Len() && !rSh.GetTblStyle( aTableName ) )
2738 rSh.GetTableFmt()->SetName( aTableName );
2740 rSh.EndAllAction();
2741 rTempView.AutoCaption(TABLE_CAP);
2743 delete pTAFmt;
2746 if( bCallEndUndo )
2748 SwRewriter aRewriter;
2750 if (rSh.GetTableFmt())
2752 aRewriter.AddRule(UNDO_ARG1, SW_RES(STR_START_QUOTE));
2753 aRewriter.AddRule(UNDO_ARG2, rSh.GetTableFmt()->GetName());
2754 aRewriter.AddRule(UNDO_ARG3, SW_RES(STR_END_QUOTE));
2757 rSh.EndUndo(UNDO_INSTABLE, &aRewriter); // wegen moegl. Shellwechsel
2762 // ----------------------------------------------------------------------------
2764 void SwBaseShell::GetGalleryState( SfxItemSet &rSet )
2766 SwWrtShell &rSh = GetShell();
2767 SfxWhichIter aIter( rSet );
2768 USHORT nWhich = aIter.FirstWhich();
2769 switch ( nWhich )
2771 case SID_GALLERY_BG_BRUSH:
2773 int nSel = rSh.GetSelectionType();
2774 SfxStringListItem aLst( nWhich );
2775 List *pLst = aLst.GetList();
2776 nParagraphPos = nGraphicPos = nOlePos = nFramePos = nTablePos =
2777 nTableRowPos = nTableCellPos = nPagePos =
2778 nHeaderPos = nFooterPos = 0;
2779 BYTE nPos = 1;
2780 pLst->Insert( (void*) new SW_RESSTR( STR_SWBG_PAGE ), pLst->Count() );
2781 nPagePos = nPos++;
2782 USHORT nHtmlMode = ::GetHtmlMode(GetView().GetDocShell());
2783 BOOL bHtmlMode = 0 != (nHtmlMode & HTMLMODE_ON);
2785 if ( (!bHtmlMode || (nHtmlMode & HTMLMODE_FULL_STYLES)) &&
2786 (nSel & nsSelectionType::SEL_TXT) )
2788 pLst->Insert( (void*) new SW_RESSTR( STR_SWBG_PARAGRAPH ), pLst->Count() );
2789 nParagraphPos = nPos++;
2791 if ( (!bHtmlMode || (nHtmlMode & HTMLMODE_SOME_STYLES)) &&
2792 nSel & (nsSelectionType::SEL_TBL|nsSelectionType::SEL_TBL_CELLS) )
2794 pLst->Insert( (void*) new SW_RESSTR( STR_SWBG_TABLE ), pLst->Count() );
2795 nTablePos = nPos++;
2797 if(!bHtmlMode)
2799 pLst->Insert( (void*) new SW_RESSTR( STR_SWBG_TABLE_ROW ), pLst->Count() );
2800 nTableRowPos = nPos++;
2803 pLst->Insert( (void*) new SW_RESSTR( STR_SWBG_TABLE_CELL), pLst->Count() );
2804 nTableCellPos = nPos++;
2806 if(!bHtmlMode)
2808 if ( nSel & nsSelectionType::SEL_FRM )
2810 pLst->Insert( (void*) new SW_RESSTR( STR_SWBG_FRAME ), pLst->Count() );
2811 nFramePos = nPos++;
2813 if ( nSel & nsSelectionType::SEL_GRF )
2815 pLst->Insert( (void*) new SW_RESSTR( STR_SWBG_GRAPHIC ), pLst->Count() );
2816 nGraphicPos = nPos++;
2818 if ( nSel & nsSelectionType::SEL_OLE )
2820 pLst->Insert( (void*) new SW_RESSTR( STR_SWBG_OLE ), pLst->Count() );
2821 nOlePos = nPos++;
2823 const USHORT nType = rSh.GetFrmType(0,TRUE);
2824 if ( nType & FRMTYPE_HEADER )
2826 pLst->Insert( (void*) new SW_RESSTR( STR_SWBG_HEADER ), pLst->Count() );
2827 nHeaderPos = nPos++;
2829 if ( nType & FRMTYPE_FOOTER )
2831 pLst->Insert( (void*) new SW_RESSTR( STR_SWBG_FOOTER ), pLst->Count() );
2832 nFooterPos = nPos;
2835 if ( pLst->Count() )
2836 rSet.Put( aLst );
2837 else
2838 rSet.DisableItem( nWhich );
2839 break;
2845 void SwBaseShell::ExecuteGallery(SfxRequest &rReq)
2847 SwWrtShell &rSh = GetShell();
2848 rSh.StartAction();
2849 const SfxItemSet* pArgs = rReq.GetArgs();
2850 USHORT nSlot = rReq.GetSlot();
2851 switch(nSlot)
2853 case SID_GALLERY_BG_BRUSH:
2855 int nSel = rSh.GetSelectionType();
2856 if ( nSel & nsSelectionType::SEL_DRW_TXT )
2857 break;
2859 BYTE nPos = (BYTE)((SfxUInt16Item &)pArgs->Get(SID_GALLERY_BG_POS)).GetValue();
2860 ++nPos;
2862 SvxBrushItem aBrush( (SvxBrushItem&)pArgs->Get(SID_GALLERY_BG_BRUSH));
2863 aBrush.SetWhich( RES_BACKGROUND );
2864 if ( nPos == nParagraphPos )
2865 rSh.SetAttr( aBrush );
2866 else if ( nPos == nTablePos )
2867 rSh.SetTabBackground( aBrush );
2868 else if ( nPos == nTableRowPos )
2869 rSh.SetRowBackground( aBrush );
2870 else if ( nPos == nTableCellPos )
2871 rSh.SetBoxBackground( aBrush );
2872 else if ( nPos == nFramePos || nPos == nGraphicPos || nPos == nOlePos )
2874 SfxItemSet aCoreSet(GetPool(), RES_BACKGROUND, RES_BACKGROUND);
2875 aCoreSet.Put( aBrush );
2876 rSh.SetFlyFrmAttr( aCoreSet );
2878 else if ( nPos == nPagePos || nPos == nHeaderPos || nPos == nFooterPos )
2880 USHORT nDesc = rSh.GetCurPageDesc();
2881 SwPageDesc aDesc( rSh.GetPageDesc( nDesc ) );
2882 if ( nPos == nPagePos )
2883 aDesc.GetMaster().SetFmtAttr( aBrush );
2884 else if ( nPos == nHeaderPos )
2886 SwFmtHeader aHead( aDesc.GetMaster().GetHeader() );
2887 aHead.GetHeaderFmt()->SetFmtAttr( aBrush );
2888 aDesc.GetMaster().SetFmtAttr( aHead );
2890 else if ( nPos == nFooterPos )
2892 SwFmtFooter aFoot( aDesc.GetMaster().GetFooter() );
2893 aFoot.GetFooterFmt()->SetFmtAttr( aBrush );
2894 aDesc.GetMaster().SetFmtAttr( aFoot );
2896 rSh.ChgPageDesc( nDesc, aDesc );
2898 break;
2901 rSh.EndAction();
2902 rReq.Done();
2905 void SwBaseShell::ExecField( SfxRequest& rReq )
2907 USHORT nSlot = rReq.GetSlot();
2908 switch( nSlot )
2910 case FN_CHANGE_DBFIELD:
2912 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
2913 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
2915 VclAbstractDialog* pDlg = pFact->CreateSwChangeDBDlg(GetView(), DLG_CHANGE_DB );
2916 DBG_ASSERT(pDlg, "Dialogdiet fail!");
2917 pDlg->Execute();
2918 delete pDlg;
2920 break;
2921 default:
2922 ASSERT(FALSE, falscher Dispatcher);