LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/ui/shells - frmsh.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 5 538 0.9 %
Date: 2013-07-09 Functions: 5 16 31.2 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10