summaryrefslogtreecommitdiff
path: root/drawinglayer/source/primitive2d
diff options
context:
space:
mode:
authorArmin Weiss <aw@openoffice.org>2008-02-07 12:42:32 +0000
committerArmin Weiss <aw@openoffice.org>2008-02-07 12:42:32 +0000
commit42b6b472aef0e9a7e6496979182cfaca1c597394 (patch)
tree4e029aef69c38fed26ca96ff9f7ebb698b83c08f /drawinglayer/source/primitive2d
parent7a7c1dcb9bfb49b38b7ea6bb276c5189262773c0 (diff)
stable version from working GIT repository for unxlngi6 build
Diffstat (limited to 'drawinglayer/source/primitive2d')
-rw-r--r--drawinglayer/source/primitive2d/baseprimitive2d.cxx29
-rw-r--r--drawinglayer/source/primitive2d/makefile.mk5
-rw-r--r--drawinglayer/source/primitive2d/pagepreviewprimitive2d.cxx188
-rw-r--r--drawinglayer/source/primitive2d/sceneprimitive2d.cxx10
4 files changed, 209 insertions, 23 deletions
diff --git a/drawinglayer/source/primitive2d/baseprimitive2d.cxx b/drawinglayer/source/primitive2d/baseprimitive2d.cxx
index 230e3f6ea25e..41e530ad15e2 100644
--- a/drawinglayer/source/primitive2d/baseprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/baseprimitive2d.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: baseprimitive2d.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: aw $ $Date: 2007-01-25 12:57:55 $
+ * last change: $Author: aw $ $Date: 2008-02-07 13:41:58 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -37,14 +37,14 @@
#include <drawinglayer/primitive2d/baseprimitive2d.hxx>
#endif
-#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX
-#include <basegfx/tools/canvastools.hxx>
-#endif
-
#ifndef INCLUDED_DRAWINGLAYER_GEOMETRY_VIEWINFORMATION2D_HXX
#include <drawinglayer/geometry/viewinformation2d.hxx>
#endif
+#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX
+#include <basegfx/tools/canvastools.hxx>
+#endif
+
//////////////////////////////////////////////////////////////////////////////
using namespace com::sun::star;
@@ -89,15 +89,15 @@ namespace drawinglayer
return getLocalDecomposition();
}
- Primitive2DSequence SAL_CALL BasePrimitive2D::getDecomposition( const graphic::Primitive2DParameters& aPrimitive2DParameters ) throw ( uno::RuntimeException )
+ Primitive2DSequence SAL_CALL BasePrimitive2D::getDecomposition( const uno::Sequence< beans::PropertyValue >& rViewParameters ) throw ( uno::RuntimeException )
{
- const geometry::ViewInformation2D aViewInformation(aPrimitive2DParameters);
+ const geometry::ViewInformation2D aViewInformation(rViewParameters);
return get2DDecomposition(aViewInformation);
}
- com::sun::star::geometry::RealRectangle2D SAL_CALL BasePrimitive2D::getRange( const graphic::Primitive2DParameters& aPrimitive2DParameters ) throw ( uno::RuntimeException )
+ com::sun::star::geometry::RealRectangle2D SAL_CALL BasePrimitive2D::getRange( const uno::Sequence< beans::PropertyValue >& rViewParameters ) throw ( uno::RuntimeException )
{
- const geometry::ViewInformation2D aViewInformation(aPrimitive2DParameters);
+ const geometry::ViewInformation2D aViewInformation(rViewParameters);
return basegfx::unotools::rectangle2DFromB2DRectangle(getB2DRange(aViewInformation));
}
} // end of namespace primitive2d
@@ -128,13 +128,8 @@ namespace drawinglayer
else
{
// use UNO API call instead
- graphic::Primitive2DParameters aPrimitive2DParameters;
-
- basegfx::unotools::affineMatrixFromHomMatrix(aPrimitive2DParameters.ViewTransformation, aViewInformation.getViewTransformation());
- aPrimitive2DParameters.Viewport = basegfx::unotools::rectangle2DFromB2DRectangle(aViewInformation.getViewport());
- aPrimitive2DParameters.Time = aViewInformation.getViewTime();
-
- aRetval.expand(basegfx::unotools::b2DRectangleFromRealRectangle2D(rCandidate->getRange(aPrimitive2DParameters)));
+ const uno::Sequence< beans::PropertyValue >& rViewParameters(aViewInformation.getViewInformationSequence());
+ aRetval.expand(basegfx::unotools::b2DRectangleFromRealRectangle2D(rCandidate->getRange(rViewParameters)));
}
}
diff --git a/drawinglayer/source/primitive2d/makefile.mk b/drawinglayer/source/primitive2d/makefile.mk
index c09562ca545d..4d48233c683d 100644
--- a/drawinglayer/source/primitive2d/makefile.mk
+++ b/drawinglayer/source/primitive2d/makefile.mk
@@ -4,9 +4,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.8 $
+# $Revision: 1.9 $
#
-# last change: $Author: aw $ $Date: 2007-09-26 11:36:36 $
+# last change: $Author: aw $ $Date: 2008-02-07 13:41:58 $
#
# The Contents of this file are made available subject to
# the terms of GNU Lesser General Public License Version 2.1.
@@ -66,6 +66,7 @@ SLOFILES= \
$(SLO)$/metafileprimitive2d.obj \
$(SLO)$/modifiedcolorprimitive2d.obj \
$(SLO)$/oleprimitive2d.obj \
+ $(SLO)$/pagepreviewprimitive2d.obj \
$(SLO)$/polypolygonprimitive2d.obj \
$(SLO)$/polygonprimitive2d.obj \
$(SLO)$/sceneprimitive2d.obj \
diff --git a/drawinglayer/source/primitive2d/pagepreviewprimitive2d.cxx b/drawinglayer/source/primitive2d/pagepreviewprimitive2d.cxx
new file mode 100644
index 000000000000..78b973c52c00
--- /dev/null
+++ b/drawinglayer/source/primitive2d/pagepreviewprimitive2d.cxx
@@ -0,0 +1,188 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: pagepreviewprimitive2d.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: aw $ $Date: 2008-02-07 13:42:32 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_PAGEPREVIEWPRIMITIVE2D_HXX
+#include <drawinglayer/primitive2d/pagepreviewprimitive2d.hxx>
+#endif
+
+#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_PRIMITIVETYPES2D_HXX
+#include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
+#endif
+
+#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_MASKPRIMITIVE2D_HXX
+#include <drawinglayer/primitive2d/maskprimitive2d.hxx>
+#endif
+
+#ifndef _BGFX_POLYGON_B2DPOLYGONTOOLS_HXX
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#endif
+
+#ifndef _BGFX_POLYGON_B2DPOLYGON_HXX
+#include <basegfx/polygon/b2dpolygon.hxx>
+#endif
+
+#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_TRANSFORMPRIMITIVE2D_HXX
+#include <drawinglayer/primitive2d/transformprimitive2d.hxx>
+#endif
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ Primitive2DSequence PagePreviewPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const
+ {
+ Primitive2DSequence xRetval;
+ Primitive2DSequence aContent(getChildren());
+
+ if(aContent.hasElements())
+ {
+ // check if content overlaps with tageted size and needs to be embedded with a
+ // clipping primitive
+ const basegfx::B2DRange aRealContentRange(getB2DRangeFromPrimitive2DSequence(aContent, rViewInformation));
+ const basegfx::B2DRange aAllowedContentRange(0.0, 0.0, getContentWidth(), getContentHeight());
+
+ if(!aAllowedContentRange.isInside(aRealContentRange))
+ {
+ const Primitive2DReference xReferenceA(new MaskPrimitive2D(basegfx::B2DPolyPolygon(basegfx::tools::createPolygonFromRect(aAllowedContentRange)), aContent));
+ aContent = Primitive2DSequence(&xReferenceA, 1);
+ }
+
+ // content is not scaled or rotated and occupates aContentRange. Create a mapping
+ // to own local geometry. Create matrix describing the content by setting scaling
+ basegfx::B2DHomMatrix aPageTrans;
+ aPageTrans.set(0, 0, getContentWidth());
+ aPageTrans.set(1, 1, getContentHeight());
+
+ // decompose to access own scaling
+ basegfx::B2DVector aScale, aTranslate;
+ double fRotate, fShearX;
+ getTransform().decompose(aScale, aTranslate, fRotate, fShearX);
+
+ if(getKeepAspectRatio())
+ {
+ // look at the aspect ratio of the content and the local geometry
+ const double fRatioOwn(aScale.getX() ? (aScale.getY() / aScale.getX()) : 1.0);
+ const double fRatioContent(getContentWidth() ? (getContentHeight() / getContentWidth()) : 1.0);
+
+ // the ratios are based on different coordinate systems, so look if they differ really more
+ // than 0,1 percent
+ if(fabs(fRatioOwn - fRatioContent) > 0.001)
+ {
+ if(basegfx::fTools::more(fRatioOwn, fRatioContent))
+ {
+ // vertically center the page by translating
+ const double fFullY(aScale.getX() ? (aScale.getY() * getContentWidth()) / aScale.getX() : 0.0);
+ const double fTransY((fFullY - getContentHeight()) * 0.5);
+ aPageTrans.set(1, 2, fTransY);
+ }
+ else
+ {
+ // horizontally center the page by translating
+ const double fFullX(aScale.getY() ? (aScale.getX() * getContentHeight()) / aScale.getY() : 0.0);
+ const double fTransX((fFullX - getContentWidth()) * 0.5);
+ aPageTrans.set(0, 2, fTransX);
+ }
+ }
+ }
+
+ // create composed transformation from content to local geometry. An
+ // eventually needed clipping is already added, so directly go to local coordinates
+ basegfx::B2DHomMatrix aPageToObject(aPageTrans);
+ aPageToObject.invert();
+ aPageToObject *= getTransform();
+
+ // embed in necessary transformation to map from SdrPage to SdrPageObject
+ const Primitive2DReference xReferenceB(new TransformPrimitive2D(aPageToObject, aContent));
+ xRetval = Primitive2DSequence(&xReferenceB, 1);
+ }
+
+ return xRetval;
+ }
+
+ PagePreviewPrimitive2D::PagePreviewPrimitive2D(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& rxDrawPage,
+ const basegfx::B2DHomMatrix& rTransform,
+ double fContentWidth,
+ double fContentHeight,
+ const Primitive2DSequence& rChildren,
+ bool bKeepAspectRatio)
+ : GroupPrimitive2D(rChildren),
+ mxDrawPage(rxDrawPage),
+ maTransform(rTransform),
+ mfContentWidth(fContentWidth),
+ mfContentHeight(fContentHeight),
+ mbKeepAspectRatio(bKeepAspectRatio)
+ {
+ }
+
+ bool PagePreviewPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(GroupPrimitive2D::operator==(rPrimitive))
+ {
+ const PagePreviewPrimitive2D& rCompare = static_cast< const PagePreviewPrimitive2D& >(rPrimitive);
+
+ return (getXDrawPage() == rCompare.getXDrawPage()
+ && getTransform() == rCompare.getTransform()
+ && getContentWidth() == rCompare.getContentWidth()
+ && getContentHeight() == rCompare.getContentHeight()
+ && getKeepAspectRatio() == rCompare.getKeepAspectRatio());
+ }
+
+ return false;
+ }
+
+ basegfx::B2DRange PagePreviewPrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation`*/) const
+ {
+ // nothing is allowed to stick out of a PagePreviewPrimitive, thus we
+ // can quickly deliver our range here
+ basegfx::B2DRange aRetval(0.0, 0.0, 1.0, 1.0);
+ aRetval.transform(getTransform());
+ return aRetval;
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(PagePreviewPrimitive2D, PRIMITIVE2D_ID_PAGEPREVIEWPRIMITIVE2D)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
diff --git a/drawinglayer/source/primitive2d/sceneprimitive2d.cxx b/drawinglayer/source/primitive2d/sceneprimitive2d.cxx
index c3db747847c7..063705323137 100644
--- a/drawinglayer/source/primitive2d/sceneprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/sceneprimitive2d.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: sceneprimitive2d.cxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: aw $ $Date: 2008-01-30 12:25:05 $
+ * last change: $Author: aw $ $Date: 2008-02-07 13:41:58 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -113,8 +113,9 @@ namespace drawinglayer
{
// test visibility
const basegfx::B2DRange aShadow2DRange(getB2DRangeFromPrimitive2DSequence(maShadowPrimitives, rViewInformation));
+ const basegfx::B2DRange aViewRange(rViewInformation.getViewport());
- if(aShadow2DRange.overlaps(rViewInformation.getViewport()))
+ if(aViewRange.isEmpty() || aShadow2DRange.overlaps(aViewRange))
{
// add extracted 2d shadows (before 3d scene creations itself)
aRetval = maShadowPrimitives;
@@ -236,8 +237,9 @@ namespace drawinglayer
{
// test visibility
const basegfx::B2DRange aLabel2DRange(getB2DRangeFromPrimitive2DSequence(maLabelPrimitives, rViewInformation));
+ const basegfx::B2DRange aViewRange(rViewInformation.getViewport());
- if(aLabel2DRange.overlaps(rViewInformation.getViewport()))
+ if(aViewRange.isEmpty() || aLabel2DRange.overlaps(aViewRange))
{
// add extracted 2d labels (after 3d scene creations)
appendPrimitive2DSequenceToPrimitive2DSequence(aRetval, maLabelPrimitives);