/* -*- 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 .
*/
void DrawDocShell::OnDocumentPrinterChanged(Printer* pNewPrinter)
{ // if we already have a printer, see if it's the same if( mpPrinter )
{ // easy case if( mpPrinter == pNewPrinter ) return;
// compare if it's the same printer with the same job setup if( (mpPrinter->GetName() == pNewPrinter->GetName()) &&
(mpPrinter->GetJobSetup() == pNewPrinter->GetJobSetup())) return;
}
SfxPrinter* const pSfxPrinter = dynamic_cast<SfxPrinter*>(pNewPrinter); if (pSfxPrinter)
{
SetPrinter(pSfxPrinter);
// Determine the device for which the output will be formatted.
VclPtr< OutputDevice > pRefDevice; switch (mpDoc->GetPrinterIndependentLayout())
{ case css::document::PrinterIndependentLayout::DISABLED:
pRefDevice = mpPrinter.get(); break;
case css::document::PrinterIndependentLayout::ENABLED:
pRefDevice = SdModule::get()->GetVirtualRefDevice(); break;
default: // We are confronted with an invalid or un-implemented // layout mode. Use the printer as formatting device // as a fall-back.
SAL_WARN( "sd", "DrawDocShell::UpdateRefDevice(): Unexpected printer layout mode");
if (bRet)
{ if( !mbSdDataObj )
mpDoc->NewOrLoadCompleted(DocCreationMode::New); // otherwise calling // NewOrLoadCompleted(NEW_LOADED) in // SdDrawDocument::AllocModel()
} return bRet;
}
/** * loads pools and document
*/ bool DrawDocShell::Load( SfxMedium& rMedium )
{ // If this is an ODF file being loaded, then by default, use legacy processing // (if required, it will be overridden in *::ReadUserDataSequence()) if (IsOwnStorageFormat(rMedium))
{
mpDoc->SetCompatibilityFlag(SdrCompatibilityFlag::AnchoredTextOverflowLegacy, true); // for tdf#99729
mpDoc->SetCompatibilityFlag(SdrCompatibilityFlag::LegacyFontwork, true); // for tdf#148000
}
// for legacy markup in OOoXML filter, convert the animations now
EffectMigration::DocumentLoaded(*pDoc);
UpdateTablePointers();
// If we're an embedded OLE object, use tight bounds // for our visArea. No point in showing the user lots of empty // space. Had to remove the check for empty VisArea below, // since XML load always sets a VisArea before. //TODO/LATER: looks a little bit strange! if( ( GetCreateMode() == SfxObjectCreateMode::EMBEDDED ) && SfxObjectShell::GetVisArea( ASPECT_CONTENT ).IsEmpty() )
{
SdPage* pPage = mpDoc->GetSdPage( 0, PageKind::Standard );
// TODO/LATER: nobody is interested in the error code?!
ErrCode nError = ERRCODE_NONE; bool bRet = SdXMLFilter( rMedium, *this, SdXMLFilterMode::Organizer, SotStorage::GetVersion( rMedium.GetStorage() ) ).Import( nError );
// tell SFX to change viewshell when in preview mode if( IsPreview() )
{
GetMedium()->GetItemSet().Put( SfxUInt16Item( SID_VIEW_ID, 5 ) );
}
return bRet;
}
/** * load from 3rd party format
*/ bool DrawDocShell::ImportFrom(SfxMedium &rMedium,
uno::Reference<text::XTextRange> const& xInsertPosition)
{ const OUString aFilterName( rMedium.GetFilter()->GetFilterName() ); if (aFilterName == "Impress MS PowerPoint 2007 XML" ||
aFilterName == "Impress MS PowerPoint 2007 XML AutoPlay" ||
aFilterName == "Impress MS PowerPoint 2007 XML VBA")
{ // As this is a MSFT format, we should use the "MS Compat" // mode for spacing before and after paragraphs.
// This is copied from what is done for .ppt import in // ImplSdPPTImport::Import() in sd/source/filter/ppt/pptin.cxx // in. We need to tell both the edit engine of the draw outliner, // and the document, to do "summation of paragraphs".
SdrOutliner& rOutl = mpDoc->GetDrawOutliner();
EEControlBits nControlWord = rOutl.GetEditEngine().GetControlWord();
nControlWord |= EEControlBits::ULSPACESUMMATION; const_cast<EditEngine&>(rOutl.GetEditEngine()).SetControlWord( nControlWord );
mpDoc->SetSummationOfParagraphs();
}
if (aFilterName == "Impress MS PowerPoint 2007 XML")
{ // This is a "MS Compact" mode for connectors. // The Libreoffice uses bounding rectangle of connected shapes but // MSO uses snap rectangle when calculate the edge track.
mpDoc->SetCompatibilityFlag(SdrCompatibilityFlag::ConnectorUseSnapRect, true);
// compatibility flag for tdf#148966
mpDoc->SetCompatibilityFlag(SdrCompatibilityFlag::IgnoreBreakAfterMultilineField, true);
// tdf#168010: PowerPoint ignores empty trailing lines in autoshrink text when scaling font // (same as Impress), but takes into account in layout:
mpDoc->SetCompatibilityFlag(SdrCompatibilityFlag::UseTrailingEmptyLinesInLayout, true);
}
if (aFilterName == "Impress MS PowerPoint 2007 XML" ||
aFilterName == "Impress MS PowerPoint 2007 XML AutoPlay" ||
aFilterName == "Impress MS PowerPoint 2007 XML VBA" ||
aFilterName == "Impress Office Open XML")
{ // We need to be able to set the default tab size for each text object. // This is possible at the moment only for the whole document. See // TextParagraphPropertiesContext constructor. So default tab width // of the LibreOffice is 1270 but MSO is 2540 on general settings.
mpDoc->SetDefaultTabulator( 2540 );
}
comphelper::ScopeGuard undoGuard([this, wasUndo = mpDoc->IsUndoEnabled()]
{ mpDoc->EnableUndo(wasUndo); }); if (xInsertPosition) // insert mode
{
undoGuard.dismiss();
} else// initial loading of the document
{
mpDoc->EnableUndo(false);
}
if (xFilter)
{ if ( mpViewShell )
{
::sd::View* pView = mpViewShell->GetView(); if ( pView->IsTextEdit() )
pView->SdrEndTextEdit();
}
bRet = xFilter->Export();
}
}
return bRet;
}
/** * Reopen own streams to ensure that nobody else can prevent use from opening * them.
*/ bool DrawDocShell::SaveCompleted( const css::uno::Reference< css::embed::XStorage >& xStorage )
{ bool bRet = false;
if (nPageNumber == SDRPAGE_NOTFOUND)
{ // Is the bookmark an object?
pObj = mpDoc->GetObj(rBookmark);
if (pObj)
{
nPageNumber = pObj->getSdrPageFromSdrObject()->GetPageNum();
}
}
} if (nPageNumber != SDRPAGE_NOTFOUND)
{ // Jump to the bookmarked page. This is done in three steps.
if (eNewPageKind != pDrawViewShell->GetPageKind())
{ // change work area
GetFrameView()->SetPageKind(eNewPageKind);
OUString sViewURL; switch (eNewPageKind)
{ case PageKind::Standard:
sViewURL = FrameworkHelper::msImpressViewURL; break; case PageKind::Notes:
sViewURL = FrameworkHelper::msNotesViewURL; break; case PageKind::Handout:
sViewURL = FrameworkHelper::msHandoutViewURL; break; default: break;
} if (!sViewURL.isEmpty())
{
std::shared_ptr<FrameworkHelper> pHelper (
FrameworkHelper::Instance(rBase));
pHelper->RequestView(
sViewURL,
FrameworkHelper::msCenterPaneURL);
pHelper->WaitForUpdate();
// Get the new DrawViewShell.
mpViewShell = pHelper->GetViewShell(FrameworkHelper::msCenterPaneURL).get();
pDrawViewShell = dynamic_cast<sd::DrawViewShell*>(mpViewShell);
} else
{
pDrawViewShell = nullptr;
}
}
if (pDrawViewShell != nullptr)
{
setEditMode(pDrawViewShell, bIsMasterPage);
// Make the bookmarked page the current page. This is done // by using the API because this takes care of all the // little things to be done. Especially writing the view // data to the frame view.
sal_uInt16 nSdPgNum = (nPageNumber - 1) / 2;
DrawController* pDrawController = rBase.GetDrawController(); if (pDrawController)
{
Reference<drawing::XDrawPage> xDrawPage (pPage->getUnoPage(), UNO_QUERY);
pDrawController->setCurrentPage (xDrawPage);
} else
{ // As a fall back switch to the page via the core.
DBG_ASSERT (pDrawController, "DrawDocShell::GotoBookmark: can't switch page via API");
pDrawViewShell->SwitchPage(nSdPgNum);
}
// Do UnmarkAll here to stop the Navigator from reselecting the previously marked // entry when a slide entry is selected.
pDrawViewShell->GetView()->UnmarkAll(); if (pObj != nullptr)
{ // show and select object if (vcl::Window* pWindow = pDrawViewShell->GetActiveWindow())
pDrawViewShell->MakeVisible(pObj->GetSnapRect(), *pWindow);
pDrawViewShell->GetView()->MarkObj(
pObj,
pDrawViewShell->GetView()->GetSdrPageView());
}
}
}
if (pFilter->IsOwnTemplateFormat())
{ /* now the StarDraw specialty: we assign known layout names to the layout template of the first page, we set the layout names of the affected masterpages and pages. We inform all text objects of the affected standard, note and masterpages about the name change.
*/
void DrawDocShell::FillClass(SvGlobalName* pClassName,
SotClipboardFormatId* pFormat,
OUString* pFullTypeName,
sal_Int32 nFileFormat, bool bTemplate /* = false */) const
{ if (nFileFormat == SOFFICE_FILEFORMAT_60)
{ if ( meDocType == DocumentType::Draw )
{
*pClassName = SvGlobalName(SO3_SDRAW_CLASSID_60);
*pFormat = SotClipboardFormatId::STARDRAW_60;
*pFullTypeName = SdResId(STR_GRAPHIC_DOCUMENT_FULLTYPE_60);
} else
{
*pClassName = SvGlobalName(SO3_SIMPRESS_CLASSID_60);
*pFormat = SotClipboardFormatId::STARIMPRESS_60;
*pFullTypeName = SdResId(STR_IMPRESS_DOCUMENT_FULLTYPE_60);
}
} elseif (nFileFormat == SOFFICE_FILEFORMAT_8)
{ if ( meDocType == DocumentType::Draw )
{
*pClassName = SvGlobalName(SO3_SDRAW_CLASSID_60);
*pFormat = bTemplate ? SotClipboardFormatId::STARDRAW_8_TEMPLATE : SotClipboardFormatId::STARDRAW_8;
*pFullTypeName = SdResId(STR_GRAPHIC_DOCUMENT_FULLTYPE_80); // HACK: method will be removed with new storage API
} else
{
*pClassName = SvGlobalName(SO3_SIMPRESS_CLASSID_60);
*pFormat = bTemplate ? SotClipboardFormatId::STARIMPRESS_8_TEMPLATE : SotClipboardFormatId::STARIMPRESS_8;
*pFullTypeName = SdResId(STR_IMPRESS_DOCUMENT_FULLTYPE_80); // HACK: method will be removed with new storage API
}
}
}
OutputDevice* DrawDocShell::GetDocumentRefDev()
{
OutputDevice* pReferenceDevice = SfxObjectShell::GetDocumentRefDev (); // Only when our parent does not have a reference device then we return // our own. if (pReferenceDevice == nullptr && mpDoc != nullptr)
pReferenceDevice = mpDoc->GetRefDevice (); return pReferenceDevice;
}
/** executes the SID_OPENDOC slot to let the framework open a document
with the given URL and this document as a referer */ void DrawDocShell::OpenBookmark( const OUString& rBookmarkURL )
{
SfxStringItem aStrItem( SID_FILE_NAME, rBookmarkURL );
SfxStringItem aReferer( SID_REFERER, GetMedium()->GetName() );
SfxUInt16Item aPresentation( SID_DOC_STARTPRESENTATION ); const SfxPoolItem* ppArgs[] = { &aStrItem, &aReferer, &aPresentation, nullptr };
void DrawDocShell::setEditMode(DrawViewShell* pDrawViewShell, bool isMasterPage)
{ // Set the edit mode to either the normal edit mode or the // master page mode.
EditMode eNewEditMode = EditMode::Page; if (isMasterPage)
{
eNewEditMode = EditMode::MasterPage;
}
if (eNewEditMode != pDrawViewShell->GetEditMode())
{ // Set EditMode
pDrawViewShell->ChangeEditMode(eNewEditMode, false);
}
}
} // end of namespace sd
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.