/* -*- 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 .
*/
// SdrGrafPrimitive2D without content in original size which carries all eventual attributes and texts const drawinglayer::primitive2d::Primitive2DReference xReferenceA(new drawinglayer::primitive2d::SdrGrafPrimitive2D(
rObjectMatrix,
rAttribute,
aEmptyGraphicObject,
aEmptyGraphicAttr, true));
xRetval = drawinglayer::primitive2d::Primitive2DContainer { xReferenceA };
// SdrGrafPrimitive2D with content (which is the preview graphic) scaled to smaller size and // without attributes
basegfx::B2DHomMatrix aSmallerMatrix;
// #i94431# for some reason, i forgot to take the PrefMapMode of the graphic // into account. Since EmptyPresObj's are only used in Draw/Impress, it is // safe to assume 100th mm as target.
Size aPrefSize(GetGrafObject().GetGrafPrefSize());
if (fOffsetX >= 0.0 && fOffsetY >= 0.0)
{ // create the EmptyPresObj fallback visualisation. The fallback graphic // is already provided in rGraphicObject in this case, use it
aSmallerMatrix = basegfx::utils::createScaleTranslateB2DHomMatrix(aPrefSize.getWidth(), aPrefSize.getHeight(), fOffsetX, fOffsetY);
aSmallerMatrix = basegfx::utils::createShearXRotateTranslateB2DHomMatrix(fShearX, fRotate, aTranslate)
* aSmallerMatrix;
// embed it to a ExclusiveEditViewPrimitive2D to allow to decide in // the primitive if to visualize or not const drawinglayer::primitive2d::Primitive2DReference aEmbedded( new drawinglayer::primitive2d::ExclusiveEditViewPrimitive2D(
drawinglayer::primitive2d::Primitive2DContainer { xReferenceB } ));
// SdrGrafPrimitive2D without content in original size which carries all eventual attributes and texts const drawinglayer::primitive2d::Primitive2DReference xReferenceA(new drawinglayer::primitive2d::SdrGrafPrimitive2D(
rObjectMatrix,
rAttribute,
aEmptyGraphicObject,
aEmptyGraphicAttr));
xRetval = drawinglayer::primitive2d::Primitive2DContainer { xReferenceA };
if(rAttribute.getLine().isDefault())
{ // create a surrounding frame when no linestyle given const Color aColor(Application::GetSettings().GetStyleSettings().GetShadowColor()); const basegfx::BColor aBColor(aColor.getBColor());
basegfx::B2DPolygon aOutline(basegfx::utils::createUnitPolygon());
aOutline.transform(rObjectMatrix);
xRetval.push_back( new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
std::move(aOutline),
aBColor));
}
// decompose object matrix to get single values
basegfx::B2DVector aScale, aTranslate; double fRotate, fShearX;
rObjectMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
// define a distance value, used for distance from bitmap to borders and from bitmap // to text, too (2 mm) constdouble fDistance(200.0);
xRetval.push_back( new drawinglayer::primitive2d::BitmapPrimitive2D(
aDraftBitmap,
aBitmapMatrix));
// consume bitmap size in X
aScale.setX(std::max(0.0, aScale.getX() - (fWidth + fDistance)));
aTranslate.setX(aTranslate.getX() + fWidth + fDistance);
}
}
// Build the text for the draft object
OUString aDraftText = GetGrafObject().GetFileName();
if (aDraftText.isEmpty())
{
aDraftText = GetGrafObject().GetName() + " ...";
}
if (!aDraftText.isEmpty())
{ // #i103255# Goal is to produce TextPrimitives which hold the given text as // BlockText in the available space. It would be very tricky to do // an own word wrap/line layout here. // Using SdrBlockTextPrimitive2D OTOH is critical since it internally // uses the SdrObject it references. To solve this, create a temp // SdrObject with Attributes and Text, generate a SdrBlockTextPrimitive2D // directly and immediately decompose it. After that, it is no longer // needed and can be deleted.
// create temp RectObj as TextObj and set needed attributes
rtl::Reference<SdrRectObj> pRectObj(new SdrRectObj(GetGrafObject().getSdrModelFromSdrObject(), SdrObjKind::Text));
pRectObj->NbcSetText(aDraftText);
pRectObj->SetMergedItem(SvxColorItem(COL_LIGHTRED, EE_CHAR_COLOR));
// get SdrText and OPO
SdrText* pSdrText(pRectObj->getText(0));
OutlinerParaObject* pOPO(pRectObj->GetOutlinerParaObject());
if(pSdrText && pOPO)
{ // directly use the remaining space as TextRangeTransform const basegfx::B2DHomMatrix aTextRangeTransform(basegfx::utils::createScaleShearXRotateTranslateB2DHomMatrix(
aScale, fShearX, fRotate, aTranslate));
// decompose immediately with neutral ViewInformation. This will // layout the text to more simple TextPrimitives from drawinglayer const drawinglayer::geometry::ViewInformation2D aViewInformation2D;
xBlockTextPrimitive->get2DDecomposition(xRetval, aViewInformation2D);
}
}
// we have content if graphic is not completely transparent constbool bHasContent(0 != aLocalGrafInfo.GetAlpha());
drawinglayer::attribute::SdrLineFillEffectsTextAttribute aAttribute(
drawinglayer::primitive2d::createNewSdrLineFillEffectsTextAttribute(
rItemSet,
GetGrafObject().getText(0),
bHasContent));
// take unrotated snap rect for position and size. Directly use model data, not getBoundRect() or getSnapRect() // which will use the primitive data we just create in the near future const ::basegfx::B2DRange aObjectRange = vcl::unotools::b2DRectangleFromRectangle(GetGrafObject().GetGeoRect());
// get the current, unchanged graphic object from SdrGrafObj const GraphicObject& rGraphicObject = GetGrafObject().GetGraphicObject();
if(visualisationUsesPresObj())
{ // it's an EmptyPresObj, create the SdrGrafPrimitive2D without content and another scaled one // with the content which is the placeholder graphic
rVisitor.visit(createVIP2DSForPresObj(aObjectMatrix, aAttribute));
} #ifndef IOS // Enforce swap-in for tiled rendering for now, while we have no delayed updating mechanism elseif(visualisationUsesDraft())
{ // #i102380# The graphic is swapped out. To not force a swap-in here, there is a mechanism // which shows a swapped-out-visualisation (which gets created here now) and an asynchronous // visual update mechanism for swapped-out graphics when they were loaded (see AsynchGraphicLoadingEvent // and ViewObjectContactOfGraphic implementation). Not forcing the swap-in here allows faster // (non-blocking) processing here and thus in the effect e.g. fast scrolling through pages
rVisitor.visit(createVIP2DSForDraft(aObjectMatrix, aAttribute));
} #endif else
{ // create primitive. Info: Calling the copy-constructor of GraphicObject in this // SdrGrafPrimitive2D constructor will force a full swap-in of the graphic const drawinglayer::primitive2d::Primitive2DReference xReference( new drawinglayer::primitive2d::SdrGrafPrimitive2D(
aObjectMatrix,
aAttribute,
rGraphicObject,
aLocalGrafInfo));
rVisitor.visit(xReference);
}
// always append an invisible outline for the cases where no visible content exists
rVisitor.visit(
drawinglayer::primitive2d::createHiddenGeometryPrimitives2D(
aObjectMatrix));
}
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.