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