/* -*- 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 .
*/
staticconstchar* lclDebugSubType( sal_Int32 nType )
{ switch (nType) { case XML_ctrTitle : return"ctrTitle"; case XML_title : return"title"; case XML_subTitle : return"subTitle"; case XML_obj : return"obj"; case XML_body : return"body"; case XML_dt : return"dt"; case XML_hdr : return"hdr"; case XML_ftr : return"frt"; case XML_sldNum : return"sldNum"; case XML_sldImg : return"sldImg";
}
switch( nSubType )
{ case XML_ctrTitle : case XML_title :
pTextListStyle = rSlidePersist.getMasterPersist() ? rSlidePersist.getMasterPersist()->getTitleTextStyle() : rSlidePersist.getTitleTextStyle(); break; case XML_subTitle : case XML_obj : case XML_body : if ( rSlidePersist.isNotesPage() )
pTextListStyle = rSlidePersist.getMasterPersist() ? rSlidePersist.getMasterPersist()->getNotesTextStyle() : rSlidePersist.getNotesTextStyle(); else
pTextListStyle = rSlidePersist.getMasterPersist() ? rSlidePersist.getMasterPersist()->getBodyTextStyle() : rSlidePersist.getBodyTextStyle(); break;
}
return pTextListStyle;
}
bool PPTShape::IsPlaceHolderCandidate(const SlidePersist& rSlidePersist) const
{ if (meShapeLocation != Slide) returnfalse; if (rSlidePersist.isNotesPage()) returnfalse; auto pTextBody = getTextBody(); if (!pTextBody) returnfalse; auto rParagraphs = pTextBody->getParagraphs(); if (rParagraphs.size() != 1) returnfalse; if (rParagraphs.front()->getRuns().size() != 1) returnfalse; // If the placeholder has a shape other than rectangle, // we have to place it in the slide as a CustomShape. if (!mpCustomShapePropertiesPtr->representsDefaultShape()) returnfalse; return ShapeHasNoVisualPropertiesOnImport(*this);
}
if( eDateFormat != SvxDateFormat::AppDefault
|| eTimeFormat != SvxTimeFormat::AppDefault )
{ // DateTimeFormat property looks for the date in 4 LSBs // and looks for time format in the 4 bits after that
sal_Int32 nDateTimeFormat = static_cast<sal_Int32>(eDateFormat) | static_cast<sal_Int32>(eTimeFormat) << 4;
xPropertySet->setPropertyValue( u"IsDateTimeVisible"_ustr, Any(true) );
xPropertySet->setPropertyValue( u"IsDateTimeFixed"_ustr, Any(false) );
xPropertySet->setPropertyValue( u"DateTimeFormat"_ustr, Any(nDateTimeFormat) ); return;
}
}
}
}
sServiceName = "com.sun.star.presentation.DateTimeShape";
bClearText = true; break; case XML_hdr :
sServiceName = "com.sun.star.presentation.HeaderShape";
bClearText = true; break; case XML_ftr : if (IsPlaceHolderCandidate(rSlidePersist))
{ const OUString aFooterText = getTextBody()->toString();
if( !aFooterText.isEmpty() )
{ // if it is possible to get the footer as a property the LO way, // get it and discard the shape
Reference< XPropertySet > xPropertySet( rSlidePersist.getPage(), UNO_QUERY );
xPropertySet->setPropertyValue( u"IsFooterVisible"_ustr, Any( true ) );
xPropertySet->setPropertyValue( u"FooterText"_ustr, Any(aFooterText) ); return;
}
}
sServiceName = "com.sun.star.presentation.FooterShape";
bClearText = true; break; case XML_sldNum : if (IsPlaceHolderCandidate(rSlidePersist))
{
TextRunPtr& pTextRun
= getTextBody()->getParagraphs().front()->getRuns().front();
oox::drawingml::TextField* pTextField
= dynamic_cast<oox::drawingml::TextField*>(pTextRun.get()); if (pTextField && pTextField->getType() == "slidenum")
{ // if it is possible to get the slidenum placeholder as a property // do that and discard the shape
Reference<XPropertySet> xPropertySet(rSlidePersist.getPage(),
UNO_QUERY);
xPropertySet->setPropertyValue(u"IsPageNumberVisible"_ustr, Any(true)); return;
}
}
sServiceName = "com.sun.star.presentation.SlideNumberShape";
bClearText = true; break; case XML_sldImg :
sServiceName = "com.sun.star.presentation.PageShape"; break; case XML_chart : if (meShapeLocation == Layout)
sServiceName = sOutlinerShapeService; else
sServiceName = "com.sun.star.presentation.ChartShape"; break; case XML_tbl : if (meShapeLocation == Layout)
sServiceName = sOutlinerShapeService; else
sServiceName = "com.sun.star.presentation.TableShape"; break; case XML_pic : if (meShapeLocation == Layout)
sServiceName = sOutlinerShapeService; else
sServiceName = "com.sun.star.presentation.GraphicObjectShape"; break; case XML_media : if (meShapeLocation == Layout)
sServiceName = sOutlinerShapeService; else
sServiceName = "com.sun.star.presentation.MediaShape"; break; default: if (mnSubType && meShapeLocation == Layout)
sServiceName = sOutlinerShapeService; break;
}
}
// Since it is not possible to represent custom shaped placeholders in Impress // Need to use service name css.drawing.CustomShape if they have a non default shape. // This workaround has the drawback of them not really being processed as placeholders // so it is done for slide footers and obj placeholder bool convertInSlideMode
= meShapeLocation == Slide
&& (mnSubType == XML_sldNum || mnSubType == XML_dt || mnSubType == XML_ftr
|| mnSubType == XML_body
|| (mnSubType == XML_obj
&& sServiceName != "com.sun.star.drawing.GraphicObjectShape"));
if (pPlaceholder) { if (maSize.Width == 0 || maSize.Height == 0) {
awt::Size aSize = maSize; if (maSize.Width == 0)
aSize.Width = pPlaceholder->getSize().Width; if (maSize.Height == 0)
aSize.Height = pPlaceholder->getSize().Height;
setSize( aSize ); if (maPosition.X == 0 || maPosition.Y == 0) {
awt::Point aPosition = maPosition; if (maPosition.X == 0)
aPosition.X = pPlaceholder->getPosition().X; if (maPosition.Y == 0)
aPosition.Y = pPlaceholder->getPosition().Y;
setPosition( aPosition );
}
}
}
}
// use placeholder index if possible if (mnSubType && getSubTypeIndex().has_value() && rSlidePersist.getMasterPersist())
{
oox::drawingml::ShapePtr pPlaceholder = PPTShape::findPlaceholderByIndex(getSubTypeIndex().value(), rSlidePersist.getMasterPersist()->getShapes()->getChildren()); // TODO: Check if this is required for non-notes slides as well... if (rSlidePersist.isNotesPage() && pPlaceholder && pPlaceholder->getSubType() != getSubType())
pPlaceholder.reset();
pNewTextListStyle->apply( pPlaceholder->getTextBody()->getTextListStyle() ); if (pPlaceholder->getMasterTextListStyle())
pNewTextListStyle->apply( *pPlaceholder->getMasterTextListStyle() );
// SAL_INFO("oox.ppt","placeholder body style"); // pPlaceholder->getTextBody()->getTextListStyle().dump(); // SAL_INFO("oox.ppt","master text list style"); // pPlaceholder->getMasterTextListStyle()->dump();
// Apply text properties on placeholder text inside this placeholder shape if (meShapeLocation == Slide && mpPlaceholder && getTextBody() && getTextBody()->isEmpty())
{
Reference < XText > xText(mxShape, UNO_QUERY); if (xText.is())
{
TextCharacterProperties aCharStyleProperties;
getTextBody()->ApplyStyleEmpty(rFilterBase, xText, aCharStyleProperties, mpMasterTextListStyle);
}
} if (pShapeMap)
{ // bnc#705982 - if optional model id reference is // there, use that to obtain target shape if (!msModelId.isEmpty())
{
(*pShapeMap)[ msModelId ] = shared_from_this();
} elseif (!msId.isEmpty())
{
(*pShapeMap)[ msId ] = shared_from_this();
}
}
// we will be losing whatever information there is in the footer placeholder on master/layout slides // since they should have the "<footer>" textfield in them in order to make LibreOffice process them as expected // likewise DateTime placeholder data on master/layout slides will be lost and replaced if( (mnSubType == XML_ftr || mnSubType == XML_dt) && meShapeLocation != Slide )
{
OUString aFieldType; if( mnSubType == XML_ftr )
aFieldType = "com.sun.star.presentation.TextField.Footer"; else
aFieldType = "com.sun.star.presentation.TextField.DateTime";
Reference < XTextField > xField( xServiceFact->createInstance( aFieldType ), UNO_QUERY );
Reference < XText > xText(mxShape, UNO_QUERY); if(xText.is())
{
xText->setString(u""_ustr);
Reference < XTextCursor > xTextCursor = xText->createTextCursor();
xText->insertTextContent( xTextCursor, xField, false);
}
}
OUString sURL;
std::vector<std::pair<OUString, Reference<XShape>>> aURLShapes; // if this is a group shape, we have to add also each child shape
Reference<XShapes> xShapes(xShape, UNO_QUERY); if (xShapes.is())
{ // temporarily remember setting
NamedShapePairs* pDiagramFontHeights(rFilterBase.getDiagramFontHeights());
// for shapes unequal to FRAMETYPE_DIAGRAM do // disable DiagramFontHeights recording if (meFrameType != FRAMETYPE_DIAGRAM)
rFilterBase.setDiagramFontHeights(nullptr);
if (!aURLShapes.empty())
{ for (autoconst& URLShape : aURLShapes)
{
Reference<XEventsSupplier> xEventsSupplier(URLShape.second, UNO_QUERY); if (!xEventsSupplier.is()) return;
Reference<XNameReplace> xEvents(xEventsSupplier->getEvents()); if (!xEvents.is()) return;
sURL = URLShape.first;
std::map<OUString, css::presentation::ClickAction>::const_iterator aIt
= ActionMap.find(sURL);
aIt != ActionMap.end() ? meClickAction = aIt->second
: meClickAction = ClickAction_BOOKMARK;
// ClickAction_BOOKMARK and ClickAction_DOCUMENT share the same event // so check here if it's a bookmark or a document if (meClickAction == ClickAction_BOOKMARK)
{ if (!sURL.startsWith("#"))
meClickAction = ClickAction_DOCUMENT; else
{
sURL = OUString::Concat("page")
+ sURL.subView(sURL.lastIndexOf(' ') + 1);
}
nPropertyCount += 1;
}
// Function to find placeholder (ph) for a shape. No idea how MSO implements this, but // this order seems to work quite well // (probably it's unnecessary complicated / wrong. i.e. tdf#104202): // 1. ph with nFirstSubType and the same oSubTypeIndex // 2. ph with nFirstSubType // 3. ph with nSecondSubType and the same oSubTypeIndex // 4. ph with nSecondSubType // 5. ph with the same oSubTypeIndex
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.