1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
44 #include <drawdoc.hxx>
45 #include <IDocumentSettingAccess.hxx>
46 #include <IDocumentDrawModelAccess.hxx>
48 #include <fmtclds.hxx>
49 #include <fmtcnct.hxx>
50 #include <swmodule.hxx>
58 #include <swdtflvr.hxx>
59 #include <viewopt.hxx>
62 #include <strings.hrc>
63 #include <swabstdlg.hxx>
65 #include <svx/svxdlg.hxx>
68 #include <svx/drawitem.hxx>
71 #define ShellClass_SwFrameShell
72 #include <sfx2/msg.hxx>
73 #include <swslots.hxx>
78 using ::editeng::SvxBorderLine
;
79 using namespace ::com::sun::star
;
80 using namespace ::com::sun::star::uno
;
83 static void lcl_FrameGetMaxLineWidth(const SvxBorderLine
* pBorderLine
, SvxBorderLine
& rBorderLine
);
84 static const SwFrameFormat
* lcl_GetFrameFormatByName(SwWrtShell
const & rSh
, std::u16string_view rName
)
86 const size_t nCount
= rSh
.GetFlyCount(FLYCNTTYPE_FRM
);
87 for( size_t i
= 0; i
< nCount
; ++i
)
89 const SwFrameFormat
* pFormat
= rSh
.GetFlyNum(i
, FLYCNTTYPE_FRM
);
90 if(pFormat
->GetName() == rName
)
96 SFX_IMPL_INTERFACE(SwFrameShell
, SwBaseShell
)
98 void SwFrameShell::InitInterface_Impl()
100 GetStaticInterface()->RegisterPopupMenu("frame");
102 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT
, SfxVisibilityFlags::Invisible
, ToolbarId::Frame_Toolbox
);
105 void SwFrameShell::ExecMove(SfxRequest
& rReq
)
107 SwWrtShell
& rSh
= GetShell();
108 sal_uInt16 nSlot
= rReq
.GetSlot();
118 void SwFrameShell::ExecField(const SfxRequest
& rReq
)
120 SwWrtShell
& rSh
= GetShell();
121 sal_uInt16 nSlot
= rReq
.GetSlot();
125 SwFieldMgr
aFieldMgr(&rSh
);
126 rSh
.InsertPostIt(aFieldMgr
, rReq
);
131 void SwFrameShell::Execute(SfxRequest
&rReq
)
133 //First those who do not need FrameMgr.
134 SwWrtShell
&rSh
= GetShell();
136 const SfxItemSet
* pArgs
= rReq
.GetArgs();
137 const SfxPoolItem
* pItem
;
138 sal_uInt16 nSlot
= rReq
.GetSlot();
142 case FN_FRAME_TO_ANCHOR
:
143 if ( rSh
.IsFrameSelected() )
150 case SID_FRAME_TO_TOP
:
151 rSh
.SelectionToTop();
154 case SID_FRAME_TO_BOTTOM
:
155 rSh
.SelectionToBottom();
159 rSh
.SelectionToTop( false );
163 rSh
.SelectionToBottom( false );
165 case FN_INSERT_FRAME
:
168 // Frame already exists, open frame dialog for editing.
169 SfxStringItem
aDefPage(FN_FORMAT_FRAME_DLG
, "columns");
170 rSh
.GetView().GetViewFrame().GetDispatcher()->ExecuteList(
172 SfxCallMode::SYNCHRON
|SfxCallMode::RECORD
,
178 // Frame already exists, only the number of columns will be changed.
179 sal_uInt16 nCols
= 1;
180 if(const SfxUInt16Item
* pColsItem
= pArgs
->GetItemIfSet(SID_ATTR_COLUMNS
, false))
181 nCols
= pColsItem
->GetValue();
183 SfxItemSetFixed
<RES_COL
,RES_COL
> aSet(GetPool());
184 rSh
.GetFlyFrameAttr( aSet
);
185 SwFormatCol
aCol(aSet
.Get(RES_COL
));
186 // GutterWidth will not always passed, hence get firstly
187 // (see view2: Execute on this slot)
188 sal_uInt16 nGutterWidth
= aCol
.GetGutterWidth();
191 aCol
.Init(nCols
, nGutterWidth
, aCol
.GetWishWidth());
193 // Template AutoUpdate
194 SwFrameFormat
* pFormat
= rSh
.GetSelectedFrameFormat();
195 if(pFormat
&& pFormat
->IsAutoUpdateOnDirectFormat())
197 rSh
.AutoUpdateFrame(pFormat
, aSet
);
201 rSh
.StartAllAction();
202 rSh
.SetFlyFrameAttr( aSet
);
210 case SID_HYPERLINK_SETLINK
:
212 if(pArgs
&& SfxItemState::SET
== pArgs
->GetItemState(SID_HYPERLINK_SETLINK
, false, &pItem
))
214 const SvxHyperlinkItem
& rHLinkItem
= *static_cast<const SvxHyperlinkItem
*>(pItem
);
215 const OUString
& rURL
= rHLinkItem
.GetURL();
216 const OUString
& rTarget
= rHLinkItem
.GetTargetFrame();
218 SfxItemSetFixed
<RES_URL
, RES_URL
> aSet( rSh
.GetAttrPool() );
219 rSh
.GetFlyFrameAttr( aSet
);
220 SwFormatURL
aURL( aSet
.Get( RES_URL
) );
222 OUString
sOldName(rHLinkItem
.GetName().toAsciiUpperCase());
223 OUString
sFlyName(rSh
.GetFlyName().toAsciiUpperCase());
224 if (sOldName
!= sFlyName
)
226 OUString
sName(sOldName
);
228 while (rSh
.FindFlyByName(sName
))
230 sName
= sOldName
+ "_" + OUString::number(i
++);
232 rSh
.SetFlyName(sName
);
234 aURL
.SetURL( rURL
, false );
235 aURL
.SetTargetFrameName(rTarget
);
238 rSh
.SetFlyFrameAttr( aSet
);
244 rSh
.GetView().GetEditWin().SetChainMode( !rSh
.GetView().GetEditWin().IsChainMode() );
247 case FN_FRAME_UNCHAIN
:
248 rSh
.Unchain( *rSh
.GetFlyFrameFormat() );
249 GetView().GetViewFrame().GetBindings().Invalidate(FN_FRAME_CHAIN
);
251 case FN_FORMAT_FOOTNOTE_DLG
:
253 GetView().ExecFormatFootnote();
256 case FN_NUMBERING_OUTLINE_DLG
:
258 GetView().ExecNumberingOutline(GetPool());
262 case SID_OPEN_XML_FILTERSETTINGS
:
264 HandleOpenXmlFilterSettings(rReq
);
267 case FN_WORDCOUNT_DIALOG
:
269 GetView().UpdateWordCount(this, nSlot
);
272 default: bMore
= true;
280 SwFlyFrameAttrMgr
aMgr( false, &rSh
, Frmmgr_Type::NONE
, nullptr );
281 bool bUpdateMgr
= true;
282 bool bCopyToFormat
= false;
285 case SID_OBJECT_ALIGN_MIDDLE
:
286 case FN_FRAME_ALIGN_VERT_CENTER
:
287 aMgr
.SetVertOrientation( text::VertOrientation::CENTER
);
289 case SID_OBJECT_ALIGN_DOWN
:
290 case FN_FRAME_ALIGN_VERT_BOTTOM
:
291 aMgr
.SetVertOrientation( text::VertOrientation::BOTTOM
);
293 case SID_OBJECT_ALIGN_UP
:
294 case FN_FRAME_ALIGN_VERT_TOP
:
295 aMgr
.SetVertOrientation( text::VertOrientation::TOP
);
298 case FN_FRAME_ALIGN_VERT_CHAR_CENTER
:
299 aMgr
.SetVertOrientation( text::VertOrientation::CHAR_CENTER
);
302 case FN_FRAME_ALIGN_VERT_CHAR_BOTTOM
:
303 aMgr
.SetVertOrientation( text::VertOrientation::CHAR_BOTTOM
);
306 case FN_FRAME_ALIGN_VERT_CHAR_TOP
:
307 aMgr
.SetVertOrientation( text::VertOrientation::CHAR_TOP
);
310 case FN_FRAME_ALIGN_VERT_ROW_CENTER
:
311 aMgr
.SetVertOrientation( text::VertOrientation::LINE_CENTER
);
314 case FN_FRAME_ALIGN_VERT_ROW_BOTTOM
:
315 aMgr
.SetVertOrientation( text::VertOrientation::LINE_BOTTOM
);
318 case FN_FRAME_ALIGN_VERT_ROW_TOP
:
319 aMgr
.SetVertOrientation( text::VertOrientation::LINE_TOP
);
321 case SID_OBJECT_ALIGN_CENTER
:
322 case FN_FRAME_ALIGN_HORZ_CENTER
:
323 aMgr
.SetHorzOrientation( text::HoriOrientation::CENTER
);
325 case SID_OBJECT_ALIGN_RIGHT
:
326 case FN_FRAME_ALIGN_HORZ_RIGHT
:
327 aMgr
.SetHorzOrientation( text::HoriOrientation::RIGHT
);
329 case SID_OBJECT_ALIGN_LEFT
:
330 case FN_FRAME_ALIGN_HORZ_LEFT
:
331 aMgr
.SetHorzOrientation( text::HoriOrientation::LEFT
);
334 case FN_SET_FRM_POSITION
:
336 aMgr
.SetAbsPos(static_cast<const SfxPointItem
&>(pArgs
->Get
337 (FN_SET_FRM_POSITION
)).GetValue());
344 aMgr
.SetAttrSet( *pArgs
);
345 bCopyToFormat
= true;
349 case SID_ATTR_ULSPACE
:
350 case SID_ATTR_LRSPACE
:
352 if(pArgs
&& SfxItemState::SET
== pArgs
->GetItemState(GetPool().GetWhich(nSlot
), false, &pItem
))
354 aMgr
.SetAttrSet( *pArgs
);
355 bCopyToFormat
= true;
360 case SID_ATTR_TRANSFORM
:
362 bool bApplyNewPos
= false;
363 bool bApplyNewSize
= false;
365 Point aNewPos
= aMgr
.GetPos();
368 if (const SfxInt32Item
* pXItem
= pArgs
->GetItemIfSet(SID_ATTR_TRANSFORM_POS_X
, false))
370 aNewPos
.setX( pXItem
->GetValue() );
373 if (const SfxInt32Item
* pYItem
= pArgs
->GetItemIfSet(SID_ATTR_TRANSFORM_POS_Y
, false))
375 aNewPos
.setY( pYItem
->GetValue() );
380 Size aNewSize
= aMgr
.GetSize();
383 if (const SfxUInt32Item
* pWidthItem
= pArgs
->GetItemIfSet(SID_ATTR_TRANSFORM_WIDTH
, false))
385 aNewSize
.setWidth( pWidthItem
->GetValue() );
386 bApplyNewSize
= true;
388 if (const SfxUInt32Item
* pHeightItem
= pArgs
->GetItemIfSet(SID_ATTR_TRANSFORM_HEIGHT
, false))
390 aNewSize
.setHeight( pHeightItem
->GetValue() );
391 bApplyNewSize
= true;
395 if (pArgs
&& (pArgs
->HasItem(SID_ATTR_TRANSFORM_ANGLE
) || pArgs
->HasItem(SID_ATTR_TRANSFORM_DELTA_ANGLE
)))
397 SfxItemSetFixed
<RES_GRFATR_ROTATION
, RES_GRFATR_ROTATION
> aSet(rSh
.GetAttrPool() );
398 rSh
.GetCurAttr(aSet
);
399 const SwRotationGrf
& rRotation
= aSet
.Get(RES_GRFATR_ROTATION
);
400 const Degree10
nOldRot(rRotation
.GetValue());
402 if (const SdrAngleItem
* pAngleItem
= pArgs
->GetItemIfSet(SID_ATTR_TRANSFORM_DELTA_ANGLE
, false))
404 const Degree10 nDeltaRot
= to
<Degree10
>(pAngleItem
->GetValue());
405 aMgr
.SetRotation(nOldRot
, nOldRot
+ nDeltaRot
, rRotation
.GetUnrotatedSize());
408 // RotGrfFlyFrame: Get Value and disable is in SwGrfShell::GetAttrStateForRotation, but the
409 // value setter uses SID_ATTR_TRANSFORM and a group of three values. Rotation is
410 // added now, so use it in this central place. Do no forget to convert angle from
411 // 100th degrees in SID_ATTR_TRANSFORM_ANGLE to 10th degrees in RES_GRFATR_ROTATION
412 if (const SdrAngleItem
* pTransformItem
= pArgs
->GetItemIfSet(SID_ATTR_TRANSFORM_ANGLE
, false))
414 const Degree10 nNewRot
= to
<Degree10
>(pTransformItem
->GetValue());
416 // RotGrfFlyFrame: Rotation change here, SwFlyFrameAttrMgr aMgr is available
417 aMgr
.SetRotation(nOldRot
, nNewRot
, rRotation
.GetUnrotatedSize());
423 aMgr
.SetAbsPos(aNewPos
);
427 aMgr
.SetSize( aNewSize
);
429 if (!bApplyNewPos
&& !bApplyNewSize
)
437 case FN_FORMAT_FRAME_DLG
:
438 case FN_DRAW_WRAP_DLG
:
440 const SelectionType nSel
= rSh
.GetSelectionType();
441 if (nSel
& SelectionType::Graphic
)
443 rSh
.GetView().GetViewFrame().GetDispatcher()->Execute(FN_FORMAT_GRAFIC_DLG
);
449 RES_FRMATR_BEGIN
, RES_FRMATR_END
- 1,
450 // FillAttribute support:
451 XATTR_FILL_FIRST
, XATTR_FILL_LAST
,
452 SID_DOCFRAME
, SID_DOCFRAME
,
453 SID_ATTR_BRUSH
, SID_ATTR_BRUSH
,
454 SID_ATTR_BORDER_INNER
, SID_ATTR_BORDER_INNER
,
455 SID_ATTR_LRSPACE
, SID_ATTR_ULSPACE
,
456 SID_ATTR_PAGE_SIZE
, SID_ATTR_PAGE_SIZE
,
457 // Items to hand over XPropertyList things like
458 // XColorList, XHatchList, XGradientList, and
459 // XBitmapList to the Area TabPage
460 SID_COLOR_TABLE
, SID_PATTERN_LIST
,
461 SID_HTML_MODE
, SID_HTML_MODE
,
462 FN_GET_PRINT_AREA
, FN_GET_PRINT_AREA
,
463 FN_SURROUND
, FN_KEEP_ASPECT_RATIO
,
464 FN_SET_FRM_ALT_NAME
, FN_SET_FRM_ALT_NAME
,
465 FN_UNO_DESCRIPTION
, FN_UNO_DESCRIPTION
,
466 FN_OLE_IS_MATH
, FN_MATH_BASELINE_ALIGNMENT
,
467 FN_PARAM_CHAIN_PREVIOUS
, FN_PARAM_CHAIN_NEXT
> aSet( GetPool() );
469 // create needed items for XPropertyList entries from the DrawModel so that
470 // the Area TabPage can access them
471 const SwDrawModel
* pDrawModel
= rSh
.GetView().GetDocShell()->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel();
472 pDrawModel
->PutAreaListItems(aSet
);
474 const SwViewOption
* pVOpt
= rSh
.GetViewOptions();
475 if(nSel
& SelectionType::Ole
)
476 aSet
.Put( SfxBoolItem(FN_KEEP_ASPECT_RATIO
, pVOpt
->IsKeepRatio()) );
477 aSet
.Put(SfxUInt16Item(SID_HTML_MODE
, ::GetHtmlMode(GetView().GetDocShell())));
478 aSet
.Put(SfxStringItem(FN_SET_FRM_NAME
, rSh
.GetFlyName()));
479 aSet
.Put(SfxStringItem(FN_UNO_DESCRIPTION
, rSh
.GetObjDescription()));
480 if( nSel
& SelectionType::Ole
)
483 aSet
.Put( SfxStringItem( FN_SET_FRM_ALT_NAME
, rSh
.GetObjTitle() ) );
486 const SwRect
&rPg
= rSh
.GetAnyCurRect(CurRectType::Page
);
487 SwFormatFrameSize
aFrameSize(SwFrameSize::Variable
, rPg
.Width(), rPg
.Height());
488 aFrameSize
.SetWhich(GetPool().GetWhich(SID_ATTR_PAGE_SIZE
));
489 aSet
.Put(aFrameSize
);
491 const SwRect
&rPr
= rSh
.GetAnyCurRect(CurRectType::PagePrt
);
492 SwFormatFrameSize
aPrtSize(SwFrameSize::Variable
, rPr
.Width(), rPr
.Height());
493 aPrtSize
.SetWhich(GetPool().GetWhich(FN_GET_PRINT_AREA
));
496 aSet
.Put(aMgr
.GetAttrSet());
497 aSet
.SetParent( aMgr
.GetAttrSet().GetParent() );
499 // On % values initialize size
500 SwFormatFrameSize
& rSize
= const_cast<SwFormatFrameSize
&>(aSet
.Get(RES_FRM_SIZE
));
501 if (rSize
.GetWidthPercent() && rSize
.GetWidthPercent() != SwFormatFrameSize::SYNCED
)
502 rSize
.SetWidth(rSh
.GetAnyCurRect(CurRectType::FlyEmbedded
).Width());
503 if (rSize
.GetHeightPercent() && rSize
.GetHeightPercent() != SwFormatFrameSize::SYNCED
)
504 rSize
.SetHeight(rSh
.GetAnyCurRect(CurRectType::FlyEmbedded
).Height());
506 // disable vertical positioning for Math Objects anchored 'as char' if baseline alignment is activated
507 aSet
.Put( SfxBoolItem( FN_MATH_BASELINE_ALIGNMENT
,
508 rSh
.GetDoc()->getIDocumentSettingAccess().get( DocumentSettingId::MATH_BASELINE_ALIGNMENT
) ) );
509 const uno::Reference
< embed::XEmbeddedObject
> xObj( rSh
.GetOleRef() );
510 aSet
.Put( SfxBoolItem( FN_OLE_IS_MATH
, xObj
.is() && SotExchange::IsMath( xObj
->getClassID() ) ) );
513 const SfxStringItem
* pDlgItem
;
514 if(pArgs
&& (pDlgItem
= pArgs
->GetItemIfSet(FN_FORMAT_FRAME_DLG
, false)))
515 sDefPage
= pDlgItem
->GetValue();
517 aSet
.Put(SfxFrameItem( SID_DOCFRAME
, &GetView().GetViewFrame().GetFrame()));
518 FieldUnit eMetric
= ::GetDfltMetric(dynamic_cast<SwWebView
*>( &GetView()) != nullptr );
519 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC
, static_cast< sal_uInt16
>(eMetric
) ));
520 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
521 ScopedVclPtr
<SfxAbstractTabDialog
> pDlg(pFact
->CreateFrameTabDialog(
522 nSel
& SelectionType::Graphic
? OUString("PictureDialog") :
523 nSel
& SelectionType::Ole
? OUString("ObjectDialog"):
524 OUString("FrameDialog"),
525 GetView().GetViewFrame(),
526 GetView().GetFrameWeld(),
531 if ( nSlot
== FN_DRAW_WRAP_DLG
)
533 pDlg
->SetCurPageId("wrap");
536 if ( pDlg
->Execute() )
538 const SfxItemSet
* pOutSet
= pDlg
->GetOutputItemSet();
542 const SfxBoolItem
* pRatioItem
= nullptr;
543 if(nSel
& SelectionType::Ole
&&
544 (pRatioItem
= pOutSet
->GetItemIfSet(FN_KEEP_ASPECT_RATIO
)))
546 SwViewOption
aUsrPref( *pVOpt
);
547 aUsrPref
.SetKeepRatio(pRatioItem
->GetValue());
548 SW_MOD()->ApplyUsrPref(aUsrPref
, &GetView());
550 if (const SfxStringItem
* pAltNameItem
= pOutSet
->GetItemIfSet(FN_SET_FRM_ALT_NAME
))
553 rSh
.SetObjTitle(pAltNameItem
->GetValue());
555 if (const SfxStringItem
* pDescripItem
= pOutSet
->GetItemIfSet(FN_UNO_DESCRIPTION
))
556 rSh
.SetObjDescription(pDescripItem
->GetValue());
558 // Template AutoUpdate
559 SwFrameFormat
* pFormat
= rSh
.GetSelectedFrameFormat();
560 if(pFormat
&& pFormat
->IsAutoUpdateOnDirectFormat())
562 rSh
.AutoUpdateFrame(pFormat
, *pOutSet
);
563 // Anything which is not supported by the format must be set hard.
564 if(const SfxStringItem
* pFrameName
= pOutSet
->GetItemIfSet(FN_SET_FRM_NAME
, false))
565 rSh
.SetFlyName(pFrameName
->GetValue());
567 RES_FRM_SIZE
, RES_FRM_SIZE
,
568 RES_SURROUND
, RES_ANCHOR
> aShellSet( GetPool() );
569 aShellSet
.Put(*pOutSet
);
570 aMgr
.SetAttrSet(aShellSet
);
571 if(const SfxStringItem
* pFrameName
= pOutSet
->GetItemIfSet(FN_SET_FRM_NAME
, false))
572 rSh
.SetFlyName(pFrameName
->GetValue());
575 aMgr
.SetAttrSet( *pOutSet
);
577 const SwFrameFormat
* pCurrFlyFormat
= rSh
.GetFlyFrameFormat();
578 if(const SfxStringItem
* pPreviousItem
=
579 pOutSet
->GetItemIfSet(FN_PARAM_CHAIN_PREVIOUS
, false))
581 rSh
.HideChainMarker();
583 OUString sPrevName
= pPreviousItem
->GetValue();
584 const SwFormatChain
&rChain
= pCurrFlyFormat
->GetChain();
585 //needs cast - no non-const method available
586 SwFlyFrameFormat
* pFlyFormat
=
590 if (pFlyFormat
->GetName() != sPrevName
)
592 rSh
.Unchain(*pFlyFormat
);
598 if (!sPrevName
.isEmpty())
600 //needs cast - no non-const method available
601 SwFrameFormat
* pPrevFormat
= const_cast<SwFrameFormat
*>(
602 lcl_GetFrameFormatByName(rSh
, sPrevName
));
603 SAL_WARN_IF(!pPrevFormat
, "sw.ui", "No frame found!");
606 rSh
.Chain(*pPrevFormat
, *pCurrFlyFormat
);
609 rSh
.SetChainMarker();
611 if(const SfxStringItem
* pChainNextItem
=
612 pOutSet
->GetItemIfSet(FN_PARAM_CHAIN_NEXT
, false))
614 rSh
.HideChainMarker();
615 OUString sNextName
= pChainNextItem
->GetValue();
616 const SwFormatChain
&rChain
= pCurrFlyFormat
->GetChain();
617 //needs cast - no non-const method available
618 SwFlyFrameFormat
* pFlyFormat
=
622 if (pFlyFormat
->GetName() != sNextName
)
624 rSh
.Unchain(*const_cast<SwFlyFrameFormat
*>(static_cast<const SwFlyFrameFormat
*>( pCurrFlyFormat
)));
630 if (!sNextName
.isEmpty())
632 //needs cast - no non-const method available
633 SwFrameFormat
* pNextFormat
= const_cast<SwFrameFormat
*>(
634 lcl_GetFrameFormatByName(rSh
, sNextName
));
635 SAL_WARN_IF(!pNextFormat
, "sw.ui", "No frame found!");
638 rSh
.Chain(*const_cast<SwFrameFormat
*>(
639 pCurrFlyFormat
), *pNextFormat
);
642 rSh
.SetChainMarker();
651 case FN_FRAME_MIRROR_ON_EVEN_PAGES
:
653 SwFormatHoriOrient
aHori(aMgr
.GetHoriOrient());
654 bool bMirror
= !aHori
.IsPosToggle();
655 aHori
.SetPosToggle(bMirror
);
656 SfxItemSetFixed
<RES_HORI_ORIENT
, RES_HORI_ORIENT
> aSet(GetPool());
658 aMgr
.SetAttrSet(aSet
);
659 bCopyToFormat
= true;
660 rReq
.SetReturnValue(SfxBoolItem(nSlot
, bMirror
));
666 SdrView
* pSdrView
= rSh
.GetDrawViewWithValidMarkList();
668 pSdrView
->GetMarkedObjectCount() == 1 )
670 OUString
aName(rSh
.GetFlyName());
671 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
672 ScopedVclPtr
<AbstractSvxObjectNameDialog
> pDlg(
673 pFact
->CreateSvxObjectNameDialog(GetView().GetFrameWeld(), aName
));
675 if ( pDlg
->Execute() == RET_OK
)
677 pDlg
->GetName(aName
);
678 rSh
.SetFlyName(aName
);
684 case FN_TITLE_DESCRIPTION_SHAPE
:
687 SdrView
* pSdrView
= rSh
.GetDrawViewWithValidMarkList();
689 pSdrView
->GetMarkedObjectCount() == 1 )
691 OUString
aDescription(rSh
.GetObjDescription());
692 OUString
aTitle(rSh
.GetObjTitle());
693 bool isDecorative(rSh
.IsObjDecorative());
695 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
696 ScopedVclPtr
<AbstractSvxObjectTitleDescDialog
> pDlg(
697 pFact
->CreateSvxObjectTitleDescDialog(GetView().GetFrameWeld(),
698 aTitle
, aDescription
, isDecorative
));
700 if ( pDlg
->Execute() == RET_OK
)
702 pDlg
->GetDescription(aDescription
);
703 pDlg
->GetTitle(aTitle
);
704 pDlg
->IsDecorative(isDecorative
);
706 rSh
.SetObjDescription(aDescription
);
707 rSh
.SetObjTitle(aTitle
);
708 rSh
.SetObjDecorative(isDecorative
);
714 assert(!"wrong dispatcher");
719 SwFrameFormat
* pFormat
= rSh
.GetSelectedFrameFormat();
720 if ( bCopyToFormat
&& pFormat
&& pFormat
->IsAutoUpdateOnDirectFormat() )
722 rSh
.AutoUpdateFrame(pFormat
, aMgr
.GetAttrSet());
726 aMgr
.UpdateFlyFrame();
732 void SwFrameShell::GetState(SfxItemSet
& rSet
)
734 SwWrtShell
&rSh
= GetShell();
735 bool bHtmlMode
= 0 != ::GetHtmlMode(rSh
.GetView().GetDocShell());
736 if (!rSh
.IsFrameSelected())
740 RES_LR_SPACE
, RES_UL_SPACE
,
741 RES_PRINT
, RES_HORI_ORIENT
> aSet(rSh
.GetAttrPool() );
742 rSh
.GetFlyFrameAttr( aSet
);
744 bool bProtect
= rSh
.IsSelObjProtected(FlyProtectFlags::Pos
) != FlyProtectFlags::NONE
;
745 bool bParentCntProt
= rSh
.IsSelObjProtected( FlyProtectFlags::Content
|FlyProtectFlags::Parent
) != FlyProtectFlags::NONE
;
747 bProtect
|= bParentCntProt
;
749 const FrameTypeFlags eFrameType
= rSh
.GetFrameType(nullptr,true);
750 SwFlyFrameAttrMgr
aMgr( false, &rSh
, Frmmgr_Type::NONE
, nullptr );
752 SfxWhichIter
aIter( rSet
);
753 sal_uInt16 nWhich
= aIter
.FirstWhich();
760 const SwFormatFrameSize
& aSz(aMgr
.GetFrameSize());
764 case RES_VERT_ORIENT
:
765 case RES_HORI_ORIENT
:
766 case SID_ATTR_ULSPACE
:
767 case SID_ATTR_LRSPACE
:
775 rSet
.Put(aSet
.Get(GetPool().GetWhich(nWhich
)));
778 case SID_OBJECT_ALIGN
:
781 rSet
.DisableItem( nWhich
);
784 case SID_OBJECT_ALIGN_LEFT
:
785 case SID_OBJECT_ALIGN_CENTER
:
786 case SID_OBJECT_ALIGN_RIGHT
:
787 case FN_FRAME_ALIGN_HORZ_CENTER
:
788 case FN_FRAME_ALIGN_HORZ_RIGHT
:
789 case FN_FRAME_ALIGN_HORZ_LEFT
:
790 if ( (eFrameType
& FrameTypeFlags::FLY_INCNT
) ||
792 ((nWhich
== FN_FRAME_ALIGN_HORZ_CENTER
|| nWhich
== SID_OBJECT_ALIGN_CENTER
) &&
795 rSet
.DisableItem( nWhich
);
799 sal_Int16 nHoriOrient
= -1;
802 case SID_OBJECT_ALIGN_LEFT
:
803 nHoriOrient
= text::HoriOrientation::LEFT
;
805 case SID_OBJECT_ALIGN_CENTER
:
806 nHoriOrient
= text::HoriOrientation::CENTER
;
808 case SID_OBJECT_ALIGN_RIGHT
:
809 nHoriOrient
= text::HoriOrientation::RIGHT
;
814 SwFormatHoriOrient
aHOrient(aMgr
.GetHoriOrient());
815 if (nHoriOrient
!= -1)
816 rSet
.Put(SfxBoolItem(nWhich
, nHoriOrient
== aHOrient
.GetHoriOrient()));
819 case FN_FRAME_ALIGN_VERT_ROW_TOP
:
820 case FN_FRAME_ALIGN_VERT_ROW_CENTER
:
821 case FN_FRAME_ALIGN_VERT_ROW_BOTTOM
:
822 case FN_FRAME_ALIGN_VERT_CHAR_TOP
:
823 case FN_FRAME_ALIGN_VERT_CHAR_CENTER
:
824 case FN_FRAME_ALIGN_VERT_CHAR_BOTTOM
:
825 if ( !(eFrameType
& FrameTypeFlags::FLY_INCNT
) || bProtect
826 || (bHtmlMode
&& FN_FRAME_ALIGN_VERT_CHAR_BOTTOM
== nWhich
) )
827 rSet
.DisableItem( nWhich
);
830 case SID_OBJECT_ALIGN_UP
:
831 case SID_OBJECT_ALIGN_MIDDLE
:
832 case SID_OBJECT_ALIGN_DOWN
:
834 case FN_FRAME_ALIGN_VERT_TOP
:
835 case FN_FRAME_ALIGN_VERT_CENTER
:
836 case FN_FRAME_ALIGN_VERT_BOTTOM
:
837 if ( bProtect
|| (bHtmlMode
&& eFrameType
& FrameTypeFlags::FLY_ATCNT
))
838 rSet
.DisableItem( nWhich
);
841 // These slots need different labels depending on whether they are anchored in a character
842 // or on a paragraph/page etc.
844 if (eFrameType
& FrameTypeFlags::FLY_INCNT
)
848 case SID_OBJECT_ALIGN_UP
:
849 case FN_FRAME_ALIGN_VERT_TOP
:
850 sNewLabel
= SwResId(STR_FRMUI_TOP_BASE
);
852 case SID_OBJECT_ALIGN_MIDDLE
:
853 case FN_FRAME_ALIGN_VERT_CENTER
:
854 sNewLabel
= SwResId(STR_FRMUI_CENTER_BASE
);
856 case SID_OBJECT_ALIGN_DOWN
:
857 case FN_FRAME_ALIGN_VERT_BOTTOM
:
859 sNewLabel
= SwResId(STR_FRMUI_BOTTOM_BASE
);
861 rSet
.DisableItem( nWhich
);
867 if (nWhich
!= FN_FRAME_ALIGN_VERT_TOP
&&
868 nWhich
!= SID_OBJECT_ALIGN_UP
)
870 if (aMgr
.GetAnchor() == RndStdIds::FLY_AT_FLY
)
872 const SwFrameFormat
* pFormat
= rSh
.IsFlyInFly();
875 const SwFormatFrameSize
& rFrameSz
= pFormat
->GetFrameSize();
876 if (rFrameSz
.GetHeightSizeType() != SwFrameSize::Fixed
)
878 rSet
.DisableItem( nWhich
);
884 OUString
aModuleName(vcl::CommandInfoProvider::GetModuleIdentifier(GetFrame()->GetFrame().GetFrameInterface()));
887 case SID_OBJECT_ALIGN_UP
:
888 case FN_FRAME_ALIGN_VERT_TOP
:
890 auto aProperties
= vcl::CommandInfoProvider::GetCommandProperties(".uno:AlignTop", aModuleName
);
891 sNewLabel
= vcl::CommandInfoProvider::GetLabelForCommand(aProperties
);
894 case SID_OBJECT_ALIGN_MIDDLE
:
895 case FN_FRAME_ALIGN_VERT_CENTER
:
897 auto aProperties
= vcl::CommandInfoProvider::GetCommandProperties(".uno:AlignVerticalCenter", aModuleName
);
898 sNewLabel
= vcl::CommandInfoProvider::GetLabelForCommand(aProperties
);
901 case SID_OBJECT_ALIGN_DOWN
:
902 case FN_FRAME_ALIGN_VERT_BOTTOM
:
904 auto aProperties
= vcl::CommandInfoProvider::GetCommandProperties(".uno:AlignBottom", aModuleName
);
905 sNewLabel
= vcl::CommandInfoProvider::GetLabelForCommand(aProperties
);
910 if ( !sNewLabel
.isEmpty() )
911 rSet
.Put( SfxStringItem( nWhich
, sNewLabel
));
914 case SID_HYPERLINK_GETLINK
:
916 SvxHyperlinkItem aHLinkItem
;
918 SfxItemSetFixed
<RES_URL
, RES_URL
> aURLSet(GetPool());
919 rSh
.GetFlyFrameAttr( aURLSet
);
921 if(const SwFormatURL
* pFormatURL
= aURLSet
.GetItemIfSet(RES_URL
))
923 aHLinkItem
.SetURL(pFormatURL
->GetURL());
924 aHLinkItem
.SetTargetFrame(pFormatURL
->GetTargetFrameName());
925 aHLinkItem
.SetName(rSh
.GetFlyName());
928 aHLinkItem
.SetInsertMode(static_cast<SvxLinkInsertMode
>(aHLinkItem
.GetInsertMode() |
929 (bHtmlMode
? HLINK_HTMLMODE
: 0)));
931 rSet
.Put(aHLinkItem
);
937 const SelectionType nSel
= rSh
.GetSelectionType();
938 if (nSel
& SelectionType::Graphic
|| nSel
& SelectionType::Ole
)
939 rSet
.DisableItem( FN_FRAME_CHAIN
);
942 const SwFrameFormat
*pFormat
= rSh
.GetFlyFrameFormat();
943 if ( bParentCntProt
|| rSh
.GetView().GetEditWin().GetApplyTemplate() ||
944 !pFormat
|| pFormat
->GetChain().GetNext() )
946 rSet
.DisableItem( FN_FRAME_CHAIN
);
950 bool bChainMode
= rSh
.GetView().GetEditWin().IsChainMode();
951 rSet
.Put( SfxBoolItem( FN_FRAME_CHAIN
, bChainMode
) );
956 case FN_FRAME_UNCHAIN
:
958 const SelectionType nSel
= rSh
.GetSelectionType();
959 if (nSel
& SelectionType::Graphic
|| nSel
& SelectionType::Ole
)
960 rSet
.DisableItem( FN_FRAME_UNCHAIN
);
963 const SwFrameFormat
*pFormat
= rSh
.GetFlyFrameFormat();
964 if ( bParentCntProt
|| rSh
.GetView().GetEditWin().GetApplyTemplate() ||
965 !pFormat
|| !pFormat
->GetChain().GetNext() )
967 rSet
.DisableItem( FN_FRAME_UNCHAIN
);
972 case SID_FRAME_TO_TOP
:
973 case SID_FRAME_TO_BOTTOM
:
976 if ( bParentCntProt
)
977 rSet
.DisableItem( nWhich
);
980 case SID_ATTR_TRANSFORM
:
982 rSet
.DisableItem( nWhich
);
986 case SID_ATTR_TRANSFORM_PROTECT_SIZE
:
988 const FlyProtectFlags eProtection
= rSh
.IsSelObjProtected( FlyProtectFlags::Size
);
989 if ( ( eProtection
& FlyProtectFlags::Content
) ||
990 ( eProtection
& FlyProtectFlags::Size
) )
992 rSet
.Put( SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_SIZE
, true ) );
996 rSet
.Put( SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_SIZE
, false ) );
1001 case SID_ATTR_TRANSFORM_WIDTH
:
1003 rSet
.Put( SfxUInt32Item( SID_ATTR_TRANSFORM_WIDTH
, aMgr
.GetSize().getWidth() ) );
1007 case SID_ATTR_TRANSFORM_HEIGHT
:
1009 rSet
.Put( SfxUInt32Item( SID_ATTR_TRANSFORM_HEIGHT
, aMgr
.GetSize().getHeight() ) );
1013 case FN_FORMAT_FRAME_DLG
:
1015 const SelectionType nSel
= rSh
.GetSelectionType();
1016 if ( bParentCntProt
|| nSel
& SelectionType::Graphic
)
1017 rSet
.DisableItem( nWhich
);
1021 case FN_TITLE_DESCRIPTION_SHAPE
:
1024 SwWrtShell
&rWrtSh
= GetShell();
1025 SdrView
* pSdrView
= rWrtSh
.GetDrawViewWithValidMarkList();
1027 pSdrView
->GetMarkedObjectCount() != 1 )
1029 rSet
.DisableItem( nWhich
);
1036 SwFlyFrame
* pFly
= rSh
.GetSelectedFlyFrame();
1039 SwFrameFormat
* pFormat
= pFly
->GetFormat();
1042 RndStdIds eAnchorId
= pFormat
->GetAnchor().GetAnchorId();
1043 // SwWrtShell::InsertPostIt() only works on as-char and at-char anchored
1045 if (eAnchorId
!= RndStdIds::FLY_AS_CHAR
&& eAnchorId
!= RndStdIds::FLY_AT_CHAR
)
1047 rSet
.DisableItem(nWhich
);
1058 nWhich
= aIter
.NextWhich();
1062 SwFrameShell::SwFrameShell(SwView
&_rView
) :
1063 SwBaseShell( _rView
)
1067 // #96392# Use this to announce it is the frame shell who creates the selection.
1068 SwTransferable::CreateSelection( _rView
.GetWrtShell(), this );
1070 SfxShell::SetContextName(vcl::EnumContext::GetContextName(vcl::EnumContext::Context::Frame
));
1073 SwFrameShell::~SwFrameShell()
1075 // #96392# Only clear the selection if it was this frame shell who created it.
1076 SwTransferable::ClearSelection( GetShell(), this );
1079 void SwFrameShell::ExecFrameStyle(SfxRequest
const & rReq
)
1081 SwWrtShell
&rSh
= GetShell();
1082 bool bDefault
= false;
1083 if (!rSh
.IsFrameSelected())
1085 // At first pick the default BoxItem out of the pool.
1086 // If unequal to regular box item, then it has already
1087 // been changed (New one is no default).
1088 const SvxBoxItem
* pPoolBoxItem
= ::GetDfltAttr(RES_BOX
);
1090 const SfxItemSet
*pArgs
= rReq
.GetArgs();
1091 SfxItemSetFixed
<RES_BOX
, RES_BOX
> aFrameSet(rSh
.GetAttrPool());
1093 rSh
.GetFlyFrameAttr( aFrameSet
);
1094 const SvxBoxItem
& rBoxItem
= aFrameSet
.Get(RES_BOX
);
1096 if (pPoolBoxItem
== &rBoxItem
)
1099 std::unique_ptr
<SvxBoxItem
> aBoxItem(rBoxItem
.Clone());
1101 SvxBorderLine aBorderLine
;
1103 if(pArgs
) // Any controller can sometimes deliver nothing #48169#
1105 switch (rReq
.GetSlot())
1107 case SID_ATTR_BORDER
:
1109 if (const SvxBoxItem
* pBoxItem
= pArgs
->GetItemIfSet(RES_BOX
))
1111 std::unique_ptr
<SvxBoxItem
> aNewBox(pBoxItem
->Clone());
1112 const SvxBorderLine
* pBorderLine
;
1114 pBorderLine
= aBoxItem
->GetTop();
1115 if (pBorderLine
!= nullptr)
1116 lcl_FrameGetMaxLineWidth(pBorderLine
, aBorderLine
);
1117 pBorderLine
= aBoxItem
->GetBottom();
1118 if (pBorderLine
!= nullptr)
1119 lcl_FrameGetMaxLineWidth(pBorderLine
, aBorderLine
);
1120 pBorderLine
= aBoxItem
->GetLeft();
1121 if (pBorderLine
!= nullptr)
1122 lcl_FrameGetMaxLineWidth(pBorderLine
, aBorderLine
);
1123 pBorderLine
= aBoxItem
->GetRight();
1124 if (pBorderLine
!= nullptr)
1125 lcl_FrameGetMaxLineWidth(pBorderLine
, aBorderLine
);
1127 if(aBorderLine
.GetOutWidth() == 0)
1129 aBorderLine
.SetBorderLineStyle(
1130 SvxBorderLineStyle::SOLID
);
1131 aBorderLine
.SetWidth( SvxBorderLineWidth::Hairline
);
1133 //Set distance only if the request is received from the controller.
1135 #if HAVE_FEATURE_SCRIPTING
1136 if(!StarBASIC::IsRunning())
1139 // TODO: should this copy 4 individual Dist instead?
1140 aNewBox
->SetAllDistances(rBoxItem
.GetSmallestDistance());
1143 aBoxItem
= std::move(aNewBox
);
1145 if( aBoxItem
->GetTop() != nullptr )
1146 aBoxItem
->SetLine(&aBorderLine
, SvxBoxItemLine::TOP
);
1147 if( aBoxItem
->GetBottom() != nullptr )
1148 aBoxItem
->SetLine(&aBorderLine
, SvxBoxItemLine::BOTTOM
);
1149 if( aBoxItem
->GetLeft() != nullptr )
1150 aBoxItem
->SetLine(&aBorderLine
, SvxBoxItemLine::LEFT
);
1151 if( aBoxItem
->GetRight() != nullptr )
1152 aBoxItem
->SetLine(&aBorderLine
, SvxBoxItemLine::RIGHT
);
1157 case SID_FRAME_LINESTYLE
:
1159 if ( const SvxLineItem
* pLineItem
= pArgs
->GetItemIfSet(SID_FRAME_LINESTYLE
, false))
1161 if ( pLineItem
->GetLine() )
1163 aBorderLine
= *(pLineItem
->GetLine());
1165 if (!aBoxItem
->GetTop() && !aBoxItem
->GetBottom() &&
1166 !aBoxItem
->GetLeft() && !aBoxItem
->GetRight())
1168 aBoxItem
->SetLine(&aBorderLine
, SvxBoxItemLine::TOP
);
1169 aBoxItem
->SetLine(&aBorderLine
, SvxBoxItemLine::BOTTOM
);
1170 aBoxItem
->SetLine(&aBorderLine
, SvxBoxItemLine::LEFT
);
1171 aBoxItem
->SetLine(&aBorderLine
, SvxBoxItemLine::RIGHT
);
1175 if( aBoxItem
->GetTop() )
1177 aBorderLine
.SetColor( aBoxItem
->GetTop()->GetColor() );
1178 aBoxItem
->SetLine(&aBorderLine
, SvxBoxItemLine::TOP
);
1180 if( aBoxItem
->GetBottom() )
1182 aBorderLine
.SetColor( aBoxItem
->GetBottom()->GetColor());
1183 aBoxItem
->SetLine(&aBorderLine
, SvxBoxItemLine::BOTTOM
);
1185 if( aBoxItem
->GetLeft() )
1187 aBorderLine
.SetColor( aBoxItem
->GetLeft()->GetColor());
1188 aBoxItem
->SetLine(&aBorderLine
, SvxBoxItemLine::LEFT
);
1190 if( aBoxItem
->GetRight() )
1192 aBorderLine
.SetColor(aBoxItem
->GetRight()->GetColor());
1193 aBoxItem
->SetLine(&aBorderLine
, SvxBoxItemLine::RIGHT
);
1199 aBoxItem
->SetLine(nullptr, SvxBoxItemLine::TOP
);
1200 aBoxItem
->SetLine(nullptr, SvxBoxItemLine::BOTTOM
);
1201 aBoxItem
->SetLine(nullptr, SvxBoxItemLine::LEFT
);
1202 aBoxItem
->SetLine(nullptr, SvxBoxItemLine::RIGHT
);
1208 case SID_FRAME_LINECOLOR
:
1210 if (const SvxColorItem
* pColorItem
= pArgs
->GetItemIfSet(SID_FRAME_LINECOLOR
, false))
1212 const Color
& rNewColor
= pColorItem
->GetValue();
1214 if (!aBoxItem
->GetTop() && !aBoxItem
->GetBottom() &&
1215 !aBoxItem
->GetLeft() && !aBoxItem
->GetRight())
1217 aBorderLine
.SetColor( rNewColor
);
1218 aBorderLine
.SetBorderLineStyle(SvxBorderLineStyle::SOLID
);
1219 aBorderLine
.SetWidth(SvxBorderLineWidth::Hairline
);
1221 aBoxItem
->SetLine(&aBorderLine
, SvxBoxItemLine::TOP
);
1222 aBoxItem
->SetLine(&aBorderLine
, SvxBoxItemLine::BOTTOM
);
1223 aBoxItem
->SetLine(&aBorderLine
, SvxBoxItemLine::LEFT
);
1224 aBoxItem
->SetLine(&aBorderLine
, SvxBoxItemLine::RIGHT
);
1228 if (aBoxItem
->GetTop())
1229 aBoxItem
->GetTop()->SetColor(rNewColor
);
1230 if (aBoxItem
->GetBottom())
1231 aBoxItem
->GetBottom()->SetColor(rNewColor
);
1232 if (aBoxItem
->GetLeft())
1233 aBoxItem
->GetLeft()->SetColor(rNewColor
);
1234 if (aBoxItem
->GetRight())
1235 aBoxItem
->GetRight()->SetColor(rNewColor
);
1242 if (bDefault
&& (aBoxItem
->GetTop() || aBoxItem
->GetBottom() ||
1243 aBoxItem
->GetLeft() || aBoxItem
->GetRight()))
1245 aBoxItem
->SetAllDistances(MIN_BORDER_DIST
);
1247 aFrameSet
.Put( std::move(aBoxItem
) );
1248 // Template AutoUpdate
1249 SwFrameFormat
* pFormat
= rSh
.GetSelectedFrameFormat();
1250 if(pFormat
&& pFormat
->IsAutoUpdateOnDirectFormat())
1252 rSh
.AutoUpdateFrame(pFormat
, aFrameSet
);
1255 rSh
.SetFlyFrameAttr( aFrameSet
);
1259 static void lcl_FrameGetMaxLineWidth(const SvxBorderLine
* pBorderLine
, SvxBorderLine
& rBorderLine
)
1261 if(pBorderLine
->GetWidth() > rBorderLine
.GetWidth())
1262 rBorderLine
.SetWidth(pBorderLine
->GetWidth());
1264 rBorderLine
.SetBorderLineStyle(pBorderLine
->GetBorderLineStyle());
1265 rBorderLine
.SetColor(pBorderLine
->GetColor());
1268 void SwFrameShell::GetLineStyleState(SfxItemSet
&rSet
)
1270 SwWrtShell
&rSh
= GetShell();
1271 bool bParentCntProt
= rSh
.IsSelObjProtected( FlyProtectFlags::Content
|FlyProtectFlags::Parent
) != FlyProtectFlags::NONE
;
1275 if (rSh
.IsFrameSelected())
1276 rSet
.DisableItem( SID_FRAME_LINECOLOR
);
1278 rSet
.DisableItem( SID_ATTR_BORDER
);
1279 rSet
.DisableItem( SID_FRAME_LINESTYLE
);
1283 if (rSh
.IsFrameSelected())
1285 SfxItemSetFixed
<RES_BOX
, RES_BOX
> aFrameSet( rSh
.GetAttrPool() );
1287 rSh
.GetFlyFrameAttr(aFrameSet
);
1289 const SvxBorderLine
* pLine
= aFrameSet
.Get(RES_BOX
).GetTop();
1290 rSet
.Put(SvxColorItem(pLine
? pLine
->GetColor() : Color(), SID_FRAME_LINECOLOR
));
1295 void SwFrameShell::StateInsert(SfxItemSet
&rSet
)
1297 const SelectionType nSel
= GetShell().GetSelectionType();
1298 if ( (nSel
& SelectionType::Graphic
)
1299 || (nSel
& SelectionType::Ole
) )
1301 rSet
.DisableItem(FN_INSERT_FRAME
);
1303 else if ( GetShell().CursorInsideInputField() )
1305 rSet
.DisableItem(FN_INSERT_FRAME
);
1309 void SwFrameShell::GetDrawAttrStateTextFrame(SfxItemSet
&rSet
)
1311 SwWrtShell
&rSh
= GetShell();
1313 if(rSh
.IsFrameSelected())
1315 rSh
.GetFlyFrameAttr(rSet
);
1319 SdrView
* pSdrView
= rSh
.GetDrawViewWithValidMarkList();
1323 rSet
.Put(pSdrView
->GetDefaultAttr());
1328 void SwFrameShell::ExecDrawAttrArgsTextFrame(SfxRequest
const & rReq
)
1330 const SfxItemSet
* pArgs
= rReq
.GetArgs();
1331 SwWrtShell
& rSh
= GetShell();
1335 if(rSh
.IsFrameSelected())
1337 rSh
.SetFlyFrameAttr(const_cast< SfxItemSet
& >(*pArgs
));
1341 SdrView
* pSdrView
= rSh
.GetDrawViewWithValidMarkList();
1345 pSdrView
->SetDefaultAttr(*pArgs
, false);
1351 SfxDispatcher
* pDis
= rSh
.GetView().GetViewFrame().GetDispatcher();
1353 switch(rReq
.GetSlot())
1355 case SID_ATTR_FILL_STYLE
:
1356 case SID_ATTR_FILL_COLOR
:
1357 case SID_ATTR_FILL_GRADIENT
:
1358 case SID_ATTR_FILL_HATCH
:
1359 case SID_ATTR_FILL_BITMAP
:
1360 case SID_ATTR_FILL_TRANSPARENCE
:
1361 case SID_ATTR_FILL_FLOATTRANSPARENCE
:
1363 pDis
->Execute(SID_ATTRIBUTES_AREA
);
1370 void SwFrameShell::ExecDrawDlgTextFrame(SfxRequest
const & rReq
)
1372 switch(rReq
.GetSlot())
1374 case SID_ATTRIBUTES_AREA
:
1376 SwWrtShell
& rSh
= GetShell();
1378 if(rSh
.IsFrameSelected())
1380 SdrModel
& rModel
= rSh
.GetDrawView()->GetModel();
1381 SfxItemSet
aNewAttr(rModel
.GetItemPool());
1383 // get attributes from FlyFrame
1384 rSh
.GetFlyFrameAttr(aNewAttr
);
1386 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
1387 VclPtr
<AbstractSvxAreaTabDialog
> pDlg(pFact
->CreateSvxAreaTabDialog(
1388 GetView().GetFrameWeld(),
1394 pDlg
->StartExecuteAsync([pDlg
, this](sal_Int32 nResult
){
1395 if(nResult
== RET_OK
)
1397 // set attributes at FlyFrame
1398 GetShell().SetFlyFrameAttr(const_cast< SfxItemSet
& >(*pDlg
->GetOutputItemSet()));
1400 static sal_uInt16 aInval
[] =
1402 SID_ATTR_FILL_STYLE
,
1403 SID_ATTR_FILL_COLOR
,
1404 SID_ATTR_FILL_TRANSPARENCE
,
1405 SID_ATTR_FILL_FLOATTRANSPARENCE
,
1409 SfxBindings
&rBnd
= GetView().GetViewFrame().GetBindings();
1411 rBnd
.Invalidate(aInval
);
1412 rBnd
.Update(SID_ATTR_FILL_STYLE
);
1413 rBnd
.Update(SID_ATTR_FILL_COLOR
);
1414 rBnd
.Update(SID_ATTR_FILL_TRANSPARENCE
);
1415 rBnd
.Update(SID_ATTR_FILL_FLOATTRANSPARENCE
);
1417 pDlg
->disposeOnce();
1426 void SwFrameShell::DisableStateTextFrame(SfxItemSet
&rSet
)
1428 SfxWhichIter
aIter(rSet
);
1429 sal_uInt16
nWhich(aIter
.FirstWhich());
1435 case SID_ATTRIBUTES_AREA
:
1437 SwWrtShell
& rSh
= GetShell();
1439 if(!rSh
.IsFrameSelected())
1441 rSet
.DisableItem(nWhich
);
1448 rSet
.DisableItem(nWhich
);
1453 nWhich
= aIter
.NextWhich();
1457 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */