f41
Caolán McNamara 14 years ago
parent da1d217923
commit eda739924d

@ -87,7 +87,7 @@ diff -ru sc.orig/source/core/data/documen3.cxx sc/source/core/data/documen3.cxx
diff -ru sc.orig/source/core/data/drwlayer.cxx sc/source/core/data/drwlayer.cxx diff -ru sc.orig/source/core/data/drwlayer.cxx sc/source/core/data/drwlayer.cxx
--- sc.orig/source/core/data/drwlayer.cxx 2009-06-04 12:39:09.000000000 +0100 --- sc.orig/source/core/data/drwlayer.cxx 2009-06-04 12:39:09.000000000 +0100
+++ sc/source/core/data/drwlayer.cxx 2009-06-05 12:28:12.000000000 +0100 +++ sc/source/core/data/drwlayer.cxx 2009-06-05 12:28:12.000000000 +0100
@@ -68,6 +68,9 @@ @@ -69,6 +69,9 @@
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include <unotools/ucbstreamhelper.hxx> #include <unotools/ucbstreamhelper.hxx>
@ -97,8 +97,8 @@ diff -ru sc.orig/source/core/data/drwlayer.cxx sc/source/core/data/drwlayer.cxx
#include "drwlayer.hxx" #include "drwlayer.hxx"
#include "drawpage.hxx" #include "drawpage.hxx"
#include "global.hxx" #include "global.hxx"
@@ -526,7 +529,41 @@ @@ -539,7 +542,41 @@
} }
} }
-void ScDrawLayer::RecalcPos( SdrObject* pObj, const ScDrawObjData& rData, bool bNegativePage, bool bUpdateNoteCaptionPos ) -void ScDrawLayer::RecalcPos( SdrObject* pObj, const ScDrawObjData& rData, bool bNegativePage, bool bUpdateNoteCaptionPos )
@ -138,126 +138,126 @@ diff -ru sc.orig/source/core/data/drwlayer.cxx sc/source/core/data/drwlayer.cxx
+ +
+void ScDrawLayer::RecalcPos( SdrObject* pObj, ScDrawObjData& rData, bool bNegativePage, bool bUpdateNoteCaptionPos ) +void ScDrawLayer::RecalcPos( SdrObject* pObj, ScDrawObjData& rData, bool bNegativePage, bool bUpdateNoteCaptionPos )
{ {
DBG_ASSERT( pDoc, "ScDrawLayer::RecalcPos - missing document" ); DBG_ASSERT( pDoc, "ScDrawLayer::RecalcPos - missing document" );
if( !pDoc ) if( !pDoc )
@@ -565,6 +602,8 @@ @@ -578,6 +615,8 @@
if( bCircle ) if( bCircle )
{ {
+ rData.maLastRect = pObj->GetLogicRect(); + rData.maLastRect = pObj->GetLogicRect();
+ +
Point aPos( pDoc->GetColOffset( nCol1, nTab1 ), pDoc->GetRowOffset( nRow1, nTab1 ) ); Point aPos( pDoc->GetColOffset( nCol1, nTab1 ), pDoc->GetRowOffset( nRow1, nTab1 ) );
TwipsToMM( aPos.X() ); TwipsToMM( aPos.X() );
TwipsToMM( aPos.Y() ); TwipsToMM( aPos.Y() );
@@ -585,11 +624,18 @@ @@ -598,11 +637,18 @@
{ {
if (bRecording) if (bRecording)
AddCalcUndo( new SdrUndoGeoObj( *pObj ) ); AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
- pObj->SetLogicRect(aRect); - pObj->SetLogicRect(aRect);
+ rData.maLastRect = lcl_makeSafeRectangle(aRect); + rData.maLastRect = lcl_makeSafeRectangle(aRect);
+ pObj->SetLogicRect(rData.maLastRect); + pObj->SetLogicRect(rData.maLastRect);
} }
} }
else if( bArrow ) else if( bArrow )
{ {
+ rData.maLastRect = pObj->GetLogicRect(); + rData.maLastRect = pObj->GetLogicRect();
+ basegfx::B2DPolygon aCalcPoly; + basegfx::B2DPolygon aCalcPoly;
+ Point aOrigStartPos(pObj->GetPoint(0)); + Point aOrigStartPos(pObj->GetPoint(0));
+ Point aOrigEndPos(pObj->GetPoint(1)); + Point aOrigEndPos(pObj->GetPoint(1));
+ aCalcPoly.append(basegfx::B2DPoint(aOrigStartPos.X(), aOrigStartPos.Y())); + aCalcPoly.append(basegfx::B2DPoint(aOrigStartPos.X(), aOrigStartPos.Y()));
+ aCalcPoly.append(basegfx::B2DPoint(aOrigEndPos.X(), aOrigEndPos.Y())); + aCalcPoly.append(basegfx::B2DPoint(aOrigEndPos.X(), aOrigEndPos.Y()));
//! nicht mehrere Undos fuer ein Objekt erzeugen (hinteres kann dann weggelassen werden) //! nicht mehrere Undos fuer ein Objekt erzeugen (hinteres kann dann weggelassen werden)
SCCOL nLastCol; SCCOL nLastCol;
@@ -610,6 +656,8 @@ @@ -623,6 +669,8 @@
{ {
if (bRecording) if (bRecording)
AddCalcUndo( new SdrUndoGeoObj( *pObj ) ); AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
+ +
+ rData.maLastRect = lcl_UpdateCalcPoly(aCalcPoly, 0, aStartPos); + rData.maLastRect = lcl_UpdateCalcPoly(aCalcPoly, 0, aStartPos);
pObj->SetPoint( aStartPos, 0 ); pObj->SetPoint( aStartPos, 0 );
} }
@@ -624,6 +672,8 @@ @@ -637,6 +685,8 @@
{ {
if (bRecording) if (bRecording)
AddCalcUndo( new SdrUndoGeoObj( *pObj ) ); AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
+ +
+ rData.maLastRect = lcl_UpdateCalcPoly(aCalcPoly, 1, aEndPos); + rData.maLastRect = lcl_UpdateCalcPoly(aCalcPoly, 1, aEndPos);
pObj->SetPoint( aEndPos, 1 ); pObj->SetPoint( aEndPos, 1 );
} }
} }
@@ -644,6 +694,8 @@ @@ -657,6 +707,8 @@
{ {
if (bRecording) if (bRecording)
AddCalcUndo( new SdrUndoGeoObj( *pObj ) ); AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
+ +
+ rData.maLastRect = lcl_UpdateCalcPoly(aCalcPoly, 1, aEndPos); + rData.maLastRect = lcl_UpdateCalcPoly(aCalcPoly, 1, aEndPos);
pObj->SetPoint( aEndPos, 1 ); pObj->SetPoint( aEndPos, 1 );
} }
@@ -660,45 +712,68 @@ @@ -673,45 +725,68 @@
{ {
if (bRecording) if (bRecording)
AddCalcUndo( new SdrUndoGeoObj( *pObj ) ); AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
+ +
+ rData.maLastRect = lcl_UpdateCalcPoly(aCalcPoly, 0, aStartPos); + rData.maLastRect = lcl_UpdateCalcPoly(aCalcPoly, 0, aStartPos);
pObj->SetPoint( aStartPos, 0 ); pObj->SetPoint( aStartPos, 0 );
} }
} }
} }
} }
- else // Referenz-Rahmen - else // Referenz-Rahmen
+ else + else
{ {
+ bool bCanResize = bValid2 && !pObj->IsResizeProtect(); + bool bCanResize = bValid2 && !pObj->IsResizeProtect();
+ +
+ //First time positioning, must be able to at least move it + //First time positioning, must be able to at least move it
+ if (rData.maLastRect.IsEmpty()) + if (rData.maLastRect.IsEmpty())
+ rData.maLastRect = pObj->GetLogicRect(); + rData.maLastRect = pObj->GetLogicRect();
+ +
DBG_ASSERT( bValid1, "ScDrawLayer::RecalcPos - invalid start position" ); DBG_ASSERT( bValid1, "ScDrawLayer::RecalcPos - invalid start position" );
Point aPos( pDoc->GetColOffset( nCol1, nTab1 ), pDoc->GetRowOffset( nRow1, nTab1 ) ); Point aPos( pDoc->GetColOffset( nCol1, nTab1 ), pDoc->GetRowOffset( nRow1, nTab1 ) );
TwipsToMM( aPos.X() ); TwipsToMM( aPos.X() );
TwipsToMM( aPos.Y() ); TwipsToMM( aPos.Y() );
+ aPos += lcl_calcAvailableDiff(*pDoc, nCol1, nRow1, nTab1, rData.maStartOffset); + aPos += lcl_calcAvailableDiff(*pDoc, nCol1, nRow1, nTab1, rData.maStartOffset);
- if( bValid2 ) - if( bValid2 )
+ if( bCanResize ) + if( bCanResize )
{ {
- Point aEnd( pDoc->GetColOffset( nCol2 + 1, nTab2 ), pDoc->GetRowOffset( nRow2 + 1, nTab2 ) ); - Point aEnd( pDoc->GetColOffset( nCol2 + 1, nTab2 ), pDoc->GetRowOffset( nRow2 + 1, nTab2 ) );
+ Point aEnd( pDoc->GetColOffset( nCol2, nTab2 ), pDoc->GetRowOffset( nRow2, nTab2 ) ); + Point aEnd( pDoc->GetColOffset( nCol2, nTab2 ), pDoc->GetRowOffset( nRow2, nTab2 ) );
TwipsToMM( aEnd.X() ); TwipsToMM( aEnd.X() );
TwipsToMM( aEnd.Y() ); TwipsToMM( aEnd.Y() );
+ aEnd += lcl_calcAvailableDiff(*pDoc, nCol2, nRow2, nTab2, rData.maEndOffset); + aEnd += lcl_calcAvailableDiff(*pDoc, nCol2, nRow2, nTab2, rData.maEndOffset);
Rectangle aNew( aPos, aEnd ); Rectangle aNew( aPos, aEnd );
if ( bNegativePage ) if ( bNegativePage )
MirrorRectRTL( aNew ); MirrorRectRTL( aNew );
if ( pObj->GetLogicRect() != aNew ) if ( pObj->GetLogicRect() != aNew )
{ {
+ Rectangle aOld(pObj->GetLogicRect()); + Rectangle aOld(pObj->GetLogicRect());
+ +
if (bRecording) if (bRecording)
AddCalcUndo( new SdrUndoGeoObj( *pObj ) ); AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
- pObj->SetLogicRect(aNew); - pObj->SetLogicRect(aNew);
+ rData.maLastRect = lcl_makeSafeRectangle(aNew); + rData.maLastRect = lcl_makeSafeRectangle(aNew);
+ pObj->SetLogicRect(rData.maLastRect); + pObj->SetLogicRect(rData.maLastRect);
} }
} }
else else
{ {
if ( bNegativePage ) if ( bNegativePage )
- aPos.X() = -aPos.X(); - aPos.X() = -aPos.X();
+ aPos.X() = -aPos.X() - rData.maLastRect.GetWidth(); + aPos.X() = -aPos.X() - rData.maLastRect.GetWidth();
if ( pObj->GetRelativePos() != aPos ) if ( pObj->GetRelativePos() != aPos )
{ {
if (bRecording) if (bRecording)
AddCalcUndo( new SdrUndoGeoObj( *pObj ) ); AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
+ rData.maLastRect.SetPos( aPos ); + rData.maLastRect.SetPos( aPos );
pObj->SetRelativePos( aPos ); pObj->SetRelativePos( aPos );
} }
} }
+ +
+ /* + /*
+ * If we were not allowed resize the object, then the end cell anchor + * If we were not allowed resize the object, then the end cell anchor
@ -267,193 +267,193 @@ diff -ru sc.orig/source/core/data/drwlayer.cxx sc/source/core/data/drwlayer.cxx
+ bool bEndAnchorIsBad = !bValid2 || pObj->IsResizeProtect(); + bool bEndAnchorIsBad = !bValid2 || pObj->IsResizeProtect();
+ if (bEndAnchorIsBad) + if (bEndAnchorIsBad)
+ ScDrawLayer::UpdateCellAnchorFromPositionEnd(*pObj, *pDoc, nTab1); + ScDrawLayer::UpdateCellAnchorFromPositionEnd(*pObj, *pDoc, nTab1);
} }
} }
@@ -873,151 +948,6 @@ @@ -886,151 +961,6 @@
return pRet; return pRet;
} }
-// MoveAreaTwips: all measures are kept in twips -// MoveAreaTwips: all measures are kept in twips
-void ScDrawLayer::MoveAreaTwips( SCTAB nTab, const Rectangle& rArea, -void ScDrawLayer::MoveAreaTwips( SCTAB nTab, const Rectangle& rArea,
- const Point& rMove, const Point& rTopLeft ) - const Point& rMove, const Point& rTopLeft )
-{ -{
- if (!rMove.X() && !rMove.Y()) - if (!rMove.X() && !rMove.Y())
- return; // nix - return; // nix
- -
- SdrPage* pPage = GetPage(static_cast<sal_uInt16>(nTab)); - SdrPage* pPage = GetPage(static_cast<sal_uInt16>(nTab));
- DBG_ASSERT(pPage,"Page nicht gefunden"); - DBG_ASSERT(pPage,"Page nicht gefunden");
- if (!pPage) - if (!pPage)
- return; - return;
- -
- BOOL bNegativePage = pDoc && pDoc->IsNegativePage( nTab ); - BOOL bNegativePage = pDoc && pDoc->IsNegativePage( nTab );
- -
- // fuer Shrinking! - // fuer Shrinking!
- Rectangle aNew( rArea ); - Rectangle aNew( rArea );
- BOOL bShrink = FALSE; - BOOL bShrink = FALSE;
- if ( rMove.X() < 0 || rMove.Y() < 0 ) // verkleinern - if ( rMove.X() < 0 || rMove.Y() < 0 ) // verkleinern
- { - {
- if ( rTopLeft != rArea.TopLeft() ) // sind gleich beim Verschieben von Zellen - if ( rTopLeft != rArea.TopLeft() ) // sind gleich beim Verschieben von Zellen
- { - {
- bShrink = TRUE; - bShrink = TRUE;
- aNew.Left() = rTopLeft.X(); - aNew.Left() = rTopLeft.X();
- aNew.Top() = rTopLeft.Y(); - aNew.Top() = rTopLeft.Y();
- } - }
- } - }
- SdrObjListIter aIter( *pPage, IM_FLAT ); - SdrObjListIter aIter( *pPage, IM_FLAT );
- SdrObject* pObject = aIter.Next(); - SdrObject* pObject = aIter.Next();
- while (pObject) - while (pObject)
- { - {
- if( GetAnchor( pObject ) == SCA_CELL ) - if( GetAnchor( pObject ) == SCA_CELL )
- { - {
- if ( GetObjData( pObject ) ) // Detektiv-Pfeil ? - if ( GetObjData( pObject ) ) // Detektiv-Pfeil ?
- { - {
- // hier nichts - // hier nichts
- } - }
- else if ( pObject->ISA( SdrEdgeObj ) ) // Verbinder? - else if ( pObject->ISA( SdrEdgeObj ) ) // Verbinder?
- { - {
- // hier auch nichts - // hier auch nichts
- //! nicht verbundene Enden wie bei Linien (s.u.) behandeln? - //! nicht verbundene Enden wie bei Linien (s.u.) behandeln?
- } - }
- else if ( pObject->IsPolyObj() && pObject->GetPointCount()==2 ) - else if ( pObject->IsPolyObj() && pObject->GetPointCount()==2 )
- { - {
- for (USHORT i=0; i<2; i++) - for (USHORT i=0; i<2; i++)
- { - {
- BOOL bMoved = FALSE; - BOOL bMoved = FALSE;
- Point aPoint = pObject->GetPoint(i); - Point aPoint = pObject->GetPoint(i);
- lcl_ReverseTwipsToMM( aPoint ); - lcl_ReverseTwipsToMM( aPoint );
- if (rArea.IsInside(aPoint)) - if (rArea.IsInside(aPoint))
- { - {
- aPoint += rMove; bMoved = TRUE; - aPoint += rMove; bMoved = TRUE;
- } - }
- else if (bShrink && aNew.IsInside(aPoint)) - else if (bShrink && aNew.IsInside(aPoint))
- { - {
- // Punkt ist in betroffener Zelle - Test auf geloeschten Bereich - // Punkt ist in betroffener Zelle - Test auf geloeschten Bereich
- if ( rMove.X() && aPoint.X() >= rArea.Left() + rMove.X() ) - if ( rMove.X() && aPoint.X() >= rArea.Left() + rMove.X() )
- { - {
- aPoint.X() = rArea.Left() + rMove.X() - SHRINK_DIST_TWIPS; - aPoint.X() = rArea.Left() + rMove.X() - SHRINK_DIST_TWIPS;
- if ( aPoint.X() < 0 ) aPoint.X() = 0; - if ( aPoint.X() < 0 ) aPoint.X() = 0;
- bMoved = TRUE; - bMoved = TRUE;
- } - }
- if ( rMove.Y() && aPoint.Y() >= rArea.Top() + rMove.Y() ) - if ( rMove.Y() && aPoint.Y() >= rArea.Top() + rMove.Y() )
- { - {
- aPoint.Y() = rArea.Top() + rMove.Y() - SHRINK_DIST_TWIPS; - aPoint.Y() = rArea.Top() + rMove.Y() - SHRINK_DIST_TWIPS;
- if ( aPoint.Y() < 0 ) aPoint.Y() = 0; - if ( aPoint.Y() < 0 ) aPoint.Y() = 0;
- bMoved = TRUE; - bMoved = TRUE;
- } - }
- } - }
- if( bMoved ) - if( bMoved )
- { - {
- AddCalcUndo( new SdrUndoGeoObj( *pObject ) ); - AddCalcUndo( new SdrUndoGeoObj( *pObject ) );
- lcl_TwipsToMM( aPoint ); - lcl_TwipsToMM( aPoint );
- pObject->SetPoint( aPoint, i ); - pObject->SetPoint( aPoint, i );
- } - }
- } - }
- } - }
- else - else
- { - {
- Rectangle aObjRect = pObject->GetLogicRect(); - Rectangle aObjRect = pObject->GetLogicRect();
- // aOldMMPos: not converted, millimeters - // aOldMMPos: not converted, millimeters
- Point aOldMMPos = bNegativePage ? aObjRect.TopRight() : aObjRect.TopLeft(); - Point aOldMMPos = bNegativePage ? aObjRect.TopRight() : aObjRect.TopLeft();
- lcl_ReverseTwipsToMM( aObjRect ); - lcl_ReverseTwipsToMM( aObjRect );
- Point aTopLeft = bNegativePage ? aObjRect.TopRight() : aObjRect.TopLeft(); // logical left - Point aTopLeft = bNegativePage ? aObjRect.TopRight() : aObjRect.TopLeft(); // logical left
- Size aMoveSize; - Size aMoveSize;
- BOOL bDoMove = FALSE; - BOOL bDoMove = FALSE;
- if (rArea.IsInside(aTopLeft)) - if (rArea.IsInside(aTopLeft))
- { - {
- aMoveSize = Size(rMove.X(),rMove.Y()); - aMoveSize = Size(rMove.X(),rMove.Y());
- bDoMove = TRUE; - bDoMove = TRUE;
- } - }
- else if (bShrink && aNew.IsInside(aTopLeft)) - else if (bShrink && aNew.IsInside(aTopLeft))
- { - {
- // Position ist in betroffener Zelle - Test auf geloeschten Bereich - // Position ist in betroffener Zelle - Test auf geloeschten Bereich
- if ( rMove.X() && aTopLeft.X() >= rArea.Left() + rMove.X() ) - if ( rMove.X() && aTopLeft.X() >= rArea.Left() + rMove.X() )
- { - {
- aMoveSize.Width() = rArea.Left() + rMove.X() - SHRINK_DIST - aTopLeft.X(); - aMoveSize.Width() = rArea.Left() + rMove.X() - SHRINK_DIST - aTopLeft.X();
- bDoMove = TRUE; - bDoMove = TRUE;
- } - }
- if ( rMove.Y() && aTopLeft.Y() >= rArea.Top() + rMove.Y() ) - if ( rMove.Y() && aTopLeft.Y() >= rArea.Top() + rMove.Y() )
- { - {
- aMoveSize.Height() = rArea.Top() + rMove.Y() - SHRINK_DIST - aTopLeft.Y(); - aMoveSize.Height() = rArea.Top() + rMove.Y() - SHRINK_DIST - aTopLeft.Y();
- bDoMove = TRUE; - bDoMove = TRUE;
- } - }
- } - }
- if ( bDoMove ) - if ( bDoMove )
- { - {
- if ( bNegativePage ) - if ( bNegativePage )
- { - {
- if ( aTopLeft.X() + aMoveSize.Width() > 0 ) - if ( aTopLeft.X() + aMoveSize.Width() > 0 )
- aMoveSize.Width() = -aTopLeft.X(); - aMoveSize.Width() = -aTopLeft.X();
- } - }
- else - else
- { - {
- if ( aTopLeft.X() + aMoveSize.Width() < 0 ) - if ( aTopLeft.X() + aMoveSize.Width() < 0 )
- aMoveSize.Width() = -aTopLeft.X(); - aMoveSize.Width() = -aTopLeft.X();
- } - }
- if ( aTopLeft.Y() + aMoveSize.Height() < 0 ) - if ( aTopLeft.Y() + aMoveSize.Height() < 0 )
- aMoveSize.Height() = -aTopLeft.Y(); - aMoveSize.Height() = -aTopLeft.Y();
- -
- // get corresponding move size in millimeters: - // get corresponding move size in millimeters:
- Point aNewPos( aTopLeft.X() + aMoveSize.Width(), aTopLeft.Y() + aMoveSize.Height() ); - Point aNewPos( aTopLeft.X() + aMoveSize.Width(), aTopLeft.Y() + aMoveSize.Height() );
- lcl_TwipsToMM( aNewPos ); - lcl_TwipsToMM( aNewPos );
- aMoveSize = Size( aNewPos.X() - aOldMMPos.X(), aNewPos.Y() - aOldMMPos.Y() ); // millimeters - aMoveSize = Size( aNewPos.X() - aOldMMPos.X(), aNewPos.Y() - aOldMMPos.Y() ); // millimeters
- -
- AddCalcUndo( new SdrUndoMoveObj( *pObject, aMoveSize ) ); - AddCalcUndo( new SdrUndoMoveObj( *pObject, aMoveSize ) );
- pObject->Move( aMoveSize ); - pObject->Move( aMoveSize );
- } - }
- else if ( rArea.IsInside( bNegativePage ? aObjRect.BottomLeft() : aObjRect.BottomRight() ) && - else if ( rArea.IsInside( bNegativePage ? aObjRect.BottomLeft() : aObjRect.BottomRight() ) &&
- !pObject->IsResizeProtect() ) - !pObject->IsResizeProtect() )
- { - {
- // geschuetzte Groessen werden nicht veraendert - // geschuetzte Groessen werden nicht veraendert
- // (Positionen schon, weil sie ja an der Zelle "verankert" sind) - // (Positionen schon, weil sie ja an der Zelle "verankert" sind)
- AddCalcUndo( new SdrUndoGeoObj( *pObject ) ); - AddCalcUndo( new SdrUndoGeoObj( *pObject ) );
- long nOldSizeX = aObjRect.Right() - aObjRect.Left() + 1; - long nOldSizeX = aObjRect.Right() - aObjRect.Left() + 1;
- long nOldSizeY = aObjRect.Bottom() - aObjRect.Top() + 1; - long nOldSizeY = aObjRect.Bottom() - aObjRect.Top() + 1;
- long nLogMoveX = rMove.X() * ( bNegativePage ? -1 : 1 ); // logical direction - long nLogMoveX = rMove.X() * ( bNegativePage ? -1 : 1 ); // logical direction
- pObject->Resize( aOldMMPos, Fraction( nOldSizeX+nLogMoveX, nOldSizeX ), - pObject->Resize( aOldMMPos, Fraction( nOldSizeX+nLogMoveX, nOldSizeX ),
- Fraction( nOldSizeY+rMove.Y(), nOldSizeY ) ); - Fraction( nOldSizeY+rMove.Y(), nOldSizeY ) );
- } - }
- } - }
- } - }
- pObject = aIter.Next(); - pObject = aIter.Next();
- } - }
-} -}
- -
void ScDrawLayer::MoveArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCROW nRow2, void ScDrawLayer::MoveArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCROW nRow2,
SCsCOL nDx,SCsROW nDy, BOOL bInsDel, bool bUpdateNoteCaptionPos ) SCsCOL nDx,SCsROW nDy, BOOL bInsDel, bool bUpdateNoteCaptionPos )
{ {
@@ -1059,11 +989,6 @@ @@ -1072,11 +1002,6 @@
aTopLeft.Y() += aMove.Y(); aTopLeft.Y() += aMove.Y();
} }
- // drawing objects are now directly included in cut&paste - // drawing objects are now directly included in cut&paste
- // -> only update references when inserting/deleting (or changing widths or heights) - // -> only update references when inserting/deleting (or changing widths or heights)
- if ( bInsDel ) - if ( bInsDel )
- MoveAreaTwips( nTab, aRect, aMove, aTopLeft ); - MoveAreaTwips( nTab, aRect, aMove, aTopLeft );
- -
// //
// Detektiv-Pfeile: Zellpositionen anpassen // Detektiv-Pfeile: Zellpositionen anpassen
// //
@@ -1101,8 +1026,6 @@ @@ -1114,8 +1039,6 @@
aTopLeft.X() = -aTopLeft.X(); aTopLeft.X() = -aTopLeft.X();
nDifTwips = -nDifTwips; nDifTwips = -nDifTwips;
} }
- -
- MoveAreaTwips( nTab, aRect, Point( nDifTwips,0 ), aTopLeft ); - MoveAreaTwips( nTab, aRect, Point( nDifTwips,0 ), aTopLeft );
} }
void ScDrawLayer::HeightChanged( SCTAB nTab, SCROW nRow, long nDifTwips ) void ScDrawLayer::HeightChanged( SCTAB nTab, SCROW nRow, long nDifTwips )
@@ -1133,8 +1056,6 @@ @@ -1146,8 +1069,6 @@
MirrorRectRTL( aRect ); MirrorRectRTL( aRect );
aTopLeft.X() = -aTopLeft.X(); aTopLeft.X() = -aTopLeft.X();
} }
- -
- MoveAreaTwips( nTab, aRect, Point( 0,nDifTwips ), aTopLeft ); - MoveAreaTwips( nTab, aRect, Point( 0,nDifTwips ), aTopLeft );
} }
BOOL ScDrawLayer::HasObjectsInRows( SCTAB nTab, SCROW nStartRow, SCROW nEndRow ) BOOL ScDrawLayer::HasObjectsInRows( SCTAB nTab, SCROW nStartRow, SCROW nEndRow, bool bIncludeNotes )
@@ -1846,35 +1767,105 @@ @@ -1823,35 +1744,105 @@
} }
} }
-void ScDrawLayer::SetAnchor( SdrObject* pObj, ScAnchorType eType ) -void ScDrawLayer::SetAnchor( SdrObject* pObj, ScAnchorType eType )
@ -484,7 +484,8 @@ diff -ru sc.orig/source/core/data/drwlayer.cxx sc/source/core/data/drwlayer.cxx
+} +}
+ +
+void ScDrawLayer::SetCellAnchored( SdrObject &rObj, const ScDrawObjData &rAnchor ) +void ScDrawLayer::SetCellAnchored( SdrObject &rObj, const ScDrawObjData &rAnchor )
+{ {
- ScAnchorType eOldAnchorType = GetAnchor( pObj );
+ ScDrawObjData* pAnchor = GetObjData( &rObj, true ); + ScDrawObjData* pAnchor = GetObjData( &rObj, true );
+ pAnchor->maStart = rAnchor.maStart; + pAnchor->maStart = rAnchor.maStart;
+ pAnchor->maEnd = rAnchor.maEnd; + pAnchor->maEnd = rAnchor.maEnd;
@ -508,7 +509,11 @@ diff -ru sc.orig/source/core/data/drwlayer.cxx sc/source/core/data/drwlayer.cxx
+ aAnchor.maStartOffset.X() = aObjRect.Left()-aCellRect.Left(); + aAnchor.maStartOffset.X() = aObjRect.Left()-aCellRect.Left();
+ else + else
+ aAnchor.maStartOffset.X() = aCellRect.Right()-aObjRect.Right(); + aAnchor.maStartOffset.X() = aCellRect.Right()-aObjRect.Right();
+
- // Ein an der Seite verankertes Objekt zeichnet sich durch eine Anker-Pos
- // von (0,1) aus. Das ist ein shabby Trick, der aber funktioniert!
- Point aAnchor( 0, eType == SCA_PAGE ? 1 : 0 );
- pObj->SetAnchorPos( aAnchor );
+ aAnchor.maEnd = aRange.aEnd; + aAnchor.maEnd = aRange.aEnd;
+ aCellRect = rDoc.GetMMRect( aRange.aEnd.Col(), aRange.aEnd.Row(), + aCellRect = rDoc.GetMMRect( aRange.aEnd.Col(), aRange.aEnd.Row(),
+ aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aEnd.Tab() ); + aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aEnd.Tab() );
@ -517,20 +522,20 @@ diff -ru sc.orig/source/core/data/drwlayer.cxx sc/source/core/data/drwlayer.cxx
+ aAnchor.maEndOffset.X() = aObjRect.Right()-aCellRect.Left(); + aAnchor.maEndOffset.X() = aObjRect.Right()-aCellRect.Left();
+ else + else
+ aAnchor.maEndOffset.X() = aCellRect.Right()-aObjRect.Left(); + aAnchor.maEndOffset.X() = aCellRect.Right()-aObjRect.Left();
+
- if ( eOldAnchorType != eType )
- pObj->notifyShapePropertyChange( ::svx::eSpreadsheetAnchor );
+ SetCellAnchored( rObj, aAnchor ); + SetCellAnchored( rObj, aAnchor );
+} }
+
-ScAnchorType ScDrawLayer::GetAnchor( const SdrObject* pObj )
+void ScDrawLayer::UpdateCellAnchorFromPositionEnd( SdrObject &rObj, const ScDocument &rDoc, SCTAB nTab ) +void ScDrawLayer::UpdateCellAnchorFromPositionEnd( SdrObject &rObj, const ScDocument &rDoc, SCTAB nTab )
{ {
- ScAnchorType eOldAnchorType = GetAnchor( pObj ); - Point aAnchor( pObj->GetAnchorPos() );
- return ( aAnchor.Y() != 0 ) ? SCA_PAGE : SCA_CELL;
+ Rectangle aObjRect(rObj.GetLogicRect()); + Rectangle aObjRect(rObj.GetLogicRect());
+ ScRange aRange = rDoc.GetRange( nTab, aObjRect ); + ScRange aRange = rDoc.GetRange( nTab, aObjRect );
+
- // Ein an der Seite verankertes Objekt zeichnet sich durch eine Anker-Pos
- // von (0,1) aus. Das ist ein shabby Trick, der aber funktioniert!
- Point aAnchor( 0, eType == SCA_PAGE ? 1 : 0 );
- pObj->SetAnchorPos( aAnchor );
+ ScDrawObjData* pAnchor = GetObjData( &rObj, true ); + ScDrawObjData* pAnchor = GetObjData( &rObj, true );
+ pAnchor->maEnd = aRange.aEnd; + pAnchor->maEnd = aRange.aEnd;
+ +
@ -543,19 +548,14 @@ diff -ru sc.orig/source/core/data/drwlayer.cxx sc/source/core/data/drwlayer.cxx
+ else + else
+ pAnchor->maEndOffset.X() = aCellRect.Right()-aObjRect.Left(); + pAnchor->maEndOffset.X() = aCellRect.Right()-aObjRect.Left();
+} +}
+
- if ( eOldAnchorType != eType )
- pObj->notifyShapePropertyChange( ::svx::eSpreadsheetAnchor );
+void ScDrawLayer::SetPageAnchored( SdrObject &rObj ) +void ScDrawLayer::SetPageAnchored( SdrObject &rObj )
+{ +{
+ DeleteFirstUserDataOfType(&rObj, SC_UD_OBJDATA); + DeleteFirstUserDataOfType(&rObj, SC_UD_OBJDATA);
} +}
+
-ScAnchorType ScDrawLayer::GetAnchor( const SdrObject* pObj )
+ScAnchorType ScDrawLayer::GetAnchorType( const SdrObject &rObj ) +ScAnchorType ScDrawLayer::GetAnchorType( const SdrObject &rObj )
{ +{
- Point aAnchor( pObj->GetAnchorPos() );
- return ( aAnchor.Y() != 0 ) ? SCA_PAGE : SCA_CELL;
+ //If this object has a cell anchor associated with it + //If this object has a cell anchor associated with it
+ //then its cell-anchored, otherwise its page-anchored + //then its cell-anchored, otherwise its page-anchored
+ return ScDrawLayer::GetObjData(const_cast<SdrObject*>(&rObj)) ? SCA_CELL : SCA_PAGE; + return ScDrawLayer::GetObjData(const_cast<SdrObject*>(&rObj)) ? SCA_CELL : SCA_PAGE;
@ -563,47 +563,47 @@ diff -ru sc.orig/source/core/data/drwlayer.cxx sc/source/core/data/drwlayer.cxx
ScDrawObjData* ScDrawLayer::GetObjData( SdrObject* pObj, BOOL bCreate ) // static ScDrawObjData* ScDrawLayer::GetObjData( SdrObject* pObj, BOOL bCreate ) // static
{ {
- USHORT nCount = pObj ? pObj->GetUserDataCount() : 0; - USHORT nCount = pObj ? pObj->GetUserDataCount() : 0;
- for( USHORT i = 0; i < nCount; i++ ) - for( USHORT i = 0; i < nCount; i++ )
- { - {
- SdrObjUserData* pData = pObj->GetUserData( i ); - SdrObjUserData* pData = pObj->GetUserData( i );
- if( pData && pData->GetInventor() == SC_DRAWLAYER - if( pData && pData->GetInventor() == SC_DRAWLAYER
- && pData->GetId() == SC_UD_OBJDATA ) - && pData->GetId() == SC_UD_OBJDATA )
- return (ScDrawObjData*) pData; - return (ScDrawObjData*) pData;
- } - }
+ if (SdrObjUserData *pData = GetFirstUserDataOfType(pObj, SC_UD_OBJDATA)) + if (SdrObjUserData *pData = GetFirstUserDataOfType(pObj, SC_UD_OBJDATA))
+ return (ScDrawObjData*) pData; + return (ScDrawObjData*) pData;
+ +
if( pObj && bCreate ) if( pObj && bCreate )
{ {
ScDrawObjData* pData = new ScDrawObjData; ScDrawObjData* pData = new ScDrawObjData;
@@ -1911,15 +1902,7 @@ @@ -1888,15 +1879,7 @@
ScIMapInfo* ScDrawLayer::GetIMapInfo( SdrObject* pObj ) // static ScIMapInfo* ScDrawLayer::GetIMapInfo( SdrObject* pObj ) // static
{ {
- USHORT nCount = pObj->GetUserDataCount(); - USHORT nCount = pObj->GetUserDataCount();
- for( USHORT i = 0; i < nCount; i++ ) - for( USHORT i = 0; i < nCount; i++ )
- { - {
- SdrObjUserData* pData = pObj->GetUserData( i ); - SdrObjUserData* pData = pObj->GetUserData( i );
- if( pData && pData->GetInventor() == SC_DRAWLAYER - if( pData && pData->GetInventor() == SC_DRAWLAYER
- && pData->GetId() == SC_UD_IMAPDATA ) - && pData->GetId() == SC_UD_IMAPDATA )
- return (ScIMapInfo*) pData; - return (ScIMapInfo*) pData;
- } - }
- return NULL; - return NULL;
+ return (ScIMapInfo*)GetFirstUserDataOfType(pObj, SC_UD_IMAPDATA); + return (ScIMapInfo*)GetFirstUserDataOfType(pObj, SC_UD_IMAPDATA);
} }
// static: // static:
@@ -1972,7 +1955,7 @@ @@ -1949,7 +1932,7 @@
else if ( pObj->ISA( SdrOle2Obj ) ) // OLE-Objekt else if ( pObj->ISA( SdrOle2Obj ) ) // OLE-Objekt
{ {
// TODO/LEAN: working with visual area needs running state // TODO/LEAN: working with visual area needs running state
- aGraphSize = ((SdrOle2Obj*)pObj)->GetOrigObjSize(); - aGraphSize = ((SdrOle2Obj*)pObj)->GetOrigObjSize();
+ aGraphSize = ((const SdrOle2Obj*)pObj)->GetOrigObjSize(); + aGraphSize = ((const SdrOle2Obj*)pObj)->GetOrigObjSize();
bObjSupported = TRUE; bObjSupported = TRUE;
} }
@@ -1990,14 +1973,9 @@ @@ -1967,14 +1950,9 @@
ScMacroInfo* ScDrawLayer::GetMacroInfo( SdrObject* pObj, BOOL bCreate ) // static ScMacroInfo* ScDrawLayer::GetMacroInfo( SdrObject* pObj, BOOL bCreate ) // static
{ {

Loading…
Cancel
Save