/* -*- 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 .
*/
// RotGrfFlyFrame: Create a transformation that maps the range inside of itself // so that it fits, takes as much space as possible and keeps the aspect ratio if(0.0 != fRotate)
{ // Fit rotated graphic to center of available space, keeping page ratio: // Adapt scaling ratio of unit object and rotate it
aRetval.scale(1.0, rTargetRange.getHeight() / rTargetRange.getWidth());
aRetval.rotate(fRotate);
// get the range to see where we are in unit coordinates
basegfx::B2DRange aFullRange(0.0, 0.0, 1.0, 1.0);
aFullRange.transform(aRetval);
// detect needed scales in X/Y and choose the smallest for staying inside the // available space while keeping aspect ratio of the source constdouble fScaleX(rTargetRange.getWidth() / aFullRange.getWidth()); constdouble fScaleY(rTargetRange.getHeight() / aFullRange.getHeight()); constdouble fScaleMin(std::min(fScaleX, fScaleY));
// TopLeft to zero, then scale, then move to center of available space
aRetval.translate(-aFullRange.getMinX(), -aFullRange.getMinY());
aRetval.scale(fScaleMin, fScaleMin);
aRetval.translate(
rTargetRange.getCenterX() - (0.5 * fScaleMin * aFullRange.getWidth()),
rTargetRange.getCenterY() - (0.5 * fScaleMin * aFullRange.getHeight()));
} else
{ // just scale/translate needed
aRetval *= createScaleTranslateB2DHomMatrix(
rTargetRange.getRange(),
rTargetRange.getMinimum());
}
return aRetval;
}
/// special for the case to map from source range to target range
B2DHomMatrix createSourceRangeTargetRangeTransform( const B2DRange& rSourceRange, const B2DRange& rTargetRange)
{
B2DHomMatrix aRetval;
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.