View | Details | Raw Unified | Return to issue 102061
Collapse All | Expand All

(-)sc.orig/inc/document.hxx (-2 / +2 lines)
Lines 1319-1326 Link Here
1319
	void			RestorePrintRanges( const ScPrintRangeSaver& rSaver );
1319
	void			RestorePrintRanges( const ScPrintRangeSaver& rSaver );
1320
1320
1321
	SC_DLLPUBLIC Rectangle		GetMMRect( SCCOL nStartCol, SCROW nStartRow,
1321
	SC_DLLPUBLIC Rectangle		GetMMRect( SCCOL nStartCol, SCROW nStartRow,
1322
								SCCOL nEndCol, SCROW nEndRow, SCTAB nTab );
1322
								SCCOL nEndCol, SCROW nEndRow, SCTAB nTab ) const;
1323
	SC_DLLPUBLIC ScRange			GetRange( SCTAB nTab, const Rectangle& rMMRect );
1323
	SC_DLLPUBLIC ScRange			GetRange( SCTAB nTab, const Rectangle& rMMRect ) const;
1324
1324
1325
	void			UpdStlShtPtrsFrmNms();
1325
	void			UpdStlShtPtrsFrmNms();
1326
	void			StylesToNames();
1326
	void			StylesToNames();
(-)sc.orig/inc/drwlayer.hxx (-5 / +6 lines)
Lines 110-122 Link Here
110
	BOOL			bHyphenatorSet;
110
	BOOL			bHyphenatorSet;
111
111
112
private:
112
private:
113
	void			MoveAreaTwips( SCTAB nTab, const Rectangle& rArea, const Point& rMove,
114
								const Point& rTopLeft );
115
	void			MoveCells( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCROW nRow2,
113
	void			MoveCells( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCROW nRow2,
116
								SCsCOL nDx,SCsROW nDy );
114
								SCsCOL nDx,SCsROW nDy );
117
115
118
	void			RecalcPos( SdrObject* pObj,
116
	void			RecalcPos( SdrObject* pObj,
119
                        const ScDrawObjData& rData,
117
                        ScDrawObjData& rData,
120
                        const ScAddress& rOldStart,
118
                        const ScAddress& rOldStart,
121
                        const ScAddress& rOldEnd,
119
                        const ScAddress& rOldEnd,
122
                        bool bNegativePage );
120
                        bool bNegativePage );
Lines 201-208 Link Here
201
	void			EnsureGraphicNames();
199
	void			EnsureGraphicNames();
202
200
203
	// Verankerung setzen und ermitteln
201
	// Verankerung setzen und ermitteln
204
	static void		SetAnchor( SdrObject*, ScAnchorType );
202
	static void		SetPageAnchored( SdrObject& );
205
	static ScAnchorType	GetAnchor( const SdrObject* );
203
	static void		SetCellAnchored( SdrObject&, const ScDrawObjData &rAnchor );
204
	static void		SetCellAnchoredFromPosition( SdrObject &rObj, const ScDocument &rDoc, SCTAB nTab );
205
	static void		UpdateCellAnchorFromPositionEnd( SdrObject &rObj, const ScDocument &rDoc, SCTAB nTab );
206
	static ScAnchorType	GetAnchorType( const SdrObject& );
206
207
207
	// Positionen fuer Detektivlinien
208
	// Positionen fuer Detektivlinien
208
	static ScDrawObjData* GetObjData( SdrObject* pObj, BOOL bCreate=FALSE );
209
	static ScDrawObjData* GetObjData( SdrObject* pObj, BOOL bCreate=FALSE );
(-)sc.orig/inc/userdat.hxx (-1 / +4 lines)
Lines 63-74 Link Here
63
public:
63
public:
64
    ScAddress           maStart;
64
    ScAddress           maStart;
65
    ScAddress           maEnd;
65
    ScAddress           maEnd;
66
    Point               maStartOffset;
67
    Point               maEndOffset;
66
    bool                mbNote;
68
    bool                mbNote;
69
    Rectangle           maLastRect;
67
70
68
    explicit            ScDrawObjData();
71
    explicit            ScDrawObjData();
69
72
70
private:
73
private:
71
	virtual ScDrawObjData* Clone( SdrObject* pObj ) const;
74
     virtual ScDrawObjData* Clone( SdrObject* pObj ) const;
72
};
75
};
73
76
74
//-------------------------------------------------------------------------
77
//-------------------------------------------------------------------------
(-)sc.orig/source/core/data/documen3.cxx (-2 / +2 lines)
Lines 1510-1516 Link Here
1510
	aEmbedRange = ScRange();
1510
	aEmbedRange = ScRange();
1511
}
1511
}
1512
1512
1513
ScRange ScDocument::GetRange( SCTAB nTab, const Rectangle& rMMRect )
1513
ScRange ScDocument::GetRange( SCTAB nTab, const Rectangle& rMMRect ) const
1514
{
1514
{
1515
	ScTable* pTable = pTab[nTab];
1515
	ScTable* pTable = pTab[nTab];
1516
	if (!pTable)
1516
	if (!pTable)
Lines 1801-1807 Link Here
1801
}
1801
}
1802
1802
1803
Rectangle ScDocument::GetMMRect( SCCOL nStartCol, SCROW nStartRow,
1803
Rectangle ScDocument::GetMMRect( SCCOL nStartCol, SCROW nStartRow,
1804
								SCCOL nEndCol, SCROW nEndRow, SCTAB nTab )
1804
								SCCOL nEndCol, SCROW nEndRow, SCTAB nTab ) const
1805
{
1805
{
1806
	if (!ValidTab(nTab) || !pTab[nTab])
1806
	if (!ValidTab(nTab) || !pTab[nTab])
1807
	{
1807
	{
(-)sc.orig/source/core/data/drwlayer.cxx (-195 / +178 lines)
Lines 69-74 Link Here
69
#include <vcl/svapp.hxx>
69
#include <vcl/svapp.hxx>
70
#include <unotools/ucbstreamhelper.hxx>
70
#include <unotools/ucbstreamhelper.hxx>
71
71
72
#include <basegfx/polygon/b2dpolygon.hxx>
73
#include <basegfx/polygon/b2dpolygontools.hxx>
74
72
#include "drwlayer.hxx"
75
#include "drwlayer.hxx"
73
#include "drawpage.hxx"
76
#include "drawpage.hxx"
74
#include "global.hxx"
77
#include "global.hxx"
Lines 526-532 Link Here
526
	}
529
	}
527
}
530
}
528
531
529
void ScDrawLayer::RecalcPos( SdrObject* pObj, const ScDrawObjData& rData,
532
namespace
533
{
534
    //Can't have a zero width dimension
535
    Rectangle lcl_makeSafeRectangle(const Rectangle &rNew)
536
    {
537
        Rectangle aRect = rNew;
538
        if (aRect.Bottom() == aRect.Top())
539
            aRect.Bottom() = aRect.Top()+1;
540
        if (aRect.Right() == aRect.Left())
541
            aRect.Right() = aRect.Left()+1;
542
        return aRect;
543
    }
544
545
    Point lcl_calcAvailableDiff(ScDocument &rDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, const Point &aWantedDiff)
546
    {
547
        Point aAvailableDiff(aWantedDiff);
548
        long nHeight = rDoc.GetRowHeight( nRow, nTab ) * HMM_PER_TWIPS;
549
        long nWidth = rDoc.GetColWidth( nCol, nTab ) * HMM_PER_TWIPS;
550
        if (aAvailableDiff.Y() > nHeight)
551
            aAvailableDiff.Y() = nHeight;
552
        if (aAvailableDiff.X() > nWidth)
553
            aAvailableDiff.X() = nWidth;
554
        return aAvailableDiff;
555
    }
556
557
    Rectangle lcl_UpdateCalcPoly(basegfx::B2DPolygon &rCalcPoly, int nWhichPoint, const Point &rPos)
558
    {
559
        rCalcPoly.setB2DPoint(nWhichPoint, basegfx::B2DPoint(rPos.X(), rPos.Y()));
560
        basegfx::B2DRange aRange(basegfx::tools::getRange(rCalcPoly));
561
        return Rectangle(aRange.getMinX(), aRange.getMinY(),
562
            aRange.getMaxX(), aRange.getMaxY());
563
    }
564
}
565
566
void ScDrawLayer::RecalcPos( SdrObject* pObj, ScDrawObjData& rData,
530
        const ScAddress& rOldStart, const ScAddress& /*rOldEnd*/, bool bNegativePage )
567
        const ScAddress& rOldStart, const ScAddress& /*rOldEnd*/, bool bNegativePage )
531
{
568
{
532
	DBG_ASSERT( pDoc, "ScDrawLayer::RecalcPos - missing document" );
569
	DBG_ASSERT( pDoc, "ScDrawLayer::RecalcPos - missing document" );
Lines 562-567 Link Here
562
599
563
	if( bCircle )
600
	if( bCircle )
564
	{
601
	{
602
		rData.maLastRect = pObj->GetLogicRect();
603
565
		Point aPos( pDoc->GetColOffset( nCol1, nTab1 ), pDoc->GetRowOffset( nRow1, nTab1 ) );
604
		Point aPos( pDoc->GetColOffset( nCol1, nTab1 ), pDoc->GetRowOffset( nRow1, nTab1 ) );
566
		TwipsToMM( aPos.X() );
605
		TwipsToMM( aPos.X() );
567
		TwipsToMM( aPos.Y() );
606
		TwipsToMM( aPos.Y() );
Lines 582-592 Link Here
582
		{
621
		{
583
			if (bRecording)
622
			if (bRecording)
584
				AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
623
				AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
585
			pObj->SetLogicRect(aRect);
624
			rData.maLastRect = lcl_makeSafeRectangle(aRect);
625
			pObj->SetLogicRect(rData.maLastRect);
586
		}
626
		}
587
	}
627
	}
588
	else if( bArrow )
628
	else if( bArrow )
589
	{
629
	{
630
		rData.maLastRect = pObj->GetLogicRect();
631
		basegfx::B2DPolygon aCalcPoly;
632
		Point aOrigStartPos(pObj->GetPoint(0));
633
		Point aOrigEndPos(pObj->GetPoint(1));
634
		aCalcPoly.append(basegfx::B2DPoint(aOrigStartPos.X(), aOrigStartPos.Y()));
635
		aCalcPoly.append(basegfx::B2DPoint(aOrigEndPos.X(), aOrigEndPos.Y()));
590
		//!	nicht mehrere Undos fuer ein Objekt erzeugen (hinteres kann dann weggelassen werden)
636
		//!	nicht mehrere Undos fuer ein Objekt erzeugen (hinteres kann dann weggelassen werden)
591
637
592
		if( bValid1 )
638
		if( bValid1 )
Lines 605-610 Link Here
605
			{
651
			{
606
				if (bRecording)
652
				if (bRecording)
607
					AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
653
					AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
654
655
				rData.maLastRect = lcl_UpdateCalcPoly(aCalcPoly, 0, aStartPos);
608
				pObj->SetPoint( aStartPos, 0 );
656
				pObj->SetPoint( aStartPos, 0 );
609
			}
657
			}
610
658
Lines 619-624 Link Here
619
				{
667
				{
620
					if (bRecording)
668
					if (bRecording)
621
						AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
669
						AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
670
671
					rData.maLastRect = lcl_UpdateCalcPoly(aCalcPoly, 1, aEndPos);
622
					pObj->SetPoint( aEndPos, 1 );
672
					pObj->SetPoint( aEndPos, 1 );
623
				}
673
				}
624
			}
674
			}
Lines 639-644 Link Here
639
			{
689
			{
640
				if (bRecording)
690
				if (bRecording)
641
					AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
691
					AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
692
693
				rData.maLastRect = lcl_UpdateCalcPoly(aCalcPoly, 1, aEndPos);
642
				pObj->SetPoint( aEndPos, 1 );
694
				pObj->SetPoint( aEndPos, 1 );
643
			}
695
			}
644
696
Lines 655-699 Link Here
655
				{
707
				{
656
					if (bRecording)
708
					if (bRecording)
657
						AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
709
						AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
710
711
					rData.maLastRect = lcl_UpdateCalcPoly(aCalcPoly, 0, aStartPos);
658
					pObj->SetPoint( aStartPos, 0 );
712
					pObj->SetPoint( aStartPos, 0 );
659
				}
713
				}
660
			}
714
			}
661
		}
715
		}
662
	}
716
	}
663
	else								// Referenz-Rahmen
717
	else
664
	{
718
	{
719
		bool bCanResize = bValid2 && !pObj->IsResizeProtect();
720
721
		//First time positioning, must be able to at least move it
722
		if (rData.maLastRect.IsEmpty())
723
			rData.maLastRect = pObj->GetLogicRect();
724
665
		DBG_ASSERT( bValid1, "ScDrawLayer::RecalcPos - invalid start position" );
725
		DBG_ASSERT( bValid1, "ScDrawLayer::RecalcPos - invalid start position" );
666
		Point aPos( pDoc->GetColOffset( nCol1, nTab1 ), pDoc->GetRowOffset( nRow1, nTab1 ) );
726
		Point aPos( pDoc->GetColOffset( nCol1, nTab1 ), pDoc->GetRowOffset( nRow1, nTab1 ) );
667
		TwipsToMM( aPos.X() );
727
		TwipsToMM( aPos.X() );
668
		TwipsToMM( aPos.Y() );
728
		TwipsToMM( aPos.Y() );
729
		aPos += lcl_calcAvailableDiff(*pDoc, nCol1, nRow1, nTab1, rData.maStartOffset);
669
730
670
		if( bValid2 )
731
		if( bCanResize )
671
		{
732
		{
672
			Point aEnd( pDoc->GetColOffset( nCol2 + 1, nTab2 ), pDoc->GetRowOffset( nRow2 + 1, nTab2 ) );
733
			Point aEnd( pDoc->GetColOffset( nCol2, nTab2 ), pDoc->GetRowOffset( nRow2, nTab2 ) );
673
			TwipsToMM( aEnd.X() );
734
			TwipsToMM( aEnd.X() );
674
			TwipsToMM( aEnd.Y() );
735
			TwipsToMM( aEnd.Y() );
736
			aEnd += lcl_calcAvailableDiff(*pDoc, nCol2, nRow2, nTab2, rData.maEndOffset);
675
737
676
			Rectangle aNew( aPos, aEnd );
738
			Rectangle aNew( aPos, aEnd );
677
			if ( bNegativePage )
739
			if ( bNegativePage )
678
				MirrorRectRTL( aNew );
740
				MirrorRectRTL( aNew );
679
			if ( pObj->GetLogicRect() != aNew )
741
			if ( pObj->GetLogicRect() != aNew )
680
			{
742
			{
743
				Rectangle aOld(pObj->GetLogicRect());
744
681
				if (bRecording)
745
				if (bRecording)
682
					AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
746
					AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
683
				pObj->SetLogicRect(aNew);
747
			    rData.maLastRect = lcl_makeSafeRectangle(aNew);
748
			    pObj->SetLogicRect(rData.maLastRect);
684
			}
749
			}
685
		}
750
		}
686
		else
751
		else
687
		{
752
		{
688
			if ( bNegativePage )
753
			if ( bNegativePage )
689
				aPos.X() = -aPos.X();
754
				aPos.X() = -aPos.X() - rData.maLastRect.GetWidth();
690
			if ( pObj->GetRelativePos() != aPos )
755
			if ( pObj->GetRelativePos() != aPos )
691
			{
756
			{
692
				if (bRecording)
757
				if (bRecording)
693
					AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
758
					AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
759
				rData.maLastRect.SetPos( aPos );
694
				pObj->SetRelativePos( aPos );
760
				pObj->SetRelativePos( aPos );
695
			}
761
			}
696
		}
762
		}
763
764
		/*
765
		 * If we were not allowed resize the object, then the end cell anchor
766
		 * is possibly incorrect now, and if the object has no end-cell (e.g.
767
		 * missing in original .xml) we are also forced to generate one
768
		*/
769
		bool bEndAnchorIsBad = !bValid2 || pObj->IsResizeProtect();
770
		if (bEndAnchorIsBad)
771
			ScDrawLayer::UpdateCellAnchorFromPositionEnd(*pObj, *pDoc, nTab1);
697
	}
772
	}
698
}
773
}
699
774
Lines 868-1018 Link Here
868
	return pRet;
943
	return pRet;
869
}
944
}
870
945
871
//	MoveAreaTwips: all measures are kept in twips
872
void ScDrawLayer::MoveAreaTwips( SCTAB nTab, const Rectangle& rArea,
873
		const Point& rMove, const Point& rTopLeft )
874
{
875
	if (!rMove.X() && !rMove.Y())
876
		return; 									// nix
877
878
	SdrPage* pPage = GetPage(static_cast<sal_uInt16>(nTab));
879
	DBG_ASSERT(pPage,"Page nicht gefunden");
880
	if (!pPage)
881
		return;
882
883
	BOOL bNegativePage = pDoc && pDoc->IsNegativePage( nTab );
884
885
	// fuer Shrinking!
886
	Rectangle aNew( rArea );
887
	BOOL bShrink = FALSE;
888
	if ( rMove.X() < 0 || rMove.Y() < 0 )		// verkleinern
889
	{
890
		if ( rTopLeft != rArea.TopLeft() )		// sind gleich beim Verschieben von Zellen
891
		{
892
			bShrink = TRUE;
893
			aNew.Left() = rTopLeft.X();
894
			aNew.Top() = rTopLeft.Y();
895
		}
896
	}
897
	SdrObjListIter aIter( *pPage, IM_FLAT );
898
	SdrObject* pObject = aIter.Next();
899
	while (pObject)
900
	{
901
		if( GetAnchor( pObject ) == SCA_CELL )
902
		{
903
			if ( GetObjData( pObject ) )					// Detektiv-Pfeil ?
904
			{
905
				// hier nichts
906
			}
907
			else if ( pObject->ISA( SdrEdgeObj ) )			// Verbinder?
908
			{
909
				//	hier auch nichts
910
				//!	nicht verbundene Enden wie bei Linien (s.u.) behandeln?
911
			}
912
			else if ( pObject->IsPolyObj() && pObject->GetPointCount()==2 )
913
			{
914
				for (USHORT i=0; i<2; i++)
915
				{
916
					BOOL bMoved = FALSE;
917
					Point aPoint = pObject->GetPoint(i);
918
					lcl_ReverseTwipsToMM( aPoint );
919
					if (rArea.IsInside(aPoint))
920
					{
921
						aPoint += rMove; bMoved = TRUE;
922
					}
923
					else if (bShrink && aNew.IsInside(aPoint))
924
					{
925
						//	Punkt ist in betroffener Zelle - Test auf geloeschten Bereich
926
						if ( rMove.X() && aPoint.X() >= rArea.Left() + rMove.X() )
927
						{
928
							aPoint.X() = rArea.Left() + rMove.X() - SHRINK_DIST_TWIPS;
929
							if ( aPoint.X() < 0 ) aPoint.X() = 0;
930
							bMoved = TRUE;
931
						}
932
						if ( rMove.Y() && aPoint.Y() >= rArea.Top() + rMove.Y() )
933
						{
934
							aPoint.Y() = rArea.Top() + rMove.Y() - SHRINK_DIST_TWIPS;
935
							if ( aPoint.Y() < 0 ) aPoint.Y() = 0;
936
							bMoved = TRUE;
937
						}
938
					}
939
					if( bMoved )
940
					{
941
						AddCalcUndo( new SdrUndoGeoObj( *pObject ) );
942
						lcl_TwipsToMM( aPoint );
943
						pObject->SetPoint( aPoint, i );
944
					}
945
				}
946
			}
947
			else
948
			{
949
				Rectangle aObjRect = pObject->GetLogicRect();
950
				// aOldMMPos: not converted, millimeters
951
				Point aOldMMPos = bNegativePage ? aObjRect.TopRight() : aObjRect.TopLeft();
952
				lcl_ReverseTwipsToMM( aObjRect );
953
				Point aTopLeft = bNegativePage ? aObjRect.TopRight() : aObjRect.TopLeft();	// logical left
954
				Size aMoveSize;
955
				BOOL bDoMove = FALSE;
956
				if (rArea.IsInside(aTopLeft))
957
				{
958
					aMoveSize = Size(rMove.X(),rMove.Y());
959
					bDoMove = TRUE;
960
				}
961
				else if (bShrink && aNew.IsInside(aTopLeft))
962
				{
963
					//	Position ist in betroffener Zelle - Test auf geloeschten Bereich
964
					if ( rMove.X() && aTopLeft.X() >= rArea.Left() + rMove.X() )
965
					{
966
						aMoveSize.Width() = rArea.Left() + rMove.X() - SHRINK_DIST - aTopLeft.X();
967
						bDoMove = TRUE;
968
					}
969
					if ( rMove.Y() && aTopLeft.Y() >= rArea.Top() + rMove.Y() )
970
					{
971
						aMoveSize.Height() = rArea.Top() + rMove.Y() - SHRINK_DIST - aTopLeft.Y();
972
						bDoMove = TRUE;
973
					}
974
				}
975
				if ( bDoMove )
976
				{
977
					if ( bNegativePage )
978
					{
979
						if ( aTopLeft.X() + aMoveSize.Width() > 0 )
980
							aMoveSize.Width() = -aTopLeft.X();
981
					}
982
					else
983
					{
984
						if ( aTopLeft.X() + aMoveSize.Width() < 0 )
985
							aMoveSize.Width() = -aTopLeft.X();
986
					}
987
					if ( aTopLeft.Y() + aMoveSize.Height() < 0 )
988
						aMoveSize.Height() = -aTopLeft.Y();
989
990
					//	get corresponding move size in millimeters:
991
					Point aNewPos( aTopLeft.X() + aMoveSize.Width(), aTopLeft.Y() + aMoveSize.Height() );
992
					lcl_TwipsToMM( aNewPos );
993
					aMoveSize = Size( aNewPos.X() - aOldMMPos.X(), aNewPos.Y() - aOldMMPos.Y() );	// millimeters
994
995
					AddCalcUndo( new SdrUndoMoveObj( *pObject, aMoveSize ) );
996
					pObject->Move( aMoveSize );
997
				}
998
				else if ( rArea.IsInside( bNegativePage ? aObjRect.BottomLeft() : aObjRect.BottomRight() ) &&
999
							!pObject->IsResizeProtect() )
1000
				{
1001
					//	geschuetzte Groessen werden nicht veraendert
1002
					//	(Positionen schon, weil sie ja an der Zelle "verankert" sind)
1003
					AddCalcUndo( new SdrUndoGeoObj( *pObject ) );
1004
					long nOldSizeX = aObjRect.Right() - aObjRect.Left() + 1;
1005
					long nOldSizeY = aObjRect.Bottom() - aObjRect.Top() + 1;
1006
					long nLogMoveX = rMove.X() * ( bNegativePage ? -1 : 1 );	// logical direction
1007
					pObject->Resize( aOldMMPos, Fraction( nOldSizeX+nLogMoveX, nOldSizeX ),
1008
												Fraction( nOldSizeY+rMove.Y(), nOldSizeY ) );
1009
				}
1010
			}
1011
		}
1012
		pObject = aIter.Next();
1013
	}
1014
}
1015
1016
void ScDrawLayer::MoveArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCROW nRow2,
946
void ScDrawLayer::MoveArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCROW nRow2,
1017
							SCsCOL nDx,SCsROW nDy, BOOL bInsDel )
947
							SCsCOL nDx,SCsROW nDy, BOOL bInsDel )
1018
{
948
{
Lines 1054-1064 Link Here
1054
			aTopLeft.Y() += aMove.Y();
984
			aTopLeft.Y() += aMove.Y();
1055
	}
985
	}
1056
986
1057
	//	drawing objects are now directly included in cut&paste
1058
	//	-> only update references when inserting/deleting (or changing widths or heights)
1059
	if ( bInsDel )
1060
		MoveAreaTwips( nTab, aRect, aMove, aTopLeft );
1061
1062
		//
987
		//
1063
		//		Detektiv-Pfeile: Zellpositionen anpassen
988
		//		Detektiv-Pfeile: Zellpositionen anpassen
1064
		//
989
		//
Lines 1096-1103 Link Here
1096
		aTopLeft.X() = -aTopLeft.X();
1021
		aTopLeft.X() = -aTopLeft.X();
1097
		nDifTwips = -nDifTwips;
1022
		nDifTwips = -nDifTwips;
1098
	}
1023
	}
1099
1100
	MoveAreaTwips( nTab, aRect, Point( nDifTwips,0 ), aTopLeft );
1101
}
1024
}
1102
1025
1103
void ScDrawLayer::HeightChanged( SCTAB nTab, SCROW nRow, long nDifTwips )
1026
void ScDrawLayer::HeightChanged( SCTAB nTab, SCROW nRow, long nDifTwips )
Lines 1128-1135 Link Here
1128
		MirrorRectRTL( aRect );
1051
		MirrorRectRTL( aRect );
1129
		aTopLeft.X() = -aTopLeft.X();
1052
		aTopLeft.X() = -aTopLeft.X();
1130
	}
1053
	}
1131
1132
	MoveAreaTwips( nTab, aRect, Point( 0,nDifTwips ), aTopLeft );
1133
}
1054
}
1134
1055
1135
BOOL ScDrawLayer::HasObjectsInRows( SCTAB nTab, SCROW nStartRow, SCROW nEndRow )
1056
BOOL ScDrawLayer::HasObjectsInRows( SCTAB nTab, SCROW nStartRow, SCROW nEndRow )
Lines 1807-1836 Link Here
1807
	}
1728
	}
1808
}
1729
}
1809
1730
1810
void ScDrawLayer::SetAnchor( SdrObject* pObj, ScAnchorType eType )
1731
namespace
1811
{
1732
{
1812
	// Ein an der Seite verankertes Objekt zeichnet sich durch eine Anker-Pos
1733
    SdrObjUserData* GetFirstUserDataOfType(const SdrObject *pObj, UINT16 nId)
1813
	// von (0,1) aus. Das ist ein shabby Trick, der aber funktioniert!
1734
    {
1814
	Point aAnchor( 0, eType == SCA_PAGE ? 1 : 0 );
1735
        USHORT nCount = pObj ? pObj->GetUserDataCount() : 0;
1815
	pObj->SetAnchorPos( aAnchor );
1736
        for( USHORT i = 0; i < nCount; i++ )
1737
        {
1738
            SdrObjUserData* pData = pObj->GetUserData( i );
1739
            if( pData && pData->GetInventor() == SC_DRAWLAYER && pData->GetId() == nId )
1740
                return pData;
1741
        }
1742
        return NULL;
1743
    }
1744
1745
    void DeleteFirstUserDataOfType(SdrObject *pObj, UINT16 nId)
1746
    {
1747
        USHORT nCount = pObj ? pObj->GetUserDataCount() : 0;
1748
        for( USHORT i = nCount; i > 0; i-- )
1749
        {
1750
            SdrObjUserData* pData = pObj->GetUserData( i-1 );
1751
            if( pData && pData->GetInventor() == SC_DRAWLAYER && pData->GetId() == nId )
1752
                pObj->DeleteUserData(i-1);
1753
        }
1754
    }
1755
}
1756
1757
void ScDrawLayer::SetCellAnchored( SdrObject &rObj, const ScDrawObjData &rAnchor )
1758
{
1759
    ScDrawObjData* pAnchor = GetObjData( &rObj, true );
1760
    pAnchor->maStart = rAnchor.maStart;
1761
    pAnchor->maEnd = rAnchor.maEnd;
1762
    pAnchor->maStartOffset = rAnchor.maStartOffset;
1763
    pAnchor->maEndOffset = rAnchor.maEndOffset;
1764
}
1765
1766
void ScDrawLayer::SetCellAnchoredFromPosition( SdrObject &rObj, const ScDocument &rDoc, SCTAB nTab )
1767
{
1768
    Rectangle aObjRect(rObj.GetLogicRect());
1769
    ScRange aRange = rDoc.GetRange( nTab, aObjRect );
1770
1771
    Rectangle aCellRect;
1772
1773
    ScDrawObjData aAnchor;
1774
    aAnchor.maStart = aRange.aStart;
1775
    aCellRect = rDoc.GetMMRect( aRange.aStart.Col(), aRange.aStart.Row(), 
1776
      aRange.aStart.Col(), aRange.aStart.Row(), aRange.aStart.Tab() );
1777
    aAnchor.maStartOffset.Y() = aObjRect.Top()-aCellRect.Top();
1778
    if (!rDoc.IsNegativePage(nTab))
1779
        aAnchor.maStartOffset.X() = aObjRect.Left()-aCellRect.Left();
1780
    else
1781
        aAnchor.maStartOffset.X() = aCellRect.Right()-aObjRect.Right();
1782
1783
    aAnchor.maEnd = aRange.aEnd;
1784
    aCellRect = rDoc.GetMMRect( aRange.aEnd.Col(), aRange.aEnd.Row(), 
1785
      aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aEnd.Tab() );
1786
    aAnchor.maEndOffset.Y() = aObjRect.Bottom()-aCellRect.Top();
1787
    if (!rDoc.IsNegativePage(nTab))
1788
        aAnchor.maEndOffset.X() = aObjRect.Right()-aCellRect.Left();
1789
    else
1790
        aAnchor.maEndOffset.X() = aCellRect.Right()-aObjRect.Left();
1791
1792
    SetCellAnchored( rObj, aAnchor );
1793
}
1794
1795
void ScDrawLayer::UpdateCellAnchorFromPositionEnd( SdrObject &rObj, const ScDocument &rDoc, SCTAB nTab )
1796
{
1797
    Rectangle aObjRect(rObj.GetLogicRect());
1798
    ScRange aRange = rDoc.GetRange( nTab, aObjRect );
1799
1800
    ScDrawObjData* pAnchor = GetObjData( &rObj, true );
1801
    pAnchor->maEnd = aRange.aEnd;
1802
1803
    Rectangle aCellRect;
1804
    aCellRect = rDoc.GetMMRect( aRange.aEnd.Col(), aRange.aEnd.Row(), 
1805
      aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aEnd.Tab() );
1806
    pAnchor->maEndOffset.Y() = aObjRect.Bottom()-aCellRect.Top();
1807
    if (!rDoc.IsNegativePage(nTab))
1808
        pAnchor->maEndOffset.X() = aObjRect.Right()-aCellRect.Left();
1809
    else
1810
        pAnchor->maEndOffset.X() = aCellRect.Right()-aObjRect.Left();
1811
}
1812
1813
void ScDrawLayer::SetPageAnchored( SdrObject &rObj )
1814
{
1815
    DeleteFirstUserDataOfType(&rObj, SC_UD_OBJDATA);
1816
}
1816
}
1817
1817
1818
ScAnchorType ScDrawLayer::GetAnchor( const SdrObject* pObj )
1818
ScAnchorType ScDrawLayer::GetAnchorType( const SdrObject &rObj )
1819
{
1819
{
1820
	Point aAnchor( pObj->GetAnchorPos() );
1820
	//If this object has a cell anchor associated with it
1821
	return ( aAnchor.Y() != 0 ) ? SCA_PAGE : SCA_CELL;
1821
	//then its cell-anchored, otherwise its page-anchored
1822
	return ScDrawLayer::GetObjData(const_cast<SdrObject*>(&rObj)) ? SCA_CELL : SCA_PAGE;
1822
}
1823
}
1823
1824
1824
ScDrawObjData* ScDrawLayer::GetObjData( SdrObject* pObj, BOOL bCreate )		// static
1825
ScDrawObjData* ScDrawLayer::GetObjData( SdrObject* pObj, BOOL bCreate )		// static
1825
{
1826
{
1826
	USHORT nCount = pObj ? pObj->GetUserDataCount() : 0;
1827
	if (SdrObjUserData *pData = GetFirstUserDataOfType(pObj, SC_UD_OBJDATA))
1827
	for( USHORT i = 0; i < nCount; i++ )
1828
		return (ScDrawObjData*) pData;
1828
	{
1829
1829
		SdrObjUserData* pData = pObj->GetUserData( i );
1830
		if( pData && pData->GetInventor() == SC_DRAWLAYER
1831
					&& pData->GetId() == SC_UD_OBJDATA )
1832
			return (ScDrawObjData*) pData;
1833
	}
1834
	if( pObj && bCreate )
1830
	if( pObj && bCreate )
1835
	{
1831
	{
1836
		ScDrawObjData* pData = new ScDrawObjData;
1832
		ScDrawObjData* pData = new ScDrawObjData;
Lines 1867-1881 Link Here
1867
1863
1868
ScIMapInfo* ScDrawLayer::GetIMapInfo( SdrObject* pObj )				// static
1864
ScIMapInfo* ScDrawLayer::GetIMapInfo( SdrObject* pObj )				// static
1869
{
1865
{
1870
	USHORT nCount = pObj->GetUserDataCount();
1866
	return (ScIMapInfo*)GetFirstUserDataOfType(pObj, SC_UD_IMAPDATA);
1871
	for( USHORT i = 0; i < nCount; i++ )
1872
	{
1873
		SdrObjUserData* pData = pObj->GetUserData( i );
1874
		if( pData && pData->GetInventor() == SC_DRAWLAYER
1875
					&& pData->GetId() == SC_UD_IMAPDATA )
1876
			return (ScIMapInfo*) pData;
1877
	}
1878
	return NULL;
1879
}
1867
}
1880
1868
1881
// static:
1869
// static:
Lines 1928-1934 Link Here
1928
		else if ( pObj->ISA( SdrOle2Obj ) ) // OLE-Objekt
1916
		else if ( pObj->ISA( SdrOle2Obj ) ) // OLE-Objekt
1929
		{
1917
		{
1930
            // TODO/LEAN: working with visual area needs running state
1918
            // TODO/LEAN: working with visual area needs running state
1931
			aGraphSize = ((SdrOle2Obj*)pObj)->GetOrigObjSize();
1919
			aGraphSize = ((const SdrOle2Obj*)pObj)->GetOrigObjSize();
1932
			bObjSupported = TRUE;
1920
			bObjSupported = TRUE;
1933
		}
1921
		}
1934
1922
Lines 1946-1959 Link Here
1946
1934
1947
ScMacroInfo* ScDrawLayer::GetMacroInfo( SdrObject* pObj, BOOL bCreate )             // static
1935
ScMacroInfo* ScDrawLayer::GetMacroInfo( SdrObject* pObj, BOOL bCreate )             // static
1948
{
1936
{
1949
    USHORT nCount = pObj->GetUserDataCount();
1937
    if (SdrObjUserData *pData = GetFirstUserDataOfType(pObj, SC_UD_MACRODATA))
1950
    for( USHORT i = 0; i < nCount; i++ )
1938
        return (ScMacroInfo*) pData;
1951
    {
1939
1952
        SdrObjUserData* pData = pObj->GetUserData( i );
1953
        if( pData && pData->GetInventor() == SC_DRAWLAYER
1954
                    && pData->GetId() == SC_UD_MACRODATA )
1955
            return (ScMacroInfo*) pData;
1956
    }
1957
    if ( bCreate )
1940
    if ( bCreate )
1958
    {
1941
    {
1959
        ScMacroInfo* pData = new ScMacroInfo;
1942
        ScMacroInfo* pData = new ScMacroInfo;
(-)sc.orig/source/core/data/postit.cxx (-1 lines)
Lines 125-131 Link Here
125
    mpCaption = new SdrCaptionObj( aTextRect, aTailPos );
125
    mpCaption = new SdrCaptionObj( aTextRect, aTailPos );
126
126
127
    // basic settings
127
    // basic settings
128
    ScDrawLayer::SetAnchor( mpCaption, SCA_PAGE );
129
    mpCaption->SetLayer( bShown ? SC_LAYER_INTERN : SC_LAYER_HIDDEN );
128
    mpCaption->SetLayer( bShown ? SC_LAYER_INTERN : SC_LAYER_HIDDEN );
130
    mpCaption->SetFixedTail();
129
    mpCaption->SetFixedTail();
131
    mpCaption->SetSpecialTextBoxShadow();
130
    mpCaption->SetSpecialTextBoxShadow();
(-)sc.orig/source/core/tool/detfunc.cxx (-5 lines)
Lines 492-498 Link Here
492
492
493
		pBox->SetMergedItemSetAndBroadcast(rData.GetBoxSet());
493
		pBox->SetMergedItemSetAndBroadcast(rData.GetBoxSet());
494
494
495
		ScDrawLayer::SetAnchor( pBox, SCA_CELL );
496
		pBox->SetLayer( SC_LAYER_INTERN );
495
		pBox->SetLayer( SC_LAYER_INTERN );
497
		pPage->InsertObject( pBox );
496
		pPage->InsertObject( pBox );
498
		pModel->AddCalcUndo( new SdrUndoInsertObj( *pBox ) );
497
		pModel->AddCalcUndo( new SdrUndoInsertObj( *pBox ) );
Lines 534-540 Link Here
534
	pArrow->NbcSetLogicRect(Rectangle(aStartPos,aEndPos));	//! noetig ???
533
	pArrow->NbcSetLogicRect(Rectangle(aStartPos,aEndPos));	//! noetig ???
535
	pArrow->SetMergedItemSetAndBroadcast(rAttrSet);
534
	pArrow->SetMergedItemSetAndBroadcast(rAttrSet);
536
535
537
	ScDrawLayer::SetAnchor( pArrow, SCA_CELL );
538
	pArrow->SetLayer( SC_LAYER_INTERN );
536
	pArrow->SetLayer( SC_LAYER_INTERN );
539
	pPage->InsertObject( pArrow );
537
	pPage->InsertObject( pArrow );
540
	pModel->AddCalcUndo( new SdrUndoInsertObj( *pArrow ) );
538
	pModel->AddCalcUndo( new SdrUndoInsertObj( *pArrow ) );
Lines 565-571 Link Here
565
563
566
		pBox->SetMergedItemSetAndBroadcast(rData.GetBoxSet());
564
		pBox->SetMergedItemSetAndBroadcast(rData.GetBoxSet());
567
565
568
		ScDrawLayer::SetAnchor( pBox, SCA_CELL );
569
		pBox->SetLayer( SC_LAYER_INTERN );
566
		pBox->SetLayer( SC_LAYER_INTERN );
570
		pPage->InsertObject( pBox );
567
		pPage->InsertObject( pBox );
571
		pModel->AddCalcUndo( new SdrUndoInsertObj( *pBox ) );
568
		pModel->AddCalcUndo( new SdrUndoInsertObj( *pBox ) );
Lines 600-606 Link Here
600
597
601
	pArrow->SetMergedItemSetAndBroadcast(rAttrSet);
598
	pArrow->SetMergedItemSetAndBroadcast(rAttrSet);
602
599
603
	ScDrawLayer::SetAnchor( pArrow, SCA_CELL );
604
	pArrow->SetLayer( SC_LAYER_INTERN );
600
	pArrow->SetLayer( SC_LAYER_INTERN );
605
	pPage->InsertObject( pArrow );
601
	pPage->InsertObject( pArrow );
606
	pModel->AddCalcUndo( new SdrUndoInsertObj( *pArrow ) );
602
	pModel->AddCalcUndo( new SdrUndoInsertObj( *pArrow ) );
Lines 668-674 Link Here
668
664
669
	pCircle->SetMergedItemSetAndBroadcast(rAttrSet);
665
	pCircle->SetMergedItemSetAndBroadcast(rAttrSet);
670
666
671
	ScDrawLayer::SetAnchor( pCircle, SCA_CELL );
672
	pCircle->SetLayer( SC_LAYER_INTERN );
667
	pCircle->SetLayer( SC_LAYER_INTERN );
673
	pPage->InsertObject( pCircle );
668
	pPage->InsertObject( pCircle );
674
	pModel->AddCalcUndo( new SdrUndoInsertObj( *pCircle ) );
669
	pModel->AddCalcUndo( new SdrUndoInsertObj( *pCircle ) );
(-)sc.orig/source/filter/xml/XMLExportIterator.hxx (+2 lines)
Lines 72-77 Link Here
72
{
72
{
73
	ScAddress	aAddress;
73
	ScAddress	aAddress;
74
	ScAddress	aEndAddress;
74
	ScAddress	aEndAddress;
75
	sal_Int32       nEndX;
76
	sal_Int32       nEndY;
75
	com::sun::star::uno::Reference<com::sun::star::drawing::XShape> xShape;
77
	com::sun::star::uno::Reference<com::sun::star::drawing::XShape> xShape;
76
78
77
	sal_Bool operator<(const ScMyShape& aShape) const;
79
	sal_Bool operator<(const ScMyShape& aShape) const;
(-)sc.orig/source/filter/xml/xmlexprt.cxx (-46 / +14 lines)
Lines 599-637 Link Here
599
												else
599
												else
600
												{
600
												{
601
													++nShapesCount;
601
													++nShapesCount;
602
													SvxShape* pShapeImp(SvxShape::getImplementation(xShape));
602
													if (SvxShape* pShapeImp = SvxShape::getImplementation(xShape))
603
													if (pShapeImp)
604
													{
603
													{
605
														SdrObject *pSdrObj(pShapeImp->GetSdrObject());
604
														if (SdrObject *pSdrObj = pShapeImp->GetSdrObject())
606
														if (pSdrObj)
607
														{
605
														{
608
															if (ScDrawLayer::GetAnchor(pSdrObj) == SCA_CELL)
606
															if (ScDrawObjData *pAnchor = ScDrawLayer::GetObjData( pSdrObj ))
609
															{
607
															{
610
																if (pDoc)
608
																ScMyShape aMyShape;
611
																{
609
																aMyShape.aAddress = pAnchor->maStart;
612
610
																aMyShape.aEndAddress = pAnchor->maEnd;
613
																	awt::Point aPoint(xShape->getPosition());
611
																aMyShape.nEndX = pAnchor->maEndOffset.X();
614
																	awt::Size aSize(xShape->getSize());
612
																aMyShape.nEndY = pAnchor->maEndOffset.Y();
615
																	rtl::OUString sType(xShape->getShapeType());
613
																aMyShape.xShape = xShape;
616
																	Rectangle aRectangle(aPoint.X, aPoint.Y, aPoint.X + aSize.Width, aPoint.Y + aSize.Height);
614
																pSharedData->AddNewShape(aMyShape);
617
																	if ( sType.equals(sCaptionShape) )
615
																pSharedData->SetLastColumn(nTable, pAnchor->maStart.Col());
618
																	{
616
																pSharedData->SetLastRow(nTable, pAnchor->maStart.Row());
619
                                                                        awt::Point aRelativeCaptionPoint;
620
                                                                        xShapeProp->getPropertyValue( sCaptionPoint ) >>= aRelativeCaptionPoint;
621
                                                                        Point aCoreRelativeCaptionPoint(aRelativeCaptionPoint.X, aRelativeCaptionPoint.Y);
622
                                                                        Point aCoreAbsoluteCaptionPoint(aPoint.X, aPoint.Y);
623
                                                                        aCoreAbsoluteCaptionPoint += aCoreRelativeCaptionPoint;
624
                                                                        aRectangle.Union(Rectangle(aCoreAbsoluteCaptionPoint, aCoreAbsoluteCaptionPoint));
625
																	}
626
																	ScRange aRange(pDoc->GetRange(static_cast<SCTAB>(nTable), aRectangle));
627
																	ScMyShape aMyShape;
628
																	aMyShape.aAddress = aRange.aStart;
629
																	aMyShape.aEndAddress = aRange.aEnd;
630
																	aMyShape.xShape = xShape;
631
																	pSharedData->AddNewShape(aMyShape);
632
																	pSharedData->SetLastColumn(nTable, aRange.aStart.Col());
633
																	pSharedData->SetLastRow(nTable, aRange.aStart.Row());
634
																}
635
															}
617
															}
636
															else
618
															else
637
																pSharedData->AddTableShape(nTable, xShape);
619
																pSharedData->AddTableShape(nTable, xShape);
Lines 2585-2613 Link Here
2585
                    aPoint.X = 2 * aItr->xShape->getPosition().X + aItr->xShape->getSize().Width - aPoint.X;
2567
                    aPoint.X = 2 * aItr->xShape->getPosition().X + aItr->xShape->getSize().Width - aPoint.X;
2586
				if ( !aItr->xShape->getShapeType().equals(sCaptionShape) )
2568
				if ( !aItr->xShape->getShapeType().equals(sCaptionShape) )
2587
				{
2569
				{
2588
					awt::Point aEndPoint;
2589
					Rectangle aEndRec(pDoc->GetMMRect(aItr->aEndAddress.Col(), aItr->aEndAddress.Row(),
2570
					Rectangle aEndRec(pDoc->GetMMRect(aItr->aEndAddress.Col(), aItr->aEndAddress.Row(),
2590
						aItr->aEndAddress.Col(), aItr->aEndAddress.Row(), aItr->aEndAddress.Tab()));
2571
						aItr->aEndAddress.Col(), aItr->aEndAddress.Row(), aItr->aEndAddress.Tab()));
2591
					rtl::OUString sEndAddress;
2572
					rtl::OUString sEndAddress;
2592
					ScRangeStringConverter::GetStringFromAddress(sEndAddress, aItr->aEndAddress, pDoc, FormulaGrammar::CONV_OOO);
2573
					ScRangeStringConverter::GetStringFromAddress(sEndAddress, aItr->aEndAddress, pDoc, FormulaGrammar::CONV_OOO);
2593
					AddAttribute(XML_NAMESPACE_TABLE, XML_END_CELL_ADDRESS, sEndAddress);
2574
					AddAttribute(XML_NAMESPACE_TABLE, XML_END_CELL_ADDRESS, sEndAddress);
2594
                    if (bNegativePage)
2595
                        aEndPoint.X = -aEndRec.Right();
2596
                    else
2597
					    aEndPoint.X = aEndRec.Left();
2598
					aEndPoint.Y = aEndRec.Top();
2599
					awt::Point aStartPoint(aItr->xShape->getPosition());
2600
					awt::Size aSize(aItr->xShape->getSize());
2601
                    sal_Int32 nEndX;
2602
                    if (bNegativePage)
2603
					    nEndX = -aStartPoint.X - aEndPoint.X;
2604
                    else
2605
					    nEndX = aStartPoint.X + aSize.Width - aEndPoint.X;
2606
					sal_Int32 nEndY(aStartPoint.Y + aSize.Height - aEndPoint.Y);
2607
					rtl::OUStringBuffer sBuffer;
2575
					rtl::OUStringBuffer sBuffer;
2608
					GetMM100UnitConverter().convertMeasure(sBuffer, nEndX);
2576
					GetMM100UnitConverter().convertMeasure(sBuffer, aItr->nEndX);
2609
					AddAttribute(XML_NAMESPACE_TABLE, XML_END_X, sBuffer.makeStringAndClear());
2577
					AddAttribute(XML_NAMESPACE_TABLE, XML_END_X, sBuffer.makeStringAndClear());
2610
					GetMM100UnitConverter().convertMeasure(sBuffer, nEndY);
2578
					GetMM100UnitConverter().convertMeasure(sBuffer, aItr->nEndY);
2611
					AddAttribute(XML_NAMESPACE_TABLE, XML_END_Y, sBuffer.makeStringAndClear());
2579
					AddAttribute(XML_NAMESPACE_TABLE, XML_END_Y, sBuffer.makeStringAndClear());
2612
				}
2580
				}
2613
				ExportShape(aItr->xShape, &aPoint);
2581
				ExportShape(aItr->xShape, &aPoint);
(-)sc.orig/source/filter/xml/xmlimprt.cxx (-1 / +1 lines)
Lines 2772-2778 Link Here
2772
        if (pDoc)
2772
        if (pDoc)
2773
            pDoc->CompileXML();
2773
            pDoc->CompileXML();
2774
        aTables.UpdateRowHeights();
2774
        aTables.UpdateRowHeights();
2775
        aTables.ResizeShapes();
2775
        aTables.FixupOLEs();
2776
    }
2776
    }
2777
    if (GetModel().is())
2777
    if (GetModel().is())
2778
    {
2778
    {
(-)sc.orig/source/filter/xml/xmlsubti.cxx (-6 / +4 lines)
Lines 145-151 Link Here
145
145
146
ScMyTables::ScMyTables(ScXMLImport& rTempImport)
146
ScMyTables::ScMyTables(ScXMLImport& rTempImport)
147
	: rImport(rTempImport),
147
	: rImport(rTempImport),
148
	aResizeShapes(rTempImport),
148
	aFixupOLEs(rTempImport),
149
	nCurrentColStylePos(0),
149
	nCurrentColStylePos(0),
150
	nCurrentDrawPage( -1 ),
150
	nCurrentDrawPage( -1 ),
151
	nCurrentXShapes( -1 ),
151
	nCurrentXShapes( -1 ),
Lines 715-726 Link Here
715
	return !((nCurrentSheet != nCurrentXShapes) || !xShapes.is());
715
	return !((nCurrentSheet != nCurrentXShapes) || !xShapes.is());
716
}
716
}
717
717
718
void ScMyTables::AddShape(uno::Reference <drawing::XShape>& rShape,
718
void ScMyTables::AddOLE(uno::Reference <drawing::XShape>& rShape,
719
	rtl::OUString* pRangeList,
719
	const rtl::OUString &rRangeList)
720
	table::CellAddress& rStartAddress, table::CellAddress& rEndAddress,
721
	sal_Int32 nEndX, sal_Int32 nEndY)
722
{
720
{
723
	aResizeShapes.AddShape(rShape, pRangeList, rStartAddress, rEndAddress, nEndX, nEndY);
721
	aFixupOLEs.AddOLE(rShape, rRangeList);
724
}
722
}
725
723
726
void ScMyTables::AddMatrixRange(sal_Int32 nStartColumn, sal_Int32 nStartRow, sal_Int32 nEndColumn, sal_Int32 nEndRow, const rtl::OUString& rFormula, const formula::FormulaGrammar::Grammar eGrammar)
724
void ScMyTables::AddMatrixRange(sal_Int32 nStartColumn, sal_Int32 nStartRow, sal_Int32 nEndColumn, sal_Int32 nEndRow, const rtl::OUString& rFormula, const formula::FormulaGrammar::Grammar eGrammar)
(-)sc.orig/source/filter/xml/xmlsubti.hxx (-7 / +6 lines)
Lines 114-120 Link Here
114
114
115
	ScXMLImport&						rImport;
115
	ScXMLImport&						rImport;
116
116
117
	ScMyShapeResizer                    aResizeShapes;
117
	ScMyOLEFixer                        aFixupOLEs;
118
118
119
	::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet > xCurrentSheet;
119
	::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet > xCurrentSheet;
120
	::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange > xCurrentCellRange;
120
	::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange > xCurrentCellRange;
Lines 151-157 Link Here
151
	void								AddColumn(sal_Bool bIsCovered);
151
	void								AddColumn(sal_Bool bIsCovered);
152
	void								NewTable(sal_Int32 nTempSpannedCols);
152
	void								NewTable(sal_Int32 nTempSpannedCols);
153
	void								UpdateRowHeights();
153
	void								UpdateRowHeights();
154
	void								ResizeShapes() { aResizeShapes.ResizeShapes(); }
154
	void								FixupOLEs() { aFixupOLEs.FixupOLEs(); }
155
	sal_Bool							IsOLE(com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& rShape) const
156
        { return ScMyOLEFixer::IsOLE(rShape); }
155
	void								DeleteTable();
157
	void								DeleteTable();
156
	com::sun::star::table::CellAddress	GetRealCellPos();
158
	com::sun::star::table::CellAddress	GetRealCellPos();
157
	void								AddColCount(sal_Int32 nTempColCount);
159
	void								AddColCount(sal_Int32 nTempColCount);
Lines 170-180 Link Here
170
										GetCurrentXShapes();
172
										GetCurrentXShapes();
171
	sal_Bool							HasDrawPage();
173
	sal_Bool							HasDrawPage();
172
	sal_Bool							HasXShapes();
174
	sal_Bool							HasXShapes();
173
	void								AddShape(com::sun::star::uno::Reference <com::sun::star::drawing::XShape>& rShape,
175
	void								AddOLE(com::sun::star::uno::Reference <com::sun::star::drawing::XShape>& rShape,
174
												rtl::OUString* pRangeList,
176
												const rtl::OUString &rRangeList);
175
												com::sun::star::table::CellAddress& rStartAddress,
176
												com::sun::star::table::CellAddress& rEndAddress,
177
												sal_Int32 nEndX, sal_Int32 nEndY);
178
177
179
    void                                AddMatrixRange( sal_Int32 nStartColumn,
178
    void                                AddMatrixRange( sal_Int32 nStartColumn,
180
                                                sal_Int32 nStartRow,
179
                                                sal_Int32 nStartRow,
(-)sc.orig/source/filter/xml/XMLTableShapeImportHelper.cxx (-28 / +30 lines)
Lines 36-41 Link Here
36
#include "drwlayer.hxx"
36
#include "drwlayer.hxx"
37
#include "xmlannoi.hxx"
37
#include "xmlannoi.hxx"
38
#include "rangeutl.hxx"
38
#include "rangeutl.hxx"
39
#include "userdat.hxx"
39
#include <xmloff/nmspmap.hxx>
40
#include <xmloff/nmspmap.hxx>
40
#include <xmloff/xmlnmspe.hxx>
41
#include <xmloff/xmlnmspe.hxx>
41
#include <xmloff/xmluconv.hxx>
42
#include <xmloff/xmluconv.hxx>
Lines 86-91 Link Here
86
	{
87
	{
87
        if (!pAnnotationContext)
88
        if (!pAnnotationContext)
88
        {
89
        {
90
			ScDrawObjData aAnchor;
91
			aAnchor.maStart = ScAddress(aStartCell.Column, aStartCell.Row, aStartCell.Sheet);
92
			awt::Point aStartPoint(rShape->getPosition());
93
			aAnchor.maStartOffset = Point(aStartPoint.X, aStartPoint.Y);
94
89
		    sal_Int32 nEndX(-1);
95
		    sal_Int32 nEndX(-1);
90
		    sal_Int32 nEndY(-1);
96
		    sal_Int32 nEndY(-1);
91
		    sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
97
		    sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
Lines 107-117 Link Here
107
				    {
113
				    {
108
					    sal_Int32 nOffset(0);
114
					    sal_Int32 nOffset(0);
109
					    ScRangeStringConverter::GetAddressFromString(aEndCell, rValue, static_cast<ScXMLImport&>(mrImporter).GetDocument(), ::formula::FormulaGrammar::CONV_OOO, nOffset);
115
					    ScRangeStringConverter::GetAddressFromString(aEndCell, rValue, static_cast<ScXMLImport&>(mrImporter).GetDocument(), ::formula::FormulaGrammar::CONV_OOO, nOffset);
116
					    aAnchor.maEnd = ScAddress(aEndCell.Column, aEndCell.Row, aEndCell.Sheet);
110
				    }
117
				    }
111
				    else if (IsXMLToken(aLocalName, XML_END_X))
118
				    else if (IsXMLToken(aLocalName, XML_END_X))
119
				    {
112
					    static_cast<ScXMLImport&>(mrImporter).GetMM100UnitConverter().convertMeasure(nEndX, rValue);
120
					    static_cast<ScXMLImport&>(mrImporter).GetMM100UnitConverter().convertMeasure(nEndX, rValue);
121
					    aAnchor.maEndOffset.X() = nEndX;
122
				    }
113
				    else if (IsXMLToken(aLocalName, XML_END_Y))
123
				    else if (IsXMLToken(aLocalName, XML_END_Y))
124
				    {
114
					    static_cast<ScXMLImport&>(mrImporter).GetMM100UnitConverter().convertMeasure(nEndY, rValue);
125
					    static_cast<ScXMLImport&>(mrImporter).GetMM100UnitConverter().convertMeasure(nEndY, rValue);
126
					    aAnchor.maEndOffset.Y() = nEndY;
127
				    }
115
				    else if (IsXMLToken(aLocalName, XML_TABLE_BACKGROUND))
128
				    else if (IsXMLToken(aLocalName, XML_TABLE_BACKGROUND))
116
					    if (IsXMLToken(rValue, XML_TRUE))
129
					    if (IsXMLToken(rValue, XML_TRUE))
117
						    nLayerID = SC_LAYER_BACK;
130
						    nLayerID = SC_LAYER_BACK;
Lines 124-162 Link Here
124
		    }
137
		    }
125
            SetLayer(rShape, nLayerID, rShape->getShapeType());
138
            SetLayer(rShape, nLayerID, rShape->getShapeType());
126
139
127
		    if (!bOnTable)
140
		    if (SvxShape* pShapeImp = SvxShape::getImplementation(rShape))
128
		    {
141
		    {
129
			    static_cast<ScXMLImport&>(mrImporter).GetTables().AddShape(rShape,
142
			    if (SdrObject *pSdrObj = pShapeImp->GetSdrObject())
130
				    pRangeList, aStartCell, aEndCell, nEndX, nEndY);
131
			    SvxShape* pShapeImp = SvxShape::getImplementation(rShape);
132
			    if (pShapeImp)
133
			    {
143
			    {
134
				    SdrObject *pSdrObj = pShapeImp->GetSdrObject();
144
				    if (!bOnTable)
135
				    if (pSdrObj)
145
                        ScDrawLayer::SetCellAnchored(*pSdrObj, aAnchor);
136
					    ScDrawLayer::SetAnchor(pSdrObj, SCA_CELL);
146
                    else
147
				        ScDrawLayer::SetPageAnchored(*pSdrObj);
137
			    }
148
			    }
138
		    }
149
		    }
139
		    else
140
		    {
141
                if ( pRangeList )
142
                {
143
                    // #i78086# If there are notification ranges, the ChartListener must be created
144
                    // also when anchored to the sheet
145
                    // -> call AddShape with invalid cell position (checked in ScMyShapeResizer::ResizeShapes)
146
147
                    table::CellAddress aInvalidPos( -1, -1, -1 );
148
                    static_cast<ScXMLImport&>(mrImporter).GetTables().AddShape(rShape,
149
                        pRangeList, aInvalidPos, aInvalidPos, 0, 0);
150
                }
151
150
152
			    SvxShape* pShapeImp = SvxShape::getImplementation(rShape);
151
            if ( bOnTable && pRangeList )
153
			    if (pShapeImp)
152
            {
154
			    {
153
                // #i78086# If there are notification ranges, the ChartListener must be created
155
				    SdrObject *pSdrObj = pShapeImp->GetSdrObject();
154
                // also when anchored to the sheet
156
				    if (pSdrObj)
155
                // -> call AddOLE (fixed up in ScMyShapeResizer::FixupOLEs)
157
					    ScDrawLayer::SetAnchor(pSdrObj, SCA_PAGE);
156
158
			    }
157
                if (static_cast<ScXMLImport&>(mrImporter).GetTables().IsOLE(rShape))
159
		    }
158
                    static_cast<ScXMLImport&>(mrImporter).GetTables().AddOLE(rShape, *pRangeList);
159
            }
160
161
            delete pRangeList;
160
        }
162
        }
161
        else // shape is annotation
163
        else // shape is annotation
162
        {
164
        {
(-)sc.orig/source/filter/xml/XMLTableShapeResizer.cxx (-262 / +36 lines)
Lines 51-88 Link Here
51
using ::std::vector;
51
using ::std::vector;
52
using ::rtl::OUString;
52
using ::rtl::OUString;
53
53
54
ScMyShapeResizer::ScMyShapeResizer(ScXMLImport& rTempImport)
54
ScMyOLEFixer::ScMyOLEFixer(ScXMLImport& rTempImport)
55
    : rImport(rTempImport),
55
    : rImport(rTempImport),
56
    aShapes(),
56
    aShapes(),
57
	pCollection(NULL)
57
	pCollection(NULL)
58
{
58
{
59
}
59
}
60
60
61
ScMyShapeResizer::~ScMyShapeResizer()
61
ScMyOLEFixer::~ScMyOLEFixer()
62
{
62
{
63
}
63
}
64
64
65
sal_Bool ScMyShapeResizer::IsOLE(uno::Reference< drawing::XShape >& rShape) const
65
sal_Bool ScMyOLEFixer::IsOLE(uno::Reference< drawing::XShape >& rShape)
66
{
66
{
67
	return rShape->getShapeType().equals(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.OLE2Shape")));
67
	return rShape->getShapeType().equals(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.OLE2Shape")));
68
}
68
}
69
69
70
void ScMyShapeResizer::CreateChartListener(ScDocument* pDoc,
70
void ScMyOLEFixer::CreateChartListener(ScDocument* pDoc,
71
	const rtl::OUString& rName,
71
	const rtl::OUString& rName,
72
	const rtl::OUString* pRangeList)
72
	const rtl::OUString& rRangeList)
73
{
73
{
74
    if (!pDoc || !pRangeList)
74
    // This is the minimum required.
75
        // These are minimum required.
75
    if (!pDoc)
76
        return;
76
        return;
77
77
78
    if (!pRangeList->getLength())
78
    if (!rRangeList.getLength())
79
    {
79
    {
80
        pDoc->AddOLEObjectToCollection(rName);
80
        pDoc->AddOLEObjectToCollection(rName);
81
        return;
81
        return;
82
    }
82
    }
83
83
84
    OUString aRangeStr;
84
    OUString aRangeStr;
85
    ScRangeStringConverter::GetStringFromXMLRangeString(aRangeStr, *pRangeList, pDoc);
85
    ScRangeStringConverter::GetStringFromXMLRangeString(aRangeStr, rRangeList, pDoc);
86
    if (!aRangeStr.getLength())
86
    if (!aRangeStr.getLength())
87
    {
87
    {
88
        pDoc->AddOLEObjectToCollection(rName);
88
        pDoc->AddOLEObjectToCollection(rName);
Lines 112-382 Link Here
112
    }
112
    }
113
}
113
}
114
114
115
void ScMyShapeResizer::AddShape(uno::Reference <drawing::XShape>& rShape,
115
void ScMyOLEFixer::AddOLE(uno::Reference <drawing::XShape>& rShape,
116
	rtl::OUString* pRangeList,
116
	const rtl::OUString &rRangeList)
117
	table::CellAddress& rStartAddress, table::CellAddress& rEndAddress,
118
	sal_Int32 nEndX, sal_Int32 nEndY)
119
{
117
{
120
	ScMyToResizeShape aShape;
118
	ScMyToFixupOLE aShape;
121
	aShape.xShape.set(rShape);
119
	aShape.xShape.set(rShape);
122
	aShape.pRangeList = pRangeList;
120
	aShape.sRangeList = rRangeList;
123
	aShape.aEndCell = rEndAddress;
124
	aShape.aStartCell = rStartAddress;
125
	aShape.nEndY = nEndY;
126
	aShape.nEndX = nEndX;
127
	aShapes.push_back(aShape);
121
	aShapes.push_back(aShape);
128
}
122
}
129
123
130
void ScMyShapeResizer::GetNewShapeSizePos(ScDocument* pDoc, const Rectangle& rStartRect,
124
void ScMyOLEFixer::FixupOLEs()
131
                                          const table::CellAddress& rEndCell,
132
                                          awt::Point& rPoint, awt::Size& rSize,
133
                                          sal_Int32& rEndX, sal_Int32& rEndY) const
134
{
135
	awt::Point aRefPoint;
136
    BOOL bNegativePage(pDoc->IsNegativePage(rEndCell.Sheet));
137
    if (bNegativePage)
138
        aRefPoint.X = rStartRect.Right();
139
    else
140
	    aRefPoint.X = rStartRect.Left();
141
	aRefPoint.Y = rStartRect.Top();
142
	Rectangle aRect(pDoc->GetMMRect(
143
		static_cast<SCCOL>(rEndCell.Column), static_cast<SCROW>(rEndCell.Row),
144
		static_cast<SCCOL>(rEndCell.Column), static_cast<SCROW>(rEndCell.Row), rEndCell.Sheet ));
145
    if (bNegativePage)
146
        rEndX = -rEndX + aRect.Right();
147
    else
148
	    rEndX += aRect.Left();
149
	rEndY += aRect.Top();
150
	rPoint.X += aRefPoint.X;
151
    if (bNegativePage)
152
    {
153
	    if (rPoint.X < rStartRect.Left())
154
		    rPoint.X = rStartRect.Left() + 2; // increment by 2 100th_mm because the cellwidth is internal in twips
155
    }
156
    else
157
    {
158
	    if (rPoint.X > rStartRect.Right())
159
		    rPoint.X = rStartRect.Right() - 2; // decrement by 2 100th_mm because the cellwidth is internal in twips
160
    }
161
	rPoint.Y += aRefPoint.Y;
162
	if (rPoint.Y > rStartRect.Bottom())
163
		rPoint.Y = rStartRect.Bottom() - 2; // decrement by 2 100th_mm because the cellheight is internal in twips
164
    if (bNegativePage)
165
    {
166
        rSize.Width = -(rEndX - rPoint.X);
167
    }
168
    else
169
	    rSize.Width = rEndX - rPoint.X;
170
	rSize.Height = rEndY - rPoint.Y;
171
}
172
173
void ScMyShapeResizer::ResizeShapes()
174
{
125
{
175
	if (!aShapes.empty() && rImport.GetModel().is())
126
	if (!aShapes.empty() && rImport.GetModel().is())
176
	{
127
	{
177
		rtl::OUString sRowHeight(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_CELLHGT));
178
		rtl::OUString sPersistName (RTL_CONSTASCII_USTRINGPARAM("PersistName"));
128
		rtl::OUString sPersistName (RTL_CONSTASCII_USTRINGPARAM("PersistName"));
179
		rtl::OUString sCaptionPoint( RTL_CONSTASCII_USTRINGPARAM( "CaptionPoint" ));
129
		ScMyToFixupOLEs::iterator aItr(aShapes.begin());
180
        rtl::OUString sConnectorShape( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ConnectorShape") );
130
		ScMyToFixupOLEs::iterator aEndItr(aShapes.end());
181
        rtl::OUString sCaptionShape( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.CaptionShape") );
131
		ScDocument* pDoc(rImport.GetDocument());
182
        rtl::OUString sStartShape(RTL_CONSTASCII_USTRINGPARAM("StartShape"));
132
183
        rtl::OUString sEndShape(RTL_CONSTASCII_USTRINGPARAM("EndShape"));
133
		rImport.LockSolarMutex();
184
        rtl::OUString sStartPosition(RTL_CONSTASCII_USTRINGPARAM("StartPosition"));
134
185
        rtl::OUString sEndPosition(RTL_CONSTASCII_USTRINGPARAM("EndPosition"));
135
		while (aItr != aEndItr)
186
		uno::Reference<table::XCellRange> xTableRow;
187
		uno::Reference<sheet::XSpreadsheet> xSheet;
188
		uno::Reference<table::XTableRows> xTableRows;
189
		sal_Int32 nOldRow(-1);
190
		sal_Int32 nOldSheet(-1);
191
		ScMyToResizeShapes::iterator aItr(aShapes.begin());
192
		ScMyToResizeShapes::iterator aEndItr(aShapes.end());
193
		uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( rImport.GetModel(), uno::UNO_QUERY );
194
		if ( xSpreadDoc.is() )
195
		{
136
		{
196
			uno::Reference<container::XIndexAccess> xIndex( xSpreadDoc->getSheets(), uno::UNO_QUERY );
137
            // #i78086# also call CreateChartListener for invalid position (anchored to sheet)
197
			ScDocument* pDoc(rImport.GetDocument());
138
			if (!IsOLE(aItr->xShape))
198
			if ( pDoc && xIndex.is() )
139
                DBG_ERROR("Only OLEs should be in here now");
140
141
			if (IsOLE(aItr->xShape))
199
			{
142
			{
200
				rImport.LockSolarMutex();
143
				uno::Reference < beans::XPropertySet > xShapeProps ( aItr->xShape, uno::UNO_QUERY );
201
				while (aItr != aEndItr)
144
				uno::Reference < beans::XPropertySetInfo > xShapeInfo(xShapeProps->getPropertySetInfo());
202
				{
145
                rtl::OUString sName;
203
                    // #i78086# invalid cell position is used to call CreateChartListener only
146
204
                    if ( aItr->aEndCell.Sheet >= 0 )
147
				if (pDoc && xShapeProps.is() && xShapeInfo.is() && xShapeInfo->hasPropertyByName(sPersistName) &&
205
                    {
148
                  (xShapeProps->getPropertyValue(sPersistName) >>= sName))
206
    					if ((nOldSheet != aItr->aEndCell.Sheet) || !xSheet.is())
149
				    CreateChartListener(pDoc, sName, aItr->sRangeList);
207
    					{
208
    						nOldSheet = aItr->aEndCell.Sheet;
209
                            xSheet.set(xIndex->getByIndex(nOldSheet), uno::UNO_QUERY);
210
    						if (xSheet.is())
211
    						{
212
    							uno::Reference<table::XColumnRowRange> xColumnRowRange (xSheet, uno::UNO_QUERY);
213
    							if (xColumnRowRange.is())
214
    								xTableRows = xColumnRowRange->getRows();
215
    						}
216
    					}
217
    					if (xTableRows.is())
218
    					{
219
    						if (nOldRow != aItr->aEndCell.Row || !xTableRow.is())
220
    						{
221
    							nOldRow = aItr->aEndCell.Row;
222
    							xTableRows->getByIndex(nOldRow) >>= xTableRow;
223
    						}
224
    						if (xTableRow.is())
225
    						{
226
    							uno::Reference <beans::XPropertySet> xRowProperties(xTableRow, uno::UNO_QUERY);
227
    							if (xRowProperties.is())
228
    							{
229
    								sal_Int32 nHeight;
230
    								if (xRowProperties->getPropertyValue(sRowHeight) >>= nHeight)
231
    								{
232
    									Rectangle aRec = pDoc->GetMMRect(static_cast<SCCOL>(aItr->aStartCell.Column), static_cast<SCROW>(aItr->aStartCell.Row),
233
    										static_cast<SCCOL>(aItr->aStartCell.Column), static_cast<SCROW>(aItr->aStartCell.Row), aItr->aStartCell.Sheet);
234
    									awt::Point aPoint(aItr->xShape->getPosition());
235
    									awt::Size aSize(aItr->xShape->getSize());
236
                                        if (pDoc->IsNegativePage(static_cast<SCTAB>(nOldSheet)))
237
                                            aPoint.X += aSize.Width;
238
    									if (aItr->nEndY >= 0 && aItr->nEndX >= 0)
239
    									{
240
                                            if (aItr->xShape->getShapeType().equals(sConnectorShape))
241
                                            {
242
                                                //#103122#; handle connected Connectorshapes
243
                                                uno::Reference<beans::XPropertySet> xShapeProps (aItr->xShape, uno::UNO_QUERY);
244
                                                if(xShapeProps.is())
245
                                                {
246
                                                    uno::Reference<drawing::XShape> xStartShape(xShapeProps->getPropertyValue(	sStartShape ), uno::UNO_QUERY);
247
                                                    uno::Reference<drawing::XShape> xEndShape(xShapeProps->getPropertyValue( sEndShape ), uno::UNO_QUERY);
248
                                                    if (!xStartShape.is() && !xEndShape.is())
249
                                                    {
250
    										            awt::Size aOldSize(aSize);
251
                                                        GetNewShapeSizePos(pDoc, aRec, aItr->aEndCell, aPoint, aSize, aItr->nEndX, aItr->nEndY);
252
    	                                                aItr->xShape->setPosition(aPoint);
253
    	                                                if( (aSize.Width != aOldSize.Width) ||
254
    		                                                (aSize.Height != aOldSize.Height) )
255
    		                                                aItr->xShape->setSize(aSize);
256
                                                    }
257
                                                    else if (xStartShape.is() && xEndShape.is())
258
                                                    {
259
                                                        // do nothing, because they are connected
260
                                                    }
261
                                                    else
262
                                                    {
263
                                                        // only one point is connected, the other should be moved
264
265
                                                        rtl::OUString sProperty;
266
                                                        if (xStartShape.is())
267
                                                        {
268
                                                            awt::Point aEndPoint;
269
                                                            xShapeProps->getPropertyValue(sEndPosition) >>= aEndPoint;
270
                                                            aPoint.X = aRec.Left() + aEndPoint.X;
271
                                                            aPoint.Y = aRec.Top() + aEndPoint.Y;
272
                                                            sProperty = sEndPosition;
273
                                                        }
274
                                                        else
275
                                                        {
276
                                                            awt::Point aStartPoint;
277
                                                            xShapeProps->getPropertyValue(sStartPosition) >>= aStartPoint;
278
                                                            aPoint.X = aRec.Left() + aStartPoint.X;
279
                                                            aPoint.Y = aRec.Top() + aStartPoint.Y;
280
                                                            sProperty = sStartPosition;
281
                                                        }
282
                                                        xShapeProps->setPropertyValue(sProperty, uno::makeAny(aPoint));
283
                                                    }
284
                                                }
285
                                            }
286
                                            else
287
                                            {
288
    										    awt::Size aOldSize(aSize);
289
                                                GetNewShapeSizePos(pDoc, aRec, aItr->aEndCell, aPoint, aSize, aItr->nEndX, aItr->nEndY);
290
                                                if (pDoc->IsNegativePage(static_cast<SCTAB>(nOldSheet)))
291
                                                    aPoint.X -= aSize.Width;
292
    	                                        aItr->xShape->setPosition(aPoint);
293
    	                                        if( (aSize.Width != aOldSize.Width) ||
294
    		                                        (aSize.Height != aOldSize.Height) )
295
    		                                        aItr->xShape->setSize(aSize);
296
                                            }
297
    									}
298
    									else
299
    									{
300
    										if (aItr->xShape->getShapeType().equals(sCaptionShape))
301
    										{
302
    											Rectangle aRectangle(aPoint.X, aPoint.Y, aPoint.X + aSize.Width, aPoint.Y + aSize.Height);
303
304
    											awt::Point aCaptionPoint;
305
    											uno::Reference< beans::XPropertySet > xShapeProps(aItr->xShape, uno::UNO_QUERY);
306
    											if (xShapeProps.is())
307
    											{
308
    												try
309
    												{
310
    													xShapeProps->getPropertyValue( sCaptionPoint ) >>= aCaptionPoint;
311
    												}
312
    												catch ( uno::Exception& )
313
    												{
314
    													DBG_ERROR("This Captionshape has no CaptionPoint property.");
315
    												}
316
    											}
317
    											Point aCorePoint(aPoint.X, aPoint.Y);
318
    											Point aCoreCaptionPoint(aCaptionPoint.X, aCaptionPoint.Y);
319
    											aCoreCaptionPoint += aCorePoint;
320
    											aRectangle.Union(Rectangle(aCoreCaptionPoint, aCoreCaptionPoint));
321
322
    											Point aBeforeRightBottomPoint(aRectangle.BottomRight());
323
324
    											aRectangle += aRec.TopLeft();
325
    											if (aRectangle.Left() > aRec.Right())
326
    												aRectangle -= (Point(aRectangle.Left() - aRec.Right() + 2, 0));
327
    											if (aRectangle.Top() > aRec.Bottom())
328
    												aRectangle -= (Point(0, aRectangle.Top() - aRec.Bottom() + 2));
329
330
    											Point aDifferencePoint(aRectangle.BottomRight() - aBeforeRightBottomPoint);
331
    											aPoint.X += aDifferencePoint.X();
332
    											aPoint.Y += aDifferencePoint.Y();
333
334
    											aItr->xShape->setPosition(aPoint);
335
    										}
336
    										else
337
    										{
338
    											// #96159# it is possible, that shapes have a negative position
339
    											// this is now handled here
340
    											DBG_ERROR("no or negative end address of this shape");
341
    											awt::Point aRefPoint;
342
    											aRefPoint.X = aRec.Left();
343
    											aRefPoint.Y = aRec.Top();
344
    											aPoint.X += aRefPoint.X;
345
    											if (aPoint.X > aRec.Right())
346
    												aPoint.X = aRec.Right() - 2; // decrement by 2 100th_mm because the cellheight is internal in twips
347
    											aPoint.Y += aRefPoint.Y;
348
    											if (aPoint.Y > aRec.Bottom())
349
    												aPoint.Y = aRec.Bottom() - 2; // decrement by 2 100th_mm because the cellheight is internal in twips
350
    											aItr->xShape->setPosition(aPoint);
351
    										}
352
    									}
353
    								}
354
    							}
355
    						}
356
    					}
357
    					else
358
					{
359
    						DBG_ERROR("something wents wrong");
360
					}
361
                    }
362
                    // #i78086# call CreateChartListener also for invalid position (anchored to sheet)
363
					if (IsOLE(aItr->xShape))
364
					{
365
						uno::Reference < beans::XPropertySet > xShapeProps ( aItr->xShape, uno::UNO_QUERY );
366
						uno::Reference < beans::XPropertySetInfo > xShapeInfo(xShapeProps->getPropertySetInfo());
367
                        rtl::OUString sName;
368
						if (xShapeProps.is() && xShapeInfo.is() && xShapeInfo->hasPropertyByName(sPersistName) &&
369
                            (xShapeProps->getPropertyValue(sPersistName) >>= sName))
370
							CreateChartListener(pDoc, sName, aItr->pRangeList);
371
					}
372
					if (aItr->pRangeList)
373
						delete aItr->pRangeList;
374
					aItr = aShapes.erase(aItr);
375
				}
376
				rImport.UnlockSolarMutex();
377
//				if (pCollection)
378
//					pDoc->SetChartListenerCollection(pCollection);
379
			}
150
			}
151
			aItr = aShapes.erase(aItr);
380
		}
152
		}
153
154
		rImport.UnlockSolarMutex();
381
	}
155
	}
382
}
156
}
(-)sc.orig/source/filter/xml/XMLTableShapeResizer.hxx (-25 / +12 lines)
Lines 41-84 Link Here
41
class ScDocument;
41
class ScDocument;
42
class Rectangle;
42
class Rectangle;
43
43
44
struct ScMyToResizeShape
44
struct ScMyToFixupOLE
45
{
45
{
46
	com::sun::star::uno::Reference <com::sun::star::drawing::XShape> xShape;
46
	com::sun::star::uno::Reference <com::sun::star::drawing::XShape> xShape;
47
	rtl::OUString* pRangeList;
47
	rtl::OUString sRangeList;
48
	com::sun::star::table::CellAddress	aEndCell;
49
	com::sun::star::table::CellAddress	aStartCell;
50
	sal_Int32 nEndX;
51
	sal_Int32 nEndY;
52
53
	ScMyToResizeShape() : pRangeList(NULL) {}
54
};
48
};
55
49
56
typedef std::list<ScMyToResizeShape> ScMyToResizeShapes;
50
typedef std::list<ScMyToFixupOLE> ScMyToFixupOLEs;
57
51
58
class ScMyShapeResizer
52
class ScMyOLEFixer
59
{
53
{
60
	ScXMLImport&				rImport;
54
	ScXMLImport&				rImport;
61
	ScMyToResizeShapes			aShapes;
55
	ScMyToFixupOLEs				aShapes;
62
	ScChartListenerCollection*	pCollection;
56
	ScChartListenerCollection*	pCollection;
63
57
64
	sal_Bool IsOLE(com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& rShape) const;
65
	void CreateChartListener(ScDocument* pDoc,
58
	void CreateChartListener(ScDocument* pDoc,
66
		const rtl::OUString& rName,
59
		const rtl::OUString& rName,
67
		const rtl::OUString* pRangeList);
60
		const rtl::OUString& rRangeList);
68
    void GetNewShapeSizePos(ScDocument* pDoc, const Rectangle& rStartRect,
69
                            const com::sun::star::table::CellAddress& rEndCell,
70
                            com::sun::star::awt::Point& rPoint, com::sun::star::awt::Size& rSize,
71
                            sal_Int32& rEndX, sal_Int32& rEndY) const;
72
public:
61
public:
73
	ScMyShapeResizer(ScXMLImport& rImport);
62
	ScMyOLEFixer(ScXMLImport& rImport);
74
	~ScMyShapeResizer();
63
	~ScMyOLEFixer();
75
64
76
	void	AddShape(com::sun::star::uno::Reference <com::sun::star::drawing::XShape>& rShape,
65
	static sal_Bool IsOLE(com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& rShape);
77
					rtl::OUString* pRangeList,
66
	void	AddOLE(com::sun::star::uno::Reference <com::sun::star::drawing::XShape>& rShape,
78
					com::sun::star::table::CellAddress& rStartAddress,
67
					const rtl::OUString &rRangeList);
79
					com::sun::star::table::CellAddress& rEndAddress,
68
	void	FixupOLEs();
80
					sal_Int32 nEndX, sal_Int32 nEndY);
81
	void	ResizeShapes();
82
};
69
};
83
70
84
#endif
71
#endif
(-)sc.orig/source/ui/Accessibility/AccessibleDocument.cxx (-28 / +4 lines)
Lines 44-49 Link Here
44
#include "drawview.hxx"
44
#include "drawview.hxx"
45
#include "gridwin.hxx"
45
#include "gridwin.hxx"
46
#include "AccessibleEditObject.hxx"
46
#include "AccessibleEditObject.hxx"
47
#include "userdat.hxx"
47
#include "scresid.hxx"
48
#include "scresid.hxx"
48
#ifndef SC_SC_HRC
49
#ifndef SC_SC_HRC
49
#include "sc.hrc"
50
#include "sc.hrc"
Lines 1017-1051 Link Here
1017
        uno::Reference<beans::XPropertySet> xShapeProp(xShape, uno::UNO_QUERY);
1018
        uno::Reference<beans::XPropertySet> xShapeProp(xShape, uno::UNO_QUERY);
1018
	    if (pShapeImp && xShapeProp.is())
1019
	    if (pShapeImp && xShapeProp.is())
1019
	    {
1020
	    {
1020
		    SdrObject *pSdrObj = pShapeImp->GetSdrObject();
1021
		    if (SdrObject *pSdrObj = pShapeImp->GetSdrObject())
1021
		    if (pSdrObj)
1022
		    {
1022
		    {
1023
			    if (ScDrawLayer::GetAnchor(pSdrObj) == SCA_CELL)
1023
				if (ScDrawObjData *pAnchor = ScDrawLayer::GetObjData(pSdrObj))
1024
			    {
1024
					return new ScAddress(pAnchor->maStart);
1025
                    ScDocument* pDoc = mpViewShell->GetViewData()->GetDocument();
1026
				    if (pDoc)
1027
				    {
1028
                        rtl::OUString sCaptionShape(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.CaptionShape"));
1029
					    awt::Point aPoint(xShape->getPosition());
1030
					    awt::Size aSize(xShape->getSize());
1031
					    rtl::OUString sType(xShape->getShapeType());
1032
					    Rectangle aRectangle(aPoint.X, aPoint.Y, aPoint.X + aSize.Width, aPoint.Y + aSize.Height);
1033
					    if ( sType.equals(sCaptionShape) )
1034
					    {
1035
						    awt::Point aRelativeCaptionPoint;
1036
                            rtl::OUString sCaptionPoint( RTL_CONSTASCII_USTRINGPARAM( "CaptionPoint" ));
1037
						    xShapeProp->getPropertyValue( sCaptionPoint ) >>= aRelativeCaptionPoint;
1038
						    Point aCoreRelativeCaptionPoint(aRelativeCaptionPoint.X, aRelativeCaptionPoint.Y);
1039
						    Point aCoreAbsoluteCaptionPoint(aPoint.X, aPoint.Y);
1040
						    aCoreAbsoluteCaptionPoint += aCoreRelativeCaptionPoint;
1041
						    aRectangle.Union(Rectangle(aCoreAbsoluteCaptionPoint, aCoreAbsoluteCaptionPoint));
1042
					    }
1043
					    ScRange aRange = pDoc->GetRange(mpAccessibleDocument->getVisibleTable(), aRectangle);
1044
                        pAddress = new ScAddress(aRange.aStart);
1045
				    }
1046
			    }
1047
//			    else
1048
//				    do nothing, because it is always a NULL Pointer
1049
		    }
1025
		    }
1050
	    }
1026
	    }
1051
    }
1027
    }
(-)sc.orig/source/ui/drawfunc/drawsh2.cxx (-1 / +1 lines)
Lines 115-121 Link Here
115
115
116
	if ( !bDisableAnchor )
116
	if ( !bDisableAnchor )
117
	{
117
	{
118
	    switch( pView->GetAnchor() )
118
	    switch( pView->GetAnchorType() )
119
	    {
119
	    {
120
		case SCA_PAGE:
120
		case SCA_PAGE:
121
	        rSet.Put( SfxBoolItem( SID_ANCHOR_PAGE, TRUE ) );
121
	        rSet.Put( SfxBoolItem( SID_ANCHOR_PAGE, TRUE ) );
(-)sc.orig/source/ui/drawfunc/drawsh5.cxx (-5 / +5 lines)
Lines 397-422 Link Here
397
            break;
397
            break;
398
398
399
        case SID_ANCHOR_PAGE:
399
        case SID_ANCHOR_PAGE:
400
            pView->SetAnchor( SCA_PAGE );
400
            pView->SetPageAnchored();
401
            rBindings.Invalidate( SID_ANCHOR_PAGE );
401
            rBindings.Invalidate( SID_ANCHOR_PAGE );
402
            rBindings.Invalidate( SID_ANCHOR_CELL );
402
            rBindings.Invalidate( SID_ANCHOR_CELL );
403
            break;
403
            break;
404
404
405
        case SID_ANCHOR_CELL:
405
        case SID_ANCHOR_CELL:
406
            pView->SetAnchor( SCA_CELL );
406
            pView->SetCellAnchored();
407
            rBindings.Invalidate( SID_ANCHOR_PAGE );
407
            rBindings.Invalidate( SID_ANCHOR_PAGE );
408
            rBindings.Invalidate( SID_ANCHOR_CELL );
408
            rBindings.Invalidate( SID_ANCHOR_CELL );
409
            break;
409
            break;
410
410
411
        case SID_ANCHOR_TOGGLE:
411
        case SID_ANCHOR_TOGGLE:
412
            {
412
            {
413
                switch( pView->GetAnchor() )
413
                switch( pView->GetAnchorType() )
414
                {
414
                {
415
                    case SCA_CELL:
415
                    case SCA_CELL:
416
                    pView->SetAnchor( SCA_PAGE );
416
                    pView->SetPageAnchored();
417
                    break;
417
                    break;
418
                    default:
418
                    default:
419
                    pView->SetAnchor( SCA_CELL );
419
                    pView->SetCellAnchored();
420
                    break;
420
                    break;
421
                }
421
                }
422
            }
422
            }
(-)sc.orig/source/ui/inc/drawview.hxx (-2 / +3 lines)
Lines 100-107 Link Here
100
100
101
	void			CalcNormScale( Fraction& rFractX, Fraction& rFractY ) const;
101
	void			CalcNormScale( Fraction& rFractX, Fraction& rFractY ) const;
102
102
103
	void			SetAnchor( ScAnchorType );
103
	void			SetPageAnchored();
104
	ScAnchorType	GetAnchor() const;
104
	void			SetCellAnchored();
105
	ScAnchorType	GetAnchorType() const;
105
106
106
	void			VCAddWin( Window* pWin );
107
	void			VCAddWin( Window* pWin );
107
	void			VCRemoveWin( Window* pWin );
108
	void			VCRemoveWin( Window* pWin );
(-)sc.orig/source/ui/unoobj/shapeuno.cxx (-34 / +29 lines)
Lines 365-384 Link Here
365
                                table::CellRangeAddress aAddress = xRangeAdd->getRangeAddress();
365
                                table::CellRangeAddress aAddress = xRangeAdd->getRangeAddress();
366
                                if (nTab == aAddress.Sheet)
366
                                if (nTab == aAddress.Sheet)
367
                                {
367
                                {
368
                                    if (aAddress.StartRow != aAddress.EndRow) //should be a Spreadsheet
369
                                    {
370
                                        DBG_ASSERT(aAddress.StartRow == 0 && aAddress.EndRow == MAXROW &&
371
                                            aAddress.StartColumn == 0 && aAddress.EndColumn == MAXCOL, "here should be a XSpreadsheet");
372
			                            ScDrawLayer::SetAnchor(pObj, SCA_PAGE);
373
                                    }
374
                                    else
375
                                    {
376
                                        DBG_ASSERT(aAddress.StartRow == aAddress.EndRow &&
377
                                            aAddress.StartColumn == aAddress.EndColumn, "here should be a XCell");
378
			                            ScDrawLayer::SetAnchor(pObj, SCA_CELL);
379
                                    }
380
                                    Rectangle aRect(pDoc->GetMMRect( static_cast<SCCOL>(aAddress.StartColumn), static_cast<SCROW>(aAddress.StartRow),
368
                                    Rectangle aRect(pDoc->GetMMRect( static_cast<SCCOL>(aAddress.StartColumn), static_cast<SCROW>(aAddress.StartRow),
381
                                        static_cast<SCCOL>(aAddress.EndColumn), static_cast<SCROW>(aAddress.EndRow), aAddress.Sheet ));
369
                                        static_cast<SCCOL>(aAddress.EndColumn), static_cast<SCROW>(aAddress.EndRow), aAddress.Sheet ));
370
                                    awt::Point aRelPoint;
382
                                    uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY );
371
                                    uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY );
383
                                    if (xShape.is())
372
                                    if (xShape.is())
384
                                    {
373
                                    {
Lines 397-403 Link Here
397
                                        awt::Size aUnoSize;
386
                                        awt::Size aUnoSize;
398
                                        awt::Point aCaptionPoint;
387
                                        awt::Point aCaptionPoint;
399
                                        ScRange aRange;
388
                                        ScRange aRange;
400
                                        awt::Point aUnoPoint(lcl_GetRelativePos( xShape, pDoc, nTab, aRange, aUnoSize, aCaptionPoint ));
389
                                        aRelPoint = lcl_GetRelativePos( xShape, pDoc, nTab, aRange, aUnoSize, aCaptionPoint );
390
                                        awt::Point aUnoPoint(aRelPoint);
401
391
402
                                        aUnoPoint.X += aPoint.X();
392
                                        aUnoPoint.X += aPoint.X();
403
                                        aUnoPoint.Y += aPoint.Y();
393
                                        aUnoPoint.Y += aPoint.Y();
Lines 426-431 Link Here
426
                                        xShape->setPosition(aUnoPoint);
416
                                        xShape->setPosition(aUnoPoint);
427
                                        pDocSh->SetModified();
417
                                        pDocSh->SetModified();
428
                                    }
418
                                    }
419
420
                                    if (aAddress.StartRow != aAddress.EndRow) //should be a Spreadsheet
421
                                    {
422
                                        DBG_ASSERT(aAddress.StartRow == 0 && aAddress.EndRow == MAXROW &&
423
                                            aAddress.StartColumn == 0 && aAddress.EndColumn == MAXCOL, "here should be a XSpreadsheet");
424
			                            ScDrawLayer::SetPageAnchored(*pObj);
425
                                    }
426
                                    else
427
                                    {
428
                                        DBG_ASSERT(aAddress.StartRow == aAddress.EndRow &&
429
                                            aAddress.StartColumn == aAddress.EndColumn, "here should be a XCell");
430
			                            ScDrawObjData aAnchor;
431
										aAnchor.maStart = ScAddress(aAddress.StartColumn, aAddress.StartRow, aAddress.Sheet);
432
										aAnchor.maStartOffset = Point(aRelPoint.X, aRelPoint.Y);
433
			                            ScDrawLayer::SetCellAnchored(*pObj, aAnchor);
434
			                            //Currently we've only got a start anchor, not an end-anchor, so generate that now
435
			                            ScDrawLayer::UpdateCellAnchorFromPositionEnd(*pObj, *pDoc, aAddress.Sheet);
436
                                    }
429
                                }
437
                                }
430
					        }
438
					        }
431
				        }
439
				        }
Lines 485-491 Link Here
485
                                uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY );
493
                                uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY );
486
                                if (xShape.is())
494
                                if (xShape.is())
487
                                {
495
                                {
488
                                    if (ScDrawLayer::GetAnchor(pObj) == SCA_PAGE)
496
                                    if (ScDrawLayer::GetAnchorType(*pObj) == SCA_PAGE)
489
                                    {
497
                                    {
490
                                        awt::Point aPoint(xShape->getPosition());
498
                                        awt::Point aPoint(xShape->getPosition());
491
                                        awt::Size aSize(xShape->getSize());
499
                                        awt::Size aSize(xShape->getSize());
Lines 512-518 Link Here
512
                                        xShape->setPosition(aPoint);
520
                                        xShape->setPosition(aPoint);
513
                                        pDocSh->SetModified();
521
                                        pDocSh->SetModified();
514
                                    }
522
                                    }
515
                                    else if (ScDrawLayer::GetAnchor(pObj) == SCA_CELL)
523
                                    else if (ScDrawLayer::GetAnchorType(*pObj) == SCA_CELL)
516
                                    {
524
                                    {
517
                                        awt::Size aUnoSize;
525
                                        awt::Size aUnoSize;
518
                                        awt::Point aCaptionPoint;
526
                                        awt::Point aCaptionPoint;
Lines 583-589 Link Here
583
                                uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY );
591
                                uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY );
584
                                if (xShape.is())
592
                                if (xShape.is())
585
                                {
593
                                {
586
                                    if (ScDrawLayer::GetAnchor(pObj) == SCA_PAGE)
594
                                    if (ScDrawLayer::GetAnchorType(*pObj) == SCA_PAGE)
587
                                    {
595
                                    {
588
                                        awt::Point aPoint = xShape->getPosition();
596
                                        awt::Point aPoint = xShape->getPosition();
589
                                        awt::Point aCaptionPoint;
597
                                        awt::Point aCaptionPoint;
Lines 596-602 Link Here
596
                                        xShape->setPosition(aPoint);
604
                                        xShape->setPosition(aPoint);
597
                                        pDocSh->SetModified();
605
                                        pDocSh->SetModified();
598
                                    }
606
                                    }
599
                                    else if (ScDrawLayer::GetAnchor(pObj) == SCA_CELL)
607
                                    else if (ScDrawLayer::GetAnchorType(*pObj) == SCA_CELL)
600
                                    {
608
                                    {
601
                                        awt::Size aUnoSize;
609
                                        awt::Size aUnoSize;
602
                                        awt::Point aCaptionPoint;
610
                                        awt::Point aCaptionPoint;
Lines 663-685 Link Here
663
				        {
671
				        {
664
					        ScDocShell* pDocSh = (ScDocShell*)pObjSh;
672
					        ScDocShell* pDocSh = (ScDocShell*)pObjSh;
665
                		    uno::Reference< uno::XInterface > xAnchor;
673
                		    uno::Reference< uno::XInterface > xAnchor;
666
			                if (ScDrawLayer::GetAnchor(pObj) == SCA_CELL)
674
			                if (ScDrawObjData *pAnchor = ScDrawLayer::GetObjDataTab(pObj, nTab))
667
                            {
675
    						    xAnchor.set(static_cast<cppu::OWeakObject*>(new ScCellObj( pDocSh, pAnchor->maStart)));
668
                                uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY );
669
                                if (xShape.is())
670
                                {
671
                                    awt::Size aUnoSize;
672
                                    awt::Point aCaptionPoint;
673
                                    ScRange aRange;
674
                                    awt::Point aUnoPoint(lcl_GetRelativePos( xShape, pDoc, nTab, aRange, aUnoSize, aCaptionPoint ));
675
676
    						        xAnchor.set(static_cast<cppu::OWeakObject*>(new ScCellObj( pDocSh, aRange.aStart )));
677
                                }
678
                            }
679
                            else
676
                            else
680
                            {
681
    						    xAnchor.set(static_cast<cppu::OWeakObject*>(new ScTableSheetObj( pDocSh, nTab )));
677
    						    xAnchor.set(static_cast<cppu::OWeakObject*>(new ScTableSheetObj( pDocSh, nTab )));
682
                            }
683
                            aAny <<= xAnchor;
678
                            aAny <<= xAnchor;
684
                        }
679
                        }
685
					}
680
					}
Lines 722-728 Link Here
722
                        uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY );
717
                        uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY );
723
                        if (xShape.is())
718
                        if (xShape.is())
724
                        {
719
                        {
725
			                if (ScDrawLayer::GetAnchor(pObj) == SCA_CELL)
720
			                if (ScDrawLayer::GetAnchorType(*pObj) == SCA_CELL)
726
                            {
721
                            {
727
                                awt::Size aUnoSize;
722
                                awt::Size aUnoSize;
728
                                awt::Point aCaptionPoint;
723
                                awt::Point aCaptionPoint;
Lines 782-788 Link Here
782
                        if (xShape.is())
777
                        if (xShape.is())
783
                        {
778
                        {
784
                		    uno::Reference< uno::XInterface > xAnchor;
779
                		    uno::Reference< uno::XInterface > xAnchor;
785
			                if (ScDrawLayer::GetAnchor(pObj) == SCA_CELL)
780
			                if (ScDrawLayer::GetAnchorType(*pObj) == SCA_CELL)
786
                            {
781
                            {
787
                                awt::Size aUnoSize;
782
                                awt::Size aUnoSize;
788
                                awt::Point aCaptionPoint;
783
                                awt::Point aCaptionPoint;
(-)sc.orig/source/ui/view/drawvie3.cxx (-4 / +39 lines)
Lines 77-83 Link Here
77
77
78
// Verankerung setzen
78
// Verankerung setzen
79
79
80
void ScDrawView::SetAnchor( ScAnchorType eType )
80
void ScDrawView::SetPageAnchored()
81
{
81
{
82
	SdrObject* pObj = NULL;
82
	SdrObject* pObj = NULL;
83
	if( AreObjectsMarked() )
83
	if( AreObjectsMarked() )
Lines 87-93 Link Here
87
		for( ULONG i=0; i<nCount; i++ )
87
		for( ULONG i=0; i<nCount; i++ )
88
		{
88
		{
89
			pObj = pMark->GetMark(i)->GetMarkedSdrObj();
89
			pObj = pMark->GetMark(i)->GetMarkedSdrObj();
90
			ScDrawLayer::SetAnchor( pObj, eType );
90
			ScDrawLayer::SetPageAnchored( *pObj );
91
		}
91
		}
92
92
93
		if ( pViewData )
93
		if ( pViewData )
Lines 95-101 Link Here
95
	}
95
	}
96
}
96
}
97
97
98
ScAnchorType ScDrawView::GetAnchor() const
98
void ScDrawView::SetCellAnchored()
99
{
100
    if (!pDoc)
101
        return;
102
103
	SdrObject* pObj = NULL;
104
	if( AreObjectsMarked() )
105
	{
106
		const SdrMarkList* pMark = &GetMarkedObjectList();
107
		ULONG nCount = pMark->GetMarkCount();
108
		for( ULONG i=0; i<nCount; i++ )
109
		{
110
			pObj = pMark->GetMark(i)->GetMarkedSdrObj();
111
			ScDrawLayer::SetCellAnchoredFromPosition(*pObj, *pDoc, nTab);
112
		}
113
114
		if ( pViewData )
115
			pViewData->GetDocShell()->SetDrawModified();
116
	}
117
}
118
119
ScAnchorType ScDrawView::GetAnchorType() const
99
{
120
{
100
	BOOL bPage = FALSE;
121
	BOOL bPage = FALSE;
101
	BOOL bCell = FALSE;
122
	BOOL bCell = FALSE;
Lines 108-114 Link Here
108
		for( ULONG i=0; i<nCount; i++ )
129
		for( ULONG i=0; i<nCount; i++ )
109
		{
130
		{
110
			pObj = pMark->GetMark(i)->GetMarkedSdrObj();
131
			pObj = pMark->GetMark(i)->GetMarkedSdrObj();
111
			if( ScDrawLayer::GetAnchor( pObj ) == SCA_CELL )
132
			if( ScDrawLayer::GetAnchorType( *pObj ) == SCA_CELL )
112
				bCell =TRUE;
133
				bCell =TRUE;
113
			else
134
			else
114
				bPage = TRUE;
135
				bPage = TRUE;
Lines 138-143 Link Here
138
		if ( nTab == ((ScTabSizeChangedHint&)rHint).GetTab() )
159
		if ( nTab == ((ScTabSizeChangedHint&)rHint).GetTab() )
139
			UpdateWorkArea();
160
			UpdateWorkArea();
140
	}
161
	}
162
	else if ( rHint.ISA( SdrHint ) )
163
	{
164
		if (const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint ))
165
		{
166
			//Update the anchors of any object that is cell anchored which has
167
			//been moved since the last anchors for its position was calculated
168
			if (pSdrHint->GetKind() == HINT_OBJCHG || pSdrHint->GetKind() == HINT_OBJINSERTED)
169
				if (SdrObject* pObj = const_cast<SdrObject*>(pSdrHint->GetObject()))
170
					if (ScDrawObjData *pAnchor = ScDrawLayer::GetObjData(pObj))
171
						if (pAnchor->maLastRect != pObj->GetLogicRect())
172
							ScDrawLayer::SetCellAnchoredFromPosition(*pObj, *pDoc, nTab);
173
		}
174
		FmFormView::Notify( rBC,rHint );
175
	}
141
	else
176
	else
142
		FmFormView::Notify( rBC,rHint );
177
		FmFormView::Notify( rBC,rHint );
143
}
178
}
(-)sc.orig/source/ui/view/drawview.cxx (-33 / +4 lines)
Lines 164-203 Link Here
164
	UINT32 nCount = rMrkList.GetMarkCount();
164
	UINT32 nCount = rMrkList.GetMarkCount();
165
	for(UINT32 nPos=0; nPos<nCount; nPos++ )
165
	for(UINT32 nPos=0; nPos<nCount; nPos++ )
166
	{
166
	{
167
		const SdrObject* pObj = rMrkList.GetMark(nPos)->GetMarkedSdrObj();
167
		SdrObject* pObj = rMrkList.GetMark(nPos)->GetMarkedSdrObj();
168
		if(ScDrawLayer::GetAnchor(pObj) == SCA_CELL)
168
		if (ScDrawObjData *pAnchor = ScDrawLayer::GetObjDataTab(pObj, nTab))
169
		{
169
		{
170
			const INT32 nDelta = 1;
170
			if (ScTabView* pView = pViewData->GetView())
171
171
				pView->CreateAnchorHandles(aHdl, pAnchor->maStart);
172
			Rectangle aBoundRect = pObj->GetCurrentBoundRect();
173
			Point aPos;
174
			if (bNegativePage)
175
			{
176
				aPos = aBoundRect.TopRight();
177
				aPos.X() = -aPos.X();			// so the loop below is the same
178
			}
179
			else
180
				aPos = aBoundRect.TopLeft();
181
			long nPosX = (long) (aPos.X() / HMM_PER_TWIPS) + nDelta;
182
			long nPosY = (long) (aPos.Y() / HMM_PER_TWIPS) + nDelta;
183
184
			SCCOL nCol;
185
			INT32 nWidth = 0;
186
187
			for(nCol=0; nCol<=MAXCOL && nWidth<=nPosX; nCol++)
188
				nWidth += pDoc->GetColWidth(nCol,nTab);
189
190
			if(nCol > 0)
191
				--nCol;
192
193
            SCROW nRow = nPosY <= 0 ? 0 : pDoc->FastGetRowForHeight( nTab,
194
                    (ULONG) nPosY);
195
			if(nRow > 0)
196
				--nRow;
197
198
			ScTabView* pView = pViewData->GetView();
199
			ScAddress aScAddress(nCol, nRow, nTab);
200
			pView->CreateAnchorHandles(aHdl, aScAddress);
201
		}
172
		}
202
	}
173
	}
203
}
174
}

Return to issue 102061