summaryrefslogtreecommitdiff
path: root/sw/source/ui/docvw
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/ui/docvw')
-rw-r--r--sw/source/ui/docvw/AnchorOverlayObject.cxx467
-rw-r--r--sw/source/ui/docvw/AnchorOverlayObject.hxx143
-rw-r--r--sw/source/ui/docvw/AnnotationMenuButton.cxx222
-rw-r--r--sw/source/ui/docvw/AnnotationMenuButton.hxx63
-rw-r--r--sw/source/ui/docvw/AnnotationWin.cxx292
-rw-r--r--sw/source/ui/docvw/PostItMgr.cxx2065
-rw-r--r--sw/source/ui/docvw/ShadowOverlayObject.cxx268
-rw-r--r--sw/source/ui/docvw/ShadowOverlayObject.hxx80
-rw-r--r--sw/source/ui/docvw/SidebarTxtControl.cxx422
-rw-r--r--sw/source/ui/docvw/SidebarTxtControl.hxx87
-rw-r--r--sw/source/ui/docvw/SidebarTxtControlAcc.cxx317
-rw-r--r--sw/source/ui/docvw/SidebarTxtControlAcc.hxx56
-rw-r--r--sw/source/ui/docvw/SidebarWin.cxx1373
-rw-r--r--sw/source/ui/docvw/SidebarWinAcc.cxx162
-rw-r--r--sw/source/ui/docvw/SidebarWinAcc.hxx67
-rw-r--r--sw/source/ui/docvw/access.src102
-rw-r--r--sw/source/ui/docvw/annotation.hrc54
-rw-r--r--sw/source/ui/docvw/annotation.src68
-rw-r--r--sw/source/ui/docvw/docvw.hrc93
-rw-r--r--sw/source/ui/docvw/docvw.src296
-rw-r--r--sw/source/ui/docvw/edtdd.cxx527
-rw-r--r--sw/source/ui/docvw/edtwin.cxx5754
-rw-r--r--sw/source/ui/docvw/edtwin2.cxx607
-rw-r--r--sw/source/ui/docvw/edtwin3.cxx216
-rw-r--r--sw/source/ui/docvw/frmsidebarwincontainer.cxx216
-rw-r--r--sw/source/ui/docvw/frmsidebarwincontainer.hxx73
-rw-r--r--sw/source/ui/docvw/makefile.mk69
-rw-r--r--sw/source/ui/docvw/romenu.cxx519
-rw-r--r--sw/source/ui/docvw/romenu.hxx75
-rw-r--r--sw/source/ui/docvw/srcedtw.cxx1103
30 files changed, 15856 insertions, 0 deletions
diff --git a/sw/source/ui/docvw/AnchorOverlayObject.cxx b/sw/source/ui/docvw/AnchorOverlayObject.cxx
new file mode 100644
index 000000000000..53afaf625710
--- /dev/null
+++ b/sw/source/ui/docvw/AnchorOverlayObject.cxx
@@ -0,0 +1,467 @@
+/************************************************************************* *
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: postit.cxx,v $
+ * $Revision: 1.8.42.11 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#include "precompiled_sw.hxx"
+
+#include <AnchorOverlayObject.hxx>
+#include <SidebarWindowsConsts.hxx>
+
+#include <swrect.hxx>
+#include <view.hxx>
+#include <svx/sdrpaintwindow.hxx>
+#include <svx/svdview.hxx>
+#include <svx/sdr/overlay/overlaymanager.hxx>
+
+#include <sw_primitivetypes2d.hxx>
+#include <drawinglayer/primitive2d/primitivetools2d.hxx>
+#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
+#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
+#include <drawinglayer/primitive2d/shadowprimitive2d.hxx>
+
+namespace sw { namespace sidebarwindows {
+
+//////////////////////////////////////////////////////////////////////////////
+// helper class: Primitive for discrete visualisation
+
+class AnchorPrimitive : public drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D
+{
+private:
+ basegfx::B2DPolygon maTriangle;
+ basegfx::B2DPolygon maLine;
+ basegfx::B2DPolygon maLineTop;
+ const AnchorState maAnchorState;
+ basegfx::BColor maColor;
+
+ // discrete line width
+ double mfLogicLineWidth;
+
+ // bitfield
+ bool mbShadow : 1;
+ bool mbLineSolid : 1;
+
+protected:
+ virtual drawinglayer::primitive2d::Primitive2DSequence create2DDecomposition(
+ const drawinglayer::geometry::ViewInformation2D& rViewInformation) const;
+
+public:
+ AnchorPrimitive( const basegfx::B2DPolygon& rTriangle,
+ const basegfx::B2DPolygon& rLine,
+ const basegfx::B2DPolygon& rLineTop,
+ AnchorState aAnchorState,
+ const basegfx::BColor& rColor,
+ double fLogicLineWidth,
+ bool bShadow,
+ bool bLineSolid )
+ : drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D(),
+ maTriangle(rTriangle),
+ maLine(rLine),
+ maLineTop(rLineTop),
+ maAnchorState(aAnchorState),
+ maColor(rColor),
+ mfLogicLineWidth(fLogicLineWidth),
+ mbShadow(bShadow),
+ mbLineSolid(bLineSolid)
+ {}
+
+ // data access
+ const basegfx::B2DPolygon& getTriangle() const { return maTriangle; }
+ const basegfx::B2DPolygon& getLine() const { return maLine; }
+ const basegfx::B2DPolygon& getLineTop() const { return maLineTop; }
+ const AnchorState getAnchorState() const { return maAnchorState; }
+ const basegfx::BColor& getColor() const { return maColor; }
+ double getLogicLineWidth() const { return mfLogicLineWidth; }
+ bool getShadow() const { return mbShadow; }
+ bool getLineSolid() const { return mbLineSolid; }
+
+ virtual bool operator==( const drawinglayer::primitive2d::BasePrimitive2D& rPrimitive ) const;
+
+ DeclPrimitrive2DIDBlock()
+};
+
+drawinglayer::primitive2d::Primitive2DSequence AnchorPrimitive::create2DDecomposition(
+ const drawinglayer::geometry::ViewInformation2D& /*rViewInformation*/) const
+{
+ drawinglayer::primitive2d::Primitive2DSequence aRetval;
+
+ if ( AS_TRI == maAnchorState ||
+ AS_ALL == maAnchorState ||
+ AS_START == maAnchorState )
+ {
+ // create triangle
+ const drawinglayer::primitive2d::Primitive2DReference aTriangle(
+ new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
+ basegfx::B2DPolyPolygon(getTriangle()),
+ getColor()));
+
+ drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aTriangle);
+ }
+
+ if ( AS_ALL == maAnchorState ||
+ AS_START == maAnchorState )
+ {
+ // create line start
+ const drawinglayer::attribute::LineAttribute aLineAttribute(
+ getColor(),
+ getLogicLineWidth() / (basegfx::fTools::equalZero(getDiscreteUnit()) ? 1.0 : getDiscreteUnit()));
+
+ if(getLineSolid())
+ {
+ const drawinglayer::primitive2d::Primitive2DReference aSolidLine(
+ new drawinglayer::primitive2d::PolygonStrokePrimitive2D(
+ getLine(),
+ aLineAttribute));
+
+ drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aSolidLine);
+ }
+ else
+ {
+ ::std::vector< double > aDotDashArray;
+ const double fDistance(3.0 * 15.0);
+ const double fDashLen(5.0 * 15.0);
+
+ aDotDashArray.push_back(fDashLen);
+ aDotDashArray.push_back(fDistance);
+
+ const drawinglayer::attribute::StrokeAttribute aStrokeAttribute(
+ aDotDashArray,
+ fDistance + fDashLen);
+
+ const drawinglayer::primitive2d::Primitive2DReference aStrokedLine(
+ new drawinglayer::primitive2d::PolygonStrokePrimitive2D(
+ getLine(),
+ aLineAttribute,
+ aStrokeAttribute));
+
+ drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aStrokedLine);
+ }
+ }
+
+ if(aRetval.hasElements() && getShadow())
+ {
+ // shadow is only for triangle and line start, and in upper left
+ // and lower right direction, in different colors
+ const double fColorChange(20.0 / 255.0);
+ const basegfx::B3DTuple aColorChange(fColorChange, fColorChange, fColorChange);
+ basegfx::BColor aLighterColor(getColor() + aColorChange);
+ basegfx::BColor aDarkerColor(getColor() - aColorChange);
+
+ aLighterColor.clamp();
+ aDarkerColor.clamp();
+
+ // create shadow sequence
+ drawinglayer::primitive2d::Primitive2DSequence aShadows(2);
+ basegfx::B2DHomMatrix aTransform;
+
+ aTransform.set(0, 2, -getDiscreteUnit());
+ aTransform.set(1, 2, -getDiscreteUnit());
+
+ aShadows[0] = drawinglayer::primitive2d::Primitive2DReference(
+ new drawinglayer::primitive2d::ShadowPrimitive2D(
+ aTransform,
+ aLighterColor,
+ aRetval));
+
+ aTransform.set(0, 2, getDiscreteUnit());
+ aTransform.set(1, 2, getDiscreteUnit());
+
+ aShadows[1] = drawinglayer::primitive2d::Primitive2DReference(
+ new drawinglayer::primitive2d::ShadowPrimitive2D(
+ aTransform,
+ aDarkerColor,
+ aRetval));
+
+ // add shadow before geometry to make it be proccessed first
+ const drawinglayer::primitive2d::Primitive2DSequence aTemporary(aRetval);
+
+ aRetval = aShadows;
+ drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(aRetval, aTemporary);
+ }
+
+ if ( AS_ALL == maAnchorState ||
+ AS_END == maAnchorState )
+ {
+ // LineTop has to be created, too, but uses no shadow, so add after
+ // the other parts are created
+ const drawinglayer::attribute::LineAttribute aLineAttribute(
+ getColor(),
+ getLogicLineWidth() / (basegfx::fTools::equalZero(getDiscreteUnit()) ? 1.0 : getDiscreteUnit()));
+
+ const drawinglayer::primitive2d::Primitive2DReference aLineTop(
+ new drawinglayer::primitive2d::PolygonStrokePrimitive2D(
+ getLineTop(),
+ aLineAttribute));
+
+ drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aLineTop);
+ }
+
+ return aRetval;
+}
+
+bool AnchorPrimitive::operator==( const drawinglayer::primitive2d::BasePrimitive2D& rPrimitive ) const
+{
+ if(drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D::operator==(rPrimitive))
+ {
+ const AnchorPrimitive& rCompare = static_cast< const AnchorPrimitive& >(rPrimitive);
+
+ return (getTriangle() == rCompare.getTriangle()
+ && getLine() == rCompare.getLine()
+ && getLineTop() == rCompare.getLineTop()
+ && getAnchorState() == rCompare.getAnchorState()
+ && getColor() == rCompare.getColor()
+ && getLogicLineWidth() == rCompare.getLogicLineWidth()
+ && getShadow() == rCompare.getShadow()
+ && getLineSolid() == rCompare.getLineSolid());
+ }
+
+ return false;
+}
+
+ImplPrimitrive2DIDBlock(AnchorPrimitive, PRIMITIVE2D_ID_SWSIDEBARANCHORPRIMITIVE)
+
+/****** AnchorOverlayObject ***********************************************************/
+/*static*/ AnchorOverlayObject* AnchorOverlayObject::CreateAnchorOverlayObject(
+ SwView& rDocView,
+ const SwRect& aAnchorRect,
+ const long& aPageBorder,
+ const Point& aLineStart,
+ const Point& aLineEnd,
+ const Color& aColorAnchor )
+{
+ AnchorOverlayObject* pAnchorOverlayObject( 0 );
+ if ( rDocView.GetDrawView() )
+ {
+ SdrPaintWindow* pPaintWindow = rDocView.GetDrawView()->GetPaintWindow(0);
+ if( pPaintWindow )
+ {
+ sdr::overlay::OverlayManager* pOverlayManager = pPaintWindow->GetOverlayManager();
+
+ if ( pOverlayManager )
+ {
+ pAnchorOverlayObject = new AnchorOverlayObject(
+ basegfx::B2DPoint( aAnchorRect.Left() , aAnchorRect.Bottom()-5*15),
+ basegfx::B2DPoint( aAnchorRect.Left()-5*15 , aAnchorRect.Bottom()+5*15),
+ basegfx::B2DPoint( aAnchorRect.Left()+5*15 , aAnchorRect.Bottom()+5*15),
+ basegfx::B2DPoint( aAnchorRect.Left(), aAnchorRect.Bottom()+2*15),
+ basegfx::B2DPoint( aPageBorder ,aAnchorRect.Bottom()+2*15),
+ basegfx::B2DPoint( aLineStart.X(),aLineStart.Y()),
+ basegfx::B2DPoint( aLineEnd.X(),aLineEnd.Y()) ,
+ aColorAnchor,
+ false,
+ false);
+ pOverlayManager->add(*pAnchorOverlayObject);
+ }
+ }
+ }
+
+ return pAnchorOverlayObject;
+}
+
+/*static*/ void AnchorOverlayObject::DestroyAnchorOverlayObject( AnchorOverlayObject* pAnchor )
+{
+ if ( pAnchor )
+ {
+ if ( pAnchor->getOverlayManager() )
+ {
+ // remove this object from the chain
+ pAnchor->getOverlayManager()->remove(*pAnchor);
+ }
+ delete pAnchor;
+ }
+}
+
+AnchorOverlayObject::AnchorOverlayObject( const basegfx::B2DPoint& rBasePos,
+ const basegfx::B2DPoint& rSecondPos,
+ const basegfx::B2DPoint& rThirdPos,
+ const basegfx::B2DPoint& rFourthPos,
+ const basegfx::B2DPoint& rFifthPos,
+ const basegfx::B2DPoint& rSixthPos,
+ const basegfx::B2DPoint& rSeventhPos,
+ const Color aBaseColor,
+ const bool bShadowedEffect,
+ const bool bLineSolid)
+ : OverlayObjectWithBasePosition( rBasePos, aBaseColor )
+ , maSecondPosition(rSecondPos)
+ , maThirdPosition(rThirdPos)
+ , maFourthPosition(rFourthPos)
+ , maFifthPosition(rFifthPos)
+ , maSixthPosition(rSixthPos)
+ , maSeventhPosition(rSeventhPos)
+ , maTriangle()
+ , maLine()
+ , maLineTop()
+ , mHeight(0)
+ , mAnchorState(AS_ALL)
+ , mbShadowedEffect(bShadowedEffect)
+ , mbLineSolid(bLineSolid)
+{
+}
+
+AnchorOverlayObject::~AnchorOverlayObject()
+{
+}
+
+void AnchorOverlayObject::implEnsureGeometry()
+{
+ if(!maTriangle.count())
+ {
+ maTriangle.append(getBasePosition());
+ maTriangle.append(GetSecondPosition());
+ maTriangle.append(GetThirdPosition());
+ maTriangle.setClosed(true);
+ }
+
+ if(!maLine.count())
+ {
+ maLine.append(GetFourthPosition());
+ maLine.append(GetFifthPosition());
+ maLine.append(GetSixthPosition());
+ }
+
+ if(!maLineTop.count())
+ {
+ maLineTop.append(GetSixthPosition());
+ maLineTop.append(GetSeventhPosition());
+ }
+}
+
+void AnchorOverlayObject::implResetGeometry()
+{
+ maTriangle.clear();
+ maLine.clear();
+ maLineTop.clear();
+}
+
+drawinglayer::primitive2d::Primitive2DSequence AnchorOverlayObject::createOverlayObjectPrimitive2DSequence()
+{
+ implEnsureGeometry();
+
+ const drawinglayer::primitive2d::Primitive2DReference aReference(
+ new AnchorPrimitive( maTriangle,
+ maLine,
+ maLineTop,
+ GetAnchorState(),
+ getBaseColor().getBColor(),
+ ANCHORLINE_WIDTH * 15.0,
+ getShadowedEffect(),
+ getLineSolid()) );
+
+ return drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1);
+}
+
+void AnchorOverlayObject::SetAllPosition( const basegfx::B2DPoint& rPoint1,
+ const basegfx::B2DPoint& rPoint2,
+ const basegfx::B2DPoint& rPoint3,
+ const basegfx::B2DPoint& rPoint4,
+ const basegfx::B2DPoint& rPoint5,
+ const basegfx::B2DPoint& rPoint6,
+ const basegfx::B2DPoint& rPoint7)
+{
+ if ( rPoint1 != getBasePosition() ||
+ rPoint2 != GetSecondPosition() ||
+ rPoint3 != GetThirdPosition() ||
+ rPoint4 != GetFourthPosition() ||
+ rPoint5 != GetFifthPosition() ||
+ rPoint6 != GetSixthPosition() ||
+ rPoint7 != GetSeventhPosition() )
+ {
+ maBasePosition = rPoint1;
+ maSecondPosition = rPoint2;
+ maThirdPosition = rPoint3;
+ maFourthPosition = rPoint4;
+ maFifthPosition = rPoint5;
+ maSixthPosition = rPoint6;
+ maSeventhPosition = rPoint7;
+
+ implResetGeometry();
+ objectChange();
+ }
+}
+
+void AnchorOverlayObject::SetSixthPosition(const basegfx::B2DPoint& rNew)
+{
+ if(rNew != maSixthPosition)
+ {
+ maSixthPosition = rNew;
+ implResetGeometry();
+ objectChange();
+ }
+}
+
+void AnchorOverlayObject::SetSeventhPosition(const basegfx::B2DPoint& rNew)
+{
+ if(rNew != maSeventhPosition)
+ {
+ maSeventhPosition = rNew;
+ implResetGeometry();
+ objectChange();
+ }
+}
+
+void AnchorOverlayObject::SetTriPosition(const basegfx::B2DPoint& rPoint1,const basegfx::B2DPoint& rPoint2,const basegfx::B2DPoint& rPoint3,
+ const basegfx::B2DPoint& rPoint4,const basegfx::B2DPoint& rPoint5)
+{
+ if(rPoint1 != getBasePosition()
+ || rPoint2 != GetSecondPosition()
+ || rPoint3 != GetThirdPosition()
+ || rPoint4 != GetFourthPosition()
+ || rPoint5 != GetFifthPosition())
+ {
+ maBasePosition = rPoint1;
+ maSecondPosition = rPoint2;
+ maThirdPosition = rPoint3;
+ maFourthPosition = rPoint4;
+ maFifthPosition = rPoint5;
+
+ implResetGeometry();
+ objectChange();
+ }
+}
+
+void AnchorOverlayObject::setLineSolid( const bool bNew )
+{
+ if ( bNew != getLineSolid() )
+ {
+ mbLineSolid = bNew;
+ objectChange();
+ }
+}
+
+void AnchorOverlayObject::SetAnchorState( const AnchorState aState)
+{
+ if ( mAnchorState != aState)
+ {
+ mAnchorState = aState;
+ objectChange();
+ }
+}
+
+} } // end of namespace sw::annotation
+
diff --git a/sw/source/ui/docvw/AnchorOverlayObject.hxx b/sw/source/ui/docvw/AnchorOverlayObject.hxx
new file mode 100644
index 000000000000..cea567f22921
--- /dev/null
+++ b/sw/source/ui/docvw/AnchorOverlayObject.hxx
@@ -0,0 +1,143 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: $
+ *
+ * $Revision: $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _ANCHOROVERLAYOBJECT_HXX
+#define _ANCHOROVERLAYOBJECT_HXX
+
+#include <svx/sdr/overlay/overlayobject.hxx>
+
+#include <basegfx/polygon/b2dpolygon.hxx>
+
+class SwView;
+class SwRect;
+class Point;
+
+namespace sw { namespace sidebarwindows {
+
+enum AnchorState
+{
+ AS_ALL,
+ AS_START,
+ AS_END,
+ AS_TRI
+};
+
+class AnchorOverlayObject: public sdr::overlay::OverlayObjectWithBasePosition
+{
+ public:
+ static AnchorOverlayObject* CreateAnchorOverlayObject( SwView& rDocView,
+ const SwRect& aAnchorRect,
+ const long& aPageBorder,
+ const Point& aLineStart,
+ const Point& aLineEnd,
+ const Color& aColorAnchor );
+ static void DestroyAnchorOverlayObject( AnchorOverlayObject* pAnchor );
+
+ inline const basegfx::B2DPoint& GetSecondPosition() const { return maSecondPosition; }
+ const basegfx::B2DPoint& GetThirdPosition() const { return maThirdPosition; }
+ const basegfx::B2DPoint& GetFourthPosition() const { return maFourthPosition; }
+ const basegfx::B2DPoint& GetFifthPosition() const { return maFifthPosition; }
+ const basegfx::B2DPoint& GetSixthPosition() const { return maSixthPosition; }
+ const basegfx::B2DPoint& GetSeventhPosition() const { return maSeventhPosition; }
+
+ void SetAllPosition( const basegfx::B2DPoint& rPoint1,
+ const basegfx::B2DPoint& rPoint2,
+ const basegfx::B2DPoint& rPoint3,
+ const basegfx::B2DPoint& rPoint4,
+ const basegfx::B2DPoint& rPoint5,
+ const basegfx::B2DPoint& rPoint6,
+ const basegfx::B2DPoint& rPoint7 );
+ void SetTriPosition( const basegfx::B2DPoint& rPoint1,
+ const basegfx::B2DPoint& rPoint2,
+ const basegfx::B2DPoint& rPoint3,
+ const basegfx::B2DPoint& rPoint4,
+ const basegfx::B2DPoint& rPoint5 );
+ void SetSixthPosition( const basegfx::B2DPoint& rNew );
+ void SetSeventhPosition( const basegfx::B2DPoint& rNew );
+
+ void setLineSolid( const bool bNew );
+ inline bool getLineSolid() const { return mbLineSolid; }
+
+ inline void SetHeight( const unsigned long aHeight ) { mHeight = aHeight; };
+
+ bool getShadowedEffect() const { return mbShadowedEffect; }
+
+ void SetAnchorState( const AnchorState aState );
+ inline AnchorState GetAnchorState() const { return mAnchorState; }
+
+ protected:
+ /* 6------------7
+ 1 /
+ /4\ ---------------5
+ 2 - 3
+ */
+
+ basegfx::B2DPoint maSecondPosition;
+ basegfx::B2DPoint maThirdPosition;
+ basegfx::B2DPoint maFourthPosition;
+ basegfx::B2DPoint maFifthPosition;
+ basegfx::B2DPoint maSixthPosition;
+ basegfx::B2DPoint maSeventhPosition;
+
+ // helpers to fill and reset geometry
+ void implEnsureGeometry();
+ void implResetGeometry();
+
+ // geometry creation for OverlayObject
+ virtual drawinglayer::primitive2d::Primitive2DSequence createOverlayObjectPrimitive2DSequence();
+
+ private:
+ // object's geometry
+ basegfx::B2DPolygon maTriangle;
+ basegfx::B2DPolygon maLine;
+ basegfx::B2DPolygon maLineTop;
+ unsigned long mHeight;
+ AnchorState mAnchorState;
+
+ bool mbShadowedEffect : 1;
+ bool mbLineSolid : 1;
+
+ AnchorOverlayObject( const basegfx::B2DPoint& rBasePos,
+ const basegfx::B2DPoint& rSecondPos,
+ const basegfx::B2DPoint& rThirdPos,
+ const basegfx::B2DPoint& rFourthPos,
+ const basegfx::B2DPoint& rFifthPos,
+ const basegfx::B2DPoint& rSixthPos,
+ const basegfx::B2DPoint& rSeventhPos,
+ const Color aBaseColor,
+ const bool bShadowedEffect,
+ const bool bLineSolid );
+ virtual ~AnchorOverlayObject();
+};
+
+} } // end of namespace sw::annotation
+
+#endif
diff --git a/sw/source/ui/docvw/AnnotationMenuButton.cxx b/sw/source/ui/docvw/AnnotationMenuButton.cxx
new file mode 100644
index 000000000000..6022a4646ae6
--- /dev/null
+++ b/sw/source/ui/docvw/AnnotationMenuButton.cxx
@@ -0,0 +1,222 @@
+/************************************************************************* *
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: $
+ * $Revision: $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#include "precompiled_sw.hxx"
+
+#include <AnnotationMenuButton.hxx>
+
+#include <annotation.hrc>
+#include <app.hrc>
+#include <access.hrc>
+
+#include <unotools/useroptions.hxx>
+
+#include <vcl/svapp.hxx>
+#include <vcl/menu.hxx>
+#include <vcl/decoview.hxx>
+#include <vcl/gradient.hxx>
+
+#include <cmdid.h>
+#include <SidebarWin.hxx>
+
+namespace sw { namespace annotation {
+
+Color ColorFromAlphaColor( const UINT8 aTransparency,
+ const Color &aFront,
+ const Color &aBack )
+{
+ return Color((UINT8)(aFront.GetRed() * aTransparency/(double)255 + aBack.GetRed() * (1-aTransparency/(double)255)),
+ (UINT8)(aFront.GetGreen() * aTransparency/(double)255 + aBack.GetGreen() * (1-aTransparency/(double)255)),
+ (UINT8)(aFront.GetBlue() * aTransparency/(double)255 + aBack.GetBlue() * (1-aTransparency/(double)255)));
+}
+
+AnnotationMenuButton::AnnotationMenuButton( sw::sidebarwindows::SwSidebarWin& rSidebarWin )
+ : MenuButton( &rSidebarWin )
+ , mrSidebarWin( rSidebarWin )
+{
+ AddEventListener( LINK( &mrSidebarWin, sw::sidebarwindows::SwSidebarWin, WindowEventListener ) );
+
+ SetAccessibleName( SW_RES( STR_ACCESS_ANNOTATION_BUTTON_NAME ) );
+ SetAccessibleDescription( SW_RES( STR_ACCESS_ANNOTATION_BUTTON_DESC ) );
+ SetQuickHelpText( GetAccessibleDescription() );
+}
+
+AnnotationMenuButton::~AnnotationMenuButton()
+{
+ RemoveEventListener( LINK( &mrSidebarWin, sw::sidebarwindows::SwSidebarWin, WindowEventListener ) );
+}
+
+void AnnotationMenuButton::Select()
+{
+ mrSidebarWin.ExecuteCommand( GetCurItemId() );
+}
+
+void AnnotationMenuButton::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ PopupMenu* pButtonPopup( GetPopupMenu() );
+ if ( mrSidebarWin.IsReadOnly() )
+ {
+ pButtonPopup->EnableItem( FN_REPLY, false );
+ pButtonPopup->EnableItem( FN_DELETE_NOTE, false );
+ pButtonPopup->EnableItem( FN_DELETE_NOTE_AUTHOR, false );
+ pButtonPopup->EnableItem( FN_DELETE_ALL_NOTES, false );
+ }
+ else
+ {
+ if ( mrSidebarWin.IsProtected() )
+ {
+ pButtonPopup->EnableItem( FN_DELETE_NOTE, false );
+ }
+ else
+ {
+ pButtonPopup->EnableItem( FN_DELETE_NOTE, true );
+ }
+ pButtonPopup->EnableItem( FN_DELETE_NOTE_AUTHOR, true );
+ pButtonPopup->EnableItem( FN_DELETE_ALL_NOTES, true );
+ }
+
+ if ( mrSidebarWin.IsProtected() )
+ {
+ pButtonPopup->EnableItem( FN_REPLY, false );
+ }
+ else
+ {
+ SvtUserOptions aUserOpt;
+ String sAuthor;
+ if ( !(sAuthor = aUserOpt.GetFullName()).Len() )
+ {
+ if ( !(sAuthor = aUserOpt.GetID()).Len() )
+ {
+ sAuthor = String( SW_RES( STR_REDLINE_UNKNOWN_AUTHOR ));
+ }
+ }
+ // do not allow to reply to ourself and no answer possible if this note is in a protected section
+ if ( sAuthor == mrSidebarWin.GetAuthor() )
+ {
+ pButtonPopup->EnableItem( FN_REPLY, false );
+ }
+ else
+ {
+ pButtonPopup->EnableItem( FN_REPLY, true );
+ }
+ }
+
+ MenuButton::MouseButtonDown( rMEvt );
+}
+
+void AnnotationMenuButton::Paint( const Rectangle& /*rRect*/ )
+{
+ if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
+ SetFillColor(COL_BLACK);
+ else
+ SetFillColor( mrSidebarWin.ColorDark() );
+ SetLineColor();
+ const Rectangle aRect( Rectangle( Point( 0, 0 ), PixelToLogic( GetSizePixel() ) ) );
+ DrawRect( aRect );
+
+ if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode())
+ {
+ //draw rect around button
+ SetFillColor(COL_BLACK);
+ SetLineColor(COL_WHITE);
+ }
+ else
+ {
+ //draw button
+ Gradient aGradient;
+ if ( IsMouseOver() )
+ aGradient = Gradient( GRADIENT_LINEAR,
+ ColorFromAlphaColor( 80, mrSidebarWin.ColorAnchor(), mrSidebarWin.ColorDark() ),
+ ColorFromAlphaColor( 15, mrSidebarWin.ColorAnchor(), mrSidebarWin.ColorDark() ));
+ else
+ aGradient = Gradient( GRADIENT_LINEAR,
+ ColorFromAlphaColor( 15, mrSidebarWin.ColorAnchor(), mrSidebarWin.ColorDark() ),
+ ColorFromAlphaColor( 80, mrSidebarWin.ColorAnchor(), mrSidebarWin.ColorDark() ));
+ DrawGradient( aRect, aGradient );
+
+ //draw rect around button
+ SetFillColor();
+ SetLineColor( ColorFromAlphaColor( 90, mrSidebarWin.ColorAnchor(), mrSidebarWin.ColorDark() ));
+ }
+ DrawRect( aRect );
+
+ if ( mrSidebarWin.IsPreview() )
+ {
+ Font aOldFont( mrSidebarWin.GetFont() );
+ Font aFont(aOldFont);
+ Color aCol( COL_BLACK);
+ aFont.SetColor( aCol );
+ aFont.SetHeight(200);
+ aFont.SetWeight(WEIGHT_MEDIUM);
+ SetFont( aFont );
+ DrawText( aRect ,
+ rtl::OUString::createFromAscii("Edit Note"),
+ TEXT_DRAW_CENTER );
+ SetFont( aOldFont );
+ }
+ else
+ {
+ Rectangle aSymbolRect( aRect );
+ // 25% distance to the left and right button border
+ const long nBorderDistanceLeftAndRight = ((aSymbolRect.GetWidth()*250)+500)/1000;
+ aSymbolRect.Left()+=nBorderDistanceLeftAndRight;
+ aSymbolRect.Right()-=nBorderDistanceLeftAndRight;
+ // 40% distance to the top button border
+ const long nBorderDistanceTop = ((aSymbolRect.GetHeight()*400)+500)/1000;
+ aSymbolRect.Top()+=nBorderDistanceTop;
+ // 15% distance to the bottom button border
+ const long nBorderDistanceBottom = ((aSymbolRect.GetHeight()*150)+500)/1000;
+ aSymbolRect.Bottom()-=nBorderDistanceBottom;
+ DecorationView aDecoView( this );
+ aDecoView.DrawSymbol( aSymbolRect, SYMBOL_SPIN_DOWN,
+ ( Application::GetSettings().GetStyleSettings().GetHighContrastMode()
+ ? Color( COL_WHITE )
+ : Color( COL_BLACK ) ) );
+ }
+}
+
+void AnnotationMenuButton::KeyInput( const KeyEvent& rKeyEvt )
+{
+ const KeyCode& rKeyCode = rKeyEvt.GetKeyCode();
+ const USHORT nKey = rKeyCode.GetCode();
+ if ( nKey == KEY_TAB )
+ {
+ mrSidebarWin.ActivatePostIt();
+ mrSidebarWin.GrabFocus();
+ }
+ else
+ {
+ MenuButton::KeyInput( rKeyEvt );
+ }
+}
+
+} } // end of namespace sw::annotation
+
diff --git a/sw/source/ui/docvw/AnnotationMenuButton.hxx b/sw/source/ui/docvw/AnnotationMenuButton.hxx
new file mode 100644
index 000000000000..c74719f1cad4
--- /dev/null
+++ b/sw/source/ui/docvw/AnnotationMenuButton.hxx
@@ -0,0 +1,63 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: $
+ *
+ * $Revision: $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _ANNOTATIONMENUBUTTON_HXX
+#define _ANNOTATIONMENUBUTTON_HXX
+
+#include <vcl/menubtn.hxx>
+
+namespace sw { namespace sidebarwindows {
+ class SwSidebarWin;
+} }
+
+namespace sw { namespace annotation {
+
+class AnnotationMenuButton : public MenuButton
+{
+ public:
+ AnnotationMenuButton( sw::sidebarwindows::SwSidebarWin& rSidebarWin );
+ ~AnnotationMenuButton();
+
+ // overloaded <MenuButton> methods
+ virtual void Select();
+
+ // overloaded <Window> methods
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void Paint( const Rectangle& rRect );
+ virtual void KeyInput( const KeyEvent& rKeyEvt );
+
+ private:
+ sw::sidebarwindows::SwSidebarWin& mrSidebarWin;
+};
+
+} } // end of namespace sw::annotation
+
+#endif
diff --git a/sw/source/ui/docvw/AnnotationWin.cxx b/sw/source/ui/docvw/AnnotationWin.cxx
new file mode 100644
index 000000000000..91ea1e13b077
--- /dev/null
+++ b/sw/source/ui/docvw/AnnotationWin.cxx
@@ -0,0 +1,292 @@
+/************************************************************************* *
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: $
+ * $Revision: $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#include "precompiled_sw.hxx"
+
+#include <AnnotationWin.hxx>
+
+#include <AnnotationMenuButton.hxx>
+#include <PostItMgr.hxx>
+
+#include <annotation.hrc>
+#include <popup.hrc>
+#include <cmdid.h>
+
+#include <vcl/menu.hxx>
+
+#include <svl/undo.hxx>
+#include <unotools/syslocale.hxx>
+#include <svl/languageoptions.hxx>
+
+#include <editeng/postitem.hxx>
+#include <editeng/fhgtitem.hxx>
+#include <editeng/langitem.hxx>
+
+#include <editeng/editview.hxx>
+#include <editeng/outliner.hxx>
+#include <editeng/editeng.hxx>
+#include <editeng/editobj.hxx>
+
+#include <docufld.hxx> // SwPostItField
+#include <txtfld.hxx>
+#include <ndtxt.hxx>
+#include <view.hxx>
+#include <wrtsh.hxx>
+#include <docsh.hxx>
+#include <doc.hxx>
+#include <SwUndoField.hxx>
+
+namespace sw { namespace annotation {
+
+SwAnnotationWin::SwAnnotationWin( SwEditWin& rEditWin,
+ WinBits nBits,
+ SwPostItMgr& aMgr,
+ SwPostItBits aBits,
+ SwSidebarItem& rSidebarItem,
+ SwFmtFld* aField )
+ : SwSidebarWin( rEditWin, nBits, aMgr, aBits, rSidebarItem )
+ , mpFmtFld(aField)
+ , mpFld( static_cast<SwPostItField*>(aField->GetFld()))
+ , mpButtonPopup(0)
+{
+}
+
+SwAnnotationWin::~SwAnnotationWin()
+{
+ delete mpButtonPopup;
+}
+
+void SwAnnotationWin::SetPostItText()
+{
+ // get text from SwPostItField and insert into our textview
+ Engine()->SetModifyHdl( Link() );
+ Engine()->EnableUndo( FALSE );
+ mpFld = static_cast<SwPostItField*>(mpFmtFld->GetFld());
+ if( mpFld->GetTextObject() )
+ Engine()->SetText( *mpFld->GetTextObject() );
+ else
+ {
+ Engine()->Clear();
+ GetOutlinerView()->SetAttribs(DefaultItem());
+ GetOutlinerView()->InsertText(mpFld->GetPar2(),false);
+ }
+
+ Engine()->ClearModifyFlag();
+ Engine()->GetUndoManager().Clear();
+ Engine()->EnableUndo( TRUE );
+ Engine()->SetModifyHdl( LINK( this, SwAnnotationWin, ModifyHdl ) );
+ Invalidate();
+}
+
+void SwAnnotationWin::UpdateData()
+{
+ if ( Engine()->IsModified() )
+ {
+ SwTxtFld* pTxtFld = mpFmtFld->GetTxtFld();
+ SwPosition aPosition( pTxtFld->GetTxtNode() );
+ aPosition.nContent = *pTxtFld->GetStart();
+ SwField* pOldField = mpFld->Copy();
+ mpFld->SetPar2(Engine()->GetEditEngine().GetText());
+ mpFld->SetTextObject(Engine()->CreateParaObject());
+ DocView().GetDocShell()->GetDoc()->AppendUndo(new SwUndoFieldFromDoc(aPosition, *pOldField, *mpFld, 0, true));
+ delete pOldField;
+ // so we get a new layout of notes (anchor position is still the same and we would otherwise not get one)
+ Mgr().SetLayout();
+ // #i98686# if we have several views, all notes should update their text
+ mpFmtFld->Broadcast(SwFmtFldHint( 0, SWFMTFLD_CHANGED));
+ DocView().GetDocShell()->SetModified();
+ }
+ Engine()->ClearModifyFlag();
+ Engine()->GetUndoManager().Clear();
+}
+
+void SwAnnotationWin::Delete()
+{
+ SwSidebarWin::Delete();
+ // we delete the field directly, the Mgr cleans up the PostIt by listening
+ DocView().GetWrtShellPtr()->GotoField(*mpFmtFld);
+ GrabFocusToDocument();
+ DocView().GetWrtShellPtr()->DelRight();
+}
+
+void SwAnnotationWin::GotoPos()
+{
+ DocView().GetDocShell()->GetWrtShell()->GotoField(*mpFmtFld);
+}
+
+sal_uInt32 SwAnnotationWin::MoveCaret()
+{
+ // if this is an answer, do not skip over all following ones, but insert directly behind the current one
+ // but when just leaving a note, skip all following ones as well to continue typing
+ return Mgr().IsAnswer()
+ ? 1
+ : 1 + CountFollowing();
+}
+
+//returns true, if there is another note right before this note
+bool SwAnnotationWin::CalcFollow()
+{
+ SwTxtFld* pTxtFld = mpFmtFld->GetTxtFld();
+ SwPosition aPosition( pTxtFld->GetTxtNode() );
+ aPosition.nContent = *pTxtFld->GetStart();
+ SwTxtAttr * const pTxtAttr = pTxtFld->GetTxtNode().GetTxtAttrForCharAt(
+ aPosition.nContent.GetIndex() - 1, RES_TXTATR_FIELD );
+ const SwField* pFld = pTxtAttr ? pTxtAttr->GetFld().GetFld() : 0;
+ return pFld && (pFld->Which()== RES_POSTITFLD);
+}
+
+// counts how many SwPostItField we have right after the current one
+sal_uInt32 SwAnnotationWin::CountFollowing()
+{
+ sal_uInt32 aCount = 1; // we start with 1, so we have to subtract one at the end again
+ SwTxtFld* pTxtFld = mpFmtFld->GetTxtFld();
+ SwPosition aPosition( pTxtFld->GetTxtNode() );
+ aPosition.nContent = *pTxtFld->GetStart();
+
+ SwTxtAttr * pTxtAttr = pTxtFld->GetTxtNode().GetTxtAttrForCharAt(
+ aPosition.nContent.GetIndex() + 1,
+ RES_TXTATR_FIELD );
+ SwField* pFld = pTxtAttr
+ ? const_cast<SwField*>(pTxtAttr->GetFld().GetFld())
+ : 0;
+ while ( pFld && ( pFld->Which()== RES_POSTITFLD ) )
+ {
+ aCount++;
+ pTxtAttr = pTxtFld->GetTxtNode().GetTxtAttrForCharAt(
+ aPosition.nContent.GetIndex() + aCount,
+ RES_TXTATR_FIELD );
+ pFld = pTxtAttr
+ ? const_cast<SwField*>(pTxtAttr->GetFld().GetFld())
+ : 0;
+ }
+ return aCount - 1;
+}
+
+MenuButton* SwAnnotationWin::CreateMenuButton()
+{
+ mpButtonPopup = new PopupMenu(SW_RES(MN_ANNOTATION_BUTTON));
+ XubString aText = mpButtonPopup->GetItemText( FN_DELETE_NOTE_AUTHOR );
+ SwRewriter aRewriter;
+ aRewriter.AddRule(UNDO_ARG1,GetAuthor());
+ aText = aRewriter.Apply(aText);
+ mpButtonPopup->SetItemText(FN_DELETE_NOTE_AUTHOR,aText);
+ MenuButton* pMenuButton = new AnnotationMenuButton( *this );
+ pMenuButton->SetPopupMenu( mpButtonPopup );
+ pMenuButton->Show();
+ return pMenuButton;
+}
+
+void SwAnnotationWin::InitAnswer(OutlinerParaObject* pText)
+{
+ //collect our old meta data
+ SwSidebarWin* pWin = Mgr().GetNextPostIt(KEY_PAGEUP, this);
+ const LocaleDataWrapper& rLocalData = SvtSysLocale().GetLocaleData();
+ String aText = String(SW_RES(STR_REPLY));
+ SwRewriter aRewriter;
+ aRewriter.AddRule(UNDO_ARG1, pWin->GetAuthor());
+ aText = aRewriter.Apply(aText);
+ aText.Append(String(rtl::OUString::createFromAscii(" (") +
+ String(rLocalData.getDate( pWin->GetDate())) + rtl::OUString::createFromAscii(", ") +
+ String(rLocalData.getTime( pWin->GetTime(),false)) + rtl::OUString::createFromAscii("): \"")));
+ GetOutlinerView()->InsertText(aText,false);
+
+ // insert old, selected text or "..."
+ // TOOD: iterate over all paragraphs, not only first one to find out if it is empty
+ if (pText->GetTextObject().GetText(0) != String(rtl::OUString::createFromAscii("")))
+ GetOutlinerView()->GetEditView().InsertText(pText->GetTextObject());
+ else
+ GetOutlinerView()->InsertText(rtl::OUString::createFromAscii("..."),false);
+ GetOutlinerView()->InsertText(rtl::OUString::createFromAscii("\"\n"),false);
+
+ GetOutlinerView()->SetSelection(ESelection(0x0,0x0,0xFFFF,0xFFFF));
+ SfxItemSet aAnswerSet( DocView().GetDocShell()->GetPool() );
+ aAnswerSet.Put(SvxFontHeightItem(200,80,EE_CHAR_FONTHEIGHT));
+ aAnswerSet.Put(SvxPostureItem(ITALIC_NORMAL,EE_CHAR_ITALIC));
+ GetOutlinerView()->SetAttribs(aAnswerSet);
+ GetOutlinerView()->SetSelection(ESelection(0xFFFF,0xFFFF,0xFFFF,0xFFFF));
+
+ //remove all attributes and reset our standard ones
+ GetOutlinerView()->GetEditView().RemoveAttribsKeepLanguages(true);
+ GetOutlinerView()->SetAttribs(DefaultItem());
+ // lets insert an undo step so the initial text can be easily deleted
+ // but do not use UpdateData() directly, would set modified state again and reentrance into Mgr
+ Engine()->SetModifyHdl( Link() );
+ SwTxtFld* pTxtFld = mpFmtFld->GetTxtFld();
+ SwPosition aPosition( pTxtFld->GetTxtNode() );
+ aPosition.nContent = *pTxtFld->GetStart();
+ SwField* pOldField = mpFld->Copy();
+ mpFld->SetPar2(Engine()->GetEditEngine().GetText());
+ mpFld->SetTextObject(Engine()->CreateParaObject());
+ DocView().GetDocShell()->GetDoc()->AppendUndo(new SwUndoFieldFromDoc(aPosition, *pOldField, *mpFld, 0, true));
+ delete pOldField;
+ Engine()->SetModifyHdl( LINK( this, SwAnnotationWin, ModifyHdl ) );
+ Engine()->ClearModifyFlag();
+ Engine()->GetUndoManager().Clear();
+}
+
+SvxLanguageItem SwAnnotationWin::GetLanguage(void)
+{
+ // set initial language for outliner
+ USHORT nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( mpFld->GetLanguage() );
+ USHORT nLangWhichId = 0;
+ switch (nScriptType)
+ {
+ case SCRIPTTYPE_LATIN : nLangWhichId = EE_CHAR_LANGUAGE ; break;
+ case SCRIPTTYPE_ASIAN : nLangWhichId = EE_CHAR_LANGUAGE_CJK; break;
+ case SCRIPTTYPE_COMPLEX : nLangWhichId = EE_CHAR_LANGUAGE_CTL; break;
+ default: DBG_ERROR("GetLanguage: wrong script tye");
+ }
+ return SvxLanguageItem(mpFld->GetLanguage(),nLangWhichId);
+}
+
+bool SwAnnotationWin::IsProtected()
+{
+ return SwSidebarWin::IsProtected() ||
+ GetLayoutStatus() == SwPostItHelper::DELETED ||
+ ( mpFmtFld ? mpFmtFld->IsProtect() : false );
+}
+
+String SwAnnotationWin::GetAuthor()
+{
+ return mpFld->GetPar1();
+}
+
+Date SwAnnotationWin::GetDate()
+{
+ return mpFld->GetDate();
+}
+
+Time SwAnnotationWin::GetTime()
+{
+ return mpFld->GetTime();
+}
+
+} } // end of namespace sw::annotation
diff --git a/sw/source/ui/docvw/PostItMgr.cxx b/sw/source/ui/docvw/PostItMgr.cxx
new file mode 100644
index 000000000000..c6b0ad4a136f
--- /dev/null
+++ b/sw/source/ui/docvw/PostItMgr.cxx
@@ -0,0 +1,2065 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+#include "PostItMgr.hxx"
+#include <postithelper.hxx>
+
+#include <SidebarWin.hxx>
+#include <AnnotationWin.hxx>
+#include <frmsidebarwincontainer.hxx>
+#include <accmap.hxx>
+
+#include <SidebarWindowsConsts.hxx>
+#include <AnchorOverlayObject.hxx>
+#include <ShadowOverlayObject.hxx>
+
+#include <vcl/svapp.hxx>
+#include <vcl/scrbar.hxx>
+#include <vcl/outdev.hxx>
+
+#include <viewopt.hxx>
+
+#include <view.hxx>
+#include <docsh.hxx>
+#include <wrtsh.hxx>
+#include <doc.hxx>
+#include <fldbas.hxx>
+#include <fmtfld.hxx>
+#include <docufld.hxx>
+#include <edtwin.hxx>
+#include <txtfld.hxx>
+#include <ndtxt.hxx>
+#include <redline.hxx>
+#include <docary.hxx>
+#include <SwRewriter.hxx>
+#include <undobj.hxx>
+#include <tools/color.hxx>
+
+#include <swmodule.hxx>
+#include <annotation.hrc>
+#include "cmdid.h"
+
+#include <SwRewriter.hxx>
+#include <undobj.hxx>
+
+#include <sfx2/request.hxx>
+#include <sfx2/event.hxx>
+#include <svl/srchitem.hxx>
+
+
+#include <svl/languageoptions.hxx>
+#include <svtools/langtab.hxx>
+#include <svl/smplhint.hxx>
+
+#include <svx/svdview.hxx>
+#include <editeng/eeitem.hxx>
+#include <editeng/langitem.hxx>
+#include <editeng/outliner.hxx>
+
+#include <i18npool/mslangid.hxx>
+#include <i18npool/lang.h>
+
+#include "swevent.hxx"
+
+// distance between Anchor Y and initial note position
+#define POSTIT_INITIAL_ANCHOR_DISTANCE 20
+//distance between two postits
+#define POSTIT_SPACE_BETWEEN 8
+#define POSTIT_MINIMUMSIZE_WITH_META 60
+#define POSTIT_SCROLL_SIDEBAR_HEIGHT 20
+
+// if we layout more often we stop, this should never happen
+#define MAX_LOOP_COUNT 50
+
+using namespace sw::sidebarwindows;
+
+/*
+bool comp_author( const SwPostItItem* a, const SwPostItItem* b)
+{
+ return a->pFmtFld->GetFld()->GetPar1() < b->pFmtFld->GetFld()->GetPar1();
+}
+
+bool comp_date( const SwPostItItem* a, const SwPostItItem* b)
+{
+ return static_cast<SwPostItField*>(a->pFmtFld->GetFld())->GetDate() < static_cast<SwPostItField*>(b->pFmtFld->GetFld())->GetDate();
+}
+*/
+
+//
+bool comp_pos(const SwSidebarItem* a, const SwSidebarItem* b)
+{
+ // --> OD 2010-01-19 #i88070#
+ // sort by anchor position
+//// if position is on the same line, sort by x (Left) position, otherwise by y(Bottom) position
+//// if two notes are at the same position, sort by logical node position
+// return (a->maLayoutInfo.mPosition.Bottom() == b->maLayoutInfo.mPosition.Bottom())
+// ? ( ( (a->maLayoutInfo.mPosition.Left() == b->maLayoutInfo.mPosition.Left()) &&
+// (a->GetBroadCaster()->ISA(SwFmtFld) && b->GetBroadCaster()->ISA(SwFmtFld)) )
+// ? *(static_cast<SwFmtFld*>(a->GetBroadCaster())->GetTxtFld()->GetStart()) <
+// *(static_cast<SwFmtFld*>(b->GetBroadCaster())->GetTxtFld()->GetStart())
+// : a->maLayoutInfo.mPosition.Left() < b->maLayoutInfo.mPosition.Left() )
+// : a->maLayoutInfo.mPosition.Bottom() < b->maLayoutInfo.mPosition.Bottom();
+ return a->GetAnchorPosition() < b->GetAnchorPosition();
+ // <--
+}
+
+SwPostItMgr::SwPostItMgr(SwView* pView)
+ : mpView(pView)
+ , mpWrtShell(mpView->GetDocShell()->GetWrtShell())
+ , mpEditWin(&mpView->GetEditWin())
+ , mnEventId(0)
+ , mbWaitingForCalcRects(false)
+ , mpActivePostIt(0)
+ , mbLayout(false)
+ , mbLayoutHeight(0)
+ , mbLayouting(false)
+ , mbReadOnly(mpView->GetDocShell()->IsReadOnly())
+ , mbDeleteNote(true)
+ , mpAnswer(0)
+ , mbIsShowAnchor( false )
+ , mpFrmSidebarWinContainer( 0 )
+{
+ if(!mpView->GetDrawView() )
+ mpView->GetWrtShell().MakeDrawView();
+
+ SwNoteProps aProps;
+ mbIsShowAnchor = aProps.IsShowAnchor();
+
+ //make sure we get the colour yellow always, even if not the first one of comments or redlining
+ SW_MOD()->GetRedlineAuthor();
+
+ // collect all PostIts and redline comments that exist after loading the document
+ // don't check for existance for any of them, don't focus them
+ AddPostIts(false,false);
+ /* this code can be used once we want redline comments in the Sidebar
+ AddRedlineComments(false,false);
+ */
+ // we want to receive stuff like SFX_HINT_DOCCHANGED
+ StartListening(*mpView->GetDocShell());
+ if (!mvPostItFlds.empty())
+ {
+ mbWaitingForCalcRects = true;
+ mnEventId = Application::PostUserEvent( LINK( this, SwPostItMgr, CalcHdl), 0 );
+ }
+}
+
+SwPostItMgr::~SwPostItMgr()
+{
+ if ( mnEventId )
+ Application::RemoveUserEvent( mnEventId );
+ // forget about all our Sidebar windows
+ RemoveSidebarWin();
+ EndListening( *mpView->GetDocShell() );
+
+ for(std::vector<SwPostItPageItem*>::iterator i = mPages.begin(); i!= mPages.end() ; i++)
+ delete (*i);
+ mPages.clear();
+
+ delete mpFrmSidebarWinContainer;
+ mpFrmSidebarWinContainer = 0;
+}
+
+void SwPostItMgr::CheckForRemovedPostIts()
+{
+ bool bRemoved = false;
+ for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end(); )
+ {
+ std::list<SwSidebarItem*>::iterator it = i++;
+ if ( !(*it)->UseElement() )
+ {
+ SwSidebarItem* p = (*it);
+ mvPostItFlds.remove(*it);
+ if (GetActiveSidebarWin() == p->pPostIt)
+ SetActiveSidebarWin(0);
+ if (p->pPostIt)
+ delete p->pPostIt;
+ delete p;
+ bRemoved = true;
+ }
+ }
+
+ if ( bRemoved )
+ {
+ // make sure that no deleted items remain in page lists
+ // todo: only remove deleted ones?!
+ if ( mvPostItFlds.empty() )
+ {
+ PreparePageContainer();
+ PrepareView();
+ }
+ else
+ // if postits are their make sure that page lists are not empty
+ // otherwise sudden paints can cause pain (in BorderOverPageBorder)
+ CalcRects();
+ }
+}
+
+void SwPostItMgr::InsertItem(SfxBroadcaster* pItem, bool bCheckExistance, bool bFocus)
+{
+ if (bCheckExistance)
+ {
+ for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++)
+ {
+ if ( (*i)->GetBroadCaster() == pItem )
+ return;
+ }
+ }
+ mbLayout = bFocus;
+ if (pItem->ISA(SwFmtFld))
+ mvPostItFlds.push_back(new SwAnnotationItem(static_cast<SwFmtFld*>(pItem), true, bFocus) );
+ /*
+ else
+ if (pItem->ISA(SwRedline))
+ mvPostItFlds.push_back(new SwRedCommentItem( static_cast<SwRedline*>(pItem), true, bFocus)) ;
+ */
+ DBG_ASSERT(pItem->ISA(SwFmtFld) /*|| pItem->ISA(SwRedline)*/,"Mgr::InsertItem: seems like new stuff was added");
+ StartListening(*pItem);
+}
+
+void SwPostItMgr::RemoveItem( SfxBroadcaster* pBroadcast )
+{
+ EndListening(*pBroadcast);
+ for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++)
+ {
+ if ( (*i)->GetBroadCaster() == pBroadcast )
+ {
+ SwSidebarItem* p = (*i);
+ if (GetActiveSidebarWin() == p->pPostIt)
+ SetActiveSidebarWin(0);
+ mvPostItFlds.remove(*i);
+ delete p->pPostIt;
+ delete p;
+ break;
+ }
+ }
+ mbLayout = true;
+ PrepareView();
+}
+
+void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
+{
+ if ( rHint.IsA(TYPE(SfxEventHint) ) )
+ {
+ sal_uInt32 nId = ((SfxEventHint&)rHint).GetEventId();
+ if ( nId == SW_EVENT_LAYOUT_FINISHED )
+ {
+ if ( !mbWaitingForCalcRects && !mvPostItFlds.empty())
+ {
+ mbWaitingForCalcRects = true;
+ mnEventId = Application::PostUserEvent( LINK( this, SwPostItMgr, CalcHdl), 0 );
+ }
+ }
+ }
+ else if ( rHint.IsA(TYPE(SfxSimpleHint) ) )
+ {
+ sal_uInt32 nId = ((SfxSimpleHint&)rHint).GetId();
+ switch ( nId )
+ {
+ case SFX_HINT_MODECHANGED:
+ {
+ if ( mbReadOnly != !!(mpView->GetDocShell()->IsReadOnly()) )
+ {
+ mbReadOnly = !mbReadOnly;
+ SetReadOnlyState();
+ mbLayout = true;
+ }
+ break;
+ }
+ case SFX_HINT_DOCCHANGED:
+ {
+ if ( mpView->GetDocShell() == &rBC )
+ {
+ if ( !mbWaitingForCalcRects && !mvPostItFlds.empty())
+ {
+ mbWaitingForCalcRects = true;
+ mnEventId = Application::PostUserEvent( LINK( this, SwPostItMgr, CalcHdl), 0 );
+ }
+ }
+ break;
+ }
+ case SFX_HINT_USER04:
+ {
+ // if we are in a SplitNode/Cut operation, do not delete note and then add again, as this will flicker
+ mbDeleteNote = !mbDeleteNote;
+ break;
+ }
+ case SFX_HINT_DYING:
+ {
+ if ( mpView->GetDocShell() != &rBC )
+ {
+ // field to be removed is the broadcaster
+ DBG_ERROR("Notification for removed SwFmtFld was not sent!");
+ RemoveItem(&rBC);
+ }
+ break;
+ }
+ }
+ }
+ /*
+ else if ( rHint.IsA(TYPE(SwRedlineHint) ) )
+ {
+ const SwRedlineHint rRedlineHint = static_cast<const SwRedlineHint&>(rHint);
+ SwRedline* pRedline = const_cast<SwRedline*>(rRedlineHint.GetRedline());
+ switch ( rRedlineHint.Which() )
+ {
+ case SWREDLINE_INSERTED :
+ {
+ bool bEmpty = !HasNotes();
+ InsertItem( pRedline, true, false );
+ if (bEmpty && !mvPostItFlds.empty())
+ PrepareView(true);
+ break;
+ }
+ case SWREDLINE_REMOVED:
+ {
+ RemoveItem(pRedline);
+ break;
+ }
+ case SWREDLINE_FOCUS:
+ {
+ if (rRedlineHint.GetView()== mpView)
+ Focus(rBC);
+ break;
+ }
+ }
+ }
+ */
+ else if ( rHint.IsA(TYPE(SwFmtFldHint) ) )
+ {
+ const SwFmtFldHint& rFmtHint = static_cast<const SwFmtFldHint&>(rHint);
+ SwFmtFld* pFld = const_cast <SwFmtFld*>( rFmtHint.GetField() );
+ switch ( rFmtHint.Which() )
+ {
+ case SWFMTFLD_INSERTED :
+ {
+ if (!pFld)
+ {
+ AddPostIts(true);
+ break;
+ }
+ // get field to be inserted from hint
+ if ( pFld->IsFldInDoc() )
+ {
+ bool bEmpty = !HasNotes();
+ InsertItem( pFld, true, false );
+ if (bEmpty && !mvPostItFlds.empty())
+ PrepareView(true);
+ }
+ else
+ {
+ DBG_ERROR( "Inserted field not in document!" );
+ }
+ break;
+ }
+ case SWFMTFLD_REMOVED:
+ {
+ if (mbDeleteNote)
+ {
+ if (!pFld)
+ {
+ CheckForRemovedPostIts();
+ break;
+ }
+ RemoveItem(pFld);
+ }
+ break;
+ }
+ case SWFMTFLD_FOCUS:
+ {
+ if (rFmtHint.GetView()== mpView)
+ Focus(rBC);
+ break;
+ }
+ case SWFMTFLD_CHANGED:
+ {
+ SwFmtFld* pFmtFld = dynamic_cast<SwFmtFld*>(&rBC);
+ for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++)
+ {
+ if ( pFmtFld == (*i)->GetBroadCaster() )
+ {
+ if ((*i)->pPostIt)
+ {
+ (*i)->pPostIt->SetPostItText();
+ mbLayout = true;
+ }
+ break;
+ }
+ }
+ break;
+ }
+ case SWFMTFLD_LANGUAGE:
+ {
+ SwFmtFld* pFmtFld = dynamic_cast<SwFmtFld*>(&rBC);
+ for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++)
+ {
+ if ( pFmtFld == (*i)->GetBroadCaster() )
+ {
+ if ((*i)->pPostIt)
+ {
+ USHORT nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( (*i)->GetFmtFld()->GetFld()->GetLanguage() );
+ USHORT nLangWhichId = 0;
+ switch (nScriptType)
+ {
+ case SCRIPTTYPE_LATIN : nLangWhichId = EE_CHAR_LANGUAGE ; break;
+ case SCRIPTTYPE_ASIAN : nLangWhichId = EE_CHAR_LANGUAGE_CJK; break;
+ case SCRIPTTYPE_COMPLEX : nLangWhichId = EE_CHAR_LANGUAGE_CTL; break;
+ }
+ (*i)->pPostIt->SetLanguage( SvxLanguageItem((*i)->GetFmtFld()->GetFld()->GetLanguage(),
+ nLangWhichId) );
+ }
+ break;
+ }
+ }
+ break;
+ }
+ }
+ }
+}
+
+void SwPostItMgr::Focus(SfxBroadcaster& rBC)
+{
+ if (!mpWrtShell->GetViewOptions()->IsPostIts())
+ {
+ SfxRequest aRequest(mpView->GetViewFrame(),FN_VIEW_NOTES);
+ mpView->ExecViewOptions(aRequest);
+ }
+
+ for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++)
+ {
+ // field to get the focus is the broadcaster
+ if ( &rBC == (*i)->GetBroadCaster() )
+ {
+ if ((*i)->pPostIt)
+ {
+ (*i)->pPostIt->GrabFocus();
+ MakeVisible((*i)->pPostIt);
+ }
+ else
+ {
+ // when the layout algorithm starts, this postit is created and receives focus
+ (*i)->bFocus = true;
+ }
+ }
+ }
+}
+
+bool SwPostItMgr::CalcRects()
+{
+ if ( mnEventId )
+ {
+ // if CalcRects() was forced and an event is still pending: remove it
+ // it is superfluous and also may cause reentrance problems if triggered while layouting
+ Application::RemoveUserEvent( mnEventId );
+ mnEventId = 0;
+ }
+
+ bool bChange = false;
+ bool bRepair = false;
+ PreparePageContainer();
+ if ( !mvPostItFlds.empty() )
+ {
+ for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++)
+ {
+ SwSidebarItem* pItem = (*i);
+ if ( !pItem->UseElement() )
+ {
+ DBG_ERROR("PostIt is not in doc or other wrong use");
+ bRepair = true;
+ continue;
+ }
+
+ //save old rect and visible state
+ SwRect aOldRect(pItem->maLayoutInfo.mPosition);
+ SwPostItHelper::SwLayoutStatus eOldStatus = pItem->mLayoutStatus;
+ std::vector< SwLayoutInfo > aInfo;
+ {
+ SwPosition aPosition = pItem->GetAnchorPosition();
+ pItem->mLayoutStatus = SwPostItHelper::getLayoutInfos( aInfo, aPosition );
+ }
+ if( aInfo.size() )
+ {
+ pItem->maLayoutInfo = aInfo[0];
+ }
+ bChange = bChange ||
+ ( pItem->maLayoutInfo.mPosition != aOldRect ) ||
+ ( eOldStatus != pItem->mLayoutStatus );
+ }
+
+ // show notes in right order in navigator
+ //prevent Anchors during layout to overlap, e.g. when moving a frame
+ Sort(SORT_POS);
+
+ // sort the items into the right page vector, so layout can be done by page
+ for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++)
+ {
+ SwSidebarItem* pItem = (*i);
+ if( SwPostItHelper::INVISIBLE == pItem->mLayoutStatus )
+ {
+ if (pItem->pPostIt)
+ pItem->pPostIt->HideNote();
+ continue;
+ }
+
+ if( SwPostItHelper::HIDDEN == pItem->mLayoutStatus )
+ {
+ if (!mpWrtShell->GetViewOptions()->IsShowHiddenChar())
+ {
+ if (pItem->pPostIt)
+ pItem->pPostIt->HideNote();
+ continue;
+ }
+ }
+
+ const unsigned long aPageNum = pItem->maLayoutInfo.mnPageNumber;
+ if (aPageNum > mPages.size())
+ {
+ const unsigned long nNumberOfPages = mPages.size();
+ for (unsigned int j=0; j<aPageNum - nNumberOfPages; ++j)
+ mPages.push_back( new SwPostItPageItem());
+ }
+ mPages[aPageNum-1]->mList->push_back(pItem);
+ mPages[aPageNum-1]->mPageRect = pItem->maLayoutInfo.mPageFrame;
+ mPages[aPageNum-1]->eSidebarPosition = pItem->maLayoutInfo.meSidebarPosition;
+ }
+
+ if (!bChange && mpWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE))
+ {
+ long nLayoutHeight = SwPostItHelper::getLayoutHeight( mpWrtShell->GetLayout() );
+ if( nLayoutHeight > mbLayoutHeight )
+ {
+ if (mPages[0]->bScrollbar || HasScrollbars())
+ bChange = true;
+ }
+ else if( nLayoutHeight < mbLayoutHeight )
+ {
+ if (mPages[0]->bScrollbar || !BorderOverPageBorder(1))
+ bChange = true;
+ }
+ }
+ }
+
+ if ( bRepair )
+ CheckForRemovedPostIts();
+
+ mbLayoutHeight = SwPostItHelper::getLayoutHeight( mpWrtShell->GetLayout() );
+ mbWaitingForCalcRects = false;
+ return bChange;
+}
+
+bool SwPostItMgr::HasScrollbars() const
+{
+ for(std::list<SwSidebarItem*>::const_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++)
+ {
+ if ((*i)->bShow && (*i)->pPostIt && (*i)->pPostIt->HasScrollbar())
+ return true;
+ }
+ return false;
+}
+
+void SwPostItMgr::PreparePageContainer()
+{
+ // we do not just delete the SwPostItPageItem, so offset/scrollbar is not lost
+ long lPageSize = mpWrtShell->GetNumPages();
+ long lContainerSize = mPages.size();
+
+ if (lContainerSize < lPageSize)
+ {
+ for (int i=0; i<lPageSize - lContainerSize;i++)
+ mPages.push_back( new SwPostItPageItem());
+ }
+ else
+ if (lContainerSize > lPageSize)
+ {
+ for (int i=mPages.size()-1; i >= lPageSize;--i)
+ {
+ delete mPages[i];
+ mPages.pop_back();
+ }
+ }
+ // only clear the list, DO NOT delete the objects itself
+ for(std::vector<SwPostItPageItem*>::iterator i = mPages.begin(); i!= mPages.end() ; i++)
+ {
+ (*i)->mList->clear();
+ if (mvPostItFlds.empty())
+ (*i)->bScrollbar = false;
+
+ }
+}
+
+void SwPostItMgr::LayoutPostIts()
+{
+ if ( !mvPostItFlds.empty() && !mbWaitingForCalcRects )
+ {
+ mbLayouting = true;
+
+ //loop over all pages and do the layout
+ // - create SwPostIt if neccessary
+ // - place SwPostIts on their initial position
+ // - calculate neccessary height for all PostIts together
+ bool bUpdate = false;
+ for (unsigned long n=0;n<mPages.size();n++)
+ {
+ // only layout if there are notes on this page
+ if (mPages[n]->mList->size()>0)
+ {
+ std::list<SwSidebarWin*> aVisiblePostItList;
+ unsigned long lNeededHeight = 0;
+ long mlPageBorder = 0;
+ long mlPageEnd = 0;
+
+ for(SwSidebarItem_iterator i = mPages[n]->mList->begin(); i!= mPages[n]->mList->end(); i++)
+ {
+ SwSidebarItem* pItem = (*i);
+ SwSidebarWin* pPostIt = pItem->pPostIt;
+
+ if (mPages[n]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT )
+ {
+ // x value for notes positioning
+ mlPageBorder = mpEditWin->LogicToPixel( Point( mPages[n]->mPageRect.Left(), 0)).X() - GetSidebarWidth(true);// - GetSidebarBorderWidth(true);
+ //bending point
+ mlPageEnd =
+ mpWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE)
+ ? pItem->maLayoutInfo.mPagePrtArea.Left()
+ : mPages[n]->mPageRect.Left() + 350;
+ }
+ else if (mPages[n]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_RIGHT )
+ {
+ // x value for notes positioning
+ mlPageBorder = mpEditWin->LogicToPixel( Point(mPages[n]->mPageRect.Right(), 0)).X() + GetSidebarBorderWidth(true);
+ //bending point
+ mlPageEnd =
+ mpWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE)
+ ? pItem->maLayoutInfo.mPagePrtArea.Right() :
+ mPages[n]->mPageRect.Right() - 350;
+ }
+
+ if (pItem->bShow)
+ {
+ long Y = mpEditWin->LogicToPixel( Point(0,pItem->maLayoutInfo.mPosition.Bottom())).Y();
+ long aPostItHeight = 0;
+ if (!pPostIt)
+ {
+ pPostIt = (*i)->GetSidebarWindow( mpView->GetEditWin(),
+ WB_DIALOGCONTROL,
+ *this,
+ 0 );
+ pPostIt->InitControls();
+ pPostIt->SetReadonly(mbReadOnly);
+ pItem->pPostIt = pPostIt;
+ if (mpAnswer)
+ {
+ if (pPostIt->CalcFollow()) //do we really have another note in front of this one
+ static_cast<sw::annotation::SwAnnotationWin*>(pPostIt)->InitAnswer(mpAnswer);
+ delete mpAnswer;
+ mpAnswer = 0;
+ }
+ }
+
+ pPostIt->SetChangeTracking(
+ pItem->mLayoutStatus,
+ GetColorAnchor(pItem->maLayoutInfo.mRedlineAuthor));
+ pPostIt->SetSidebarPosition(mPages[n]->eSidebarPosition);
+ pPostIt->SetFollow(pPostIt->CalcFollow());
+ aPostItHeight = ( pPostIt->GetPostItTextHeight() < pPostIt->GetMinimumSizeWithoutMeta()
+ ? pPostIt->GetMinimumSizeWithoutMeta()
+ : pPostIt->GetPostItTextHeight() )
+ + pPostIt->GetMetaHeight();
+ pPostIt->SetPosSizePixelRect( mlPageBorder ,
+ Y - GetInitialAnchorDistance(),
+ GetNoteWidth() ,
+ aPostItHeight,
+ pItem->maLayoutInfo.mPosition,
+ mlPageEnd );
+ pPostIt->ChangeSidebarItem( *pItem );
+
+ if (pItem->bFocus)
+ {
+ mbLayout = true;
+ pPostIt->GrabFocus();
+ pItem->bFocus = false;
+ }
+ // only the visible postits are used for the final layout
+ aVisiblePostItList.push_back(pPostIt);
+ lNeededHeight += pPostIt->IsFollow() ? aPostItHeight : aPostItHeight+GetSpaceBetween();
+ }
+ else // we don't want to see it
+ {
+ if (pPostIt)
+ pPostIt->HideNote();
+ }
+ }
+
+ if ((aVisiblePostItList.size()>0) && ShowNotes())
+ {
+ bool bOldScrollbar = mPages[n]->bScrollbar;
+ if (ShowNotes())
+ mPages[n]->bScrollbar = LayoutByPage(aVisiblePostItList, mPages[n]->mPageRect.SVRect(), lNeededHeight);
+ else
+ mPages[n]->bScrollbar = false;
+ if (!mPages[n]->bScrollbar)
+ {
+ mPages[n]->lOffset = 0;
+ }
+ else
+ {
+ //when we changed our zoom level, the offset value can be to big, so lets check for the largest possible zoom value
+ long aAvailableHeight = mpEditWin->LogicToPixel(Size(0,mPages[n]->mPageRect.Height())).Height() - 2 * GetSidebarScrollerHeight();
+ long lOffset = -1 * GetScrollSize() * (aVisiblePostItList.size() - aAvailableHeight / GetScrollSize());
+ if (mPages[n]->lOffset < lOffset)
+ mPages[n]->lOffset = lOffset;
+ }
+ bUpdate = (bOldScrollbar != mPages[n]->bScrollbar) || bUpdate;
+ const long aSidebarheight = mPages[n]->bScrollbar ? mpEditWin->PixelToLogic(Size(0,GetSidebarScrollerHeight())).Height() : 0;
+ /*
+ TODO
+ - enlarge all notes till GetNextBorder(), as we resized to average value before
+ */
+ //lets hide the ones which overlap the page
+ for(SwSidebarWin_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++)
+ {
+ if (mPages[n]->lOffset != 0)
+ (*i)->TranslateTopPosition(mPages[n]->lOffset);
+
+ bool bBottom = mpEditWin->PixelToLogic(Point(0,(*i)->VirtualPos().Y()+(*i)->VirtualSize().Height())).Y() <= (mPages[n]->mPageRect.Bottom()-aSidebarheight);
+ bool bTop = mpEditWin->PixelToLogic(Point(0,(*i)->VirtualPos().Y())).Y() >= (mPages[n]->mPageRect.Top()+aSidebarheight);
+ if ( bBottom && bTop )
+ {
+ (*i)->ShowNote();
+ }
+ else
+ {
+ if (mpEditWin->PixelToLogic(Point(0,(*i)->VirtualPos().Y())).Y() < (mPages[n]->mPageRect.Top()+aSidebarheight))
+ {
+ if ( mPages[n]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT )
+ (*i)->ShowAnchorOnly(Point( mPages[n]->mPageRect.Left(),
+ mPages[n]->mPageRect.Top()));
+ else if ( mPages[n]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_RIGHT )
+ (*i)->ShowAnchorOnly(Point( mPages[n]->mPageRect.Right(),
+ mPages[n]->mPageRect.Top()));
+ }
+ else
+ {
+ if ( mPages[n]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT )
+ (*i)->ShowAnchorOnly(Point(mPages[n]->mPageRect.Left(),
+ mPages[n]->mPageRect.Bottom()));
+ else if ( mPages[n]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_RIGHT )
+ (*i)->ShowAnchorOnly(Point(mPages[n]->mPageRect.Right(),
+ mPages[n]->mPageRect.Bottom()));
+ }
+ DBG_ASSERT(mPages[n]->bScrollbar,"SwPostItMgr::LayoutByPage(): note overlaps, but bScrollbar is not true");
+ }
+ }
+
+ // do some magic so we really see the focused note
+ for(SwSidebarWin_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++)
+ {
+ if ((*i)->HasChildPathFocus())
+ {
+ MakeVisible((*i),n+1);
+ break;
+ }
+ }
+ }
+ else
+ {
+ for(SwSidebarWin_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++)
+ (*i)->SetPosAndSize();
+
+ bool bOldScrollbar = mPages[n]->bScrollbar;
+ mPages[n]->bScrollbar = false;
+ bUpdate = (bOldScrollbar != mPages[n]->bScrollbar) || bUpdate;
+ }
+ aVisiblePostItList.clear();
+ }
+ else
+ {
+ bUpdate = true;
+ mPages[n]->bScrollbar = false;
+ }
+ }
+
+ if (!ShowNotes())
+ { // we do not want to see the notes anymore -> Options-Writer-View-Notes
+ bool bRepair = false;
+ for(SwSidebarItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++)
+ {
+ SwSidebarItem* pItem = (*i);
+ if ( !pItem->UseElement() )
+ {
+ DBG_ERROR("PostIt is not in doc!");
+ bRepair = true;
+ continue;
+ }
+
+ if ((*i)->pPostIt)
+ {
+ (*i)->pPostIt->HideNote();
+ if ((*i)->pPostIt->HasChildPathFocus())
+ {
+ SetActiveSidebarWin(0);
+ (*i)->pPostIt->GrabFocusToDocument();
+ }
+ }
+ }
+
+ if ( bRepair )
+ CheckForRemovedPostIts();
+ }
+
+
+ // notes scrollbar is otherwise not drawn correctly for some cases
+ // scrollbar area is enough
+ if (bUpdate)
+ mpEditWin->Invalidate();
+ mbLayouting = false;
+ }
+}
+
+bool SwPostItMgr::BorderOverPageBorder(unsigned long aPage) const
+{
+ if ( mPages[aPage-1]->mList->empty() )
+ {
+ DBG_ERROR("Notes SidePane painted but no rects and page lists calculated!");
+ return false;
+ }
+
+ SwSidebarItem_iterator aItem = mPages[aPage-1]->mList->end();
+ --aItem;
+ DBG_ASSERT ((*aItem)->pPostIt,"BorderOverPageBorder: NULL postIt, should never happen");
+ if ((*aItem)->pPostIt)
+ {
+ const long aSidebarheight = mPages[aPage-1]->bScrollbar ? mpEditWin->PixelToLogic(Size(0,GetSidebarScrollerHeight())).Height() : 0;
+ const long aEndValue = mpEditWin->PixelToLogic(Point(0,(*aItem)->pPostIt->GetPosPixel().Y()+(*aItem)->pPostIt->GetSizePixel().Height())).Y();
+ return aEndValue <= mPages[aPage-1]->mPageRect.Bottom()-aSidebarheight;
+ }
+ else
+ return false;
+}
+
+void SwPostItMgr::Scroll(const long lScroll,const unsigned long aPage)
+{
+ DBG_ASSERT((lScroll % GetScrollSize() )==0,"SwPostItMgr::Scroll: scrolling by wrong value");
+ // do not scroll more than neccessary up or down
+ if ( ((mPages[aPage-1]->lOffset == 0) && (lScroll>0)) || ( BorderOverPageBorder(aPage) && (lScroll<0)) )
+ return;
+
+ const bool bOldUp = ArrowEnabled(KEY_PAGEUP,aPage);
+ const bool bOldDown = ArrowEnabled(KEY_PAGEDOWN,aPage);
+ const long aSidebarheight = mpEditWin->PixelToLogic(Size(0,GetSidebarScrollerHeight())).Height();
+ for(SwSidebarItem_iterator i = mPages[aPage-1]->mList->begin(); i!= mPages[aPage-1]->mList->end(); i++)
+ {
+ SwSidebarWin* pPostIt = (*i)->pPostIt;
+ // if this is an answer, we should take the normal position and not the real, slightly moved position
+ pPostIt->SetVirtualPosSize(pPostIt->GetPosPixel(),pPostIt->GetSizePixel());
+ pPostIt->TranslateTopPosition(lScroll);
+
+ if ((*i)->bShow)
+ {
+ bool bBottom = mpEditWin->PixelToLogic(Point(0,pPostIt->VirtualPos().Y()+pPostIt->VirtualSize().Height())).Y() <= (mPages[aPage-1]->mPageRect.Bottom()-aSidebarheight);
+ bool bTop = mpEditWin->PixelToLogic(Point(0,pPostIt->VirtualPos().Y())).Y() >= (mPages[aPage-1]->mPageRect.Top()+aSidebarheight);
+ if ( bBottom && bTop)
+ {
+ pPostIt->ShowNote();
+ }
+ else
+ {
+ if ( mpEditWin->PixelToLogic(Point(0,pPostIt->VirtualPos().Y())).Y() < (mPages[aPage-1]->mPageRect.Top()+aSidebarheight))
+ {
+ if (mPages[aPage-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT)
+ pPostIt->ShowAnchorOnly(Point(mPages[aPage-1]->mPageRect.Left(),mPages[aPage-1]->mPageRect.Top()));
+ else if (mPages[aPage-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_RIGHT)
+ pPostIt->ShowAnchorOnly(Point(mPages[aPage-1]->mPageRect.Right(),mPages[aPage-1]->mPageRect.Top()));
+ }
+ else
+ {
+ if (mPages[aPage-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT)
+ pPostIt->ShowAnchorOnly(Point(mPages[aPage-1]->mPageRect.Left(),mPages[aPage-1]->mPageRect.Bottom()));
+ else if (mPages[aPage-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_RIGHT)
+ pPostIt->ShowAnchorOnly(Point(mPages[aPage-1]->mPageRect.Right(),mPages[aPage-1]->mPageRect.Bottom()));
+ }
+ }
+ }
+ }
+ mPages[aPage-1]->lOffset += lScroll;
+ if ( (bOldUp != ArrowEnabled(KEY_PAGEUP,aPage)) ||(bOldDown != ArrowEnabled(KEY_PAGEDOWN,aPage)) )
+ {
+ mpEditWin->Invalidate(GetBottomScrollRect(aPage));
+ mpEditWin->Invalidate(GetTopScrollRect(aPage));
+ }
+}
+
+void SwPostItMgr::AutoScroll(const SwSidebarWin* pPostIt,const unsigned long aPage )
+{
+ // otherwise all notes are visible
+ if (mPages[aPage-1]->bScrollbar)
+ {
+ const long aSidebarheight = mpEditWin->PixelToLogic(Size(0,GetSidebarScrollerHeight())).Height();
+ const bool bBottom = mpEditWin->PixelToLogic(Point(0,pPostIt->GetPosPixel().Y()+pPostIt->GetSizePixel().Height())).Y() <= (mPages[aPage-1]->mPageRect.Bottom()-aSidebarheight);
+ const bool bTop = mpEditWin->PixelToLogic(Point(0,pPostIt->GetPosPixel().Y())).Y() >= (mPages[aPage-1]->mPageRect.Top()+aSidebarheight);
+ if ( !(bBottom && bTop))
+ {
+ const long aDiff = bBottom ? mpEditWin->LogicToPixel(Point(0,mPages[aPage-1]->mPageRect.Top() + aSidebarheight)).Y() - pPostIt->GetPosPixel().Y() :
+ mpEditWin->LogicToPixel(Point(0,mPages[aPage-1]->mPageRect.Bottom() - aSidebarheight)).Y() - (pPostIt->GetPosPixel().Y()+pPostIt->GetSizePixel().Height());
+ // this just adds the missing value to get the next a* GetScrollSize() after aDiff
+ // e.g aDiff= 61 POSTIT_SCOLL=50 --> lScroll = 100
+ const long lScroll = bBottom ? (aDiff + ( GetScrollSize() - (aDiff % GetScrollSize()))) : (aDiff - (GetScrollSize() + (aDiff % GetScrollSize())));
+ Scroll(lScroll, aPage);
+ }
+ }
+}
+
+void SwPostItMgr::MakeVisible(const SwSidebarWin* pPostIt,long aPage )
+{
+ if (aPage == -1)
+ {
+ // we dont know the page yet, lets find it ourselves
+ for (unsigned long n=0;n<mPages.size();n++)
+ {
+ if (mPages[n]->mList->size()>0)
+ {
+ for(SwSidebarItem_iterator i = mPages[n]->mList->begin(); i!= mPages[n]->mList->end(); i++)
+ {
+ if ((*i)->pPostIt==pPostIt)
+ {
+ aPage = n+1;
+ break;
+ }
+ }
+ }
+ }
+ }
+ if (aPage!=-1)
+ AutoScroll(pPostIt,aPage);
+ Rectangle aNoteRect (Point(pPostIt->GetPosPixel().X(),pPostIt->GetPosPixel().Y()-5),pPostIt->GetSizePixel());
+ if (!aNoteRect.IsEmpty())
+ mpWrtShell->MakeVisible(SwRect(mpEditWin->PixelToLogic(aNoteRect)));
+}
+
+bool SwPostItMgr::ArrowEnabled(USHORT aDirection,unsigned long aPage) const
+{
+ switch (aDirection)
+ {
+ case KEY_PAGEUP:
+ {
+ return (mPages[aPage-1]->lOffset != 0);
+ }
+ case KEY_PAGEDOWN:
+ {
+ return (!BorderOverPageBorder(aPage));
+ }
+ default: return false;
+ }
+}
+
+Color SwPostItMgr::GetArrowColor(USHORT aDirection,unsigned long aPage) const
+{
+ if (ArrowEnabled(aDirection,aPage))
+ {
+ if (Application::GetSettings().GetStyleSettings().GetHighContrastMode())
+ return Color(COL_WHITE);
+ else
+ return COL_NOTES_SIDEPANE_ARROW_ENABLED;
+ }
+ else
+ {
+ return COL_NOTES_SIDEPANE_ARROW_DISABLED;
+ }
+}
+
+bool SwPostItMgr::LayoutByPage(std::list<SwSidebarWin*> &aVisiblePostItList,const Rectangle aBorder, long lNeededHeight)
+{
+ /*** General layout idea:***/
+ // - if we have space left, we always move the current one up,
+ // otherwise the next one down
+ // - first all notes are resized
+ // - then the real layout starts
+ /*************************************************************/
+
+ //rBorder is the page rect
+ const Rectangle rBorder = mpEditWin->LogicToPixel( aBorder);
+ long lTopBorder = rBorder.Top() + 5;
+ long lBottomBorder = rBorder.Bottom() - 5;
+ const long lVisibleHeight = lBottomBorder - lTopBorder; //rBorder.GetHeight() ;
+ long lSpaceUsed = 0;
+ long lTranslatePos = 0;
+ int loop = 0;
+ bool bDone = false;
+ bool bScrollbars = false;
+
+ // do all neccessary resizings
+ if (lVisibleHeight < lNeededHeight)
+ {
+ // ok, now we have to really resize and adding scrollbars
+ const long lAverageHeight = (lVisibleHeight - aVisiblePostItList.size()*GetSpaceBetween()) / aVisiblePostItList.size();
+ if (lAverageHeight<GetMinimumSizeWithMeta())
+ {
+ bScrollbars = true;
+ lTopBorder += GetSidebarScrollerHeight() + 10;
+ lBottomBorder -= (GetSidebarScrollerHeight() + 10);
+ for(SwSidebarWin_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++)
+ (*i)->SetSize(Size((*i)->VirtualSize().getWidth(),(*i)->GetMinimumSizeWithMeta()));
+ }
+ else
+ {
+ for(SwSidebarWin_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++)
+ {
+ if ( (*i)->VirtualSize().getHeight() > lAverageHeight)
+ (*i)->SetSize(Size((*i)->VirtualSize().getWidth(),lAverageHeight));
+ }
+ }
+ }
+
+ //start the real layout so nothing overlaps anymore
+ if (aVisiblePostItList.size()>1)
+ {
+ // if no window is moved anymore we are finished
+ while (!bDone)
+ {
+ loop++;
+ bDone = true;
+ lSpaceUsed = lTopBorder + GetSpaceBetween();
+ for(SwSidebarWin_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++)
+ {
+ SwSidebarWin_iterator aNextPostIt = i;
+ ++aNextPostIt;
+
+ if (aNextPostIt !=aVisiblePostItList.end())
+ {
+ lTranslatePos = ( (*i)->VirtualPos().Y() + (*i)->VirtualSize().Height()) - (*aNextPostIt)->VirtualPos().Y();
+ if (lTranslatePos > 0) // note windows overlaps the next one
+ {
+ // we are not done yet, loop at least once more
+ bDone = false;
+ // if there is space left, move the current note up
+ // it could also happen that there is no space left for the first note due to a scrollbar
+ // then we also jump into, so we move the current one up and the next one down
+ if ( (lSpaceUsed <= (*i)->VirtualPos().Y()) || (i==aVisiblePostItList.begin()))
+ {
+ // we have space left, so let's move the current one up
+ if ( ((*i)->VirtualPos().Y()- lTranslatePos - GetSpaceBetween()) > lTopBorder)
+ {
+ if ((*aNextPostIt)->IsFollow())
+ (*i)->TranslateTopPosition(-1*(lTranslatePos+ANCHORLINE_WIDTH));
+ else
+ (*i)->TranslateTopPosition(-1*(lTranslatePos+GetSpaceBetween()));
+ }
+ else
+ {
+ long lMoveUp = (*i)->VirtualPos().Y() - lTopBorder;
+ (*i)->TranslateTopPosition(-1* lMoveUp);
+ if ((*aNextPostIt)->IsFollow())
+ (*aNextPostIt)->TranslateTopPosition( (lTranslatePos+ANCHORLINE_WIDTH) - lMoveUp);
+ else
+ (*aNextPostIt)->TranslateTopPosition( (lTranslatePos+GetSpaceBetween()) - lMoveUp);
+ }
+ }
+ else
+ {
+ // no space left, left move the next one down
+ if ((*aNextPostIt)->IsFollow())
+ (*aNextPostIt)->TranslateTopPosition(lTranslatePos+ANCHORLINE_WIDTH);
+ else
+ (*aNextPostIt)->TranslateTopPosition(lTranslatePos+GetSpaceBetween());
+ }
+ }
+ else
+ {
+ // the first one could overlap the topborder instead of a second note
+ if (i==aVisiblePostItList.begin())
+ {
+ long lMoveDown = lTopBorder - (*i)->VirtualPos().Y();
+ if (lMoveDown>0)
+ {
+ bDone = false;
+ (*i)->TranslateTopPosition( lMoveDown);
+ }
+ }
+ }
+ if (aNextPostIt !=aVisiblePostItList.end() && (*aNextPostIt)->IsFollow())
+ lSpaceUsed += (*i)->VirtualSize().Height() + ANCHORLINE_WIDTH;
+ else
+ lSpaceUsed += (*i)->VirtualSize().Height() + GetSpaceBetween();
+ }
+ else
+ {
+ //(*i) is the last visible item
+ SwSidebarWin_iterator aPrevPostIt = i;
+ --aPrevPostIt;
+ //lTranslatePos = ( (*aPrevPostIt)->VirtualPos().Y() + (*aPrevPostIt)->VirtualSize().Height() + GetSpaceBetween() ) - (*i)->VirtualPos().Y();
+ lTranslatePos = ( (*aPrevPostIt)->VirtualPos().Y() + (*aPrevPostIt)->VirtualSize().Height() ) - (*i)->VirtualPos().Y();
+ if (lTranslatePos > 0)
+ {
+ bDone = false;
+ if ( ((*i)->VirtualPos().Y()+ (*i)->VirtualSize().Height()+lTranslatePos) < lBottomBorder)
+ {
+ if ( (*i)->IsFollow() )
+ (*i)->TranslateTopPosition(lTranslatePos+ANCHORLINE_WIDTH);
+ else
+ (*i)->TranslateTopPosition(lTranslatePos+GetSpaceBetween());
+ }
+ else
+ {
+ (*i)->TranslateTopPosition(lBottomBorder - ((*i)->VirtualPos().Y()+ (*i)->VirtualSize().Height()) );
+ }
+ }
+ else
+ {
+ // note does not overlap, but we might be over the lower border
+ // only do this if there are no scrollbars, otherwise notes are supposed to overlap the border
+ if (!bScrollbars && ((*i)->VirtualPos().Y()+ (*i)->VirtualSize().Height() > lBottomBorder) )
+ {
+ bDone = false;
+ (*i)->TranslateTopPosition(lBottomBorder - ((*i)->VirtualPos().Y()+ (*i)->VirtualSize().Height()));
+ }
+ }
+ }
+ }
+ // security check so we don't loop forever
+ if (loop>MAX_LOOP_COUNT)
+ {
+ DBG_ERROR("PostItMgr::Layout(): We are looping forever");
+ break;
+ }
+ }
+ }
+ else
+ {
+ // only one left, make sure it is not hidden at the top or bottom
+ SwSidebarWin_iterator i = aVisiblePostItList.begin();
+ lTranslatePos = lTopBorder - (*i)->VirtualPos().Y();
+ if (lTranslatePos>0)
+ {
+ (*i)->TranslateTopPosition(lTranslatePos+GetSpaceBetween());
+ }
+ lTranslatePos = lBottomBorder - ((*i)->VirtualPos().Y()+ (*i)->VirtualSize().Height());
+ if (lTranslatePos<0)
+ {
+ (*i)->TranslateTopPosition(lTranslatePos);
+ }
+ }
+ return bScrollbars;
+ }
+
+/*
+void SwPostItMgr::AddRedlineComments(bool bCheckExistance, bool bFocus)
+{
+ bool bEmpty = mvPostItFlds.empty();
+ const SwRedlineTbl& aTable = mpView->GetDocShell()->GetDoc()->GetRedlineTbl();
+ for( USHORT i = 0; i < aTable.Count(); ++i )
+ {
+ SwRedline* pRedline = const_cast<SwRedline*>((aTable)[i]);
+ if ( pRedline->GetComment() != String(rtl::OUString::createFromAscii("")) )
+ InsertItem(pRedline, bCheckExistance, bFocus);
+ }
+ if (bEmpty && !mvPostItFlds.empty())
+ PrepareView(true);
+ }
+ */
+
+void SwPostItMgr::AddPostIts(bool bCheckExistance, bool bFocus)
+{
+ bool bEmpty = mvPostItFlds.empty();
+ SwFieldType* pType = mpView->GetDocShell()->GetDoc()->GetFldType(RES_POSTITFLD, aEmptyStr,false);
+ SwClientIter aIter( *pType );
+ SwClient * pFirst = aIter.GoStart();
+ while(pFirst)
+ {
+ SwFmtFld* pSwFmtFld = static_cast<SwFmtFld*>(pFirst);
+ if ( pSwFmtFld->GetTxtFld())
+ {
+ if ( pSwFmtFld->IsFldInDoc() )
+ InsertItem(pSwFmtFld,bCheckExistance,bFocus);
+ }
+ pFirst = aIter++;
+ }
+
+ // if we just added the first one we have to update the view for centering
+ if (bEmpty && !mvPostItFlds.empty())
+ PrepareView(true);
+}
+
+void SwPostItMgr::RemoveSidebarWin()
+{
+ if (!mvPostItFlds.empty())
+ {
+ for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++)
+ {
+ EndListening( *((*i)->GetBroadCaster()) );
+ if ((*i)->pPostIt)
+ delete (*i)->pPostIt;
+ delete (*i);
+ }
+ mvPostItFlds.clear();
+ }
+
+ // all postits removed, no items should be left in pages
+ PreparePageContainer();
+}
+
+// copy to new vector, otherwise RemoveItem would operate and delete stuff on mvPostItFlds as well
+// RemoveItem will clean up the core field and visible postit if neccessary
+// we cannot just delete everything as before, as postits could move into change tracking
+void SwPostItMgr::Delete(String aAuthor)
+{
+ mpWrtShell->StartAllAction();
+ if ( HasActiveSidebarWin() && (GetActiveSidebarWin()->GetAuthor()==aAuthor) )
+ {
+ SetActiveSidebarWin(0);
+ }
+ SwRewriter aRewriter;
+ String aUndoString = SW_RES(STR_DELETE_AUTHOR_NOTES);
+ aUndoString += aAuthor;
+ aRewriter.AddRule(UNDO_ARG1, aUndoString);
+ mpWrtShell->StartUndo( UNDO_DELETE, &aRewriter );
+
+ std::vector<SwFmtFld*> aTmp;
+ aTmp.reserve( mvPostItFlds.size() );
+ for(std::list<SwSidebarItem*>::iterator pPostIt = mvPostItFlds.begin(); pPostIt!= mvPostItFlds.end() ; pPostIt++)
+ {
+ if ((*pPostIt)->GetFmtFld() && ((*pPostIt)->pPostIt->GetAuthor() == aAuthor) )
+ aTmp.push_back( (*pPostIt)->GetFmtFld() );
+ }
+ for(std::vector<SwFmtFld*>::iterator i = aTmp.begin(); i!= aTmp.end() ; i++)
+ {
+ mpWrtShell->GotoField( *(*i) );
+ mpWrtShell->DelRight();
+ }
+ mpWrtShell->EndUndo( UNDO_DELETE );
+ PrepareView();
+ mpWrtShell->EndAllAction();
+ mbLayout = true;
+ CalcRects();
+ LayoutPostIts();
+}
+
+void SwPostItMgr::Delete()
+{
+ mpWrtShell->StartAllAction();
+ SetActiveSidebarWin(0);
+ SwRewriter aRewriter;
+ aRewriter.AddRule(UNDO_ARG1, SW_RES(STR_DELETE_ALL_NOTES) );
+ mpWrtShell->StartUndo( UNDO_DELETE, &aRewriter );
+
+ std::vector<SwFmtFld*> aTmp;
+ aTmp.reserve( mvPostItFlds.size() );
+ for(std::list<SwSidebarItem*>::iterator pPostIt = mvPostItFlds.begin(); pPostIt!= mvPostItFlds.end() ; pPostIt++)
+ {
+ if ((*pPostIt)->GetFmtFld())
+ aTmp.push_back( (*pPostIt)->GetFmtFld() );
+ }
+ for(std::vector<SwFmtFld*>::iterator i = aTmp.begin(); i!= aTmp.end() ; i++)
+ {
+ mpWrtShell->GotoField( *(*i) );
+ mpWrtShell->DelRight();
+ }
+
+/*
+ for(std::list<SwPostItItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++)
+ {
+ SwPostItItem* pItem = (*i);
+ // stop listening, we delete ourselves
+ EndListening( *(pItem->pFmtFld) );
+ // delete the actual SwPostItField
+ mpWrtShell->GotoField(*pItem->pFmtFld);
+ mpWrtShell->DelRight();
+ // delete visual representation
+ delete pItem->pPostIt;
+ // delete struct saving the pointers
+ delete pItem;
+ }
+ mvPostItFlds.clear();
+*/
+
+ mpWrtShell->EndUndo( UNDO_DELETE );
+ PrepareView();
+ mpWrtShell->EndAllAction();
+ mbLayout = true;
+ CalcRects();
+ LayoutPostIts();
+}
+
+void SwPostItMgr::Hide(SwPostItField* pPostItField )
+{
+ for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++)
+ {
+ if ((*i)->GetFmtFld())
+ {
+ SwPostItField* pField = static_cast<SwPostItField*>((*i)->GetFmtFld()->GetFld());
+ if (pPostItField==pField)
+ {
+ (*i)->bShow = false;
+ (*i)->pPostIt->HideNote();
+ break;
+ }
+ }
+ }
+
+ LayoutPostIts();
+}
+
+void SwPostItMgr::Hide( const String& rAuthor )
+{
+ for(SwSidebarItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++)
+ {
+ if ( (*i)->pPostIt && ((*i)->pPostIt->GetAuthor() == rAuthor) )
+ {
+ (*i)->bShow = false;
+ (*i)->pPostIt->HideNote();
+ }
+ }
+
+ LayoutPostIts();
+}
+
+void SwPostItMgr::Hide()
+{
+ for(SwSidebarItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++)
+ {
+ (*i)->bShow = false;
+ (*i)->pPostIt->HideNote();
+ }
+}
+
+
+void SwPostItMgr::Show()
+{
+ for(SwSidebarItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++)
+ {
+ (*i)->bShow = true;
+ }
+ LayoutPostIts();
+}
+
+void SwPostItMgr::Sort(const short aType)
+{
+ if (mvPostItFlds.size()>1 )
+ {
+ switch (aType)
+ {
+ case SORT_POS:
+ mvPostItFlds.sort(comp_pos);
+ break;
+ /*
+ case SORT_AUTHOR:
+ mvPostItFlds.sort(comp_author);
+ break;
+ case SORT_DATE:
+ mvPostItFlds.sort(comp_date);
+ break;
+ */
+ }
+ }
+}
+
+SwSidebarWin* SwPostItMgr::GetSidebarWin( const SfxBroadcaster* pBroadcaster) const
+{
+ for(const_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++)
+ {
+ if ( (*i)->GetBroadCaster() == pBroadcaster)
+ return (*i)->pPostIt;
+ }
+ return NULL;
+}
+
+sw::annotation::SwAnnotationWin* SwPostItMgr::GetAnnotationWin(const SwPostItField* pFld) const
+{
+ for(const_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++)
+ {
+ if ( (*i)->GetFmtFld() && ((*i)->GetFmtFld()->GetFld() == pFld))
+ return dynamic_cast<sw::annotation::SwAnnotationWin*>((*i)->pPostIt);
+ }
+ return NULL;
+}
+
+bool SwPostItMgr::ShowPreview(const SwField* pFld, SwFmtFld*& pFmtFld) const
+{
+ for (unsigned long n=0;n<mPages.size();n++)
+ {
+ if (mPages[n]->mList->size()>0)
+ {
+ for(const_iterator i = mPages[n]->mList->begin(); i!= mPages[n]->mList->end(); i++)
+ {
+ if ( (*i)->GetFmtFld() && ((*i)->GetFmtFld()->GetFld()==pFld) )
+ {
+ pFmtFld = (*i)->GetFmtFld();
+ const long aSidebarheight = mPages[n]->bScrollbar ? mpEditWin->PixelToLogic(Size(0,GetSidebarScrollerHeight())).Height() : 0;
+ bool bTopPage = mpEditWin->PixelToLogic(Point(0,(*i)->pPostIt->GetPosPixel().Y())).Y() >= (mPages[n]->mPageRect.Top()+aSidebarheight);
+ bool bBottomPage = mpEditWin->PixelToLogic(Point(0,(*i)->pPostIt->GetPosPixel().Y()+(*i)->pPostIt->GetSizePixel().Height())).Y() <= (mPages[n]->mPageRect.Bottom()-aSidebarheight);
+ const bool bTopVis = mpEditWin->PixelToLogic(Point(0,(*i)->pPostIt->GetPosPixel().Y())).Y() > mpView->GetVisArea().Top();
+ const bool bBottomVis = mpEditWin->PixelToLogic(Point(0,(*i)->pPostIt->GetPosPixel().Y()/*+(*i)->pPostIt->GetSizePixel().Height()*/)).Y() <= mpView->GetVisArea().Bottom();
+ return !(bBottomPage && bTopPage && bBottomVis && bTopVis);
+ }
+ }
+ }
+ }
+ return false;
+}
+
+SwSidebarWin* SwPostItMgr::GetNextPostIt( USHORT aDirection,
+ SwSidebarWin* aPostIt )
+{
+ if (mvPostItFlds.size()>1)
+ {
+ for(SwSidebarItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++)
+ {
+ if ( (*i)->pPostIt ==aPostIt)
+ {
+ SwSidebarItem_iterator iNextPostIt = i;
+ if (aDirection==KEY_PAGEUP)
+ {
+ if ( iNextPostIt==mvPostItFlds.begin() )
+ {
+ return NULL;
+ }
+ --iNextPostIt;
+ }
+ else
+ {
+ iNextPostIt++;
+ if ( iNextPostIt==mvPostItFlds.end() )
+ {
+ return NULL;
+ }
+ }
+ // lets quit, we are back at the beginng
+ if ( (*iNextPostIt)->pPostIt==aPostIt)
+ return NULL;
+ return (*iNextPostIt)->pPostIt;
+ }
+ }
+ return NULL;
+ }
+ else
+ return NULL;
+}
+
+long SwPostItMgr::GetNextBorder()
+{
+ for (unsigned long n=0;n<mPages.size();n++)
+ {
+ for(SwSidebarItem_iterator b = mPages[n]->mList->begin(); b!= mPages[n]->mList->end(); b++)
+ {
+ if ((*b)->pPostIt == mpActivePostIt)
+ {
+ SwSidebarItem_iterator aNext = b;
+ aNext++;
+ bool bFollow = (aNext == mPages[n]->mList->end()) ? false : (*aNext)->pPostIt->IsFollow();
+ if ( mPages[n]->bScrollbar || bFollow )
+ {
+ return -1;
+ }
+ else
+ {
+ //if this is the last item, return the bottom border otherwise the next item
+ if (aNext == mPages[n]->mList->end())
+ return mpEditWin->LogicToPixel(Point(0,mPages[n]->mPageRect.Bottom())).Y() - GetSpaceBetween();
+ else
+ return (*aNext)->pPostIt->GetPosPixel().Y() - GetSpaceBetween();
+ }
+ }
+ }
+ }
+
+ DBG_ERROR("SwPostItMgr::GetNextBorder(): We have to find a next border here");
+ return -1;
+}
+
+void SwPostItMgr::SetShadowState(const SwPostItField* pFld,bool bCursor)
+{
+ if (pFld)
+ {
+ if (pFld !=mShadowState.mpShadowFld)
+ {
+ if (mShadowState.mpShadowFld)
+ {
+ // reset old one if still alive
+ // TODO: does not work properly if mouse and cursor was set
+ sw::annotation::SwAnnotationWin* pOldPostIt =
+ GetAnnotationWin(mShadowState.mpShadowFld);
+ if (pOldPostIt && pOldPostIt->Shadow() && (pOldPostIt->Shadow()->GetShadowState() != SS_EDIT))
+ pOldPostIt->SetViewState(VS_NORMAL);
+ }
+ //set new one, if it is not currently edited
+ sw::annotation::SwAnnotationWin* pNewPostIt = GetAnnotationWin(pFld);
+ if (pNewPostIt && pNewPostIt->Shadow() && (pNewPostIt->Shadow()->GetShadowState() != SS_EDIT))
+ {
+ pNewPostIt->SetViewState(VS_VIEW);
+ //remember our new field
+ mShadowState.mpShadowFld = pFld;
+ mShadowState.bCursor = false;
+ mShadowState.bMouse = false;
+ }
+ }
+ if (bCursor)
+ mShadowState.bCursor = true;
+ else
+ mShadowState.bMouse = true;
+ }
+ else
+ {
+ if (mShadowState.mpShadowFld)
+ {
+ if (bCursor)
+ mShadowState.bCursor = false;
+ else
+ mShadowState.bMouse = false;
+ if (!mShadowState.bCursor && !mShadowState.bMouse)
+ {
+ // reset old one if still alive
+ sw::annotation::SwAnnotationWin* pOldPostIt = GetAnnotationWin(mShadowState.mpShadowFld);
+ if (pOldPostIt && pOldPostIt->Shadow() && (pOldPostIt->Shadow()->GetShadowState() != SS_EDIT))
+ {
+ pOldPostIt->SetViewState(VS_NORMAL);
+ mShadowState.mpShadowFld = 0;
+ }
+ }
+ }
+ }
+}
+
+void SwPostItMgr::PrepareView(bool bIgnoreCount)
+{
+ if (!HasNotes() || bIgnoreCount)
+ {
+ mpWrtShell->StartAllAction();
+ //mpEditWin->Invalidate(); // really not needed anymore??
+ SwRootFrm* pLayout = mpWrtShell->GetLayout();
+ if ( pLayout )
+ SwPostItHelper::setSidebarChanged( pLayout,
+ mpWrtShell->getIDocumentSettingAccess()->get( IDocumentSettingAccess::BROWSE_MODE ) );
+ mpWrtShell->EndAllAction();
+ }
+}
+
+bool SwPostItMgr::ShowScrollbar(const unsigned long aPage) const
+{
+ if (mPages.size() > aPage-1)
+ return (mPages[aPage-1]->bScrollbar && !mbWaitingForCalcRects);
+ else
+ return false;
+}
+
+bool SwPostItMgr::IsHit(const Point &aPointPixel)
+{
+ if (HasNotes() && ShowNotes())
+ {
+ const Point aPoint = mpEditWin->PixelToLogic(aPointPixel);
+ const SwRootFrm* pLayout = mpWrtShell->GetLayout();
+ SwRect aPageFrm;
+ const unsigned long nPageNum = SwPostItHelper::getPageInfo( aPageFrm, pLayout, aPoint );
+ if( nPageNum )
+ {
+ Rectangle aRect;
+ DBG_ASSERT(mPages.size()>nPageNum-1,"SwPostitMgr:: page container size wrong");
+ aRect = mPages[nPageNum-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT
+ ? Rectangle(Point(aPageFrm.Left()-GetSidebarWidth()-GetSidebarBorderWidth(),aPageFrm.Top()),Size(GetSidebarWidth(),aPageFrm.Height()))
+ : Rectangle( Point(aPageFrm.Right()+GetSidebarBorderWidth(),aPageFrm.Top()) , Size(GetSidebarWidth(),aPageFrm.Height()));
+ if (aRect.IsInside(aPoint))
+ {
+ // we hit the note's sidebar
+ // lets now test for the arrow area
+ if (mPages[nPageNum-1]->bScrollbar)
+ return ScrollbarHit(nPageNum,aPoint);
+ else
+ return false;
+ }
+ }
+ }
+ return false;
+}
+Rectangle SwPostItMgr::GetBottomScrollRect(const unsigned long aPage) const
+{
+ SwRect aPageRect = mPages[aPage-1]->mPageRect;
+ Point aPointBottom = mPages[aPage-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT
+ ? Point(aPageRect.Left() - GetSidebarWidth() - GetSidebarBorderWidth() + mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Bottom()- mpEditWin->PixelToLogic(Size(0,2+GetSidebarScrollerHeight())).Height())
+ : Point(aPageRect.Right() + GetSidebarBorderWidth() + mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Bottom()- mpEditWin->PixelToLogic(Size(0,2+GetSidebarScrollerHeight())).Height());
+ Size aSize(GetSidebarWidth() - mpEditWin->PixelToLogic(Size(4,0)).Width(), mpEditWin->PixelToLogic(Size(0,GetSidebarScrollerHeight())).Height()) ;
+ return Rectangle(aPointBottom,aSize);
+
+}
+
+Rectangle SwPostItMgr::GetTopScrollRect(const unsigned long aPage) const
+{
+ SwRect aPageRect = mPages[aPage-1]->mPageRect;
+ Point aPointTop = mPages[aPage-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT
+ ? Point(aPageRect.Left() - GetSidebarWidth() -GetSidebarBorderWidth()+ mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Top() + mpEditWin->PixelToLogic(Size(0,2)).Height())
+ : Point(aPageRect.Right() + GetSidebarBorderWidth() + mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Top() + mpEditWin->PixelToLogic(Size(0,2)).Height());
+ Size aSize(GetSidebarWidth() - mpEditWin->PixelToLogic(Size(4,0)).Width(), mpEditWin->PixelToLogic(Size(0,GetSidebarScrollerHeight())).Height()) ;
+ return Rectangle(aPointTop,aSize);
+}
+
+
+//IMPORTANT: if you change the rects here, also change SwPageFrm::PaintNotesSidebar()
+bool SwPostItMgr::ScrollbarHit(const unsigned long aPage,const Point &aPoint)
+{
+ SwRect aPageRect = mPages[aPage-1]->mPageRect;
+ Point aPointBottom = mPages[aPage-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT
+ ? Point(aPageRect.Left() - GetSidebarWidth()-GetSidebarBorderWidth() + mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Bottom()- mpEditWin->PixelToLogic(Size(0,2+GetSidebarScrollerHeight())).Height())
+ : Point(aPageRect.Right() + GetSidebarBorderWidth()+ mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Bottom()- mpEditWin->PixelToLogic(Size(0,2+GetSidebarScrollerHeight())).Height());
+
+ Point aPointTop = mPages[aPage-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT
+ ? Point(aPageRect.Left() - GetSidebarWidth()-GetSidebarBorderWidth()+ mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Top() + mpEditWin->PixelToLogic(Size(0,2)).Height())
+ : Point(aPageRect.Right()+GetSidebarBorderWidth()+ mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Top() + mpEditWin->PixelToLogic(Size(0,2)).Height());
+
+ Rectangle aRectBottom(GetBottomScrollRect(aPage));
+ Rectangle aRectTop(GetTopScrollRect(aPage));
+
+ if (aRectBottom.IsInside(aPoint))
+ {
+ if (aPoint.X() < long((aPointBottom.X() + GetSidebarWidth()/3)))
+ Scroll( GetScrollSize(),aPage);
+ else
+ Scroll( -1*GetScrollSize(), aPage);
+ return true;
+ }
+ else
+ if (aRectTop.IsInside(aPoint))
+ {
+ if (aPoint.X() < long((aPointTop.X() + GetSidebarWidth()/3*2)))
+ Scroll(GetScrollSize(), aPage);
+ else
+ Scroll(-1*GetScrollSize(), aPage);
+ return true;
+ }
+ return false;
+}
+
+void SwPostItMgr::CorrectPositions()
+{
+ if ( mbWaitingForCalcRects || mbLayouting || mvPostItFlds.empty() )
+ return;
+
+ // find first valid note
+ SwSidebarWin *pFirstPostIt = 0;
+ for(SwSidebarItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++)
+ {
+ pFirstPostIt = (*i)->pPostIt;
+ if (pFirstPostIt)
+ break;
+ }
+
+ //if we have not found a valid note, forget about it and leave
+ if (!pFirstPostIt)
+ return;
+
+ // yeah, I know, if this is a left page it could be wrong, but finding the page and the note is probably not even faster than just doing it
+ const long aAnchorX = mpEditWin->LogicToPixel( Point((long)(pFirstPostIt->Anchor()->GetSixthPosition().getX()),0)).X();
+ const long aAnchorY = mpEditWin->LogicToPixel( Point(0,(long)(pFirstPostIt->Anchor()->GetSixthPosition().getY()))).Y() + 1;
+ if (Point(aAnchorX,aAnchorY) != pFirstPostIt->GetPosPixel())
+ {
+ long aAnchorPosX = 0;
+ long aAnchorPosY = 0;
+ for (unsigned long n=0;n<mPages.size();n++)
+ {
+ for(SwSidebarItem_iterator i = mPages[n]->mList->begin(); i!= mPages[n]->mList->end(); i++)
+ {
+ if ((*i)->bShow && (*i)->pPostIt)
+ {
+ aAnchorPosX = mPages[n]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT
+ ? mpEditWin->LogicToPixel( Point((long)((*i)->pPostIt->Anchor()->GetSeventhPosition().getX()),0)).X()
+ : mpEditWin->LogicToPixel( Point((long)((*i)->pPostIt->Anchor()->GetSixthPosition().getX()),0)).X();
+ aAnchorPosY = mpEditWin->LogicToPixel( Point(0,(long)((*i)->pPostIt->Anchor()->GetSixthPosition().getY()))).Y() + 1;
+ (*i)->pPostIt->SetPosPixel(Point(aAnchorPosX,aAnchorPosY));
+ }
+ }
+ }
+ }
+}
+
+
+bool SwPostItMgr::ShowNotes() const
+{
+ // we only want to see notes if Options - Writer - View - Notes is ticked
+ return mpWrtShell->GetViewOptions()->IsPostIts();
+}
+
+bool SwPostItMgr::HasNotes() const
+{
+ return !mvPostItFlds.empty();
+}
+
+unsigned long SwPostItMgr::GetSidebarWidth(bool bPx) const
+{
+ unsigned long aWidth = (unsigned long)(mpWrtShell->GetViewOptions()->GetZoom() * 1.8);
+ if (bPx)
+ return aWidth;
+ else
+ return mpEditWin->PixelToLogic(Size( aWidth ,0)).Width();
+}
+
+unsigned long SwPostItMgr::GetSidebarBorderWidth(bool bPx) const
+{
+ if (bPx)
+ return 2;
+ else
+ return mpEditWin->PixelToLogic(Size(2,0)).Width();
+}
+
+unsigned long SwPostItMgr::GetNoteWidth()
+{
+ return GetSidebarWidth(true);
+}
+
+Color SwPostItMgr::GetColorDark(sal_uInt16 aAuthorIndex)
+{
+ if (!Application::GetSettings().GetStyleSettings().GetHighContrastMode())
+ {
+ static const Color aArrayNormal[] = {
+ COL_AUTHOR1_NORMAL, COL_AUTHOR2_NORMAL, COL_AUTHOR3_NORMAL,
+ COL_AUTHOR4_NORMAL, COL_AUTHOR5_NORMAL, COL_AUTHOR6_NORMAL,
+ COL_AUTHOR7_NORMAL, COL_AUTHOR8_NORMAL, COL_AUTHOR9_NORMAL };
+
+ return Color( aArrayNormal[ aAuthorIndex % (sizeof( aArrayNormal )/ sizeof( aArrayNormal[0] ))]);
+ }
+ else
+ return Color(COL_WHITE);
+}
+
+Color SwPostItMgr::GetColorLight(sal_uInt16 aAuthorIndex)
+{
+ if (!Application::GetSettings().GetStyleSettings().GetHighContrastMode())
+ {
+ static const Color aArrayLight[] = {
+ COL_AUTHOR1_LIGHT, COL_AUTHOR2_LIGHT, COL_AUTHOR3_LIGHT,
+ COL_AUTHOR4_LIGHT, COL_AUTHOR5_LIGHT, COL_AUTHOR6_LIGHT,
+ COL_AUTHOR7_LIGHT, COL_AUTHOR8_LIGHT, COL_AUTHOR9_LIGHT };
+
+ return Color( aArrayLight[ aAuthorIndex % (sizeof( aArrayLight )/ sizeof( aArrayLight[0] ))]);
+ }
+ else
+ return Color(COL_WHITE);
+}
+
+Color SwPostItMgr::GetColorAnchor(sal_uInt16 aAuthorIndex)
+{
+ if (!Application::GetSettings().GetStyleSettings().GetHighContrastMode())
+ {
+ static const Color aArrayAnchor[] = {
+ COL_AUTHOR1_DARK, COL_AUTHOR2_DARK, COL_AUTHOR3_DARK,
+ COL_AUTHOR4_DARK, COL_AUTHOR5_DARK, COL_AUTHOR6_DARK,
+ COL_AUTHOR7_DARK, COL_AUTHOR8_DARK, COL_AUTHOR9_DARK };
+
+ return Color( aArrayAnchor[ aAuthorIndex % (sizeof( aArrayAnchor ) / sizeof( aArrayAnchor[0] ))]);
+ }
+ else
+ return Color(COL_WHITE);
+}
+
+void SwPostItMgr::SetActiveSidebarWin( SwSidebarWin* p)
+{
+ if ( p != mpActivePostIt )
+ {
+ // we need the temp variable so we can set mpActivePostIt before we call DeactivatePostIt
+ // therefore we get a new layout in DOCCHANGED when switching from postit to document,
+ // otherwise, GetActivePostIt() would still hold our old postit
+ SwSidebarWin* pActive = mpActivePostIt;
+ mpActivePostIt = p;
+ if (pActive)
+ {
+ pActive->DeactivatePostIt();
+ mShadowState.mpShadowFld = 0;
+ }
+ if (mpActivePostIt)
+ {
+ mpActivePostIt->GotoPos();
+ mpView->AttrChangedNotify(0);
+ mpActivePostIt->ActivatePostIt();
+ }
+ }
+}
+
+IMPL_LINK( SwPostItMgr, CalcHdl, void*, /* pVoid*/ )
+{
+ mnEventId = 0;
+ if ( mbLayouting )
+ {
+ DBG_ERROR("Reentrance problem in Layout Manager!");
+ mbWaitingForCalcRects = false;
+ return 0;
+ }
+
+ // do not change order, even if it would seem so in the first place, we need the calcrects always
+ if (CalcRects() || mbLayout)
+ {
+ mbLayout = false;
+ LayoutPostIts();
+ }
+ return 0;
+}
+
+void SwPostItMgr::Rescale()
+{
+ for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++)
+ if ( (*i)->pPostIt )
+ (*i)->pPostIt->Rescale();
+}
+
+sal_Int32 SwPostItMgr::GetInitialAnchorDistance() const
+{
+ const Fraction& f( mpEditWin->GetMapMode().GetScaleY() );
+ return POSTIT_INITIAL_ANCHOR_DISTANCE * f.GetNumerator() / f.GetDenominator();
+}
+
+sal_Int32 SwPostItMgr::GetSpaceBetween() const
+{
+ const Fraction& f( mpEditWin->GetMapMode().GetScaleY() );
+ return ( POSTIT_SPACE_BETWEEN ) * f.GetNumerator() / f.GetDenominator();
+}
+
+sal_Int32 SwPostItMgr::GetScrollSize() const
+{
+ const Fraction& f( mpEditWin->GetMapMode().GetScaleY() );
+ return ( POSTIT_SPACE_BETWEEN + POSTIT_MINIMUMSIZE_WITH_META ) * f.GetNumerator() / f.GetDenominator();
+}
+
+sal_Int32 SwPostItMgr::GetMinimumSizeWithMeta() const
+{
+ const Fraction& f( mpEditWin->GetMapMode().GetScaleY() );
+ return POSTIT_MINIMUMSIZE_WITH_META * f.GetNumerator() / f.GetDenominator();
+}
+
+sal_Int32 SwPostItMgr::GetSidebarScrollerHeight() const
+{
+ const Fraction& f( mpEditWin->GetMapMode().GetScaleY() );
+ return POSTIT_SCROLL_SIDEBAR_HEIGHT * f.GetNumerator() / f.GetDenominator();
+}
+
+void SwPostItMgr::SetSpellChecking()
+{
+ for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++)
+ if ( (*i)->pPostIt )
+ (*i)->pPostIt->SetSpellChecking();
+}
+
+void SwPostItMgr::SetReadOnlyState()
+{
+ for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++)
+ if ( (*i)->pPostIt )
+ (*i)->pPostIt->SetReadonly( mbReadOnly );
+}
+
+void SwPostItMgr::CheckMetaText()
+{
+ for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++)
+ if ( (*i)->pPostIt )
+ (*i)->pPostIt->CheckMetaText();
+
+}
+
+sal_uInt16 SwPostItMgr::Replace(SvxSearchItem* pItem)
+{
+ SwSidebarWin* pWin = GetActiveSidebarWin();
+ sal_uInt16 aResult = pWin->GetOutlinerView()->StartSearchAndReplace( *pItem );
+ if (!aResult)
+ SetActiveSidebarWin(0);
+ return aResult;
+}
+
+sal_uInt16 SwPostItMgr::FinishSearchReplace(const ::com::sun::star::util::SearchOptions& rSearchOptions, bool bSrchForward)
+{
+ SwSidebarWin* pWin = GetActiveSidebarWin();
+ SvxSearchItem aItem(SID_SEARCH_ITEM );
+ aItem.SetSearchOptions(rSearchOptions);
+ aItem.SetBackward(!bSrchForward);
+ sal_uInt16 aResult = pWin->GetOutlinerView()->StartSearchAndReplace( aItem );
+ if (!aResult)
+ SetActiveSidebarWin(0);
+ return aResult;
+}
+
+sal_uInt16 SwPostItMgr::SearchReplace(const SwFmtFld &pFld, const ::com::sun::star::util::SearchOptions& rSearchOptions, bool bSrchForward)
+{
+ sal_uInt16 aResult = 0;
+ SwSidebarWin* pWin = GetSidebarWin(&pFld);
+ if (pWin)
+ {
+ ESelection aOldSelection = pWin->GetOutlinerView()->GetSelection();
+ if (bSrchForward)
+ pWin->GetOutlinerView()->SetSelection(ESelection(0,0,0,0));
+ else
+ pWin->GetOutlinerView()->SetSelection(ESelection(0xFFFF,0xFFFF,0xFFFF,0xFFFF));
+ SvxSearchItem aItem(SID_SEARCH_ITEM );
+ aItem.SetSearchOptions(rSearchOptions);
+ aItem.SetBackward(!bSrchForward);
+ aResult = pWin->GetOutlinerView()->StartSearchAndReplace( aItem );
+ if (!aResult)
+ pWin->GetOutlinerView()->SetSelection(aOldSelection);
+ else
+ {
+ SetActiveSidebarWin(pWin);
+ MakeVisible(pWin);
+ }
+ }
+ return aResult;
+}
+
+void SwPostItMgr::AssureStdModeAtShell()
+{
+ //#i103373# #i103645#
+ // deselect any drawing or frame and leave editing mode
+ SdrView* pSdrView = mpWrtShell->GetDrawView();
+ if ( pSdrView && pSdrView->IsTextEdit() )
+ {
+ sal_Bool bLockView = mpWrtShell->IsViewLocked();
+ mpWrtShell->LockView( sal_True );
+ mpWrtShell->EndTextEdit();
+ mpWrtShell->LockView( bLockView );
+ }
+
+ if( mpWrtShell->IsSelFrmMode() || mpWrtShell->IsObjSelected())
+ {
+ mpWrtShell->UnSelectFrm();
+ mpWrtShell->LeaveSelFrmMode();
+ mpWrtShell->GetView().LeaveDrawCreate();
+ mpWrtShell->EnterStdMode();
+
+ mpWrtShell->DrawSelChanged();
+ mpView->StopShellTimer();
+ }
+}
+
+bool SwPostItMgr::HasActiveSidebarWin() const
+{
+ return mpActivePostIt != 0;
+}
+
+bool SwPostItMgr::HasActiveAnnotationWin() const
+{
+ return HasActiveSidebarWin() &&
+ dynamic_cast<sw::annotation::SwAnnotationWin*>(mpActivePostIt) != 0;
+}
+
+void SwPostItMgr::GrabFocusOnActiveSidebarWin()
+{
+ if ( HasActiveSidebarWin() )
+ {
+ mpActivePostIt->GrabFocus();
+ }
+}
+
+void SwPostItMgr::UpdateDataOnActiveSidebarWin()
+{
+ if ( HasActiveSidebarWin() )
+ {
+ mpActivePostIt->UpdateData();
+ }
+}
+
+void SwPostItMgr::DeleteActiveSidebarWin()
+{
+ if ( HasActiveSidebarWin() )
+ {
+ mpActivePostIt->Delete();
+ }
+}
+
+void SwPostItMgr::HideActiveSidebarWin()
+{
+ if ( HasActiveSidebarWin() )
+ {
+ mpActivePostIt->Hide();
+ }
+}
+
+void SwPostItMgr::ToggleInsModeOnActiveSidebarWin()
+{
+ if ( HasActiveSidebarWin() )
+ {
+ mpActivePostIt->ToggleInsMode();
+ }
+}
+
+void SwPostItMgr::ConnectSidebarWinToFrm( const SwFrm& rFrm,
+ const SwFmtFld& rFmtFld,
+ SwSidebarWin& rSidebarWin )
+{
+ if ( mpFrmSidebarWinContainer == 0 )
+ {
+ mpFrmSidebarWinContainer = new SwFrmSidebarWinContainer();
+ }
+
+ const bool bInserted = mpFrmSidebarWinContainer->insert( rFrm, rFmtFld, rSidebarWin );
+ if ( bInserted &&
+ mpWrtShell->GetAccessibleMap() )
+ {
+ mpWrtShell->GetAccessibleMap()->InvalidatePosOrSize( 0, 0, &rSidebarWin, SwRect() );
+ }
+}
+
+void SwPostItMgr::DisconnectSidebarWinFromFrm( const SwFrm& rFrm,
+ SwSidebarWin& rSidebarWin )
+{
+ if ( mpFrmSidebarWinContainer != 0 )
+ {
+ const bool bRemoved = mpFrmSidebarWinContainer->remove( rFrm, rSidebarWin );
+ if ( bRemoved &&
+ mpWrtShell->GetAccessibleMap() )
+ {
+ mpWrtShell->GetAccessibleMap()->Dispose( 0, 0, &rSidebarWin );
+ }
+ }
+}
+
+bool SwPostItMgr::HasFrmConnectedSidebarWins( const SwFrm& rFrm )
+{
+ bool bRet( false );
+
+ if ( mpFrmSidebarWinContainer != 0 )
+ {
+ bRet = !mpFrmSidebarWinContainer->empty( rFrm );
+ }
+
+ return bRet;
+}
+
+Window* SwPostItMgr::GetSidebarWinForFrmByIndex( const SwFrm& rFrm,
+ const sal_Int32 nIndex )
+{
+ Window* pSidebarWin( 0 );
+
+ if ( mpFrmSidebarWinContainer != 0 )
+ {
+ pSidebarWin = mpFrmSidebarWinContainer->get( rFrm, nIndex );
+ }
+
+ return pSidebarWin;
+}
+
+void SwPostItMgr::GetAllSidebarWinForFrm( const SwFrm& rFrm,
+ std::vector< Window* >* pChildren )
+{
+ if ( mpFrmSidebarWinContainer != 0 )
+ {
+ mpFrmSidebarWinContainer->getAll( rFrm, pChildren );
+ }
+}
+
+void SwNoteProps::Commit() {}
+void SwNoteProps::Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& ) {}
diff --git a/sw/source/ui/docvw/ShadowOverlayObject.cxx b/sw/source/ui/docvw/ShadowOverlayObject.cxx
new file mode 100644
index 000000000000..b11fc914b5fd
--- /dev/null
+++ b/sw/source/ui/docvw/ShadowOverlayObject.cxx
@@ -0,0 +1,268 @@
+/************************************************************************* *
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: postit.cxx,v $
+ * $Revision: 1.8.42.11 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#include "precompiled_sw.hxx"
+
+#include <ShadowOverlayObject.hxx>
+
+#include <view.hxx>
+#include <svx/sdrpaintwindow.hxx>
+#include <svx/svdview.hxx>
+#include <svx/sdr/overlay/overlaymanager.hxx>
+
+#include <sw_primitivetypes2d.hxx>
+#include <drawinglayer/primitive2d/primitivetools2d.hxx>
+#include <drawinglayer/primitive2d/fillgradientprimitive2d.hxx>
+
+namespace sw { namespace sidebarwindows {
+
+//////////////////////////////////////////////////////////////////////////////
+// helper SwPostItShadowPrimitive
+//
+// Used to allow view-dependent primitive definition. For that purpose, the
+// initially created primitive (this one) always has to be view-independent,
+// but the decomposition is made view-dependent. Very simple primitive which
+// just remembers the discrete data and applies it at decomposition time.
+
+class ShadowPrimitive : public drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D
+{
+private:
+ basegfx::B2DPoint maBasePosition;
+ basegfx::B2DPoint maSecondPosition;
+ ShadowState maShadowState;
+
+protected:
+ virtual drawinglayer::primitive2d::Primitive2DSequence create2DDecomposition(
+ const drawinglayer::geometry::ViewInformation2D& rViewInformation) const;
+
+public:
+ ShadowPrimitive(
+ const basegfx::B2DPoint& rBasePosition,
+ const basegfx::B2DPoint& rSecondPosition,
+ ShadowState aShadowState)
+ : drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D(),
+ maBasePosition(rBasePosition),
+ maSecondPosition(rSecondPosition),
+ maShadowState(aShadowState)
+ {}
+
+ // data access
+ const basegfx::B2DPoint& getBasePosition() const { return maBasePosition; }
+ const basegfx::B2DPoint& getSecondPosition() const { return maSecondPosition; }
+ ShadowState getShadowState() const { return maShadowState; }
+
+ virtual bool operator==( const drawinglayer::primitive2d::BasePrimitive2D& rPrimitive ) const;
+
+ DeclPrimitrive2DIDBlock()
+};
+
+drawinglayer::primitive2d::Primitive2DSequence ShadowPrimitive::create2DDecomposition(
+ const drawinglayer::geometry::ViewInformation2D& /*rViewInformation*/) const
+{
+ // get logic sizes in object coordinate system
+ drawinglayer::primitive2d::Primitive2DSequence xRetval;
+ basegfx::B2DRange aRange(getBasePosition());
+
+ switch(maShadowState)
+ {
+ case SS_NORMAL:
+ {
+ aRange.expand(basegfx::B2DTuple(getSecondPosition().getX(), getSecondPosition().getY() + (2.0 * getDiscreteUnit())));
+ const ::drawinglayer::attribute::FillGradientAttribute aFillGradientAttribute(
+ drawinglayer::attribute::GRADIENTSTYLE_LINEAR,
+ 0.0,
+ 0.5,
+ 0.5,
+ 1800.0 * F_PI1800,
+ basegfx::BColor(230.0/255.0,230.0/255.0,230.0/255.0),
+ basegfx::BColor(180.0/255.0,180.0/255.0,180.0/255.0),
+ 2);
+
+ const drawinglayer::primitive2d::Primitive2DReference xReference(
+ new drawinglayer::primitive2d::FillGradientPrimitive2D(
+ aRange,
+ aFillGradientAttribute));
+
+ xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+ break;
+ }
+ case SS_VIEW:
+ {
+ aRange.expand(basegfx::B2DTuple(getSecondPosition().getX(), getSecondPosition().getY() + (4.0 * getDiscreteUnit())));
+ const drawinglayer::attribute::FillGradientAttribute aFillGradientAttribute(
+ drawinglayer::attribute::GRADIENTSTYLE_LINEAR,
+ 0.0,
+ 0.5,
+ 0.5,
+ 1800.0 * F_PI1800,
+ basegfx::BColor(230.0/255.0,230.0/255.0,230.0/255.0),
+ basegfx::BColor(180.0/255.0,180.0/255.0,180.0/255.0),
+ 4);
+
+ const drawinglayer::primitive2d::Primitive2DReference xReference(
+ new drawinglayer::primitive2d::FillGradientPrimitive2D(
+ aRange,
+ aFillGradientAttribute));
+
+ xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+ break;
+ }
+ case SS_EDIT:
+ {
+ aRange.expand(basegfx::B2DTuple(getSecondPosition().getX(), getSecondPosition().getY() + (4.0 * getDiscreteUnit())));
+ const drawinglayer::attribute::FillGradientAttribute aFillGradientAttribute(
+ drawinglayer::attribute::GRADIENTSTYLE_LINEAR,
+ 0.0,
+ 0.5,
+ 0.5,
+ 1800.0 * F_PI1800,
+ basegfx::BColor(230.0/255.0,230.0/255.0,230.0/255.0),
+ basegfx::BColor(83.0/255.0,83.0/255.0,83.0/255.0),
+ 4);
+
+ const drawinglayer::primitive2d::Primitive2DReference xReference(
+ new drawinglayer::primitive2d::FillGradientPrimitive2D(
+ aRange,
+ aFillGradientAttribute));
+
+ xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+
+ return xRetval;
+}
+
+bool ShadowPrimitive::operator==( const drawinglayer::primitive2d::BasePrimitive2D& rPrimitive ) const
+{
+ if(drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D::operator==(rPrimitive))
+ {
+ const ShadowPrimitive& rCompare = static_cast< const ShadowPrimitive& >(rPrimitive);
+
+ return (getBasePosition() == rCompare.getBasePosition()
+ && getSecondPosition() == rCompare.getSecondPosition()
+ && getShadowState() == rCompare.getShadowState());
+ }
+
+ return false;
+}
+
+ImplPrimitrive2DIDBlock(ShadowPrimitive, PRIMITIVE2D_ID_SWSIDEBARSHADOWPRIMITIVE)
+
+/****** ShadowOverlayObject **************************************************/
+/* static */ ShadowOverlayObject* ShadowOverlayObject::CreateShadowOverlayObject( SwView& rDocView )
+{
+ ShadowOverlayObject* pShadowOverlayObject( 0 );
+
+ if ( rDocView.GetDrawView() )
+ {
+ SdrPaintWindow* pPaintWindow = rDocView.GetDrawView()->GetPaintWindow(0);
+ if( pPaintWindow )
+ {
+ sdr::overlay::OverlayManager* pOverlayManager = pPaintWindow->GetOverlayManager();
+
+ if ( pOverlayManager )
+ {
+ pShadowOverlayObject = new ShadowOverlayObject( basegfx::B2DPoint(0,0),
+ basegfx::B2DPoint(0,0),
+ Color(0,0,0),
+ SS_NORMAL );
+ pOverlayManager->add(*pShadowOverlayObject);
+ }
+ }
+ }
+
+ return pShadowOverlayObject;
+}
+
+/* static */ void ShadowOverlayObject::DestroyShadowOverlayObject( ShadowOverlayObject* pShadow )
+{
+ if ( pShadow )
+ {
+ if ( pShadow->getOverlayManager() )
+ {
+ pShadow->getOverlayManager()->remove(*pShadow);
+ }
+ delete pShadow;
+ }
+}
+
+ShadowOverlayObject::ShadowOverlayObject( const basegfx::B2DPoint& rBasePos,
+ const basegfx::B2DPoint& rSecondPosition,
+ Color aBaseColor,
+ ShadowState aState )
+ : OverlayObjectWithBasePosition(rBasePos, aBaseColor)
+ , maSecondPosition(rSecondPosition)
+ , mShadowState(aState)
+{
+}
+
+ShadowOverlayObject::~ShadowOverlayObject()
+{
+}
+
+drawinglayer::primitive2d::Primitive2DSequence ShadowOverlayObject::createOverlayObjectPrimitive2DSequence()
+{
+ const drawinglayer::primitive2d::Primitive2DReference aReference(
+ new ShadowPrimitive( getBasePosition(),
+ GetSecondPosition(),
+ GetShadowState() ) );
+ return drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1);
+}
+
+void ShadowOverlayObject::SetShadowState(ShadowState aState)
+{
+ if (mShadowState != aState)
+ {
+ mShadowState = aState;
+
+ objectChange();
+ }
+}
+
+void ShadowOverlayObject::SetPosition( const basegfx::B2DPoint& rPoint1,
+ const basegfx::B2DPoint& rPoint2)
+{
+ if(!rPoint1.equal(getBasePosition()) || !rPoint2.equal(GetSecondPosition()))
+ {
+ maBasePosition = rPoint1;
+ maSecondPosition = rPoint2;
+
+ objectChange();
+ }
+}
+
+} } // end of namespace sw::sidebarwindows
+
diff --git a/sw/source/ui/docvw/ShadowOverlayObject.hxx b/sw/source/ui/docvw/ShadowOverlayObject.hxx
new file mode 100644
index 000000000000..a00aea380fdb
--- /dev/null
+++ b/sw/source/ui/docvw/ShadowOverlayObject.hxx
@@ -0,0 +1,80 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: $
+ *
+ * $Revision: $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SHADOWOVERLAYOBJECT_HXX
+#define _SHADOWOVERLAYOBJECT_HXX
+
+#include <svx/sdr/overlay/overlayobject.hxx>
+
+class SwView;
+
+namespace sw { namespace sidebarwindows {
+
+enum ShadowState
+{
+ SS_NORMAL,
+ SS_VIEW,
+ SS_EDIT
+};
+
+class ShadowOverlayObject: public sdr::overlay::OverlayObjectWithBasePosition
+{
+ protected:
+ // geometry creation for OverlayObject
+ virtual drawinglayer::primitive2d::Primitive2DSequence createOverlayObjectPrimitive2DSequence();
+
+ private:
+ basegfx::B2DPoint maSecondPosition;
+ ShadowState mShadowState;
+
+ ShadowOverlayObject( const basegfx::B2DPoint& rBasePos,
+ const basegfx::B2DPoint& rSecondPosition,
+ Color aBaseColor,
+ ShadowState aState );
+ virtual ~ShadowOverlayObject();
+
+ public:
+ void SetShadowState(ShadowState aState);
+ inline ShadowState GetShadowState() {return mShadowState;}
+
+ inline const basegfx::B2DPoint& GetSecondPosition() const { return maSecondPosition; }
+ void SetSecondPosition( const basegfx::B2DPoint& rNew );
+
+ void SetPosition( const basegfx::B2DPoint& rPoint1,
+ const basegfx::B2DPoint& rPoint2 );
+
+ static ShadowOverlayObject* CreateShadowOverlayObject( SwView& rDocView );
+ static void DestroyShadowOverlayObject( ShadowOverlayObject* pShadow );
+};
+
+} } // end of namespace sw::sidebarwindows
+
+#endif
diff --git a/sw/source/ui/docvw/SidebarTxtControl.cxx b/sw/source/ui/docvw/SidebarTxtControl.cxx
new file mode 100644
index 000000000000..61d4884157cf
--- /dev/null
+++ b/sw/source/ui/docvw/SidebarTxtControl.cxx
@@ -0,0 +1,422 @@
+/************************************************************************* *
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: $
+ * $Revision: $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#include "precompiled_sw.hxx"
+
+#include <SidebarTxtControl.hxx>
+
+#include <SidebarTxtControlAcc.hxx>
+
+#include <SidebarWin.hxx>
+#include <PostItMgr.hxx>
+
+#include <cmdid.h>
+#include <docvw.hrc>
+
+#include <unotools/securityoptions.hxx>
+
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/mnumgr.hxx>
+
+#include <vcl/svapp.hxx>
+#include <vcl/help.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/gradient.hxx>
+#include <vcl/scrbar.hxx>
+
+#include <editeng/outliner.hxx>
+#include <editeng/editeng.hxx>
+#include <editeng/editview.hxx>
+#include <editeng/flditem.hxx>
+
+#include <uitool.hxx>
+#include <view.hxx>
+#include <wrtsh.hxx>
+#include <shellres.hxx>
+#include <SwRewriter.hxx>
+#include <undobj.hxx>
+
+namespace css = ::com::sun::star;
+
+namespace sw { namespace sidebarwindows {
+
+SidebarTxtControl::SidebarTxtControl( SwSidebarWin& rSidebarWin,
+ WinBits nBits,
+ SwView& rDocView,
+ SwPostItMgr& rPostItMgr )
+ : Control( &rSidebarWin, nBits )
+ , mrSidebarWin( rSidebarWin )
+ , mrDocView( rDocView )
+ , mrPostItMgr( rPostItMgr )
+ , mbMouseOver( false )
+{
+ AddEventListener( LINK( &mrSidebarWin, SwSidebarWin, WindowEventListener ) );
+}
+
+SidebarTxtControl::~SidebarTxtControl()
+{
+ RemoveEventListener( LINK( &mrSidebarWin, SwSidebarWin, WindowEventListener ) );
+}
+
+OutlinerView* SidebarTxtControl::GetTextView() const
+{
+ return mrSidebarWin.GetOutlinerView();
+}
+
+void SidebarTxtControl::GetFocus()
+{
+ Window::GetFocus();
+ if ( !mrSidebarWin.IsMouseOver() )
+ {
+ Invalidate();
+ }
+}
+
+void SidebarTxtControl::LoseFocus()
+{
+ // write the visible text back into the SwField
+ mrSidebarWin.UpdateData();
+
+ Window::LoseFocus();
+ if ( !mrSidebarWin.IsMouseOver() )
+ {
+ Invalidate();
+ }
+}
+
+void SidebarTxtControl::RequestHelp(const HelpEvent &rEvt)
+{
+ USHORT nResId = 0;
+ switch( mrSidebarWin.GetLayoutStatus() )
+ {
+ case SwPostItHelper::INSERTED: nResId = STR_REDLINE_INSERT; break;
+ case SwPostItHelper::DELETED: nResId = STR_REDLINE_DELETE; break;
+ default: nResId = 0;
+ }
+
+ SwContentAtPos aCntntAtPos( SwContentAtPos::SW_REDLINE );
+ if ( nResId &&
+ mrDocView.GetWrtShell().GetContentAtPos( mrSidebarWin.GetAnchorPos(), aCntntAtPos ) )
+ {
+ String sTxt;
+ sTxt = SW_RESSTR( nResId );
+ sTxt.AppendAscii( RTL_CONSTASCII_STRINGPARAM(": " ));
+ sTxt += aCntntAtPos.aFnd.pRedl->GetAuthorString();
+ sTxt.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " - " ));
+ sTxt += GetAppLangDateTimeString( aCntntAtPos.aFnd.pRedl->GetTimeStamp() );
+ Help::ShowQuickHelp( this,PixelToLogic(Rectangle(rEvt.GetMousePosPixel(),Size(50,10))),sTxt);
+ }
+}
+
+void SidebarTxtControl::Paint( const Rectangle& rRect)
+{
+ if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
+ {
+ if ( mrSidebarWin.IsMouseOverSidebarWin() ||
+ HasFocus() )
+ {
+ DrawGradient( Rectangle( Point(0,0), PixelToLogic(GetSizePixel()) ),
+ Gradient( GRADIENT_LINEAR,
+ mrSidebarWin.ColorDark(),
+ mrSidebarWin.ColorDark() ) );
+ }
+ else
+ {
+ DrawGradient( Rectangle( Point(0,0), PixelToLogic(GetSizePixel()) ),
+ Gradient( GRADIENT_LINEAR,
+ mrSidebarWin.ColorLight(),
+ mrSidebarWin.ColorDark()));
+ }
+ }
+
+ if ( GetTextView() )
+ {
+ GetTextView()->Paint( rRect );
+ }
+
+ if ( mrSidebarWin.GetLayoutStatus()==SwPostItHelper::DELETED )
+ {
+ SetLineColor(mrSidebarWin.GetChangeColor());
+ DrawLine( PixelToLogic( GetPosPixel() ),
+ PixelToLogic( GetPosPixel() +
+ Point( GetSizePixel().Width(),
+ GetSizePixel().Height() ) ) );
+ DrawLine( PixelToLogic( GetPosPixel() +
+ Point( GetSizePixel().Width(),0) ),
+ PixelToLogic( GetPosPixel() +
+ Point( 0, GetSizePixel().Height() ) ) );
+ }
+}
+
+void SidebarTxtControl::KeyInput( const KeyEvent& rKeyEvt )
+{
+ const KeyCode& rKeyCode = rKeyEvt.GetKeyCode();
+ USHORT nKey = rKeyCode.GetCode();
+ if ( ( rKeyCode.IsMod1() && rKeyCode.IsMod2() ) &&
+ ( (nKey == KEY_PAGEUP) || (nKey == KEY_PAGEDOWN) ) )
+ {
+ mrSidebarWin.SwitchToPostIt(nKey);
+ }
+ else if ( nKey == KEY_ESCAPE ||
+ ( rKeyCode.IsMod1() &&
+ ( nKey == KEY_PAGEUP ||
+ nKey == KEY_PAGEDOWN ) ) )
+ {
+ mrSidebarWin.SwitchToFieldPos();
+ }
+ else if ( nKey == KEY_INSERT )
+ {
+ if ( !rKeyCode.IsMod1() && !rKeyCode.IsMod2() )
+ {
+ mrSidebarWin.ToggleInsMode();
+ }
+ }
+ else
+ {
+ //let's make sure we see our note
+ mrPostItMgr.MakeVisible(&mrSidebarWin);
+
+ long aOldHeight = mrSidebarWin.GetPostItTextHeight();
+ bool bDone = false;
+
+ /// HACK: need to switch off processing of Undo/Redo in Outliner
+ if ( !( (nKey == KEY_Z || nKey == KEY_Y) && rKeyCode.IsMod1()) )
+ {
+ bool bIsProtected = mrSidebarWin.IsProtected();
+ if ( !bIsProtected ||
+ ( bIsProtected &&
+ !mrSidebarWin.GetOutlinerView()->GetOutliner()->GetEditEngine().DoesKeyChangeText(rKeyEvt)) )
+ {
+ bDone = GetTextView() && GetTextView()->PostKeyEvent( rKeyEvt );
+ }
+ else
+ {
+ InfoBox( this, SW_RES( MSG_READONLY_CONTENT )).Execute();
+ }
+ }
+ if (bDone)
+ mrSidebarWin.ResizeIfNeccessary( aOldHeight, mrSidebarWin.GetPostItTextHeight() );
+ else
+ {
+ // write back data first when showing navigator
+ if ( nKey==KEY_F5 )
+ mrSidebarWin.UpdateData();
+ if (!mrDocView.KeyInput(rKeyEvt))
+ Window::KeyInput(rKeyEvt);
+ }
+ }
+
+ mrDocView.GetViewFrame()->GetBindings().InvalidateAll(FALSE);
+}
+
+void SidebarTxtControl::MouseMove( const MouseEvent& rMEvt )
+{
+ if ( GetTextView() )
+ {
+ OutlinerView* pOutlinerView( GetTextView() );
+ pOutlinerView->MouseMove( rMEvt );
+ // mba: why does OutlinerView not handle the modifier setting?!
+ // this forces the postit to handle *all* pointer types
+ SetPointer( pOutlinerView->GetPointer( rMEvt.GetPosPixel() ) );
+
+ const EditView& aEV = pOutlinerView->GetEditView();
+ const SvxFieldItem* pItem = aEV.GetFieldUnderMousePointer();
+ if ( pItem )
+ {
+ const SvxFieldData* pFld = pItem->GetField();
+ const SvxURLField* pURL = PTR_CAST( SvxURLField, pFld );
+ if ( pURL )
+ {
+ String sURL( pURL->GetURL() );
+ SvtSecurityOptions aSecOpts;
+ if ( aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK) )
+ {
+ sURL.InsertAscii( ": ", 0 );
+ sURL.Insert( ViewShell::GetShellRes()->aHyperlinkClick, 0 );
+ }
+ Help::ShowQuickHelp( this,PixelToLogic(Rectangle(GetPosPixel(),Size(50,10))),sURL);
+ }
+ }
+ }
+}
+
+void SidebarTxtControl::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ if ( GetTextView() )
+ {
+ SvtSecurityOptions aSecOpts;
+ bool bExecuteMod = aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK);
+
+ if ( !bExecuteMod || (bExecuteMod && rMEvt.GetModifier() == KEY_MOD1))
+ {
+ const EditView& aEV = GetTextView()->GetEditView();
+ const SvxFieldItem* pItem = aEV.GetFieldUnderMousePointer();
+ if ( pItem )
+ {
+ const SvxFieldData* pFld = pItem->GetField();
+ const SvxURLField* pURL = PTR_CAST( SvxURLField, pFld );
+ if ( pURL )
+ {
+ GetTextView()->MouseButtonDown( rMEvt );
+ SwWrtShell &rSh = mrDocView.GetWrtShell();
+ String sURL( pURL->GetURL() );
+ String sTarget( pURL->GetTargetFrame() );
+ ::LoadURL( sURL, &rSh, URLLOAD_NOFILTER, &sTarget);
+ return;
+ }
+ }
+ }
+ }
+
+ GrabFocus();
+ if ( GetTextView() )
+ {
+ GetTextView()->MouseButtonDown( rMEvt );
+ }
+ mrDocView.GetViewFrame()->GetBindings().InvalidateAll(FALSE);
+}
+
+void SidebarTxtControl::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ if ( GetTextView() )
+ GetTextView()->MouseButtonUp( rMEvt );
+}
+
+IMPL_LINK( SidebarTxtControl, OnlineSpellCallback, SpellCallbackInfo*, pInfo )
+{
+ if ( pInfo->nCommand == SPELLCMD_STARTSPELLDLG )
+ {
+ mrDocView.GetViewFrame()->GetDispatcher()->Execute( FN_SPELL_GRAMMAR_DIALOG, SFX_CALLMODE_ASYNCHRON);
+ }
+ return 0;
+}
+
+IMPL_LINK( SidebarTxtControl, Select, Menu*, pSelMenu )
+{
+ mrSidebarWin.ExecuteCommand( pSelMenu->GetCurItemId() );
+ return 0;
+}
+
+void SidebarTxtControl::Command( const CommandEvent& rCEvt )
+{
+ if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )
+ {
+ if ( !mrSidebarWin.IsProtected() &&
+ GetTextView() &&
+ GetTextView()->IsWrongSpelledWordAtPos( rCEvt.GetMousePosPixel(),TRUE ))
+ {
+ Link aLink = LINK(this, SidebarTxtControl, OnlineSpellCallback);
+ GetTextView()->ExecuteSpellPopup(rCEvt.GetMousePosPixel(),&aLink);
+ }
+ else
+ {
+ SfxPopupMenuManager* aMgr = mrDocView.GetViewFrame()->GetDispatcher()->Popup(0, this,&rCEvt.GetMousePosPixel());
+ ((PopupMenu*)aMgr->GetSVMenu())->SetSelectHdl( LINK(this, SidebarTxtControl, Select) );
+
+ {
+ XubString aText = ((PopupMenu*)aMgr->GetSVMenu())->GetItemText( FN_DELETE_NOTE_AUTHOR );
+ SwRewriter aRewriter;
+ aRewriter.AddRule(UNDO_ARG1, mrSidebarWin.GetAuthor());
+ aText = aRewriter.Apply(aText);
+ ((PopupMenu*)aMgr->GetSVMenu())->SetItemText(FN_DELETE_NOTE_AUTHOR,aText);
+ }
+
+ if (rCEvt.IsMouseEvent())
+ ((PopupMenu*)aMgr->GetSVMenu())->Execute(this,rCEvt.GetMousePosPixel());
+ else
+ {
+ const Size aSize = GetSizePixel();
+ const Point aPos = Point( aSize.getWidth()/2, aSize.getHeight()/2 );
+ ((PopupMenu*)aMgr->GetSVMenu())->Execute(this,aPos);
+ }
+ delete aMgr;
+ }
+ }
+ else
+ if (rCEvt.GetCommand() == COMMAND_WHEEL)
+ {
+ if (mrSidebarWin.IsScrollbarVisible())
+ {
+ const CommandWheelData* pData = rCEvt.GetWheelData();
+ if (pData->IsShift() || pData->IsMod1() || pData->IsMod2())
+ {
+ mrDocView.HandleWheelCommands(rCEvt);
+ }
+ else
+ {
+ HandleScrollCommand( rCEvt, 0 , mrSidebarWin.Scrollbar());
+ }
+ }
+ else
+ {
+ mrDocView.HandleWheelCommands(rCEvt);
+ }
+ }
+ else
+ {
+ if ( GetTextView() )
+ GetTextView()->Command( rCEvt );
+ else
+ Window::Command(rCEvt);
+ }
+}
+
+XubString SidebarTxtControl::GetSurroundingText() const
+{
+ if( GetTextView() )
+ return GetTextView()->GetSurroundingText();
+ else
+ return XubString::EmptyString();
+}
+
+Selection SidebarTxtControl::GetSurroundingTextSelection() const
+{
+ if( GetTextView() )
+ return GetTextView()->GetSurroundingTextSelection();
+ else
+ return Selection( 0, 0 );
+}
+
+css::uno::Reference< css::accessibility::XAccessible > SidebarTxtControl::CreateAccessible()
+{
+
+ SidebarTxtControlAccessible* pAcc( new SidebarTxtControlAccessible( *this ) );
+ css::uno::Reference< css::awt::XWindowPeer > xWinPeer( pAcc );
+ SetWindowPeer( xWinPeer, pAcc );
+
+ css::uno::Reference< css::accessibility::XAccessible > xAcc( xWinPeer, css::uno::UNO_QUERY );
+ return xAcc;
+}
+
+} } // end of namespace sw::sidebarwindows
+
diff --git a/sw/source/ui/docvw/SidebarTxtControl.hxx b/sw/source/ui/docvw/SidebarTxtControl.hxx
new file mode 100644
index 000000000000..08a5de0003c4
--- /dev/null
+++ b/sw/source/ui/docvw/SidebarTxtControl.hxx
@@ -0,0 +1,87 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: $
+ *
+ * $Revision: $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SIDEBARTXTCONTROL_HXX
+#define _SIDEBARTXTCONTROL_HXX
+
+#include <vcl/ctrl.hxx>
+
+class OutlinerView;
+class SwView;
+class SwPostItMgr;
+class SpellCallbackInfo;
+
+namespace sw { namespace sidebarwindows {
+
+class SwSidebarWin;
+
+class SidebarTxtControl : public Control
+{
+ private:
+ SwSidebarWin& mrSidebarWin;
+ SwView& mrDocView;
+ SwPostItMgr& mrPostItMgr;
+
+ bool mbMouseOver;
+
+ protected:
+ virtual void Paint( const Rectangle& rRect);
+ virtual void KeyInput( const KeyEvent& rKeyEvt );
+ virtual void MouseMove( const MouseEvent& rMEvt );
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void MouseButtonUp( const MouseEvent& rMEvt );
+ virtual void Command( const CommandEvent& rCEvt );
+ virtual void LoseFocus();
+ virtual void RequestHelp(const HelpEvent &rEvt);
+ virtual XubString GetSurroundingText() const;
+ virtual Selection GetSurroundingTextSelection() const;
+
+ DECL_LINK( Select, Menu* );
+
+ public:
+ SidebarTxtControl( SwSidebarWin& rSidebarWin,
+ WinBits nBits,
+ SwView& rDocView,
+ SwPostItMgr& rPostItMgr );
+ ~SidebarTxtControl();
+
+ virtual void GetFocus();
+
+ OutlinerView* GetTextView() const;
+
+ DECL_LINK( OnlineSpellCallback, SpellCallbackInfo*);
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
+};
+
+} } // end of namespace sw::sidebarwindows
+
+#endif
diff --git a/sw/source/ui/docvw/SidebarTxtControlAcc.cxx b/sw/source/ui/docvw/SidebarTxtControlAcc.cxx
new file mode 100644
index 000000000000..8b0f0293367c
--- /dev/null
+++ b/sw/source/ui/docvw/SidebarTxtControlAcc.cxx
@@ -0,0 +1,317 @@
+/************************************************************************* *
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: $
+ * $Revision: $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#include "precompiled_sw.hxx"
+
+#include <SidebarTxtControlAcc.hxx>
+
+#include <SidebarTxtControl.hxx>
+
+#include <svl/brdcst.hxx>
+#include <toolkit/awt/vclxaccessiblecomponent.hxx>
+#include <editeng/unoedsrc.hxx>
+#include <editeng/unoforou.hxx>
+#include <editeng/unoviwou.hxx>
+#include <editeng/unoedhlp.hxx>
+#include <svx/AccessibleTextHelper.hxx>
+#include <editeng/outliner.hxx>
+
+
+namespace css = ::com::sun::star;
+
+namespace sw { namespace sidebarwindows {
+
+// =============================================================================
+// declaration and implementation of <SvxEditSource>
+// for <::accessibiliy::AccessibleTextHelper> instance
+// =============================================================================
+class SidebarTextEditSource : public SvxEditSource,
+ public SfxBroadcaster
+{
+ public:
+ SidebarTextEditSource( SidebarTxtControl& rSidebarTxtControl );
+ virtual ~SidebarTextEditSource();
+
+ virtual SvxEditSource* Clone() const;
+
+ virtual SvxTextForwarder* GetTextForwarder();
+ virtual SvxViewForwarder* GetViewForwarder();
+ virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool bCreate = sal_False );
+
+ virtual void UpdateData();
+
+ virtual SfxBroadcaster& GetBroadcaster() const;
+ DECL_LINK( NotifyHdl, EENotify* );
+
+ private:
+ SidebarTxtControl& mrSidebarTxtControl;
+ SvxOutlinerForwarder mTextForwarder;
+ SvxDrawOutlinerViewForwarder mViewForwarder;
+};
+
+SidebarTextEditSource::SidebarTextEditSource( SidebarTxtControl& rSidebarTxtControl )
+ : SvxEditSource()
+ , mrSidebarTxtControl( rSidebarTxtControl )
+ , mTextForwarder( *(rSidebarTxtControl.GetTextView()->GetOutliner()), NULL )
+ , mViewForwarder( *(rSidebarTxtControl.GetTextView()) )
+{
+ if ( mrSidebarTxtControl.GetTextView() )
+ {
+ mrSidebarTxtControl.GetTextView()->GetOutliner()->SetNotifyHdl( LINK(this, SidebarTextEditSource, NotifyHdl) );
+ }
+}
+
+SidebarTextEditSource::~SidebarTextEditSource()
+{
+ if ( mrSidebarTxtControl.GetTextView() )
+ {
+ mrSidebarTxtControl.GetTextView()->GetOutliner()->SetNotifyHdl( Link() );
+ }
+}
+
+SvxEditSource* SidebarTextEditSource::Clone() const
+{
+ return new SidebarTextEditSource( mrSidebarTxtControl );
+}
+
+SvxTextForwarder* SidebarTextEditSource::GetTextForwarder()
+{
+ return &mTextForwarder;
+}
+
+SvxViewForwarder* SidebarTextEditSource::GetViewForwarder()
+{
+ return &mViewForwarder;
+}
+
+SvxEditViewForwarder* SidebarTextEditSource::GetEditViewForwarder( sal_Bool /*bCreate*/ )
+{
+ return &mViewForwarder;
+}
+
+void SidebarTextEditSource::UpdateData()
+{
+ // nothing to do
+}
+
+SfxBroadcaster& SidebarTextEditSource::GetBroadcaster() const
+{
+ return *( const_cast< SidebarTextEditSource* > (this) );
+}
+
+IMPL_LINK(SidebarTextEditSource, NotifyHdl, EENotify*, pNotify)
+{
+ if ( pNotify )
+ {
+ ::std::auto_ptr< SfxHint > aHint( SvxEditSourceHelper::EENotification2Hint( pNotify ) );
+
+ if( aHint.get() )
+ {
+ Broadcast( *aHint.get() );
+ }
+ }
+
+ return 0;
+}
+
+
+// =============================================================================
+// declaration and implementation of accessible context for <SidebarTxtControl> instance
+// =============================================================================
+class SidebarTxtControlAccessibleContext : public VCLXAccessibleComponent
+{
+ public:
+ explicit SidebarTxtControlAccessibleContext( SidebarTxtControl& rSidebarTxtControl );
+ virtual ~SidebarTxtControlAccessibleContext();
+
+ virtual sal_Int32 SAL_CALL
+ getAccessibleChildCount()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
+ getAccessibleChild( sal_Int32 i )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+
+ using WeakAggComponentImplHelperBase::addEventListener;
+ using WeakAggComponentImplHelperBase::removeEventListener;
+
+ virtual void SAL_CALL
+ addEventListener (
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleEventListener >& xListener)
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL
+ removeEventListener (
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleEventListener >& xListener)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent );
+
+ private:
+ SidebarTxtControl& mrSidebarTxtControl;
+ ::accessibility::AccessibleTextHelper* mpAccessibleTextHelper;
+
+ ::vos::OMutex maMutex;
+
+ void defunc();
+};
+
+SidebarTxtControlAccessibleContext::SidebarTxtControlAccessibleContext( SidebarTxtControl& rSidebarTxtControl )
+ : VCLXAccessibleComponent( rSidebarTxtControl.GetWindowPeer() )
+ , mrSidebarTxtControl( rSidebarTxtControl )
+ , mpAccessibleTextHelper( 0 )
+ , maMutex()
+{
+ ::std::auto_ptr<SvxEditSource> pEditSource(
+ new SidebarTextEditSource( mrSidebarTxtControl ) );
+ mpAccessibleTextHelper = new ::accessibility::AccessibleTextHelper( pEditSource );
+ mpAccessibleTextHelper->SetEventSource( mrSidebarTxtControl.GetWindowPeer() );
+}
+
+SidebarTxtControlAccessibleContext::~SidebarTxtControlAccessibleContext()
+{
+ defunc();
+}
+
+void SidebarTxtControlAccessibleContext::defunc()
+{
+ delete mpAccessibleTextHelper;
+ mpAccessibleTextHelper = 0;
+}
+
+sal_Int32 SAL_CALL SidebarTxtControlAccessibleContext::getAccessibleChildCount()
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ vos::OGuard aGuard( maMutex );
+
+ sal_Int32 nChildCount( 0 );
+
+ if ( mpAccessibleTextHelper )
+ {
+ nChildCount = mpAccessibleTextHelper->GetChildCount();
+ }
+
+ return nChildCount;
+}
+
+css::uno::Reference< css::accessibility::XAccessible > SAL_CALL SidebarTxtControlAccessibleContext::getAccessibleChild( sal_Int32 i )
+ throw ( css::lang::IndexOutOfBoundsException, css::uno::RuntimeException )
+{
+ vos::OGuard aGuard( maMutex );
+
+ css::uno::Reference< css::accessibility::XAccessible > xChild;
+
+ if ( mpAccessibleTextHelper )
+ {
+ xChild = mpAccessibleTextHelper->GetChild( i );
+ }
+
+ return xChild;
+}
+
+void SAL_CALL SidebarTxtControlAccessibleContext::addEventListener (
+ const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener)
+ throw (css::uno::RuntimeException)
+{
+ vos::OGuard aGuard( maMutex );
+
+ if ( mpAccessibleTextHelper )
+ {
+ mpAccessibleTextHelper->AddEventListener(xListener);
+ }
+}
+
+void SAL_CALL SidebarTxtControlAccessibleContext::removeEventListener (
+ const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener)
+ throw (css::uno::RuntimeException)
+{
+ vos::OGuard aGuard( maMutex );
+
+ if ( mpAccessibleTextHelper )
+ {
+ mpAccessibleTextHelper->RemoveEventListener(xListener);
+ }
+}
+
+void SidebarTxtControlAccessibleContext::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
+{
+ if ( mpAccessibleTextHelper )
+ {
+ switch ( rVclWindowEvent.GetId() )
+ {
+ case VCLEVENT_OBJECT_DYING:
+ {
+ defunc();
+ }
+ break;
+ case VCLEVENT_WINDOW_GETFOCUS:
+ case VCLEVENT_CONTROL_GETFOCUS:
+ {
+ mpAccessibleTextHelper->SetFocus( sal_True );
+ }
+ break;
+ case VCLEVENT_WINDOW_LOSEFOCUS:
+ case VCLEVENT_CONTROL_LOSEFOCUS:
+ {
+ mpAccessibleTextHelper->SetFocus( sal_False );
+ }
+ break;
+ }
+ }
+
+ VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent );
+}
+
+// =============================================================================
+// implementaion of accessible for <SidebarTxtControl> instance
+// =============================================================================
+SidebarTxtControlAccessible::SidebarTxtControlAccessible( SidebarTxtControl& rSidebarTxtControl )
+ : VCLXWindow()
+ , mrSidebarTxtControl( rSidebarTxtControl )
+{
+ SetWindow( &mrSidebarTxtControl );
+}
+
+SidebarTxtControlAccessible::~SidebarTxtControlAccessible()
+{
+}
+
+css::uno::Reference< css::accessibility::XAccessibleContext > SidebarTxtControlAccessible::CreateAccessibleContext()
+{
+ SidebarTxtControlAccessibleContext* pAccContext(
+ new SidebarTxtControlAccessibleContext( mrSidebarTxtControl ) );
+ css::uno::Reference< css::accessibility::XAccessibleContext > xAcc( pAccContext );
+ return xAcc;
+}
+
+} } // end of namespace sw::sidebarwindows
+
diff --git a/sw/source/ui/docvw/SidebarTxtControlAcc.hxx b/sw/source/ui/docvw/SidebarTxtControlAcc.hxx
new file mode 100644
index 000000000000..57edc50512d5
--- /dev/null
+++ b/sw/source/ui/docvw/SidebarTxtControlAcc.hxx
@@ -0,0 +1,56 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: $
+ *
+ * $Revision: $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SIDEBARTXTCONTROLACC_HXX
+#define _SIDEBARTXTCONTROLACC_HXX
+
+#include <toolkit/awt/vclxwindow.hxx>
+
+namespace sw { namespace sidebarwindows {
+
+class SidebarTxtControl;
+
+class SidebarTxtControlAccessible : public VCLXWindow
+{
+ public:
+ explicit SidebarTxtControlAccessible( SidebarTxtControl& rSidebarTxtControl );
+ virtual ~SidebarTxtControlAccessible();
+
+ virtual com::sun::star::uno::Reference< com::sun::star::accessibility::XAccessibleContext >
+ CreateAccessibleContext();
+
+ private:
+ SidebarTxtControl& mrSidebarTxtControl;
+};
+
+} } // end of namespace sw::sidebarwindows
+
+#endif
diff --git a/sw/source/ui/docvw/SidebarWin.cxx b/sw/source/ui/docvw/SidebarWin.cxx
new file mode 100644
index 000000000000..cce6db3a891b
--- /dev/null
+++ b/sw/source/ui/docvw/SidebarWin.cxx
@@ -0,0 +1,1373 @@
+/************************************************************************* *
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompiled_sw.hxx"
+
+#include <SidebarWin.hxx>
+#include <SidebarWinAcc.hxx>
+#include <PostItMgr.hxx>
+
+#include <SidebarTxtControl.hxx>
+#include <AnchorOverlayObject.hxx>
+#include <ShadowOverlayObject.hxx>
+
+#include <annotation.hrc>
+#include <popup.hrc>
+#include <docvw.hrc>
+#include <app.hrc>
+#include <access.hrc>
+
+#include <viewopt.hxx>
+#include <cmdid.h>
+
+#include <editeng/fontitem.hxx>
+#include <editeng/fhgtitem.hxx>
+#include <editeng/langitem.hxx>
+#include <editeng/editview.hxx>
+#include <editeng/outliner.hxx>
+#include <editeng/editeng.hxx>
+#include <editeng/eeitem.hxx>
+
+#include <svl/zforlist.hxx>
+#include <svl/undo.hxx>
+#include <svl/stritem.hxx>
+
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+
+#include <vcl/scrbar.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/menubtn.hxx>
+
+#include <edtwin.hxx>
+#include <view.hxx>
+#include <docsh.hxx>
+#include <wrtsh.hxx>
+#include <doc.hxx>
+#include <swmodule.hxx>
+#include <langhelper.hxx>
+
+#include <sw_primitivetypes2d.hxx>
+#include <drawinglayer/primitive2d/primitivetools2d.hxx>
+#include <drawinglayer/primitive2d/fillgradientprimitive2d.hxx>
+#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
+#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
+#include <drawinglayer/primitive2d/shadowprimitive2d.hxx>
+
+namespace css = ::com::sun::star;
+
+namespace sw { namespace sidebarwindows {
+
+#define METABUTTON_WIDTH 16
+#define METABUTTON_HEIGHT 18
+#define METABUTTON_AREA_WIDTH 30
+#define POSTIT_META_HEIGHT (sal_Int32) 30
+#define POSTIT_MINIMUMSIZE_WITHOUT_META 50
+
+#define POSTIT_SHADOW_BRIGHT Color(180,180,180)
+#define POSTIT_SHADOW_DARK Color(83,83,83)
+
+#define EMPTYSTRING rtl::OUString::createFromAscii("")
+
+/************** SwSidebarWin************************************/
+SwSidebarWin::SwSidebarWin( SwEditWin& rEditWin,
+ WinBits nBits,
+ SwPostItMgr& aMgr,
+ SwPostItBits aBits,
+ SwSidebarItem& rSidebarItem )
+ : Window(&rEditWin, nBits)
+ , mrMgr(aMgr)
+ , mrView( rEditWin.GetView() )
+ , nFlags(aBits)
+ , mnEventId(0)
+ , mpOutlinerView(0)
+ , mpOutliner(0)
+ , mpSidebarTxtControl(0)
+ , mpVScrollbar(0)
+ , mpMetadataAuthor(0)
+ , mpMetadataDate(0)
+ , mpMenuButton(0)
+ , mpAnchor(0)
+ , mpShadow(0)
+ , mColorAnchor()
+ , mColorDark()
+ , mColorLight()
+ , mChangeColor()
+ , meSidebarPosition( sw::sidebarwindows::SIDEBAR_NONE )
+ , mPosSize()
+ , mAnchorRect()
+ , mPageBorder( 0 )
+ , mbMouseOver( false )
+ , mLayoutStatus( SwPostItHelper::INVISIBLE )
+ , mbReadonly( false )
+ , mbIsFollow( false )
+ , mrSidebarItem( rSidebarItem )
+ , mpAnchorFrm( rSidebarItem.maLayoutInfo.mpAnchorFrm )
+{
+ mpShadow = ShadowOverlayObject::CreateShadowOverlayObject( mrView );
+ if ( mpShadow )
+ {
+ mpShadow->setVisible(false);
+ }
+
+ mrMgr.ConnectSidebarWinToFrm( *(mrSidebarItem.maLayoutInfo.mpAnchorFrm),
+ *(mrSidebarItem.GetFmtFld()),
+ *this );
+}
+
+SwSidebarWin::~SwSidebarWin()
+{
+ mrMgr.DisconnectSidebarWinFromFrm( *(mrSidebarItem.maLayoutInfo.mpAnchorFrm),
+ *this );
+
+ Disable();
+
+ if ( mpSidebarTxtControl )
+ {
+ if ( mpOutlinerView )
+ {
+ mpOutlinerView->SetWindow( 0 );
+ }
+ delete mpSidebarTxtControl;
+ mpSidebarTxtControl = 0;
+ }
+
+ if ( mpOutlinerView )
+ {
+ delete mpOutlinerView;
+ mpOutlinerView = 0;
+ }
+
+ if (mpOutliner)
+ {
+ delete mpOutliner;
+ mpOutliner = 0;
+ }
+
+ if (mpMetadataAuthor)
+ {
+ mpMetadataAuthor->RemoveEventListener( LINK( this, SwSidebarWin, WindowEventListener ) );
+ delete mpMetadataAuthor;
+ mpMetadataAuthor = 0;
+ }
+
+ if (mpMetadataDate)
+ {
+ mpMetadataDate->RemoveEventListener( LINK( this, SwSidebarWin, WindowEventListener ) );
+ delete mpMetadataDate;
+ mpMetadataDate = 0;
+ }
+
+ if (mpVScrollbar)
+ {
+ mpVScrollbar->RemoveEventListener( LINK( this, SwSidebarWin, WindowEventListener ) );
+ delete mpVScrollbar;
+ mpVScrollbar = 0;
+ }
+
+ AnchorOverlayObject::DestroyAnchorOverlayObject( mpAnchor );
+ mpAnchor = 0;
+
+ ShadowOverlayObject::DestroyShadowOverlayObject( mpShadow );
+ mpShadow = 0;
+
+ delete mpMenuButton;
+ mpMenuButton = 0;
+
+ if (mnEventId)
+ Application::RemoveUserEvent( mnEventId );
+}
+
+void SwSidebarWin::Paint( const Rectangle& rRect)
+{
+ Window::Paint(rRect);
+
+ if (mpMetadataAuthor->IsVisible() )
+ {
+ //draw left over space
+ if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
+ {
+ SetFillColor(COL_BLACK);
+ }
+ else
+ {
+ SetFillColor(mColorDark);
+ }
+ SetLineColor();
+ DrawRect( PixelToLogic(
+ Rectangle( Point( mpMetadataAuthor->GetPosPixel().X() +
+ mpMetadataAuthor->GetSizePixel().Width(),
+ mpMetadataAuthor->GetPosPixel().Y() ),
+ Size( GetMetaButtonAreaWidth(),
+ mpMetadataAuthor->GetSizePixel().Height() +
+ mpMetadataDate->GetSizePixel().Height() ) ) ) );
+ }
+}
+
+void SwSidebarWin::SetPosSizePixelRect( long nX,
+ long nY,
+ long nWidth,
+ long nHeight,
+ const SwRect &aRect,
+ const long aPageBorder)
+{
+ mPosSize = Rectangle(Point(nX,nY),Size(nWidth,nHeight));
+ mAnchorRect = aRect;
+ mPageBorder = aPageBorder;
+}
+
+void SwSidebarWin::SetSize( const Size& rNewSize )
+{
+ mPosSize.SetSize(rNewSize);
+}
+
+void SwSidebarWin::SetVirtualPosSize( const Point& aPoint, const Size& aSize)
+{
+ mPosSize = Rectangle(aPoint,aSize);
+}
+
+void SwSidebarWin::TranslateTopPosition(const long aAmount)
+{
+ mPosSize.Move(0,aAmount);
+}
+
+void SwSidebarWin::ShowAnchorOnly(const Point &aPoint)
+{
+ HideNote();
+ SetPosAndSize();
+ if (mpAnchor)
+ {
+ mpAnchor->SetSixthPosition(basegfx::B2DPoint(aPoint.X(),aPoint.Y()));
+ mpAnchor->SetSeventhPosition(basegfx::B2DPoint(aPoint.X(),aPoint.Y()));
+ mpAnchor->SetAnchorState(AS_ALL);
+ mpAnchor->setVisible(true);
+ }
+ if (mpShadow)
+ mpShadow->setVisible(false);
+}
+
+SfxItemSet SwSidebarWin::DefaultItem()
+{
+ SfxItemSet aItem( mrView.GetDocShell()->GetPool() );
+ aItem.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT));
+ aItem.Put(SvxFontItem(FAMILY_SWISS,GetSettings().GetStyleSettings().GetFieldFont().GetName(),
+ EMPTYSTRING,PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO));
+ return aItem;
+}
+
+void SwSidebarWin::InitControls()
+{
+ AddEventListener( LINK( this, SwSidebarWin, WindowEventListener ) );
+
+ // actual window which holds the user text
+ mpSidebarTxtControl = new SidebarTxtControl( *this,
+ WB_NODIALOGCONTROL,
+ mrView, mrMgr );
+ mpSidebarTxtControl->SetPointer(Pointer(POINTER_TEXT));
+
+ // window controls for author and date
+ mpMetadataAuthor = new Edit( this, 0 );
+ mpMetadataAuthor->SetAccessibleName( SW_RES( STR_ACCESS_ANNOTATION_AUTHOR_NAME ) );
+ mpMetadataAuthor->SetReadOnly();
+ mpMetadataAuthor->AlwaysDisableInput(true);
+ mpMetadataAuthor->SetCallHandlersOnInputDisabled(true);
+ mpMetadataAuthor->AddEventListener( LINK( this, SwSidebarWin, WindowEventListener ) );
+ // we should leave this setting alone, but for this we need a better layout algo
+ // with variable meta size height
+ {
+ AllSettings aSettings = mpMetadataAuthor->GetSettings();
+ StyleSettings aStyleSettings = aSettings.GetStyleSettings();
+ Font aFont = aStyleSettings.GetFieldFont();
+ aFont.SetHeight(8);
+ aStyleSettings.SetFieldFont(aFont);
+ aSettings.SetStyleSettings(aStyleSettings);
+ mpMetadataAuthor->SetSettings(aSettings);
+ }
+
+ mpMetadataDate = new Edit( this, 0 );
+ mpMetadataDate->SetAccessibleName( SW_RES( STR_ACCESS_ANNOTATION_DATE_NAME ) );
+ mpMetadataDate->SetReadOnly();
+ mpMetadataDate->AlwaysDisableInput(true);
+ mpMetadataDate->SetCallHandlersOnInputDisabled(true);
+ mpMetadataDate->AddEventListener( LINK( this, SwSidebarWin, WindowEventListener ) );
+ // we should leave this setting alone, but for this we need a better layout algo
+ // with variable meta size height
+ {
+ AllSettings aSettings = mpMetadataDate->GetSettings();
+ StyleSettings aStyleSettings = aSettings.GetStyleSettings();
+ Font aFont = aStyleSettings.GetFieldFont();
+ aFont.SetHeight(8);
+ aStyleSettings.SetFieldFont(aFont);
+ aSettings.SetStyleSettings(aStyleSettings);
+ mpMetadataDate->SetSettings(aSettings);
+ }
+
+
+ SwDocShell* aShell = mrView.GetDocShell();
+ mpOutliner = new Outliner(&aShell->GetPool(),OUTLINERMODE_TEXTOBJECT);
+ aShell->GetDoc()->SetCalcFieldValueHdl( mpOutliner );
+ mpOutliner->SetUpdateMode( TRUE );
+ Rescale();
+
+ OutputDevice* pDev = aShell->GetDoc()->getReferenceDevice(TRUE);
+ if ( pDev )
+ {
+ mpOutliner->SetRefDevice( pDev );
+ }
+
+ mpOutlinerView = new OutlinerView ( mpOutliner, mpSidebarTxtControl );
+ mpOutlinerView->SetBackgroundColor(COL_TRANSPARENT);
+ mpOutliner->InsertView(mpOutlinerView );
+ mpOutlinerView->SetOutputArea( PixelToLogic( Rectangle(0,0,1,1) ) );
+
+ mpOutlinerView->SetAttribs(DefaultItem());
+
+ // TODO: ??
+ EEHorizontalTextDirection aDefHoriTextDir = Application::GetSettings().GetLayoutRTL() ? EE_HTEXTDIR_R2L : EE_HTEXTDIR_L2R;
+ mpOutliner->SetDefaultHorizontalTextDirection( aDefHoriTextDir );
+
+ //create Scrollbars
+ mpVScrollbar = new ScrollBar(this, WB_3DLOOK |WB_VSCROLL|WB_DRAG);
+ mpVScrollbar->EnableNativeWidget(false);
+ mpVScrollbar->EnableRTL( false );
+ mpVScrollbar->SetScrollHdl(LINK(this, SwSidebarWin, ScrollHdl));
+ mpVScrollbar->EnableDrag();
+ mpVScrollbar->AddEventListener( LINK( this, SwSidebarWin, WindowEventListener ) );
+
+ const SwViewOption* pVOpt = mrView.GetWrtShellPtr()->GetViewOptions();
+ ULONG nCntrl = mpOutliner->GetControlWord();
+ // TODO: crash when AUTOCOMPLETE enabled
+ nCntrl |= EE_CNTRL_MARKFIELDS | EE_CNTRL_PASTESPECIAL | EE_CNTRL_AUTOCORRECT | EV_CNTRL_AUTOSCROLL | EE_CNTRL_URLSFXEXECUTE; // | EE_CNTRL_AUTOCOMPLETE;
+ if (pVOpt->IsFieldShadings())
+ nCntrl |= EE_CNTRL_MARKFIELDS;
+ else
+ nCntrl &= ~EE_CNTRL_MARKFIELDS;
+ if (pVOpt->IsOnlineSpell())
+ nCntrl |= EE_CNTRL_ONLINESPELLING;
+ else
+ nCntrl &= ~EE_CNTRL_ONLINESPELLING;
+ mpOutliner->SetControlWord(nCntrl);
+
+ sal_uInt16 aIndex = SW_MOD()->InsertRedlineAuthor(GetAuthor());
+ SetColor( mrMgr.GetColorDark(aIndex),
+ mrMgr.GetColorLight(aIndex),
+ mrMgr.GetColorAnchor(aIndex));
+
+ CheckMetaText();
+
+ mpMenuButton = CreateMenuButton();
+
+ SetLanguage(GetLanguage());
+ GetOutlinerView()->StartSpeller();
+ SetPostItText();
+ Engine()->CompleteOnlineSpelling();
+
+ mpSidebarTxtControl->Show();
+ mpMetadataAuthor->Show();
+ mpMetadataDate->Show();
+ mpVScrollbar->Show();
+}
+
+void SwSidebarWin::CheckMetaText()
+{
+ const LocaleDataWrapper& rLocalData = SvtSysLocale().GetLocaleData();
+ String sMeta = GetAuthor();
+ if (sMeta.Len() == 0)
+ {
+ sMeta = String(SW_RES(STR_NOAUTHOR));
+ }
+ else if (sMeta.Len() > 22)
+ {
+ sMeta.Erase(20);
+ sMeta = sMeta + rtl::OUString::createFromAscii("...");
+ }
+ if ( mpMetadataAuthor->GetText() != sMeta )
+ {
+ mpMetadataAuthor->SetText(sMeta);
+ }
+
+ Date aDate = GetDate();
+ if (aDate==Date())
+ {
+ sMeta = String(SW_RES(STR_POSTIT_TODAY));
+ }
+ else if (aDate == Date(Date()-1))
+ {
+ sMeta = String(SW_RES(STR_POSTIT_YESTERDAY));
+ }
+ else if (aDate.IsValid() )
+ {
+ sMeta = rLocalData.getDate(aDate);
+ }
+ else
+ {
+ sMeta = String(SW_RES(STR_NODATE));
+ }
+ if (GetTime()!=0)
+ {
+ sMeta = sMeta + rtl::OUString::createFromAscii(" ") + rLocalData.getTime( GetTime(),false );
+ }
+ if ( mpMetadataDate->GetText() != sMeta )
+ {
+ mpMetadataDate->SetText(sMeta);
+ }
+
+}
+
+void SwSidebarWin::Rescale()
+{
+ MapMode aMode = GetParent()->GetMapMode();
+ aMode.SetOrigin( Point() );
+ mpOutliner->SetRefMapMode( aMode );
+ SetMapMode( aMode );
+ mpSidebarTxtControl->SetMapMode( aMode );
+ if ( mpMetadataAuthor )
+ {
+ Font aFont( mpMetadataAuthor->GetSettings().GetStyleSettings().GetFieldFont() );
+ sal_Int32 nHeight = aFont.GetHeight();
+ nHeight = nHeight * aMode.GetScaleY().GetNumerator() / aMode.GetScaleY().GetDenominator();
+ aFont.SetHeight( nHeight );
+ mpMetadataAuthor->SetControlFont( aFont );
+ }
+ if ( mpMetadataDate )
+ {
+ Font aFont( mpMetadataDate->GetSettings().GetStyleSettings().GetFieldFont() );
+ sal_Int32 nHeight = aFont.GetHeight();
+ nHeight = nHeight * aMode.GetScaleY().GetNumerator() / aMode.GetScaleY().GetDenominator();
+ aFont.SetHeight( nHeight );
+ mpMetadataDate->SetControlFont( aFont );
+ }
+}
+
+void SwSidebarWin::SetPosAndSize()
+{
+ bool bChange = false;
+
+ if (GetSizePixel() != mPosSize.GetSize())
+ {
+ bChange = true;
+ SetSizePixel(mPosSize.GetSize());
+ DoResize();
+ }
+
+ if (GetPosPixel().X() != mPosSize.TopLeft().X() || (abs(GetPosPixel().Y() - mPosSize.TopLeft().Y()) > 5) )
+ {
+ bChange = true;
+ SetPosPixel(mPosSize.TopLeft());
+
+ Point aLineStart;
+ Point aLineEnd ;
+ switch ( meSidebarPosition )
+ {
+ case sw::sidebarwindows::SIDEBAR_LEFT:
+ {
+ aLineStart = EditWin()->PixelToLogic( Point(GetPosPixel().X()+GetSizePixel().Width(),GetPosPixel().Y()-1) );
+ aLineEnd = EditWin()->PixelToLogic( Point(GetPosPixel().X(),GetPosPixel().Y()-1) );
+ }
+ break;
+ case sw::sidebarwindows::SIDEBAR_RIGHT:
+ {
+ aLineStart = EditWin()->PixelToLogic( Point(GetPosPixel().X(),GetPosPixel().Y()-1) );
+ aLineEnd = EditWin()->PixelToLogic( Point(GetPosPixel().X()+GetSizePixel().Width(),GetPosPixel().Y()-1) );
+ }
+ break;
+ default:
+ ASSERT( false,
+ "<SwSidebarWin::SetPosAndSize()> - unexpected position of sidebar" );
+ break;
+ }
+
+ if (!IsPreview())
+ {
+ if (mpAnchor)
+ {
+ mpAnchor->SetAllPosition( basegfx::B2DPoint( mAnchorRect.Left() , mAnchorRect.Bottom() - 5* 15),
+ basegfx::B2DPoint( mAnchorRect.Left()-5*15 , mAnchorRect.Bottom()+5*15),
+ basegfx::B2DPoint( mAnchorRect.Left()+5*15 , mAnchorRect.Bottom()+5*15),
+ basegfx::B2DPoint( mAnchorRect.Left(), mAnchorRect.Bottom()+2*15),
+ basegfx::B2DPoint( mPageBorder ,mAnchorRect.Bottom()+2*15),
+ basegfx::B2DPoint( aLineStart.X(),aLineStart.Y()),
+ basegfx::B2DPoint( aLineEnd.X(),aLineEnd.Y()));
+ mpAnchor->SetHeight(mAnchorRect.Height());
+ }
+ else
+ {
+ mpAnchor = AnchorOverlayObject::CreateAnchorOverlayObject( mrView,
+ mAnchorRect,
+ mPageBorder,
+ aLineStart,
+ aLineEnd,
+ mColorAnchor );
+ if ( mpAnchor )
+ {
+ mpAnchor->SetHeight(mAnchorRect.Height());
+ mpAnchor->setVisible(true);
+ mpAnchor->SetAnchorState(AS_TRI);
+ if (HasChildPathFocus())
+ {
+ mpAnchor->setLineSolid(true);
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ if ( mpAnchor &&
+ ( mpAnchor->getBasePosition() != basegfx::B2DPoint( mAnchorRect.Left() , mAnchorRect.Bottom()-5*15) ) )
+ {
+ mpAnchor->SetTriPosition( basegfx::B2DPoint( mAnchorRect.Left() , mAnchorRect.Bottom() - 5* 15),
+ basegfx::B2DPoint( mAnchorRect.Left()-5*15 , mAnchorRect.Bottom()+5*15),
+ basegfx::B2DPoint( mAnchorRect.Left()+5*15 , mAnchorRect.Bottom()+5*15),
+ basegfx::B2DPoint( mAnchorRect.Left(), mAnchorRect.Bottom()+2*15),
+ basegfx::B2DPoint( mPageBorder , mAnchorRect.Bottom()+2*15));
+ }
+ }
+
+ if (bChange)
+ {
+ Point aStart = EditWin()->PixelToLogic(GetPosPixel()+Point(0,GetSizePixel().Height()));
+ Point aEnd = EditWin()->PixelToLogic(GetPosPixel()+Point(GetSizePixel().Width()-1,GetSizePixel().Height()));
+ mpShadow->SetPosition(basegfx::B2DPoint(aStart.X(),aStart.Y()), basegfx::B2DPoint(aEnd.X(),aEnd.Y()));
+ }
+
+ if (mrMgr.ShowNotes())
+ {
+ if (IsFollow() && !HasChildPathFocus())
+ {
+ mpAnchor->SetAnchorState(AS_END);
+ }
+ else
+ {
+ mpAnchor->SetAnchorState(AS_ALL);
+ SwSidebarWin* pWin = GetTopReplyNote();
+ if (pWin)
+ pWin->Anchor()->SetAnchorState(AS_END);
+ }
+ }
+}
+
+void SwSidebarWin::DoResize()
+{
+ long aTextHeight = LogicToPixel( mpOutliner->CalcTextSize()).Height();
+ long aHeight = GetSizePixel().Height();
+ unsigned long aWidth = GetSizePixel().Width();
+
+ aHeight -= GetMetaHeight();
+ mpMetadataAuthor->Show();
+ mpMetadataDate->Show();
+ mpSidebarTxtControl->SetQuickHelpText(EMPTYSTRING);
+
+ if ((aTextHeight > aHeight) && !IsPreview())
+ { // we need vertical scrollbars and have to reduce the width
+ aWidth -= GetScrollbarWidth();
+ mpVScrollbar->Show();
+ }
+ else
+ {
+ mpVScrollbar->Hide();
+ }
+
+ {
+ const Size aSizeOfMetadataControls( GetSizePixel().Width() - GetMetaButtonAreaWidth(),
+ GetMetaHeight()/2 );
+ mpMetadataAuthor->SetPosSizePixel( 0,
+ aHeight,
+ aSizeOfMetadataControls.Width(),
+ aSizeOfMetadataControls.Height() );
+ mpMetadataDate->SetPosSizePixel( 0,
+ aHeight + aSizeOfMetadataControls.Height(),
+ aSizeOfMetadataControls.Width(),
+ aSizeOfMetadataControls.Height() );
+ }
+
+ mpOutliner->SetPaperSize( PixelToLogic( Size(aWidth,aHeight) ) ) ;
+ mpOutlinerView->SetOutputArea( PixelToLogic( Rectangle(0,0,aWidth,aHeight) ) );
+ if (!mpVScrollbar->IsVisible())
+ { // if we do not have a scrollbar anymore, we want to see the complete text
+ mpOutlinerView->SetVisArea( PixelToLogic( Rectangle(0,0,aWidth,aHeight) ) );
+ }
+
+ if (!Application::GetSettings().GetLayoutRTL())
+ {
+ mpSidebarTxtControl->SetPosSizePixel(0, 0, aWidth, aHeight);
+ mpVScrollbar->SetPosSizePixel( aWidth, 0, GetScrollbarWidth(), aHeight);
+ }
+ else
+ {
+ mpSidebarTxtControl->SetPosSizePixel( ( (aTextHeight > aHeight) && !IsPreview()
+ ? GetScrollbarWidth() : 0 ) , 0,
+ aWidth, aHeight);
+ mpVScrollbar->SetPosSizePixel( 0, 0, GetScrollbarWidth(), aHeight);
+ }
+
+ mpVScrollbar->SetVisibleSize( PixelToLogic(Size(0,aHeight)).Height() );
+ mpVScrollbar->SetPageSize( PixelToLogic(Size(0,aHeight)).Height() * 8 / 10 );
+ mpVScrollbar->SetLineSize( mpOutliner->GetTextHeight() / 10 );
+ SetScrollbar();
+ mpVScrollbar->SetRange( Range(0, mpOutliner->GetTextHeight()));
+
+ //calculate rects for meta- button
+ const Fraction& fx( GetMapMode().GetScaleX() );
+ const Fraction& fy( GetMapMode().GetScaleY() );
+
+ const Point aPos( mpMetadataAuthor->GetPosPixel());
+ Rectangle aRectMetaButton;
+ if (IsPreview())
+ {
+ aRectMetaButton = PixelToLogic(
+ Rectangle( Point( aPos.X()+GetSizePixel().Width()-(METABUTTON_WIDTH*4+10)*fx.GetNumerator()/fx.GetDenominator(),
+ aPos.Y()+5*fy.GetNumerator()/fy.GetDenominator() ),
+ Size( METABUTTON_WIDTH*4*fx.GetNumerator()/fx.GetDenominator(),
+ METABUTTON_HEIGHT*fy.GetNumerator()/fy.GetDenominator() ) ) );
+ }
+ else
+ {
+ aRectMetaButton = PixelToLogic(
+ Rectangle( Point( aPos.X()+GetSizePixel().Width()-(METABUTTON_WIDTH+10)*fx.GetNumerator()/fx.GetDenominator(),
+ aPos.Y()+5*fy.GetNumerator()/fy.GetDenominator() ),
+ Size( METABUTTON_WIDTH*fx.GetNumerator()/fx.GetDenominator(),
+ METABUTTON_HEIGHT*fy.GetNumerator()/fy.GetDenominator() ) ) );
+ }
+
+ {
+ const Rectangle aRectMetaButtonPixel( LogicToPixel( aRectMetaButton ) );
+ mpMenuButton->SetPosSizePixel( aRectMetaButtonPixel.Left(),
+ aRectMetaButtonPixel.Top(),
+ aRectMetaButtonPixel.GetWidth(),
+ aRectMetaButtonPixel.GetHeight() );
+ }
+}
+
+void SwSidebarWin::SetSizePixel( const Size& rNewSize )
+{
+ Window::SetSizePixel(rNewSize);
+
+ if (mpShadow)
+ {
+ Point aStart = EditWin()->PixelToLogic(GetPosPixel()+Point(0,GetSizePixel().Height()));
+ Point aEnd = EditWin()->PixelToLogic(GetPosPixel()+Point(GetSizePixel().Width()-1,GetSizePixel().Height()));
+ mpShadow->SetPosition(basegfx::B2DPoint(aStart.X(),aStart.Y()), basegfx::B2DPoint(aEnd.X(),aEnd.Y()));
+ }
+}
+
+void SwSidebarWin::SetScrollbar()
+{
+ mpVScrollbar->SetThumbPos( mpOutlinerView->GetVisArea().Top()+ mpOutlinerView->GetEditView().GetCursor()->GetOffsetY());
+}
+
+void SwSidebarWin::ResizeIfNeccessary(long aOldHeight, long aNewHeight)
+{
+ if (aOldHeight != aNewHeight)
+ {
+ //check for lower border or next note
+ long aBorder = mrMgr.GetNextBorder();
+ if (aBorder != -1)
+ {
+ if (aNewHeight > GetMinimumSizeWithoutMeta())
+ {
+ long aNewLowerValue = GetPosPixel().Y() + aNewHeight + GetMetaHeight();
+ if (aNewLowerValue < aBorder)
+ SetSizePixel(Size(GetSizePixel().Width(),aNewHeight+GetMetaHeight()));
+ else
+ SetSizePixel(Size(GetSizePixel().Width(),aBorder - GetPosPixel().Y()));
+ DoResize();
+ Invalidate();
+ }
+ else
+ {
+ if (GetSizePixel().Height() != GetMinimumSizeWithoutMeta() + GetMetaHeight())
+ SetSizePixel(Size(GetSizePixel().Width(),GetMinimumSizeWithoutMeta() + GetMetaHeight()));
+ DoResize();
+ Invalidate();
+ }
+ }
+ else
+ {
+ DoResize();
+ Invalidate();
+ }
+ }
+ else
+ {
+ SetScrollbar();
+ }
+}
+
+void SwSidebarWin::SetColor(Color aColorDark,Color aColorLight, Color aColorAnchor)
+{
+ mColorDark = aColorDark;
+ mColorLight = aColorLight;
+ mColorAnchor = aColorAnchor;
+
+ if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
+ {
+ {
+ mpMetadataAuthor->SetControlBackground(mColorDark);
+ AllSettings aSettings = mpMetadataAuthor->GetSettings();
+ StyleSettings aStyleSettings = aSettings.GetStyleSettings();
+ aStyleSettings.SetFieldTextColor(aColorAnchor);
+ aSettings.SetStyleSettings(aStyleSettings);
+ mpMetadataAuthor->SetSettings(aSettings);
+ }
+
+ {
+ mpMetadataDate->SetControlBackground(mColorDark);
+ AllSettings aSettings = mpMetadataDate->GetSettings();
+ StyleSettings aStyleSettings = aSettings.GetStyleSettings();
+ aStyleSettings.SetFieldTextColor(aColorAnchor);
+ aSettings.SetStyleSettings(aStyleSettings);
+ mpMetadataDate->SetSettings(aSettings);
+ }
+
+ AllSettings aSettings2 = mpVScrollbar->GetSettings();
+ StyleSettings aStyleSettings2 = aSettings2.GetStyleSettings();
+ aStyleSettings2.SetButtonTextColor(Color(0,0,0));
+ aStyleSettings2.SetCheckedColor(mColorLight); //hintergund
+ aStyleSettings2.SetShadowColor(mColorAnchor);
+ aStyleSettings2.SetFaceColor(mColorDark);
+ aSettings2.SetStyleSettings(aStyleSettings2);
+ mpVScrollbar->SetSettings(aSettings2);
+ }
+}
+
+void SwSidebarWin::SetSidebarPosition(sw::sidebarwindows::SidebarPosition eSidebarPosition)
+{
+ meSidebarPosition = eSidebarPosition;
+}
+
+void SwSidebarWin::SetReadonly(BOOL bSet)
+{
+ mbReadonly = bSet;
+ GetOutlinerView()->SetReadOnly(bSet);
+}
+
+void SwSidebarWin::SetLanguage(const SvxLanguageItem aNewItem)
+{
+ Link pLink = Engine()->GetModifyHdl();
+ Engine()->SetModifyHdl( Link() );
+ ESelection aOld = GetOutlinerView()->GetSelection();
+
+ ESelection aNewSelection( 0, 0, (USHORT)Engine()->GetParagraphCount()-1, USHRT_MAX );
+ GetOutlinerView()->SetSelection( aNewSelection );
+ SfxItemSet aEditAttr(GetOutlinerView()->GetAttribs());
+ aEditAttr.Put(aNewItem);
+ GetOutlinerView()->SetAttribs( aEditAttr );
+
+ GetOutlinerView()->SetSelection(aOld);
+ Engine()->SetModifyHdl( pLink );
+
+ const SwViewOption* pVOpt = mrView.GetWrtShellPtr()->GetViewOptions();
+ ULONG nCntrl = Engine()->GetControlWord();
+ // turn off
+ if (!pVOpt->IsOnlineSpell())
+ nCntrl &= ~EE_CNTRL_ONLINESPELLING;
+ else
+ nCntrl &= ~EE_CNTRL_ONLINESPELLING;
+ Engine()->SetControlWord(nCntrl);
+
+ //turn back on
+ if (pVOpt->IsOnlineSpell())
+ nCntrl |= EE_CNTRL_ONLINESPELLING;
+ else
+ nCntrl &= ~EE_CNTRL_ONLINESPELLING;
+ Engine()->SetControlWord(nCntrl);
+
+ Engine()->CompleteOnlineSpelling();
+ Invalidate();
+}
+
+void SwSidebarWin::DataChanged( const DataChangedEvent& aEvent)
+{
+ Window::DataChanged( aEvent );
+}
+
+void SwSidebarWin::GetFocus()
+{
+ if (mpSidebarTxtControl)
+ mpSidebarTxtControl->GrabFocus();
+}
+
+void SwSidebarWin::LoseFocus()
+{
+}
+
+void SwSidebarWin::ShowNote()
+{
+ SetPosAndSize();
+ if (!IsVisible())
+ Window::Show();
+ if (mpShadow && !mpShadow->isVisible())
+ mpShadow->setVisible(true);
+ if (mpAnchor && !mpAnchor->isVisible())
+ mpAnchor->setVisible(true);
+}
+
+void SwSidebarWin::HideNote()
+{
+ if (IsVisible())
+ Window::Hide();
+ if (mpAnchor)
+ {
+ if (mrMgr.IsShowAnchor())
+ mpAnchor->SetAnchorState(AS_TRI);
+ else
+ mpAnchor->setVisible(false);
+ }
+ if (mpShadow && mpShadow->isVisible())
+ mpShadow->setVisible(false);
+}
+
+void SwSidebarWin::ActivatePostIt()
+{
+ mrMgr.AssureStdModeAtShell();
+
+ mpOutliner->ClearModifyFlag();
+ mpOutliner->GetUndoManager().Clear();
+
+ CheckMetaText();
+ SetViewState(VS_EDIT);
+ GetOutlinerView()->ShowCursor();
+
+ mpOutlinerView->GetEditView().SetInsertMode(mrView.GetWrtShellPtr()->IsInsMode());
+
+ if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
+ GetOutlinerView()->SetBackgroundColor(mColorDark);
+}
+
+void SwSidebarWin::DeactivatePostIt()
+{
+ // remove selection, #i87073#
+ if (GetOutlinerView()->GetEditView().HasSelection())
+ {
+ ESelection aSelection = GetOutlinerView()->GetEditView().GetSelection();
+ aSelection.nEndPara = aSelection.nStartPara;
+ aSelection.nEndPos = aSelection.nStartPos;
+ GetOutlinerView()->GetEditView().SetSelection(aSelection);
+ }
+
+ mpOutliner->CompleteOnlineSpelling();
+
+ SetViewState(VS_NORMAL);
+ // write the visible text back into the SwField
+ UpdateData();
+
+ if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
+ GetOutlinerView()->SetBackgroundColor(COL_TRANSPARENT);
+
+
+ if ( !IsProtected() &&
+ Engine()->GetEditEngine().GetText()==String(EMPTYSTRING) )
+ {
+ mnEventId = Application::PostUserEvent( LINK( this, SwSidebarWin, DeleteHdl), 0 );
+ }
+}
+
+void SwSidebarWin::ToggleInsMode()
+{
+ if (!mrView.GetWrtShell().IsRedlineOn())
+ {
+ //change outliner
+ mpOutlinerView->GetEditView().SetInsertMode(!mpOutlinerView->GetEditView().IsInsertMode());
+ //change documnet
+ mrView.GetWrtShell().ToggleInsMode();
+ //update statusbar
+ SfxBindings &rBnd = mrView.GetViewFrame()->GetBindings();
+ rBnd.Invalidate(SID_ATTR_INSERT);
+ rBnd.Update(SID_ATTR_INSERT);
+ }
+}
+
+void SwSidebarWin::ExecuteCommand(USHORT nSlot)
+{
+ mrMgr.AssureStdModeAtShell();
+
+ switch (nSlot)
+ {
+ case FN_POSTIT:
+ case FN_REPLY:
+ {
+ // if this note is empty, it will be deleted once losing the focus, so no reply, but only a new note
+ // will be created
+ if (Engine()->GetEditEngine().GetText() != String(EMPTYSTRING))
+ {
+ OutlinerParaObject* pPara = new OutlinerParaObject(*GetOutlinerView()->GetEditView().CreateTextObject());
+ mrMgr.RegisterAnswer(pPara);
+ }
+ if (mrMgr.HasActiveSidebarWin())
+ mrMgr.SetActiveSidebarWin(0);
+ SwitchToFieldPos();
+ mrView.GetViewFrame()->GetDispatcher()->Execute(FN_POSTIT);
+ break;
+ }
+ case FN_DELETE_COMMENT:
+ case FN_DELETE_NOTE:
+
+ //Delete(); // do not kill the parent of our open popup menu
+ mnEventId = Application::PostUserEvent( LINK( this, SwSidebarWin, DeleteHdl), 0 );
+ break;
+ case FN_DELETE_ALL_NOTES:
+ case FN_HIDE_ALL_NOTES:
+ // not possible as slot as this would require that "this" is the active postit
+ mrView.GetViewFrame()->GetBindings().Execute( nSlot, 0, 0, SFX_CALLMODE_ASYNCHRON );
+ break;
+ case FN_DELETE_NOTE_AUTHOR:
+ case FN_HIDE_NOTE_AUTHOR:
+ {
+ // not possible as slot as this would require that "this" is the active postit
+ SfxStringItem aItem( nSlot, GetAuthor() );
+ const SfxPoolItem* aItems[2];
+ aItems[0] = &aItem;
+ aItems[1] = 0;
+ mrView.GetViewFrame()->GetBindings().Execute( nSlot, aItems, 0, SFX_CALLMODE_ASYNCHRON );
+ }
+ default:
+ mrView.GetViewFrame()->GetBindings().Execute( nSlot );
+ break;
+ }
+}
+
+SwEditWin* SwSidebarWin::EditWin()
+{
+ return &mrView.GetEditWin();
+}
+
+long SwSidebarWin::GetPostItTextHeight()
+{
+ return mpOutliner ? LogicToPixel(mpOutliner->CalcTextSize()).Height() : 0;
+}
+
+void SwSidebarWin::SwitchToPostIt(USHORT aDirection)
+{
+ SwSidebarWin* pPostIt = mrMgr.GetNextPostIt(aDirection, this);
+ if (pPostIt)
+ pPostIt->GrabFocus();
+}
+
+IMPL_LINK( SwSidebarWin, WindowEventListener, VclSimpleEvent*, pEvent )
+{
+ VclWindowEvent* pWinEvent = dynamic_cast<VclWindowEvent*>(pEvent);
+ if ( pWinEvent )
+ {
+ if ( pWinEvent->GetId() == VCLEVENT_WINDOW_MOUSEMOVE )
+ {
+ MouseEvent* pMouseEvt = (MouseEvent*)pWinEvent->GetData();
+ if ( pMouseEvt->IsEnterWindow() )
+ {
+ mbMouseOver = true;
+ if ( !HasFocus() )
+ {
+ SetViewState(VS_VIEW);
+ Invalidate();
+ }
+ }
+ else if ( pMouseEvt->IsLeaveWindow())
+ {
+ if (IsPreview())
+ {
+ //doLazyDelete();
+ }
+ else
+ {
+ mbMouseOver = false;
+ if ( !HasFocus() )
+ {
+ SetViewState(VS_NORMAL);
+ Invalidate();
+ }
+ }
+ }
+ }
+ else if ( pWinEvent->GetId() == VCLEVENT_WINDOW_ACTIVATE &&
+ pWinEvent->GetWindow() == mpSidebarTxtControl )
+ {
+ const BOOL bLockView = mrView.GetWrtShell().IsViewLocked();
+ mrView.GetWrtShell().LockView( TRUE );
+
+ if ( !IsPreview() )
+ {
+ mrMgr.SetActiveSidebarWin( this );
+ }
+
+ mrView.GetWrtShell().LockView( bLockView );
+ mrMgr.MakeVisible( this );
+ }
+ else if ( pWinEvent->GetWindow() == mpSidebarTxtControl )
+ {
+ int i = 5;
+ ++i;
+ }
+ }
+ return sal_True;
+}
+
+void SwSidebarWin::Delete()
+{
+ if ( mrMgr.GetActiveSidebarWin() == this)
+ {
+ mrMgr.SetActiveSidebarWin(0);
+ // if the note is empty, the previous line will send a delete event, but we are already there
+ if (mnEventId)
+ {
+ Application::RemoveUserEvent( mnEventId );
+ mnEventId = 0;
+ }
+ }
+}
+
+IMPL_LINK(SwSidebarWin, ScrollHdl, ScrollBar*, pScroll)
+{
+ long nDiff = GetOutlinerView()->GetEditView().GetVisArea().Top() - pScroll->GetThumbPos();
+ GetOutlinerView()->Scroll( 0, nDiff );
+ return 0;
+}
+
+IMPL_LINK(SwSidebarWin, ModifyHdl, void*, pVoid)
+{
+ // no warnings, please
+ pVoid=0;
+ mrView.GetDocShell()->SetModified(sal_True);
+ return 0;
+}
+
+IMPL_LINK(SwSidebarWin, DeleteHdl, void*, pVoid)
+{
+ // no warnings, please
+ pVoid=0;
+ mnEventId = 0;
+ Delete();
+ return 0;
+}
+
+
+void SwSidebarWin::ResetAttributes()
+{
+ mpOutlinerView->RemoveAttribsKeepLanguages(TRUE);
+ mpOutliner->RemoveFields(TRUE);
+ mpOutlinerView->SetAttribs(DefaultItem());
+}
+
+sal_Int32 SwSidebarWin::GetScrollbarWidth()
+{
+ return mrView.GetWrtShell().GetViewOptions()->GetZoom() / 10;
+}
+
+sal_Int32 SwSidebarWin::GetMetaButtonAreaWidth()
+{
+ const Fraction& f( GetMapMode().GetScaleX() );
+ if (IsPreview())
+ return 3 * METABUTTON_AREA_WIDTH * f.GetNumerator() / f.GetDenominator();
+ else
+ return METABUTTON_AREA_WIDTH * f.GetNumerator() / f.GetDenominator();
+}
+
+sal_Int32 SwSidebarWin::GetMetaHeight()
+{
+ const Fraction& f( GetMapMode().GetScaleY() );
+ return POSTIT_META_HEIGHT * f.GetNumerator() / f.GetDenominator();
+}
+
+sal_Int32 SwSidebarWin::GetMinimumSizeWithMeta()
+{
+ return mrMgr.GetMinimumSizeWithMeta();
+}
+
+sal_Int32 SwSidebarWin::GetMinimumSizeWithoutMeta()
+{
+ const Fraction& f( GetMapMode().GetScaleY() );
+ return POSTIT_MINIMUMSIZE_WITHOUT_META * f.GetNumerator() / f.GetDenominator();
+}
+
+void SwSidebarWin::SetSpellChecking()
+{
+ const SwViewOption* pVOpt = mrView.GetWrtShellPtr()->GetViewOptions();
+ ULONG nCntrl = mpOutliner->GetControlWord();
+ if (pVOpt->IsOnlineSpell())
+ nCntrl |= EE_CNTRL_ONLINESPELLING;
+ else
+ nCntrl &= ~EE_CNTRL_ONLINESPELLING;
+ mpOutliner->SetControlWord(nCntrl);
+
+ mpOutliner->CompleteOnlineSpelling();
+ Invalidate();
+}
+
+void SwSidebarWin::SetViewState(ViewState bViewState)
+{
+ switch (bViewState)
+ {
+ case VS_EDIT:
+ {
+ if (mpAnchor)
+ {
+ mpAnchor->SetAnchorState(AS_ALL);
+ SwSidebarWin* pWin = GetTopReplyNote();
+ if (pWin)
+ pWin->Anchor()->SetAnchorState(AS_END);
+ mpAnchor->setLineSolid(true);
+ }
+ if (mpShadow)
+ mpShadow->SetShadowState(SS_EDIT);
+ break;
+ }
+ case VS_VIEW:
+ {
+ if (mpAnchor)
+ mpAnchor->setLineSolid(true);
+ if (mpShadow)
+ mpShadow->SetShadowState(SS_VIEW);
+ break;
+ }
+ case VS_NORMAL:
+ {
+ if (mpAnchor)
+ {
+ if (IsFollow())
+ {
+ // if there is no visible parent note, we want to see the complete anchor ??
+ //if (IsAnyStackParentVisible())
+ mpAnchor->SetAnchorState(AS_END);
+ SwSidebarWin* pTopWinSelf = GetTopReplyNote();
+ SwSidebarWin* pTopWinActive = mrMgr.HasActiveSidebarWin()
+ ? mrMgr.GetActiveSidebarWin()->GetTopReplyNote()
+ : 0;
+ if (pTopWinSelf && (pTopWinSelf!=pTopWinActive))
+ {
+ if (pTopWinSelf!=mrMgr.GetActiveSidebarWin())
+ pTopWinSelf->Anchor()->setLineSolid(false);
+ pTopWinSelf->Anchor()->SetAnchorState(AS_ALL);
+ }
+ }
+ mpAnchor->setLineSolid(false);
+ }
+ if (mpShadow)
+ mpShadow->SetShadowState(SS_NORMAL);
+ break;
+ }
+ }
+}
+
+SwSidebarWin* SwSidebarWin::GetTopReplyNote()
+{
+ SwSidebarWin* pTopNote = 0;
+ SwSidebarWin* pSidebarWin = IsFollow() ? mrMgr.GetNextPostIt(KEY_PAGEUP, this) : 0;
+ while (pSidebarWin)
+ {
+ pTopNote = pSidebarWin;
+ pSidebarWin = pSidebarWin->IsFollow() ? mrMgr.GetNextPostIt(KEY_PAGEUP, pSidebarWin) : 0;
+ }
+ return pTopNote;
+}
+
+void SwSidebarWin::SwitchToFieldPos()
+{
+ if ( mrMgr.GetActiveSidebarWin() == this )
+ mrMgr.SetActiveSidebarWin(0);
+ GotoPos();
+ sal_uInt32 aCount = MoveCaret();
+ if (aCount)
+ mrView.GetDocShell()->GetWrtShell()->SwCrsrShell::Right(aCount, 0, FALSE);
+ GrabFocusToDocument();
+}
+
+SvxLanguageItem SwSidebarWin::GetLanguage(void)
+{
+ return SvxLanguageItem(SwLangHelper::GetLanguage(mrView.GetWrtShell(),RES_CHRATR_LANGUAGE),RES_CHRATR_LANGUAGE);
+}
+
+void SwSidebarWin::SetChangeTracking( const SwPostItHelper::SwLayoutStatus aLayoutStatus,
+ const Color& aChangeColor )
+{
+ if ( (mLayoutStatus != aLayoutStatus) ||
+ (mChangeColor != aChangeColor) )
+ {
+ mLayoutStatus = aLayoutStatus;
+ mChangeColor = aChangeColor;
+ Invalidate();
+ }
+}
+
+bool SwSidebarWin::HasScrollbar() const
+{
+ return mpVScrollbar != 0;
+}
+
+bool SwSidebarWin::IsScrollbarVisible() const
+{
+ return HasScrollbar() && mpVScrollbar->IsVisible();
+}
+
+void SwSidebarWin::ChangeSidebarItem( SwSidebarItem& rSidebarItem )
+{
+ const bool bAnchorChanged = mpAnchorFrm != rSidebarItem.maLayoutInfo.mpAnchorFrm;
+ if ( bAnchorChanged )
+ {
+ mrMgr.DisconnectSidebarWinFromFrm( *(mpAnchorFrm), *this );
+ }
+
+ mrSidebarItem = rSidebarItem;
+ mpAnchorFrm = mrSidebarItem.maLayoutInfo.mpAnchorFrm;
+
+ if ( GetWindowPeer() )
+ {
+ SidebarWinAccessible* pAcc =
+ static_cast<SidebarWinAccessible*>( GetWindowPeer() );
+ ASSERT( dynamic_cast<SidebarWinAccessible*>( GetWindowPeer() ),
+ "<SwSidebarWin::ChangeSidebarItem(..)> - unexpected type of window peer -> crash possible!" );
+ pAcc->ChangeSidebarItem( mrSidebarItem );
+ }
+
+ if ( bAnchorChanged )
+ {
+ mrMgr.ConnectSidebarWinToFrm( *(mrSidebarItem.maLayoutInfo.mpAnchorFrm),
+ *(mrSidebarItem.GetFmtFld()),
+ *this );
+ }
+}
+
+css::uno::Reference< css::accessibility::XAccessible > SwSidebarWin::CreateAccessible()
+{
+ SidebarWinAccessible* pAcc( new SidebarWinAccessible( *this,
+ mrView.GetWrtShell(),
+ mrSidebarItem ) );
+ css::uno::Reference< css::awt::XWindowPeer > xWinPeer( pAcc );
+ SetWindowPeer( xWinPeer, pAcc );
+
+ css::uno::Reference< css::accessibility::XAccessible > xAcc( xWinPeer, css::uno::UNO_QUERY );
+ return xAcc;
+}
+
+} } // eof of namespace sw::sidebarwindows
+
+/********** SwRedComment**************/
+/*
+SwRedComment::SwRedComment( Window* pParent, WinBits nBits,SwPostItMgr* aMgr,SwPostItBits aBits,SwRedline* pRed)
+ : SwSidebarWin(pParent,nBits,aMgr,aBits),
+ pRedline(pRed)
+{
+}
+
+void SwRedComment::SetPopup()
+{
+ mpButtonPopup = new PopupMenu(SW_RES(MN_REDCOMMENT_BUTTON));
+ //mpButtonPopup->SetMenuFlags(MENU_FLAG_ALWAYSSHOWDISABLEDENTRIES);
+}
+
+void SwRedComment::UpdateData()
+{
+ if ( Engine()->IsModified() )
+ {
+ // so we get a new layout of notes (Anchor position is still the same and we would otherwise not get one)
+ Mgr()->SetLayout();
+ // SetRedline is calling SetModified already
+ DocView()->GetWrtShell().SetRedlineComment(Engine()->GetEditEngine().GetText());
+ }
+ Engine()->ClearModifyFlag();
+ Engine()->GetUndoManager().Clear();
+}
+
+void SwRedComment::SetPostItText()
+{
+ Engine()->SetModifyHdl( Link() );
+ Engine()->EnableUndo( FALSE );
+
+ Engine()->Clear();
+ View()->SetAttribs(DefaultItem());
+ View()->InsertText(pRedline->GetComment(),false);
+
+ Engine()->ClearModifyFlag();
+ Engine()->GetUndoManager().Clear();
+ Engine()->EnableUndo( TRUE );
+ Engine()->SetModifyHdl( LINK( this, SwSidebarWin, ModifyHdl ) );
+ Invalidate();
+}
+
+void SwRedComment::DeactivatePostIt()
+{
+ SwSidebarWin::DeactivatePostIt();
+ // current Redline is still selected
+ DocView()->GetWrtShellPtr()->ClearMark();
+}
+
+void SwRedComment::ActivatePostIt()
+{
+ SwSidebarWin::ActivatePostIt();
+
+ // do we want the redline selected?
+ // otherwise, SwRedComment::ActivatePostIt() as well as SwRedComment::DeactivatePostIt()
+ // can be thrown out completly
+ DocView()->GetDocShell()->GetWrtShell()->GotoRedline(
+ DocView()->GetDocShell()->GetWrtShell()->FindRedlineOfData(pRedline->GetRedlineData()),true);
+}
+
+void SwRedComment::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ if (mRectMetaButton.IsInside(PixelToLogic(rMEvt.GetPosPixel())) && rMEvt.IsLeft())
+ {
+ ExecuteCommand( mpButtonPopup->Execute( this,Rectangle(LogicToPixel(mRectMetaButton.BottomLeft()),LogicToPixel(mRectMetaButton.BottomLeft())),POPUPMENU_EXECUTE_DOWN | POPUPMENU_NOMOUSEUPCLOSE) );
+ }
+}
+
+void SwRedComment::Delete()
+{
+ SwSidebarWin::Delete();
+ // we are not neccessarily on our redline, so let's move there
+ GotoPos();
+ DocView()->GetWrtShell().SetRedlineComment(EMPTYSTRING);
+ DocView()->GetWrtShell().ClearMark();
+ // so we get a new layout of notes (Anchor position is still the same and we would otherwise not get one)
+ Mgr()->SetLayout();
+ Mgr()->RemoveItem(pRedline);
+}
+
+void SwRedComment::GotoPos()
+{
+ DocView()->GetDocShell()->GetWrtShell()->GotoRedline(
+ DocView()->GetDocShell()->GetWrtShell()->FindRedlineOfData(pRedline->GetRedlineData()));
+}
+
+String SwRedComment::GetAuthor()
+{
+ return pRedline->GetAuthorString();
+}
+
+Date SwRedComment::GetDate()
+{
+ return pRedline->GetTimeStamp().GetDate();
+}
+
+Time SwRedComment::GetTime()
+{
+ return pRedline->GetTimeStamp().GetTime();
+}
+
+bool SwRedComment::IsProtected()
+{
+ return SwSidebarWin::IsProtected() || pRedline->Start()->nNode.GetNode().GetTxtNode()->IsInProtectSect();
+}
+*/
diff --git a/sw/source/ui/docvw/SidebarWinAcc.cxx b/sw/source/ui/docvw/SidebarWinAcc.cxx
new file mode 100644
index 000000000000..214913963dcb
--- /dev/null
+++ b/sw/source/ui/docvw/SidebarWinAcc.cxx
@@ -0,0 +1,162 @@
+/************************************************************************* *
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: $
+ * $Revision: $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#include "precompiled_sw.hxx"
+
+#include <SidebarWinAcc.hxx>
+
+#include <SidebarWin.hxx>
+#include <viewsh.hxx>
+#include <accmap.hxx>
+#include <toolkit/awt/vclxaccessiblecomponent.hxx>
+
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+
+namespace css = ::com::sun::star;
+
+namespace sw { namespace sidebarwindows {
+
+// =============================================================================
+// declaration and implementation of accessible context for <SidebarWinAccessible> instance
+// =============================================================================
+class SidebarWinAccessibleContext : public VCLXAccessibleComponent
+{
+ public:
+ explicit SidebarWinAccessibleContext( SwSidebarWin& rSidebarWin,
+ ViewShell& rViewShell,
+ const SwFrm* pAnchorFrm )
+ : VCLXAccessibleComponent( rSidebarWin.GetWindowPeer() )
+ , mrViewShell( rViewShell )
+ , mpAnchorFrm( pAnchorFrm )
+ , maMutex()
+ {
+ rSidebarWin.SetAccessibleRole( css::accessibility::AccessibleRole::COMMENT );
+ }
+
+ virtual ~SidebarWinAccessibleContext()
+ {}
+
+ void ChangeAnchor( const SwFrm* pAnchorFrm )
+ {
+ vos::OGuard aGuard(maMutex);
+
+ mpAnchorFrm = pAnchorFrm;
+ }
+
+ virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL
+ getAccessibleParent() throw (css::uno::RuntimeException)
+ {
+ vos::OGuard aGuard(maMutex);
+
+ css::uno::Reference< css::accessibility::XAccessible > xAccParent;
+
+ if ( mpAnchorFrm &&
+ mrViewShell.GetAccessibleMap() )
+ {
+ xAccParent = mrViewShell.GetAccessibleMap()->GetContext( mpAnchorFrm, sal_False );
+ }
+
+ return xAccParent;
+ }
+
+ virtual sal_Int32 SAL_CALL getAccessibleIndexInParent() throw (css::uno::RuntimeException)
+ {
+ vos::OGuard aGuard(maMutex);
+
+ sal_Int32 nIndex( -1 );
+
+ if ( mpAnchorFrm && GetWindow() &&
+ mrViewShell.GetAccessibleMap() )
+ {
+ nIndex = mrViewShell.GetAccessibleMap()->GetChildIndex( *mpAnchorFrm,
+ *GetWindow() );
+ }
+
+ return nIndex;
+ }
+
+ private:
+ ViewShell& mrViewShell;
+ const SwFrm* mpAnchorFrm;
+
+ ::vos::OMutex maMutex;
+};
+
+// =============================================================================
+// implementaion of accessible for <SwSidebarWin> instance
+// =============================================================================
+SidebarWinAccessible::SidebarWinAccessible( SwSidebarWin& rSidebarWin,
+ ViewShell& rViewShell,
+ const SwSidebarItem& rSidebarItem )
+ : VCLXWindow()
+ , mrSidebarWin( rSidebarWin )
+ , mrViewShell( rViewShell )
+ , mpAnchorFrm( rSidebarItem.maLayoutInfo.mpAnchorFrm )
+ , bAccContextCreated( false )
+{
+ SetWindow( &mrSidebarWin );
+}
+
+SidebarWinAccessible::~SidebarWinAccessible()
+{
+}
+
+void SidebarWinAccessible::ChangeSidebarItem( const SwSidebarItem& rSidebarItem )
+{
+ if ( bAccContextCreated )
+ {
+ css::uno::Reference< css::accessibility::XAccessibleContext > xAcc
+ = getAccessibleContext();
+ if ( xAcc.is() )
+ {
+ SidebarWinAccessibleContext* pAccContext =
+ dynamic_cast<SidebarWinAccessibleContext*>(xAcc.get());
+ if ( pAccContext )
+ {
+ pAccContext->ChangeAnchor( rSidebarItem.maLayoutInfo.mpAnchorFrm );
+ }
+ }
+ }
+}
+
+css::uno::Reference< css::accessibility::XAccessibleContext > SidebarWinAccessible::CreateAccessibleContext()
+{
+ SidebarWinAccessibleContext* pAccContext =
+ new SidebarWinAccessibleContext( mrSidebarWin,
+ mrViewShell,
+ mpAnchorFrm );
+ css::uno::Reference< css::accessibility::XAccessibleContext > xAcc( pAccContext );
+ bAccContextCreated = true;
+ return xAcc;
+}
+
+} } // end of namespace sw::sidebarwindows
+
diff --git a/sw/source/ui/docvw/SidebarWinAcc.hxx b/sw/source/ui/docvw/SidebarWinAcc.hxx
new file mode 100644
index 000000000000..0abe1acbfaf5
--- /dev/null
+++ b/sw/source/ui/docvw/SidebarWinAcc.hxx
@@ -0,0 +1,67 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: $
+ *
+ * $Revision: $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SIDEBARWINACC_HXX
+#define _SIDEBARWINACC_HXX
+
+#include <toolkit/awt/vclxwindow.hxx>
+
+class ViewShell;
+class SwSidebarItem;
+class SwFrm;
+
+namespace sw { namespace sidebarwindows {
+
+class SwSidebarWin;
+
+class SidebarWinAccessible : public VCLXWindow
+{
+ public:
+ explicit SidebarWinAccessible( SwSidebarWin& rSidebarWin,
+ ViewShell& rViewShell,
+ const SwSidebarItem& rSidebarItem );
+ virtual ~SidebarWinAccessible();
+
+ virtual com::sun::star::uno::Reference< com::sun::star::accessibility::XAccessibleContext >
+ CreateAccessibleContext();
+
+ void ChangeSidebarItem( const SwSidebarItem& rSidebarItem );
+
+ private:
+ SwSidebarWin& mrSidebarWin;
+ ViewShell& mrViewShell;
+ const SwFrm* mpAnchorFrm;
+ bool bAccContextCreated;
+};
+
+} } // end of namespace sw::sidebarwindows
+
+#endif
diff --git a/sw/source/ui/docvw/access.src b/sw/source/ui/docvw/access.src
new file mode 100644
index 000000000000..42081d3ab7e7
--- /dev/null
+++ b/sw/source/ui/docvw/access.src
@@ -0,0 +1,102 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "access.hrc"
+
+String STR_ACCESS_DOC_NAME
+{
+ Text [ en-US ] = "Document view";
+};
+String STR_ACCESS_DOC_DESC
+{
+ Text [ en-US ] = "Document view";
+};
+String STR_ACCESS_HEADING_WITH_NUM_DESC
+{
+ Text [ en-US ] = "Heading number $(ARG2): $(ARG1)";
+};
+String STR_ACCESS_HEADER_NAME
+{
+ Text [ en-US ] = "Header $(ARG1)";
+};
+String STR_ACCESS_HEADER_DESC
+{
+ Text [ en-US ] = "Header page $(ARG1)";
+};
+String STR_ACCESS_FOOTER_NAME
+{
+ Text [ en-US ] = "Footer $(ARG1)";
+};
+String STR_ACCESS_FOOTER_DESC
+{
+ Text [ en-US ] = "Footer page $(ARG1)";
+};
+String STR_ACCESS_FOOTNOTE_NAME
+{
+ Text [ en-US ] = "Footnote $(ARG1)";
+};
+String STR_ACCESS_FOOTNOTE_DESC
+{
+ Text [ en-US ] = "Footnote $(ARG1)";
+};
+String STR_ACCESS_ENDNOTE_NAME
+{
+ Text [ en-US ] = "Endnote $(ARG1)";
+};
+String STR_ACCESS_ENDNOTE_DESC
+{
+ Text [ en-US ] = "Endnote $(ARG1)";
+};
+String STR_ACCESS_TABLE_DESC
+{
+ Text [ en-US ] = "$(ARG1) on page $(ARG2)";
+};
+String STR_ACCESS_PAGE_NAME
+{
+ Text [ en-US ] = "Page $(ARG1)";
+};
+String STR_ACCESS_PAGE_DESC
+{
+ Text [ en-US ] = "Page: $(ARG1)";
+};
+String STR_ACCESS_ANNOTATION_AUTHOR_NAME
+{
+ Text [ en-US ] = "Author";
+};
+String STR_ACCESS_ANNOTATION_DATE_NAME
+{
+ Text [ en-US ] = "Date";
+};
+String STR_ACCESS_ANNOTATION_BUTTON_NAME
+{
+ Text [ en-US ] = "Actions";
+};
+String STR_ACCESS_ANNOTATION_BUTTON_DESC
+{
+ Text [ en-US ] = "Activate this button to open a list of actions which can be performed on this comment and other comments";
+};
+
diff --git a/sw/source/ui/docvw/annotation.hrc b/sw/source/ui/docvw/annotation.hrc
new file mode 100644
index 000000000000..e43a90342409
--- /dev/null
+++ b/sw/source/ui/docvw/annotation.hrc
@@ -0,0 +1,54 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: $
+ * $Revision: $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _ANNOTATION_HRC
+#define _ANNOTATION_HRC
+
+#include "rcid.hrc"
+
+#define STR_POSTIT_TODAY (RC_ANNOTATION_BEGIN + 1)
+#define STR_POSTIT_YESTERDAY (RC_ANNOTATION_BEGIN + 2)
+
+#define STR_DELETE_ALL_NOTES (RC_ANNOTATION_BEGIN + 3)
+#define STR_DELETE_AUTHOR_NOTES (RC_ANNOTATION_BEGIN + 4)
+
+#define STR_NODATE (RC_ANNOTATION_BEGIN + 5)
+#define STR_NOAUTHOR (RC_ANNOTATION_BEGIN + 6)
+
+#define STR_REPLY (RC_ANNOTATION_BEGIN + 7)
+
+
+#define ANNOTATION_ACT_END STR_REPLY
+#if ANNOTATION_ACT_END > RC_ANNOTATION_END
+#error Resource-Id Ueberlauf in #file, #line
+#endif
+
+
+#endif
diff --git a/sw/source/ui/docvw/annotation.src b/sw/source/ui/docvw/annotation.src
new file mode 100644
index 000000000000..8dcda9c25b8c
--- /dev/null
+++ b/sw/source/ui/docvw/annotation.src
@@ -0,0 +1,68 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: $
+ * $Revision: $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "annotation.hrc"
+#include "cmdid.h"
+
+String STR_POSTIT_TODAY
+{
+ Text [ en-US ] = "Today," ;
+};
+
+String STR_POSTIT_YESTERDAY
+{
+ Text [ en-US ] = "Yesterday," ;
+};
+
+String STR_DELETE_ALL_NOTES
+{
+ Text [ en-US ] = "All Comments" ;
+};
+
+String STR_DELETE_AUTHOR_NOTES
+{
+ Text [ en-US ] = "Comments by " ;
+};
+
+String STR_NODATE
+{
+ Text [ en-US ] = "(no date)" ;
+};
+
+String STR_NOAUTHOR
+{
+ Text [ en-US ] = "(no author)" ;
+};
+
+String STR_REPLY
+{
+ Text [ en-US ] = "Reply to $1" ;
+};
+
diff --git a/sw/source/ui/docvw/docvw.hrc b/sw/source/ui/docvw/docvw.hrc
new file mode 100644
index 000000000000..c0f15291795b
--- /dev/null
+++ b/sw/source/ui/docvw/docvw.hrc
@@ -0,0 +1,93 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _DOCVW_HRC
+#define _DOCVW_HRC
+
+#include "rcid.hrc"
+
+#define MN_READONLY_POPUP (RC_DOCVW_BEGIN + 1)
+#define MN_READONLY_OPENURL (RC_DOCVW_BEGIN + 2)
+#define MN_READONLY_OPENURLNEW (RC_DOCVW_BEGIN + 3)
+#define MN_READONLY_EDITDOC (RC_DOCVW_BEGIN + 4)
+ // FREE, formerly known as MN_READONLY_BROWSE_STOP
+#define MN_READONLY_BROWSE_BACKWARD (RC_DOCVW_BEGIN + 6)
+#define MN_READONLY_BROWSE_FORWARD (RC_DOCVW_BEGIN + 7)
+#define MN_READONLY_SELECTION_MODE (RC_DOCVW_BEGIN + 8)
+#define MN_READONLY_SAVEGRAPHIC (RC_DOCVW_BEGIN + 11)
+#define MN_READONLY_SAVEBACKGROUND (RC_DOCVW_BEGIN + 12)
+#define MN_READONLY_COPYLINK (RC_DOCVW_BEGIN + 13)
+#define MN_READONLY_COPYGRAPHIC (RC_DOCVW_BEGIN + 14)
+#define MN_READONLY_LOADGRAPHIC (RC_DOCVW_BEGIN + 15)
+#define MN_READONLY_GRAPHICOFF (RC_DOCVW_BEGIN + 16)
+#define MN_READONLY_PLUGINOFF (RC_DOCVW_BEGIN + 17)
+#define MN_READONLY_TOGALLERYLINK (RC_DOCVW_BEGIN + 18)
+#define MN_READONLY_TOGALLERYCOPY (RC_DOCVW_BEGIN + 19)
+#define MN_READONLY_SOURCEVIEW (RC_DOCVW_BEGIN + 20)
+#define MN_READONLY_RELOAD_FRAME (RC_DOCVW_BEGIN + 21)
+#define MN_READONLY_RELOAD (RC_DOCVW_BEGIN + 22)
+#define MN_READONLY_COPY (RC_DOCVW_BEGIN + 23)
+
+//Bei den folgenden brauchen wir Luft fuer die Gallery-Themen
+#define MN_READONLY_GRAPHICTOGALLERY (RC_DOCVW_BEGIN + 24)
+#define MN_READONLY_BACKGROUNDTOGALLERY (RC_DOCVW_BEGIN + 60)
+
+
+#define STR_EXPORT_GRAFIK_TITLE (RC_DOCVW_BEGIN + 1)
+#define STR_CHAIN_OK (RC_DOCVW_BEGIN + 2)
+#define STR_CHAIN_NOT_EMPTY (RC_DOCVW_BEGIN + 3)
+#define STR_CHAIN_IS_IN_CHAIN (RC_DOCVW_BEGIN + 4)
+#define STR_CHAIN_WRONG_AREA (RC_DOCVW_BEGIN + 5)
+#define STR_CHAIN_NOT_FOUND (RC_DOCVW_BEGIN + 6)
+#define STR_CHAIN_SOURCE_CHAINED (RC_DOCVW_BEGIN + 7)
+#define STR_CHAIN_SELF (RC_DOCVW_BEGIN + 8)
+#define STR_REDLINE_INSERT (RC_DOCVW_BEGIN + 9)
+#define STR_REDLINE_DELETE (RC_DOCVW_BEGIN + 10)
+#define STR_REDLINE_FORMAT (RC_DOCVW_BEGIN + 11)
+#define STR_REDLINE_TABLE (RC_DOCVW_BEGIN + 12)
+#define STR_REDLINE_FMTCOLL (RC_DOCVW_BEGIN + 13)
+#define STR_ENDNOTE (RC_DOCVW_BEGIN + 14)
+#define STR_FTNNOTE (RC_DOCVW_BEGIN + 15)
+
+#define STR_TABLE_COL_ADJUST (RC_DOCVW_BEGIN + 16)
+#define STR_TABLE_ROW_ADJUST (RC_DOCVW_BEGIN + 17)
+#define STR_TABLE_SELECT_ALL (RC_DOCVW_BEGIN + 18)
+#define STR_TABLE_SELECT_ROW (RC_DOCVW_BEGIN + 19)
+#define STR_TABLE_SELECT_COL (RC_DOCVW_BEGIN + 20)
+
+#define STR_SMARTTAG_CLICK (RC_DOCVW_BEGIN + 21)
+
+#define MSG_READONLY_CONTENT (RC_DOCVW_BEGIN + 1)
+
+#define DOCVW_ACT_END STR_SMARTTAG_CLICK
+
+#if DOCVW_ACT_END > RC_DOCVW_END
+#error Resource-Id Ueberlauf in #file, #line
+#endif
+
+
+#endif
diff --git a/sw/source/ui/docvw/docvw.src b/sw/source/ui/docvw/docvw.src
new file mode 100644
index 000000000000..dcd0f98103f4
--- /dev/null
+++ b/sw/source/ui/docvw/docvw.src
@@ -0,0 +1,296 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "docvw.hrc"
+#include "cmdid.h"
+#include "helpid.h"
+#define SEPARATOR MenuItem { Separator = TRUE; };
+Menu MN_READONLY_POPUP
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = MN_READONLY_OPENURL ;
+ HelpID = SID_OPENDOC ;
+ Text [ en-US ] = "~Open" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_READONLY_OPENURLNEW ;
+ HelpID = SID_OPENDOC ;
+ Text [ en-US ] = "Open in New Window" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_READONLY_EDITDOC ;
+ HelpID = SID_EDITDOC ;
+ Text [ en-US ] = "~Edit" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_READONLY_SELECTION_MODE ;
+ HelpID = FN_READONLY_SELECTION_MODE ;
+ Text [ en-US ] = "Select Text";
+ };
+ MenuItem
+ {
+ Identifier = MN_READONLY_RELOAD;
+ HelpID = SID_RELOAD;
+ Text [ en-US ] = "Re~load";
+ };
+ MenuItem
+ {
+ Identifier = MN_READONLY_RELOAD_FRAME;
+ HelpID = SID_RELOAD;
+ Text [ en-US ] = "Reload Frame";
+ };
+ MenuItem
+ {
+ Identifier = MN_READONLY_SOURCEVIEW ;
+ HelpID = HID_SOURCEVIEW ;
+ Text [ en-US ] = "HT~ML Source" ;
+ };
+ SEPARATOR
+ MenuItem
+ {
+ Identifier = MN_READONLY_BROWSE_BACKWARD ;
+ HelpID = SID_BROWSE_BACKWARD ;
+ Text [ en-US ] = "Backwards" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_READONLY_BROWSE_FORWARD ;
+ HelpID = SID_BROWSE_FORWARD ;
+ Text [ en-US ] = "~Forward" ;
+ };
+ SEPARATOR
+ MenuItem
+ {
+ Identifier = MN_READONLY_SAVEGRAPHIC ;
+ HelpID = HID_MN_READONLY_SAVEGRAPHIC ;
+ Text [ en-US ] = "Save Graphics..." ;
+ };
+ MenuItem
+ {
+ Identifier = MN_READONLY_GRAPHICTOGALLERY ;
+ HelpID = HID_MN_READONLY_GRAPHICTOGALLERY ;
+ SubMenu = Menu
+ {
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = MN_READONLY_TOGALLERYLINK ;
+ HelpID = HID_MN_READONLY_TOGALLERYLINK ;
+ Text [ en-US ] = "As Link" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_READONLY_TOGALLERYCOPY ;
+ HelpID = HID_MN_READONLY_TOGALLERYCOPY ;
+ Text [ en-US ] = "Copy" ;
+ };
+ SEPARATOR
+ };
+ };
+ Text [ en-US ] = "Add Graphics" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_READONLY_SAVEBACKGROUND ;
+ HelpID = HID_MN_READONLY_SAVEBACKGROUND ;
+ Text [ en-US ] = "Save Background..." ;
+ };
+ MenuItem
+ {
+ Identifier = MN_READONLY_BACKGROUNDTOGALLERY ;
+ HelpID = HID_MN_READONLY_BACKGROUNDTOGALLERY ;
+ SubMenu = Menu
+ {
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = MN_READONLY_TOGALLERYLINK ;
+ HelpID = HID_MN_READONLY_TOGALLERYLINK ;
+ Text [ en-US ] = "As Link" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_READONLY_TOGALLERYCOPY ;
+ HelpID = HID_MN_READONLY_TOGALLERYCOPY ;
+ Text [ en-US ] = "Copy" ;
+ };
+ SEPARATOR
+ };
+ };
+ Text [ en-US ] = "Add Background" ;
+ };
+ SEPARATOR
+ MenuItem
+ {
+ Identifier = MN_READONLY_COPYLINK ;
+ HelpID = HID_MN_READONLY_COPYLINK ;
+ Text [ en-US ] = "Copy ~Link" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_READONLY_COPYGRAPHIC ;
+ HelpID = HID_MN_READONLY_COPYGRAPHIC ;
+ /* ### ACHTUNG: Neuer Text in Resource? Grafik ~kopieren : ~Grafik kopieren */
+ /* ### ACHTUNG: Neuer Text in Resource? Grafik ~kopieren : ~Grafik kopieren */
+ /* ### ACHTUNG: Neuer Text in Resource? Grafik ~kopieren : ~Grafik kopieren */
+ Text [ en-US ] = "Copy ~Graphics" ;
+ };
+ SEPARATOR
+ MenuItem
+ {
+ Identifier = MN_READONLY_LOADGRAPHIC ;
+ HelpID = HID_MN_READONLY_LOADGRAPHIC ;
+ Text [ en-US ] = "Load Graphics" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_READONLY_GRAPHICOFF ;
+ HelpID = HID_MN_READONLY_GRAPHICOFF ;
+ Text [ en-US ] = "Graphics Off" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_READONLY_PLUGINOFF ;
+ HelpID = HID_MN_READONLY_PLUGINOFF ;
+ Text [ en-US ] = "Plug-ins Off" ;
+ };
+ SEPARATOR
+ MenuItem
+ {
+ Identifier = SID_WIN_FULLSCREEN;
+ HelpID = SID_WIN_FULLSCREEN;
+ Text [ en-US ] = "Leave Full-Screen Mode" ;
+ };
+ SEPARATOR
+ MenuItem
+ {
+ Identifier = MN_READONLY_COPY ;
+ HelpID = SID_COPY;
+ Text [ en-US ] = "~Copy" ;
+ };
+ };
+};
+String STR_EXPORT_GRAFIK_TITLE
+{
+ Text [ en-US ] = "Graphics Export" ;
+};
+String STR_CHAIN_OK
+{
+ Text [ en-US ] = "Click the left mouse button to link the frames." ;
+};
+String STR_CHAIN_NOT_EMPTY
+{
+ Text [ en-US ] = "Target frame not empty." ;
+};
+String STR_CHAIN_IS_IN_CHAIN
+{
+ Text [ en-US ] = "Target frame is already linked." ;
+};
+String STR_CHAIN_WRONG_AREA
+{
+ Text [ en-US ] = "The target frame for the link is in an invalid area." ;
+};
+String STR_CHAIN_NOT_FOUND
+{
+ Text [ en-US ] = "Target frame not found at current position." ;
+};
+String STR_CHAIN_SOURCE_CHAINED
+{
+ Text [ en-US ] = "The source frame is already the source of a link." ;
+};
+String STR_CHAIN_SELF
+{
+ Text [ en-US ] = "A closed link is not possible." ;
+};
+String STR_REDLINE_INSERT
+{
+ Text [ en-US ] = "Inserted" ;
+};
+String STR_REDLINE_DELETE
+{
+ Text [ en-US ] = "Deleted" ;
+};
+String STR_REDLINE_FORMAT
+{
+ Text [ en-US ] = "Formatted" ;
+};
+String STR_REDLINE_TABLE
+{
+ Text [ en-US ] = "Table changed" ;
+};
+String STR_REDLINE_FMTCOLL
+{
+ Text [ en-US ] = "Applied Paragraph Styles";
+};
+String STR_ENDNOTE
+{
+ Text [ en-US ] = "Endnote: " ;
+};
+String STR_FTNNOTE
+{
+ Text [ en-US ] = "Footnote: " ;
+};
+
+InfoBox MSG_READONLY_CONTENT
+{
+ Message [ en-US ] = "Readonly content cannot be changed.\nNo modifications will be accepted";
+};
+
+String STR_TABLE_COL_ADJUST
+{
+ Text [ en-US ] = "Adjust table column" ;
+};
+String STR_TABLE_ROW_ADJUST
+{
+ Text [ en-US ] = "Adjust table row" ;
+};
+String STR_TABLE_SELECT_ALL
+{
+ Text [ en-US ] = "Select whole table" ;
+};
+String STR_TABLE_SELECT_ROW
+{
+ Text [ en-US ] = "Select table row" ;
+};
+String STR_TABLE_SELECT_COL
+{
+ Text [ en-US ] = "Select table column" ;
+};
+
+String STR_SMARTTAG_CLICK
+{
+ Text [ en-US ] = "%s-click to open Smart Tag menu" ;
+};
+
diff --git a/sw/source/ui/docvw/edtdd.cxx b/sw/source/ui/docvw/edtdd.cxx
new file mode 100644
index 000000000000..8e11e5117c27
--- /dev/null
+++ b/sw/source/ui/docvw/edtdd.cxx
@@ -0,0 +1,527 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+
+#include <hintids.hxx>
+
+
+#include <svx/svdview.hxx>
+#include <editeng/outliner.hxx>
+//#ifndef _SVDVMARK_HXX //autogen
+//#include <svx/svdvmark.hxx>
+//#endif
+#include <svx/svdobj.hxx>
+#include <sot/exchange.hxx>
+#include <sot/formats.hxx>
+#include <sfx2/bindings.hxx>
+
+#include <sfx2/viewfrm.hxx>
+#include <fmturl.hxx>
+#include <frmfmt.hxx>
+#include <wrtsh.hxx>
+#include <edtwin.hxx>
+#ifndef _VIEW_HXX
+#include <view.hxx>
+#endif
+#include <viewopt.hxx>
+#include <swdtflvr.hxx>
+#include <swmodule.hxx>
+#ifndef _DOCSH_HXX
+#include <docsh.hxx>
+#endif
+#include <wdocsh.hxx>
+#include <swundo.hxx>
+
+using namespace ::com::sun::star;
+
+// no include "dbgoutsw.hxx" here!!!!!!
+
+extern BOOL bNoInterrupt;
+extern BOOL bFrmDrag;
+extern BOOL bDDTimerStarted;
+
+BOOL bExecuteDrag = FALSE;
+
+void SwEditWin::StartDDTimer()
+{
+ aTimer.SetTimeoutHdl(LINK(this, SwEditWin, DDHandler));
+ aTimer.SetTimeout(480);
+ aTimer.Start();
+ bDDTimerStarted = TRUE;
+}
+
+
+void SwEditWin::StopDDTimer(SwWrtShell *pSh, const Point &rPt)
+{
+ aTimer.Stop();
+ bDDTimerStarted = FALSE;
+ if(!pSh->IsSelFrmMode())
+ (pSh->*pSh->fnSetCrsr)(&rPt,FALSE);
+ aTimer.SetTimeoutHdl(LINK(this,SwEditWin, TimerHandler));
+}
+
+void SwEditWin::StartDrag( sal_Int8 /*nAction*/, const Point& rPosPixel )
+{
+ SwWrtShell &rSh = rView.GetWrtShell();
+ if( rSh.GetDrawView() )
+ {
+ CommandEvent aDragEvent( rPosPixel, COMMAND_STARTDRAG, TRUE );
+ if( rSh.GetDrawView()->Command( aDragEvent, this ) )
+ {
+ rView.GetViewFrame()->GetBindings().InvalidateAll(FALSE);
+ return; // Event von der SdrView ausgewertet
+ }
+ }
+
+ if ( !pApplyTempl && !rSh.IsDrawCreate() && !IsDrawAction())
+ {
+ BOOL bStart = FALSE, bDelSelect = FALSE;
+ SdrObject *pObj = NULL;
+ Point aDocPos( PixelToLogic( rPosPixel ) );
+ if ( !rSh.IsInSelect() && rSh.ChgCurrPam( aDocPos, TRUE, TRUE))
+ //Wir sind nicht beim Selektieren und stehen auf einer
+ //Selektion
+ bStart = TRUE;
+ else if ( !bFrmDrag && rSh.IsSelFrmMode() &&
+ rSh.IsInsideSelectedObj( aDocPos ) )
+ {
+ //Wir sind nicht am internen Draggen und stehen auf
+ //einem Objekt (Rahmen, Zeichenobjekt)
+
+ bStart = TRUE;
+ }
+ else if( !bFrmDrag && rView.GetDocShell()->IsReadOnly() &&
+ OBJCNT_NONE != rSh.GetObjCntType( aDocPos, pObj ))
+ {
+ rSh.LockPaint();
+ if( rSh.SelectObj( aDocPos, 0, pObj ))
+ bStart = bDelSelect = TRUE;
+ else
+ rSh.UnlockPaint();
+ }
+ else
+ {
+ SwContentAtPos aSwContentAtPos( SwContentAtPos::SW_INETATTR );
+ bStart = rSh.GetContentAtPos( aDocPos,
+ aSwContentAtPos,
+ FALSE );
+ }
+
+ if ( bStart && !bIsInDrag )
+ {
+ bMBPressed = FALSE;
+ ReleaseMouse();
+ bFrmDrag = FALSE;
+ bExecuteDrag = TRUE;
+ SwEditWin::nDDStartPosY = aDocPos.Y();
+ SwEditWin::nDDStartPosX = aDocPos.X();
+ aMovePos = aDocPos;
+ StartExecuteDrag();
+ if( bDelSelect )
+ {
+ rSh.UnSelectFrm();
+ rSh.UnlockPaint();
+ }
+ }
+ }
+}
+
+void SwEditWin::StartExecuteDrag()
+{
+ if( !bExecuteDrag || bIsInDrag )
+ return;
+
+ bIsInDrag = TRUE;
+
+ SwTransferable* pTransfer = new SwTransferable( rView.GetWrtShell() );
+ uno::Reference<
+ datatransfer::XTransferable > xRef( pTransfer );
+
+ pTransfer->StartDrag( this, aMovePos );
+}
+
+void SwEditWin::DragFinished()
+{
+ DropCleanup();
+ aTimer.SetTimeoutHdl( LINK(this,SwEditWin, TimerHandler) );
+ bIsInDrag = FALSE;
+}
+
+
+void SwEditWin::DropCleanup()
+{
+ SwWrtShell &rSh = rView.GetWrtShell();
+
+ // Stati zuruecksetzen
+ bNoInterrupt = FALSE;
+ if ( bOldIdleSet )
+ {
+ ((SwViewOption*)rSh.GetViewOptions())->SetIdle( bOldIdle );
+ bOldIdleSet = FALSE;
+ }
+ if ( pUserMarker )
+ CleanupDropUserMarker();
+ else
+ rSh.UnSetVisCrsr();
+
+}
+
+void SwEditWin::CleanupDropUserMarker()
+{
+ if ( pUserMarker )
+ {
+ delete pUserMarker;
+ pUserMarker = 0;
+ pUserMarkerObj = 0;
+ }
+}
+
+
+//Messehack (MA,MBA)
+void lcl_SelectShellForDrop( SwView &rView )
+{
+ if ( !rView.GetCurShell() )
+ rView.SelectShell();
+}
+
+sal_Int8 SwEditWin::ExecuteDrop( const ExecuteDropEvent& rEvt )
+{
+ ::lcl_SelectShellForDrop( GetView() );
+ DropCleanup();
+ sal_Int8 nRet = DND_ACTION_NONE;
+
+ //Ein Drop auf eine offene OutlinerView geht uns nichts an (siehe auch QueryDrop)
+ SwWrtShell &rSh = rView.GetWrtShell();
+ const Point aDocPt( PixelToLogic( rEvt.maPosPixel ));
+ SdrObject *pObj = 0;
+ OutlinerView* pOLV;
+ rSh.GetObjCntType( aDocPt, pObj );
+
+ if( pObj && 0 != ( pOLV = rSh.GetDrawView()->GetTextEditOutlinerView() ))
+ {
+ Rectangle aRect( pOLV->GetOutputArea() );
+ aRect.Union( pObj->GetLogicRect() );
+ const Point aPos = pOLV->GetWindow()->PixelToLogic(rEvt.maPosPixel);
+ if ( aRect.IsInside(aPos) )
+ {
+ rSh.StartAllAction();
+//!! sal_Int8 nRet = DND_ACTION_NONE/*pOLV->ExecuteDrop( rEvt )*/;
+ rSh.EndAllAction();
+ return nRet;
+ }
+ }
+
+
+ // dvo 2002-05-27, #99027#: There's a special treatment for file lists with a single
+ // element, that depends on the actual content of the
+ // Transferable to be accessible. Since the transferable
+ // may only be accessed after the drop has been accepted
+ // (according to KA due to Java D&D), we'll have to
+ // reevaluate the drop action once more _with_ the
+ // Transferable.
+ USHORT nEventAction;
+ sal_Int8 nUserOpt = rEvt.mbDefault ? EXCHG_IN_ACTION_DEFAULT
+ : rEvt.mnAction;
+ m_nDropAction = SotExchange::GetExchangeAction(
+ GetDataFlavorExVector(),
+ m_nDropDestination,
+ rEvt.mnAction,
+//!! rEvt.GetSourceOptions(),
+ nUserOpt, m_nDropFormat, nEventAction, 0,
+ &rEvt.maDropEvent.Transferable );
+
+
+ TransferableDataHelper aData( rEvt.maDropEvent.Transferable );
+ nRet = rEvt.mnAction;
+ if( !SwTransferable::PasteData( aData, rSh, m_nDropAction, m_nDropFormat,
+ m_nDropDestination, FALSE, rEvt.mbDefault, &aDocPt, nRet))
+//!! nRet = SFX_APP()->ExecuteDrop( rEvt );
+ nRet = DND_ACTION_NONE;
+ else if ( SW_MOD()->pDragDrop )
+ //Bei internem D&D nicht mehr aufraeumen!
+ SW_MOD()->pDragDrop->SetCleanUp( FALSE );
+
+ return nRet;
+}
+
+
+USHORT SwEditWin::GetDropDestination( const Point& rPixPnt, SdrObject ** ppObj )
+{
+ SwWrtShell &rSh = rView.GetWrtShell();
+ const Point aDocPt( PixelToLogic( rPixPnt ) );
+ if( rSh.ChgCurrPam( aDocPt ) || rSh.IsOverReadOnlyPos( aDocPt ) )
+ return 0;
+
+ SdrObject *pObj = NULL;
+ const ObjCntType eType = rSh.GetObjCntType( aDocPt, pObj );
+
+ //Drop auf OutlinerView (TextEdit im Drawing) soll diese selbst entscheiden!
+ if( pObj )
+ {
+ OutlinerView* pOLV = rSh.GetDrawView()->GetTextEditOutlinerView();
+ if ( pOLV )
+ {
+ Rectangle aRect( pOLV->GetOutputArea() );
+ aRect.Union( pObj->GetLogicRect() );
+ const Point aPos = pOLV->GetWindow()->PixelToLogic( rPixPnt );
+ if( aRect.IsInside( aPos ) )
+ return 0;
+ }
+ }
+
+ //Auf was wollen wir denn gerade droppen?
+ USHORT nDropDestination = 0;
+
+ //Sonst etwas aus der DrawingEngine getroffen?
+ if( OBJCNT_NONE != eType )
+ {
+ switch ( eType )
+ {
+ case OBJCNT_GRF:
+ {
+ BOOL bLink,
+ bIMap = 0 != rSh.GetFmtFromObj( aDocPt )->GetURL().GetMap();
+ String aDummy;
+ rSh.GetGrfAtPos( aDocPt, aDummy, bLink );
+ if ( bLink && bIMap )
+ nDropDestination = EXCHG_DEST_DOC_LNKD_GRAPH_W_IMAP;
+ else if ( bLink )
+ nDropDestination = EXCHG_DEST_DOC_LNKD_GRAPHOBJ;
+ else if ( bIMap )
+ nDropDestination = EXCHG_DEST_DOC_GRAPH_W_IMAP;
+ else
+ nDropDestination = EXCHG_DEST_DOC_GRAPHOBJ;
+ }
+ break;
+ case OBJCNT_FLY:
+ if( rSh.GetView().GetDocShell()->ISA(SwWebDocShell) )
+ nDropDestination = EXCHG_DEST_DOC_TEXTFRAME_WEB;
+ else
+ nDropDestination = EXCHG_DEST_DOC_TEXTFRAME;
+ break;
+ case OBJCNT_OLE: nDropDestination = EXCHG_DEST_DOC_OLEOBJ; break;
+ case OBJCNT_CONTROL: /* no Action avail */
+ case OBJCNT_SIMPLE: nDropDestination = EXCHG_DEST_DOC_DRAWOBJ; break;
+ case OBJCNT_URLBUTTON: nDropDestination = EXCHG_DEST_DOC_URLBUTTON; break;
+ case OBJCNT_GROUPOBJ: nDropDestination = EXCHG_DEST_DOC_GROUPOBJ; break;
+
+ default: ASSERT( !this, "new ObjectType?" );
+ }
+ }
+ if ( !nDropDestination )
+ {
+ if( rSh.GetView().GetDocShell()->ISA(SwWebDocShell) )
+ nDropDestination = EXCHG_DEST_SWDOC_FREE_AREA_WEB;
+ else
+ nDropDestination = EXCHG_DEST_SWDOC_FREE_AREA;
+ }
+ if( ppObj )
+ *ppObj = pObj;
+ return nDropDestination;
+}
+
+sal_Int8 SwEditWin::AcceptDrop( const AcceptDropEvent& rEvt )
+{
+ if( rEvt.mbLeaving )
+ {
+ DropCleanup();
+ return rEvt.mnAction;
+ }
+
+ if( rView.GetDocShell()->IsReadOnly() )
+ return DND_ACTION_NONE;
+
+ SwWrtShell &rSh = rView.GetWrtShell();
+
+ Point aPixPt( rEvt.maPosPixel );
+
+ // If the cursor is near the inner boundary
+ // we attempt to scroll towards the desired direction.
+ Point aPoint;
+ Rectangle aWin(aPoint,GetOutputSizePixel());
+ const int nMargin = 10;
+ aWin.Left() += nMargin;
+ aWin.Top() += nMargin;
+ aWin.Right() -= nMargin;
+ aWin.Bottom() -= nMargin;
+ if(!aWin.IsInside(aPixPt)) {
+ static ULONG last_tick = 0;
+ ULONG current_tick = Time::GetSystemTicks();
+ if((current_tick-last_tick) > 500) {
+ last_tick = current_tick;
+ if(!bOldIdleSet) {
+ bOldIdle = rSh.GetViewOptions()->IsIdle();
+ ((SwViewOption *)rSh.GetViewOptions())->SetIdle(FALSE);
+ bOldIdleSet = TRUE;
+ }
+ CleanupDropUserMarker();
+ if(aPixPt.X() > aWin.Right()) aPixPt.X() += nMargin;
+ if(aPixPt.X() < aWin.Left()) aPixPt.X() -= nMargin;
+ if(aPixPt.Y() > aWin.Bottom()) aPixPt.Y() += nMargin;
+ if(aPixPt.Y() < aWin.Top()) aPixPt.Y() -= nMargin;
+ Point aDocPt(PixelToLogic(aPixPt));
+ SwRect rect(aDocPt,Size(1,1));
+ rSh.MakeVisible(rect);
+ }
+ }
+
+ if(bOldIdleSet) {
+ ((SwViewOption *)rSh.GetViewOptions())->SetIdle( bOldIdle );
+ bOldIdleSet = FALSE;
+ }
+
+ SdrObject *pObj = NULL;
+ m_nDropDestination = GetDropDestination( aPixPt, &pObj );
+ if( !m_nDropDestination )
+ return DND_ACTION_NONE;
+
+ USHORT nEventAction;
+ sal_Int8 nUserOpt = rEvt.mbDefault ? EXCHG_IN_ACTION_DEFAULT
+ : rEvt.mnAction;
+
+ m_nDropAction = SotExchange::GetExchangeAction(
+ GetDataFlavorExVector(),
+ m_nDropDestination,
+ rEvt.mnAction,
+//!! rEvt.GetSourceOptions(),
+ nUserOpt, m_nDropFormat, nEventAction );
+
+ if( EXCHG_INOUT_ACTION_NONE != m_nDropAction )
+ {
+ const Point aDocPt( PixelToLogic( aPixPt ) );
+
+ //Bei den default Aktionen wollen wir noch ein bischen mitreden.
+ SwModule *pMod = SW_MOD();
+ if( pMod->pDragDrop )
+ {
+ BOOL bCleanup = FALSE;
+ //Zeichenobjekte in Kopf-/Fusszeilen sind nicht erlaubt
+
+ SwWrtShell *pSrcSh = pMod->pDragDrop->GetShell();
+ if( (pSrcSh->GetSelFrmType() == FRMTYPE_DRAWOBJ) &&
+ pSrcSh->IsSelContainsControl() &&
+ (rSh.GetFrmType( &aDocPt, FALSE ) & (FRMTYPE_HEADER|FRMTYPE_FOOTER)) )
+ {
+ bCleanup = TRUE;
+ }
+ // keine positionsgeschuetzten Objecte verschieben!
+ else if( DND_ACTION_MOVE == rEvt.mnAction &&
+ pSrcSh->IsSelObjProtected( FLYPROTECT_POS ) )
+ {
+ bCleanup = TRUE;
+ }
+ else if( rEvt.mbDefault )
+ {
+ // JP 13.08.98: internes Drag&Drop: bei gleichem Doc ein Move
+ // ansonten ein Copy - Task 54974
+ nEventAction = pSrcSh->GetDoc() == rSh.GetDoc()
+ ? DND_ACTION_MOVE
+ : DND_ACTION_COPY;
+ }
+ if ( bCleanup )
+ {
+ CleanupDropUserMarker();
+ rSh.UnSetVisCrsr();
+ return DND_ACTION_NONE;
+ }
+ }
+ else
+ {
+ //D&D von ausserhalb des SW soll per default ein Copy sein.
+ if( EXCHG_IN_ACTION_DEFAULT == nEventAction &&
+ DND_ACTION_MOVE == rEvt.mnAction )
+ nEventAction = DND_ACTION_COPY;
+
+ if( (SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE == m_nDropFormat &&
+ EXCHG_IN_ACTION_LINK == m_nDropAction) ||
+ SOT_FORMATSTR_ID_SBA_CTRLDATAEXCHANGE == m_nDropFormat )
+ {
+ SdrMarkView* pMView = PTR_CAST( SdrMarkView, rSh.GetDrawView() );
+ if( pMView && !pMView->IsDesignMode() )
+ return DND_ACTION_NONE;
+ }
+ }
+
+ if ( EXCHG_IN_ACTION_DEFAULT != nEventAction )
+ nUserOpt = (sal_Int8)nEventAction;
+
+ // show DropCursor or UserMarker ?
+ if( EXCHG_DEST_SWDOC_FREE_AREA_WEB == m_nDropDestination ||
+ EXCHG_DEST_SWDOC_FREE_AREA == m_nDropDestination )
+ {
+ CleanupDropUserMarker();
+ SwContentAtPos aCont( SwContentAtPos::SW_CONTENT_CHECK );
+ if(rSh.GetContentAtPos(aDocPt, aCont))
+ rSh.SwCrsrShell::SetVisCrsr( aDocPt );
+ }
+ else
+ {
+ rSh.UnSetVisCrsr();
+
+ if ( pUserMarkerObj != pObj )
+ {
+ CleanupDropUserMarker();
+ pUserMarkerObj = pObj;
+
+ if(pUserMarkerObj)
+ {
+ pUserMarker = new SdrDropMarkerOverlay( *rSh.GetDrawView(), *pUserMarkerObj );
+ }
+ }
+ }
+ return nUserOpt;
+ }
+
+ CleanupDropUserMarker();
+ rSh.UnSetVisCrsr();
+//!! return SFX_APP()->AcceptDrop( rEvt );
+ return DND_ACTION_NONE;
+}
+
+
+IMPL_LINK( SwEditWin, DDHandler, Timer *, EMPTYARG )
+{
+ bDDTimerStarted = FALSE;
+ aTimer.Stop();
+ aTimer.SetTimeout(240);
+ bMBPressed = FALSE;
+ ReleaseMouse();
+ bFrmDrag = FALSE;
+
+ if ( rView.GetViewFrame() )
+ {
+ bExecuteDrag = TRUE;
+ StartExecuteDrag();
+ }
+ return 0;
+}
+
+
+
diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx
new file mode 100644
index 000000000000..e2e59e17831e
--- /dev/null
+++ b/sw/source/ui/docvw/edtwin.cxx
@@ -0,0 +1,5754 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+
+#include <tools/list.hxx>
+#include <swtypes.hxx>
+#include <hintids.hxx>
+#include <com/sun/star/accessibility/XAccessible.hpp>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/i18n/XBreakIterator.hpp>
+#include <com/sun/star/i18n/ScriptType.hpp>
+#include <com/sun/star/i18n/InputSequenceCheckMode.hpp>
+
+#include <com/sun/star/i18n/UnicodeScript.hpp>
+
+#include <vcl/help.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/cmdevt.h>
+#include <sot/storage.hxx>
+#include <svl/macitem.hxx>
+#include <unotools/securityoptions.hxx>
+#include <basic/sbxvar.hxx>
+#include <svl/ctloptions.hxx>
+#include <basic/sbx.hxx>
+#include <svl/eitem.hxx>
+#include <svl/stritem.hxx>
+#include <sfx2/ipclient.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svl/ptitem.hxx>
+#include <editeng/sizeitem.hxx>
+#include <editeng/langitem.hxx>
+#include <svx/htmlmode.hxx>
+#include <svx/svdview.hxx>
+#include <svx/svdhdl.hxx>
+#include <svx/svdoutl.hxx>
+#include <editeng/editeng.hxx>
+#include <editeng/svxacorr.hxx>
+#include <editeng/scripttypeitem.hxx>
+#include <editeng/flditem.hxx>
+#include <editeng/colritem.hxx>
+#include <editeng/brshitem.hxx>
+#include <editeng/wghtitem.hxx>
+#include <editeng/udlnitem.hxx>
+#include <editeng/postitem.hxx>
+#include <editeng/protitem.hxx>
+#include <unotools/charclass.hxx>
+
+#include <editeng/acorrcfg.hxx>
+#include <SwSmartTagMgr.hxx>
+#include <edtwin.hxx>
+#include <view.hxx>
+#include <wrtsh.hxx>
+#include <IDocumentSettingAccess.hxx>
+#include <fldbas.hxx>
+#include <swmodule.hxx>
+#include <docsh.hxx>
+#include <viewopt.hxx>
+#include <drawbase.hxx>
+#include <dselect.hxx>
+#include <textsh.hxx>
+#include <shdwcrsr.hxx>
+#include <fmtanchr.hxx>
+#include <fmtornt.hxx>
+#include <fmtfsize.hxx>
+#include <fmtclds.hxx>
+#include <frmfmt.hxx>
+#include <modcfg.hxx>
+#include <fmtcol.hxx>
+#include <wview.hxx>
+#include <listsh.hxx>
+#include <gloslst.hxx>
+#include <inputwin.hxx>
+#include <gloshdl.hxx>
+#include <swundo.hxx>
+#include <drwtxtsh.hxx>
+#include <fchrfmt.hxx>
+#include <fmturl.hxx>
+#include <romenu.hxx>
+#include <initui.hxx>
+#include <frmatr.hxx>
+#include <extinput.hxx>
+#include <acmplwrd.hxx>
+#include <swcalwrp.hxx>
+#include <swdtflvr.hxx>
+#include <wdocsh.hxx>
+#include <crsskip.hxx>
+#include <breakit.hxx>
+#include <checkit.hxx>
+
+#include <helpid.h>
+#include <cmdid.h>
+#ifndef _DOCVW_HRC
+#include <docvw.hrc>
+#endif
+#include <uitool.hxx>
+// OD 18.09.2003 #i18732#
+#include <fmtfollowtextflow.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <charfmt.hxx>
+#include <numrule.hxx>
+#include <pagedesc.hxx>
+#include <svtools/ruler.hxx> // #i23726#
+#include "formatclipboard.hxx"
+#include <vos/mutex.hxx>
+#include <vcl/svapp.hxx>
+
+#include <IMark.hxx>
+#include <doc.hxx>
+#include <xmloff/odffields.hxx>
+
+#include <PostItMgr.hxx>
+
+//JP 11.10.2001: enable test code for bug fix 91313
+#if defined(DBG_UTIL) && (OSL_DEBUG_LEVEL > 1)
+//#define TEST_FOR_BUG91313
+#endif
+
+using namespace sw::mark;
+using namespace ::com::sun::star;
+
+/*--------------------------------------------------------------------
+ Beschreibung: Globals
+ --------------------------------------------------------------------*/
+
+static bool bInputLanguageSwitched = false;
+extern BOOL bNoInterrupt; // in mainwn.cxx
+
+//Normalerweise wird im MouseButtonUp eine Selektion aufgehoben wenn die
+//Selektion nicht gerade aufgezogen wird. Leider wird im MouseButtonDown
+//bei doppel-/dreifach-Klick Selektiert, diese Selektion wird in dem Handler
+//komplett abgeschlossen und kann deshalb im Up nicht mehr unterschieden
+//werden. Um dies Aufzuloese wird bHoldSelection im Down gesetzt und im
+//Up ausgewertet.
+static BOOL bHoldSelection = FALSE;
+
+BOOL bFrmDrag = FALSE;
+BOOL bValidCrsrPos = FALSE;
+BOOL bModePushed = FALSE;
+BOOL bDDTimerStarted = FALSE;
+BOOL bFlushCharBuffer = FALSE;
+BOOL SwEditWin::bReplaceQuote = FALSE;
+BOOL bDDINetAttr = FALSE;
+SdrHdlKind eSdrMoveHdl = HDL_USER;
+
+QuickHelpData* SwEditWin::pQuickHlpData = 0;
+
+long SwEditWin::nDDStartPosY = 0;
+long SwEditWin::nDDStartPosX = 0;
+Color SwEditWin::aTextBackColor(COL_YELLOW);
+Color SwEditWin::aTextColor(COL_RED);
+BOOL SwEditWin::bTransparentBackColor = FALSE; // Hintergrund nicht transparent
+
+
+extern BOOL bExecuteDrag;
+
+SfxShell* lcl_GetShellFromDispatcher( SwView& rView, TypeId nType );
+
+DBG_NAME(edithdl)
+
+class SwAnchorMarker
+{
+ SdrHdl* pHdl;
+ Point aHdlPos;
+ Point aLastPos;
+public:
+ SwAnchorMarker( SdrHdl* pH ) :
+ pHdl( pH ), aHdlPos( pH->GetPos() ), aLastPos( pH->GetPos() ) {}
+ const Point& GetLastPos() const { return aLastPos; }
+ void SetLastPos( const Point& rNew ) { aLastPos = rNew; }
+ void SetPos( const Point& rNew ) { pHdl->SetPos( rNew ); }
+ const Point& GetPos() { return pHdl->GetPos(); }
+ const Point& GetHdlPos() { return aHdlPos; }
+ void ChgHdl( SdrHdl* pNew ) { pHdl = pNew; }
+};
+
+struct QuickHelpData
+{
+ SvStringsISortDtor aArr;
+ USHORT* pAttrs;
+ CommandExtTextInputData* pCETID;
+ ULONG nTipId;
+ USHORT nLen, nCurArrPos;
+ BOOL bClear : 1, bChkInsBlank : 1, bIsTip : 1, bIsAutoText : 1;
+
+ QuickHelpData() : pAttrs( 0 ), pCETID( 0 ) { ClearCntnt(); }
+
+ void Move( QuickHelpData& rCpy );
+ void ClearCntnt();
+ void Start( SwWrtShell& rSh, USHORT nWrdLen );
+ void Stop( SwWrtShell& rSh );
+
+ BOOL HasCntnt() const { return aArr.Count() && 0 != nLen; }
+
+ void Inc( BOOL bEndLess )
+ {
+ if( ++nCurArrPos >= aArr.Count() )
+ nCurArrPos = (bEndLess && !bIsAutoText )? 0 : nCurArrPos-1;
+ }
+ void Dec( BOOL bEndLess )
+ {
+ if( 0 == nCurArrPos-- )
+ nCurArrPos = (bEndLess && !bIsAutoText ) ? aArr.Count()-1 : 0;
+ }
+ void FillStrArr( SwWrtShell& rSh, const String& rWord );
+};
+
+
+/*--------------------------------------------------------------------
+ Beschreibung: Minimale Bewegung Zittern vermeiden
+ --------------------------------------------------------------------*/
+
+#define HIT_PIX 2 /* Hit-Toleranz in Pixel */
+#define MIN_MOVE 4
+
+inline BOOL IsMinMove(const Point &rStartPos, const Point &rLPt)
+{
+ return Abs(rStartPos.X() - rLPt.X()) > MIN_MOVE ||
+ Abs(rStartPos.Y() - rLPt.Y()) > MIN_MOVE;
+}
+
+/*--------------------------------------------------------------------
+ JP 30.07.98: fuer MouseButtonDown - feststellen, ob ein DrawObject
+ und KEIN SwgFrame getroffen wurde! Shift/Ctrl sollen
+ nur bei DrawObjecte zum Selektieren fuehren, bei SwgFlys
+ ggfs zum ausloesen von Hyperlinks (DownLoad/NewWindow!)
+ --------------------------------------------------------------------*/
+inline BOOL IsDrawObjSelectable( const SwWrtShell& rSh, const Point& rPt )
+{
+ BOOL bRet = TRUE;
+ SdrObject* pObj;
+ switch( rSh.GetObjCntType( rPt, pObj ))
+ {
+ case OBJCNT_NONE:
+ case OBJCNT_FLY:
+ case OBJCNT_GRF:
+ case OBJCNT_OLE:
+ bRet = FALSE;
+ break;
+ default:; //prevent warning
+ }
+ return bRet;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Pointer umschalten
+ --------------------------------------------------------------------*/
+
+
+void SwEditWin::UpdatePointer(const Point &rLPt, USHORT nModifier )
+{
+ SwWrtShell &rSh = rView.GetWrtShell();
+ if( pApplyTempl )
+ {
+ PointerStyle eStyle = POINTER_FILL;
+ if( rSh.IsOverReadOnlyPos( rLPt ))
+ {
+ if( pUserMarker )
+ {
+ delete pUserMarker;
+ pUserMarker = 0L;
+ }
+// rSh.SwCrsrShell::UnSetVisCrsr( rLPt );
+ eStyle = POINTER_NOTALLOWED;
+ }
+ else
+ {
+ SwRect aRect;
+ SwRect* pRect = &aRect;
+ const SwFrmFmt* pFmt = 0;
+
+ bool bFrameIsValidTarget = false;
+ if( pApplyTempl->pFormatClipboard )
+ bFrameIsValidTarget = pApplyTempl->pFormatClipboard->HasContentForThisType( nsSelectionType::SEL_FRM );
+ else if( !pApplyTempl->nColor )
+ bFrameIsValidTarget = ( pApplyTempl->eType == SFX_STYLE_FAMILY_FRAME );
+
+ if( bFrameIsValidTarget &&
+ 0 !=(pFmt = rSh.GetFmtFromObj( rLPt, &pRect )) &&
+ PTR_CAST(SwFlyFrmFmt, pFmt))
+ {
+ //Highlight fuer Rahmen anwerfen
+ Rectangle aTmp( pRect->SVRect() );
+
+ if ( !pUserMarker )
+ {
+ pUserMarker = new SdrDropMarkerOverlay( *rSh.GetDrawView(), aTmp );
+ }
+ }
+ else if(pUserMarker)
+ {
+ delete pUserMarker;
+ pUserMarker = 0L;
+ }
+
+ rSh.SwCrsrShell::SetVisCrsr( rLPt );
+ }
+ SetPointer( eStyle );
+ return;
+ }
+
+ if( !rSh.VisArea().Width() )
+ return;
+
+ SET_CURR_SHELL(&rSh);
+
+ if ( IsChainMode() )
+ {
+ SwRect aRect;
+ int nChainable = rSh.Chainable( aRect, *rSh.GetFlyFrmFmt(), rLPt );
+ PointerStyle eStyle = nChainable
+ ? POINTER_CHAIN_NOTALLOWED : POINTER_CHAIN;
+ if ( !nChainable )
+ {
+ Rectangle aTmp( aRect.SVRect() );
+
+ if ( !pUserMarker )
+ {
+ pUserMarker = new SdrDropMarkerOverlay( *rSh.GetDrawView(), aTmp );
+ }
+ }
+ else
+ {
+ delete pUserMarker;
+ pUserMarker = 0L;
+ }
+
+ rView.GetViewFrame()->ShowStatusText(
+ SW_RESSTR(STR_CHAIN_OK+nChainable));
+ SetPointer( eStyle );
+ return;
+ }
+
+ // Removed ExecHyperlink option.
+ //BOOL bExecHyperlinks = rSh.GetViewOptions()->IsExecHyperlinks() ^
+ // (nModifier == KEY_MOD2 ? TRUE : FALSE);
+ BOOL bExecHyperlinks = rView.GetDocShell()->IsReadOnly();
+ if ( !bExecHyperlinks )
+ {
+ SvtSecurityOptions aSecOpts;
+ const BOOL bSecureOption = aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK );
+ if ( ( bSecureOption && nModifier == KEY_MOD1 ) ||
+ ( !bSecureOption && nModifier != KEY_MOD1 ) )
+ bExecHyperlinks = TRUE;
+ }
+
+ const BOOL bExecSmarttags = nModifier == KEY_MOD1;
+
+ SdrView *pSdrView = rSh.GetDrawView();
+ BOOL bPrefSdrPointer = FALSE;
+ BOOL bHitHandle = FALSE;
+ BOOL bCntAtPos = FALSE;
+ BOOL bIsDocReadOnly = rView.GetDocShell()->IsReadOnly() &&
+ rSh.IsCrsrReadonly();
+ aActHitType = SDRHIT_NONE;
+ PointerStyle eStyle = POINTER_TEXT;
+ if ( !pSdrView )
+ bCntAtPos = TRUE;
+ else if ( TRUE == (bHitHandle = pSdrView->PickHandle( rLPt ) != 0) )
+ {
+ aActHitType = SDRHIT_OBJECT;
+ bPrefSdrPointer = TRUE;
+ }
+ else
+ {
+ const BOOL bNotInSelObj = !rSh.IsInsideSelectedObj( rLPt );
+ if ( rView.GetDrawFuncPtr() && !bInsDraw && bNotInSelObj )
+ {
+ aActHitType = SDRHIT_OBJECT;
+ if (IsObjectSelect())
+ eStyle = POINTER_ARROW;
+ else
+ bPrefSdrPointer = TRUE;
+ }
+ else
+ {
+ SdrObject* pObj; SdrPageView* pPV;
+ pSdrView->SetHitTolerancePixel( HIT_PIX );
+ if ( bNotInSelObj && bExecHyperlinks &&
+ pSdrView->PickObj( rLPt, pSdrView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKMACRO ))
+ {
+ SdrObjMacroHitRec aTmp;
+ aTmp.aPos = rLPt;
+ aTmp.pPageView = pPV;
+ SetPointer( pObj->GetMacroPointer( aTmp ) );
+ return;
+ }
+ else
+ {
+ // dvo: IsObjSelectable() eventually calls SdrView::PickObj, so
+ // apparently this is used to determine whether this is a
+ // drawling layer object or not.
+ if ( rSh.IsObjSelectable( rLPt ) )
+ {
+ if (pSdrView->IsTextEdit())
+ {
+ aActHitType = SDRHIT_NONE;
+ bPrefSdrPointer = TRUE;
+ }
+ else
+ {
+ SdrViewEvent aVEvt;
+ SdrHitKind eHit = pSdrView->PickAnything(rLPt, aVEvt);
+
+ if (eHit == SDRHIT_URLFIELD && bExecHyperlinks)
+ {
+ aActHitType = SDRHIT_OBJECT;
+ bPrefSdrPointer = TRUE;
+ }
+ else
+ {
+ // if we're over a selected object, we show an
+ // ARROW by default. We only show a MOVE if 1) the
+ // object is selected, and 2) it may be moved
+ // (i.e., position is not protected).
+ bool bMovable =
+ (!bNotInSelObj) &&
+ (rSh.IsObjSelected() || rSh.IsFrmSelected()) &&
+ (!rSh.IsSelObjProtected(FLYPROTECT_POS));
+
+ eStyle = bMovable ? POINTER_MOVE : POINTER_ARROW;
+ aActHitType = SDRHIT_OBJECT;
+ }
+ }
+ }
+ else
+ {
+ if ( rSh.IsFrmSelected() && !bNotInSelObj )
+ {
+ // dvo: this branch appears to be dead and should be
+ // removed in a future version. Reason: The condition
+ // !bNotInSelObj means that this branch will only be
+ // executed in the cursor points inside a selected
+ // object. However, if this is the case, the previous
+ // if( rSh.IsObjSelectable(rLPt) ) must always be true:
+ // rLPt is inside a selected object, then obviously
+ // rLPt is over a selectable object.
+ if (rSh.IsSelObjProtected(FLYPROTECT_SIZE))
+ eStyle = POINTER_NOTALLOWED;
+ else
+ eStyle = POINTER_MOVE;
+ aActHitType = SDRHIT_OBJECT;
+ }
+ else
+ {
+ if ( rView.GetDrawFuncPtr() )
+ bPrefSdrPointer = TRUE;
+ else
+ bCntAtPos = TRUE;
+ }
+ }
+ }
+ }
+ }
+ if ( bPrefSdrPointer )
+ {
+ if (bIsDocReadOnly || (rSh.IsObjSelected() && rSh.IsSelObjProtected(FLYPROTECT_CONTENT)))
+ SetPointer( POINTER_NOTALLOWED );
+ else
+ {
+ if (rView.GetDrawFuncPtr() && rView.GetDrawFuncPtr()->IsInsertForm() && !bHitHandle)
+ SetPointer( POINTER_DRAW_RECT );
+ else
+ SetPointer( pSdrView->GetPreferedPointer( rLPt, rSh.GetOut() ) );
+ }
+ }
+ else
+ {
+ if( !rSh.IsPageAtPos( rLPt ) || pAnchorMarker )
+ eStyle = POINTER_ARROW;
+ else
+ {
+ if( bCntAtPos )
+ {
+ SwContentAtPos aSwContentAtPos(
+ SwContentAtPos::SW_CLICKFIELD|
+ SwContentAtPos::SW_INETATTR|
+ SwContentAtPos::SW_FTN |
+ SwContentAtPos::SW_SMARTTAG );
+ if( rSh.GetContentAtPos( rLPt, aSwContentAtPos) )
+ {
+ const bool bClickToFollow = SwContentAtPos::SW_INETATTR == aSwContentAtPos.eCntntAtPos ||
+ SwContentAtPos::SW_SMARTTAG == aSwContentAtPos.eCntntAtPos;
+
+ if( !bClickToFollow ||
+ (SwContentAtPos::SW_INETATTR == aSwContentAtPos.eCntntAtPos && bExecHyperlinks) ||
+ (SwContentAtPos::SW_SMARTTAG == aSwContentAtPos.eCntntAtPos && bExecSmarttags) )
+ eStyle = POINTER_REFHAND;
+ }
+ }
+ }
+
+ // which kind of text pointer have we to show - horz / vert - ?
+ if( POINTER_TEXT == eStyle && rSh.IsInVerticalText( &rLPt ))
+ eStyle = POINTER_TEXT_VERTICAL;
+
+ SetPointer( eStyle );
+ }
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Timer fuer Selektion vergroessern
+ --------------------------------------------------------------------*/
+
+
+IMPL_LINK( SwEditWin, TimerHandler, Timer *, EMPTYARG )
+{
+ DBG_PROFSTART(edithdl);
+
+ SwWrtShell &rSh = rView.GetWrtShell();
+ Point aModPt( aMovePos );
+ const SwRect aOldVis( rSh.VisArea() );
+ BOOL bDone = FALSE;
+
+ if ( !rSh.VisArea().IsInside( aModPt ) )
+ {
+ if ( bInsDraw )
+ {
+ const int nMaxScroll = 40;
+ rView.Scroll( Rectangle(aModPt,Size(1,1)), nMaxScroll, nMaxScroll);
+ bDone = TRUE;
+ }
+ else if ( bFrmDrag )
+ {
+ (rSh.*rSh.fnDrag)(&aModPt,FALSE);
+ bDone = TRUE;
+ }
+ if ( !bDone )
+ aModPt = rSh.GetCntntPos( aModPt,aModPt.Y() > rSh.VisArea().Bottom() );
+ }
+ if ( !bDone && !(bFrmDrag || bInsDraw) )
+ {
+ if ( pRowColumnSelectionStart )
+ {
+ Point aPos( aModPt );
+ rSh.SelectTableRowCol( *pRowColumnSelectionStart, &aPos, bIsRowDrag );
+ }
+ else
+ (rSh.*rSh.fnSetCrsr)( &aModPt, FALSE );
+
+ //fix(24138): Es kann sein, dass der "Sprung" ueber eine Tabelle so
+ //nicht geschafft wird. Deshalb wir hier eben per Up/Down ueber die
+ //Tabelle gesprungen.
+ const SwRect& rVisArea = rSh.VisArea();
+ if( aOldVis == rVisArea && !rSh.IsStartOfDoc() && !rSh.IsEndOfDoc() )
+ {
+ //JP 11.10.2001 Bug 72294 - take the center point of VisArea to
+ // decide in which direction the user want.
+ if( aModPt.Y() < ( rVisArea.Top() + rVisArea.Height() / 2 ) )
+ rSh.Up( TRUE, 1 );
+ else
+ rSh.Down( TRUE, 1 );
+ }
+ }
+
+ aMovePos += rSh.VisArea().Pos() - aOldVis.Pos();
+ JustifyAreaTimer();
+ DBG_PROFSTOP(edithdl);
+ return 0;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+void SwEditWin::JustifyAreaTimer()
+{
+ const Rectangle &rVisArea = GetView().GetVisArea();
+#ifdef UNX
+ const long coMinLen = 100;
+#else
+ const long coMinLen = 50;
+#endif
+ long nTimeout = 800,
+ nDiff = Max(
+ Max( aMovePos.Y() - rVisArea.Bottom(), rVisArea.Top() - aMovePos.Y() ),
+ Max( aMovePos.X() - rVisArea.Right(), rVisArea.Left() - aMovePos.X()));
+#ifdef TEST_FOR_BUG91313
+ aTimer.SetTimeout( Max( coMinLen, nTimeout - nDiff) );
+#else
+ aTimer.SetTimeout( Max( coMinLen, nTimeout - nDiff*2L) );
+#endif
+}
+
+void SwEditWin::LeaveArea(const Point &rPos)
+{
+ aMovePos = rPos;
+ JustifyAreaTimer();
+ if( !aTimer.IsActive() )
+ aTimer.Start();
+ if( pShadCrsr )
+ delete pShadCrsr, pShadCrsr = 0;
+}
+
+inline void SwEditWin::EnterArea()
+{
+ aTimer.Stop();
+}
+
+/*------------------------------------------------------------------------
+ Beschreibung: Modus fuer Rahmen einfuegen
+------------------------------------------------------------------------*/
+
+
+void SwEditWin::InsFrm(USHORT nCols)
+{
+ StdDrawMode( OBJ_NONE, FALSE );
+ bInsFrm = TRUE;
+ nInsFrmColCount = nCols;
+}
+
+
+
+void SwEditWin::StdDrawMode( SdrObjKind eSdrObjectKind, BOOL bObjSelect )
+{
+ SetSdrDrawMode( eSdrObjectKind );
+
+/* if (GetDrawFuncPtr())
+ GetDrawFuncPtr()->Deactivate();*/
+
+ if (bObjSelect)
+ rView.SetDrawFuncPtr(new DrawSelection( &rView.GetWrtShell(), this, &rView ));
+ else
+ rView.SetDrawFuncPtr(new SwDrawBase( &rView.GetWrtShell(), this, &rView ));
+
+ rView.SetSelDrawSlot();
+ SetSdrDrawMode( eSdrObjectKind );
+ if (bObjSelect)
+ rView.GetDrawFuncPtr()->Activate( SID_OBJECT_SELECT );
+ else
+ rView.GetDrawFuncPtr()->Activate( sal::static_int_cast< USHORT >(eSdrObjectKind) ); // don't know if this is useful at all; but it keeps functionality as it was...
+ bInsFrm = FALSE;
+ nInsFrmColCount = 1;
+}
+
+
+
+void SwEditWin::StopInsFrm()
+{
+ if (rView.GetDrawFuncPtr())
+ {
+ rView.GetDrawFuncPtr()->Deactivate();
+ rView.SetDrawFuncPtr(NULL);
+ }
+ rView.LeaveDrawCreate(); // Konstruktionsmode verlassen
+ bInsFrm = FALSE;
+ nInsFrmColCount = 1;
+}
+
+/*--------------------------------------------------------------------
+ --------------------------------------------------------------------*/
+
+
+BOOL SwEditWin::IsInputSequenceCheckingRequired( const String &rText, const SwPaM& rCrsr ) const
+{
+ const SvtCTLOptions& rCTLOptions = SW_MOD()->GetCTLOptions();
+ if ( !rCTLOptions.IsCTLFontEnabled() ||
+ !rCTLOptions.IsCTLSequenceChecking() )
+ return FALSE;
+
+ const xub_StrLen nFirstPos = rCrsr.Start()->nContent.GetIndex();
+ if ( 0 == nFirstPos ) /* first char needs not to be checked */
+ return FALSE;
+
+ SwBreakIt *pBreakIter = SwBreakIt::Get();
+ uno::Reference < i18n::XBreakIterator > xBI = pBreakIter->GetBreakIter();
+ long nCTLScriptPos = -1;
+
+ if (xBI.is())
+ {
+ if (xBI->getScriptType( rText, 0 ) == i18n::ScriptType::COMPLEX)
+ nCTLScriptPos = 0;
+ else
+ nCTLScriptPos = xBI->nextScript( rText, 0, i18n::ScriptType::COMPLEX );
+ }
+
+ return (0 <= nCTLScriptPos && nCTLScriptPos <= rText.Len());
+}
+
+
+/*--------------------------------------------------------------------
+ Beschreibung: Der Character Buffer wird in das Dokument eingefuegt
+ --------------------------------------------------------------------*/
+
+
+void SwEditWin::FlushInBuffer()
+{
+ if ( aInBuffer.Len() )
+ {
+ SwWrtShell& rSh = rView.GetWrtShell();
+
+ // generate new sequence input checker if not already done
+ if ( !pCheckIt )
+ pCheckIt = new SwCheckIt;
+
+ uno::Reference < i18n::XExtendedInputSequenceChecker > xISC = pCheckIt->xCheck;
+ if ( xISC.is() && IsInputSequenceCheckingRequired( aInBuffer, *rSh.GetCrsr() ) )
+ {
+ //
+ // apply (Thai) input sequence checking/correction
+ //
+
+ rSh.Push(); // push current cursor to stack
+
+ // get text from the beginning (i.e left side) of current selection
+ // to the start of the paragraph
+ rSh.NormalizePam(); // make point be the first (left) one
+ if (!rSh.GetCrsr()->HasMark())
+ rSh.GetCrsr()->SetMark();
+ rSh.GetCrsr()->GetMark()->nContent = 0;
+ String aLeftText( rSh.GetCrsr()->GetTxt() );
+
+ SvtCTLOptions& rCTLOptions = SW_MOD()->GetCTLOptions();
+
+ xub_StrLen nExpandSelection = 0;
+ if (aLeftText.Len() > 0)
+ {
+ sal_Unicode cChar = '\0';
+
+ xub_StrLen nTmpPos = aLeftText.Len();
+ sal_Int16 nCheckMode = rCTLOptions.IsCTLSequenceCheckingRestricted() ?
+ i18n::InputSequenceCheckMode::STRICT : i18n::InputSequenceCheckMode::BASIC;
+
+ rtl::OUString aOldText( aLeftText );
+ rtl::OUString aNewText( aOldText );
+ if (rCTLOptions.IsCTLSequenceCheckingTypeAndReplace())
+ {
+ for (xub_StrLen k = 0; k < aInBuffer.Len(); ++k)
+ {
+ cChar = aInBuffer.GetChar(k);
+ const xub_StrLen nPrevPos = static_cast<xub_StrLen>(xISC->correctInputSequence( aNewText, nTmpPos - 1, cChar, nCheckMode ));
+
+ // valid sequence or sequence could be corrected:
+ if (nPrevPos != aNewText.getLength())
+ nTmpPos = nPrevPos + 1;
+ }
+
+ // find position of first character that has changed
+ sal_Int32 nOldLen = aOldText.getLength();
+ sal_Int32 nNewLen = aNewText.getLength();
+ const sal_Unicode *pOldTxt = aOldText.getStr();
+ const sal_Unicode *pNewTxt = aNewText.getStr();
+ sal_Int32 nChgPos = 0;
+ while ( nChgPos < nOldLen && nChgPos < nNewLen &&
+ pOldTxt[nChgPos] == pNewTxt[nChgPos] )
+ ++nChgPos;
+
+ xub_StrLen nChgLen = static_cast< xub_StrLen >(nNewLen - nChgPos);
+ String aChgText( aNewText.copy( static_cast< xub_StrLen >(nChgPos), nChgLen ) );
+
+ if (aChgText.Len())
+ {
+ aInBuffer = aChgText;
+ nExpandSelection = aLeftText.Len() - static_cast< xub_StrLen >(nChgPos);
+ }
+ else
+ aInBuffer.Erase();
+ }
+ else
+ {
+ for (xub_StrLen k = 0; k < aInBuffer.Len(); ++k)
+ {
+ cChar = aInBuffer.GetChar(k);
+ if (xISC->checkInputSequence( aNewText, nTmpPos - 1, cChar, nCheckMode ))
+ {
+ // character can be inserted:
+ aNewText += rtl::OUString( (sal_Unicode) cChar );
+ ++nTmpPos;
+ }
+ }
+ aInBuffer = aNewText.copy( aOldText.getLength() ); // copy new text to be inserted to buffer
+ }
+ }
+
+ // at this point now we will insert the buffer text 'normally' some lines below...
+
+ rSh.Pop( FALSE ); // pop old cursor from stack
+
+ if (!aInBuffer.Len())
+ return;
+
+ // if text prior to the original selection needs to be changed
+ // as well, we now expand the selection accordingly.
+ SwPaM &rCrsr = *rSh.GetCrsr();
+ xub_StrLen nCrsrStartPos = rCrsr.Start()->nContent.GetIndex();
+ DBG_ASSERT( nCrsrStartPos >= nExpandSelection, "cannot expand selection as specified!!" );
+ if (nExpandSelection && nCrsrStartPos >= nExpandSelection)
+ {
+ if (!rCrsr.HasMark())
+ rCrsr.SetMark();
+ rCrsr.Start()->nContent -= nExpandSelection;
+ }
+ }
+
+ uno::Reference< frame::XDispatchRecorder > xRecorder =
+ rView.GetViewFrame()->GetBindings().GetRecorder();
+ if ( xRecorder.is() )
+ {
+ //Shell ermitteln
+ SfxShell *pSfxShell = lcl_GetShellFromDispatcher( rView, TYPE(SwTextShell) );
+ // Request generieren und recorden
+ if (pSfxShell)
+ {
+ SfxRequest aReq( rView.GetViewFrame(), FN_INSERT_STRING );
+ aReq.AppendItem( SfxStringItem( FN_INSERT_STRING, aInBuffer ) );
+ aReq.Done();
+ }
+ }
+ //#21019# apply CTL and CJK language to the text input
+ sal_Bool bLang = true;
+ if(eBufferLanguage != LANGUAGE_DONTKNOW)
+ {
+ USHORT nWhich = 0;
+ switch( GetI18NScriptTypeOfLanguage( eBufferLanguage ))
+ {
+ case i18n::ScriptType::ASIAN: nWhich = RES_CHRATR_CJK_LANGUAGE; break;
+ case i18n::ScriptType::COMPLEX: nWhich = RES_CHRATR_CTL_LANGUAGE; break;
+ case i18n::ScriptType::LATIN: nWhich = RES_CHRATR_LANGUAGE; break;
+ default: bLang = sal_False;
+ }
+ if(bLang)
+ {
+ SfxItemSet aLangSet(rView.GetPool(), nWhich, nWhich);
+ rSh.GetCurAttr(aLangSet);
+ if(SFX_ITEM_DEFAULT <= aLangSet.GetItemState(nWhich, TRUE))
+ {
+ LanguageType eLang = static_cast<const SvxLanguageItem&>(aLangSet.Get(nWhich)).GetLanguage();
+ if ( eLang == eBufferLanguage )
+ // current language attribute equal to language reported from system
+ bLang = sal_False;
+ else if ( !bInputLanguageSwitched && RES_CHRATR_LANGUAGE == nWhich /* && (eLang&LANGUAGE_MASK_PRIMARY) == LANGUAGE_ENGLISH */ )
+ {
+ // special case: switching between two "LATIN" languages
+ // In case the current keyboard setting might be suitable for both languages we can't safely assume that the user
+ // wants to use the language reported from the system, except if we knew that it was explicitly switched (thus the check for "bInputLangeSwitched").
+ // The language reported by the system could be just the system default language that the user is not even aware of,
+ // because no language selection tool is installed at all. In this case the OOo language should get preference as
+ // it might have been selected by the user explicitly.
+ // Usually this case happens if the OOo language is different to the system language but the system keyboard is still suitable
+ // for the OOo language (e.g. writing English texts with a German keyboard).
+ // For non-latin keyboards overwriting the attribute is still valid. We do this for kyrillic and greek ATM.
+ // In future versions of OOo this should be replaced by a configuration switch that allows to give the preference to
+ // the OOo setting or the system setting explicitly and/or a better handling of the script type.
+ sal_Int16 nScript = GetAppCharClass().getScript( aInBuffer, 0 );
+ i18n::UnicodeScript eType = (i18n::UnicodeScript) nScript;
+
+ bool bSystemIsNonLatin = false, bOOoLangIsNonLatin = false;
+ switch ( eType )
+ {
+ case i18n::UnicodeScript_kGreek:
+ case i18n::UnicodeScript_kCyrillic:
+ // in case other UnicodeScripts require special keyboards they can be added here
+ bSystemIsNonLatin = true;
+ break;
+ default:
+ break;
+ }
+
+ switch ( eLang )
+ {
+ case LANGUAGE_AZERI_CYRILLIC:
+ case LANGUAGE_BOSNIAN_CYRILLIC_BOSNIA_HERZEGOVINA:
+ case LANGUAGE_BULGARIAN:
+ case LANGUAGE_GREEK:
+ case LANGUAGE_RUSSIAN:
+ case LANGUAGE_RUSSIAN_MOLDOVA:
+ case LANGUAGE_SERBIAN_CYRILLIC:
+ case LANGUAGE_SERBIAN_CYRILLIC_BOSNIA_HERZEGOVINA:
+ case LANGUAGE_UZBEK_CYRILLIC:
+ case LANGUAGE_UKRAINIAN:
+ case LANGUAGE_BELARUSIAN:
+ bOOoLangIsNonLatin = true;
+ break;
+ default:
+ break;
+ }
+
+ bLang = (bSystemIsNonLatin != bOOoLangIsNonLatin);
+ }
+ }
+ if(bLang)
+ {
+ SvxLanguageItem aLangItem( eBufferLanguage, nWhich );
+ rSh.SetAttr( aLangItem );
+ }
+ }
+ }
+
+ rSh.Insert( aInBuffer );
+ eBufferLanguage = LANGUAGE_DONTKNOW;
+ aInBuffer.Erase();
+ bFlushCharBuffer = FALSE;
+ }
+}
+
+#define MOVE_LEFT_SMALL 0
+#define MOVE_UP_SMALL 1
+#define MOVE_RIGHT_BIG 2
+#define MOVE_DOWN_BIG 3
+#define MOVE_LEFT_BIG 4
+#define MOVE_UP_BIG 5
+#define MOVE_RIGHT_SMALL 6
+#define MOVE_DOWN_SMALL 7
+
+void SwEditWin::ChangeFly( BYTE nDir, BOOL bWeb )
+{
+ SwWrtShell &rSh = rView.GetWrtShell();
+ SwRect aTmp = rSh.GetFlyRect();
+ if( aTmp.HasArea() &&
+ // --> FME 2005-01-13 #i40348#
+ // IsSelObjProtected() seems to be the correct condition, not
+ // !HasReadonlySel(), otherwise frame is not moveable if content is
+ // protected.
+ !rSh.IsSelObjProtected( FLYPROTECT_POS|FLYPROTECT_SIZE ) )
+ // <--
+ {
+ // OD 18.09.2003 #i18732# - add item <RES_FOLLOW_TEXT_FLOW>
+ SfxItemSet aSet(rSh.GetAttrPool(),
+ RES_FRM_SIZE, RES_FRM_SIZE,
+ RES_VERT_ORIENT, RES_ANCHOR,
+ RES_COL, RES_COL,
+ RES_PROTECT, RES_PROTECT,
+ RES_FOLLOW_TEXT_FLOW, RES_FOLLOW_TEXT_FLOW, 0);
+ rSh.GetFlyFrmAttr( aSet );
+ RndStdIds eAnchorId = ((SwFmtAnchor&)aSet.Get(RES_ANCHOR)).GetAnchorId();
+ Size aSnap;
+ if(MOVE_LEFT_SMALL == nDir ||
+ MOVE_UP_SMALL == nDir ||
+ MOVE_RIGHT_SMALL == nDir ||
+ MOVE_DOWN_SMALL == nDir )
+ aSnap = PixelToLogic(Size(1,1));
+ else
+ {
+ aSnap = rSh.GetViewOptions()->GetSnapSize();
+ short nDiv = rSh.GetViewOptions()->GetDivisionX();
+ if ( nDiv > 0 )
+ aSnap.Width() = Max( (ULONG)1, (ULONG)aSnap.Width() / nDiv );
+ nDiv = rSh.GetViewOptions()->GetDivisionY();
+ if ( nDiv > 0 )
+ aSnap.Height() = Max( (ULONG)1, (ULONG)aSnap.Height() / nDiv );
+ }
+
+ SwRect aBoundRect;
+ Point aRefPoint;
+ // OD 18.09.2003 #i18732# - adjustment for allowing vertical position
+ // aligned to page for fly frame anchored to paragraph or to character.
+ {
+ SwFmtVertOrient aVert( (SwFmtVertOrient&)aSet.Get(RES_VERT_ORIENT) );
+ const bool bFollowTextFlow =
+ static_cast<const SwFmtFollowTextFlow&>(aSet.Get(RES_FOLLOW_TEXT_FLOW)).GetValue();
+ // OD 12.11.2003 #i22341# - additional provide content position
+ const SwPosition* pToCharCntntPos = ((SwFmtAnchor&)aSet.Get(RES_ANCHOR)).GetCntntAnchor();
+ rSh.CalcBoundRect( aBoundRect, eAnchorId,
+ text::RelOrientation::FRAME, aVert.GetRelationOrient(),
+ pToCharCntntPos, bFollowTextFlow,
+ false, &aRefPoint );
+ }
+ long nLeft = Min( aTmp.Left() - aBoundRect.Left(), aSnap.Width() );
+ long nRight = Min( aBoundRect.Right() - aTmp.Right(), aSnap.Width() );
+ long nUp = Min( aTmp.Top() - aBoundRect.Top(), aSnap.Height() );
+ long nDown = Min( aBoundRect.Bottom() - aTmp.Bottom(), aSnap.Height() );
+
+ switch ( nDir )
+ {
+ case MOVE_LEFT_BIG:
+ case MOVE_LEFT_SMALL: aTmp.Left( aTmp.Left() - nLeft ); break;
+ case MOVE_UP_BIG:
+ case MOVE_UP_SMALL: aTmp.Top( aTmp.Top() - nUp ); break;
+ case MOVE_RIGHT_SMALL: if( aTmp.Width() < aSnap.Width() + MINFLY ) break;
+ nRight = aSnap.Width(); // kein break
+ case MOVE_RIGHT_BIG: aTmp.Left( aTmp.Left() + nRight ); break;
+ case MOVE_DOWN_SMALL: if( aTmp.Height() < aSnap.Height() + MINFLY ) break;
+ nDown = aSnap.Height(); // kein break
+ case MOVE_DOWN_BIG: aTmp.Top( aTmp.Top() + nDown ); break;
+ default: ASSERT( TRUE, "ChangeFly: Unknown direction." );
+ }
+ BOOL bSet = FALSE;
+ if ((FLY_AS_CHAR == eAnchorId) && ( nDir % 2 ))
+ {
+ long aDiff = aTmp.Top() - aRefPoint.Y();
+ if( aDiff > 0 )
+ aDiff = 0;
+ else if ( aDiff < -aTmp.Height() )
+ aDiff = -aTmp.Height();
+ SwFmtVertOrient aVert( (SwFmtVertOrient&)aSet.Get(RES_VERT_ORIENT) );
+ sal_Int16 eNew;
+ if( bWeb )
+ {
+ eNew = aVert.GetVertOrient();
+ BOOL bDown = 0 != ( nDir & 0x02 );
+ switch( eNew )
+ {
+ case text::VertOrientation::CHAR_TOP:
+ if( bDown ) eNew = text::VertOrientation::CENTER;
+ break;
+ case text::VertOrientation::CENTER:
+ eNew = bDown ? text::VertOrientation::TOP : text::VertOrientation::CHAR_TOP;
+ break;
+ case text::VertOrientation::TOP:
+ if( !bDown ) eNew = text::VertOrientation::CENTER;
+ break;
+ case text::VertOrientation::LINE_TOP:
+ if( bDown ) eNew = text::VertOrientation::LINE_CENTER;
+ break;
+ case text::VertOrientation::LINE_CENTER:
+ eNew = bDown ? text::VertOrientation::LINE_BOTTOM : text::VertOrientation::LINE_TOP;
+ break;
+ case text::VertOrientation::LINE_BOTTOM:
+ if( !bDown ) eNew = text::VertOrientation::LINE_CENTER;
+ break;
+ default:; //prevent warning
+ }
+ }
+ else
+ {
+ aVert.SetPos( aDiff );
+ eNew = text::VertOrientation::NONE;
+ }
+ aVert.SetVertOrient( eNew );
+ aSet.Put( aVert );
+ bSet = TRUE;
+ }
+ if (bWeb && (FLY_AT_PARA == eAnchorId)
+ && ( nDir==MOVE_LEFT_SMALL || nDir==MOVE_RIGHT_BIG ))
+ {
+ SwFmtHoriOrient aHori( (SwFmtHoriOrient&)aSet.Get(RES_HORI_ORIENT) );
+ sal_Int16 eNew;
+ eNew = aHori.GetHoriOrient();
+ switch( eNew )
+ {
+ case text::HoriOrientation::RIGHT:
+ if( nDir==MOVE_LEFT_SMALL )
+ eNew = text::HoriOrientation::LEFT;
+ break;
+ case text::HoriOrientation::LEFT:
+ if( nDir==MOVE_RIGHT_BIG )
+ eNew = text::HoriOrientation::RIGHT;
+ break;
+ default:; //prevent warning
+ }
+ if( eNew != aHori.GetHoriOrient() )
+ {
+ aHori.SetHoriOrient( eNew );
+ aSet.Put( aHori );
+ bSet = TRUE;
+ }
+ }
+ rSh.StartAllAction();
+ if( bSet )
+ rSh.SetFlyFrmAttr( aSet );
+ BOOL bSetPos = (FLY_AS_CHAR != eAnchorId);
+ if(bSetPos && bWeb)
+ {
+ if (FLY_AT_PAGE != eAnchorId)
+ {
+ bSetPos = FALSE;
+ }
+ else
+ {
+ bSetPos = (::GetHtmlMode(rView.GetDocShell()) & HTMLMODE_SOME_ABS_POS) ?
+ TRUE : FALSE;
+ }
+ }
+ if( bSetPos )
+ rSh.SetFlyPos( aTmp.Pos() );
+ rSh.EndAllAction();
+ }
+}
+/* -----------------------------23.05.2002 11:35------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SwEditWin::ChangeDrawing( BYTE nDir )
+{
+ // --> OD 2005-01-31 #i40845# - start undo action in order to get only one
+ // undo action for this change.
+ SwWrtShell &rSh = rView.GetWrtShell();
+ rSh.StartUndo();
+ // <--
+
+ long nX = 0;
+ long nY = 0;
+ sal_Bool bOnePixel = sal_False;
+ USHORT nAnchorDir = SW_MOVE_UP;
+ switch(nDir)
+ {
+ case MOVE_LEFT_SMALL:
+ bOnePixel = sal_True;
+ //no break;
+ case MOVE_LEFT_BIG:
+ nX = -1;
+ nAnchorDir = SW_MOVE_LEFT;
+ break;
+ case MOVE_UP_SMALL:
+ bOnePixel = sal_True;
+ //no break;
+ case MOVE_UP_BIG:
+ nY = -1;
+ break;
+ case MOVE_RIGHT_SMALL:
+ bOnePixel = sal_True;
+ //no break;
+ case MOVE_RIGHT_BIG:
+ nX = +1;
+ nAnchorDir = SW_MOVE_RIGHT;
+ break;
+ case MOVE_DOWN_SMALL:
+ bOnePixel = sal_True;
+ //no break;
+ case MOVE_DOWN_BIG:
+ nY = +1;
+ nAnchorDir = SW_MOVE_DOWN;
+ break;
+ }
+
+ if(0 != nX || 0 != nY)
+ {
+ BYTE nProtect = rSh.IsSelObjProtected( FLYPROTECT_POS|FLYPROTECT_SIZE );
+ Size aSnap( rSh.GetViewOptions()->GetSnapSize() );
+ short nDiv = rSh.GetViewOptions()->GetDivisionX();
+ if ( nDiv > 0 )
+ aSnap.Width() = Max( (ULONG)1, (ULONG)aSnap.Width() / nDiv );
+ nDiv = rSh.GetViewOptions()->GetDivisionY();
+ if ( nDiv > 0 )
+ aSnap.Height() = Max( (ULONG)1, (ULONG)aSnap.Height() / nDiv );
+
+ if(bOnePixel)
+ aSnap = PixelToLogic(Size(1,1));
+
+ nX *= aSnap.Width();
+ nY *= aSnap.Height();
+
+ SdrView *pSdrView = rSh.GetDrawView();
+ const SdrHdlList& rHdlList = pSdrView->GetHdlList();
+ SdrHdl* pHdl = rHdlList.GetFocusHdl();
+ rSh.StartAllAction();
+ if(0L == pHdl)
+ {
+ // now move the selected draw objects
+ // if the object's position is not protected
+ if(0 == (nProtect&FLYPROTECT_POS))
+ {
+ // --> FME 2005-04-26 #i47138#
+ // Check if object is anchored as character and move direction
+ BOOL bDummy;
+ const bool bVertAnchor = rSh.IsFrmVertical( TRUE, bDummy );
+ const bool bHoriMove = !bVertAnchor == !( nDir % 2 );
+ const bool bMoveAllowed =
+ !bHoriMove || (rSh.GetAnchorId() != FLY_AS_CHAR);
+ if ( bMoveAllowed )
+ {
+ // <--
+ pSdrView->MoveAllMarked(Size(nX, nY));
+ rSh.SetModified();
+ }
+ }
+ }
+ else
+ {
+ // move handle with index nHandleIndex
+ if(pHdl && (nX || nY))
+ {
+ if( HDL_ANCHOR == pHdl->GetKind() ||
+ HDL_ANCHOR_TR == pHdl->GetKind() )
+ {
+ // anchor move cannot be allowed when position is protected
+ if(0 == (nProtect&FLYPROTECT_POS))
+ rSh.MoveAnchor( nAnchorDir );
+ }
+ //now resize if size is protected
+ else if(0 == (nProtect&FLYPROTECT_SIZE))
+ {
+ // now move the Handle (nX, nY)
+ Point aStartPoint(pHdl->GetPos());
+ Point aEndPoint(pHdl->GetPos() + Point(nX, nY));
+ const SdrDragStat& rDragStat = pSdrView->GetDragStat();
+
+ // start dragging
+ pSdrView->BegDragObj(aStartPoint, 0, pHdl, 0);
+
+ if(pSdrView->IsDragObj())
+ {
+ BOOL bWasNoSnap = static_cast< BOOL >(rDragStat.IsNoSnap());
+ BOOL bWasSnapEnabled = pSdrView->IsSnapEnabled();
+
+ // switch snapping off
+ if(!bWasNoSnap)
+ ((SdrDragStat&)rDragStat).SetNoSnap(TRUE);
+ if(bWasSnapEnabled)
+ pSdrView->SetSnapEnabled(FALSE);
+
+ pSdrView->MovAction(aEndPoint);
+ pSdrView->EndDragObj();
+ rSh.SetModified();
+
+ // restore snap
+ if(!bWasNoSnap)
+ ((SdrDragStat&)rDragStat).SetNoSnap(bWasNoSnap);
+ if(bWasSnapEnabled)
+ pSdrView->SetSnapEnabled(bWasSnapEnabled);
+ }
+ }
+ }
+ }
+ rSh.EndAllAction();
+ }
+
+ // --> OD 2005-01-31 #i40845# - end undo action
+ rSh.EndUndo();
+ // <--
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: KeyEvents
+ --------------------------------------------------------------------*/
+
+
+
+void SwEditWin::KeyInput(const KeyEvent &rKEvt)
+{
+ if( rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE &&
+ pApplyTempl && pApplyTempl->pFormatClipboard )
+ {
+ pApplyTempl->pFormatClipboard->Erase();
+ SetApplyTemplate(SwApplyTemplate());
+ rView.GetViewFrame()->GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
+ }
+
+ SfxObjectShell *pObjSh = (SfxObjectShell*)rView.GetViewFrame()->GetObjectShell();
+ if ( bLockInput || (pObjSh && pObjSh->GetProgress()) )
+ // Wenn die Rechenleiste aktiv ist oder
+ // auf dem Document ein Progress laeuft wird keine
+ // Bestellungen angenommen.
+ return;
+
+ if( pShadCrsr )
+ delete pShadCrsr, pShadCrsr = 0;
+ aKeyInputFlushTimer.Stop();
+
+ SwWrtShell &rSh = rView.GetWrtShell();
+ BOOL bIsDocReadOnly = rView.GetDocShell()->IsReadOnly() &&
+ rSh.IsCrsrReadonly();
+
+ //if the language changes the buffer must be flushed
+ LanguageType eNewLanguage = GetInputLanguage();
+ if(!bIsDocReadOnly && eBufferLanguage != eNewLanguage && aInBuffer.Len())
+ {
+ FlushInBuffer();
+ }
+ eBufferLanguage = eNewLanguage;
+
+ QuickHelpData aTmpQHD;
+ if( pQuickHlpData->bClear )
+ {
+ aTmpQHD.Move( *pQuickHlpData );
+ pQuickHlpData->Stop( rSh );
+ }
+
+ // OS:auch die DrawView braucht noch ein readonly-Flag
+ if ( !bIsDocReadOnly && rSh.GetDrawView() && rSh.GetDrawView()->KeyInput( rKEvt, this ) )
+ {
+ rSh.GetView().GetViewFrame()->GetBindings().InvalidateAll( FALSE );
+ rSh.SetModified();
+ return; // Event von der SdrView ausgewertet
+ }
+
+ if ( rView.GetDrawFuncPtr() && bInsFrm )
+ {
+ StopInsFrm();
+ rSh.Edit();
+ }
+
+ BOOL bFlushBuffer = FALSE;
+ BOOL bNormalChar = FALSE;
+ BOOL bChkInsBlank = pQuickHlpData->bChkInsBlank;
+ pQuickHlpData->bChkInsBlank = FALSE;
+
+ KeyEvent aKeyEvent( rKEvt );
+ // look for vertical mappings
+ if( !bIsDocReadOnly && !rSh.IsSelFrmMode() && !rSh.IsObjSelected() )
+ {
+ //JP 21.2.2002: must changed from switch to if, because the Linux
+ // compiler has problem with the code. Has to remove if the new general
+ // handler exist.
+ USHORT nKey = rKEvt.GetKeyCode().GetCode();
+
+ if( KEY_UP == nKey || KEY_DOWN == nKey ||
+ KEY_LEFT == nKey || KEY_RIGHT == nKey )
+ {
+ // In general, we want to map the direction keys if we are inside
+ // some vertical formatted text.
+ // 1. Exception: For a table cursor in a horizontal table, the
+ // directions should never be mapped.
+ // 2. Exception: For a table cursor in a vertical table, the
+ // directions should always be mapped.
+ const bool bVertText = rSh.IsInVerticalText();
+ const bool bTblCrsr = rSh.GetTableCrsr();
+ const bool bVertTable = rSh.IsTableVertical();
+ if( ( bVertText && ( !bTblCrsr || bVertTable ) ) ||
+ ( bTblCrsr && bVertTable ) )
+ {
+ if( KEY_UP == nKey ) nKey = KEY_LEFT;
+ else if( KEY_DOWN == nKey ) nKey = KEY_RIGHT;
+ else if( KEY_LEFT == nKey ) nKey = KEY_DOWN;
+ else if( KEY_RIGHT == nKey ) nKey = KEY_UP;
+ }
+ if ( rSh.IsInRightToLeftText() )
+ {
+ if( KEY_LEFT == nKey ) nKey = KEY_RIGHT;
+ else if( KEY_RIGHT == nKey ) nKey = KEY_LEFT;
+ }
+
+ aKeyEvent = KeyEvent( rKEvt.GetCharCode(),
+ KeyCode( nKey, rKEvt.GetKeyCode().GetModifier() ),
+ rKEvt.GetRepeat() );
+ }
+ }
+
+ const KeyCode& rKeyCode = aKeyEvent.GetKeyCode();
+ sal_Unicode aCh = aKeyEvent.GetCharCode();
+
+ // enable switching to notes ankor with Ctrl - Alt - Page Up/Down
+ // pressing this inside a note will switch to next/previous note
+ if ((rKeyCode.IsMod1() && rKeyCode.IsMod2()) && ((rKeyCode.GetCode() == KEY_PAGEUP) || (rKeyCode.GetCode() == KEY_PAGEDOWN)))
+ {
+ bool bNext = rKeyCode.GetCode()==KEY_PAGEDOWN ? true : false;
+ SwFieldType* pFldType = rSh.GetFldType(0, RES_POSTITFLD);
+ rSh.MoveFldType( pFldType, bNext );
+ return;
+ }
+
+ const SwFrmFmt* pFlyFmt = rSh.GetFlyFrmFmt();
+ if( pFlyFmt )
+ {
+ USHORT nEvent;
+
+ if( 32 <= aCh &&
+ 0 == (( KEY_MOD1 | KEY_MOD2 ) & rKeyCode.GetModifier() ))
+ nEvent = SW_EVENT_FRM_KEYINPUT_ALPHA;
+ else
+ nEvent = SW_EVENT_FRM_KEYINPUT_NOALPHA;
+
+ const SvxMacro* pMacro = pFlyFmt->GetMacro().GetMacroTable().Get( nEvent );
+ if( pMacro )
+ {
+ String sRet;
+ SbxArrayRef xArgs = new SbxArray;
+ SbxVariableRef xVar = new SbxVariable;
+ xVar->PutString( pFlyFmt->GetName() );
+ xArgs->Put( &xVar, 1 );
+
+ xVar = new SbxVariable;
+ if( SW_EVENT_FRM_KEYINPUT_ALPHA == nEvent )
+ xVar->PutChar( aCh );
+ else
+ xVar->PutUShort( rKeyCode.GetModifier() | rKeyCode.GetCode() );
+ xArgs->Put( &xVar, 2 );
+
+ rSh.ExecMacro( *pMacro, &sRet, &xArgs );
+ if( sRet.Len() && 0 != sRet.ToInt32() )
+ return ;
+ }
+ }
+ int nLclSelectionType;
+ //A is converted to 1
+ if( rKeyCode.GetFullCode() == (KEY_A | KEY_MOD1 |KEY_SHIFT)
+ && rSh.HasDrawView() &&
+ (0 != (nLclSelectionType = rSh.GetSelectionType()) &&
+ ((nLclSelectionType & (nsSelectionType::SEL_FRM|nsSelectionType::SEL_GRF)) ||
+ ((nLclSelectionType & (nsSelectionType::SEL_DRW|nsSelectionType::SEL_DRW_FORM)) &&
+ rSh.GetDrawView()->GetMarkedObjectList().GetMarkCount() == 1))))
+ {
+ SdrHdlList& rHdlList = (SdrHdlList&)rSh.GetDrawView()->GetHdlList();
+ SdrHdl* pAnchor = rHdlList.GetHdl(HDL_ANCHOR);
+ if ( ! pAnchor )
+ pAnchor = rHdlList.GetHdl(HDL_ANCHOR_TR);
+ if(pAnchor)
+ rHdlList.SetFocusHdl(pAnchor);
+ return;
+ }
+
+ SvxAutoCorrCfg* pACfg = 0;
+ SvxAutoCorrect* pACorr = 0;
+
+ uno::Reference< frame::XDispatchRecorder > xRecorder =
+ rView.GetViewFrame()->GetBindings().GetRecorder();
+ if ( !xRecorder.is() )
+ {
+ pACfg = SvxAutoCorrCfg::Get();
+ pACorr = pACfg->GetAutoCorrect();
+ }
+
+ SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
+
+ TblChgWidthHeightType eTblChgMode = nsTblChgWidthHeightType::WH_COL_LEFT; // initialization just for warning-free code
+ USHORT nTblChgSize = 0;
+ BOOL bStopKeyInputTimer = TRUE;
+ String sFmlEntry;
+
+ enum SW_KeyState { KS_Start,
+ KS_CheckKey, KS_InsChar, KS_InsTab,
+ KS_NoNum, KS_NumOff, KS_NumOrNoNum, KS_NumDown, KS_NumUp,
+ // -> #i23725#
+ KS_NumIndentInc, KS_NumIndentDec,
+ // <- #i23725#
+
+ KS_OutlineLvOff,
+ KS_NextCell, KS_PrevCell, KS_OutlineUp, KS_OutlineDown,
+ KS_GlossaryExpand, KS_NextPrevGlossary,
+ KS_AutoFmtByInput,
+ KS_NextObject, KS_PrevObject,
+ KS_KeyToView,
+ KS_LaunchOLEObject, KS_GoIntoFly, KS_GoIntoDrawing,
+ KS_EnterDrawHandleMode,
+ KS_CheckDocReadOnlyKeys,
+ KS_CheckAutoCorrect, KS_EditFormula,
+ KS_ColLeftBig, KS_ColRightBig,
+ KS_ColLeftSmall, KS_ColRightSmall,
+ KS_ColTopBig, KS_ColBottomBig,
+ KS_ColTopSmall, KS_ColBottomSmall,
+ KS_CellLeftBig, KS_CellRightBig,
+ KS_CellLeftSmall, KS_CellRightSmall,
+ KS_CellTopBig, KS_CellBottomBig,
+ KS_CellTopSmall, KS_CellBottomSmall,
+
+ KS_InsDel_ColLeftBig, KS_InsDel_ColRightBig,
+ KS_InsDel_ColLeftSmall, KS_InsDel_ColRightSmall,
+ KS_InsDel_ColTopBig, KS_InsDel_ColBottomBig,
+ KS_InsDel_ColTopSmall, KS_InsDel_ColBottomSmall,
+ KS_InsDel_CellLeftBig, KS_InsDel_CellRightBig,
+ KS_InsDel_CellLeftSmall, KS_InsDel_CellRightSmall,
+ KS_InsDel_CellTopBig, KS_InsDel_CellBottomBig,
+ KS_InsDel_CellTopSmall, KS_InsDel_CellBottomSmall,
+ KS_TblColCellInsDel,
+
+ KS_Fly_Change, KS_Draw_Change,
+ KS_SpecialInsert,
+ KS_EnterCharCell,
+ KS_GotoNextFieldMark,
+ KS_GotoPrevFieldMark,
+ KS_Ende };
+
+
+
+ SW_KeyState eKeyState = bIsDocReadOnly ? KS_CheckDocReadOnlyKeys
+ : KS_CheckKey,
+ eNextKeyState = KS_Ende;
+ BYTE nDir = 0;
+
+ // -> #i23725#
+ if (nKS_NUMDOWN_Count > 0)
+ nKS_NUMDOWN_Count--;
+
+ if (nKS_NUMINDENTINC_Count > 0)
+ nKS_NUMINDENTINC_Count--;
+ // <- #i23725#
+
+ while( KS_Ende != eKeyState )
+ {
+ SW_KeyState eFlyState = KS_KeyToView;
+
+ switch( eKeyState )
+ {
+ case KS_CheckKey:
+ eKeyState = KS_KeyToView; // default weiter zur View
+
+#ifdef DBG_UTIL
+//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ // JP 19.01.99: zum Umschalten des Cursor Verhaltens in ReadOnly
+ // Bereichen
+ if( 0x7210 == rKeyCode.GetFullCode() )
+ rSh.SetReadOnlyAvailable( !rSh.IsReadOnlyAvailable() );
+ else
+//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+#endif
+
+ if( !rKeyCode.IsMod2() && '=' == aCh &&
+ !rSh.IsTableMode() && rSh.GetTableFmt() &&
+ rSh.IsSttPara() /*&& rSh.IsEndPara()*/ &&
+ !rSh.HasReadonlySel() )
+ {
+ // in der Tabelle am Anfang der Zelle ein '=' ->
+ // EditZeile aufrufen (F2-Funktionalitaet)
+ rSh.Push();
+ if( !rSh.MoveSection( fnSectionCurr, fnSectionStart) &&
+ !rSh.IsTableBoxTextFormat() )
+ {
+ // steht also am Anfang der Box
+ eKeyState = KS_EditFormula;
+ if( rSh.HasMark() )
+ rSh.SwapPam();
+ else
+ rSh.SttSelect();
+ rSh.MoveSection( fnSectionCurr, fnSectionEnd );
+ rSh.Pop( TRUE );
+ rSh.EndSelect();
+ sFmlEntry = '=';
+ }
+ else
+ rSh.Pop( FALSE );
+ }
+ else
+ {
+ if( pACorr && aTmpQHD.HasCntnt() && !rSh.HasSelection() &&
+ !rSh.HasReadonlySel() && !aTmpQHD.bIsAutoText &&
+ pACorr->GetSwFlags().nAutoCmpltExpandKey ==
+ (rKeyCode.GetModifier() | rKeyCode.GetCode()) )
+ {
+ eKeyState = KS_GlossaryExpand;
+ break;
+ }
+
+ switch( rKeyCode.GetModifier() | rKeyCode.GetCode() )
+ {
+ case KEY_RIGHT | KEY_MOD2:
+ eKeyState = KS_ColRightBig;
+ eFlyState = KS_Fly_Change;
+ nDir = MOVE_RIGHT_SMALL;
+ goto KEYINPUT_CHECKTABLE;
+
+ case KEY_LEFT | KEY_MOD2:
+ eKeyState = KS_ColRightSmall;
+ eFlyState = KS_Fly_Change;
+ nDir = MOVE_LEFT_SMALL;
+ goto KEYINPUT_CHECKTABLE;
+ case KEY_RIGHT | KEY_MOD2 | KEY_SHIFT:
+ eKeyState = KS_ColLeftSmall;
+ goto KEYINPUT_CHECKTABLE;
+ case KEY_LEFT | KEY_MOD2 | KEY_SHIFT:
+ eKeyState = KS_ColLeftBig;
+ goto KEYINPUT_CHECKTABLE;
+
+ case KEY_RIGHT | KEY_MOD2 | KEY_MOD1:
+ eKeyState = KS_CellRightBig;
+ goto KEYINPUT_CHECKTABLE;
+ case KEY_LEFT | KEY_MOD2 | KEY_MOD1:
+ eKeyState = KS_CellRightSmall;
+ goto KEYINPUT_CHECKTABLE;
+ case KEY_RIGHT | KEY_MOD2 | KEY_SHIFT | KEY_MOD1:
+ eKeyState = KS_CellLeftSmall;
+ goto KEYINPUT_CHECKTABLE;
+ case KEY_LEFT | KEY_MOD2 | KEY_SHIFT | KEY_MOD1:
+ eKeyState = KS_CellLeftBig;
+ goto KEYINPUT_CHECKTABLE;
+
+ case KEY_UP | KEY_MOD2:
+ eKeyState = KS_ColBottomSmall;
+ eFlyState = KS_Fly_Change;
+ nDir = MOVE_UP_SMALL;
+ goto KEYINPUT_CHECKTABLE;
+ case KEY_DOWN | KEY_MOD2:
+ eKeyState = KS_ColBottomBig;
+ eFlyState = KS_Fly_Change;
+ nDir = MOVE_DOWN_SMALL;
+ goto KEYINPUT_CHECKTABLE;
+// case KEY_UP | KEY_MOD2 | KEY_SHIFT:
+// eKeyState = KS_ColTopBig;
+// goto KEYINPUT_CHECKTABLE;
+// case KEY_DOWN | KEY_MOD2 | KEY_SHIFT:
+// eKeyState = KS_ColTopSmall;
+// goto KEYINPUT_CHECKTABLE;
+
+ case KEY_UP | KEY_MOD2 | KEY_MOD1:
+ eKeyState = KS_CellBottomSmall;
+ goto KEYINPUT_CHECKTABLE;
+ case KEY_DOWN | KEY_MOD2 | KEY_MOD1:
+ eKeyState = KS_CellBottomBig;
+ goto KEYINPUT_CHECKTABLE;
+ case KEY_UP | KEY_MOD2 | KEY_SHIFT | KEY_MOD1:
+ eKeyState = KS_CellTopBig;
+ goto KEYINPUT_CHECKTABLE;
+ case KEY_DOWN | KEY_MOD2 | KEY_SHIFT | KEY_MOD1:
+ eKeyState = KS_CellTopSmall;
+ goto KEYINPUT_CHECKTABLE;
+
+KEYINPUT_CHECKTABLE:
+ if( rSh.IsTableMode() || !rSh.GetTableFmt() )
+ {
+ if(KS_KeyToView != eFlyState)
+ {
+ if(!pFlyFmt && KS_KeyToView != eFlyState &&
+ (rSh.GetSelectionType() & (nsSelectionType::SEL_DRW|nsSelectionType::SEL_DRW_FORM)) &&
+ rSh.GetDrawView()->AreObjectsMarked())
+ eKeyState = KS_Draw_Change;
+ }
+
+ if( pFlyFmt )
+ eKeyState = eFlyState;
+ else if( KS_Draw_Change != eKeyState)
+ eKeyState = KS_EnterCharCell;
+ }
+ break;
+
+//-------
+// Insert/Delete
+ case KEY_LEFT:
+ case KEY_LEFT | KEY_MOD1:
+ {
+ BOOL bMod1 = 0 != (rKeyCode.GetModifier() & KEY_MOD1);
+ if(!bMod1)
+ {
+ eFlyState = KS_Fly_Change;
+ nDir = MOVE_LEFT_BIG;
+ }
+ eTblChgMode = nsTblChgWidthHeightType::WH_FLAG_INSDEL |
+ ( bMod1
+ ? nsTblChgWidthHeightType::WH_CELL_LEFT
+ : nsTblChgWidthHeightType::WH_COL_LEFT );
+ nTblChgSize = pModOpt->GetTblVInsert();
+ }
+ goto KEYINPUT_CHECKTABLE_INSDEL;
+// case KEY_RIGHT:
+ case KEY_RIGHT | KEY_MOD1:
+ {
+ eTblChgMode = nsTblChgWidthHeightType::WH_FLAG_INSDEL | nsTblChgWidthHeightType::WH_CELL_RIGHT;
+ nTblChgSize = pModOpt->GetTblVInsert();
+ }
+ goto KEYINPUT_CHECKTABLE_INSDEL;
+ case KEY_UP:
+ case KEY_UP | KEY_MOD1:
+ {
+ BOOL bMod1 = 0 != (rKeyCode.GetModifier() & KEY_MOD1);
+ if(!bMod1)
+ {
+ eFlyState = KS_Fly_Change;
+ nDir = MOVE_UP_BIG;
+ }
+ eTblChgMode = nsTblChgWidthHeightType::WH_FLAG_INSDEL |
+ ( bMod1
+ ? nsTblChgWidthHeightType::WH_CELL_TOP
+ : nsTblChgWidthHeightType::WH_ROW_TOP );
+ nTblChgSize = pModOpt->GetTblHInsert();
+ }
+ goto KEYINPUT_CHECKTABLE_INSDEL;
+ case KEY_DOWN:
+ case KEY_DOWN | KEY_MOD1:
+ {
+ BOOL bMod1 = 0 != (rKeyCode.GetModifier() & KEY_MOD1);
+ if(!bMod1)
+ {
+ eFlyState = KS_Fly_Change;
+ nDir = MOVE_DOWN_BIG;
+ }
+ eTblChgMode = nsTblChgWidthHeightType::WH_FLAG_INSDEL |
+ ( bMod1
+ ? nsTblChgWidthHeightType::WH_CELL_BOTTOM
+ : nsTblChgWidthHeightType::WH_ROW_BOTTOM );
+ nTblChgSize = pModOpt->GetTblHInsert();
+ }
+ goto KEYINPUT_CHECKTABLE_INSDEL;
+
+KEYINPUT_CHECKTABLE_INSDEL:
+ if( rSh.IsTableMode() || !rSh.GetTableFmt() ||
+ !bTblInsDelMode ||
+ FALSE /* Tabelle geschuetzt */
+ )
+ {
+ const int nSelectionType = rSh.GetSelectionType();
+
+ eKeyState = KS_KeyToView;
+ if(KS_KeyToView != eFlyState)
+ {
+ if((nSelectionType & (nsSelectionType::SEL_DRW|nsSelectionType::SEL_DRW_FORM)) &&
+ rSh.GetDrawView()->AreObjectsMarked())
+ eKeyState = KS_Draw_Change;
+ else if(nSelectionType & (nsSelectionType::SEL_FRM|nsSelectionType::SEL_OLE|nsSelectionType::SEL_GRF))
+ eKeyState = KS_Fly_Change;
+ }
+ }
+ else
+ {
+ if( !bTblIsInsMode )
+ eTblChgMode = eTblChgMode | nsTblChgWidthHeightType::WH_FLAG_BIGGER;
+ eKeyState = KS_TblColCellInsDel;
+ }
+ break;
+
+ case KEY_DELETE:
+ if (rSh.IsInFrontOfLabel() &&
+ rSh.NumOrNoNum(FALSE))
+ eKeyState = KS_NumOrNoNum;
+ break;
+
+ case KEY_DELETE | KEY_MOD2:
+ if( !rSh.IsTableMode() && rSh.GetTableFmt() )
+ {
+ eKeyState = KS_Ende;
+ bTblInsDelMode = TRUE;
+ bTblIsInsMode = FALSE;
+ bTblIsColMode = TRUE;
+ aKeyInputTimer.Start();
+ bStopKeyInputTimer = FALSE;
+ }
+ break;
+ case KEY_INSERT | KEY_MOD2:
+ if( !rSh.IsTableMode() && rSh.GetTableFmt() )
+ {
+ eKeyState = KS_Ende;
+ bTblInsDelMode = TRUE;
+ bTblIsInsMode = TRUE;
+ bTblIsColMode = TRUE;
+ aKeyInputTimer.Start();
+ bStopKeyInputTimer = FALSE;
+ }
+ break;
+
+ case KEY_RETURN: // Return
+ if( !rSh.HasReadonlySel() )
+ {
+ const int nSelectionType = rSh.GetSelectionType();
+ if(nSelectionType & nsSelectionType::SEL_OLE)
+ eKeyState = KS_LaunchOLEObject;
+ else if(nSelectionType & nsSelectionType::SEL_FRM)
+ eKeyState = KS_GoIntoFly;
+ else if((nSelectionType & nsSelectionType::SEL_DRW) &&
+ 0 == (nSelectionType & nsSelectionType::SEL_DRW_TXT) &&
+ rSh.GetDrawView()->GetMarkedObjectList().GetMarkCount() == 1)
+ eKeyState = KS_GoIntoDrawing;
+ else if( aTmpQHD.HasCntnt() && !rSh.HasSelection() &&
+ aTmpQHD.bIsAutoText )
+ eKeyState = KS_GlossaryExpand;
+
+ //RETURN und leerer Absatz in Numerierung -> Num. beenden
+ else if( !aInBuffer.Len() &&
+ rSh.GetCurNumRule() &&
+ !rSh.GetCurNumRule()->IsOutlineRule() &&
+ !rSh.HasSelection() &&
+ rSh.IsSttPara() && rSh.IsEndPara() )
+ eKeyState = KS_NumOff, eNextKeyState = KS_OutlineLvOff;
+
+ //RETURN fuer neuen Absatz mit AutoFormatierung
+ else if( pACfg && pACfg->IsAutoFmtByInput() &&
+ !(nSelectionType & (nsSelectionType::SEL_GRF |
+ nsSelectionType::SEL_OLE | nsSelectionType::SEL_FRM |
+ nsSelectionType::SEL_TBL_CELLS | nsSelectionType::SEL_DRW |
+ nsSelectionType::SEL_DRW_TXT)) )
+ eKeyState = KS_CheckAutoCorrect, eNextKeyState = KS_AutoFmtByInput;
+ else
+ eNextKeyState = eKeyState, eKeyState = KS_CheckAutoCorrect;
+ }
+ break;
+
+ case KEY_RETURN | KEY_MOD2: // ALT-Return
+ if( !rSh.HasReadonlySel() && !rSh.IsSttPara() && rSh.GetCurNumRule() )
+ eKeyState = KS_NoNum;
+ else if( rSh.CanSpecialInsert() )
+ eKeyState = KS_SpecialInsert;
+ break;
+
+ case KEY_BACKSPACE:
+ case KEY_BACKSPACE | KEY_SHIFT:
+ if( !rSh.HasReadonlySel() )
+ {
+ // #i23725#
+ BOOL bDone = FALSE;
+ // --> OD 2006-01-31 - try to add comment for code snip:
+ // Remove the paragraph indent, if the cursor is at the
+ // beginning of a paragraph, there is no selection
+ // and no numbering rule found at the current paragraph
+ // --> OD 2006-01-31 #b6341339#, #i58776#
+ // Also try to remove indent, if current paragraph
+ // has numbering rule, but isn't counted and only
+ // key <backspace> is hit.
+ const bool bOnlyBackspaceKey(
+ KEY_BACKSPACE == rKeyCode.GetFullCode() );
+ if ( rSh.IsSttPara() &&
+ !rSh.HasSelection() && // i40834
+ ( NULL == rSh.GetCurNumRule() ||
+ ( rSh.IsNoNum() && bOnlyBackspaceKey ) ) )
+ {
+ bDone = rSh.TryRemoveIndent();
+ }
+ // <--
+
+ // -> #i23725#
+ if (bDone)
+ eKeyState = KS_Ende;
+ else
+ {
+ if (rSh.IsSttPara() &&
+ ! rSh.IsNoNum())
+ {
+ if (nKS_NUMDOWN_Count > 0 &&
+ 0 < rSh.GetNumLevel())
+ {
+ eKeyState = KS_NumUp;
+ nKS_NUMDOWN_Count = 2;
+ bDone = TRUE;
+ }
+ else if (nKS_NUMINDENTINC_Count > 0)
+ {
+ eKeyState = KS_NumIndentDec;
+ nKS_NUMINDENTINC_Count = 2;
+ bDone = TRUE;
+ }
+ }
+ // <- #i23725#
+ // --> OD 2006-01-31 #b6341339#, #i58776#
+ // --> OD 2006-04-21 #i63540#
+ // revise fix for issues b6341339 and i58776:
+ // If the cursor is in an empty paragraph, which has
+ // a numbering, but not the oultine numbering, and
+ // there is no selection, the numbering has to be
+ // deleted on key <Backspace>.
+ // Otherwise method <SwEditShell::NumOrNoNum(..)>
+ // should only change the <IsCounted()> state of
+ // the current paragraph depending of the key.
+ // On <backspace> it is set to <false>,
+ // on <shift-backspace> it is set to <true>.
+ // Thus, assure that method <SwEditShell::NumOrNum(..)>
+ // is only called for the intended purpose.
+ bool bCallNumOrNoNum( false );
+ {
+ if ( !bDone )
+ {
+ if ( bOnlyBackspaceKey && !rSh.IsNoNum() )
+ {
+ bCallNumOrNoNum = true;
+ }
+ else if ( !bOnlyBackspaceKey && rSh.IsNoNum() )
+ {
+ bCallNumOrNoNum = true;
+ }
+ else if ( bOnlyBackspaceKey &&
+ rSh.IsSttPara() && rSh.IsEndPara() &&
+ !rSh.HasSelection() )
+ {
+ const SwNumRule* pCurrNumRule( rSh.GetCurNumRule() );
+ if ( pCurrNumRule &&
+ pCurrNumRule != rSh.GetOutlineNumRule() )
+ {
+ bCallNumOrNoNum = true;
+ }
+ }
+ }
+ }
+ if ( bCallNumOrNoNum &&
+ rSh.NumOrNoNum( !bOnlyBackspaceKey, TRUE ) )
+ {
+ eKeyState = KS_NumOrNoNum;
+ }
+ // <--
+ }
+ }
+ break;
+
+ case KEY_RIGHT:
+ {
+ eFlyState = KS_Fly_Change;
+ nDir = MOVE_RIGHT_BIG;
+ eTblChgMode = nsTblChgWidthHeightType::WH_FLAG_INSDEL | nsTblChgWidthHeightType::WH_COL_RIGHT;
+ nTblChgSize = pModOpt->GetTblVInsert();
+ goto KEYINPUT_CHECKTABLE_INSDEL;
+ }
+ case KEY_TAB:
+ {
+
+#ifdef SW_CRSR_TIMER
+ BOOL bOld = rSh.ChgCrsrTimerFlag( FALSE );
+#endif
+ if (rSh.IsFormProtected() || rSh.GetCurrentFieldmark() || rSh.GetChar(FALSE)==CH_TXT_ATR_FORMELEMENT)
+ {
+ eKeyState=KS_GotoNextFieldMark;
+ }
+ else
+ if( rSh.GetCurNumRule() && rSh.IsSttOfPara() &&
+ !rSh.HasReadonlySel() )
+ {
+ // --> OD 2007-10-02 #b660435#
+// if (rSh.IsFirstOfNumRule()) // #i23725#
+ if ( rSh.IsFirstOfNumRule() &&
+ numfunc::ChangeIndentOnTabAtFirstPosOfFirstListItem() )
+ // <--
+ eKeyState = KS_NumIndentInc;
+ else
+ eKeyState = KS_NumDown;
+ }
+ else if ( rSh.GetTableFmt() )
+ {
+ if( rSh.HasSelection() || rSh.HasReadonlySel() )
+ eKeyState = KS_NextCell;
+ else
+ eKeyState = KS_CheckAutoCorrect, eNextKeyState = KS_NextCell;
+ }
+ else if ( rSh.GetSelectionType() &
+ (nsSelectionType::SEL_GRF |
+ nsSelectionType::SEL_FRM |
+ nsSelectionType::SEL_OLE |
+ nsSelectionType::SEL_DRW |
+ nsSelectionType::SEL_DRW_FORM))
+
+ eKeyState = KS_NextObject;
+ else
+ {
+ eKeyState = KS_InsTab;
+ if( rSh.IsSttOfPara() && !rSh.HasReadonlySel() )
+ {
+ SwTxtFmtColl* pColl = rSh.GetCurTxtFmtColl();
+ if( pColl &&
+ //0 <= pColl->GetOutlineLevel() && #i24560#
+ //MAXLEVEL - 1 > pColl->GetOutlineLevel() )//#outline level,zhaojianwei
+ pColl->IsAssignedToListLevelOfOutlineStyle()
+ && MAXLEVEL-1 > pColl->GetAssignedOutlineStyleLevel() )//<-end,zhaojianwei
+ eKeyState = KS_OutlineDown;
+ }
+ }
+#ifdef SW_CRSR_TIMER
+ rSh.ChgCrsrTimerFlag( bOld );
+#endif
+ }
+ break;
+ case KEY_TAB | KEY_SHIFT:
+ {
+#ifdef SW_CRSR_TIMER
+ BOOL bOld = rSh.ChgCrsrTimerFlag( FALSE );
+#endif
+ if (rSh.IsFormProtected() || rSh.GetCurrentFieldmark()|| rSh.GetChar(FALSE)==CH_TXT_ATR_FORMELEMENT) {
+ eKeyState=KS_GotoPrevFieldMark;
+ }
+ else if( rSh.GetCurNumRule() && rSh.IsSttOfPara() &&
+ !rSh.HasReadonlySel() )
+ {
+ // --> OD 2007-10-02 #b660435#
+// if (rSh.IsFirstOfNumRule()) // #i23725#
+ if ( rSh.IsFirstOfNumRule() &&
+ numfunc::ChangeIndentOnTabAtFirstPosOfFirstListItem() )
+ // <--
+ eKeyState = KS_NumIndentDec;
+ else
+ eKeyState = KS_NumUp;
+ }
+ else if ( rSh.GetTableFmt() )
+ {
+ if( rSh.HasSelection() || rSh.HasReadonlySel() )
+ eKeyState = KS_PrevCell;
+ else
+ eKeyState = KS_CheckAutoCorrect, eNextKeyState = KS_PrevCell;
+ }
+ else if ( rSh.GetSelectionType() &
+ (nsSelectionType::SEL_GRF |
+ nsSelectionType::SEL_FRM |
+ nsSelectionType::SEL_OLE |
+ nsSelectionType::SEL_DRW |
+ nsSelectionType::SEL_DRW_FORM))
+
+ eKeyState = KS_PrevObject;
+ else
+ {
+ eKeyState = KS_Ende;
+ if( rSh.IsSttOfPara() && !rSh.HasReadonlySel() )
+ {
+ SwTxtFmtColl* pColl = rSh.GetCurTxtFmtColl();
+ //if( pColl && 0 < pColl->GetOutlineLevel() && //#outline level,zhaojianwei
+ // MAXLEVEL - 1 >= pColl->GetOutlineLevel() )
+ if( pColl &&
+ pColl->IsAssignedToListLevelOfOutlineStyle() &&
+ 0 < pColl->GetAssignedOutlineStyleLevel())
+ eKeyState = KS_OutlineUp;
+ }
+ }
+#ifdef SW_CRSR_TIMER
+ rSh.ChgCrsrTimerFlag( bOld );
+#endif
+ }
+ break;
+ case KEY_TAB | KEY_MOD1:
+ case KEY_TAB | KEY_MOD2:
+ if( !rSh.HasReadonlySel() )
+ {
+ if( aTmpQHD.HasCntnt() && !rSh.HasSelection() )
+ {
+ // zum naechsten Tip
+ aTmpQHD.Inc( pACorr && pACorr->GetSwFlags().
+ bAutoCmpltEndless );
+ eKeyState = KS_NextPrevGlossary;
+ }
+ else if( rSh.GetTableFmt() )
+ eKeyState = KS_InsTab;
+ else if((rSh.GetSelectionType() &
+ (nsSelectionType::SEL_DRW|nsSelectionType::SEL_DRW_FORM|
+ nsSelectionType::SEL_FRM|nsSelectionType::SEL_OLE|nsSelectionType::SEL_GRF)) &&
+ rSh.GetDrawView()->AreObjectsMarked())
+ eKeyState = KS_EnterDrawHandleMode;
+ else
+ {
+ eKeyState = KS_InsTab;
+ }
+ }
+ break;
+
+ case KEY_TAB | KEY_MOD1 | KEY_SHIFT:
+ if( aTmpQHD.HasCntnt() && !rSh.HasSelection() &&
+ !rSh.HasReadonlySel() )
+ {
+ // zum vorherigen Tip
+ aTmpQHD.Dec( pACorr && pACorr->GetSwFlags().
+ bAutoCmpltEndless );
+ eKeyState = KS_NextPrevGlossary;
+ }
+ else if((rSh.GetSelectionType() & (nsSelectionType::SEL_DRW|nsSelectionType::SEL_DRW_FORM|
+ nsSelectionType::SEL_FRM|nsSelectionType::SEL_OLE|nsSelectionType::SEL_GRF)) &&
+ rSh.GetDrawView()->AreObjectsMarked())
+ eKeyState = KS_EnterDrawHandleMode;
+ break;
+ case KEY_F2 :
+ if( !rSh.HasReadonlySel() )
+ {
+ const int nSelectionType = rSh.GetSelectionType();
+ if(nSelectionType & nsSelectionType::SEL_FRM)
+ eKeyState = KS_GoIntoFly;
+ else if((nSelectionType & nsSelectionType::SEL_DRW))
+ eKeyState = KS_GoIntoDrawing;
+ }
+ break;
+ }
+ }
+ break;
+ case KS_CheckDocReadOnlyKeys:
+ {
+ eKeyState = KS_KeyToView;
+ switch( rKeyCode.GetModifier() | rKeyCode.GetCode() )
+ {
+ case KEY_TAB:
+ case KEY_TAB | KEY_SHIFT:
+ bNormalChar = FALSE;
+ eKeyState = KS_Ende;
+ if ( rSh.GetSelectionType() &
+ (nsSelectionType::SEL_GRF |
+ nsSelectionType::SEL_FRM |
+ nsSelectionType::SEL_OLE |
+ nsSelectionType::SEL_DRW |
+ nsSelectionType::SEL_DRW_FORM))
+
+ {
+ eKeyState = rKeyCode.GetModifier() & KEY_SHIFT ?
+ KS_PrevObject : KS_NextObject;
+ }
+ else
+ rSh.SelectNextPrevHyperlink(
+ KEY_SHIFT != rKeyCode.GetModifier() );
+ break;
+ case KEY_RETURN:
+ {
+ const int nSelectionType = rSh.GetSelectionType();
+ if(nSelectionType & nsSelectionType::SEL_FRM)
+ eKeyState = KS_GoIntoFly;
+ else
+ {
+ SfxItemSet aSet(rSh.GetAttrPool(), RES_TXTATR_INETFMT, RES_TXTATR_INETFMT);
+ rSh.GetCurAttr(aSet);
+ if(SFX_ITEM_SET == aSet.GetItemState(RES_TXTATR_INETFMT, FALSE))
+ {
+ const SfxPoolItem& rItem = aSet.Get(RES_TXTATR_INETFMT, TRUE);
+ bNormalChar = FALSE;
+ eKeyState = KS_Ende;
+ rSh.ClickToINetAttr((const SwFmtINetFmt&)rItem, URLLOAD_NOFILTER);
+ }
+ }
+ }
+ break;
+ }
+ }
+ break;
+
+ case KS_EnterCharCell:
+ {
+ eKeyState = KS_KeyToView;
+ switch ( rKeyCode.GetModifier() | rKeyCode.GetCode() )
+ {
+ case KEY_RIGHT | KEY_MOD2:
+ rSh.Right( CRSR_SKIP_CHARS, FALSE, 1, FALSE );
+ eKeyState = KS_Ende;
+ FlushInBuffer();
+ break;
+ case KEY_LEFT | KEY_MOD2:
+ rSh.Left( CRSR_SKIP_CHARS, FALSE, 1, FALSE );
+ eKeyState = KS_Ende;
+ FlushInBuffer();
+ break;
+ }
+ }
+ break;
+
+ case KS_KeyToView:
+ {
+ eKeyState = KS_Ende;
+ bNormalChar =
+ !rKeyCode.IsMod2() &&
+ rKeyCode.GetModifier() != (KEY_MOD1) &&
+ rKeyCode.GetModifier() != (KEY_MOD1|KEY_SHIFT) &&
+ SW_ISPRINTABLE( aCh );
+
+ if (bNormalChar && rSh.IsInFrontOfLabel())
+ {
+ rSh.NumOrNoNum(FALSE);
+ }
+
+ if( aInBuffer.Len() && ( !bNormalChar || bIsDocReadOnly ))
+ FlushInBuffer();
+
+ if( rView.KeyInput( aKeyEvent ) )
+ bFlushBuffer = TRUE, bNormalChar = FALSE;
+ else
+ {
+// OS 22.09.95: Da der Sfx Acceleratoren nur aufruft, wenn sie beim letzten
+// Statusupdate enabled wurden, muss copy ggf. von uns
+// 'gewaltsam' gerufen werden.
+ if( rKeyCode.GetFunction() == KEYFUNC_COPY )
+ GetView().GetViewFrame()->GetBindings().Execute(SID_COPY);
+
+
+ if( !bIsDocReadOnly && bNormalChar )
+ {
+ const int nSelectionType = rSh.GetSelectionType();
+ if((nSelectionType & nsSelectionType::SEL_DRW) &&
+ 0 == (nSelectionType & nsSelectionType::SEL_DRW_TXT) &&
+ rSh.GetDrawView()->GetMarkedObjectList().GetMarkCount() == 1)
+ {
+ SdrObject* pObj = rSh.GetDrawView()->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
+ if(pObj)
+ {
+ EnterDrawTextMode(pObj->GetLogicRect().Center());
+ if ( rView.GetCurShell()->ISA(SwDrawTextShell) )
+ ((SwDrawTextShell*)rView.GetCurShell())->Init();
+ rSh.GetDrawView()->KeyInput( rKEvt, this );
+ }
+ }
+ else if(nSelectionType & nsSelectionType::SEL_FRM)
+ {
+ rSh.UnSelectFrm();
+ rSh.LeaveSelFrmMode();
+ rView.AttrChangedNotify(&rSh);
+ rSh.MoveSection( fnSectionCurr, fnSectionEnd );
+ }
+ eKeyState = KS_InsChar;
+ }
+ else
+ {
+ bNormalChar = FALSE;
+ Window::KeyInput( aKeyEvent );
+ }
+ }
+ }
+ break;
+ case KS_LaunchOLEObject:
+ rSh.LaunchOLEObj();
+ eKeyState = KS_Ende;
+ break;
+ case KS_GoIntoFly :
+ rSh.UnSelectFrm();
+ rSh.LeaveSelFrmMode();
+ rView.AttrChangedNotify(&rSh);
+ rSh.MoveSection( fnSectionCurr, fnSectionEnd );
+ eKeyState = KS_Ende;
+ break;
+ case KS_GoIntoDrawing :
+ {
+ SdrObject* pObj = rSh.GetDrawView()->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
+ if(pObj)
+ {
+ EnterDrawTextMode(pObj->GetLogicRect().Center());
+ if ( rView.GetCurShell()->ISA(SwDrawTextShell) )
+ ((SwDrawTextShell*)rView.GetCurShell())->Init();
+ }
+ eKeyState = KS_Ende;
+ }
+ break;
+ case KS_EnterDrawHandleMode:
+ {
+ const SdrHdlList& rHdlList = rSh.GetDrawView()->GetHdlList();
+ sal_Bool bForward(!aKeyEvent.GetKeyCode().IsShift());
+
+ ((SdrHdlList&)rHdlList).TravelFocusHdl(bForward);
+ eKeyState = KS_Ende;
+ }
+ break;
+ case KS_InsTab:
+ if( rView.ISA( SwWebView )) //Kein Tabulator fuer Web!
+ {
+ // Bug 56196 - dann sollte der weiter gereicht werden.
+ Window::KeyInput( aKeyEvent );
+ eKeyState = KS_Ende;
+ break;
+ }
+ aCh = '\t';
+ // kein break!
+ case KS_InsChar:
+ if (rSh.GetChar(FALSE)==CH_TXT_ATR_FORMELEMENT)
+ {
+ ::sw::mark::ICheckboxFieldmark* pFieldmark =
+ dynamic_cast< ::sw::mark::ICheckboxFieldmark* >
+ (rSh.GetCurrentFieldmark());
+ OSL_ENSURE(pFieldmark,
+ "Where is my FieldMark??");
+ if(pFieldmark)
+ {
+ pFieldmark->SetChecked(!pFieldmark->IsChecked());
+ SwDocShell* pDocSh = rView.GetDocShell();
+ SwDoc *pDoc=pDocSh->GetDoc();
+ OSL_ENSURE(pFieldmark->IsExpanded(),
+ "where is the otherpos?");
+ if (pFieldmark->IsExpanded())
+ {
+ SwPaM aPaM(pFieldmark->GetMarkPos(), pFieldmark->GetOtherMarkPos());
+ if(0)
+ {
+ rSh.StartAllAction(); //$flr TODO: understand why this not works
+ pDoc->SetModified(aPaM);
+ rSh.EndAllAction();
+ }
+ else
+ {
+ rSh.CalcLayout(); // workaround
+ }
+ }
+ }
+ eKeyState = KS_Ende;
+ }
+ else if(!rSh.HasReadonlySel())
+ {
+ BOOL bIsNormalChar = GetAppCharClass().isLetterNumeric(
+ String( aCh ), 0 );
+ if( bChkInsBlank && bIsNormalChar &&
+ (aInBuffer.Len() || !rSh.IsSttPara() || !rSh.IsEndPara() ))
+ {
+ // vor dem Zeichen noch ein Blank einfuegen. Dieses
+ // kommt zwischen den Expandierten Text und dem neuen
+ // "nicht Worttrenner".
+ aInBuffer.Expand( aInBuffer.Len() + 1, ' ' );
+ }
+
+
+ BOOL bIsAutoCorrectChar = SvxAutoCorrect::IsAutoCorrectChar( aCh );
+ BOOL bRunNext = pACorr->HasRunNext();
+ if( !aKeyEvent.GetRepeat() && pACorr && ( bIsAutoCorrectChar || bRunNext ) &&
+ pACfg->IsAutoFmtByInput() &&
+ (( pACorr->IsAutoCorrFlag( ChgWeightUnderl ) &&
+ ( '*' == aCh || '_' == aCh ) ) ||
+ ( pACorr->IsAutoCorrFlag( ChgQuotes ) && ('\"' == aCh ))||
+ ( pACorr->IsAutoCorrFlag( ChgSglQuotes ) && ( '\'' == aCh))))
+ {
+ FlushInBuffer();
+ rSh.AutoCorrect( *pACorr, aCh );
+ if( '\"' != aCh && '\'' != aCh ) // nur bei "*_" rufen!
+ rSh.UpdateAttr();
+ }
+ else if( !aKeyEvent.GetRepeat() && pACorr && ( bIsAutoCorrectChar || bRunNext ) &&
+ pACfg->IsAutoFmtByInput() &&
+ pACorr->IsAutoCorrFlag( CptlSttSntnc | CptlSttWrd |
+ ChgOrdinalNumber | AddNonBrkSpace |
+ ChgToEnEmDash | SetINetAttr |
+ Autocorrect ) &&
+ '\"' != aCh && '\'' != aCh && '*' != aCh && '_' != aCh
+ )
+ {
+ FlushInBuffer();
+ rSh.AutoCorrect( *pACorr, aCh );
+ }
+ else
+ {
+ aInBuffer.Expand( aInBuffer.Len() + aKeyEvent.GetRepeat() + 1,aCh );
+ bFlushCharBuffer = Application::AnyInput( INPUT_KEYBOARD );
+ bFlushBuffer = !bFlushCharBuffer;
+ if( bFlushCharBuffer )
+ aKeyInputFlushTimer.Start();
+ }
+ eKeyState = KS_Ende;
+ }
+ else
+ {
+ InfoBox( this, SW_RES( MSG_READONLY_CONTENT )).Execute();
+ // ??? Window::KeyInput( aKeyEvent );
+ eKeyState = KS_Ende;
+ }
+ break;
+
+ case KS_CheckAutoCorrect:
+ {
+ if( pACorr && pACfg->IsAutoFmtByInput() &&
+ pACorr->IsAutoCorrFlag( CptlSttSntnc | CptlSttWrd |
+ ChgOrdinalNumber |
+ ChgToEnEmDash | SetINetAttr |
+ Autocorrect ) &&
+ !rSh.HasReadonlySel() )
+ /* {
+ pACorr->IsAutoCorrFlag( CptlSttSntnc | CptlSttWrd |
+ ChgFractionSymbol | ChgOrdinalNumber |
+ ChgToEnEmDash | SetINetAttr |
+ Autocorrect ) &&
+ !rSh.HasReadonlySel() ) */
+ {
+ FlushInBuffer();
+ rSh.AutoCorrect( *pACorr, static_cast< sal_Unicode >('\0') );
+ }
+ eKeyState = eNextKeyState;
+ }
+ break;
+
+ default:
+ {
+ USHORT nSlotId = 0;
+ FlushInBuffer();
+//??? if( bFlushCharBuffer )
+//??? FlushInBuffer( &rSh );
+ switch( eKeyState )
+ {
+ case KS_SpecialInsert:
+ rSh.DoSpecialInsert();
+ break;
+
+ case KS_NoNum:
+ rSh.NoNum();
+ break;
+
+ case KS_NumOff:
+ // Shellwechsel - also vorher aufzeichnen
+ rSh.DelNumRules();
+ eKeyState = eNextKeyState;
+ break;
+ case KS_OutlineLvOff: // delete autofmt outlinelevel later
+ break;
+
+ case KS_NumDown:
+ rSh.NumUpDown( TRUE );
+ nKS_NUMDOWN_Count = 2; // #i23725#
+ break;
+ case KS_NumUp:
+ rSh.NumUpDown( FALSE );
+ break;
+
+ // -> #i23726#
+ case KS_NumIndentInc:
+ // --> OD 2008-06-16 #i90078#
+ rSh.ChangeIndentOfAllListLevels(360);
+ // <--
+ nKS_NUMINDENTINC_Count = 2;
+ break;
+
+ case KS_GotoNextFieldMark:
+ {
+ ::sw::mark::IFieldmark const * const pFieldmark = rSh.GetFieldmarkAfter();
+ if(pFieldmark) rSh.GotoFieldmark(pFieldmark);
+ }
+ break;
+
+ case KS_GotoPrevFieldMark:
+ {
+ ::sw::mark::IFieldmark const * const pFieldmark = rSh.GetFieldmarkBefore();
+ if(pFieldmark) rSh.GotoFieldmark(pFieldmark);
+ }
+ break;
+
+ case KS_NumIndentDec:
+ // --> OD 2008-06-16 #i90078#
+ rSh.ChangeIndentOfAllListLevels(-360);
+ // <--
+ break;
+ // <- #i23726#
+
+ case KS_OutlineDown:
+ rSh.OutlineUpDown( 1 );
+ break;
+ case KS_OutlineUp:
+ rSh.OutlineUpDown( -1 );
+ break;
+
+ case KS_NextCell:
+ //In Tabelle immer 'flushen'
+ rSh.GoNextCell();
+ nSlotId = FN_GOTO_NEXT_CELL;
+ break;
+ case KS_PrevCell:
+ rSh.GoPrevCell();
+ nSlotId = FN_GOTO_PREV_CELL;
+ break;
+ case KS_AutoFmtByInput:
+ rSh.SplitNode( TRUE );
+ break;
+
+// case KS_NumOrNoNum:
+// break;
+ case KS_NextObject:
+ case KS_PrevObject:
+ if(rSh.GotoObj( KS_NextObject == eKeyState, GOTOOBJ_GOTO_ANY))
+ {
+ if( rSh.IsFrmSelected() &&
+ rView.GetDrawFuncPtr() )
+ {
+ rView.GetDrawFuncPtr()->Deactivate();
+ rView.SetDrawFuncPtr(NULL);
+ rView.LeaveDrawCreate();
+ rView.AttrChangedNotify( &rSh );
+ }
+ rSh.HideCrsr();
+ rSh.EnterSelFrmMode();
+ }
+ break;
+ case KS_GlossaryExpand:
+ {
+ // ersetze das Wort oder Kuerzel durch den den Textbaustein
+ rSh.StartUndo( UNDO_START );
+
+ String sFnd( *aTmpQHD.aArr[ aTmpQHD.nCurArrPos ] );
+ if( aTmpQHD.bIsAutoText )
+ {
+ SwGlossaryList* pList = ::GetGlossaryList();
+ String sShrtNm;
+ String sGroup;
+ if(pList->GetShortName( sFnd, sShrtNm, sGroup))
+ {
+ rSh.SttSelect();
+ rSh.ExtendSelection( FALSE, aTmpQHD.nLen );
+ SwGlossaryHdl* pGlosHdl = GetView().GetGlosHdl();
+ pGlosHdl->SetCurGroup(sGroup, TRUE);
+ pGlosHdl->InsertGlossary( sShrtNm);
+ pQuickHlpData->bChkInsBlank = TRUE;
+ }
+ }
+ else
+ {
+ rSh.Insert( sFnd.Erase( 0, aTmpQHD.nLen ));
+ pQuickHlpData->bChkInsBlank = !pACorr ||
+ pACorr->GetSwFlags().bAutoCmpltAppendBlanc;
+ }
+ rSh.EndUndo( UNDO_END );
+ }
+ break;
+
+ case KS_NextPrevGlossary:
+ pQuickHlpData->Move( aTmpQHD );
+ pQuickHlpData->Start( rSh, USHRT_MAX );
+ break;
+
+ case KS_EditFormula:
+ {
+ const USHORT nId = SwInputChild::GetChildWindowId();
+
+ SfxViewFrame* pVFrame = GetView().GetViewFrame();
+ pVFrame->ToggleChildWindow( nId );
+ SwInputChild* pChildWin = (SwInputChild*)pVFrame->
+ GetChildWindow( nId );
+ if( pChildWin )
+ pChildWin->SetFormula( sFmlEntry );
+ }
+ break;
+
+ case KS_ColLeftBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_COL_LEFT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHMove() ); break;
+ case KS_ColRightBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_COL_RIGHT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHMove() ); break;
+ case KS_ColLeftSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_COL_LEFT, pModOpt->GetTblHMove() ); break;
+ case KS_ColRightSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_COL_RIGHT, pModOpt->GetTblHMove() ); break;
+// case KS_ColTopBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_ROW_TOP|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVMove() ); break;
+ case KS_ColBottomBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_ROW_BOTTOM|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVMove() ); break;
+// case KS_ColTopSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_ROW_TOP, pModOpt->GetTblVMove() ); break;
+ case KS_ColBottomSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_ROW_BOTTOM, pModOpt->GetTblVMove() ); break;
+ case KS_CellLeftBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_LEFT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHMove() ); break;
+ case KS_CellRightBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_RIGHT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHMove() ); break;
+ case KS_CellLeftSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_LEFT, pModOpt->GetTblHMove() ); break;
+ case KS_CellRightSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_RIGHT, pModOpt->GetTblHMove() ); break;
+ case KS_CellTopBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_TOP|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVMove() ); break;
+ case KS_CellBottomBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_BOTTOM|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVMove() ); break;
+ case KS_CellTopSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_TOP, pModOpt->GetTblVMove() ); break;
+ case KS_CellBottomSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_BOTTOM, pModOpt->GetTblVMove() ); break;
+
+//---------------
+ case KS_InsDel_ColLeftBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_COL_LEFT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHInsert() ); break;
+ case KS_InsDel_ColRightBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_COL_RIGHT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHInsert() ); break;
+ case KS_InsDel_ColLeftSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_COL_LEFT, pModOpt->GetTblHInsert() ); break;
+ case KS_InsDel_ColRightSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_COL_RIGHT, pModOpt->GetTblHInsert() ); break;
+ case KS_InsDel_ColTopBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_ROW_TOP|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVInsert() ); break;
+ case KS_InsDel_ColBottomBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_ROW_BOTTOM|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVInsert() ); break;
+ case KS_InsDel_ColTopSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_ROW_TOP, pModOpt->GetTblVInsert() ); break;
+ case KS_InsDel_ColBottomSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_ROW_BOTTOM, pModOpt->GetTblVInsert() ); break;
+ case KS_InsDel_CellLeftBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_LEFT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHInsert() ); break;
+ case KS_InsDel_CellRightBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_RIGHT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHInsert() ); break;
+ case KS_InsDel_CellLeftSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_LEFT, pModOpt->GetTblHInsert() ); break;
+ case KS_InsDel_CellRightSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_RIGHT, pModOpt->GetTblHInsert() ); break;
+ case KS_InsDel_CellTopBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_TOP|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVInsert() ); break;
+ case KS_InsDel_CellBottomBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_BOTTOM|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVInsert() ); break;
+ case KS_InsDel_CellTopSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_TOP, pModOpt->GetTblVInsert() ); break;
+ case KS_InsDel_CellBottomSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_BOTTOM, pModOpt->GetTblVInsert() ); break;
+//---------------
+ case KS_TblColCellInsDel:
+ rSh.SetColRowWidthHeight( eTblChgMode, nTblChgSize );
+ break;
+ case KS_Fly_Change:
+ {
+ SdrView *pSdrView = rSh.GetDrawView();
+ const SdrHdlList& rHdlList = pSdrView->GetHdlList();
+ if(rHdlList.GetFocusHdl())
+ ChangeDrawing( nDir );
+ else
+ ChangeFly( nDir, rView.ISA( SwWebView ) );
+ }
+ break;
+ case KS_Draw_Change :
+ ChangeDrawing( nDir );
+ break;
+ default:; //prevent warning
+ }
+ if( nSlotId && rView.GetViewFrame()->GetBindings().GetRecorder().is() )
+ {
+ SfxRequest aReq(rView.GetViewFrame(), nSlotId );
+ aReq.Done();
+ }
+ eKeyState = KS_Ende;
+ }
+ }
+ }
+
+ if( bStopKeyInputTimer )
+ {
+ aKeyInputTimer.Stop();
+ bTblInsDelMode = FALSE;
+ }
+
+ // falls die gepufferten Zeichen eingefuegt werden sollen
+ if( bFlushBuffer && aInBuffer.Len() )
+ {
+ //OS 16.02.96 11.04: bFlushCharBuffer wurde hier nicht zurueckgesetzt
+ // warum nicht?
+ BOOL bSave = bFlushCharBuffer;
+ FlushInBuffer();
+ bFlushCharBuffer = bSave;
+
+ // evt. Tip-Hilfe anzeigen
+ String sWord;
+ if( bNormalChar && pACfg && pACorr &&
+ ( pACfg->IsAutoTextTip() ||
+ pACorr->GetSwFlags().bAutoCompleteWords ) &&
+ rSh.GetPrevAutoCorrWord( *pACorr, sWord ) )
+ {
+ ShowAutoTextCorrectQuickHelp(sWord, pACfg, pACorr);
+ }
+ }
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: MouseEvents
+ --------------------------------------------------------------------*/
+
+
+void SwEditWin::RstMBDownFlags()
+{
+ //Nicht auf allen Systemen kommt vor dem modalen
+ //Dialog noch ein MouseButton Up (wie unter WINDOWS).
+ //Daher hier die Stati zuruecksetzen und die Maus
+ //fuer den Dialog freigeben.
+ bMBPressed = bNoInterrupt = FALSE;
+ EnterArea();
+ ReleaseMouse();
+}
+
+
+
+void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
+{
+ SwWrtShell &rSh = rView.GetWrtShell();
+
+ // We have to check if a context menu is shown and we have an UI
+ // active inplace client. In that case we have to ignore the mouse
+ // button down event. Otherwise we would crash (context menu has been
+ // opened by inplace client and we would deactivate the inplace client,
+ // the contex menu is closed by VCL asynchronously which in the end
+ // would work on deleted objects or the context menu has no parent anymore)
+ // See #126086# and #128122#
+ SfxInPlaceClient* pIPClient = rSh.GetSfxViewShell()->GetIPClient();
+ BOOL bIsOleActive = ( pIPClient && pIPClient->IsObjectInPlaceActive() );
+
+ if ( bIsOleActive && PopupMenu::IsInExecute() )
+ return;
+
+ MouseEvent rMEvt(_rMEvt);
+
+ if (rView.GetPostItMgr()->IsHit(rMEvt.GetPosPixel()))
+ return;
+
+ rView.GetPostItMgr()->SetActiveSidebarWin(0);
+
+ GrabFocus();
+
+ //ignore key modifiers for format paintbrush
+ {
+ BOOL bExecFormatPaintbrush = pApplyTempl && pApplyTempl->pFormatClipboard
+ && pApplyTempl->pFormatClipboard->HasContent();
+ if( bExecFormatPaintbrush )
+ rMEvt = MouseEvent( _rMEvt.GetPosPixel(), _rMEvt.GetClicks(),
+ _rMEvt.GetMode(), _rMEvt.GetButtons() );
+ }
+
+ bWasShdwCrsr = 0 != pShadCrsr;
+ if( bWasShdwCrsr )
+ delete pShadCrsr, pShadCrsr = 0;
+
+ const Point aDocPos( PixelToLogic( rMEvt.GetPosPixel() ) );
+
+ if ( IsChainMode() )
+ {
+ SetChainMode( FALSE );
+ SwRect aDummy;
+ SwFlyFrmFmt *pFmt = (SwFlyFrmFmt*)rSh.GetFlyFrmFmt();
+ if ( !rSh.Chainable( aDummy, *pFmt, aDocPos ) )
+ rSh.Chain( *pFmt, aDocPos );
+ UpdatePointer( aDocPos, rMEvt.GetModifier() );
+ return;
+ }
+
+ //Nach GrabFocus sollte eine Shell gepusht sein. Das muss eigentlich
+ //klappen aber in der Praxis ...
+ lcl_SelectShellForDrop( rView );
+
+ BOOL bIsDocReadOnly = rView.GetDocShell()->IsReadOnly();
+ BOOL bCallBase = TRUE;
+
+ if( pQuickHlpData->bClear )
+ pQuickHlpData->Stop( rSh );
+ pQuickHlpData->bChkInsBlank = FALSE;
+
+ if( rSh.FinishOLEObj() )
+ return; //InPlace beenden und der Klick zaehlt nicht mehr
+
+ SET_CURR_SHELL( &rSh );
+
+ SdrView *pSdrView = rSh.GetDrawView();
+ if ( pSdrView )
+ {
+ if (pSdrView->MouseButtonDown( rMEvt, this ) )
+ {
+ rSh.GetView().GetViewFrame()->GetBindings().InvalidateAll(FALSE);
+ return; // Event von der SdrView ausgewertet
+ }
+ }
+
+
+ bIsInMove = FALSE;
+ aStartPos = rMEvt.GetPosPixel();
+ aRszMvHdlPt.X() = 0, aRszMvHdlPt.Y() = 0;
+
+ BYTE nMouseTabCol = 0;
+ const BOOL bTmp = !rSh.IsDrawCreate() && !pApplyTempl && !rSh.IsInSelect() &&
+ rMEvt.GetClicks() == 1 && MOUSE_LEFT == rMEvt.GetButtons();
+ if ( bTmp &&
+ 0 != (nMouseTabCol = rSh.WhichMouseTabCol( aDocPos ) ) &&
+ !rSh.IsObjSelectable( aDocPos ) )
+ {
+ // --> FME 2004-07-30 #i32329# Enhanced table selection
+ if ( SW_TABSEL_HORI <= nMouseTabCol && SW_TABCOLSEL_VERT >= nMouseTabCol )
+ {
+ rSh.EnterStdMode();
+ rSh.SelectTableRowCol( aDocPos );
+ if( SW_TABSEL_HORI != nMouseTabCol && SW_TABSEL_HORI_RTL != nMouseTabCol)
+ {
+ pRowColumnSelectionStart = new Point( aDocPos );
+ bIsRowDrag = SW_TABROWSEL_HORI == nMouseTabCol||
+ SW_TABROWSEL_HORI_RTL == nMouseTabCol ||
+ SW_TABCOLSEL_VERT == nMouseTabCol;
+ bMBPressed = TRUE;
+ CaptureMouse();
+ }
+ return;
+ }
+ // <--
+
+ if ( !rSh.IsTableMode() )
+ {
+ //Zuppeln von Tabellenspalten aus dem Dokument heraus.
+ if(SW_TABCOL_VERT == nMouseTabCol || SW_TABCOL_HORI == nMouseTabCol)
+ rView.SetTabColFromDoc( TRUE );
+ else
+ rView.SetTabRowFromDoc( TRUE );
+
+ rView.SetTabColFromDocPos( aDocPos );
+ rView.InvalidateRulerPos();
+ SfxBindings& rBind = rView.GetViewFrame()->GetBindings();
+ rBind.Update();
+ if ( RulerColumnDrag( rMEvt,
+ (SW_TABCOL_VERT == nMouseTabCol || SW_TABROW_HORI == nMouseTabCol)) )
+ {
+ rView.SetTabColFromDoc( FALSE );
+ rView.SetTabRowFromDoc( FALSE );
+ rView.InvalidateRulerPos();
+ rBind.Update();
+ bCallBase = FALSE;
+ }
+ else
+ {
+ return;
+ }
+ }
+ }
+ // #i23726#
+ else if (bTmp &&
+ rSh.IsNumLabel(aDocPos))
+ {
+ SwTxtNode* pNodeAtPos = rSh.GetNumRuleNodeAtPos( aDocPos );
+ rView.SetNumRuleNodeFromDoc( pNodeAtPos );
+ rView.InvalidateRulerPos();
+ SfxBindings& rBind = rView.GetViewFrame()->GetBindings();
+ rBind.Update();
+
+ // --> OD 2005-02-21 #i42921#
+ if ( RulerMarginDrag( rMEvt,
+ rSh.IsVerticalModeAtNdAndPos( *pNodeAtPos, aDocPos ) ) )
+ // <--
+ {
+ rView.SetNumRuleNodeFromDoc( NULL );
+ rView.InvalidateRulerPos();
+ rBind.Update();
+ bCallBase = FALSE;
+ }
+ else
+ {
+ // --> FME 2005-11-03 #125036# Make sure the pointer is set to 0,
+ // otherwise it may point to nowhere after deleting the corresponding
+ // text node.
+ rView.SetNumRuleNodeFromDoc( NULL );
+ // <--
+ return;
+ }
+ }
+
+ //Man kann sich in einem Selektionszustand befinden, wenn zuletzt
+ //mit dem Keyboard selektiert wurde, aber noch kein CURSOR_KEY
+ //anschliessend bewegt worden ist. In diesem Fall muss die vorher-
+ //gehende Selektion zuerst beendet werden.
+ //MA 07. Oct. 95: Und zwar nicht nur bei Linker Maustaste sondern immer.
+ //siehe auch Bug: 19263
+ if ( rSh.IsInSelect() )
+ rSh.EndSelect();
+
+ //Abfrage auf LEFT, da sonst auch bei einem Click mit der rechten Taste
+ //beispielsweise die Selektion aufgehoben wird.
+ if ( MOUSE_LEFT == rMEvt.GetButtons() )
+ {
+ BOOL bOnlyText = FALSE;
+ bMBPressed = bNoInterrupt = TRUE;
+ nKS_NUMDOWN_Count = 0; // #i23725#
+
+ CaptureMouse();
+
+ //ggf. Cursorpositionen zuruecksetzen
+ rSh.ResetCursorStack();
+
+ switch ( rMEvt.GetModifier() + rMEvt.GetButtons() )
+ {
+ case MOUSE_LEFT:
+ case MOUSE_LEFT + KEY_SHIFT:
+ case MOUSE_LEFT + KEY_MOD2:
+ if( rSh.IsObjSelected() )
+ {
+ SdrHdl* pHdl;
+ if( !bIsDocReadOnly &&
+ !pAnchorMarker &&
+ 0 != ( pHdl = pSdrView->PickHandle(aDocPos) ) &&
+ ( pHdl->GetKind() == HDL_ANCHOR ||
+ pHdl->GetKind() == HDL_ANCHOR_TR ) )
+ {
+ pAnchorMarker = new SwAnchorMarker( pHdl );
+ UpdatePointer( aDocPos, rMEvt.GetModifier() );
+ return;
+ }
+ }
+ if ( EnterDrawMode( rMEvt, aDocPos ) )
+ {
+ bNoInterrupt = FALSE;
+ return;
+ }
+ else if ( rView.GetDrawFuncPtr() && bInsFrm )
+ {
+ StopInsFrm();
+ rSh.Edit();
+ }
+
+ // Ohne SHIFT, da sonst Toggle bei Selektion nicht funktioniert
+ if (rMEvt.GetClicks() == 1)
+ {
+ if ( rSh.IsSelFrmMode())
+ {
+ SdrHdl* pHdl = rSh.GetDrawView()->PickHandle(aDocPos);
+ BOOL bHitHandle = pHdl && pHdl->GetKind() != HDL_ANCHOR &&
+ pHdl->GetKind() != HDL_ANCHOR_TR;
+
+ if ((rSh.IsInsideSelectedObj(aDocPos) || bHitHandle) &&
+ !(rMEvt.GetModifier() == KEY_SHIFT && !bHitHandle))
+ {
+ rSh.EnterSelFrmMode( &aDocPos );
+ if ( !pApplyTempl )
+ {
+ //nur, wenn keine Position zum Sizen getroffen ist.
+ if (!bHitHandle)
+ {
+ StartDDTimer();
+ SwEditWin::nDDStartPosY = aDocPos.Y();
+ SwEditWin::nDDStartPosX = aDocPos.X();
+ }
+ bFrmDrag = TRUE;
+ }
+ bNoInterrupt = FALSE;
+ return;
+ }
+ }
+ }
+ }
+
+ BOOL bExecHyperlinks = rView.GetDocShell()->IsReadOnly();
+ if ( !bExecHyperlinks )
+ {
+ SvtSecurityOptions aSecOpts;
+ const BOOL bSecureOption = aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK );
+ if ( ( bSecureOption && rMEvt.GetModifier() == KEY_MOD1 ) ||
+ ( !bSecureOption && rMEvt.GetModifier() != KEY_MOD1 ) )
+ bExecHyperlinks = TRUE;
+ }
+
+ // --> FME 2004-07-30 #i32329# Enhanced selection
+ BYTE nNumberOfClicks = static_cast< BYTE >(rMEvt.GetClicks() % 4);
+ if ( 0 == nNumberOfClicks && 0 < rMEvt.GetClicks() )
+ nNumberOfClicks = 4;
+ // <--
+
+ BOOL bExecDrawTextLink = FALSE;
+
+ switch ( rMEvt.GetModifier() + rMEvt.GetButtons() )
+ {
+ case MOUSE_LEFT:
+ case MOUSE_LEFT + KEY_MOD1:
+ case MOUSE_LEFT + KEY_MOD2:
+ switch ( nNumberOfClicks )
+ {
+ case 1:
+ {
+ UpdatePointer( aDocPos, rMEvt.GetModifier() );
+ SwEditWin::nDDStartPosY = aDocPos.Y();
+ SwEditWin::nDDStartPosX = aDocPos.X();
+
+ // URL in DrawText-Objekt getroffen?
+ if (bExecHyperlinks && pSdrView)
+ {
+ SdrViewEvent aVEvt;
+ pSdrView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
+
+ if (aVEvt.eEvent == SDREVENT_EXECUTEURL)
+ bExecDrawTextLink = TRUE;
+ }
+
+ //Rahmen nur zu selektieren versuchen, wenn
+ //der Pointer bereits entsprechend geschaltet wurde
+ if ( aActHitType != SDRHIT_NONE && !rSh.IsSelFrmMode() &&
+ !GetView().GetViewFrame()->GetDispatcher()->IsLocked() &&
+ !bExecDrawTextLink)
+ {
+ // #107513#
+ // Test if there is a draw object at that position and if it should be selected.
+ sal_Bool bShould = rSh.ShouldObjectBeSelected(aDocPos);
+
+ if(bShould)
+ {
+ rView.NoRotate();
+ rSh.HideCrsr();
+
+ BOOL bUnLockView = !rSh.IsViewLocked();
+ rSh.LockView( TRUE );
+ BOOL bSelObj = rSh.SelectObj( aDocPos,
+ rMEvt.IsMod1() ? SW_ENTER_GROUP : 0);
+ if( bUnLockView )
+ rSh.LockView( FALSE );
+
+ if( bSelObj )
+ {
+ // falls im Macro der Rahmen deselektiert
+ // wurde, muss nur noch der Cursor
+ // wieder angezeigt werden.
+ if( FRMTYPE_NONE == rSh.GetSelFrmType() )
+ rSh.ShowCrsr();
+ else
+ {
+ if (rSh.IsFrmSelected() && rView.GetDrawFuncPtr())
+ {
+ rView.GetDrawFuncPtr()->Deactivate();
+ rView.SetDrawFuncPtr(NULL);
+ rView.LeaveDrawCreate();
+ rView.AttrChangedNotify( &rSh );
+ }
+
+ rSh.EnterSelFrmMode( &aDocPos );
+ bFrmDrag = TRUE;
+ UpdatePointer( aDocPos, rMEvt.GetModifier() );
+ }
+ return;
+ }
+ else
+ bOnlyText = static_cast< BOOL >(rSh.IsObjSelectable( aDocPos ));
+
+ if (!rView.GetDrawFuncPtr())
+ rSh.ShowCrsr();
+ }
+ else
+ bOnlyText = KEY_MOD1 != rMEvt.GetModifier();
+ }
+ else if ( rSh.IsSelFrmMode() &&
+ (aActHitType == SDRHIT_NONE ||
+ !rSh.IsInsideSelectedObj( aDocPos )))
+ {
+ rView.NoRotate();
+ SdrHdl *pHdl;
+ if( !bIsDocReadOnly && !pAnchorMarker && 0 !=
+ ( pHdl = pSdrView->PickHandle(aDocPos) ) &&
+ ( pHdl->GetKind() == HDL_ANCHOR ||
+ pHdl->GetKind() == HDL_ANCHOR_TR ) )
+ {
+ pAnchorMarker = new SwAnchorMarker( pHdl );
+ UpdatePointer( aDocPos, rMEvt.GetModifier() );
+ return;
+ }
+ else
+ {
+ BOOL bUnLockView = !rSh.IsViewLocked();
+ rSh.LockView( TRUE );
+ BYTE nFlag = rMEvt.IsShift() ? SW_ADD_SELECT :0;
+ if( rMEvt.IsMod1() )
+ nFlag = nFlag | SW_ENTER_GROUP;
+
+ if ( rSh.IsSelFrmMode() )
+ {
+ rSh.UnSelectFrm();
+ rSh.LeaveSelFrmMode();
+ rView.AttrChangedNotify(&rSh);
+ }
+
+ BOOL bSelObj = rSh.SelectObj( aDocPos, nFlag );
+ if( bUnLockView )
+ rSh.LockView( FALSE );
+
+ if( !bSelObj )
+ {
+ // Cursor hier umsetzen, damit er nicht zuerst
+ // im Rahmen gezeichnet wird; ShowCrsr() geschieht
+ // in LeaveSelFrmMode()
+ bValidCrsrPos = !(CRSR_POSCHG & (rSh.*rSh.fnSetCrsr)(&aDocPos,FALSE));
+ rSh.LeaveSelFrmMode();
+ rView.AttrChangedNotify( &rSh );
+ bCallBase = FALSE;
+ }
+ else
+ {
+ rSh.HideCrsr();
+ rSh.EnterSelFrmMode( &aDocPos );
+ rSh.SelFlyGrabCrsr();
+ rSh.MakeSelVisible();
+ bFrmDrag = TRUE;
+ if( rSh.IsFrmSelected() &&
+ rView.GetDrawFuncPtr() )
+ {
+ rView.GetDrawFuncPtr()->Deactivate();
+ rView.SetDrawFuncPtr(NULL);
+ rView.LeaveDrawCreate();
+ rView.AttrChangedNotify( &rSh );
+ }
+ UpdatePointer( aDocPos, rMEvt.GetModifier() );
+ return;
+ }
+ }
+ }
+
+ break;
+ }
+ case 2:
+ {
+ bFrmDrag = FALSE;
+ if ( !bIsDocReadOnly && rSh.IsInsideSelectedObj(aDocPos) &&
+ 0 == rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) )
+
+/* SJ: 01.03.2005: this is no good, on the one hand GetSelectionType is used as flag field (take a look into the GetSelectionType method)
+ on the other hand the return value is used in a switch without proper masking (very nice), this must lead to trouble
+*/
+ switch ( rSh.GetSelectionType() &~ ( nsSelectionType::SEL_FONTWORK | nsSelectionType::SEL_EXTRUDED_CUSTOMSHAPE ) )
+ {
+ case nsSelectionType::SEL_GRF:
+ RstMBDownFlags();
+ GetView().GetViewFrame()->GetBindings().Execute(
+ FN_FORMAT_GRAFIC_DLG, 0, 0,
+ SFX_CALLMODE_RECORD|SFX_CALLMODE_SLOT);
+ return;
+
+ // Doppelklick auf OLE-Objekt --> OLE-InPlace
+ case nsSelectionType::SEL_OLE:
+ if (!rSh.IsSelObjProtected(FLYPROTECT_CONTENT))
+ {
+ RstMBDownFlags();
+ rSh.LaunchOLEObj();
+ }
+ return;
+
+ case nsSelectionType::SEL_FRM:
+ RstMBDownFlags();
+ GetView().GetViewFrame()->GetBindings().Execute(
+ FN_FORMAT_FRAME_DLG, 0, 0, SFX_CALLMODE_RECORD|SFX_CALLMODE_SLOT);
+ return;
+
+ case nsSelectionType::SEL_DRW:
+ RstMBDownFlags();
+ EnterDrawTextMode(aDocPos);
+ if ( rView.GetCurShell()->ISA(SwDrawTextShell) )
+ ((SwDrawTextShell*)rView.GetCurShell())->Init();
+ return;
+ }
+
+ //falls die Cursorposition korrigiert wurde oder
+ // ein Fly im ReadOnlyModus selektiert ist,
+ //keine Wortselektion.
+ if ( !bValidCrsrPos ||
+ (rSh.IsFrmSelected() && rSh.IsFrmSelected() ))
+ return;
+
+ SwField *pFld;
+ BOOL bFtn = FALSE;
+
+ if( !bIsDocReadOnly &&
+ ( 0 != ( pFld = rSh.GetCurFld() ) ||
+ 0 != ( bFtn = rSh.GetCurFtn() )) )
+ {
+ RstMBDownFlags();
+ if( bFtn )
+ GetView().GetViewFrame()->GetBindings().Execute( FN_EDIT_FOOTNOTE );
+ else
+ {
+ USHORT nTypeId = pFld->GetTypeId();
+ SfxViewFrame* pVFrame = GetView().GetViewFrame();
+ switch( nTypeId )
+ {
+ case TYP_POSTITFLD:
+ case TYP_SCRIPTFLD:
+ {
+ //falls es ein Readonly-Bereich ist, dann muss der Status
+ //enabled werden
+ USHORT nSlot = TYP_POSTITFLD == nTypeId ? FN_POSTIT : FN_JAVAEDIT;
+ SfxBoolItem aItem(nSlot, TRUE);
+ pVFrame->GetBindings().SetState(aItem);
+ pVFrame->GetBindings().Execute(nSlot);
+ break;
+ }
+ case TYP_AUTHORITY :
+ pVFrame->GetBindings().Execute(FN_EDIT_AUTH_ENTRY_DLG);
+ break;
+ default:
+ pVFrame->GetBindings().Execute(FN_EDIT_FIELD);
+ }
+ }
+ return;
+ }
+ //im Extended Mode hat Doppel- und
+ //Dreifachklick keine Auswirkungen.
+ if ( rSh.IsExtMode() || rSh.IsBlockMode() )
+ return;
+
+ //Wort selektieren, gfs. Additional Mode
+ if ( KEY_MOD1 == rMEvt.GetModifier() && !rSh.IsAddMode() )
+ {
+ rSh.EnterAddMode();
+ rSh.SelWrd( &aDocPos );
+ rSh.LeaveAddMode();
+ }
+ else
+ rSh.SelWrd( &aDocPos );
+ bHoldSelection = TRUE;
+ return;
+ }
+ case 3:
+ case 4:
+ {
+ bFrmDrag = FALSE;
+ //im Extended Mode hat Doppel- und
+ //Dreifachklick keine Auswirkungen.
+ if ( rSh.IsExtMode() )
+ return;
+
+ //falls die Cursorposition korrigiert wurde oder
+ // ein Fly im ReadOnlyModus selektiert ist,
+ //keine Wortselektion.
+ if ( !bValidCrsrPos || rSh.IsFrmSelected() )
+ return;
+
+ //Zeile selektieren, gfs. Additional Mode
+ const bool bMod = KEY_MOD1 == rMEvt.GetModifier() &&
+ !rSh.IsAddMode();
+
+ if ( bMod )
+ rSh.EnterAddMode();
+
+ // --> FME 2004-07-30 #i32329# Enhanced selection
+ if ( 3 == nNumberOfClicks )
+ rSh.SelSentence( &aDocPos );
+ else
+ rSh.SelPara( &aDocPos );
+ // <--
+
+ if ( bMod )
+ rSh.LeaveAddMode();
+
+ bHoldSelection = TRUE;
+ return;
+ }
+
+ default:
+ return;
+ }
+ /* no break */
+ case MOUSE_LEFT + KEY_SHIFT:
+ case MOUSE_LEFT + KEY_SHIFT + KEY_MOD1:
+ {
+ BOOL bLockView = bWasShdwCrsr;
+
+ switch ( rMEvt.GetModifier() )
+ {
+ case KEY_MOD1 + KEY_SHIFT:
+ {
+ if ( !bInsDraw && IsDrawObjSelectable( rSh, aDocPos ) )
+ {
+ rView.NoRotate();
+ rSh.HideCrsr();
+ if ( rSh.IsSelFrmMode() )
+ rSh.SelectObj(aDocPos, SW_ADD_SELECT | SW_ENTER_GROUP);
+ else
+ { if ( rSh.SelectObj( aDocPos, SW_ADD_SELECT | SW_ENTER_GROUP ) )
+ {
+ rSh.EnterSelFrmMode( &aDocPos );
+ SwEditWin::nDDStartPosY = aDocPos.Y();
+ SwEditWin::nDDStartPosX = aDocPos.X();
+ bFrmDrag = TRUE;
+ return;
+ }
+ }
+ }
+ else if( rSh.IsSelFrmMode() &&
+ rSh.GetDrawView()->PickHandle( aDocPos ))
+ {
+ bFrmDrag = TRUE;
+ bNoInterrupt = FALSE;
+ return;
+ }
+ }
+ break;
+ case KEY_MOD1:
+ if ( !bExecDrawTextLink )
+ {
+ if ( !bInsDraw && IsDrawObjSelectable( rSh, aDocPos ) )
+ {
+ rView.NoRotate();
+ rSh.HideCrsr();
+ if ( rSh.IsSelFrmMode() )
+ rSh.SelectObj(aDocPos, SW_ENTER_GROUP);
+ else
+ { if ( rSh.SelectObj( aDocPos, SW_ENTER_GROUP ) )
+ {
+ rSh.EnterSelFrmMode( &aDocPos );
+ SwEditWin::nDDStartPosY = aDocPos.Y();
+ SwEditWin::nDDStartPosX = aDocPos.X();
+ bFrmDrag = TRUE;
+ return;
+ }
+ }
+ }
+ else if( rSh.IsSelFrmMode() &&
+ rSh.GetDrawView()->PickHandle( aDocPos ))
+ {
+ bFrmDrag = TRUE;
+ bNoInterrupt = FALSE;
+ return;
+ }
+ else
+ {
+ if ( !rSh.IsAddMode() && !rSh.IsExtMode() && !rSh.IsBlockMode() )
+ {
+ rSh.PushMode();
+ bModePushed = TRUE;
+
+ BOOL bUnLockView = !rSh.IsViewLocked();
+ rSh.LockView( TRUE );
+ rSh.EnterAddMode();
+ if( bUnLockView )
+ rSh.LockView( FALSE );
+ }
+ bCallBase = FALSE;
+ }
+ }
+ break;
+ case KEY_MOD2:
+ {
+ if ( !rSh.IsAddMode() && !rSh.IsExtMode() && !rSh.IsBlockMode() )
+ {
+ rSh.PushMode();
+ bModePushed = TRUE;
+ BOOL bUnLockView = !rSh.IsViewLocked();
+ rSh.LockView( TRUE );
+ rSh.EnterBlockMode();
+ if( bUnLockView )
+ rSh.LockView( FALSE );
+ }
+ bCallBase = FALSE;
+ }
+ break;
+ case KEY_SHIFT:
+ {
+ if ( !bInsDraw && IsDrawObjSelectable( rSh, aDocPos ) )
+ {
+ rView.NoRotate();
+ rSh.HideCrsr();
+ if ( rSh.IsSelFrmMode() )
+ {
+ rSh.SelectObj(aDocPos, SW_ADD_SELECT);
+
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+ if (rMarkList.GetMark(0) == NULL)
+ {
+ rSh.LeaveSelFrmMode();
+ rView.AttrChangedNotify(&rSh);
+ bFrmDrag = FALSE;
+ }
+ }
+ else
+ { if ( rSh.SelectObj( aDocPos ) )
+ {
+ rSh.EnterSelFrmMode( &aDocPos );
+ SwEditWin::nDDStartPosY = aDocPos.Y();
+ SwEditWin::nDDStartPosX = aDocPos.X();
+ bFrmDrag = TRUE;
+ return;
+ }
+ }
+ }
+ else
+ {
+ if ( rSh.IsSelFrmMode() &&
+ rSh.IsInsideSelectedObj( aDocPos ) )
+ {
+ rSh.EnterSelFrmMode( &aDocPos );
+ SwEditWin::nDDStartPosY = aDocPos.Y();
+ SwEditWin::nDDStartPosX = aDocPos.X();
+ bFrmDrag = TRUE;
+ return;
+ }
+ if ( rSh.IsSelFrmMode() )
+ {
+ rSh.UnSelectFrm();
+ rSh.LeaveSelFrmMode();
+ rView.AttrChangedNotify(&rSh);
+ bFrmDrag = FALSE;
+ }
+ if ( !rSh.IsExtMode() )
+ {
+ // keine Selection anfangen, wenn in ein URL-
+ // Feld oder eine -Grafik geklickt wird
+ BOOL bSttSelect = rSh.HasSelection() ||
+ Pointer(POINTER_REFHAND) != GetPointer();
+
+ if( !bSttSelect )
+ {
+ bSttSelect = TRUE;
+ if( bExecHyperlinks )
+ {
+ SwContentAtPos aCntntAtPos(
+ SwContentAtPos::SW_FTN |
+ SwContentAtPos::SW_INETATTR );
+
+ if( rSh.GetContentAtPos( aDocPos, aCntntAtPos ) )
+ {
+ if( !rSh.IsViewLocked() &&
+ !rSh.IsReadOnlyAvailable() &&
+ aCntntAtPos.IsInProtectSect() )
+ bLockView = TRUE;
+
+ bSttSelect = FALSE;
+ }
+ else if( rSh.IsURLGrfAtPos( aDocPos ))
+ bSttSelect = FALSE;
+ }
+ }
+
+ if( bSttSelect )
+ rSh.SttSelect();
+ }
+ }
+ bCallBase = FALSE;
+ break;
+ }
+ default:
+ if( !rSh.IsViewLocked() )
+ {
+ SwContentAtPos aCntntAtPos( SwContentAtPos::SW_CLICKFIELD |
+ SwContentAtPos::SW_INETATTR );
+ if( rSh.GetContentAtPos( aDocPos, aCntntAtPos, FALSE ) &&
+ !rSh.IsReadOnlyAvailable() &&
+ aCntntAtPos.IsInProtectSect() )
+ bLockView = TRUE;
+ }
+ }
+
+ if ( rSh.IsGCAttr() )
+ {
+ rSh.GCAttr();
+ rSh.ClearGCAttr();
+ }
+
+ BOOL bOverSelect = rSh.ChgCurrPam( aDocPos ), bOverURLGrf = FALSE;
+ if( !bOverSelect )
+ bOverURLGrf = bOverSelect = 0 != rSh.IsURLGrfAtPos( aDocPos );
+
+ if ( !bOverSelect )
+ {
+ const BOOL bTmpNoInterrupt = bNoInterrupt;
+ bNoInterrupt = FALSE;
+
+ if( !rSh.IsViewLocked() && bLockView )
+ rSh.LockView( TRUE );
+ else
+ bLockView = FALSE;
+
+ int nTmpSetCrsr = 0;
+
+ { // nur temp. Move-Kontext aufspannen, da sonst die
+ // Abfrage auf die Inhaltsform nicht funktioniert!!!
+ MV_KONTEXT( &rSh );
+ nTmpSetCrsr = (rSh.*rSh.fnSetCrsr)(&aDocPos,bOnlyText);
+ bValidCrsrPos = !(CRSR_POSCHG & nTmpSetCrsr);
+ bCallBase = FALSE;
+ }
+
+ //#i42732# - notify the edit window that from now on we do not use the input language
+ if ( !(CRSR_POSOLD & nTmpSetCrsr) )
+ SetUseInputLanguage( sal_False );
+
+ if( bLockView )
+ rSh.LockView( FALSE );
+
+ bNoInterrupt = bTmpNoInterrupt;
+ }
+ if ( !bOverURLGrf && !bOnlyText )
+ {
+ const int nSelType = rSh.GetSelectionType();
+ // --> OD 2009-12-30 #i89920#
+ // Check in general, if an object is selectable at given position.
+ // Thus, also text fly frames in background become selectable via Ctrl-Click.
+ if ( nSelType & nsSelectionType::SEL_OLE ||
+ nSelType & nsSelectionType::SEL_GRF ||
+ rSh.IsObjSelectable( aDocPos ) )
+ // <--
+ {
+ MV_KONTEXT( &rSh );
+ if( !rSh.IsFrmSelected() )
+ rSh.GotoNextFly();
+ rSh.EnterSelFrmMode();
+ bCallBase = FALSE;
+ }
+ }
+ // nicht mehr hier zuruecksetzen, damit -- falls durch MouseMove
+ // bei gedrueckter Ctrl-Taste eine Mehrfachselektion erfolgen soll,
+ // im Drag nicht die vorherige Selektion aufgehoben wird.
+// if(bModePushed)
+// rSh.PopMode(FALSE);
+ break;
+ }
+ }
+ }
+ if (bCallBase)
+ Window::MouseButtonDown(rMEvt);
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: MouseMove
+ --------------------------------------------------------------------*/
+
+
+void SwEditWin::MouseMove(const MouseEvent& _rMEvt)
+{
+ MouseEvent rMEvt(_rMEvt);
+
+ //ignore key modifiers for format paintbrush
+ {
+ BOOL bExecFormatPaintbrush = pApplyTempl && pApplyTempl->pFormatClipboard
+ && pApplyTempl->pFormatClipboard->HasContent();
+ if( bExecFormatPaintbrush )
+ rMEvt = MouseEvent( _rMEvt.GetPosPixel(), _rMEvt.GetClicks(),
+ _rMEvt.GetMode(), _rMEvt.GetButtons() );
+ }
+
+ // solange eine Action laeuft sollte das MouseMove abgeklemmt sein
+ // Ansonsten gibt es den Bug 40102
+ SwWrtShell &rSh = rView.GetWrtShell();
+ if( rSh.ActionPend() )
+ return ;
+
+ if( pShadCrsr && 0 != (rMEvt.GetModifier() + rMEvt.GetButtons() ) )
+ delete pShadCrsr, pShadCrsr = 0;
+
+ BOOL bIsDocReadOnly = rView.GetDocShell()->IsReadOnly();
+
+ SET_CURR_SHELL( &rSh );
+
+ //aPixPt == Point in Pixel, rel. zu ChildWin
+ //aDocPt == Point in Twips, Dokumentkoordinaten
+ const Point aPixPt( rMEvt.GetPosPixel() );
+ const Point aDocPt( PixelToLogic( aPixPt ) );
+
+ if ( IsChainMode() )
+ {
+ UpdatePointer( aDocPt, rMEvt.GetModifier() );
+ if ( rMEvt.IsLeaveWindow() )
+ rView.GetViewFrame()->HideStatusText();
+ return;
+ }
+
+ SdrView *pSdrView = rSh.GetDrawView();
+
+ const SwCallMouseEvent aLastCallEvent( aSaveCallEvent );
+ aSaveCallEvent.Clear();
+
+ if ( !bIsDocReadOnly && pSdrView && pSdrView->MouseMove(rMEvt,this) )
+ {
+ SetPointer( POINTER_TEXT );
+ return; // Event von der SdrView ausgewertet
+ }
+
+ const Point aOldPt( rSh.VisArea().Pos() );
+#ifdef TEST_FOR_BUG91313
+ // n Pixel as FUZZY border
+ SwRect aVis( rSh.VisArea() );
+ Size aFuzzySz( 2, 2 );
+ aFuzzySz = PixelToLogic( aFuzzySz );
+
+ aVis.Top( aVis.Top() + aFuzzySz.Height() );
+ aVis.Bottom( aVis.Bottom() - aFuzzySz.Height() );
+ aVis.Left( aVis.Left() + aFuzzySz.Width() );
+ aVis.Right( aVis.Right() - aFuzzySz.Width() );
+ const BOOL bInsWin = aVis.IsInside( aDocPt );
+#else
+ const BOOL bInsWin = rSh.VisArea().IsInside( aDocPt );
+#endif
+
+ if( pShadCrsr && !bInsWin )
+ delete pShadCrsr, pShadCrsr = 0;
+
+ if( bInsWin && pRowColumnSelectionStart )
+ {
+ EnterArea();
+ Point aPos( aDocPt );
+ if( rSh.SelectTableRowCol( *pRowColumnSelectionStart, &aPos, bIsRowDrag ))
+ return;
+ }
+
+ // Position ist noetig fuer OS/2, da dort nach einem MB-Down
+ // offensichtlich sofort ein MB-Move gerufen wird.
+ if( bDDTimerStarted )
+ {
+ Point aDD( SwEditWin::nDDStartPosX, SwEditWin::nDDStartPosY );
+ aDD = LogicToPixel( aDD );
+ Rectangle aRect( aDD.X()-3, aDD.Y()-3, aDD.X()+3, aDD.Y()+3 );
+ if ( !aRect.IsInside( aPixPt ) ) // MA 23. May. 95: Tatterschutz.
+ StopDDTimer( &rSh, aDocPt );
+ }
+
+ if(rView.GetDrawFuncPtr())
+ {
+ if( bInsDraw )
+ {
+ rView.GetDrawFuncPtr()->MouseMove( rMEvt );
+ if ( !bInsWin )
+ {
+ Point aTmp( aDocPt );
+ aTmp += rSh.VisArea().Pos() - aOldPt;
+ LeaveArea( aTmp );
+ }
+ else
+ EnterArea();
+ return;
+ }
+ else if(!rSh.IsFrmSelected() && !rSh.IsObjSelected())
+ {
+ SfxBindings &rBnd = rSh.GetView().GetViewFrame()->GetBindings();
+ Point aRelPos = rSh.GetRelativePagePosition(aDocPt);
+ if(aRelPos.X() >= 0)
+ {
+ FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &GetView()));
+ SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
+ const SfxPointItem aTmp1( SID_ATTR_POSITION, aRelPos );
+ rBnd.SetState( aTmp1 );
+ }
+ else
+ {
+ rBnd.Invalidate(SID_ATTR_POSITION);
+ }
+ rBnd.Invalidate(SID_ATTR_SIZE);
+ const SfxStringItem aCell( SID_TABLE_CELL, aEmptyStr );
+ rBnd.SetState( aCell );
+ }
+ }
+
+ BYTE nMouseTabCol;
+ if( !bIsDocReadOnly && bInsWin && !pApplyTempl && !rSh.IsInSelect() )
+ {
+ if ( SW_TABCOL_NONE != (nMouseTabCol = rSh.WhichMouseTabCol( aDocPt ) ) &&
+ !rSh.IsObjSelectable( aDocPt ) )
+ {
+ USHORT nPointer = USHRT_MAX;
+ bool bChkTblSel = false;
+
+ switch ( nMouseTabCol )
+ {
+ case SW_TABCOL_VERT :
+ case SW_TABROW_HORI :
+ nPointer = POINTER_VSIZEBAR;
+ bChkTblSel = true;
+ break;
+ case SW_TABROW_VERT :
+ case SW_TABCOL_HORI :
+ nPointer = POINTER_HSIZEBAR;
+ bChkTblSel = true;
+ break;
+ // --> FME 2004-07-30 #i20126# Enhanced table selection
+ case SW_TABSEL_HORI :
+ nPointer = POINTER_TAB_SELECT_SE;
+ break;
+ case SW_TABSEL_HORI_RTL :
+ case SW_TABSEL_VERT :
+ nPointer = POINTER_TAB_SELECT_SW;
+ break;
+ case SW_TABCOLSEL_HORI :
+ case SW_TABROWSEL_VERT :
+ nPointer = POINTER_TAB_SELECT_S;
+ break;
+ case SW_TABROWSEL_HORI :
+ nPointer = POINTER_TAB_SELECT_E;
+ break;
+ case SW_TABROWSEL_HORI_RTL :
+ case SW_TABCOLSEL_VERT :
+ nPointer = POINTER_TAB_SELECT_W;
+ break;
+ // <--
+ }
+
+ if ( USHRT_MAX != nPointer &&
+ // --> FME 2004-10-20 #i35543#
+ // Enhanced table selection is explicitely allowed in table mode
+ ( !bChkTblSel || !rSh.IsTableMode() ) )
+ // <--
+ {
+ SetPointer( nPointer );
+ }
+
+ return;
+ }
+ // #i23726#
+ else if (rSh.IsNumLabel(aDocPt, RULER_MOUSE_MARGINWIDTH))
+ {
+ // --> OD 2005-02-21 #i42921# - consider vertical mode
+ SwTxtNode* pNodeAtPos = rSh.GetNumRuleNodeAtPos( aDocPt );
+ const USHORT nPointer =
+ rSh.IsVerticalModeAtNdAndPos( *pNodeAtPos, aDocPt )
+ ? POINTER_VSIZEBAR
+ : POINTER_HSIZEBAR;
+ SetPointer( nPointer );
+ // <--
+
+ return;
+ }
+ }
+
+ BOOL bDelShadCrsr = TRUE;
+
+ switch ( rMEvt.GetModifier() + rMEvt.GetButtons() )
+ {
+ case MOUSE_LEFT:
+ if( pAnchorMarker )
+ {
+ // Now we need to refresh the SdrHdl pointer of pAnchorMarker.
+ // This looks a little bit tricky, but it solves the following
+ // problem: the pAnchorMarker contains a pointer to an SdrHdl,
+ // if the FindAnchorPos-call cause a scrolling of the visible
+ // area, it's possible that the SdrHdl will be destroyed and a
+ // new one will initialized at the original position(GetHdlPos).
+ // So the pAnchorMarker has to find the right SdrHdl, if it's
+ // the old one, it will find it with position aOld, if this one
+ // is destroyed, it will find a new one at position GetHdlPos().
+ Point aOld = pAnchorMarker->GetPos();
+ Point aNew = rSh.FindAnchorPos( aDocPt );
+ SdrHdl* pHdl;
+ if( (0!=( pHdl = pSdrView->PickHandle( aOld ) )||
+ 0 !=(pHdl = pSdrView->PickHandle( pAnchorMarker->GetHdlPos()) ) ) &&
+ ( pHdl->GetKind() == HDL_ANCHOR ||
+ pHdl->GetKind() == HDL_ANCHOR_TR ) )
+ {
+ pAnchorMarker->ChgHdl( pHdl );
+ if( aNew.X() || aNew.Y() )
+ {
+ pAnchorMarker->SetPos( aNew );
+ pAnchorMarker->SetLastPos( aDocPt );
+ //OLMpSdrView->RefreshAllIAOManagers();
+ }
+ }
+ else
+ {
+ delete pAnchorMarker;
+ pAnchorMarker = NULL;
+ }
+ }
+ if ( bInsDraw )
+ {
+ if ( !bMBPressed )
+ break;
+ if ( bIsInMove || IsMinMove( aStartPos, aPixPt ) )
+ {
+ if ( !bInsWin )
+ LeaveArea( aDocPt );
+ else
+ EnterArea();
+ if ( rView.GetDrawFuncPtr() )
+ {
+ pSdrView->SetOrtho(FALSE);
+ rView.GetDrawFuncPtr()->MouseMove( rMEvt );
+ }
+ bIsInMove = TRUE;
+ }
+ return;
+ }
+ case MOUSE_LEFT + KEY_SHIFT:
+ case MOUSE_LEFT + KEY_SHIFT + KEY_MOD1:
+ if ( !bMBPressed )
+ break;
+ case MOUSE_LEFT + KEY_MOD1:
+ if ( bFrmDrag && rSh.IsSelFrmMode() )
+ {
+ if( !bMBPressed )
+ break;
+
+ if ( bIsInMove || IsMinMove( aStartPos, aPixPt ) )
+ {
+ // Event-Verarbeitung fuers Resizen
+ if( pSdrView->AreObjectsMarked() )
+ {
+ const SwFrmFmt* pFlyFmt;
+ const SvxMacro* pMacro;
+
+ const Point aSttPt( PixelToLogic( aStartPos ) );
+
+ // geht es los?
+ if( HDL_USER == eSdrMoveHdl )
+ {
+ SdrHdl* pHdl = pSdrView->PickHandle( aSttPt );
+ eSdrMoveHdl = pHdl ? pHdl->GetKind() : HDL_MOVE;
+ }
+
+ USHORT nEvent = HDL_MOVE == eSdrMoveHdl
+ ? SW_EVENT_FRM_MOVE
+ : SW_EVENT_FRM_RESIZE;
+
+ if( 0 != ( pFlyFmt = rSh.GetFlyFrmFmt() ) &&
+ 0 != ( pMacro = pFlyFmt->GetMacro().GetMacroTable().
+ Get( nEvent )) &&
+// oder nur z.B. alle 20 Twip bescheid sagen?
+// ( 20 > Abs( aRszMvHdlPt.X() - aDocPt.X() ) ||
+// 20 > Abs( aRszMvHdlPt.Y() - aDocPt.Y() ) )
+ aRszMvHdlPt != aDocPt )
+ {
+ aRszMvHdlPt = aDocPt;
+ USHORT nPos = 0;
+ String sRet;
+ SbxArrayRef xArgs = new SbxArray;
+ SbxVariableRef xVar = new SbxVariable;
+ xVar->PutString( pFlyFmt->GetName() );
+ xArgs->Put( &xVar, ++nPos );
+
+ if( SW_EVENT_FRM_RESIZE == nEvent )
+ {
+ xVar = new SbxVariable;
+ xVar->PutUShort( static_cast< UINT16 >(eSdrMoveHdl) );
+ xArgs->Put( &xVar, ++nPos );
+ }
+
+ xVar = new SbxVariable;
+ xVar->PutLong( aDocPt.X() - aSttPt.X() );
+ xArgs->Put( &xVar, ++nPos );
+ xVar = new SbxVariable;
+ xVar->PutLong( aDocPt.Y() - aSttPt.Y() );
+ xArgs->Put( &xVar, ++nPos );
+
+ ReleaseMouse();
+
+ rSh.ExecMacro( *pMacro, &sRet, &xArgs );
+
+ CaptureMouse();
+
+ if( sRet.Len() && 0 != sRet.ToInt32() )
+ return ;
+ }
+ }
+ // Event-Verarbeitung fuers Resizen
+
+ if( bIsDocReadOnly )
+ break;
+
+ if ( rMEvt.IsShift() )
+ {
+ pSdrView->SetOrtho(TRUE);
+ pSdrView->SetAngleSnapEnabled(TRUE);
+ }
+ else
+ {
+ pSdrView->SetOrtho(FALSE);
+ pSdrView->SetAngleSnapEnabled(FALSE);
+ }
+
+ (rSh.*rSh.fnDrag)( &aDocPt, rMEvt.IsShift() );
+ bIsInMove = TRUE;
+ }
+ else if( bIsDocReadOnly )
+ break;
+
+ if ( !bInsWin )
+ {
+ Point aTmp( aDocPt );
+ aTmp += rSh.VisArea().Pos() - aOldPt;
+ LeaveArea( aTmp );
+ }
+ else if(bIsInMove)
+ EnterArea();
+ return;
+ }
+ if ( !rSh.IsSelFrmMode() && !bDDINetAttr &&
+ (IsMinMove( aStartPos,aPixPt ) || bIsInMove) &&
+ (rSh.IsInSelect() || !rSh.ChgCurrPam( aDocPt )) )
+ {
+ if ( pSdrView )
+ {
+ if ( rMEvt.IsShift() )
+ pSdrView->SetOrtho(TRUE);
+ else
+ pSdrView->SetOrtho(FALSE);
+ }
+ if ( !bInsWin )
+ {
+ Point aTmp( aDocPt );
+ aTmp += rSh.VisArea().Pos() - aOldPt;
+ LeaveArea( aTmp );
+ }
+ else
+ {
+ //JP 24.09.98: Fix fuer die Bugs 55592 / 55931
+ //JP 23.04.99: Fix fuer den Bugs 65289
+ //JP 06.07.99: Fix fuer den Bugs 67360
+ if( !rMEvt.IsSynthetic() &&
+ !(( MOUSE_LEFT + KEY_MOD1 ==
+ rMEvt.GetModifier() + rMEvt.GetButtons() ) &&
+ rSh.Is_FnDragEQBeginDrag() && !rSh.IsAddMode() ))
+ {
+ (rSh.*rSh.fnDrag)( &aDocPt,FALSE );
+
+ bValidCrsrPos = !(CRSR_POSCHG & (rSh.*rSh.fnSetCrsr)(&aDocPt,FALSE));
+ EnterArea();
+ }
+ }
+ }
+ bDDINetAttr = FALSE;
+ break;
+ case 0:
+ {
+ if ( pApplyTempl )
+ {
+ UpdatePointer(aDocPt, 0); // evtl. muss hier ein Rahmen markiert werden
+ break;
+ }
+ //#i6193#, change ui if mouse is over SwPostItField
+ // TODO: do the same thing for redlines SW_REDLINE
+ SwRect aFldRect;
+ SwContentAtPos aCntntAtPos( SwContentAtPos::SW_FIELD);
+ if( rSh.GetContentAtPos( aDocPt, aCntntAtPos, FALSE, &aFldRect ) )
+ {
+ const SwField* pFld = aCntntAtPos.aFnd.pFld;
+ if (pFld->Which()== RES_POSTITFLD)
+ {
+ rView.GetPostItMgr()->SetShadowState(reinterpret_cast<const SwPostItField*>(pFld),false);
+ }
+ else
+ rView.GetPostItMgr()->SetShadowState(0,false);
+ }
+ else
+ rView.GetPostItMgr()->SetShadowState(0,false);
+ // no break;
+ }
+ case KEY_SHIFT:
+ case KEY_MOD2:
+ case KEY_MOD1:
+ if ( !bInsDraw )
+ {
+ BOOL bTstShdwCrsr = TRUE;
+
+ UpdatePointer( aDocPt, rMEvt.GetModifier() );
+
+ const SwFrmFmt* pFmt = 0;
+ const SwFmtINetFmt* pINet = 0;
+ SwContentAtPos aCntntAtPos( SwContentAtPos::SW_INETATTR );
+ if( rSh.GetContentAtPos( aDocPt, aCntntAtPos ) )
+ pINet = (SwFmtINetFmt*)aCntntAtPos.aFnd.pAttr;
+
+ const void* pTmp = pINet;
+
+ if( pINet ||
+ 0 != ( pTmp = pFmt = rSh.GetFmtFromAnyObj( aDocPt )))
+ {
+ bTstShdwCrsr = FALSE;
+ if( pTmp == pINet )
+ aSaveCallEvent.Set( pINet );
+ else
+ {
+ IMapObject* pIMapObj = pFmt->GetIMapObject( aDocPt );
+ if( pIMapObj )
+ aSaveCallEvent.Set( pFmt, pIMapObj );
+ else
+ aSaveCallEvent.Set( EVENT_OBJECT_URLITEM, pFmt );
+ }
+
+ // sollte wir ueber einem InternetFeld mit einem
+ // gebundenen Macro stehen?
+ if( aSaveCallEvent != aLastCallEvent )
+ {
+ if( aLastCallEvent.HasEvent() )
+ rSh.CallEvent( SFX_EVENT_MOUSEOUT_OBJECT,
+ aLastCallEvent, TRUE );
+ // 0 besagt, das das Object gar keine Tabelle hat
+ if( !rSh.CallEvent( SFX_EVENT_MOUSEOVER_OBJECT,
+ aSaveCallEvent ))
+ aSaveCallEvent.Clear();
+ }
+ }
+ else if( aLastCallEvent.HasEvent() )
+ {
+ // Cursor stand auf einem Object
+ rSh.CallEvent( SFX_EVENT_MOUSEOUT_OBJECT,
+ aLastCallEvent, TRUE );
+ }
+
+ if( bTstShdwCrsr && bInsWin && !bIsDocReadOnly &&
+ !bInsFrm &&
+ !rSh.getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) &&
+ rSh.GetViewOptions()->IsShadowCursor() &&
+ !(rMEvt.GetModifier() + rMEvt.GetButtons()) &&
+ !rSh.HasSelection() && !GetConnectMetaFile() )
+ {
+ SwRect aRect;
+ sal_Int16 eOrient;
+ SwFillMode eMode = (SwFillMode)rSh.GetViewOptions()->GetShdwCrsrFillMode();
+ if( rSh.GetShadowCrsrPos( aDocPt, eMode, aRect, eOrient ))
+ {
+ if( !pShadCrsr )
+ pShadCrsr = new SwShadowCursor( *this,
+ SwViewOption::GetDirectCursorColor() );
+ if( text::HoriOrientation::RIGHT != eOrient && text::HoriOrientation::CENTER != eOrient )
+ eOrient = text::HoriOrientation::LEFT;
+ pShadCrsr->SetPos( aRect.Pos(), aRect.Height(), static_cast< USHORT >(eOrient) );
+ bDelShadCrsr = FALSE;
+ }
+ }
+ }
+ break;
+ case MOUSE_LEFT + KEY_MOD2:
+ if( rSh.IsBlockMode() && !rMEvt.IsSynthetic() )
+ {
+ (rSh.*rSh.fnDrag)( &aDocPt,FALSE );
+ bValidCrsrPos = !(CRSR_POSCHG & (rSh.*rSh.fnSetCrsr)(&aDocPt,FALSE));
+ EnterArea();
+ }
+ break;
+ }
+
+ if( bDelShadCrsr && pShadCrsr )
+ delete pShadCrsr, pShadCrsr = 0;
+ bWasShdwCrsr = FALSE;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Button Up
+ --------------------------------------------------------------------*/
+
+
+void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt)
+{
+ BOOL bCallBase = TRUE;
+
+ BOOL bCallShadowCrsr = bWasShdwCrsr;
+ bWasShdwCrsr = FALSE;
+ if( pShadCrsr )
+ delete pShadCrsr, pShadCrsr = 0;
+
+ if( pRowColumnSelectionStart )
+ DELETEZ( pRowColumnSelectionStart );
+
+ SdrHdlKind eOldSdrMoveHdl = eSdrMoveHdl;
+ eSdrMoveHdl = HDL_USER; // fuer die MoveEvents - wieder zuruecksetzen
+
+ // sicherheitshalber zuruecksetzen Bug 27900
+ rView.SetTabColFromDoc( FALSE );
+ rView.SetNumRuleNodeFromDoc(NULL);
+
+ SwWrtShell &rSh = rView.GetWrtShell();
+ SET_CURR_SHELL( &rSh );
+ SdrView *pSdrView = rSh.GetDrawView();
+ if ( pSdrView )
+ {
+ pSdrView->SetOrtho(FALSE);
+
+ if ( pSdrView->MouseButtonUp( rMEvt,this ) )
+ {
+ rSh.GetView().GetViewFrame()->GetBindings().InvalidateAll(FALSE);
+ return; // Event von der SdrView ausgewertet
+ }
+ }
+ //MouseButtonUp nur bearbeiten, wenn auch das Down an dieses Fenster ging.
+ if ( !bMBPressed )
+ {
+// OS 25.02.97 Undo fuer die Giesskann ist bereits im CommandHdl
+//JP 29.09.95: so sollte es sein!!! if(pApplyTempl->bUndo)
+// if( pApplyTempl && MOUSE_RIGHT == rMEvt.GetModifier() + rMEvt.GetButtons() )
+// rSh.Do( SwWrtShell::UNDO );
+ return;
+ }
+
+ Point aDocPt( PixelToLogic( rMEvt.GetPosPixel() ) );
+
+ if ( bDDTimerStarted )
+ {
+ StopDDTimer( &rSh, aDocPt );
+ bMBPressed = FALSE;
+ if ( rSh.IsSelFrmMode() )
+ {
+ (rSh.*rSh.fnEndDrag)( &aDocPt, FALSE );
+ bFrmDrag = FALSE;
+ }
+ bNoInterrupt = FALSE;
+ ReleaseMouse();
+ return;
+ }
+
+ if( pAnchorMarker )
+ {
+ Point aPnt( pAnchorMarker->GetLastPos() );
+ //OLMpSdrView->RefreshAllIAOManagers();
+ DELETEZ( pAnchorMarker );
+ if( aPnt.X() || aPnt.Y() )
+ rSh.FindAnchorPos( aPnt, TRUE );
+ }
+ if ( bInsDraw && rView.GetDrawFuncPtr() )
+ {
+ if ( rView.GetDrawFuncPtr()->MouseButtonUp( rMEvt ) )
+ {
+ if (rView.GetDrawFuncPtr()) // Koennte im MouseButtonUp zerstoert worden sein
+ {
+ rView.GetDrawFuncPtr()->Deactivate();
+
+ if (!rView.IsDrawMode())
+ {
+ rView.SetDrawFuncPtr(NULL);
+ SfxBindings& rBind = rView.GetViewFrame()->GetBindings();
+ rBind.Invalidate( SID_ATTR_SIZE );
+ rBind.Invalidate( SID_TABLE_CELL );
+ }
+ }
+
+ if ( rSh.IsObjSelected() )
+ {
+ rSh.EnterSelFrmMode();
+ if (!rView.GetDrawFuncPtr())
+ StdDrawMode( OBJ_NONE, TRUE );
+ }
+ else if ( rSh.IsFrmSelected() )
+ {
+ rSh.EnterSelFrmMode();
+ StopInsFrm();
+ }
+ else
+ {
+ const Point aDocPos( PixelToLogic( aStartPos ) );
+ bValidCrsrPos = !(CRSR_POSCHG & (rSh.*rSh.fnSetCrsr)(&aDocPos,FALSE));
+ rSh.Edit();
+ }
+
+ rView.AttrChangedNotify( &rSh );
+ }
+ else if (rMEvt.GetButtons() == MOUSE_RIGHT && rSh.IsDrawCreate())
+ rView.GetDrawFuncPtr()->BreakCreate(); // Zeichnen abbrechen
+
+ bNoInterrupt = FALSE;
+ ReleaseMouse();
+ return;
+ }
+ BOOL bPopMode = FALSE;
+ switch ( rMEvt.GetModifier() + rMEvt.GetButtons() )
+ {
+ case MOUSE_LEFT:
+ if ( bInsDraw && rSh.IsDrawCreate() )
+ {
+ if ( rView.GetDrawFuncPtr() && rView.GetDrawFuncPtr()->MouseButtonUp(rMEvt) == TRUE )
+ {
+ rView.GetDrawFuncPtr()->Deactivate();
+ rView.AttrChangedNotify( &rSh );
+ if ( rSh.IsObjSelected() )
+ rSh.EnterSelFrmMode();
+ if ( rView.GetDrawFuncPtr() && bInsFrm )
+ StopInsFrm();
+ }
+ bCallBase = FALSE;
+ break;
+ }
+ case MOUSE_LEFT + KEY_MOD1:
+ case MOUSE_LEFT + KEY_MOD2:
+ case MOUSE_LEFT + KEY_SHIFT + KEY_MOD1:
+ if ( bFrmDrag && rSh.IsSelFrmMode() )
+ {
+ if ( rMEvt.IsMod1() ) //Kopieren und nicht moven.
+ {
+ //Drag abbrechen, statt dessen internes Copy verwenden
+ Rectangle aRect;
+ rSh.GetDrawView()->TakeActionRect( aRect );
+ if (!aRect.IsEmpty())
+ {
+ rSh.BreakDrag();
+ Point aEndPt, aSttPt;
+ if ( rSh.GetSelFrmType() & FRMTYPE_FLY_ATCNT )
+ {
+ aEndPt = aRect.TopLeft();
+ aSttPt = rSh.GetDrawView()->GetAllMarkedRect().TopLeft();
+ }
+ else
+ {
+ aEndPt = aRect.Center();
+ aSttPt = rSh.GetDrawView()->GetAllMarkedRect().Center();
+ }
+ if ( aSttPt != aEndPt )
+ {
+ rSh.StartUndo( UNDO_UI_DRAG_AND_COPY );
+ rSh.Copy(&rSh, aSttPt, aEndPt, FALSE);
+ rSh.EndUndo( UNDO_UI_DRAG_AND_COPY );
+ }
+ }
+ else
+ (rSh.*rSh.fnEndDrag)( &aDocPt,FALSE );
+ }
+ else
+ {
+ {
+ const SwFrmFmt* pFlyFmt;
+ const SvxMacro* pMacro;
+
+ USHORT nEvent = HDL_MOVE == eOldSdrMoveHdl
+ ? SW_EVENT_FRM_MOVE
+ : SW_EVENT_FRM_RESIZE;
+
+ if( 0 != ( pFlyFmt = rSh.GetFlyFrmFmt() ) &&
+ 0 != ( pMacro = pFlyFmt->GetMacro().GetMacroTable().
+ Get( nEvent )) )
+ {
+ const Point aSttPt( PixelToLogic( aStartPos ) );
+ aRszMvHdlPt = aDocPt;
+ USHORT nPos = 0;
+ SbxArrayRef xArgs = new SbxArray;
+ SbxVariableRef xVar = new SbxVariable;
+ xVar->PutString( pFlyFmt->GetName() );
+ xArgs->Put( &xVar, ++nPos );
+
+ if( SW_EVENT_FRM_RESIZE == nEvent )
+ {
+ xVar = new SbxVariable;
+ xVar->PutUShort( static_cast< UINT16 >(eOldSdrMoveHdl) );
+ xArgs->Put( &xVar, ++nPos );
+ }
+
+ xVar = new SbxVariable;
+ xVar->PutLong( aDocPt.X() - aSttPt.X() );
+ xArgs->Put( &xVar, ++nPos );
+ xVar = new SbxVariable;
+ xVar->PutLong( aDocPt.Y() - aSttPt.Y() );
+ xArgs->Put( &xVar, ++nPos );
+
+ xVar = new SbxVariable;
+ xVar->PutUShort( 1 );
+ xArgs->Put( &xVar, ++nPos );
+
+ ReleaseMouse();
+
+ rSh.ExecMacro( *pMacro, 0, &xArgs );
+
+ CaptureMouse();
+ }
+ }
+ (rSh.*rSh.fnEndDrag)( &aDocPt,FALSE );
+ }
+ bFrmDrag = FALSE;
+ bCallBase = FALSE;
+ break;
+ }
+ bPopMode = TRUE;
+ // no break
+ case MOUSE_LEFT + KEY_SHIFT:
+ if (rSh.IsSelFrmMode())
+ {
+
+ (rSh.*rSh.fnEndDrag)( &aDocPt, FALSE );
+ bFrmDrag = FALSE;
+ bCallBase = FALSE;
+ break;
+ }
+
+ if( bHoldSelection )
+ {
+ //JP 27.04.99: Bug 65389 - das EndDrag sollte auf jedenfall
+ // gerufen werden.
+ bHoldSelection = FALSE;
+ (rSh.*rSh.fnEndDrag)( &aDocPt, FALSE );
+ }
+ else
+ {
+ if ( !rSh.IsInSelect() && rSh.ChgCurrPam( aDocPt ) )
+ {
+ const BOOL bTmpNoInterrupt = bNoInterrupt;
+ bNoInterrupt = FALSE;
+ { // nur temp. Move-Kontext aufspannen, da sonst die
+ // Abfrage auf die Inhaltsform nicht funktioniert!!!
+ MV_KONTEXT( &rSh );
+ const Point aDocPos( PixelToLogic( aStartPos ) );
+ bValidCrsrPos = !(CRSR_POSCHG & (rSh.*rSh.fnSetCrsr)(&aDocPos,FALSE));
+ }
+ bNoInterrupt = bTmpNoInterrupt;
+
+ }
+ else
+ {
+ BOOL bInSel = rSh.IsInSelect();
+ (rSh.*rSh.fnEndDrag)( &aDocPt, FALSE );
+
+ // Internetfield? --> Link-Callen (DocLaden!!)
+//JP 18.10.96: Bug 32437 -
+// if( !rSh.HasSelection() )
+ if( !bInSel )
+ {
+ USHORT nFilter = URLLOAD_NOFILTER;
+ if( KEY_MOD1 == rMEvt.GetModifier() )
+ nFilter |= URLLOAD_NEWVIEW;
+
+ BOOL bExecHyperlinks = rView.GetDocShell()->IsReadOnly();
+ if ( !bExecHyperlinks )
+ {
+ SvtSecurityOptions aSecOpts;
+ const BOOL bSecureOption = aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK );
+ if ( ( bSecureOption && rMEvt.GetModifier() == KEY_MOD1 ) ||
+ ( !bSecureOption && rMEvt.GetModifier() != KEY_MOD1 ) )
+ bExecHyperlinks = TRUE;
+ }
+
+ const BOOL bExecSmarttags = rMEvt.GetModifier() == KEY_MOD1;
+
+ if(pApplyTempl)
+ bExecHyperlinks = FALSE;
+
+ SwContentAtPos aCntntAtPos( SwContentAtPos::SW_CLICKFIELD |
+ SwContentAtPos::SW_INETATTR |
+ SwContentAtPos::SW_SMARTTAG | SwContentAtPos::SW_FORMCTRL);
+
+ if( rSh.GetContentAtPos( aDocPt, aCntntAtPos, TRUE ) )
+ {
+ BOOL bViewLocked = rSh.IsViewLocked();
+ if( !bViewLocked && !rSh.IsReadOnlyAvailable() &&
+ aCntntAtPos.IsInProtectSect() )
+ rSh.LockView( TRUE );
+
+ ReleaseMouse();
+
+ if( SwContentAtPos::SW_FIELD == aCntntAtPos.eCntntAtPos )
+ {
+ rSh.ClickToField( *aCntntAtPos.aFnd.pFld );
+ }
+ else if ( SwContentAtPos::SW_SMARTTAG == aCntntAtPos.eCntntAtPos )
+ {
+ // execute smarttag menu
+ if ( bExecSmarttags && SwSmartTagMgr::Get().IsSmartTagsEnabled() )
+ rView.ExecSmartTagPopup( aDocPt );
+ }
+ else if ( SwContentAtPos::SW_FORMCTRL == aCntntAtPos.eCntntAtPos )
+ {
+ ASSERT( aCntntAtPos.aFnd.pFldmark != NULL, "where is my field ptr???");
+ if ( aCntntAtPos.aFnd.pFldmark != NULL)
+ {
+ IFieldmark *fieldBM = const_cast< IFieldmark* > ( aCntntAtPos.aFnd.pFldmark );
+ //SwDocShell* pDocSh = rView.GetDocShell();
+ //SwDoc *pDoc=pDocSh->GetDoc();
+ if (fieldBM->GetFieldname( ).equalsAscii( ODF_FORMCHECKBOX ) )
+ {
+ ICheckboxFieldmark* pCheckboxFm = dynamic_cast<ICheckboxFieldmark*>(fieldBM);
+ pCheckboxFm->SetChecked(!pCheckboxFm->IsChecked());
+ pCheckboxFm->Invalidate();
+ rSh.InvalidateWindows( rView.GetVisArea() );
+ } else if (fieldBM->GetFieldname().equalsAscii( ODF_FORMDROPDOWN) ) {
+ rView.ExecFieldPopup( aDocPt, fieldBM );
+ fieldBM->Invalidate();
+ rSh.InvalidateWindows( rView.GetVisArea() );
+ } else {
+ // unknown type..
+ }
+ }
+ }
+ else // if ( SwContentAtPos::SW_INETATTR == aCntntAtPos.eCntntAtPos )
+ {
+ if ( bExecHyperlinks )
+ rSh.ClickToINetAttr( *(SwFmtINetFmt*)aCntntAtPos.aFnd.pAttr, nFilter );
+ }
+
+ rSh.LockView( bViewLocked );
+ bCallShadowCrsr = FALSE;
+ }
+ else
+ {
+ aCntntAtPos = SwContentAtPos( SwContentAtPos::SW_FTN );
+ if( !rSh.GetContentAtPos( aDocPt, aCntntAtPos, TRUE ) && bExecHyperlinks )
+ {
+ SdrViewEvent aVEvt;
+
+ if (pSdrView)
+ pSdrView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
+
+ if (pSdrView && aVEvt.eEvent == SDREVENT_EXECUTEURL)
+ {
+ // URL-Feld getroffen
+ const SvxURLField *pField = aVEvt.pURLField;
+ if (pField)
+ {
+ String sURL(pField->GetURL());
+ String sTarget(pField->GetTargetFrame());
+ ::LoadURL( sURL, &rSh, nFilter, &sTarget);
+ }
+ bCallShadowCrsr = FALSE;
+ }
+ else
+ {
+ // Grafik getroffen
+ ReleaseMouse();
+ if( rSh.ClickToINetGrf( aDocPt, nFilter ))
+ bCallShadowCrsr = FALSE;
+ }
+ }
+ }
+
+ if( bCallShadowCrsr &&
+ rSh.GetViewOptions()->IsShadowCursor() &&
+ MOUSE_LEFT == (rMEvt.GetModifier() + rMEvt.GetButtons()) &&
+ !rSh.HasSelection() &&
+ !GetConnectMetaFile() &&
+ rSh.VisArea().IsInside( aDocPt ))
+ {
+ if( UNDO_INS_FROM_SHADOWCRSR == rSh.GetUndoIds() )
+ rSh.Undo();
+ SwFillMode eMode = (SwFillMode)rSh.GetViewOptions()->GetShdwCrsrFillMode();
+ rSh.SetShadowCrsrPos( aDocPt, eMode );
+ }
+ }
+ }
+ bCallBase = FALSE;
+
+ }
+
+ // gfs. im Down gepushten Mode wieder zuruecksetzen
+ if ( bPopMode && bModePushed )
+ {
+ rSh.PopMode();
+ bModePushed = FALSE;
+ bCallBase = FALSE;
+ }
+ break;
+
+ default:
+ ReleaseMouse();
+ return;
+ }
+
+ if( pApplyTempl )
+ {
+ int eSelection = rSh.GetSelectionType();
+ SwFormatClipboard* pFormatClipboard = pApplyTempl->pFormatClipboard;
+ if( pFormatClipboard )//apply format paintbrush
+ {
+ //get some parameters
+ SwWrtShell& rWrtShell = rView.GetWrtShell();
+ SfxStyleSheetBasePool* pPool=0;
+ bool bNoCharacterFormats = false;
+ bool bNoParagraphFormats = false;
+ {
+ SwDocShell* pDocSh = rView.GetDocShell();
+ if(pDocSh)
+ pPool = pDocSh->GetStyleSheetPool();
+ if( (rMEvt.GetModifier()&KEY_MOD1) && (rMEvt.GetModifier()&KEY_SHIFT) )
+ bNoCharacterFormats = true;
+ else if( rMEvt.GetModifier() & KEY_MOD1 )
+ bNoParagraphFormats = true;
+ }
+ //execute paste
+ pFormatClipboard->Paste( rWrtShell, pPool, bNoCharacterFormats, bNoParagraphFormats );
+
+ //if the clipboard is empty after paste remove the ApplyTemplate
+ if(!pFormatClipboard->HasContent())
+ SetApplyTemplate(SwApplyTemplate());
+ }
+ else if( pApplyTempl->nColor )
+ {
+ USHORT nId = 0;
+ switch( pApplyTempl->nColor )
+ {
+ case SID_ATTR_CHAR_COLOR_EXT:
+ nId = RES_CHRATR_COLOR;
+ break;
+ case SID_ATTR_CHAR_COLOR_BACKGROUND_EXT:
+ nId = RES_CHRATR_BACKGROUND;
+ break;
+ }
+ if( nId && (nsSelectionType::SEL_TXT|nsSelectionType::SEL_TBL) & eSelection)
+ {
+ if( rSh.IsSelection() && !rSh.HasReadonlySel() )
+ {
+ if(nId == RES_CHRATR_BACKGROUND)
+ {
+ Color aColor( COL_TRANSPARENT );
+ if( !SwEditWin::bTransparentBackColor )
+ aColor = SwEditWin::aTextBackColor;
+ rSh.SetAttr( SvxBrushItem( aColor, nId ) );
+ }
+ else
+ rSh.SetAttr( SvxColorItem(SwEditWin::aTextColor, nId) );
+ rSh.UnSetVisCrsr();
+ rSh.EnterStdMode();
+ rSh.SetVisCrsr(aDocPt);
+
+ pApplyTempl->bUndo = TRUE;
+ bCallBase = FALSE;
+ aTemplateTimer.Stop();
+ }
+ else if(rMEvt.GetClicks() == 1)
+ {
+ // keine Selektion -> also Giesskanne abschalten
+ aTemplateTimer.Start();
+ }
+ }
+ }
+ else
+ {
+ String aStyleName;
+ switch ( pApplyTempl->eType )
+ {
+ case SFX_STYLE_FAMILY_PARA:
+ if( (( nsSelectionType::SEL_TXT | nsSelectionType::SEL_TBL )
+ & eSelection ) && !rSh.HasReadonlySel() )
+ {
+ rSh.SetTxtFmtColl( pApplyTempl->aColl.pTxtColl );
+ pApplyTempl->bUndo = TRUE;
+ bCallBase = FALSE;
+ if ( pApplyTempl->aColl.pTxtColl )
+ aStyleName = pApplyTempl->aColl.pTxtColl->GetName();
+ }
+ break;
+ case SFX_STYLE_FAMILY_CHAR:
+ if( (( nsSelectionType::SEL_TXT | nsSelectionType::SEL_TBL )
+ & eSelection ) && !rSh.HasReadonlySel() )
+ {
+ rSh.SetAttr( SwFmtCharFmt(pApplyTempl->aColl.pCharFmt) );
+ rSh.UnSetVisCrsr();
+ rSh.EnterStdMode();
+ rSh.SetVisCrsr(aDocPt);
+ pApplyTempl->bUndo = TRUE;
+ bCallBase = FALSE;
+ if ( pApplyTempl->aColl.pCharFmt )
+ aStyleName = pApplyTempl->aColl.pCharFmt->GetName();
+ }
+ break;
+ case SFX_STYLE_FAMILY_FRAME :
+ {
+ const SwFrmFmt* pFmt = rSh.GetFmtFromObj( aDocPt );
+ if(PTR_CAST(SwFlyFrmFmt, pFmt))
+ {
+ rSh.SetFrmFmt( pApplyTempl->aColl.pFrmFmt, FALSE, &aDocPt );
+ pApplyTempl->bUndo = TRUE;
+ bCallBase = FALSE;
+ if( pApplyTempl->aColl.pFrmFmt )
+ aStyleName = pApplyTempl->aColl.pFrmFmt->GetName();
+ }
+ break;
+ }
+ case SFX_STYLE_FAMILY_PAGE:
+ // Kein Undo bei Seitenvorlagen
+ rSh.ChgCurPageDesc( *pApplyTempl->aColl.pPageDesc );
+ if ( pApplyTempl->aColl.pPageDesc )
+ aStyleName = pApplyTempl->aColl.pPageDesc->GetName();
+ bCallBase = FALSE;
+ break;
+ case SFX_STYLE_FAMILY_PSEUDO:
+ if( !rSh.HasReadonlySel() )
+ {
+ // --> OD 2008-03-17 #refactorlists#
+ rSh.SetCurNumRule( *pApplyTempl->aColl.pNumRule,
+ false,
+ pApplyTempl->aColl.pNumRule->GetDefaultListId() );
+ // <--
+ bCallBase = FALSE;
+ pApplyTempl->bUndo = TRUE;
+ if( pApplyTempl->aColl.pNumRule )
+ aStyleName = pApplyTempl->aColl.pNumRule->GetName();
+ }
+ break;
+ }
+
+ uno::Reference< frame::XDispatchRecorder > xRecorder =
+ rView.GetViewFrame()->GetBindings().GetRecorder();
+ if ( aStyleName.Len() && xRecorder.is() )
+ {
+ SfxShell *pSfxShell = lcl_GetShellFromDispatcher( rView, TYPE(SwTextShell) );
+ if ( pSfxShell )
+ {
+ SfxRequest aReq( rView.GetViewFrame(), SID_STYLE_APPLY );
+ aReq.AppendItem( SfxStringItem( SID_STYLE_APPLY, aStyleName ) );
+ aReq.AppendItem( SfxUInt16Item( SID_STYLE_FAMILY, (USHORT) pApplyTempl->eType ) );
+ aReq.Done();
+ }
+ }
+ }
+
+ }
+ ReleaseMouse();
+ // Hier kommen nur verarbeitete MouseEvents an; nur bei diesen duerfen
+ // die Modi zurueckgesetzt werden.
+ bMBPressed = FALSE;
+
+ //sicherheitshalber aufrufen, da jetzt das Selektieren bestimmt zu Ende ist.
+ //Andernfalls koennte der Timeout des Timers Kummer machen.
+ EnterArea();
+ bNoInterrupt = FALSE;
+
+ if (bCallBase)
+ Window::MouseButtonUp(rMEvt);
+}
+
+
+/*--------------------------------------------------------------------
+ Beschreibung: Vorlage anwenden
+ --------------------------------------------------------------------*/
+
+
+void SwEditWin::SetApplyTemplate(const SwApplyTemplate &rTempl)
+{
+ static BOOL bIdle = FALSE;
+ DELETEZ(pApplyTempl);
+ SwWrtShell &rSh = rView.GetWrtShell();
+
+ if(rTempl.pFormatClipboard)
+ {
+ pApplyTempl = new SwApplyTemplate( rTempl );
+ SetPointer( POINTER_FILL );//@todo #i20119# maybe better a new brush pointer here in future
+ rSh.NoEdit( FALSE );
+ bIdle = rSh.GetViewOptions()->IsIdle();
+ ((SwViewOption *)rSh.GetViewOptions())->SetIdle( FALSE );
+ }
+ else if(rTempl.nColor)
+ {
+ pApplyTempl = new SwApplyTemplate( rTempl );
+ SetPointer( POINTER_FILL );
+ rSh.NoEdit( FALSE );
+ bIdle = rSh.GetViewOptions()->IsIdle();
+ ((SwViewOption *)rSh.GetViewOptions())->SetIdle( FALSE );
+ }
+ else if( rTempl.eType )
+ {
+ pApplyTempl = new SwApplyTemplate( rTempl );
+ SetPointer( POINTER_FILL );
+ rSh.NoEdit( FALSE );
+ bIdle = rSh.GetViewOptions()->IsIdle();
+ ((SwViewOption *)rSh.GetViewOptions())->SetIdle( FALSE );
+ }
+ else
+ {
+ SetPointer( POINTER_TEXT );
+ rSh.UnSetVisCrsr();
+
+ ((SwViewOption *)rSh.GetViewOptions())->SetIdle( bIdle );
+ if ( !rSh.IsSelFrmMode() )
+ rSh.Edit();
+ }
+
+ static USHORT __READONLY_DATA aInva[] =
+ {
+ SID_STYLE_WATERCAN,
+ SID_ATTR_CHAR_COLOR_EXT,
+ SID_ATTR_CHAR_COLOR_BACKGROUND_EXT,
+ 0
+ };
+ rView.GetViewFrame()->GetBindings().Invalidate(aInva);
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: ctor
+ --------------------------------------------------------------------*/
+
+
+SwEditWin::SwEditWin(Window *pParent, SwView &rMyView):
+ Window(pParent, WinBits(WB_CLIPCHILDREN | WB_DIALOGCONTROL)),
+ DropTargetHelper( this ),
+ DragSourceHelper( this ),
+
+ eBufferLanguage(LANGUAGE_DONTKNOW),
+ pApplyTempl(0),
+ pAnchorMarker( 0 ),
+ pUserMarker( 0 ),
+ pUserMarkerObj( 0 ),
+ pShadCrsr( 0 ),
+ pRowColumnSelectionStart( 0 ),
+
+ rView( rMyView ),
+
+ aActHitType(SDRHIT_NONE),
+ m_nDropFormat( 0 ),
+ m_nDropAction( 0 ),
+ m_nDropDestination( 0 ),
+
+ nInsFrmColCount( 1 ),
+ eDrawMode(OBJ_NONE),
+
+ bLockInput(FALSE),
+ bObjectSelect( FALSE ),
+ nKS_NUMDOWN_Count(0), // #i23725#
+ nKS_NUMINDENTINC_Count(0) // #i23725#
+{
+ SetHelpId(HID_EDIT_WIN);
+ EnableChildTransparentMode();
+ SetDialogControlFlags( WINDOW_DLGCTRL_RETURN | WINDOW_DLGCTRL_WANTFOCUS );
+
+ bLinkRemoved = bMBPressed = bInsDraw = bInsFrm =
+ bIsInDrag = bOldIdle = bOldIdleSet = bChainMode = bWasShdwCrsr = FALSE;
+ //#i42732# initially use the input language
+ bUseInputLanguage = sal_True;
+
+ SetMapMode(MapMode(MAP_TWIP));
+
+ SetPointer( POINTER_TEXT );
+ aTimer.SetTimeoutHdl(LINK(this, SwEditWin, TimerHandler));
+
+ bTblInsDelMode = FALSE;
+ aKeyInputTimer.SetTimeout( 3000 );
+ aKeyInputTimer.SetTimeoutHdl(LINK(this, SwEditWin, KeyInputTimerHandler));
+
+ aKeyInputFlushTimer.SetTimeout( 200 );
+ aKeyInputFlushTimer.SetTimeoutHdl(LINK(this, SwEditWin, KeyInputFlushHandler));
+
+ // TemplatePointer fuer Farben soll nach Einfachclick
+ // ohne Selektion zurueckgesetzt werden
+ aTemplateTimer.SetTimeout(400);
+ aTemplateTimer.SetTimeoutHdl(LINK(this, SwEditWin, TemplateTimerHdl));
+
+ //JP 16.12.98: temporaere Loesung!!! Sollte bei jeder Cursorbewegung
+ // den Font von der akt. einfuege Position setzen!
+ if( !rMyView.GetDocShell()->IsReadOnly() )
+ {
+ Font aFont;
+ SetInputContext( InputContext( aFont, INPUTCONTEXT_TEXT |
+ INPUTCONTEXT_EXTTEXTINPUT ) );
+ }
+}
+
+
+
+SwEditWin::~SwEditWin()
+{
+ aKeyInputTimer.Stop();
+ delete pShadCrsr;
+ delete pRowColumnSelectionStart;
+ if( pQuickHlpData->bClear && rView.GetWrtShellPtr() )
+ pQuickHlpData->Stop( rView.GetWrtShell() );
+ bExecuteDrag = FALSE;
+ delete pApplyTempl;
+ rView.SetDrawFuncPtr(NULL);
+
+ if(pUserMarker)
+ {
+ delete pUserMarker;
+ }
+
+ delete pAnchorMarker;
+}
+
+
+/******************************************************************************
+ * Beschreibung: DrawTextEditMode einschalten
+ ******************************************************************************/
+
+
+void SwEditWin::EnterDrawTextMode( const Point& aDocPos )
+{
+ if ( rView.EnterDrawTextMode(aDocPos) == TRUE )
+ {
+ if (rView.GetDrawFuncPtr())
+ {
+ rView.GetDrawFuncPtr()->Deactivate();
+ rView.SetDrawFuncPtr(NULL);
+ rView.LeaveDrawCreate();
+ }
+ rView.NoRotate();
+ rView.AttrChangedNotify( &rView.GetWrtShell() );
+ }
+}
+
+/******************************************************************************
+ * Beschreibung: DrawMode einschalten
+ ******************************************************************************/
+
+
+
+BOOL SwEditWin::EnterDrawMode(const MouseEvent& rMEvt, const Point& aDocPos)
+{
+ SwWrtShell &rSh = rView.GetWrtShell();
+ SdrView *pSdrView = rSh.GetDrawView();
+
+// if ( GetDrawFuncPtr() && (aActHitType == SDRHIT_NONE || rSh.IsDrawCreate()) )
+ if ( rView.GetDrawFuncPtr() )
+ {
+ if (rSh.IsDrawCreate())
+ return TRUE;
+
+ BOOL bRet = rView.GetDrawFuncPtr()->MouseButtonDown( rMEvt );
+ rView.AttrChangedNotify( &rSh );
+ return bRet;
+ }
+
+ if ( pSdrView && pSdrView->IsTextEdit() )
+ {
+ BOOL bUnLockView = !rSh.IsViewLocked();
+ rSh.LockView( TRUE );
+
+ rSh.EndTextEdit(); // Danebengeklickt, Ende mit Edit
+ rSh.SelectObj( aDocPos );
+ if ( !rSh.IsObjSelected() && !rSh.IsFrmSelected() )
+ rSh.LeaveSelFrmMode();
+ else
+ {
+ SwEditWin::nDDStartPosY = aDocPos.Y();
+ SwEditWin::nDDStartPosX = aDocPos.X();
+ bFrmDrag = TRUE;
+ }
+ if( bUnLockView )
+ rSh.LockView( FALSE );
+ rView.AttrChangedNotify( &rSh );
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/******************************************************************************
+ * Beschreibung:
+ ******************************************************************************/
+
+
+
+BOOL SwEditWin::IsDrawSelMode()
+{
+// return (IsFrmAction() == FALSE && GetSdrDrawMode() == OBJ_NONE);
+ return IsObjectSelect();
+}
+
+/******************************************************************************
+ * Beschreibung:
+ ******************************************************************************/
+
+
+void SwEditWin::GetFocus()
+{
+ if ( rView.GetPostItMgr()->HasActiveSidebarWin() )
+ {
+ rView.GetPostItMgr()->GrabFocusOnActiveSidebarWin();
+ }
+ else
+ {
+ rView.GotFocus();
+ Window::GetFocus();
+ rView.GetWrtShell().InvalidateAccessibleFocus();
+ }
+}
+
+/******************************************************************************
+ * Beschreibung:
+ ******************************************************************************/
+
+
+
+void SwEditWin::LoseFocus()
+{
+ rView.GetWrtShell().InvalidateAccessibleFocus();
+ Window::LoseFocus();
+ if( pQuickHlpData->bClear )
+ pQuickHlpData->Stop( rView.GetWrtShell() );
+ rView.LostFocus();
+}
+
+/******************************************************************************
+ * Beschreibung:
+ ******************************************************************************/
+
+
+
+void SwEditWin::Command( const CommandEvent& rCEvt )
+{
+ SwWrtShell &rSh = rView.GetWrtShell();
+
+ if ( !rView.GetViewFrame() )
+ {
+ //Wenn der ViewFrame in Kuerze stirbt kein Popup mehr!
+ Window::Command(rCEvt);
+ return;
+ }
+
+ // The command event is send to the window after a possible context
+ // menu from an inplace client has been closed. Now we have the chance
+ // to deactivate the inplace client without any problem regarding parent
+ // windows and code on the stack.
+ // For more information, see #126086# and #128122#
+ SfxInPlaceClient* pIPClient = rSh.GetSfxViewShell()->GetIPClient();
+ BOOL bIsOleActive = ( pIPClient && pIPClient->IsObjectInPlaceActive() );
+ if ( bIsOleActive && ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU ))
+ {
+ rSh.FinishOLEObj();
+ return;
+ }
+
+ BOOL bCallBase = TRUE;
+
+ switch ( rCEvt.GetCommand() )
+ {
+ case COMMAND_CONTEXTMENU:
+ {
+ const USHORT nId = SwInputChild::GetChildWindowId();
+ SwInputChild* pChildWin = (SwInputChild*)GetView().GetViewFrame()->
+ GetChildWindow( nId );
+
+ if (rView.GetPostItMgr()->IsHit(rCEvt.GetMousePosPixel()))
+ return;
+
+ if((!pChildWin || pChildWin->GetView() != &rView) &&
+ !rSh.IsDrawCreate() && !IsDrawAction())
+ {
+ SET_CURR_SHELL( &rSh );
+ if (!pApplyTempl)
+ {
+ if (bNoInterrupt == TRUE)
+ {
+ ReleaseMouse();
+ bNoInterrupt = FALSE;
+ bMBPressed = FALSE;
+ }
+ Point aDocPos( PixelToLogic( rCEvt.GetMousePosPixel() ) );
+ if ( !rCEvt.IsMouseEvent() )
+ aDocPos = rSh.GetCharRect().Center();
+ else
+ {
+ SelectMenuPosition(rSh, rCEvt.GetMousePosPixel());
+ rView.StopShellTimer();
+
+ }
+ const Point aPixPos = LogicToPixel( aDocPos );
+
+ if ( rView.GetDocShell()->IsReadOnly() )
+ {
+ SwReadOnlyPopup* pROPopup = new SwReadOnlyPopup( aDocPos, rView );
+
+ ui::ContextMenuExecuteEvent aEvent;
+ aEvent.SourceWindow = VCLUnoHelper::GetInterface( this );
+ aEvent.ExecutePosition.X = aPixPos.X();
+ aEvent.ExecutePosition.Y = aPixPos.Y();
+ Menu* pMenu = 0;
+ ::rtl::OUString sMenuName =
+ ::rtl::OUString::createFromAscii( "private:resource/ReadonlyContextMenu");
+ if( GetView().TryContextMenuInterception( *pROPopup, sMenuName, pMenu, aEvent ) )
+ {
+ if ( pMenu )
+ {
+ USHORT nExecId = ((PopupMenu*)pMenu)->Execute(this, aPixPos);
+ if( !::ExecuteMenuCommand( *static_cast<PopupMenu*>(pMenu), *rView.GetViewFrame(), nExecId ))
+ pROPopup->Execute(this, nExecId);
+ }
+ else
+ pROPopup->Execute(this, aPixPos);
+ }
+ delete pROPopup;
+ }
+ else if ( !rView.ExecSpellPopup( aDocPos ) )
+ GetView().GetViewFrame()->GetDispatcher()->ExecutePopup( 0, this, &aPixPos);
+ }
+ else if (pApplyTempl->bUndo)
+ rSh.Do(SwWrtShell::UNDO);
+ bCallBase = FALSE;
+ }
+ }
+ break;
+
+ case COMMAND_WHEEL:
+ case COMMAND_STARTAUTOSCROLL:
+ case COMMAND_AUTOSCROLL:
+ if( pShadCrsr )
+ delete pShadCrsr, pShadCrsr = 0;
+ bCallBase = !rView.HandleWheelCommands( rCEvt );
+ break;
+
+ case COMMAND_VOICE:
+ {
+ //ggf. an Outliner weiterleiten
+ if ( rSh.HasDrawView() && rSh.GetDrawView()->IsTextEdit() )
+ {
+ bCallBase = FALSE;
+ rSh.GetDrawView()->GetTextEditOutlinerView()->Command( rCEvt );
+ break;
+ }
+
+ const CommandVoiceData *pCData = rCEvt.GetVoiceData();
+ if ( VOICECOMMANDTYPE_CONTROL == pCData->GetType() )
+ break;
+
+
+ USHORT nSlotId = 0;
+ SfxPoolItem *pItem = 0;
+
+ switch ( pCData->GetCommand() )
+ {
+ case DICTATIONCOMMAND_NEWPARAGRAPH: nSlotId = FN_INSERT_BREAK; break;
+ case DICTATIONCOMMAND_NEWLINE: nSlotId = FN_INSERT_LINEBREAK; break;
+ case DICTATIONCOMMAND_LEFT: nSlotId = FN_PREV_WORD; break;
+ case DICTATIONCOMMAND_RIGHT: nSlotId = FN_NEXT_WORD; break;
+ case DICTATIONCOMMAND_UP: nSlotId = FN_LINE_UP; break;
+ case DICTATIONCOMMAND_DOWN: nSlotId = FN_LINE_DOWN; break;
+ case DICTATIONCOMMAND_UNDO: nSlotId = SID_UNDO; break;
+ case DICTATIONCOMMAND_REPEAT: nSlotId = SID_REPEAT; break;
+ case DICTATIONCOMMAND_DEL: nSlotId = FN_DELETE_BACK_WORD; break;
+
+ case DICTATIONCOMMAND_BOLD_ON: nSlotId = SID_ATTR_CHAR_WEIGHT;
+ pItem = new SvxWeightItem( WEIGHT_BOLD, RES_CHRATR_WEIGHT );
+ break;
+ case DICTATIONCOMMAND_BOLD_OFF: nSlotId = SID_ATTR_CHAR_WEIGHT;
+ pItem = new SvxWeightItem( WEIGHT_NORMAL, RES_CHRATR_WEIGHT );
+ break;
+ case DICTATIONCOMMAND_UNDERLINE_ON: nSlotId = SID_ATTR_CHAR_UNDERLINE;
+ pItem = new SvxUnderlineItem( UNDERLINE_SINGLE, RES_CHRATR_WEIGHT );
+ break;
+ case DICTATIONCOMMAND_UNDERLINE_OFF:nSlotId = SID_ATTR_CHAR_UNDERLINE;
+ pItem = new SvxUnderlineItem( UNDERLINE_NONE, RES_CHRATR_UNDERLINE );
+ break;
+ case DICTATIONCOMMAND_ITALIC_ON: nSlotId = SID_ATTR_CHAR_POSTURE;
+ pItem = new SvxPostureItem( ITALIC_NORMAL, RES_CHRATR_POSTURE );
+ break;
+ case DICTATIONCOMMAND_ITALIC_OFF: nSlotId = SID_ATTR_CHAR_POSTURE;
+ pItem = new SvxPostureItem( ITALIC_NONE, RES_CHRATR_POSTURE );
+ break;
+ case DICTATIONCOMMAND_NUMBERING_ON:
+ if ( !rSh.GetCurNumRule() )
+ nSlotId = FN_NUM_NUMBERING_ON;
+ break;
+ case DICTATIONCOMMAND_NUMBERING_OFF:
+ if ( rSh.GetCurNumRule() )
+ nSlotId = FN_NUM_NUMBERING_ON;
+ break;
+ case DICTATIONCOMMAND_TAB:
+ {
+ rSh.Insert( '\t' );
+ }
+ break;
+ case DICTATIONCOMMAND_UNKNOWN:
+ {
+ rView.GetWrtShell().Insert( pCData->GetText() );
+ }
+ break;
+
+#ifdef DBG_UTIL
+ default:
+ ASSERT( !this, "unknown speech command." );
+#endif
+ }
+ if ( nSlotId )
+ {
+ bCallBase = FALSE;
+ if ( pItem )
+ {
+ const SfxPoolItem* aArgs[2];
+ aArgs[0] = pItem;
+ aArgs[1] = 0;
+ GetView().GetViewFrame()->GetBindings().Execute(
+ nSlotId, aArgs, 0, SFX_CALLMODE_STANDARD );
+ delete pItem;
+ }
+ else
+ GetView().GetViewFrame()->GetBindings().Execute( nSlotId );
+ }
+ }
+ break;
+
+ case COMMAND_STARTEXTTEXTINPUT:
+ {
+ BOOL bIsDocReadOnly = rView.GetDocShell()->IsReadOnly() &&
+ rSh.IsCrsrReadonly();
+ if(!bIsDocReadOnly)
+ {
+ if( rSh.HasDrawView() && rSh.GetDrawView()->IsTextEdit() )
+ {
+ bCallBase = FALSE;
+ rSh.GetDrawView()->GetTextEditOutlinerView()->Command( rCEvt );
+ }
+ else
+ {
+ if( rSh.HasSelection() )
+ rSh.DelRight();
+
+ bCallBase = FALSE;
+ LanguageType eInputLanguage = GetInputLanguage();
+ rSh.CreateExtTextInput(eInputLanguage);
+ }
+ }
+ break;
+ }
+ case COMMAND_ENDEXTTEXTINPUT:
+ {
+ BOOL bIsDocReadOnly = rView.GetDocShell()->IsReadOnly() &&
+ rSh.IsCrsrReadonly();
+ if(!bIsDocReadOnly)
+ {
+ if( rSh.HasDrawView() && rSh.GetDrawView()->IsTextEdit() )
+ {
+ bCallBase = FALSE;
+ rSh.GetDrawView()->GetTextEditOutlinerView()->Command( rCEvt );
+ }
+ else
+ {
+ bCallBase = FALSE;
+ String sRecord = rSh.DeleteExtTextInput();
+ uno::Reference< frame::XDispatchRecorder > xRecorder =
+ rView.GetViewFrame()->GetBindings().GetRecorder();
+
+ if ( sRecord.Len() )
+ {
+ // #102812# convert quotes in IME text
+ // works on the last input character, this is escpecially in Korean text often done
+ // quotes that are inside of the string are not replaced!
+ const sal_Unicode aCh = sRecord.GetChar(sRecord.Len() - 1);
+ SvxAutoCorrCfg* pACfg = SvxAutoCorrCfg::Get();
+ SvxAutoCorrect* pACorr = pACfg->GetAutoCorrect();
+ if(pACorr &&
+ (( pACorr->IsAutoCorrFlag( ChgQuotes ) && ('\"' == aCh ))||
+ ( pACorr->IsAutoCorrFlag( ChgSglQuotes ) && ( '\'' == aCh))))
+ {
+ rSh.DelLeft();
+ rSh.AutoCorrect( *pACorr, aCh );
+ }
+
+ if ( xRecorder.is() )
+ {
+ //Shell ermitteln
+ SfxShell *pSfxShell = lcl_GetShellFromDispatcher( rView, TYPE(SwTextShell) );
+ // Request generieren und recorden
+ if (pSfxShell)
+ {
+ SfxRequest aReq( rView.GetViewFrame(), FN_INSERT_STRING );
+ aReq.AppendItem( SfxStringItem( FN_INSERT_STRING, sRecord ) );
+ aReq.Done();
+ }
+ }
+ }
+ }
+ }
+ }
+ break;
+ case COMMAND_EXTTEXTINPUT:
+ {
+ BOOL bIsDocReadOnly = rView.GetDocShell()->IsReadOnly() &&
+ rSh.IsCrsrReadonly();
+ if(!bIsDocReadOnly)
+ {
+ QuickHelpData aTmpQHD;
+ if( pQuickHlpData->bClear )
+ {
+ aTmpQHD.Move( *pQuickHlpData );
+ pQuickHlpData->Stop( rSh );
+ }
+ String sWord;
+ if( rSh.HasDrawView() && rSh.GetDrawView()->IsTextEdit() )
+ {
+ bCallBase = FALSE;
+ rSh.GetDrawView()->GetTextEditOutlinerView()->Command( rCEvt );
+ }
+ else
+ {
+ const CommandExtTextInputData* pData = rCEvt.GetExtTextInputData();
+ if( pData )
+ {
+ sWord = pData->GetText();
+ bCallBase = FALSE;
+ rSh.SetExtTextInputData( *pData );
+ }
+ }
+ uno::Reference< frame::XDispatchRecorder > xRecorder =
+ rView.GetViewFrame()->GetBindings().GetRecorder();
+ if(!xRecorder.is())
+ {
+ SvxAutoCorrCfg* pACfg = SvxAutoCorrCfg::Get();
+ SvxAutoCorrect* pACorr = pACfg->GetAutoCorrect();
+ if( pACfg && pACorr &&
+ ( pACfg->IsAutoTextTip() ||
+ pACorr->GetSwFlags().bAutoCompleteWords ) &&
+ rSh.GetPrevAutoCorrWord( *pACorr, sWord ) )
+ {
+ ShowAutoTextCorrectQuickHelp(sWord, pACfg, pACorr, sal_True);
+ }
+ }
+ }
+ }
+ break;
+ case COMMAND_CURSORPOS:
+ // will be handled by the base class
+ break;
+
+ case COMMAND_PASTESELECTION:
+ if( !rView.GetDocShell()->IsReadOnly() )
+ {
+ TransferableDataHelper aDataHelper(
+ TransferableDataHelper::CreateFromSelection( this ));
+ if( !aDataHelper.GetXTransferable().is() )
+ break;
+
+ ULONG nDropFormat;
+ USHORT nEventAction, nDropAction, nDropDestination;
+ nDropDestination = GetDropDestination( rCEvt.GetMousePosPixel() );
+ if( !nDropDestination )
+ break;
+
+ nDropAction = SotExchange::GetExchangeAction(
+ aDataHelper.GetDataFlavorExVector(),
+ nDropDestination, EXCHG_IN_ACTION_COPY,
+ EXCHG_IN_ACTION_COPY, nDropFormat,
+ nEventAction );
+ if( EXCHG_INOUT_ACTION_NONE != nDropAction )
+ {
+ const Point aDocPt( PixelToLogic( rCEvt.GetMousePosPixel() ) );
+ SwTransferable::PasteData( aDataHelper, rSh, nDropAction,
+ nDropFormat, nDropDestination, FALSE,
+ FALSE, &aDocPt, EXCHG_IN_ACTION_COPY,
+ TRUE );
+ }
+ }
+ break;
+ case COMMAND_MODKEYCHANGE :
+ {
+ const CommandModKeyData* pCommandData = (const CommandModKeyData*)rCEvt.GetData();
+ if(pCommandData->IsMod1() && !pCommandData->IsMod2())
+ {
+ USHORT nSlot = 0;
+ if(pCommandData->IsLeftShift() && !pCommandData->IsRightShift())
+ nSlot = SID_ATTR_PARA_LEFT_TO_RIGHT;
+ else if(!pCommandData->IsLeftShift() && pCommandData->IsRightShift())
+ nSlot = SID_ATTR_PARA_RIGHT_TO_LEFT;
+ if(nSlot && SW_MOD()->GetCTLOptions().IsCTLFontEnabled())
+ GetView().GetViewFrame()->GetDispatcher()->Execute(nSlot);
+ }
+ }
+ break;
+ case COMMAND_HANGUL_HANJA_CONVERSION :
+ GetView().GetViewFrame()->GetDispatcher()->Execute(SID_HANGUL_HANJA_CONVERSION);
+ break;
+ case COMMAND_INPUTLANGUAGECHANGE :
+ //#i42732# update state of fontname if input language changes
+ bInputLanguageSwitched = true;
+ SetUseInputLanguage( sal_True );
+ break;
+ case COMMAND_SELECTIONCHANGE:
+ {
+ const CommandSelectionChangeData *pData = rCEvt.GetSelectionChangeData();
+ rSh.SttCrsrMove();
+ rSh.GoStartSentence();
+ rSh.GetCrsr()->GetPoint()->nContent += sal::static_int_cast<sal_uInt16, ULONG>(pData->GetStart());
+ rSh.SetMark();
+ rSh.GetCrsr()->GetMark()->nContent += sal::static_int_cast<sal_uInt16, ULONG>(pData->GetEnd() - pData->GetStart());
+ rSh.EndCrsrMove( TRUE );
+ }
+ break;
+ case COMMAND_PREPARERECONVERSION:
+ if( rSh.HasSelection() )
+ {
+ SwPaM *pCrsr = (SwPaM*)rSh.GetCrsr();
+
+ if( rSh.IsMultiSelection() )
+ {
+ if( pCrsr && !pCrsr->HasMark() &&
+ pCrsr->GetPoint() == pCrsr->GetMark() )
+ {
+ rSh.GoPrevCrsr();
+ pCrsr = (SwPaM*)rSh.GetCrsr();
+ }
+
+ // Cancel all selections other than the last selected one.
+ while( rSh.GetCrsr()->GetNext() != rSh.GetCrsr() )
+ delete rSh.GetCrsr()->GetNext();
+ }
+
+ if( pCrsr )
+ {
+ ULONG nPosNodeIdx = pCrsr->GetPoint()->nNode.GetIndex();
+ xub_StrLen nPosIdx = pCrsr->GetPoint()->nContent.GetIndex();
+ ULONG nMarkNodeIdx = pCrsr->GetMark()->nNode.GetIndex();
+ xub_StrLen nMarkIdx = pCrsr->GetMark()->nContent.GetIndex();
+
+ if( !rSh.GetCrsr()->HasMark() )
+ rSh.GetCrsr()->SetMark();
+
+ rSh.SttCrsrMove();
+
+ if( nPosNodeIdx < nMarkNodeIdx )
+ {
+ rSh.GetCrsr()->GetPoint()->nNode = nPosNodeIdx;
+ rSh.GetCrsr()->GetPoint()->nContent = nPosIdx;
+ rSh.GetCrsr()->GetMark()->nNode = nPosNodeIdx;
+ rSh.GetCrsr()->GetMark()->nContent =
+ rSh.GetCrsr()->GetCntntNode( TRUE )->Len();
+ }
+ else if( nPosNodeIdx == nMarkNodeIdx )
+ {
+ rSh.GetCrsr()->GetPoint()->nNode = nPosNodeIdx;
+ rSh.GetCrsr()->GetPoint()->nContent = nPosIdx;
+ rSh.GetCrsr()->GetMark()->nNode = nMarkNodeIdx;
+ rSh.GetCrsr()->GetMark()->nContent = nMarkIdx;
+ }
+ else
+ {
+ rSh.GetCrsr()->GetMark()->nNode = nMarkNodeIdx;
+ rSh.GetCrsr()->GetMark()->nContent = nMarkIdx;
+ rSh.GetCrsr()->GetPoint()->nNode = nMarkNodeIdx;
+ rSh.GetCrsr()->GetPoint()->nContent =
+ rSh.GetCrsr()->GetCntntNode( FALSE )->Len();
+ }
+
+ rSh.EndCrsrMove( TRUE );
+ }
+ }
+ break;
+#ifdef DBG_UTIL
+ default:
+ ASSERT( !this, "unknown command." );
+#endif
+ }
+ if (bCallBase)
+ Window::Command(rCEvt);
+}
+
+/* -----------------25.08.2003 10:12-----------------
+ #i18686#: select the object/cursor at the mouse
+ position of the context menu request
+ --------------------------------------------------*/
+BOOL SwEditWin::SelectMenuPosition(SwWrtShell& rSh, const Point& rMousePos )
+{
+ BOOL bRet = FALSE;
+ const Point aDocPos( PixelToLogic( rMousePos ) );
+ // --> OD 2005-02-17 #i42258#
+ const bool bIsInsideSelectedObj( rSh.IsInsideSelectedObj( aDocPos ) );
+ // <--
+ //create a synthetic mouse event out of the coordinates
+ MouseEvent aMEvt(rMousePos);
+ SdrView *pSdrView = rSh.GetDrawView();
+ if ( pSdrView )
+ {
+ // --> OD 2005-02-17 #i42258# - no close of insert_draw and reset of
+ // draw mode, if context menu position is inside a selected object.
+ if ( !bIsInsideSelectedObj && rView.GetDrawFuncPtr() )
+ // <--
+ {
+
+ rView.GetDrawFuncPtr()->Deactivate();
+ rView.SetDrawFuncPtr(NULL);
+ rView.LeaveDrawCreate();
+ SfxBindings& rBind = rView.GetViewFrame()->GetBindings();
+ rBind.Invalidate( SID_ATTR_SIZE );
+ rBind.Invalidate( SID_TABLE_CELL );
+ }
+
+ // if draw text is active and there's a text selection
+ // at the mouse position then do nothing
+ if(rSh.GetSelectionType() & nsSelectionType::SEL_DRW_TXT)
+ {
+ OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
+ ESelection aSelection = pOLV->GetSelection();
+ if(!aSelection.IsZero())
+ {
+ SdrOutliner* pOutliner = pSdrView->GetTextEditOutliner();
+ BOOL bVertical = pOutliner->IsVertical();
+ const EditEngine& rEditEng = pOutliner->GetEditEngine();
+ Point aEEPos(aDocPos);
+ const Rectangle& rOutputArea = pOLV->GetOutputArea();
+ // regard vertical mode
+ if(bVertical)
+ {
+ aEEPos -= rOutputArea.TopRight();
+ //invert the horizontal direction and exchange X and Y
+ long nTemp = -aEEPos.X();
+ aEEPos.X() = aEEPos.Y();
+ aEEPos.Y() = nTemp;
+ }
+ else
+ aEEPos -= rOutputArea.TopLeft();
+
+ EPosition aDocPosition = rEditEng.FindDocPosition(aEEPos);
+ ESelection aCompare(aDocPosition.nPara, aDocPosition.nIndex);
+ // make it a forward selection - otherwise the IsLess/IsGreater do not work :-(
+ aSelection.Adjust();
+ if(!aCompare.IsLess(aSelection) && !aCompare.IsGreater(aSelection))
+ {
+ return FALSE;
+ }
+ }
+
+ }
+
+ if (pSdrView->MouseButtonDown( aMEvt, this ) )
+ {
+ pSdrView->MouseButtonUp( aMEvt, this );
+ rSh.GetView().GetViewFrame()->GetBindings().InvalidateAll(FALSE);
+ return TRUE;
+ }
+ }
+ rSh.ResetCursorStack();
+
+ if ( EnterDrawMode( aMEvt, aDocPos ) )
+ {
+ return TRUE;
+ }
+ if ( rView.GetDrawFuncPtr() && bInsFrm )
+ {
+ StopInsFrm();
+ rSh.Edit();
+ }
+
+ UpdatePointer( aDocPos, 0 );
+
+ if( !rSh.IsSelFrmMode() &&
+ !GetView().GetViewFrame()->GetDispatcher()->IsLocked() )
+ {
+ // #107513#
+ // Test if there is a draw object at that position and if it should be selected.
+ sal_Bool bShould = rSh.ShouldObjectBeSelected(aDocPos);
+
+ if(bShould)
+ {
+ rView.NoRotate();
+ rSh.HideCrsr();
+
+ BOOL bUnLockView = !rSh.IsViewLocked();
+ rSh.LockView( TRUE );
+ BOOL bSelObj = rSh.SelectObj( aDocPos, 0);
+ if( bUnLockView )
+ rSh.LockView( FALSE );
+
+ if( bSelObj )
+ {
+ bRet = TRUE;
+ // falls im Macro der Rahmen deselektiert
+ // wurde, muss nur noch der Cursor
+ // wieder angezeigt werden.
+ if( FRMTYPE_NONE == rSh.GetSelFrmType() )
+ rSh.ShowCrsr();
+ else
+ {
+ if (rSh.IsFrmSelected() && rView.GetDrawFuncPtr())
+ {
+ rView.GetDrawFuncPtr()->Deactivate();
+ rView.SetDrawFuncPtr(NULL);
+ rView.LeaveDrawCreate();
+ rView.AttrChangedNotify( &rSh );
+ }
+
+ rSh.EnterSelFrmMode( &aDocPos );
+ bFrmDrag = TRUE;
+ UpdatePointer( aDocPos, 0 );
+ return bRet;
+ }
+ }
+
+ if (!rView.GetDrawFuncPtr())
+ rSh.ShowCrsr();
+ }
+ }
+ else if ( rSh.IsSelFrmMode() &&
+ (aActHitType == SDRHIT_NONE ||
+ !bIsInsideSelectedObj))
+ {
+ rView.NoRotate();
+ BOOL bUnLockView = !rSh.IsViewLocked();
+ rSh.LockView( TRUE );
+ BYTE nFlag = 0;
+
+ if ( rSh.IsSelFrmMode() )
+ {
+ rSh.UnSelectFrm();
+ rSh.LeaveSelFrmMode();
+ rView.AttrChangedNotify(&rSh);
+ bRet = TRUE;
+ }
+
+ BOOL bSelObj = rSh.SelectObj( aDocPos, nFlag );
+ if( bUnLockView )
+ rSh.LockView( FALSE );
+
+ if( !bSelObj )
+ {
+ // Cursor hier umsetzen, damit er nicht zuerst
+ // im Rahmen gezeichnet wird; ShowCrsr() geschieht
+ // in LeaveSelFrmMode()
+ bValidCrsrPos = !(CRSR_POSCHG & (rSh.*rSh.fnSetCrsr)(&aDocPos,FALSE));
+ rSh.LeaveSelFrmMode();
+ rView.LeaveDrawCreate();
+ rView.AttrChangedNotify( &rSh );
+ bRet = TRUE;
+ }
+ else
+ {
+ rSh.HideCrsr();
+ rSh.EnterSelFrmMode( &aDocPos );
+ rSh.SelFlyGrabCrsr();
+ rSh.MakeSelVisible();
+ bFrmDrag = TRUE;
+ if( rSh.IsFrmSelected() &&
+ rView.GetDrawFuncPtr() )
+ {
+ rView.GetDrawFuncPtr()->Deactivate();
+ rView.SetDrawFuncPtr(NULL);
+ rView.LeaveDrawCreate();
+ rView.AttrChangedNotify( &rSh );
+ }
+ UpdatePointer( aDocPos, 0 );
+ bRet = TRUE;
+ }
+ }
+ else if ( rSh.IsSelFrmMode() && bIsInsideSelectedObj )
+ {
+ // ## object at the mouse cursor is already selected - do nothing
+ return FALSE;
+ }
+
+ if ( rSh.IsGCAttr() )
+ {
+ rSh.GCAttr();
+ rSh.ClearGCAttr();
+ }
+
+ BOOL bOverSelect = rSh.ChgCurrPam( aDocPos ), bOverURLGrf = FALSE;
+ if( !bOverSelect )
+ bOverURLGrf = bOverSelect = 0 != rSh.IsURLGrfAtPos( aDocPos );
+
+ if ( !bOverSelect )
+ {
+ { // nur temp. Move-Kontext aufspannen, da sonst die
+ // Abfrage auf die Inhaltsform nicht funktioniert!!!
+ MV_KONTEXT( &rSh );
+ (rSh.*rSh.fnSetCrsr)(&aDocPos, FALSE);
+ bRet = TRUE;
+ }
+ }
+ if( !bOverURLGrf )
+ {
+ const int nSelType = rSh.GetSelectionType();
+ if( nSelType == nsSelectionType::SEL_OLE ||
+ nSelType == nsSelectionType::SEL_GRF )
+ {
+ MV_KONTEXT( &rSh );
+ if( !rSh.IsFrmSelected() )
+ rSh.GotoNextFly();
+ rSh.EnterSelFrmMode();
+ bRet = TRUE;
+ }
+ }
+ return bRet;
+}
+
+SfxShell* lcl_GetShellFromDispatcher( SwView& rView, TypeId nType )
+{
+ //Shell ermitteln
+ SfxShell* pShell;
+ SfxDispatcher* pDispatcher = rView.GetViewFrame()->GetDispatcher();
+ for(USHORT i = 0; TRUE; ++i )
+ {
+ pShell = pDispatcher->GetShell( i );
+ if( !pShell || pShell->IsA( nType ) )
+ break;
+ }
+ return pShell;
+}
+
+
+
+void SwEditWin::ClearTip()
+{
+}
+
+IMPL_LINK( SwEditWin, KeyInputFlushHandler, Timer *, EMPTYARG )
+{
+ FlushInBuffer();
+ return 0;
+}
+
+
+IMPL_LINK( SwEditWin, KeyInputTimerHandler, Timer *, EMPTYARG )
+{
+ bTblInsDelMode = FALSE;
+ return 0;
+}
+
+void SwEditWin::_InitStaticData()
+{
+ pQuickHlpData = new QuickHelpData();
+}
+
+void SwEditWin::_FinitStaticData()
+{
+ delete pQuickHlpData;
+}
+/* -----------------23.01.2003 12:15-----------------
+ * #i3370# remove quick help to prevent saving
+ * of autocorrection suggestions
+ * --------------------------------------------------*/
+void SwEditWin::StopQuickHelp()
+{
+ if( HasFocus() && pQuickHlpData && pQuickHlpData->bClear )
+ pQuickHlpData->Stop( rView.GetWrtShell() );
+}
+
+/*-----------------23.02.97 18:39-------------------
+
+--------------------------------------------------*/
+
+
+IMPL_LINK(SwEditWin, TemplateTimerHdl, Timer*, EMPTYARG)
+{
+ SetApplyTemplate(SwApplyTemplate());
+ return 0;
+}
+
+
+void SwEditWin::SetChainMode( BOOL bOn )
+{
+ if ( !bChainMode )
+ StopInsFrm();
+
+ if ( pUserMarker )
+ {
+ delete pUserMarker;
+ pUserMarker = 0L;
+ }
+
+ bChainMode = bOn;
+ if ( !bChainMode )
+ rView.GetViewFrame()->HideStatusText();
+
+ static USHORT __READONLY_DATA aInva[] =
+ {
+ FN_FRAME_CHAIN, FN_FRAME_UNCHAIN, 0
+ };
+ rView.GetViewFrame()->GetBindings().Invalidate(aInva);
+}
+
+uno::Reference< ::com::sun::star::accessibility::XAccessible > SwEditWin::CreateAccessible()
+{
+ vos::OGuard aGuard(Application::GetSolarMutex()); // this should have
+ // happend already!!!
+ SwWrtShell *pSh = rView.GetWrtShellPtr();
+ ASSERT( pSh, "no writer shell, no accessible object" );
+ uno::Reference<
+ ::com::sun::star::accessibility::XAccessible > xAcc;
+ if( pSh )
+ xAcc = pSh->CreateAccessible();
+
+ return xAcc;
+}
+
+//-------------------------------------------------------------
+
+void QuickHelpData::Move( QuickHelpData& rCpy )
+{
+ // Pointer verschieben
+ aArr.Insert( &rCpy.aArr );
+ rCpy.aArr.Remove( (USHORT)0, rCpy.aArr.Count() );
+// nTipId = rCpy.nTipId;
+ bClear = rCpy.bClear;
+ nLen = rCpy.nLen;
+ nCurArrPos = rCpy.nCurArrPos;
+ bChkInsBlank = rCpy.bChkInsBlank;
+ bIsTip = rCpy.bIsTip;
+ bIsAutoText = rCpy.bIsAutoText;
+
+ if( pCETID ) delete pCETID;
+ pCETID = rCpy.pCETID;
+ rCpy.pCETID = 0;
+
+ if( pAttrs )
+ delete[] pAttrs;
+ pAttrs = rCpy.pAttrs;
+ rCpy.pAttrs = 0;
+}
+
+void QuickHelpData::ClearCntnt()
+{
+ nLen = nCurArrPos = 0;
+ bClear = bChkInsBlank = FALSE;
+ nTipId = 0;
+ aArr.DeleteAndDestroy( 0 , aArr.Count() );
+ bIsTip = TRUE;
+ bIsAutoText = TRUE;
+ delete pCETID, pCETID = 0;
+ delete[] pAttrs, pAttrs = 0;
+}
+
+
+void QuickHelpData::Start( SwWrtShell& rSh, USHORT nWrdLen )
+{
+ if( pCETID ) delete pCETID, pCETID = 0;
+ if( pAttrs ) delete[] pAttrs, pAttrs = 0;
+
+ if( USHRT_MAX != nWrdLen )
+ {
+ nLen = nWrdLen;
+ nCurArrPos = 0;
+ }
+ bClear = TRUE;
+
+ Window& rWin = rSh.GetView().GetEditWin();
+ if( bIsTip )
+ {
+ Point aPt( rWin.OutputToScreenPixel( rWin.LogicToPixel(
+ rSh.GetCharRect().Pos() )));
+ aPt.Y() -= 3;
+ nTipId = Help::ShowTip( &rWin, Rectangle( aPt, Size( 1, 1 )),
+ *aArr[ nCurArrPos ],
+ QUICKHELP_LEFT | QUICKHELP_BOTTOM );
+ }
+ else
+ {
+ String sStr( *aArr[ nCurArrPos ] );
+ sStr.Erase( 0, nLen );
+ USHORT nL = sStr.Len();
+ pAttrs = new USHORT[ nL ];
+ for( USHORT n = nL; n; )
+ *(pAttrs + --n ) = EXTTEXTINPUT_ATTR_DOTTEDUNDERLINE |
+ EXTTEXTINPUT_ATTR_HIGHLIGHT;
+ pCETID = new CommandExtTextInputData( sStr, pAttrs, nL,
+ 0, 0, 0, FALSE );
+ rSh.CreateExtTextInput(rWin.GetInputLanguage());
+ rSh.SetExtTextInputData( *pCETID );
+ }
+}
+
+void QuickHelpData::Stop( SwWrtShell& rSh )
+{
+ if( !bIsTip )
+ rSh.DeleteExtTextInput( 0, FALSE );
+ else if( nTipId )
+ Help::HideTip( nTipId );
+ ClearCntnt();
+}
+
+
+
+void QuickHelpData::FillStrArr( SwWrtShell& rSh, const String& rWord )
+{
+ salhelper::SingletonRef<SwCalendarWrapper>* pCalendar = s_getCalendarWrapper();
+ (*pCalendar)->LoadDefaultCalendar( rSh.GetCurLang() );
+
+ {
+ uno::Sequence< i18n::CalendarItem > aNames(
+ (*pCalendar)->getMonths() );
+ for( int n = 0; n < 2; ++n )
+ {
+ for( long nPos = 0, nEnd = aNames.getLength(); nPos < nEnd; ++nPos )
+ {
+ String sStr( aNames[ nPos ].FullName );
+ if( rWord.Len() + 1 < sStr.Len() &&
+
+//!!! UNICODE: fehlendes interface
+// pIntl->CompareEqual( rWord, sStr.Copy( 0, rWord.Len() ),
+// INTN_COMPARE_IGNORECASE ) )
+ COMPARE_EQUAL == rWord.CompareIgnoreCaseToAscii(
+ sStr, rWord.Len() ))
+ {
+ String* pNew = new String( sStr );
+ if( !aArr.Insert( pNew ) )
+ delete pNew;
+ }
+ }
+ if( !n ) // get data for the second loop
+ aNames = (*pCalendar)->getDays();
+ }
+ }
+
+ // and than add all words from the AutoCompleteWord-List
+ const SwAutoCompleteWord& rACLst = rSh.GetAutoCompleteWords();
+ USHORT nStt, nEnd;
+ if( rACLst.GetRange( rWord, nStt, nEnd ) )
+ {
+ while( nStt < nEnd )
+ {
+ const String& rS = rACLst[ nStt ];
+ //JP 16.06.99: Bug 66927 - only if the count of chars
+ // from the suggest greater as the
+ // actual word
+ if( rS.Len() > rWord.Len() )
+ {
+ String* pNew = new String( rS );
+ if( !aArr.Insert( pNew ) )
+ delete pNew;
+ }
+ ++nStt;
+ }
+ }
+}
+/* -----------------06.11.2002 12:01-----------------
+ *
+ * --------------------------------------------------*/
+void SwEditWin::ShowAutoTextCorrectQuickHelp(
+ const String& rWord, SvxAutoCorrCfg* pACfg, SvxAutoCorrect* pACorr,
+ sal_Bool bFromIME )
+{
+ SwWrtShell& rSh = rView.GetWrtShell();
+ pQuickHlpData->ClearCntnt();
+ if( pACfg->IsAutoTextTip() )
+ {
+ SwGlossaryList* pList = ::GetGlossaryList();
+ pList->HasLongName( rWord, &pQuickHlpData->aArr );
+ }
+
+ if( pQuickHlpData->aArr.Count() )
+ {
+ pQuickHlpData->bIsTip = TRUE;
+ pQuickHlpData->bIsAutoText = TRUE;
+ }
+ else if( pACorr->GetSwFlags().bAutoCompleteWords )
+ {
+ pQuickHlpData->bIsAutoText = FALSE;
+ pQuickHlpData->bIsTip = bFromIME ||
+ !pACorr ||
+ pACorr->GetSwFlags().bAutoCmpltShowAsTip;
+
+ pQuickHlpData->FillStrArr( rSh, rWord );
+ }
+
+ if( pQuickHlpData->aArr.Count() )
+ pQuickHlpData->Start( rSh, rWord.Len() );
+}
+
+/* -----------------29.03.2006 11:01-----------------
+ *
+ * --------------------------------------------------*/
+
+void SwEditWin::SetUseInputLanguage( sal_Bool bNew )
+{
+ if ( bNew || bUseInputLanguage )
+ {
+ SfxBindings& rBind = GetView().GetViewFrame()->GetBindings();
+ rBind.Invalidate( SID_ATTR_CHAR_FONT );
+ rBind.Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
+ }
+ bUseInputLanguage = bNew;
+}
+
+/*-- 13.11.2008 10:18:17---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+XubString SwEditWin::GetSurroundingText() const
+{
+ String sReturn;
+ SwWrtShell& rSh = rView.GetWrtShell();
+ if( rSh.HasSelection() && !rSh.IsMultiSelection() && rSh.IsSelOnePara() )
+ rSh.GetSelectedText( sReturn, GETSELTXT_PARABRK_TO_ONLYCR );
+ else if( !rSh.HasSelection() )
+ {
+ SwPosition *pPos = rSh.GetCrsr()->GetPoint();
+ xub_StrLen nPos = pPos->nContent.GetIndex();
+
+ // get the sentence around the cursor
+ rSh.HideCrsr();
+ rSh.GoStartSentence();
+ rSh.SetMark();
+ rSh.GoEndSentence();
+ rSh.GetSelectedText( sReturn, GETSELTXT_PARABRK_TO_ONLYCR );
+
+ pPos->nContent = nPos;
+ rSh.ClearMark();
+ rSh.HideCrsr();
+ }
+
+ return sReturn;
+}
+/*-- 13.11.2008 10:18:17---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+Selection SwEditWin::GetSurroundingTextSelection() const
+{
+ SwWrtShell& rSh = rView.GetWrtShell();
+ if( rSh.HasSelection() )
+ {
+ String sReturn;
+ rSh.GetSelectedText( sReturn, GETSELTXT_PARABRK_TO_ONLYCR );
+ return Selection( 0, sReturn.Len() );
+ }
+ else
+ {
+ // Return the position of the visible cursor in the sentence
+ // around the visible cursor.
+ SwPosition *pPos = rSh.GetCrsr()->GetPoint();
+ xub_StrLen nPos = pPos->nContent.GetIndex();
+
+ rSh.HideCrsr();
+ rSh.GoStartSentence();
+ xub_StrLen nStartPos = rSh.GetCrsr()->GetPoint()->nContent.GetIndex();
+
+ pPos->nContent = nPos;
+ rSh.ClearMark();
+ rSh.ShowCrsr();
+
+ return Selection( nPos - nStartPos, nPos - nStartPos );
+ }
+}
diff --git a/sw/source/ui/docvw/edtwin2.cxx b/sw/source/ui/docvw/edtwin2.cxx
new file mode 100644
index 000000000000..763504c75db6
--- /dev/null
+++ b/sw/source/ui/docvw/edtwin2.cxx
@@ -0,0 +1,607 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+#include <tools/ref.hxx>
+#include <hintids.hxx>
+
+#include <doc.hxx>
+#ifdef DBG_UTIL
+#include <stdio.h>
+#endif
+
+#ifndef _HELP_HXX //autogen
+#include <vcl/help.hxx>
+#endif
+#include <svl/stritem.hxx>
+#include <unotools/securityoptions.hxx>
+#include <tools/urlobj.hxx>
+#include <txtrfmrk.hxx>
+#include <fmtrfmrk.hxx>
+#include <editeng/flditem.hxx>
+#include <svl/urihelper.hxx>
+#include <svx/svdotext.hxx>
+#ifndef _OUTLINER_HXX //autogen
+#define _EEITEMID_HXX
+#include <editeng/outliner.hxx>
+#endif
+#include <svl/itemiter.hxx>
+#include <svx/svdview.hxx>
+#include <svx/svdpagv.hxx>
+#include <swmodule.hxx>
+#ifndef _MODCFG_HXX
+#include <modcfg.hxx>
+#endif
+#ifndef _VIEW_HXX
+#include <view.hxx>
+#endif
+#include <wrtsh.hxx>
+#ifndef _DOCSH_HXX
+#include <docsh.hxx>
+#endif
+#include <edtwin.hxx>
+#include <dpage.hxx>
+#include <shellres.hxx>
+#include <docufld.hxx>
+#include <dbfld.hxx>
+#include <reffld.hxx>
+#include <cellatr.hxx>
+#include <shdwcrsr.hxx>
+#include <fmtcol.hxx>
+#include <charfmt.hxx>
+#include <fmtftn.hxx>
+#include <redline.hxx>
+#include <tox.hxx>
+#include <txttxmrk.hxx>
+#include <uitool.hxx>
+#include <viewopt.hxx>
+#ifndef _DOCVW_HRC
+#include <docvw.hrc>
+#endif
+#ifndef _UTLUI_HRC
+#include <utlui.hrc>
+#endif
+
+#include <PostItMgr.hxx>
+#include <fmtfld.hxx>
+
+// --> OD 2009-08-18 #i104300#
+#include <IDocumentMarkAccess.hxx>
+#include <ndtxt.hxx>
+// <--
+
+/*--------------------------------------------------------------------
+ Beschreibung: KeyEvents
+ --------------------------------------------------------------------*/
+static void lcl_GetRedlineHelp( const SwRedline& rRedl, String& rTxt, BOOL bBalloon )
+{
+ USHORT nResId = 0;
+ switch( rRedl.GetType() )
+ {
+ case nsRedlineType_t::REDLINE_INSERT: nResId = STR_REDLINE_INSERT; break;
+ case nsRedlineType_t::REDLINE_DELETE: nResId = STR_REDLINE_DELETE; break;
+ case nsRedlineType_t::REDLINE_FORMAT: nResId = STR_REDLINE_FORMAT; break;
+ case nsRedlineType_t::REDLINE_TABLE: nResId = STR_REDLINE_TABLE; break;
+ case nsRedlineType_t::REDLINE_FMTCOLL: nResId = STR_REDLINE_FMTCOLL; break;
+ }
+
+ if( nResId )
+ {
+ rTxt = SW_RESSTR( nResId );
+ rTxt.AppendAscii( RTL_CONSTASCII_STRINGPARAM(": " ));
+ rTxt += rRedl.GetAuthorString();
+ rTxt.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " - " ));
+ rTxt += GetAppLangDateTimeString( rRedl.GetTimeStamp() );
+ if( bBalloon && rRedl.GetComment().Len() )
+ ( rTxt += '\n' ) += rRedl.GetComment();
+ }
+}
+
+
+void SwEditWin::RequestHelp(const HelpEvent &rEvt)
+{
+ SwWrtShell &rSh = rView.GetWrtShell();
+ BOOL bQuickBalloon = 0 != (rEvt.GetMode() & ( HELPMODE_QUICK | HELPMODE_BALLOON ));
+ if(bQuickBalloon && rSh.GetViewOptions()->IsPreventTips())
+ return;
+ BOOL bWeiter = TRUE;
+ SET_CURR_SHELL(&rSh);
+ String sTxt;
+ Point aPos( PixelToLogic( ScreenToOutputPixel( rEvt.GetMousePosPixel() ) ));
+ BOOL bBalloon = static_cast< BOOL >(rEvt.GetMode() & HELPMODE_BALLOON);
+
+ SdrView *pSdrView = rSh.GetDrawView();
+
+ if( bQuickBalloon )
+ {
+ if( pSdrView )
+ {
+ SdrPageView* pPV = pSdrView->GetSdrPageView();
+ SwDPage* pPage = pPV ? ((SwDPage*)pPV->GetPage()) : 0;
+ bWeiter = pPage && pPage->RequestHelp(this, pSdrView, rEvt);
+ }
+ }
+
+ if( bWeiter && bQuickBalloon)
+ {
+ SwRect aFldRect;
+ USHORT nStyle = 0; // style of quick help
+ SwContentAtPos aCntntAtPos( SwContentAtPos::SW_FIELD |
+ SwContentAtPos::SW_INETATTR |
+ SwContentAtPos::SW_FTN |
+ SwContentAtPos::SW_REDLINE |
+ SwContentAtPos::SW_TOXMARK |
+ SwContentAtPos::SW_REFMARK |
+ SwContentAtPos::SW_SMARTTAG |
+#ifdef DBG_UTIL
+ SwContentAtPos::SW_TABLEBOXVALUE |
+ ( bBalloon ? SwContentAtPos::SW_CURR_ATTRS : 0) |
+#endif
+ SwContentAtPos::SW_TABLEBOXFML );
+
+ if( rSh.GetContentAtPos( aPos, aCntntAtPos, FALSE, &aFldRect ) )
+ {
+ switch( aCntntAtPos.eCntntAtPos )
+ {
+ case SwContentAtPos::SW_TABLEBOXFML:
+ sTxt.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "= " ));
+ sTxt += ((SwTblBoxFormula*)aCntntAtPos.aFnd.pAttr)->GetFormula();
+ break;
+#ifdef DBG_UTIL
+ case SwContentAtPos::SW_TABLEBOXVALUE:
+ {
+ sTxt = UniString(
+ ByteString::CreateFromDouble(
+ ((SwTblBoxValue*)aCntntAtPos.aFnd.pAttr)->GetValue() )
+ , gsl_getSystemTextEncoding());
+ }
+ break;
+ case SwContentAtPos::SW_CURR_ATTRS:
+ sTxt = aCntntAtPos.sStr;
+ break;
+#endif
+
+ case SwContentAtPos::SW_INETATTR:
+ {
+ sTxt = ((SfxStringItem*)aCntntAtPos.aFnd.pAttr)->GetValue();
+ sTxt = URIHelper::removePassword( sTxt,
+ INetURLObject::WAS_ENCODED,
+ INetURLObject::DECODE_UNAMBIGUOUS);
+ //#i63832# remove the link target type
+ xub_StrLen nFound = sTxt.Search(cMarkSeperator);
+ if( nFound != STRING_NOTFOUND && (++nFound) < sTxt.Len() )
+ {
+ String sSuffix( sTxt.Copy(nFound) );
+ if( sSuffix.EqualsAscii( pMarkToTable ) ||
+ sSuffix.EqualsAscii( pMarkToFrame ) ||
+ sSuffix.EqualsAscii( pMarkToRegion ) ||
+ sSuffix.EqualsAscii( pMarkToOutline ) ||
+ sSuffix.EqualsAscii( pMarkToText ) ||
+ sSuffix.EqualsAscii( pMarkToGraphic ) ||
+ sSuffix.EqualsAscii( pMarkToOLE ))
+ sTxt = sTxt.Copy( 0, nFound - 1);
+ }
+ // --> OD 2009-08-18 #i104300#
+ // special handling if target is a cross-reference bookmark
+ {
+ String sTmpSearchStr = sTxt.Copy( 1, sTxt.Len() );
+ IDocumentMarkAccess* const pMarkAccess =
+ rSh.getIDocumentMarkAccess();
+ IDocumentMarkAccess::const_iterator_t ppBkmk =
+ pMarkAccess->findBookmark( sTmpSearchStr );
+ if ( ppBkmk != pMarkAccess->getBookmarksEnd() &&
+ IDocumentMarkAccess::GetType( *(ppBkmk->get()) )
+ == IDocumentMarkAccess::CROSSREF_HEADING_BOOKMARK )
+ {
+ SwTxtNode* pTxtNode = ppBkmk->get()->GetMarkStart().nNode.GetNode().GetTxtNode();
+ if ( pTxtNode )
+ {
+ sTxt = pTxtNode->GetExpandTxt( 0, pTxtNode->Len(), true, true );
+
+ if( sTxt.Len() )
+ {
+ sTxt.EraseAllChars( 0xad );
+ for( sal_Unicode* p = sTxt.GetBufferAccess(); *p; ++p )
+ {
+ if( *p < 0x20 )
+ *p = 0x20;
+ else if(*p == 0x2011)
+ *p = '-';
+ }
+ }
+ }
+ }
+ }
+ // <--
+ // --> OD 2007-07-26 #i80029#
+ BOOL bExecHyperlinks = rView.GetDocShell()->IsReadOnly();
+ if ( !bExecHyperlinks )
+ {
+ SvtSecurityOptions aSecOpts;
+ bExecHyperlinks = !aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK );
+
+ if ( !bExecHyperlinks )
+ {
+ sTxt.InsertAscii( ": ", 0 );
+ sTxt.Insert( ViewShell::GetShellRes()->aHyperlinkClick, 0 );
+ }
+ }
+ // <--
+ break;
+ }
+ case SwContentAtPos::SW_SMARTTAG:
+ {
+ sTxt = SW_RESSTR(STR_SMARTTAG_CLICK);
+
+ KeyCode aCode( KEY_SPACE );
+ KeyCode aModifiedCode( KEY_SPACE, KEY_MOD1 );
+ String aModStr( aModifiedCode.GetName() );
+ aModStr.SearchAndReplace( aCode.GetName(), String() );
+ aModStr.SearchAndReplaceAllAscii( "+", String() );
+ sTxt.SearchAndReplaceAllAscii( "%s", aModStr );
+ }
+ break;
+
+ case SwContentAtPos::SW_FTN:
+ if( aCntntAtPos.pFndTxtAttr && aCntntAtPos.aFnd.pAttr )
+ {
+ const SwFmtFtn* pFtn = (SwFmtFtn*)aCntntAtPos.aFnd.pAttr;
+ pFtn->GetFtnText( sTxt );
+ sTxt.Insert( SW_RESSTR( pFtn->IsEndNote()
+ ? STR_ENDNOTE : STR_FTNNOTE ), 0 );
+ if( aCntntAtPos.IsInRTLText() )
+ nStyle |= QUICKHELP_BIDI_RTL;
+ }
+ break;
+
+ case SwContentAtPos::SW_REDLINE:
+ lcl_GetRedlineHelp( *aCntntAtPos.aFnd.pRedl, sTxt, bBalloon );
+ break;
+
+ case SwContentAtPos::SW_TOXMARK:
+ sTxt = aCntntAtPos.sStr;
+ if( sTxt.Len() && aCntntAtPos.pFndTxtAttr )
+ {
+ const SwTOXType* pTType = aCntntAtPos.pFndTxtAttr->
+ GetTOXMark().GetTOXType();
+ if( pTType && pTType->GetTypeName().Len() )
+ {
+ sTxt.InsertAscii( ": ", 0 );
+ sTxt.Insert( pTType->GetTypeName(), 0 );
+ }
+ }
+ break;
+ case SwContentAtPos::SW_REFMARK:
+ if(aCntntAtPos.aFnd.pAttr)
+ {
+ sTxt = SW_RES(STR_CONTENT_TYPE_SINGLE_REFERENCE);
+ sTxt.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": "));
+ sTxt += ((const SwFmtRefMark*)aCntntAtPos.aFnd.pAttr)->GetRefName();
+ }
+ break;
+
+ default:
+ {
+ SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
+ if(!pModOpt->IsHideFieldTips())
+ {
+ const SwField* pFld = aCntntAtPos.aFnd.pFld;
+ switch( pFld->Which() )
+ {
+ case RES_SETEXPFLD:
+ case RES_TABLEFLD:
+ case RES_GETEXPFLD:
+ {
+ USHORT nOldSubType = pFld->GetSubType();
+ ((SwField*)pFld)->SetSubType(nsSwExtendedSubType::SUB_CMD);
+ sTxt = pFld->Expand();
+ ((SwField*)pFld)->SetSubType(nOldSubType);
+ }
+ break;
+
+ case RES_POSTITFLD:
+ {
+ /*
+ SwPostItMgr* pMgr = rView.GetPostItMgr();
+ if (pMgr->ShowNotes())
+ {
+ SwFmtFld* pSwFmtFld = 0;
+ if (pMgr->ShowPreview(pFld,pSwFmtFld))
+ {
+ SwPostIt* pPostIt = new SwPostIt(static_cast<Window*>(this),0,pSwFmtFld,pMgr,PB_Preview);
+ pPostIt->InitControls();
+ pPostIt->SetReadonly(true);
+ pMgr->SetColors(pPostIt,static_cast<SwPostItField*>(pSwFmtFld->GetFld()));
+ pPostIt->SetVirtualPosSize(rEvt.GetMousePosPixel(),Size(180,70));
+ pPostIt->ShowNote();
+ SetPointerPosPixel(pPostIt->GetPosPixel() + Point(20,20));
+ }
+ return;
+ }
+ */
+ break;
+ }
+ case RES_INPUTFLD: // BubbleHelp, da der Hinweis ggf ziemlich lang sein kann
+ bBalloon = TRUE;
+ /* no break */
+ case RES_JUMPEDITFLD:
+ sTxt = pFld->GetPar2();
+ break;
+
+ case RES_DBFLD:
+ sTxt = ((SwDBField*)pFld)->GetCntnt(TRUE);
+ break;
+
+ case RES_USERFLD:
+ case RES_HIDDENTXTFLD:
+ sTxt = pFld->GetPar1();
+ break;
+
+ case RES_DOCSTATFLD:
+ break;
+
+ case RES_MACROFLD:
+ sTxt = ((const SwMacroField*)pFld)->GetMacro();
+ break;
+
+ case RES_GETREFFLD:
+ {
+ // --> OD 2008-01-09 #i85090#
+ const SwGetRefField* pRefFld( dynamic_cast<const SwGetRefField*>(pFld) );
+ ASSERT( pRefFld,
+ "<SwEditWin::RequestHelp(..)> - unexpected type of <pFld>" );
+ if ( pRefFld )
+ {
+ if ( pRefFld->IsRefToHeadingCrossRefBookmark() ||
+ pRefFld->IsRefToNumItemCrossRefBookmark() )
+ {
+ sTxt = pRefFld->GetExpandedTxtOfReferencedTxtNode();
+ if ( sTxt.Len() > 80 )
+ {
+ sTxt.Erase( 80 );
+ sTxt += '.';
+ sTxt += '.';
+ sTxt += '.';
+ }
+ }
+ else
+ {
+ sTxt = ((SwGetRefField*)pFld)->GetSetRefName();
+ }
+ }
+ // <--
+ }
+ break;
+ }
+ }
+
+ if( !sTxt.Len() )
+ {
+ aCntntAtPos.eCntntAtPos = SwContentAtPos::SW_REDLINE;
+ if( rSh.GetContentAtPos( aPos, aCntntAtPos, FALSE, &aFldRect ) )
+ lcl_GetRedlineHelp( *aCntntAtPos.aFnd.pRedl,
+ sTxt, bBalloon );
+ }
+ }
+ }
+ if (sTxt.Len() )
+ {
+ if( bBalloon )
+ Help::ShowBalloon( this, rEvt.GetMousePosPixel(), sTxt );
+ else
+ {
+ // dann zeige die Hilfe mal an:
+ Rectangle aRect( aFldRect.SVRect() );
+ Point aPt( OutputToScreenPixel( LogicToPixel( aRect.TopLeft() )));
+ aRect.Left() = aPt.X();
+ aRect.Top() = aPt.Y();
+ aPt = OutputToScreenPixel( LogicToPixel( aRect.BottomRight() ));
+ aRect.Right() = aPt.X();
+ aRect.Bottom() = aPt.Y();
+ Help::ShowQuickHelp( this, aRect, sTxt, nStyle );
+ }
+ }
+
+ bWeiter = FALSE;
+ }
+ if( bWeiter )
+ {
+ BYTE nTabCols = rSh.WhichMouseTabCol(aPos);
+ USHORT nTabRes = 0;
+ switch(nTabCols)
+ {
+ case SW_TABCOL_HORI:
+ case SW_TABCOL_VERT:
+ nTabRes = STR_TABLE_COL_ADJUST;
+ break;
+ case SW_TABROW_HORI:
+ case SW_TABROW_VERT:
+ nTabRes = STR_TABLE_ROW_ADJUST;
+ break;
+ // --> FME 2004-07-30 #i32329# Enhanced table selection
+ case SW_TABSEL_HORI:
+ case SW_TABSEL_HORI_RTL:
+ case SW_TABSEL_VERT:
+ nTabRes = STR_TABLE_SELECT_ALL;
+ break;
+ case SW_TABROWSEL_HORI:
+ case SW_TABROWSEL_HORI_RTL:
+ case SW_TABROWSEL_VERT:
+ nTabRes = STR_TABLE_SELECT_ROW;
+ break;
+ case SW_TABCOLSEL_HORI:
+ case SW_TABCOLSEL_VERT:
+ nTabRes = STR_TABLE_SELECT_COL;
+ break;
+ // <--
+ }
+ if(nTabRes)
+ {
+ sTxt = SW_RESSTR(nTabRes);
+ Size aTxtSize( GetTextWidth(sTxt), GetTextHeight());
+ Rectangle aRect(rEvt.GetMousePosPixel(), aTxtSize);
+ Help::ShowQuickHelp(this, aRect, sTxt);
+ }
+ bWeiter = FALSE;
+ }
+ }
+
+/*
+aktuelle Zeichenvorlage anzeigen?
+ if( bWeiter && rEvt.GetMode() & ( HELPMODE_QUICK | HELPMODE_BALLOON ))
+ {
+ SwCharFmt* pChrFmt = rSh.GetCurCharFmt();
+
+ }
+*/
+ if( bWeiter && pSdrView && bQuickBalloon)
+ {
+ SdrViewEvent aVEvt;
+ SdrHitKind eHit = pSdrView->PickAnything(aPos, aVEvt);
+ const SvxURLField *pField;
+ SdrObject* pObj = NULL;
+
+ if ((pField = aVEvt.pURLField) != 0)
+ {
+ // URL-Feld getroffen
+ if (pField)
+ {
+ pObj = aVEvt.pObj;
+ sTxt = pField->GetURL();
+
+ bWeiter = FALSE;
+ }
+ }
+ if (bWeiter && eHit == SDRHIT_TEXTEDIT)
+ {
+ // URL-Feld in zum Editieren ge?ffneten DrawText-Objekt suchen
+ OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
+ const SvxFieldItem* pFieldItem;
+
+ if (pSdrView->AreObjectsMarked())
+ {
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+
+ if (rMarkList.GetMarkCount() == 1)
+ pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+ }
+
+ if (pObj && pObj->ISA(SdrTextObj) && pOLV &&
+ (pFieldItem = pOLV->GetFieldUnderMousePointer()) != 0)
+ {
+ pField = dynamic_cast<const SvxURLField*>(pFieldItem->GetField());
+
+ if (pField )
+ {
+ sTxt = ((const SvxURLField*) pField)->GetURL();
+ bWeiter = FALSE;
+ }
+ }
+ }
+ if (sTxt.Len() && pObj)
+ {
+ sTxt = URIHelper::removePassword( sTxt, INetURLObject::WAS_ENCODED,
+ INetURLObject::DECODE_UNAMBIGUOUS);
+
+ Rectangle aLogicPix = LogicToPixel(pObj->GetLogicRect());
+ Rectangle aScreenRect(OutputToScreenPixel(aLogicPix.TopLeft()),
+ OutputToScreenPixel(aLogicPix.BottomRight()));
+
+ if (bBalloon)
+ Help::ShowBalloon(this, rEvt.GetMousePosPixel(), aScreenRect, sTxt);
+ else
+ Help::ShowQuickHelp(this, aScreenRect, sTxt);
+ }
+ }
+
+ if( bWeiter )
+ Window::RequestHelp( rEvt );
+}
+
+void SwEditWin::PrePaint()
+{
+ SwWrtShell* pWrtShell = GetView().GetWrtShellPtr();
+
+ if(pWrtShell)
+ {
+ pWrtShell->PrePaint();
+ }
+}
+
+void SwEditWin::Paint(const Rectangle& rRect)
+{
+#if defined(MYDEBUG)
+ // StartUp-Statistik
+ if ( pTickList )
+ {
+ SYSTICK( "Start SwEditWin::Paint" );
+ READ_FIRST_TICKS()
+ FLUSH_TICKS()
+ }
+#endif
+
+ SwWrtShell* pWrtShell = GetView().GetWrtShellPtr();
+ if(!pWrtShell)
+ return;
+ BOOL bPaintShadowCrsr = FALSE;
+ if( pShadCrsr )
+ {
+ Rectangle aRect( pShadCrsr->GetRect());
+ // liegt vollstaendig drin?
+ if( rRect.IsInside( aRect ) )
+ // dann aufheben
+ delete pShadCrsr, pShadCrsr = 0;
+ else if( rRect.IsOver( aRect ))
+ {
+ // liegt irgendwie drueber, dann ist alles ausserhalb geclippt
+ // und wir muessen den "inneren Teil" am Ende vom Paint
+ // wieder sichtbar machen. Sonst kommt es zu Paintfehlern!
+ bPaintShadowCrsr = TRUE;
+ }
+ }
+/*
+ //TODO/LATER: what's the replacement for this? Do we need it?
+ SwDocShell* pDocShell = GetView().GetDocShell();
+
+ SvInPlaceEnvironment *pIpEnv = pDocShell ?
+ pDocShell->GetIPEnv() : 0;
+ if ( pIpEnv && pIpEnv->GetRectsChangedLockCount() )
+ //Wir stehen in Groessenverhandlungen (MM), Paint verzoegern
+ Invalidate( rRect );
+ else */
+ if ( GetView().GetVisArea().GetWidth() <= 0 ||
+ GetView().GetVisArea().GetHeight() <= 0 )
+ Invalidate( rRect );
+ else
+ pWrtShell->Paint( rRect );
+
+ if( bPaintShadowCrsr )
+ pShadCrsr->Paint();
+}
+
+
diff --git a/sw/source/ui/docvw/edtwin3.cxx b/sw/source/ui/docvw/edtwin3.cxx
new file mode 100644
index 000000000000..c2d7492cb066
--- /dev/null
+++ b/sw/source/ui/docvw/edtwin3.cxx
@@ -0,0 +1,216 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+
+
+#include <hintids.hxx>
+#include <vcl/settings.hxx>
+#include <svx/ruler.hxx>
+#include <viewopt.hxx>
+#include "view.hxx"
+#include "wrtsh.hxx"
+#include "basesh.hxx"
+#include "pview.hxx"
+#include "mdiexp.hxx"
+#include "edtwin.hxx"
+#include "swmodule.hxx"
+#include "modcfg.hxx"
+#include "swtable.hxx"
+#include "docsh.hxx"
+#include "pagedesc.hxx" // Aktuelles Seitenformat
+#include <frmatr.hxx>
+#include <editeng/frmdiritem.hxx>
+
+
+/*--------------------------------------------------------------------
+ Beschreibung: Core-Notify
+ --------------------------------------------------------------------*/
+
+
+
+void ScrollMDI( ViewShell* pVwSh, const SwRect &rRect,
+ USHORT nRangeX, USHORT nRangeY)
+{
+ SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
+ if (pSfxVwSh && pSfxVwSh->ISA(SwView))
+ ((SwView *)pSfxVwSh)->Scroll( rRect.SVRect(), nRangeX, nRangeY );
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Docmdi - verschiebbar
+ --------------------------------------------------------------------*/
+
+
+
+BOOL IsScrollMDI( ViewShell* pVwSh, const SwRect &rRect )
+{
+ SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
+ if (pSfxVwSh && pSfxVwSh->ISA(SwView))
+ return (((SwView *)pSfxVwSh)->IsScroll(rRect.SVRect()));
+ return FALSE;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Notify fuer Groessen-Aenderung
+ --------------------------------------------------------------------*/
+
+
+
+void SizeNotify(ViewShell* pVwSh, const Size &rSize)
+{
+ SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
+ if (pSfxVwSh)
+ {
+ if (pSfxVwSh->ISA(SwView))
+ ((SwView *)pSfxVwSh)->DocSzChgd(rSize);
+ else if (pSfxVwSh->ISA(SwPagePreView))
+ ((SwPagePreView *)pSfxVwSh)->DocSzChgd( rSize );
+ }
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Notify fuer Seitenzahl-Update
+ --------------------------------------------------------------------*/
+
+
+
+void PageNumNotify( ViewShell* pVwSh, USHORT nPhyNum, USHORT nVirtNum,
+ const String& rPgStr)
+{
+ SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
+ if ( pSfxVwSh && pSfxVwSh->ISA(SwView) &&
+ ((SwView*)pSfxVwSh)->GetCurShell() )
+ ((SwView *)pSfxVwSh)->UpdatePageNums(nPhyNum, nVirtNum, rPgStr);
+}
+
+/******************************************************************************
+ * Methode : void FrameNotify( DocMDIBase *pWin, FlyMode eMode )
+ * Beschreibung:
+ * Erstellt : OK 08.02.94 13:49
+ * Aenderung :
+ ******************************************************************************/
+
+
+
+void FrameNotify( ViewShell* pVwSh, FlyMode eMode )
+{
+ if ( pVwSh->ISA(SwCrsrShell) )
+ SwBaseShell::SetFrmMode( eMode, (SwWrtShell*)pVwSh );
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Notify fuer Seitenzahl-Update
+ --------------------------------------------------------------------*/
+BOOL SwEditWin::RulerColumnDrag( const MouseEvent& rMEvt, BOOL bVerticalMode)
+{
+ SvxRuler& rRuler = bVerticalMode ? rView.GetVLineal() : rView.GetHLineal();
+ return (!rRuler.StartDocDrag( rMEvt, RULER_TYPE_BORDER ) &&
+ !rRuler.StartDocDrag( rMEvt, RULER_TYPE_MARGIN1) &&
+ !rRuler.StartDocDrag( rMEvt, RULER_TYPE_MARGIN2));
+}
+
+// #i23726#
+// --> OD 2005-02-18 #i42921# - add 3rd parameter <bVerticalMode> in order
+// to consider vertical layout
+BOOL SwEditWin::RulerMarginDrag( const MouseEvent& rMEvt,
+ const bool bVerticalMode )
+{
+ SvxRuler& rRuler = bVerticalMode ? rView.GetVLineal() : rView.GetHLineal();
+ return !rRuler.StartDocDrag( rMEvt, RULER_TYPE_INDENT);
+}
+// <--
+
+LAYOUT_NS Dialog* GetSearchDialog()
+{
+ return SwView::GetSearchDialog();
+}
+
+TblChgMode GetTblChgDefaultMode()
+{
+ SwModuleOptions* pOpt = SW_MOD()->GetModuleConfig();
+ return pOpt ? pOpt->GetTblMode() : TBLVAR_CHGABS;
+}
+
+void RepaintPagePreview( ViewShell* pVwSh, const SwRect& rRect )
+{
+ SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
+ if (pSfxVwSh && pSfxVwSh->ISA( SwPagePreView ))
+ ((SwPagePreView *)pSfxVwSh)->RepaintCoreRect( rRect );
+}
+
+BOOL JumpToSwMark( ViewShell* pVwSh, const String& rMark )
+{
+ SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
+ if( pSfxVwSh && pSfxVwSh->ISA( SwView ) )
+ return ((SwView *)pSfxVwSh)->JumpToSwMark( rMark );
+ return FALSE;
+}
+
+void SwEditWin::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ Window::DataChanged( rDCEvt );
+
+ SwWrtShell* pSh = GetView().GetWrtShellPtr();
+ //#99906# DataChanged() is sometimes called prior to creating
+ // the SwWrtShell
+ if(!pSh)
+ return;
+ BOOL bViewWasLocked = pSh->IsViewLocked(), bUnlockPaint = FALSE;
+ pSh->LockView( TRUE );
+ switch( rDCEvt.GetType() )
+ {
+ case DATACHANGED_SETTINGS:
+ // ScrollBars neu anordnen bzw. Resize ausloesen, da sich
+ // ScrollBar-Groesse geaendert haben kann. Dazu muss dann im
+ // Resize-Handler aber auch die Groesse der ScrollBars aus
+ // den Settings abgefragt werden.
+ if( rDCEvt.GetFlags() & SETTINGS_STYLE )
+ {
+ pSh->LockPaint();
+ bUnlockPaint = TRUE;
+ ViewShell::DeleteReplacementBitmaps();
+ GetView().InvalidateBorder(); //Scrollbarbreiten
+ }
+ break;
+
+ case DATACHANGED_PRINTER:
+ case DATACHANGED_DISPLAY:
+ case DATACHANGED_FONTS:
+ case DATACHANGED_FONTSUBSTITUTION:
+ pSh->LockPaint();
+ bUnlockPaint = TRUE;
+ GetView().GetDocShell()->UpdateFontList(); //z.B. Druckerwechsel
+ break;
+ }
+ pSh->LockView( bViewWasLocked );
+ if( bUnlockPaint )
+ pSh->UnlockPaint();
+}
+
diff --git a/sw/source/ui/docvw/frmsidebarwincontainer.cxx b/sw/source/ui/docvw/frmsidebarwincontainer.cxx
new file mode 100644
index 000000000000..b5e406dcf69b
--- /dev/null
+++ b/sw/source/ui/docvw/frmsidebarwincontainer.cxx
@@ -0,0 +1,216 @@
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: $
+ * $Revision: $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+#include <frmsidebarwincontainer.hxx>
+
+#include <map>
+#include <fmtfld.hxx>
+#include <txtfld.hxx>
+#include <SidebarWin.hxx>
+
+namespace {
+ struct SidebarWinKey
+ {
+ const xub_StrLen mnIndex;
+
+ explicit SidebarWinKey( const xub_StrLen nIndex )
+ : mnIndex( nIndex )
+ {}
+
+ bool operator < ( const SidebarWinKey& rSidebarWinKey ) const
+ {
+ return mnIndex < rSidebarWinKey.mnIndex;
+ }
+ };
+
+ struct SidebarWinOrder
+ {
+ sal_Bool operator()( const SidebarWinKey& rSidebarWinKeyA,
+ const SidebarWinKey& rSidebarWinKeyB ) const
+ {
+ return rSidebarWinKeyA < rSidebarWinKeyB;
+ }
+ };
+
+ typedef ::std::map < SidebarWinKey, sw::sidebarwindows::SwSidebarWin*, SidebarWinOrder > SidebarWinContainer;
+
+ struct FrmKey
+ {
+ const SwFrm* mpFrm;
+
+ explicit FrmKey( const SwFrm* pFrm )
+ : mpFrm( pFrm )
+ {}
+
+ bool operator < ( const FrmKey& rFrmKey ) const
+ {
+ return mpFrm < rFrmKey.mpFrm;
+ }
+ };
+
+ struct FrmOrder
+ {
+ sal_Bool operator()( const FrmKey& rFrmKeyA,
+ const FrmKey& rFrmKeyB ) const
+ {
+ return rFrmKeyA < rFrmKeyB;
+ }
+ };
+
+ typedef ::std::map < FrmKey, SidebarWinContainer, FrmOrder > _FrmSidebarWinContainer;
+}
+
+namespace sw { namespace sidebarwindows {
+
+class FrmSidebarWinContainer : public _FrmSidebarWinContainer
+{
+};
+
+SwFrmSidebarWinContainer::SwFrmSidebarWinContainer()
+ : mpFrmSidebarWinContainer( new FrmSidebarWinContainer() )
+{}
+
+SwFrmSidebarWinContainer::~SwFrmSidebarWinContainer()
+{
+ mpFrmSidebarWinContainer->clear();
+ delete mpFrmSidebarWinContainer;
+}
+
+bool SwFrmSidebarWinContainer::insert( const SwFrm& rFrm,
+ const SwFmtFld& rFmtFld,
+ SwSidebarWin& rSidebarWin )
+{
+ bool bInserted( false );
+
+ FrmKey aFrmKey( &rFrm );
+ SidebarWinContainer& rSidebarWinContainer = (*mpFrmSidebarWinContainer)[ aFrmKey ];
+
+ SidebarWinKey aSidebarWinKey( *(rFmtFld.GetTxtFld()->GetStart()) );
+ if ( rSidebarWinContainer.empty() ||
+ rSidebarWinContainer.find( aSidebarWinKey) == rSidebarWinContainer.end() )
+ {
+ rSidebarWinContainer[ aSidebarWinKey ] = &rSidebarWin;
+ bInserted = true;
+ }
+
+ return bInserted;
+}
+
+bool SwFrmSidebarWinContainer::remove( const SwFrm& rFrm,
+ const SwSidebarWin& rSidebarWin )
+{
+ bool bRemoved( false );
+
+ FrmKey aFrmKey( &rFrm );
+ FrmSidebarWinContainer::iterator aFrmIter = mpFrmSidebarWinContainer->find( aFrmKey );
+ if ( aFrmIter != mpFrmSidebarWinContainer->end() )
+ {
+ SidebarWinContainer& rSidebarWinContainer = (*aFrmIter).second;
+ for ( SidebarWinContainer::iterator aIter = rSidebarWinContainer.begin();
+ aIter != rSidebarWinContainer.end();
+ ++aIter )
+ {
+ if ( (*aIter).second == &rSidebarWin )
+ {
+ rSidebarWinContainer.erase( aIter );
+ bRemoved = true;
+ break;
+ }
+ }
+ }
+
+ return bRemoved;
+}
+
+bool SwFrmSidebarWinContainer::empty( const SwFrm& rFrm )
+{
+ bool bEmpty( true );
+
+ FrmKey aFrmKey( &rFrm );
+ FrmSidebarWinContainer::iterator aFrmIter = mpFrmSidebarWinContainer->find( aFrmKey );
+ if ( aFrmIter != mpFrmSidebarWinContainer->end() )
+ {
+ bEmpty = (*aFrmIter).second.empty();
+ }
+
+ return bEmpty;
+}
+
+SwSidebarWin* SwFrmSidebarWinContainer::get( const SwFrm& rFrm,
+ const sal_Int32 nIndex )
+{
+ SwSidebarWin* pRet( 0 );
+
+ FrmKey aFrmKey( &rFrm );
+ FrmSidebarWinContainer::iterator aFrmIter = mpFrmSidebarWinContainer->find( aFrmKey );
+ if ( aFrmIter != mpFrmSidebarWinContainer->end() )
+ {
+ SidebarWinContainer& rSidebarWinContainer = (*aFrmIter).second;
+ sal_Int32 nCounter( nIndex );
+ for ( SidebarWinContainer::iterator aIter = rSidebarWinContainer.begin();
+ nCounter >= 0 && aIter != rSidebarWinContainer.end();
+ ++aIter )
+ {
+ if ( nCounter == 0 )
+ {
+ pRet = (*aIter).second;
+ break;
+ }
+
+ --nCounter;
+ }
+ }
+
+ return pRet;
+}
+
+void SwFrmSidebarWinContainer::getAll( const SwFrm& rFrm,
+ std::vector< Window* >* pSidebarWins )
+{
+ pSidebarWins->clear();
+
+ FrmKey aFrmKey( &rFrm );
+ FrmSidebarWinContainer::iterator aFrmIter = mpFrmSidebarWinContainer->find( aFrmKey );
+ if ( aFrmIter != mpFrmSidebarWinContainer->end() )
+ {
+ SidebarWinContainer& rSidebarWinContainer = (*aFrmIter).second;
+ for ( SidebarWinContainer::iterator aIter = rSidebarWinContainer.begin();
+ aIter != rSidebarWinContainer.end();
+ ++aIter )
+ {
+ pSidebarWins->push_back( (*aIter).second );
+ }
+ }
+}
+
+} } // eof of namespace sw::sidebarwindows::
diff --git a/sw/source/ui/docvw/frmsidebarwincontainer.hxx b/sw/source/ui/docvw/frmsidebarwincontainer.hxx
new file mode 100644
index 000000000000..1583f36a0bb6
--- /dev/null
+++ b/sw/source/ui/docvw/frmsidebarwincontainer.hxx
@@ -0,0 +1,73 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: $
+ * $Revision: $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _FRMSIDEBARWINCONTAINER_HXX
+#define _FRMSIDEBARWINCONTAINER_HXX
+
+#include <sal/types.h>
+#include <vector>
+
+class SwFrm;
+class SwFmtFld;
+class Window;
+
+namespace sw { namespace sidebarwindows {
+
+class SwSidebarWin;
+class FrmSidebarWinContainer;
+
+class SwFrmSidebarWinContainer
+{
+ public:
+ SwFrmSidebarWinContainer();
+ ~SwFrmSidebarWinContainer();
+
+ bool insert( const SwFrm& rFrm,
+ const SwFmtFld& rFmtFld,
+ SwSidebarWin& rSidebarWin );
+
+ bool remove( const SwFrm& rFrm,
+ const SwSidebarWin& rSidebarWin );
+
+ bool empty( const SwFrm& rFrm );
+
+ SwSidebarWin* get( const SwFrm& rFrm,
+ const sal_Int32 nIndex );
+
+ void getAll( const SwFrm& rFrm,
+ std::vector< Window* >* pSidebarWins );
+
+ private:
+ FrmSidebarWinContainer* mpFrmSidebarWinContainer;
+};
+
+} } // eof of namespace sw::sidebarwindows::
+
+#endif
+
diff --git a/sw/source/ui/docvw/makefile.mk b/sw/source/ui/docvw/makefile.mk
new file mode 100644
index 000000000000..a2914b2f86b7
--- /dev/null
+++ b/sw/source/ui/docvw/makefile.mk
@@ -0,0 +1,69 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org 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 version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sw
+TARGET=docvw
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/inc$/swpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/inc$/sw.mk
+
+# --- Files --------------------------------------------------------
+
+SRS1NAME=$(TARGET)
+SRC1FILES = \
+ access.src \
+ docvw.src \
+ annotation.src
+
+SLOFILES = \
+ $(SLO)$/edtdd.obj \
+ $(SLO)$/edtwin.obj \
+ $(SLO)$/edtwin2.obj \
+ $(SLO)$/edtwin3.obj \
+ $(SLO)$/romenu.obj \
+ $(SLO)$/srcedtw.obj \
+ $(SLO)$/PostItMgr.obj \
+ $(SLO)$/frmsidebarwincontainer.obj \
+ $(SLO)$/AnchorOverlayObject.obj \
+ $(SLO)$/ShadowOverlayObject.obj \
+ $(SLO)$/SidebarWin.obj \
+ $(SLO)$/SidebarWinAcc.obj \
+ $(SLO)$/AnnotationWin.obj \
+ $(SLO)$/AnnotationMenuButton.obj \
+ $(SLO)$/SidebarTxtControl.obj \
+ $(SLO)$/SidebarTxtControlAcc.obj
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/sw/source/ui/docvw/romenu.cxx b/sw/source/ui/docvw/romenu.cxx
new file mode 100644
index 000000000000..f793a7f854b7
--- /dev/null
+++ b/sw/source/ui/docvw/romenu.cxx
@@ -0,0 +1,519 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+#include <hintids.hxx>
+
+
+#include <tools/urlobj.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/msgbox.hxx>
+#include <sot/formats.hxx>
+#include <svl/eitem.hxx>
+#include <svl/stritem.hxx>
+#include <unotools/pathoptions.hxx>
+#include <svtools/filter.hxx>
+#include <svtools/imap.hxx>
+#include <svtools/inetimg.hxx>
+#include <svtools/transfer.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svx/xoutbmp.hxx>
+#include <svx/gallery.hxx>
+#include <editeng/brshitem.hxx>
+
+
+#include <swunodef.hxx>
+#include <frmatr.hxx>
+#include <fmturl.hxx>
+#include <fmtinfmt.hxx>
+#include <docsh.hxx>
+#include <view.hxx>
+#include <wrtsh.hxx>
+#include <viewopt.hxx>
+#include <swmodule.hxx>
+#include <romenu.hxx>
+#include <pagedesc.hxx>
+#include <modcfg.hxx>
+
+#include <cmdid.h>
+#include <helpid.h>
+#include <docvw.hrc>
+#include <docvw.hrc>
+#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
+#include <com/sun/star/ui/dialogs/XFilterManager.hpp>
+#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
+#include <sfx2/filedlghelper.hxx>
+
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::ui::dialogs;
+using namespace ::sfx2;
+
+SwReadOnlyPopup::~SwReadOnlyPopup()
+{
+ String *pDel = (String*)aThemeList.First();
+ while ( pDel )
+ {
+ delete pDel;
+ pDel = (String*)aThemeList.Next();
+ }
+ delete pImageMap;
+ delete pTargetURL;
+}
+
+
+
+void SwReadOnlyPopup::Check( USHORT nMID, USHORT nSID, SfxDispatcher &rDis )
+{
+ SfxPoolItem *_pItem = 0;
+ SfxItemState eState = rDis.GetBindings()->QueryState( nSID, _pItem );
+ if (eState >= SFX_ITEM_AVAILABLE)
+ {
+ EnableItem( nMID, TRUE );
+ if (_pItem)
+ {
+ CheckItem ( nMID, !_pItem->ISA(SfxVoidItem) &&
+ _pItem->ISA(SfxBoolItem) &&
+ ((SfxBoolItem*)_pItem)->GetValue());
+ //remove full screen entry when not in full screen mode
+ if(SID_WIN_FULLSCREEN == nSID && !IsItemChecked(SID_WIN_FULLSCREEN) )
+ EnableItem(nMID, FALSE);
+ }
+ }
+ else
+ EnableItem( nMID, FALSE );
+
+ delete _pItem;
+}
+
+
+SwReadOnlyPopup::SwReadOnlyPopup( const Point &rDPos, SwView &rV ) :
+ PopupMenu( SW_RES(MN_READONLY_POPUP) ),
+ rView ( rV ),
+ rDocPos( rDPos ),
+ pImageMap( 0 ),
+ pTargetURL( 0 )
+{
+ bGrfToGalleryAsLnk = SW_MOD()->GetModuleConfig()->IsGrfToGalleryAsLnk();
+ SwWrtShell &rSh = rView.GetWrtShell();
+ rSh.IsURLGrfAtPos( rDocPos, &sURL, &sTargetFrameName, &sDescription );
+ if ( !sURL.Len() )
+ {
+ SwContentAtPos aCntntAtPos( SwContentAtPos::SW_INETATTR );
+ if( rSh.GetContentAtPos( rDocPos, aCntntAtPos, FALSE))
+ {
+ SwFmtINetFmt &rIItem = *(SwFmtINetFmt*)aCntntAtPos.aFnd.pAttr;
+ sURL = rIItem.GetValue();
+ sTargetFrameName = rIItem.GetTargetFrame();
+ sDescription = aCntntAtPos.sStr;
+ }
+ }
+
+ BOOL bLink = FALSE;
+ const Graphic *pGrf;
+ if ( 0 == (pGrf = rSh.GetGrfAtPos( rDocPos, sGrfName, bLink )) )
+ {
+ EnableItem( MN_READONLY_SAVEGRAPHIC, FALSE );
+ EnableItem( MN_READONLY_COPYGRAPHIC, FALSE );
+ }
+ else
+ {
+ aGraphic = *pGrf;
+ const SwFrmFmt* pGrfFmt = rSh.GetFmtFromObj( rDocPos );
+ const SfxPoolItem* pURLItem;
+ if( pGrfFmt && SFX_ITEM_SET == pGrfFmt->GetItemState(
+ RES_URL, TRUE, &pURLItem ))
+ {
+ const SwFmtURL& rURL = *(SwFmtURL*)pURLItem;
+ if( rURL.GetMap() )
+ pImageMap = new ImageMap( *rURL.GetMap() );
+ else if( rURL.GetURL().Len() )
+ pTargetURL = new INetImage( bLink ? sGrfName : aEmptyStr,
+ rURL.GetURL(),
+ rURL.GetTargetFrameName(),
+ aEmptyStr, Size() );
+ }
+ }
+
+ BOOL bEnableGraphicToGallery;
+ if ( TRUE == (bEnableGraphicToGallery = bLink) )
+ {
+ GalleryExplorer::FillThemeList( aThemeList );
+ if ( aThemeList.Count() )
+ {
+ PopupMenu *pMenu = GetPopupMenu(MN_READONLY_GRAPHICTOGALLERY);
+ pMenu->CheckItem( MN_READONLY_TOGALLERYLINK, bGrfToGalleryAsLnk );
+ pMenu->CheckItem( MN_READONLY_TOGALLERYCOPY, !bGrfToGalleryAsLnk );
+ for ( USHORT i=0; i < aThemeList.Count(); ++i )
+ pMenu->InsertItem( MN_READONLY_GRAPHICTOGALLERY+i + 3,
+ *(String*)aThemeList.GetObject( i ) );
+ }
+ else
+ bEnableGraphicToGallery = FALSE;
+ }
+ EnableItem( MN_READONLY_GRAPHICTOGALLERY, bEnableGraphicToGallery );
+
+ SfxViewFrame * pVFrame = rV.GetViewFrame();
+ SfxDispatcher &rDis = *pVFrame->GetDispatcher();
+ const SwPageDesc &rDesc = rSh.GetPageDesc( rSh.GetCurPageDesc() );
+ pItem = &rDesc.GetMaster().GetBackground();
+ BOOL bEnableBackGallery = FALSE,
+ bEnableBack = FALSE;
+
+ if ( GPOS_NONE != pItem->GetGraphicPos() )
+ {
+ bEnableBack = TRUE;
+ if ( pItem->GetGraphicLink() )
+ {
+ if ( !aThemeList.Count() )
+ GalleryExplorer::FillThemeList( aThemeList );
+ if ( aThemeList.Count() )
+ {
+ PopupMenu *pMenu = GetPopupMenu(MN_READONLY_BACKGROUNDTOGALLERY);
+ pMenu->CheckItem( MN_READONLY_TOGALLERYLINK, bGrfToGalleryAsLnk );
+ pMenu->CheckItem( MN_READONLY_TOGALLERYCOPY, !bGrfToGalleryAsLnk );
+ bEnableBackGallery = TRUE;
+ for ( USHORT i=0; i < aThemeList.Count(); ++i )
+ pMenu->InsertItem( MN_READONLY_BACKGROUNDTOGALLERY+i + 3,
+ *(String*)aThemeList.GetObject( i ) );
+ }
+ }
+ }
+ EnableItem( MN_READONLY_SAVEBACKGROUND, bEnableBack );
+ EnableItem( MN_READONLY_BACKGROUNDTOGALLERY, bEnableBackGallery );
+
+ if ( !rSh.GetViewOptions()->IsGraphic() )
+ CheckItem( MN_READONLY_GRAPHICOFF );
+ else
+ EnableItem( MN_READONLY_LOADGRAPHIC, FALSE );
+
+ BOOL bReloadFrame = 0 != rSh.GetView().GetViewFrame()->GetFrame().GetParentFrame();
+ EnableItem( MN_READONLY_RELOAD_FRAME,
+ bReloadFrame );
+ EnableItem( MN_READONLY_RELOAD, !bReloadFrame);
+
+ Check( MN_READONLY_EDITDOC, SID_EDITDOC, rDis );
+ Check( MN_READONLY_SELECTION_MODE, FN_READONLY_SELECTION_MODE, rDis );
+ Check( MN_READONLY_SOURCEVIEW, SID_SOURCEVIEW, rDis );
+ Check( MN_READONLY_BROWSE_BACKWARD, SID_BROWSE_BACKWARD,rDis );
+ Check( MN_READONLY_BROWSE_FORWARD, SID_BROWSE_FORWARD, rDis );
+#ifdef WNT
+ Check( MN_READONLY_PLUGINOFF, SID_PLUGINS_ACTIVE, rDis );
+#endif
+ Check( MN_READONLY_OPENURL, SID_OPENDOC, rDis );
+ Check( MN_READONLY_OPENURLNEW, SID_OPENDOC, rDis );
+
+ SfxPoolItem* pState;
+
+ SfxItemState eState = pVFrame->GetBindings().QueryState( SID_COPY, pState );
+ Check( MN_READONLY_COPY, SID_COPY, rDis );
+ if(eState < SFX_ITEM_AVAILABLE)
+ EnableItem( MN_READONLY_COPY, FALSE );
+
+ eState = pVFrame->GetBindings().QueryState( SID_EDITDOC, pState );
+ if(eState < SFX_ITEM_DEFAULT ||
+ rSh.IsGlobalDoc() && rView.GetDocShell()->IsReadOnlyUI())
+ EnableItem( MN_READONLY_EDITDOC, FALSE );
+
+ if ( !sURL.Len() )
+ {
+ EnableItem( MN_READONLY_OPENURL, FALSE );
+ EnableItem( MN_READONLY_OPENURLNEW, FALSE );
+ EnableItem( MN_READONLY_COPYLINK, FALSE );
+ }
+ Check( SID_WIN_FULLSCREEN, SID_WIN_FULLSCREEN, rDis );
+
+ RemoveDisabledEntries( TRUE, TRUE );
+}
+
+void SwReadOnlyPopup::Execute( Window* pWin, const Point &rPixPos )
+{
+ USHORT nId = PopupMenu::Execute(
+ pWin,
+ rPixPos );
+ Execute(pWin, nId);
+}
+
+/*-- 17.03.2004 13:06:18---------------------------------------------------
+ execute the resulting ID only - necessary to support XContextMenuInterception
+ -----------------------------------------------------------------------*/
+void SwReadOnlyPopup::Execute( Window* pWin, USHORT nId )
+{
+ SwWrtShell &rSh = rView.GetWrtShell();
+ SfxDispatcher &rDis = *rView.GetViewFrame()->GetDispatcher();
+ if ( nId >= MN_READONLY_GRAPHICTOGALLERY )
+ {
+ String sTmp;
+ USHORT nSaveId;
+ if ( nId >= MN_READONLY_BACKGROUNDTOGALLERY )
+ {
+ nId -= MN_READONLY_BACKGROUNDTOGALLERY+3;
+ nSaveId = MN_READONLY_SAVEBACKGROUND;
+ sTmp = *pItem->GetGraphicLink();
+ }
+ else
+ {
+ nId -= MN_READONLY_GRAPHICTOGALLERY+3;
+ nSaveId = MN_READONLY_SAVEGRAPHIC;
+ sTmp = sGrfName;
+ }
+ if ( !bGrfToGalleryAsLnk )
+ sTmp = SaveGraphic( nSaveId );
+
+ if ( sTmp.Len() )
+ {
+ String sThemeName( *(String*)aThemeList.GetObject( nId ));
+ GalleryExplorer::InsertURL( sThemeName, sTmp );
+ }
+ return;
+ }
+
+ TransferDataContainer* pClipCntnr = 0;
+
+ USHORT nExecId = USHRT_MAX;
+ USHORT nFilter = USHRT_MAX;
+ switch( nId )
+ {
+ case SID_WIN_FULLSCREEN : nExecId = SID_WIN_FULLSCREEN; break;
+ case MN_READONLY_OPENURL: nFilter = URLLOAD_NOFILTER; break;
+ case MN_READONLY_OPENURLNEW: nFilter = URLLOAD_NEWVIEW; break;
+ case MN_READONLY_COPY: nExecId = SID_COPY; break;
+
+ case MN_READONLY_EDITDOC: nExecId = SID_EDITDOC; break;
+ case MN_READONLY_SELECTION_MODE: nExecId = FN_READONLY_SELECTION_MODE; break;
+ case MN_READONLY_RELOAD:
+ case MN_READONLY_RELOAD_FRAME:
+ rSh.GetView().GetViewFrame()->GetDispatcher()->Execute(SID_RELOAD);
+ break;
+
+ case MN_READONLY_BROWSE_BACKWARD: nExecId = SID_BROWSE_BACKWARD;break;
+ case MN_READONLY_BROWSE_FORWARD: nExecId = SID_BROWSE_FORWARD; break;
+ case MN_READONLY_SOURCEVIEW: nExecId = SID_SOURCEVIEW; break;
+ case MN_READONLY_SAVEGRAPHIC:
+ case MN_READONLY_SAVEBACKGROUND:
+ {
+ SaveGraphic( nId );
+ break;
+ }
+ case MN_READONLY_COPYLINK:
+ pClipCntnr = new TransferDataContainer;
+ pClipCntnr->CopyString( sURL );
+ break;
+
+ case MN_READONLY_COPYGRAPHIC:
+ pClipCntnr = new TransferDataContainer;
+ pClipCntnr->CopyGraphic( aGraphic );
+
+ if( pImageMap )
+ pClipCntnr->CopyImageMap( *pImageMap );
+ if( pTargetURL )
+ pClipCntnr->CopyINetImage( *pTargetURL );
+ break;
+
+ case MN_READONLY_LOADGRAPHIC:
+ {
+ BOOL bModified = rSh.IsModified();
+ SwViewOption aOpt( *rSh.GetViewOptions() );
+ aOpt.SetGraphic( TRUE );
+ rSh.ApplyViewOptions( aOpt );
+ if(!bModified)
+ rSh.ResetModified();
+ break;
+ }
+ case MN_READONLY_GRAPHICOFF: nExecId = FN_VIEW_GRAPHIC; break;
+#ifdef WNT
+ case MN_READONLY_PLUGINOFF: nExecId = SID_PLUGINS_ACTIVE; break;
+#endif
+ case MN_READONLY_TOGALLERYLINK:
+ SW_MOD()->GetModuleConfig()->SetGrfToGalleryAsLnk( TRUE );
+ break;
+ case MN_READONLY_TOGALLERYCOPY:
+ SW_MOD()->GetModuleConfig()->SetGrfToGalleryAsLnk( FALSE );
+ break;
+
+ default: //forward the id to the SfxBindings
+ nExecId = nId;
+ }
+ if( USHRT_MAX != nExecId )
+ rDis.GetBindings()->Execute( nExecId );
+ if( USHRT_MAX != nFilter )
+ ::LoadURL( sURL, &rSh, nFilter, &sTargetFrameName);
+
+ if( pClipCntnr )
+ {
+ STAR_REFERENCE( datatransfer::XTransferable ) xRef( pClipCntnr );
+ if( pClipCntnr->HasAnyData() )
+ pClipCntnr->CopyToClipboard( pWin );
+ }
+}
+static void lcl_GetPreferedExtension( String &rExt, const Graphic &rGrf )
+{
+ // dann ggfs. ueber die native-Info der Grafik den "besten"
+ // Filter vorschlagen
+ const sal_Char* pExt = "png";
+ switch( const_cast<Graphic&>(rGrf).GetLink().GetType() )
+ {
+ case GFX_LINK_TYPE_NATIVE_GIF: pExt = "gif"; break;
+ case GFX_LINK_TYPE_NATIVE_TIF: pExt = "tif"; break;
+ case GFX_LINK_TYPE_NATIVE_WMF: pExt = "wmf"; break;
+ case GFX_LINK_TYPE_NATIVE_MET: pExt = "met"; break;
+ case GFX_LINK_TYPE_NATIVE_PCT: pExt = "pct"; break;
+ case GFX_LINK_TYPE_NATIVE_JPG: pExt = "jpg"; break;
+ default:; //prevent warning
+ }
+ rExt.AssignAscii( pExt );
+}
+
+
+String SwReadOnlyPopup::SaveGraphic( USHORT nId )
+{
+
+ //Namen der Grafik herausfischen.
+ String aName;
+ if ( MN_READONLY_SAVEBACKGROUND == nId )
+ {
+ if ( pItem->GetGraphicLink() )
+ sGrfName = *pItem->GetGraphicLink();
+ ((SvxBrushItem*)pItem)->SetDoneLink( Link() );
+ const Graphic *pGrf = pItem->GetGraphic();
+ if ( pGrf )
+ {
+ aGraphic = *pGrf;
+ if ( pItem->GetGraphicLink() )
+ sGrfName = *pItem->GetGraphicLink();
+ }
+ else
+ return aEmptyStr;
+ }
+ return ExportGraphic( aGraphic, sGrfName );
+}
+
+String ExportGraphic( const Graphic &rGraphic, const String &rGrfName )
+{
+ SvtPathOptions aPathOpt;
+ String sGrfPath( aPathOpt.GetGraphicPath() );
+
+ FileDialogHelper aDlgHelper( TemplateDescription::FILESAVE_SIMPLE, 0 );
+ Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker();
+
+// aExpDlg.SetHelpId(HID_FILEDLG_ROMENU);
+ INetURLObject aPath;
+ aPath.SetSmartURL( sGrfPath );
+
+ //Namen der Grafik herausfischen.
+ String aName = rGrfName;
+
+ aDlgHelper.SetTitle( SW_RESSTR(STR_EXPORT_GRAFIK_TITLE));
+ aDlgHelper.SetDisplayDirectory( aPath.GetMainURL(INetURLObject::DECODE_TO_IURI) );
+ INetURLObject aURL;
+ aURL.SetSmartURL( aName );
+ aDlgHelper.SetFileName( aURL.GetName() );
+
+ GraphicFilter& rGF = *GraphicFilter::GetGraphicFilter();
+ const USHORT nCount = rGF.GetExportFormatCount();
+
+ String aExt( aURL.GetExtension() );
+ if( !aExt.Len() )
+ lcl_GetPreferedExtension( aExt, rGraphic );
+
+ aExt.ToLowerAscii();
+ USHORT nDfltFilter = USHRT_MAX;
+
+ Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY);
+
+ for ( USHORT i = 0; i < nCount; i++ )
+ {
+ xFltMgr->appendFilter( rGF.GetExportFormatName( i ), rGF.GetExportWildcard( i ) );
+ if ( COMPARE_EQUAL == aExt.CompareIgnoreCaseToAscii(rGF.GetExportFormatShortName( i ).ToLowerAscii() ))
+ nDfltFilter = i;
+ }
+ if ( USHRT_MAX == nDfltFilter )
+ {
+ //"falsche" Extension?
+ lcl_GetPreferedExtension( aExt, rGraphic );
+ for ( USHORT i = 0; i < nCount; ++i )
+ if ( aExt == rGF.GetExportFormatShortName( i ).ToLowerAscii() )
+ {
+ nDfltFilter = i;
+ break;
+ }
+ }
+
+ if( USHRT_MAX != nDfltFilter )
+ {
+ xFltMgr->setCurrentFilter( rGF.GetExportFormatName( nDfltFilter ) ) ;
+
+ if( aDlgHelper.Execute() == ERRCODE_NONE )
+ {
+ String sPath( xFP->getFiles().getConstArray()[0] );
+ //verwendeten Pfad merken - bitte nicht wieder wegoptimieren!
+ aPath.SetSmartURL( sPath);
+ sGrfPath = aPath.GetPath();
+
+ if( rGrfName.Len() &&
+ nDfltFilter == rGF.GetExportFormatNumber( xFltMgr->getCurrentFilter()))
+ {
+ //Versuchen die Originalgrafik zu speichern.
+ SfxMedium aIn( rGrfName, STREAM_READ | STREAM_NOCREATE,
+ TRUE );
+ if( aIn.GetInStream() && !aIn.GetInStream()->GetError() )
+ {
+ SfxMedium aOut( sPath, STREAM_WRITE | STREAM_SHARE_DENYNONE,
+ FALSE);
+ if( aOut.GetOutStream() && !aOut.GetOutStream()->GetError())
+ {
+ *aOut.GetOutStream() << *aIn.GetInStream();
+ if ( 0 == aIn.GetError() )
+ {
+ aOut.Close();
+ aOut.Commit();
+ if ( 0 == aOut.GetError() )
+ return sPath;
+ }
+ }
+ }
+ }
+
+ USHORT nFilter;
+ if ( xFltMgr->getCurrentFilter().getLength() && rGF.GetExportFormatCount() )
+ nFilter = rGF.GetExportFormatNumber( xFltMgr->getCurrentFilter() );
+ else
+ nFilter = GRFILTER_FORMAT_DONTKNOW;
+ String aFilter( rGF.GetExportFormatShortName( nFilter ) );
+ XOutBitmap::WriteGraphic( rGraphic, sPath, aFilter,
+ XOUTBMP_DONT_EXPAND_FILENAME );
+ return sPath;
+ }
+ }
+ return aEmptyStr;
+}
+
+
+
diff --git a/sw/source/ui/docvw/romenu.hxx b/sw/source/ui/docvw/romenu.hxx
new file mode 100644
index 000000000000..2d60689c6854
--- /dev/null
+++ b/sw/source/ui/docvw/romenu.hxx
@@ -0,0 +1,75 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _ROMENU_HXX
+#define _ROMENU_HXX
+
+
+#ifndef _GRAPH_HXX //autogen
+#include <vcl/graph.hxx>
+#endif
+#include <tools/list.hxx>
+#ifndef _MENU_HXX //autogen
+#include <vcl/menu.hxx>
+#endif
+
+class SwView;
+class SfxDispatcher;
+class SvxBrushItem;
+class ImageMap;
+class INetImage;
+
+class SwReadOnlyPopup : public PopupMenu
+{
+ SwView &rView;
+ const SvxBrushItem *pItem;
+ const Point &rDocPos;
+ Graphic aGraphic;
+ String sURL,
+ sTargetFrameName,
+ sDescription,
+ sGrfName;
+ List aThemeList;
+ BOOL bGrfToGalleryAsLnk;
+ ImageMap* pImageMap;
+ INetImage* pTargetURL;
+
+ void Check( USHORT nMID, USHORT nSID, SfxDispatcher &rDis );
+ String SaveGraphic( USHORT nId );
+
+ using PopupMenu::Execute;
+
+public:
+ SwReadOnlyPopup( const Point &rDPos, SwView &rV );
+ ~SwReadOnlyPopup();
+
+ void Execute( Window* pWin, const Point &rPPos );
+ void Execute( Window* pWin, USHORT nId );
+};
+
+
+#endif
+
diff --git a/sw/source/ui/docvw/srcedtw.cxx b/sw/source/ui/docvw/srcedtw.cxx
new file mode 100644
index 000000000000..55a0cb47e296
--- /dev/null
+++ b/sw/source/ui/docvw/srcedtw.cxx
@@ -0,0 +1,1103 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+
+#include <hintids.hxx>
+#ifndef _CMDID_H
+#include <cmdid.h>
+#endif
+
+
+#include <svtools/textview.hxx>
+#ifndef _SVX_SVXIDS_HRC
+#include <svx/svxids.hrc>
+#endif
+#ifndef _SCRBAR_HXX //autogen
+#include <vcl/scrbar.hxx>
+#endif
+#include <sfx2/dispatch.hxx>
+#include <sfx2/app.hxx>
+#include <svtools/htmltokn.h>
+#include <svtools/txtattr.hxx>
+#include <unotools/sourceviewconfig.hxx>
+#include <svtools/colorcfg.hxx>
+#include <editeng/flstitem.hxx>
+#include <vcl/metric.hxx>
+#include <svtools/ctrltool.hxx>
+#include <tools/time.hxx>
+#include <swmodule.hxx>
+#ifndef _DOCSH_HXX
+#include <docsh.hxx>
+#endif
+#ifndef _SRCVIEW_HXX
+#include <srcview.hxx>
+#endif
+#ifndef _HELPID_H
+#include <helpid.h>
+#endif
+
+
+struct SwTextPortion
+{
+ USHORT nLine;
+ USHORT nStart, nEnd;
+ svtools::ColorConfigEntry eType;
+};
+
+#define MAX_SYNTAX_HIGHLIGHT 20
+#define MAX_HIGHLIGHTTIME 200
+#define SYNTAX_HIGHLIGHT_TIMEOUT 200
+
+SV_DECL_VARARR(SwTextPortions, SwTextPortion,16,16)
+
+/* -----------------15.01.97 12.07-------------------
+
+--------------------------------------------------*/
+
+SV_IMPL_VARARR(SwTextPortions, SwTextPortion)
+
+/*-----------------15.01.97 12.08-------------------
+
+--------------------------------------------------*/
+
+static void lcl_Highlight(const String& rSource, SwTextPortions& aPortionList)
+{
+ const sal_Unicode cOpenBracket = '<';
+ const sal_Unicode cCloseBracket= '>';
+ const sal_Unicode cSlash = '/';
+ const sal_Unicode cExclamation = '!';
+ const sal_Unicode cMinus = '-';
+ const sal_Unicode cSpace = ' ';
+ const sal_Unicode cTab = 0x09;
+ const sal_Unicode cLF = 0x0a;
+ const sal_Unicode cCR = 0x0d;
+
+
+ const USHORT nStrLen = rSource.Len();
+ USHORT nInsert = 0; // Anzahl der eingefuegten Portions
+ USHORT nActPos = 0; //Position, an der '<' gefunden wurde
+ USHORT nOffset = 0; //Offset von nActPos zur '<'
+ USHORT nPortStart = USHRT_MAX; // fuer die TextPortion
+ USHORT nPortEnd = 0; //
+ SwTextPortion aText;
+ while(nActPos < nStrLen)
+ {
+ svtools::ColorConfigEntry eFoundType = svtools::HTMLUNKNOWN;
+ if(rSource.GetChar(nActPos) == cOpenBracket && nActPos < nStrLen - 2 )
+ {
+ // 'leere' Portion einfuegen
+ if(nPortEnd < nActPos - 1 )
+ {
+ aText.nLine = 0;
+ // am Anfang nicht verschieben
+ aText.nStart = nPortEnd;
+ if(nInsert)
+ aText.nStart += 1;
+ aText.nEnd = nActPos - 1;
+ aText.eType = svtools::HTMLUNKNOWN;
+ aPortionList.Insert(aText, nInsert++);
+ }
+ sal_Unicode cFollowFirst = rSource.GetChar((xub_StrLen)(nActPos + 1));
+ sal_Unicode cFollowNext = rSource.GetChar((xub_StrLen)(nActPos + 2));
+ if(cExclamation == cFollowFirst)
+ {
+ // "<!" SGML oder Kommentar
+ if(cMinus == cFollowNext &&
+ nActPos < nStrLen - 3 && cMinus == rSource.GetChar((xub_StrLen)(nActPos + 3)))
+ {
+ eFoundType = svtools::HTMLCOMMENT;
+ }
+ else
+ eFoundType = svtools::HTMLSGML;
+ nPortStart = nActPos;
+ nPortEnd = nActPos + 1;
+ }
+ else if(cSlash == cFollowFirst)
+ {
+ // "</" Slash ignorieren
+ nPortStart = nActPos;
+ nActPos++;
+ nOffset++;
+ }
+ if(svtools::HTMLUNKNOWN == eFoundType)
+ {
+ //jetzt koennte hier ein keyword folgen
+ USHORT nSrchPos = nActPos;
+ while(++nSrchPos < nStrLen - 1)
+ {
+ sal_Unicode cNext = rSource.GetChar(nSrchPos);
+ if( cNext == cSpace ||
+ cNext == cTab ||
+ cNext == cLF ||
+ cNext == cCR)
+ break;
+ else if(cNext == cCloseBracket)
+ {
+ break;
+ }
+ }
+ if(nSrchPos > nActPos + 1)
+ {
+ //irgend ein String wurde gefunden
+ String sToken = rSource.Copy(nActPos + 1, nSrchPos - nActPos - 1 );
+ sToken.ToUpperAscii();
+ int nToken = ::GetHTMLToken(sToken);
+ if(nToken)
+ {
+ //Token gefunden
+ eFoundType = svtools::HTMLKEYWORD;
+ nPortEnd = nSrchPos;
+ nPortStart = nActPos;
+ }
+ else
+ {
+ //was war das denn?
+#if OSL_DEBUG_LEVEL > 1
+ DBG_ERROR("Token nicht erkannt!");
+ DBG_ERROR(ByteString(sToken, gsl_getSystemTextEncoding()).GetBuffer());
+#endif
+ }
+
+ }
+ }
+ // jetzt muss noch '>' gesucht werden
+ if(svtools::HTMLUNKNOWN != eFoundType)
+ {
+ BOOL bFound = FALSE;
+ for(USHORT i = nPortEnd; i < nStrLen; i++)
+ if(cCloseBracket == rSource.GetChar(i))
+ {
+ bFound = TRUE;
+ nPortEnd = i;
+ break;
+ }
+ if(!bFound && (eFoundType == svtools::HTMLCOMMENT))
+ {
+ // Kommentar ohne Ende in dieser Zeile
+ bFound = TRUE;
+ nPortEnd = nStrLen - 1;
+ }
+
+ if(bFound ||(eFoundType == svtools::HTMLCOMMENT))
+ {
+ SwTextPortion aTextPortion;
+ aTextPortion.nLine = 0;
+ aTextPortion.nStart = nPortStart + 1;
+ aTextPortion.nEnd = nPortEnd;
+ aTextPortion.eType = eFoundType;
+ aPortionList.Insert(aTextPortion, nInsert++);
+ eFoundType = svtools::HTMLUNKNOWN;
+ }
+
+ }
+ }
+ nActPos++;
+ }
+ if(nInsert && nPortEnd < nActPos - 1)
+ {
+ aText.nLine = 0;
+ aText.nStart = nPortEnd + 1;
+ aText.nEnd = nActPos - 1;
+ aText.eType = svtools::HTMLUNKNOWN;
+ aPortionList.Insert(aText, nInsert++);
+ }
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+SwSrcEditWindow::SwSrcEditWindow( Window* pParent, SwSrcView* pParentView ) :
+ Window( pParent, WB_BORDER|WB_CLIPCHILDREN ),
+
+ pTextEngine(0),
+
+ pOutWin(0),
+ pHScrollbar(0),
+ pVScrollbar(0),
+
+ pSrcView(pParentView),
+ pSourceViewConfig(new utl::SourceViewConfig),
+
+ nCurTextWidth(0),
+ nStartLine(USHRT_MAX),
+ eSourceEncoding(gsl_getSystemTextEncoding()),
+ bDoSyntaxHighlight(TRUE),
+ bHighlighting(FALSE)
+{
+ SetHelpId(HID_SOURCE_EDITWIN);
+ CreateTextEngine();
+ pSourceViewConfig->AddListener(this);
+}
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+ SwSrcEditWindow::~SwSrcEditWindow()
+{
+ pSourceViewConfig->RemoveListener(this);
+ delete pSourceViewConfig;
+ aSyntaxIdleTimer.Stop();
+ if ( pTextEngine )
+ {
+ EndListening( *pTextEngine );
+ pTextEngine->RemoveView( pTextView );
+
+ delete pHScrollbar;
+ delete pVScrollbar;
+
+ delete pTextView;
+ delete pTextEngine;
+ }
+ delete pOutWin;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+void SwSrcEditWindow::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ Window::DataChanged( rDCEvt );
+
+ switch ( rDCEvt.GetType() )
+ {
+ case DATACHANGED_SETTINGS:
+ // ScrollBars neu anordnen bzw. Resize ausloesen, da sich
+ // ScrollBar-Groesse geaendert haben kann. Dazu muss dann im
+ // Resize-Handler aber auch die Groesse der ScrollBars aus
+ // den Settings abgefragt werden.
+ if( rDCEvt.GetFlags() & SETTINGS_STYLE )
+ Resize();
+ break;
+ }
+}
+
+void SwSrcEditWindow::Resize()
+{
+ // ScrollBars, etc. passiert in Adjust...
+ if ( pTextView )
+ {
+ long nVisY = pTextView->GetStartDocPos().Y();
+ pTextView->ShowCursor();
+ Size aOutSz( GetOutputSizePixel() );
+ long nMaxVisAreaStart = pTextView->GetTextEngine()->GetTextHeight() - aOutSz.Height();
+ if ( nMaxVisAreaStart < 0 )
+ nMaxVisAreaStart = 0;
+ if ( pTextView->GetStartDocPos().Y() > nMaxVisAreaStart )
+ {
+ Point aStartDocPos( pTextView->GetStartDocPos() );
+ aStartDocPos.Y() = nMaxVisAreaStart;
+ pTextView->SetStartDocPos( aStartDocPos );
+ pTextView->ShowCursor();
+ }
+ long nScrollStd = GetSettings().GetStyleSettings().GetScrollBarSize();
+ Size aScrollSz(aOutSz.Width() - nScrollStd, nScrollStd );
+ Point aScrollPos(0, aOutSz.Height() - nScrollStd);
+
+ pHScrollbar->SetPosSizePixel( aScrollPos, aScrollSz);
+
+ aScrollSz.Width() = aScrollSz.Height();
+ aScrollSz.Height() = aOutSz.Height();
+ aScrollPos = Point(aOutSz.Width() - nScrollStd, 0);
+
+ pVScrollbar->SetPosSizePixel( aScrollPos, aScrollSz);
+ aOutSz.Width() -= nScrollStd;
+ aOutSz.Height() -= nScrollStd;
+ pOutWin->SetOutputSizePixel(aOutSz);
+ InitScrollBars();
+
+ // Zeile im ersten Resize setzen
+ if(USHRT_MAX != nStartLine)
+ {
+ if(nStartLine < pTextEngine->GetParagraphCount())
+ {
+ TextSelection aSel(TextPaM( nStartLine, 0 ), TextPaM( nStartLine, 0x0 ));
+ pTextView->SetSelection(aSel);
+ pTextView->ShowCursor();
+ }
+ nStartLine = USHRT_MAX;
+ }
+
+ if ( nVisY != pTextView->GetStartDocPos().Y() )
+ Invalidate();
+ }
+
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+void TextViewOutWin::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ Window::DataChanged( rDCEvt );
+
+ switch( rDCEvt.GetType() )
+ {
+ case DATACHANGED_SETTINGS:
+ // den Settings abgefragt werden.
+ if( rDCEvt.GetFlags() & SETTINGS_STYLE )
+ {
+ const Color &rCol = GetSettings().GetStyleSettings().GetWindowColor();
+ SetBackground( rCol );
+ Font aFont( pTextView->GetTextEngine()->GetFont() );
+ aFont.SetFillColor( rCol );
+ pTextView->GetTextEngine()->SetFont( aFont );
+ }
+ break;
+ }
+}
+
+void TextViewOutWin::MouseMove( const MouseEvent &rEvt )
+{
+ if ( pTextView )
+ pTextView->MouseMove( rEvt );
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+void TextViewOutWin::MouseButtonUp( const MouseEvent &rEvt )
+{
+ if ( pTextView )
+ {
+ pTextView->MouseButtonUp( rEvt );
+ SfxBindings& rBindings = ((SwSrcEditWindow*)GetParent())->GetSrcView()->GetViewFrame()->GetBindings();
+ rBindings.Invalidate( SID_TABLE_CELL );
+ rBindings.Invalidate( SID_CUT );
+ rBindings.Invalidate( SID_COPY );
+ }
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+void TextViewOutWin::MouseButtonDown( const MouseEvent &rEvt )
+{
+ GrabFocus();
+ if ( pTextView )
+ pTextView->MouseButtonDown( rEvt );
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+void TextViewOutWin::Command( const CommandEvent& rCEvt )
+{
+ switch(rCEvt.GetCommand())
+ {
+ case COMMAND_CONTEXTMENU:
+ ((SwSrcEditWindow*)GetParent())->GetSrcView()->GetViewFrame()->
+ GetDispatcher()->ExecutePopup();
+ break;
+ case COMMAND_WHEEL:
+ case COMMAND_STARTAUTOSCROLL:
+ case COMMAND_AUTOSCROLL:
+ {
+ const CommandWheelData* pWData = rCEvt.GetWheelData();
+ if( !pWData || COMMAND_WHEEL_ZOOM != pWData->GetMode() )
+ {
+ ((SwSrcEditWindow*)GetParent())->HandleWheelCommand( rCEvt );
+ }
+ }
+ break;
+
+ default:
+ if ( pTextView )
+ pTextView->Command( rCEvt );
+ else
+ Window::Command(rCEvt);
+ }
+}
+
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+void TextViewOutWin::KeyInput( const KeyEvent& rKEvt )
+{
+ BOOL bDone = FALSE;
+ SwSrcEditWindow* pSrcEditWin = (SwSrcEditWindow*)GetParent();
+ BOOL bChange = !pSrcEditWin->IsReadonly() || !TextEngine::DoesKeyChangeText( rKEvt );
+ if(bChange)
+ bDone = pTextView->KeyInput( rKEvt );
+
+ SfxBindings& rBindings = ((SwSrcEditWindow*)GetParent())->GetSrcView()->GetViewFrame()->GetBindings();
+ if ( !bDone )
+ {
+ if ( !SfxViewShell::Current()->KeyInput( rKEvt ) )
+ Window::KeyInput( rKEvt );
+ }
+ else
+ {
+ rBindings.Invalidate( SID_TABLE_CELL );
+ if ( rKEvt.GetKeyCode().GetGroup() == KEYGROUP_CURSOR )
+ rBindings.Update( SID_BASICIDE_STAT_POS );
+ if (pSrcEditWin->GetTextEngine()->IsModified() )
+ {
+ rBindings.Invalidate( SID_SAVEDOC );
+ rBindings.Invalidate( SID_DOC_MODIFIED );
+ }
+ if( rKEvt.GetKeyCode().GetCode() == KEY_INSERT )
+ rBindings.Invalidate( SID_ATTR_INSERT );
+ }
+
+ rBindings.Invalidate( SID_CUT );
+ rBindings.Invalidate( SID_COPY );
+
+ SwDocShell* pDocShell = pSrcEditWin->GetSrcView()->GetDocShell();
+ if(pSrcEditWin->GetTextEngine()->IsModified())
+ {
+ pDocShell->SetModified();
+ }
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+void TextViewOutWin::Paint( const Rectangle& rRect )
+{
+ pTextView->Paint( rRect );
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+void SwSrcEditWindow::CreateTextEngine()
+{
+ const Color &rCol = GetSettings().GetStyleSettings().GetWindowColor();
+ pOutWin = new TextViewOutWin(this, 0);
+ pOutWin->SetBackground(Wallpaper(rCol));
+ pOutWin->SetPointer(Pointer(POINTER_TEXT));
+ pOutWin->Show();
+
+ //Scrollbars anlegen
+ pHScrollbar = new ScrollBar(this, WB_3DLOOK |WB_HSCROLL|WB_DRAG);
+ pHScrollbar->EnableRTL( false ); // #107300# --- RTL --- no mirroring for scrollbars
+ pHScrollbar->SetScrollHdl(LINK(this, SwSrcEditWindow, ScrollHdl));
+ pHScrollbar->Show();
+
+ pVScrollbar = new ScrollBar(this, WB_3DLOOK |WB_VSCROLL|WB_DRAG);
+ pVScrollbar->EnableRTL( false ); // #107300# --- RTL --- no mirroring for scrollbars
+ pVScrollbar->SetScrollHdl(LINK(this, SwSrcEditWindow, ScrollHdl));
+ pHScrollbar->EnableDrag();
+ pVScrollbar->Show();
+
+ pTextEngine = new ExtTextEngine;
+ pTextView = new ExtTextView( pTextEngine, pOutWin );
+ pTextView->SetAutoIndentMode(TRUE);
+ pOutWin->SetTextView(pTextView);
+
+ pTextEngine->SetUpdateMode( FALSE );
+ pTextEngine->InsertView( pTextView );
+
+ Font aFont;
+ aFont.SetTransparent( FALSE );
+ aFont.SetFillColor( rCol );
+ SetPointFont( aFont );
+ aFont = GetFont();
+ aFont.SetFillColor( rCol );
+ pOutWin->SetFont( aFont );
+ pTextEngine->SetFont( aFont );
+
+ aSyntaxIdleTimer.SetTimeout( SYNTAX_HIGHLIGHT_TIMEOUT );
+ aSyntaxIdleTimer.SetTimeoutHdl( LINK( this, SwSrcEditWindow, SyntaxTimerHdl ) );
+
+ pTextEngine->EnableUndo( TRUE );
+ pTextEngine->SetUpdateMode( TRUE );
+
+ pTextView->ShowCursor( TRUE, TRUE );
+ InitScrollBars();
+ StartListening( *pTextEngine );
+
+ SfxBindings& rBind = GetSrcView()->GetViewFrame()->GetBindings();
+ rBind.Invalidate( SID_TABLE_CELL );
+// rBind.Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+void SwSrcEditWindow::SetScrollBarRanges()
+{
+ // Extra-Methode, nicht InitScrollBars, da auch fuer TextEngine-Events.
+
+ pHScrollbar->SetRange( Range( 0, nCurTextWidth-1 ) );
+ pVScrollbar->SetRange( Range(0, pTextEngine->GetTextHeight()-1) );
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+void SwSrcEditWindow::InitScrollBars()
+{
+ SetScrollBarRanges();
+
+ Size aOutSz( pOutWin->GetOutputSizePixel() );
+ pVScrollbar->SetVisibleSize( aOutSz.Height() );
+ pVScrollbar->SetPageSize( aOutSz.Height() * 8 / 10 );
+ pVScrollbar->SetLineSize( pOutWin->GetTextHeight() );
+ pVScrollbar->SetThumbPos( pTextView->GetStartDocPos().Y() );
+ pHScrollbar->SetVisibleSize( aOutSz.Width() );
+ pHScrollbar->SetPageSize( aOutSz.Width() * 8 / 10 );
+ pHScrollbar->SetLineSize( pOutWin->GetTextWidth( 'x' ) );
+ pHScrollbar->SetThumbPos( pTextView->GetStartDocPos().X() );
+
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+IMPL_LINK(SwSrcEditWindow, ScrollHdl, ScrollBar*, pScroll)
+{
+ if(pScroll == pVScrollbar)
+ {
+ long nDiff = pTextView->GetStartDocPos().Y() - pScroll->GetThumbPos();
+ GetTextView()->Scroll( 0, nDiff );
+ pTextView->ShowCursor( FALSE, TRUE );
+ pScroll->SetThumbPos( pTextView->GetStartDocPos().Y() );
+ }
+ else
+ {
+ long nDiff = pTextView->GetStartDocPos().X() - pScroll->GetThumbPos();
+ GetTextView()->Scroll( nDiff, 0 );
+ pTextView->ShowCursor( FALSE, TRUE );
+ pScroll->SetThumbPos( pTextView->GetStartDocPos().X() );
+ }
+ GetSrcView()->GetViewFrame()->GetBindings().Invalidate( SID_TABLE_CELL );
+ return 0;
+}
+
+/*-----------------15.01.97 09.22-------------------
+
+--------------------------------------------------*/
+
+IMPL_LINK( SwSrcEditWindow, SyntaxTimerHdl, Timer *, pTimer )
+{
+ Time aSyntaxCheckStart;
+ DBG_ASSERT( pTextView, "Noch keine View, aber Syntax-Highlight ?!" );
+ // pTextEngine->SetUpdateMode( FALSE );
+
+ bHighlighting = TRUE;
+ USHORT nLine;
+ USHORT nCount = 0;
+ // zuerst wird der Bereich um dem Cursor bearbeitet
+ TextSelection aSel = pTextView->GetSelection();
+ USHORT nCur = (USHORT)aSel.GetStart().GetPara();
+ if(nCur > 40)
+ nCur -= 40;
+ else
+ nCur = 0;
+ if(aSyntaxLineTable.Count())
+ for(USHORT i = 0; i < 80 && nCount < 40; i++, nCur++)
+ {
+ void * p = aSyntaxLineTable.Get(nCur);
+ if(p)
+ {
+ DoSyntaxHighlight( nCur );
+ aSyntaxLineTable.Remove( nCur );
+ nCount++;
+ if(!aSyntaxLineTable.Count())
+ break;
+ if((Time().GetTime() - aSyntaxCheckStart.GetTime()) > MAX_HIGHLIGHTTIME )
+ {
+ pTimer->SetTimeout( 2 * SYNTAX_HIGHLIGHT_TIMEOUT );
+ break;
+ }
+ }
+ }
+
+ // wenn dann noch etwas frei ist, wird von Beginn an weitergearbeitet
+ void* p = aSyntaxLineTable.First();
+ while ( p && nCount < MAX_SYNTAX_HIGHLIGHT)
+ {
+ nLine = (USHORT)aSyntaxLineTable.GetCurKey();
+ DoSyntaxHighlight( nLine );
+ USHORT nCurKey = (USHORT)aSyntaxLineTable.GetCurKey();
+ p = aSyntaxLineTable.Next();
+ aSyntaxLineTable.Remove(nCurKey);
+ nCount ++;
+ if(Time().GetTime() - aSyntaxCheckStart.GetTime() > MAX_HIGHLIGHTTIME)
+ {
+ pTimer->SetTimeout( 2 * SYNTAX_HIGHLIGHT_TIMEOUT );
+ break;
+ }
+ }
+ // os: #43050# hier wird ein TextView-Problem umpopelt:
+ // waehrend des Highlightings funktionierte das Scrolling nicht
+ /* MT: Shouldn't be a oproblem any more, using IdeFormatter in Insert/RemoveAttrib now.
+
+ TextView* pTmp = pTextEngine->GetActiveView();
+ pTextEngine->SetActiveView(0);
+ // pTextEngine->SetUpdateMode( TRUE );
+ pTextEngine->SetActiveView(pTmp);
+ pTextView->ShowCursor(FALSE, FALSE);
+ */
+
+ if(aSyntaxLineTable.Count() && !pTimer->IsActive())
+ pTimer->Start();
+ // SyntaxTimerHdl wird gerufen, wenn Text-Aenderung
+ // => gute Gelegenheit, Textbreite zu ermitteln!
+ long nPrevTextWidth = nCurTextWidth;
+ nCurTextWidth = pTextEngine->CalcTextWidth() + 25; // kleine Toleranz
+ if ( nCurTextWidth != nPrevTextWidth )
+ SetScrollBarRanges();
+ bHighlighting = FALSE;
+
+ return 0;
+}
+/*-----------------15.01.97 10.01-------------------
+
+--------------------------------------------------*/
+
+void SwSrcEditWindow::DoSyntaxHighlight( USHORT nPara )
+{
+ // Durch das DelayedSyntaxHighlight kann es passieren,
+ // dass die Zeile nicht mehr existiert!
+ if ( nPara < pTextEngine->GetParagraphCount() )
+ {
+ BOOL bTempModified = IsModified();
+ pTextEngine->RemoveAttribs( nPara, (BOOL)TRUE );
+ String aSource( pTextEngine->GetText( nPara ) );
+ pTextEngine->SetUpdateMode( FALSE );
+ ImpDoHighlight( aSource, nPara );
+ // os: #43050# hier wird ein TextView-Problem umpopelt:
+ // waehrend des Highlightings funktionierte das Scrolling nicht
+ TextView* pTmp = pTextEngine->GetActiveView();
+ pTmp->SetAutoScroll(FALSE);
+ pTextEngine->SetActiveView(0);
+ pTextEngine->SetUpdateMode( TRUE );
+ pTextEngine->SetActiveView(pTmp);
+ // Bug 72887 show the cursor
+ pTmp->SetAutoScroll(TRUE);
+ pTmp->ShowCursor( FALSE/*pTmp->IsAutoScroll()*/ );
+
+ if(!bTempModified)
+ ClearModifyFlag();
+ }
+}
+
+/*-----------------15.01.97 09.49-------------------
+
+--------------------------------------------------*/
+
+void SwSrcEditWindow::DoDelayedSyntaxHighlight( USHORT nPara )
+{
+ if ( !bHighlighting && bDoSyntaxHighlight )
+ {
+ aSyntaxLineTable.Insert( nPara, (void*)(USHORT)1 );
+ aSyntaxIdleTimer.Start();
+ }
+}
+
+/*-----------------15.01.97 11.32-------------------
+
+--------------------------------------------------*/
+
+void SwSrcEditWindow::ImpDoHighlight( const String& rSource, USHORT nLineOff )
+{
+ SwTextPortions aPortionList;
+ lcl_Highlight(rSource, aPortionList);
+
+ USHORT nCount = aPortionList.Count();
+ if ( !nCount )
+ return;
+
+ SwTextPortion& rLast = aPortionList[nCount-1];
+ if ( rLast.nStart > rLast.nEnd ) // Nur bis Bug von MD behoeben
+ {
+ nCount--;
+ aPortionList.Remove( nCount);
+ if ( !nCount )
+ return;
+ }
+
+ // Evtl. Optimieren:
+ // Wenn haufig gleiche Farbe, dazwischen Blank ohne Farbe,
+ // ggf. zusammenfassen, oder zumindest das Blank,
+ // damit weniger Attribute
+ BOOL bOptimizeHighlight = TRUE; // war in der BasicIDE static
+ if ( bOptimizeHighlight )
+ {
+ // Es muessen nur die Blanks und Tabs mit attributiert werden.
+ // Wenn zwei gleiche Attribute hintereinander eingestellt werden,
+ // optimiert das die TextEngine.
+ USHORT nLastEnd = 0;
+
+#ifdef DBG_UTIL
+ USHORT nLine = aPortionList[0].nLine;
+#endif
+ for ( USHORT i = 0; i < nCount; i++ )
+ {
+ SwTextPortion& r = aPortionList[i];
+ DBG_ASSERT( r.nLine == nLine, "doch mehrere Zeilen ?" );
+ if ( r.nStart > r.nEnd ) // Nur bis Bug von MD behoeben
+ continue;
+
+ if ( r.nStart > nLastEnd )
+ {
+ // Kann ich mich drauf verlassen, dass alle ausser
+ // Blank und Tab gehighlightet wird ?!
+ r.nStart = nLastEnd;
+ }
+ nLastEnd = r.nEnd+1;
+ if ( ( i == (nCount-1) ) && ( r.nEnd < rSource.Len() ) )
+ r.nEnd = rSource.Len();
+ }
+ }
+
+ for ( USHORT i = 0; i < aPortionList.Count(); i++ )
+ {
+ SwTextPortion& r = aPortionList[i];
+ if ( r.nStart > r.nEnd ) // Nur bis Bug von MD behoeben
+ continue;
+ if(r.eType != svtools::HTMLSGML &&
+ r.eType != svtools::HTMLCOMMENT &&
+ r.eType != svtools::HTMLKEYWORD &&
+ r.eType != svtools::HTMLUNKNOWN)
+ r.eType = svtools::HTMLUNKNOWN;
+ Color aColor((ColorData)SW_MOD()->GetColorConfig().GetColorValue((svtools::ColorConfigEntry)r.eType).nColor);
+ USHORT nLine = nLineOff+r.nLine; //
+ pTextEngine->SetAttrib( TextAttribFontColor( aColor ), nLine, r.nStart, r.nEnd+1, TRUE );
+ }
+}
+
+/*-----------------30.06.97 09:12-------------------
+
+--------------------------------------------------*/
+
+void SwSrcEditWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
+{
+ if ( rHint.ISA( TextHint ) )
+ {
+ const TextHint& rTextHint = (const TextHint&)rHint;
+ if( rTextHint.GetId() == TEXT_HINT_VIEWSCROLLED )
+ {
+ pHScrollbar->SetThumbPos( pTextView->GetStartDocPos().X() );
+ pVScrollbar->SetThumbPos( pTextView->GetStartDocPos().Y() );
+ }
+ else if( rTextHint.GetId() == TEXT_HINT_TEXTHEIGHTCHANGED )
+ {
+ if ( (long)pTextEngine->GetTextHeight() < pOutWin->GetOutputSizePixel().Height() )
+ pTextView->Scroll( 0, pTextView->GetStartDocPos().Y() );
+ pVScrollbar->SetThumbPos( pTextView->GetStartDocPos().Y() );
+ SetScrollBarRanges();
+ }
+ else if( ( rTextHint.GetId() == TEXT_HINT_PARAINSERTED ) ||
+ ( rTextHint.GetId() == TEXT_HINT_PARACONTENTCHANGED ) )
+ {
+ DoDelayedSyntaxHighlight( (USHORT)rTextHint.GetValue() );
+ }
+ }
+}
+
+void SwSrcEditWindow::ConfigurationChanged( utl::ConfigurationBroadcaster* pBrdCst, sal_uInt32 )
+{
+ if( pBrdCst == pSourceViewConfig)
+ SetFont();
+}
+
+/*-----------------30.06.97 13:22-------------------
+
+--------------------------------------------------*/
+
+void SwSrcEditWindow::Invalidate(USHORT )
+{
+ pOutWin->Invalidate();
+ Window::Invalidate();
+
+}
+
+void SwSrcEditWindow::Command( const CommandEvent& rCEvt )
+{
+ switch(rCEvt.GetCommand())
+ {
+ case COMMAND_WHEEL:
+ case COMMAND_STARTAUTOSCROLL:
+ case COMMAND_AUTOSCROLL:
+ {
+ const CommandWheelData* pWData = rCEvt.GetWheelData();
+ if( !pWData || COMMAND_WHEEL_ZOOM != pWData->GetMode() )
+ HandleScrollCommand( rCEvt, pHScrollbar, pVScrollbar );
+ }
+ break;
+ default:
+ Window::Command(rCEvt);
+ }
+}
+
+void SwSrcEditWindow::HandleWheelCommand( const CommandEvent& rCEvt )
+{
+ pTextView->Command(rCEvt);
+ HandleScrollCommand( rCEvt, pHScrollbar, pVScrollbar );
+}
+
+void SwSrcEditWindow::GetFocus()
+{
+ pOutWin->GrabFocus();
+}
+
+/*void SwSrcEditWindow::LoseFocus()
+{
+ Window::LoseFocus();
+// pOutWin->LoseFocus();
+// rView.LostFocus();
+} */
+/* -----------------------------29.08.2002 13:21------------------------------
+
+ ---------------------------------------------------------------------------*/
+BOOL lcl_GetLanguagesForEncoding(rtl_TextEncoding eEnc, LanguageType aLanguages[])
+{
+ switch(eEnc)
+ {
+ case RTL_TEXTENCODING_UTF7 :
+ case RTL_TEXTENCODING_UTF8 :
+ // don#t fill - all LANGUAGE_SYSTEM means unicode font has to be used
+ break;
+
+
+ case RTL_TEXTENCODING_ISO_8859_3:
+ case RTL_TEXTENCODING_ISO_8859_1 :
+ case RTL_TEXTENCODING_MS_1252 :
+ case RTL_TEXTENCODING_APPLE_ROMAN :
+ case RTL_TEXTENCODING_IBM_850 :
+ case RTL_TEXTENCODING_ISO_8859_14 :
+ case RTL_TEXTENCODING_ISO_8859_15 :
+ //fill with western languages
+ aLanguages[0] = LANGUAGE_GERMAN;
+ aLanguages[1] = LANGUAGE_FRENCH;
+ aLanguages[2] = LANGUAGE_ITALIAN;
+ aLanguages[3] = LANGUAGE_SPANISH;
+ break;
+
+ case RTL_TEXTENCODING_IBM_865 :
+ //scandinavian
+ aLanguages[0] = LANGUAGE_FINNISH;
+ aLanguages[1] = LANGUAGE_NORWEGIAN;
+ aLanguages[2] = LANGUAGE_SWEDISH;
+ aLanguages[3] = LANGUAGE_DANISH;
+ break;
+
+ case RTL_TEXTENCODING_ISO_8859_10 :
+ case RTL_TEXTENCODING_ISO_8859_13 :
+ case RTL_TEXTENCODING_ISO_8859_2 :
+ case RTL_TEXTENCODING_IBM_852 :
+ case RTL_TEXTENCODING_MS_1250 :
+ case RTL_TEXTENCODING_APPLE_CENTEURO :
+ aLanguages[0] = LANGUAGE_POLISH;
+ aLanguages[1] = LANGUAGE_CZECH;
+ aLanguages[2] = LANGUAGE_HUNGARIAN;
+ aLanguages[3] = LANGUAGE_SLOVAK;
+ break;
+
+ case RTL_TEXTENCODING_ISO_8859_4 :
+ case RTL_TEXTENCODING_IBM_775 :
+ case RTL_TEXTENCODING_MS_1257 :
+ aLanguages[0] = LANGUAGE_LATVIAN ;
+ aLanguages[1] = LANGUAGE_LITHUANIAN;
+ aLanguages[2] = LANGUAGE_ESTONIAN ;
+ break;
+
+ case RTL_TEXTENCODING_IBM_863 : aLanguages[0] = LANGUAGE_FRENCH_CANADIAN; break;
+ case RTL_TEXTENCODING_APPLE_FARSI : aLanguages[0] = LANGUAGE_FARSI; break;
+ case RTL_TEXTENCODING_APPLE_ROMANIAN:aLanguages[0] = LANGUAGE_ROMANIAN; break;
+
+ case RTL_TEXTENCODING_IBM_861 :
+ case RTL_TEXTENCODING_APPLE_ICELAND :
+ aLanguages[0] = LANGUAGE_ICELANDIC;
+ break;
+
+ case RTL_TEXTENCODING_APPLE_CROATIAN:aLanguages[0] = LANGUAGE_CROATIAN; break;
+
+ case RTL_TEXTENCODING_IBM_437 :
+ case RTL_TEXTENCODING_ASCII_US : aLanguages[0] = LANGUAGE_ENGLISH; break;
+
+ case RTL_TEXTENCODING_IBM_862 :
+ case RTL_TEXTENCODING_MS_1255 :
+ case RTL_TEXTENCODING_APPLE_HEBREW :
+ case RTL_TEXTENCODING_ISO_8859_8 :
+ aLanguages[0] = LANGUAGE_HEBREW;
+ break;
+
+ case RTL_TEXTENCODING_IBM_857 :
+ case RTL_TEXTENCODING_MS_1254 :
+ case RTL_TEXTENCODING_APPLE_TURKISH:
+ case RTL_TEXTENCODING_ISO_8859_9 :
+ aLanguages[0] = LANGUAGE_TURKISH;
+ break;
+
+ case RTL_TEXTENCODING_IBM_860 :
+ aLanguages[0] = LANGUAGE_PORTUGUESE;
+ break;
+
+ case RTL_TEXTENCODING_IBM_869 :
+ case RTL_TEXTENCODING_MS_1253 :
+ case RTL_TEXTENCODING_APPLE_GREEK :
+ case RTL_TEXTENCODING_ISO_8859_7 :
+ case RTL_TEXTENCODING_IBM_737 :
+ aLanguages[0] = LANGUAGE_GREEK;
+ break;
+
+ case RTL_TEXTENCODING_KOI8_R :
+ case RTL_TEXTENCODING_ISO_8859_5 :
+ case RTL_TEXTENCODING_IBM_855 :
+ case RTL_TEXTENCODING_MS_1251 :
+ case RTL_TEXTENCODING_IBM_866 :
+ case RTL_TEXTENCODING_APPLE_CYRILLIC :
+ aLanguages[0] = LANGUAGE_RUSSIAN;
+ break;
+
+ case RTL_TEXTENCODING_APPLE_UKRAINIAN:
+ case RTL_TEXTENCODING_KOI8_U:
+ aLanguages[0] = LANGUAGE_UKRAINIAN;
+ break;
+
+ case RTL_TEXTENCODING_IBM_864 :
+ case RTL_TEXTENCODING_MS_1256 :
+ case RTL_TEXTENCODING_ISO_8859_6 :
+ case RTL_TEXTENCODING_APPLE_ARABIC :
+ aLanguages[0] = LANGUAGE_ARABIC_SAUDI_ARABIA;
+ break;
+
+ case RTL_TEXTENCODING_APPLE_CHINTRAD :
+ case RTL_TEXTENCODING_MS_950 :
+ case RTL_TEXTENCODING_GBT_12345 :
+ case RTL_TEXTENCODING_BIG5 :
+ case RTL_TEXTENCODING_EUC_TW :
+ case RTL_TEXTENCODING_BIG5_HKSCS :
+ aLanguages[0] = LANGUAGE_CHINESE_TRADITIONAL;
+ break;
+
+ case RTL_TEXTENCODING_EUC_JP :
+ case RTL_TEXTENCODING_ISO_2022_JP :
+ case RTL_TEXTENCODING_JIS_X_0201 :
+ case RTL_TEXTENCODING_JIS_X_0208 :
+ case RTL_TEXTENCODING_JIS_X_0212 :
+ case RTL_TEXTENCODING_APPLE_JAPANESE :
+ case RTL_TEXTENCODING_MS_932 :
+ case RTL_TEXTENCODING_SHIFT_JIS :
+ aLanguages[0] = LANGUAGE_JAPANESE;
+ break;
+
+ case RTL_TEXTENCODING_GB_2312 :
+ case RTL_TEXTENCODING_MS_936 :
+ case RTL_TEXTENCODING_GBK :
+ case RTL_TEXTENCODING_GB_18030 :
+ case RTL_TEXTENCODING_APPLE_CHINSIMP :
+ case RTL_TEXTENCODING_EUC_CN :
+ case RTL_TEXTENCODING_ISO_2022_CN :
+ aLanguages[0] = LANGUAGE_CHINESE_SIMPLIFIED;
+ break;
+
+ case RTL_TEXTENCODING_APPLE_KOREAN :
+ case RTL_TEXTENCODING_MS_949 :
+ case RTL_TEXTENCODING_EUC_KR :
+ case RTL_TEXTENCODING_ISO_2022_KR :
+ case RTL_TEXTENCODING_MS_1361 :
+ aLanguages[0] = LANGUAGE_KOREAN;
+ break;
+
+ case RTL_TEXTENCODING_APPLE_THAI :
+ case RTL_TEXTENCODING_MS_874 :
+ case RTL_TEXTENCODING_TIS_620 :
+ aLanguages[0] = LANGUAGE_THAI;
+ break;
+// case RTL_TEXTENCODING_SYMBOL :
+// case RTL_TEXTENCODING_DONTKNOW: :
+ default: aLanguages[0] = Application::GetSettings().GetUILanguage();
+ }
+ return aLanguages[0] != LANGUAGE_SYSTEM;
+}
+void SwSrcEditWindow::SetFont()
+{
+ String sFontName = pSourceViewConfig->GetFontName();
+ if(!sFontName.Len())
+ {
+ LanguageType aLanguages[5] =
+ {
+ LANGUAGE_SYSTEM, LANGUAGE_SYSTEM, LANGUAGE_SYSTEM, LANGUAGE_SYSTEM, LANGUAGE_SYSTEM
+ };
+ Font aFont;
+ if(lcl_GetLanguagesForEncoding(eSourceEncoding, aLanguages))
+ {
+ //TODO: check for multiple languages
+ aFont = OutputDevice::GetDefaultFont(DEFAULTFONT_FIXED, aLanguages[0], 0, this);
+ }
+ else
+ aFont = OutputDevice::GetDefaultFont(DEFAULTFONT_SANS_UNICODE,
+ Application::GetSettings().GetLanguage(), 0, this);
+ sFontName = aFont.GetName();
+ }
+ const SvxFontListItem* pFontListItem =
+ (const SvxFontListItem* )pSrcView->GetDocShell()->GetItem( SID_ATTR_CHAR_FONTLIST );
+ const FontList* pList = pFontListItem->GetFontList();
+ FontInfo aInfo = pList->Get(sFontName,WEIGHT_NORMAL, ITALIC_NONE);
+
+ const Font& rFont = GetTextEngine()->GetFont();
+ Font aFont(aInfo);
+ Size aSize(rFont.GetSize());
+ //font height is stored in point and set in twip
+ aSize.Height() = pSourceViewConfig->GetFontHeight() * 20;
+ aFont.SetSize(pOutWin->LogicToPixel(aSize, MAP_TWIP));
+ GetTextEngine()->SetFont( aFont );
+ pOutWin->SetFont(aFont);
+}
+/* -----------------------------29.08.2002 13:47------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SwSrcEditWindow::SetTextEncoding(rtl_TextEncoding eEncoding)
+{
+ eSourceEncoding = eEncoding;
+ SetFont();
+}
+