xref: /aoo41x/main/sw/source/ui/app/applab.cxx (revision cdf0e10c)
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 #if STLPORT_VERSION>=321
33*cdf0e10cSrcweir #include <cstdarg>
34*cdf0e10cSrcweir #endif
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #include <hintids.hxx>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir #include <vcl/svapp.hxx>
40*cdf0e10cSrcweir #include <vcl/wrkwin.hxx>
41*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
42*cdf0e10cSrcweir #include <sfx2/app.hxx>
43*cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
44*cdf0e10cSrcweir #include <sfx2/printer.hxx>
45*cdf0e10cSrcweir #include <sfx2/request.hxx>
46*cdf0e10cSrcweir #include <sfx2/linkmgr.hxx>
47*cdf0e10cSrcweir #include <editeng/pbinitem.hxx>
48*cdf0e10cSrcweir #include <editeng/ulspitem.hxx>
49*cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
50*cdf0e10cSrcweir #include <editeng/boxitem.hxx>
51*cdf0e10cSrcweir #include <editeng/paperinf.hxx>
52*cdf0e10cSrcweir #include <editeng/protitem.hxx>
53*cdf0e10cSrcweir #include <com/sun/star/frame/XStorable.hpp>
54*cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp>
55*cdf0e10cSrcweir #include <fmthdft.hxx>
56*cdf0e10cSrcweir #include <fmtanchr.hxx>
57*cdf0e10cSrcweir #include <fmtfsize.hxx>
58*cdf0e10cSrcweir #include <fmtornt.hxx>
59*cdf0e10cSrcweir #include <swwait.hxx>
60*cdf0e10cSrcweir #include <gloshdl.hxx>
61*cdf0e10cSrcweir #include <mdiexp.hxx>
62*cdf0e10cSrcweir #include <frmatr.hxx>
63*cdf0e10cSrcweir #include <paratr.hxx>
64*cdf0e10cSrcweir #include <swmodule.hxx>
65*cdf0e10cSrcweir #include <view.hxx>
66*cdf0e10cSrcweir #include <docsh.hxx>
67*cdf0e10cSrcweir #include <fldbas.hxx>
68*cdf0e10cSrcweir #include <swundo.hxx>
69*cdf0e10cSrcweir #include <wrtsh.hxx>
70*cdf0e10cSrcweir #include <cmdid.h>
71*cdf0e10cSrcweir #include <dbmgr.hxx>
72*cdf0e10cSrcweir #include <fmtcol.hxx>
73*cdf0e10cSrcweir #include <expfld.hxx>
74*cdf0e10cSrcweir #include <fldmgr.hxx>
75*cdf0e10cSrcweir #include <label.hxx>
76*cdf0e10cSrcweir #include <labimg.hxx>
77*cdf0e10cSrcweir #include <section.hxx>
78*cdf0e10cSrcweir #include <pagedesc.hxx>
79*cdf0e10cSrcweir #include <poolfmt.hxx>
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir #ifndef _APP_HRC
82*cdf0e10cSrcweir #include <app.hrc>
83*cdf0e10cSrcweir #endif
84*cdf0e10cSrcweir #ifndef _POOLFMT_HRC
85*cdf0e10cSrcweir #include <poolfmt.hrc>
86*cdf0e10cSrcweir #endif
87*cdf0e10cSrcweir #include "swabstdlg.hxx"
88*cdf0e10cSrcweir #include "envelp.hrc"
89*cdf0e10cSrcweir #include <misc.hrc>
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir #include <IDocumentDeviceAccess.hxx>
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir using namespace ::com::sun::star;
94*cdf0e10cSrcweir using ::rtl::OUString;
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir // steht im appenv.cxx
97*cdf0e10cSrcweir extern String InsertLabEnvText( SwWrtShell& , SwFldMgr& , const String& );
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir const char __FAR_DATA MASTER_LABEL[] = "MasterLabel";
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir // --------------------------------------------------------------------------
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir const SwFrmFmt *lcl_InsertBCText( SwWrtShell& rSh, const SwLabItem& rItem,
104*cdf0e10cSrcweir 						SwFrmFmt &rFmt,
105*cdf0e10cSrcweir 						sal_uInt16 nCol, sal_uInt16 nRow, sal_Bool bPage)
106*cdf0e10cSrcweir {
107*cdf0e10cSrcweir 	SfxItemSet aSet(rSh.GetAttrPool(), RES_ANCHOR, RES_ANCHOR,
108*cdf0e10cSrcweir 						RES_VERT_ORIENT, RES_VERT_ORIENT, RES_HORI_ORIENT, RES_HORI_ORIENT, 0 );
109*cdf0e10cSrcweir 	sal_uInt16 nPhyPageNum, nVirtPageNum;
110*cdf0e10cSrcweir 	rSh.GetPageNum( nPhyPageNum, nVirtPageNum );
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir     aSet.Put(SwFmtAnchor(bPage ? FLY_AS_CHAR : FLY_AT_PAGE, nPhyPageNum));
113*cdf0e10cSrcweir 	if (!bPage)
114*cdf0e10cSrcweir 	{
115*cdf0e10cSrcweir 		aSet.Put(SwFmtHoriOrient(rItem.lLeft + nCol * rItem.lHDist,
116*cdf0e10cSrcweir                                                     text::HoriOrientation::NONE, text::RelOrientation::PAGE_FRAME ));
117*cdf0e10cSrcweir 		aSet.Put(SwFmtVertOrient(rItem.lUpper + nRow * rItem.lVDist,
118*cdf0e10cSrcweir                                                     text::VertOrientation::NONE, text::RelOrientation::PAGE_FRAME ));
119*cdf0e10cSrcweir 	}
120*cdf0e10cSrcweir 	const SwFrmFmt *pFmt = rSh.NewFlyFrm(aSet, sal_True,  &rFmt );	// Fly einfuegen
121*cdf0e10cSrcweir 	ASSERT( pFmt, "Fly not inserted" );
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir 	rSh.UnSelectFrm();	//Rahmen wurde automatisch selektiert
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir 	rSh.SetTxtFmtColl( rSh.GetTxtCollFromPool( RES_POOLCOLL_STANDARD ) );
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir 	//
128*cdf0e10cSrcweir 	if(!rItem.bSynchron || !(nCol|nRow))
129*cdf0e10cSrcweir 	{
130*cdf0e10cSrcweir 		SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
131*cdf0e10cSrcweir         DBG_ASSERT(pFact, "Dialogdiet fail!");
132*cdf0e10cSrcweir 		::GlossarySetActGroup fnSetActGroup = pFact->SetGlossaryActGroupFunc( DLG_RENAME_GLOS );
133*cdf0e10cSrcweir 		if ( fnSetActGroup )
134*cdf0e10cSrcweir 			(*fnSetActGroup)( rItem.sGlossaryGroup );
135*cdf0e10cSrcweir 		SwGlossaryHdl* pGlosHdl = rSh.GetView().GetGlosHdl();
136*cdf0e10cSrcweir 		pGlosHdl->SetCurGroup(rItem.sGlossaryGroup, sal_True);
137*cdf0e10cSrcweir 		pGlosHdl->InsertGlossary( rItem.sGlossaryBlockName );
138*cdf0e10cSrcweir 	}
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir 	return pFmt;
141*cdf0e10cSrcweir }
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir const SwFrmFmt *lcl_InsertLabText( SwWrtShell& rSh, const SwLabItem& rItem,
144*cdf0e10cSrcweir 						SwFrmFmt &rFmt, SwFldMgr& rFldMgr,
145*cdf0e10cSrcweir 						sal_uInt16 nCol, sal_uInt16 nRow, sal_Bool bLast, sal_Bool bPage)
146*cdf0e10cSrcweir {
147*cdf0e10cSrcweir 	SfxItemSet aSet(rSh.GetAttrPool(), RES_ANCHOR, RES_ANCHOR,
148*cdf0e10cSrcweir 						RES_VERT_ORIENT, RES_VERT_ORIENT, RES_HORI_ORIENT, RES_HORI_ORIENT, 0 );
149*cdf0e10cSrcweir 	sal_uInt16 nPhyPageNum, nVirtPageNum;
150*cdf0e10cSrcweir 	rSh.GetPageNum( nPhyPageNum, nVirtPageNum );
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir     aSet.Put(SwFmtAnchor(bPage ? FLY_AS_CHAR : FLY_AT_PAGE, nPhyPageNum));
153*cdf0e10cSrcweir 	if (!bPage)
154*cdf0e10cSrcweir 	{
155*cdf0e10cSrcweir 		aSet.Put(SwFmtHoriOrient(rItem.lLeft + nCol * rItem.lHDist,
156*cdf0e10cSrcweir                                                     text::HoriOrientation::NONE, text::RelOrientation::PAGE_FRAME ));
157*cdf0e10cSrcweir 		aSet.Put(SwFmtVertOrient(rItem.lUpper + nRow * rItem.lVDist,
158*cdf0e10cSrcweir                                                     text::VertOrientation::NONE, text::RelOrientation::PAGE_FRAME ));
159*cdf0e10cSrcweir 	}
160*cdf0e10cSrcweir 	const SwFrmFmt *pFmt = rSh.NewFlyFrm(aSet, sal_True,  &rFmt );	// Fly einfuegen
161*cdf0e10cSrcweir 	ASSERT( pFmt, "Fly not inserted" );
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir 	rSh.UnSelectFrm();	//Rahmen wurde automatisch selektiert
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir 	rSh.SetTxtFmtColl( rSh.GetTxtCollFromPool( RES_POOLCOLL_STANDARD ) );
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir 	// Ggf. "Naechster Datensatz"
168*cdf0e10cSrcweir 	String sDBName;
169*cdf0e10cSrcweir 	if( (!rItem.bSynchron || !(nCol|nRow)) && (sDBName = InsertLabEnvText( rSh, rFldMgr, rItem.aWriting )).Len() && !bLast )
170*cdf0e10cSrcweir 	{
171*cdf0e10cSrcweir         sDBName.SetToken( 3, DB_DELIM, String::CreateFromAscii("True"));
172*cdf0e10cSrcweir         SwInsertFld_Data aData(TYP_DBNEXTSETFLD, 0, sDBName, aEmptyStr, 0, &rSh );
173*cdf0e10cSrcweir         rFldMgr.InsertFld( aData );
174*cdf0e10cSrcweir 	}
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir 	return pFmt;
177*cdf0e10cSrcweir }
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir // ----------------------------------------------------------------------------
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir void SwModule::InsertLab(SfxRequest& rReq, sal_Bool bLabel)
183*cdf0e10cSrcweir {
184*cdf0e10cSrcweir static sal_uInt16 nLabelTitleNo = 0;
185*cdf0e10cSrcweir static sal_uInt16 nBCTitleNo = 0;
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir 	// DB-Manager anlegen
188*cdf0e10cSrcweir 	SwNewDBMgr* pNewDBMgr = new SwNewDBMgr;
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir 	// SwLabItem aus Config lesen
191*cdf0e10cSrcweir 	SwLabCfgItem aLabCfg(bLabel);
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir 	// Dialog hochfahren
194*cdf0e10cSrcweir 	SfxItemSet aSet( GetPool(), FN_LABEL, FN_LABEL, 0 );
195*cdf0e10cSrcweir 	aSet.Put( aLabCfg.GetItem() );
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir     SwAbstractDialogFactory* pDialogFactory = SwAbstractDialogFactory::Create();
198*cdf0e10cSrcweir     DBG_ASSERT(pDialogFactory, "SwAbstractDialogFactory fail!");
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir     AbstarctSwLabDlg* pDlg = pDialogFactory->CreateSwLabDlg( 0, aSet, pNewDBMgr, bLabel, DLG_LAB );
201*cdf0e10cSrcweir     DBG_ASSERT(pDlg, "Dialogdiet fail!");
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir 	if ( RET_OK == pDlg->Execute() )
204*cdf0e10cSrcweir 	{
205*cdf0e10cSrcweir 		// Dialog auslesen, Item in Config speichern
206*cdf0e10cSrcweir 		const SwLabItem& rItem = (const SwLabItem&) pDlg->
207*cdf0e10cSrcweir 											GetOutputItemSet()->Get(FN_LABEL);
208*cdf0e10cSrcweir 		aLabCfg.GetItem() = rItem;
209*cdf0e10cSrcweir 		aLabCfg.Commit();
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir 		// Neues Dokument erzeugen.
212*cdf0e10cSrcweir 		SfxObjectShellLock xDocSh( new SwDocShell( SFX_CREATE_MODE_STANDARD));
213*cdf0e10cSrcweir 		xDocSh->DoInitNew( 0 );
214*cdf0e10cSrcweir 
215*cdf0e10cSrcweir 		// Drucker
216*cdf0e10cSrcweir 		Printer *pPrt = pDlg->GetPrt();
217*cdf0e10cSrcweir 		if (pPrt)
218*cdf0e10cSrcweir 		{
219*cdf0e10cSrcweir 			SwDocShell *pDocSh = (SwDocShell*)(&*xDocSh);
220*cdf0e10cSrcweir             pDocSh->getIDocumentDeviceAccess()->setJobsetup(pPrt->GetJobSetup());
221*cdf0e10cSrcweir 		}
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir 		SfxViewFrame* pViewFrame = SfxViewFrame::DisplayNewDocument( *xDocSh, rReq );
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir         SwView      *pNewView = (SwView*) pViewFrame->GetViewShell();
226*cdf0e10cSrcweir         pNewView->AttrChangedNotify( &pNewView->GetWrtShell() );//Damit SelectShell gerufen wird.
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir 		// Dokumenttitel setzen
229*cdf0e10cSrcweir 		String aTmp;
230*cdf0e10cSrcweir 		if(bLabel)
231*cdf0e10cSrcweir 		{
232*cdf0e10cSrcweir 			aTmp = String(SW_RES( STR_LAB_TITLE));
233*cdf0e10cSrcweir 			aTmp += String::CreateFromInt32(++nLabelTitleNo );
234*cdf0e10cSrcweir 		}
235*cdf0e10cSrcweir 		else
236*cdf0e10cSrcweir 		{
237*cdf0e10cSrcweir 			aTmp = pDlg->GetBusinessCardStr();
238*cdf0e10cSrcweir 			aTmp += String::CreateFromInt32( ++nBCTitleNo );
239*cdf0e10cSrcweir 		}
240*cdf0e10cSrcweir 		xDocSh->SetTitle( aTmp );
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir 		pViewFrame->GetFrame().Appear();
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir 		// Shell ermitteln
245*cdf0e10cSrcweir         SwWrtShell *pSh = pNewView->GetWrtShellPtr();
246*cdf0e10cSrcweir 		ASSERT( pSh, "missing WrtShell" );
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir 		{	// block for locks the dispatcher!!
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir 			SwWait aWait( (SwDocShell&)*xDocSh, sal_True );
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir 			SET_CURR_SHELL(pSh);
253*cdf0e10cSrcweir             pSh->SetLabelDoc(rItem.bSynchron);
254*cdf0e10cSrcweir             pSh->DoUndo( sal_False );
255*cdf0e10cSrcweir 			pSh->StartAllAction();
256*cdf0e10cSrcweir 
257*cdf0e10cSrcweir 			pSh->SetNewDoc();		// Performanceprobleme vermeiden
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir 			SwPageDesc aDesc = pSh->GetPageDesc( 0 );
260*cdf0e10cSrcweir 			SwFrmFmt&  rFmt  = aDesc.GetMaster();
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir 			// Raender
263*cdf0e10cSrcweir             SvxLRSpaceItem aLRMargin( RES_LR_SPACE );
264*cdf0e10cSrcweir             SvxULSpaceItem aULMargin( RES_UL_SPACE );
265*cdf0e10cSrcweir 			aLRMargin.SetLeft ((sal_uInt16) rItem.lLeft );
266*cdf0e10cSrcweir 			aULMargin.SetUpper((sal_uInt16) rItem.lUpper);
267*cdf0e10cSrcweir             aLRMargin.SetRight(MINLAY/2);
268*cdf0e10cSrcweir             aULMargin.SetLower(MINLAY/2);
269*cdf0e10cSrcweir             rFmt.SetFmtAttr(aLRMargin);
270*cdf0e10cSrcweir             rFmt.SetFmtAttr(aULMargin);
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir 			// Kopf- und Fusszeilen
273*cdf0e10cSrcweir             rFmt.SetFmtAttr(SwFmtHeader(sal_Bool(sal_False)));
274*cdf0e10cSrcweir 			aDesc.ChgHeaderShare(sal_False);
275*cdf0e10cSrcweir             rFmt.SetFmtAttr(SwFmtFooter(sal_Bool(sal_False)));
276*cdf0e10cSrcweir 			aDesc.ChgFooterShare(sal_False);
277*cdf0e10cSrcweir 
278*cdf0e10cSrcweir 
279*cdf0e10cSrcweir 			aDesc.SetUseOn(nsUseOnPage::PD_ALL);				// Seitennumerierung
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir 			// Einstellen der Seitengroesse
282*cdf0e10cSrcweir             rFmt.SetFmtAttr(SwFmtFrmSize(ATT_FIX_SIZE,
283*cdf0e10cSrcweir                                         rItem.lLeft  + rItem.nCols * rItem.lHDist + MINLAY,
284*cdf0e10cSrcweir                                         rItem.lUpper + rItem.nRows * rItem.lVDist + MINLAY));
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir 			// Numerierungsart
287*cdf0e10cSrcweir 			SvxNumberType aType;
288*cdf0e10cSrcweir 			aType.SetNumberingType(SVX_NUM_NUMBER_NONE);
289*cdf0e10cSrcweir 			aDesc.SetNumType( aType );
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir 			// Folgevorlage
292*cdf0e10cSrcweir 			const SwPageDesc &rFollow = pSh->GetPageDesc( pSh->GetCurPageDesc() );
293*cdf0e10cSrcweir 			aDesc.SetFollow( &rFollow );
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir             pPrt = pSh->getIDocumentDeviceAccess()->getPrinter( true );
296*cdf0e10cSrcweir             SvxPaperBinItem aItem( RES_PAPER_BIN );
297*cdf0e10cSrcweir 			aItem.SetValue((sal_Int8)pPrt->GetPaperBin());
298*cdf0e10cSrcweir             rFmt.SetFmtAttr(aItem);
299*cdf0e10cSrcweir 
300*cdf0e10cSrcweir 			//determine orientation by calculating the width and height of the resulting page
301*cdf0e10cSrcweir 			const int nResultWidth = rItem.lHDist * (rItem.nCols - 1) + rItem.lWidth + rItem.lLeft;
302*cdf0e10cSrcweir 			const int nResultHeight = rItem.lVDist * (rItem.nRows - 1) + rItem.lHeight + rItem.lUpper;
303*cdf0e10cSrcweir 			aDesc.SetLandscape(nResultWidth > nResultHeight);
304*cdf0e10cSrcweir 
305*cdf0e10cSrcweir 			pSh->ChgPageDesc( 0, aDesc );
306*cdf0e10cSrcweir 
307*cdf0e10cSrcweir 			// Rahmen einfuegen
308*cdf0e10cSrcweir 			SwFldMgr*		 pFldMgr = new SwFldMgr;
309*cdf0e10cSrcweir 			pFldMgr->SetEvalExpFlds(sal_False);
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir 			//fix(24446): Damit der Text der Ettiketten nicht im unbedruckbaren
312*cdf0e10cSrcweir 			//Bereich landet stellen wir entsprechende Raender ein. Um das Handling
313*cdf0e10cSrcweir 			//so Optimal wie moeglich zu halten stellen wir zunaechst an der
314*cdf0e10cSrcweir 			//aktuellen Absatzvorlage keinen Rand als hartes Attribut ein (Damit die
315*cdf0e10cSrcweir 			//Formatierung wg. der Zeichengeb. Rahmen passt. Dann stellen wir die
316*cdf0e10cSrcweir 			//Standarabsatzvorlage anhand des unbedruckbaren Bereiches ein.
317*cdf0e10cSrcweir 			const long nMin = pPrt->GetPageOffset().X() - rItem.lLeft;
318*cdf0e10cSrcweir 			if ( nMin > 0 )
319*cdf0e10cSrcweir 			{
320*cdf0e10cSrcweir                 SvxLRSpaceItem aLR( RES_LR_SPACE );
321*cdf0e10cSrcweir 				pSh->SetAttr( aLR );
322*cdf0e10cSrcweir 				SwFmt *pStandard = pSh->GetTxtCollFromPool( RES_POOLCOLL_STANDARD );
323*cdf0e10cSrcweir 				aLR.SetLeft ( sal_uInt16(nMin) );
324*cdf0e10cSrcweir 				aLR.SetRight( sal_uInt16(nMin) );
325*cdf0e10cSrcweir                 pStandard->SetFmtAttr( aLR );
326*cdf0e10cSrcweir 			}
327*cdf0e10cSrcweir 
328*cdf0e10cSrcweir 			// Rahmenvorlage vorbereiten
329*cdf0e10cSrcweir 			SwFrmFmt* pFmt = pSh->GetFrmFmtFromPool( RES_POOLFRM_LABEL );
330*cdf0e10cSrcweir 			SwFmtFrmSize aFrmSize(	ATT_FIX_SIZE,
331*cdf0e10cSrcweir 									rItem.lHDist - (rItem.lHDist-rItem.lWidth),
332*cdf0e10cSrcweir 									rItem.lVDist - (rItem.lVDist-rItem.lHeight));
333*cdf0e10cSrcweir             pFmt->SetFmtAttr(aFrmSize);
334*cdf0e10cSrcweir 
335*cdf0e10cSrcweir 			SvxLRSpaceItem aFrmLRSpace(	0, (sal_uInt16)(rItem.lHDist - rItem.lWidth),
336*cdf0e10cSrcweir 										0, 0,
337*cdf0e10cSrcweir 										RES_LR_SPACE);
338*cdf0e10cSrcweir             pFmt->SetFmtAttr(aFrmLRSpace);
339*cdf0e10cSrcweir 
340*cdf0e10cSrcweir 			SvxULSpaceItem aFrmULSpace(	0, (sal_uInt16)(rItem.lVDist - rItem.lHeight),
341*cdf0e10cSrcweir 										RES_UL_SPACE);
342*cdf0e10cSrcweir             pFmt->SetFmtAttr(aFrmULSpace);
343*cdf0e10cSrcweir 
344*cdf0e10cSrcweir 			const SwFrmFmt *pFirstFlyFmt = 0;
345*cdf0e10cSrcweir 			if ( rItem.bPage )
346*cdf0e10cSrcweir 			{
347*cdf0e10cSrcweir 				SwFmtVertOrient aFrmVertOrient( pFmt->GetVertOrient() );
348*cdf0e10cSrcweir                 aFrmVertOrient.SetVertOrient( text::VertOrientation::TOP );
349*cdf0e10cSrcweir                 pFmt->SetFmtAttr(aFrmVertOrient);
350*cdf0e10cSrcweir 
351*cdf0e10cSrcweir 				for ( sal_uInt16 i = 0; i < rItem.nRows; ++i )
352*cdf0e10cSrcweir 				{
353*cdf0e10cSrcweir 					for ( sal_uInt16 j = 0; j < rItem.nCols; ++j )
354*cdf0e10cSrcweir 					{
355*cdf0e10cSrcweir 						pSh->Push();
356*cdf0e10cSrcweir 						const SwFrmFmt *pTmp =
357*cdf0e10cSrcweir 								bLabel ?
358*cdf0e10cSrcweir 								lcl_InsertLabText( *pSh, rItem, *pFmt, *pFldMgr, j, i,
359*cdf0e10cSrcweir 									i == rItem.nRows - 1 && j == rItem.nCols - 1,
360*cdf0e10cSrcweir 									sal_True ) :
361*cdf0e10cSrcweir 								lcl_InsertBCText(*pSh, rItem, *pFmt, j, i, sal_True);
362*cdf0e10cSrcweir 						if (!(i|j))
363*cdf0e10cSrcweir 						{
364*cdf0e10cSrcweir 							pFirstFlyFmt = pTmp;
365*cdf0e10cSrcweir 
366*cdf0e10cSrcweir 							if (rItem.bSynchron)
367*cdf0e10cSrcweir 							{
368*cdf0e10cSrcweir 								// if there is no content in the fly then
369*cdf0e10cSrcweir 								// dont leave the fly!!!
370*cdf0e10cSrcweir 								pSh->Push();
371*cdf0e10cSrcweir 								pSh->SttDoc();
372*cdf0e10cSrcweir 								sal_Bool bInFly = 0 != pSh->WizzardGetFly();
373*cdf0e10cSrcweir 								pSh->Pop( bInFly );
374*cdf0e10cSrcweir 
375*cdf0e10cSrcweir 								if( bInFly )
376*cdf0e10cSrcweir 									pSh->EndDoc(sal_True);	// select all content
377*cdf0e10cSrcweir 														// in the fly
378*cdf0e10cSrcweir 								else
379*cdf0e10cSrcweir 									pSh->SetMark();		// set only the mark
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir                                 SwSectionData aSect(CONTENT_SECTION,
382*cdf0e10cSrcweir                                     String::CreateFromAscii(MASTER_LABEL));
383*cdf0e10cSrcweir 								pSh->InsertSection(aSect);
384*cdf0e10cSrcweir 							}
385*cdf0e10cSrcweir 						}
386*cdf0e10cSrcweir 						else if (rItem.bSynchron)
387*cdf0e10cSrcweir                         {
388*cdf0e10cSrcweir                             SwSectionData aSect(FILE_LINK_SECTION,
389*cdf0e10cSrcweir                                     pSh->GetUniqueSectionName());
390*cdf0e10cSrcweir                             String sLinkName(sfx2::cTokenSeperator);
391*cdf0e10cSrcweir                             sLinkName += sfx2::cTokenSeperator;
392*cdf0e10cSrcweir 							sLinkName += String::CreateFromAscii(MASTER_LABEL);
393*cdf0e10cSrcweir 							aSect.SetLinkFileName(sLinkName);
394*cdf0e10cSrcweir                             aSect.SetProtectFlag(true);
395*cdf0e10cSrcweir 							pSh->Insert(aDotStr);	// Dummytext zum Zuweisen der Section
396*cdf0e10cSrcweir 							pSh->SttDoc();
397*cdf0e10cSrcweir 							pSh->EndDoc(sal_True);	// Alles im Rahmen selektieren
398*cdf0e10cSrcweir 							pSh->InsertSection(aSect);
399*cdf0e10cSrcweir 						}
400*cdf0e10cSrcweir 						pSh->Pop( sal_False );
401*cdf0e10cSrcweir 					}
402*cdf0e10cSrcweir 					if ( i + 1 != rItem.nRows )
403*cdf0e10cSrcweir 						pSh->SplitNode(); // Kleine Optimierung
404*cdf0e10cSrcweir 				}
405*cdf0e10cSrcweir 			}
406*cdf0e10cSrcweir 			else
407*cdf0e10cSrcweir 			{
408*cdf0e10cSrcweir 				pFirstFlyFmt = bLabel ?
409*cdf0e10cSrcweir 					lcl_InsertLabText( *pSh, rItem, *pFmt, *pFldMgr,
410*cdf0e10cSrcweir                             static_cast< sal_uInt16 >(rItem.nCol - 1),
411*cdf0e10cSrcweir                             static_cast< sal_uInt16 >(rItem.nRow - 1), sal_True, sal_False ) :
412*cdf0e10cSrcweir                     lcl_InsertBCText(*pSh, rItem, *pFmt,
413*cdf0e10cSrcweir                             static_cast< sal_uInt16 >(rItem.nCol - 1),
414*cdf0e10cSrcweir                             static_cast< sal_uInt16 >(rItem.nRow - 1), sal_False);
415*cdf0e10cSrcweir 			}
416*cdf0e10cSrcweir 
417*cdf0e10cSrcweir 			//fill the user fields
418*cdf0e10cSrcweir 			if(!bLabel)
419*cdf0e10cSrcweir 			{
420*cdf0e10cSrcweir 				uno::Reference< frame::XModel >  xModel = pSh->GetView().GetDocShell()->GetBaseModel();
421*cdf0e10cSrcweir                 DBG_ASSERT(pDialogFactory, "SwAbstractDialogFactory fail!");
422*cdf0e10cSrcweir                 SwLabDlgMethod SwLabDlgUpdateFieldInformation = pDialogFactory->GetSwLabDlgStaticMethod ();
423*cdf0e10cSrcweir 				SwLabDlgUpdateFieldInformation(xModel, rItem);
424*cdf0e10cSrcweir 			}
425*cdf0e10cSrcweir 
426*cdf0e10cSrcweir 			pFldMgr->SetEvalExpFlds(sal_True);
427*cdf0e10cSrcweir 			pFldMgr->EvalExpFlds(pSh);
428*cdf0e10cSrcweir 
429*cdf0e10cSrcweir 			delete pFldMgr;
430*cdf0e10cSrcweir 
431*cdf0e10cSrcweir 			pSh->GotoFly(pFirstFlyFmt->GetName(), FLYCNTTYPE_ALL, sal_False);
432*cdf0e10cSrcweir 
433*cdf0e10cSrcweir 			pSh->EndAllAction();
434*cdf0e10cSrcweir 			pSh->DoUndo( sal_True );
435*cdf0e10cSrcweir         }
436*cdf0e10cSrcweir 
437*cdf0e10cSrcweir 		if( rItem.aWriting.indexOf( '<' ) >= 0 )
438*cdf0e10cSrcweir 		{
439*cdf0e10cSrcweir 			// Datenbankbrowser mit zuletzt verwendeter Datenbank oeffnen
440*cdf0e10cSrcweir             ShowDBObj( *pNewView, pSh->GetDBData() );
441*cdf0e10cSrcweir 		}
442*cdf0e10cSrcweir 
443*cdf0e10cSrcweir 		if( rItem.bSynchron )
444*cdf0e10cSrcweir 		{
445*cdf0e10cSrcweir 			SfxDispatcher* pDisp = pViewFrame->GetDispatcher();
446*cdf0e10cSrcweir 			ASSERT(pDisp, "Heute kein Dispatcher am Frame?");
447*cdf0e10cSrcweir 			pDisp->Execute(FN_SYNC_LABELS, SFX_CALLMODE_ASYNCHRON);
448*cdf0e10cSrcweir 		}
449*cdf0e10cSrcweir         rReq.SetReturnValue(SfxVoidItem(bLabel ? FN_LABEL : FN_BUSINESS_CARD));
450*cdf0e10cSrcweir 	}
451*cdf0e10cSrcweir 	delete pDlg;
452*cdf0e10cSrcweir 
453*cdf0e10cSrcweir 	if( pNewDBMgr )
454*cdf0e10cSrcweir 		delete pNewDBMgr;
455*cdf0e10cSrcweir }
456*cdf0e10cSrcweir 
457*cdf0e10cSrcweir 
458