/* -*- 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 .
*/
// DrawingEngine has to know where it is...
FmFormModel::SetStyleSheetPool( new SdStyleSheetPool( GetPool(), this ) );
// Set StyleSheetPool for DrawOutliner, so text objects can be read correctly. // The link to the StyleRequest handler of the document is set later, in // NewOrLoadCompleted, because only then do all the templates exist.
SdrOutliner& rOutliner = GetDrawOutliner();
rOutliner.SetStyleSheetPool(static_cast<SfxStyleSheetPool*>(GetStyleSheetPool()));
SetCalcFieldValueHdl( &rOutliner );
// set linguistic options if (!comphelper::IsFuzzing())
{ const SvtLinguConfig aLinguConfig;
SvtLinguOptions aOptions;
aLinguConfig.GetOptions( aOptions );
// If the current application language is a language that uses right-to-left text...
LanguageType eRealCTLLanguage = Application::GetSettings().GetLanguageTag().getLanguageType();
// for korean and japanese languages we have a different default for apply spacing between asian, latin and ctl text if (MsLangId::isKorean(eRealCTLLanguage) || (LANGUAGE_JAPANESE == eRealCTLLanguage))
{
GetPool().GetSecondaryPool()->SetUserDefaultItem( SvxScriptSpaceItem( false, EE_PARA_ASIANCJKSPACING ) );
}
// Set DefTab and SpellOptions for the SD module if (eType == DocumentType::Impress) if (aSysLocale.GetLocaleData().getMeasurementSystemEnum() == MeasurementSystem::Metric)
SetDefaultTabulator( static_cast<sal_uInt16>(officecfg::Office::Impress::Layout::Other::TabStop::Metric::get()) ); else
SetDefaultTabulator( static_cast<sal_uInt16>(officecfg::Office::Impress::Layout::Other::TabStop::NonMetric::get()) ); else if (aSysLocale.GetLocaleData().getMeasurementSystemEnum() == MeasurementSystem::Metric)
SetDefaultTabulator( static_cast<sal_uInt16>(officecfg::Office::Draw::Layout::Other::TabStop::Metric::get()) ); else
SetDefaultTabulator( static_cast<sal_uInt16>(officecfg::Office::Draw::Layout::Other::TabStop::NonMetric::get()) );
// Initialize the printer independent layout mode
SetPrinterIndependentLayout (pOptions->GetPrinterIndependentLayout());
// Set the StyleSheetPool for HitTestOutliner. // The link to the StyleRequest handler of the document is set later, in // NewOrLoadCompleted, because only then do all the templates exist.
m_pHitTestOutliner->SetStyleSheetPool( static_cast<SfxStyleSheetPool*>(GetStyleSheetPool()) );
/** Create layers * * We create the following default layers on all pages and master pages: * * sUNO_LayerName_layout; "layout": default layer for drawing objects of normal pages * localized by SdResId(STR_LAYER_LAYOUT) * * sUNO_LayerName_background; "background": background of the master page * localized by SdResId(STR_LAYER_BCKGRND) * (currently unused within normal pages and not visible to users) * * sUNO_LayerName_background_objects; "backgroundobjects": objects on the background of master pages * localized by SdResId(STR_LAYER_BCKGRNDOBJ) * (currently unused within normal pages) * * sUNO_LayerName_controls; "controls": default layer for controls * localized by SdResId(STR_LAYER_CONTROLS) * (currently special handling in regard to z-order) * * sUNO_LayerName_measurelines; "measurelines" : default layer for measure lines * localized by SdResId(STR_LAYER_MEASURELINES)
*/
// call fully implemented local version, including getting // some more information from one of the Pages (1st one)
AdaptPageSizeForAllPages(
rNewSize,
PageKind::Standard,
nullptr,
nLeft,
nRight,
nUpper,
nLower, true,
pPage->GetOrientation(),
pPage->GetPaperBin(),
pPage->IsBackgroundFullSize());
// adjust handout page to new format of the standard page if(0 != nPageCnt)
{
GetSdPage(0, PageKind::Handout)->CreateTitleAndLayout(true);
}
}
for (const beans::Property& rProperty : aProperties)
{ const OUString& rKey = rProperty.Name;
uno::Any aValue = xSourcePropertySet->getPropertyValue(rKey); // We know that pDestination was just created, so has no properties: addProperty() will never throw.
xDestinationPropertyContainer->addProperty(rKey, beans::PropertyAttribute::REMOVABLE, aValue);
}
}
}
// This method creates a new document (SdDrawDocument) and returns a pointer to // said document. The drawing engine uses this method to put the document (or // parts of it) into the clipboard/DragServer.
SdDrawDocument* SdDrawDocument::AllocSdDrawDocument() const
{
SdDrawDocument* pNewModel = nullptr;
if( mpCreatingTransferable )
{ // Document is created for drag & drop/clipboard. To be able to // do this, the document has to know a DocShell (SvPersist).
SfxObjectShell* pObj = nullptr;
::sd::DrawDocShell* pNewDocSh = nullptr;
if( meDocType == DocumentType::Impress )
mpCreatingTransferable->SetDocShell( new ::sd::DrawDocShell(
SfxObjectCreateMode::EMBEDDED, true, meDocType ) ); else
mpCreatingTransferable->SetDocShell( new ::sd::GraphicDocShell(
SfxObjectCreateMode::EMBEDDED ) );
// Only necessary for clipboard - // for drag & drop this is handled by DragServer
SdStyleSheetPool* pOldStylePool = static_cast<SdStyleSheetPool*>( GetStyleSheetPool() );
SdStyleSheetPool* pNewStylePool = static_cast<SdStyleSheetPool*>( pNewModel->GetStyleSheetPool() );
// This method creates a new page (SdPage) and returns a pointer to said page. // The drawing engine uses this method to create pages (whose types it does // not know, as they are _derivatives_ of SdrPage) when loading.
rtl::Reference<SdrPage> SdDrawDocument::AllocPage(bool bMasterPage)
{ return AllocSdPage(bMasterPage);
}
// When the model has changed void SdDrawDocument::SetChanged(bool bFlag)
{ if (mpDocSh)
{ if (mbNewOrLoadCompleted && mpDocSh->IsEnableSetModified())
{ // Pass on to base class
FmFormModel::SetChanged(bFlag);
// Forward to ObjectShell
mpDocSh->SetModified(bFlag);
}
} else
{ // Pass on to base class
FmFormModel::SetChanged(bFlag);
}
}
// The model changed, don't call anything else void SdDrawDocument::NbcSetChanged(bool bFlag)
{ // forward to baseclass
FmFormModel::SetChanged(bFlag);
}
// NewOrLoadCompleted is called when the document is loaded, or when it is clear // it won't load any more. void SdDrawDocument::NewOrLoadCompleted(DocCreationMode eMode)
{ if (eMode == DocCreationMode::New)
{ // New document: // create slideshow and default templates, // create pool for virtual controls
CreateLayoutTemplates();
CreateDefaultCellStyles();
for ( sal_uInt16 nPage = 0; nPage < GetMasterPageCount(); nPage++)
{ // LayoutName and PageName must be the same
SdPage* pPage = static_cast<SdPage*>( GetMasterPage( nPage ) );
// Create names of the styles in the user's language static_cast<SdStyleSheetPool*>(mxStyleSheetPool.get())->UpdateStdNames();
// Create any missing styles - eg. formerly, there was no Subtitle style static_cast<SdStyleSheetPool*>(mxStyleSheetPool.get())->CreatePseudosIfNecessary();
}
// Set default style of Drawing Engine
OUString aName( SdResId(STR_STANDARD_STYLESHEET_NAME));
SetDefaultStyleSheet(static_cast<SfxStyleSheet*>(mxStyleSheetPool->Find(aName, SfxStyleFamily::Para)));
// #i119287# Set default StyleSheet for SdrGrafObj and SdrOle2Obj
SetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj(static_cast<SfxStyleSheet*>(mxStyleSheetPool->Find(SdResId(STR_POOLSHEET_OBJNOLINENOFILL), SfxStyleFamily::Para)));
// Initialize DrawOutliner and DocumentOutliner, but don't initialize the // global outliner, as it is not document specific like StyleSheetPool and // StyleRequestHandler are.
::Outliner& rDrawOutliner = GetDrawOutliner();
rDrawOutliner.SetStyleSheetPool(static_cast<SfxStyleSheetPool*>(GetStyleSheetPool()));
EEControlBits nCntrl = rDrawOutliner.GetControlWord(); if (mbOnlineSpell)
nCntrl |= EEControlBits::ONLINESPELLING; else
nCntrl &= ~EEControlBits::ONLINESPELLING;
rDrawOutliner.SetControlWord(nCntrl);
// Initialize HitTestOutliner and DocumentOutliner, but don't initialize the // global outliner, as it is not document specific like StyleSheetPool and // StyleRequestHandler are.
m_pHitTestOutliner->SetStyleSheetPool(static_cast<SfxStyleSheetPool*>(GetStyleSheetPool()));
/** updates all links, only links in this document should by resolved */ void SdDrawDocument::UpdateAllLinks()
{ if (s_pDocLockedInsertingLinks || !m_pLinkManager || m_pLinkManager->GetLinks().empty()) return;
s_pDocLockedInsertingLinks = this; // lock inserting links. only links in this document should by resolved
if (mpDocSh)
{
comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = mpDocSh->getEmbeddedObjectContainer();
rEmbeddedObjectContainer.setUserAllowsLinkUpdate(true);
}
m_pLinkManager->UpdateAllLinks(true, false, nullptr, u""_ustr); // query box: update all links?
/** this loops over the presentation objects of a page and repairs some new settings from old binary files and resets all default strings for empty presentation objects.
*/ void SdDrawDocument::NewOrLoadCompleted( SdPage* pPage, SdStyleSheetPool* pSPool )
{
sd::ShapeList& rPresentationShapes( pPage->GetPresentationShapeList() ); if(rPresentationShapes.isEmpty()) return;
// Create lists of title and outline styles
OUString aName = pPage->GetLayoutName();
aName = aName.copy( 0, aName.indexOf( SD_LT_SEPARATOR ) );
// Now look for title and outline text objects, then make those objects // listeners. while( (pObj = rPresentationShapes.getNextShape()) )
{ if (pObj->GetObjInventor() == SdrInventor::Default)
{
OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject();
SdrObjKind nId = pObj->GetObjIdentifier();
// Local outliner that is used for outline mode. In this outliner, OutlinerViews // may be inserted.
SdOutliner* SdDrawDocument::GetOutliner(bool bCreateOutliner)
{ if (!mpOutliner && bCreateOutliner)
{
mpOutliner.reset(new SdOutliner( *this, OutlinerMode::TextObject ));
if (mpDocSh)
mpOutliner->SetRefDevice(SdModule::get()->GetVirtualRefDevice());
// Internal outliner that is used to create text objects. We don't insert any // OutlinerViews into this outliner!
SdOutliner* SdDrawDocument::GetInternalOutliner(bool bCreateOutliner)
{ if ( !mpInternalOutliner && bCreateOutliner )
{
mpInternalOutliner.reset( new SdOutliner( *this, OutlinerMode::TextObject ) );
// This outliner is only used to create special text objects. As no // information about portions is saved in this outliner, the update mode // can/should always remain sal_False.
mpInternalOutliner->SetUpdateLayout( false );
mpInternalOutliner->EnableUndo( false );
if (mpDocSh)
mpInternalOutliner->SetRefDevice(SdModule::get()->GetVirtualRefDevice());
void SdDrawDocument::SetPrinterIndependentLayout (sal_Int32 nMode)
{ switch (nMode)
{ case css::document::PrinterIndependentLayout::DISABLED: case css::document::PrinterIndependentLayout::ENABLED: // Just store supported modes and inform the doc shell
mnPrinterIndependentLayout = nMode;
// Since it is possible that a SdDrawDocument is constructed without a // SdDrawDocShell the pointer member mpDocSh needs to be tested // before the call is executed. This is e. g. used for copy/paste. if(mpDocSh)
{
mpDocSh->UpdateRefDevice ();
}
sal_uInt16 SdDrawDocument::GetAnnotationAuthorIndex( const OUString& rAuthor )
{ // force current user to have first color if( maAnnotationAuthors.empty() )
{
SvtUserOptions aUserOptions;
maAnnotationAuthors.push_back( aUserOptions.GetFullName() );
}
auto iter = std::find(maAnnotationAuthors.begin(), maAnnotationAuthors.end(), rAuthor);
sal_uInt16 idx = static_cast<sal_uInt16>(std::distance(maAnnotationAuthors.begin(), iter));
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.