22#include <com/sun/star/frame/XModel.hpp>
23#include <com/sun/star/geometry/RealPoint2D.hpp>
24#include <com/sun/star/text/XTextCursor.hpp>
25#include <com/sun/star/util/DateTime.hpp>
26#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
27#include <com/sun/star/lang/XMultiServiceFactory.hpp>
66 DrawAnnotationContext( SvXMLImport& rImport,
const Reference< xml::sax::XFastAttributeList>& xAttrList,
const Reference< XAnnotationAccess >& xAnnotationAccess );
69 sal_Int32 nElement,
const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList )
override;
73 Reference< XAnnotation > mxAnnotation;
74 Reference< XTextCursor > mxCursor;
76 OUStringBuffer maAuthorBuffer;
77 OUStringBuffer maInitialsBuffer;
78 OUStringBuffer maDateBuffer;
83DrawAnnotationContext::DrawAnnotationContext( SvXMLImport& rImport,
const Reference< xml::sax::XFastAttributeList>& xAttrList,
const Reference< XAnnotationAccess >& xAnnotationAccess )
85, mxAnnotation( xAnnotationAccess->createAndInsertAnnotation() )
87 if( !mxAnnotation.is() )
90 RealPoint2D aPosition;
95 switch( aIter.getToken() )
101 GetImport().GetMM100UnitConverter().convertMeasureToCore(
103 aPosition.X =
static_cast<double>(
x) / 100.0;
110 GetImport().GetMM100UnitConverter().convertMeasureToCore(
112 aPosition.Y =
static_cast<double>(
y) / 100.0;
119 GetImport().GetMM100UnitConverter().convertMeasureToCore(
121 aSize.Width =
static_cast<double>(
w) / 100.0;
128 GetImport().GetMM100UnitConverter().convertMeasureToCore(
130 aSize.Height =
static_cast<double>(
h) / 100.0;
138 mxAnnotation->setPosition( aPosition );
139 mxAnnotation->setSize( aSize );
142css::uno::Reference< css::xml::sax::XFastContextHandler > DrawAnnotationContext::createFastChildContext(
144 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
146 if( mxAnnotation.is() )
163 uno::Reference< text::XText > xText( mxAnnotation->getTextRange() );
167 mxCursor = xText->createTextCursor();
169 xTxtImport->SetCursor( mxCursor );
176 auto p = GetImport().GetTextImport()->CreateTextChildContext( GetImport(), nElement, xAttrList );
186void DrawAnnotationContext::endFastElement(sal_Int32)
191 mxCursor->gotoEnd(
false );
192 mxCursor->goLeft( 1,
true );
193 mxCursor->setString(
"" );
196 GetImport().GetTextImport()->ResetCursor();
199 if( mxAnnotation.is() )
201 mxAnnotation->setAuthor( maAuthorBuffer.makeStringAndClear() );
202 mxAnnotation->setInitials( maInitialsBuffer.makeStringAndClear() );
204 util::DateTime aDateTime;
207 mxAnnotation->setDateTime(aDateTime);
209 maDateBuffer.setLength(0);
215 SvXMLImport& rImport,
216 const Reference< xml::sax::XFastAttributeList>& xAttrList,
217 Reference< drawing::XShapes >
const & rShapes)
220, mxAnnotationAccess( rShapes, UNO_QUERY )
241 GetImport().GetFormImport()->startPage( Reference< drawing::XDrawPage >::query(
mxShapes ) );
246 const Reference< xml::sax::XFastAttributeList>& xAttrList )
275 GetImport().GetShapeImport()->popGroupAndPostProcess();
284 Reference <beans::XPropertySet> xSet(
mxShapes, uno::UNO_QUERY_THROW );
285 Reference< beans::XPropertySetInfo > xInfo( xSet->getPropertySetInfo() );
289 static constexpr OUStringLiteral aStrHeaderTextProp(
u"HeaderText" );
290 if( xInfo->hasPropertyByName( aStrHeaderTextProp ) )
291 xSet->setPropertyValue( aStrHeaderTextProp,
297 static constexpr OUStringLiteral aStrFooterTextProp(
u"FooterText" );
298 if( xInfo->hasPropertyByName( aStrFooterTextProp ) )
299 xSet->setPropertyValue( aStrFooterTextProp,
305 static constexpr OUStringLiteral aStrDateTimeTextProp(
u"DateTimeText" );
306 if( xInfo->hasPropertyByName( aStrDateTimeTextProp ) )
309 OUString aDateTimeFormat;
312 xSet->setPropertyValue(
"IsDateTimeFixed",
317 xSet->setPropertyValue( aStrDateTimeTextProp,
Any( aText ) );
319 else if( !aDateTimeFormat.isEmpty() )
332 xSet->setPropertyValue(
"DateTimeFormat",
340 catch(
const uno::Exception&)
352 if(rStyleName.isEmpty())
366 Reference <beans::XPropertySet> xPropSet1(
mxShapes, uno::UNO_QUERY);
369 Reference< beans::XPropertySet > xPropSet( xPropSet1 );
370 Reference< beans::XPropertySet > xBackgroundSet;
372 static constexpr OUStringLiteral aBackground(
u"Background");
373 if( xPropSet1->getPropertySetInfo()->hasPropertyByName( aBackground ) )
375 Reference< beans::XPropertySetInfo > xInfo( xPropSet1->getPropertySetInfo() );
376 if( xInfo.is() && xInfo->hasPropertyByName( aBackground ) )
378 Reference< lang::XMultiServiceFactory > xServiceFact(
GetSdImport().GetModel(), uno::UNO_QUERY);
379 if(xServiceFact.is())
381 xBackgroundSet.set(xServiceFact->createInstance(
"com.sun.star.drawing.Background"), UNO_QUERY);
385 if( xBackgroundSet.is() )
393 if( xBackgroundSet.is() )
394 xPropSet1->setPropertyValue( aBackground,
uno::Any( xBackgroundSet ) );
400 catch (
const uno::Exception&)
412 sal_Int32
nType = -1;
422 nType = pLayout->GetTypeId();
428 Reference< container::XNameAccess > xPageLayouts(
GetSdImport().getPageLayouts() );
429 if( xPageLayouts.is() )
439 Reference <beans::XPropertySet> xPropSet(
mxShapes, uno::UNO_QUERY);
443 Reference< beans::XPropertySetInfo > xInfo( xPropSet->getPropertySetInfo() );
444 if( xInfo.is() && xInfo->hasPropertyByName(
aPropName ) )
456 Reference< drawing::XShape > xShape;
470 if (!
GetSdImport().GetShapeImport()->GetStylesContext())
486 if (!pPageMasterContext)
490 if (!xMasterPage.is())
494 Reference <beans::XPropertySet> xPropSet(xMasterPage, uno::UNO_QUERY);
497 xPropSet->setPropertyValue(
"BorderBottom",
Any(pPageMasterContext->
GetBorderBottom()));
498 xPropSet->setPropertyValue(
"BorderLeft",
Any(pPageMasterContext->
GetBorderLeft()));
499 xPropSet->setPropertyValue(
"BorderRight",
Any(pPageMasterContext->
GetBorderRight()));
500 xPropSet->setPropertyValue(
"BorderTop",
Any(pPageMasterContext->
GetBorderTop()));
501 xPropSet->setPropertyValue(
"Width",
Any(pPageMasterContext->
GetWidth()));
502 xPropSet->setPropertyValue(
"Height",
Any(pPageMasterContext->
GetHeight()));
503 xPropSet->setPropertyValue(
"Orientation",
Any(pPageMasterContext->
GetOrientation()));
509class XoNavigationOrderAccess :
public ::cppu::WeakImplHelper< XIndexAccess >
512 explicit XoNavigationOrderAccess( std::vector< Reference< XShape > >& rShapes );
515 virtual sal_Int32 SAL_CALL getCount( )
override;
516 virtual Any SAL_CALL getByIndex( sal_Int32
Index )
override;
519 virtual Type SAL_CALL getElementType( )
override;
520 virtual sal_Bool SAL_CALL hasElements( )
override;
523 std::vector< Reference< XShape > > maShapes;
528XoNavigationOrderAccess::XoNavigationOrderAccess( std::vector< Reference< XShape > >& rShapes )
530 maShapes.swap( rShapes );
534sal_Int32 SAL_CALL XoNavigationOrderAccess::getCount( )
536 return static_cast< sal_Int32
>( maShapes.size() );
539Any SAL_CALL XoNavigationOrderAccess::getByIndex( sal_Int32
Index )
542 throw IndexOutOfBoundsException();
548Type SAL_CALL XoNavigationOrderAccess::getElementType( )
553sal_Bool SAL_CALL XoNavigationOrderAccess::hasElements( )
555 return !maShapes.empty();
566 const sal_uInt32
nCount =
static_cast< sal_uInt32
>(
mxShapes->getCount() );
567 std::vector< Reference< XShape > > aShapes(
nCount );
571 std::u16string_view
sId;
582 if( !aShapes[
nIndex].is() )
584 OSL_FAIL(
"xmloff::SdXMLGenericPageContext::SetNavigationOrder(), draw:nav-order attribute incomplete!");
590 Reference< XPropertySet > xSet(
mxShapes, UNO_QUERY_THROW );
591 xSet->setPropertyValue(
"NavigationOrder",
Any( Reference< XIndexAccess >(
new XoNavigationOrderAccess( aShapes ) ) ) );
593 catch(
const uno::Exception&)
596 "unexpected exception caught while importing shape navigation order!");
Reference< XPropertySet > PropertySetMerger_CreateInstance(const Reference< XPropertySet > &rPropSet1, const Reference< XPropertySet > &rPropSet2) noexcept
SdXMLGenericPageContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes)
OUString maUseHeaderDeclName
void SetNavigationOrder()
const SdXMLImport & GetSdImport() const
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
void SetLayout()
sets the presentation layout at this page.
virtual ~SdXMLGenericPageContext() override
css::uno::Reference< css::drawing::XShapes > mxShapes
OUString maUseDateTimeDeclName
void DeleteAllShapes()
deletes all shapes on this drawing page
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
OUString maUseFooterDeclName
css::uno::Reference< css::office::XAnnotationAccess > mxAnnotationAccess
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
void SetPageMaster(OUString const &rsPageMasterName)
sets the properties from a page master style with the given name on this contexts page
const css::uno::Reference< css::drawing::XShapes > & GetLocalShapesContext() const
OUString maPageLayoutName
void SetStyle(OUString const &rStyleName)
sets the page style on this page
sal_Int32 GetDrawKey() const
const SdXMLPageMasterStyleContext * GetPageMasterStyle() const
sal_Int32 GetBorderRight() const
sal_Int32 GetBorderLeft() const
css::view::PaperOrientation GetOrientation() const
sal_Int32 GetBorderBottom() const
sal_Int32 GetHeight() const
sal_Int32 GetBorderTop() const
sal_Int32 GetWidth() const
This class deliberately does not support XWeak, to improve performance when loading large documents.
virtual void SAL_CALL endFastElement(sal_Int32 Element) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
SvXMLImport & GetImport()
virtual css::uno::Reference< XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
const SvXMLStyleContext * FindStyleChildContext(XmlStyleFamily nFamily, const OUString &rName, bool bCreateIndex=false) const
bool getNextToken(std::u16string_view &rToken)
static SvXMLShapeContext * CreateGroupChildContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes, bool bTemporaryShape=false)
Import all text into a string buffer.
const css::uno::Reference< css::uno::XInterface > & getReference(const OUString &rIdentifier) const
css::uno::Type const & get()
static bool parseDateTime(css::util::DateTime &rDateTime, std::u16string_view rString)
#define TOOLS_WARN_EXCEPTION(area, stream)
@ SD_PAGEMASTERCONTEXT_ID
@ SD_PRESENTATIONPAGELAYOUT_ID
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
Handling of tokens in XML:
#define XMLOFF_WARN_UNKNOWN_ELEMENT(area, token)
#define XMLOFF_WARN_UNKNOWN(area, rIter)
#define XML_ELEMENT(prefix, name)