summaryrefslogtreecommitdiff
path: root/drawinglayer/source
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@cib.de>2017-07-31 14:46:03 +0200
committerArmin Le Grand <Armin.Le.Grand@cib.de>2017-07-31 21:26:03 +0200
commitd62d07b3d29014f76c0d676c891cbafa80d0765f (patch)
tree0e5f5c4bcd2348a1ef98ad06142c0573e1c7684b /drawinglayer/source
parent22334f8a003d26c71d772a8e00fc80b7e6d2bef1 (diff)
Corrected HitTest for layouted text
For text layouted using EditEngine the HitTest in SVX is identifying Field like URLs. Thus ist is better to use the anyways more precise primitives for HitTest (rotation/shear/ mirror, ...). This was necessary since the former mechanism which used a combination of primitive-beased HitTest and then using an Outliner to get the position/content of the Field landed on different positions e.g. when the layout needed to use multiple lines for the contained URL, but there could be more cases found. Adapted the text decompositon, the primitive HitTest and the TextHirearchyFieldPrimitive2D accordingly. Change-Id: Ice559e20d02547fdcfcf9783e7cc5481706aab03 Reviewed-on: https://gerrit.libreoffice.org/40591 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
Diffstat (limited to 'drawinglayer/source')
-rw-r--r--drawinglayer/source/primitive2d/texthierarchyprimitive2d.cxx23
-rw-r--r--drawinglayer/source/processor2d/hittestprocessor2d.cxx9
-rw-r--r--drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx12
3 files changed, 38 insertions, 6 deletions
diff --git a/drawinglayer/source/primitive2d/texthierarchyprimitive2d.cxx b/drawinglayer/source/primitive2d/texthierarchyprimitive2d.cxx
index 86883e43b6cb..45fa8531bee3 100644
--- a/drawinglayer/source/primitive2d/texthierarchyprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/texthierarchyprimitive2d.cxx
@@ -95,11 +95,28 @@ namespace drawinglayer
TextHierarchyFieldPrimitive2D::TextHierarchyFieldPrimitive2D(
const Primitive2DContainer& rChildren,
const FieldType& rFieldType,
- const OUString& rString)
+ const std::vector< std::pair< OUString, OUString>>* pNameValue)
: GroupPrimitive2D(rChildren),
meType(rFieldType),
- maString(rString)
+ meNameValue()
{
+ if (nullptr != pNameValue)
+ {
+ meNameValue = *pNameValue;
+ }
+ }
+
+ OUString TextHierarchyFieldPrimitive2D::getValue(const OUString& rName) const
+ {
+ for (const std::pair< OUString, OUString >& candidate : meNameValue)
+ {
+ if (candidate.first.equals(rName))
+ {
+ return candidate.second;
+ }
+ }
+
+ return OUString();
}
bool TextHierarchyFieldPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
@@ -109,7 +126,7 @@ namespace drawinglayer
const TextHierarchyFieldPrimitive2D& rCompare = static_cast<const TextHierarchyFieldPrimitive2D&>(rPrimitive);
return (getType() == rCompare.getType()
- && getString() == rCompare.getString());
+ && getNameValue() == rCompare.getNameValue());
}
return false;
diff --git a/drawinglayer/source/processor2d/hittestprocessor2d.cxx b/drawinglayer/source/processor2d/hittestprocessor2d.cxx
index 82ccfd00b7fe..cae95d7e6a51 100644
--- a/drawinglayer/source/processor2d/hittestprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/hittestprocessor2d.cxx
@@ -45,6 +45,8 @@ namespace drawinglayer
: BaseProcessor2D(rViewInformation),
maDiscreteHitPosition(),
mfDiscreteHitTolerance(0.0),
+ maHitStack(),
+ mbCollectHitStack(false),
mbHit(false),
mbHitTextOnly(bHitTextOnly)
{
@@ -536,6 +538,13 @@ namespace drawinglayer
break;
}
}
+
+ if (getHit() && getCollectHitStack())
+ {
+ /// push candidate to HitStack to create it. This only happens when a hit is found and
+ /// creating the HitStack was requested (see collectHitStack)
+ maHitStack.append(primitive2d::Primitive2DReference(const_cast< primitive2d::BasePrimitive2D* >(&rCandidate)));
+ }
}
} // end of namespace processor2d
diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
index efe3342b7cf9..c8ec56088085 100644
--- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
@@ -977,6 +977,7 @@ namespace drawinglayer
const OString aCommentStringCommon("FIELD_SEQ_BEGIN");
const OString aCommentStringPage("FIELD_SEQ_BEGIN;PageField");
const OString aCommentStringEnd("FIELD_SEQ_END");
+ OUString aURL;
switch(rFieldPrimitive.getType())
{
@@ -992,8 +993,13 @@ namespace drawinglayer
}
case drawinglayer::primitive2d::FIELD_TYPE_URL :
{
- const OUString& rURL = rFieldPrimitive.getString();
- mpMetaFile->AddAction(new MetaCommentAction(aCommentStringCommon, 0, reinterpret_cast< const sal_uInt8* >(rURL.getStr()), 2 * rURL.getLength()));
+ aURL = rFieldPrimitive.getValue("URL");
+
+ if (!aURL.isEmpty())
+ {
+ mpMetaFile->AddAction(new MetaCommentAction(aCommentStringCommon, 0, reinterpret_cast<const sal_uInt8*>(aURL.getStr()), 2 * aURL.getLength()));
+ }
+
break;
}
}
@@ -1015,7 +1021,7 @@ namespace drawinglayer
(sal_Int32)ceil(aViewRange.getMaxX()), (sal_Int32)ceil(aViewRange.getMaxY()));
vcl::PDFExtOutDevBookmarkEntry aBookmark;
aBookmark.nLinkId = mpPDFExtOutDevData->CreateLink(aRectLogic);
- aBookmark.aBookmark = rFieldPrimitive.getString();
+ aBookmark.aBookmark = aURL;
std::vector< vcl::PDFExtOutDevBookmarkEntry >& rBookmarks = mpPDFExtOutDevData->GetBookmarks();
rBookmarks.push_back( aBookmark );
}