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