/* -*- 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 .
*/
ContextHandlerRef Transform2DContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
{ if (mbtxXfrm)
{ // The child elements <a:off> and <a:ext> of a <dsp:txXfrm> element describe the position and // size of the text area rectangle. We cannot change the text area rectangle directly, because // currently we depend on the geometry definition of the preset. As workaround we change the // indents to move and scale the text block. The needed shifts are calculated here as moTextOff // and used in TextBodyProperties::pushTextDistances().
awt::Rectangle aPresetTextRectangle; if (!ConstructPresetTextRectangle(mrShape, aPresetTextRectangle)) return nullptr; // faulty shape or text area calculation not implemented
switch (aElementToken)
{ case A_TOKEN(off):
{ // need <a:ext> too, so only save values here. const OUString sXValue = rAttribs.getStringDefaulted(XML_x); const OUString sYValue = rAttribs.getStringDefaulted(XML_y); if (!sXValue.isEmpty() && !sYValue.isEmpty())
{
mno_txXfrmOffX = sXValue.toInt32();
mno_txXfrmOffY = sYValue.toInt32();
}
} break; case A_TOKEN(ext):
{ // Build text frame from txXfrm element
awt::Rectangle aUnrotatedTxXfrm = aPresetTextRectangle; // dummy initialize const OUString sCXValue = rAttribs.getStringDefaulted(XML_cx); const OUString sCYValue = rAttribs.getStringDefaulted(XML_cy); if (!sCXValue.isEmpty() && !sCYValue.isEmpty())
{
aUnrotatedTxXfrm.Width = sCXValue.toInt32();
aUnrotatedTxXfrm.Height = sCYValue.toInt32();
} if (mno_txXfrmOffX.has_value() && mno_txXfrmOffY.has_value())
{
aUnrotatedTxXfrm.X = mno_txXfrmOffX.value();
aUnrotatedTxXfrm.Y = mno_txXfrmOffY.value();
}
// Has the txXfrm an own rotation beyond compensation of the shape rotation? // Happens e.g. in diagram type 'Detailed Process'.
sal_Int32 nAngleDiff
= (mrShape.getRotation() + mno_txXfrmRot.value_or(0)) % 21600000; if (nAngleDiff != 0)
{ // Rectangle aUnrotatedTxXfrm rotates around its center not around text area // center from preset. We shift aUnrotatedTxXfrm so that it is at the original // position after rotation of text area rectangle from preset.
basegfx::B2DPoint aXfrmCenter(getCenter(aUnrotatedTxXfrm));
basegfx::B2DPoint aPresetCenter(getCenter(aPresetTextRectangle));
if (nOffsetLeft)
mrShape.getTextBody()->getTextProperties().moTextOffLeft
= GetCoordinate(nOffsetLeft); if (nOffsetTop)
mrShape.getTextBody()->getTextProperties().moTextOffUpper
= GetCoordinate(nOffsetTop); if (nOffsetRight)
mrShape.getTextBody()->getTextProperties().moTextOffRight
= GetCoordinate(nOffsetRight); if (nOffsetBottom)
mrShape.getTextBody()->getTextProperties().moTextOffLower
= GetCoordinate(nOffsetBottom);
}
} break;
} return nullptr;
} // end of case mbtxXfrm
switch( aElementToken )
{ case A_TOKEN( off ): // horz/vert translation
mrShape.setPosition( awt::Point( rAttribs.getInteger( XML_x, 0 ), rAttribs.getInteger( XML_y, 0 ) ) ); break; case A_TOKEN( ext ): // horz/vert size
mrShape.setSize( awt::Size( rAttribs.getInteger( XML_cx, 0 ), rAttribs.getInteger( XML_cy, 0 ) ) ); break; case A_TOKEN( chOff ): // horz/vert translation of children
mrShape.setChildPosition( awt::Point( rAttribs.getInteger( XML_x, 0 ), rAttribs.getInteger( XML_y, 0 ) ) ); break; case A_TOKEN( chExt ): // horz/vert size of children
{
sal_Int32 nChExtCx = rAttribs.getInteger(XML_cx, 0);
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.