LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/ui/dialog - regionsw.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 105 1.0 %
Date: 2013-07-09 Functions: 2 5 40.0 %
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 <uitool.hxx>
      22             : #include <svl/urihelper.hxx>
      23             : #include <svl/PasswordHelper.hxx>
      24             : #include <vcl/msgbox.hxx>
      25             : #include <svl/stritem.hxx>
      26             : #include <svl/eitem.hxx>
      27             : #include <sot/formats.hxx>
      28             : #include <sfx2/passwd.hxx>
      29             : #include <sfx2/docfilt.hxx>
      30             : #include <sfx2/request.hxx>
      31             : #include <sfx2/docfile.hxx>
      32             : #include <sfx2/linkmgr.hxx>
      33             : #include <editeng/sizeitem.hxx>
      34             : #include <svtools/htmlcfg.hxx>
      35             : #include <section.hxx>
      36             : #include <docary.hxx>
      37             : #include <regionsw.hxx>
      38             : #include <basesh.hxx>
      39             : #include <wdocsh.hxx>
      40             : #include <view.hxx>
      41             : #include <swmodule.hxx>
      42             : #include <wrtsh.hxx>
      43             : #include <swundo.hxx>                   // for Undo-Ids
      44             : #include <column.hxx>
      45             : #include <fmtfsize.hxx>
      46             : #include <shellio.hxx>
      47             : #include <helpid.h>
      48             : #include <cmdid.h>
      49             : #include <regionsw.hrc>
      50             : #include <comcore.hrc>
      51             : #include <globals.hrc>
      52             : #include <sfx2/bindings.hxx>
      53             : #include <sfx2/htmlmode.hxx>
      54             : #include <svx/dlgutil.hxx>
      55             : #include "swabstdlg.hxx"
      56             : #include <boost/scoped_ptr.hpp>
      57             : 
      58           0 : void SwBaseShell::InsertRegionDialog(SfxRequest& rReq)
      59             : {
      60           0 :     SwWrtShell& rSh = GetShell();
      61           0 :     const SfxItemSet *pSet = rReq.GetArgs();
      62             : 
      63           0 :     SfxItemSet aSet(GetPool(),
      64             :             RES_COL, RES_COL,
      65             :             RES_LR_SPACE, RES_LR_SPACE,
      66             :             RES_COLUMNBALANCE, RES_FRAMEDIR,
      67             :             RES_BACKGROUND, RES_BACKGROUND,
      68             :             RES_FRM_SIZE, RES_FRM_SIZE,
      69             :             RES_FTN_AT_TXTEND, RES_END_AT_TXTEND,
      70             :             SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
      71           0 :             0);
      72             : 
      73           0 :     if (!pSet || pSet->Count()==0)
      74             :     {
      75           0 :         SwRect aRect;
      76           0 :         rSh.CalcBoundRect(aRect, FLY_AS_CHAR);
      77             : 
      78           0 :         long nWidth = aRect.Width();
      79           0 :         aSet.Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth));
      80             : 
      81             :         // height=width for more consistent preview (analog to edit region)
      82           0 :         aSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(nWidth, nWidth)));
      83           0 :         SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
      84             :         OSL_ENSURE(pFact, "Dialogdiet fail!");
      85             :         AbstractInsertSectionTabDialog* aTabDlg = pFact->CreateInsertSectionTabDialog( DLG_INSERT_SECTION,
      86           0 :                                                         &GetView().GetViewFrame()->GetWindow(), aSet , rSh);
      87             :         OSL_ENSURE(aTabDlg, "Dialogdiet fail!");
      88           0 :         aTabDlg->Execute();
      89           0 :         rReq.Ignore();
      90           0 :         delete aTabDlg;
      91             :     }
      92             :     else
      93             :     {
      94           0 :         const SfxPoolItem *pItem = 0;
      95           0 :         String aTmpStr;
      96           0 :         if ( SFX_ITEM_SET ==
      97           0 :                 pSet->GetItemState(FN_PARAM_REGION_NAME, sal_True, &pItem) )
      98             :         {
      99           0 :             String sRemoveWhenUniStringIsGone = ((const SfxStringItem *)pItem)->GetValue();
     100           0 :             aTmpStr = rSh.GetUniqueSectionName(&sRemoveWhenUniStringIsGone);
     101             :         }
     102             :         else
     103           0 :             aTmpStr = rSh.GetUniqueSectionName();
     104             : 
     105           0 :         SwSectionData aSection(CONTENT_SECTION, aTmpStr);
     106           0 :         rReq.SetReturnValue(SfxStringItem(FN_INSERT_REGION, aTmpStr));
     107             : 
     108           0 :         aSet.Put( *pSet );
     109           0 :         if(SFX_ITEM_SET == pSet->GetItemState(SID_ATTR_COLUMNS, sal_False, &pItem)||
     110           0 :             SFX_ITEM_SET == pSet->GetItemState(FN_INSERT_REGION, sal_False, &pItem))
     111             :         {
     112           0 :             SwFmtCol aCol;
     113           0 :             SwRect aRect;
     114           0 :             rSh.CalcBoundRect(aRect, FLY_AS_CHAR);
     115           0 :             long nWidth = aRect.Width();
     116             : 
     117           0 :             sal_uInt16 nCol = ((SfxUInt16Item *)pItem)->GetValue();
     118           0 :             if(nCol)
     119             :             {
     120           0 :                 aCol.Init( nCol, 0, static_cast< sal_uInt16 >(nWidth) );
     121           0 :                 aSet.Put(aCol);
     122           0 :             }
     123             :         }
     124           0 :         else if(SFX_ITEM_SET == pSet->GetItemState(RES_COL, sal_False, &pItem))
     125             :         {
     126           0 :             aSet.Put(*pItem);
     127             :         }
     128             : 
     129             :         const sal_Bool bHidden = SFX_ITEM_SET ==
     130           0 :             pSet->GetItemState(FN_PARAM_REGION_HIDDEN, sal_True, &pItem)?
     131           0 :             (sal_Bool)((const SfxBoolItem *)pItem)->GetValue():sal_False;
     132             :         const sal_Bool bProtect = SFX_ITEM_SET ==
     133           0 :             pSet->GetItemState(FN_PARAM_REGION_PROTECT, sal_True, &pItem)?
     134           0 :             (sal_Bool)((const SfxBoolItem *)pItem)->GetValue():sal_False;
     135             :         // #114856# edit in readonly sections
     136             :         const sal_Bool bEditInReadonly = SFX_ITEM_SET ==
     137           0 :             pSet->GetItemState(FN_PARAM_REGION_EDIT_IN_READONLY, sal_True, &pItem)?
     138           0 :             (sal_Bool)((const SfxBoolItem *)pItem)->GetValue():sal_False;
     139             : 
     140           0 :         aSection.SetProtectFlag(bProtect);
     141           0 :         aSection.SetHidden(bHidden);
     142             :         // #114856# edit in readonly sections
     143           0 :         aSection.SetEditInReadonlyFlag(bEditInReadonly);
     144             : 
     145           0 :         if(SFX_ITEM_SET ==
     146           0 :                 pSet->GetItemState(FN_PARAM_REGION_CONDITION, sal_True, &pItem))
     147           0 :             aSection.SetCondition(((const SfxStringItem *)pItem)->GetValue());
     148             : 
     149           0 :         String aFile, aSub;
     150           0 :         if(SFX_ITEM_SET ==
     151           0 :                 pSet->GetItemState(FN_PARAM_1, sal_True, &pItem))
     152           0 :             aFile = ((const SfxStringItem *)pItem)->GetValue();
     153             : 
     154           0 :         if(SFX_ITEM_SET ==
     155           0 :                 pSet->GetItemState(FN_PARAM_3, sal_True, &pItem))
     156           0 :             aSub = ((const SfxStringItem *)pItem)->GetValue();
     157             : 
     158             : 
     159           0 :         if(aFile.Len() || aSub.Len())
     160             :         {
     161           0 :             String sLinkFileName = OUString(sfx2::cTokenSeparator);
     162           0 :             sLinkFileName += sfx2::cTokenSeparator;
     163           0 :             sLinkFileName.SetToken(0, sfx2::cTokenSeparator,aFile);
     164             : 
     165           0 :             if(SFX_ITEM_SET ==
     166           0 :                     pSet->GetItemState(FN_PARAM_2, sal_True, &pItem))
     167             :                 sLinkFileName.SetToken(1, sfx2::cTokenSeparator,
     168           0 :                     ((const SfxStringItem *)pItem)->GetValue());
     169             : 
     170           0 :             sLinkFileName += aSub;
     171           0 :             aSection.SetType( FILE_LINK_SECTION );
     172           0 :             aSection.SetLinkFileName(sLinkFileName);
     173             :         }
     174           0 :         rSh.InsertSection(aSection, aSet.Count() ? &aSet : 0);
     175           0 :         rReq.Done();
     176           0 :     }
     177           0 : }
     178             : 
     179           0 : IMPL_STATIC_LINK( SwWrtShell, InsertRegionDialog, SwSectionData*, pSect )
     180             : {
     181           0 :     boost::scoped_ptr<SwSectionData> xSectionData(pSect);
     182           0 :     if (xSectionData.get())
     183             :     {
     184           0 :         SfxItemSet aSet(pThis->GetView().GetPool(),
     185             :                 RES_COL, RES_COL,
     186             :                 RES_BACKGROUND, RES_BACKGROUND,
     187             :                 RES_FRM_SIZE, RES_FRM_SIZE,
     188             :                 SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
     189           0 :                 0);
     190           0 :         SwRect aRect;
     191           0 :         pThis->CalcBoundRect(aRect, FLY_AS_CHAR);
     192           0 :         long nWidth = aRect.Width();
     193           0 :         aSet.Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth));
     194             :         // height=width for more consistent preview (analog to edit region)
     195           0 :         aSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(nWidth, nWidth)));
     196           0 :         SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     197             :         OSL_ENSURE(pFact, "Dialogdiet fail!");
     198             :         AbstractInsertSectionTabDialog* aTabDlg = pFact->CreateInsertSectionTabDialog( DLG_INSERT_SECTION,
     199           0 :                                                         &pThis->GetView().GetViewFrame()->GetWindow(),aSet , *pThis);
     200             :         OSL_ENSURE(aTabDlg, "Dialogdiet fail!");
     201           0 :         aTabDlg->SetSectionData(*xSectionData);
     202           0 :         aTabDlg->Execute();
     203             : 
     204           0 :         delete aTabDlg;
     205             :     }
     206           0 :     return 0;
     207             : }
     208             : 
     209           0 : void SwBaseShell::EditRegionDialog(SfxRequest& rReq)
     210             : {
     211           0 :     const SfxItemSet* pArgs = rReq.GetArgs();
     212           0 :     sal_uInt16 nSlot = rReq.GetSlot();
     213           0 :     const SfxPoolItem* pItem = 0;
     214           0 :     if(pArgs)
     215           0 :         pArgs->GetItemState(nSlot, sal_False, &pItem);
     216           0 :     SwWrtShell& rWrtShell = GetShell();
     217             : 
     218           0 :     switch ( nSlot )
     219             :     {
     220             :         case FN_EDIT_REGION:
     221             :         {
     222           0 :             Window* pParentWin = &GetView().GetViewFrame()->GetWindow();
     223             :             {
     224           0 :                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     225             :                 OSL_ENSURE(pFact, "Dialogdiet fail!");
     226           0 :                 AbstractEditRegionDlg* pEditRegionDlg = pFact->CreateEditRegionDlg(pParentWin, rWrtShell);
     227             :                 OSL_ENSURE(pEditRegionDlg, "Dialogdiet fail!");
     228           0 :                 if(pItem && pItem->ISA(SfxStringItem))
     229             :                 {
     230           0 :                     pEditRegionDlg->SelectSection(((const SfxStringItem*)pItem)->GetValue());
     231             :                 }
     232           0 :                 pEditRegionDlg->Execute();
     233           0 :                 delete pEditRegionDlg;
     234             :             }
     235             :         }
     236           0 :         break;
     237             :     }
     238          99 : }
     239             : 
     240             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10