1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sw.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir #include <hintids.hxx> 33*cdf0e10cSrcweir #include <uitool.hxx> 34*cdf0e10cSrcweir #include <svl/urihelper.hxx> 35*cdf0e10cSrcweir #include <svl/PasswordHelper.hxx> 36*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 37*cdf0e10cSrcweir #include <svl/stritem.hxx> 38*cdf0e10cSrcweir #include <svl/eitem.hxx> 39*cdf0e10cSrcweir #include <sot/formats.hxx> 40*cdf0e10cSrcweir #include <sfx2/passwd.hxx> 41*cdf0e10cSrcweir #include <sfx2/docfilt.hxx> 42*cdf0e10cSrcweir #include <sfx2/request.hxx> 43*cdf0e10cSrcweir #include <sfx2/docfile.hxx> 44*cdf0e10cSrcweir #include <sfx2/linkmgr.hxx> 45*cdf0e10cSrcweir #include <editeng/sizeitem.hxx> 46*cdf0e10cSrcweir #include <svtools/htmlcfg.hxx> 47*cdf0e10cSrcweir #include <section.hxx> 48*cdf0e10cSrcweir #include <docary.hxx> 49*cdf0e10cSrcweir #include <regionsw.hxx> 50*cdf0e10cSrcweir #include <basesh.hxx> 51*cdf0e10cSrcweir #include <wdocsh.hxx> 52*cdf0e10cSrcweir #include <view.hxx> 53*cdf0e10cSrcweir #include <swmodule.hxx> 54*cdf0e10cSrcweir #include <wrtsh.hxx> 55*cdf0e10cSrcweir #include <swundo.hxx> // fuer Undo-Ids 56*cdf0e10cSrcweir #include <column.hxx> 57*cdf0e10cSrcweir #include <fmtfsize.hxx> 58*cdf0e10cSrcweir #include <swunodef.hxx> 59*cdf0e10cSrcweir #include <shellio.hxx> 60*cdf0e10cSrcweir #include <helpid.h> 61*cdf0e10cSrcweir #include <cmdid.h> 62*cdf0e10cSrcweir #include <regionsw.hrc> 63*cdf0e10cSrcweir #include <comcore.hrc> 64*cdf0e10cSrcweir #include <globals.hrc> 65*cdf0e10cSrcweir #include <sfx2/bindings.hxx> 66*cdf0e10cSrcweir #include <svx/htmlmode.hxx> 67*cdf0e10cSrcweir #include <svx/dlgutil.hxx> 68*cdf0e10cSrcweir #include "swabstdlg.hxx" 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir /*-------------------------------------------------------------------- 71*cdf0e10cSrcweir Beschreibung: Bereiche einfuegen 72*cdf0e10cSrcweir --------------------------------------------------------------------*/ 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir void SwBaseShell::InsertRegionDialog(SfxRequest& rReq) 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir SwWrtShell& rSh = GetShell(); 78*cdf0e10cSrcweir const SfxItemSet *pSet = rReq.GetArgs(); 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir SfxItemSet aSet(GetPool(), 81*cdf0e10cSrcweir RES_COL, RES_COL, 82*cdf0e10cSrcweir RES_LR_SPACE, RES_LR_SPACE, 83*cdf0e10cSrcweir RES_COLUMNBALANCE, RES_FRAMEDIR, 84*cdf0e10cSrcweir RES_BACKGROUND, RES_BACKGROUND, 85*cdf0e10cSrcweir RES_FRM_SIZE, RES_FRM_SIZE, 86*cdf0e10cSrcweir RES_FTN_AT_TXTEND, RES_END_AT_TXTEND, 87*cdf0e10cSrcweir SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE, 88*cdf0e10cSrcweir 0); 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir if (!pSet || pSet->Count()==0) 91*cdf0e10cSrcweir { 92*cdf0e10cSrcweir SwRect aRect; 93*cdf0e10cSrcweir rSh.CalcBoundRect(aRect, FLY_AS_CHAR); 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir long nWidth = aRect.Width(); 96*cdf0e10cSrcweir aSet.Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth)); 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir // Hoehe=Breite fuer konsistentere Vorschau (analog zu Bereich bearbeiten) 99*cdf0e10cSrcweir aSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(nWidth, nWidth))); 100*cdf0e10cSrcweir SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 101*cdf0e10cSrcweir DBG_ASSERT(pFact, "Dialogdiet fail!"); 102*cdf0e10cSrcweir AbstractInsertSectionTabDialog* aTabDlg = pFact->CreateInsertSectionTabDialog( DLG_INSERT_SECTION, 103*cdf0e10cSrcweir &GetView().GetViewFrame()->GetWindow(), aSet , rSh); 104*cdf0e10cSrcweir DBG_ASSERT(aTabDlg, "Dialogdiet fail!"); 105*cdf0e10cSrcweir aTabDlg->Execute(); 106*cdf0e10cSrcweir rReq.Ignore(); 107*cdf0e10cSrcweir delete aTabDlg; 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir else 110*cdf0e10cSrcweir { 111*cdf0e10cSrcweir const SfxPoolItem *pItem = 0; 112*cdf0e10cSrcweir String aTmpStr; 113*cdf0e10cSrcweir if ( SFX_ITEM_SET == 114*cdf0e10cSrcweir pSet->GetItemState(FN_PARAM_REGION_NAME, sal_True, &pItem) ) 115*cdf0e10cSrcweir aTmpStr = rSh.GetUniqueSectionName( 116*cdf0e10cSrcweir &((const SfxStringItem *)pItem)->GetValue() ); 117*cdf0e10cSrcweir else 118*cdf0e10cSrcweir aTmpStr = rSh.GetUniqueSectionName(); 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir SwSectionData aSection(CONTENT_SECTION, aTmpStr); 121*cdf0e10cSrcweir rReq.SetReturnValue(SfxStringItem(FN_INSERT_REGION, aTmpStr)); 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir aSet.Put( *pSet ); 124*cdf0e10cSrcweir if(SFX_ITEM_SET == pSet->GetItemState(SID_ATTR_COLUMNS, sal_False, &pItem)|| 125*cdf0e10cSrcweir SFX_ITEM_SET == pSet->GetItemState(FN_INSERT_REGION, sal_False, &pItem)) 126*cdf0e10cSrcweir { 127*cdf0e10cSrcweir SwFmtCol aCol; 128*cdf0e10cSrcweir SwRect aRect; 129*cdf0e10cSrcweir rSh.CalcBoundRect(aRect, FLY_AS_CHAR); 130*cdf0e10cSrcweir long nWidth = aRect.Width(); 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir sal_uInt16 nCol = ((SfxUInt16Item *)pItem)->GetValue(); 133*cdf0e10cSrcweir if(nCol) 134*cdf0e10cSrcweir { 135*cdf0e10cSrcweir aCol.Init( nCol, 0, static_cast< sal_uInt16 >(nWidth) ); 136*cdf0e10cSrcweir aSet.Put(aCol); 137*cdf0e10cSrcweir } 138*cdf0e10cSrcweir } 139*cdf0e10cSrcweir else if(SFX_ITEM_SET == pSet->GetItemState(RES_COL, sal_False, &pItem)) 140*cdf0e10cSrcweir { 141*cdf0e10cSrcweir aSet.Put(*pItem); 142*cdf0e10cSrcweir } 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir const sal_Bool bHidden = SFX_ITEM_SET == 145*cdf0e10cSrcweir pSet->GetItemState(FN_PARAM_REGION_HIDDEN, sal_True, &pItem)? 146*cdf0e10cSrcweir (sal_Bool)((const SfxBoolItem *)pItem)->GetValue():sal_False; 147*cdf0e10cSrcweir const sal_Bool bProtect = SFX_ITEM_SET == 148*cdf0e10cSrcweir pSet->GetItemState(FN_PARAM_REGION_PROTECT, sal_True, &pItem)? 149*cdf0e10cSrcweir (sal_Bool)((const SfxBoolItem *)pItem)->GetValue():sal_False; 150*cdf0e10cSrcweir // --> FME 2004-06-22 #114856# edit in readonly sections 151*cdf0e10cSrcweir const sal_Bool bEditInReadonly = SFX_ITEM_SET == 152*cdf0e10cSrcweir pSet->GetItemState(FN_PARAM_REGION_EDIT_IN_READONLY, sal_True, &pItem)? 153*cdf0e10cSrcweir (sal_Bool)((const SfxBoolItem *)pItem)->GetValue():sal_False; 154*cdf0e10cSrcweir // <-- 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir aSection.SetProtectFlag(bProtect); 157*cdf0e10cSrcweir aSection.SetHidden(bHidden); 158*cdf0e10cSrcweir // --> FME 2004-06-22 #114856# edit in readonly sections 159*cdf0e10cSrcweir aSection.SetEditInReadonlyFlag(bEditInReadonly); 160*cdf0e10cSrcweir // <-- 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir if(SFX_ITEM_SET == 163*cdf0e10cSrcweir pSet->GetItemState(FN_PARAM_REGION_CONDITION, sal_True, &pItem)) 164*cdf0e10cSrcweir aSection.SetCondition(((const SfxStringItem *)pItem)->GetValue()); 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir String aFile, aSub; 167*cdf0e10cSrcweir if(SFX_ITEM_SET == 168*cdf0e10cSrcweir pSet->GetItemState(FN_PARAM_1, sal_True, &pItem)) 169*cdf0e10cSrcweir aFile = ((const SfxStringItem *)pItem)->GetValue(); 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir if(SFX_ITEM_SET == 172*cdf0e10cSrcweir pSet->GetItemState(FN_PARAM_3, sal_True, &pItem)) 173*cdf0e10cSrcweir aSub = ((const SfxStringItem *)pItem)->GetValue(); 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir if(aFile.Len() || aSub.Len()) 177*cdf0e10cSrcweir { 178*cdf0e10cSrcweir String sLinkFileName(sfx2::cTokenSeperator); 179*cdf0e10cSrcweir sLinkFileName += sfx2::cTokenSeperator; 180*cdf0e10cSrcweir sLinkFileName.SetToken(0, sfx2::cTokenSeperator,aFile); 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir if(SFX_ITEM_SET == 183*cdf0e10cSrcweir pSet->GetItemState(FN_PARAM_2, sal_True, &pItem)) 184*cdf0e10cSrcweir sLinkFileName.SetToken(1, sfx2::cTokenSeperator, 185*cdf0e10cSrcweir ((const SfxStringItem *)pItem)->GetValue()); 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir sLinkFileName += aSub; 188*cdf0e10cSrcweir aSection.SetType( FILE_LINK_SECTION ); 189*cdf0e10cSrcweir aSection.SetLinkFileName(sLinkFileName); 190*cdf0e10cSrcweir } 191*cdf0e10cSrcweir rSh.InsertSection(aSection, aSet.Count() ? &aSet : 0); 192*cdf0e10cSrcweir rReq.Done(); 193*cdf0e10cSrcweir } 194*cdf0e10cSrcweir } 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir IMPL_STATIC_LINK( SwWrtShell, InsertRegionDialog, SwSectionData*, pSect ) 197*cdf0e10cSrcweir { 198*cdf0e10cSrcweir ::std::auto_ptr<SwSectionData> pSectionData(pSect); 199*cdf0e10cSrcweir if (pSectionData.get()) 200*cdf0e10cSrcweir { 201*cdf0e10cSrcweir SfxItemSet aSet(pThis->GetView().GetPool(), 202*cdf0e10cSrcweir RES_COL, RES_COL, 203*cdf0e10cSrcweir RES_BACKGROUND, RES_BACKGROUND, 204*cdf0e10cSrcweir RES_FRM_SIZE, RES_FRM_SIZE, 205*cdf0e10cSrcweir SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE, 206*cdf0e10cSrcweir 0); 207*cdf0e10cSrcweir SwRect aRect; 208*cdf0e10cSrcweir pThis->CalcBoundRect(aRect, FLY_AS_CHAR); 209*cdf0e10cSrcweir long nWidth = aRect.Width(); 210*cdf0e10cSrcweir aSet.Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth)); 211*cdf0e10cSrcweir // Hoehe=Breite fuer konsistentere Vorschau (analog zu Bereich bearbeiten) 212*cdf0e10cSrcweir aSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(nWidth, nWidth))); 213*cdf0e10cSrcweir SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 214*cdf0e10cSrcweir DBG_ASSERT(pFact, "Dialogdiet fail!"); 215*cdf0e10cSrcweir AbstractInsertSectionTabDialog* aTabDlg = pFact->CreateInsertSectionTabDialog( DLG_INSERT_SECTION, 216*cdf0e10cSrcweir &pThis->GetView().GetViewFrame()->GetWindow(),aSet , *pThis); 217*cdf0e10cSrcweir DBG_ASSERT(aTabDlg, "Dialogdiet fail!"); 218*cdf0e10cSrcweir aTabDlg->SetSectionData(*pSectionData); 219*cdf0e10cSrcweir aTabDlg->Execute(); 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir delete aTabDlg; 222*cdf0e10cSrcweir } 223*cdf0e10cSrcweir return 0; 224*cdf0e10cSrcweir } 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir /*-------------------------------------------------------------------- 227*cdf0e10cSrcweir Beschreibung: Bereich bearbeiten 228*cdf0e10cSrcweir --------------------------------------------------------------------*/ 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir void SwBaseShell::EditRegionDialog(SfxRequest& rReq) 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir const SfxItemSet* pArgs = rReq.GetArgs(); 233*cdf0e10cSrcweir sal_uInt16 nSlot = rReq.GetSlot(); 234*cdf0e10cSrcweir const SfxPoolItem* pItem = 0; 235*cdf0e10cSrcweir if(pArgs) 236*cdf0e10cSrcweir pArgs->GetItemState(nSlot, sal_False, &pItem); 237*cdf0e10cSrcweir SwWrtShell& rWrtShell = GetShell(); 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir switch ( nSlot ) 240*cdf0e10cSrcweir { 241*cdf0e10cSrcweir case FN_EDIT_REGION: 242*cdf0e10cSrcweir { 243*cdf0e10cSrcweir Window* pParentWin = &GetView().GetViewFrame()->GetWindow(); 244*cdf0e10cSrcweir sal_Bool bStart = sal_True; 245*cdf0e10cSrcweir if(bStart) 246*cdf0e10cSrcweir { 247*cdf0e10cSrcweir SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 248*cdf0e10cSrcweir DBG_ASSERT(pFact, "Dialogdiet fail!"); 249*cdf0e10cSrcweir AbstractEditRegionDlg* pEditRegionDlg = pFact->CreateEditRegionDlg( MD_EDIT_REGION, 250*cdf0e10cSrcweir pParentWin, rWrtShell); 251*cdf0e10cSrcweir DBG_ASSERT(pEditRegionDlg, "Dialogdiet fail!"); 252*cdf0e10cSrcweir if(pItem && pItem->ISA(SfxStringItem)) 253*cdf0e10cSrcweir { 254*cdf0e10cSrcweir pEditRegionDlg->SelectSection(((const SfxStringItem*)pItem)->GetValue()); 255*cdf0e10cSrcweir } 256*cdf0e10cSrcweir pEditRegionDlg->Execute(); 257*cdf0e10cSrcweir delete pEditRegionDlg; 258*cdf0e10cSrcweir } 259*cdf0e10cSrcweir else 260*cdf0e10cSrcweir InfoBox(pParentWin, SW_RES(REG_WRONG_PASSWORD)).Execute(); 261*cdf0e10cSrcweir } 262*cdf0e10cSrcweir break; 263*cdf0e10cSrcweir } 264*cdf0e10cSrcweir } 265