summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drawinglayer/inc/drawinglayer/primitive2d/textlayoutdevice.hxx7
-rw-r--r--drawinglayer/source/primitive2d/graphicprimitive2d.cxx25
-rw-r--r--drawinglayer/source/primitive2d/metafileprimitive2d.cxx73
-rw-r--r--drawinglayer/source/primitive2d/textlayoutdevice.cxx10
-rw-r--r--drawinglayer/source/processor2d/vclprocessor2d.cxx25
5 files changed, 108 insertions, 32 deletions
diff --git a/drawinglayer/inc/drawinglayer/primitive2d/textlayoutdevice.hxx b/drawinglayer/inc/drawinglayer/primitive2d/textlayoutdevice.hxx
index f454459211df..f3de43c22fd7 100644
--- a/drawinglayer/inc/drawinglayer/primitive2d/textlayoutdevice.hxx
+++ b/drawinglayer/inc/drawinglayer/primitive2d/textlayoutdevice.hxx
@@ -49,6 +49,7 @@ class VirtualDevice;
class Font;
class String;
class OutputDevice;
+class GDIMetaFile;
namespace drawinglayer { namespace attribute {
class FontAttribute;
@@ -117,6 +118,12 @@ namespace drawinglayer
double getFontAscent() const;
double getFontDescent() const;
+
+ void addTextRectActions(
+ const Rectangle& rRectangle,
+ const String& rText,
+ sal_uInt16 nStyle,
+ GDIMetaFile& rGDIMetaFile);
};
} // end of namespace primitive2d
} // end of namespace drawinglayer
diff --git a/drawinglayer/source/primitive2d/graphicprimitive2d.cxx b/drawinglayer/source/primitive2d/graphicprimitive2d.cxx
index d7d3929a7a56..d224aca16709 100644
--- a/drawinglayer/source/primitive2d/graphicprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/graphicprimitive2d.cxx
@@ -56,6 +56,15 @@
#include <vcl/svapp.hxx>
//////////////////////////////////////////////////////////////////////////////
+// includes for testing MetafilePrimitive2D::create2DDecomposition
+
+#ifdef DBG_UTIL
+#include <vcl/gradient.hxx>
+#include <vcl/pngread.hxx>
+#include <vcl/lineinfo.hxx>
+#endif // DBG_UTIL
+
+//////////////////////////////////////////////////////////////////////////////
namespace
{
@@ -207,10 +216,6 @@ namespace
//////////////////////////////////////////////////////////////////////////////
-#include <vcl/gradient.hxx>
-#include <vcl/pngread.hxx>
-#include <vcl/lineinfo.hxx>
-
namespace drawinglayer
{
namespace primitive2d
@@ -297,11 +302,17 @@ namespace drawinglayer
case GRAPHIC_GDIMETAFILE :
{
- // create MetafilePrimitive2D
+#ifdef DBG_UTIL
static bool bDoTest(false);
if(bDoTest)
{
+ // All this is/was test code for testing MetafilePrimitive2D::create2DDecomposition
+ // extensively. It may be needed again when diverse actions need debugging, so i leave
+ // it in here, but take it out using DBG_UTIL.
+ // Use it by compiling with the code, insert any DrawObject, convert to Metafile. The
+ // debugger will then stop here (when breakpoint set, of course). You may enter single
+ // parts of actions and/or change to true what You want to check.
GDIMetaFile aMtf;
VirtualDevice aOut;
const basegfx::B2DRange aRange(getB2DRange(rViewInformation));
@@ -729,6 +740,8 @@ namespace drawinglayer
}
else
{
+#endif // DBG_UTIL
+ // create MetafilePrimitive2D
const Graphic aGraphic(getGraphicObject().GetGraphic());
const GDIMetaFile& rMetafile = aTransformedGraphic.GetGDIMetaFile();
@@ -760,7 +773,9 @@ namespace drawinglayer
basegfx::B2DPolyPolygon(aMaskPolygon),
aChildContent));
}
+#ifdef DBG_UTIL
}
+#endif // DBG_UTIL
break;
}
diff --git a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx
index e618093a7457..94e642d06469 100644
--- a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx
@@ -1994,9 +1994,53 @@ namespace
}
case META_TEXTRECT_ACTION :
{
- /** NEEDS IMPLEMENTATION */
- OSL_ENSURE(false, "META_TEXTRECT_ACTION requested (!)");
- // const MetaTextRectAction* pA = (const MetaTextRectAction*)pAction;
+ /** CHECKED, WORKS WELL */
+ // OSL_ENSURE(false, "META_TEXTRECT_ACTION requested (!)");
+ const MetaTextRectAction* pA = (const MetaTextRectAction*)pAction;
+ const Rectangle& rRectangle = pA->GetRect();
+
+ if(!rRectangle.IsEmpty() && 0 != pA->GetText().Len())
+ {
+ // The problem with this action is that it describes unlayouted text
+ // and the layout capabilities are in EditEngine/Outliner in SVX. The
+ // same problem is true for VCL which internally has implementations
+ // to layout text in this case. There exists even a call
+ // OutputDevice::AddTextRectActions(...) to create the needed actions
+ // as 'sub-content' of a Metafile. Unfortunately i do not have an
+ // OutputDevice here since this interpreter tries to work without
+ // VCL AFAP.
+ // Since AddTextRectActions is the only way as long as we do not have
+ // a simple text layouter available, i will try to add it to the
+ // TextLayouterDevice isloation.
+ drawinglayer::primitive2d::TextLayouterDevice aTextLayouterDevice;
+ aTextLayouterDevice.setFont(rPropertyHolders.Current().getFont());
+ GDIMetaFile aGDIMetaFile;
+
+ aTextLayouterDevice.addTextRectActions(
+ rRectangle, pA->GetText(), pA->GetStyle(), aGDIMetaFile);
+
+ if(aGDIMetaFile.GetActionCount())
+ {
+ // cerate sub-content
+ drawinglayer::primitive2d::Primitive2DSequence xSubContent;
+ {
+ rTargetHolders.Push();
+ interpretMetafile(aGDIMetaFile, rTargetHolders, rPropertyHolders, rViewInformation);
+ xSubContent = rTargetHolders.Current().getPrimitive2DSequence(rPropertyHolders.Current());
+ rTargetHolders.Pop();
+ }
+
+ if(xSubContent.hasElements())
+ {
+ // add with transformation
+ rTargetHolders.Current().append(
+ new drawinglayer::primitive2d::TransformPrimitive2D(
+ rPropertyHolders.Current().getTransformation(),
+ xSubContent));
+ }
+ }
+ }
+
break;
}
case META_BMP_ACTION :
@@ -2557,22 +2601,12 @@ namespace
// case. A height needs to be guessed (similar to OutputDevice::ImplNewFont())
Font aCorrectedFont(pA->GetFont());
- if(aFontSize.Width())
- {
- // guess width
- aFontSize = Size(0, aFontSize.Width() * 3);
- }
- else
- {
- // guess 21 pixel
- aFontSize = Size(0, 21);
- }
+ // guess 16 pixel (as in VCL)
+ aFontSize = Size(0, 16);
- if(aFontSize.Height() < 75)
- {
- // assume size is in pixels and convert
- aFontSize = Application::GetDefaultDevice()->PixelToLogic(aFontSize, MAP_100TH_MM);
- }
+ // convert to target MapUnit if not pixels
+ aFontSize = Application::GetDefaultDevice()->LogicToLogic(
+ aFontSize, MAP_PIXEL, rPropertyHolders.Current().getMapUnit());
aCorrectedFont.SetSize(aFontSize);
rPropertyHolders.Current().setFont(aCorrectedFont);
@@ -2969,6 +3003,9 @@ namespace drawinglayer
TargetHolders aTargetHolders;
PropertyHolders aPropertyHolders;
+ // set target MapUnit at Properties
+ aPropertyHolders.Current().setMapUnit(getMetaFile().GetPrefMapMode().GetMapUnit());
+
// interpret the Metafile
interpretMetafile(getMetaFile(), aTargetHolders, aPropertyHolders, rViewInformation);
diff --git a/drawinglayer/source/primitive2d/textlayoutdevice.cxx b/drawinglayer/source/primitive2d/textlayoutdevice.cxx
index f24398a1a6ac..2950427d6b57 100644
--- a/drawinglayer/source/primitive2d/textlayoutdevice.cxx
+++ b/drawinglayer/source/primitive2d/textlayoutdevice.cxx
@@ -309,6 +309,16 @@ namespace drawinglayer
const ::FontMetric& rMetric = mrDevice.GetFontMetric();
return rMetric.GetDescent();
}
+
+ void TextLayouterDevice::addTextRectActions(
+ const Rectangle& rRectangle,
+ const String& rText,
+ sal_uInt16 nStyle,
+ GDIMetaFile& rGDIMetaFile)
+ {
+ mrDevice.AddTextRectActions(
+ rRectangle, rText, nStyle, rGDIMetaFile);
+ }
} // end of namespace primitive2d
} // end of namespace drawinglayer
diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx
index 40f3eebcc78b..9def01619286 100644
--- a/drawinglayer/source/processor2d/vclprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx
@@ -1235,13 +1235,13 @@ namespace drawinglayer
{
// The new decomposition of Metafiles made it necessary to add an Eps
// primitive to handle embedded Eps data. On some devices, this can be
- // painted directly (mac, printer). Printer is handled in the
- // VclMetafileProcessor2D by not decomposing the Metafiles at all.
- // For Mac, the Eps should be painted directly, but unfortunately cannot
- // be tested (only in the salgdi layer where true/false is returned).
- // To risk nothing currently, always render it using VCL
+ // painted directly (mac, printer).
+ // To be able to handle the replacement correctly, i need to handle it myself
+ // since DrawEPS will not be able e.g. to rotate the replacement. To be able
+ // to do that, i added a boolean return to OutputDevice::DrawEPS(..)
+ // to know when EPS was handled directly already.
basegfx::B2DRange aRange(0.0, 0.0, 1.0, 1.0);
- aRange.transform(rEpsPrimitive2D.getEpsTransform());
+ aRange.transform(maCurrentTransformation * rEpsPrimitive2D.getEpsTransform());
if(!aRange.isEmpty())
{
@@ -1251,12 +1251,19 @@ namespace drawinglayer
if(!aRectangle.IsEmpty())
{
- const GDIMetaFile& rMetafile = rEpsPrimitive2D.getMetaFile();
- mpOutputDevice->DrawEPS(
+ // try to paint EPS directly without fallback visualisation
+ const bool bEPSPaintedDirectly(mpOutputDevice->DrawEPS(
aRectangle.TopLeft(),
aRectangle.GetSize(),
rEpsPrimitive2D.getGfxLink(),
- rMetafile.GetActionCount() ? const_cast<GDIMetaFile*>(&rMetafile) : 0);
+ 0));
+
+ if(!bEPSPaintedDirectly)
+ {
+ // use the decomposition which will correctly handle the
+ // fallback visualisation using full transformation (e.g. rotation)
+ process(rEpsPrimitive2D.get2DDecomposition(getViewInformation2D()));
+ }
}
}
}