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