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

Generated by: LCOV version 1.10