fdo#62116: Be sure to convert relative URLs into absolute ones.
Just to preserve the old (and correct) behavior. Change-Id: I229e0b80097f6d70ff3023072b52576815010b15
This commit is contained in:
parent
1163783131
commit
d64b5cc1c3
6 changed files with 56 additions and 1 deletions
|
@ -39,6 +39,7 @@ DBG_NAMEEX( EE_EditTextObject )
|
|||
class SfxItemPool;
|
||||
class SfxStyleSheetPool;
|
||||
class SvxFieldItem;
|
||||
class SvxFieldData;
|
||||
|
||||
namespace editeng {
|
||||
|
||||
|
@ -99,6 +100,7 @@ public:
|
|||
|
||||
bool IsFieldObject() const;
|
||||
const SvxFieldItem* GetField() const;
|
||||
const SvxFieldData* GetFieldData(size_t nPara, size_t nPos, sal_Int32 nType) const;
|
||||
bool HasField( sal_Int32 nType = com::sun::star::text::textfield::Type::UNSPECIFIED ) const;
|
||||
|
||||
const SfxItemSet& GetParaAttribs(size_t nPara) const;
|
||||
|
|
|
@ -256,6 +256,11 @@ const SvxFieldItem* EditTextObject::GetField() const
|
|||
return mpImpl->GetField();
|
||||
}
|
||||
|
||||
const SvxFieldData* EditTextObject::GetFieldData(size_t nPara, size_t nPos, sal_Int32 nType) const
|
||||
{
|
||||
return mpImpl->GetFieldData(nPara, nPos, nType);
|
||||
}
|
||||
|
||||
bool EditTextObject::HasField( sal_Int32 nType ) const
|
||||
{
|
||||
return mpImpl->HasField(nType);
|
||||
|
@ -703,6 +708,41 @@ const SvxFieldItem* EditTextObjectImpl::GetField() const
|
|||
return 0;
|
||||
}
|
||||
|
||||
const SvxFieldData* EditTextObjectImpl::GetFieldData(size_t nPara, size_t nPos, sal_Int32 nType) const
|
||||
{
|
||||
if (nPara >= aContents.size())
|
||||
return NULL;
|
||||
|
||||
const ContentInfo& rC = aContents[nPara];
|
||||
if (nPos >= rC.aAttribs.size())
|
||||
// URL position is out-of-bound.
|
||||
return NULL;
|
||||
|
||||
ContentInfo::XEditAttributesType::const_iterator it = rC.aAttribs.begin(), itEnd = rC.aAttribs.end();
|
||||
size_t nCurPos = 0;
|
||||
for (; it != itEnd; ++it)
|
||||
{
|
||||
const XEditAttribute& rAttr = *it;
|
||||
if (rAttr.GetItem()->Which() != EE_FEATURE_FIELD)
|
||||
// Skip attributes that are not fields.
|
||||
continue;
|
||||
|
||||
const SvxFieldItem* pField = static_cast<const SvxFieldItem*>(rAttr.GetItem());
|
||||
const SvxFieldData* pFldData = pField->GetField();
|
||||
if (nType != text::textfield::Type::UNSPECIFIED && nType != pFldData->GetClassId())
|
||||
// Field type doesn't match. Skip it. UNSPECIFIED matches all field types.
|
||||
continue;
|
||||
|
||||
if (nCurPos == nPos)
|
||||
// Found it!
|
||||
return pFldData;
|
||||
|
||||
++nCurPos;
|
||||
}
|
||||
|
||||
return NULL; // field not found.
|
||||
}
|
||||
|
||||
bool EditTextObjectImpl::HasField( sal_Int32 nType ) const
|
||||
{
|
||||
size_t nParagraphs = aContents.size();
|
||||
|
|
|
@ -221,6 +221,8 @@ public:
|
|||
|
||||
bool IsFieldObject() const;
|
||||
const SvxFieldItem* GetField() const;
|
||||
const SvxFieldData* GetFieldData(size_t nPara, size_t nPos, sal_Int32 nType) const;
|
||||
|
||||
bool HasField( sal_Int32 nType = com::sun::star::text::textfield::Type::UNSPECIFIED ) const;
|
||||
|
||||
const SfxItemSet& GetParaAttribs(size_t nPara) const;
|
||||
|
|
Binary file not shown.
|
@ -48,6 +48,7 @@
|
|||
#include <editeng/brushitem.hxx>
|
||||
#include <editeng/justifyitem.hxx>
|
||||
#include <editeng/borderline.hxx>
|
||||
#include "editeng/flditem.hxx"
|
||||
#include <dbdata.hxx>
|
||||
#include "validat.hxx"
|
||||
#include "formulacell.hxx"
|
||||
|
@ -1757,6 +1758,15 @@ void ScFiltersTest::testRichTextContentODS()
|
|||
CPPUNIT_ASSERT_MESSAGE("Failed to retrieve edit text object.", pEditText);
|
||||
CPPUNIT_ASSERT_MESSAGE("Date field item not found.", pEditText->HasField(text::textfield::Type::DOCINFO_TITLE));
|
||||
|
||||
// URL for a file in the same directory. It should be converted into an absolute URL on import.
|
||||
aPos.IncRow();
|
||||
pEditText = pDoc->GetEditText(aPos);
|
||||
CPPUNIT_ASSERT_MESSAGE("Failed to retrieve edit text object.", pEditText);
|
||||
const SvxFieldData* pData = pEditText->GetFieldData(0, 0, text::textfield::Type::URL);
|
||||
CPPUNIT_ASSERT_MESSAGE("Failed to get the URL data.", pData && pData->GetClassId() == text::textfield::Type::URL);
|
||||
const SvxURLField* pURLData = static_cast<const SvxURLField*>(pData);
|
||||
CPPUNIT_ASSERT_MESSAGE("URL is not absolute with respect to the file system.", pURLData->GetURL().startsWith("file:///"));
|
||||
|
||||
xDocSh->DoClose();
|
||||
}
|
||||
|
||||
|
|
|
@ -598,7 +598,8 @@ void ScXMLTableRowCellContext::PushParagraphFieldDocTitle(const OUString& rStyle
|
|||
void ScXMLTableRowCellContext::PushParagraphFieldURL(
|
||||
const OUString& rURL, const OUString& rRep, const OUString& rStyleName)
|
||||
{
|
||||
PushParagraphField(new SvxURLField(rURL, rRep, SVXURLFORMAT_REPR), rStyleName);
|
||||
OUString aAbsURL = GetScImport().GetAbsoluteReference(rURL);
|
||||
PushParagraphField(new SvxURLField(aAbsURL, rRep, SVXURLFORMAT_REPR), rStyleName);
|
||||
}
|
||||
|
||||
void ScXMLTableRowCellContext::PushParagraphEnd()
|
||||
|
|
Loading…
Reference in a new issue