Kaydet (Commit) 58b44ad7 authored tarafından Armin Le Grand's avatar Armin Le Grand

i122326 added text clipping, corrected text box distances

üst 10e1831a
...@@ -75,6 +75,9 @@ ...@@ -75,6 +75,9 @@
#include <svx/xflbmtit.hxx> #include <svx/xflbmtit.hxx>
#include <svx/xflbstit.hxx> #include <svx/xflbstit.hxx>
#include <svx/svdpntv.hxx> #include <svx/svdpntv.hxx>
#include <basegfx/polygon/b2dpolypolygontools.hxx>
#include <svx/svditer.hxx>
#include <svx/svdogrp.hxx>
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
...@@ -484,6 +487,72 @@ void ImpSdrGDIMetaFileImport::InsertObj(SdrObject* pObj, bool bScale) ...@@ -484,6 +487,72 @@ void ImpSdrGDIMetaFileImport::InsertObj(SdrObject* pObj, bool bScale)
const SdrLayerID aOldLayer(pObj->GetLayer()); const SdrLayerID aOldLayer(pObj->GetLayer());
const SfxItemSet aOldItemSet(pObj->GetMergedItemSet()); const SfxItemSet aOldItemSet(pObj->GetMergedItemSet());
const SdrGrafObj* pSdrGrafObj = dynamic_cast< SdrGrafObj* >(pObj); const SdrGrafObj* pSdrGrafObj = dynamic_cast< SdrGrafObj* >(pObj);
const SdrTextObj* pSdrTextObj = dynamic_cast< SdrTextObj* >(pObj);
if(pSdrTextObj && pSdrTextObj->HasText())
{
// all text objects are created from ImportText and have no line or fill attributes, so
// it is okay to concentrate on the text itself
while(true)
{
const basegfx::B2DPolyPolygon aTextContour(pSdrTextObj->TakeContour());
const basegfx::B2DRange aTextRange(aTextContour.getB2DRange());
const basegfx::B2DRange aClipRange(maClip.getB2DRange());
// no overlap -> completely outside
if(!aClipRange.overlaps(aTextRange))
{
SdrObject::Free(pObj);
break;
}
// when the clip is a rectangle fast check for inside is possible
if(basegfx::tools::isRectangle(maClip) && aClipRange.isInside(aTextRange))
{
// completely inside ClipRect
break;
}
// here text needs to be clipped; to do so, convert to SdrObjects with polygons
// and add these recursively. Delete original object, do not add in this run
SdrObject* pConverted = pSdrTextObj->ConvertToPolyObj(true, true);
SdrObject::Free(pObj);
if(pConverted)
{
// recursively add created conversion; per definition this shall not
// contain further SdrTextObjs. Visit only non-group objects
SdrObjListIter aIter(*pConverted, IM_DEEPNOGROUPS);
// work with clones; the created conversion may contain group objects
// and when working with the original objects the loop itself could
// break and the cleanup later would be pretty complicated (only delete group
// objects, are these empty, ...?)
while(aIter.IsMore())
{
SdrObject* pCandidate = aIter.Next();
OSL_ENSURE(pCandidate && 0 == dynamic_cast< SdrObjGroup* >(pCandidate), "SdrObjListIter with IM_DEEPNOGROUPS error (!)");
SdrObject* pNewClone = pCandidate->Clone();
if(pNewClone)
{
InsertObj(pNewClone, false);
}
else
{
OSL_ENSURE(false, "SdrObject::Clone() failed (!)");
}
}
// cleanup temporary conversion objects
SdrObject::Free(pConverted);
}
break;
}
}
else
{
BitmapEx aBitmapEx; BitmapEx aBitmapEx;
if(pSdrGrafObj) if(pSdrGrafObj)
...@@ -545,6 +614,7 @@ void ImpSdrGDIMetaFileImport::InsertObj(SdrObject* pObj, bool bScale) ...@@ -545,6 +614,7 @@ void ImpSdrGDIMetaFileImport::InsertObj(SdrObject* pObj, bool bScale)
} }
} }
} }
}
if(pObj) if(pObj)
{ {
...@@ -959,19 +1029,22 @@ void ImpSdrGDIMetaFileImport::ImportText( const Point& rPos, const XubString& rS ...@@ -959,19 +1029,22 @@ void ImpSdrGDIMetaFileImport::ImportText( const Point& rPos, const XubString& rS
Rectangle aTextRect( aPos, aSize ); Rectangle aTextRect( aPos, aSize );
SdrRectObj* pText =new SdrRectObj( OBJ_TEXT, aTextRect ); SdrRectObj* pText =new SdrRectObj( OBJ_TEXT, aTextRect );
pText->SetMergedItem ( SdrTextUpperDistItem (0));
pText->SetMergedItem ( SdrTextLowerDistItem (0));
pText->SetMergedItem ( SdrTextRightDistItem (0));
pText->SetMergedItem ( SdrTextLeftDistItem (0));
if ( aFnt.GetWidth() || ( rAct.GetType() == META_STRETCHTEXT_ACTION ) ) if ( aFnt.GetWidth() || ( rAct.GetType() == META_STRETCHTEXT_ACTION ) )
{ {
pText->ClearMergedItem( SDRATTR_TEXT_AUTOGROWWIDTH ); pText->ClearMergedItem( SDRATTR_TEXT_AUTOGROWWIDTH );
pText->SetMergedItem( SdrTextAutoGrowHeightItem( false ) ); pText->SetMergedItem( SdrTextAutoGrowHeightItem( false ) );
// don't let the margins eat the space needed for the text // don't let the margins eat the space needed for the text
pText->SetMergedItem ( SdrTextUpperDistItem (0));
pText->SetMergedItem ( SdrTextLowerDistItem (0));
pText->SetMergedItem ( SdrTextRightDistItem (0));
pText->SetMergedItem ( SdrTextLeftDistItem (0));
pText->SetMergedItem( SdrTextFitToSizeTypeItem( SDRTEXTFIT_ALLLINES ) ); pText->SetMergedItem( SdrTextFitToSizeTypeItem( SDRTEXTFIT_ALLLINES ) );
} }
else else
{
pText->SetMergedItem( SdrTextAutoGrowWidthItem( true ) ); pText->SetMergedItem( SdrTextAutoGrowWidthItem( true ) );
}
pText->SetModel(mpModel); pText->SetModel(mpModel);
pText->SetLayer(mnLayer); pText->SetLayer(mnLayer);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment