| 1 |
diff -ru sc.orig/inc/document.hxx sc/inc/document.hxx
|
| 2 |
--- sc.orig/inc/document.hxx 2009-06-04 12:39:48.000000000 +0100
|
| 3 |
+++ sc/inc/document.hxx 2009-06-04 12:40:23.000000000 +0100
|
| 4 |
@@ -1319,8 +1319,8 @@
|
| 5 |
void RestorePrintRanges( const ScPrintRangeSaver& rSaver );
|
| 6 |
|
| 7 |
SC_DLLPUBLIC Rectangle GetMMRect( SCCOL nStartCol, SCROW nStartRow,
|
| 8 |
- SCCOL nEndCol, SCROW nEndRow, SCTAB nTab );
|
| 9 |
- SC_DLLPUBLIC ScRange GetRange( SCTAB nTab, const Rectangle& rMMRect );
|
| 10 |
+ SCCOL nEndCol, SCROW nEndRow, SCTAB nTab ) const;
|
| 11 |
+ SC_DLLPUBLIC ScRange GetRange( SCTAB nTab, const Rectangle& rMMRect ) const;
|
| 12 |
|
| 13 |
void UpdStlShtPtrsFrmNms();
|
| 14 |
void StylesToNames();
|
| 15 |
diff -ru sc.orig/inc/drwlayer.hxx sc/inc/drwlayer.hxx
|
| 16 |
--- sc.orig/inc/drwlayer.hxx 2009-06-04 12:39:49.000000000 +0100
|
| 17 |
+++ sc/inc/drwlayer.hxx 2009-06-04 12:40:23.000000000 +0100
|
| 18 |
@@ -110,12 +110,10 @@
|
| 19 |
BOOL bHyphenatorSet;
|
| 20 |
|
| 21 |
private:
|
| 22 |
- void MoveAreaTwips( SCTAB nTab, const Rectangle& rArea, const Point& rMove,
|
| 23 |
- const Point& rTopLeft );
|
| 24 |
void MoveCells( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCROW nRow2,
|
| 25 |
SCsCOL nDx,SCsROW nDy );
|
| 26 |
|
| 27 |
- void RecalcPos( SdrObject* pObj, const ScDrawObjData& rData, bool bNegativePage );
|
| 28 |
+ void RecalcPos( SdrObject* pObj, ScDrawObjData& rData, bool bNegativePage );
|
| 29 |
|
| 30 |
public:
|
| 31 |
ScDrawLayer( ScDocument* pDocument, const String& rName );
|
| 32 |
@@ -197,8 +195,11 @@
|
| 33 |
void EnsureGraphicNames();
|
| 34 |
|
| 35 |
// Verankerung setzen und ermitteln
|
| 36 |
- static void SetAnchor( SdrObject*, ScAnchorType );
|
| 37 |
- static ScAnchorType GetAnchor( const SdrObject* );
|
| 38 |
+ static void SetPageAnchored( SdrObject& );
|
| 39 |
+ static void SetCellAnchored( SdrObject&, const ScDrawObjData &rAnchor );
|
| 40 |
+ static void SetCellAnchoredFromPosition( SdrObject &rObj, const ScDocument &rDoc, SCTAB nTab );
|
| 41 |
+ static void UpdateCellAnchorFromPositionEnd( SdrObject &rObj, const ScDocument &rDoc, SCTAB nTab );
|
| 42 |
+ static ScAnchorType GetAnchorType( const SdrObject& );
|
| 43 |
|
| 44 |
// Positionen fuer Detektivlinien
|
| 45 |
static ScDrawObjData* GetObjData( SdrObject* pObj, BOOL bCreate=FALSE );
|
| 46 |
diff -ru sc.orig/inc/userdat.hxx sc/inc/userdat.hxx
|
| 47 |
--- sc.orig/inc/userdat.hxx 2009-06-04 12:39:49.000000000 +0100
|
| 48 |
+++ sc/inc/userdat.hxx 2009-06-04 12:40:23.000000000 +0100
|
| 49 |
@@ -63,12 +63,15 @@
|
| 50 |
public:
|
| 51 |
ScAddress maStart;
|
| 52 |
ScAddress maEnd;
|
| 53 |
+ Point maStartOffset;
|
| 54 |
+ Point maEndOffset;
|
| 55 |
bool mbNote;
|
| 56 |
+ Rectangle maLastRect;
|
| 57 |
|
| 58 |
explicit ScDrawObjData();
|
| 59 |
|
| 60 |
private:
|
| 61 |
- virtual ScDrawObjData* Clone( SdrObject* pObj ) const;
|
| 62 |
+ virtual ScDrawObjData* Clone( SdrObject* pObj ) const;
|
| 63 |
};
|
| 64 |
|
| 65 |
//-------------------------------------------------------------------------
|
| 66 |
diff -ru sc.orig/source/core/data/documen3.cxx sc/source/core/data/documen3.cxx
|
| 67 |
--- sc.orig/source/core/data/documen3.cxx 2009-06-04 12:39:09.000000000 +0100
|
| 68 |
+++ sc/source/core/data/documen3.cxx 2009-06-04 12:40:23.000000000 +0100
|
| 69 |
@@ -1510,7 +1510,7 @@
|
| 70 |
aEmbedRange = ScRange();
|
| 71 |
}
|
| 72 |
|
| 73 |
-ScRange ScDocument::GetRange( SCTAB nTab, const Rectangle& rMMRect )
|
| 74 |
+ScRange ScDocument::GetRange( SCTAB nTab, const Rectangle& rMMRect ) const
|
| 75 |
{
|
| 76 |
ScTable* pTable = pTab[nTab];
|
| 77 |
if (!pTable)
|
| 78 |
@@ -1801,7 +1801,7 @@
|
| 79 |
}
|
| 80 |
|
| 81 |
Rectangle ScDocument::GetMMRect( SCCOL nStartCol, SCROW nStartRow,
|
| 82 |
- SCCOL nEndCol, SCROW nEndRow, SCTAB nTab )
|
| 83 |
+ SCCOL nEndCol, SCROW nEndRow, SCTAB nTab ) const
|
| 84 |
{
|
| 85 |
if (!ValidTab(nTab) || !pTab[nTab])
|
| 86 |
{
|
| 87 |
diff -ru sc.orig/source/core/data/drwlayer.cxx sc/source/core/data/drwlayer.cxx
|
| 88 |
--- sc.orig/source/core/data/drwlayer.cxx 2009-06-04 12:39:09.000000000 +0100
|
| 89 |
+++ sc/source/core/data/drwlayer.cxx 2009-06-05 12:28:12.000000000 +0100
|
| 90 |
@@ -70,6 +70,9 @@
|
| 91 |
#include <vcl/svapp.hxx>
|
| 92 |
#include <unotools/ucbstreamhelper.hxx>
|
| 93 |
|
| 94 |
+#include <basegfx/polygon/b2dpolygon.hxx>
|
| 95 |
+#include <basegfx/polygon/b2dpolygontools.hxx>
|
| 96 |
+
|
| 97 |
#include "drwlayer.hxx"
|
| 98 |
#include "drawpage.hxx"
|
| 99 |
#include "global.hxx"
|
| 100 |
@@ -527,7 +530,41 @@
|
| 101 |
}
|
| 102 |
}
|
| 103 |
|
| 104 |
-void ScDrawLayer::RecalcPos( SdrObject* pObj, const ScDrawObjData& rData, bool bNegativePage )
|
| 105 |
+namespace
|
| 106 |
+{
|
| 107 |
+ //Can't have a zero width dimension
|
| 108 |
+ Rectangle lcl_makeSafeRectangle(const Rectangle &rNew)
|
| 109 |
+ {
|
| 110 |
+ Rectangle aRect = rNew;
|
| 111 |
+ if (aRect.Bottom() == aRect.Top())
|
| 112 |
+ aRect.Bottom() = aRect.Top()+1;
|
| 113 |
+ if (aRect.Right() == aRect.Left())
|
| 114 |
+ aRect.Right() = aRect.Left()+1;
|
| 115 |
+ return aRect;
|
| 116 |
+ }
|
| 117 |
+
|
| 118 |
+ Point lcl_calcAvailableDiff(ScDocument &rDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, const Point &aWantedDiff)
|
| 119 |
+ {
|
| 120 |
+ Point aAvailableDiff(aWantedDiff);
|
| 121 |
+ long nHeight = rDoc.GetRowHeight( nRow, nTab ) * HMM_PER_TWIPS;
|
| 122 |
+ long nWidth = rDoc.GetColWidth( nCol, nTab ) * HMM_PER_TWIPS;
|
| 123 |
+ if (aAvailableDiff.Y() > nHeight)
|
| 124 |
+ aAvailableDiff.Y() = nHeight;
|
| 125 |
+ if (aAvailableDiff.X() > nWidth)
|
| 126 |
+ aAvailableDiff.X() = nWidth;
|
| 127 |
+ return aAvailableDiff;
|
| 128 |
+ }
|
| 129 |
+
|
| 130 |
+ Rectangle lcl_UpdateCalcPoly(basegfx::B2DPolygon &rCalcPoly, int nWhichPoint, const Point &rPos)
|
| 131 |
+ {
|
| 132 |
+ rCalcPoly.setB2DPoint(nWhichPoint, basegfx::B2DPoint(rPos.X(), rPos.Y()));
|
| 133 |
+ basegfx::B2DRange aRange(basegfx::tools::getRange(rCalcPoly));
|
| 134 |
+ return Rectangle(aRange.getMinX(), aRange.getMinY(),
|
| 135 |
+ aRange.getMaxX(), aRange.getMaxY());
|
| 136 |
+ }
|
| 137 |
+}
|
| 138 |
+
|
| 139 |
+void ScDrawLayer::RecalcPos( SdrObject* pObj, ScDrawObjData& rData, bool bNegativePage )
|
| 140 |
{
|
| 141 |
DBG_ASSERT( pDoc, "ScDrawLayer::RecalcPos - missing document" );
|
| 142 |
if( !pDoc )
|
| 143 |
@@ -569,6 +606,8 @@
|
| 144 |
|
| 145 |
if( bCircle )
|
| 146 |
{
|
| 147 |
+ rData.maLastRect = pObj->GetLogicRect();
|
| 148 |
+
|
| 149 |
Point aPos( pDoc->GetColOffset( nCol1, nTab1 ), pDoc->GetRowOffset( nRow1, nTab1 ) );
|
| 150 |
TwipsToMM( aPos.X() );
|
| 151 |
TwipsToMM( aPos.Y() );
|
| 152 |
@@ -589,11 +628,18 @@
|
| 153 |
{
|
| 154 |
if (bRecording)
|
| 155 |
AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
|
| 156 |
- pObj->SetLogicRect(aRect);
|
| 157 |
+ rData.maLastRect = lcl_makeSafeRectangle(aRect);
|
| 158 |
+ pObj->SetLogicRect(rData.maLastRect);
|
| 159 |
}
|
| 160 |
}
|
| 161 |
else if( bArrow )
|
| 162 |
{
|
| 163 |
+ rData.maLastRect = pObj->GetLogicRect();
|
| 164 |
+ basegfx::B2DPolygon aCalcPoly;
|
| 165 |
+ Point aOrigStartPos(pObj->GetPoint(0));
|
| 166 |
+ Point aOrigEndPos(pObj->GetPoint(1));
|
| 167 |
+ aCalcPoly.append(basegfx::B2DPoint(aOrigStartPos.X(), aOrigStartPos.Y()));
|
| 168 |
+ aCalcPoly.append(basegfx::B2DPoint(aOrigEndPos.X(), aOrigEndPos.Y()));
|
| 169 |
//! nicht mehrere Undos fuer ein Objekt erzeugen (hinteres kann dann weggelassen werden)
|
| 170 |
|
| 171 |
if( bValid1 )
|
| 172 |
@@ -612,6 +658,8 @@
|
| 173 |
{
|
| 174 |
if (bRecording)
|
| 175 |
AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
|
| 176 |
+
|
| 177 |
+ rData.maLastRect = lcl_UpdateCalcPoly(aCalcPoly, 0, aStartPos);
|
| 178 |
pObj->SetPoint( aStartPos, 0 );
|
| 179 |
}
|
| 180 |
|
| 181 |
@@ -626,6 +674,8 @@
|
| 182 |
{
|
| 183 |
if (bRecording)
|
| 184 |
AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
|
| 185 |
+
|
| 186 |
+ rData.maLastRect = lcl_UpdateCalcPoly(aCalcPoly, 1, aEndPos);
|
| 187 |
pObj->SetPoint( aEndPos, 1 );
|
| 188 |
}
|
| 189 |
}
|
| 190 |
@@ -646,6 +696,8 @@
|
| 191 |
{
|
| 192 |
if (bRecording)
|
| 193 |
AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
|
| 194 |
+
|
| 195 |
+ rData.maLastRect = lcl_UpdateCalcPoly(aCalcPoly, 1, aEndPos);
|
| 196 |
pObj->SetPoint( aEndPos, 1 );
|
| 197 |
}
|
| 198 |
|
| 199 |
@@ -662,45 +714,68 @@
|
| 200 |
{
|
| 201 |
if (bRecording)
|
| 202 |
AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
|
| 203 |
+
|
| 204 |
+ rData.maLastRect = lcl_UpdateCalcPoly(aCalcPoly, 0, aStartPos);
|
| 205 |
pObj->SetPoint( aStartPos, 0 );
|
| 206 |
}
|
| 207 |
}
|
| 208 |
}
|
| 209 |
}
|
| 210 |
- else // Referenz-Rahmen
|
| 211 |
+ else
|
| 212 |
{
|
| 213 |
+ bool bCanResize = bValid2 && !pObj->IsResizeProtect();
|
| 214 |
+
|
| 215 |
+ //First time positioning, must be able to at least move it
|
| 216 |
+ if (rData.maLastRect.IsEmpty())
|
| 217 |
+ rData.maLastRect = pObj->GetLogicRect();
|
| 218 |
+
|
| 219 |
DBG_ASSERT( bValid1, "ScDrawLayer::RecalcPos - invalid start position" );
|
| 220 |
Point aPos( pDoc->GetColOffset( nCol1, nTab1 ), pDoc->GetRowOffset( nRow1, nTab1 ) );
|
| 221 |
TwipsToMM( aPos.X() );
|
| 222 |
TwipsToMM( aPos.Y() );
|
| 223 |
+ aPos += lcl_calcAvailableDiff(*pDoc, nCol1, nRow1, nTab1, rData.maStartOffset);
|
| 224 |
|
| 225 |
- if( bValid2 )
|
| 226 |
+ if( bCanResize )
|
| 227 |
{
|
| 228 |
- Point aEnd( pDoc->GetColOffset( nCol2 + 1, nTab2 ), pDoc->GetRowOffset( nRow2 + 1, nTab2 ) );
|
| 229 |
+ Point aEnd( pDoc->GetColOffset( nCol2, nTab2 ), pDoc->GetRowOffset( nRow2, nTab2 ) );
|
| 230 |
TwipsToMM( aEnd.X() );
|
| 231 |
TwipsToMM( aEnd.Y() );
|
| 232 |
+ aEnd += lcl_calcAvailableDiff(*pDoc, nCol2, nRow2, nTab2, rData.maEndOffset);
|
| 233 |
|
| 234 |
Rectangle aNew( aPos, aEnd );
|
| 235 |
if ( bNegativePage )
|
| 236 |
MirrorRectRTL( aNew );
|
| 237 |
if ( pObj->GetLogicRect() != aNew )
|
| 238 |
{
|
| 239 |
+ Rectangle aOld(pObj->GetLogicRect());
|
| 240 |
+
|
| 241 |
if (bRecording)
|
| 242 |
AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
|
| 243 |
- pObj->SetLogicRect(aNew);
|
| 244 |
+ rData.maLastRect = lcl_makeSafeRectangle(aNew);
|
| 245 |
+ pObj->SetLogicRect(rData.maLastRect);
|
| 246 |
}
|
| 247 |
}
|
| 248 |
else
|
| 249 |
{
|
| 250 |
if ( bNegativePage )
|
| 251 |
- aPos.X() = -aPos.X();
|
| 252 |
+ aPos.X() = -aPos.X() - rData.maLastRect.GetWidth();
|
| 253 |
if ( pObj->GetRelativePos() != aPos )
|
| 254 |
{
|
| 255 |
if (bRecording)
|
| 256 |
AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
|
| 257 |
+ rData.maLastRect.SetPos( aPos );
|
| 258 |
pObj->SetRelativePos( aPos );
|
| 259 |
}
|
| 260 |
}
|
| 261 |
+
|
| 262 |
+ /*
|
| 263 |
+ * If we were not allowed resize the object, then the end cell anchor
|
| 264 |
+ * is possibly incorrect now, and if the object has no end-cell (e.g.
|
| 265 |
+ * missing in original .xml) we are also forced to generate one
|
| 266 |
+ */
|
| 267 |
+ bool bEndAnchorIsBad = !bValid2 || pObj->IsResizeProtect();
|
| 268 |
+ if (bEndAnchorIsBad)
|
| 269 |
+ ScDrawLayer::UpdateCellAnchorFromPositionEnd(*pObj, *pDoc, nTab1);
|
| 270 |
}
|
| 271 |
}
|
| 272 |
|
| 273 |
@@ -875,151 +950,6 @@
|
| 274 |
return pRet;
|
| 275 |
}
|
| 276 |
|
| 277 |
-// MoveAreaTwips: all measures are kept in twips
|
| 278 |
-void ScDrawLayer::MoveAreaTwips( SCTAB nTab, const Rectangle& rArea,
|
| 279 |
- const Point& rMove, const Point& rTopLeft )
|
| 280 |
-{
|
| 281 |
- if (!rMove.X() && !rMove.Y())
|
| 282 |
- return; // nix
|
| 283 |
-
|
| 284 |
- SdrPage* pPage = GetPage(static_cast<sal_uInt16>(nTab));
|
| 285 |
- DBG_ASSERT(pPage,"Page nicht gefunden");
|
| 286 |
- if (!pPage)
|
| 287 |
- return;
|
| 288 |
-
|
| 289 |
- BOOL bNegativePage = pDoc && pDoc->IsNegativePage( nTab );
|
| 290 |
-
|
| 291 |
- // fuer Shrinking!
|
| 292 |
- Rectangle aNew( rArea );
|
| 293 |
- BOOL bShrink = FALSE;
|
| 294 |
- if ( rMove.X() < 0 || rMove.Y() < 0 ) // verkleinern
|
| 295 |
- {
|
| 296 |
- if ( rTopLeft != rArea.TopLeft() ) // sind gleich beim Verschieben von Zellen
|
| 297 |
- {
|
| 298 |
- bShrink = TRUE;
|
| 299 |
- aNew.Left() = rTopLeft.X();
|
| 300 |
- aNew.Top() = rTopLeft.Y();
|
| 301 |
- }
|
| 302 |
- }
|
| 303 |
- SdrObjListIter aIter( *pPage, IM_FLAT );
|
| 304 |
- SdrObject* pObject = aIter.Next();
|
| 305 |
- while (pObject)
|
| 306 |
- {
|
| 307 |
- if( GetAnchor( pObject ) == SCA_CELL )
|
| 308 |
- {
|
| 309 |
- if ( GetObjData( pObject ) ) // Detektiv-Pfeil ?
|
| 310 |
- {
|
| 311 |
- // hier nichts
|
| 312 |
- }
|
| 313 |
- else if ( pObject->ISA( SdrEdgeObj ) ) // Verbinder?
|
| 314 |
- {
|
| 315 |
- // hier auch nichts
|
| 316 |
- //! nicht verbundene Enden wie bei Linien (s.u.) behandeln?
|
| 317 |
- }
|
| 318 |
- else if ( pObject->IsPolyObj() && pObject->GetPointCount()==2 )
|
| 319 |
- {
|
| 320 |
- for (USHORT i=0; i<2; i++)
|
| 321 |
- {
|
| 322 |
- BOOL bMoved = FALSE;
|
| 323 |
- Point aPoint = pObject->GetPoint(i);
|
| 324 |
- lcl_ReverseTwipsToMM( aPoint );
|
| 325 |
- if (rArea.IsInside(aPoint))
|
| 326 |
- {
|
| 327 |
- aPoint += rMove; bMoved = TRUE;
|
| 328 |
- }
|
| 329 |
- else if (bShrink && aNew.IsInside(aPoint))
|
| 330 |
- {
|
| 331 |
- // Punkt ist in betroffener Zelle - Test auf geloeschten Bereich
|
| 332 |
- if ( rMove.X() && aPoint.X() >= rArea.Left() + rMove.X() )
|
| 333 |
- {
|
| 334 |
- aPoint.X() = rArea.Left() + rMove.X() - SHRINK_DIST_TWIPS;
|
| 335 |
- if ( aPoint.X() < 0 ) aPoint.X() = 0;
|
| 336 |
- bMoved = TRUE;
|
| 337 |
- }
|
| 338 |
- if ( rMove.Y() && aPoint.Y() >= rArea.Top() + rMove.Y() )
|
| 339 |
- {
|
| 340 |
- aPoint.Y() = rArea.Top() + rMove.Y() - SHRINK_DIST_TWIPS;
|
| 341 |
- if ( aPoint.Y() < 0 ) aPoint.Y() = 0;
|
| 342 |
- bMoved = TRUE;
|
| 343 |
- }
|
| 344 |
- }
|
| 345 |
- if( bMoved )
|
| 346 |
- {
|
| 347 |
- AddCalcUndo( new SdrUndoGeoObj( *pObject ) );
|
| 348 |
- lcl_TwipsToMM( aPoint );
|
| 349 |
- pObject->SetPoint( aPoint, i );
|
| 350 |
- }
|
| 351 |
- }
|
| 352 |
- }
|
| 353 |
- else
|
| 354 |
- {
|
| 355 |
- Rectangle aObjRect = pObject->GetLogicRect();
|
| 356 |
- // aOldMMPos: not converted, millimeters
|
| 357 |
- Point aOldMMPos = bNegativePage ? aObjRect.TopRight() : aObjRect.TopLeft();
|
| 358 |
- lcl_ReverseTwipsToMM( aObjRect );
|
| 359 |
- Point aTopLeft = bNegativePage ? aObjRect.TopRight() : aObjRect.TopLeft(); // logical left
|
| 360 |
- Size aMoveSize;
|
| 361 |
- BOOL bDoMove = FALSE;
|
| 362 |
- if (rArea.IsInside(aTopLeft))
|
| 363 |
- {
|
| 364 |
- aMoveSize = Size(rMove.X(),rMove.Y());
|
| 365 |
- bDoMove = TRUE;
|
| 366 |
- }
|
| 367 |
- else if (bShrink && aNew.IsInside(aTopLeft))
|
| 368 |
- {
|
| 369 |
- // Position ist in betroffener Zelle - Test auf geloeschten Bereich
|
| 370 |
- if ( rMove.X() && aTopLeft.X() >= rArea.Left() + rMove.X() )
|
| 371 |
- {
|
| 372 |
- aMoveSize.Width() = rArea.Left() + rMove.X() - SHRINK_DIST - aTopLeft.X();
|
| 373 |
- bDoMove = TRUE;
|
| 374 |
- }
|
| 375 |
- if ( rMove.Y() && aTopLeft.Y() >= rArea.Top() + rMove.Y() )
|
| 376 |
- {
|
| 377 |
- aMoveSize.Height() = rArea.Top() + rMove.Y() - SHRINK_DIST - aTopLeft.Y();
|
| 378 |
- bDoMove = TRUE;
|
| 379 |
- }
|
| 380 |
- }
|
| 381 |
- if ( bDoMove )
|
| 382 |
- {
|
| 383 |
- if ( bNegativePage )
|
| 384 |
- {
|
| 385 |
- if ( aTopLeft.X() + aMoveSize.Width() > 0 )
|
| 386 |
- aMoveSize.Width() = -aTopLeft.X();
|
| 387 |
- }
|
| 388 |
- else
|
| 389 |
- {
|
| 390 |
- if ( aTopLeft.X() + aMoveSize.Width() < 0 )
|
| 391 |
- aMoveSize.Width() = -aTopLeft.X();
|
| 392 |
- }
|
| 393 |
- if ( aTopLeft.Y() + aMoveSize.Height() < 0 )
|
| 394 |
- aMoveSize.Height() = -aTopLeft.Y();
|
| 395 |
-
|
| 396 |
- // get corresponding move size in millimeters:
|
| 397 |
- Point aNewPos( aTopLeft.X() + aMoveSize.Width(), aTopLeft.Y() + aMoveSize.Height() );
|
| 398 |
- lcl_TwipsToMM( aNewPos );
|
| 399 |
- aMoveSize = Size( aNewPos.X() - aOldMMPos.X(), aNewPos.Y() - aOldMMPos.Y() ); // millimeters
|
| 400 |
-
|
| 401 |
- AddCalcUndo( new SdrUndoMoveObj( *pObject, aMoveSize ) );
|
| 402 |
- pObject->Move( aMoveSize );
|
| 403 |
- }
|
| 404 |
- else if ( rArea.IsInside( bNegativePage ? aObjRect.BottomLeft() : aObjRect.BottomRight() ) &&
|
| 405 |
- !pObject->IsResizeProtect() )
|
| 406 |
- {
|
| 407 |
- // geschuetzte Groessen werden nicht veraendert
|
| 408 |
- // (Positionen schon, weil sie ja an der Zelle "verankert" sind)
|
| 409 |
- AddCalcUndo( new SdrUndoGeoObj( *pObject ) );
|
| 410 |
- long nOldSizeX = aObjRect.Right() - aObjRect.Left() + 1;
|
| 411 |
- long nOldSizeY = aObjRect.Bottom() - aObjRect.Top() + 1;
|
| 412 |
- long nLogMoveX = rMove.X() * ( bNegativePage ? -1 : 1 ); // logical direction
|
| 413 |
- pObject->Resize( aOldMMPos, Fraction( nOldSizeX+nLogMoveX, nOldSizeX ),
|
| 414 |
- Fraction( nOldSizeY+rMove.Y(), nOldSizeY ) );
|
| 415 |
- }
|
| 416 |
- }
|
| 417 |
- }
|
| 418 |
- pObject = aIter.Next();
|
| 419 |
- }
|
| 420 |
-}
|
| 421 |
-
|
| 422 |
void ScDrawLayer::MoveArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCROW nRow2,
|
| 423 |
SCsCOL nDx,SCsROW nDy, BOOL bInsDel )
|
| 424 |
{
|
| 425 |
@@ -1061,11 +991,6 @@
|
| 426 |
aTopLeft.Y() += aMove.Y();
|
| 427 |
}
|
| 428 |
|
| 429 |
- // drawing objects are now directly included in cut&paste
|
| 430 |
- // -> only update references when inserting/deleting (or changing widths or heights)
|
| 431 |
- if ( bInsDel )
|
| 432 |
- MoveAreaTwips( nTab, aRect, aMove, aTopLeft );
|
| 433 |
-
|
| 434 |
//
|
| 435 |
// Detektiv-Pfeile: Zellpositionen anpassen
|
| 436 |
//
|
| 437 |
@@ -1103,8 +1028,6 @@
|
| 438 |
aTopLeft.X() = -aTopLeft.X();
|
| 439 |
nDifTwips = -nDifTwips;
|
| 440 |
}
|
| 441 |
-
|
| 442 |
- MoveAreaTwips( nTab, aRect, Point( nDifTwips,0 ), aTopLeft );
|
| 443 |
}
|
| 444 |
|
| 445 |
void ScDrawLayer::HeightChanged( SCTAB nTab, SCROW nRow, long nDifTwips )
|
| 446 |
@@ -1135,8 +1058,6 @@
|
| 447 |
MirrorRectRTL( aRect );
|
| 448 |
aTopLeft.X() = -aTopLeft.X();
|
| 449 |
}
|
| 450 |
-
|
| 451 |
- MoveAreaTwips( nTab, aRect, Point( 0,nDifTwips ), aTopLeft );
|
| 452 |
}
|
| 453 |
|
| 454 |
BOOL ScDrawLayer::HasObjectsInRows( SCTAB nTab, SCROW nStartRow, SCROW nEndRow )
|
| 455 |
@@ -1814,35 +1735,105 @@
|
| 456 |
}
|
| 457 |
}
|
| 458 |
|
| 459 |
-void ScDrawLayer::SetAnchor( SdrObject* pObj, ScAnchorType eType )
|
| 460 |
+namespace
|
| 461 |
+{
|
| 462 |
+ SdrObjUserData* GetFirstUserDataOfType(const SdrObject *pObj, UINT16 nId)
|
| 463 |
+ {
|
| 464 |
+ USHORT nCount = pObj ? pObj->GetUserDataCount() : 0;
|
| 465 |
+ for( USHORT i = 0; i < nCount; i++ )
|
| 466 |
+ {
|
| 467 |
+ SdrObjUserData* pData = pObj->GetUserData( i );
|
| 468 |
+ if( pData && pData->GetInventor() == SC_DRAWLAYER && pData->GetId() == nId )
|
| 469 |
+ return pData;
|
| 470 |
+ }
|
| 471 |
+ return NULL;
|
| 472 |
+ }
|
| 473 |
+
|
| 474 |
+ void DeleteFirstUserDataOfType(SdrObject *pObj, UINT16 nId)
|
| 475 |
+ {
|
| 476 |
+ USHORT nCount = pObj ? pObj->GetUserDataCount() : 0;
|
| 477 |
+ for( USHORT i = nCount; i > 0; i-- )
|
| 478 |
+ {
|
| 479 |
+ SdrObjUserData* pData = pObj->GetUserData( i-1 );
|
| 480 |
+ if( pData && pData->GetInventor() == SC_DRAWLAYER && pData->GetId() == nId )
|
| 481 |
+ pObj->DeleteUserData(i-1);
|
| 482 |
+ }
|
| 483 |
+ }
|
| 484 |
+}
|
| 485 |
+
|
| 486 |
+void ScDrawLayer::SetCellAnchored( SdrObject &rObj, const ScDrawObjData &rAnchor )
|
| 487 |
+{
|
| 488 |
+ ScDrawObjData* pAnchor = GetObjData( &rObj, true );
|
| 489 |
+ pAnchor->maStart = rAnchor.maStart;
|
| 490 |
+ pAnchor->maEnd = rAnchor.maEnd;
|
| 491 |
+ pAnchor->maStartOffset = rAnchor.maStartOffset;
|
| 492 |
+ pAnchor->maEndOffset = rAnchor.maEndOffset;
|
| 493 |
+}
|
| 494 |
+
|
| 495 |
+void ScDrawLayer::SetCellAnchoredFromPosition( SdrObject &rObj, const ScDocument &rDoc, SCTAB nTab )
|
| 496 |
+{
|
| 497 |
+ Rectangle aObjRect(rObj.GetLogicRect());
|
| 498 |
+ ScRange aRange = rDoc.GetRange( nTab, aObjRect );
|
| 499 |
+
|
| 500 |
+ Rectangle aCellRect;
|
| 501 |
+
|
| 502 |
+ ScDrawObjData aAnchor;
|
| 503 |
+ aAnchor.maStart = aRange.aStart;
|
| 504 |
+ aCellRect = rDoc.GetMMRect( aRange.aStart.Col(), aRange.aStart.Row(),
|
| 505 |
+ aRange.aStart.Col(), aRange.aStart.Row(), aRange.aStart.Tab() );
|
| 506 |
+ aAnchor.maStartOffset.Y() = aObjRect.Top()-aCellRect.Top();
|
| 507 |
+ if (!rDoc.IsNegativePage(nTab))
|
| 508 |
+ aAnchor.maStartOffset.X() = aObjRect.Left()-aCellRect.Left();
|
| 509 |
+ else
|
| 510 |
+ aAnchor.maStartOffset.X() = aCellRect.Right()-aObjRect.Right();
|
| 511 |
+
|
| 512 |
+ aAnchor.maEnd = aRange.aEnd;
|
| 513 |
+ aCellRect = rDoc.GetMMRect( aRange.aEnd.Col(), aRange.aEnd.Row(),
|
| 514 |
+ aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aEnd.Tab() );
|
| 515 |
+ aAnchor.maEndOffset.Y() = aObjRect.Bottom()-aCellRect.Top();
|
| 516 |
+ if (!rDoc.IsNegativePage(nTab))
|
| 517 |
+ aAnchor.maEndOffset.X() = aObjRect.Right()-aCellRect.Left();
|
| 518 |
+ else
|
| 519 |
+ aAnchor.maEndOffset.X() = aCellRect.Right()-aObjRect.Left();
|
| 520 |
+
|
| 521 |
+ SetCellAnchored( rObj, aAnchor );
|
| 522 |
+}
|
| 523 |
+
|
| 524 |
+void ScDrawLayer::UpdateCellAnchorFromPositionEnd( SdrObject &rObj, const ScDocument &rDoc, SCTAB nTab )
|
| 525 |
{
|
| 526 |
- ScAnchorType eOldAnchorType = GetAnchor( pObj );
|
| 527 |
+ Rectangle aObjRect(rObj.GetLogicRect());
|
| 528 |
+ ScRange aRange = rDoc.GetRange( nTab, aObjRect );
|
| 529 |
|
| 530 |
- // Ein an der Seite verankertes Objekt zeichnet sich durch eine Anker-Pos
|
| 531 |
- // von (0,1) aus. Das ist ein shabby Trick, der aber funktioniert!
|
| 532 |
- Point aAnchor( 0, eType == SCA_PAGE ? 1 : 0 );
|
| 533 |
- pObj->SetAnchorPos( aAnchor );
|
| 534 |
+ ScDrawObjData* pAnchor = GetObjData( &rObj, true );
|
| 535 |
+ pAnchor->maEnd = aRange.aEnd;
|
| 536 |
+
|
| 537 |
+ Rectangle aCellRect;
|
| 538 |
+ aCellRect = rDoc.GetMMRect( aRange.aEnd.Col(), aRange.aEnd.Row(),
|
| 539 |
+ aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aEnd.Tab() );
|
| 540 |
+ pAnchor->maEndOffset.Y() = aObjRect.Bottom()-aCellRect.Top();
|
| 541 |
+ if (!rDoc.IsNegativePage(nTab))
|
| 542 |
+ pAnchor->maEndOffset.X() = aObjRect.Right()-aCellRect.Left();
|
| 543 |
+ else
|
| 544 |
+ pAnchor->maEndOffset.X() = aCellRect.Right()-aObjRect.Left();
|
| 545 |
+}
|
| 546 |
|
| 547 |
- if ( eOldAnchorType != eType )
|
| 548 |
- pObj->notifyShapePropertyChange( ::svx::eSpreadsheetAnchor );
|
| 549 |
+void ScDrawLayer::SetPageAnchored( SdrObject &rObj )
|
| 550 |
+{
|
| 551 |
+ DeleteFirstUserDataOfType(&rObj, SC_UD_OBJDATA);
|
| 552 |
}
|
| 553 |
|
| 554 |
-ScAnchorType ScDrawLayer::GetAnchor( const SdrObject* pObj )
|
| 555 |
+ScAnchorType ScDrawLayer::GetAnchorType( const SdrObject &rObj )
|
| 556 |
{
|
| 557 |
- Point aAnchor( pObj->GetAnchorPos() );
|
| 558 |
- return ( aAnchor.Y() != 0 ) ? SCA_PAGE : SCA_CELL;
|
| 559 |
+ //If this object has a cell anchor associated with it
|
| 560 |
+ //then its cell-anchored, otherwise its page-anchored
|
| 561 |
+ return ScDrawLayer::GetObjData(const_cast<SdrObject*>(&rObj)) ? SCA_CELL : SCA_PAGE;
|
| 562 |
}
|
| 563 |
|
| 564 |
ScDrawObjData* ScDrawLayer::GetObjData( SdrObject* pObj, BOOL bCreate ) // static
|
| 565 |
{
|
| 566 |
- USHORT nCount = pObj ? pObj->GetUserDataCount() : 0;
|
| 567 |
- for( USHORT i = 0; i < nCount; i++ )
|
| 568 |
- {
|
| 569 |
- SdrObjUserData* pData = pObj->GetUserData( i );
|
| 570 |
- if( pData && pData->GetInventor() == SC_DRAWLAYER
|
| 571 |
- && pData->GetId() == SC_UD_OBJDATA )
|
| 572 |
- return (ScDrawObjData*) pData;
|
| 573 |
- }
|
| 574 |
+ if (SdrObjUserData *pData = GetFirstUserDataOfType(pObj, SC_UD_OBJDATA))
|
| 575 |
+ return (ScDrawObjData*) pData;
|
| 576 |
+
|
| 577 |
if( pObj && bCreate )
|
| 578 |
{
|
| 579 |
ScDrawObjData* pData = new ScDrawObjData;
|
| 580 |
@@ -1879,15 +1870,7 @@
|
| 581 |
|
| 582 |
ScIMapInfo* ScDrawLayer::GetIMapInfo( SdrObject* pObj ) // static
|
| 583 |
{
|
| 584 |
- USHORT nCount = pObj->GetUserDataCount();
|
| 585 |
- for( USHORT i = 0; i < nCount; i++ )
|
| 586 |
- {
|
| 587 |
- SdrObjUserData* pData = pObj->GetUserData( i );
|
| 588 |
- if( pData && pData->GetInventor() == SC_DRAWLAYER
|
| 589 |
- && pData->GetId() == SC_UD_IMAPDATA )
|
| 590 |
- return (ScIMapInfo*) pData;
|
| 591 |
- }
|
| 592 |
- return NULL;
|
| 593 |
+ return (ScIMapInfo*)GetFirstUserDataOfType(pObj, SC_UD_IMAPDATA);
|
| 594 |
}
|
| 595 |
|
| 596 |
// static:
|
| 597 |
@@ -1940,7 +1923,7 @@
|
| 598 |
else if ( pObj->ISA( SdrOle2Obj ) ) // OLE-Objekt
|
| 599 |
{
|
| 600 |
// TODO/LEAN: working with visual area needs running state
|
| 601 |
- aGraphSize = ((SdrOle2Obj*)pObj)->GetOrigObjSize();
|
| 602 |
+ aGraphSize = ((const SdrOle2Obj*)pObj)->GetOrigObjSize();
|
| 603 |
bObjSupported = TRUE;
|
| 604 |
}
|
| 605 |
|
| 606 |
@@ -1958,14 +1941,9 @@
|
| 607 |
|
| 608 |
ScMacroInfo* ScDrawLayer::GetMacroInfo( SdrObject* pObj, BOOL bCreate ) // static
|
| 609 |
{
|
| 610 |
- USHORT nCount = pObj->GetUserDataCount();
|
| 611 |
- for( USHORT i = 0; i < nCount; i++ )
|
| 612 |
- {
|
| 613 |
- SdrObjUserData* pData = pObj->GetUserData( i );
|
| 614 |
- if( pData && pData->GetInventor() == SC_DRAWLAYER
|
| 615 |
- && pData->GetId() == SC_UD_MACRODATA )
|
| 616 |
- return (ScMacroInfo*) pData;
|
| 617 |
- }
|
| 618 |
+ if (SdrObjUserData *pData = GetFirstUserDataOfType(pObj, SC_UD_MACRODATA))
|
| 619 |
+ return (ScMacroInfo*) pData;
|
| 620 |
+
|
| 621 |
if ( bCreate )
|
| 622 |
{
|
| 623 |
ScMacroInfo* pData = new ScMacroInfo;
|
| 624 |
diff -ru sc.orig/source/core/data/postit.cxx sc/source/core/data/postit.cxx
|
| 625 |
--- sc.orig/source/core/data/postit.cxx 2009-06-04 12:39:10.000000000 +0100
|
| 626 |
+++ sc/source/core/data/postit.cxx 2009-06-04 12:40:23.000000000 +0100
|
| 627 |
@@ -102,7 +102,6 @@
|
| 628 |
|
| 629 |
void ScCaptionUtil::SetBasicCaptionSettings( SdrCaptionObj& rCaption, bool bShown )
|
| 630 |
{
|
| 631 |
- ScDrawLayer::SetAnchor( &rCaption, SCA_PAGE );
|
| 632 |
SetCaptionLayer( rCaption, bShown );
|
| 633 |
rCaption.SetFixedTail();
|
| 634 |
rCaption.SetSpecialTextBoxShadow();
|
| 635 |
diff -ru sc.orig/source/core/tool/detfunc.cxx sc/source/core/tool/detfunc.cxx
|
| 636 |
--- sc.orig/source/core/tool/detfunc.cxx 2009-06-04 12:39:11.000000000 +0100
|
| 637 |
+++ sc/source/core/tool/detfunc.cxx 2009-06-04 12:40:23.000000000 +0100
|
| 638 |
@@ -492,7 +492,6 @@
|
| 639 |
|
| 640 |
pBox->SetMergedItemSetAndBroadcast(rData.GetBoxSet());
|
| 641 |
|
| 642 |
- ScDrawLayer::SetAnchor( pBox, SCA_CELL );
|
| 643 |
pBox->SetLayer( SC_LAYER_INTERN );
|
| 644 |
pPage->InsertObject( pBox );
|
| 645 |
pModel->AddCalcUndo( new SdrUndoInsertObj( *pBox ) );
|
| 646 |
@@ -534,7 +533,6 @@
|
| 647 |
pArrow->NbcSetLogicRect(Rectangle(aStartPos,aEndPos)); //! noetig ???
|
| 648 |
pArrow->SetMergedItemSetAndBroadcast(rAttrSet);
|
| 649 |
|
| 650 |
- ScDrawLayer::SetAnchor( pArrow, SCA_CELL );
|
| 651 |
pArrow->SetLayer( SC_LAYER_INTERN );
|
| 652 |
pPage->InsertObject( pArrow );
|
| 653 |
pModel->AddCalcUndo( new SdrUndoInsertObj( *pArrow ) );
|
| 654 |
@@ -565,7 +563,6 @@
|
| 655 |
|
| 656 |
pBox->SetMergedItemSetAndBroadcast(rData.GetBoxSet());
|
| 657 |
|
| 658 |
- ScDrawLayer::SetAnchor( pBox, SCA_CELL );
|
| 659 |
pBox->SetLayer( SC_LAYER_INTERN );
|
| 660 |
pPage->InsertObject( pBox );
|
| 661 |
pModel->AddCalcUndo( new SdrUndoInsertObj( *pBox ) );
|
| 662 |
@@ -600,7 +597,6 @@
|
| 663 |
|
| 664 |
pArrow->SetMergedItemSetAndBroadcast(rAttrSet);
|
| 665 |
|
| 666 |
- ScDrawLayer::SetAnchor( pArrow, SCA_CELL );
|
| 667 |
pArrow->SetLayer( SC_LAYER_INTERN );
|
| 668 |
pPage->InsertObject( pArrow );
|
| 669 |
pModel->AddCalcUndo( new SdrUndoInsertObj( *pArrow ) );
|
| 670 |
@@ -668,7 +664,6 @@
|
| 671 |
|
| 672 |
pCircle->SetMergedItemSetAndBroadcast(rAttrSet);
|
| 673 |
|
| 674 |
- ScDrawLayer::SetAnchor( pCircle, SCA_CELL );
|
| 675 |
pCircle->SetLayer( SC_LAYER_INTERN );
|
| 676 |
pPage->InsertObject( pCircle );
|
| 677 |
pModel->AddCalcUndo( new SdrUndoInsertObj( *pCircle ) );
|
| 678 |
diff -ru sc.orig/source/filter/xml/XMLExportIterator.hxx sc/source/filter/xml/XMLExportIterator.hxx
|
| 679 |
--- sc.orig/source/filter/xml/XMLExportIterator.hxx 2009-06-04 12:39:13.000000000 +0100
|
| 680 |
+++ sc/source/filter/xml/XMLExportIterator.hxx 2009-06-04 12:40:23.000000000 +0100
|
| 681 |
@@ -72,6 +72,8 @@
|
| 682 |
{
|
| 683 |
ScAddress aAddress;
|
| 684 |
ScAddress aEndAddress;
|
| 685 |
+ sal_Int32 nEndX;
|
| 686 |
+ sal_Int32 nEndY;
|
| 687 |
com::sun::star::uno::Reference<com::sun::star::drawing::XShape> xShape;
|
| 688 |
|
| 689 |
sal_Bool operator<(const ScMyShape& aShape) const;
|
| 690 |
diff -ru sc.orig/source/filter/xml/xmlexprt.cxx sc/source/filter/xml/xmlexprt.cxx
|
| 691 |
--- sc.orig/source/filter/xml/xmlexprt.cxx 2009-06-04 12:39:13.000000000 +0100
|
| 692 |
+++ sc/source/filter/xml/xmlexprt.cxx 2009-06-04 12:51:46.000000000 +0100
|
| 693 |
@@ -599,39 +599,21 @@
|
| 694 |
else
|
| 695 |
{
|
| 696 |
++nShapesCount;
|
| 697 |
- SvxShape* pShapeImp(SvxShape::getImplementation(xShape));
|
| 698 |
- if (pShapeImp)
|
| 699 |
+ if (SvxShape* pShapeImp = SvxShape::getImplementation(xShape))
|
| 700 |
{
|
| 701 |
- SdrObject *pSdrObj(pShapeImp->GetSdrObject());
|
| 702 |
- if (pSdrObj)
|
| 703 |
+ if (SdrObject *pSdrObj = pShapeImp->GetSdrObject())
|
| 704 |
{
|
| 705 |
- if (ScDrawLayer::GetAnchor(pSdrObj) == SCA_CELL)
|
| 706 |
+ if (ScDrawObjData *pAnchor = ScDrawLayer::GetObjData( pSdrObj ))
|
| 707 |
{
|
| 708 |
- if (pDoc)
|
| 709 |
- {
|
| 710 |
-
|
| 711 |
- awt::Point aPoint(xShape->getPosition());
|
| 712 |
- awt::Size aSize(xShape->getSize());
|
| 713 |
- rtl::OUString sType(xShape->getShapeType());
|
| 714 |
- Rectangle aRectangle(aPoint.X, aPoint.Y, aPoint.X + aSize.Width, aPoint.Y + aSize.Height);
|
| 715 |
- if ( sType.equals(sCaptionShape) )
|
| 716 |
- {
|
| 717 |
- awt::Point aRelativeCaptionPoint;
|
| 718 |
- xShapeProp->getPropertyValue( sCaptionPoint ) >>= aRelativeCaptionPoint;
|
| 719 |
- Point aCoreRelativeCaptionPoint(aRelativeCaptionPoint.X, aRelativeCaptionPoint.Y);
|
| 720 |
- Point aCoreAbsoluteCaptionPoint(aPoint.X, aPoint.Y);
|
| 721 |
- aCoreAbsoluteCaptionPoint += aCoreRelativeCaptionPoint;
|
| 722 |
- aRectangle.Union(Rectangle(aCoreAbsoluteCaptionPoint, aCoreAbsoluteCaptionPoint));
|
| 723 |
- }
|
| 724 |
- ScRange aRange(pDoc->GetRange(static_cast<SCTAB>(nTable), aRectangle));
|
| 725 |
- ScMyShape aMyShape;
|
| 726 |
- aMyShape.aAddress = aRange.aStart;
|
| 727 |
- aMyShape.aEndAddress = aRange.aEnd;
|
| 728 |
- aMyShape.xShape = xShape;
|
| 729 |
- pSharedData->AddNewShape(aMyShape);
|
| 730 |
- pSharedData->SetLastColumn(nTable, aRange.aStart.Col());
|
| 731 |
- pSharedData->SetLastRow(nTable, aRange.aStart.Row());
|
| 732 |
- }
|
| 733 |
+ ScMyShape aMyShape;
|
| 734 |
+ aMyShape.aAddress = pAnchor->maStart;
|
| 735 |
+ aMyShape.aEndAddress = pAnchor->maEnd;
|
| 736 |
+ aMyShape.nEndX = pAnchor->maEndOffset.X();
|
| 737 |
+ aMyShape.nEndY = pAnchor->maEndOffset.Y();
|
| 738 |
+ aMyShape.xShape = xShape;
|
| 739 |
+ pSharedData->AddNewShape(aMyShape);
|
| 740 |
+ pSharedData->SetLastColumn(nTable, pAnchor->maStart.Col());
|
| 741 |
+ pSharedData->SetLastRow(nTable, pAnchor->maStart.Row());
|
| 742 |
}
|
| 743 |
else
|
| 744 |
pSharedData->AddTableShape(nTable, xShape);
|
| 745 |
@@ -2585,29 +2567,15 @@
|
| 746 |
aPoint.X = 2 * aItr->xShape->getPosition().X + aItr->xShape->getSize().Width - aPoint.X;
|
| 747 |
if ( !aItr->xShape->getShapeType().equals(sCaptionShape) )
|
| 748 |
{
|
| 749 |
- awt::Point aEndPoint;
|
| 750 |
Rectangle aEndRec(pDoc->GetMMRect(aItr->aEndAddress.Col(), aItr->aEndAddress.Row(),
|
| 751 |
aItr->aEndAddress.Col(), aItr->aEndAddress.Row(), aItr->aEndAddress.Tab()));
|
| 752 |
rtl::OUString sEndAddress;
|
| 753 |
ScRangeStringConverter::GetStringFromAddress(sEndAddress, aItr->aEndAddress, pDoc, FormulaGrammar::CONV_OOO);
|
| 754 |
AddAttribute(XML_NAMESPACE_TABLE, XML_END_CELL_ADDRESS, sEndAddress);
|
| 755 |
- if (bNegativePage)
|
| 756 |
- aEndPoint.X = -aEndRec.Right();
|
| 757 |
- else
|
| 758 |
- aEndPoint.X = aEndRec.Left();
|
| 759 |
- aEndPoint.Y = aEndRec.Top();
|
| 760 |
- awt::Point aStartPoint(aItr->xShape->getPosition());
|
| 761 |
- awt::Size aSize(aItr->xShape->getSize());
|
| 762 |
- sal_Int32 nEndX;
|
| 763 |
- if (bNegativePage)
|
| 764 |
- nEndX = -aStartPoint.X - aEndPoint.X;
|
| 765 |
- else
|
| 766 |
- nEndX = aStartPoint.X + aSize.Width - aEndPoint.X;
|
| 767 |
- sal_Int32 nEndY(aStartPoint.Y + aSize.Height - aEndPoint.Y);
|
| 768 |
rtl::OUStringBuffer sBuffer;
|
| 769 |
- GetMM100UnitConverter().convertMeasure(sBuffer, nEndX);
|
| 770 |
+ GetMM100UnitConverter().convertMeasure(sBuffer, aItr->nEndX);
|
| 771 |
AddAttribute(XML_NAMESPACE_TABLE, XML_END_X, sBuffer.makeStringAndClear());
|
| 772 |
- GetMM100UnitConverter().convertMeasure(sBuffer, nEndY);
|
| 773 |
+ GetMM100UnitConverter().convertMeasure(sBuffer, aItr->nEndY);
|
| 774 |
AddAttribute(XML_NAMESPACE_TABLE, XML_END_Y, sBuffer.makeStringAndClear());
|
| 775 |
}
|
| 776 |
ExportShape(aItr->xShape, &aPoint);
|
| 777 |
diff -ru sc.orig/source/filter/xml/xmlimprt.cxx sc/source/filter/xml/xmlimprt.cxx
|
| 778 |
--- sc.orig/source/filter/xml/xmlimprt.cxx 2009-06-04 12:39:13.000000000 +0100
|
| 779 |
+++ sc/source/filter/xml/xmlimprt.cxx 2009-06-04 15:23:47.000000000 +0100
|
| 780 |
@@ -2813,7 +2813,7 @@
|
| 781 |
}
|
| 782 |
|
| 783 |
aTables.UpdateRowHeights();
|
| 784 |
- aTables.ResizeShapes();
|
| 785 |
+ aTables.FixupOLEs();
|
| 786 |
}
|
| 787 |
if (GetModel().is())
|
| 788 |
{
|
| 789 |
diff -ru sc.orig/source/filter/xml/xmlsubti.cxx sc/source/filter/xml/xmlsubti.cxx
|
| 790 |
--- sc.orig/source/filter/xml/xmlsubti.cxx 2009-06-04 12:39:13.000000000 +0100
|
| 791 |
+++ sc/source/filter/xml/xmlsubti.cxx 2009-06-04 15:17:25.000000000 +0100
|
| 792 |
@@ -153,7 +153,7 @@
|
| 793 |
|
| 794 |
ScMyTables::ScMyTables(ScXMLImport& rTempImport)
|
| 795 |
: rImport(rTempImport),
|
| 796 |
- aResizeShapes(rTempImport),
|
| 797 |
+ aFixupOLEs(rTempImport),
|
| 798 |
nCurrentColStylePos(0),
|
| 799 |
nCurrentDrawPage( -1 ),
|
| 800 |
nCurrentXShapes( -1 ),
|
| 801 |
@@ -757,12 +757,10 @@
|
| 802 |
return !((nCurrentSheet != nCurrentXShapes) || !xShapes.is());
|
| 803 |
}
|
| 804 |
|
| 805 |
-void ScMyTables::AddShape(uno::Reference <drawing::XShape>& rShape,
|
| 806 |
- rtl::OUString* pRangeList,
|
| 807 |
- table::CellAddress& rStartAddress, table::CellAddress& rEndAddress,
|
| 808 |
- sal_Int32 nEndX, sal_Int32 nEndY)
|
| 809 |
+void ScMyTables::AddOLE(uno::Reference <drawing::XShape>& rShape,
|
| 810 |
+ const rtl::OUString &rRangeList)
|
| 811 |
{
|
| 812 |
- aResizeShapes.AddShape(rShape, pRangeList, rStartAddress, rEndAddress, nEndX, nEndY);
|
| 813 |
+ aFixupOLEs.AddOLE(rShape, rRangeList);
|
| 814 |
}
|
| 815 |
|
| 816 |
void ScMyTables::AddMatrixRange(
|
| 817 |
diff -ru sc.orig/source/filter/xml/xmlsubti.hxx sc/source/filter/xml/xmlsubti.hxx
|
| 818 |
--- sc.orig/source/filter/xml/xmlsubti.hxx 2009-06-04 12:39:13.000000000 +0100
|
| 819 |
+++ sc/source/filter/xml/xmlsubti.hxx 2009-06-04 15:23:00.000000000 +0100
|
| 820 |
@@ -114,7 +114,7 @@
|
| 821 |
|
| 822 |
ScXMLImport& rImport;
|
| 823 |
|
| 824 |
- ScMyShapeResizer aResizeShapes;
|
| 825 |
+ ScMyOLEFixer aFixupOLEs;
|
| 826 |
|
| 827 |
::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet > xCurrentSheet;
|
| 828 |
::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange > xCurrentCellRange;
|
| 829 |
@@ -151,7 +151,9 @@
|
| 830 |
void AddColumn(sal_Bool bIsCovered);
|
| 831 |
void NewTable(sal_Int32 nTempSpannedCols);
|
| 832 |
void UpdateRowHeights();
|
| 833 |
- void ResizeShapes() { aResizeShapes.ResizeShapes(); }
|
| 834 |
+ void FixupOLEs() { aFixupOLEs.FixupOLEs(); }
|
| 835 |
+ sal_Bool IsOLE(com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& rShape) const
|
| 836 |
+ { return ScMyOLEFixer::IsOLE(rShape); }
|
| 837 |
void DeleteTable();
|
| 838 |
com::sun::star::table::CellAddress GetRealCellPos();
|
| 839 |
void AddColCount(sal_Int32 nTempColCount);
|
| 840 |
@@ -170,11 +172,8 @@
|
| 841 |
GetCurrentXShapes();
|
| 842 |
sal_Bool HasDrawPage();
|
| 843 |
sal_Bool HasXShapes();
|
| 844 |
- void AddShape(com::sun::star::uno::Reference <com::sun::star::drawing::XShape>& rShape,
|
| 845 |
- rtl::OUString* pRangeList,
|
| 846 |
- com::sun::star::table::CellAddress& rStartAddress,
|
| 847 |
- com::sun::star::table::CellAddress& rEndAddress,
|
| 848 |
- sal_Int32 nEndX, sal_Int32 nEndY);
|
| 849 |
+ void AddOLE(com::sun::star::uno::Reference <com::sun::star::drawing::XShape>& rShape,
|
| 850 |
+ const rtl::OUString &rRangeList);
|
| 851 |
|
| 852 |
void AddMatrixRange( sal_Int32 nStartColumn,
|
| 853 |
sal_Int32 nStartRow,
|
| 854 |
diff -ru sc.orig/source/filter/xml/XMLTableShapeImportHelper.cxx sc/source/filter/xml/XMLTableShapeImportHelper.cxx
|
| 855 |
--- sc.orig/source/filter/xml/XMLTableShapeImportHelper.cxx 2009-06-04 12:39:13.000000000 +0100
|
| 856 |
+++ sc/source/filter/xml/XMLTableShapeImportHelper.cxx 2009-06-04 15:17:38.000000000 +0100
|
| 857 |
@@ -36,6 +36,7 @@
|
| 858 |
#include "drwlayer.hxx"
|
| 859 |
#include "xmlannoi.hxx"
|
| 860 |
#include "rangeutl.hxx"
|
| 861 |
+#include "userdat.hxx"
|
| 862 |
#include "docuno.hxx"
|
| 863 |
#include "sheetdata.hxx"
|
| 864 |
#include <xmloff/nmspmap.hxx>
|
| 865 |
@@ -90,6 +91,11 @@
|
| 866 |
{
|
| 867 |
if (!pAnnotationContext)
|
| 868 |
{
|
| 869 |
+ ScDrawObjData aAnchor;
|
| 870 |
+ aAnchor.maStart = ScAddress(aStartCell.Column, aStartCell.Row, aStartCell.Sheet);
|
| 871 |
+ awt::Point aStartPoint(rShape->getPosition());
|
| 872 |
+ aAnchor.maStartOffset = Point(aStartPoint.X, aStartPoint.Y);
|
| 873 |
+
|
| 874 |
sal_Int32 nEndX(-1);
|
| 875 |
sal_Int32 nEndY(-1);
|
| 876 |
sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
|
| 877 |
@@ -111,11 +117,18 @@
|
| 878 |
{
|
| 879 |
sal_Int32 nOffset(0);
|
| 880 |
ScRangeStringConverter::GetAddressFromString(aEndCell, rValue, static_cast<ScXMLImport&>(mrImporter).GetDocument(), ::formula::FormulaGrammar::CONV_OOO, nOffset);
|
| 881 |
+ aAnchor.maEnd = ScAddress(aEndCell.Column, aEndCell.Row, aEndCell.Sheet);
|
| 882 |
}
|
| 883 |
else if (IsXMLToken(aLocalName, XML_END_X))
|
| 884 |
+ {
|
| 885 |
static_cast<ScXMLImport&>(mrImporter).GetMM100UnitConverter().convertMeasure(nEndX, rValue);
|
| 886 |
+ aAnchor.maEndOffset.X() = nEndX;
|
| 887 |
+ }
|
| 888 |
else if (IsXMLToken(aLocalName, XML_END_Y))
|
| 889 |
+ {
|
| 890 |
static_cast<ScXMLImport&>(mrImporter).GetMM100UnitConverter().convertMeasure(nEndY, rValue);
|
| 891 |
+ aAnchor.maEndOffset.Y() = nEndY;
|
| 892 |
+ }
|
| 893 |
else if (IsXMLToken(aLocalName, XML_TABLE_BACKGROUND))
|
| 894 |
if (IsXMLToken(rValue, XML_TRUE))
|
| 895 |
nLayerID = SC_LAYER_BACK;
|
| 896 |
@@ -128,39 +141,28 @@
|
| 897 |
}
|
| 898 |
SetLayer(rShape, nLayerID, rShape->getShapeType());
|
| 899 |
|
| 900 |
- if (!bOnTable)
|
| 901 |
+ if (SvxShape* pShapeImp = SvxShape::getImplementation(rShape))
|
| 902 |
{
|
| 903 |
- rTables.AddShape(rShape,
|
| 904 |
- pRangeList, aStartCell, aEndCell, nEndX, nEndY);
|
| 905 |
- SvxShape* pShapeImp = SvxShape::getImplementation(rShape);
|
| 906 |
- if (pShapeImp)
|
| 907 |
- {
|
| 908 |
- SdrObject *pSdrObj = pShapeImp->GetSdrObject();
|
| 909 |
- if (pSdrObj)
|
| 910 |
- ScDrawLayer::SetAnchor(pSdrObj, SCA_CELL);
|
| 911 |
- }
|
| 912 |
+ if (SdrObject *pSdrObj = pShapeImp->GetSdrObject())
|
| 913 |
+ {
|
| 914 |
+ if (!bOnTable)
|
| 915 |
+ ScDrawLayer::SetCellAnchored(*pSdrObj, aAnchor);
|
| 916 |
+ else
|
| 917 |
+ ScDrawLayer::SetPageAnchored(*pSdrObj);
|
| 918 |
+ }
|
| 919 |
}
|
| 920 |
- else
|
| 921 |
- {
|
| 922 |
- if ( pRangeList )
|
| 923 |
- {
|
| 924 |
- // #i78086# If there are notification ranges, the ChartListener must be created
|
| 925 |
- // also when anchored to the sheet
|
| 926 |
- // -> call AddShape with invalid cell position (checked in ScMyShapeResizer::ResizeShapes)
|
| 927 |
-
|
| 928 |
- table::CellAddress aInvalidPos( -1, -1, -1 );
|
| 929 |
- rTables.AddShape(rShape,
|
| 930 |
- pRangeList, aInvalidPos, aInvalidPos, 0, 0);
|
| 931 |
- }
|
| 932 |
|
| 933 |
- SvxShape* pShapeImp = SvxShape::getImplementation(rShape);
|
| 934 |
- if (pShapeImp)
|
| 935 |
- {
|
| 936 |
- SdrObject *pSdrObj = pShapeImp->GetSdrObject();
|
| 937 |
- if (pSdrObj)
|
| 938 |
- ScDrawLayer::SetAnchor(pSdrObj, SCA_PAGE);
|
| 939 |
- }
|
| 940 |
- }
|
| 941 |
+ if ( bOnTable && pRangeList )
|
| 942 |
+ {
|
| 943 |
+ // #i78086# If there are notification ranges, the ChartListener must be created
|
| 944 |
+ // also when anchored to the sheet
|
| 945 |
+ // -> call AddOLE with invalid cell position (checked in ScMyShapeResizer::ResizeShapes)
|
| 946 |
+
|
| 947 |
+ if (rTables.IsOLE(rShape))
|
| 948 |
+ rTables.AddOLE(rShape, *pRangeList);
|
| 949 |
+ }
|
| 950 |
+
|
| 951 |
+ delete pRangeList;
|
| 952 |
}
|
| 953 |
else // shape is annotation
|
| 954 |
{
|
| 955 |
diff -ru sc.orig/source/filter/xml/XMLTableShapeResizer.cxx sc/source/filter/xml/XMLTableShapeResizer.cxx
|
| 956 |
--- sc.orig/source/filter/xml/XMLTableShapeResizer.cxx 2009-06-04 12:39:13.000000000 +0100
|
| 957 |
+++ sc/source/filter/xml/XMLTableShapeResizer.cxx 2009-06-04 15:27:39.000000000 +0100
|
| 958 |
@@ -51,38 +51,38 @@
|
| 959 |
using ::std::vector;
|
| 960 |
using ::rtl::OUString;
|
| 961 |
|
| 962 |
-ScMyShapeResizer::ScMyShapeResizer(ScXMLImport& rTempImport)
|
| 963 |
+ScMyOLEFixer::ScMyOLEFixer(ScXMLImport& rTempImport)
|
| 964 |
: rImport(rTempImport),
|
| 965 |
aShapes(),
|
| 966 |
pCollection(NULL)
|
| 967 |
{
|
| 968 |
}
|
| 969 |
|
| 970 |
-ScMyShapeResizer::~ScMyShapeResizer()
|
| 971 |
+ScMyOLEFixer::~ScMyOLEFixer()
|
| 972 |
{
|
| 973 |
}
|
| 974 |
|
| 975 |
-sal_Bool ScMyShapeResizer::IsOLE(uno::Reference< drawing::XShape >& rShape) const
|
| 976 |
+sal_Bool ScMyOLEFixer::IsOLE(uno::Reference< drawing::XShape >& rShape)
|
| 977 |
{
|
| 978 |
return rShape->getShapeType().equals(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.OLE2Shape")));
|
| 979 |
}
|
| 980 |
|
| 981 |
-void ScMyShapeResizer::CreateChartListener(ScDocument* pDoc,
|
| 982 |
+void ScMyOLEFixer::CreateChartListener(ScDocument* pDoc,
|
| 983 |
const rtl::OUString& rName,
|
| 984 |
- const rtl::OUString* pRangeList)
|
| 985 |
+ const rtl::OUString& rRangeList)
|
| 986 |
{
|
| 987 |
- if (!pDoc || !pRangeList)
|
| 988 |
- // These are minimum required.
|
| 989 |
+ // This is the minimum required.
|
| 990 |
+ if (!pDoc)
|
| 991 |
return;
|
| 992 |
|
| 993 |
- if (!pRangeList->getLength())
|
| 994 |
+ if (!rRangeList.getLength())
|
| 995 |
{
|
| 996 |
pDoc->AddOLEObjectToCollection(rName);
|
| 997 |
return;
|
| 998 |
}
|
| 999 |
|
| 1000 |
OUString aRangeStr;
|
| 1001 |
- ScRangeStringConverter::GetStringFromXMLRangeString(aRangeStr, *pRangeList, pDoc);
|
| 1002 |
+ ScRangeStringConverter::GetStringFromXMLRangeString(aRangeStr, rRangeList, pDoc);
|
| 1003 |
if (!aRangeStr.getLength())
|
| 1004 |
{
|
| 1005 |
pDoc->AddOLEObjectToCollection(rName);
|
| 1006 |
@@ -112,271 +112,45 @@
|
| 1007 |
}
|
| 1008 |
}
|
| 1009 |
|
| 1010 |
-void ScMyShapeResizer::AddShape(uno::Reference <drawing::XShape>& rShape,
|
| 1011 |
- rtl::OUString* pRangeList,
|
| 1012 |
- table::CellAddress& rStartAddress, table::CellAddress& rEndAddress,
|
| 1013 |
- sal_Int32 nEndX, sal_Int32 nEndY)
|
| 1014 |
+void ScMyOLEFixer::AddOLE(uno::Reference <drawing::XShape>& rShape,
|
| 1015 |
+ const rtl::OUString &rRangeList)
|
| 1016 |
{
|
| 1017 |
- ScMyToResizeShape aShape;
|
| 1018 |
+ ScMyToFixupOLE aShape;
|
| 1019 |
aShape.xShape.set(rShape);
|
| 1020 |
- aShape.pRangeList = pRangeList;
|
| 1021 |
- aShape.aEndCell = rEndAddress;
|
| 1022 |
- aShape.aStartCell = rStartAddress;
|
| 1023 |
- aShape.nEndY = nEndY;
|
| 1024 |
- aShape.nEndX = nEndX;
|
| 1025 |
+ aShape.sRangeList = rRangeList;
|
| 1026 |
aShapes.push_back(aShape);
|
| 1027 |
}
|
| 1028 |
|
| 1029 |
-void ScMyShapeResizer::GetNewShapeSizePos(ScDocument* pDoc, const Rectangle& rStartRect,
|
| 1030 |
- const table::CellAddress& rEndCell,
|
| 1031 |
- awt::Point& rPoint, awt::Size& rSize,
|
| 1032 |
- sal_Int32& rEndX, sal_Int32& rEndY) const
|
| 1033 |
-{
|
| 1034 |
- awt::Point aRefPoint;
|
| 1035 |
- BOOL bNegativePage(pDoc->IsNegativePage(rEndCell.Sheet));
|
| 1036 |
- if (bNegativePage)
|
| 1037 |
- aRefPoint.X = rStartRect.Right();
|
| 1038 |
- else
|
| 1039 |
- aRefPoint.X = rStartRect.Left();
|
| 1040 |
- aRefPoint.Y = rStartRect.Top();
|
| 1041 |
- Rectangle aRect(pDoc->GetMMRect(
|
| 1042 |
- static_cast<SCCOL>(rEndCell.Column), static_cast<SCROW>(rEndCell.Row),
|
| 1043 |
- static_cast<SCCOL>(rEndCell.Column), static_cast<SCROW>(rEndCell.Row), rEndCell.Sheet ));
|
| 1044 |
- if (bNegativePage)
|
| 1045 |
- rEndX = -rEndX + aRect.Right();
|
| 1046 |
- else
|
| 1047 |
- rEndX += aRect.Left();
|
| 1048 |
- rEndY += aRect.Top();
|
| 1049 |
- rPoint.X += aRefPoint.X;
|
| 1050 |
- if (bNegativePage)
|
| 1051 |
- {
|
| 1052 |
- if (rPoint.X < rStartRect.Left())
|
| 1053 |
- rPoint.X = rStartRect.Left() + 2; // increment by 2 100th_mm because the cellwidth is internal in twips
|
| 1054 |
- }
|
| 1055 |
- else
|
| 1056 |
- {
|
| 1057 |
- if (rPoint.X > rStartRect.Right())
|
| 1058 |
- rPoint.X = rStartRect.Right() - 2; // decrement by 2 100th_mm because the cellwidth is internal in twips
|
| 1059 |
- }
|
| 1060 |
- rPoint.Y += aRefPoint.Y;
|
| 1061 |
- if (rPoint.Y > rStartRect.Bottom())
|
| 1062 |
- rPoint.Y = rStartRect.Bottom() - 2; // decrement by 2 100th_mm because the cellheight is internal in twips
|
| 1063 |
- if (bNegativePage)
|
| 1064 |
- {
|
| 1065 |
- rSize.Width = -(rEndX - rPoint.X);
|
| 1066 |
- }
|
| 1067 |
- else
|
| 1068 |
- rSize.Width = rEndX - rPoint.X;
|
| 1069 |
- rSize.Height = rEndY - rPoint.Y;
|
| 1070 |
-}
|
| 1071 |
-
|
| 1072 |
-void ScMyShapeResizer::ResizeShapes()
|
| 1073 |
+void ScMyOLEFixer::FixupOLEs()
|
| 1074 |
{
|
| 1075 |
if (!aShapes.empty() && rImport.GetModel().is())
|
| 1076 |
{
|
| 1077 |
- rtl::OUString sRowHeight(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_CELLHGT));
|
| 1078 |
rtl::OUString sPersistName (RTL_CONSTASCII_USTRINGPARAM("PersistName"));
|
| 1079 |
- rtl::OUString sCaptionPoint( RTL_CONSTASCII_USTRINGPARAM( "CaptionPoint" ));
|
| 1080 |
- rtl::OUString sConnectorShape( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ConnectorShape") );
|
| 1081 |
- rtl::OUString sCaptionShape( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.CaptionShape") );
|
| 1082 |
- rtl::OUString sStartShape(RTL_CONSTASCII_USTRINGPARAM("StartShape"));
|
| 1083 |
- rtl::OUString sEndShape(RTL_CONSTASCII_USTRINGPARAM("EndShape"));
|
| 1084 |
- rtl::OUString sStartPosition(RTL_CONSTASCII_USTRINGPARAM("StartPosition"));
|
| 1085 |
- rtl::OUString sEndPosition(RTL_CONSTASCII_USTRINGPARAM("EndPosition"));
|
| 1086 |
- uno::Reference<table::XCellRange> xTableRow;
|
| 1087 |
- uno::Reference<sheet::XSpreadsheet> xSheet;
|
| 1088 |
- uno::Reference<table::XTableRows> xTableRows;
|
| 1089 |
- sal_Int32 nOldRow(-1);
|
| 1090 |
- sal_Int32 nOldSheet(-1);
|
| 1091 |
- ScMyToResizeShapes::iterator aItr(aShapes.begin());
|
| 1092 |
- ScMyToResizeShapes::iterator aEndItr(aShapes.end());
|
| 1093 |
- uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( rImport.GetModel(), uno::UNO_QUERY );
|
| 1094 |
- if ( xSpreadDoc.is() )
|
| 1095 |
+ ScMyToFixupOLEs::iterator aItr(aShapes.begin());
|
| 1096 |
+ ScMyToFixupOLEs::iterator aEndItr(aShapes.end());
|
| 1097 |
+ ScDocument* pDoc(rImport.GetDocument());
|
| 1098 |
+
|
| 1099 |
+ rImport.LockSolarMutex();
|
| 1100 |
+
|
| 1101 |
+ while (aItr != aEndItr)
|
| 1102 |
{
|
| 1103 |
- uno::Reference<container::XIndexAccess> xIndex( xSpreadDoc->getSheets(), uno::UNO_QUERY );
|
| 1104 |
- ScDocument* pDoc(rImport.GetDocument());
|
| 1105 |
- if ( pDoc && xIndex.is() )
|
| 1106 |
+ // #i78086# also call CreateChartListener for invalid position (anchored to sheet)
|
| 1107 |
+ if (!IsOLE(aItr->xShape))
|
| 1108 |
+ DBG_ERROR("Only OLEs should be in here now");
|
| 1109 |
+
|
| 1110 |
+ if (IsOLE(aItr->xShape))
|
| 1111 |
{
|
| 1112 |
- rImport.LockSolarMutex();
|
| 1113 |
- while (aItr != aEndItr)
|
| 1114 |
- {
|
| 1115 |
- // #i78086# invalid cell position is used to call CreateChartListener only
|
| 1116 |
- if ( aItr->aEndCell.Sheet >= 0 )
|
| 1117 |
- {
|
| 1118 |
- if ((nOldSheet != aItr->aEndCell.Sheet) || !xSheet.is())
|
| 1119 |
- {
|
| 1120 |
- nOldSheet = aItr->aEndCell.Sheet;
|
| 1121 |
- xSheet.set(xIndex->getByIndex(nOldSheet), uno::UNO_QUERY);
|
| 1122 |
- if (xSheet.is())
|
| 1123 |
- {
|
| 1124 |
- uno::Reference<table::XColumnRowRange> xColumnRowRange (xSheet, uno::UNO_QUERY);
|
| 1125 |
- if (xColumnRowRange.is())
|
| 1126 |
- xTableRows = xColumnRowRange->getRows();
|
| 1127 |
- }
|
| 1128 |
- }
|
| 1129 |
- if (xTableRows.is())
|
| 1130 |
- {
|
| 1131 |
- if (nOldRow != aItr->aEndCell.Row || !xTableRow.is())
|
| 1132 |
- {
|
| 1133 |
- nOldRow = aItr->aEndCell.Row;
|
| 1134 |
- xTableRows->getByIndex(nOldRow) >>= xTableRow;
|
| 1135 |
- }
|
| 1136 |
- if (xTableRow.is())
|
| 1137 |
- {
|
| 1138 |
- uno::Reference <beans::XPropertySet> xRowProperties(xTableRow, uno::UNO_QUERY);
|
| 1139 |
- if (xRowProperties.is())
|
| 1140 |
- {
|
| 1141 |
- sal_Int32 nHeight;
|
| 1142 |
- if (xRowProperties->getPropertyValue(sRowHeight) >>= nHeight)
|
| 1143 |
- {
|
| 1144 |
- Rectangle aRec = pDoc->GetMMRect(static_cast<SCCOL>(aItr->aStartCell.Column), static_cast<SCROW>(aItr->aStartCell.Row),
|
| 1145 |
- static_cast<SCCOL>(aItr->aStartCell.Column), static_cast<SCROW>(aItr->aStartCell.Row), aItr->aStartCell.Sheet);
|
| 1146 |
- awt::Point aPoint(aItr->xShape->getPosition());
|
| 1147 |
- awt::Size aSize(aItr->xShape->getSize());
|
| 1148 |
- if (pDoc->IsNegativePage(static_cast<SCTAB>(nOldSheet)))
|
| 1149 |
- aPoint.X += aSize.Width;
|
| 1150 |
- if (aItr->nEndY >= 0 && aItr->nEndX >= 0)
|
| 1151 |
- {
|
| 1152 |
- if (aItr->xShape->getShapeType().equals(sConnectorShape))
|
| 1153 |
- {
|
| 1154 |
- //#103122#; handle connected Connectorshapes
|
| 1155 |
- uno::Reference<beans::XPropertySet> xShapeProps (aItr->xShape, uno::UNO_QUERY);
|
| 1156 |
- if(xShapeProps.is())
|
| 1157 |
- {
|
| 1158 |
- uno::Reference<drawing::XShape> xStartShape(xShapeProps->getPropertyValue( sStartShape ), uno::UNO_QUERY);
|
| 1159 |
- uno::Reference<drawing::XShape> xEndShape(xShapeProps->getPropertyValue( sEndShape ), uno::UNO_QUERY);
|
| 1160 |
- if (!xStartShape.is() && !xEndShape.is())
|
| 1161 |
- {
|
| 1162 |
- awt::Size aOldSize(aSize);
|
| 1163 |
- GetNewShapeSizePos(pDoc, aRec, aItr->aEndCell, aPoint, aSize, aItr->nEndX, aItr->nEndY);
|
| 1164 |
- aItr->xShape->setPosition(aPoint);
|
| 1165 |
- if( (aSize.Width != aOldSize.Width) ||
|
| 1166 |
- (aSize.Height != aOldSize.Height) )
|
| 1167 |
- aItr->xShape->setSize(aSize);
|
| 1168 |
- }
|
| 1169 |
- else if (xStartShape.is() && xEndShape.is())
|
| 1170 |
- {
|
| 1171 |
- // do nothing, because they are connected
|
| 1172 |
- }
|
| 1173 |
- else
|
| 1174 |
- {
|
| 1175 |
- // only one point is connected, the other should be moved
|
| 1176 |
-
|
| 1177 |
- rtl::OUString sProperty;
|
| 1178 |
- if (xStartShape.is())
|
| 1179 |
- {
|
| 1180 |
- awt::Point aEndPoint;
|
| 1181 |
- xShapeProps->getPropertyValue(sEndPosition) >>= aEndPoint;
|
| 1182 |
- aPoint.X = aRec.Left() + aEndPoint.X;
|
| 1183 |
- aPoint.Y = aRec.Top() + aEndPoint.Y;
|
| 1184 |
- sProperty = sEndPosition;
|
| 1185 |
- }
|
| 1186 |
- else
|
| 1187 |
- {
|
| 1188 |
- awt::Point aStartPoint;
|
| 1189 |
- xShapeProps->getPropertyValue(sStartPosition) >>= aStartPoint;
|
| 1190 |
- aPoint.X = aRec.Left() + aStartPoint.X;
|
| 1191 |
- aPoint.Y = aRec.Top() + aStartPoint.Y;
|
| 1192 |
- sProperty = sStartPosition;
|
| 1193 |
- }
|
| 1194 |
- xShapeProps->setPropertyValue(sProperty, uno::makeAny(aPoint));
|
| 1195 |
- }
|
| 1196 |
- }
|
| 1197 |
- }
|
| 1198 |
- else
|
| 1199 |
- {
|
| 1200 |
- awt::Size aOldSize(aSize);
|
| 1201 |
- GetNewShapeSizePos(pDoc, aRec, aItr->aEndCell, aPoint, aSize, aItr->nEndX, aItr->nEndY);
|
| 1202 |
- if (pDoc->IsNegativePage(static_cast<SCTAB>(nOldSheet)))
|
| 1203 |
- aPoint.X -= aSize.Width;
|
| 1204 |
- aItr->xShape->setPosition(aPoint);
|
| 1205 |
- if( (aSize.Width != aOldSize.Width) ||
|
| 1206 |
- (aSize.Height != aOldSize.Height) )
|
| 1207 |
- aItr->xShape->setSize(aSize);
|
| 1208 |
- }
|
| 1209 |
- }
|
| 1210 |
- else
|
| 1211 |
- {
|
| 1212 |
- if (aItr->xShape->getShapeType().equals(sCaptionShape))
|
| 1213 |
- {
|
| 1214 |
- Rectangle aRectangle(aPoint.X, aPoint.Y, aPoint.X + aSize.Width, aPoint.Y + aSize.Height);
|
| 1215 |
-
|
| 1216 |
- awt::Point aCaptionPoint;
|
| 1217 |
- uno::Reference< beans::XPropertySet > xShapeProps(aItr->xShape, uno::UNO_QUERY);
|
| 1218 |
- if (xShapeProps.is())
|
| 1219 |
- {
|
| 1220 |
- try
|
| 1221 |
- {
|
| 1222 |
- xShapeProps->getPropertyValue( sCaptionPoint ) >>= aCaptionPoint;
|
| 1223 |
- }
|
| 1224 |
- catch ( uno::Exception& )
|
| 1225 |
- {
|
| 1226 |
- DBG_ERROR("This Captionshape has no CaptionPoint property.");
|
| 1227 |
- }
|
| 1228 |
- }
|
| 1229 |
- Point aCorePoint(aPoint.X, aPoint.Y);
|
| 1230 |
- Point aCoreCaptionPoint(aCaptionPoint.X, aCaptionPoint.Y);
|
| 1231 |
- aCoreCaptionPoint += aCorePoint;
|
| 1232 |
- aRectangle.Union(Rectangle(aCoreCaptionPoint, aCoreCaptionPoint));
|
| 1233 |
-
|
| 1234 |
- Point aBeforeRightBottomPoint(aRectangle.BottomRight());
|
| 1235 |
-
|
| 1236 |
- aRectangle += aRec.TopLeft();
|
| 1237 |
- if (aRectangle.Left() > aRec.Right())
|
| 1238 |
- aRectangle -= (Point(aRectangle.Left() - aRec.Right() + 2, 0));
|
| 1239 |
- if (aRectangle.Top() > aRec.Bottom())
|
| 1240 |
- aRectangle -= (Point(0, aRectangle.Top() - aRec.Bottom() + 2));
|
| 1241 |
-
|
| 1242 |
- Point aDifferencePoint(aRectangle.BottomRight() - aBeforeRightBottomPoint);
|
| 1243 |
- aPoint.X += aDifferencePoint.X();
|
| 1244 |
- aPoint.Y += aDifferencePoint.Y();
|
| 1245 |
-
|
| 1246 |
- aItr->xShape->setPosition(aPoint);
|
| 1247 |
- }
|
| 1248 |
- else
|
| 1249 |
- {
|
| 1250 |
- // #96159# it is possible, that shapes have a negative position
|
| 1251 |
- // this is now handled here
|
| 1252 |
- DBG_ERROR("no or negative end address of this shape");
|
| 1253 |
- awt::Point aRefPoint;
|
| 1254 |
- aRefPoint.X = aRec.Left();
|
| 1255 |
- aRefPoint.Y = aRec.Top();
|
| 1256 |
- aPoint.X += aRefPoint.X;
|
| 1257 |
- if (aPoint.X > aRec.Right())
|
| 1258 |
- aPoint.X = aRec.Right() - 2; // decrement by 2 100th_mm because the cellheight is internal in twips
|
| 1259 |
- aPoint.Y += aRefPoint.Y;
|
| 1260 |
- if (aPoint.Y > aRec.Bottom())
|
| 1261 |
- aPoint.Y = aRec.Bottom() - 2; // decrement by 2 100th_mm because the cellheight is internal in twips
|
| 1262 |
- aItr->xShape->setPosition(aPoint);
|
| 1263 |
- }
|
| 1264 |
- }
|
| 1265 |
- }
|
| 1266 |
- }
|
| 1267 |
- }
|
| 1268 |
- }
|
| 1269 |
- else
|
| 1270 |
- {
|
| 1271 |
- DBG_ERROR("something wents wrong");
|
| 1272 |
- }
|
| 1273 |
- }
|
| 1274 |
- // #i78086# call CreateChartListener also for invalid position (anchored to sheet)
|
| 1275 |
- if (IsOLE(aItr->xShape))
|
| 1276 |
- {
|
| 1277 |
- uno::Reference < beans::XPropertySet > xShapeProps ( aItr->xShape, uno::UNO_QUERY );
|
| 1278 |
- uno::Reference < beans::XPropertySetInfo > xShapeInfo(xShapeProps->getPropertySetInfo());
|
| 1279 |
- rtl::OUString sName;
|
| 1280 |
- if (xShapeProps.is() && xShapeInfo.is() && xShapeInfo->hasPropertyByName(sPersistName) &&
|
| 1281 |
- (xShapeProps->getPropertyValue(sPersistName) >>= sName))
|
| 1282 |
- CreateChartListener(pDoc, sName, aItr->pRangeList);
|
| 1283 |
- }
|
| 1284 |
- if (aItr->pRangeList)
|
| 1285 |
- delete aItr->pRangeList;
|
| 1286 |
- aItr = aShapes.erase(aItr);
|
| 1287 |
- }
|
| 1288 |
- rImport.UnlockSolarMutex();
|
| 1289 |
-// if (pCollection)
|
| 1290 |
-// pDoc->SetChartListenerCollection(pCollection);
|
| 1291 |
+ uno::Reference < beans::XPropertySet > xShapeProps ( aItr->xShape, uno::UNO_QUERY );
|
| 1292 |
+ uno::Reference < beans::XPropertySetInfo > xShapeInfo(xShapeProps->getPropertySetInfo());
|
| 1293 |
+ rtl::OUString sName;
|
| 1294 |
+
|
| 1295 |
+ if (pDoc && xShapeProps.is() && xShapeInfo.is() && xShapeInfo->hasPropertyByName(sPersistName) &&
|
| 1296 |
+ (xShapeProps->getPropertyValue(sPersistName) >>= sName))
|
| 1297 |
+ CreateChartListener(pDoc, sName, aItr->sRangeList);
|
| 1298 |
}
|
| 1299 |
+ aItr = aShapes.erase(aItr);
|
| 1300 |
}
|
| 1301 |
+
|
| 1302 |
+ rImport.UnlockSolarMutex();
|
| 1303 |
}
|
| 1304 |
}
|
| 1305 |
diff -ru sc.orig/source/filter/xml/XMLTableShapeResizer.hxx sc/source/filter/xml/XMLTableShapeResizer.hxx
|
| 1306 |
--- sc.orig/source/filter/xml/XMLTableShapeResizer.hxx 2009-06-04 12:39:13.000000000 +0100
|
| 1307 |
+++ sc/source/filter/xml/XMLTableShapeResizer.hxx 2009-06-04 15:22:38.000000000 +0100
|
| 1308 |
@@ -41,44 +41,31 @@
|
| 1309 |
class ScDocument;
|
| 1310 |
class Rectangle;
|
| 1311 |
|
| 1312 |
-struct ScMyToResizeShape
|
| 1313 |
+struct ScMyToFixupOLE
|
| 1314 |
{
|
| 1315 |
com::sun::star::uno::Reference <com::sun::star::drawing::XShape> xShape;
|
| 1316 |
- rtl::OUString* pRangeList;
|
| 1317 |
- com::sun::star::table::CellAddress aEndCell;
|
| 1318 |
- com::sun::star::table::CellAddress aStartCell;
|
| 1319 |
- sal_Int32 nEndX;
|
| 1320 |
- sal_Int32 nEndY;
|
| 1321 |
-
|
| 1322 |
- ScMyToResizeShape() : pRangeList(NULL) {}
|
| 1323 |
+ rtl::OUString sRangeList;
|
| 1324 |
};
|
| 1325 |
|
| 1326 |
-typedef std::list<ScMyToResizeShape> ScMyToResizeShapes;
|
| 1327 |
+typedef std::list<ScMyToFixupOLE> ScMyToFixupOLEs;
|
| 1328 |
|
| 1329 |
-class ScMyShapeResizer
|
| 1330 |
+class ScMyOLEFixer
|
| 1331 |
{
|
| 1332 |
ScXMLImport& rImport;
|
| 1333 |
- ScMyToResizeShapes aShapes;
|
| 1334 |
+ ScMyToFixupOLEs aShapes;
|
| 1335 |
ScChartListenerCollection* pCollection;
|
| 1336 |
|
| 1337 |
- sal_Bool IsOLE(com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& rShape) const;
|
| 1338 |
void CreateChartListener(ScDocument* pDoc,
|
| 1339 |
const rtl::OUString& rName,
|
| 1340 |
- const rtl::OUString* pRangeList);
|
| 1341 |
- void GetNewShapeSizePos(ScDocument* pDoc, const Rectangle& rStartRect,
|
| 1342 |
- const com::sun::star::table::CellAddress& rEndCell,
|
| 1343 |
- com::sun::star::awt::Point& rPoint, com::sun::star::awt::Size& rSize,
|
| 1344 |
- sal_Int32& rEndX, sal_Int32& rEndY) const;
|
| 1345 |
+ const rtl::OUString& rRangeList);
|
| 1346 |
public:
|
| 1347 |
- ScMyShapeResizer(ScXMLImport& rImport);
|
| 1348 |
- ~ScMyShapeResizer();
|
| 1349 |
+ ScMyOLEFixer(ScXMLImport& rImport);
|
| 1350 |
+ ~ScMyOLEFixer();
|
| 1351 |
|
| 1352 |
- void AddShape(com::sun::star::uno::Reference <com::sun::star::drawing::XShape>& rShape,
|
| 1353 |
- rtl::OUString* pRangeList,
|
| 1354 |
- com::sun::star::table::CellAddress& rStartAddress,
|
| 1355 |
- com::sun::star::table::CellAddress& rEndAddress,
|
| 1356 |
- sal_Int32 nEndX, sal_Int32 nEndY);
|
| 1357 |
- void ResizeShapes();
|
| 1358 |
+ static sal_Bool IsOLE(com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& rShape);
|
| 1359 |
+ void AddOLE(com::sun::star::uno::Reference <com::sun::star::drawing::XShape>& rShape,
|
| 1360 |
+ const rtl::OUString &rRangeList);
|
| 1361 |
+ void FixupOLEs();
|
| 1362 |
};
|
| 1363 |
|
| 1364 |
#endif
|
| 1365 |
diff -ru sc.orig/source/ui/Accessibility/AccessibleDocument.cxx sc/source/ui/Accessibility/AccessibleDocument.cxx
|
| 1366 |
--- sc.orig/source/ui/Accessibility/AccessibleDocument.cxx 2009-06-04 12:39:41.000000000 +0100
|
| 1367 |
+++ sc/source/ui/Accessibility/AccessibleDocument.cxx 2009-06-04 12:40:23.000000000 +0100
|
| 1368 |
@@ -44,6 +44,7 @@
|
| 1369 |
#include "drawview.hxx"
|
| 1370 |
#include "gridwin.hxx"
|
| 1371 |
#include "AccessibleEditObject.hxx"
|
| 1372 |
+#include "userdat.hxx"
|
| 1373 |
#include "scresid.hxx"
|
| 1374 |
#ifndef SC_SC_HRC
|
| 1375 |
#include "sc.hrc"
|
| 1376 |
@@ -1017,35 +1018,10 @@
|
| 1377 |
uno::Reference<beans::XPropertySet> xShapeProp(xShape, uno::UNO_QUERY);
|
| 1378 |
if (pShapeImp && xShapeProp.is())
|
| 1379 |
{
|
| 1380 |
- SdrObject *pSdrObj = pShapeImp->GetSdrObject();
|
| 1381 |
- if (pSdrObj)
|
| 1382 |
+ if (SdrObject *pSdrObj = pShapeImp->GetSdrObject())
|
| 1383 |
{
|
| 1384 |
- if (ScDrawLayer::GetAnchor(pSdrObj) == SCA_CELL)
|
| 1385 |
- {
|
| 1386 |
- ScDocument* pDoc = mpViewShell->GetViewData()->GetDocument();
|
| 1387 |
- if (pDoc)
|
| 1388 |
- {
|
| 1389 |
- rtl::OUString sCaptionShape(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.CaptionShape"));
|
| 1390 |
- awt::Point aPoint(xShape->getPosition());
|
| 1391 |
- awt::Size aSize(xShape->getSize());
|
| 1392 |
- rtl::OUString sType(xShape->getShapeType());
|
| 1393 |
- Rectangle aRectangle(aPoint.X, aPoint.Y, aPoint.X + aSize.Width, aPoint.Y + aSize.Height);
|
| 1394 |
- if ( sType.equals(sCaptionShape) )
|
| 1395 |
- {
|
| 1396 |
- awt::Point aRelativeCaptionPoint;
|
| 1397 |
- rtl::OUString sCaptionPoint( RTL_CONSTASCII_USTRINGPARAM( "CaptionPoint" ));
|
| 1398 |
- xShapeProp->getPropertyValue( sCaptionPoint ) >>= aRelativeCaptionPoint;
|
| 1399 |
- Point aCoreRelativeCaptionPoint(aRelativeCaptionPoint.X, aRelativeCaptionPoint.Y);
|
| 1400 |
- Point aCoreAbsoluteCaptionPoint(aPoint.X, aPoint.Y);
|
| 1401 |
- aCoreAbsoluteCaptionPoint += aCoreRelativeCaptionPoint;
|
| 1402 |
- aRectangle.Union(Rectangle(aCoreAbsoluteCaptionPoint, aCoreAbsoluteCaptionPoint));
|
| 1403 |
- }
|
| 1404 |
- ScRange aRange = pDoc->GetRange(mpAccessibleDocument->getVisibleTable(), aRectangle);
|
| 1405 |
- pAddress = new ScAddress(aRange.aStart);
|
| 1406 |
- }
|
| 1407 |
- }
|
| 1408 |
-// else
|
| 1409 |
-// do nothing, because it is always a NULL Pointer
|
| 1410 |
+ if (ScDrawObjData *pAnchor = ScDrawLayer::GetObjData(pSdrObj))
|
| 1411 |
+ return new ScAddress(pAnchor->maStart);
|
| 1412 |
}
|
| 1413 |
}
|
| 1414 |
}
|
| 1415 |
diff -ru sc.orig/source/ui/drawfunc/drawsh2.cxx sc/source/ui/drawfunc/drawsh2.cxx
|
| 1416 |
--- sc.orig/source/ui/drawfunc/drawsh2.cxx 2009-06-04 12:39:40.000000000 +0100
|
| 1417 |
+++ sc/source/ui/drawfunc/drawsh2.cxx 2009-06-04 12:40:23.000000000 +0100
|
| 1418 |
@@ -115,7 +115,7 @@
|
| 1419 |
|
| 1420 |
if ( !bDisableAnchor )
|
| 1421 |
{
|
| 1422 |
- switch( pView->GetAnchor() )
|
| 1423 |
+ switch( pView->GetAnchorType() )
|
| 1424 |
{
|
| 1425 |
case SCA_PAGE:
|
| 1426 |
rSet.Put( SfxBoolItem( SID_ANCHOR_PAGE, TRUE ) );
|
| 1427 |
diff -ru sc.orig/source/ui/drawfunc/drawsh5.cxx sc/source/ui/drawfunc/drawsh5.cxx
|
| 1428 |
--- sc.orig/source/ui/drawfunc/drawsh5.cxx 2009-06-04 12:39:40.000000000 +0100
|
| 1429 |
+++ sc/source/ui/drawfunc/drawsh5.cxx 2009-06-04 12:40:23.000000000 +0100
|
| 1430 |
@@ -397,26 +397,26 @@
|
| 1431 |
break;
|
| 1432 |
|
| 1433 |
case SID_ANCHOR_PAGE:
|
| 1434 |
- pView->SetAnchor( SCA_PAGE );
|
| 1435 |
+ pView->SetPageAnchored();
|
| 1436 |
rBindings.Invalidate( SID_ANCHOR_PAGE );
|
| 1437 |
rBindings.Invalidate( SID_ANCHOR_CELL );
|
| 1438 |
break;
|
| 1439 |
|
| 1440 |
case SID_ANCHOR_CELL:
|
| 1441 |
- pView->SetAnchor( SCA_CELL );
|
| 1442 |
+ pView->SetCellAnchored();
|
| 1443 |
rBindings.Invalidate( SID_ANCHOR_PAGE );
|
| 1444 |
rBindings.Invalidate( SID_ANCHOR_CELL );
|
| 1445 |
break;
|
| 1446 |
|
| 1447 |
case SID_ANCHOR_TOGGLE:
|
| 1448 |
{
|
| 1449 |
- switch( pView->GetAnchor() )
|
| 1450 |
+ switch( pView->GetAnchorType() )
|
| 1451 |
{
|
| 1452 |
case SCA_CELL:
|
| 1453 |
- pView->SetAnchor( SCA_PAGE );
|
| 1454 |
+ pView->SetPageAnchored();
|
| 1455 |
break;
|
| 1456 |
default:
|
| 1457 |
- pView->SetAnchor( SCA_CELL );
|
| 1458 |
+ pView->SetCellAnchored();
|
| 1459 |
break;
|
| 1460 |
}
|
| 1461 |
}
|
| 1462 |
diff -ru sc.orig/source/ui/inc/drawview.hxx sc/source/ui/inc/drawview.hxx
|
| 1463 |
--- sc.orig/source/ui/inc/drawview.hxx 2009-06-04 12:39:46.000000000 +0100
|
| 1464 |
+++ sc/source/ui/inc/drawview.hxx 2009-06-04 12:40:23.000000000 +0100
|
| 1465 |
@@ -100,8 +100,9 @@
|
| 1466 |
|
| 1467 |
void CalcNormScale( Fraction& rFractX, Fraction& rFractY ) const;
|
| 1468 |
|
| 1469 |
- void SetAnchor( ScAnchorType );
|
| 1470 |
- ScAnchorType GetAnchor() const;
|
| 1471 |
+ void SetPageAnchored();
|
| 1472 |
+ void SetCellAnchored();
|
| 1473 |
+ ScAnchorType GetAnchorType() const;
|
| 1474 |
|
| 1475 |
void VCAddWin( Window* pWin );
|
| 1476 |
void VCRemoveWin( Window* pWin );
|
| 1477 |
diff -ru sc.orig/source/ui/unoobj/shapeuno.cxx sc/source/ui/unoobj/shapeuno.cxx
|
| 1478 |
--- sc.orig/source/ui/unoobj/shapeuno.cxx 2009-06-04 12:39:29.000000000 +0100
|
| 1479 |
+++ sc/source/ui/unoobj/shapeuno.cxx 2009-06-04 12:40:23.000000000 +0100
|
| 1480 |
@@ -365,20 +365,9 @@
|
| 1481 |
table::CellRangeAddress aAddress = xRangeAdd->getRangeAddress();
|
| 1482 |
if (nTab == aAddress.Sheet)
|
| 1483 |
{
|
| 1484 |
- if (aAddress.StartRow != aAddress.EndRow) //should be a Spreadsheet
|
| 1485 |
- {
|
| 1486 |
- DBG_ASSERT(aAddress.StartRow == 0 && aAddress.EndRow == MAXROW &&
|
| 1487 |
- aAddress.StartColumn == 0 && aAddress.EndColumn == MAXCOL, "here should be a XSpreadsheet");
|
| 1488 |
- ScDrawLayer::SetAnchor(pObj, SCA_PAGE);
|
| 1489 |
- }
|
| 1490 |
- else
|
| 1491 |
- {
|
| 1492 |
- DBG_ASSERT(aAddress.StartRow == aAddress.EndRow &&
|
| 1493 |
- aAddress.StartColumn == aAddress.EndColumn, "here should be a XCell");
|
| 1494 |
- ScDrawLayer::SetAnchor(pObj, SCA_CELL);
|
| 1495 |
- }
|
| 1496 |
Rectangle aRect(pDoc->GetMMRect( static_cast<SCCOL>(aAddress.StartColumn), static_cast<SCROW>(aAddress.StartRow),
|
| 1497 |
static_cast<SCCOL>(aAddress.EndColumn), static_cast<SCROW>(aAddress.EndRow), aAddress.Sheet ));
|
| 1498 |
+ awt::Point aRelPoint;
|
| 1499 |
uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY );
|
| 1500 |
if (xShape.is())
|
| 1501 |
{
|
| 1502 |
@@ -397,7 +386,8 @@
|
| 1503 |
awt::Size aUnoSize;
|
| 1504 |
awt::Point aCaptionPoint;
|
| 1505 |
ScRange aRange;
|
| 1506 |
- awt::Point aUnoPoint(lcl_GetRelativePos( xShape, pDoc, nTab, aRange, aUnoSize, aCaptionPoint ));
|
| 1507 |
+ aRelPoint = lcl_GetRelativePos( xShape, pDoc, nTab, aRange, aUnoSize, aCaptionPoint );
|
| 1508 |
+ awt::Point aUnoPoint(aRelPoint);
|
| 1509 |
|
| 1510 |
aUnoPoint.X += aPoint.X();
|
| 1511 |
aUnoPoint.Y += aPoint.Y();
|
| 1512 |
@@ -426,6 +416,24 @@
|
| 1513 |
xShape->setPosition(aUnoPoint);
|
| 1514 |
pDocSh->SetModified();
|
| 1515 |
}
|
| 1516 |
+
|
| 1517 |
+ if (aAddress.StartRow != aAddress.EndRow) //should be a Spreadsheet
|
| 1518 |
+ {
|
| 1519 |
+ DBG_ASSERT(aAddress.StartRow == 0 && aAddress.EndRow == MAXROW &&
|
| 1520 |
+ aAddress.StartColumn == 0 && aAddress.EndColumn == MAXCOL, "here should be a XSpreadsheet");
|
| 1521 |
+ ScDrawLayer::SetPageAnchored(*pObj);
|
| 1522 |
+ }
|
| 1523 |
+ else
|
| 1524 |
+ {
|
| 1525 |
+ DBG_ASSERT(aAddress.StartRow == aAddress.EndRow &&
|
| 1526 |
+ aAddress.StartColumn == aAddress.EndColumn, "here should be a XCell");
|
| 1527 |
+ ScDrawObjData aAnchor;
|
| 1528 |
+ aAnchor.maStart = ScAddress(aAddress.StartColumn, aAddress.StartRow, aAddress.Sheet);
|
| 1529 |
+ aAnchor.maStartOffset = Point(aRelPoint.X, aRelPoint.Y);
|
| 1530 |
+ ScDrawLayer::SetCellAnchored(*pObj, aAnchor);
|
| 1531 |
+ //Currently we've only got a start anchor, not an end-anchor, so generate that now
|
| 1532 |
+ ScDrawLayer::UpdateCellAnchorFromPositionEnd(*pObj, *pDoc, aAddress.Sheet);
|
| 1533 |
+ }
|
| 1534 |
}
|
| 1535 |
}
|
| 1536 |
}
|
| 1537 |
@@ -485,7 +493,7 @@
|
| 1538 |
uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY );
|
| 1539 |
if (xShape.is())
|
| 1540 |
{
|
| 1541 |
- if (ScDrawLayer::GetAnchor(pObj) == SCA_PAGE)
|
| 1542 |
+ if (ScDrawLayer::GetAnchorType(*pObj) == SCA_PAGE)
|
| 1543 |
{
|
| 1544 |
awt::Point aPoint(xShape->getPosition());
|
| 1545 |
awt::Size aSize(xShape->getSize());
|
| 1546 |
@@ -512,7 +520,7 @@
|
| 1547 |
xShape->setPosition(aPoint);
|
| 1548 |
pDocSh->SetModified();
|
| 1549 |
}
|
| 1550 |
- else if (ScDrawLayer::GetAnchor(pObj) == SCA_CELL)
|
| 1551 |
+ else if (ScDrawLayer::GetAnchorType(*pObj) == SCA_CELL)
|
| 1552 |
{
|
| 1553 |
awt::Size aUnoSize;
|
| 1554 |
awt::Point aCaptionPoint;
|
| 1555 |
@@ -583,7 +591,7 @@
|
| 1556 |
uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY );
|
| 1557 |
if (xShape.is())
|
| 1558 |
{
|
| 1559 |
- if (ScDrawLayer::GetAnchor(pObj) == SCA_PAGE)
|
| 1560 |
+ if (ScDrawLayer::GetAnchorType(*pObj) == SCA_PAGE)
|
| 1561 |
{
|
| 1562 |
awt::Point aPoint = xShape->getPosition();
|
| 1563 |
awt::Point aCaptionPoint;
|
| 1564 |
@@ -596,7 +604,7 @@
|
| 1565 |
xShape->setPosition(aPoint);
|
| 1566 |
pDocSh->SetModified();
|
| 1567 |
}
|
| 1568 |
- else if (ScDrawLayer::GetAnchor(pObj) == SCA_CELL)
|
| 1569 |
+ else if (ScDrawLayer::GetAnchorType(*pObj) == SCA_CELL)
|
| 1570 |
{
|
| 1571 |
awt::Size aUnoSize;
|
| 1572 |
awt::Point aCaptionPoint;
|
| 1573 |
@@ -663,23 +671,10 @@
|
| 1574 |
{
|
| 1575 |
ScDocShell* pDocSh = (ScDocShell*)pObjSh;
|
| 1576 |
uno::Reference< uno::XInterface > xAnchor;
|
| 1577 |
- if (ScDrawLayer::GetAnchor(pObj) == SCA_CELL)
|
| 1578 |
- {
|
| 1579 |
- uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY );
|
| 1580 |
- if (xShape.is())
|
| 1581 |
- {
|
| 1582 |
- awt::Size aUnoSize;
|
| 1583 |
- awt::Point aCaptionPoint;
|
| 1584 |
- ScRange aRange;
|
| 1585 |
- awt::Point aUnoPoint(lcl_GetRelativePos( xShape, pDoc, nTab, aRange, aUnoSize, aCaptionPoint ));
|
| 1586 |
-
|
| 1587 |
- xAnchor.set(static_cast<cppu::OWeakObject*>(new ScCellObj( pDocSh, aRange.aStart )));
|
| 1588 |
- }
|
| 1589 |
- }
|
| 1590 |
+ if (ScDrawObjData *pAnchor = ScDrawLayer::GetObjDataTab(pObj, nTab))
|
| 1591 |
+ xAnchor.set(static_cast<cppu::OWeakObject*>(new ScCellObj( pDocSh, pAnchor->maStart)));
|
| 1592 |
else
|
| 1593 |
- {
|
| 1594 |
xAnchor.set(static_cast<cppu::OWeakObject*>(new ScTableSheetObj( pDocSh, nTab )));
|
| 1595 |
- }
|
| 1596 |
aAny <<= xAnchor;
|
| 1597 |
}
|
| 1598 |
}
|
| 1599 |
@@ -722,7 +717,7 @@
|
| 1600 |
uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY );
|
| 1601 |
if (xShape.is())
|
| 1602 |
{
|
| 1603 |
- if (ScDrawLayer::GetAnchor(pObj) == SCA_CELL)
|
| 1604 |
+ if (ScDrawLayer::GetAnchorType(*pObj) == SCA_CELL)
|
| 1605 |
{
|
| 1606 |
awt::Size aUnoSize;
|
| 1607 |
awt::Point aCaptionPoint;
|
| 1608 |
@@ -782,7 +777,7 @@
|
| 1609 |
if (xShape.is())
|
| 1610 |
{
|
| 1611 |
uno::Reference< uno::XInterface > xAnchor;
|
| 1612 |
- if (ScDrawLayer::GetAnchor(pObj) == SCA_CELL)
|
| 1613 |
+ if (ScDrawLayer::GetAnchorType(*pObj) == SCA_CELL)
|
| 1614 |
{
|
| 1615 |
awt::Size aUnoSize;
|
| 1616 |
awt::Point aCaptionPoint;
|
| 1617 |
diff -ru sc.orig/source/ui/view/drawvie3.cxx sc/source/ui/view/drawvie3.cxx
|
| 1618 |
--- sc.orig/source/ui/view/drawvie3.cxx 2009-06-04 12:39:42.000000000 +0100
|
| 1619 |
+++ sc/source/ui/view/drawvie3.cxx 2009-06-05 08:47:05.000000000 +0100
|
| 1620 |
@@ -77,7 +77,7 @@
|
| 1621 |
|
| 1622 |
// Verankerung setzen
|
| 1623 |
|
| 1624 |
-void ScDrawView::SetAnchor( ScAnchorType eType )
|
| 1625 |
+void ScDrawView::SetPageAnchored()
|
| 1626 |
{
|
| 1627 |
SdrObject* pObj = NULL;
|
| 1628 |
if( AreObjectsMarked() )
|
| 1629 |
@@ -87,7 +87,7 @@
|
| 1630 |
for( ULONG i=0; i<nCount; i++ )
|
| 1631 |
{
|
| 1632 |
pObj = pMark->GetMark(i)->GetMarkedSdrObj();
|
| 1633 |
- ScDrawLayer::SetAnchor( pObj, eType );
|
| 1634 |
+ ScDrawLayer::SetPageAnchored( *pObj );
|
| 1635 |
}
|
| 1636 |
|
| 1637 |
if ( pViewData )
|
| 1638 |
@@ -95,7 +95,28 @@
|
| 1639 |
}
|
| 1640 |
}
|
| 1641 |
|
| 1642 |
-ScAnchorType ScDrawView::GetAnchor() const
|
| 1643 |
+void ScDrawView::SetCellAnchored()
|
| 1644 |
+{
|
| 1645 |
+ if (!pDoc)
|
| 1646 |
+ return;
|
| 1647 |
+
|
| 1648 |
+ SdrObject* pObj = NULL;
|
| 1649 |
+ if( AreObjectsMarked() )
|
| 1650 |
+ {
|
| 1651 |
+ const SdrMarkList* pMark = &GetMarkedObjectList();
|
| 1652 |
+ ULONG nCount = pMark->GetMarkCount();
|
| 1653 |
+ for( ULONG i=0; i<nCount; i++ )
|
| 1654 |
+ {
|
| 1655 |
+ pObj = pMark->GetMark(i)->GetMarkedSdrObj();
|
| 1656 |
+ ScDrawLayer::SetCellAnchoredFromPosition(*pObj, *pDoc, nTab);
|
| 1657 |
+ }
|
| 1658 |
+
|
| 1659 |
+ if ( pViewData )
|
| 1660 |
+ pViewData->GetDocShell()->SetDrawModified();
|
| 1661 |
+ }
|
| 1662 |
+}
|
| 1663 |
+
|
| 1664 |
+ScAnchorType ScDrawView::GetAnchorType() const
|
| 1665 |
{
|
| 1666 |
BOOL bPage = FALSE;
|
| 1667 |
BOOL bCell = FALSE;
|
| 1668 |
@@ -108,7 +129,7 @@
|
| 1669 |
for( ULONG i=0; i<nCount; i++ )
|
| 1670 |
{
|
| 1671 |
pObj = pMark->GetMark(i)->GetMarkedSdrObj();
|
| 1672 |
- if( ScDrawLayer::GetAnchor( pObj ) == SCA_CELL )
|
| 1673 |
+ if( ScDrawLayer::GetAnchorType( *pObj ) == SCA_CELL )
|
| 1674 |
bCell =TRUE;
|
| 1675 |
else
|
| 1676 |
bPage = TRUE;
|
| 1677 |
@@ -138,6 +159,20 @@
|
| 1678 |
if ( nTab == ((ScTabSizeChangedHint&)rHint).GetTab() )
|
| 1679 |
UpdateWorkArea();
|
| 1680 |
}
|
| 1681 |
+ else if ( rHint.ISA( SdrHint ) )
|
| 1682 |
+ {
|
| 1683 |
+ if (const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint ))
|
| 1684 |
+ {
|
| 1685 |
+ //Update the anchors of any non note object that is cell anchored which has
|
| 1686 |
+ //been moved since the last anchors for its position was calculated
|
| 1687 |
+ if (pSdrHint->GetKind() == HINT_OBJCHG || pSdrHint->GetKind() == HINT_OBJINSERTED)
|
| 1688 |
+ if (SdrObject* pObj = const_cast<SdrObject*>(pSdrHint->GetObject()))
|
| 1689 |
+ if (ScDrawObjData *pAnchor = ScDrawLayer::GetObjData(pObj))
|
| 1690 |
+ if (!pAnchor->mbNote && pAnchor->maLastRect != pObj->GetLogicRect())
|
| 1691 |
+ ScDrawLayer::SetCellAnchoredFromPosition(*pObj, *pDoc, nTab);
|
| 1692 |
+ }
|
| 1693 |
+ FmFormView::Notify( rBC,rHint );
|
| 1694 |
+ }
|
| 1695 |
else
|
| 1696 |
FmFormView::Notify( rBC,rHint );
|
| 1697 |
}
|
| 1698 |
diff -ru sc.orig/source/ui/view/drawview.cxx sc/source/ui/view/drawview.cxx
|
| 1699 |
--- sc.orig/source/ui/view/drawview.cxx 2009-06-04 12:39:41.000000000 +0100
|
| 1700 |
+++ sc/source/ui/view/drawview.cxx 2009-06-04 12:40:23.000000000 +0100
|
| 1701 |
@@ -164,40 +164,11 @@
|
| 1702 |
UINT32 nCount = rMrkList.GetMarkCount();
|
| 1703 |
for(UINT32 nPos=0; nPos<nCount; nPos++ )
|
| 1704 |
{
|
| 1705 |
- const SdrObject* pObj = rMrkList.GetMark(nPos)->GetMarkedSdrObj();
|
| 1706 |
- if(ScDrawLayer::GetAnchor(pObj) == SCA_CELL)
|
| 1707 |
+ SdrObject* pObj = rMrkList.GetMark(nPos)->GetMarkedSdrObj();
|
| 1708 |
+ if (ScDrawObjData *pAnchor = ScDrawLayer::GetObjDataTab(pObj, nTab))
|
| 1709 |
{
|
| 1710 |
- const INT32 nDelta = 1;
|
| 1711 |
-
|
| 1712 |
- Rectangle aBoundRect = pObj->GetCurrentBoundRect();
|
| 1713 |
- Point aPos;
|
| 1714 |
- if (bNegativePage)
|
| 1715 |
- {
|
| 1716 |
- aPos = aBoundRect.TopRight();
|
| 1717 |
- aPos.X() = -aPos.X(); // so the loop below is the same
|
| 1718 |
- }
|
| 1719 |
- else
|
| 1720 |
- aPos = aBoundRect.TopLeft();
|
| 1721 |
- long nPosX = (long) (aPos.X() / HMM_PER_TWIPS) + nDelta;
|
| 1722 |
- long nPosY = (long) (aPos.Y() / HMM_PER_TWIPS) + nDelta;
|
| 1723 |
-
|
| 1724 |
- SCCOL nCol;
|
| 1725 |
- INT32 nWidth = 0;
|
| 1726 |
-
|
| 1727 |
- for(nCol=0; nCol<=MAXCOL && nWidth<=nPosX; nCol++)
|
| 1728 |
- nWidth += pDoc->GetColWidth(nCol,nTab);
|
| 1729 |
-
|
| 1730 |
- if(nCol > 0)
|
| 1731 |
- --nCol;
|
| 1732 |
-
|
| 1733 |
- SCROW nRow = nPosY <= 0 ? 0 : pDoc->FastGetRowForHeight( nTab,
|
| 1734 |
- (ULONG) nPosY);
|
| 1735 |
- if(nRow > 0)
|
| 1736 |
- --nRow;
|
| 1737 |
-
|
| 1738 |
- ScTabView* pView = pViewData->GetView();
|
| 1739 |
- ScAddress aScAddress(nCol, nRow, nTab);
|
| 1740 |
- pView->CreateAnchorHandles(aHdl, aScAddress);
|
| 1741 |
+ if (ScTabView* pView = pViewData->GetView())
|
| 1742 |
+ pView->CreateAnchorHandles(aHdl, pAnchor->maStart);
|
| 1743 |
}
|
| 1744 |
}
|
| 1745 |
}
|