/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
for(size_t a = 0; a < nCount; a++)
{
MetaAction* pAct = rMtf.GetAction(a);
if(!pAct)
{
OSL_ENSURE(false, "OOps, no action at valid position (!)");
pAct = rMtf.GetAction(0);
}
switch (pAct->GetType())
{ case MetaActionType::PIXEL : break; case MetaActionType::POINT : break; case MetaActionType::LINE : DoAction(static_cast<MetaLineAction &>(*pAct)); break; case MetaActionType::RECT : DoAction(static_cast<MetaRectAction &>(*pAct)); break; case MetaActionType::ROUNDRECT : DoAction(static_cast<MetaRoundRectAction &>(*pAct)); break; case MetaActionType::ELLIPSE : DoAction(static_cast<MetaEllipseAction &>(*pAct)); break; case MetaActionType::ARC : DoAction(static_cast<MetaArcAction &>(*pAct)); break; case MetaActionType::PIE : DoAction(static_cast<MetaPieAction &>(*pAct)); break; case MetaActionType::CHORD : DoAction(static_cast<MetaChordAction &>(*pAct)); break; case MetaActionType::POLYLINE : DoAction(static_cast<MetaPolyLineAction &>(*pAct)); break; case MetaActionType::POLYGON : DoAction(static_cast<MetaPolygonAction &>(*pAct)); break; case MetaActionType::POLYPOLYGON : DoAction(static_cast<MetaPolyPolygonAction &>(*pAct)); break; case MetaActionType::TEXT : DoAction(static_cast<MetaTextAction &>(*pAct)); break; case MetaActionType::TEXTARRAY : DoAction(static_cast<MetaTextArrayAction &>(*pAct)); break; case MetaActionType::STRETCHTEXT : DoAction(static_cast<MetaStretchTextAction &>(*pAct)); break; case MetaActionType::BMP : DoAction(static_cast<MetaBmpAction &>(*pAct)); break; case MetaActionType::BMPSCALE : DoAction(static_cast<MetaBmpScaleAction &>(*pAct)); break; case MetaActionType::BMPEX : DoAction(static_cast<MetaBmpExAction &>(*pAct)); break; case MetaActionType::BMPEXSCALE : DoAction(static_cast<MetaBmpExScaleAction &>(*pAct)); break; case MetaActionType::LINECOLOR : DoAction(static_cast<MetaLineColorAction &>(*pAct)); break; case MetaActionType::FILLCOLOR : DoAction(static_cast<MetaFillColorAction &>(*pAct)); break; case MetaActionType::TEXTCOLOR : DoAction(static_cast<MetaTextColorAction &>(*pAct)); break; case MetaActionType::TEXTFILLCOLOR : DoAction(static_cast<MetaTextFillColorAction &>(*pAct)); break; case MetaActionType::FONT : DoAction(static_cast<MetaFontAction &>(*pAct)); break; case MetaActionType::TEXTALIGN : DoAction(static_cast<MetaTextAlignAction &>(*pAct)); break; case MetaActionType::MAPMODE : DoAction(static_cast<MetaMapModeAction &>(*pAct)); break; case MetaActionType::CLIPREGION : DoAction(static_cast<MetaClipRegionAction &>(*pAct)); break; case MetaActionType::MOVECLIPREGION : DoAction(static_cast<MetaMoveClipRegionAction &>(*pAct)); break; case MetaActionType::ISECTRECTCLIPREGION: DoAction(static_cast<MetaISectRectClipRegionAction&>(*pAct)); break; case MetaActionType::ISECTREGIONCLIPREGION: DoAction(static_cast<MetaISectRegionClipRegionAction&>(*pAct)); break; case MetaActionType::RASTEROP : DoAction(static_cast<MetaRasterOpAction &>(*pAct)); break; case MetaActionType::PUSH : DoAction(static_cast<MetaPushAction &>(*pAct)); break; case MetaActionType::POP : DoAction(static_cast<MetaPopAction &>(*pAct)); break; case MetaActionType::HATCH : DoAction(static_cast<MetaHatchAction &>(*pAct)); break;
// #i125211# MetaCommentAction may change index, thus hand it over case MetaActionType::COMMENT : DoAction(static_cast<MetaCommentAction&>(*pAct), rMtf, a); break;
// missing actions added case MetaActionType::TEXTRECT : DoAction(static_cast<MetaTextRectAction&>(*pAct)); break; case MetaActionType::BMPSCALEPART : DoAction(static_cast<MetaBmpScalePartAction&>(*pAct)); break; case MetaActionType::BMPEXSCALEPART : DoAction(static_cast<MetaBmpExScalePartAction&>(*pAct)); break; case MetaActionType::MASK : DoAction(static_cast<MetaMaskAction&>(*pAct)); break; case MetaActionType::MASKSCALE : DoAction(static_cast<MetaMaskScaleAction&>(*pAct)); break; case MetaActionType::MASKSCALEPART : DoAction(static_cast<MetaMaskScalePartAction&>(*pAct)); break; case MetaActionType::GRADIENT : DoAction(static_cast<MetaGradientAction&>(*pAct)); break; case MetaActionType::WALLPAPER : OSL_ENSURE(false, "Tried to construct SdrObject from MetaWallpaperAction: not supported (!)"); break; case MetaActionType::Transparent : DoAction(static_cast<MetaTransparentAction&>(*pAct)); break; case MetaActionType::EPS : OSL_ENSURE(false, "Tried to construct SdrObject from MetaEPSAction: not supported (!)"); break; case MetaActionType::REFPOINT : DoAction(static_cast<MetaRefPointAction&>(*pAct)); break; case MetaActionType::TEXTLINECOLOR : DoAction(static_cast<MetaTextLineColorAction&>(*pAct)); break; case MetaActionType::TEXTLINE : OSL_ENSURE(false, "Tried to construct SdrObject from MetaTextLineAction: not supported (!)"); break; case MetaActionType::FLOATTRANSPARENT : DoAction(static_cast<MetaFloatTransparentAction&>(*pAct)); break; case MetaActionType::GRADIENTEX : DoAction(static_cast<MetaGradientExAction&>(*pAct)); break; case MetaActionType::LAYOUTMODE : DoAction(static_cast<MetaLayoutModeAction&>(*pAct)); break; case MetaActionType::TEXTLANGUAGE : DoAction(static_cast<MetaTextLanguageAction&>(*pAct)); break; case MetaActionType::OVERLINECOLOR : DoAction(static_cast<MetaOverlineColorAction&>(*pAct)); break; default: break;
}
// To calculate the progress meter, we use GetActionSize()*3. // However, maTmpList has a lower entry count limit than GetActionSize(), // so the actions that were assumed were too much have to be re-added.
nActionsToReport = (rMtf.GetActionSize() - maTmpList.size()) * 2;
// announce all currently unannounced rescales if(pProgrInfo)
{
pProgrInfo->ReportRescales(nActionsToReport);
pProgrInfo->SetInsertCount(maTmpList.size());
}
nActionsToReport = 0;
// insert all objects cached in aTmpList now into rOL from nInsPos
nInsPos = std::min(nInsPos, rOL.GetObjCount());
switch(maLineJoin)
{ case basegfx::B2DLineJoin::NONE:
mpLineAttr->Put(XLineJointItem(css::drawing::LineJoint_NONE)); break; case basegfx::B2DLineJoin::Bevel:
mpLineAttr->Put(XLineJointItem(css::drawing::LineJoint_BEVEL)); break; case basegfx::B2DLineJoin::Miter:
mpLineAttr->Put(XLineJointItem(css::drawing::LineJoint_MITER)); break; case basegfx::B2DLineJoin::Round:
mpLineAttr->Put(XLineJointItem(css::drawing::LineJoint_ROUND)); break;
}
// Add LineCap support
mpLineAttr->Put(XLineCapItem(maLineCap));
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());
// when the clip is a rectangle fast check for inside is possible if(basegfx::utils::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
rtl::Reference<SdrObject> pConverted = pSdrTextObj->ConvertToPolyObj(true, true);
pObj.clear();
if(pConverted)
{ // recursively add created conversion; per definition this shall not // contain further SdrTextObjs. Visit only non-group objects
SdrObjListIter aIter(*pConverted, SdrIterMode::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 && dynamic_cast< SdrObjGroup* >(pCandidate) == nullptr, "SdrObjListIter with SdrIterMode::DeepNoGroups error (!)");
rtl::Reference<SdrObject> pNewClone(pCandidate->CloneSdrObject(pCandidate->getSdrModelFromSdrObject()));
if(!aBitmapEx.IsEmpty())
{ // aNewRange is inside of aOldRange and defines which part of aBitmapEx is used constdouble fScaleX(aBitmapEx.GetSizePixel().Width() / (aOldRange.getWidth() ? aOldRange.getWidth() : 1.0)); constdouble fScaleY(aBitmapEx.GetSizePixel().Height() / (aOldRange.getHeight() ? aOldRange.getHeight() : 1.0));
basegfx::B2DRange aPixel(aNewRange);
basegfx::B2DHomMatrix aTrans;
if(pGrafObj)
{ // this may be refined to check if the graphic really is visible. It // is here to ensure that graphic objects without fill, line and text // get created
bVisible = true;
}
}
void ImpSdrGDIMetaFileImport::ImportText( const Point& rPos, const OUString& rStr, const MetaAction& rAct )
{ // calc text box size, add 5% to make it fit safely
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
pGraf->SetMergedItem(XFillStyleItem(drawing::FillStyle_NONE));
InsertObj(pGraf.get());
}
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
pGraf->SetMergedItem(XFillStyleItem(drawing::FillStyle_NONE));
InsertObj(pGraf.get());
}
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
pGraf->SetMergedItem(XFillStyleItem(drawing::FillStyle_NONE));
InsertObj(pGraf.get());
}
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
pGraf->SetMergedItem(XFillStyleItem(drawing::FillStyle_NONE));
InsertObj(pGraf.get());
}
void ImpSdrGDIMetaFileImport::DoAction( MetaHatchAction const & rAct )
{ // #i73407# reformulation to use new B2DPolygon classes
basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon());
const Hatch& rHatch = rAct.GetHatch();
rtl::Reference<SdrPathObj> pPath = new SdrPathObj(
*mpModel,
SdrObjKind::Polygon,
std::move(aSource)); // #i125211# Use the ranges from the SdrObject to create a new empty SfxItemSet
SfxItemSet aHatchAttr(mpModel->GetItemPool(), pPath->GetMergedItemSet().GetRanges());
css::drawing::HatchStyle eStyle;
if (a < rMtf.GetActionSize() && rAct.GetComment().equalsIgnoreAsciiCase("XGRAD_SEQ_BEGIN"))
{ // #i125211# Check if next action is a MetaGradientExAction
MetaGradientExAction* pAct = dynamic_cast< MetaGradientExAction* >(rMtf.GetAction(a + 1));
if( pAct && pAct->GetType() == MetaActionType::GRADIENTEX )
{ // #i73407# reformulation to use new B2DPolygon classes
basegfx::B2DPolyPolygon aSource(pAct->GetPolyPolygon().getB2DPolyPolygon());
if(aSource.count())
{ if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
{ const Gradient& rGrad = pAct->GetGradient();
rtl::Reference<SdrPathObj> pPath = new SdrPathObj(
*mpModel,
SdrObjKind::Polygon,
std::move(aSource)); // #i125211# Use the ranges from the SdrObject to create a new empty SfxItemSet
SfxItemSet aGradAttr(mpModel->GetItemPool(), pPath->GetMergedItemSet().GetRanges());
basegfx::BGradient aBGradient(
basegfx::BColorStops(
rGrad.GetStartColor().getBColor(),
rGrad.GetEndColor().getBColor()));
// no need to use SetAttributes(..) here since line and fill style // need to be set individually // SetAttributes(pPath);
// switch line off; if there was one there will be a // MetaActionType::POLYLINE following creating another object
aGradAttr.Put(XLineStyleItem(drawing::LineStyle_NONE));
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
pGraf->SetMergedItem(XFillStyleItem(drawing::FillStyle_NONE));
InsertObj(pGraf.get());
}
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
pGraf->SetMergedItem(XFillStyleItem(drawing::FillStyle_NONE));
InsertObj(pGraf.get());
}
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
pGraf->SetMergedItem(XFillStyleItem(drawing::FillStyle_NONE));
InsertObj(pGraf.get());
}
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
pGraf->SetMergedItem(XFillStyleItem(drawing::FillStyle_NONE));
InsertObj(pGraf.get());
}
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
pGraf->SetMergedItem(XFillStyleItem(drawing::FillStyle_NONE));
InsertObj(pGraf.get());
}
// create and add object
rtl::Reference<SdrGrafObj> pGraf = new SdrGrafObj(
*mpModel,
aBitmapEx,
aRect);
// for MetaFloatTransparentAction, do not use SetAttributes(...) // since these metafile content is not used to draw line/fill // dependent of these setting at the device content
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
pGraf->SetMergedItem(XFillStyleItem(drawing::FillStyle_NONE));
InsertObj(pGraf.get());
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.