Bugzilla – Attachment 42122 Details for
Bug 33205
Better Cell Anchoring
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
impl
sc.ooo102061.better.cellanchoring.patch (text/plain), 99.14 KB, created by
Caolán McNamara
on 2011-01-17 08:24:05 UTC
(
hide
)
Description:
impl
Filename:
MIME Type:
Creator:
Caolán McNamara
Created:
2011-01-17 08:24:05 UTC
Size:
99.14 KB
patch
obsolete
>diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx >index 462cc14..26d7707 100644 >--- a/sc/inc/document.hxx >+++ b/sc/inc/document.hxx >@@ -1432,8 +1432,8 @@ public: > void RestorePrintRanges( const ScPrintRangeSaver& rSaver ); > > SC_DLLPUBLIC Rectangle GetMMRect( SCCOL nStartCol, SCROW nStartRow, >- SCCOL nEndCol, SCROW nEndRow, SCTAB nTab ); >- SC_DLLPUBLIC ScRange GetRange( SCTAB nTab, const Rectangle& rMMRect ); >+ SCCOL nEndCol, SCROW nEndRow, SCTAB nTab ) const; >+ SC_DLLPUBLIC ScRange GetRange( SCTAB nTab, const Rectangle& rMMRect ) const; > > void UpdStlShtPtrsFrmNms(); > void StylesToNames(); >diff --git a/sc/inc/drwlayer.hxx b/sc/inc/drwlayer.hxx >index 9bf279e..17b5aa0 100644 >--- a/sc/inc/drwlayer.hxx >+++ b/sc/inc/drwlayer.hxx >@@ -107,12 +107,10 @@ private: > BOOL bHyphenatorSet; > > private: >- void MoveAreaTwips( SCTAB nTab, const Rectangle& rArea, const Point& rMove, >- const Point& rTopLeft ); > void MoveCells( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCROW nRow2, > SCsCOL nDx,SCsROW nDy, bool bUpdateNoteCaptionPos ); > >- void RecalcPos( SdrObject* pObj, const ScDrawObjData& rData, bool bNegativePage, bool bUpdateNoteCaptionPos ); >+ void RecalcPos( SdrObject* pObj, ScDrawObjData& rData, bool bNegativePage, bool bUpdateNoteCaptionPos ); > > public: > ScDrawLayer( ScDocument* pDocument, const String& rName ); >@@ -154,8 +152,6 @@ public: > > void MoveArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCROW nRow2, > SCsCOL nDx,SCsROW nDy, BOOL bInsDel, bool bUpdateNoteCaptionPos = true ); >- void WidthChanged( SCTAB nTab, SCCOL nCol, long nDifTwips ); >- void HeightChanged( SCTAB nTab, SCROW nRow, long nDifTwips ); > > BOOL HasObjectsInRows( SCTAB nTab, SCROW nStartRow, SCROW nEndRow, bool bIncludeNotes = true ); > >@@ -188,8 +184,11 @@ public: > String GetNewGraphicName( long* pnCounter = NULL ) const; > void EnsureGraphicNames(); > >- static void SetAnchor( SdrObject*, ScAnchorType ); >- static ScAnchorType GetAnchor( const SdrObject* ); >+ static void SetPageAnchored( SdrObject& ); >+ static void SetCellAnchored( SdrObject&, const ScDrawObjData &rAnchor ); >+ static void SetCellAnchoredFromPosition( SdrObject &rObj, const ScDocument &rDoc, SCTAB nTab ); >+ static void UpdateCellAnchorFromPositionEnd( SdrObject &rObj, const ScDocument &rDoc, SCTAB nTab ); >+ static ScAnchorType GetAnchorType( const SdrObject& ); > > // positions for detektive lines > static ScDrawObjData* GetObjData( SdrObject* pObj, BOOL bCreate=FALSE ); >diff --git a/sc/inc/userdat.hxx b/sc/inc/userdat.hxx >index 42ca28a..f551d17 100644 >--- a/sc/inc/userdat.hxx >+++ b/sc/inc/userdat.hxx >@@ -61,12 +61,15 @@ class ScDrawObjData : public SdrObjUserData > public: > ScAddress maStart; > ScAddress maEnd; >+ Point maStartOffset; >+ Point maEndOffset; > bool mbNote; >+ Rectangle maLastRect; > > explicit ScDrawObjData(); > > private: >- virtual ScDrawObjData* Clone( SdrObject* pObj ) const; >+ virtual ScDrawObjData* Clone( SdrObject* pObj ) const; > }; > > //------------------------------------------------------------------------- >diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx >index f2da784..ab20868 100644 >--- a/sc/qa/unit/ucalc.cxx >+++ b/sc/qa/unit/ucalc.cxx >@@ -65,11 +65,15 @@ > #include <document.hxx> > #include <stringutil.hxx> > #include <scmatrix.hxx> >+#include <drwlayer.hxx> > > #include <dpshttab.hxx> > #include <dpobject.hxx> > #include <dpsave.hxx> > >+#include <svx/svdograf.hxx> >+#include <svx/svdpage.hxx> >+ > #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp> > #include <com/sun/star/sheet/GeneralFunction.hpp> > >@@ -105,6 +109,8 @@ public: > void testDataPilot(); > void testSheetCopy(); > >+ void testGraphicsInGroup(); >+ > CPPUNIT_TEST_SUITE(Test); > CPPUNIT_TEST(testCollator); > CPPUNIT_TEST(testSUM); >@@ -113,6 +119,7 @@ public: > CPPUNIT_TEST(testMatrix); > CPPUNIT_TEST(testDataPilot); > CPPUNIT_TEST(testSheetCopy); >+ CPPUNIT_TEST(testGraphicsInGroup); > CPPUNIT_TEST_SUITE_END(); > > private: >@@ -596,6 +603,50 @@ void Test::testSheetCopy() > m_pDoc->DeleteTab(0); > } > >+void Test::testGraphicsInGroup() >+{ >+ OUString aTabName(RTL_CONSTASCII_USTRINGPARAM("TestTab")); >+ m_pDoc->InsertTab(0, aTabName); >+ CPPUNIT_ASSERT_MESSAGE("document should have one sheet to begin with.", m_pDoc->GetTableCount() == 1); >+ SCROW nRow1, nRow2; >+ bool bHidden = m_pDoc->RowHidden(0, 0, &nRow1, &nRow2); >+ CPPUNIT_ASSERT_MESSAGE("new sheet should have all rows visible", !bHidden && nRow1 == 0 && nRow2 == MAXROW); >+ >+ m_pDoc->InitDrawLayer(); >+ ScDrawLayer *pDrawLayer = m_pDoc->GetDrawLayer(); >+ CPPUNIT_ASSERT_MESSAGE("must have a draw layer", pDrawLayer != NULL); >+ SdrPage* pPage = pDrawLayer->GetPage(0); >+ CPPUNIT_ASSERT_MESSAGE("must have a draw page", pPage != NULL); >+ >+ //Add a square >+ Rectangle aOrigRect(2,2,100,100); >+ SdrRectObj *pObj = new SdrRectObj(aOrigRect); >+ pPage->InsertObject(pObj); >+ const Rectangle &rNewRect = pObj->GetLogicRect(); >+ CPPUNIT_ASSERT_MESSAGE("must have equal position and size", aOrigRect == rNewRect); >+ >+ ScDrawLayer::SetPageAnchored(*pObj); >+ >+ //Use a range of rows guaranteed to include all of the square >+ m_pDoc->ShowRows(0, 100, 0, false); >+ CPPUNIT_ASSERT_MESSAGE("Should not change when page anchored", aOrigRect == rNewRect); >+ m_pDoc->ShowRows(0, 100, 0, true); >+ CPPUNIT_ASSERT_MESSAGE("Should not change when page anchored", aOrigRect == rNewRect); >+ >+ ScDrawLayer::SetCellAnchoredFromPosition(*pObj, *m_pDoc, 0); >+ CPPUNIT_ASSERT_MESSAGE("That shouldn't change size or positioning", aOrigRect == rNewRect); >+ >+ m_pDoc->ShowRows(0, 100, 0, false); >+ CPPUNIT_ASSERT_MESSAGE("Left and Right should be unchanged", >+ aOrigRect.nLeft == rNewRect.nLeft && aOrigRect.nRight == rNewRect.nRight); >+ CPPUNIT_ASSERT_MESSAGE("Height should be minimum allowed height", >+ (rNewRect.nBottom - rNewRect.nTop) <= 1); >+ m_pDoc->ShowRows(0, 100, 0, true); >+ CPPUNIT_ASSERT_MESSAGE("Should not change when page anchored", aOrigRect == rNewRect); >+ >+ m_pDoc->DeleteTab(0); >+} >+ > CPPUNIT_TEST_SUITE_REGISTRATION(Test); > > } >diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx >index 4454cfb..7a3bb8f 100644 >--- a/sc/source/core/data/documen3.cxx >+++ b/sc/source/core/data/documen3.cxx >@@ -1576,7 +1576,7 @@ bool lcl_AddTwipsWhile( long & rTwips, long nStopTwips, SCROW & rPosY, SCROW nEn > return bAdded; > } > >-ScRange ScDocument::GetRange( SCTAB nTab, const Rectangle& rMMRect ) >+ScRange ScDocument::GetRange( SCTAB nTab, const Rectangle& rMMRect ) const > { > ScTable* pTable = pTab[nTab]; > if (!pTable) >@@ -1876,8 +1876,7 @@ void ScDocument::SetDrawDefaults() > UpdateDrawDefaults(); > } > >-Rectangle ScDocument::GetMMRect( SCCOL nStartCol, SCROW nStartRow, >- SCCOL nEndCol, SCROW nEndRow, SCTAB nTab ) >+Rectangle ScDocument::GetMMRect( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab ) const > { > if (!ValidTab(nTab) || !pTab[nTab]) > { >diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx >index 733964a..980a46a 100644 >--- a/sc/source/core/data/drwlayer.cxx >+++ b/sc/source/core/data/drwlayer.cxx >@@ -69,6 +69,9 @@ > #include <vcl/svapp.hxx> > #include <unotools/ucbstreamhelper.hxx> > >+#include <basegfx/polygon/b2dpolygon.hxx> >+#include <basegfx/polygon/b2dpolygontools.hxx> >+ > #include "drwlayer.hxx" > #include "drawpage.hxx" > #include "global.hxx" >@@ -533,7 +536,41 @@ void ScDrawLayer::SetPageSize( USHORT nPageNo, const Size& rSize, bool bUpdateNo > } > } > >-void ScDrawLayer::RecalcPos( SdrObject* pObj, const ScDrawObjData& rData, bool bNegativePage, bool bUpdateNoteCaptionPos ) >+namespace >+{ >+ //Can't have a zero width dimension >+ Rectangle lcl_makeSafeRectangle(const Rectangle &rNew) >+ { >+ Rectangle aRect = rNew; >+ if (aRect.Bottom() == aRect.Top()) >+ aRect.Bottom() = aRect.Top()+1; >+ if (aRect.Right() == aRect.Left()) >+ aRect.Right() = aRect.Left()+1; >+ return aRect; >+ } >+ >+ Point lcl_calcAvailableDiff(ScDocument &rDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, const Point &aWantedDiff) >+ { >+ Point aAvailableDiff(aWantedDiff); >+ long nHeight = rDoc.GetRowHeight( nRow, nTab ) * HMM_PER_TWIPS; >+ long nWidth = rDoc.GetColWidth( nCol, nTab ) * HMM_PER_TWIPS; >+ if (aAvailableDiff.Y() > nHeight) >+ aAvailableDiff.Y() = nHeight; >+ if (aAvailableDiff.X() > nWidth) >+ aAvailableDiff.X() = nWidth; >+ return aAvailableDiff; >+ } >+ >+ Rectangle lcl_UpdateCalcPoly(basegfx::B2DPolygon &rCalcPoly, int nWhichPoint, const Point &rPos) >+ { >+ rCalcPoly.setB2DPoint(nWhichPoint, basegfx::B2DPoint(rPos.X(), rPos.Y())); >+ basegfx::B2DRange aRange(basegfx::tools::getRange(rCalcPoly)); >+ return Rectangle(aRange.getMinX(), aRange.getMinY(), >+ aRange.getMaxX(), aRange.getMaxY()); >+ } >+} >+ >+void ScDrawLayer::RecalcPos( SdrObject* pObj, ScDrawObjData& rData, bool bNegativePage, bool bUpdateNoteCaptionPos ) > { > DBG_ASSERT( pDoc, "ScDrawLayer::RecalcPos - missing document" ); > if( !pDoc ) >@@ -572,6 +609,8 @@ void ScDrawLayer::RecalcPos( SdrObject* pObj, const ScDrawObjData& rData, bool b > > if( bCircle ) > { >+ rData.maLastRect = pObj->GetLogicRect(); >+ > Point aPos( pDoc->GetColOffset( nCol1, nTab1 ), pDoc->GetRowOffset( nRow1, nTab1 ) ); > TwipsToMM( aPos.X() ); > TwipsToMM( aPos.Y() ); >@@ -592,11 +631,18 @@ void ScDrawLayer::RecalcPos( SdrObject* pObj, const ScDrawObjData& rData, bool b > { > if (bRecording) > AddCalcUndo( new SdrUndoGeoObj( *pObj ) ); >- pObj->SetLogicRect(aRect); >+ rData.maLastRect = lcl_makeSafeRectangle(aRect); >+ pObj->SetLogicRect(rData.maLastRect); > } > } > else if( bArrow ) > { >+ rData.maLastRect = pObj->GetLogicRect(); >+ basegfx::B2DPolygon aCalcPoly; >+ Point aOrigStartPos(pObj->GetPoint(0)); >+ Point aOrigEndPos(pObj->GetPoint(1)); >+ aCalcPoly.append(basegfx::B2DPoint(aOrigStartPos.X(), aOrigStartPos.Y())); >+ aCalcPoly.append(basegfx::B2DPoint(aOrigEndPos.X(), aOrigEndPos.Y())); > //! nicht mehrere Undos fuer ein Objekt erzeugen (hinteres kann dann weggelassen werden) > > SCCOL nLastCol; >@@ -617,6 +663,8 @@ void ScDrawLayer::RecalcPos( SdrObject* pObj, const ScDrawObjData& rData, bool b > { > if (bRecording) > AddCalcUndo( new SdrUndoGeoObj( *pObj ) ); >+ >+ rData.maLastRect = lcl_UpdateCalcPoly(aCalcPoly, 0, aStartPos); > pObj->SetPoint( aStartPos, 0 ); > } > >@@ -631,6 +679,8 @@ void ScDrawLayer::RecalcPos( SdrObject* pObj, const ScDrawObjData& rData, bool b > { > if (bRecording) > AddCalcUndo( new SdrUndoGeoObj( *pObj ) ); >+ >+ rData.maLastRect = lcl_UpdateCalcPoly(aCalcPoly, 1, aEndPos); > pObj->SetPoint( aEndPos, 1 ); > } > } >@@ -651,6 +701,8 @@ void ScDrawLayer::RecalcPos( SdrObject* pObj, const ScDrawObjData& rData, bool b > { > if (bRecording) > AddCalcUndo( new SdrUndoGeoObj( *pObj ) ); >+ >+ rData.maLastRect = lcl_UpdateCalcPoly(aCalcPoly, 1, aEndPos); > pObj->SetPoint( aEndPos, 1 ); > } > >@@ -667,45 +719,68 @@ void ScDrawLayer::RecalcPos( SdrObject* pObj, const ScDrawObjData& rData, bool b > { > if (bRecording) > AddCalcUndo( new SdrUndoGeoObj( *pObj ) ); >+ >+ rData.maLastRect = lcl_UpdateCalcPoly(aCalcPoly, 0, aStartPos); > pObj->SetPoint( aStartPos, 0 ); > } > } > } > } >- else // Referenz-Rahmen >+ else > { >+ bool bCanResize = bValid2 && !pObj->IsResizeProtect(); >+ >+ //First time positioning, must be able to at least move it >+ if (rData.maLastRect.IsEmpty()) >+ rData.maLastRect = pObj->GetLogicRect(); >+ > DBG_ASSERT( bValid1, "ScDrawLayer::RecalcPos - invalid start position" ); > Point aPos( pDoc->GetColOffset( nCol1, nTab1 ), pDoc->GetRowOffset( nRow1, nTab1 ) ); > TwipsToMM( aPos.X() ); > TwipsToMM( aPos.Y() ); >+ aPos += lcl_calcAvailableDiff(*pDoc, nCol1, nRow1, nTab1, rData.maStartOffset); > >- if( bValid2 ) >+ if( bCanResize ) > { >- Point aEnd( pDoc->GetColOffset( nCol2 + 1, nTab2 ), pDoc->GetRowOffset( nRow2 + 1, nTab2 ) ); >+ Point aEnd( pDoc->GetColOffset( nCol2, nTab2 ), pDoc->GetRowOffset( nRow2, nTab2 ) ); > TwipsToMM( aEnd.X() ); > TwipsToMM( aEnd.Y() ); >+ aEnd += lcl_calcAvailableDiff(*pDoc, nCol2, nRow2, nTab2, rData.maEndOffset); > > Rectangle aNew( aPos, aEnd ); > if ( bNegativePage ) > MirrorRectRTL( aNew ); > if ( pObj->GetLogicRect() != aNew ) > { >+ Rectangle aOld(pObj->GetLogicRect()); >+ > if (bRecording) > AddCalcUndo( new SdrUndoGeoObj( *pObj ) ); >- pObj->SetLogicRect(aNew); >+ rData.maLastRect = lcl_makeSafeRectangle(aNew); >+ pObj->SetLogicRect(rData.maLastRect); > } > } > else > { > if ( bNegativePage ) >- aPos.X() = -aPos.X(); >+ aPos.X() = -aPos.X() - rData.maLastRect.GetWidth(); > if ( pObj->GetRelativePos() != aPos ) > { > if (bRecording) > AddCalcUndo( new SdrUndoGeoObj( *pObj ) ); >+ rData.maLastRect.SetPos( aPos ); > pObj->SetRelativePos( aPos ); > } > } >+ >+ /* >+ * If we were not allowed resize the object, then the end cell anchor >+ * is possibly incorrect now, and if the object has no end-cell (e.g. >+ * missing in original .xml) we are also forced to generate one >+ */ >+ bool bEndAnchorIsBad = !bValid2 || pObj->IsResizeProtect(); >+ if (bEndAnchorIsBad) >+ ScDrawLayer::UpdateCellAnchorFromPositionEnd(*pObj, *pDoc, nTab1); > } > } > >@@ -876,151 +951,6 @@ SdrUndoGroup* ScDrawLayer::GetCalcUndo() > return pRet; > } > >-// MoveAreaTwips: all measures are kept in twips >-void ScDrawLayer::MoveAreaTwips( SCTAB nTab, const Rectangle& rArea, >- const Point& rMove, const Point& rTopLeft ) >-{ >- if (!rMove.X() && !rMove.Y()) >- return; // nix >- >- SdrPage* pPage = GetPage(static_cast<sal_uInt16>(nTab)); >- DBG_ASSERT(pPage,"Page nicht gefunden"); >- if (!pPage) >- return; >- >- BOOL bNegativePage = pDoc && pDoc->IsNegativePage( nTab ); >- >- // fuer Shrinking! >- Rectangle aNew( rArea ); >- BOOL bShrink = FALSE; >- if ( rMove.X() < 0 || rMove.Y() < 0 ) // verkleinern >- { >- if ( rTopLeft != rArea.TopLeft() ) // sind gleich beim Verschieben von Zellen >- { >- bShrink = TRUE; >- aNew.Left() = rTopLeft.X(); >- aNew.Top() = rTopLeft.Y(); >- } >- } >- SdrObjListIter aIter( *pPage, IM_FLAT ); >- SdrObject* pObject = aIter.Next(); >- while (pObject) >- { >- if( GetAnchor( pObject ) == SCA_CELL ) >- { >- if ( GetObjData( pObject ) ) // Detektiv-Pfeil ? >- { >- // hier nichts >- } >- else if ( pObject->ISA( SdrEdgeObj ) ) // Verbinder? >- { >- // hier auch nichts >- //! nicht verbundene Enden wie bei Linien (s.u.) behandeln? >- } >- else if ( pObject->IsPolyObj() && pObject->GetPointCount()==2 ) >- { >- for (USHORT i=0; i<2; i++) >- { >- BOOL bMoved = FALSE; >- Point aPoint = pObject->GetPoint(i); >- lcl_ReverseTwipsToMM( aPoint ); >- if (rArea.IsInside(aPoint)) >- { >- aPoint += rMove; bMoved = TRUE; >- } >- else if (bShrink && aNew.IsInside(aPoint)) >- { >- // Punkt ist in betroffener Zelle - Test auf geloeschten Bereich >- if ( rMove.X() && aPoint.X() >= rArea.Left() + rMove.X() ) >- { >- aPoint.X() = rArea.Left() + rMove.X() - SHRINK_DIST_TWIPS; >- if ( aPoint.X() < 0 ) aPoint.X() = 0; >- bMoved = TRUE; >- } >- if ( rMove.Y() && aPoint.Y() >= rArea.Top() + rMove.Y() ) >- { >- aPoint.Y() = rArea.Top() + rMove.Y() - SHRINK_DIST_TWIPS; >- if ( aPoint.Y() < 0 ) aPoint.Y() = 0; >- bMoved = TRUE; >- } >- } >- if( bMoved ) >- { >- AddCalcUndo( new SdrUndoGeoObj( *pObject ) ); >- lcl_TwipsToMM( aPoint ); >- pObject->SetPoint( aPoint, i ); >- } >- } >- } >- else >- { >- Rectangle aObjRect = pObject->GetLogicRect(); >- // aOldMMPos: not converted, millimeters >- Point aOldMMPos = bNegativePage ? aObjRect.TopRight() : aObjRect.TopLeft(); >- lcl_ReverseTwipsToMM( aObjRect ); >- Point aTopLeft = bNegativePage ? aObjRect.TopRight() : aObjRect.TopLeft(); // logical left >- Size aMoveSize; >- BOOL bDoMove = FALSE; >- if (rArea.IsInside(aTopLeft)) >- { >- aMoveSize = Size(rMove.X(),rMove.Y()); >- bDoMove = TRUE; >- } >- else if (bShrink && aNew.IsInside(aTopLeft)) >- { >- // Position ist in betroffener Zelle - Test auf geloeschten Bereich >- if ( rMove.X() && aTopLeft.X() >= rArea.Left() + rMove.X() ) >- { >- aMoveSize.Width() = rArea.Left() + rMove.X() - SHRINK_DIST - aTopLeft.X(); >- bDoMove = TRUE; >- } >- if ( rMove.Y() && aTopLeft.Y() >= rArea.Top() + rMove.Y() ) >- { >- aMoveSize.Height() = rArea.Top() + rMove.Y() - SHRINK_DIST - aTopLeft.Y(); >- bDoMove = TRUE; >- } >- } >- if ( bDoMove ) >- { >- if ( bNegativePage ) >- { >- if ( aTopLeft.X() + aMoveSize.Width() > 0 ) >- aMoveSize.Width() = -aTopLeft.X(); >- } >- else >- { >- if ( aTopLeft.X() + aMoveSize.Width() < 0 ) >- aMoveSize.Width() = -aTopLeft.X(); >- } >- if ( aTopLeft.Y() + aMoveSize.Height() < 0 ) >- aMoveSize.Height() = -aTopLeft.Y(); >- >- // get corresponding move size in millimeters: >- Point aNewPos( aTopLeft.X() + aMoveSize.Width(), aTopLeft.Y() + aMoveSize.Height() ); >- lcl_TwipsToMM( aNewPos ); >- aMoveSize = Size( aNewPos.X() - aOldMMPos.X(), aNewPos.Y() - aOldMMPos.Y() ); // millimeters >- >- AddCalcUndo( new SdrUndoMoveObj( *pObject, aMoveSize ) ); >- pObject->Move( aMoveSize ); >- } >- else if ( rArea.IsInside( bNegativePage ? aObjRect.BottomLeft() : aObjRect.BottomRight() ) && >- !pObject->IsResizeProtect() ) >- { >- // geschuetzte Groessen werden nicht veraendert >- // (Positionen schon, weil sie ja an der Zelle "verankert" sind) >- AddCalcUndo( new SdrUndoGeoObj( *pObject ) ); >- long nOldSizeX = aObjRect.Right() - aObjRect.Left() + 1; >- long nOldSizeY = aObjRect.Bottom() - aObjRect.Top() + 1; >- long nLogMoveX = rMove.X() * ( bNegativePage ? -1 : 1 ); // logical direction >- pObject->Resize( aOldMMPos, Fraction( nOldSizeX+nLogMoveX, nOldSizeX ), >- Fraction( nOldSizeY+rMove.Y(), nOldSizeY ) ); >- } >- } >- } >- pObject = aIter.Next(); >- } >-} >- > void ScDrawLayer::MoveArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCROW nRow2, > SCsCOL nDx,SCsROW nDy, BOOL bInsDel, bool bUpdateNoteCaptionPos ) > { >@@ -1062,11 +992,6 @@ void ScDrawLayer::MoveArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCR > aTopLeft.Y() += aMove.Y(); > } > >- // drawing objects are now directly included in cut&paste >- // -> only update references when inserting/deleting (or changing widths or heights) >- if ( bInsDel ) >- MoveAreaTwips( nTab, aRect, aMove, aTopLeft ); >- > // > // Detektiv-Pfeile: Zellpositionen anpassen > // >@@ -1074,72 +999,6 @@ void ScDrawLayer::MoveArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCR > MoveCells( nTab, nCol1,nRow1, nCol2,nRow2, nDx,nDy, bUpdateNoteCaptionPos ); > } > >-void ScDrawLayer::WidthChanged( SCTAB nTab, SCCOL nCol, long nDifTwips ) >-{ >- DBG_ASSERT( pDoc, "ScDrawLayer::WidthChanged without document" ); >- if ( !pDoc ) >- return; >- >- if (!bAdjustEnabled) >- return; >- >- Rectangle aRect; >- Point aTopLeft; >- >- for (SCCOL i=0; i<nCol; i++) >- aRect.Left() += pDoc->GetColWidth(i,nTab); >- aTopLeft.X() = aRect.Left(); >- aRect.Left() += pDoc->GetColWidth(nCol,nTab); >- >- aRect.Right() = MAXMM; >- aRect.Top() = 0; >- aRect.Bottom() = MAXMM; >- >- //! aTopLeft ist falsch, wenn mehrere Spalten auf einmal ausgeblendet werden >- >- BOOL bNegativePage = pDoc->IsNegativePage( nTab ); >- if ( bNegativePage ) >- { >- MirrorRectRTL( aRect ); >- aTopLeft.X() = -aTopLeft.X(); >- nDifTwips = -nDifTwips; >- } >- >- MoveAreaTwips( nTab, aRect, Point( nDifTwips,0 ), aTopLeft ); >-} >- >-void ScDrawLayer::HeightChanged( SCTAB nTab, SCROW nRow, long nDifTwips ) >-{ >- DBG_ASSERT( pDoc, "ScDrawLayer::HeightChanged without document" ); >- if ( !pDoc ) >- return; >- >- if (!bAdjustEnabled) >- return; >- >- Rectangle aRect; >- Point aTopLeft; >- >- aRect.Top() += pDoc->GetRowHeight( 0, nRow-1, nTab); >- aTopLeft.Y() = aRect.Top(); >- aRect.Top() += pDoc->GetRowHeight(nRow, nTab); >- >- aRect.Bottom() = MAXMM; >- aRect.Left() = 0; >- aRect.Right() = MAXMM; >- >- //! aTopLeft ist falsch, wenn mehrere Zeilen auf einmal ausgeblendet werden >- >- BOOL bNegativePage = pDoc->IsNegativePage( nTab ); >- if ( bNegativePage ) >- { >- MirrorRectRTL( aRect ); >- aTopLeft.X() = -aTopLeft.X(); >- } >- >- MoveAreaTwips( nTab, aRect, Point( 0,nDifTwips ), aTopLeft ); >-} >- > BOOL ScDrawLayer::HasObjectsInRows( SCTAB nTab, SCROW nStartRow, SCROW nEndRow, bool bIncludeNotes ) > { > DBG_ASSERT( pDoc, "ScDrawLayer::HasObjectsInRows without document" ); >@@ -1807,35 +1666,105 @@ void ScDrawLayer::EnsureGraphicNames() > } > } > >-void ScDrawLayer::SetAnchor( SdrObject* pObj, ScAnchorType eType ) >+namespace > { >- ScAnchorType eOldAnchorType = GetAnchor( pObj ); >+ SdrObjUserData* GetFirstUserDataOfType(const SdrObject *pObj, UINT16 nId) >+ { >+ USHORT nCount = pObj ? pObj->GetUserDataCount() : 0; >+ for( USHORT i = 0; i < nCount; i++ ) >+ { >+ SdrObjUserData* pData = pObj->GetUserData( i ); >+ if( pData && pData->GetInventor() == SC_DRAWLAYER && pData->GetId() == nId ) >+ return pData; >+ } >+ return NULL; >+ } > >- // 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 ); >+ void DeleteFirstUserDataOfType(SdrObject *pObj, UINT16 nId) >+ { >+ USHORT nCount = pObj ? pObj->GetUserDataCount() : 0; >+ for( USHORT i = nCount; i > 0; i-- ) >+ { >+ SdrObjUserData* pData = pObj->GetUserData( i-1 ); >+ if( pData && pData->GetInventor() == SC_DRAWLAYER && pData->GetId() == nId ) >+ pObj->DeleteUserData(i-1); >+ } >+ } >+} > >- if ( eOldAnchorType != eType ) >- pObj->notifyShapePropertyChange( ::svx::eSpreadsheetAnchor ); >+void ScDrawLayer::SetCellAnchored( SdrObject &rObj, const ScDrawObjData &rAnchor ) >+{ >+ ScDrawObjData* pAnchor = GetObjData( &rObj, true ); >+ pAnchor->maStart = rAnchor.maStart; >+ pAnchor->maEnd = rAnchor.maEnd; >+ pAnchor->maStartOffset = rAnchor.maStartOffset; >+ pAnchor->maEndOffset = rAnchor.maEndOffset; > } > >-ScAnchorType ScDrawLayer::GetAnchor( const SdrObject* pObj ) >+void ScDrawLayer::SetCellAnchoredFromPosition( SdrObject &rObj, const ScDocument &rDoc, SCTAB nTab ) > { >- Point aAnchor( pObj->GetAnchorPos() ); >- return ( aAnchor.Y() != 0 ) ? SCA_PAGE : SCA_CELL; >+ Rectangle aObjRect(rObj.GetLogicRect()); >+ ScRange aRange = rDoc.GetRange( nTab, aObjRect ); >+ >+ Rectangle aCellRect; >+ >+ ScDrawObjData aAnchor; >+ aAnchor.maStart = aRange.aStart; >+ aCellRect = rDoc.GetMMRect( aRange.aStart.Col(), aRange.aStart.Row(), >+ aRange.aStart.Col(), aRange.aStart.Row(), aRange.aStart.Tab() ); >+ aAnchor.maStartOffset.Y() = aObjRect.Top()-aCellRect.Top(); >+ if (!rDoc.IsNegativePage(nTab)) >+ aAnchor.maStartOffset.X() = aObjRect.Left()-aCellRect.Left(); >+ else >+ aAnchor.maStartOffset.X() = aCellRect.Right()-aObjRect.Right(); >+ >+ aAnchor.maEnd = aRange.aEnd; >+ aCellRect = rDoc.GetMMRect( aRange.aEnd.Col(), aRange.aEnd.Row(), >+ aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aEnd.Tab() ); >+ aAnchor.maEndOffset.Y() = aObjRect.Bottom()-aCellRect.Top(); >+ if (!rDoc.IsNegativePage(nTab)) >+ aAnchor.maEndOffset.X() = aObjRect.Right()-aCellRect.Left(); >+ else >+ aAnchor.maEndOffset.X() = aCellRect.Right()-aObjRect.Left(); >+ >+ SetCellAnchored( rObj, aAnchor ); >+} >+ >+void ScDrawLayer::UpdateCellAnchorFromPositionEnd( SdrObject &rObj, const ScDocument &rDoc, SCTAB nTab ) >+{ >+ Rectangle aObjRect(rObj.GetLogicRect()); >+ ScRange aRange = rDoc.GetRange( nTab, aObjRect ); >+ >+ ScDrawObjData* pAnchor = GetObjData( &rObj, true ); >+ pAnchor->maEnd = aRange.aEnd; >+ >+ Rectangle aCellRect; >+ aCellRect = rDoc.GetMMRect( aRange.aEnd.Col(), aRange.aEnd.Row(), >+ aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aEnd.Tab() ); >+ pAnchor->maEndOffset.Y() = aObjRect.Bottom()-aCellRect.Top(); >+ if (!rDoc.IsNegativePage(nTab)) >+ pAnchor->maEndOffset.X() = aObjRect.Right()-aCellRect.Left(); >+ else >+ pAnchor->maEndOffset.X() = aCellRect.Right()-aObjRect.Left(); >+} >+ >+void ScDrawLayer::SetPageAnchored( SdrObject &rObj ) >+{ >+ DeleteFirstUserDataOfType(&rObj, SC_UD_OBJDATA); >+} >+ >+ScAnchorType ScDrawLayer::GetAnchorType( const SdrObject &rObj ) >+{ >+ //If this object has a cell anchor associated with it >+ //then its cell-anchored, otherwise its page-anchored >+ return ScDrawLayer::GetObjData(const_cast<SdrObject*>(&rObj)) ? SCA_CELL : SCA_PAGE; > } > > ScDrawObjData* ScDrawLayer::GetObjData( SdrObject* pObj, BOOL bCreate ) // static > { >- USHORT nCount = pObj ? pObj->GetUserDataCount() : 0; >- for( USHORT i = 0; i < nCount; i++ ) >- { >- SdrObjUserData* pData = pObj->GetUserData( i ); >- if( pData && pData->GetInventor() == SC_DRAWLAYER >- && pData->GetId() == SC_UD_OBJDATA ) >- return (ScDrawObjData*) pData; >- } >+ if (SdrObjUserData *pData = GetFirstUserDataOfType(pObj, SC_UD_OBJDATA)) >+ return (ScDrawObjData*) pData; >+ > if( pObj && bCreate ) > { > ScDrawObjData* pData = new ScDrawObjData; >@@ -1872,15 +1801,7 @@ ScDrawObjData* ScDrawLayer::GetNoteCaptionData( SdrObject* pObj, SCTAB nTab ) > > ScIMapInfo* ScDrawLayer::GetIMapInfo( SdrObject* pObj ) // static > { >- USHORT nCount = pObj->GetUserDataCount(); >- for( USHORT i = 0; i < nCount; i++ ) >- { >- SdrObjUserData* pData = pObj->GetUserData( i ); >- if( pData && pData->GetInventor() == SC_DRAWLAYER >- && pData->GetId() == SC_UD_IMAPDATA ) >- return (ScIMapInfo*) pData; >- } >- return NULL; >+ return (ScIMapInfo*)GetFirstUserDataOfType(pObj, SC_UD_IMAPDATA); > } > > // static: >@@ -1933,7 +1854,7 @@ IMapObject* ScDrawLayer::GetHitIMapObject( SdrObject* pObj, > else if ( pObj->ISA( SdrOle2Obj ) ) // OLE-Objekt > { > // TODO/LEAN: working with visual area needs running state >- aGraphSize = ((SdrOle2Obj*)pObj)->GetOrigObjSize(); >+ aGraphSize = ((const SdrOle2Obj*)pObj)->GetOrigObjSize(); > bObjSupported = TRUE; > } > >@@ -1951,14 +1872,9 @@ IMapObject* ScDrawLayer::GetHitIMapObject( SdrObject* pObj, > > ScMacroInfo* ScDrawLayer::GetMacroInfo( SdrObject* pObj, BOOL bCreate ) // static > { >- USHORT nCount = pObj->GetUserDataCount(); >- for( USHORT i = 0; i < nCount; i++ ) >- { >- SdrObjUserData* pData = pObj->GetUserData( i ); >- if( pData && pData->GetInventor() == SC_DRAWLAYER >- && pData->GetId() == SC_UD_MACRODATA ) >- return (ScMacroInfo*) pData; >- } >+ if (SdrObjUserData *pData = GetFirstUserDataOfType(pObj, SC_UD_MACRODATA)) >+ return (ScMacroInfo*) pData; >+ > if ( bCreate ) > { > ScMacroInfo* pData = new ScMacroInfo; >diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx >index 77a332f..feef952 100644 >--- a/sc/source/core/data/postit.cxx >+++ b/sc/source/core/data/postit.cxx >@@ -100,7 +100,6 @@ void ScCaptionUtil::SetCaptionLayer( SdrCaptionObj& rCaption, bool bShown ) > > void ScCaptionUtil::SetBasicCaptionSettings( SdrCaptionObj& rCaption, bool bShown ) > { >- ScDrawLayer::SetAnchor( &rCaption, SCA_PAGE ); > SetCaptionLayer( rCaption, bShown ); > rCaption.SetFixedTail(); > rCaption.SetSpecialTextBoxShadow(); >diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx >index c58a96c..e177dac 100644 >--- a/sc/source/core/data/table2.cxx >+++ b/sc/source/core/data/table2.cxx >@@ -2102,9 +2102,6 @@ void ScTable::SetColWidth( SCCOL nCol, USHORT nNewWidth ) > { > IncRecalcLevel(); > InitializeNoteCaptions(); >- ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer(); >- if (pDrawLayer) >- pDrawLayer->WidthChanged( nTab, nCol, ((long) nNewWidth) - (long) pColWidth[nCol] ); > pColWidth[nCol] = nNewWidth; > DecRecalcLevel(); > >@@ -2144,9 +2141,6 @@ void ScTable::SetRowHeight( SCROW nRow, USHORT nNewHeight ) > { > IncRecalcLevel(); > InitializeNoteCaptions(); >- ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer(); >- if (pDrawLayer) >- pDrawLayer->HeightChanged( nTab, nRow, ((long) nNewHeight) - (long) nOldHeight ); > mpRowHeights->setValue(nRow, nRow, nNewHeight); > DecRecalcLevel(); > >@@ -2227,22 +2221,7 @@ BOOL ScTable::SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, USHORT nNewHeig > if (!bChanged) > bChanged = lcl_pixelSizeChanged(*mpRowHeights, nStartRow, nEndRow, nNewHeight, nPPTY); > >- /* #i94028# #i94991# If drawing objects are involved, each row >- has to be changed for its own, because each call to >- ScDrawLayer::HeightChanged expects correct row heights >- above passed row in the document. Cannot use array iterator >- because array changes in every cycle. */ >- if( pDrawLayer ) >- { >- for( SCROW nRow = nStartRow; nRow <= nEndRow ; ++nRow ) >- { >- pDrawLayer->HeightChanged( nTab, nRow, >- static_cast<long>(nNewHeight) - static_cast<long>(mpRowHeights->getValue(nRow))); >- mpRowHeights->setValue(nRow, nRow, nNewHeight); >- } >- } >- else >- mpRowHeights->setValue(nStartRow, nEndRow, nNewHeight); >+ mpRowHeights->setValue(nStartRow, nEndRow, nNewHeight); > } > else > { >@@ -2255,17 +2234,6 @@ BOOL ScTable::SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, USHORT nNewHeig > } > else > { >- if (pDrawLayer) >- { >- // #i115025# When comparing to nNewHeight for the whole range, the height >- // including hidden rows has to be used (same behavior as 3.2). >- unsigned long nOldHeights = mpRowHeights->getSumValue(nStartRow, nEndRow); >- // FIXME: should we test for overflows? >- long nHeightDif = (long) (unsigned long) nNewHeight * >- (nEndRow - nStartRow + 1) - nOldHeights; >- pDrawLayer->HeightChanged( nTab, nEndRow, nHeightDif ); >- } >- > if (!bChanged) > bChanged = lcl_pixelSizeChanged(*mpRowHeights, nStartRow, nEndRow, nNewHeight, nPPTY); > >@@ -2519,17 +2487,9 @@ void ScTable::ShowCol(SCCOL nCol, bool bShow) > { > IncRecalcLevel(); > InitializeNoteCaptions(); >- ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer(); >- if (pDrawLayer) >- { >- if (bShow) >- pDrawLayer->WidthChanged( nTab, nCol, (long) pColWidth[nCol] ); >- else >- pDrawLayer->WidthChanged( nTab, nCol, -(long) pColWidth[nCol] ); >- } > > SetColHidden(nCol, nCol, !bShow); >- DecRecalcLevel(); >+ DecRecalcLevel(); > > ScChartListenerCollection* pCharts = pDocument->GetChartListenerCollection(); > if ( pCharts ) >@@ -2550,17 +2510,6 @@ void ScTable::ShowRow(SCROW nRow, bool bShow) > bool bWasVis = !RowHidden(nRow); > if (bWasVis != bShow) > { >- ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer(); >- if (pDrawLayer) >- { >- if (bShow) >- pDrawLayer->HeightChanged( >- nTab, nRow, static_cast<long>(mpRowHeights->getValue(nRow))); >- else >- pDrawLayer->HeightChanged( >- nTab, nRow, -static_cast<long>(mpRowHeights->getValue(nRow))); >- } >- > SetRowHidden(nRow, nRow, !bShow); > if (bShow) > SetRowFiltered(nRow, nRow, false); >@@ -2585,19 +2534,6 @@ void ScTable::DBShowRow(SCROW nRow, bool bShow) > bool bWasVis = !RowHidden(nRow); > IncRecalcLevel(); > InitializeNoteCaptions(); >- if (bWasVis != bShow) >- { >- ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer(); >- if (pDrawLayer) >- { >- if (bShow) >- pDrawLayer->HeightChanged( >- nTab, nRow, static_cast<long>(mpRowHeights->getValue(nRow))); >- else >- pDrawLayer->HeightChanged( >- nTab, nRow, -static_cast<long>(mpRowHeights->getValue(nRow))); >- } >- } > > // Filter-Flag immer setzen, auch wenn Hidden unveraendert > SetRowHidden(nRow, nRow, !bShow); >@@ -2635,18 +2571,6 @@ void ScTable::DBShowRows(SCROW nRow1, SCROW nRow2, bool bShow, bool bSetFlags) > nEndRow = nRow2; > > BOOL bChanged = ( bWasVis != bShow ); >- if ( bChanged && bSetFlags ) >- { >- ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer(); >- if (pDrawLayer) >- { >- long nHeight = static_cast<long>(mpRowHeights->getSumValue(nStartRow, nEndRow)); >- if (bShow) >- pDrawLayer->HeightChanged( nTab, nStartRow, nHeight ); >- else >- pDrawLayer->HeightChanged( nTab, nStartRow, -nHeight ); >- } >- } > > // #i116164# Directly modify the flags only if there are drawing objects within the area. > // Otherwise, all modifications are made together in ScTable::Query, so the tree isn't constantly rebuilt. >@@ -2683,9 +2607,6 @@ void ScTable::ShowRows(SCROW nRow1, SCROW nRow2, bool bShow) > // #i116164# if there are no drawing objects within the row range, a single HeightChanged call is enough > ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer(); > bool bHasObjects = pDrawLayer && pDrawLayer->HasObjectsInRows( nTab, nRow1, nRow2, false ); >- long nOldHeight = 0; >- if ( pDrawLayer && !bHasObjects ) >- nOldHeight = static_cast<long>(GetRowHeight(nRow1, nRow2)); > > while (nStartRow <= nRow2) > { >@@ -2695,17 +2616,6 @@ void ScTable::ShowRows(SCROW nRow1, SCROW nRow2, bool bShow) > nEndRow = nRow2; > > BOOL bChanged = ( bWasVis != bShow ); >- if ( bChanged && bHasObjects ) >- { >- if (pDrawLayer) >- { >- long nHeight = static_cast<long>(mpRowHeights->getSumValue(nStartRow, nEndRow)); >- if (bShow) >- pDrawLayer->HeightChanged( nTab, nStartRow, nHeight ); >- else >- pDrawLayer->HeightChanged( nTab, nStartRow, -nHeight ); >- } >- } > > // #i116164# Directly modify the flags only if there are drawing objects within the area. > // Otherwise, all rows are modified together after the loop, so the tree isn't constantly rebuilt. >@@ -2734,16 +2644,6 @@ void ScTable::ShowRows(SCROW nRow1, SCROW nRow2, bool bShow) > SetRowHidden(nRow1, nRow2, !bShow); > if (bShow) > SetRowFiltered(nRow1, nRow2, false); >- >- if ( pDrawLayer ) >- { >- // if there are no objects in the range, a single HeightChanged call is enough >- long nNewHeight = 0; >- if ( bShow ) >- nNewHeight = static_cast<long>(GetRowHeight(nRow1, nRow2)); >- if ( nNewHeight != nOldHeight ) >- pDrawLayer->HeightChanged( nTab, nRow1, nNewHeight - nOldHeight ); >- } > } > > DecRecalcLevel(); >diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx >index 3d66d3d..579fabe 100644 >--- a/sc/source/core/data/table3.cxx >+++ b/sc/source/core/data/table3.cxx >@@ -1742,11 +1742,6 @@ SCSIZE ScTable::Query(ScQueryParam& rParamOrg, BOOL bKeepSub) > std::vector<ScShowRowsEntry>::const_iterator aIter = aEntries.begin(); > if ( aIter != aEnd ) > { >- // do only one HeightChanged call with the final difference in heights >- long nOldHeight = 0; >- if ( pDrawLayer ) >- nOldHeight = static_cast<long>(GetRowHeight(aParam.nRow1 + nHeader, aParam.nRow2)); >- > // clear the range first instead of many changes in the middle of the filled array > SetRowHidden(aParam.nRow1 + nHeader, aParam.nRow2, false); > SetRowFiltered(aParam.nRow1 + nHeader, aParam.nRow2, false); >@@ -1769,13 +1764,6 @@ SCSIZE ScTable::Query(ScQueryParam& rParamOrg, BOOL bKeepSub) > > mpHiddenRows->setInsertFromBack(false); > mpFilteredRows->setInsertFromBack(false); >- >- if ( pDrawLayer ) >- { >- // if there are no objects in the filtered range, a single HeightChanged call is enough >- long nNewHeight = static_cast<long>(GetRowHeight(aParam.nRow1 + nHeader, aParam.nRow2)); >- pDrawLayer->HeightChanged( nTab, aParam.nRow1 + nHeader, nNewHeight - nOldHeight ); >- } > } > } > >diff --git a/sc/source/core/tool/detfunc.cxx b/sc/source/core/tool/detfunc.cxx >index 51e400a..ad9febc 100644 >--- a/sc/source/core/tool/detfunc.cxx >+++ b/sc/source/core/tool/detfunc.cxx >@@ -502,7 +502,6 @@ BOOL ScDetectiveFunc::InsertArrow( SCCOL nCol, SCROW nRow, > > pBox->SetMergedItemSetAndBroadcast(rData.GetBoxSet()); > >- ScDrawLayer::SetAnchor( pBox, SCA_CELL ); > pBox->SetLayer( SC_LAYER_INTERN ); > pPage->InsertObject( pBox ); > pModel->AddCalcUndo( new SdrUndoInsertObj( *pBox ) ); >@@ -544,7 +543,6 @@ BOOL ScDetectiveFunc::InsertArrow( SCCOL nCol, SCROW nRow, > pArrow->NbcSetLogicRect(Rectangle(aStartPos,aEndPos)); //! noetig ??? > pArrow->SetMergedItemSetAndBroadcast(rAttrSet); > >- ScDrawLayer::SetAnchor( pArrow, SCA_CELL ); > pArrow->SetLayer( SC_LAYER_INTERN ); > pPage->InsertObject( pArrow ); > pModel->AddCalcUndo( new SdrUndoInsertObj( *pArrow ) ); >@@ -576,7 +574,6 @@ BOOL ScDetectiveFunc::InsertToOtherTab( SCCOL nStartCol, SCROW nStartRow, > > pBox->SetMergedItemSetAndBroadcast(rData.GetBoxSet()); > >- ScDrawLayer::SetAnchor( pBox, SCA_CELL ); > pBox->SetLayer( SC_LAYER_INTERN ); > pPage->InsertObject( pBox ); > pModel->AddCalcUndo( new SdrUndoInsertObj( *pBox ) ); >@@ -611,7 +608,6 @@ BOOL ScDetectiveFunc::InsertToOtherTab( SCCOL nStartCol, SCROW nStartRow, > > pArrow->SetMergedItemSetAndBroadcast(rAttrSet); > >- ScDrawLayer::SetAnchor( pArrow, SCA_CELL ); > pArrow->SetLayer( SC_LAYER_INTERN ); > pPage->InsertObject( pArrow ); > pModel->AddCalcUndo( new SdrUndoInsertObj( *pArrow ) ); >@@ -680,7 +676,6 @@ void ScDetectiveFunc::DrawCircle( SCCOL nCol, SCROW nRow, ScDetectiveData& rData > > pCircle->SetMergedItemSetAndBroadcast(rAttrSet); > >- ScDrawLayer::SetAnchor( pCircle, SCA_CELL ); > pCircle->SetLayer( SC_LAYER_INTERN ); > pPage->InsertObject( pCircle ); > pModel->AddCalcUndo( new SdrUndoInsertObj( *pCircle ) ); >diff --git a/sc/source/filter/xcl97/xcl97rec.cxx b/sc/source/filter/xcl97/xcl97rec.cxx >index 3801414..0e45bfe 100644 >--- a/sc/source/filter/xcl97/xcl97rec.cxx >+++ b/sc/source/filter/xcl97/xcl97rec.cxx >@@ -978,7 +978,7 @@ GetEditAs( XclObjAny& rObj ) > if( const SdrObject* pShape = EscherEx::GetSdrObject( rObj.GetShape() ) ) > { > // OOXTODO: returning "twoCell" >- switch( ScDrawLayer::GetAnchor( pShape ) ) >+ switch( ScDrawLayer::GetAnchorType( *pShape ) ) > { > case SCA_CELL: return "oneCell"; > default: break; >diff --git a/sc/source/filter/xml/XMLExportIterator.hxx b/sc/source/filter/xml/XMLExportIterator.hxx >index 836e4f1..2364e7c 100644 >--- a/sc/source/filter/xml/XMLExportIterator.hxx >+++ b/sc/source/filter/xml/XMLExportIterator.hxx >@@ -71,6 +71,8 @@ struct ScMyShape > { > ScAddress aAddress; > ScAddress aEndAddress; >+ sal_Int32 nEndX; >+ sal_Int32 nEndY; > com::sun::star::uno::Reference<com::sun::star::drawing::XShape> xShape; > > sal_Bool operator<(const ScMyShape& aShape) const; >diff --git a/sc/source/filter/xml/XMLTableShapeImportHelper.cxx b/sc/source/filter/xml/XMLTableShapeImportHelper.cxx >index 320681e..bae8ae2 100644 >--- a/sc/source/filter/xml/XMLTableShapeImportHelper.cxx >+++ b/sc/source/filter/xml/XMLTableShapeImportHelper.cxx >@@ -34,6 +34,7 @@ > #include "drwlayer.hxx" > #include "xmlannoi.hxx" > #include "rangeutl.hxx" >+#include "userdat.hxx" > #include "docuno.hxx" > #include "sheetdata.hxx" > #include <xmloff/nmspmap.hxx> >@@ -90,6 +91,11 @@ void XMLTableShapeImportHelper::finishShape( > { > if (!pAnnotationContext) > { >+ ScDrawObjData aAnchor; >+ aAnchor.maStart = ScAddress(aStartCell.Column, aStartCell.Row, aStartCell.Sheet); >+ awt::Point aStartPoint(rShape->getPosition()); >+ aAnchor.maStartOffset = Point(aStartPoint.X, aStartPoint.Y); >+ > sal_Int32 nEndX(-1); > sal_Int32 nEndY(-1); > sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; >@@ -111,11 +117,18 @@ void XMLTableShapeImportHelper::finishShape( > { > sal_Int32 nOffset(0); > ScRangeStringConverter::GetAddressFromString(aEndCell, rValue, static_cast<ScXMLImport&>(mrImporter).GetDocument(), ::formula::FormulaGrammar::CONV_OOO, nOffset); >+ aAnchor.maEnd = ScAddress(aEndCell.Column, aEndCell.Row, aEndCell.Sheet); > } > else if (IsXMLToken(aLocalName, XML_END_X)) >+ { > static_cast<ScXMLImport&>(mrImporter).GetMM100UnitConverter().convertMeasure(nEndX, rValue); >+ aAnchor.maEndOffset.X() = nEndX; >+ } > else if (IsXMLToken(aLocalName, XML_END_Y)) >+ { > static_cast<ScXMLImport&>(mrImporter).GetMM100UnitConverter().convertMeasure(nEndY, rValue); >+ aAnchor.maEndOffset.Y() = nEndY; >+ } > else if (IsXMLToken(aLocalName, XML_TABLE_BACKGROUND)) > if (IsXMLToken(rValue, XML_TRUE)) > nLayerID = SC_LAYER_BACK; >@@ -128,39 +141,28 @@ void XMLTableShapeImportHelper::finishShape( > } > SetLayer(rShape, nLayerID, rShape->getShapeType()); > >- if (!bOnTable) >+ if (SvxShape* pShapeImp = SvxShape::getImplementation(rShape)) > { >- rTables.AddShape(rShape, >- pRangeList, aStartCell, aEndCell, nEndX, nEndY); >- SvxShape* pShapeImp = SvxShape::getImplementation(rShape); >- if (pShapeImp) >+ if (SdrObject *pSdrObj = pShapeImp->GetSdrObject()) > { >- SdrObject *pSdrObj = pShapeImp->GetSdrObject(); >- if (pSdrObj) >- ScDrawLayer::SetAnchor(pSdrObj, SCA_CELL); >+ if (!bOnTable) >+ ScDrawLayer::SetCellAnchored(*pSdrObj, aAnchor); >+ else >+ ScDrawLayer::SetPageAnchored(*pSdrObj); > } > } >- else >- { >- if ( pRangeList ) >- { >- // #i78086# If there are notification ranges, the ChartListener must be created >- // also when anchored to the sheet >- // -> call AddShape with invalid cell position (checked in ScMyShapeResizer::ResizeShapes) > >- table::CellAddress aInvalidPos( -1, -1, -1 ); >- rTables.AddShape(rShape, >- pRangeList, aInvalidPos, aInvalidPos, 0, 0); >- } >+ if ( bOnTable && pRangeList ) >+ { >+ // #i78086# If there are notification ranges, the ChartListener must be created >+ // also when anchored to the sheet >+ // -> call AddOLE with invalid cell position (checked in ScMyShapeResizer::ResizeShapes) > >- SvxShape* pShapeImp = SvxShape::getImplementation(rShape); >- if (pShapeImp) >- { >- SdrObject *pSdrObj = pShapeImp->GetSdrObject(); >- if (pSdrObj) >- ScDrawLayer::SetAnchor(pSdrObj, SCA_PAGE); >- } >+ if (rTables.IsOLE(rShape)) >+ rTables.AddOLE(rShape, *pRangeList); > } >+ >+ delete pRangeList; > } > else // shape is annotation > { >diff --git a/sc/source/filter/xml/XMLTableShapeResizer.cxx b/sc/source/filter/xml/XMLTableShapeResizer.cxx >index 1e452e5..ae9a3e0 100644 >--- a/sc/source/filter/xml/XMLTableShapeResizer.cxx >+++ b/sc/source/filter/xml/XMLTableShapeResizer.cxx >@@ -49,38 +49,38 @@ using ::std::auto_ptr; > using ::std::vector; > using ::rtl::OUString; > >-ScMyShapeResizer::ScMyShapeResizer(ScXMLImport& rTempImport) >+ScMyOLEFixer::ScMyOLEFixer(ScXMLImport& rTempImport) > : rImport(rTempImport), > aShapes(), > pCollection(NULL) > { > } > >-ScMyShapeResizer::~ScMyShapeResizer() >+ScMyOLEFixer::~ScMyOLEFixer() > { > } > >-sal_Bool ScMyShapeResizer::IsOLE(uno::Reference< drawing::XShape >& rShape) const >+sal_Bool ScMyOLEFixer::IsOLE(uno::Reference< drawing::XShape >& rShape) > { >- return rShape->getShapeType().equals(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.OLE2Shape"))); >+ return rShape->getShapeType().equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.OLE2Shape")); > } > >-void ScMyShapeResizer::CreateChartListener(ScDocument* pDoc, >+void ScMyOLEFixer::CreateChartListener(ScDocument* pDoc, > const rtl::OUString& rName, >- const rtl::OUString* pRangeList) >+ const rtl::OUString& rRangeList) > { >- if (!pDoc || !pRangeList) >- // These are minimum required. >+ // This is the minimum required. >+ if (!pDoc) > return; > >- if (!pRangeList->getLength()) >+ if (!rRangeList.getLength()) > { > pDoc->AddOLEObjectToCollection(rName); > return; > } > > OUString aRangeStr; >- ScRangeStringConverter::GetStringFromXMLRangeString(aRangeStr, *pRangeList, pDoc); >+ ScRangeStringConverter::GetStringFromXMLRangeString(aRangeStr, rRangeList, pDoc); > if (!aRangeStr.getLength()) > { > pDoc->AddOLEObjectToCollection(rName); >@@ -116,268 +116,43 @@ void ScMyShapeResizer::CreateChartListener(ScDocument* pDoc, > } > } > >-void ScMyShapeResizer::AddShape(uno::Reference <drawing::XShape>& rShape, >- rtl::OUString* pRangeList, >- table::CellAddress& rStartAddress, table::CellAddress& rEndAddress, >- sal_Int32 nEndX, sal_Int32 nEndY) >+void ScMyOLEFixer::AddOLE(uno::Reference <drawing::XShape>& rShape, >+ const rtl::OUString &rRangeList) > { >- ScMyToResizeShape aShape; >+ ScMyToFixupOLE aShape; > aShape.xShape.set(rShape); >- aShape.pRangeList = pRangeList; >- aShape.aEndCell = rEndAddress; >- aShape.aStartCell = rStartAddress; >- aShape.nEndY = nEndY; >- aShape.nEndX = nEndX; >+ aShape.sRangeList = rRangeList; > aShapes.push_back(aShape); > } > >-void ScMyShapeResizer::GetNewShapeSizePos(ScDocument* pDoc, const Rectangle& rStartRect, >- const table::CellAddress& rEndCell, >- awt::Point& rPoint, awt::Size& rSize, >- sal_Int32& rEndX, sal_Int32& rEndY) const >-{ >- awt::Point aRefPoint; >- BOOL bNegativePage(pDoc->IsNegativePage(rEndCell.Sheet)); >- if (bNegativePage) >- aRefPoint.X = rStartRect.Right(); >- else >- aRefPoint.X = rStartRect.Left(); >- aRefPoint.Y = rStartRect.Top(); >- Rectangle aRect(pDoc->GetMMRect( >- static_cast<SCCOL>(rEndCell.Column), static_cast<SCROW>(rEndCell.Row), >- static_cast<SCCOL>(rEndCell.Column), static_cast<SCROW>(rEndCell.Row), rEndCell.Sheet )); >- if (bNegativePage) >- rEndX = -rEndX + aRect.Right(); >- else >- rEndX += aRect.Left(); >- rEndY += aRect.Top(); >- rPoint.X += aRefPoint.X; >- if (bNegativePage) >- { >- if (rPoint.X < rStartRect.Left()) >- rPoint.X = rStartRect.Left() + 2; // increment by 2 100th_mm because the cellwidth is internal in twips >- } >- else >- { >- if (rPoint.X > rStartRect.Right()) >- rPoint.X = rStartRect.Right() - 2; // decrement by 2 100th_mm because the cellwidth is internal in twips >- } >- rPoint.Y += aRefPoint.Y; >- if (rPoint.Y > rStartRect.Bottom()) >- rPoint.Y = rStartRect.Bottom() - 2; // decrement by 2 100th_mm because the cellheight is internal in twips >- if (bNegativePage) >- { >- rSize.Width = -(rEndX - rPoint.X); >- } >- else >- rSize.Width = rEndX - rPoint.X; >- rSize.Height = rEndY - rPoint.Y; >-} >- >-void ScMyShapeResizer::ResizeShapes() >+void ScMyOLEFixer::FixupOLEs() > { > if (!aShapes.empty() && rImport.GetModel().is()) > { >- rtl::OUString sRowHeight(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_CELLHGT)); > rtl::OUString sPersistName (RTL_CONSTASCII_USTRINGPARAM("PersistName")); >- rtl::OUString sCaptionPoint( RTL_CONSTASCII_USTRINGPARAM( "CaptionPoint" )); >- rtl::OUString sConnectorShape( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ConnectorShape") ); >- rtl::OUString sCaptionShape( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.CaptionShape") ); >- rtl::OUString sStartShape(RTL_CONSTASCII_USTRINGPARAM("StartShape")); >- rtl::OUString sEndShape(RTL_CONSTASCII_USTRINGPARAM("EndShape")); >- rtl::OUString sStartPosition(RTL_CONSTASCII_USTRINGPARAM("StartPosition")); >- rtl::OUString sEndPosition(RTL_CONSTASCII_USTRINGPARAM("EndPosition")); >- uno::Reference<table::XCellRange> xTableRow; >- uno::Reference<sheet::XSpreadsheet> xSheet; >- uno::Reference<table::XTableRows> xTableRows; >- sal_Int32 nOldRow(-1); >- sal_Int32 nOldSheet(-1); >- ScMyToResizeShapes::iterator aItr(aShapes.begin()); >- ScMyToResizeShapes::iterator aEndItr(aShapes.end()); >- uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( rImport.GetModel(), uno::UNO_QUERY ); >- if ( xSpreadDoc.is() ) >- { >- uno::Reference<container::XIndexAccess> xIndex( xSpreadDoc->getSheets(), uno::UNO_QUERY ); >- ScDocument* pDoc(rImport.GetDocument()); >- if ( pDoc && xIndex.is() ) >- { >- ScXMLImport::MutexGuard aGuard(rImport); >- while (aItr != aEndItr) >- { >- // #i78086# invalid cell position is used to call CreateChartListener only >- if ( aItr->aEndCell.Sheet >= 0 ) >- { >- if ((nOldSheet != aItr->aEndCell.Sheet) || !xSheet.is()) >- { >- nOldSheet = aItr->aEndCell.Sheet; >- xSheet.set(xIndex->getByIndex(nOldSheet), uno::UNO_QUERY); >- if (xSheet.is()) >- { >- uno::Reference<table::XColumnRowRange> xColumnRowRange (xSheet, uno::UNO_QUERY); >- if (xColumnRowRange.is()) >- xTableRows = xColumnRowRange->getRows(); >- } >- } >- if (xTableRows.is()) >- { >- if (nOldRow != aItr->aEndCell.Row || !xTableRow.is()) >- { >- nOldRow = aItr->aEndCell.Row; >- xTableRows->getByIndex(nOldRow) >>= xTableRow; >- } >- if (xTableRow.is()) >- { >- uno::Reference <beans::XPropertySet> xRowProperties(xTableRow, uno::UNO_QUERY); >- if (xRowProperties.is()) >- { >- sal_Int32 nHeight; >- if (xRowProperties->getPropertyValue(sRowHeight) >>= nHeight) >- { >- Rectangle aRec = pDoc->GetMMRect(static_cast<SCCOL>(aItr->aStartCell.Column), static_cast<SCROW>(aItr->aStartCell.Row), >- static_cast<SCCOL>(aItr->aStartCell.Column), static_cast<SCROW>(aItr->aStartCell.Row), aItr->aStartCell.Sheet); >- awt::Point aPoint(aItr->xShape->getPosition()); >- awt::Size aSize(aItr->xShape->getSize()); >- if (pDoc->IsNegativePage(static_cast<SCTAB>(nOldSheet))) >- aPoint.X += aSize.Width; >- if (aItr->nEndY >= 0 && aItr->nEndX >= 0) >- { >- if (aItr->xShape->getShapeType().equals(sConnectorShape)) >- { >- //#103122#; handle connected Connectorshapes >- uno::Reference<beans::XPropertySet> xShapeProps (aItr->xShape, uno::UNO_QUERY); >- if(xShapeProps.is()) >- { >- uno::Reference<drawing::XShape> xStartShape(xShapeProps->getPropertyValue( sStartShape ), uno::UNO_QUERY); >- uno::Reference<drawing::XShape> xEndShape(xShapeProps->getPropertyValue( sEndShape ), uno::UNO_QUERY); >- if (!xStartShape.is() && !xEndShape.is()) >- { >- awt::Size aOldSize(aSize); >- GetNewShapeSizePos(pDoc, aRec, aItr->aEndCell, aPoint, aSize, aItr->nEndX, aItr->nEndY); >- aItr->xShape->setPosition(aPoint); >- if( (aSize.Width != aOldSize.Width) || >- (aSize.Height != aOldSize.Height) ) >- aItr->xShape->setSize(aSize); >- } >- else if (xStartShape.is() && xEndShape.is()) >- { >- // do nothing, because they are connected >- } >- else >- { >- // only one point is connected, the other should be moved >- >- rtl::OUString sProperty; >- if (xStartShape.is()) >- { >- awt::Point aEndPoint; >- xShapeProps->getPropertyValue(sEndPosition) >>= aEndPoint; >- aPoint.X = aRec.Left() + aEndPoint.X; >- aPoint.Y = aRec.Top() + aEndPoint.Y; >- sProperty = sEndPosition; >- } >- else >- { >- awt::Point aStartPoint; >- xShapeProps->getPropertyValue(sStartPosition) >>= aStartPoint; >- aPoint.X = aRec.Left() + aStartPoint.X; >- aPoint.Y = aRec.Top() + aStartPoint.Y; >- sProperty = sStartPosition; >- } >- xShapeProps->setPropertyValue(sProperty, uno::makeAny(aPoint)); >- } >- } >- } >- else >- { >- awt::Size aOldSize(aSize); >- GetNewShapeSizePos(pDoc, aRec, aItr->aEndCell, aPoint, aSize, aItr->nEndX, aItr->nEndY); >- if (pDoc->IsNegativePage(static_cast<SCTAB>(nOldSheet))) >- aPoint.X -= aSize.Width; >- aItr->xShape->setPosition(aPoint); >- if( (aSize.Width != aOldSize.Width) || >- (aSize.Height != aOldSize.Height) ) >- aItr->xShape->setSize(aSize); >- } >- } >- else >- { >- if (aItr->xShape->getShapeType().equals(sCaptionShape)) >- { >- Rectangle aRectangle(aPoint.X, aPoint.Y, aPoint.X + aSize.Width, aPoint.Y + aSize.Height); >+ ScMyToFixupOLEs::iterator aItr(aShapes.begin()); >+ ScMyToFixupOLEs::iterator aEndItr(aShapes.end()); >+ ScDocument* pDoc(rImport.GetDocument()); > >- awt::Point aCaptionPoint; >- uno::Reference< beans::XPropertySet > xShapeProps(aItr->xShape, uno::UNO_QUERY); >- if (xShapeProps.is()) >- { >- try >- { >- xShapeProps->getPropertyValue( sCaptionPoint ) >>= aCaptionPoint; >- } >- catch ( uno::Exception& ) >- { >- DBG_ERROR("This Captionshape has no CaptionPoint property."); >- } >- } >- Point aCorePoint(aPoint.X, aPoint.Y); >- Point aCoreCaptionPoint(aCaptionPoint.X, aCaptionPoint.Y); >- aCoreCaptionPoint += aCorePoint; >- aRectangle.Union(Rectangle(aCoreCaptionPoint, aCoreCaptionPoint)); >+ ScXMLImport::MutexGuard aGuard(rImport); > >- Point aBeforeRightBottomPoint(aRectangle.BottomRight()); >- >- aRectangle += aRec.TopLeft(); >- if (aRectangle.Left() > aRec.Right()) >- aRectangle -= (Point(aRectangle.Left() - aRec.Right() + 2, 0)); >- if (aRectangle.Top() > aRec.Bottom()) >- aRectangle -= (Point(0, aRectangle.Top() - aRec.Bottom() + 2)); >+ while (aItr != aEndItr) >+ { >+ // #i78086# also call CreateChartListener for invalid position (anchored to sheet) >+ if (!IsOLE(aItr->xShape)) >+ DBG_ERROR("Only OLEs should be in here now"); > >- Point aDifferencePoint(aRectangle.BottomRight() - aBeforeRightBottomPoint); >- aPoint.X += aDifferencePoint.X(); >- aPoint.Y += aDifferencePoint.Y(); >+ if (IsOLE(aItr->xShape)) >+ { >+ uno::Reference < beans::XPropertySet > xShapeProps ( aItr->xShape, uno::UNO_QUERY ); >+ uno::Reference < beans::XPropertySetInfo > xShapeInfo(xShapeProps->getPropertySetInfo()); > >- aItr->xShape->setPosition(aPoint); >- } >- else >- { >- // #96159# it is possible, that shapes have a negative position >- // this is now handled here >- DBG_ERROR("no or negative end address of this shape"); >- awt::Point aRefPoint; >- aRefPoint.X = aRec.Left(); >- aRefPoint.Y = aRec.Top(); >- aPoint.X += aRefPoint.X; >- if (aPoint.X > aRec.Right()) >- aPoint.X = aRec.Right() - 2; // decrement by 2 100th_mm because the cellheight is internal in twips >- aPoint.Y += aRefPoint.Y; >- if (aPoint.Y > aRec.Bottom()) >- aPoint.Y = aRec.Bottom() - 2; // decrement by 2 100th_mm because the cellheight is internal in twips >- aItr->xShape->setPosition(aPoint); >- } >- } >- } >- } >- } >- } >- else >- { >- DBG_ERROR("something wents wrong"); >- } >- } >- // #i78086# call CreateChartListener also for invalid position (anchored to sheet) >- if (IsOLE(aItr->xShape)) >- { >- uno::Reference < beans::XPropertySet > xShapeProps ( aItr->xShape, uno::UNO_QUERY ); >- uno::Reference < beans::XPropertySetInfo > xShapeInfo(xShapeProps->getPropertySetInfo()); >- rtl::OUString sName; >- if (xShapeProps.is() && xShapeInfo.is() && xShapeInfo->hasPropertyByName(sPersistName) && >- (xShapeProps->getPropertyValue(sPersistName) >>= sName)) >- CreateChartListener(pDoc, sName, aItr->pRangeList); >- } >- if (aItr->pRangeList) >- delete aItr->pRangeList; >- aItr = aShapes.erase(aItr); >- } >+ rtl::OUString sName; >+ if (pDoc && xShapeProps.is() && xShapeInfo.is() && xShapeInfo->hasPropertyByName(sPersistName) && >+ (xShapeProps->getPropertyValue(sPersistName) >>= sName)) >+ CreateChartListener(pDoc, sName, aItr->sRangeList); > } >+ aItr = aShapes.erase(aItr); > } > } > } >diff --git a/sc/source/filter/xml/XMLTableShapeResizer.hxx b/sc/source/filter/xml/XMLTableShapeResizer.hxx >index 618b0a3..c71f52b 100644 >--- a/sc/source/filter/xml/XMLTableShapeResizer.hxx >+++ b/sc/source/filter/xml/XMLTableShapeResizer.hxx >@@ -39,44 +39,31 @@ class ScChartListenerCollection; > class ScDocument; > class Rectangle; > >-struct ScMyToResizeShape >+struct ScMyToFixupOLE > { > com::sun::star::uno::Reference <com::sun::star::drawing::XShape> xShape; >- rtl::OUString* pRangeList; >- com::sun::star::table::CellAddress aEndCell; >- com::sun::star::table::CellAddress aStartCell; >- sal_Int32 nEndX; >- sal_Int32 nEndY; >- >- ScMyToResizeShape() : pRangeList(NULL) {} >+ rtl::OUString sRangeList; > }; > >-typedef std::list<ScMyToResizeShape> ScMyToResizeShapes; >+typedef std::list<ScMyToFixupOLE> ScMyToFixupOLEs; > >-class ScMyShapeResizer >+class ScMyOLEFixer > { > ScXMLImport& rImport; >- ScMyToResizeShapes aShapes; >+ ScMyToFixupOLEs aShapes; > ScChartListenerCollection* pCollection; > >- sal_Bool IsOLE(com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& rShape) const; > void CreateChartListener(ScDocument* pDoc, > const rtl::OUString& rName, >- const rtl::OUString* pRangeList); >- void GetNewShapeSizePos(ScDocument* pDoc, const Rectangle& rStartRect, >- const com::sun::star::table::CellAddress& rEndCell, >- com::sun::star::awt::Point& rPoint, com::sun::star::awt::Size& rSize, >- sal_Int32& rEndX, sal_Int32& rEndY) const; >+ const rtl::OUString& rRangeList); > public: >- ScMyShapeResizer(ScXMLImport& rImport); >- ~ScMyShapeResizer(); >+ ScMyOLEFixer(ScXMLImport& rImport); >+ ~ScMyOLEFixer(); > >- void AddShape(com::sun::star::uno::Reference <com::sun::star::drawing::XShape>& rShape, >- rtl::OUString* pRangeList, >- com::sun::star::table::CellAddress& rStartAddress, >- com::sun::star::table::CellAddress& rEndAddress, >- sal_Int32 nEndX, sal_Int32 nEndY); >- void ResizeShapes(); >+ static sal_Bool IsOLE(com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& rShape); >+ void AddOLE(com::sun::star::uno::Reference <com::sun::star::drawing::XShape>& rShape, >+ const rtl::OUString &rRangeList); >+ void FixupOLEs(); > }; > > #endif >diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx >index 9799058..faa2f20 100644 >--- a/sc/source/filter/xml/xmlexprt.cxx >+++ b/sc/source/filter/xml/xmlexprt.cxx >@@ -682,39 +682,21 @@ void ScXMLExport::CollectSharedData(sal_Int32& nTableCount, sal_Int32& nShapesCo > else > { > ++nShapesCount; >- SvxShape* pShapeImp(SvxShape::getImplementation(xShape)); >- if (pShapeImp) >+ if (SvxShape* pShapeImp = SvxShape::getImplementation(xShape)) > { >- SdrObject *pSdrObj(pShapeImp->GetSdrObject()); >- if (pSdrObj) >+ if (SdrObject *pSdrObj = pShapeImp->GetSdrObject()) > { >- if (ScDrawLayer::GetAnchor(pSdrObj) == SCA_CELL) >+ if (ScDrawObjData *pAnchor = ScDrawLayer::GetObjData( pSdrObj )) > { >- if (pDoc) >- { >- >- awt::Point aPoint(xShape->getPosition()); >- awt::Size aSize(xShape->getSize()); >- rtl::OUString sType(xShape->getShapeType()); >- Rectangle aRectangle(aPoint.X, aPoint.Y, aPoint.X + aSize.Width, aPoint.Y + aSize.Height); >- if ( sType.equals(sCaptionShape) ) >- { >- awt::Point aRelativeCaptionPoint; >- xShapeProp->getPropertyValue( sCaptionPoint ) >>= aRelativeCaptionPoint; >- Point aCoreRelativeCaptionPoint(aRelativeCaptionPoint.X, aRelativeCaptionPoint.Y); >- Point aCoreAbsoluteCaptionPoint(aPoint.X, aPoint.Y); >- aCoreAbsoluteCaptionPoint += aCoreRelativeCaptionPoint; >- aRectangle.Union(Rectangle(aCoreAbsoluteCaptionPoint, aCoreAbsoluteCaptionPoint)); >- } >- ScRange aRange(pDoc->GetRange(static_cast<SCTAB>(nTable), aRectangle)); >- ScMyShape aMyShape; >- aMyShape.aAddress = aRange.aStart; >- aMyShape.aEndAddress = aRange.aEnd; >- aMyShape.xShape = xShape; >- pSharedData->AddNewShape(aMyShape); >- pSharedData->SetLastColumn(nTable, aRange.aStart.Col()); >- pSharedData->SetLastRow(nTable, aRange.aStart.Row()); >- } >+ ScMyShape aMyShape; >+ aMyShape.aAddress = pAnchor->maStart; >+ aMyShape.aEndAddress = pAnchor->maEnd; >+ aMyShape.nEndX = pAnchor->maEndOffset.X(); >+ aMyShape.nEndY = pAnchor->maEndOffset.Y(); >+ aMyShape.xShape = xShape; >+ pSharedData->AddNewShape(aMyShape); >+ pSharedData->SetLastColumn(nTable, pAnchor->maStart.Col()); >+ pSharedData->SetLastRow(nTable, pAnchor->maStart.Row()); > } > else > pSharedData->AddTableShape(nTable, xShape); >@@ -3208,29 +3190,15 @@ void ScXMLExport::WriteShapes(const ScMyCell& rMyCell) > aPoint.X = 2 * aItr->xShape->getPosition().X + aItr->xShape->getSize().Width - aPoint.X; > if ( !aItr->xShape->getShapeType().equals(sCaptionShape) ) > { >- awt::Point aEndPoint; > Rectangle aEndRec(pDoc->GetMMRect(aItr->aEndAddress.Col(), aItr->aEndAddress.Row(), > aItr->aEndAddress.Col(), aItr->aEndAddress.Row(), aItr->aEndAddress.Tab())); > rtl::OUString sEndAddress; > ScRangeStringConverter::GetStringFromAddress(sEndAddress, aItr->aEndAddress, pDoc, FormulaGrammar::CONV_OOO); > AddAttribute(XML_NAMESPACE_TABLE, XML_END_CELL_ADDRESS, sEndAddress); >- if (bNegativePage) >- aEndPoint.X = -aEndRec.Right(); >- else >- aEndPoint.X = aEndRec.Left(); >- aEndPoint.Y = aEndRec.Top(); >- awt::Point aStartPoint(aItr->xShape->getPosition()); >- awt::Size aSize(aItr->xShape->getSize()); >- sal_Int32 nEndX; >- if (bNegativePage) >- nEndX = -aStartPoint.X - aEndPoint.X; >- else >- nEndX = aStartPoint.X + aSize.Width - aEndPoint.X; >- sal_Int32 nEndY(aStartPoint.Y + aSize.Height - aEndPoint.Y); > rtl::OUStringBuffer sBuffer; >- GetMM100UnitConverter().convertMeasure(sBuffer, nEndX); >+ GetMM100UnitConverter().convertMeasure(sBuffer, aItr->nEndX); > AddAttribute(XML_NAMESPACE_TABLE, XML_END_X, sBuffer.makeStringAndClear()); >- GetMM100UnitConverter().convertMeasure(sBuffer, nEndY); >+ GetMM100UnitConverter().convertMeasure(sBuffer, aItr->nEndY); > AddAttribute(XML_NAMESPACE_TABLE, XML_END_Y, sBuffer.makeStringAndClear()); > } > ExportShape(aItr->xShape, &aPoint); >diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx >index c8ec2e7..fb39fbe 100644 >--- a/sc/source/filter/xml/xmlimprt.cxx >+++ b/sc/source/filter/xml/xmlimprt.cxx >@@ -2918,7 +2918,7 @@ throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeE > } > > aTables.UpdateRowHeights(); >- aTables.ResizeShapes(); >+ aTables.FixupOLEs(); > } > if (GetModel().is()) > { >diff --git a/sc/source/filter/xml/xmlsubti.cxx b/sc/source/filter/xml/xmlsubti.cxx >index 60ff93a..291f99f 100644 >--- a/sc/source/filter/xml/xmlsubti.cxx >+++ b/sc/source/filter/xml/xmlsubti.cxx >@@ -159,7 +159,7 @@ ScXMLTabProtectionData::ScXMLTabProtectionData() : > > ScMyTables::ScMyTables(ScXMLImport& rTempImport) > : rImport(rTempImport), >- aResizeShapes(rTempImport), >+ aFixupOLEs(rTempImport), > nCurrentColStylePos(0), > nCurrentDrawPage( -1 ), > nCurrentXShapes( -1 ), >@@ -761,12 +761,10 @@ sal_Bool ScMyTables::HasXShapes() > return !((nCurrentSheet != nCurrentXShapes) || !xShapes.is()); > } > >-void ScMyTables::AddShape(uno::Reference <drawing::XShape>& rShape, >- rtl::OUString* pRangeList, >- table::CellAddress& rStartAddress, table::CellAddress& rEndAddress, >- sal_Int32 nEndX, sal_Int32 nEndY) >+void ScMyTables::AddOLE(uno::Reference <drawing::XShape>& rShape, >+ const rtl::OUString &rRangeList) > { >- aResizeShapes.AddShape(rShape, pRangeList, rStartAddress, rEndAddress, nEndX, nEndY); >+ aFixupOLEs.AddOLE(rShape, rRangeList); > } > > void ScMyTables::AddMatrixRange( >diff --git a/sc/source/filter/xml/xmlsubti.hxx b/sc/source/filter/xml/xmlsubti.hxx >index e412872..65ee98b 100644 >--- a/sc/source/filter/xml/xmlsubti.hxx >+++ b/sc/source/filter/xml/xmlsubti.hxx >@@ -129,7 +129,7 @@ private: > > ScXMLImport& rImport; > >- ScMyShapeResizer aResizeShapes; >+ ScMyOLEFixer aFixupOLEs; > > ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet > xCurrentSheet; > ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange > xCurrentCellRange; >@@ -164,7 +164,9 @@ public: > void AddColumn(sal_Bool bIsCovered); > void NewTable(sal_Int32 nTempSpannedCols); > void UpdateRowHeights(); >- void ResizeShapes() { aResizeShapes.ResizeShapes(); } >+ void FixupOLEs() { aFixupOLEs.FixupOLEs(); } >+ sal_Bool IsOLE(com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& rShape) const >+ { return ScMyOLEFixer::IsOLE(rShape); } > void DeleteTable(); > com::sun::star::table::CellAddress GetRealCellPos(); > void AddColCount(sal_Int32 nTempColCount); >@@ -184,11 +186,8 @@ public: > GetCurrentXShapes(); > sal_Bool HasDrawPage(); > sal_Bool HasXShapes(); >- void AddShape(com::sun::star::uno::Reference <com::sun::star::drawing::XShape>& rShape, >- rtl::OUString* pRangeList, >- com::sun::star::table::CellAddress& rStartAddress, >- com::sun::star::table::CellAddress& rEndAddress, >- sal_Int32 nEndX, sal_Int32 nEndY); >+ void AddOLE(com::sun::star::uno::Reference <com::sun::star::drawing::XShape>& rShape, >+ const rtl::OUString &rRangeList); > > void AddMatrixRange( sal_Int32 nStartColumn, > sal_Int32 nStartRow, >diff --git a/sc/source/ui/Accessibility/AccessibleDocument.cxx b/sc/source/ui/Accessibility/AccessibleDocument.cxx >index 722f41a..6e2e2b8 100644 >--- a/sc/source/ui/Accessibility/AccessibleDocument.cxx >+++ b/sc/source/ui/Accessibility/AccessibleDocument.cxx >@@ -41,6 +41,7 @@ > #include "drawview.hxx" > #include "gridwin.hxx" > #include "AccessibleEditObject.hxx" >+#include "userdat.hxx" > #include "scresid.hxx" > #include "sc.hrc" > #include <com/sun/star/accessibility/AccessibleEventId.hpp> >@@ -977,35 +978,10 @@ ScAddress* ScChildrenShapes::GetAnchor(const uno::Reference<drawing::XShape>& xS > uno::Reference<beans::XPropertySet> xShapeProp(xShape, uno::UNO_QUERY); > if (pShapeImp && xShapeProp.is()) > { >- SdrObject *pSdrObj = pShapeImp->GetSdrObject(); >- if (pSdrObj) >+ if (SdrObject *pSdrObj = pShapeImp->GetSdrObject()) > { >- if (ScDrawLayer::GetAnchor(pSdrObj) == SCA_CELL) >- { >- ScDocument* pDoc = mpViewShell->GetViewData()->GetDocument(); >- if (pDoc) >- { >- rtl::OUString sCaptionShape(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.CaptionShape")); >- awt::Point aPoint(xShape->getPosition()); >- awt::Size aSize(xShape->getSize()); >- rtl::OUString sType(xShape->getShapeType()); >- Rectangle aRectangle(aPoint.X, aPoint.Y, aPoint.X + aSize.Width, aPoint.Y + aSize.Height); >- if ( sType.equals(sCaptionShape) ) >- { >- awt::Point aRelativeCaptionPoint; >- rtl::OUString sCaptionPoint( RTL_CONSTASCII_USTRINGPARAM( "CaptionPoint" )); >- xShapeProp->getPropertyValue( sCaptionPoint ) >>= aRelativeCaptionPoint; >- Point aCoreRelativeCaptionPoint(aRelativeCaptionPoint.X, aRelativeCaptionPoint.Y); >- Point aCoreAbsoluteCaptionPoint(aPoint.X, aPoint.Y); >- aCoreAbsoluteCaptionPoint += aCoreRelativeCaptionPoint; >- aRectangle.Union(Rectangle(aCoreAbsoluteCaptionPoint, aCoreAbsoluteCaptionPoint)); >- } >- ScRange aRange = pDoc->GetRange(mpAccessibleDocument->getVisibleTable(), aRectangle); >- pAddress = new ScAddress(aRange.aStart); >- } >- } >-// else >-// do nothing, because it is always a NULL Pointer >+ if (ScDrawObjData *pAnchor = ScDrawLayer::GetObjData(pSdrObj)) >+ return new ScAddress(pAnchor->maStart); > } > } > } >diff --git a/sc/source/ui/drawfunc/drawsh2.cxx b/sc/source/ui/drawfunc/drawsh2.cxx >index b32bc7a..5f61794 100644 >--- a/sc/source/ui/drawfunc/drawsh2.cxx >+++ b/sc/source/ui/drawfunc/drawsh2.cxx >@@ -113,7 +113,7 @@ void ScDrawShell::GetState( SfxItemSet& rSet ) // Zustaende / Toggles > > if ( !bDisableAnchor ) > { >- switch( pView->GetAnchor() ) >+ switch( pView->GetAnchorType() ) > { > case SCA_PAGE: > rSet.Put( SfxBoolItem( SID_ANCHOR_PAGE, TRUE ) ); >diff --git a/sc/source/ui/drawfunc/drawsh5.cxx b/sc/source/ui/drawfunc/drawsh5.cxx >index 04c9a75..1466ba4 100644 >--- a/sc/source/ui/drawfunc/drawsh5.cxx >+++ b/sc/source/ui/drawfunc/drawsh5.cxx >@@ -385,26 +385,26 @@ void ScDrawShell::ExecDrawFunc( SfxRequest& rReq ) > break; > > case SID_ANCHOR_PAGE: >- pView->SetAnchor( SCA_PAGE ); >+ pView->SetPageAnchored(); > rBindings.Invalidate( SID_ANCHOR_PAGE ); > rBindings.Invalidate( SID_ANCHOR_CELL ); > break; > > case SID_ANCHOR_CELL: >- pView->SetAnchor( SCA_CELL ); >+ pView->SetCellAnchored(); > rBindings.Invalidate( SID_ANCHOR_PAGE ); > rBindings.Invalidate( SID_ANCHOR_CELL ); > break; > > case SID_ANCHOR_TOGGLE: > { >- switch( pView->GetAnchor() ) >+ switch( pView->GetAnchorType() ) > { > case SCA_CELL: >- pView->SetAnchor( SCA_PAGE ); >+ pView->SetPageAnchored(); > break; > default: >- pView->SetAnchor( SCA_CELL ); >+ pView->SetCellAnchored(); > break; > } > } >diff --git a/sc/source/ui/inc/drawview.hxx b/sc/source/ui/inc/drawview.hxx >index d11979e..be375ce 100644 >--- a/sc/source/ui/inc/drawview.hxx >+++ b/sc/source/ui/inc/drawview.hxx >@@ -93,8 +93,9 @@ public: > > void CalcNormScale( Fraction& rFractX, Fraction& rFractY ) const; > >- void SetAnchor( ScAnchorType ); >- ScAnchorType GetAnchor() const; >+ void SetPageAnchored(); >+ void SetCellAnchored(); >+ ScAnchorType GetAnchorType() const; > > void VCAddWin( Window* pWin ); > void VCRemoveWin( Window* pWin ); >diff --git a/sc/source/ui/unoobj/shapeuno.cxx b/sc/source/ui/unoobj/shapeuno.cxx >index ef0598b..be68c66 100644 >--- a/sc/source/ui/unoobj/shapeuno.cxx >+++ b/sc/source/ui/unoobj/shapeuno.cxx >@@ -387,20 +387,9 @@ void SAL_CALL ScShapeObj::setPropertyValue( > table::CellRangeAddress aAddress = xRangeAdd->getRangeAddress(); > if (nTab == aAddress.Sheet) > { >- if (aAddress.StartRow != aAddress.EndRow) //should be a Spreadsheet >- { >- DBG_ASSERT(aAddress.StartRow == 0 && aAddress.EndRow == MAXROW && >- aAddress.StartColumn == 0 && aAddress.EndColumn == MAXCOL, "here should be a XSpreadsheet"); >- ScDrawLayer::SetAnchor(pObj, SCA_PAGE); >- } >- else >- { >- DBG_ASSERT(aAddress.StartRow == aAddress.EndRow && >- aAddress.StartColumn == aAddress.EndColumn, "here should be a XCell"); >- ScDrawLayer::SetAnchor(pObj, SCA_CELL); >- } > Rectangle aRect(pDoc->GetMMRect( static_cast<SCCOL>(aAddress.StartColumn), static_cast<SCROW>(aAddress.StartRow), > static_cast<SCCOL>(aAddress.EndColumn), static_cast<SCROW>(aAddress.EndRow), aAddress.Sheet )); >+ awt::Point aRelPoint; > uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY ); > if (xShape.is()) > { >@@ -419,7 +408,8 @@ void SAL_CALL ScShapeObj::setPropertyValue( > awt::Size aUnoSize; > awt::Point aCaptionPoint; > ScRange aRange; >- awt::Point aUnoPoint(lcl_GetRelativePos( xShape, pDoc, nTab, aRange, aUnoSize, aCaptionPoint )); >+ aRelPoint = lcl_GetRelativePos( xShape, pDoc, nTab, aRange, aUnoSize, aCaptionPoint ); >+ awt::Point aUnoPoint(aRelPoint); > > aUnoPoint.X += aPoint.X(); > aUnoPoint.Y += aPoint.Y(); >@@ -448,6 +438,24 @@ void SAL_CALL ScShapeObj::setPropertyValue( > xShape->setPosition(aUnoPoint); > pDocSh->SetModified(); > } >+ >+ if (aAddress.StartRow != aAddress.EndRow) //should be a Spreadsheet >+ { >+ DBG_ASSERT(aAddress.StartRow == 0 && aAddress.EndRow == MAXROW && >+ aAddress.StartColumn == 0 && aAddress.EndColumn == MAXCOL, "here should be a XSpreadsheet"); >+ ScDrawLayer::SetPageAnchored(*pObj); >+ } >+ else >+ { >+ DBG_ASSERT(aAddress.StartRow == aAddress.EndRow && >+ aAddress.StartColumn == aAddress.EndColumn, "here should be a XCell"); >+ ScDrawObjData aAnchor; >+ aAnchor.maStart = ScAddress(aAddress.StartColumn, aAddress.StartRow, aAddress.Sheet); >+ aAnchor.maStartOffset = Point(aRelPoint.X, aRelPoint.Y); >+ ScDrawLayer::SetCellAnchored(*pObj, aAnchor); >+ //Currently we've only got a start anchor, not an end-anchor, so generate that now >+ ScDrawLayer::UpdateCellAnchorFromPositionEnd(*pObj, *pDoc, aAddress.Sheet); >+ } > } > } > } >@@ -507,7 +515,7 @@ void SAL_CALL ScShapeObj::setPropertyValue( > uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY ); > if (xShape.is()) > { >- if (ScDrawLayer::GetAnchor(pObj) == SCA_PAGE) >+ if (ScDrawLayer::GetAnchorType(*pObj) == SCA_PAGE) > { > awt::Point aPoint(xShape->getPosition()); > awt::Size aSize(xShape->getSize()); >@@ -534,7 +542,7 @@ void SAL_CALL ScShapeObj::setPropertyValue( > xShape->setPosition(aPoint); > pDocSh->SetModified(); > } >- else if (ScDrawLayer::GetAnchor(pObj) == SCA_CELL) >+ else if (ScDrawLayer::GetAnchorType(*pObj) == SCA_CELL) > { > awt::Size aUnoSize; > awt::Point aCaptionPoint; >@@ -605,7 +613,7 @@ void SAL_CALL ScShapeObj::setPropertyValue( > uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY ); > if (xShape.is()) > { >- if (ScDrawLayer::GetAnchor(pObj) == SCA_PAGE) >+ if (ScDrawLayer::GetAnchorType(*pObj) == SCA_PAGE) > { > awt::Point aPoint = xShape->getPosition(); > awt::Point aCaptionPoint; >@@ -618,7 +626,7 @@ void SAL_CALL ScShapeObj::setPropertyValue( > xShape->setPosition(aPoint); > pDocSh->SetModified(); > } >- else if (ScDrawLayer::GetAnchor(pObj) == SCA_CELL) >+ else if (ScDrawLayer::GetAnchorType(*pObj) == SCA_CELL) > { > awt::Size aUnoSize; > awt::Point aCaptionPoint; >@@ -702,23 +710,10 @@ uno::Any SAL_CALL ScShapeObj::getPropertyValue( const rtl::OUString& aPropertyNa > { > ScDocShell* pDocSh = (ScDocShell*)pObjSh; > uno::Reference< uno::XInterface > xAnchor; >- if (ScDrawLayer::GetAnchor(pObj) == SCA_CELL) >- { >- uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY ); >- if (xShape.is()) >- { >- awt::Size aUnoSize; >- awt::Point aCaptionPoint; >- ScRange aRange; >- awt::Point aUnoPoint(lcl_GetRelativePos( xShape, pDoc, nTab, aRange, aUnoSize, aCaptionPoint )); >- >- xAnchor.set(static_cast<cppu::OWeakObject*>(new ScCellObj( pDocSh, aRange.aStart ))); >- } >- } >+ if (ScDrawObjData *pAnchor = ScDrawLayer::GetObjDataTab(pObj, nTab)) >+ xAnchor.set(static_cast<cppu::OWeakObject*>(new ScCellObj( pDocSh, pAnchor->maStart))); > else >- { > xAnchor.set(static_cast<cppu::OWeakObject*>(new ScTableSheetObj( pDocSh, nTab ))); >- } > aAny <<= xAnchor; > } > } >@@ -761,7 +756,7 @@ uno::Any SAL_CALL ScShapeObj::getPropertyValue( const rtl::OUString& aPropertyNa > uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY ); > if (xShape.is()) > { >- if (ScDrawLayer::GetAnchor(pObj) == SCA_CELL) >+ if (ScDrawLayer::GetAnchorType(*pObj) == SCA_CELL) > { > awt::Size aUnoSize; > awt::Point aCaptionPoint; >@@ -821,7 +816,7 @@ uno::Any SAL_CALL ScShapeObj::getPropertyValue( const rtl::OUString& aPropertyNa > if (xShape.is()) > { > uno::Reference< uno::XInterface > xAnchor; >- if (ScDrawLayer::GetAnchor(pObj) == SCA_CELL) >+ if (ScDrawLayer::GetAnchorType(*pObj) == SCA_CELL) > { > awt::Size aUnoSize; > awt::Point aCaptionPoint; >diff --git a/sc/source/ui/view/drawvie3.cxx b/sc/source/ui/view/drawvie3.cxx >index 8d111af..9cecb0c 100644 >--- a/sc/source/ui/view/drawvie3.cxx >+++ b/sc/source/ui/view/drawvie3.cxx >@@ -74,7 +74,7 @@ ScDrawView::ScDrawView( OutputDevice* pOut, ScViewData* pData ) : > > // Verankerung setzen > >-void ScDrawView::SetAnchor( ScAnchorType eType ) >+void ScDrawView::SetPageAnchored() > { > SdrObject* pObj = NULL; > if( AreObjectsMarked() ) >@@ -84,7 +84,7 @@ void ScDrawView::SetAnchor( ScAnchorType eType ) > for( ULONG i=0; i<nCount; i++ ) > { > pObj = pMark->GetMark(i)->GetMarkedSdrObj(); >- ScDrawLayer::SetAnchor( pObj, eType ); >+ ScDrawLayer::SetPageAnchored( *pObj ); > } > > if ( pViewData ) >@@ -92,7 +92,28 @@ void ScDrawView::SetAnchor( ScAnchorType eType ) > } > } > >-ScAnchorType ScDrawView::GetAnchor() const >+void ScDrawView::SetCellAnchored() >+{ >+ if (!pDoc) >+ return; >+ >+ SdrObject* pObj = NULL; >+ if( AreObjectsMarked() ) >+ { >+ const SdrMarkList* pMark = &GetMarkedObjectList(); >+ ULONG nCount = pMark->GetMarkCount(); >+ for( ULONG i=0; i<nCount; i++ ) >+ { >+ pObj = pMark->GetMark(i)->GetMarkedSdrObj(); >+ ScDrawLayer::SetCellAnchoredFromPosition(*pObj, *pDoc, nTab); >+ } >+ >+ if ( pViewData ) >+ pViewData->GetDocShell()->SetDrawModified(); >+ } >+} >+ >+ScAnchorType ScDrawView::GetAnchorType() const > { > BOOL bPage = FALSE; > BOOL bCell = FALSE; >@@ -105,7 +126,7 @@ ScAnchorType ScDrawView::GetAnchor() const > for( ULONG i=0; i<nCount; i++ ) > { > pObj = pMark->GetMark(i)->GetMarkedSdrObj(); >- if( ScDrawLayer::GetAnchor( pObj ) == SCA_CELL ) >+ if( ScDrawLayer::GetAnchorType( *pObj ) == SCA_CELL ) > bCell =TRUE; > else > bPage = TRUE; >@@ -135,6 +156,20 @@ void ScDrawView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) > if ( nTab == ((ScTabSizeChangedHint&)rHint).GetTab() ) > UpdateWorkArea(); > } >+ else if ( rHint.ISA( SdrHint ) ) >+ { >+ if (const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint )) >+ { >+ //Update the anchors of any non note object that is cell anchored which has >+ //been moved since the last anchors for its position was calculated >+ if (pSdrHint->GetKind() == HINT_OBJCHG || pSdrHint->GetKind() == HINT_OBJINSERTED) >+ if (SdrObject* pObj = const_cast<SdrObject*>(pSdrHint->GetObject())) >+ if (ScDrawObjData *pAnchor = ScDrawLayer::GetObjData(pObj)) >+ if (!pAnchor->mbNote && pAnchor->maLastRect != pObj->GetLogicRect()) >+ ScDrawLayer::SetCellAnchoredFromPosition(*pObj, *pDoc, nTab); >+ } >+ FmFormView::Notify( rBC,rHint ); >+ } > else > FmFormView::Notify( rBC,rHint ); > } >diff --git a/sc/source/ui/view/drawview.cxx b/sc/source/ui/view/drawview.cxx >index 875ccec..33f34c2 100644 >--- a/sc/source/ui/view/drawview.cxx >+++ b/sc/source/ui/view/drawview.cxx >@@ -155,46 +155,15 @@ ScDrawView::~ScDrawView() > > void ScDrawView::AddCustomHdl() > { >- BOOL bNegativePage = pDoc->IsNegativePage( nTab ); >- > const SdrMarkList &rMrkList = GetMarkedObjectList(); > UINT32 nCount = rMrkList.GetMarkCount(); > for(UINT32 nPos=0; nPos<nCount; nPos++ ) > { >- const SdrObject* pObj = rMrkList.GetMark(nPos)->GetMarkedSdrObj(); >- if(ScDrawLayer::GetAnchor(pObj) == SCA_CELL) >+ SdrObject* pObj = rMrkList.GetMark(nPos)->GetMarkedSdrObj(); >+ if (ScDrawObjData *pAnchor = ScDrawLayer::GetObjDataTab(pObj, nTab)) > { >- const INT32 nDelta = 1; >- >- Rectangle aBoundRect = pObj->GetCurrentBoundRect(); >- Point aPos; >- if (bNegativePage) >- { >- aPos = aBoundRect.TopRight(); >- aPos.X() = -aPos.X(); // so the loop below is the same >- } >- else >- aPos = aBoundRect.TopLeft(); >- long nPosX = (long) (aPos.X() / HMM_PER_TWIPS) + nDelta; >- long nPosY = (long) (aPos.Y() / HMM_PER_TWIPS) + nDelta; >- >- SCCOL nCol; >- INT32 nWidth = 0; >- >- for(nCol=0; nCol<=MAXCOL && nWidth<=nPosX; nCol++) >- nWidth += pDoc->GetColWidth(nCol,nTab); >- >- if(nCol > 0) >- --nCol; >- >- SCROW nRow = nPosY <= 0 ? 0 : pDoc->GetRowForHeight( nTab, >- (ULONG) nPosY); >- if(nRow > 0) >- --nRow; >- >- ScTabView* pView = pViewData->GetView(); >- ScAddress aScAddress(nCol, nRow, nTab); >- pView->CreateAnchorHandles(aHdl, aScAddress); >+ if (ScTabView* pView = pViewData->GetView()) >+ pView->CreateAnchorHandles(aHdl, pAnchor->maStart); > } > } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 33205
: 42122