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