xref: /trunk/main/sw/source/ui/shells/frmsh.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1  /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sw.hxx"
30 
31 
32 #include <hintids.hxx>
33 #include <svl/whiter.hxx>
34 #include <svtools/imapobj.hxx>
35 #include <svl/srchitem.hxx>
36 #include <svtools/imap.hxx>
37 #include <sfx2/viewfrm.hxx>
38 #include <basic/sbstar.hxx>
39 #include <svl/rectitem.hxx>
40 #include <svl/ptitem.hxx>
41 #include <svl/stritem.hxx>
42 #include <editeng/colritem.hxx>
43 #include <editeng/bolnitem.hxx>
44 #include <editeng/boxitem.hxx>
45 #include <editeng/protitem.hxx>
46 #include <sfx2/dispatch.hxx>
47 #include <sfx2/request.hxx>
48 #include <sfx2/objface.hxx>
49 #include <svx/hlnkitem.hxx>
50 // --> OD 2009-07-07 #i73249#
51 #include <svx/svdview.hxx>
52 #include <vcl/msgbox.hxx>
53 // <--
54 
55 #include <doc.hxx>
56 #include <fmturl.hxx>
57 #include <fmtclds.hxx>
58 #include <fmtcnct.hxx>
59 #include <swmodule.hxx>
60 #include <wrtsh.hxx>
61 #include <wview.hxx>
62 #include <frmatr.hxx>
63 #include <uitool.hxx>
64 #include <frmfmt.hxx>
65 #include <frmsh.hxx>
66 #include <frmmgr.hxx>
67 #include <frmdlg.hxx>
68 #include <swevent.hxx>
69 #include <usrpref.hxx>
70 #include <edtwin.hxx>
71 #include <swdtflvr.hxx>
72 #include <swwait.hxx>
73 #include <docstat.hxx>
74 #include <IDocumentStatistics.hxx>
75 
76 #include <comphelper/processfactory.hxx>
77 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
78 
79 #include <helpid.h>
80 #include <cmdid.h>
81 #include <cfgitems.hxx>
82 #include <globals.hrc>
83 #include <popup.hrc>
84 #include <shells.hrc>
85 #include "swabstdlg.hxx"
86 #include "misc.hrc"
87 // --> OD 2009-07-14 #i73249#
88 #include <svx/dialogs.hrc>
89 // <--
90 
91 using namespace ::com::sun::star;
92 using namespace ::com::sun::star::uno;
93 
94 // Prototypen ------------------------------------------------------------
95 
96 void lcl_FrmGetMaxLineWidth(const SvxBorderLine* pBorderLine, SvxBorderLine& rBorderLine);
97 const SwFrmFmt* lcl_GetFrmFmtByName(SwWrtShell& rSh, const String& rName)
98 {
99     sal_uInt16 nCount = rSh.GetFlyCount(FLYCNTTYPE_FRM);
100     for( sal_uInt16 i = 0; i < nCount; i++)
101     {
102         const SwFrmFmt* pFmt = rSh.GetFlyNum(i, FLYCNTTYPE_FRM);
103         if(pFmt->GetName() == rName)
104             return pFmt;
105     }
106     return 0;
107 }
108 
109 #define SwFrameShell
110 #include <sfx2/msg.hxx>
111 #include "swslots.hxx"
112 
113 SFX_IMPL_INTERFACE(SwFrameShell, SwBaseShell, SW_RES(STR_SHELLNAME_FRAME))
114 {
115     SFX_POPUPMENU_REGISTRATION(SW_RES(MN_FRM_POPUPMENU));
116     SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_FRAME_TOOLBOX));
117 }
118 
119 
120 
121 void SwFrameShell::Execute(SfxRequest &rReq)
122 {
123     //Erstmal die, die keinen FrmMgr benoetigen.
124     SwWrtShell &rSh = GetShell();
125     sal_Bool bMore = sal_False;
126     const SfxItemSet* pArgs = rReq.GetArgs();
127     const SfxPoolItem* pItem;
128     sal_uInt16 nSlot = rReq.GetSlot();
129 
130     switch ( nSlot )
131     {
132         case FN_FRAME_TO_ANCHOR:
133             if ( rSh.IsFrmSelected() )
134             {
135                 rSh.GotoFlyAnchor();
136                 rSh.EnterStdMode();
137                 rSh.CallChgLnk();
138             }
139             break;
140         case SID_FRAME_TO_TOP:
141             rSh.SelectionToTop();
142             break;
143 
144         case SID_FRAME_TO_BOTTOM:
145             rSh.SelectionToBottom();
146             break;
147 
148         case FN_FRAME_UP:
149             rSh.SelectionToTop( sal_False );
150             break;
151 
152         case FN_FRAME_DOWN:
153             rSh.SelectionToBottom( sal_False );
154             break;
155         case FN_INSERT_FRAME:
156             if (!pArgs)
157             {
158                 // Rahmen existiert bereits, Rahmendialog zur Bearbeitung oeffnen
159                 SfxUInt16Item aDefPage(FN_FORMAT_FRAME_DLG, TP_COLUMN);
160                 rSh.GetView().GetViewFrame()->GetDispatcher()->Execute( FN_FORMAT_FRAME_DLG,
161                                 SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD,
162                                 &aDefPage, 0L );
163 
164             }
165             else
166             {
167                 // Rahmen existiert bereits, nur Spaltenanzahl wird geaendert
168                 sal_uInt16 nCols = 1;
169                 if(pArgs->GetItemState(SID_ATTR_COLUMNS, sal_False, &pItem) == SFX_ITEM_SET)
170                     nCols = ((SfxUInt16Item *)pItem)->GetValue();
171 
172                 SfxItemSet aSet(GetPool(),RES_COL,RES_COL);
173                 rSh.GetFlyFrmAttr( aSet );
174                 SwFmtCol aCol((const SwFmtCol&)aSet.Get(RES_COL));
175                 // GutterWidth wird nicht immer uebergeben, daher erst besorgen (siehe view2: Execute auf diesen Slot)
176                 sal_uInt16 nGutterWidth = aCol.GetGutterWidth();
177                 if(!nCols )
178                     nCols++;
179                 aCol.Init(nCols, nGutterWidth, aCol.GetWishWidth());
180                 aSet.Put(aCol);
181                 // Vorlagen-AutoUpdate
182                 SwFrmFmt* pFmt = rSh.GetCurFrmFmt();
183                 if(pFmt && pFmt->IsAutoUpdateFmt())
184                 {
185                     rSh.AutoUpdateFrame(pFmt, aSet);
186                 }
187                 else
188                 {
189                     rSh.StartAllAction();
190                     rSh.SetFlyFrmAttr( aSet );
191                     rSh.SetModified();
192                     rSh.EndAllAction();
193                 }
194 
195             }
196             return;
197 
198         case SID_HYPERLINK_SETLINK:
199         {
200             if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_HYPERLINK_SETLINK, sal_False, &pItem))
201             {
202                 const SvxHyperlinkItem& rHLinkItem = *(const SvxHyperlinkItem *)pItem;
203                 const String& rURL = rHLinkItem.GetURL();
204                 const String& rTarget = rHLinkItem.GetTargetFrame();
205 
206                 SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL );
207                 rSh.GetFlyFrmAttr( aSet );
208                 SwFmtURL aURL( (SwFmtURL&)aSet.Get( RES_URL ) );
209 
210                 String sOldName(rHLinkItem.GetName());
211                 String sFlyName(rSh.GetFlyName());
212                 if (sOldName.ToUpperAscii() != sFlyName.ToUpperAscii())
213                 {
214                     String sName(sOldName);
215                     sal_uInt16 i = 1;
216                     while (rSh.FindFlyByName(sName))
217                     {
218                         sName = sOldName;
219                         sName += '_';
220                         sName += String::CreateFromInt32(i++);
221                     }
222                     rSh.SetFlyName(sName);
223                 }
224                 aURL.SetURL( rURL, sal_False );
225                 aURL.SetTargetFrameName(rTarget);
226 
227                 aSet.Put( aURL );
228                 rSh.SetFlyFrmAttr( aSet );
229             }
230         }
231         break;
232 
233         case FN_FRAME_CHAIN:
234             rSh.GetView().GetEditWin().SetChainMode( !rSh.GetView().GetEditWin().IsChainMode() );
235             break;
236 
237         case FN_FRAME_UNCHAIN:
238             rSh.Unchain( (SwFrmFmt&)*rSh.GetFlyFrmFmt() );
239             GetView().GetViewFrame()->GetBindings().Invalidate(FN_FRAME_CHAIN);
240             break;
241         case FN_FORMAT_FOOTNOTE_DLG:
242         {
243             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
244             DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
245 
246             VclAbstractDialog* pDlg = pFact->CreateSwFootNoteOptionDlg( GetView().GetWindow(), GetView().GetWrtShell(), DLG_DOC_FOOTNOTE );
247             DBG_ASSERT(pDlg, "Dialogdiet fail!");
248             pDlg->Execute();
249             delete pDlg;
250             break;
251         }
252         case FN_NUMBERING_OUTLINE_DLG:
253         {
254             SfxItemSet aTmp(GetPool(), FN_PARAM_1, FN_PARAM_1);
255             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
256             DBG_ASSERT(pFact, "Dialogdiet fail!");
257             SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_TAB_OUTLINE,
258                                                         GetView().GetWindow(), &aTmp, GetView().GetWrtShell());
259             DBG_ASSERT(pDlg, "Dialogdiet fail!");
260             pDlg->Execute();
261             delete pDlg;
262             rReq.Done();
263             break;
264         }
265         case SID_OPEN_XML_FILTERSETTINGS:
266         {
267             try
268             {
269                 uno::Reference < ui::dialogs::XExecutableDialog > xDialog(::comphelper::getProcessServiceFactory()->createInstance(rtl::OUString::createFromAscii("com.sun.star.comp.ui.XSLTFilterDialog")), uno::UNO_QUERY);
270                 if( xDialog.is() )
271                 {
272                     xDialog->execute();
273                 }
274             }
275             catch( uno::Exception& )
276             {
277             }
278             rReq.Ignore ();
279         }
280         break;
281         case FN_WORDCOUNT_DIALOG:
282         {
283             SwDocStat aCurr;
284             SwDocStat aDocStat( rSh.getIDocumentStatistics()->GetDocStat() );
285             {
286                 SwWait aWait( *GetView().GetDocShell(), sal_True );
287                 rSh.StartAction();
288                 rSh.CountWords( aCurr );
289                 rSh.UpdateDocStat( aDocStat );
290                 rSh.EndAction();
291             }
292 
293             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
294             DBG_ASSERT(pFact, "Dialogdiet fail!");
295             AbstractSwWordCountDialog* pDialog = pFact->CreateSwWordCountDialog( GetView().GetWindow() );
296             pDialog->SetValues(aCurr, aDocStat );
297             pDialog->Execute();
298             delete pDialog;
299         }
300         break;
301         default: bMore = sal_True;
302     }
303 
304     if ( !bMore )
305     {
306         return;
307     }
308 
309     SwFlyFrmAttrMgr aMgr( sal_False, &rSh, FRMMGR_TYPE_NONE );
310     sal_Bool bUpdateMgr = sal_True;
311     sal_Bool bCopyToFmt = sal_False;
312     switch ( nSlot )
313     {
314         case SID_OBJECT_ALIGN_MIDDLE:
315         case FN_FRAME_ALIGN_VERT_CENTER:
316             aMgr.SetVertOrientation( text::VertOrientation::CENTER );
317             break;
318         case SID_OBJECT_ALIGN_DOWN :
319         case FN_FRAME_ALIGN_VERT_BOTTOM:
320             aMgr.SetVertOrientation( text::VertOrientation::BOTTOM );
321             break;
322         case SID_OBJECT_ALIGN_UP :
323         case FN_FRAME_ALIGN_VERT_TOP:
324             aMgr.SetVertOrientation( text::VertOrientation::TOP );
325             break;
326 
327         case FN_FRAME_ALIGN_VERT_CHAR_CENTER:
328             aMgr.SetVertOrientation( text::VertOrientation::CHAR_CENTER );
329             break;
330 
331         case FN_FRAME_ALIGN_VERT_CHAR_BOTTOM:
332             aMgr.SetVertOrientation( text::VertOrientation::CHAR_BOTTOM );
333             break;
334 
335         case FN_FRAME_ALIGN_VERT_CHAR_TOP:
336             aMgr.SetVertOrientation( text::VertOrientation::CHAR_TOP );
337             break;
338 
339         case FN_FRAME_ALIGN_VERT_ROW_CENTER:
340             aMgr.SetVertOrientation( text::VertOrientation::LINE_CENTER );
341             break;
342 
343         case FN_FRAME_ALIGN_VERT_ROW_BOTTOM:
344             aMgr.SetVertOrientation( text::VertOrientation::LINE_BOTTOM );
345             break;
346 
347         case FN_FRAME_ALIGN_VERT_ROW_TOP:
348             aMgr.SetVertOrientation( text::VertOrientation::LINE_TOP );
349             break;
350         case SID_OBJECT_ALIGN_CENTER :
351         case FN_FRAME_ALIGN_HORZ_CENTER:
352             aMgr.SetHorzOrientation( text::HoriOrientation::CENTER );
353             break;
354         case SID_OBJECT_ALIGN_RIGHT:
355         case FN_FRAME_ALIGN_HORZ_RIGHT:
356             aMgr.SetHorzOrientation( text::HoriOrientation::RIGHT );
357             break;
358         case SID_OBJECT_ALIGN_LEFT:
359         case FN_FRAME_ALIGN_HORZ_LEFT:
360             aMgr.SetHorzOrientation( text::HoriOrientation::LEFT );
361             break;
362 
363         case FN_SET_FRM_POSITION:
364         {
365             aMgr.SetAbsPos(((SfxPointItem &)pArgs->Get
366                                 (FN_SET_FRM_POSITION)).GetValue());
367         }
368         break;
369         case SID_ATTR_BRUSH:
370         {
371             if(pArgs)
372             {
373                 aMgr.SetAttrSet( *pArgs );
374                 bCopyToFmt = sal_True;
375             }
376         }
377         break;
378         case SID_ATTR_ULSPACE:
379         case SID_ATTR_LRSPACE:
380         {
381             if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(GetPool().GetWhich(nSlot), sal_False, &pItem))
382             {
383                 aMgr.SetAttrSet( *pArgs );
384                 if(SID_ATTR_ULSPACE == nSlot && SID_ATTR_ULSPACE == nSlot)
385                     bCopyToFmt = sal_True;
386             }
387         }
388         break;
389         case FN_FORMAT_FRAME_DLG:
390         {
391             const int nSel = rSh.GetSelectionType();
392             if (nSel & nsSelectionType::SEL_GRF)
393             {
394                 rSh.GetView().GetViewFrame()->GetDispatcher()->Execute(FN_FORMAT_GRAFIC_DLG);
395                 bUpdateMgr = sal_False;
396             }
397             else
398             {
399                 SfxItemSet aSet(GetPool(),  RES_FRMATR_BEGIN,       RES_FRMATR_END-1,
400                                             SID_ATTR_BORDER_INNER,  SID_ATTR_BORDER_INNER,
401                                             FN_GET_PRINT_AREA,      FN_GET_PRINT_AREA,
402                                             SID_ATTR_PAGE_SIZE,     SID_ATTR_PAGE_SIZE,
403                                             SID_ATTR_BRUSH,         SID_ATTR_BRUSH,
404                                             SID_ATTR_LRSPACE,       SID_ATTR_ULSPACE,
405                                             FN_SURROUND,            FN_HORI_ORIENT,
406                                             FN_SET_FRM_NAME,        FN_SET_FRM_NAME,
407                                             FN_KEEP_ASPECT_RATIO,   FN_KEEP_ASPECT_RATIO,
408                                             SID_DOCFRAME,           SID_DOCFRAME,
409                                             SID_HTML_MODE,          SID_HTML_MODE,
410                                             FN_SET_FRM_ALT_NAME,    FN_SET_FRM_ALT_NAME,
411                                             FN_PARAM_CHAIN_PREVIOUS, FN_PARAM_CHAIN_NEXT,
412                                             FN_OLE_IS_MATH,         FN_OLE_IS_MATH,
413                                             FN_MATH_BASELINE_ALIGNMENT, FN_MATH_BASELINE_ALIGNMENT,
414                                             0);
415 
416                 const SwViewOption* pVOpt = rSh.GetViewOptions();
417                 if(nSel & nsSelectionType::SEL_OLE)
418                     aSet.Put( SfxBoolItem(FN_KEEP_ASPECT_RATIO, pVOpt->IsKeepRatio()) );
419                 aSet.Put(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(GetView().GetDocShell())));
420                 aSet.Put(SfxStringItem(FN_SET_FRM_NAME, rSh.GetFlyName()));
421                 if( nSel & nsSelectionType::SEL_OLE )
422                 {
423                     // --> OD 2009-07-13 #i73249#
424 //                    aSet.Put(SfxStringItem(FN_SET_FRM_ALT_NAME, rSh.GetAlternateText()));
425                     aSet.Put( SfxStringItem( FN_SET_FRM_ALT_NAME, rSh.GetObjTitle() ) );
426                     // <--
427                 }
428 
429                 const SwRect &rPg = rSh.GetAnyCurRect(RECT_PAGE);
430                 SwFmtFrmSize aFrmSize(ATT_VAR_SIZE, rPg.Width(), rPg.Height());
431                 aFrmSize.SetWhich(GetPool().GetWhich(SID_ATTR_PAGE_SIZE));
432                 aSet.Put(aFrmSize);
433 
434                 const SwRect &rPr = rSh.GetAnyCurRect(RECT_PAGE_PRT);
435                 SwFmtFrmSize aPrtSize(ATT_VAR_SIZE, rPr.Width(), rPr.Height());
436                 aPrtSize.SetWhich(GetPool().GetWhich(FN_GET_PRINT_AREA));
437                 aSet.Put(aPrtSize);
438 
439                 aSet.Put(aMgr.GetAttrSet());
440                 aSet.SetParent( aMgr.GetAttrSet().GetParent() );
441 
442                 // Bei %-Werten Groesse initialisieren
443                 SwFmtFrmSize& rSize = (SwFmtFrmSize&)aSet.Get(RES_FRM_SIZE);
444                 if (rSize.GetWidthPercent() && rSize.GetWidthPercent() != 0xff)
445                     rSize.SetWidth(rSh.GetAnyCurRect(RECT_FLY_EMBEDDED).Width());
446                 if (rSize.GetHeightPercent() && rSize.GetHeightPercent() != 0xff)
447                     rSize.SetHeight(rSh.GetAnyCurRect(RECT_FLY_EMBEDDED).Height());
448 
449                 // disable vertical positioning for Math Objects anchored 'as char' if baseline alignment is activated
450                 aSet.Put( SfxBoolItem( FN_MATH_BASELINE_ALIGNMENT,
451                         rSh.GetDoc()->get( IDocumentSettingAccess::MATH_BASELINE_ALIGNMENT ) ) );
452                 const uno::Reference < embed::XEmbeddedObject > xObj( rSh.GetOleRef() );
453                 aSet.Put( SfxBoolItem( FN_OLE_IS_MATH, xObj.is() && SotExchange::IsMath( xObj->getClassID() ) ) );
454 
455                 sal_uInt16 nDefPage = 0;
456                 if(pArgs && pArgs->GetItemState(FN_FORMAT_FRAME_DLG, sal_False, &pItem) == SFX_ITEM_SET)
457                     nDefPage = ((SfxUInt16Item *)pItem)->GetValue();
458 
459                 aSet.Put(SfxFrameItem( SID_DOCFRAME, &GetView().GetViewFrame()->GetTopFrame()));
460                 FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &GetView()));
461                 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric) ));
462                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
463                 DBG_ASSERT(pFact, "Dialogdiet fail!");
464                 SfxAbstractTabDialog* pDlg = pFact->CreateFrmTabDialog( DLG_FRM_STD,
465                                                         GetView().GetViewFrame(),
466                                                         GetView().GetWindow(),
467                                                         aSet, sal_False,
468                                                         nSel & nsSelectionType::SEL_GRF ? DLG_FRM_GRF :
469                                                         nSel & nsSelectionType::SEL_OLE ? DLG_FRM_OLE :
470                                                                                         DLG_FRM_STD,
471                                                         sal_False,
472                                                         nDefPage);
473                 DBG_ASSERT(pDlg, "Dialogdiet fail!");
474 
475                 if ( pDlg->Execute() )
476                 {
477                     const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
478                     if(pOutSet)
479                     {
480                         rReq.Done(*pOutSet);
481                         if(nSel & nsSelectionType::SEL_OLE &&
482                         SFX_ITEM_SET == pOutSet->GetItemState(FN_KEEP_ASPECT_RATIO, sal_True, &pItem))
483                         {
484                             SwViewOption aUsrPref( *pVOpt );
485                             aUsrPref.SetKeepRatio(((const SfxBoolItem*)pItem)->GetValue());
486                             SW_MOD()->ApplyUsrPref(aUsrPref, &GetView());
487                         }
488                         if (SFX_ITEM_SET == pOutSet->GetItemState(FN_SET_FRM_ALT_NAME, sal_True, &pItem))
489                         {
490                             // --> OD 2009-07-13 #i73249#
491 //                            rSh.SetAlternateText(((const SfxStringItem*)pItem)->GetValue());
492                             rSh.SetObjTitle(((const SfxStringItem*)pItem)->GetValue());
493                             // <--
494                         }
495                         // Vorlagen-AutoUpdate
496                         SwFrmFmt* pFmt = rSh.GetCurFrmFmt();
497                         if(pFmt && pFmt->IsAutoUpdateFmt())
498                         {
499                             rSh.AutoUpdateFrame(pFmt, *pOutSet);
500                             // alles, dass das Format nicht kann, muss hart
501                             // gesetzt werden
502                             if(SFX_ITEM_SET == pOutSet->GetItemState(FN_SET_FRM_NAME, sal_False, &pItem))
503                                 rSh.SetFlyName(((SfxStringItem*)pItem)->GetValue());
504                             SfxItemSet aShellSet(GetPool(), RES_FRM_SIZE,   RES_FRM_SIZE,
505                                                             RES_SURROUND,   RES_SURROUND,
506                                                             RES_ANCHOR,     RES_ANCHOR,
507                                                             RES_VERT_ORIENT,RES_HORI_ORIENT,
508                                                             0);
509                             aShellSet.Put(*pOutSet);
510                             aMgr.SetAttrSet(aShellSet);
511                             if(SFX_ITEM_SET == pOutSet->GetItemState(FN_SET_FRM_NAME, sal_False, &pItem))
512                                 rSh.SetFlyName(((SfxStringItem*)pItem)->GetValue());
513                         }
514                         else
515                             aMgr.SetAttrSet( *pOutSet );
516 
517                         const SwFrmFmt* pCurrFlyFmt = rSh.GetFlyFrmFmt();
518                         if(SFX_ITEM_SET ==
519                            pOutSet->GetItemState(FN_PARAM_CHAIN_PREVIOUS,
520                                                  sal_False, &pItem))
521                         {
522                             rSh.HideChainMarker();
523 
524                             String sPrevName =
525                                 ((const SfxStringItem*)pItem)->GetValue();
526                             const SwFmtChain &rChain = pCurrFlyFmt->GetChain();
527                             //needs cast - no non-const method available
528                             SwFlyFrmFmt* pFlyFmt =
529                                 (SwFlyFrmFmt*)rChain.GetPrev();
530                             if(pFlyFmt)
531                             {
532                                 if (pFlyFmt->GetName() != sPrevName)
533                                 {
534                                     rSh.Unchain(*pFlyFmt);
535                                 }
536                                 else
537                                     sPrevName.Erase();
538                             }
539 
540                             if(sPrevName.Len())
541                             {
542                                 //needs cast - no non-const method available
543                                 SwFrmFmt* pPrevFmt = (SwFrmFmt*)
544                                     lcl_GetFrmFmtByName(rSh, sPrevName);
545                                 DBG_ASSERT(pPrevFmt, "No frame found!");
546                                 if(pPrevFmt)
547                                 {
548                                     rSh.Chain(*pPrevFmt, *pCurrFlyFmt);
549                                 }
550                             }
551                             rSh.SetChainMarker();
552                         }
553                         if(SFX_ITEM_SET ==
554                            pOutSet->GetItemState(FN_PARAM_CHAIN_NEXT, sal_False,
555                                                  &pItem))
556                         {
557                             rSh.HideChainMarker();
558                             String sNextName =
559                                 ((const SfxStringItem*)pItem)->GetValue();
560                             const SwFmtChain &rChain = pCurrFlyFmt->GetChain();
561                             //needs cast - no non-const method available
562                             SwFlyFrmFmt* pFlyFmt =
563                                 (SwFlyFrmFmt*)rChain.GetNext();
564                             if(pFlyFmt)
565                             {
566                                 if (pFlyFmt->GetName() != sNextName)
567                                 {
568                                     rSh.Unchain(*((SwFlyFrmFmt*) pCurrFlyFmt));
569                                 }
570                                 else
571                                     sNextName.Erase();
572                             }
573 
574                             if(sNextName.Len())
575                             {
576                                 //needs cast - no non-const method available
577                                 SwFrmFmt* pNextFmt = (SwFrmFmt*)
578                                     lcl_GetFrmFmtByName(rSh, sNextName);
579                                 DBG_ASSERT(pNextFmt, "No frame found!");
580                                 if(pNextFmt)
581                                 {
582                                     rSh.Chain(*(SwFrmFmt*)
583                                               pCurrFlyFmt, *pNextFmt);
584                                 }
585                             }
586                             rSh.SetChainMarker();
587                         }
588                     }
589                 }
590                 else
591                     bUpdateMgr = sal_False;
592                 delete pDlg;
593             }
594         }
595         break;
596         case FN_FRAME_MIRROR_ON_EVEN_PAGES:
597         {
598             SwFmtHoriOrient aHori(aMgr.GetHoriOrient());
599             sal_Bool bMirror = !aHori.IsPosToggle();
600             aHori.SetPosToggle(bMirror);
601             SfxItemSet aSet(GetPool(), RES_HORI_ORIENT, RES_HORI_ORIENT);
602             aSet.Put(aHori);
603             aMgr.SetAttrSet(aSet);
604             bCopyToFmt = sal_True;
605             rReq.SetReturnValue(SfxBoolItem(nSlot, bMirror));
606         }
607         break;
608         // --> OD 2009-07-14 #i73249#
609         case FN_TITLE_DESCRIPTION_SHAPE:
610         {
611             bUpdateMgr = sal_False;
612             SdrView* pSdrView = rSh.GetDrawViewWithValidMarkList();
613             if ( pSdrView &&
614                  pSdrView->GetMarkedObjectCount() == 1 )
615             {
616                 String aDescription(rSh.GetObjDescription());
617                 String aTitle(rSh.GetObjTitle());
618 
619                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
620                 OSL_ENSURE(pFact, "Dialogdiet fail!");
621                 AbstractSvxObjectTitleDescDialog* pDlg =
622                     pFact->CreateSvxObjectTitleDescDialog( NULL,
623                                                            aTitle,
624                                                            aDescription );
625                 OSL_ENSURE(pDlg, "Dialogdiet fail!");
626 
627                 if ( pDlg->Execute() == RET_OK )
628                 {
629                     pDlg->GetDescription(aDescription);
630                     pDlg->GetTitle(aTitle);
631 
632                     rSh.SetObjDescription(aDescription);
633                     rSh.SetObjTitle(aTitle);
634                 }
635 
636                 delete pDlg;
637             }
638         }
639         break;
640         // <--
641         default:
642             ASSERT( !this, "falscher Dispatcher" );
643             return;
644     }
645     // Vorlagen-AutoUpdate
646     SwFrmFmt* pFmt = rSh.GetCurFrmFmt();
647     if ( bUpdateMgr )
648     {
649         if(bCopyToFmt && pFmt && pFmt->IsAutoUpdateFmt())
650         {
651             rSh.AutoUpdateFrame(pFmt, aMgr.GetAttrSet());
652         }
653         else
654             aMgr.UpdateFlyFrm();
655     }
656 
657 }
658 
659 /*--------------------------------------------------------------------
660     Beschreibung:
661  --------------------------------------------------------------------*/
662 
663 
664 void SwFrameShell::GetState(SfxItemSet& rSet)
665 {
666     SwWrtShell &rSh = GetShell();
667     sal_Bool bHtmlMode = 0 != ::GetHtmlMode(rSh.GetView().GetDocShell());
668     if (rSh.IsFrmSelected())
669     {
670         SfxItemSet aSet( rSh.GetAttrPool(),
671                             RES_LR_SPACE, RES_UL_SPACE,
672                             RES_PROTECT, RES_HORI_ORIENT,
673                             RES_OPAQUE, RES_OPAQUE,
674                             RES_PRINT, RES_OPAQUE,
675                             0 );
676         rSh.GetFlyFrmAttr( aSet );
677 
678         sal_Bool bProtect = rSh.IsSelObjProtected(FLYPROTECT_POS);
679         sal_Bool bParentCntProt = rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0;
680 
681         bProtect |= bParentCntProt;
682 
683         const sal_uInt16 eFrmType = rSh.GetFrmType(0,sal_True);
684         SwFlyFrmAttrMgr aMgr( sal_False, &rSh, FRMMGR_TYPE_NONE );
685 
686         SfxWhichIter aIter( rSet );
687         sal_uInt16 nWhich = aIter.FirstWhich();
688         while ( nWhich )
689         {
690             switch ( nWhich )
691             {
692                 case RES_FRM_SIZE:
693                 {
694                     SwFmtFrmSize aSz(aMgr.GetFrmSize());
695                     rSet.Put(aSz);
696                 }
697                 break;
698                 case RES_VERT_ORIENT:
699                 case RES_HORI_ORIENT:
700                 case SID_ATTR_ULSPACE:
701                 case SID_ATTR_LRSPACE:
702                 case RES_LR_SPACE:
703                 case RES_UL_SPACE:
704                 case RES_PROTECT:
705                 case RES_OPAQUE:
706                 case RES_PRINT:
707                 case RES_SURROUND:
708                 {
709                     rSet.Put(aSet.Get(GetPool().GetWhich(nWhich), sal_True ));
710                 }
711                 break;
712                 case SID_OBJECT_ALIGN_LEFT   :
713                 case SID_OBJECT_ALIGN_CENTER :
714                 case SID_OBJECT_ALIGN_RIGHT  :
715                 case FN_FRAME_ALIGN_HORZ_CENTER:
716                 case FN_FRAME_ALIGN_HORZ_RIGHT:
717                 case FN_FRAME_ALIGN_HORZ_LEFT:
718                     if ( (eFrmType & FRMTYPE_FLY_INCNT) ||
719                             bProtect ||
720                             ((nWhich == FN_FRAME_ALIGN_HORZ_CENTER  || nWhich == SID_OBJECT_ALIGN_CENTER)&& bHtmlMode) )
721                         rSet.DisableItem( nWhich );
722                 break;
723                 case FN_FRAME_ALIGN_VERT_ROW_TOP:
724                 case FN_FRAME_ALIGN_VERT_ROW_CENTER:
725                 case FN_FRAME_ALIGN_VERT_ROW_BOTTOM:
726                 case FN_FRAME_ALIGN_VERT_CHAR_TOP:
727                 case FN_FRAME_ALIGN_VERT_CHAR_CENTER:
728                 case FN_FRAME_ALIGN_VERT_CHAR_BOTTOM:
729                     if ( !(eFrmType & FRMTYPE_FLY_INCNT) || bProtect
730                             || (bHtmlMode && FN_FRAME_ALIGN_VERT_CHAR_BOTTOM == nWhich) )
731                         rSet.DisableItem( nWhich );
732                 break;
733 
734                 case SID_OBJECT_ALIGN_UP     :
735                 case SID_OBJECT_ALIGN_MIDDLE :
736                 case SID_OBJECT_ALIGN_DOWN :
737 
738                 case FN_FRAME_ALIGN_VERT_TOP:
739                 case FN_FRAME_ALIGN_VERT_CENTER:
740                 case FN_FRAME_ALIGN_VERT_BOTTOM:
741                     if ( bProtect || (bHtmlMode && eFrmType & FRMTYPE_FLY_ATCNT) )
742                         rSet.DisableItem( nWhich );
743                     else
744                     {
745                         sal_uInt16 nId = 0;
746                         if (eFrmType & FRMTYPE_FLY_INCNT)
747                         {
748                             switch (nWhich)
749                             {
750                                 case SID_OBJECT_ALIGN_UP     :
751                                 case FN_FRAME_ALIGN_VERT_TOP:
752                                     nId = STR_TOP_BASE; break;
753                                 case SID_OBJECT_ALIGN_MIDDLE :
754                                 case FN_FRAME_ALIGN_VERT_CENTER:
755                                     nId = STR_CENTER_BASE;  break;
756                                 case SID_OBJECT_ALIGN_DOWN :
757                                 case FN_FRAME_ALIGN_VERT_BOTTOM:
758                                     if(!bHtmlMode)
759                                         nId = STR_BOTTOM_BASE;
760                                     else
761                                         rSet.DisableItem( nWhich );
762                                 break;
763                             }
764                         }
765                         else
766                         {
767                             if (nWhich != FN_FRAME_ALIGN_VERT_TOP &&
768                                     nWhich != SID_OBJECT_ALIGN_UP )
769                             {
770                                 if (aMgr.GetAnchor() == FLY_AT_FLY)
771                                 {
772                                     const SwFrmFmt* pFmt = rSh.IsFlyInFly();
773                                     if (pFmt)
774                                     {
775                                         const SwFmtFrmSize& rFrmSz = pFmt->GetFrmSize();
776                                         if (rFrmSz.GetHeightSizeType() != ATT_FIX_SIZE)
777                                         {
778                                             rSet.DisableItem( nWhich );
779                                             break;
780                                         }
781                                     }
782                                 }
783                             }
784                             switch (nWhich)
785                             {
786                                 case SID_OBJECT_ALIGN_UP :
787                                 case FN_FRAME_ALIGN_VERT_TOP:
788                                     nId = STR_TOP; break;
789                                 case SID_OBJECT_ALIGN_MIDDLE:
790                                 case FN_FRAME_ALIGN_VERT_CENTER:
791                                     nId = STR_CENTER_VERT; break;
792                                 case SID_OBJECT_ALIGN_DOWN:
793                                 case FN_FRAME_ALIGN_VERT_BOTTOM:
794                                     nId = STR_BOTTOM; break;
795                             }
796                         }
797                         if ( nId )
798                             rSet.Put( SfxStringItem( nWhich, SW_RES(nId) ));
799                     }
800                 break;
801                 case SID_HYPERLINK_GETLINK:
802                 {
803                     String sURL;
804                     SvxHyperlinkItem aHLinkItem;
805                     const SfxPoolItem* pItem;
806 
807                     SfxItemSet aURLSet(GetPool(), RES_URL, RES_URL);
808                     rSh.GetFlyFrmAttr( aURLSet );
809 
810                     if(SFX_ITEM_SET == aURLSet.GetItemState(RES_URL, sal_True, &pItem))
811                     {
812                         const SwFmtURL* pFmtURL = (const SwFmtURL*)pItem;
813                         aHLinkItem.SetURL(pFmtURL->GetURL());
814                         aHLinkItem.SetTargetFrame(pFmtURL->GetTargetFrameName());
815                         aHLinkItem.SetName(rSh.GetFlyName());
816                     }
817 
818                     aHLinkItem.SetInsertMode((SvxLinkInsertMode)(aHLinkItem.GetInsertMode() |
819                         (bHtmlMode ? HLINK_HTMLMODE : 0)));
820 
821                     rSet.Put(aHLinkItem);
822                 }
823                 break;
824 
825                 case FN_FRAME_CHAIN:
826                 {
827                     const int nSel = rSh.GetSelectionType();
828                     if (nSel & nsSelectionType::SEL_GRF || nSel & nsSelectionType::SEL_OLE)
829                         rSet.DisableItem( FN_FRAME_CHAIN );
830                     else
831                     {
832                         const SwFrmFmt *pFmt = rSh.GetFlyFrmFmt();
833                         if ( bParentCntProt || rSh.GetView().GetEditWin().GetApplyTemplate() ||
834                             !pFmt || pFmt->GetChain().GetNext() )
835                         {
836                             rSet.DisableItem( FN_FRAME_CHAIN );
837                         }
838                         else
839                         {
840                             sal_Bool bChainMode = rSh.GetView().GetEditWin().IsChainMode();
841                             rSet.Put( SfxBoolItem( FN_FRAME_CHAIN, bChainMode ) );
842                         }
843                     }
844                 }
845                 break;
846                 case FN_FRAME_UNCHAIN:
847                 {
848                     const int nSel = rSh.GetSelectionType();
849                     if (nSel & nsSelectionType::SEL_GRF || nSel & nsSelectionType::SEL_OLE)
850                         rSet.DisableItem( FN_FRAME_UNCHAIN );
851                     else
852                     {
853                         const SwFrmFmt *pFmt = rSh.GetFlyFrmFmt();
854                         if ( bParentCntProt || rSh.GetView().GetEditWin().GetApplyTemplate() ||
855                             !pFmt || !pFmt->GetChain().GetNext() )
856                         {
857                             rSet.DisableItem( FN_FRAME_UNCHAIN );
858                         }
859                     }
860                 }
861                 break;
862                 case SID_FRAME_TO_TOP:
863                 case SID_FRAME_TO_BOTTOM:
864                 case FN_FRAME_UP:
865                 case FN_FRAME_DOWN:
866                     if ( bParentCntProt )
867                         rSet.DisableItem( nWhich );
868                 break;
869                 case FN_FORMAT_FRAME_DLG:
870                 {
871                     const int nSel = rSh.GetSelectionType();
872                     if ( bParentCntProt || nSel & nsSelectionType::SEL_GRF)
873                         rSet.DisableItem( nWhich );
874                 }
875                 break;
876                 // --> OD 2009-07-07 #i73249#
877                 case FN_TITLE_DESCRIPTION_SHAPE:
878                 {
879                     SwWrtShell &rWrtSh = GetShell();
880                     SdrView* pSdrView = rWrtSh.GetDrawViewWithValidMarkList();
881                     if ( !pSdrView ||
882                          pSdrView->GetMarkedObjectCount() != 1 )
883                     {
884                         rSet.DisableItem( nWhich );
885                     }
886 
887                 }
888                 break;
889                 // <--
890                 default:
891                     /* do nothing */;
892                     break;
893             }
894             nWhich = aIter.NextWhich();
895         }
896     }
897 }
898 
899 /*--------------------------------------------------------------------
900     Beschreibung:   Ctor fuer FrameShell
901  --------------------------------------------------------------------*/
902 
903 
904 SwFrameShell::SwFrameShell(SwView &_rView) :
905     SwBaseShell( _rView )
906 {
907     SetName(String::CreateFromAscii("Frame"));
908     SetHelpId(SW_FRAMESHELL);
909 
910     /* #96392# Use this to announce it is the frame shell who creates the
911        selection. */
912     SwTransferable::CreateSelection( _rView.GetWrtShell(), (ViewShell *) this );
913 }
914 
915 SwFrameShell::~SwFrameShell()
916 {
917     /* #96392# Only clear the selection if it was this frame shell who created
918        it. */
919     SwTransferable::ClearSelection( GetShell(), (ViewShell *) this );
920 }
921 
922 /*--------------------------------------------------------------------
923     Beschreibung:
924  --------------------------------------------------------------------*/
925 
926 
927 
928 void SwFrameShell::ExecFrameStyle(SfxRequest& rReq)
929 {
930     SwWrtShell &rSh = GetShell();
931     sal_Bool bDefault = sal_False;
932     if (!rSh.IsFrmSelected())
933         return;
934 
935     // Erst Default-BoxItem aus Pool holen. Wenn ungleich normalem Boxitem,
936     // dann ist es bereits geaendert worden (neues ist kein Default).
937     const SvxBoxItem* pPoolBoxItem = (const SvxBoxItem*)::GetDfltAttr(RES_BOX);
938 
939     const SfxItemSet *pArgs = rReq.GetArgs();
940     SfxItemSet aFrameSet(rSh.GetAttrPool(), RES_BOX, RES_BOX);
941 
942     rSh.GetFlyFrmAttr( aFrameSet );
943     const SvxBoxItem& rBoxItem = (const SvxBoxItem&)aFrameSet.Get(RES_BOX);
944 
945     if (pPoolBoxItem == &rBoxItem)
946         bDefault = sal_True;
947 
948     SvxBoxItem aBoxItem(rBoxItem);
949 
950     SvxBorderLine aBorderLine;
951     const SfxPoolItem *pItem = 0;
952 
953     if(pArgs)    //irgendein Controller kann auch mal nichts liefern #48169#
954     {
955         switch (rReq.GetSlot())
956         {
957             case SID_ATTR_BORDER:
958             {
959                 if (pArgs->GetItemState(RES_BOX, sal_True, &pItem) == SFX_ITEM_SET)
960                 {
961                     SvxBoxItem aNewBox(*((SvxBoxItem *)pItem));
962                     const SvxBorderLine* pBorderLine;
963 
964                     if ((pBorderLine = aBoxItem.GetTop()) != NULL)
965                         lcl_FrmGetMaxLineWidth(pBorderLine, aBorderLine);
966                     if ((pBorderLine = aBoxItem.GetBottom()) != NULL)
967                         lcl_FrmGetMaxLineWidth(pBorderLine, aBorderLine);
968                     if ((pBorderLine = aBoxItem.GetLeft()) != NULL)
969                         lcl_FrmGetMaxLineWidth(pBorderLine, aBorderLine);
970                     if ((pBorderLine = aBoxItem.GetRight()) != NULL)
971                         lcl_FrmGetMaxLineWidth(pBorderLine, aBorderLine);
972 
973                     if(aBorderLine.GetOutWidth() == 0)
974                     {
975                         aBorderLine.SetInWidth(0);
976                         aBorderLine.SetOutWidth(DEF_LINE_WIDTH_0);
977                         aBorderLine.SetDistance(0);
978                     }
979                     //Distance nur setzen, wenn der Request vom Controller kommt
980 
981                     if(!StarBASIC::IsRunning())
982                     {
983                         aNewBox.SetDistance( rBoxItem.GetDistance() );
984                     }
985 
986                     aBoxItem = aNewBox;
987                     SvxBorderLine aDestBorderLine;
988 
989                     if ((pBorderLine = aBoxItem.GetTop()) != NULL)
990                         aBoxItem.SetLine(&aBorderLine, BOX_LINE_TOP);
991                     if ((pBorderLine = aBoxItem.GetBottom()) != NULL)
992                         aBoxItem.SetLine(&aBorderLine, BOX_LINE_BOTTOM);
993                     if ((pBorderLine = aBoxItem.GetLeft()) != NULL)
994                         aBoxItem.SetLine(&aBorderLine, BOX_LINE_LEFT);
995                     if ((pBorderLine = aBoxItem.GetRight()) != NULL)
996                         aBoxItem.SetLine(&aBorderLine, BOX_LINE_RIGHT);
997                 }
998             }
999             break;
1000 
1001             case SID_FRAME_LINESTYLE:
1002             {
1003                 if (pArgs->GetItemState(SID_FRAME_LINESTYLE, sal_False, &pItem) == SFX_ITEM_SET)
1004                 {
1005                     const SvxLineItem* pLineItem =
1006                             (const SvxLineItem*)pItem;
1007 
1008                     if ( pLineItem->GetLine() )
1009                     {
1010                         aBorderLine = *(pLineItem->GetLine());
1011 
1012                         if (!aBoxItem.GetTop() && !aBoxItem.GetBottom() &&
1013                             !aBoxItem.GetLeft() && !aBoxItem.GetRight())
1014                         {
1015                             aBoxItem.SetLine(&aBorderLine, BOX_LINE_TOP);
1016                             aBoxItem.SetLine(&aBorderLine, BOX_LINE_BOTTOM);
1017                             aBoxItem.SetLine(&aBorderLine, BOX_LINE_LEFT);
1018                             aBoxItem.SetLine(&aBorderLine, BOX_LINE_RIGHT);
1019                         }
1020                         else
1021                         {
1022                             if( aBoxItem.GetTop() )
1023                             {
1024                                 aBorderLine.SetColor( aBoxItem.GetTop()->GetColor() );
1025                                 aBoxItem.SetLine(&aBorderLine, BOX_LINE_TOP);
1026                             }
1027                             if( aBoxItem.GetBottom() )
1028                             {
1029                                 aBorderLine.SetColor( aBoxItem.GetBottom()->GetColor());
1030                                 aBoxItem.SetLine(&aBorderLine, BOX_LINE_BOTTOM);
1031                             }
1032                             if( aBoxItem.GetLeft() )
1033                             {
1034                                 aBorderLine.SetColor( aBoxItem.GetLeft()->GetColor());
1035                                 aBoxItem.SetLine(&aBorderLine, BOX_LINE_LEFT);
1036                             }
1037                             if( aBoxItem.GetRight() )
1038                             {
1039                                 aBorderLine.SetColor(aBoxItem.GetRight()->GetColor());
1040                                 aBoxItem.SetLine(&aBorderLine, BOX_LINE_RIGHT);
1041                             }
1042                         }
1043                     }
1044                     else
1045                     {
1046                         aBoxItem.SetLine(0, BOX_LINE_TOP);
1047                         aBoxItem.SetLine(0, BOX_LINE_BOTTOM);
1048                         aBoxItem.SetLine(0, BOX_LINE_LEFT);
1049                         aBoxItem.SetLine(0, BOX_LINE_RIGHT);
1050                     }
1051                 }
1052             }
1053             break;
1054 
1055             case SID_FRAME_LINECOLOR:
1056             {
1057                 if (pArgs->GetItemState(SID_FRAME_LINECOLOR, sal_False, &pItem) == SFX_ITEM_SET)
1058                 {
1059                     const Color& rNewColor = ((const SvxColorItem*)pItem)->GetValue();
1060 
1061                     if (!aBoxItem.GetTop() && !aBoxItem.GetBottom() &&
1062                         !aBoxItem.GetLeft() && !aBoxItem.GetRight())
1063                     {
1064                         aBorderLine.SetColor( rNewColor );
1065                         aBoxItem.SetLine(&aBorderLine, BOX_LINE_TOP);
1066                         aBoxItem.SetLine(&aBorderLine, BOX_LINE_BOTTOM);
1067                         aBoxItem.SetLine(&aBorderLine, BOX_LINE_LEFT);
1068                         aBoxItem.SetLine(&aBorderLine, BOX_LINE_RIGHT);
1069                     }
1070                     else
1071                     {
1072                         if ( aBoxItem.GetTop() )
1073                             ((SvxBorderLine*)aBoxItem.GetTop())->SetColor( rNewColor );
1074                         if ( aBoxItem.GetBottom() )
1075                             ((SvxBorderLine*)aBoxItem.GetBottom())->SetColor( rNewColor );
1076                         if ( aBoxItem.GetLeft() )
1077                             ((SvxBorderLine*)aBoxItem.GetLeft())->SetColor( rNewColor );
1078                         if ( aBoxItem.GetRight() )
1079                             ((SvxBorderLine*)aBoxItem.GetRight())->SetColor( rNewColor );
1080                     }
1081                 }
1082             }
1083             break;
1084         }
1085     }
1086     if (bDefault && (aBoxItem.GetTop() || aBoxItem.GetBottom() ||
1087         aBoxItem.GetLeft() || aBoxItem.GetRight()))
1088     {
1089         aBoxItem.SetDistance(MIN_BORDER_DIST);
1090     }
1091     aFrameSet.Put( aBoxItem );
1092     // Vorlagen-AutoUpdate
1093     SwFrmFmt* pFmt = rSh.GetCurFrmFmt();
1094     if(pFmt && pFmt->IsAutoUpdateFmt())
1095     {
1096         rSh.AutoUpdateFrame(pFmt, aFrameSet);
1097     }
1098     else
1099         rSh.SetFlyFrmAttr( aFrameSet );
1100 
1101 }
1102 
1103 
1104 
1105 void lcl_FrmGetMaxLineWidth(const SvxBorderLine* pBorderLine, SvxBorderLine& rBorderLine)
1106 {
1107     if(pBorderLine->GetInWidth() > rBorderLine.GetInWidth())
1108         rBorderLine.SetInWidth(pBorderLine->GetInWidth());
1109 
1110     if(pBorderLine->GetOutWidth() > rBorderLine.GetOutWidth())
1111         rBorderLine.SetOutWidth(pBorderLine->GetOutWidth());
1112 
1113     if(pBorderLine->GetDistance() > rBorderLine.GetDistance())
1114         rBorderLine.SetDistance(pBorderLine->GetDistance());
1115 
1116     rBorderLine.SetColor(pBorderLine->GetColor());
1117 }
1118 
1119 
1120 
1121 void SwFrameShell::GetLineStyleState(SfxItemSet &rSet)
1122 {
1123     SwWrtShell &rSh = GetShell();
1124     sal_Bool bParentCntProt = rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0;
1125 
1126     if (bParentCntProt)
1127     {
1128         if (rSh.IsFrmSelected())
1129             rSet.DisableItem( SID_FRAME_LINECOLOR );
1130 
1131         rSet.DisableItem( SID_ATTR_BORDER );
1132         rSet.DisableItem( SID_FRAME_LINESTYLE );
1133     }
1134     else
1135     {
1136         if (rSh.IsFrmSelected())
1137         {
1138             SfxItemSet aFrameSet( rSh.GetAttrPool(), RES_BOX, RES_BOX );
1139 
1140             rSh.GetFlyFrmAttr(aFrameSet);
1141 
1142             const SvxBorderLine* pLine = ((const SvxBoxItem&)aFrameSet.Get(RES_BOX)).GetTop();
1143             rSet.Put(SvxColorItem(pLine ? pLine->GetColor() : Color(), SID_FRAME_LINECOLOR));
1144         }
1145     }
1146 }
1147 
1148 void  SwFrameShell::StateInsert(SfxItemSet &rSet)
1149 {
1150     const int nSel = GetShell().GetSelectionType();
1151 
1152     if ((nSel & nsSelectionType::SEL_GRF) || (nSel & nsSelectionType::SEL_OLE))
1153         rSet.DisableItem(FN_INSERT_FRAME);
1154 }
1155 
1156