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