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