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;
74 Reference< XTextCursor > mxCursor;
76 OUStringBuffer maAuthorBuffer;
77 OUStringBuffer maInitialsBuffer;
78 OUStringBuffer maDateBuffer;
83 DrawAnnotationContext::DrawAnnotationContext(
SvXMLImport& rImport,
const Reference< xml::sax::XFastAttributeList>& xAttrList,
const Reference< XAnnotationAccess >& xAnnotationAccess )
85 ,
mxAnnotation( xAnnotationAccess->createAndInsertAnnotation() )
90 RealPoint2D aPosition;
95 switch( aIter.getToken() )
103 aPosition.X =
static_cast<double>(x) / 100.0;
112 aPosition.Y =
static_cast<double>(y) / 100.0;
121 aSize.Width =
static_cast<double>(w) / 100.0;
130 aSize.Height =
static_cast<double>(h) / 100.0;
142 css::uno::Reference< css::xml::sax::XFastContextHandler > DrawAnnotationContext::createFastChildContext(
144 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
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 );
186 void DrawAnnotationContext::endFastElement(sal_Int32)
191 mxCursor->gotoEnd(
false );
192 mxCursor->goLeft( 1,
true );
193 mxCursor->setString(
"" );
196 GetImport().GetTextImport()->ResetCursor();
201 mxAnnotation->setAuthor( maAuthorBuffer.makeStringAndClear() );
202 mxAnnotation->setInitials( maInitialsBuffer.makeStringAndClear() );
204 util::DateTime aDateTime;
206 maDateBuffer.makeStringAndClear()))
216 const Reference< xml::sax::XFastAttributeList>& xAttrList,
217 Reference< drawing::XShapes >
const & rShapes)
219 , mxShapes( rShapes )
220 , mxAnnotationAccess( rShapes, UNO_QUERY )
246 const Reference< xml::sax::XFastAttributeList>& xAttrList )
289 static const OUStringLiteral aStrHeaderTextProp(
u"HeaderText" );
290 if( xInfo->hasPropertyByName( aStrHeaderTextProp ) )
291 xSet->setPropertyValue( aStrHeaderTextProp,
297 static const OUStringLiteral aStrFooterTextProp(
u"FooterText" );
298 if( xInfo->hasPropertyByName( aStrFooterTextProp ) )
299 xSet->setPropertyValue( aStrFooterTextProp,
305 static const 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())
359 if (
const SdXMLStylesContext* pStyles = dynamic_cast<const SdXMLStylesContext *>(pContext))
364 if (
const XMLPropStyleContext* pPropStyle = dynamic_cast<const XMLPropStyleContext*>(pStyle))
372 static const OUStringLiteral aBackground(
u"Background");
373 if( xPropSet1->getPropertySetInfo()->hasPropertyByName( aBackground ) )
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;
416 if (
const SdXMLStylesContext* pStyles = dynamic_cast<const SdXMLStylesContext *>(pContext))
422 nType = pLayout->GetTypeId();
429 if( xPageLayouts.is() )
444 if( xInfo.is() && xInfo->hasPropertyByName( aPropName ) )
445 xPropSet->setPropertyValue(aPropName,
uno::Any( static_cast<sal_Int16>(nType) ) );
456 Reference< drawing::XShape > xShape;
470 if (!
GetSdImport().GetShapeImport()->GetStylesContext())
486 if (!pPageMasterContext)
490 if (!xMasterPage.is())
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()));
509 class 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;
528 XoNavigationOrderAccess::XoNavigationOrderAccess( std::vector< Reference< XShape > >& rShapes )
530 maShapes.swap( rShapes );
534 sal_Int32 SAL_CALL XoNavigationOrderAccess::getCount( )
536 return static_cast< sal_Int32
>( maShapes.size() );
539 Any SAL_CALL XoNavigationOrderAccess::getByIndex( sal_Int32
Index )
541 if( (Index < 0) || (Index > getCount()) )
542 throw IndexOutOfBoundsException();
544 return Any( maShapes[Index] );
548 Type SAL_CALL XoNavigationOrderAccess::getElementType( )
553 sal_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;
572 for( nIndex = 0; nIndex < nCount; ++nIndex )
577 aShapes[nIndex].set( rIdMapper.
getReference( OUString(sId) ), UNO_QUERY );
580 for( nIndex = 0; nIndex < nCount; ++nIndex )
582 if( !aShapes[nIndex].is() )
584 OSL_FAIL(
"xmloff::SdXMLGenericPageContext::SetNavigationOrder(), draw:nav-order attribute incomplete!");
591 xSet->setPropertyValue(
"NavigationOrder",
Any( Reference< XIndexAccess >(
new XoNavigationOrderAccess( aShapes ) ) ) );
593 catch(
const uno::Exception&)
596 "unexpected exception caught while importing shape navigation order!");
void SetLayout()
sets the presentation layout at this page.
bool convertMeasureToCore(sal_Int32 &rValue, std::u16string_view rString, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32) const
convert string to measure with meCoreMeasureUnit, using optional min and max values ...
rtl::Reference< ::xmloff::OFormLayerXMLImport > const & GetFormImport()
void SetPageMaster(OUString const &rsPageMasterName)
sets the properties from a page master style with the given name on this contexts page ...
OUString maUseHeaderDeclName
SvXMLImport & GetImport()
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 ...
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
static bool parseDateTime(css::util::DateTime &rDateTime, std::u16string_view rString)
rtl::Reference< Annotation > mxAnnotation
OUString maUseFooterDeclName
sal_Int32 GetBorderLeft() const
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
sal_Int32 GetHeight() const
const css::uno::Reference< css::uno::XInterface > & getReference(const OUString &rIdentifier) const
#define XMLOFF_WARN_UNKNOWN(area, rIter)
::comphelper::UnoInterfaceToUniqueIdentifierMapper & getInterfaceToIdentifierMapper()
sal_Int32 GetDrawKey() const
const SdXMLPageMasterStyleContext * GetPageMasterStyle() const
#define TOOLS_WARN_EXCEPTION(area, stream)
css::uno::Reference< css::drawing::XShapes > mxShapes
void DeleteAllShapes()
deletes all shapes on this drawing page
void SetNavigationOrder()
bool getNextToken(std::u16string_view &rToken)
sal_Int32 GetWidth() const
css::view::PaperOrientation GetOrientation() const
sal_Int32 GetBorderBottom() const
OUString maUseDateTimeDeclName
css::uno::Reference< css::office::XAnnotationAccess > mxAnnotationAccess
css::uno::Type const & get()
sal_Int32 GetBorderTop() const
Import all text into a string buffer.
OUString maPageLayoutName
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 ...
Handling of tokens in XML:
virtual css::uno::Reference< XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
const css::uno::Reference< css::drawing::XShapes > & GetLocalShapesContext() const
#define XML_ELEMENT(prefix, name)
const SvXMLUnitConverter & GetMM100UnitConverter() const
const SvXMLStyleContext * FindStyleChildContext(XmlStyleFamily nFamily, const OUString &rName, bool bCreateIndex=false) const
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
#define XMLOFF_WARN_UNKNOWN_ELEMENT(area, token)
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)
Reference< XPropertySet > PropertySetMerger_CreateInstance(const Reference< XPropertySet > &rPropSet1, const Reference< XPropertySet > &rPropSet2) noexcept
void SetStyle(OUString const &rStyleName)
sets the page style on this page
sal_Int32 GetBorderRight() const
SdXMLGenericPageContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes)
virtual ~SdXMLGenericPageContext() override
rtl::Reference< XMLShapeImportHelper > const & GetShapeImport()