28#include <com/sun/star/text/XTextField.hpp>
29#include <com/sun/star/container/XNamed.hpp>
30#include <com/sun/star/frame/XModel.hpp>
31#include <com/sun/star/lang/XMultiServiceFactory.hpp>
32#include <com/sun/star/drawing/XDrawPage.hpp>
33#include <com/sun/star/drawing/XDrawPages.hpp>
34#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
35#include <com/sun/star/drawing/XShapes.hpp>
36#include <com/sun/star/text/XText.hpp>
37#include <com/sun/star/document/XEventsSupplier.hpp>
38#include <com/sun/star/container/XNameReplace.hpp>
39#include <com/sun/star/presentation/ClickAction.hpp>
43#include <oox/token/tokens.hxx>
44#include <oox/token/properties.hxx>
62:
Shape( pServiceName )
63, meShapeLocation( eShapeLocation )
64, mbReferenced( false )
65, mbHasNoninheritedShapeProperties( false )
98 return "unknown - please extend lclDebugSubType";
107 && !rPPTShape.
getTextBody()->hasVisualRunProperties()
108 && !rPPTShape.
getTextBody()->hasNoninheritedBodyProperties()
109 && !rPPTShape.
getTextBody()->hasListStyleOnImport()
110 && !rPPTShape.
getTextBody()->hasParagraphProperties();
136 return pTextListStyle;
148 auto rParagraphs = pTextBody->getParagraphs();
149 if (rParagraphs.size() != 1)
151 if (rParagraphs.front()->getRuns().size() != 1)
157 return ShapeHasNoVisualPropertiesOnImport(*
this);
164 const Reference< XShapes >& rxShapes,
179 Reference<lang::XMultiServiceFactory> xServiceFact(rFilterBase.
getModel(), UNO_QUERY_THROW);
180 bool bClearText =
false;
182 if (
sServiceName !=
"com.sun.star.drawing.GraphicObjectShape" &&
185 static constexpr OUStringLiteral sOutlinerShapeService(
u"com.sun.star.presentation.OutlinerShape");
192 sServiceName =
"com.sun.star.presentation.TitleTextShape";
201 sServiceName =
"com.sun.star.presentation.SubtitleShape";
233 OUString aType = pTextField->
getType();
234 if ( aType.startsWith(
"datetime") )
238 Reference< XPropertySet > xPropertySet( rSlidePersist.
getPage(), UNO_QUERY );
240 if( eDateFormat != SvxDateFormat::AppDefault
241 || eTimeFormat != SvxTimeFormat::AppDefault )
245 sal_Int32 nDateTimeFormat =
static_cast<sal_Int32
>(eDateFormat) |
246 static_cast<sal_Int32
>(eTimeFormat) << 4;
247 xPropertySet->setPropertyValue(
"IsDateTimeVisible",
Any(
true) );
248 xPropertySet->setPropertyValue(
"IsDateTimeFixed",
Any(
false) );
249 xPropertySet->setPropertyValue(
"DateTimeFormat",
Any(nDateTimeFormat) );
255 sServiceName =
"com.sun.star.presentation.DateTimeShape";
265 const OUString& rFooterText =
getTextBody()->toString();
267 if( !rFooterText.isEmpty() )
271 Reference< XPropertySet > xPropertySet( rSlidePersist.
getPage(), UNO_QUERY );
272 xPropertySet->setPropertyValue(
"IsFooterVisible",
Any(
true ) );
273 xPropertySet->setPropertyValue(
"FooterText",
Any(rFooterText) );
284 =
getTextBody()->getParagraphs().front()->getRuns().front();
287 if (pTextField && pTextField->
getType() ==
"slidenum")
291 Reference<XPropertySet> xPropertySet(rSlidePersist.
getPage(),
293 xPropertySet->setPropertyValue(
"IsPageNumberVisible",
Any(
true));
297 sServiceName =
"com.sun.star.presentation.SlideNumberShape";
319 sServiceName =
"com.sun.star.presentation.GraphicObjectShape";
356 aSize.Width = pPlaceholder->getSize().Width;
358 aSize.Height = pPlaceholder->getSize().Height;
363 aPosition.X = pPlaceholder->getPosition().X;
365 aPosition.Y = pPlaceholder->getPosition().Y;
378 pPlaceholder.reset();
382 PPTShape* pPPTPlaceholder =
dynamic_cast< PPTShape*
>( pPlaceholder.get() );
385 if (pPlaceholder->getTextBody()) {
387 pNewTextListStyle->apply( pPlaceholder->getTextBody()->getTextListStyle() );
388 if (pPlaceholder->getMasterTextListStyle())
389 pNewTextListStyle->apply( *pPlaceholder->getMasterTextListStyle() );
396 aMasterTextListStyle = pNewTextListStyle;
405 pNewTextListStyle->apply( pPPTPlaceholder->
mpPlaceholder->getTextBody()->getTextListStyle() );
406 if (pPlaceholderStyle) {
407 pNewTextListStyle->apply( *pPlaceholderStyle );
412 aMasterTextListStyle.reset();
414 SAL_INFO(
"oox.ppt",
"placeholder id: " << (pPlaceholder ? pPlaceholder->getId() :
"not found"));
419 if (!aMasterTextListStyle)
428 aMasterTextListStyle->apply( *aSlideStyle );
432 aMasterTextListStyle = aSlideStyle;
437 TextListStylePtr aCombinedTextListStyle = std::make_shared<TextListStyle>();
439 aCombinedTextListStyle->apply( *aMasterTextListStyle );
442 aCombinedTextListStyle->apply(
mpPlaceholder->getTextBody()->getTextListStyle() );
443 aCombinedTextListStyle->apply(
getTextBody()->getTextListStyle() );
454 Reference < XText > xText(
mxShape, UNO_QUERY);
457 TextCharacterProperties aCharStyleProperties;
467 (*pShapeMap)[
msModelId ] = shared_from_this();
469 else if (!
msId.isEmpty())
471 (*pShapeMap)[
msId ] = shared_from_this();
482 aFieldType =
"com.sun.star.presentation.TextField.Footer";
484 aFieldType =
"com.sun.star.presentation.TextField.DateTime";
485 Reference < XTextField > xField( xServiceFact->createInstance( aFieldType ), UNO_QUERY );
486 Reference < XText > xText(
mxShape, UNO_QUERY);
489 xText->setString(
"");
490 Reference < XTextCursor > xTextCursor = xText->createTextCursor();
491 xText->insertTextContent( xTextCursor, xField,
false);
496 std::vector<std::pair<OUString, Reference<XShape>>> aURLShapes;
498 Reference<XShapes> xShapes(xShape, UNO_QUERY);
509 addChildren( rFilterBase, *
this, pTheme, xShapes, pShapeMap, aTransformation );
516 this->
getChildren()[
i]->getShapeProperties().getProperty(PROP_URL) >>= sURL;
519 Reference<XShape> xChild = this->
getChildren()[
i]->getXShape();
520 aURLShapes.push_back({ sURL, xChild });
537 if (!sURL.isEmpty() && !xShapes.is())
538 aURLShapes.push_back({ sURL, xShape });
540 if (!aURLShapes.empty())
542 for (
auto const& URLShape : aURLShapes)
544 Reference<XEventsSupplier> xEventsSupplier(URLShape.second, UNO_QUERY);
545 if (!xEventsSupplier.is())
548 Reference<XNameReplace> xEvents(xEventsSupplier->getEvents());
552 OUString sAPIEventName;
553 sal_Int32 nPropertyCount = 2;
554 css::presentation::ClickAction meClickAction;
557 std::map<OUString, css::presentation::ClickAction> ActionMap = {
558 {
"#action?jump=nextslide", ClickAction_NEXTPAGE },
559 {
"#action?jump=previousslide", ClickAction_PREVPAGE },
560 {
"#action?jump=firstslide", ClickAction_FIRSTPAGE },
561 {
"#action?jump=lastslide", ClickAction_LASTPAGE },
562 {
"#action?jump=endshow", ClickAction_STOPPRESENTATION },
565 sURL = URLShape.first;
566 std::map<OUString, css::presentation::ClickAction>::const_iterator aIt
567 = ActionMap.find(sURL);
568 aIt != ActionMap.end() ? meClickAction = aIt->second
569 : meClickAction = ClickAction_BOOKMARK;
573 if (meClickAction == ClickAction_BOOKMARK)
575 if (!sURL.startsWith(
"#"))
576 meClickAction = ClickAction_DOCUMENT;
579 sURL = OUString::Concat(
"page")
580 + sURL.subView(sURL.lastIndexOf(
' ') + 1);
586 beans::PropertyValue* pProperties =
aProperties.getArray();
588 pProperties->Name =
"EventType";
589 pProperties->Handle = -1;
590 pProperties->Value <<= OUString(
"Presentation");
591 pProperties->State = beans::PropertyState_DIRECT_VALUE;
594 pProperties->Name =
"ClickAction";
595 pProperties->Handle = -1;
596 pProperties->Value <<= meClickAction;
597 pProperties->State = beans::PropertyState_DIRECT_VALUE;
600 switch (meClickAction)
602 case ClickAction_BOOKMARK:
603 case ClickAction_DOCUMENT:
604 pProperties->Name =
"Bookmark";
605 pProperties->Handle = -1;
606 pProperties->Value <<= sURL;
607 pProperties->State = beans::PropertyState_DIRECT_VALUE;
613 sAPIEventName =
"OnClick";
643 const std::optional< sal_Int32 >& oSubTypeIndex, std::vector< oox::drawingml::ShapePtr >& rShapes,
bool bMasterOnly )
653 void add(
const oox::drawingml::ShapePtr& aShape, sal_Int32 nFirstSubType, sal_Int32 nSecondSubType,
const std::optional< sal_Int32 >& oSubTypeIndex)
659 const bool bSameFirstSubType = aShape->getSubType() == nFirstSubType;
660 const bool bSameSecondSubType = aShape->getSubType() == nSecondSubType;
661 const bool bSameIndex = aShape->getSubTypeIndex() == oSubTypeIndex;
665 if (bSameIndex && bSameFirstSubType)
667 else if (!bSameIndex && bSameFirstSubType)
669 else if (bSameIndex && bSameSecondSubType)
671 else if (!bSameIndex && bSameSecondSubType)
677 if (aPrioIndex != -1)
679 if (!aChoice.at(aPrioIndex))
681 aChoice.at(aPrioIndex) = aShape;
700 bool hasByPrio(
size_t aIndex)
const
702 return bool(aChoice.at(
aIndex));
706 std::vector< oox::drawingml::ShapePtr > aChoice;
711 std::vector< oox::drawingml::ShapePtr >::reverse_iterator aRevIter( rShapes.rbegin() );
712 for (; aRevIter != rShapes.rend(); ++aRevIter)
715 if (!bMasterOnly || ShapeLocationIsMaster((*aRevIter).get()))
718 aPlaceholders.add(aShape, nFirstSubType, nSecondSubType, oSubTypeIndex);
722 std::vector< oox::drawingml::ShapePtr >& rChildren = (*aRevIter)->getChildren();
723 if (!rChildren.empty())
728 aPlaceholders.add(aShape, nFirstSubType, nSecondSubType, oSubTypeIndex);
732 if (aPlaceholders.hasByPrio(0))
739 return aPlaceholders.getByPrio();
746 std::vector< oox::drawingml::ShapePtr >::reverse_iterator aRevIter( rShapes.rbegin() );
747 while( aRevIter != rShapes.rend() )
749 if ( (*aRevIter)->getSubTypeIndex().has_value() && (*aRevIter)->getSubTypeIndex().value() == nIdx &&
750 ( !bMasterOnly || ShapeLocationIsMaster((*aRevIter).get()) ) )
752 aShapePtr = *aRevIter;
755 std::vector< oox::drawingml::ShapePtr >& rChildren = (*aRevIter)->getChildren();
PropertiesInfo aProperties
constexpr OUStringLiteral sServiceName
css::uno::Any getProperty(sal_Int32 nPropId)
const css::uno::Reference< css::frame::XModel > & getModel() const
Returns the document model (always existing).
void setDiagramFontHeights(NamedShapePairs *pDiagramFontHeights)
NamedShapePairs * getDiagramFontHeights()
FrameType meFrameType
Type for graphic frame shapes.
PropertyMap & getShapeProperties()
void setSize(css::awt::Size aSize)
std::vector< ShapePtr > & getChildren()
void propagateDiagramHelper()
const std::optional< sal_Int32 > & getSubTypeIndex() const
void setMasterTextListStyle(const TextListStylePtr &pMasterTextListStyle)
@ FRAMETYPE_DIAGRAM
Complex diagram drawing shape.
void addChildren(::oox::core::XmlFilterBase &rFilterBase, Shape &rMaster, const Theme *pTheme, const css::uno::Reference< css::drawing::XShapes > &rxShapes, ShapeIdMap *pShapeMap, const basegfx::B2DHomMatrix &aTransformation)
sal_Int32 getSubType() const
css::awt::Point maPosition
TextListStylePtr mpMasterTextListStyle
void keepDiagramCompatibilityInfo()
CustomShapePropertiesPtr mpCustomShapePropertiesPtr
FillProperties & getFillProperties()
void setPosition(css::awt::Point nPosition)
const TextBodyPtr & getTextBody() const
css::uno::Reference< css::drawing::XShape > const & createAndInsert(::oox::core::XmlFilterBase &rFilterBase, const OUString &rServiceName, const Theme *pTheme, const css::uno::Reference< css::drawing::XShapes > &rxShapes, bool bClearText, bool bDoNotInsertEmptyTextBody, basegfx::B2DHomMatrix &aTransformation, const FillProperties &rShapeOrParentShapeFillProps, oox::drawingml::ShapePtr pParentGroupShape=nullptr)
css::uno::Reference< css::drawing::XShape > mxShape
bool hasShapeStyleRefs() const
static SvxDateFormat getLODateFormat(std::u16string_view rDateTimeType)
Gets the corresponding LO Date format for given OOXML datetime field type.
const OUString & getType() const
static SvxTimeFormat getLOTimeFormat(std::u16string_view rDateTimeType)
Gets the corresponding LO Time format for given OOXML datetime field type.
static oox::drawingml::ShapePtr findPlaceholder(const sal_Int32 nFirstSubType, const sal_Int32 nSecondSubType, const std::optional< sal_Int32 > &oSubTypeIndex, std::vector< oox::drawingml::ShapePtr > &rShapes, bool bMasterOnly=false)
bool hasNonInheritedShapeProperties() const
Returns whether or not the shape had a non-empty spPr tag.
void addShape(oox::core::XmlFilterBase &rFilterBase, const SlidePersist &rPersist, const oox::drawingml::Theme *pTheme, const css::uno::Reference< css::drawing::XShapes > &rxShapes, basegfx::B2DHomMatrix &aTransformation, ::oox::drawingml::ShapeIdMap *pShapeMap)
PPTShape(const oox::ppt::ShapeLocation eShapeLocation, const char *pServiceType)
ShapeLocation getShapeLocation() const
static oox::drawingml::TextListStylePtr getSubTypeTextListStyle(const SlidePersist &rSlidePersist, sal_Int32 nSubType)
virtual ~PPTShape() override
static oox::drawingml::ShapePtr findPlaceholderByIndex(const sal_Int32 nIdx, std::vector< oox::drawingml::ShapePtr > &rShapes, bool bMasterOnly=false)
bool IsPlaceHolderCandidate(const SlidePersist &rSlidePersist) const
ShapeLocation meShapeLocation
oox::drawingml::ShapePtr mpPlaceholder
const oox::drawingml::TextListStylePtr & getOtherTextStyle() const
const oox::drawingml::TextListStylePtr & getBodyTextStyle() const
const css::uno::Reference< css::drawing::XDrawPage > & getPage() const
const oox::drawingml::TextListStylePtr & getTitleTextStyle() const
const oox::drawingml::TextListStylePtr & getNotesTextStyle() const
const oox::drawingml::TextListStylePtr & getDefaultTextStyle() const
const SlidePersistPtr & getMasterPersist() const
const oox::drawingml::ShapePtr & getShapes() const
std::deque< AttacherIndex_Impl > aIndex
#define SAL_INFO(area, stream)
std::map< OUString, ShapePairs > NamedShapePairs
std::shared_ptr< Shape > ShapePtr
std::shared_ptr< TextRun > TextRunPtr
::std::map< OUString, ShapePtr > ShapeIdMap
std::shared_ptr< TextListStyle > TextListStylePtr
static const char * lclDebugSubType(sal_Int32 nType)