Add a comment to clarify what kind of inputs the class handles
[LibreOffice.git] / sw / source / uibase / shells / frmsh.cxx
blob8f613c9a83f167ae2c3c83f0253c7843da87179a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <config_features.h>
22 #include <hintids.hxx>
23 #include <svl/whiter.hxx>
24 #include <sfx2/viewfrm.hxx>
25 #include <basic/sbstar.hxx>
26 #include <svl/ptitem.hxx>
27 #include <svl/stritem.hxx>
28 #include <svl/intitem.hxx>
29 #include <svl/eitem.hxx>
30 #include <editeng/colritem.hxx>
31 #include <editeng/lineitem.hxx>
32 #include <editeng/boxitem.hxx>
33 #include <sfx2/dispatch.hxx>
34 #include <sfx2/request.hxx>
35 #include <sfx2/objface.hxx>
36 #include <vcl/EnumContext.hxx>
37 #include <svx/hlnkitem.hxx>
38 #include <svx/svdview.hxx>
39 #include <svx/sdangitm.hxx>
40 #include <vcl/commandinfoprovider.hxx>
41 #include <sal/log.hxx>
43 #include <doc.hxx>
44 #include <drawdoc.hxx>
45 #include <IDocumentSettingAccess.hxx>
46 #include <IDocumentDrawModelAccess.hxx>
47 #include <fmturl.hxx>
48 #include <fmtclds.hxx>
49 #include <fmtcnct.hxx>
50 #include <swmodule.hxx>
51 #include <wrtsh.hxx>
52 #include <wview.hxx>
53 #include <uitool.hxx>
54 #include <frmfmt.hxx>
55 #include <frmsh.hxx>
56 #include <frmmgr.hxx>
57 #include <edtwin.hxx>
58 #include <swdtflvr.hxx>
59 #include <viewopt.hxx>
61 #include <cmdid.h>
62 #include <strings.hrc>
63 #include <swabstdlg.hxx>
65 #include <svx/svxdlg.hxx>
67 #include <docsh.hxx>
68 #include <svx/drawitem.hxx>
69 #include <memory>
71 #define ShellClass_SwFrameShell
72 #include <sfx2/msg.hxx>
73 #include <swslots.hxx>
74 #include <grfatr.hxx>
75 #include <fldmgr.hxx>
76 #include <flyfrm.hxx>
78 using ::editeng::SvxBorderLine;
79 using namespace ::com::sun::star;
80 using namespace ::com::sun::star::uno;
82 // Prototypes
83 static void lcl_FrameGetMaxLineWidth(const SvxBorderLine* pBorderLine, SvxBorderLine& rBorderLine);
85 SFX_IMPL_INTERFACE(SwFrameShell, SwBaseShell)
87 void SwFrameShell::InitInterface_Impl()
89 GetStaticInterface()->RegisterPopupMenu(u"frame"_ustr);
91 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT, SfxVisibilityFlags::Invisible, ToolbarId::Frame_Toolbox);
94 void SwFrameShell::ExecMove(SfxRequest& rReq)
96 SwWrtShell& rSh = GetShell();
97 sal_uInt16 nSlot = rReq.GetSlot();
98 switch (nSlot)
100 case SID_SELECTALL:
101 rSh.SelAll();
102 rReq.Done();
103 break;
107 void SwFrameShell::ExecField(const SfxRequest& rReq)
109 SwWrtShell& rSh = GetShell();
110 sal_uInt16 nSlot = rReq.GetSlot();
111 switch (nSlot)
113 case FN_POSTIT:
114 SwFieldMgr aFieldMgr(&rSh);
115 rSh.InsertPostIt(aFieldMgr, rReq);
116 break;
120 void SwFrameShell::Execute(SfxRequest &rReq)
122 //First those who do not need FrameMgr.
123 SwWrtShell &rSh = GetShell();
124 bool bMore = false;
125 const SfxItemSet* pArgs = rReq.GetArgs();
126 const SfxPoolItem* pItem;
127 sal_uInt16 nSlot = rReq.GetSlot();
129 switch ( nSlot )
131 case FN_FRAME_TO_ANCHOR:
132 if ( rSh.IsFrameSelected() )
134 rSh.GotoFlyAnchor();
135 rSh.EnterStdMode();
136 rSh.CallChgLnk();
138 break;
139 case SID_FRAME_TO_TOP:
140 rSh.SelectionToTop();
141 break;
143 case SID_FRAME_TO_BOTTOM:
144 rSh.SelectionToBottom();
145 break;
147 case FN_FRAME_UP:
148 rSh.SelectionToTop( false );
149 break;
151 case FN_FRAME_DOWN:
152 rSh.SelectionToBottom( false );
153 break;
154 case FN_INSERT_FRAME:
155 if (!pArgs)
157 // Frame already exists, open frame dialog for editing.
158 SfxStringItem aDefPage(FN_FORMAT_FRAME_DLG, u"columns"_ustr);
159 rSh.GetView().GetViewFrame().GetDispatcher()->ExecuteList(
160 FN_FORMAT_FRAME_DLG,
161 SfxCallMode::SYNCHRON|SfxCallMode::RECORD,
162 { &aDefPage });
165 else
167 // Frame already exists, only the number of columns will be changed.
168 sal_uInt16 nCols = 1;
169 if(const SfxUInt16Item* pColsItem = pArgs->GetItemIfSet(SID_ATTR_COLUMNS, false))
170 nCols = pColsItem->GetValue();
172 SfxItemSetFixed<RES_COL,RES_COL> aSet(GetPool());
173 rSh.GetFlyFrameAttr( aSet );
174 SwFormatCol aCol(aSet.Get(RES_COL));
175 // GutterWidth will not always passed, hence get firstly
176 // (see view2: Execute on this slot)
177 sal_uInt16 nGutterWidth = aCol.GetGutterWidth();
178 if(!nCols )
179 nCols++;
180 aCol.Init(nCols, nGutterWidth, aCol.GetWishWidth());
181 aSet.Put(aCol);
182 // Template AutoUpdate
183 SwFrameFormat* pFormat = rSh.GetSelectedFrameFormat();
184 if(pFormat && pFormat->IsAutoUpdateOnDirectFormat())
186 rSh.AutoUpdateFrame(pFormat, aSet);
188 else
190 rSh.StartAllAction();
191 rSh.SetFlyFrameAttr( aSet );
192 rSh.SetModified();
193 rSh.EndAllAction();
197 return;
199 case SID_HYPERLINK_SETLINK:
201 if(pArgs && SfxItemState::SET == pArgs->GetItemState(SID_HYPERLINK_SETLINK, false, &pItem))
203 const SvxHyperlinkItem& rHLinkItem = *static_cast<const SvxHyperlinkItem *>(pItem);
204 const OUString& rURL = rHLinkItem.GetURL();
205 const OUString& rTarget = rHLinkItem.GetTargetFrame();
207 SfxItemSetFixed<RES_URL, RES_URL> aSet( rSh.GetAttrPool() );
208 rSh.GetFlyFrameAttr( aSet );
209 SwFormatURL aURL( aSet.Get( RES_URL ) );
211 OUString sOldName(rHLinkItem.GetName().toAsciiUpperCase());
212 OUString sFlyName(rSh.GetFlyName().toAsciiUpperCase());
213 if (sOldName != sFlyName)
215 OUString sName(sOldName);
216 sal_uInt16 i = 1;
217 while (rSh.FindFlyByName(sName))
219 sName = sOldName + "_" + OUString::number(i++);
221 rSh.SetFlyName(sName);
223 aURL.SetURL( rURL, false );
224 aURL.SetTargetFrameName(rTarget);
226 aSet.Put( aURL );
227 rSh.SetFlyFrameAttr( aSet );
230 break;
232 case FN_FRAME_CHAIN:
233 rSh.GetView().GetEditWin().SetChainMode( !rSh.GetView().GetEditWin().IsChainMode() );
234 break;
236 case FN_FRAME_UNCHAIN:
237 rSh.Unchain( *rSh.GetFlyFrameFormat() );
238 GetView().GetViewFrame().GetBindings().Invalidate(FN_FRAME_CHAIN);
239 break;
240 case FN_FORMAT_FOOTNOTE_DLG:
242 GetView().ExecFormatFootnote();
243 break;
245 case FN_NUMBERING_OUTLINE_DLG:
247 GetView().ExecNumberingOutline(GetPool());
248 rReq.Done();
249 break;
251 case SID_OPEN_XML_FILTERSETTINGS:
253 HandleOpenXmlFilterSettings(rReq);
255 break;
256 case FN_WORDCOUNT_DIALOG:
258 GetView().UpdateWordCount(this, nSlot);
259 break;
261 case FN_UNFLOAT_FRAME:
263 rSh.UnfloatFlyFrame();
264 rReq.Done();
265 break;
267 default: bMore = true;
270 if ( !bMore )
272 return;
275 SwFlyFrameAttrMgr aMgr( false, &rSh, Frmmgr_Type::NONE, nullptr );
276 bool bUpdateMgr = true;
277 bool bCopyToFormat = false;
278 switch ( nSlot )
280 case SID_OBJECT_ALIGN_MIDDLE:
281 case FN_FRAME_ALIGN_VERT_CENTER:
282 aMgr.SetVertOrientation( text::VertOrientation::CENTER );
283 break;
284 case SID_OBJECT_ALIGN_DOWN :
285 case FN_FRAME_ALIGN_VERT_BOTTOM:
286 aMgr.SetVertOrientation( text::VertOrientation::BOTTOM );
287 break;
288 case SID_OBJECT_ALIGN_UP :
289 case FN_FRAME_ALIGN_VERT_TOP:
290 aMgr.SetVertOrientation( text::VertOrientation::TOP );
291 break;
293 case FN_FRAME_ALIGN_VERT_CHAR_CENTER:
294 aMgr.SetVertOrientation( text::VertOrientation::CHAR_CENTER );
295 break;
297 case FN_FRAME_ALIGN_VERT_CHAR_BOTTOM:
298 aMgr.SetVertOrientation( text::VertOrientation::CHAR_BOTTOM );
299 break;
301 case FN_FRAME_ALIGN_VERT_CHAR_TOP:
302 aMgr.SetVertOrientation( text::VertOrientation::CHAR_TOP );
303 break;
305 case FN_FRAME_ALIGN_VERT_ROW_CENTER:
306 aMgr.SetVertOrientation( text::VertOrientation::LINE_CENTER );
307 break;
309 case FN_FRAME_ALIGN_VERT_ROW_BOTTOM:
310 aMgr.SetVertOrientation( text::VertOrientation::LINE_BOTTOM );
311 break;
313 case FN_FRAME_ALIGN_VERT_ROW_TOP:
314 aMgr.SetVertOrientation( text::VertOrientation::LINE_TOP );
315 break;
316 case SID_OBJECT_ALIGN_CENTER :
317 case FN_FRAME_ALIGN_HORZ_CENTER:
318 aMgr.SetHorzOrientation( text::HoriOrientation::CENTER );
319 break;
320 case SID_OBJECT_ALIGN_RIGHT:
321 case FN_FRAME_ALIGN_HORZ_RIGHT:
322 aMgr.SetHorzOrientation( text::HoriOrientation::RIGHT );
323 break;
324 case SID_OBJECT_ALIGN_LEFT:
325 case FN_FRAME_ALIGN_HORZ_LEFT:
326 aMgr.SetHorzOrientation( text::HoriOrientation::LEFT );
327 break;
329 case FN_SET_FRM_POSITION:
331 aMgr.SetAbsPos(static_cast<const SfxPointItem &>(pArgs->Get
332 (FN_SET_FRM_POSITION)).GetValue());
334 break;
335 case SID_ATTR_BRUSH:
337 if(pArgs)
339 aMgr.SetAttrSet( *pArgs );
340 bCopyToFormat = true;
343 break;
344 case SID_ATTR_ULSPACE:
345 case SID_ATTR_LRSPACE:
347 if(pArgs && SfxItemState::SET == pArgs->GetItemState(GetPool().GetWhichIDFromSlotID(nSlot), false, &pItem))
349 aMgr.SetAttrSet( *pArgs );
350 bCopyToFormat = true;
353 break;
355 case SID_ATTR_TRANSFORM:
357 bool bApplyNewPos = false;
358 bool bApplyNewSize = false;
360 Point aNewPos = aMgr.GetPos();
361 if (pArgs)
363 if (const SfxInt32Item* pXItem = pArgs->GetItemIfSet(SID_ATTR_TRANSFORM_POS_X, false))
365 aNewPos.setX( pXItem->GetValue() );
366 bApplyNewPos = true;
368 if (const SfxInt32Item* pYItem = pArgs->GetItemIfSet(SID_ATTR_TRANSFORM_POS_Y, false))
370 aNewPos.setY( pYItem->GetValue() );
371 bApplyNewPos = true;
375 Size aNewSize = aMgr.GetSize();
376 if (pArgs)
378 if (const SfxUInt32Item* pWidthItem = pArgs->GetItemIfSet(SID_ATTR_TRANSFORM_WIDTH, false))
380 aNewSize.setWidth( pWidthItem->GetValue() );
381 bApplyNewSize = true;
383 if (const SfxUInt32Item* pHeightItem = pArgs->GetItemIfSet(SID_ATTR_TRANSFORM_HEIGHT, false))
385 aNewSize.setHeight( pHeightItem->GetValue() );
386 bApplyNewSize = true;
390 if (pArgs && (pArgs->HasItem(SID_ATTR_TRANSFORM_ANGLE) || pArgs->HasItem(SID_ATTR_TRANSFORM_DELTA_ANGLE)))
392 SfxItemSetFixed<RES_GRFATR_ROTATION, RES_GRFATR_ROTATION> aSet(rSh.GetAttrPool() );
393 rSh.GetCurAttr(aSet);
394 const SwRotationGrf& rRotation = aSet.Get(RES_GRFATR_ROTATION);
395 const Degree10 nOldRot(rRotation.GetValue());
397 if (const SdrAngleItem* pAngleItem = pArgs->GetItemIfSet(SID_ATTR_TRANSFORM_DELTA_ANGLE, false))
399 const Degree10 nDeltaRot = to<Degree10>(pAngleItem->GetValue());
400 aMgr.SetRotation(nOldRot, nOldRot + nDeltaRot, rRotation.GetUnrotatedSize());
403 // RotGrfFlyFrame: Get Value and disable is in SwGrfShell::GetAttrStateForRotation, but the
404 // value setter uses SID_ATTR_TRANSFORM and a group of three values. Rotation is
405 // added now, so use it in this central place. Do no forget to convert angle from
406 // 100th degrees in SID_ATTR_TRANSFORM_ANGLE to 10th degrees in RES_GRFATR_ROTATION
407 if (const SdrAngleItem* pTransformItem = pArgs->GetItemIfSet(SID_ATTR_TRANSFORM_ANGLE, false))
409 const Degree10 nNewRot = to<Degree10>(pTransformItem->GetValue());
411 // RotGrfFlyFrame: Rotation change here, SwFlyFrameAttrMgr aMgr is available
412 aMgr.SetRotation(nOldRot, nNewRot, rRotation.GetUnrotatedSize());
416 if (bApplyNewPos)
418 aMgr.SetAbsPos(aNewPos);
420 if ( bApplyNewSize )
422 aMgr.SetSize( aNewSize );
424 if (!bApplyNewPos && !bApplyNewSize)
426 bUpdateMgr = false;
430 break;
432 case FN_FORMAT_FRAME_DLG:
433 case FN_DRAW_WRAP_DLG:
435 const SelectionType nSel = rSh.GetSelectionType();
436 if (nSel & SelectionType::Graphic)
438 rSh.GetView().GetViewFrame().GetDispatcher()->Execute(FN_FORMAT_GRAFIC_DLG);
439 bUpdateMgr = false;
441 else
443 SfxItemSetFixed<
444 RES_FRMATR_BEGIN, RES_FRMATR_END - 1,
445 // FillAttribute support:
446 XATTR_FILL_FIRST, XATTR_FILL_LAST,
447 SID_DOCFRAME, SID_DOCFRAME,
448 SID_ATTR_BRUSH, SID_ATTR_BRUSH,
449 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
450 SID_ATTR_LRSPACE, SID_ATTR_ULSPACE,
451 SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
452 // Items to hand over XPropertyList things like
453 // XColorList, XHatchList, XGradientList, and
454 // XBitmapList to the Area TabPage
455 SID_COLOR_TABLE, SID_PATTERN_LIST,
456 SID_HTML_MODE, SID_HTML_MODE,
457 FN_GET_PRINT_AREA, FN_GET_PRINT_AREA,
458 FN_SURROUND, FN_KEEP_ASPECT_RATIO,
459 FN_SET_FRM_ALT_NAME, FN_SET_FRM_ALT_NAME,
460 FN_UNO_DESCRIPTION, FN_UNO_DESCRIPTION,
461 FN_OLE_IS_MATH, FN_MATH_BASELINE_ALIGNMENT,
462 FN_PARAM_CHAIN_PREVIOUS, FN_PARAM_CHAIN_NEXT> aSet( GetPool() );
464 // create needed items for XPropertyList entries from the DrawModel so that
465 // the Area TabPage can access them
466 const SwDrawModel* pDrawModel = rSh.GetView().GetDocShell()->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel();
467 pDrawModel->PutAreaListItems(aSet);
469 const SwViewOption* pVOpt = rSh.GetViewOptions();
470 if(nSel & SelectionType::Ole)
471 aSet.Put( SfxBoolItem(FN_KEEP_ASPECT_RATIO, pVOpt->IsKeepRatio()) );
472 aSet.Put(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(GetView().GetDocShell())));
473 aSet.Put(SfxStringItem(FN_SET_FRM_NAME, rSh.GetFlyName()));
474 aSet.Put(SfxStringItem(FN_UNO_DESCRIPTION, rSh.GetObjDescription()));
475 if( nSel & SelectionType::Ole )
477 // #i73249#
478 aSet.Put( SfxStringItem( FN_SET_FRM_ALT_NAME, rSh.GetObjTitle() ) );
481 const SwRect &rPg = rSh.GetAnyCurRect(CurRectType::Page);
482 SwFormatFrameSize aFrameSize(SwFrameSize::Variable, rPg.Width(), rPg.Height());
483 aFrameSize.SetWhich(GetPool().GetWhichIDFromSlotID(SID_ATTR_PAGE_SIZE));
484 aSet.Put(aFrameSize);
486 const SwRect &rPr = rSh.GetAnyCurRect(CurRectType::PagePrt);
487 SwFormatFrameSize aPrtSize(SwFrameSize::Variable, rPr.Width(), rPr.Height());
488 aPrtSize.SetWhich(GetPool().GetWhichIDFromSlotID(FN_GET_PRINT_AREA));
489 aSet.Put(aPrtSize);
491 aSet.Put(aMgr.GetAttrSet());
492 aSet.SetParent( aMgr.GetAttrSet().GetParent() );
494 // On % values initialize size
495 SwFormatFrameSize& rSize = const_cast<SwFormatFrameSize&>(aSet.Get(RES_FRM_SIZE));
496 if (rSize.GetWidthPercent() && rSize.GetWidthPercent() != SwFormatFrameSize::SYNCED)
497 rSize.SetWidth(rSh.GetAnyCurRect(CurRectType::FlyEmbedded).Width());
498 if (rSize.GetHeightPercent() && rSize.GetHeightPercent() != SwFormatFrameSize::SYNCED)
499 rSize.SetHeight(rSh.GetAnyCurRect(CurRectType::FlyEmbedded).Height());
501 // disable vertical positioning for Math Objects anchored 'as char' if baseline alignment is activated
502 aSet.Put( SfxBoolItem( FN_MATH_BASELINE_ALIGNMENT,
503 rSh.GetDoc()->getIDocumentSettingAccess().get( DocumentSettingId::MATH_BASELINE_ALIGNMENT ) ) );
504 const uno::Reference < embed::XEmbeddedObject > xObj( rSh.GetOleRef() );
505 aSet.Put( SfxBoolItem( FN_OLE_IS_MATH, xObj.is() && SotExchange::IsMath( xObj->getClassID() ) ) );
507 OUString sDefPage;
508 const SfxStringItem* pDlgItem;
509 if(pArgs && (pDlgItem = pArgs->GetItemIfSet(FN_FORMAT_FRAME_DLG, false)))
510 sDefPage = pDlgItem->GetValue();
512 aSet.Put(SfxFrameItem( SID_DOCFRAME, &GetView().GetViewFrame().GetFrame()));
513 FieldUnit eMetric = ::GetDfltMetric(dynamic_cast<SwWebView*>( &GetView()) != nullptr );
514 SwModule* mod = SwModule::get();
515 mod->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast<sal_uInt16>(eMetric)));
516 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
517 ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateFrameTabDialog(
518 nSel & SelectionType::Graphic ? u"PictureDialog"_ustr :
519 nSel & SelectionType::Ole ? u"ObjectDialog"_ustr:
520 u"FrameDialog"_ustr,
521 GetView().GetViewFrame(),
522 GetView().GetFrameWeld(),
523 aSet,
524 false,
525 sDefPage));
527 if ( nSlot == FN_DRAW_WRAP_DLG )
529 pDlg->SetCurPageId(u"wrap"_ustr);
532 if ( pDlg->Execute() )
534 const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
535 if(pOutSet)
537 rReq.Done(*pOutSet);
538 const SfxBoolItem* pRatioItem = nullptr;
539 if(nSel & SelectionType::Ole &&
540 (pRatioItem = pOutSet->GetItemIfSet(FN_KEEP_ASPECT_RATIO)))
542 SwViewOption aUsrPref( *pVOpt );
543 aUsrPref.SetKeepRatio(pRatioItem->GetValue());
544 mod->ApplyUsrPref(aUsrPref, &GetView());
546 if (const SfxStringItem* pAltNameItem = pOutSet->GetItemIfSet(FN_SET_FRM_ALT_NAME))
548 // #i73249#
549 rSh.SetObjTitle(pAltNameItem->GetValue());
551 if (const SfxStringItem* pDescripItem = pOutSet->GetItemIfSet(FN_UNO_DESCRIPTION))
552 rSh.SetObjDescription(pDescripItem->GetValue());
554 // Template AutoUpdate
555 SwFrameFormat* pFormat = rSh.GetSelectedFrameFormat();
556 if(pFormat && pFormat->IsAutoUpdateOnDirectFormat())
558 rSh.AutoUpdateFrame(pFormat, *pOutSet);
559 // Anything which is not supported by the format must be set hard.
560 if(const SfxStringItem* pFrameName = pOutSet->GetItemIfSet(FN_SET_FRM_NAME, false))
561 rSh.SetFlyName(pFrameName->GetValue());
562 SfxItemSetFixed<
563 RES_FRM_SIZE, RES_FRM_SIZE,
564 RES_SURROUND, RES_ANCHOR> aShellSet( GetPool() );
565 aShellSet.Put(*pOutSet);
566 aMgr.SetAttrSet(aShellSet);
567 if(const SfxStringItem* pFrameName = pOutSet->GetItemIfSet(FN_SET_FRM_NAME, false))
568 rSh.SetFlyName(pFrameName->GetValue());
570 else
571 aMgr.SetAttrSet( *pOutSet );
573 const SwFrameFormat* pCurrFlyFormat = rSh.GetFlyFrameFormat();
574 if(const SfxStringItem* pPreviousItem =
575 pOutSet->GetItemIfSet(FN_PARAM_CHAIN_PREVIOUS, false))
577 rSh.HideChainMarker();
579 OUString sPrevName = pPreviousItem->GetValue();
580 const SwFormatChain &rChain = pCurrFlyFormat->GetChain();
581 //needs cast - no non-const method available
582 SwFlyFrameFormat* pFlyFormat =
583 rChain.GetPrev();
584 if(pFlyFormat)
586 if (pFlyFormat->GetName() != sPrevName)
588 rSh.Unchain(*pFlyFormat);
590 else
591 sPrevName.clear();
594 if (!sPrevName.isEmpty())
596 //needs cast - no non-const method available
597 SwFrameFormat* pPrevFormat = rSh.GetDoc()->GetFlyFrameFormatByName(sPrevName);
598 SAL_WARN_IF(!pPrevFormat, "sw.ui", "No frame found!");
599 if(pPrevFormat)
601 rSh.Chain(*pPrevFormat, *pCurrFlyFormat);
604 rSh.SetChainMarker();
606 if(const SfxStringItem* pChainNextItem =
607 pOutSet->GetItemIfSet(FN_PARAM_CHAIN_NEXT, false))
609 rSh.HideChainMarker();
610 OUString sNextName = pChainNextItem->GetValue();
611 const SwFormatChain &rChain = pCurrFlyFormat->GetChain();
612 //needs cast - no non-const method available
613 SwFlyFrameFormat* pFlyFormat =
614 rChain.GetNext();
615 if(pFlyFormat)
617 if (pFlyFormat->GetName() != sNextName)
619 rSh.Unchain(*const_cast<SwFlyFrameFormat*>(static_cast<const SwFlyFrameFormat*>( pCurrFlyFormat)));
621 else
622 sNextName.clear();
625 if (!sNextName.isEmpty())
627 //needs cast - no non-const method available
628 SwFrameFormat* pNextFormat = rSh.GetDoc()->GetFlyFrameFormatByName(sNextName);
629 SAL_WARN_IF(!pNextFormat, "sw.ui", "No frame found!");
630 if(pNextFormat)
632 rSh.Chain(*const_cast<SwFrameFormat*>(
633 pCurrFlyFormat), *pNextFormat);
636 rSh.SetChainMarker();
640 else
641 bUpdateMgr = false;
644 break;
645 case FN_FRAME_MIRROR_ON_EVEN_PAGES:
647 SwFormatHoriOrient aHori(aMgr.GetHoriOrient());
648 bool bMirror = !aHori.IsPosToggle();
649 aHori.SetPosToggle(bMirror);
650 SfxItemSetFixed<RES_HORI_ORIENT, RES_HORI_ORIENT> aSet(GetPool());
651 aSet.Put(aHori);
652 aMgr.SetAttrSet(aSet);
653 bCopyToFormat = true;
654 rReq.SetReturnValue(SfxBoolItem(nSlot, bMirror));
656 break;
657 case FN_NAME_SHAPE:
659 bUpdateMgr = false;
660 SdrView* pSdrView = rSh.GetDrawViewWithValidMarkList();
661 if ( pSdrView &&
662 pSdrView->GetMarkedObjectList().GetMarkCount() == 1 )
664 OUString aName(rSh.GetFlyName());
665 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
666 VclPtr<AbstractSvxObjectNameDialog> pDlg(
667 pFact->CreateSvxObjectNameDialog(GetView().GetFrameWeld(), aName));
669 pDlg->StartExecuteAsync(
670 [this, pDlg] (sal_Int32 nResult)->void
672 if (nResult == RET_OK)
673 GetShell().SetFlyName(pDlg->GetName());
674 pDlg->disposeOnce();
679 break;
680 // #i73249#
681 case FN_TITLE_DESCRIPTION_SHAPE:
683 bUpdateMgr = false;
684 SdrView* pSdrView = rSh.GetDrawViewWithValidMarkList();
685 if ( pSdrView &&
686 pSdrView->GetMarkedObjectList().GetMarkCount() == 1 )
688 OUString aDescription(rSh.GetObjDescription());
689 OUString aTitle(rSh.GetObjTitle());
690 bool isDecorative(rSh.IsObjDecorative());
692 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
693 VclPtr<AbstractSvxObjectTitleDescDialog> pDlg(
694 pFact->CreateSvxObjectTitleDescDialog(GetView().GetFrameWeld(),
695 aTitle, aDescription, isDecorative));
697 pDlg->StartExecuteAsync(
698 [this, pDlg] (sal_Int32 nResult)->void
700 if (nResult == RET_OK)
702 GetShell().SetObjDescription(pDlg->GetDescription());
703 GetShell().SetObjTitle(pDlg->GetTitle());
704 GetShell().SetObjDecorative(pDlg->IsDecorative());
706 pDlg->disposeOnce();
711 break;
712 default:
713 assert(!"wrong dispatcher");
714 return;
716 if ( bUpdateMgr )
718 SwFrameFormat* pFormat = rSh.GetSelectedFrameFormat();
719 if ( bCopyToFormat && pFormat && pFormat->IsAutoUpdateOnDirectFormat() )
721 rSh.AutoUpdateFrame(pFormat, aMgr.GetAttrSet());
723 else
725 aMgr.UpdateFlyFrame();
731 void SwFrameShell::GetState(SfxItemSet& rSet)
733 SwWrtShell &rSh = GetShell();
734 bool bHtmlMode = 0 != ::GetHtmlMode(rSh.GetView().GetDocShell());
735 if (!rSh.IsFrameSelected())
736 return;
738 SfxItemSetFixed<
739 RES_LR_SPACE, RES_UL_SPACE,
740 RES_PRINT, RES_HORI_ORIENT> aSet(rSh.GetAttrPool() );
741 rSh.GetFlyFrameAttr( aSet );
743 bool bProtect = rSh.IsSelObjProtected(FlyProtectFlags::Pos) != FlyProtectFlags::NONE;
744 bool bParentCntProt = rSh.IsSelObjProtected( FlyProtectFlags::Content|FlyProtectFlags::Parent ) != FlyProtectFlags::NONE;
746 bProtect |= bParentCntProt;
748 const FrameTypeFlags eFrameType = rSh.GetFrameType(nullptr,true);
749 SwFlyFrameAttrMgr aMgr( false, &rSh, Frmmgr_Type::NONE, nullptr );
751 SfxWhichIter aIter( rSet );
752 sal_uInt16 nWhich = aIter.FirstWhich();
753 while ( nWhich )
755 switch ( nWhich )
757 case RES_FRM_SIZE:
759 const SwFormatFrameSize& aSz(aMgr.GetFrameSize());
760 rSet.Put(aSz);
762 break;
763 case RES_VERT_ORIENT:
764 case RES_HORI_ORIENT:
765 case SID_ATTR_ULSPACE:
766 case SID_ATTR_LRSPACE:
767 case RES_LR_SPACE:
768 case RES_UL_SPACE:
769 case RES_PROTECT:
770 case RES_OPAQUE:
771 case RES_PRINT:
772 case RES_SURROUND:
774 rSet.Put(aSet.Get(GetPool().GetWhichIDFromSlotID(nWhich)));
776 break;
777 case SID_OBJECT_ALIGN:
779 if ( bProtect )
780 rSet.DisableItem( nWhich );
782 break;
783 case SID_OBJECT_ALIGN_LEFT :
784 case SID_OBJECT_ALIGN_CENTER :
785 case SID_OBJECT_ALIGN_RIGHT :
786 case FN_FRAME_ALIGN_HORZ_CENTER:
787 case FN_FRAME_ALIGN_HORZ_RIGHT:
788 case FN_FRAME_ALIGN_HORZ_LEFT:
789 if ( (eFrameType & FrameTypeFlags::FLY_INCNT) ||
790 bProtect ||
791 ((nWhich == FN_FRAME_ALIGN_HORZ_CENTER || nWhich == SID_OBJECT_ALIGN_CENTER) &&
792 bHtmlMode ))
794 rSet.DisableItem( nWhich );
796 else
798 sal_Int16 nHoriOrient = -1;
799 switch(nWhich)
801 case SID_OBJECT_ALIGN_LEFT:
802 nHoriOrient = text::HoriOrientation::LEFT;
803 break;
804 case SID_OBJECT_ALIGN_CENTER:
805 nHoriOrient = text::HoriOrientation::CENTER;
806 break;
807 case SID_OBJECT_ALIGN_RIGHT:
808 nHoriOrient = text::HoriOrientation::RIGHT;
809 break;
810 default:
811 break;
813 const SwFormatHoriOrient& aHOrient(aMgr.GetHoriOrient());
814 if (nHoriOrient != -1)
815 rSet.Put(SfxBoolItem(nWhich, nHoriOrient == aHOrient.GetHoriOrient()));
817 break;
818 case FN_FRAME_ALIGN_VERT_ROW_TOP:
819 case FN_FRAME_ALIGN_VERT_ROW_CENTER:
820 case FN_FRAME_ALIGN_VERT_ROW_BOTTOM:
821 case FN_FRAME_ALIGN_VERT_CHAR_TOP:
822 case FN_FRAME_ALIGN_VERT_CHAR_CENTER:
823 case FN_FRAME_ALIGN_VERT_CHAR_BOTTOM:
824 if ( !(eFrameType & FrameTypeFlags::FLY_INCNT) || bProtect
825 || (bHtmlMode && FN_FRAME_ALIGN_VERT_CHAR_BOTTOM == nWhich) )
826 rSet.DisableItem( nWhich );
827 break;
829 case SID_OBJECT_ALIGN_UP :
830 case SID_OBJECT_ALIGN_MIDDLE :
831 case SID_OBJECT_ALIGN_DOWN :
833 case FN_FRAME_ALIGN_VERT_TOP:
834 case FN_FRAME_ALIGN_VERT_CENTER:
835 case FN_FRAME_ALIGN_VERT_BOTTOM:
836 if ( bProtect || (bHtmlMode && eFrameType & FrameTypeFlags::FLY_ATCNT))
837 rSet.DisableItem( nWhich );
838 else
840 // These slots need different labels depending on whether they are anchored in a character
841 // or on a paragraph/page etc.
842 OUString sNewLabel;
843 if (eFrameType & FrameTypeFlags::FLY_INCNT)
845 switch (nWhich)
847 case SID_OBJECT_ALIGN_UP :
848 case FN_FRAME_ALIGN_VERT_TOP:
849 sNewLabel = SwResId(STR_FRMUI_TOP_BASE);
850 break;
851 case SID_OBJECT_ALIGN_MIDDLE :
852 case FN_FRAME_ALIGN_VERT_CENTER:
853 sNewLabel = SwResId(STR_FRMUI_CENTER_BASE);
854 break;
855 case SID_OBJECT_ALIGN_DOWN :
856 case FN_FRAME_ALIGN_VERT_BOTTOM:
857 if(!bHtmlMode)
858 sNewLabel = SwResId(STR_FRMUI_BOTTOM_BASE);
859 else
860 rSet.DisableItem( nWhich );
861 break;
864 else
866 if (nWhich != FN_FRAME_ALIGN_VERT_TOP &&
867 nWhich != SID_OBJECT_ALIGN_UP )
869 if (aMgr.GetAnchor() == RndStdIds::FLY_AT_FLY)
871 const SwFrameFormat* pFormat = rSh.IsFlyInFly();
872 if (pFormat)
874 const SwFormatFrameSize& rFrameSz = pFormat->GetFrameSize();
875 if (rFrameSz.GetHeightSizeType() != SwFrameSize::Fixed)
877 rSet.DisableItem( nWhich );
878 break;
883 OUString aModuleName;
884 if (SfxViewFrame* pFrame = GetFrame())
885 aModuleName = vcl::CommandInfoProvider::GetModuleIdentifier(pFrame->GetFrame().GetFrameInterface());
886 switch (nWhich)
888 case SID_OBJECT_ALIGN_UP :
889 case FN_FRAME_ALIGN_VERT_TOP:
891 auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(u".uno:AlignTop"_ustr, aModuleName);
892 sNewLabel = vcl::CommandInfoProvider::GetLabelForCommand(aProperties);
893 break;
895 case SID_OBJECT_ALIGN_MIDDLE:
896 case FN_FRAME_ALIGN_VERT_CENTER:
898 auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(u".uno:AlignVerticalCenter"_ustr, aModuleName);
899 sNewLabel = vcl::CommandInfoProvider::GetLabelForCommand(aProperties);
900 break;
902 case SID_OBJECT_ALIGN_DOWN:
903 case FN_FRAME_ALIGN_VERT_BOTTOM:
905 auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(u".uno:AlignBottom"_ustr, aModuleName);
906 sNewLabel = vcl::CommandInfoProvider::GetLabelForCommand(aProperties);
907 break;
911 if ( !sNewLabel.isEmpty() )
912 rSet.Put( SfxStringItem( nWhich, sNewLabel ));
914 break;
915 case SID_HYPERLINK_GETLINK:
917 SvxHyperlinkItem aHLinkItem;
919 SfxItemSetFixed<RES_URL, RES_URL> aURLSet(GetPool());
920 rSh.GetFlyFrameAttr( aURLSet );
922 if(const SwFormatURL* pFormatURL = aURLSet.GetItemIfSet(RES_URL))
924 aHLinkItem.SetURL(pFormatURL->GetURL());
925 aHLinkItem.SetTargetFrame(pFormatURL->GetTargetFrameName());
926 aHLinkItem.SetName(rSh.GetFlyName());
929 aHLinkItem.SetInsertMode(static_cast<SvxLinkInsertMode>(aHLinkItem.GetInsertMode() |
930 (bHtmlMode ? HLINK_HTMLMODE : 0)));
932 rSet.Put(aHLinkItem);
934 break;
936 case FN_FRAME_CHAIN:
938 const SelectionType nSel = rSh.GetSelectionType();
939 if (nSel & SelectionType::Graphic || nSel & SelectionType::Ole)
940 rSet.DisableItem( FN_FRAME_CHAIN );
941 else
943 const SwFrameFormat *pFormat = rSh.GetFlyFrameFormat();
944 if ( bParentCntProt || rSh.GetView().GetEditWin().GetApplyTemplate() ||
945 !pFormat || pFormat->GetChain().GetNext() )
947 rSet.DisableItem( FN_FRAME_CHAIN );
949 else
951 bool bChainMode = rSh.GetView().GetEditWin().IsChainMode();
952 rSet.Put( SfxBoolItem( FN_FRAME_CHAIN, bChainMode ) );
956 break;
957 case FN_FRAME_UNCHAIN:
959 const SelectionType nSel = rSh.GetSelectionType();
960 if (nSel & SelectionType::Graphic || nSel & SelectionType::Ole)
961 rSet.DisableItem( FN_FRAME_UNCHAIN );
962 else
964 const SwFrameFormat *pFormat = rSh.GetFlyFrameFormat();
965 if ( bParentCntProt || rSh.GetView().GetEditWin().GetApplyTemplate() ||
966 !pFormat || !pFormat->GetChain().GetNext() )
968 rSet.DisableItem( FN_FRAME_UNCHAIN );
972 break;
973 case SID_FRAME_TO_TOP:
974 case SID_FRAME_TO_BOTTOM:
975 case FN_FRAME_UP:
976 case FN_FRAME_DOWN:
977 if ( bParentCntProt )
978 rSet.DisableItem( nWhich );
979 break;
981 case SID_ATTR_TRANSFORM:
983 rSet.DisableItem( nWhich );
985 break;
987 case SID_ATTR_TRANSFORM_PROTECT_SIZE:
989 const FlyProtectFlags eProtection = rSh.IsSelObjProtected( FlyProtectFlags::Size );
990 if ( ( eProtection & FlyProtectFlags::Content ) ||
991 ( eProtection & FlyProtectFlags::Size ) )
993 rSet.Put( SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_SIZE, true ) );
995 else
997 rSet.Put( SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_SIZE, false ) );
1000 break;
1002 case SID_ATTR_TRANSFORM_WIDTH:
1004 rSet.Put( SfxUInt32Item( SID_ATTR_TRANSFORM_WIDTH, aMgr.GetSize().getWidth() ) );
1006 break;
1008 case SID_ATTR_TRANSFORM_HEIGHT:
1010 rSet.Put( SfxUInt32Item( SID_ATTR_TRANSFORM_HEIGHT, aMgr.GetSize().getHeight() ) );
1012 break;
1014 case FN_FORMAT_FRAME_DLG:
1016 const SelectionType nSel = rSh.GetSelectionType();
1017 if ( bParentCntProt || nSel & SelectionType::Graphic)
1018 rSet.DisableItem( nWhich );
1020 break;
1021 // #i73249#
1022 case FN_TITLE_DESCRIPTION_SHAPE:
1023 case FN_NAME_SHAPE:
1025 SwWrtShell &rWrtSh = GetShell();
1026 SdrView* pSdrView = rWrtSh.GetDrawViewWithValidMarkList();
1027 if ( !pSdrView ||
1028 pSdrView->GetMarkedObjectList().GetMarkCount() != 1 )
1030 rSet.DisableItem( nWhich );
1033 break;
1035 case FN_POSTIT:
1037 SwFlyFrame* pFly = rSh.GetSelectedFlyFrame();
1038 if (pFly)
1040 SwFrameFormat* pFormat = pFly->GetFormat();
1041 if (pFormat)
1043 RndStdIds eAnchorId = pFormat->GetAnchor().GetAnchorId();
1044 // SwWrtShell::InsertPostIt() only works on as-char and at-char anchored
1045 // images.
1046 if (eAnchorId != RndStdIds::FLY_AS_CHAR && eAnchorId != RndStdIds::FLY_AT_CHAR)
1048 rSet.DisableItem(nWhich);
1053 break;
1055 default:
1056 /* do nothing */;
1057 break;
1059 nWhich = aIter.NextWhich();
1063 SwFrameShell::SwFrameShell(SwView &_rView) :
1064 SwBaseShell( _rView )
1066 SetName(u"Frame"_ustr);
1068 // #96392# Use this to announce it is the frame shell who creates the selection.
1069 SwTransferable::CreateSelection( _rView.GetWrtShell(), this );
1071 SfxShell::SetContextName(vcl::EnumContext::GetContextName(vcl::EnumContext::Context::Frame));
1074 SwFrameShell::~SwFrameShell()
1076 // #96392# Only clear the selection if it was this frame shell who created it.
1077 SwTransferable::ClearSelection( GetShell(), this );
1080 void SwFrameShell::ExecFrameStyle(SfxRequest const & rReq)
1082 SwWrtShell &rSh = GetShell();
1083 bool bDefault = false;
1084 if (!rSh.IsFrameSelected())
1085 return;
1086 // At first pick the default BoxItem out of the pool.
1087 // If unequal to regular box item, then it has already
1088 // been changed (New one is no default).
1089 const SvxBoxItem* pPoolBoxItem = ::GetDfltAttr(RES_BOX);
1091 const SfxItemSet *pArgs = rReq.GetArgs();
1092 SfxItemSetFixed<RES_BOX, RES_BOX> aFrameSet(rSh.GetAttrPool());
1094 rSh.GetFlyFrameAttr( aFrameSet );
1095 const SvxBoxItem& rBoxItem = aFrameSet.Get(RES_BOX);
1097 if (SfxPoolItem::areSame(pPoolBoxItem, &rBoxItem))
1098 bDefault = true;
1100 std::unique_ptr<SvxBoxItem> aBoxItem(rBoxItem.Clone());
1102 SvxBorderLine aBorderLine;
1104 if(pArgs) // Any controller can sometimes deliver nothing #48169#
1106 switch (rReq.GetSlot())
1108 case SID_ATTR_BORDER:
1110 if (const SvxBoxItem* pBoxItem = pArgs->GetItemIfSet(RES_BOX))
1112 std::unique_ptr<SvxBoxItem> aNewBox(pBoxItem->Clone());
1113 const SvxBorderLine* pBorderLine;
1115 pBorderLine = aBoxItem->GetTop();
1116 if (pBorderLine != nullptr)
1117 lcl_FrameGetMaxLineWidth(pBorderLine, aBorderLine);
1118 pBorderLine = aBoxItem->GetBottom();
1119 if (pBorderLine != nullptr)
1120 lcl_FrameGetMaxLineWidth(pBorderLine, aBorderLine);
1121 pBorderLine = aBoxItem->GetLeft();
1122 if (pBorderLine != nullptr)
1123 lcl_FrameGetMaxLineWidth(pBorderLine, aBorderLine);
1124 pBorderLine = aBoxItem->GetRight();
1125 if (pBorderLine != nullptr)
1126 lcl_FrameGetMaxLineWidth(pBorderLine, aBorderLine);
1128 if(aBorderLine.GetOutWidth() == 0)
1130 aBorderLine.SetBorderLineStyle(
1131 SvxBorderLineStyle::SOLID);
1132 aBorderLine.SetWidth( SvxBorderLineWidth::Hairline );
1134 //Set distance only if the request is received from the controller.
1136 #if HAVE_FEATURE_SCRIPTING
1137 if(!StarBASIC::IsRunning())
1138 #endif
1140 // TODO: should this copy 4 individual Dist instead?
1141 aNewBox->SetAllDistances(rBoxItem.GetSmallestDistance());
1144 aBoxItem = std::move(aNewBox);
1146 if( aBoxItem->GetTop() != nullptr )
1147 aBoxItem->SetLine(&aBorderLine, SvxBoxItemLine::TOP);
1148 if( aBoxItem->GetBottom() != nullptr )
1149 aBoxItem->SetLine(&aBorderLine, SvxBoxItemLine::BOTTOM);
1150 if( aBoxItem->GetLeft() != nullptr )
1151 aBoxItem->SetLine(&aBorderLine, SvxBoxItemLine::LEFT);
1152 if( aBoxItem->GetRight() != nullptr )
1153 aBoxItem->SetLine(&aBorderLine, SvxBoxItemLine::RIGHT);
1156 break;
1158 case SID_FRAME_LINESTYLE:
1160 if ( const SvxLineItem* pLineItem = pArgs->GetItemIfSet(SID_FRAME_LINESTYLE, false))
1162 if ( pLineItem->GetLine() )
1164 aBorderLine = *(pLineItem->GetLine());
1166 if (!aBoxItem->GetTop() && !aBoxItem->GetBottom() &&
1167 !aBoxItem->GetLeft() && !aBoxItem->GetRight())
1169 aBoxItem->SetLine(&aBorderLine, SvxBoxItemLine::TOP);
1170 aBoxItem->SetLine(&aBorderLine, SvxBoxItemLine::BOTTOM);
1171 aBoxItem->SetLine(&aBorderLine, SvxBoxItemLine::LEFT);
1172 aBoxItem->SetLine(&aBorderLine, SvxBoxItemLine::RIGHT);
1174 else
1176 if( aBoxItem->GetTop() )
1178 aBorderLine.SetColor( aBoxItem->GetTop()->GetColor() );
1179 aBoxItem->SetLine(&aBorderLine, SvxBoxItemLine::TOP);
1181 if( aBoxItem->GetBottom() )
1183 aBorderLine.SetColor( aBoxItem->GetBottom()->GetColor());
1184 aBoxItem->SetLine(&aBorderLine, SvxBoxItemLine::BOTTOM);
1186 if( aBoxItem->GetLeft() )
1188 aBorderLine.SetColor( aBoxItem->GetLeft()->GetColor());
1189 aBoxItem->SetLine(&aBorderLine, SvxBoxItemLine::LEFT);
1191 if( aBoxItem->GetRight() )
1193 aBorderLine.SetColor(aBoxItem->GetRight()->GetColor());
1194 aBoxItem->SetLine(&aBorderLine, SvxBoxItemLine::RIGHT);
1198 else
1200 aBoxItem->SetLine(nullptr, SvxBoxItemLine::TOP);
1201 aBoxItem->SetLine(nullptr, SvxBoxItemLine::BOTTOM);
1202 aBoxItem->SetLine(nullptr, SvxBoxItemLine::LEFT);
1203 aBoxItem->SetLine(nullptr, SvxBoxItemLine::RIGHT);
1207 break;
1209 case SID_FRAME_LINECOLOR:
1211 if (const SvxColorItem* pColorItem = pArgs->GetItemIfSet(SID_FRAME_LINECOLOR, false))
1213 const Color& rNewColor = pColorItem->GetValue();
1215 if (!aBoxItem->GetTop() && !aBoxItem->GetBottom() &&
1216 !aBoxItem->GetLeft() && !aBoxItem->GetRight())
1218 aBorderLine.SetColor( rNewColor );
1219 aBorderLine.SetBorderLineStyle(SvxBorderLineStyle::SOLID);
1220 aBorderLine.SetWidth(SvxBorderLineWidth::Hairline);
1222 aBoxItem->SetLine(&aBorderLine, SvxBoxItemLine::TOP);
1223 aBoxItem->SetLine(&aBorderLine, SvxBoxItemLine::BOTTOM);
1224 aBoxItem->SetLine(&aBorderLine, SvxBoxItemLine::LEFT);
1225 aBoxItem->SetLine(&aBorderLine, SvxBoxItemLine::RIGHT);
1227 else
1229 if (aBoxItem->GetTop())
1230 aBoxItem->GetTop()->SetColor(rNewColor);
1231 if (aBoxItem->GetBottom())
1232 aBoxItem->GetBottom()->SetColor(rNewColor);
1233 if (aBoxItem->GetLeft())
1234 aBoxItem->GetLeft()->SetColor(rNewColor);
1235 if (aBoxItem->GetRight())
1236 aBoxItem->GetRight()->SetColor(rNewColor);
1240 break;
1243 if (bDefault && (aBoxItem->GetTop() || aBoxItem->GetBottom() ||
1244 aBoxItem->GetLeft() || aBoxItem->GetRight()))
1246 aBoxItem->SetAllDistances(MIN_BORDER_DIST);
1248 aFrameSet.Put( std::move(aBoxItem) );
1249 // Template AutoUpdate
1250 SwFrameFormat* pFormat = rSh.GetSelectedFrameFormat();
1251 if(pFormat && pFormat->IsAutoUpdateOnDirectFormat())
1253 rSh.AutoUpdateFrame(pFormat, aFrameSet);
1255 else
1256 rSh.SetFlyFrameAttr( aFrameSet );
1260 static void lcl_FrameGetMaxLineWidth(const SvxBorderLine* pBorderLine, SvxBorderLine& rBorderLine)
1262 if(pBorderLine->GetWidth() > rBorderLine.GetWidth())
1263 rBorderLine.SetWidth(pBorderLine->GetWidth());
1265 rBorderLine.SetBorderLineStyle(pBorderLine->GetBorderLineStyle());
1266 rBorderLine.SetColor(pBorderLine->GetColor());
1269 void SwFrameShell::GetLineStyleState(SfxItemSet &rSet)
1271 SwWrtShell &rSh = GetShell();
1272 bool bParentCntProt = rSh.IsSelObjProtected( FlyProtectFlags::Content|FlyProtectFlags::Parent ) != FlyProtectFlags::NONE;
1274 if (bParentCntProt)
1276 if (rSh.IsFrameSelected())
1277 rSet.DisableItem( SID_FRAME_LINECOLOR );
1279 rSet.DisableItem( SID_ATTR_BORDER );
1280 rSet.DisableItem( SID_FRAME_LINESTYLE );
1282 else
1284 if (rSh.IsFrameSelected())
1286 SfxItemSetFixed<RES_BOX, RES_BOX> aFrameSet( rSh.GetAttrPool() );
1288 rSh.GetFlyFrameAttr(aFrameSet);
1290 const SvxBorderLine* pLine = aFrameSet.Get(RES_BOX).GetTop();
1291 rSet.Put(SvxColorItem(pLine ? pLine->GetColor() : Color(), SID_FRAME_LINECOLOR));
1296 void SwFrameShell::StateInsert(SfxItemSet &rSet)
1298 const SelectionType nSel = GetShell().GetSelectionType();
1299 if ( (nSel & SelectionType::Graphic)
1300 || (nSel & SelectionType::Ole) )
1302 rSet.DisableItem(FN_INSERT_FRAME);
1304 else if ( GetShell().CursorInsideInputField() )
1306 rSet.DisableItem(FN_INSERT_FRAME);
1310 void SwFrameShell::GetDrawAttrStateTextFrame(SfxItemSet &rSet)
1312 SwWrtShell &rSh = GetShell();
1314 if(rSh.IsFrameSelected())
1316 rSh.GetFlyFrameAttr(rSet);
1318 else
1320 SdrView* pSdrView = rSh.GetDrawViewWithValidMarkList();
1322 if(pSdrView)
1324 rSet.Put(pSdrView->GetDefaultAttr());
1329 void SwFrameShell::ExecDrawAttrArgsTextFrame(SfxRequest const & rReq)
1331 const SfxItemSet* pArgs = rReq.GetArgs();
1332 SwWrtShell& rSh = GetShell();
1334 if(pArgs)
1336 if(rSh.IsFrameSelected())
1338 rSh.SetFlyFrameAttr(const_cast< SfxItemSet& >(*pArgs));
1340 else
1342 SdrView* pSdrView = rSh.GetDrawViewWithValidMarkList();
1344 if(pSdrView)
1346 pSdrView->SetDefaultAttr(*pArgs, false);
1350 else
1352 SfxDispatcher* pDis = rSh.GetView().GetViewFrame().GetDispatcher();
1354 switch(rReq.GetSlot())
1356 case SID_ATTR_FILL_STYLE:
1357 case SID_ATTR_FILL_COLOR:
1358 case SID_ATTR_FILL_GRADIENT:
1359 case SID_ATTR_FILL_HATCH:
1360 case SID_ATTR_FILL_BITMAP:
1361 case SID_ATTR_FILL_TRANSPARENCE:
1362 case SID_ATTR_FILL_FLOATTRANSPARENCE:
1364 pDis->Execute(SID_ATTRIBUTES_AREA);
1365 break;
1371 void SwFrameShell::ExecDrawDlgTextFrame(SfxRequest const & rReq)
1373 switch(rReq.GetSlot())
1375 case SID_ATTRIBUTES_AREA:
1377 SwWrtShell& rSh = GetShell();
1379 if(rSh.IsFrameSelected())
1381 SdrModel& rModel = rSh.GetDrawView()->GetModel();
1382 SfxItemSet aNewAttr(rModel.GetItemPool());
1384 // get attributes from FlyFrame
1385 rSh.GetFlyFrameAttr(aNewAttr);
1387 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1388 VclPtr<AbstractSvxAreaTabDialog> pDlg(pFact->CreateSvxAreaTabDialog(
1389 GetView().GetFrameWeld(),
1390 &aNewAttr,
1391 &rModel,
1392 false,
1393 false));
1395 pDlg->StartExecuteAsync([pDlg, this](sal_Int32 nResult){
1396 if(nResult == RET_OK)
1398 // set attributes at FlyFrame
1399 GetShell().SetFlyFrameAttr(const_cast< SfxItemSet& >(*pDlg->GetOutputItemSet()));
1401 static sal_uInt16 aInval[] =
1403 SID_ATTR_FILL_STYLE,
1404 SID_ATTR_FILL_COLOR,
1405 SID_ATTR_FILL_TRANSPARENCE,
1406 SID_ATTR_FILL_FLOATTRANSPARENCE,
1410 SfxBindings &rBnd = GetView().GetViewFrame().GetBindings();
1412 rBnd.Invalidate(aInval);
1413 rBnd.Update(SID_ATTR_FILL_STYLE);
1414 rBnd.Update(SID_ATTR_FILL_COLOR);
1415 rBnd.Update(SID_ATTR_FILL_TRANSPARENCE);
1416 rBnd.Update(SID_ATTR_FILL_FLOATTRANSPARENCE);
1418 pDlg->disposeOnce();
1422 break;
1427 void SwFrameShell::DisableStateTextFrame(SfxItemSet &rSet)
1429 SfxWhichIter aIter(rSet);
1430 sal_uInt16 nWhich(aIter.FirstWhich());
1432 while(nWhich)
1434 switch(nWhich)
1436 case SID_ATTRIBUTES_AREA:
1438 SwWrtShell& rSh = GetShell();
1440 if(!rSh.IsFrameSelected())
1442 rSet.DisableItem(nWhich);
1445 break;
1447 default:
1449 rSet.DisableItem(nWhich);
1450 break;
1454 nWhich = aIter.NextWhich();
1458 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */