summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorFrank Schönheit <fs@openoffice.org>2002-11-22 13:39:17 +0000
committerFrank Schönheit <fs@openoffice.org>2002-11-22 13:39:17 +0000
commit404549ae70ddc1f2fb1d6d4eeea3dc29d7891fb0 (patch)
tree6e02115828debe8ef80e3fbe36b3e3386e901c62 /xmloff
parentf263988fa9d05d3239e861eb8c6d851d88be47de (diff)
#105340# +OURLReferenceImport for properly importing all relative URLs
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/forms/elementimport.cxx64
-rw-r--r--xmloff/source/forms/elementimport.hxx38
2 files changed, 75 insertions, 27 deletions
diff --git a/xmloff/source/forms/elementimport.cxx b/xmloff/source/forms/elementimport.cxx
index b2d5f393709a..e9b0b4b0670f 100644
--- a/xmloff/source/forms/elementimport.cxx
+++ b/xmloff/source/forms/elementimport.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: elementimport.cxx,v $
*
- * $Revision: 1.32 $
+ * $Revision: 1.33 $
*
- * last change: $Author: fs $ $Date: 2002-11-06 10:37:04 $
+ * last change: $Author: fs $ $Date: 2002-11-22 14:39:17 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -822,13 +822,50 @@ namespace xmloff
}
//=====================================================================
+ //= OURLReferenceImport
+ //=====================================================================
+ OURLReferenceImport::OURLReferenceImport(IFormsImportContext& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
+ const Reference< XNameContainer >& _rxParentContainer,
+ OControlElement::ElementType _eType)
+ :OControlImport(_rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer, _eType)
+ {
+ }
+
+ //---------------------------------------------------------------------
+ void OURLReferenceImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue)
+ {
+ static const sal_Char* s_pTargetLocationAttributeName = getCommonControlAttributeName( CCA_TARGET_LOCATION );
+ static const sal_Char* s_pImageDataAttributeName = getCommonControlAttributeName( CCA_IMAGE_DATA );
+
+ // need to make the URL absolute if
+ // * it's the image-data attribute
+ // * it's the target-location attribute, and we're dealign with an object which has the respective property
+ sal_Bool bMakeAbsolute =
+ ( 0 == _rLocalName.compareToAscii( s_pImageDataAttributeName ) )
+ || ( ( 0 == _rLocalName.compareToAscii( s_pTargetLocationAttributeName ) )
+ && ( ( OControlElement::BUTTON == m_eElementType )
+ || ( OControlElement::IMAGE == m_eElementType )
+ )
+ );
+
+ if ( bMakeAbsolute )
+ {
+ // make a global URL out of the local one
+ ::rtl::OUString sAdjustedValue = m_rContext.getGlobalContext().GetAbsoluteReference( _rValue );
+ OControlImport::handleAttribute( _nNamespaceKey, _rLocalName, sAdjustedValue );
+ }
+ else
+ OControlImport::handleAttribute( _nNamespaceKey, _rLocalName, _rValue );
+ }
+
+ //=====================================================================
//= OButtonImport
//=====================================================================
//---------------------------------------------------------------------
OButtonImport::OButtonImport(IFormsImportContext& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
const Reference< XNameContainer >& _rxParentContainer,
OControlElement::ElementType _eType)
- :OControlImport(_rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer, _eType)
+ :OURLReferenceImport(_rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer, _eType)
{
enableTrackAttributes();
}
@@ -842,21 +879,6 @@ namespace xmloff
simluateDefaultedAttribute(getCommonControlAttributeName(CCA_TARGET_FRAME), PROPERTY_TARGETFRAME, "_blank");
}
- //---------------------------------------------------------------------
- void OButtonImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue)
- {
- static const ::rtl::OUString s_sTargetLocationAttributeName = ::rtl::OUString::createFromAscii(getCommonControlAttributeName(CCA_TARGET_LOCATION));
- static const ::rtl::OUString s_sImageDataAttributeName = ::rtl::OUString::createFromAscii(getCommonControlAttributeName(CCA_IMAGE_DATA));
- if ( (s_sTargetLocationAttributeName == _rLocalName) || (s_sImageDataAttributeName == _rLocalName) )
- {
- // make a global URL out of the local one
- ::rtl::OUString sAdjustedValue = m_rContext.getGlobalContext().GetAbsoluteReference(_rValue);
- OControlImport::handleAttribute(_nNamespaceKey, _rLocalName, sAdjustedValue);
- }
- else
- OControlImport::handleAttribute(_nNamespaceKey, _rLocalName, _rValue);
- }
-
//=====================================================================
//= OTextLikeImport
//=====================================================================
@@ -1216,6 +1238,9 @@ namespace xmloff
case OControlElement::IMAGE:
return new OButtonImport(m_rFormImport, m_rEventManager, _nPrefix, _rLocalName, m_xParentContainer, _eType);
+ case OControlElement::IMAGE_FRAME:
+ return new OURLReferenceImport( m_rFormImport, m_rEventManager, _nPrefix, _rLocalName, m_xParentContainer, _eType );
+
case OControlElement::COMBOBOX:
case OControlElement::LISTBOX:
return new OListAndComboImport(m_rFormImport, m_rEventManager, _nPrefix, _rLocalName, m_xParentContainer, _eType);
@@ -1429,6 +1454,9 @@ namespace xmloff
/*************************************************************************
* history:
* $Log: not supported by cvs2svn $
+ * Revision 1.32 2002/11/06 10:37:04 fs
+ * #102407# (on behalf of BerryJia@openoffice.org) when importing a control model which can be ALIGNed, initialize this property to the XML default
+ *
* Revision 1.31 2002/10/25 13:14:15 fs
* #104402# importing grid column styles now
*
diff --git a/xmloff/source/forms/elementimport.hxx b/xmloff/source/forms/elementimport.hxx
index 53a2cdb3dc65..25f0ae4cf691 100644
--- a/xmloff/source/forms/elementimport.hxx
+++ b/xmloff/source/forms/elementimport.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: elementimport.hxx,v $
*
- * $Revision: 1.17 $
+ * $Revision: 1.18 $
*
- * last change: $Author: fs $ $Date: 2002-11-06 10:37:03 $
+ * last change: $Author: fs $ $Date: 2002-11-22 14:39:17 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -368,12 +368,34 @@ namespace xmloff
};
//=====================================================================
+ //= OURLReferenceImport
+ //=====================================================================
+ /** a specialized version of the <type>OControlImport</type> class, which is able
+ to handle attributes which denote URLs (and stored relative)
+ */
+ class OURLReferenceImport : public OControlImport
+ {
+ public:
+ OURLReferenceImport(
+ IFormsImportContext& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& _rxParentContainer,
+ OControlElement::ElementType _eType
+ );
+
+ protected:
+ // OPropertyImport overridables
+ virtual void handleAttribute(sal_uInt16 _nNamespaceKey,
+ const ::rtl::OUString& _rLocalName,
+ const ::rtl::OUString& _rValue);
+ };
+
+ //=====================================================================
//= OButtonImport
//=====================================================================
/** A specialized version of the <type>OControlImport</type> class, which handles
- some specialities of buttons and imagebuttons (namely the target frame)
+ the target frame for image and command buttons
*/
- class OButtonImport : public OControlImport
+ class OButtonImport : public OURLReferenceImport
{
public:
OButtonImport(
@@ -386,11 +408,6 @@ namespace xmloff
// SvXMLImportContext overridables
virtual void StartElement(
const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList);
-
- // OPropertyImport overridables
- virtual void handleAttribute(sal_uInt16 _nNamespaceKey,
- const ::rtl::OUString& _rLocalName,
- const ::rtl::OUString& _rValue);
};
//=====================================================================
@@ -661,6 +678,9 @@ namespace xmloff
/*************************************************************************
* history:
* $Log: not supported by cvs2svn $
+ * Revision 1.17 2002/11/06 10:37:03 fs
+ * #102407# (on behalf of BerryJia@openoffice.org) when importing a control model which can be ALIGNed, initialize this property to the XML default
+ *
* Revision 1.16 2002/10/25 13:14:15 fs
* #104402# importing grid column styles now
*