1*efeef26fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*efeef26fSAndrew Rist * distributed with this work for additional information 6*efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*efeef26fSAndrew Rist * "License"); you may not use this file except in compliance 9*efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*efeef26fSAndrew Rist * software distributed under the License is distributed on an 15*efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*efeef26fSAndrew Rist * KIND, either express or implied. See the License for the 17*efeef26fSAndrew Rist * specific language governing permissions and limitations 18*efeef26fSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*efeef26fSAndrew Rist *************************************************************/ 21*efeef26fSAndrew Rist 22*efeef26fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sw.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir #if STLPORT_VERSION>=321 29cdf0e10cSrcweir #include <cstdarg> 30cdf0e10cSrcweir #endif 31cdf0e10cSrcweir 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <hintids.hxx> 34cdf0e10cSrcweir 35cdf0e10cSrcweir #include <sfx2/request.hxx> 36cdf0e10cSrcweir #include <svx/svxids.hrc> 37cdf0e10cSrcweir 38cdf0e10cSrcweir #include <svtools/svmedit.hxx> 39cdf0e10cSrcweir #include <vcl/svapp.hxx> 40cdf0e10cSrcweir #include <vcl/wrkwin.hxx> 41cdf0e10cSrcweir #include <sfx2/app.hxx> 42cdf0e10cSrcweir #include <sfx2/docfac.hxx> 43cdf0e10cSrcweir #include <sfx2/printer.hxx> 44cdf0e10cSrcweir #include <vcl/msgbox.hxx> 45cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 46cdf0e10cSrcweir #include <editeng/boxitem.hxx> 47cdf0e10cSrcweir #include <editeng/lrspitem.hxx> 48cdf0e10cSrcweir #include <editeng/ulspitem.hxx> 49cdf0e10cSrcweir #include <editeng/pbinitem.hxx> 50cdf0e10cSrcweir #include <editeng/paperinf.hxx> 51cdf0e10cSrcweir #include <editeng/brkitem.hxx> 52cdf0e10cSrcweir #include <fmthdft.hxx> 53cdf0e10cSrcweir #include <swwait.hxx> 54cdf0e10cSrcweir #include <paratr.hxx> 55cdf0e10cSrcweir #include <swmodule.hxx> 56cdf0e10cSrcweir #include <wrtsh.hxx> 57cdf0e10cSrcweir #include <view.hxx> 58cdf0e10cSrcweir #include <docsh.hxx> 59cdf0e10cSrcweir #include <frmatr.hxx> 60cdf0e10cSrcweir #include <fldbas.hxx> 61cdf0e10cSrcweir #include <swundo.hxx> 62cdf0e10cSrcweir #include <IDocumentDeviceAccess.hxx> 63cdf0e10cSrcweir #include <dbmgr.hxx> 64cdf0e10cSrcweir #include <fmtcol.hxx> 65cdf0e10cSrcweir #include <frmmgr.hxx> 66cdf0e10cSrcweir #include <fldmgr.hxx> 67cdf0e10cSrcweir #include <pagedesc.hxx> 68cdf0e10cSrcweir #include <poolfmt.hxx> 69cdf0e10cSrcweir #include <expfld.hxx> 70cdf0e10cSrcweir #include <SwStyleNameMapper.hxx> 71cdf0e10cSrcweir #include <crsskip.hxx> 72cdf0e10cSrcweir 73cdf0e10cSrcweir #include <cmdid.h> 74cdf0e10cSrcweir #ifndef _GLOBALS_HRC 75cdf0e10cSrcweir #include <globals.hrc> 76cdf0e10cSrcweir #endif 77cdf0e10cSrcweir #ifndef _APP_HRC 78cdf0e10cSrcweir #include <app.hrc> 79cdf0e10cSrcweir #endif 80cdf0e10cSrcweir #ifndef _POOLFMT_HRC 81cdf0e10cSrcweir #include <poolfmt.hrc> 82cdf0e10cSrcweir #endif 83cdf0e10cSrcweir #include "swabstdlg.hxx" 84cdf0e10cSrcweir #include "envelp.hrc" 85cdf0e10cSrcweir #include "envimg.hxx" 86cdf0e10cSrcweir 87cdf0e10cSrcweir #define ENV_NEWDOC RET_OK 88cdf0e10cSrcweir #define ENV_INSERT RET_USER 89cdf0e10cSrcweir #define ENV_CANCEL SHRT_MAX 90cdf0e10cSrcweir 91cdf0e10cSrcweir 92cdf0e10cSrcweir // -------------------------------------------------------------------------- 93cdf0e10cSrcweir 94cdf0e10cSrcweir 95cdf0e10cSrcweir // Funktion wird fuer Etiketten und Briefumschlaege benutzt! 96cdf0e10cSrcweir // im applab.cxx und appenv.cxx 97cdf0e10cSrcweir String InsertLabEnvText( SwWrtShell& rSh, SwFldMgr& rFldMgr, const String& rText ) 98cdf0e10cSrcweir { 99cdf0e10cSrcweir String sRet; 100cdf0e10cSrcweir String aText(rText); 101cdf0e10cSrcweir aText.EraseAllChars( '\r' ); 102cdf0e10cSrcweir 103cdf0e10cSrcweir 104cdf0e10cSrcweir sal_uInt16 nTokenPos = 0; 105cdf0e10cSrcweir while( STRING_NOTFOUND != nTokenPos ) 106cdf0e10cSrcweir { 107cdf0e10cSrcweir String aLine = aText.GetToken( 0, '\n', nTokenPos ); 108cdf0e10cSrcweir while ( aLine.Len() ) 109cdf0e10cSrcweir { 110cdf0e10cSrcweir String sTmpText; 111cdf0e10cSrcweir sal_Bool bField = sal_False; 112cdf0e10cSrcweir 113cdf0e10cSrcweir sal_uInt16 nPos = aLine.Search( '<' ); 114cdf0e10cSrcweir if ( nPos ) 115cdf0e10cSrcweir { 116cdf0e10cSrcweir sTmpText = aLine.Copy( 0, nPos ); 117cdf0e10cSrcweir aLine.Erase( 0, nPos ); 118cdf0e10cSrcweir // sTmpText = aLine.Cut( 0, nPos ); 119cdf0e10cSrcweir } 120cdf0e10cSrcweir else 121cdf0e10cSrcweir { 122cdf0e10cSrcweir nPos = aLine.Search( '>' ); 123cdf0e10cSrcweir if ( nPos == STRING_NOTFOUND ) 124cdf0e10cSrcweir { 125cdf0e10cSrcweir sTmpText = aLine; 126cdf0e10cSrcweir aLine.Erase(); 127cdf0e10cSrcweir // sTmpText = aLine.Cut(); 128cdf0e10cSrcweir } 129cdf0e10cSrcweir else 130cdf0e10cSrcweir { 131cdf0e10cSrcweir sTmpText = aLine.Copy( 0, nPos + 1); 132cdf0e10cSrcweir aLine.Erase( 0, nPos + 1); 133cdf0e10cSrcweir // sTmpText = aLine.Cut( 0, nPos + 1 ); 134cdf0e10cSrcweir 135cdf0e10cSrcweir // Datenbankfelder muesen mind. 3 Punkte beinhalten! 136cdf0e10cSrcweir String sDBName( sTmpText.Copy( 1, sTmpText.Len() - 2)); 137cdf0e10cSrcweir sal_uInt16 nCnt = sDBName.GetTokenCount('.'); 138cdf0e10cSrcweir if (nCnt >= 3) 139cdf0e10cSrcweir { 140cdf0e10cSrcweir ::ReplacePoint(sDBName, sal_True); 141cdf0e10cSrcweir SwInsertFld_Data aData(TYP_DBFLD, 0, sDBName, aEmptyStr, 0, &rSh ); 142cdf0e10cSrcweir rFldMgr.InsertFld( aData ); 143cdf0e10cSrcweir sRet = sDBName; 144cdf0e10cSrcweir bField = sal_True; 145cdf0e10cSrcweir } 146cdf0e10cSrcweir } 147cdf0e10cSrcweir } 148cdf0e10cSrcweir if ( !bField ) 149cdf0e10cSrcweir rSh.Insert( sTmpText ); 150cdf0e10cSrcweir } 151cdf0e10cSrcweir rSh.InsertLineBreak(); 152cdf0e10cSrcweir } 153cdf0e10cSrcweir rSh.DelLeft(); // Letzten Linebreak wieder l???schen 154cdf0e10cSrcweir 155cdf0e10cSrcweir return sRet; 156cdf0e10cSrcweir } 157cdf0e10cSrcweir 158cdf0e10cSrcweir // ---------------------------------------------------------------------------- 159cdf0e10cSrcweir 160cdf0e10cSrcweir 161cdf0e10cSrcweir void lcl_CopyCollAttr(SwWrtShell* pOldSh, SwWrtShell* pNewSh, sal_uInt16 nCollId) 162cdf0e10cSrcweir { 163cdf0e10cSrcweir sal_uInt16 nCollCnt = pOldSh->GetTxtFmtCollCount(); 164cdf0e10cSrcweir SwTxtFmtColl* pColl; 165cdf0e10cSrcweir for( sal_uInt16 nCnt = 0; nCnt < nCollCnt; ++nCnt ) 166cdf0e10cSrcweir if(nCollId == (pColl = &pOldSh->GetTxtFmtColl(nCnt))->GetPoolFmtId()) 167cdf0e10cSrcweir pNewSh->GetTxtCollFromPool(nCollId)->SetFmtAttr(pColl->GetAttrSet()); 168cdf0e10cSrcweir } 169cdf0e10cSrcweir 170cdf0e10cSrcweir // ---------------------------------------------------------------------------- 171cdf0e10cSrcweir 172cdf0e10cSrcweir 173cdf0e10cSrcweir void SwModule::InsertEnv( SfxRequest& rReq ) 174cdf0e10cSrcweir { 175cdf0e10cSrcweir static sal_uInt16 nTitleNo = 0; 176cdf0e10cSrcweir 177cdf0e10cSrcweir SwDocShell *pMyDocSh; 178cdf0e10cSrcweir SfxViewFrame *pFrame; 179cdf0e10cSrcweir SwView *pNewView; 180cdf0e10cSrcweir SwWrtShell *pOldSh, 181cdf0e10cSrcweir *pSh; 182cdf0e10cSrcweir 183cdf0e10cSrcweir //aktuelle Shell besorgen 184cdf0e10cSrcweir pMyDocSh = (SwDocShell*) SfxObjectShell::Current(); 185cdf0e10cSrcweir pOldSh = pMyDocSh ? pMyDocSh->GetWrtShell() : 0; 186cdf0e10cSrcweir 187cdf0e10cSrcweir // Neues Dokument erzeugen (kein Show!) 188cdf0e10cSrcweir SfxObjectShellLock xDocSh( new SwDocShell( SFX_CREATE_MODE_STANDARD ) ); 189cdf0e10cSrcweir xDocSh->DoInitNew( 0 ); 190cdf0e10cSrcweir pFrame = SfxViewFrame::LoadHiddenDocument( *xDocSh, 0 ); 191cdf0e10cSrcweir pNewView = (SwView*) pFrame->GetViewShell(); 192cdf0e10cSrcweir pNewView->AttrChangedNotify( &pNewView->GetWrtShell() );//Damit SelectShell gerufen wird. 193cdf0e10cSrcweir pSh = pNewView->GetWrtShellPtr(); 194cdf0e10cSrcweir 195cdf0e10cSrcweir String aTmp( SW_RES(STR_ENV_TITLE) ); 196cdf0e10cSrcweir aTmp += String::CreateFromInt32( ++nTitleNo ); 197cdf0e10cSrcweir xDocSh->SetTitle( aTmp ); 198cdf0e10cSrcweir 199cdf0e10cSrcweir // Ggf. alte Collections "Absender" und "Empfaenger" in neues 200cdf0e10cSrcweir // Dokument kopieren 201cdf0e10cSrcweir if ( pOldSh ) 202cdf0e10cSrcweir { 203cdf0e10cSrcweir ::lcl_CopyCollAttr(pOldSh, pSh, RES_POOLCOLL_JAKETADRESS); 204cdf0e10cSrcweir ::lcl_CopyCollAttr(pOldSh, pSh, RES_POOLCOLL_SENDADRESS); 205cdf0e10cSrcweir } 206cdf0e10cSrcweir 207cdf0e10cSrcweir // SwEnvItem aus Config lesen 208cdf0e10cSrcweir SwEnvCfgItem aEnvCfg; 209cdf0e10cSrcweir 210cdf0e10cSrcweir //Haben wir schon einen Briefumschlag. 211cdf0e10cSrcweir sal_Bool bEnvChange = sal_False; 212cdf0e10cSrcweir 213cdf0e10cSrcweir SfxItemSet aSet(GetPool(), FN_ENVELOP, FN_ENVELOP, 0); 214cdf0e10cSrcweir aSet.Put(aEnvCfg.GetItem()); 215cdf0e10cSrcweir 216cdf0e10cSrcweir SfxPrinter* pTempPrinter = pSh->getIDocumentDeviceAccess()->getPrinter( true ); 217cdf0e10cSrcweir if(pOldSh ) 218cdf0e10cSrcweir { 219cdf0e10cSrcweir const SwPageDesc& rCurPageDesc = pOldSh->GetPageDesc(pOldSh->GetCurPageDesc()); 220cdf0e10cSrcweir String sJacket; 221cdf0e10cSrcweir SwStyleNameMapper::FillUIName( RES_POOLPAGE_JAKET, sJacket ); 222cdf0e10cSrcweir bEnvChange = rCurPageDesc.GetName() == sJacket; 223cdf0e10cSrcweir 224cdf0e10cSrcweir IDocumentDeviceAccess* pIDDA_old = pOldSh->getIDocumentDeviceAccess(); 225cdf0e10cSrcweir if( pIDDA_old->getPrinter( false ) ) 226cdf0e10cSrcweir { 227cdf0e10cSrcweir IDocumentDeviceAccess* pIDDA = pSh->getIDocumentDeviceAccess(); 228cdf0e10cSrcweir pIDDA->setJobsetup( *pIDDA_old->getJobsetup() ); 229cdf0e10cSrcweir //#69563# if it isn't the same printer then the pointer has been invalidated! 230cdf0e10cSrcweir pTempPrinter = pIDDA->getPrinter( true ); 231cdf0e10cSrcweir } 232cdf0e10cSrcweir pTempPrinter->SetPaperBin(rCurPageDesc.GetMaster().GetPaperBin().GetValue()); 233cdf0e10cSrcweir 234cdf0e10cSrcweir } 235cdf0e10cSrcweir 236cdf0e10cSrcweir Window *pParent = pOldSh ? pOldSh->GetWin() : 0; 237cdf0e10cSrcweir SfxAbstractTabDialog * pDlg=NULL; 238cdf0e10cSrcweir short nMode = ENV_INSERT; 239cdf0e10cSrcweir 240cdf0e10cSrcweir SFX_REQUEST_ARG( rReq, pItem, SwEnvItem, FN_ENVELOP, sal_False ); 241cdf0e10cSrcweir if ( !pItem ) 242cdf0e10cSrcweir { 243cdf0e10cSrcweir SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 244cdf0e10cSrcweir DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); 245cdf0e10cSrcweir 246cdf0e10cSrcweir pDlg = pFact->CreateSwEnvDlg( pParent, aSet, pOldSh, pTempPrinter, !bEnvChange, DLG_ENV ); 247cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialogdiet fail!"); 248cdf0e10cSrcweir nMode = pDlg->Execute(); 249cdf0e10cSrcweir } 250cdf0e10cSrcweir else 251cdf0e10cSrcweir { 252cdf0e10cSrcweir SFX_REQUEST_ARG( rReq, pBoolItem, SfxBoolItem, FN_PARAM_1, sal_False ); 253cdf0e10cSrcweir if ( pBoolItem && pBoolItem->GetValue() ) 254cdf0e10cSrcweir nMode = ENV_NEWDOC; 255cdf0e10cSrcweir } 256cdf0e10cSrcweir 257cdf0e10cSrcweir if (nMode == ENV_NEWDOC || nMode == ENV_INSERT) 258cdf0e10cSrcweir { 259cdf0e10cSrcweir SwWait aWait( (SwDocShell&)*xDocSh, sal_True ); 260cdf0e10cSrcweir 261cdf0e10cSrcweir // Dialog auslesen, Item in Config speichern 262cdf0e10cSrcweir const SwEnvItem& rItem = pItem ? *pItem : (const SwEnvItem&) pDlg->GetOutputItemSet()->Get(FN_ENVELOP); 263cdf0e10cSrcweir aEnvCfg.GetItem() = rItem; 264cdf0e10cSrcweir aEnvCfg.Commit(); 265cdf0e10cSrcweir 266cdf0e10cSrcweir //Wenn wir Drucken uebernehmen wir den eingestellten Jobsetup aus 267cdf0e10cSrcweir //dem Dialog. Die Informationen muessen hier vor dem evtl. zerstoeren 268cdf0e10cSrcweir //der neuen Shell gesetzt werden, weil deren Drucker an den Dialog 269cdf0e10cSrcweir //gereicht wurde. 270cdf0e10cSrcweir if ( nMode != ENV_NEWDOC ) 271cdf0e10cSrcweir { 272cdf0e10cSrcweir ASSERT(pOldSh, "Kein Dokument - war 'Einfuegen' nicht disabled???"); 273cdf0e10cSrcweir SvxPaperBinItem aItem( RES_PAPER_BIN ); 274cdf0e10cSrcweir aItem.SetValue((sal_uInt8)pSh->getIDocumentDeviceAccess()->getPrinter(true)->GetPaperBin()); 275cdf0e10cSrcweir pOldSh->GetPageDescFromPool(RES_POOLPAGE_JAKET)->GetMaster().SetFmtAttr(aItem); 276cdf0e10cSrcweir } 277cdf0e10cSrcweir 278cdf0e10cSrcweir SwWrtShell *pTmp = nMode == ENV_INSERT ? pOldSh : pSh; 279cdf0e10cSrcweir const SwPageDesc* pFollow = 0; 280cdf0e10cSrcweir SwTxtFmtColl *pSend = pTmp->GetTxtCollFromPool( RES_POOLCOLL_SENDADRESS ), 281cdf0e10cSrcweir *pAddr = pTmp->GetTxtCollFromPool( RES_POOLCOLL_JAKETADRESS); 282cdf0e10cSrcweir const String &rSendMark = pSend->GetName(); 283cdf0e10cSrcweir const String &rAddrMark = pAddr->GetName(); 284cdf0e10cSrcweir 285cdf0e10cSrcweir if (nMode == ENV_INSERT) 286cdf0e10cSrcweir { 287cdf0e10cSrcweir 288cdf0e10cSrcweir SetView(&pOldSh->GetView()); // Pointer auf oberste View restaurieren 289cdf0e10cSrcweir 290cdf0e10cSrcweir //Neues Dok wieder loeschen 291cdf0e10cSrcweir xDocSh->DoClose(); 292cdf0e10cSrcweir pSh = pOldSh; 293cdf0e10cSrcweir //#i4251# selected text or objects in the document should 294cdf0e10cSrcweir //not be deleted on inserting envelopes 295cdf0e10cSrcweir pSh->EnterStdMode(); 296cdf0e10cSrcweir // Los geht's (Einfuegen) 297cdf0e10cSrcweir pSh->StartUndo(UNDO_UI_INSERT_ENVELOPE, NULL); 298cdf0e10cSrcweir pSh->StartAllAction(); 299cdf0e10cSrcweir pSh->SttEndDoc(sal_True); 300cdf0e10cSrcweir 301cdf0e10cSrcweir if (bEnvChange) 302cdf0e10cSrcweir { 303cdf0e10cSrcweir // Folgevorlage: Seite 2 304cdf0e10cSrcweir pFollow = pSh->GetPageDesc(pSh->GetCurPageDesc()).GetFollow(); 305cdf0e10cSrcweir 306cdf0e10cSrcweir // Text der ersten Seite loeschen 307cdf0e10cSrcweir if ( !pSh->SttNxtPg(sal_True) ) 308cdf0e10cSrcweir pSh->EndPg(sal_True); 309cdf0e10cSrcweir pSh->DelRight(); 310cdf0e10cSrcweir // Rahmen der ersten Seite loeschen 311cdf0e10cSrcweir if( pSh->GotoFly( rSendMark ) ) 312cdf0e10cSrcweir { 313cdf0e10cSrcweir pSh->EnterSelFrmMode(); 314cdf0e10cSrcweir pSh->DelRight(); 315cdf0e10cSrcweir } 316cdf0e10cSrcweir if ( pSh->GotoFly( rAddrMark ) ) 317cdf0e10cSrcweir { 318cdf0e10cSrcweir pSh->EnterSelFrmMode(); 319cdf0e10cSrcweir pSh->DelRight(); 320cdf0e10cSrcweir } 321cdf0e10cSrcweir pSh->SttEndDoc(sal_True); 322cdf0e10cSrcweir } 323cdf0e10cSrcweir else 324cdf0e10cSrcweir // Folgevorlage: Seite 1 325cdf0e10cSrcweir pFollow = &pSh->GetPageDesc(pSh->GetCurPageDesc()); 326cdf0e10cSrcweir 327cdf0e10cSrcweir // Seitenumbruch einfuegen 328cdf0e10cSrcweir if ( pSh->IsCrsrInTbl() ) 329cdf0e10cSrcweir { 330cdf0e10cSrcweir pSh->SplitNode(); 331cdf0e10cSrcweir pSh->Right( CRSR_SKIP_CHARS, sal_False, 1, sal_False ); 332cdf0e10cSrcweir SfxItemSet aBreakSet( pSh->GetAttrPool(), RES_BREAK, RES_BREAK, 0 ); 333cdf0e10cSrcweir aBreakSet.Put( SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE, RES_BREAK) ); 334cdf0e10cSrcweir pSh->SetTblAttr( aBreakSet ); 335cdf0e10cSrcweir } 336cdf0e10cSrcweir else 337cdf0e10cSrcweir pSh->InsertPageBreak(0, sal_False); 338cdf0e10cSrcweir pSh->SttEndDoc(sal_True); 339cdf0e10cSrcweir } 340cdf0e10cSrcweir else 341cdf0e10cSrcweir { 342cdf0e10cSrcweir pFollow = &pSh->GetPageDesc(pSh->GetCurPageDesc()); 343cdf0e10cSrcweir // Los geht's (Drucken) 344cdf0e10cSrcweir pSh->StartAllAction(); 345cdf0e10cSrcweir pSh->DoUndo(sal_False); 346cdf0e10cSrcweir 347cdf0e10cSrcweir // Neue Collections "Absender" und "Empfaenger" wieder in neues 348cdf0e10cSrcweir // Dokument kopieren 349cdf0e10cSrcweir if ( pOldSh ) 350cdf0e10cSrcweir { 351cdf0e10cSrcweir ::lcl_CopyCollAttr(pOldSh, pSh, RES_POOLCOLL_JAKETADRESS); 352cdf0e10cSrcweir ::lcl_CopyCollAttr(pOldSh, pSh, RES_POOLCOLL_SENDADRESS); 353cdf0e10cSrcweir } 354cdf0e10cSrcweir } 355cdf0e10cSrcweir 356cdf0e10cSrcweir SET_CURR_SHELL(pSh); 357cdf0e10cSrcweir pSh->SetNewDoc(); // Performanceprobleme vermeiden 358cdf0e10cSrcweir 359cdf0e10cSrcweir // Flys dieser Seite merken 360cdf0e10cSrcweir SvPtrarr aFlyArr(0, 5); 361cdf0e10cSrcweir if( ENV_NEWDOC != nMode && !bEnvChange ) 362cdf0e10cSrcweir pSh->GetPageObjs( aFlyArr ); 363cdf0e10cSrcweir 364cdf0e10cSrcweir // Page-Desc ermitteln 365cdf0e10cSrcweir SwPageDesc* pDesc = pSh->GetPageDescFromPool(RES_POOLPAGE_JAKET); 366cdf0e10cSrcweir SwFrmFmt& rFmt = pDesc->GetMaster(); 367cdf0e10cSrcweir 368cdf0e10cSrcweir Printer *pPrt = pSh->getIDocumentDeviceAccess()->getPrinter( true ); 369cdf0e10cSrcweir 370cdf0e10cSrcweir // Raender (setzen sich zusammen aus Shift-Offset und 371cdf0e10cSrcweir // Ausrichtung) 372cdf0e10cSrcweir Size aPaperSize = pPrt->PixelToLogic( pPrt->GetPaperSizePixel(), 373cdf0e10cSrcweir MAP_TWIP); 374cdf0e10cSrcweir if ( !aPaperSize.Width() && !aPaperSize.Height() ) 375cdf0e10cSrcweir aPaperSize = SvxPaperInfo::GetPaperSize(PAPER_A4); 376cdf0e10cSrcweir if ( aPaperSize.Width() > aPaperSize.Height() ) 377cdf0e10cSrcweir Swap( aPaperSize ); 378cdf0e10cSrcweir 379cdf0e10cSrcweir long lLeft = rItem.lShiftRight, 380cdf0e10cSrcweir lUpper = rItem.lShiftDown; 381cdf0e10cSrcweir 382cdf0e10cSrcweir sal_uInt16 nPageW = (sal_uInt16) Max(rItem.lWidth, rItem.lHeight), 383cdf0e10cSrcweir nPageH = (sal_uInt16) Min(rItem.lWidth, rItem.lHeight); 384cdf0e10cSrcweir 385cdf0e10cSrcweir switch (rItem.eAlign) 386cdf0e10cSrcweir { 387cdf0e10cSrcweir case ENV_HOR_LEFT: break; 388cdf0e10cSrcweir case ENV_HOR_CNTR: lLeft += Max(0L, long(aPaperSize.Width() - nPageW)) / 2; 389cdf0e10cSrcweir break; 390cdf0e10cSrcweir case ENV_HOR_RGHT: lLeft += Max(0L, long(aPaperSize.Width() - nPageW)); 391cdf0e10cSrcweir break; 392cdf0e10cSrcweir case ENV_VER_LEFT: lUpper += Max(0L, long(aPaperSize.Width() - nPageH)); 393cdf0e10cSrcweir break; 394cdf0e10cSrcweir case ENV_VER_CNTR: lUpper += Max(0L, long(aPaperSize.Width() - nPageH)) / 2; 395cdf0e10cSrcweir break; 396cdf0e10cSrcweir case ENV_VER_RGHT: break; 397cdf0e10cSrcweir } 398cdf0e10cSrcweir SvxLRSpaceItem aLRMargin( RES_LR_SPACE ); 399cdf0e10cSrcweir SvxULSpaceItem aULMargin( RES_UL_SPACE ); 400cdf0e10cSrcweir aLRMargin.SetLeft ((sal_uInt16) lLeft ); 401cdf0e10cSrcweir aULMargin.SetUpper((sal_uInt16) lUpper); 402cdf0e10cSrcweir aLRMargin.SetRight(0); 403cdf0e10cSrcweir aULMargin.SetLower(0); 404cdf0e10cSrcweir rFmt.SetFmtAttr(aLRMargin); 405cdf0e10cSrcweir rFmt.SetFmtAttr(aULMargin); 406cdf0e10cSrcweir 407cdf0e10cSrcweir // Kopf-, Fusszeilen 408cdf0e10cSrcweir rFmt.SetFmtAttr(SwFmtHeader(sal_Bool(sal_False))); 409cdf0e10cSrcweir pDesc->ChgHeaderShare(sal_False); 410cdf0e10cSrcweir rFmt.SetFmtAttr(SwFmtFooter(sal_Bool(sal_False))); 411cdf0e10cSrcweir pDesc->ChgFooterShare(sal_False); 412cdf0e10cSrcweir 413cdf0e10cSrcweir // Seitennumerierung 414cdf0e10cSrcweir pDesc->SetUseOn(nsUseOnPage::PD_ALL); 415cdf0e10cSrcweir 416cdf0e10cSrcweir // Einstellen der Seitengroesse 417cdf0e10cSrcweir rFmt.SetFmtAttr(SwFmtFrmSize(ATT_FIX_SIZE, 418cdf0e10cSrcweir nPageW + lLeft, nPageH + lUpper)); 419cdf0e10cSrcweir 420cdf0e10cSrcweir // Einstellen der Numerierungsart der Seite 421cdf0e10cSrcweir SvxNumberType aType; 422cdf0e10cSrcweir aType.SetNumberingType(SVX_NUM_NUMBER_NONE); 423cdf0e10cSrcweir pDesc->SetNumType(aType); 424cdf0e10cSrcweir 425cdf0e10cSrcweir // Folgevorlage 426cdf0e10cSrcweir if (pFollow) 427cdf0e10cSrcweir pDesc->SetFollow(pFollow); 428cdf0e10cSrcweir 429cdf0e10cSrcweir // Landscape 430cdf0e10cSrcweir pDesc->SetLandscape( rItem.eAlign >= ENV_VER_LEFT && 431cdf0e10cSrcweir rItem.eAlign <= ENV_VER_RGHT); 432cdf0e10cSrcweir 433cdf0e10cSrcweir // Page-Desc anwenden 434cdf0e10cSrcweir 435cdf0e10cSrcweir sal_uInt16 nPos; 436cdf0e10cSrcweir pSh->FindPageDescByName( pDesc->GetName(), 437cdf0e10cSrcweir sal_False, 438cdf0e10cSrcweir &nPos ); 439cdf0e10cSrcweir 440cdf0e10cSrcweir 441cdf0e10cSrcweir pSh->ChgPageDesc( nPos, *pDesc); 442cdf0e10cSrcweir pSh->ChgCurPageDesc(*pDesc); 443cdf0e10cSrcweir 444cdf0e10cSrcweir // Rahmen einfuegen 445cdf0e10cSrcweir SwFlyFrmAttrMgr aMgr(sal_False, pSh, FRMMGR_TYPE_ENVELP); 446cdf0e10cSrcweir SwFldMgr aFldMgr; 447cdf0e10cSrcweir aMgr.SetHeightSizeType(ATT_VAR_SIZE); 448cdf0e10cSrcweir 449cdf0e10cSrcweir //Defaults ueberschreiben! 450cdf0e10cSrcweir aMgr.GetAttrSet().Put( SvxBoxItem(RES_BOX) ); 451cdf0e10cSrcweir aMgr.SetULSpace( 0L, 0L ); 452cdf0e10cSrcweir aMgr.SetLRSpace( 0L, 0L ); 453cdf0e10cSrcweir 454cdf0e10cSrcweir // Absender 455cdf0e10cSrcweir if (rItem.bSend) 456cdf0e10cSrcweir { 457cdf0e10cSrcweir pSh->SttEndDoc(sal_True); 458cdf0e10cSrcweir aMgr.InsertFlyFrm(FLY_AT_PAGE, 459cdf0e10cSrcweir Point(rItem.lSendFromLeft + lLeft, rItem.lSendFromTop + lUpper), 460cdf0e10cSrcweir Size (rItem.lAddrFromLeft - rItem.lSendFromLeft, 0)); 461cdf0e10cSrcweir 462cdf0e10cSrcweir pSh->EnterSelFrmMode(); 463cdf0e10cSrcweir pSh->SetFlyName( rSendMark ); 464cdf0e10cSrcweir pSh->UnSelectFrm(); 465cdf0e10cSrcweir pSh->LeaveSelFrmMode(); 466cdf0e10cSrcweir pSh->SetTxtFmtColl( pSend ); 467cdf0e10cSrcweir InsertLabEnvText( *pSh, aFldMgr, rItem.aSendText ); 468cdf0e10cSrcweir aMgr.UpdateAttrMgr(); 469cdf0e10cSrcweir } 470cdf0e10cSrcweir 471cdf0e10cSrcweir // Empfaenger 472cdf0e10cSrcweir pSh->SttEndDoc(sal_True); 473cdf0e10cSrcweir 474cdf0e10cSrcweir aMgr.InsertFlyFrm(FLY_AT_PAGE, 475cdf0e10cSrcweir Point(rItem.lAddrFromLeft + lLeft, rItem.lAddrFromTop + lUpper), 476cdf0e10cSrcweir Size (nPageW - rItem.lAddrFromLeft - 566, 0)); 477cdf0e10cSrcweir pSh->EnterSelFrmMode(); 478cdf0e10cSrcweir pSh->SetFlyName( rAddrMark ); 479cdf0e10cSrcweir pSh->UnSelectFrm(); 480cdf0e10cSrcweir pSh->LeaveSelFrmMode(); 481cdf0e10cSrcweir pSh->SetTxtFmtColl( pAddr ); 482cdf0e10cSrcweir InsertLabEnvText(*pSh, aFldMgr, rItem.aAddrText); 483cdf0e10cSrcweir 484cdf0e10cSrcweir // Flys auf die "alten" Seiten verschieben 485cdf0e10cSrcweir if (aFlyArr.Count()) 486cdf0e10cSrcweir pSh->SetPageObjsNewPage(aFlyArr, 1); 487cdf0e10cSrcweir 488cdf0e10cSrcweir // Fertig 489cdf0e10cSrcweir pSh->SttEndDoc(sal_True); 490cdf0e10cSrcweir 491cdf0e10cSrcweir pSh->EndAllAction(); 492cdf0e10cSrcweir 493cdf0e10cSrcweir if (nMode == ENV_NEWDOC) 494cdf0e10cSrcweir pSh->DoUndo(sal_True); 495cdf0e10cSrcweir else 496cdf0e10cSrcweir pSh->EndUndo(UNDO_UI_INSERT_ENVELOPE); 497cdf0e10cSrcweir 498cdf0e10cSrcweir if (nMode == ENV_NEWDOC) 499cdf0e10cSrcweir { 500cdf0e10cSrcweir pFrame->GetFrame().Appear(); 501cdf0e10cSrcweir 502cdf0e10cSrcweir if ( rItem.aAddrText.indexOf('<') >= 0 ) 503cdf0e10cSrcweir { 504cdf0e10cSrcweir static sal_uInt16 __READONLY_DATA aInva[] = 505cdf0e10cSrcweir { 506cdf0e10cSrcweir SID_SBA_BRW_UPDATE, 507cdf0e10cSrcweir SID_SBA_BRW_INSERT, 508cdf0e10cSrcweir SID_SBA_BRW_MERGE, 509cdf0e10cSrcweir 0 510cdf0e10cSrcweir }; 511cdf0e10cSrcweir pFrame->GetBindings().Invalidate( aInva ); 512cdf0e10cSrcweir 513cdf0e10cSrcweir // Datenbankbeamer oeffnen 514cdf0e10cSrcweir ShowDBObj(*pNewView, pSh->GetDBData()); 515cdf0e10cSrcweir } 516cdf0e10cSrcweir } 517cdf0e10cSrcweir 518cdf0e10cSrcweir if ( !pItem ) 519cdf0e10cSrcweir { 520cdf0e10cSrcweir rReq.AppendItem( rItem ); 521cdf0e10cSrcweir if ( nMode == ENV_NEWDOC ) 522cdf0e10cSrcweir rReq.AppendItem( SfxBoolItem( FN_PARAM_1, sal_True ) ); 523cdf0e10cSrcweir } 524cdf0e10cSrcweir 525cdf0e10cSrcweir rReq.Done(); 526cdf0e10cSrcweir } 527cdf0e10cSrcweir else //Abbruch 528cdf0e10cSrcweir { 529cdf0e10cSrcweir rReq.Ignore(); 530cdf0e10cSrcweir 531cdf0e10cSrcweir xDocSh->DoClose(); 532cdf0e10cSrcweir --nTitleNo; 533cdf0e10cSrcweir 534cdf0e10cSrcweir // Pointer auf oberste View restaurieren 535cdf0e10cSrcweir if (pOldSh) 536cdf0e10cSrcweir SetView(&pOldSh->GetView()); 537cdf0e10cSrcweir } 538cdf0e10cSrcweir delete pDlg; 539cdf0e10cSrcweir } 540cdf0e10cSrcweir 541cdf0e10cSrcweir 542