sc/source/filter/xml/xmlstyle.cxx | 24 ++++++++++ sc/source/filter/xml/xmlstyle.hxx | 7 +++ sc/source/filter/xml/xmlstyli.cxx | 83 ++++++++++++++++++++++++++++++++++++++ sc/source/ui/unoobj/cellsuno.cxx | 2 sc/source/ui/unoobj/styleuno.cxx | 1 xmloff/inc/xmloff/xmlprcon.hxx | 2 xmloff/inc/xmloff/xmltoken.hxx | 1 xmloff/source/core/xmltoken.cxx | 1 8 files changed, 119 insertions(+), 2 deletions(-)
New commits: commit 066bdb31f7ff801b7a36c79c43ecbd527ffb2a88 Author: Noel Power <noel.po...@suse.com> Date: Fri Jan 11 09:52:39 2013 +0000 support saving/loading hyperlink cell attribute in extended odf style:table-cell-properties has new child element style:hyperlink which will store the hyperlink info in attributes xlink:href & xlink:type Change-Id: I184310d124c4242cd62fdabb45f9773094cfc229 diff --git a/sc/source/filter/xml/xmlstyle.cxx b/sc/source/filter/xml/xmlstyle.cxx index a40e833..e81a173 100644 --- a/sc/source/filter/xml/xmlstyle.cxx +++ b/sc/source/filter/xml/xmlstyle.cxx @@ -79,6 +79,7 @@ const XMLPropertyMapEntry aXMLScCellStylesProperties[] = MAP( "HoriJustify", XML_NAMESPACE_FO, XML_TEXT_ALIGN, XML_TYPE_PROP_PARAGRAPH|XML_SC_TYPE_HORIJUSTIFY|MID_FLAG_MERGE_PROPERTY, 0 ), MAP( "HoriJustify", XML_NAMESPACE_STYLE, XML_TEXT_ALIGN_SOURCE, XML_TYPE_PROP_TABLE_CELL|XML_SC_TYPE_HORIJUSTIFYSOURCE|MID_FLAG_MERGE_PROPERTY, 0 ), MAP( "HoriJustify", XML_NAMESPACE_STYLE, XML_REPEAT_CONTENT, XML_TYPE_PROP_TABLE_CELL|XML_SC_TYPE_HORIJUSTIFYREPEAT|MID_FLAG_MERGE_PROPERTY, 0 ), + MAP_EXT( SC_UNONAME_HYPERLINK, XML_NAMESPACE_STYLE, XML_HYPERLINK, XML_TYPE_PROP_TABLE_CELL | XML_TYPE_STRING | MID_FLAG_ELEMENT_ITEM, CTF_SC_HYPERLINK ), MAP_EXT( SC_UNONAME_CELLHJUS_METHOD, XML_NAMESPACE_CSS3TEXT, XML_TEXT_JUSTIFY, XML_TYPE_PROP_PARAGRAPH|XML_SC_TYPE_HORIJUSTIFY_METHOD, 0 ), MAP( "IsCellBackgroundTransparent", XML_NAMESPACE_FO, XML_BACKGROUND_COLOR, XML_TYPE_PROP_TABLE_CELL|XML_TYPE_ISTRANSPARENT|MID_FLAG_MULTI_PROPERTY|MID_FLAG_MERGE_ATTRIBUTE, 0 ), MAP( "IsTextWrapped", XML_NAMESPACE_FO, XML_WRAP_OPTION, XML_TYPE_PROP_TABLE_CELL|XML_SC_ISTEXTWRAPPED, 0 ), @@ -107,7 +108,6 @@ const XMLPropertyMapEntry aXMLScCellStylesProperties[] = MAP( "ValidationXML", XML_NAMESPACE_TABLE, XML_CONTENT_VALIDATION, XML_TYPE_PROP_TABLE_CELL|XML_TYPE_BUILDIN_CMP_ONLY, CTF_SC_VALIDATION ), MAP( "VertJustify", XML_NAMESPACE_STYLE, XML_VERTICAL_ALIGN, XML_TYPE_PROP_TABLE_CELL|XML_SC_TYPE_VERTJUSTIFY, 0), MAP_EXT( SC_UNONAME_CELLVJUS_METHOD, XML_NAMESPACE_STYLE, XML_VERTICAL_JUSTIFY, XML_TYPE_PROP_TABLE_CELL|XML_SC_TYPE_VERTJUSTIFY_METHOD, 0 ), - MAP_END() }; @@ -520,6 +520,28 @@ void ScXMLCellExportPropertyMapper::handleSpecialItem( // the SpecialItem ConditionlaFormat must not be handled by this method // the SpecialItem CharBackColor must not be handled by this method } +void ScXMLCellExportPropertyMapper::handleElementItem( + SvXMLExport& rExport, + const XMLPropertyState& rProperty, + sal_uInt16 nFlags, + const ::std::vector< XMLPropertyState > *pProperties, + sal_uInt32 nIdx ) const +{ + sal_uInt32 nContextId = getPropertySetMapper()->GetEntryContextId( rProperty.mnIndex ); + OUString sURL; + if ( ( nContextId == CTF_SC_HYPERLINK ) && + ( rProperty.maValue >>= sURL ) && + !sURL.isEmpty() ) + { + rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, sURL ); + rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, + XML_SIMPLE ); + sal_uInt32 nPropIndex = rProperty.mnIndex; + sal_uInt16 nPrefix = getPropertySetMapper()->GetEntryNameSpace( nPropIndex ); + OUString sLocalName = getPropertySetMapper()->GetEntryXMLName( nPropIndex ); + SvXMLElementExport aElem( rExport, nPrefix, sLocalName, sal_True, sal_True ); + } +} ScXMLRowExportPropertyMapper::ScXMLRowExportPropertyMapper( const UniReference< XMLPropertySetMapper >& rMapper ) diff --git a/sc/source/filter/xml/xmlstyle.hxx b/sc/source/filter/xml/xmlstyle.hxx index 85c971b..feb62e5 100644 --- a/sc/source/filter/xml/xmlstyle.hxx +++ b/sc/source/filter/xml/xmlstyle.hxx @@ -94,6 +94,7 @@ extern const XMLPropertyMapEntry aXMLScTableStylesImportProperties[]; #define CTF_SC_ISVISIBLE (XML_SC_CTF_START + 53) #define CTF_SC_MASTERPAGENAME (XML_SC_CTF_START + 53) +#define CTF_SC_HYPERLINK (XML_SC_CTF_START + 54) //ColumnStyles #define XML_SC_TYPE_BREAKBEFORE (XML_SC_TYPES_START + 50) @@ -112,6 +113,12 @@ public: ScXMLCellExportPropertyMapper( const UniReference< XMLPropertySetMapper >& rMapper ); virtual ~ScXMLCellExportPropertyMapper(); + virtual void handleElementItem( + SvXMLExport& rExport, + const XMLPropertyState& rProperty, + sal_uInt16 nFlags, + const ::std::vector< XMLPropertyState > *pProperties = 0, + sal_uInt32 nIdx = 0 ) const; /** this method is called for every item that has the MID_FLAG_SPECIAL_ITEM_EXPORT flag set */ virtual void handleSpecialItem( diff --git a/sc/source/filter/xml/xmlstyli.cxx b/sc/source/filter/xml/xmlstyli.cxx index a479283..7cca689 100644 --- a/sc/source/filter/xml/xmlstyli.cxx +++ b/sc/source/filter/xml/xmlstyli.cxx @@ -276,6 +276,75 @@ void ScXMLRowImportPropertyMapper::finished(::std::vector< XMLPropertyState >& r // don't access pointers to rProperties elements after push_back! } +class XMLTableCellPropsContext : public SvXMLPropertySetContext +{ + using SvXMLPropertySetContext::CreateChildContext; + public: + XMLTableCellPropsContext( + SvXMLImport& rImport, sal_uInt16 nPrfx, + const OUString& rLName, + const uno::Reference< xml::sax::XAttributeList >& xAttrList, + sal_uInt32 nFamily, + ::std::vector< XMLPropertyState > &rProps, + const UniReference < SvXMLImportPropertyMapper > &rMap); + + virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, + const OUString& rLocalName, + const uno::Reference< xml::sax::XAttributeList >& xAttrList, + ::std::vector< XMLPropertyState > &rProperties, + const XMLPropertyState& rProp ); +}; + +XMLTableCellPropsContext::XMLTableCellPropsContext( + SvXMLImport& rImport, sal_uInt16 nPrfx, + const OUString& rLName, + const uno::Reference< xml::sax::XAttributeList >& xAttrList, + sal_uInt32 nFamily, + ::std::vector< XMLPropertyState > &rProps, + const UniReference < SvXMLImportPropertyMapper > &rMap) + : SvXMLPropertySetContext( rImport, nPrfx, rLName, xAttrList, nFamily, + rProps, rMap ) +{ +} + +SvXMLImportContext* XMLTableCellPropsContext::CreateChildContext( sal_uInt16 nPrefix, + const OUString& rLocalName, + const uno::Reference< xml::sax::XAttributeList >& xAttrList, + ::std::vector< XMLPropertyState > &rProperties, + const XMLPropertyState& rProp ) +{ + // no need for a custom context or indeed a SvXMLTokenMap to grab just the + // single attribute ( href ) that we are interested in. + // still though, we will check namesspaces etc. + if ( ( XML_NAMESPACE_STYLE == nPrefix) && + IsXMLToken(rLocalName, XML_HYPERLINK ) ) + { + OUString sURL; + for ( int i=0; i<xAttrList->getLength(); ++i ) + { + OUString aLocalName; + OUString sName = xAttrList->getNameByIndex(i); + sal_uInt16 nPrfx = GetImport().GetNamespaceMap().GetKeyByAttrName( sName, + &aLocalName ); + if ( nPrfx == XML_NAMESPACE_XLINK ) + { + if ( IsXMLToken( aLocalName, XML_HREF ) ) + { + sURL = xAttrList->getValueByIndex(i); + break; + } + } + } + if ( !sURL.isEmpty() ) + { + XMLPropertyState aProp( rProp ); + aProp.maValue <<= sURL; + rProperties.push_back( aProp ); + } + } + return SvXMLPropertySetContext::CreateChildContext( nPrefix, rLocalName, xAttrList, rProperties, rProp ); +} + class ScXMLMapContext : public SvXMLImportContext { rtl::OUString msApplyStyle; @@ -407,6 +476,20 @@ SvXMLImportContext *XMLTableStyleContext::CreateChildContext( pContext = pMapContext; mpCondFormat->AddEntry(pMapContext->CreateConditionEntry()); } + else if ( ( XML_NAMESPACE_STYLE == nPrefix) && + IsXMLToken(rLocalName, XML_TABLE_CELL_PROPERTIES ) ) + { + UniReference < SvXMLImportPropertyMapper > xImpPrMap = + ((SvXMLStylesContext *)GetStyles())->GetImportPropertyMapper( + GetFamily() ); + if( xImpPrMap.is() ) + pContext = new XMLTableCellPropsContext( GetImport(), nPrefix, + rLocalName, xAttrList, + XML_TYPE_PROP_TABLE_CELL, + GetProperties(), + xImpPrMap ); + } + if (!pContext) pContext = XMLPropStyleContext::CreateChildContext( nPrefix, rLocalName, xAttrList ); diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 922ed13..4bd3855 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -245,6 +245,7 @@ static const SfxItemPropertySet* lcl_GetCellsPropertySet() {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, &getCppuType((sal_Int32*)0), 0, 0 }, {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, &::getCppuType((const sal_Int32*)0), 0, 0 }, {MAP_CHAR_LEN(SC_UNONAME_WRITING), ATTR_WRITINGDIR, &getCppuType((sal_Int16*)0), 0, 0 }, + {MAP_CHAR_LEN(SC_UNONAME_HYPERLINK), ATTR_HYPERLINK, &getCppuType((rtl::OUString*)0), 0, 0 }, {0,0,0,0,0,0} }; static SfxItemPropertySet aCellsPropertySet( aCellsPropertyMap_Impl ); @@ -468,6 +469,7 @@ static const SfxItemPropertySet* lcl_GetCellPropertySet() {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, &::getCppuType((const sal_Int32*)0), 0, 0 }, {MAP_CHAR_LEN(SC_UNONAME_WRITING), ATTR_WRITINGDIR, &getCppuType((sal_Int16*)0), 0, 0 }, {MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_ESCAPEMENT), EE_CHAR_ESCAPEMENT, &getCppuType((sal_Int32*)0), 0, 0 }, + {MAP_CHAR_LEN(SC_UNONAME_HYPERLINK), ATTR_HYPERLINK, &getCppuType((rtl::OUString*)0), 0, 0 }, {0,0,0,0,0,0} }; static SfxItemPropertySet aCellPropertySet( aCellPropertyMap_Impl ); diff --git a/sc/source/ui/unoobj/styleuno.cxx b/sc/source/ui/unoobj/styleuno.cxx index 6913685..9d9acf5 100644 --- a/sc/source/ui/unoobj/styleuno.cxx +++ b/sc/source/ui/unoobj/styleuno.cxx @@ -159,6 +159,7 @@ static const SfxItemPropertySet* lcl_GetCellStyleSet() {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, &::getCppuType((const sal_Int32*)0), 0, 0 }, {MAP_CHAR_LEN(SC_UNONAME_WRITING), ATTR_WRITINGDIR, &getCppuType((sal_Int16*)0), 0, 0 }, {MAP_CHAR_LEN(SC_UNONAME_HIDDEN), ATTR_HIDDEN, &getCppuType((sal_Bool*)0), 0, 0 }, + {MAP_CHAR_LEN(SC_UNONAME_HYPERLINK), ATTR_HYPERLINK, &getCppuType((rtl::OUString*)0), 0, 0 }, {0,0,0,0,0,0} }; static SfxItemPropertySet aCellStyleSet_Impl( aCellStyleMap_Impl ); diff --git a/xmloff/inc/xmloff/xmlprcon.hxx b/xmloff/inc/xmloff/xmlprcon.hxx index 7d6b13a..69b49ec 100644 --- a/xmloff/inc/xmloff/xmlprcon.hxx +++ b/xmloff/inc/xmloff/xmlprcon.hxx @@ -29,7 +29,7 @@ namespace rtl { class OUString; } class SvXMLImportPropertyMapper; -class SvXMLPropertySetContext : public SvXMLImportContext +class XMLOFF_DLLPUBLIC SvXMLPropertySetContext : public SvXMLImportContext { protected: sal_Int32 mnStartIdx; diff --git a/xmloff/inc/xmloff/xmltoken.hxx b/xmloff/inc/xmloff/xmltoken.hxx index 41acb78..1492d24 100644 --- a/xmloff/inc/xmloff/xmltoken.hxx +++ b/xmloff/inc/xmloff/xmltoken.hxx @@ -960,6 +960,7 @@ namespace xmloff { namespace token { XML_HOWPUBLISHED, XML_HREF, XML_HTML, + XML_HYPERLINK, XML_HYPERLINK_BEHAVIOUR, XML_HYPHENATE, XML_HYPHENATION_KEEP, diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index d7ebd2f..670596f 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -965,6 +965,7 @@ namespace xmloff { namespace token { TOKEN( "howpublished", XML_HOWPUBLISHED ), TOKEN( "href", XML_HREF ), TOKEN( "html", XML_HTML ), + TOKEN( "hyperlink", XML_HYPERLINK ), TOKEN( "hyperlink-behaviour", XML_HYPERLINK_BEHAVIOUR ), TOKEN( "hyphenate", XML_HYPHENATE ), TOKEN( "hyphenation-keep", XML_HYPHENATION_KEEP ), _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits