/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
// Function used for labels and envelopes in applab.cxx and appenv.cxx
OUString InsertLabEnvText( SwWrtShell& rSh, SwFieldMgr& rFieldMgr, const OUString& rText )
{
OUString sRet;
OUString aText = rText.replaceAll("\r", "");
// Get current shell
pMyDocSh = static_cast<SwDocShell*>( SfxObjectShell::Current());
pOldSh = pMyDocSh ? pMyDocSh->GetWrtShell() : nullptr;
// Create new document (don't show!)
SfxObjectShellLock xDocSh( new SwDocShell( SfxObjectCreateMode::STANDARD ) );
xDocSh->DoInitNew();
pFrame = SfxViewFrame::LoadHiddenDocument( *xDocSh, SFX_INTERFACE_NONE );
pNewView = static_cast<SwView*>( pFrame->GetViewShell());
pNewView->AttrChangedNotify(nullptr); // so that SelectShell is being called
pSh = pNewView->GetWrtShellPtr();
// if applicable, copy the old Collections "Sender" and "Receiver" to // a new document if ( pOldSh )
{
::lcl_CopyCollAttr(pOldSh, pSh, RES_POOLCOLL_ENVELOPE_ADDRESS);
::lcl_CopyCollAttr(pOldSh, pSh, RES_POOLCOLL_SEND_ADDRESS);
}
// Read SwEnvItem from config
SwEnvCfgItem aEnvCfg;
// Check if there's already an envelope. bool bEnvChange = false;
IDocumentDeviceAccess& rIDDA_old = pOldSh->getIDocumentDeviceAccess(); if( rIDDA_old.getPrinter( false ) )
{
IDocumentDeviceAccess& rIDDA = pSh->getIDocumentDeviceAccess();
rIDDA.setJobsetup( *rIDDA_old.getJobsetup() ); //#69563# if it isn't the same printer then the pointer has been invalidated!
pTempPrinter = rIDDA.getPrinter( true );
}
pTempPrinter->SetPaperBin(rCurPageDesc.GetMaster().GetPaperBin().GetValue());
}
ScopedVclPtr<SfxAbstractTabDialog> pDlg; short nMode = ENV_INSERT;
// Read dialog and save item to config const SwEnvItem& rItem = pItem ? *pItem : static_cast<const SwEnvItem&>( pDlg->GetOutputItemSet()->Get(FN_ENVELOP) );
aEnvCfg.GetItem() = rItem;
aEnvCfg.Commit();
// When we print we take the Jobsetup that is set up in the dialog. // Information has to be set here, before a possible destruction of // the new shell because the shell's printer has been handed to the // dialog. if ( nMode != ENV_NEWDOC )
{
OSL_ENSURE(pOldSh, "No document - wasn't 'Insert' disabled???");
SvxPaperBinItem aItem( RES_PAPER_BIN );
aItem.SetValue(static_cast<sal_uInt8>(pSh->getIDocumentDeviceAccess().getPrinter(true)->GetPaperBin()));
pOldSh->GetPageDescFromPool(RES_POOLPAGE_ENVELOPE)->GetMaster().SetFormatAttr(aItem);
}
SetView(&pOldSh->GetView()); // Set pointer to top view
// Delete new document
xDocSh->DoClose();
pSh = pOldSh; //#i4251# selected text or objects in the document should //not be deleted on inserting envelopes
pSh->EnterStdMode(); // Here it goes (insert)
pSh->StartUndo(SwUndoId::UI_INSERT_ENVELOPE);
pSh->StartAllAction();
pSh->SttEndDoc(true);
// Delete text from the first page if ( !pSh->SttNxtPg(true) )
pSh->EndPg(true);
pSh->DelRight(); // Delete frame of the first page if ( pSh->GotoFly(sSendMark) )
{
pSh->EnterSelFrameMode();
pSh->DelRight();
} if ( pSh->GotoFly(sAddrMark) )
{
pSh->EnterSelFrameMode();
pSh->DelRight();
}
pSh->SttEndDoc(true);
} else // Followup template: page 1
pFollow = &pSh->GetPageDesc(pSh->GetCurPageDesc());
// Again, copy the new collections "Sender" and "Receiver" to // a new document if ( pOldSh )
{
::lcl_CopyCollAttr(pOldSh, pSh, RES_POOLCOLL_ENVELOPE_ADDRESS);
::lcl_CopyCollAttr(pOldSh, pSh, RES_POOLCOLL_SEND_ADDRESS);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.