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