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 <hintids.hxx>
21 #include <svl/whiter.hxx>
22 #include <svtools/imapobj.hxx>
23 #include <svtools/miscopt.hxx>
24 #include <svl/srchitem.hxx>
25 #include <svtools/imap.hxx>
26 #include <sfx2/viewfrm.hxx>
27 #include <basic/sbstar.hxx>
28 #include <svl/rectitem.hxx>
29 #include <svl/ptitem.hxx>
30 #include <svl/stritem.hxx>
31 #include <svl/intitem.hxx>
32 #include <svl/eitem.hxx>
33 #include <editeng/colritem.hxx>
34 #include <editeng/lineitem.hxx>
35 #include <editeng/boxitem.hxx>
36 #include <editeng/protitem.hxx>
37 #include <sfx2/dispatch.hxx>
38 #include <sfx2/request.hxx>
39 #include <sfx2/objface.hxx>
40 #include <sfx2/sidebar/EnumContext.hxx>
41 #include <svx/hlnkitem.hxx>
43 #include <svx/svdview.hxx>
44 #include <vcl/msgbox.hxx>
45 #include <tools/diagnose_ex.h>
49 #include <fmtclds.hxx>
50 #include <fmtcnct.hxx>
51 #include <swmodule.hxx>
60 #include <swevent.hxx>
61 #include <usrpref.hxx>
63 #include <swdtflvr.hxx>
65 #include <docstat.hxx>
66 #include <IDocumentStatistics.hxx>
68 #include <comphelper/processfactory.hxx>
69 #include <com/sun/star/ui/dialogs/XSLTFilterDialog.hpp>
73 #include <cfgitems.hxx>
74 #include <globals.hrc>
77 #include "swabstdlg.hxx"
80 #include <svx/dialogs.hrc>
81 #include <wordcountdialog.hxx>
83 using ::editeng::SvxBorderLine
;
84 using namespace ::com::sun::star
;
85 using namespace ::com::sun::star::uno
;
88 static void lcl_FrmGetMaxLineWidth(const SvxBorderLine
* pBorderLine
, SvxBorderLine
& rBorderLine
);
89 static const SwFrmFmt
* lcl_GetFrmFmtByName(SwWrtShell
& rSh
, const String
& rName
)
91 sal_uInt16 nCount
= rSh
.GetFlyCount(FLYCNTTYPE_FRM
);
92 for( sal_uInt16 i
= 0; i
< nCount
; i
++)
94 const SwFrmFmt
* pFmt
= rSh
.GetFlyNum(i
, FLYCNTTYPE_FRM
);
95 if(pFmt
->GetName() == rName
)
102 #include <sfx2/msg.hxx>
103 #include "swslots.hxx"
105 SFX_IMPL_INTERFACE(SwFrameShell
, SwBaseShell
, SW_RES(STR_SHELLNAME_FRAME
))
107 SFX_POPUPMENU_REGISTRATION(SW_RES(MN_FRM_POPUPMENU
));
108 SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT
, SW_RES(RID_FRAME_TOOLBOX
));
111 void SwFrameShell::Execute(SfxRequest
&rReq
)
113 //First those who do not need FrmMgr.
114 SwWrtShell
&rSh
= GetShell();
116 const SfxItemSet
* pArgs
= rReq
.GetArgs();
117 const SfxPoolItem
* pItem
;
118 sal_uInt16 nSlot
= rReq
.GetSlot();
122 case FN_FRAME_TO_ANCHOR
:
123 if ( rSh
.IsFrmSelected() )
130 case SID_FRAME_TO_TOP
:
131 rSh
.SelectionToTop();
134 case SID_FRAME_TO_BOTTOM
:
135 rSh
.SelectionToBottom();
139 rSh
.SelectionToTop( sal_False
);
143 rSh
.SelectionToBottom( sal_False
);
145 case FN_INSERT_FRAME
:
148 // Frame already exists, open frame dialog for editing.
149 SfxUInt16Item
aDefPage(FN_FORMAT_FRAME_DLG
, TP_COLUMN
);
150 rSh
.GetView().GetViewFrame()->GetDispatcher()->Execute( FN_FORMAT_FRAME_DLG
,
151 SFX_CALLMODE_SYNCHRON
|SFX_CALLMODE_RECORD
,
157 // Frame already exists, only the number of columns will be changed.
158 sal_uInt16 nCols
= 1;
159 if(pArgs
->GetItemState(SID_ATTR_COLUMNS
, sal_False
, &pItem
) == SFX_ITEM_SET
)
160 nCols
= ((SfxUInt16Item
*)pItem
)->GetValue();
162 SfxItemSet
aSet(GetPool(),RES_COL
,RES_COL
);
163 rSh
.GetFlyFrmAttr( aSet
);
164 SwFmtCol
aCol((const SwFmtCol
&)aSet
.Get(RES_COL
));
165 // GutterWidth will not always passed, hence get firstly
166 // (see view2: Execute on this slot)
167 sal_uInt16 nGutterWidth
= aCol
.GetGutterWidth();
170 aCol
.Init(nCols
, nGutterWidth
, aCol
.GetWishWidth());
172 // Template AutoUpdate
173 SwFrmFmt
* pFmt
= rSh
.GetCurFrmFmt();
174 if(pFmt
&& pFmt
->IsAutoUpdateFmt())
176 rSh
.AutoUpdateFrame(pFmt
, aSet
);
180 rSh
.StartAllAction();
181 rSh
.SetFlyFrmAttr( aSet
);
189 case SID_HYPERLINK_SETLINK
:
191 if(pArgs
&& SFX_ITEM_SET
== pArgs
->GetItemState(SID_HYPERLINK_SETLINK
, sal_False
, &pItem
))
193 const SvxHyperlinkItem
& rHLinkItem
= *(const SvxHyperlinkItem
*)pItem
;
194 const String
& rURL
= rHLinkItem
.GetURL();
195 const String
& rTarget
= rHLinkItem
.GetTargetFrame();
197 SfxItemSet
aSet( rSh
.GetAttrPool(), RES_URL
, RES_URL
);
198 rSh
.GetFlyFrmAttr( aSet
);
199 SwFmtURL
aURL( (SwFmtURL
&)aSet
.Get( RES_URL
) );
201 String
sOldName(rHLinkItem
.GetName());
202 String
sFlyName(rSh
.GetFlyName());
203 if (sOldName
.ToUpperAscii() != sFlyName
.ToUpperAscii())
205 String
sName(sOldName
);
207 while (rSh
.FindFlyByName(sName
))
211 sName
+= OUString::number(i
++);
213 rSh
.SetFlyName(sName
);
215 aURL
.SetURL( rURL
, sal_False
);
216 aURL
.SetTargetFrameName(rTarget
);
219 rSh
.SetFlyFrmAttr( aSet
);
225 rSh
.GetView().GetEditWin().SetChainMode( !rSh
.GetView().GetEditWin().IsChainMode() );
228 case FN_FRAME_UNCHAIN
:
229 rSh
.Unchain( (SwFrmFmt
&)*rSh
.GetFlyFrmFmt() );
230 GetView().GetViewFrame()->GetBindings().Invalidate(FN_FRAME_CHAIN
);
232 case FN_FORMAT_FOOTNOTE_DLG
:
234 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
235 OSL_ENSURE(pFact
, "SwAbstractDialogFactory fail!");
237 VclAbstractDialog
* pDlg
= pFact
->CreateSwFootNoteOptionDlg( GetView().GetWindow(), GetView().GetWrtShell(), DLG_DOC_FOOTNOTE
);
238 OSL_ENSURE(pDlg
, "Dialogdiet fail!");
243 case FN_NUMBERING_OUTLINE_DLG
:
245 SfxItemSet
aTmp(GetPool(), FN_PARAM_1
, FN_PARAM_1
);
246 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
247 OSL_ENSURE(pFact
, "Dialogdiet fail!");
248 SfxAbstractTabDialog
* pDlg
= pFact
->CreateSwTabDialog( DLG_TAB_OUTLINE
,
249 GetView().GetWindow(), &aTmp
, GetView().GetWrtShell());
250 OSL_ENSURE(pDlg
, "Dialogdiet fail!");
256 case SID_OPEN_XML_FILTERSETTINGS
:
260 uno::Reference
< ui::dialogs::XExecutableDialog
> xDialog
= ui::dialogs::XSLTFilterDialog::create(::comphelper::getProcessComponentContext());
263 catch (const uno::Exception
&)
265 DBG_UNHANDLED_EXCEPTION();
270 case FN_WORDCOUNT_DIALOG
:
272 SfxViewFrame
* pVFrame
= GetView().GetViewFrame();
275 pVFrame
->ToggleChildWindow(FN_WORDCOUNT_DIALOG
);
276 Invalidate(rReq
.GetSlot());
278 SwWordCountWrapper
*pWrdCnt
= (SwWordCountWrapper
*)pVFrame
->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
280 pWrdCnt
->UpdateCounts();
284 default: bMore
= true;
292 SwFlyFrmAttrMgr
aMgr( sal_False
, &rSh
, FRMMGR_TYPE_NONE
);
293 bool bUpdateMgr
= true;
294 bool bCopyToFmt
= false;
297 case SID_OBJECT_ALIGN_MIDDLE
:
298 case FN_FRAME_ALIGN_VERT_CENTER
:
299 aMgr
.SetVertOrientation( text::VertOrientation::CENTER
);
301 case SID_OBJECT_ALIGN_DOWN
:
302 case FN_FRAME_ALIGN_VERT_BOTTOM
:
303 aMgr
.SetVertOrientation( text::VertOrientation::BOTTOM
);
305 case SID_OBJECT_ALIGN_UP
:
306 case FN_FRAME_ALIGN_VERT_TOP
:
307 aMgr
.SetVertOrientation( text::VertOrientation::TOP
);
310 case FN_FRAME_ALIGN_VERT_CHAR_CENTER
:
311 aMgr
.SetVertOrientation( text::VertOrientation::CHAR_CENTER
);
314 case FN_FRAME_ALIGN_VERT_CHAR_BOTTOM
:
315 aMgr
.SetVertOrientation( text::VertOrientation::CHAR_BOTTOM
);
318 case FN_FRAME_ALIGN_VERT_CHAR_TOP
:
319 aMgr
.SetVertOrientation( text::VertOrientation::CHAR_TOP
);
322 case FN_FRAME_ALIGN_VERT_ROW_CENTER
:
323 aMgr
.SetVertOrientation( text::VertOrientation::LINE_CENTER
);
326 case FN_FRAME_ALIGN_VERT_ROW_BOTTOM
:
327 aMgr
.SetVertOrientation( text::VertOrientation::LINE_BOTTOM
);
330 case FN_FRAME_ALIGN_VERT_ROW_TOP
:
331 aMgr
.SetVertOrientation( text::VertOrientation::LINE_TOP
);
333 case SID_OBJECT_ALIGN_CENTER
:
334 case FN_FRAME_ALIGN_HORZ_CENTER
:
335 aMgr
.SetHorzOrientation( text::HoriOrientation::CENTER
);
337 case SID_OBJECT_ALIGN_RIGHT
:
338 case FN_FRAME_ALIGN_HORZ_RIGHT
:
339 aMgr
.SetHorzOrientation( text::HoriOrientation::RIGHT
);
341 case SID_OBJECT_ALIGN_LEFT
:
342 case FN_FRAME_ALIGN_HORZ_LEFT
:
343 aMgr
.SetHorzOrientation( text::HoriOrientation::LEFT
);
346 case FN_SET_FRM_POSITION
:
348 aMgr
.SetAbsPos(((SfxPointItem
&)pArgs
->Get
349 (FN_SET_FRM_POSITION
)).GetValue());
356 aMgr
.SetAttrSet( *pArgs
);
361 case SID_ATTR_ULSPACE
:
362 case SID_ATTR_LRSPACE
:
364 if(pArgs
&& SFX_ITEM_SET
== pArgs
->GetItemState(GetPool().GetWhich(nSlot
), sal_False
, &pItem
))
366 aMgr
.SetAttrSet( *pArgs
);
372 case SID_ATTR_TRANSFORM
:
374 bool bApplyNewSize
= false;
376 Size aNewSize
= aMgr
.GetSize();
377 if ( SFX_ITEM_SET
== pArgs
->GetItemState( SID_ATTR_TRANSFORM_WIDTH
, sal_False
, &pItem
) )
379 aNewSize
.setWidth( static_cast< const SfxUInt32Item
* >(pItem
)->GetValue() );
380 bApplyNewSize
= true;
383 if ( SFX_ITEM_SET
== pArgs
->GetItemState( SID_ATTR_TRANSFORM_HEIGHT
, sal_False
, &pItem
) )
385 aNewSize
.setHeight( static_cast< const SfxUInt32Item
* >(pItem
)->GetValue() );
386 bApplyNewSize
= true;
391 aMgr
.SetSize( aNewSize
);
395 bUpdateMgr
= sal_False
;
401 case FN_FORMAT_FRAME_DLG
:
402 case FN_DRAW_WRAP_DLG
:
404 const int nSel
= rSh
.GetSelectionType();
405 if (nSel
& nsSelectionType::SEL_GRF
)
407 rSh
.GetView().GetViewFrame()->GetDispatcher()->Execute(FN_FORMAT_GRAFIC_DLG
);
412 SfxItemSet
aSet(GetPool(), RES_FRMATR_BEGIN
, RES_FRMATR_END
-1,
413 SID_ATTR_BORDER_INNER
, SID_ATTR_BORDER_INNER
,
414 FN_GET_PRINT_AREA
, FN_GET_PRINT_AREA
,
415 SID_ATTR_PAGE_SIZE
, SID_ATTR_PAGE_SIZE
,
416 SID_ATTR_BRUSH
, SID_ATTR_BRUSH
,
417 SID_ATTR_LRSPACE
, SID_ATTR_ULSPACE
,
418 FN_SURROUND
, FN_HORI_ORIENT
,
419 FN_SET_FRM_NAME
, FN_SET_FRM_NAME
,
420 FN_KEEP_ASPECT_RATIO
, FN_KEEP_ASPECT_RATIO
,
421 SID_DOCFRAME
, SID_DOCFRAME
,
422 SID_HTML_MODE
, SID_HTML_MODE
,
423 FN_SET_FRM_ALT_NAME
, FN_SET_FRM_ALT_NAME
,
424 FN_PARAM_CHAIN_PREVIOUS
, FN_PARAM_CHAIN_NEXT
,
425 FN_OLE_IS_MATH
, FN_OLE_IS_MATH
,
426 FN_MATH_BASELINE_ALIGNMENT
, FN_MATH_BASELINE_ALIGNMENT
,
429 const SwViewOption
* pVOpt
= rSh
.GetViewOptions();
430 if(nSel
& nsSelectionType::SEL_OLE
)
431 aSet
.Put( SfxBoolItem(FN_KEEP_ASPECT_RATIO
, pVOpt
->IsKeepRatio()) );
432 aSet
.Put(SfxUInt16Item(SID_HTML_MODE
, ::GetHtmlMode(GetView().GetDocShell())));
433 aSet
.Put(SfxStringItem(FN_SET_FRM_NAME
, rSh
.GetFlyName()));
434 if( nSel
& nsSelectionType::SEL_OLE
)
437 aSet
.Put( SfxStringItem( FN_SET_FRM_ALT_NAME
, rSh
.GetObjTitle() ) );
440 const SwRect
&rPg
= rSh
.GetAnyCurRect(RECT_PAGE
);
441 SwFmtFrmSize
aFrmSize(ATT_VAR_SIZE
, rPg
.Width(), rPg
.Height());
442 aFrmSize
.SetWhich(GetPool().GetWhich(SID_ATTR_PAGE_SIZE
));
445 const SwRect
&rPr
= rSh
.GetAnyCurRect(RECT_PAGE_PRT
);
446 SwFmtFrmSize
aPrtSize(ATT_VAR_SIZE
, rPr
.Width(), rPr
.Height());
447 aPrtSize
.SetWhich(GetPool().GetWhich(FN_GET_PRINT_AREA
));
450 aSet
.Put(aMgr
.GetAttrSet());
451 aSet
.SetParent( aMgr
.GetAttrSet().GetParent() );
453 // On % values initialize size
454 SwFmtFrmSize
& rSize
= (SwFmtFrmSize
&)aSet
.Get(RES_FRM_SIZE
);
455 if (rSize
.GetWidthPercent() && rSize
.GetWidthPercent() != 0xff)
456 rSize
.SetWidth(rSh
.GetAnyCurRect(RECT_FLY_EMBEDDED
).Width());
457 if (rSize
.GetHeightPercent() && rSize
.GetHeightPercent() != 0xff)
458 rSize
.SetHeight(rSh
.GetAnyCurRect(RECT_FLY_EMBEDDED
).Height());
460 // disable vertical positioning for Math Objects anchored 'as char' if baseline alignment is activated
461 aSet
.Put( SfxBoolItem( FN_MATH_BASELINE_ALIGNMENT
,
462 rSh
.GetDoc()->get( IDocumentSettingAccess::MATH_BASELINE_ALIGNMENT
) ) );
463 const uno::Reference
< embed::XEmbeddedObject
> xObj( rSh
.GetOleRef() );
464 aSet
.Put( SfxBoolItem( FN_OLE_IS_MATH
, xObj
.is() && SotExchange::IsMath( xObj
->getClassID() ) ) );
466 sal_uInt16 nDefPage
= 0;
467 if(pArgs
&& pArgs
->GetItemState(FN_FORMAT_FRAME_DLG
, sal_False
, &pItem
) == SFX_ITEM_SET
)
468 nDefPage
= ((SfxUInt16Item
*)pItem
)->GetValue();
470 aSet
.Put(SfxFrameItem( SID_DOCFRAME
, &GetView().GetViewFrame()->GetTopFrame()));
471 FieldUnit eMetric
= ::GetDfltMetric(0 != PTR_CAST(SwWebView
, &GetView()));
472 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC
, static_cast< sal_uInt16
>(eMetric
) ));
473 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
474 OSL_ENSURE(pFact
, "Dialogdiet fail!");
475 SfxAbstractTabDialog
* pDlg
= pFact
->CreateFrmTabDialog( DLG_FRM_STD
,
476 GetView().GetViewFrame(),
477 GetView().GetWindow(),
479 nSel
& nsSelectionType::SEL_GRF
? DLG_FRM_GRF
:
480 nSel
& nsSelectionType::SEL_OLE
? DLG_FRM_OLE
:
484 OSL_ENSURE(pDlg
, "Dialogdiet fail!");
486 if ( nSlot
== FN_DRAW_WRAP_DLG
)
488 pDlg
->SetCurPageId(TP_FRM_WRAP
);
491 if ( pDlg
->Execute() )
493 const SfxItemSet
* pOutSet
= pDlg
->GetOutputItemSet();
497 if(nSel
& nsSelectionType::SEL_OLE
&&
498 SFX_ITEM_SET
== pOutSet
->GetItemState(FN_KEEP_ASPECT_RATIO
, sal_True
, &pItem
))
500 SwViewOption
aUsrPref( *pVOpt
);
501 aUsrPref
.SetKeepRatio(((const SfxBoolItem
*)pItem
)->GetValue());
502 SW_MOD()->ApplyUsrPref(aUsrPref
, &GetView());
504 if (SFX_ITEM_SET
== pOutSet
->GetItemState(FN_SET_FRM_ALT_NAME
, sal_True
, &pItem
))
507 rSh
.SetObjTitle(((const SfxStringItem
*)pItem
)->GetValue());
509 // Template AutoUpdate
510 SwFrmFmt
* pFmt
= rSh
.GetCurFrmFmt();
511 if(pFmt
&& pFmt
->IsAutoUpdateFmt())
513 rSh
.AutoUpdateFrame(pFmt
, *pOutSet
);
514 // Anything which is not supported by the format must be set hard.
515 if(SFX_ITEM_SET
== pOutSet
->GetItemState(FN_SET_FRM_NAME
, sal_False
, &pItem
))
516 rSh
.SetFlyName(((SfxStringItem
*)pItem
)->GetValue());
517 SfxItemSet
aShellSet(GetPool(), RES_FRM_SIZE
, RES_FRM_SIZE
,
518 RES_SURROUND
, RES_SURROUND
,
519 RES_ANCHOR
, RES_ANCHOR
,
520 RES_VERT_ORIENT
,RES_HORI_ORIENT
,
522 aShellSet
.Put(*pOutSet
);
523 aMgr
.SetAttrSet(aShellSet
);
524 if(SFX_ITEM_SET
== pOutSet
->GetItemState(FN_SET_FRM_NAME
, sal_False
, &pItem
))
525 rSh
.SetFlyName(((SfxStringItem
*)pItem
)->GetValue());
528 aMgr
.SetAttrSet( *pOutSet
);
530 const SwFrmFmt
* pCurrFlyFmt
= rSh
.GetFlyFrmFmt();
532 pOutSet
->GetItemState(FN_PARAM_CHAIN_PREVIOUS
,
535 rSh
.HideChainMarker();
538 ((const SfxStringItem
*)pItem
)->GetValue();
539 const SwFmtChain
&rChain
= pCurrFlyFmt
->GetChain();
540 //needs cast - no non-const method available
541 SwFlyFrmFmt
* pFlyFmt
=
542 (SwFlyFrmFmt
*)rChain
.GetPrev();
545 if (pFlyFmt
->GetName() != sPrevName
)
547 rSh
.Unchain(*pFlyFmt
);
555 //needs cast - no non-const method available
556 SwFrmFmt
* pPrevFmt
= (SwFrmFmt
*)
557 lcl_GetFrmFmtByName(rSh
, sPrevName
);
558 OSL_ENSURE(pPrevFmt
, "No frame found!");
561 rSh
.Chain(*pPrevFmt
, *pCurrFlyFmt
);
564 rSh
.SetChainMarker();
567 pOutSet
->GetItemState(FN_PARAM_CHAIN_NEXT
, sal_False
,
570 rSh
.HideChainMarker();
572 ((const SfxStringItem
*)pItem
)->GetValue();
573 const SwFmtChain
&rChain
= pCurrFlyFmt
->GetChain();
574 //needs cast - no non-const method available
575 SwFlyFrmFmt
* pFlyFmt
=
576 (SwFlyFrmFmt
*)rChain
.GetNext();
579 if (pFlyFmt
->GetName() != sNextName
)
581 rSh
.Unchain(*((SwFlyFrmFmt
*) pCurrFlyFmt
));
589 //needs cast - no non-const method available
590 SwFrmFmt
* pNextFmt
= (SwFrmFmt
*)
591 lcl_GetFrmFmtByName(rSh
, sNextName
);
592 OSL_ENSURE(pNextFmt
, "No frame found!");
595 rSh
.Chain(*(SwFrmFmt
*)
596 pCurrFlyFmt
, *pNextFmt
);
599 rSh
.SetChainMarker();
609 case FN_FRAME_MIRROR_ON_EVEN_PAGES
:
611 SwFmtHoriOrient
aHori(aMgr
.GetHoriOrient());
612 sal_Bool bMirror
= !aHori
.IsPosToggle();
613 aHori
.SetPosToggle(bMirror
);
614 SfxItemSet
aSet(GetPool(), RES_HORI_ORIENT
, RES_HORI_ORIENT
);
616 aMgr
.SetAttrSet(aSet
);
618 rReq
.SetReturnValue(SfxBoolItem(nSlot
, bMirror
));
622 case FN_TITLE_DESCRIPTION_SHAPE
:
625 SdrView
* pSdrView
= rSh
.GetDrawViewWithValidMarkList();
627 pSdrView
->GetMarkedObjectCount() == 1 )
629 String
aDescription(rSh
.GetObjDescription());
630 String
aTitle(rSh
.GetObjTitle());
632 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
633 OSL_ENSURE(pFact
, "Dialogdiet fail!");
634 AbstractSvxObjectTitleDescDialog
* pDlg
=
635 pFact
->CreateSvxObjectTitleDescDialog( NULL
,
638 OSL_ENSURE(pDlg
, "Dialogdiet fail!");
640 if ( pDlg
->Execute() == RET_OK
)
642 pDlg
->GetDescription(aDescription
);
643 pDlg
->GetTitle(aTitle
);
645 rSh
.SetObjDescription(aDescription
);
646 rSh
.SetObjTitle(aTitle
);
654 OSL_ENSURE( !this, "wrong dispatcher" );
659 SwFrmFmt
* pFmt
= rSh
.GetCurFrmFmt();
660 if ( bCopyToFmt
&& pFmt
&& pFmt
->IsAutoUpdateFmt() )
662 rSh
.AutoUpdateFrame(pFmt
, aMgr
.GetAttrSet());
672 void SwFrameShell::GetState(SfxItemSet
& rSet
)
674 SwWrtShell
&rSh
= GetShell();
675 bool bHtmlMode
= 0 != ::GetHtmlMode(rSh
.GetView().GetDocShell());
676 if (rSh
.IsFrmSelected())
678 SfxItemSet
aSet( rSh
.GetAttrPool(),
679 RES_LR_SPACE
, RES_UL_SPACE
,
680 RES_PROTECT
, RES_HORI_ORIENT
,
681 RES_OPAQUE
, RES_OPAQUE
,
682 RES_PRINT
, RES_OPAQUE
,
684 rSh
.GetFlyFrmAttr( aSet
);
686 sal_Bool bProtect
= rSh
.IsSelObjProtected(FLYPROTECT_POS
);
687 sal_Bool bParentCntProt
= rSh
.IsSelObjProtected( FLYPROTECT_CONTENT
|FLYPROTECT_PARENT
) != 0;
689 bProtect
|= bParentCntProt
;
691 const sal_uInt16 eFrmType
= rSh
.GetFrmType(0,sal_True
);
692 SwFlyFrmAttrMgr
aMgr( sal_False
, &rSh
, FRMMGR_TYPE_NONE
);
694 SfxWhichIter
aIter( rSet
);
695 sal_uInt16 nWhich
= aIter
.FirstWhich();
702 SwFmtFrmSize
aSz(aMgr
.GetFrmSize());
706 case RES_VERT_ORIENT
:
707 case RES_HORI_ORIENT
:
708 case SID_ATTR_ULSPACE
:
709 case SID_ATTR_LRSPACE
:
717 rSet
.Put(aSet
.Get(GetPool().GetWhich(nWhich
), sal_True
));
720 case SID_OBJECT_ALIGN_LEFT
:
721 case SID_OBJECT_ALIGN_CENTER
:
722 case SID_OBJECT_ALIGN_RIGHT
:
723 case FN_FRAME_ALIGN_HORZ_CENTER
:
724 case FN_FRAME_ALIGN_HORZ_RIGHT
:
725 case FN_FRAME_ALIGN_HORZ_LEFT
:
726 if ( (eFrmType
& FRMTYPE_FLY_INCNT
) ||
728 ((nWhich
== FN_FRAME_ALIGN_HORZ_CENTER
|| nWhich
== SID_OBJECT_ALIGN_CENTER
) &&
730 rSet
.DisableItem( nWhich
);
732 case FN_FRAME_ALIGN_VERT_ROW_TOP
:
733 case FN_FRAME_ALIGN_VERT_ROW_CENTER
:
734 case FN_FRAME_ALIGN_VERT_ROW_BOTTOM
:
735 case FN_FRAME_ALIGN_VERT_CHAR_TOP
:
736 case FN_FRAME_ALIGN_VERT_CHAR_CENTER
:
737 case FN_FRAME_ALIGN_VERT_CHAR_BOTTOM
:
738 if ( !(eFrmType
& FRMTYPE_FLY_INCNT
) || bProtect
739 || (bHtmlMode
&& FN_FRAME_ALIGN_VERT_CHAR_BOTTOM
== nWhich
) )
740 rSet
.DisableItem( nWhich
);
743 case SID_OBJECT_ALIGN_UP
:
744 case SID_OBJECT_ALIGN_MIDDLE
:
745 case SID_OBJECT_ALIGN_DOWN
:
747 case FN_FRAME_ALIGN_VERT_TOP
:
748 case FN_FRAME_ALIGN_VERT_CENTER
:
749 case FN_FRAME_ALIGN_VERT_BOTTOM
:
750 if ( bProtect
|| (bHtmlMode
&& eFrmType
& FRMTYPE_FLY_ATCNT
))
751 rSet
.DisableItem( nWhich
);
755 if (eFrmType
& FRMTYPE_FLY_INCNT
)
759 case SID_OBJECT_ALIGN_UP
:
760 case FN_FRAME_ALIGN_VERT_TOP
:
761 nId
= STR_TOP_BASE
; break;
762 case SID_OBJECT_ALIGN_MIDDLE
:
763 case FN_FRAME_ALIGN_VERT_CENTER
:
764 nId
= STR_CENTER_BASE
; break;
765 case SID_OBJECT_ALIGN_DOWN
:
766 case FN_FRAME_ALIGN_VERT_BOTTOM
:
768 nId
= STR_BOTTOM_BASE
;
770 rSet
.DisableItem( nWhich
);
776 if (nWhich
!= FN_FRAME_ALIGN_VERT_TOP
&&
777 nWhich
!= SID_OBJECT_ALIGN_UP
)
779 if (aMgr
.GetAnchor() == FLY_AT_FLY
)
781 const SwFrmFmt
* pFmt
= rSh
.IsFlyInFly();
784 const SwFmtFrmSize
& rFrmSz
= pFmt
->GetFrmSize();
785 if (rFrmSz
.GetHeightSizeType() != ATT_FIX_SIZE
)
787 rSet
.DisableItem( nWhich
);
795 case SID_OBJECT_ALIGN_UP
:
796 case FN_FRAME_ALIGN_VERT_TOP
:
797 nId
= STR_TOP
; break;
798 case SID_OBJECT_ALIGN_MIDDLE
:
799 case FN_FRAME_ALIGN_VERT_CENTER
:
800 nId
= STR_CENTER_VERT
; break;
801 case SID_OBJECT_ALIGN_DOWN
:
802 case FN_FRAME_ALIGN_VERT_BOTTOM
:
803 nId
= STR_BOTTOM
; break;
807 rSet
.Put( SfxStringItem( nWhich
, SW_RES(nId
) ));
810 case SID_HYPERLINK_GETLINK
:
812 SvxHyperlinkItem aHLinkItem
;
813 const SfxPoolItem
* pItem
;
815 SfxItemSet
aURLSet(GetPool(), RES_URL
, RES_URL
);
816 rSh
.GetFlyFrmAttr( aURLSet
);
818 if(SFX_ITEM_SET
== aURLSet
.GetItemState(RES_URL
, sal_True
, &pItem
))
820 const SwFmtURL
* pFmtURL
= (const SwFmtURL
*)pItem
;
821 aHLinkItem
.SetURL(pFmtURL
->GetURL());
822 aHLinkItem
.SetTargetFrame(pFmtURL
->GetTargetFrameName());
823 aHLinkItem
.SetName(rSh
.GetFlyName());
826 aHLinkItem
.SetInsertMode((SvxLinkInsertMode
)(aHLinkItem
.GetInsertMode() |
827 (bHtmlMode
? HLINK_HTMLMODE
: 0)));
829 rSet
.Put(aHLinkItem
);
835 const int nSel
= rSh
.GetSelectionType();
836 if (nSel
& nsSelectionType::SEL_GRF
|| nSel
& nsSelectionType::SEL_OLE
)
837 rSet
.DisableItem( FN_FRAME_CHAIN
);
840 const SwFrmFmt
*pFmt
= rSh
.GetFlyFrmFmt();
841 if ( bParentCntProt
|| rSh
.GetView().GetEditWin().GetApplyTemplate() ||
842 !pFmt
|| pFmt
->GetChain().GetNext() )
844 rSet
.DisableItem( FN_FRAME_CHAIN
);
848 sal_Bool bChainMode
= rSh
.GetView().GetEditWin().IsChainMode();
849 rSet
.Put( SfxBoolItem( FN_FRAME_CHAIN
, bChainMode
) );
854 case FN_FRAME_UNCHAIN
:
856 const int nSel
= rSh
.GetSelectionType();
857 if (nSel
& nsSelectionType::SEL_GRF
|| nSel
& nsSelectionType::SEL_OLE
)
858 rSet
.DisableItem( FN_FRAME_UNCHAIN
);
861 const SwFrmFmt
*pFmt
= rSh
.GetFlyFrmFmt();
862 if ( bParentCntProt
|| rSh
.GetView().GetEditWin().GetApplyTemplate() ||
863 !pFmt
|| !pFmt
->GetChain().GetNext() )
865 rSet
.DisableItem( FN_FRAME_UNCHAIN
);
870 case SID_FRAME_TO_TOP
:
871 case SID_FRAME_TO_BOTTOM
:
874 if ( bParentCntProt
)
875 rSet
.DisableItem( nWhich
);
878 case SID_ATTR_TRANSFORM
:
880 rSet
.DisableItem( nWhich
);
884 case SID_ATTR_TRANSFORM_PROTECT_SIZE
:
886 const sal_uInt8 eProtection
= rSh
.IsSelObjProtected( FLYPROTECT_SIZE
);
887 if ( ( eProtection
& FLYPROTECT_CONTENT
) ||
888 ( eProtection
& FLYPROTECT_SIZE
) )
890 rSet
.Put( SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_SIZE
, sal_True
) );
894 rSet
.Put( SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_SIZE
, sal_False
) );
899 case SID_ATTR_TRANSFORM_WIDTH
:
901 rSet
.Put( SfxUInt32Item( SID_ATTR_TRANSFORM_WIDTH
, aMgr
.GetSize().getWidth() ) );
905 case SID_ATTR_TRANSFORM_HEIGHT
:
907 rSet
.Put( SfxUInt32Item( SID_ATTR_TRANSFORM_HEIGHT
, aMgr
.GetSize().getHeight() ) );
911 case FN_FORMAT_FRAME_DLG
:
913 const int nSel
= rSh
.GetSelectionType();
914 if ( bParentCntProt
|| nSel
& nsSelectionType::SEL_GRF
)
915 rSet
.DisableItem( nWhich
);
919 case FN_TITLE_DESCRIPTION_SHAPE
:
921 SwWrtShell
&rWrtSh
= GetShell();
922 SdrView
* pSdrView
= rWrtSh
.GetDrawViewWithValidMarkList();
924 pSdrView
->GetMarkedObjectCount() != 1 )
926 rSet
.DisableItem( nWhich
);
936 nWhich
= aIter
.NextWhich();
941 SwFrameShell::SwFrameShell(SwView
&_rView
) :
942 SwBaseShell( _rView
)
944 SetName(OUString("Frame"));
945 SetHelpId(SW_FRAMESHELL
);
947 // #96392# Use this to announce it is the frame shell who creates the selection.
948 SwTransferable::CreateSelection( _rView
.GetWrtShell(), (ViewShell
*) this );
950 SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Frame
));
953 SwFrameShell::~SwFrameShell()
955 // #96392# Only clear the selection if it was this frame shell who created it.
956 SwTransferable::ClearSelection( GetShell(), (ViewShell
*) this );
959 void SwFrameShell::ExecFrameStyle(SfxRequest
& rReq
)
961 SwWrtShell
&rSh
= GetShell();
962 bool bDefault
= false;
963 if (!rSh
.IsFrmSelected())
965 // At first pick the default BoxItem out of the pool.
966 // If unequal to regular box item, then it has already
967 // been changed (New one is no default).
968 const SvxBoxItem
* pPoolBoxItem
= (const SvxBoxItem
*)::GetDfltAttr(RES_BOX
);
970 const SfxItemSet
*pArgs
= rReq
.GetArgs();
971 SfxItemSet
aFrameSet(rSh
.GetAttrPool(), RES_BOX
, RES_BOX
);
973 rSh
.GetFlyFrmAttr( aFrameSet
);
974 const SvxBoxItem
& rBoxItem
= (const SvxBoxItem
&)aFrameSet
.Get(RES_BOX
);
976 if (pPoolBoxItem
== &rBoxItem
)
979 SvxBoxItem
aBoxItem(rBoxItem
);
981 SvxBorderLine aBorderLine
;
982 const SfxPoolItem
*pItem
= 0;
984 if(pArgs
) // Any controller can sometimes deliver nothing #48169#
986 switch (rReq
.GetSlot())
988 case SID_ATTR_BORDER
:
990 if (pArgs
->GetItemState(RES_BOX
, sal_True
, &pItem
) == SFX_ITEM_SET
)
992 SvxBoxItem
aNewBox(*((SvxBoxItem
*)pItem
));
993 const SvxBorderLine
* pBorderLine
;
995 if ((pBorderLine
= aBoxItem
.GetTop()) != NULL
)
996 lcl_FrmGetMaxLineWidth(pBorderLine
, aBorderLine
);
997 if ((pBorderLine
= aBoxItem
.GetBottom()) != NULL
)
998 lcl_FrmGetMaxLineWidth(pBorderLine
, aBorderLine
);
999 if ((pBorderLine
= aBoxItem
.GetLeft()) != NULL
)
1000 lcl_FrmGetMaxLineWidth(pBorderLine
, aBorderLine
);
1001 if ((pBorderLine
= aBoxItem
.GetRight()) != NULL
)
1002 lcl_FrmGetMaxLineWidth(pBorderLine
, aBorderLine
);
1004 if(aBorderLine
.GetOutWidth() == 0)
1006 aBorderLine
.SetBorderLineStyle(
1007 table::BorderLineStyle::SOLID
);
1008 aBorderLine
.SetWidth( DEF_LINE_WIDTH_0
);
1010 //Set distance only if the request is received from the controller.
1012 #ifndef DISABLE_SCRIPTING
1013 if(!StarBASIC::IsRunning())
1016 aNewBox
.SetDistance( rBoxItem
.GetDistance() );
1020 SvxBorderLine aDestBorderLine
;
1022 if ((pBorderLine
= aBoxItem
.GetTop()) != NULL
)
1023 aBoxItem
.SetLine(&aBorderLine
, BOX_LINE_TOP
);
1024 if ((pBorderLine
= aBoxItem
.GetBottom()) != NULL
)
1025 aBoxItem
.SetLine(&aBorderLine
, BOX_LINE_BOTTOM
);
1026 if ((pBorderLine
= aBoxItem
.GetLeft()) != NULL
)
1027 aBoxItem
.SetLine(&aBorderLine
, BOX_LINE_LEFT
);
1028 if ((pBorderLine
= aBoxItem
.GetRight()) != NULL
)
1029 aBoxItem
.SetLine(&aBorderLine
, BOX_LINE_RIGHT
);
1034 case SID_FRAME_LINESTYLE
:
1036 if (pArgs
->GetItemState(SID_FRAME_LINESTYLE
, sal_False
, &pItem
) == SFX_ITEM_SET
)
1038 const SvxLineItem
* pLineItem
=
1039 (const SvxLineItem
*)pItem
;
1041 if ( pLineItem
->GetLine() )
1043 aBorderLine
= *(pLineItem
->GetLine());
1045 if (!aBoxItem
.GetTop() && !aBoxItem
.GetBottom() &&
1046 !aBoxItem
.GetLeft() && !aBoxItem
.GetRight())
1048 aBoxItem
.SetLine(&aBorderLine
, BOX_LINE_TOP
);
1049 aBoxItem
.SetLine(&aBorderLine
, BOX_LINE_BOTTOM
);
1050 aBoxItem
.SetLine(&aBorderLine
, BOX_LINE_LEFT
);
1051 aBoxItem
.SetLine(&aBorderLine
, BOX_LINE_RIGHT
);
1055 if( aBoxItem
.GetTop() )
1057 aBorderLine
.SetColor( aBoxItem
.GetTop()->GetColor() );
1058 aBoxItem
.SetLine(&aBorderLine
, BOX_LINE_TOP
);
1060 if( aBoxItem
.GetBottom() )
1062 aBorderLine
.SetColor( aBoxItem
.GetBottom()->GetColor());
1063 aBoxItem
.SetLine(&aBorderLine
, BOX_LINE_BOTTOM
);
1065 if( aBoxItem
.GetLeft() )
1067 aBorderLine
.SetColor( aBoxItem
.GetLeft()->GetColor());
1068 aBoxItem
.SetLine(&aBorderLine
, BOX_LINE_LEFT
);
1070 if( aBoxItem
.GetRight() )
1072 aBorderLine
.SetColor(aBoxItem
.GetRight()->GetColor());
1073 aBoxItem
.SetLine(&aBorderLine
, BOX_LINE_RIGHT
);
1079 aBoxItem
.SetLine(0, BOX_LINE_TOP
);
1080 aBoxItem
.SetLine(0, BOX_LINE_BOTTOM
);
1081 aBoxItem
.SetLine(0, BOX_LINE_LEFT
);
1082 aBoxItem
.SetLine(0, BOX_LINE_RIGHT
);
1088 case SID_FRAME_LINECOLOR
:
1090 if (pArgs
->GetItemState(SID_FRAME_LINECOLOR
, sal_False
, &pItem
) == SFX_ITEM_SET
)
1092 const Color
& rNewColor
= ((const SvxColorItem
*)pItem
)->GetValue();
1094 if (!aBoxItem
.GetTop() && !aBoxItem
.GetBottom() &&
1095 !aBoxItem
.GetLeft() && !aBoxItem
.GetRight())
1097 aBorderLine
.SetColor( rNewColor
);
1098 aBoxItem
.SetLine(&aBorderLine
, BOX_LINE_TOP
);
1099 aBoxItem
.SetLine(&aBorderLine
, BOX_LINE_BOTTOM
);
1100 aBoxItem
.SetLine(&aBorderLine
, BOX_LINE_LEFT
);
1101 aBoxItem
.SetLine(&aBorderLine
, BOX_LINE_RIGHT
);
1105 if ( aBoxItem
.GetTop() )
1106 ((SvxBorderLine
*)aBoxItem
.GetTop())->SetColor( rNewColor
);
1107 if ( aBoxItem
.GetBottom() )
1108 ((SvxBorderLine
*)aBoxItem
.GetBottom())->SetColor( rNewColor
);
1109 if ( aBoxItem
.GetLeft() )
1110 ((SvxBorderLine
*)aBoxItem
.GetLeft())->SetColor( rNewColor
);
1111 if ( aBoxItem
.GetRight() )
1112 ((SvxBorderLine
*)aBoxItem
.GetRight())->SetColor( rNewColor
);
1119 if (bDefault
&& (aBoxItem
.GetTop() || aBoxItem
.GetBottom() ||
1120 aBoxItem
.GetLeft() || aBoxItem
.GetRight()))
1122 aBoxItem
.SetDistance(MIN_BORDER_DIST
);
1124 aFrameSet
.Put( aBoxItem
);
1125 // Template AutoUpdate
1126 SwFrmFmt
* pFmt
= rSh
.GetCurFrmFmt();
1127 if(pFmt
&& pFmt
->IsAutoUpdateFmt())
1129 rSh
.AutoUpdateFrame(pFmt
, aFrameSet
);
1132 rSh
.SetFlyFrmAttr( aFrameSet
);
1136 static void lcl_FrmGetMaxLineWidth(const SvxBorderLine
* pBorderLine
, SvxBorderLine
& rBorderLine
)
1138 if(pBorderLine
->GetWidth() > rBorderLine
.GetWidth())
1139 rBorderLine
.SetWidth(pBorderLine
->GetWidth());
1141 rBorderLine
.SetBorderLineStyle(pBorderLine
->GetBorderLineStyle());
1142 rBorderLine
.SetColor(pBorderLine
->GetColor());
1145 void SwFrameShell::GetLineStyleState(SfxItemSet
&rSet
)
1147 SwWrtShell
&rSh
= GetShell();
1148 bool bParentCntProt
= rSh
.IsSelObjProtected( FLYPROTECT_CONTENT
|FLYPROTECT_PARENT
) != 0;
1152 if (rSh
.IsFrmSelected())
1153 rSet
.DisableItem( SID_FRAME_LINECOLOR
);
1155 rSet
.DisableItem( SID_ATTR_BORDER
);
1156 rSet
.DisableItem( SID_FRAME_LINESTYLE
);
1160 if (rSh
.IsFrmSelected())
1162 SfxItemSet
aFrameSet( rSh
.GetAttrPool(), RES_BOX
, RES_BOX
);
1164 rSh
.GetFlyFrmAttr(aFrameSet
);
1166 const SvxBorderLine
* pLine
= ((const SvxBoxItem
&)aFrameSet
.Get(RES_BOX
)).GetTop();
1167 rSet
.Put(SvxColorItem(pLine
? pLine
->GetColor() : Color(), SID_FRAME_LINECOLOR
));
1172 void SwFrameShell::StateInsert(SfxItemSet
&rSet
)
1174 const int nSel
= GetShell().GetSelectionType();
1176 if ((nSel
& nsSelectionType::SEL_GRF
) || (nSel
& nsSelectionType::SEL_OLE
))
1177 rSet
.DisableItem(FN_INSERT_FRAME
);
1180 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */