summaryrefslogtreecommitdiff
path: root/xmloff/source
diff options
context:
space:
mode:
Diffstat (limited to 'xmloff/source')
-rw-r--r--xmloff/source/draw/sdxmlimp.cxx2
-rw-r--r--xmloff/source/draw/sdxmlimp_impl.hxx5
-rw-r--r--xmloff/source/draw/ximpbody.cxx2
-rw-r--r--xmloff/source/draw/ximppage.cxx21
-rw-r--r--xmloff/source/draw/ximppage.hxx4
-rw-r--r--xmloff/source/draw/ximpstyl.cxx149
-rw-r--r--xmloff/source/draw/ximpstyl.hxx8
7 files changed, 153 insertions, 38 deletions
diff --git a/xmloff/source/draw/sdxmlimp.cxx b/xmloff/source/draw/sdxmlimp.cxx
index f8ec3a1b3aca..2cf82579f078 100644
--- a/xmloff/source/draw/sdxmlimp.cxx
+++ b/xmloff/source/draw/sdxmlimp.cxx
@@ -338,7 +338,7 @@ void SAL_CALL SdXMLImport::setTargetDocument( const uno::Reference< lang::XCompo
// prepare access to master pages
uno::Reference < drawing::XMasterPagesSupplier > xMasterPagesSupplier(GetModel(), uno::UNO_QUERY);
if(xMasterPagesSupplier.is())
- mxDocMasterPages = xMasterPagesSupplier->getMasterPages();
+ mxDocMasterPages.set(xMasterPagesSupplier->getMasterPages(), uno::UNO_QUERY_THROW);
// prepare access to draw pages
uno::Reference <drawing::XDrawPagesSupplier> xDrawPagesSupplier(GetModel(), uno::UNO_QUERY);
diff --git a/xmloff/source/draw/sdxmlimp_impl.hxx b/xmloff/source/draw/sdxmlimp_impl.hxx
index 60641601a93f..212e65c01c16 100644
--- a/xmloff/source/draw/sdxmlimp_impl.hxx
+++ b/xmloff/source/draw/sdxmlimp_impl.hxx
@@ -20,6 +20,7 @@
#pragma once
#include <com/sun/star/drawing/XDrawPage.hpp>
+#include <com/sun/star/drawing/XDrawPages2.hpp>
#include <com/sun/star/task/XStatusIndicator.hpp>
#include <xmloff/xmltkmap.hxx>
#include <com/sun/star/container/XNameAccess.hpp>
@@ -48,7 +49,7 @@ typedef std::map<OUString, DateTimeDeclContextImpl> DateTimeDeclMap;
class SdXMLImport: public SvXMLImport
{
css::uno::Reference< css::container::XNameAccess > mxDocStyleFamilies;
- css::uno::Reference< css::container::XIndexAccess > mxDocMasterPages;
+ css::uno::Reference< css::drawing::XDrawPages2 > mxDocMasterPages;
css::uno::Reference< css::container::XIndexAccess > mxDocDrawPages;
css::uno::Reference< css::container::XNameAccess > mxPageLayouts;
@@ -103,7 +104,7 @@ public:
// export local parameters concerning page access and similar
const css::uno::Reference< css::container::XNameAccess >& GetLocalDocStyleFamilies() const { return mxDocStyleFamilies; }
- const css::uno::Reference< css::container::XIndexAccess >& GetLocalMasterPages() const { return mxDocMasterPages; }
+ const css::uno::Reference< css::drawing::XDrawPages2 >& GetLocalMasterPages() const { return mxDocMasterPages; }
const css::uno::Reference< css::container::XIndexAccess >& GetLocalDrawPages() const { return mxDocDrawPages; }
sal_Int32 GetNewPageCount() const { return mnNewPageCount; }
diff --git a/xmloff/source/draw/ximpbody.cxx b/xmloff/source/draw/ximpbody.cxx
index 38664f6c121d..f1f19a156ffa 100644
--- a/xmloff/source/draw/ximpbody.cxx
+++ b/xmloff/source/draw/ximpbody.cxx
@@ -144,7 +144,7 @@ SdXMLDrawPageContext::SdXMLDrawPageContext( SdXMLImport& rImport,
// because of content/style file split. Now the mechanism is to
// compare the wanted masterpage-name with the existing masterpages
// which were loaded and created in the styles section loading.
- uno::Reference< drawing::XDrawPages > xMasterPages(GetSdImport().GetLocalMasterPages(), uno::UNO_QUERY);
+ uno::Reference< drawing::XDrawPages2 > xMasterPages(GetSdImport().GetLocalMasterPages());
uno::Reference < drawing::XMasterPageTarget > xDrawPage(rShapes, uno::UNO_QUERY);
uno::Reference< drawing::XDrawPage > xMasterPage;
diff --git a/xmloff/source/draw/ximppage.cxx b/xmloff/source/draw/ximppage.cxx
index cb1ded1de477..8a9a69a63b66 100644
--- a/xmloff/source/draw/ximppage.cxx
+++ b/xmloff/source/draw/ximppage.cxx
@@ -229,6 +229,27 @@ SdXMLGenericPageContext::SdXMLGenericPageContext(
}
}
+SdXMLGenericPageContext::SdXMLGenericPageContext(
+ SvXMLImport& rImport,
+ const Reference< xml::sax::XFastAttributeList>& xAttrList)
+: SvXMLImportContext( rImport )
+{
+ for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ))
+ {
+ if( aIter.getToken() == XML_ELEMENT(DRAW, XML_NAV_ORDER) )
+ {
+ msNavOrder = aIter.toString();
+ break;
+ }
+ }
+}
+
+void SdXMLGenericPageContext::SetShapes(Reference< drawing::XShapes > const & rShapes)
+{
+ mxShapes = rShapes;
+ mxAnnotationAccess.set( rShapes, UNO_QUERY );
+}
+
SdXMLGenericPageContext::~SdXMLGenericPageContext()
{
}
diff --git a/xmloff/source/draw/ximppage.hxx b/xmloff/source/draw/ximppage.hxx
index 5303458dd112..0073e8a12035 100644
--- a/xmloff/source/draw/ximppage.hxx
+++ b/xmloff/source/draw/ximppage.hxx
@@ -56,11 +56,15 @@ protected:
void SetNavigationOrder();
+ void SetShapes(css::uno::Reference< css::drawing::XShapes > const & rShapes);
+
public:
SdXMLGenericPageContext( SvXMLImport& rImport,
const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
css::uno::Reference< css::drawing::XShapes > const & rShapes);
+ SdXMLGenericPageContext( SvXMLImport& rImport,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList);
virtual ~SdXMLGenericPageContext() override;
virtual void SAL_CALL startFastElement( sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
diff --git a/xmloff/source/draw/ximpstyl.cxx b/xmloff/source/draw/ximpstyl.cxx
index 82f9160c2e69..2014ea5aec8c 100644
--- a/xmloff/source/draw/ximpstyl.cxx
+++ b/xmloff/source/draw/ximpstyl.cxx
@@ -681,6 +681,7 @@ SdXMLPresentationPlaceholderContext::~SdXMLPresentationPlaceholderContext()
}
+// Only called for handout master
SdXMLMasterPageContext::SdXMLMasterPageContext(
SdXMLImport& rImport,
sal_Int32 nElement,
@@ -688,7 +689,7 @@ SdXMLMasterPageContext::SdXMLMasterPageContext(
uno::Reference< drawing::XShapes > const & rShapes)
: SdXMLGenericPageContext( rImport, xAttrList, rShapes )
{
- const bool bHandoutMaster = (nElement & TOKEN_MASK) == XML_HANDOUT_MASTER;
+ assert((nElement & TOKEN_MASK) == XML_HANDOUT_MASTER); (void)nElement;
OUString sStyleName, sPageMasterName;
for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ))
@@ -748,14 +749,111 @@ SdXMLMasterPageContext::SdXMLMasterPageContext(
GetImport().GetShapeImport()->startPage( GetLocalShapesContext() );
- // set page name?
- if(!bHandoutMaster && !msDisplayName.isEmpty() && GetLocalShapesContext().is())
+ // set page-master?
+ if(!sPageMasterName.isEmpty())
{
- uno::Reference < container::XNamed > xNamed(GetLocalShapesContext(), uno::UNO_QUERY);
- if(xNamed.is())
- xNamed->setName(msDisplayName);
+ SetPageMaster( sPageMasterName );
}
+ SetStyle( sStyleName );
+
+ SetLayout();
+
+ DeleteAllShapes();
+}
+
+// only called for normal master pages
+SdXMLMasterPageContext::SdXMLMasterPageContext(
+ SdXMLImport& rImport,
+ sal_Int32 nElement,
+ const uno::Reference< xml::sax::XFastAttributeList>& xAttrList,
+ uno::Reference< drawing::XDrawPages2 > const & xMasterPages)
+: SdXMLGenericPageContext( rImport, xAttrList )
+{
+ assert((nElement & TOKEN_MASK) != XML_HANDOUT_MASTER); (void)nElement;
+ OUString sStyleName, sPageMasterName;
+
+ for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ))
+ {
+ const OUString sValue = aIter.toString();
+ switch(aIter.getToken())
+ {
+ case XML_ELEMENT(STYLE, XML_NAME):
+ {
+ msName = sValue;
+ break;
+ }
+ case XML_ELEMENT(STYLE, XML_DISPLAY_NAME):
+ {
+ msDisplayName = sValue;
+ break;
+ }
+ case XML_ELEMENT(STYLE, XML_PAGE_LAYOUT_NAME):
+ {
+ sPageMasterName = sValue;
+ break;
+ }
+ case XML_ELEMENT(DRAW, XML_STYLE_NAME):
+ {
+ sStyleName = sValue;
+ break;
+ }
+ case XML_ELEMENT(PRESENTATION, XML_PRESENTATION_PAGE_LAYOUT_NAME):
+ {
+ maPageLayoutName = sValue;
+ break;
+ }
+ case XML_ELEMENT(PRESENTATION, XML_USE_HEADER_NAME):
+ {
+ maUseHeaderDeclName = sValue;
+ break;
+ }
+ case XML_ELEMENT(PRESENTATION, XML_USE_FOOTER_NAME):
+ {
+ maUseFooterDeclName = sValue;
+ break;
+ }
+ case XML_ELEMENT(PRESENTATION, XML_USE_DATE_TIME_NAME):
+ {
+ maUseDateTimeDeclName = sValue;
+ break;
+ }
+ default:
+ XMLOFF_WARN_UNKNOWN("xmloff", aIter);
+ }
+ }
+
+ if( msDisplayName.isEmpty() )
+ msDisplayName = msName;
+ else if( msDisplayName != msName )
+ GetImport().AddStyleDisplayName( XmlStyleFamily::MASTER_PAGE, msName, msDisplayName );
+
+ sal_Int32 nNewMasterPageCount = GetSdImport().GetNewMasterPageCount();
+ sal_Int32 nMasterPageCount = xMasterPages->getCount();
+ uno::Reference< drawing::XDrawPage > xNewMasterPage;
+ if (nNewMasterPageCount + 1 > nMasterPageCount)
+ {
+ // new page, create and insert
+ xNewMasterPage = xMasterPages->insertNamedNewByIndex(nMasterPageCount, msDisplayName);
+ SetShapes(xNewMasterPage);
+ }
+ else
+ {
+ // existing page, use it
+ xMasterPages->getByIndex(nNewMasterPageCount) >>= xNewMasterPage;
+ SetShapes(xNewMasterPage);
+ if(!msDisplayName.isEmpty())
+ {
+ uno::Reference < container::XNamed > xNamed(xNewMasterPage, uno::UNO_QUERY);
+ if(xNamed.is())
+ xNamed->setName(msDisplayName);
+ }
+ }
+ // increment global import page counter
+ GetSdImport().IncrementNewMasterPageCount();
+
+ GetImport().GetShapeImport()->startPage( GetLocalShapesContext() );
+
// set page-master?
if(!sPageMasterName.isEmpty())
{
@@ -1323,41 +1421,24 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLMasterStylesConte
else if( nElement == XML_ELEMENT(STYLE, XML_MASTER_PAGE) )
{
// style:masterpage inside office:styles context
- uno::Reference< drawing::XDrawPage > xNewMasterPage;
- uno::Reference< drawing::XDrawPages > xMasterPages(GetSdImport().GetLocalMasterPages(), uno::UNO_QUERY);
+ uno::Reference< drawing::XDrawPages2 > xMasterPages(GetSdImport().GetLocalMasterPages());
if( xMasterPages.is() )
{
- sal_Int32 nNewMasterPageCount = GetSdImport().GetNewMasterPageCount();
sal_Int32 nMasterPageCount = xMasterPages->getCount();
- if (nNewMasterPageCount + 1 > nMasterPageCount)
- {
- // arbitrary limit to master pages when fuzzing to avoid deadend timeouts
- if (nMasterPageCount >= 64 && comphelper::IsFuzzing())
- return nullptr;
+ // arbitrary limit to master pages when fuzzing to avoid deadend timeouts
+ if (nMasterPageCount >= 64 && comphelper::IsFuzzing())
+ return nullptr;
- // new page, create and insert
- xNewMasterPage = xMasterPages->insertNewByIndex(nMasterPageCount);
- }
- else
- {
- // existing page, use it
- xMasterPages->getByIndex(nNewMasterPageCount) >>= xNewMasterPage;
- }
-
- // increment global import page counter
- GetSdImport().IncrementNewMasterPageCount();
+ // new page, create and insert
- if(xNewMasterPage.is())
+ if(GetSdImport().GetShapeImport()->GetStylesContext())
{
- if(GetSdImport().GetShapeImport()->GetStylesContext())
- {
- const rtl::Reference<SdXMLMasterPageContext> xLclContext{
- new SdXMLMasterPageContext(GetSdImport(),
- nElement, xAttrList, xNewMasterPage)};
- maMasterPageList.push_back(xLclContext);
- return xLclContext;
- }
+ const rtl::Reference<SdXMLMasterPageContext> xLclContext{
+ new SdXMLMasterPageContext(GetSdImport(),
+ nElement, xAttrList, xMasterPages)};
+ maMasterPageList.push_back(xLclContext);
+ return xLclContext;
}
}
}
diff --git a/xmloff/source/draw/ximpstyl.hxx b/xmloff/source/draw/ximpstyl.hxx
index 115bf2bcb5b5..1a89cc83bffa 100644
--- a/xmloff/source/draw/ximpstyl.hxx
+++ b/xmloff/source/draw/ximpstyl.hxx
@@ -27,6 +27,7 @@
#include "ximppage.hxx"
#include <xmloff/xmlstyle.hxx>
#include <com/sun/star/view/PaperOrientation.hpp>
+#include <com/sun/star/drawing/XDrawPages2.hpp>
#include <memory>
#include <vector>
@@ -93,6 +94,13 @@ class SdXMLMasterPageContext: public SdXMLGenericPageContext
public:
+ // called for normal master page
+ SdXMLMasterPageContext(
+ SdXMLImport& rImport,
+ sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList,
+ css::uno::Reference< css::drawing::XDrawPages2 > const & xMasterPages);
+ // Called for handout master page
SdXMLMasterPageContext(
SdXMLImport& rImport,
sal_Int32 nElement,