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