[Libreoffice-commits] .: xmloff/inc xmloff/source
Miklos Vajna
vmiklos at kemper.freedesktop.org
Thu Jul 5 02:40:27 PDT 2012
xmloff/inc/XMLTextHeaderFooterContext.hxx | 5 +-
xmloff/inc/xmloff/XMLTextMasterPageContext.hxx | 7 ++
xmloff/inc/xmloff/XMLTextMasterPageExport.hxx | 4 +
xmloff/inc/xmloff/txtimp.hxx | 2
xmloff/inc/xmloff/xmltoken.hxx | 2
xmloff/source/core/xmltoken.cxx | 2
xmloff/source/text/XMLTextHeaderFooterContext.cxx | 53 +++++++++++++++++-----
xmloff/source/text/XMLTextMasterPageContext.cxx | 22 +++++++--
xmloff/source/text/XMLTextMasterPageExport.cxx | 50 ++++++++++++++++++++
xmloff/source/text/txtimp.cxx | 2
10 files changed, 131 insertions(+), 18 deletions(-)
New commits:
commit 7ac60704206d229b45dd002ca3b9d70c4c64034e
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Thu Jul 5 11:37:26 2012 +0200
xmloff: implement first page header/footer import/export
Change-Id: I920c236125ae044fe66cf0eacafdfc94ef81a4fd
diff --git a/xmloff/inc/XMLTextHeaderFooterContext.hxx b/xmloff/inc/XMLTextHeaderFooterContext.hxx
index 7a7c98f..73102fc 100644
--- a/xmloff/inc/XMLTextHeaderFooterContext.hxx
+++ b/xmloff/inc/XMLTextHeaderFooterContext.hxx
@@ -36,11 +36,14 @@ class XMLTextHeaderFooterContext: public SvXMLImportContext
const ::rtl::OUString sOn;
const ::rtl::OUString sShareContent;
+ const ::rtl::OUString sShareContentFirst;
const ::rtl::OUString sText;
+ const ::rtl::OUString sTextFirst;
const ::rtl::OUString sTextLeft;
sal_Bool bInsertContent : 1;
sal_Bool bLeft : 1;
+ sal_Bool bFirst : 1;
public:
TYPEINFO();
@@ -51,7 +54,7 @@ public:
::com::sun::star::xml::sax::XAttributeList > & xAttrList,
const ::com::sun::star::uno::Reference <
::com::sun::star::beans::XPropertySet > & rPageStylePropSet,
- sal_Bool bFooter, sal_Bool bLft );
+ sal_Bool bFooter, sal_Bool bLft, sal_Bool bFrst );
virtual ~XMLTextHeaderFooterContext();
diff --git a/xmloff/inc/xmloff/XMLTextMasterPageContext.hxx b/xmloff/inc/xmloff/XMLTextMasterPageContext.hxx
index ff4898f..16ae310 100644
--- a/xmloff/inc/xmloff/XMLTextMasterPageContext.hxx
+++ b/xmloff/inc/xmloff/XMLTextMasterPageContext.hxx
@@ -43,10 +43,14 @@ class XMLOFF_DLLPUBLIC XMLTextMasterPageContext : public SvXMLStyleContext
sal_Bool bInsertFooter;
sal_Bool bInsertHeaderLeft;
sal_Bool bInsertFooterLeft;
+ sal_Bool bInsertHeaderFirst;
+ sal_Bool bInsertFooterFirst;
sal_Bool bHeaderInserted;
sal_Bool bFooterInserted;
sal_Bool bHeaderLeftInserted;
sal_Bool bFooterLeftInserted;
+ sal_Bool bHeaderFirstInserted;
+ sal_Bool bFooterFirstInserted;
SAL_DLLPRIVATE ::com::sun::star::uno::Reference <
::com::sun::star::style::XStyle > Create();
@@ -74,7 +78,8 @@ public:
const ::rtl::OUString& rLocalName,
const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
const sal_Bool bFooter,
- const sal_Bool bLeft );
+ const sal_Bool bLeft,
+ const sal_Bool bFirst );
virtual void Finish( sal_Bool bOverwrite );
};
diff --git a/xmloff/inc/xmloff/XMLTextMasterPageExport.hxx b/xmloff/inc/xmloff/XMLTextMasterPageExport.hxx
index d88b85f..02b2b6c 100644
--- a/xmloff/inc/xmloff/XMLTextMasterPageExport.hxx
+++ b/xmloff/inc/xmloff/XMLTextMasterPageExport.hxx
@@ -35,11 +35,15 @@ class XMLOFF_DLLPUBLIC XMLTextMasterPageExport : public XMLPageExport
const ::rtl::OUString sHeaderText;
const ::rtl::OUString sHeaderOn;
const ::rtl::OUString sHeaderShareContent;
+ const ::rtl::OUString sHeaderShareContentFirst;
+ const ::rtl::OUString sHeaderTextFirst;
const ::rtl::OUString sHeaderTextLeft;
const ::rtl::OUString sFooterText;
const ::rtl::OUString sFooterOn;
const ::rtl::OUString sFooterShareContent;
+ const ::rtl::OUString sFooterShareContentFirst;
+ const ::rtl::OUString sFooterTextFirst;
const ::rtl::OUString sFooterTextLeft;
protected:
diff --git a/xmloff/inc/xmloff/txtimp.hxx b/xmloff/inc/xmloff/txtimp.hxx
index f364402..f01c0ec 100644
--- a/xmloff/inc/xmloff/txtimp.hxx
+++ b/xmloff/inc/xmloff/txtimp.hxx
@@ -343,6 +343,8 @@ enum XMLTextPageMasterElemTokens
XML_TOK_TEXT_MP_FOOTER,
XML_TOK_TEXT_MP_HEADER_LEFT,
XML_TOK_TEXT_MP_FOOTER_LEFT,
+ XML_TOK_TEXT_MP_HEADER_FIRST,
+ XML_TOK_TEXT_MP_FOOTER_FIRST,
XML_TOK_TEXT_MP_END=XML_TOK_UNKNOWN
};
diff --git a/xmloff/inc/xmloff/xmltoken.hxx b/xmloff/inc/xmloff/xmltoken.hxx
index e45091e..73dcd95 100644
--- a/xmloff/inc/xmloff/xmltoken.hxx
+++ b/xmloff/inc/xmloff/xmltoken.hxx
@@ -831,6 +831,7 @@ namespace xmloff { namespace token {
XML_FONTWORK_START,
XML_FONTWORK_STYLE,
XML_FOOTER,
+ XML_FOOTER_FIRST,
XML_FOOTER_LEFT,
XML_FOOTER_STYLE,
XML_FOOTNOTE,
@@ -923,6 +924,7 @@ namespace xmloff { namespace token {
XML_HATCHSTYLE_SINGLE,
XML_HATCHSTYLE_TRIPLE,
XML_HEADER,
+ XML_HEADER_FIRST,
XML_HEADER_LEFT,
XML_HEADER_STYLE,
XML_HEADERS,
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index 875d0d9..14c3fb1 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -835,6 +835,7 @@ namespace xmloff { namespace token {
TOKEN( "fontwork-start", XML_FONTWORK_START ),
TOKEN( "fontwork-style", XML_FONTWORK_STYLE ),
TOKEN( "footer", XML_FOOTER ),
+ TOKEN( "footer-first", XML_FOOTER_FIRST ),
TOKEN( "footer-left", XML_FOOTER_LEFT ),
TOKEN( "footer-style", XML_FOOTER_STYLE ),
TOKEN( "footnote", XML_FOOTNOTE ),
@@ -927,6 +928,7 @@ namespace xmloff { namespace token {
TOKEN( "single", XML_HATCHSTYLE_SINGLE ),
TOKEN( "triple", XML_HATCHSTYLE_TRIPLE ),
TOKEN( "header", XML_HEADER ),
+ TOKEN( "header-first", XML_HEADER_FIRST ),
TOKEN( "header-left", XML_HEADER_LEFT ),
TOKEN( "header-style", XML_HEADER_STYLE ),
TOKEN( "headers", XML_HEADERS ),
diff --git a/xmloff/source/text/XMLTextHeaderFooterContext.cxx b/xmloff/source/text/XMLTextHeaderFooterContext.cxx
index 6c0c721..c69ff1e 100644
--- a/xmloff/source/text/XMLTextHeaderFooterContext.cxx
+++ b/xmloff/source/text/XMLTextHeaderFooterContext.cxx
@@ -52,19 +52,22 @@ XMLTextHeaderFooterContext::XMLTextHeaderFooterContext( SvXMLImport& rImport, sa
const uno::Reference<
xml::sax::XAttributeList > &,
const Reference < XPropertySet > & rPageStylePropSet,
- sal_Bool bFooter, sal_Bool bLft ) :
+ sal_Bool bFooter, sal_Bool bLft, sal_Bool bFrst ) :
SvXMLImportContext( rImport, nPrfx, rLName ),
xPropSet( rPageStylePropSet ),
sOn( bFooter ? OUString(RTL_CONSTASCII_USTRINGPARAM( "FooterIsOn" )) : OUString(RTL_CONSTASCII_USTRINGPARAM( "HeaderIsOn" )) ),
sShareContent( bFooter ? OUString(RTL_CONSTASCII_USTRINGPARAM( "FooterIsShared" ))
: OUString(RTL_CONSTASCII_USTRINGPARAM( "HeaderIsShared" )) ),
+ sShareContentFirst( bFooter ? OUString("FooterIsSharedFirst" ) : OUString( "HeaderIsSharedFirst" ) ),
sText( bFooter ? OUString(RTL_CONSTASCII_USTRINGPARAM( "FooterText" )) : OUString(RTL_CONSTASCII_USTRINGPARAM( "HeaderText" )) ),
+ sTextFirst(bFooter ? OUString("FooterTextFirst") : OUString("HeaderTextFirst")),
sTextLeft( bFooter ? OUString(RTL_CONSTASCII_USTRINGPARAM( "FooterTextLeft" ))
: OUString(RTL_CONSTASCII_USTRINGPARAM( "HeaderTextLeft" )) ),
bInsertContent( sal_True ),
- bLeft( bLft )
+ bLeft( bLft ),
+ bFirst( bFrst )
{
- if( bLeft )
+ if( bLeft || bFirst )
{
Any aAny;
@@ -73,14 +76,29 @@ XMLTextHeaderFooterContext::XMLTextHeaderFooterContext( SvXMLImport& rImport, sa
if( bOn )
{
- aAny = xPropSet->getPropertyValue( sShareContent );
- sal_Bool bShared = *(sal_Bool *)aAny.getValue();
- if( bShared )
+ if (bLeft)
{
- // Don't share headers any longer
- bShared = sal_False;
- aAny.setValue( &bShared, ::getBooleanCppuType() );
- xPropSet->setPropertyValue( sShareContent, aAny );
+ aAny = xPropSet->getPropertyValue( sShareContent );
+ sal_Bool bShared = *(sal_Bool *)aAny.getValue();
+ if( bShared )
+ {
+ // Don't share headers any longer
+ bShared = sal_False;
+ aAny.setValue( &bShared, ::getBooleanCppuType() );
+ xPropSet->setPropertyValue( sShareContent, aAny );
+ }
+ }
+ if (bFirst)
+ {
+ aAny = xPropSet->getPropertyValue( sShareContentFirst );
+ sal_Bool bSharedFirst = *(sal_Bool *)aAny.getValue();
+ if( bSharedFirst )
+ {
+ // Don't share first/right headers any longer
+ bSharedFirst = sal_False;
+ aAny.setValue( &bSharedFirst, ::getBooleanCppuType() );
+ xPropSet->setPropertyValue( sShareContentFirst, aAny );
+ }
}
}
else
@@ -108,11 +126,14 @@ SvXMLImportContext *XMLTextHeaderFooterContext::CreateChildContext(
{
sal_Bool bRemoveContent = sal_True;
Any aAny;
- if( bLeft )
+ if( bLeft || bFirst )
{
// Headers and footers are switched on already,
// and they aren't shared.
- aAny = xPropSet->getPropertyValue( sTextLeft );
+ if (bLeft)
+ aAny = xPropSet->getPropertyValue( sTextLeft );
+ else
+ aAny = xPropSet->getPropertyValue( sTextFirst );
}
else
{
@@ -140,6 +161,14 @@ SvXMLImportContext *XMLTextHeaderFooterContext::CreateChildContext(
aAny.setValue( &bShared, ::getBooleanCppuType() );
xPropSet->setPropertyValue( sShareContent, aAny );
}
+ aAny = xPropSet->getPropertyValue( sShareContentFirst );
+ sal_Bool bSharedFirst = *(sal_Bool *)aAny.getValue();
+ if( !bSharedFirst )
+ {
+ bSharedFirst = sal_True;
+ aAny.setValue( &bSharedFirst, ::getBooleanCppuType() );
+ xPropSet->setPropertyValue( sShareContentFirst, aAny );
+ }
aAny = xPropSet->getPropertyValue( sText );
}
diff --git a/xmloff/source/text/XMLTextMasterPageContext.cxx b/xmloff/source/text/XMLTextMasterPageContext.cxx
index 1075079..fa4d2d6 100644
--- a/xmloff/source/text/XMLTextMasterPageContext.cxx
+++ b/xmloff/source/text/XMLTextMasterPageContext.cxx
@@ -83,10 +83,14 @@ XMLTextMasterPageContext::XMLTextMasterPageContext( SvXMLImport& rImport,
, bInsertFooter( sal_False )
, bInsertHeaderLeft( sal_False )
, bInsertFooterLeft( sal_False )
+, bInsertHeaderFirst( sal_False )
+, bInsertFooterFirst( sal_False )
, bHeaderInserted( sal_False )
, bFooterInserted( sal_False )
, bHeaderLeftInserted( sal_False )
, bFooterLeftInserted( sal_False )
+, bHeaderFirstInserted( sal_False )
+, bFooterFirstInserted( sal_False )
{
OUString sName, sDisplayName;
sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
@@ -173,6 +177,7 @@ XMLTextMasterPageContext::XMLTextMasterPageContext( SvXMLImport& rImport,
bInsertHeader = bInsertFooter = sal_True;
bInsertHeaderLeft = bInsertFooterLeft = sal_True;
+ bInsertHeaderFirst = bInsertFooterFirst = sal_True;
}
}
@@ -190,7 +195,7 @@ SvXMLImportContext *XMLTextMasterPageContext::CreateChildContext(
const SvXMLTokenMap& rTokenMap =
GetImport().GetTextImport()->GetTextMasterPageElemTokenMap();
- sal_Bool bInsert = sal_False, bFooter = sal_False, bLeft = sal_False;
+ sal_Bool bInsert = sal_False, bFooter = sal_False, bLeft = sal_False, bFirst = sal_False;
switch( rTokenMap.Get( nPrefix, rLocalName ) )
{
case XML_TOK_TEXT_MP_HEADER:
@@ -215,13 +220,21 @@ SvXMLImportContext *XMLTextMasterPageContext::CreateChildContext(
if( bInsertFooterLeft && bFooterInserted && !bFooterLeftInserted )
bInsert = bFooter = bLeft = sal_True;
break;
+ case XML_TOK_TEXT_MP_HEADER_FIRST:
+ if( bInsertHeaderFirst && bHeaderInserted && !bHeaderFirstInserted )
+ bInsert = bFirst = sal_True;
+ break;
+ case XML_TOK_TEXT_MP_FOOTER_FIRST:
+ if( bInsertFooterFirst && bFooterInserted && !bFooterFirstInserted )
+ bInsert = bFooter = bFirst = sal_True;
+ break;
}
if( bInsert && xStyle.is() )
{
pContext = CreateHeaderFooterContext( nPrefix, rLocalName,
xAttrList,
- bFooter, bLeft );
+ bFooter, bLeft, bFirst );
}
else
{
@@ -237,14 +250,15 @@ SvXMLImportContext *XMLTextMasterPageContext::CreateHeaderFooterContext(
const ::rtl::OUString& rLocalName,
const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
const sal_Bool bFooter,
- const sal_Bool bLeft )
+ const sal_Bool bLeft,
+ const sal_Bool bFirst )
{
Reference < XPropertySet > xPropSet( xStyle, UNO_QUERY );
return new XMLTextHeaderFooterContext( GetImport(),
nPrefix, rLocalName,
xAttrList,
xPropSet,
- bFooter, bLeft );
+ bFooter, bLeft, bFirst );
}
void XMLTextMasterPageContext::Finish( sal_Bool bOverwrite )
diff --git a/xmloff/source/text/XMLTextMasterPageExport.cxx b/xmloff/source/text/XMLTextMasterPageExport.cxx
index 71fccc1..2e0a3fe 100644
--- a/xmloff/source/text/XMLTextMasterPageExport.cxx
+++ b/xmloff/source/text/XMLTextMasterPageExport.cxx
@@ -40,10 +40,14 @@ XMLTextMasterPageExport::XMLTextMasterPageExport( SvXMLExport& rExp ) :
sHeaderText( RTL_CONSTASCII_USTRINGPARAM( "HeaderText" ) ),
sHeaderOn( RTL_CONSTASCII_USTRINGPARAM( "HeaderIsOn" ) ),
sHeaderShareContent( RTL_CONSTASCII_USTRINGPARAM( "HeaderIsShared" ) ),
+ sHeaderShareContentFirst( "HeaderIsSharedFirst" ),
+ sHeaderTextFirst( "HeaderTextFirst" ),
sHeaderTextLeft( RTL_CONSTASCII_USTRINGPARAM( "HeaderTextLeft" ) ),
sFooterText( RTL_CONSTASCII_USTRINGPARAM( "FooterText" ) ),
sFooterOn( RTL_CONSTASCII_USTRINGPARAM( "FooterIsOn" ) ),
sFooterShareContent( RTL_CONSTASCII_USTRINGPARAM( "FooterIsShared" ) ),
+ sFooterShareContentFirst( "FooterIsSharedFirst" ),
+ sFooterTextFirst( "FooterTextFirst" ),
sFooterTextLeft( RTL_CONSTASCII_USTRINGPARAM( "FooterTextLeft" ) )
{
}
@@ -86,6 +90,10 @@ void XMLTextMasterPageExport::exportMasterPageContent(
aAny = rPropSet->getPropertyValue( sHeaderText );
aAny >>= xHeaderText;
+ Reference < XText > xHeaderTextFirst;
+ aAny = rPropSet->getPropertyValue( sHeaderTextFirst );
+ aAny >>= xHeaderTextFirst;
+
Reference < XText > xHeaderTextLeft;
aAny = rPropSet->getPropertyValue( sHeaderTextLeft );
aAny >>= xHeaderTextLeft;
@@ -94,6 +102,10 @@ void XMLTextMasterPageExport::exportMasterPageContent(
aAny = rPropSet->getPropertyValue( sFooterText );
aAny >>= xFooterText;
+ Reference < XText > xFooterTextFirst;
+ aAny = rPropSet->getPropertyValue( sFooterTextFirst );
+ aAny >>= xFooterTextFirst;
+
Reference < XText > xFooterTextLeft;
aAny = rPropSet->getPropertyValue( sFooterTextLeft );
aAny >>= xFooterTextLeft;
@@ -102,10 +114,14 @@ void XMLTextMasterPageExport::exportMasterPageContent(
{
if( xHeaderText.is() )
exportHeaderFooterContent( xHeaderText, sal_True );
+ if( xHeaderTextFirst.is() && xHeaderTextFirst != xHeaderText )
+ exportHeaderFooterContent( xHeaderTextFirst, sal_True );
if( xHeaderTextLeft.is() && xHeaderTextLeft != xHeaderText )
exportHeaderFooterContent( xHeaderTextLeft, sal_True );
if( xFooterText.is() )
exportHeaderFooterContent( xFooterText, sal_True );
+ if( xFooterTextFirst.is() && xFooterTextFirst != xFooterText )
+ exportHeaderFooterContent( xFooterTextFirst, sal_True );
if( xFooterTextLeft.is() && xFooterTextLeft != xFooterText )
exportHeaderFooterContent( xFooterTextLeft, sal_True );
}
@@ -114,6 +130,13 @@ void XMLTextMasterPageExport::exportMasterPageContent(
aAny = rPropSet->getPropertyValue( sHeaderOn );
sal_Bool bHeader = *(sal_Bool *)aAny.getValue();
+ sal_Bool bHeaderFirst = sal_False;
+ if( bHeader )
+ {
+ aAny = rPropSet->getPropertyValue( sHeaderShareContentFirst );
+ bHeaderFirst = !*(sal_Bool *)aAny.getValue();
+ }
+
sal_Bool bHeaderLeft = sal_False;
if( bHeader )
{
@@ -131,6 +154,16 @@ void XMLTextMasterPageExport::exportMasterPageContent(
exportHeaderFooterContent( xHeaderText, sal_False );
}
+ if( xHeaderTextFirst.is() && xHeaderTextFirst != xHeaderText )
+ {
+ if( !bHeaderFirst )
+ GetExport().AddAttribute( XML_NAMESPACE_STYLE,
+ XML_DISPLAY, XML_FALSE );
+ SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
+ XML_HEADER_FIRST, sal_True, sal_True );
+ exportHeaderFooterContent( xHeaderTextFirst, sal_False );
+ }
+
if( xHeaderTextLeft.is() && xHeaderTextLeft != xHeaderText )
{
if( !bHeaderLeft )
@@ -144,6 +177,13 @@ void XMLTextMasterPageExport::exportMasterPageContent(
aAny = rPropSet->getPropertyValue( sFooterOn );
sal_Bool bFooter = *(sal_Bool *)aAny.getValue();
+ sal_Bool bFooterFirst = sal_False;
+ if( bFooter )
+ {
+ aAny = rPropSet->getPropertyValue( sFooterShareContentFirst );
+ bFooterFirst = !*(sal_Bool *)aAny.getValue();
+ }
+
sal_Bool bFooterLeft = sal_False;
if( bFooter )
{
@@ -161,6 +201,16 @@ void XMLTextMasterPageExport::exportMasterPageContent(
exportHeaderFooterContent( xFooterText, sal_False );
}
+ if( xFooterTextFirst.is() && xFooterTextFirst != xFooterText )
+ {
+ if( !bFooterFirst )
+ GetExport().AddAttribute( XML_NAMESPACE_STYLE,
+ XML_DISPLAY, XML_FALSE );
+ SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
+ XML_FOOTER_FIRST, sal_True, sal_True );
+ exportHeaderFooterContent( xFooterTextFirst, sal_False );
+ }
+
if( xFooterTextLeft.is() && xFooterTextLeft != xFooterText )
{
if( !bFooterLeft )
diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx
index 1139501..d80ed05 100644
--- a/xmloff/source/text/txtimp.cxx
+++ b/xmloff/source/text/txtimp.cxx
@@ -438,6 +438,8 @@ static SvXMLTokenMapEntry aTextMasterPageElemTokenMap[] =
{ XML_NAMESPACE_STYLE, XML_FOOTER, XML_TOK_TEXT_MP_FOOTER },
{ XML_NAMESPACE_STYLE, XML_HEADER_LEFT, XML_TOK_TEXT_MP_HEADER_LEFT },
{ XML_NAMESPACE_STYLE, XML_FOOTER_LEFT, XML_TOK_TEXT_MP_FOOTER_LEFT },
+ { XML_NAMESPACE_STYLE, XML_HEADER_FIRST, XML_TOK_TEXT_MP_HEADER_FIRST },
+ { XML_NAMESPACE_STYLE, XML_FOOTER_FIRST, XML_TOK_TEXT_MP_FOOTER_FIRST },
XML_TOKEN_MAP_END
};
More information about the Libreoffice-commits
mailing list