Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <cstdarg>
31 : :
32 : : #include <hintids.hxx>
33 : :
34 : : #include <comphelper/string.hxx>
35 : : #include <sfx2/request.hxx>
36 : : #include <svx/svxids.hrc>
37 : :
38 : : #include <svtools/svmedit.hxx>
39 : : #include <vcl/svapp.hxx>
40 : : #include <vcl/wrkwin.hxx>
41 : : #include <sfx2/app.hxx>
42 : : #include <sfx2/docfac.hxx>
43 : : #include <sfx2/printer.hxx>
44 : : #include <vcl/msgbox.hxx>
45 : : #include <sfx2/dispatch.hxx>
46 : : #include <editeng/boxitem.hxx>
47 : : #include <editeng/lrspitem.hxx>
48 : : #include <editeng/ulspitem.hxx>
49 : : #include <editeng/pbinitem.hxx>
50 : : #include <editeng/paperinf.hxx>
51 : : #include <editeng/brkitem.hxx>
52 : : #include <fmthdft.hxx>
53 : : #include <swwait.hxx>
54 : : #include <paratr.hxx>
55 : : #include <swmodule.hxx>
56 : : #include <wrtsh.hxx>
57 : : #include <view.hxx>
58 : : #include <docsh.hxx>
59 : : #include <frmatr.hxx>
60 : : #include <fldbas.hxx>
61 : : #include <swundo.hxx>
62 : : #include <IDocumentDeviceAccess.hxx>
63 : : #include <dbmgr.hxx>
64 : : #include <fmtcol.hxx>
65 : : #include <frmmgr.hxx>
66 : : #include <fldmgr.hxx>
67 : : #include <pagedesc.hxx>
68 : : #include <poolfmt.hxx>
69 : : #include <expfld.hxx>
70 : : #include <SwStyleNameMapper.hxx>
71 : : #include <crsskip.hxx>
72 : :
73 : : #include <cmdid.h>
74 : : #include <globals.hrc>
75 : : #include <app.hrc>
76 : : #include <poolfmt.hrc>
77 : : #include "swabstdlg.hxx"
78 : : #include "envelp.hrc"
79 : : #include "envimg.hxx"
80 : :
81 : : #define ENV_NEWDOC RET_OK
82 : : #define ENV_INSERT RET_USER
83 : :
84 : : // Function used for labels and envelopes in applab.cxx and appenv.cxx
85 : 0 : String InsertLabEnvText( SwWrtShell& rSh, SwFldMgr& rFldMgr, const String& rText )
86 : : {
87 [ # # ]: 0 : String sRet;
88 [ # # ][ # # ]: 0 : String aText(comphelper::string::remove(rText, '\r'));
89 : :
90 : 0 : sal_uInt16 nTokenPos = 0;
91 [ # # ]: 0 : while( STRING_NOTFOUND != nTokenPos )
92 : : {
93 [ # # ]: 0 : String aLine = aText.GetToken( 0, '\n', nTokenPos );
94 [ # # ]: 0 : while ( aLine.Len() )
95 : : {
96 [ # # ]: 0 : String sTmpText;
97 : 0 : sal_Bool bField = sal_False;
98 : :
99 [ # # ]: 0 : sal_uInt16 nPos = aLine.Search( '<' );
100 [ # # ]: 0 : if ( nPos )
101 : : {
102 [ # # ][ # # ]: 0 : sTmpText = aLine.Copy( 0, nPos );
[ # # ]
103 [ # # ]: 0 : aLine.Erase( 0, nPos );
104 : : }
105 : : else
106 : : {
107 [ # # ]: 0 : nPos = aLine.Search( '>' );
108 [ # # ]: 0 : if ( nPos == STRING_NOTFOUND )
109 : : {
110 [ # # ]: 0 : sTmpText = aLine;
111 [ # # ]: 0 : aLine.Erase();
112 : : }
113 : : else
114 : : {
115 [ # # ][ # # ]: 0 : sTmpText = aLine.Copy( 0, nPos + 1);
[ # # ]
116 [ # # ]: 0 : aLine.Erase( 0, nPos + 1);
117 : :
118 : : // Database fields must contain at least 3 points!
119 [ # # ]: 0 : String sDBName( sTmpText.Copy( 1, sTmpText.Len() - 2));
120 [ # # ][ # # ]: 0 : sal_uInt16 nCnt = comphelper::string::getTokenCount(sDBName, '.');
121 [ # # ]: 0 : if (nCnt >= 3)
122 : : {
123 [ # # ]: 0 : ::ReplacePoint(sDBName, sal_True);
124 [ # # ]: 0 : SwInsertFld_Data aData(TYP_DBFLD, 0, sDBName, aEmptyStr, 0, &rSh );
125 [ # # ]: 0 : rFldMgr.InsertFld( aData );
126 [ # # ]: 0 : sRet = sDBName;
127 [ # # ]: 0 : bField = sal_True;
128 [ # # ]: 0 : }
129 : : }
130 : : }
131 [ # # ]: 0 : if ( !bField )
132 [ # # ]: 0 : rSh.Insert( sTmpText );
133 [ # # ]: 0 : }
134 [ # # ]: 0 : rSh.InsertLineBreak();
135 [ # # ]: 0 : }
136 [ # # ]: 0 : rSh.DelLeft(); // Again remove last linebreak
137 : :
138 [ # # ]: 0 : return sRet;
139 : : }
140 : :
141 : 0 : void lcl_CopyCollAttr(SwWrtShell* pOldSh, SwWrtShell* pNewSh, sal_uInt16 nCollId)
142 : : {
143 : 0 : sal_uInt16 nCollCnt = pOldSh->GetTxtFmtCollCount();
144 : : SwTxtFmtColl* pColl;
145 [ # # ]: 0 : for( sal_uInt16 nCnt = 0; nCnt < nCollCnt; ++nCnt )
146 [ # # ]: 0 : if(nCollId == (pColl = &pOldSh->GetTxtFmtColl(nCnt))->GetPoolFmtId())
147 : 0 : pNewSh->GetTxtCollFromPool(nCollId)->SetFmtAttr(pColl->GetAttrSet());
148 : 0 : }
149 : :
150 : 0 : void SwModule::InsertEnv( SfxRequest& rReq )
151 : : {
152 : : static sal_uInt16 nTitleNo = 0;
153 : :
154 : : SwDocShell *pMyDocSh;
155 : : SfxViewFrame *pFrame;
156 : : SwView *pNewView;
157 : : SwWrtShell *pOldSh,
158 : : *pSh;
159 : :
160 : : // Get current shell
161 [ # # ]: 0 : pMyDocSh = (SwDocShell*) SfxObjectShell::Current();
162 [ # # ]: 0 : pOldSh = pMyDocSh ? pMyDocSh->GetWrtShell() : 0;
163 : :
164 : : // Create new document (don't show!)
165 [ # # ][ # # ]: 0 : SfxObjectShellLock xDocSh( new SwDocShell( SFX_CREATE_MODE_STANDARD ) );
[ # # ]
166 [ # # ]: 0 : xDocSh->DoInitNew( 0 );
167 [ # # ]: 0 : pFrame = SfxViewFrame::LoadHiddenDocument( *xDocSh, 0 );
168 [ # # ]: 0 : pNewView = (SwView*) pFrame->GetViewShell();
169 [ # # ]: 0 : pNewView->AttrChangedNotify( &pNewView->GetWrtShell() ); // so that SelectShell is being called
170 : 0 : pSh = pNewView->GetWrtShellPtr();
171 : :
172 [ # # ]: 0 : String aTmp( SW_RES(STR_ENV_TITLE) );
173 [ # # ][ # # ]: 0 : aTmp += String::CreateFromInt32( ++nTitleNo );
[ # # ]
174 [ # # ]: 0 : xDocSh->SetTitle( aTmp );
175 : :
176 : : // if applicable, copy the old Collections "Sender" and "Reciever" to
177 : : // a new document
178 [ # # ]: 0 : if ( pOldSh )
179 : : {
180 [ # # ]: 0 : ::lcl_CopyCollAttr(pOldSh, pSh, RES_POOLCOLL_JAKETADRESS);
181 [ # # ]: 0 : ::lcl_CopyCollAttr(pOldSh, pSh, RES_POOLCOLL_SENDADRESS);
182 : : }
183 : :
184 : : // Read SwEnvItem from config
185 [ # # ]: 0 : SwEnvCfgItem aEnvCfg;
186 : :
187 : : // Check if there's already an envelope.
188 : 0 : sal_Bool bEnvChange = sal_False;
189 : :
190 [ # # ]: 0 : SfxItemSet aSet(GetPool(), FN_ENVELOP, FN_ENVELOP, 0);
191 [ # # ]: 0 : aSet.Put(aEnvCfg.GetItem());
192 : :
193 [ # # ][ # # ]: 0 : SfxPrinter* pTempPrinter = pSh->getIDocumentDeviceAccess()->getPrinter( true );
194 [ # # ]: 0 : if(pOldSh )
195 : : {
196 [ # # ][ # # ]: 0 : const SwPageDesc& rCurPageDesc = pOldSh->GetPageDesc(pOldSh->GetCurPageDesc());
197 [ # # ]: 0 : String sJacket;
198 [ # # ]: 0 : SwStyleNameMapper::FillUIName( RES_POOLPAGE_JAKET, sJacket );
199 [ # # ]: 0 : bEnvChange = rCurPageDesc.GetName() == sJacket;
200 : :
201 [ # # ]: 0 : IDocumentDeviceAccess* pIDDA_old = pOldSh->getIDocumentDeviceAccess();
202 [ # # ][ # # ]: 0 : if( pIDDA_old->getPrinter( false ) )
203 : : {
204 [ # # ]: 0 : IDocumentDeviceAccess* pIDDA = pSh->getIDocumentDeviceAccess();
205 [ # # ][ # # ]: 0 : pIDDA->setJobsetup( *pIDDA_old->getJobsetup() );
206 : : //#69563# if it isn't the same printer then the pointer has been invalidated!
207 [ # # ]: 0 : pTempPrinter = pIDDA->getPrinter( true );
208 : : }
209 [ # # ][ # # ]: 0 : pTempPrinter->SetPaperBin(rCurPageDesc.GetMaster().GetPaperBin().GetValue());
[ # # ]
210 : :
211 : : }
212 : :
213 [ # # ]: 0 : Window *pParent = pOldSh ? pOldSh->GetWin() : 0;
214 : 0 : SfxAbstractTabDialog * pDlg=NULL;
215 : 0 : short nMode = ENV_INSERT;
216 : :
217 [ # # ][ # # ]: 0 : SFX_REQUEST_ARG( rReq, pItem, SwEnvItem, FN_ENVELOP, sal_False );
218 [ # # ]: 0 : if ( !pItem )
219 : : {
220 [ # # ]: 0 : SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
221 : : OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
222 : :
223 [ # # ]: 0 : pDlg = pFact->CreateSwEnvDlg( pParent, aSet, pOldSh, pTempPrinter, !bEnvChange, DLG_ENV );
224 : : OSL_ENSURE(pDlg, "Dialogdiet fail!");
225 [ # # ]: 0 : nMode = pDlg->Execute();
226 : : }
227 : : else
228 : : {
229 [ # # ][ # # ]: 0 : SFX_REQUEST_ARG( rReq, pBoolItem, SfxBoolItem, FN_PARAM_1, sal_False );
230 [ # # ][ # # ]: 0 : if ( pBoolItem && pBoolItem->GetValue() )
[ # # ]
231 : 0 : nMode = ENV_NEWDOC;
232 : : }
233 : :
234 [ # # ][ # # ]: 0 : if (nMode == ENV_NEWDOC || nMode == ENV_INSERT)
235 : : {
236 [ # # ]: 0 : SwWait aWait( (SwDocShell&)*xDocSh, sal_True );
237 : :
238 : : // Read dialog and save item to config
239 [ # # ][ # # ]: 0 : const SwEnvItem& rItem = pItem ? *pItem : (const SwEnvItem&) pDlg->GetOutputItemSet()->Get(FN_ENVELOP);
[ # # ]
240 [ # # ]: 0 : aEnvCfg.GetItem() = rItem;
241 [ # # ]: 0 : aEnvCfg.Commit();
242 : :
243 : : // When we print we take the Jobsetup that is set up in the dialog.
244 : : // Information has to be set here, before a possible destruction of
245 : : // the new shell because the shell's printer has been handed to the
246 : : // dialog.
247 [ # # ]: 0 : if ( nMode != ENV_NEWDOC )
248 : : {
249 : : OSL_ENSURE(pOldSh, "No document - wasn't 'Insert' disabled???");
250 [ # # ]: 0 : SvxPaperBinItem aItem( RES_PAPER_BIN );
251 [ # # ][ # # ]: 0 : aItem.SetValue((sal_uInt8)pSh->getIDocumentDeviceAccess()->getPrinter(true)->GetPaperBin());
[ # # ]
252 [ # # ][ # # ]: 0 : pOldSh->GetPageDescFromPool(RES_POOLPAGE_JAKET)->GetMaster().SetFmtAttr(aItem);
[ # # ]
253 : : }
254 : :
255 [ # # ]: 0 : SwWrtShell *pTmp = nMode == ENV_INSERT ? pOldSh : pSh;
256 : 0 : const SwPageDesc* pFollow = 0;
257 [ # # ]: 0 : SwTxtFmtColl *pSend = pTmp->GetTxtCollFromPool( RES_POOLCOLL_SENDADRESS ),
258 [ # # ]: 0 : *pAddr = pTmp->GetTxtCollFromPool( RES_POOLCOLL_JAKETADRESS);
259 : 0 : const String &rSendMark = pSend->GetName();
260 : 0 : const String &rAddrMark = pAddr->GetName();
261 : :
262 [ # # ]: 0 : if (nMode == ENV_INSERT)
263 : : {
264 : :
265 : 0 : SetView(&pOldSh->GetView()); // Set pointer to top view
266 : :
267 : : // Delete new document
268 [ # # ]: 0 : xDocSh->DoClose();
269 : 0 : pSh = pOldSh;
270 : : //#i4251# selected text or objects in the document should
271 : : //not be deleted on inserting envelopes
272 [ # # ]: 0 : pSh->EnterStdMode();
273 : : // Here it goes (insert)
274 [ # # ]: 0 : pSh->StartUndo(UNDO_UI_INSERT_ENVELOPE, NULL);
275 [ # # ]: 0 : pSh->StartAllAction();
276 [ # # ]: 0 : pSh->SttEndDoc(sal_True);
277 : :
278 [ # # ]: 0 : if (bEnvChange)
279 : : {
280 : : // followup template: page 2
281 [ # # ][ # # ]: 0 : pFollow = pSh->GetPageDesc(pSh->GetCurPageDesc()).GetFollow();
282 : :
283 : : // Delete text from the first page
284 [ # # ][ # # ]: 0 : if ( !pSh->SttNxtPg(sal_True) )
285 [ # # ]: 0 : pSh->EndPg(sal_True);
286 [ # # ]: 0 : pSh->DelRight();
287 : : // Delete frame of the first page
288 [ # # ][ # # ]: 0 : if( pSh->GotoFly( rSendMark ) )
289 : : {
290 [ # # ]: 0 : pSh->EnterSelFrmMode();
291 [ # # ]: 0 : pSh->DelRight();
292 : : }
293 [ # # ][ # # ]: 0 : if ( pSh->GotoFly( rAddrMark ) )
294 : : {
295 [ # # ]: 0 : pSh->EnterSelFrmMode();
296 [ # # ]: 0 : pSh->DelRight();
297 : : }
298 [ # # ]: 0 : pSh->SttEndDoc(sal_True);
299 : : }
300 : : else
301 : : // Followup template: page 1
302 [ # # ][ # # ]: 0 : pFollow = &pSh->GetPageDesc(pSh->GetCurPageDesc());
303 : :
304 : : // Insert page break
305 [ # # ][ # # ]: 0 : if ( pSh->IsCrsrInTbl() )
306 : : {
307 [ # # ]: 0 : pSh->SplitNode();
308 [ # # ]: 0 : pSh->Right( CRSR_SKIP_CHARS, sal_False, 1, sal_False );
309 [ # # ][ # # ]: 0 : SfxItemSet aBreakSet( pSh->GetAttrPool(), RES_BREAK, RES_BREAK, 0 );
310 [ # # ][ # # ]: 0 : aBreakSet.Put( SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE, RES_BREAK) );
[ # # ]
311 [ # # ][ # # ]: 0 : pSh->SetTblAttr( aBreakSet );
312 : : }
313 : : else
314 [ # # ]: 0 : pSh->InsertPageBreak(0, sal_False);
315 [ # # ]: 0 : pSh->SttEndDoc(sal_True);
316 : : }
317 : : else
318 : : {
319 [ # # ][ # # ]: 0 : pFollow = &pSh->GetPageDesc(pSh->GetCurPageDesc());
320 : : // Let's go (print)
321 [ # # ]: 0 : pSh->StartAllAction();
322 [ # # ]: 0 : pSh->DoUndo(sal_False);
323 : :
324 : : // Again, copy the new collections "Sender" and "Reciever" to
325 : : // a new document
326 [ # # ]: 0 : if ( pOldSh )
327 : : {
328 [ # # ]: 0 : ::lcl_CopyCollAttr(pOldSh, pSh, RES_POOLCOLL_JAKETADRESS);
329 [ # # ]: 0 : ::lcl_CopyCollAttr(pOldSh, pSh, RES_POOLCOLL_SENDADRESS);
330 : : }
331 : : }
332 : :
333 [ # # ]: 0 : SET_CURR_SHELL(pSh);
334 [ # # ]: 0 : pSh->SetNewDoc(); // Avoid performance problems
335 : :
336 : : // Remember Flys of this site
337 [ # # ]: 0 : std::vector<SwFrmFmt*> aFlyArr;
338 [ # # ][ # # ]: 0 : if( ENV_NEWDOC != nMode && !bEnvChange )
339 [ # # ]: 0 : pSh->GetPageObjs( aFlyArr );
340 : :
341 : : // Get page description
342 [ # # ]: 0 : SwPageDesc* pDesc = pSh->GetPageDescFromPool(RES_POOLPAGE_JAKET);
343 : 0 : SwFrmFmt& rFmt = pDesc->GetMaster();
344 : :
345 [ # # ][ # # ]: 0 : Printer *pPrt = pSh->getIDocumentDeviceAccess()->getPrinter( true );
346 : :
347 : : // Borders (are put together by Shift-Offset and alignment)
348 : 0 : Size aPaperSize = pPrt->PixelToLogic( pPrt->GetPaperSizePixel(),
349 [ # # # # ]: 0 : MAP_TWIP);
[ # # ]
350 [ # # ][ # # ]: 0 : if ( !aPaperSize.Width() && !aPaperSize.Height() )
[ # # ]
351 [ # # ]: 0 : aPaperSize = SvxPaperInfo::GetPaperSize(PAPER_A4);
352 [ # # ]: 0 : if ( aPaperSize.Width() > aPaperSize.Height() )
353 : 0 : Swap( aPaperSize );
354 : :
355 : 0 : long lLeft = rItem.lShiftRight,
356 : 0 : lUpper = rItem.lShiftDown;
357 : :
358 : 0 : sal_uInt16 nPageW = (sal_uInt16) Max(rItem.lWidth, rItem.lHeight),
359 : 0 : nPageH = (sal_uInt16) Min(rItem.lWidth, rItem.lHeight);
360 : :
361 [ # # # # : 0 : switch (rItem.eAlign)
# # # ]
362 : : {
363 : 0 : case ENV_HOR_LEFT: break;
364 : 0 : case ENV_HOR_CNTR: lLeft += Max(0L, long(aPaperSize.Width() - nPageW)) / 2;
365 : 0 : break;
366 : 0 : case ENV_HOR_RGHT: lLeft += Max(0L, long(aPaperSize.Width() - nPageW));
367 : 0 : break;
368 : 0 : case ENV_VER_LEFT: lUpper += Max(0L, long(aPaperSize.Width() - nPageH));
369 : 0 : break;
370 : 0 : case ENV_VER_CNTR: lUpper += Max(0L, long(aPaperSize.Width() - nPageH)) / 2;
371 : 0 : break;
372 : 0 : case ENV_VER_RGHT: break;
373 : : }
374 [ # # ]: 0 : SvxLRSpaceItem aLRMargin( RES_LR_SPACE );
375 [ # # ]: 0 : SvxULSpaceItem aULMargin( RES_UL_SPACE );
376 : 0 : aLRMargin.SetLeft ((sal_uInt16) lLeft );
377 : 0 : aULMargin.SetUpper((sal_uInt16) lUpper);
378 : 0 : aLRMargin.SetRight(0);
379 : 0 : aULMargin.SetLower(0);
380 [ # # ]: 0 : rFmt.SetFmtAttr(aLRMargin);
381 [ # # ]: 0 : rFmt.SetFmtAttr(aULMargin);
382 : :
383 : : // Header and footer
384 [ # # ][ # # ]: 0 : rFmt.SetFmtAttr(SwFmtHeader(sal_Bool(sal_False)));
[ # # ]
385 : 0 : pDesc->ChgHeaderShare(sal_False);
386 [ # # ][ # # ]: 0 : rFmt.SetFmtAttr(SwFmtFooter(sal_Bool(sal_False)));
[ # # ]
387 : 0 : pDesc->ChgFooterShare(sal_False);
388 : :
389 : : // Page numbering
390 : 0 : pDesc->SetUseOn(nsUseOnPage::PD_ALL);
391 : :
392 : : // Page size
393 : : rFmt.SetFmtAttr(SwFmtFrmSize(ATT_FIX_SIZE,
394 [ # # ][ # # ]: 0 : nPageW + lLeft, nPageH + lUpper));
[ # # ]
395 : :
396 : : // Set type of page numbering
397 [ # # ]: 0 : SvxNumberType aType;
398 : 0 : aType.SetNumberingType(SVX_NUM_NUMBER_NONE);
399 : 0 : pDesc->SetNumType(aType);
400 : :
401 : : // Followup template
402 [ # # ]: 0 : if (pFollow)
403 : 0 : pDesc->SetFollow(pFollow);
404 : :
405 : : // Landscape
406 : : pDesc->SetLandscape( rItem.eAlign >= ENV_VER_LEFT &&
407 [ # # ][ # # ]: 0 : rItem.eAlign <= ENV_VER_RGHT);
408 : :
409 : : // Apply page description
410 : :
411 : : sal_uInt16 nPos;
412 : 0 : pSh->FindPageDescByName( pDesc->GetName(),
413 : : sal_False,
414 [ # # ]: 0 : &nPos );
415 : :
416 : :
417 [ # # ]: 0 : pSh->ChgPageDesc( nPos, *pDesc);
418 [ # # ]: 0 : pSh->ChgCurPageDesc(*pDesc);
419 : :
420 : : // Insert Frame
421 [ # # ]: 0 : SwFlyFrmAttrMgr aMgr(sal_False, pSh, FRMMGR_TYPE_ENVELP);
422 [ # # ]: 0 : SwFldMgr aFldMgr;
423 [ # # ]: 0 : aMgr.SetHeightSizeType(ATT_VAR_SIZE);
424 : :
425 : : // Overwrite defaults!
426 [ # # ][ # # ]: 0 : aMgr.GetAttrSet().Put( SvxBoxItem(RES_BOX) );
[ # # ]
427 [ # # ]: 0 : aMgr.SetULSpace( 0L, 0L );
428 [ # # ]: 0 : aMgr.SetLRSpace( 0L, 0L );
429 : :
430 : : // Sender
431 [ # # ]: 0 : if (rItem.bSend)
432 : : {
433 [ # # ]: 0 : pSh->SttEndDoc(sal_True);
434 : : aMgr.InsertFlyFrm(FLY_AT_PAGE,
435 : : Point(rItem.lSendFromLeft + lLeft, rItem.lSendFromTop + lUpper),
436 [ # # ]: 0 : Size (rItem.lAddrFromLeft - rItem.lSendFromLeft, 0));
437 : :
438 [ # # ]: 0 : pSh->EnterSelFrmMode();
439 [ # # ]: 0 : pSh->SetFlyName( rSendMark );
440 [ # # ]: 0 : pSh->UnSelectFrm();
441 [ # # ]: 0 : pSh->LeaveSelFrmMode();
442 [ # # ]: 0 : pSh->SetTxtFmtColl( pSend );
443 [ # # ][ # # ]: 0 : InsertLabEnvText( *pSh, aFldMgr, rItem.aSendText );
[ # # ][ # # ]
444 [ # # ]: 0 : aMgr.UpdateAttrMgr();
445 : : }
446 : :
447 : : // Addressee
448 [ # # ]: 0 : pSh->SttEndDoc(sal_True);
449 : :
450 : : aMgr.InsertFlyFrm(FLY_AT_PAGE,
451 : : Point(rItem.lAddrFromLeft + lLeft, rItem.lAddrFromTop + lUpper),
452 [ # # ]: 0 : Size (nPageW - rItem.lAddrFromLeft - 566, 0));
453 [ # # ]: 0 : pSh->EnterSelFrmMode();
454 [ # # ]: 0 : pSh->SetFlyName( rAddrMark );
455 [ # # ]: 0 : pSh->UnSelectFrm();
456 [ # # ]: 0 : pSh->LeaveSelFrmMode();
457 [ # # ]: 0 : pSh->SetTxtFmtColl( pAddr );
458 [ # # ][ # # ]: 0 : InsertLabEnvText(*pSh, aFldMgr, rItem.aAddrText);
[ # # ][ # # ]
459 : :
460 : : // Move Flys to the "old" pages
461 [ # # ]: 0 : if (!aFlyArr.empty())
462 [ # # ]: 0 : pSh->SetPageObjsNewPage(aFlyArr, 1);
463 : :
464 : : // Finished
465 [ # # ]: 0 : pSh->SttEndDoc(sal_True);
466 : :
467 [ # # ]: 0 : pSh->EndAllAction();
468 : :
469 [ # # ]: 0 : if (nMode == ENV_NEWDOC)
470 [ # # ]: 0 : pSh->DoUndo(sal_True);
471 : : else
472 [ # # ]: 0 : pSh->EndUndo(UNDO_UI_INSERT_ENVELOPE);
473 : :
474 [ # # ]: 0 : if (nMode == ENV_NEWDOC)
475 : : {
476 [ # # ][ # # ]: 0 : pFrame->GetFrame().Appear();
477 : :
478 [ # # ]: 0 : if ( rItem.aAddrText.indexOf('<') >= 0 )
479 : : {
480 : : static sal_uInt16 const aInva[] =
481 : : {
482 : : SID_SBA_BRW_UPDATE,
483 : : SID_SBA_BRW_INSERT,
484 : : SID_SBA_BRW_MERGE,
485 : : 0
486 : : };
487 [ # # ]: 0 : pFrame->GetBindings().Invalidate( aInva );
488 : :
489 : : // Open database beamer
490 [ # # ][ # # ]: 0 : ShowDBObj(*pNewView, pSh->GetDBData());
491 : : }
492 : : }
493 : :
494 [ # # ]: 0 : if ( !pItem )
495 : : {
496 [ # # ]: 0 : rReq.AppendItem( rItem );
497 [ # # ]: 0 : if ( nMode == ENV_NEWDOC )
498 [ # # ][ # # ]: 0 : rReq.AppendItem( SfxBoolItem( FN_PARAM_1, sal_True ) );
[ # # ]
499 : : }
500 : :
501 [ # # ][ # # ]: 0 : rReq.Done();
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
502 : : }
503 : : else // Abort
504 : : {
505 [ # # ]: 0 : rReq.Ignore();
506 : :
507 [ # # ]: 0 : xDocSh->DoClose();
508 : 0 : --nTitleNo;
509 : :
510 : : // Set pointer to top view
511 [ # # ]: 0 : if (pOldSh)
512 : 0 : SetView(&pOldSh->GetView());
513 : : }
514 [ # # ][ # # ]: 0 : delete pDlg;
[ # # ][ # # ]
[ # # ][ # # ]
515 : 0 : }
516 : :
517 : :
518 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|