Commits

Anonymous committed 5c30191

CWS-TOOLING: integrate CWS calc31stopper3_DEV300
2009-03-12 17:41:49 +0100 er r269429 : #i100135# reference (position and size) never changes for external references when inserting/deleting/moving cells
2009-03-12 15:29:31 +0100 dr r269424 : #i10000# missing parentheses
2009-03-12 15:15:11 +0100 dr r269422 : #i100148# handle empty text shapes

  • Participants
  • Parent commits aedc74e

Comments (0)

Files changed (6)

oox/source/xls/worksheethelper.cxx

 
 void WorksheetData::setCellFormat( const OoxCellData& rCellData )
 {
-    if( rCellData.mxCell.is() && (rCellData.mnXfId >= 0) || (rCellData.mnNumFmtId >= 0) )
+    if( rCellData.mxCell.is() && ((rCellData.mnXfId >= 0) || (rCellData.mnNumFmtId >= 0)) )
     {
         // try to merge existing ranges and to write some formatting properties
         if( !maXfIdRanges.empty() )
     virtual const String&           GetString() const;
     virtual const ScSingleRefData&  GetSingleRef() const;
     virtual ScSingleRefData&          GetSingleRef();
+    virtual void                CalcAbsIfRel( const ScAddress& );
+    virtual void                CalcRelFromAbs( const ScAddress& );
     virtual BOOL                operator==( const formula::FormulaToken& rToken ) const;
     virtual FormulaToken*       Clone() const { return new ScExternalSingleRefToken(*this); }
 };
     virtual ScSingleRefData&       GetSingleRef2();
     virtual const ScComplexRefData&    GetDoubleRef() const;
     virtual ScComplexRefData&      GetDoubleRef();
+    virtual void                CalcAbsIfRel( const ScAddress& );
+    virtual void                CalcRelFromAbs( const ScAddress& );
     virtual BOOL                operator==( const formula::FormulaToken& rToken ) const;
     virtual FormulaToken*       Clone() const { return new ScExternalDoubleRefToken(*this); }
 };

sc/source/core/tool/compiler.cxx

             else if( t->GetType() != svIndex )  // it may be a DB area!!!
             {
                 t->CalcAbsIfRel( rOldPos );
-                if ( t->GetType() == svSingleRef || t->GetType() == svExternalSingleRef )
+                switch (t->GetType())
                 {
-                    if ( ScRefUpdate::Update( pDoc, eUpdateRefMode, aPos,
-                            r, nDx, nDy, nDz,
-                            SingleDoubleRefModifier( t->GetSingleRef() ).Ref() )
-                            != UR_NOTHING
-                        )
-                        rChanged = TRUE;
-                }
-                else
-                {
-                    ScComplexRefData& rRef = t->GetDoubleRef();
-                    SCCOL nCols = rRef.Ref2.nCol - rRef.Ref1.nCol;
-                    SCROW nRows = rRef.Ref2.nRow - rRef.Ref1.nRow;
-                    SCTAB nTabs = rRef.Ref2.nTab - rRef.Ref1.nTab;
-                    if ( ScRefUpdate::Update( pDoc, eUpdateRefMode, aPos,
-                                r, nDx, nDy, nDz, t->GetDoubleRef() )
-                            != UR_NOTHING
-                        )
-                    {
-                        rChanged = TRUE;
-                        if (rRef.Ref2.nCol - rRef.Ref1.nCol != nCols ||
-                                rRef.Ref2.nRow - rRef.Ref1.nRow != nRows ||
-                                rRef.Ref2.nTab - rRef.Ref1.nTab != nTabs)
-                            rRefSizeChanged = TRUE;
-                    }
+                    case svExternalSingleRef:
+                    case svExternalDoubleRef:
+                        // External references never change their positioning 
+                        // nor point to parts that will be removed or expanded. 
+                        // In fact, calling ScRefUpdate::Update() for URM_MOVE 
+                        // may have negative side effects. Simply adapt 
+                        // relative references to the new position.
+                        t->CalcRelFromAbs( aPos);
+                        break;
+                    case svSingleRef:
+                        {
+                            if ( ScRefUpdate::Update( pDoc, eUpdateRefMode, 
+                                        aPos, r, nDx, nDy, nDz, 
+                                        SingleDoubleRefModifier( 
+                                            t->GetSingleRef()).Ref())
+                                    != UR_NOTHING)
+                                rChanged = TRUE;
+                        }
+                        break;
+                    default:
+                        {
+                            ScComplexRefData& rRef = t->GetDoubleRef();
+                            SCCOL nCols = rRef.Ref2.nCol - rRef.Ref1.nCol;
+                            SCROW nRows = rRef.Ref2.nRow - rRef.Ref1.nRow;
+                            SCTAB nTabs = rRef.Ref2.nTab - rRef.Ref1.nTab;
+                            if ( ScRefUpdate::Update( pDoc, eUpdateRefMode, 
+                                        aPos, r, nDx, nDy, nDz, 
+                                        t->GetDoubleRef()) != UR_NOTHING)
+                            {
+                                rChanged = TRUE;
+                                if (rRef.Ref2.nCol - rRef.Ref1.nCol != nCols ||
+                                        rRef.Ref2.nRow - rRef.Ref1.nRow != nRows ||
+                                        rRef.Ref2.nTab - rRef.Ref1.nTab != nTabs)
+                                    rRefSizeChanged = TRUE;
+                            }
+                        }
                 }
             }
         }

sc/source/core/tool/token.cxx

     return maSingleRef;
 }
 
+void ScExternalSingleRefToken::CalcAbsIfRel( const ScAddress& rPos )
+{
+    maSingleRef.CalcAbsIfRel( rPos );
+}
+
+void ScExternalSingleRefToken::CalcRelFromAbs( const ScAddress& rPos )
+{
+    maSingleRef.CalcRelFromAbs( rPos );
+}
+
 BOOL ScExternalSingleRefToken::operator ==( const FormulaToken& r ) const
 {
     if (!FormulaToken::operator==(r))
     return maDoubleRef;
 }
 
+void ScExternalDoubleRefToken::CalcAbsIfRel( const ScAddress& rPos )
+{
+    maDoubleRef.CalcAbsIfRel( rPos );
+}
+
+void ScExternalDoubleRefToken::CalcRelFromAbs( const ScAddress& rPos )
+{
+    maDoubleRef.CalcRelFromAbs( rPos );
+}
+
 BOOL ScExternalDoubleRefToken::operator ==( const FormulaToken& r ) const
 {
     if (!ScToken::operator==(r))

sc/source/filter/excel/xiescher.cxx

                 // plain text
                 pTextObj->NbcSetText( maTextData.mxString->GetText() );
             }
+
+            /*  #i96858# Do not apply any formatting if there is no text.
+                SdrObjCustomShape::SetVerticalWriting (initiated from
+                SetMergedItem) calls SdrTextObj::ForceOutlinerParaObject which
+                ensures that we can erroneously write a ClientTextbox record
+                (with no content) while exporting to XLS, which can cause a
+                corrupted exported document. */
+
+            // horizontal text alignment
+            SvxAdjust eHorAlign = SVX_ADJUST_LEFT;
+            switch( maTextData.maData.GetHorAlign() )
+            {
+                case EXC_OBJ_HOR_LEFT:      eHorAlign = SVX_ADJUST_LEFT;    break;
+                case EXC_OBJ_HOR_CENTER:    eHorAlign = SVX_ADJUST_CENTER;  break;
+                case EXC_OBJ_HOR_RIGHT:     eHorAlign = SVX_ADJUST_RIGHT;   break;
+                case EXC_OBJ_HOR_JUSTIFY:   eHorAlign = SVX_ADJUST_BLOCK;   break;
+            }
+            rSdrObj.SetMergedItem( SvxAdjustItem( eHorAlign, EE_PARA_JUST ) );
+
+            // vertical text alignment
+            SdrTextVertAdjust eVerAlign = SDRTEXTVERTADJUST_TOP;
+            switch( maTextData.maData.GetVerAlign() )
+            {
+                case EXC_OBJ_VER_TOP:       eVerAlign = SDRTEXTVERTADJUST_TOP;      break;
+                case EXC_OBJ_VER_CENTER:    eVerAlign = SDRTEXTVERTADJUST_CENTER;   break;
+                case EXC_OBJ_VER_BOTTOM:    eVerAlign = SDRTEXTVERTADJUST_BOTTOM;   break;
+                case EXC_OBJ_VER_JUSTIFY:   eVerAlign = SDRTEXTVERTADJUST_BLOCK;    break;
+            }
+            rSdrObj.SetMergedItem( SdrTextVertAdjustItem( eVerAlign ) );
+
+            // orientation (this is only a fake, drawing does not support real text orientation)
+            namespace csst = ::com::sun::star::text;
+            csst::WritingMode eWriteMode = csst::WritingMode_LR_TB;
+            switch( maTextData.maData.mnOrient )
+            {
+                case EXC_OBJ_ORIENT_NONE:       eWriteMode = csst::WritingMode_LR_TB;   break;
+                case EXC_OBJ_ORIENT_STACKED:    eWriteMode = csst::WritingMode_TB_RL;   break;
+                case EXC_OBJ_ORIENT_90CCW:      eWriteMode = csst::WritingMode_TB_RL;   break;
+                case EXC_OBJ_ORIENT_90CW:       eWriteMode = csst::WritingMode_TB_RL;   break;
+            }
+            rSdrObj.SetMergedItem( SvxWritingModeItem( eWriteMode, SDRATTR_TEXTDIRECTION ) );
         }
-
-        // horizontal text alignment
-        SvxAdjust eHorAlign = SVX_ADJUST_LEFT;
-        switch( maTextData.maData.GetHorAlign() )
-        {
-            case EXC_OBJ_HOR_LEFT:      eHorAlign = SVX_ADJUST_LEFT;    break;
-            case EXC_OBJ_HOR_CENTER:    eHorAlign = SVX_ADJUST_CENTER;  break;
-            case EXC_OBJ_HOR_RIGHT:     eHorAlign = SVX_ADJUST_RIGHT;   break;
-            case EXC_OBJ_HOR_JUSTIFY:   eHorAlign = SVX_ADJUST_BLOCK;   break;
-        }
-        rSdrObj.SetMergedItem( SvxAdjustItem( eHorAlign, EE_PARA_JUST ) );
-
-        // vertical text alignment
-        SdrTextVertAdjust eVerAlign = SDRTEXTVERTADJUST_TOP;
-        switch( maTextData.maData.GetVerAlign() )
-        {
-            case EXC_OBJ_VER_TOP:       eVerAlign = SDRTEXTVERTADJUST_TOP;      break;
-            case EXC_OBJ_VER_CENTER:    eVerAlign = SDRTEXTVERTADJUST_CENTER;   break;
-            case EXC_OBJ_VER_BOTTOM:    eVerAlign = SDRTEXTVERTADJUST_BOTTOM;   break;
-            case EXC_OBJ_VER_JUSTIFY:   eVerAlign = SDRTEXTVERTADJUST_BLOCK;    break;
-        }
-        rSdrObj.SetMergedItem( SdrTextVertAdjustItem( eVerAlign ) );
-
-        // orientation (this is only a fake, drawing does not support real text orientation)
-        namespace csst = ::com::sun::star::text;
-        csst::WritingMode eWriteMode = csst::WritingMode_LR_TB;
-        switch( maTextData.maData.mnOrient )
-        {
-            case EXC_OBJ_ORIENT_NONE:       eWriteMode = csst::WritingMode_LR_TB;   break;
-            case EXC_OBJ_ORIENT_STACKED:    eWriteMode = csst::WritingMode_TB_RL;   break;
-            case EXC_OBJ_ORIENT_90CCW:      eWriteMode = csst::WritingMode_TB_RL;   break;
-            case EXC_OBJ_ORIENT_90CW:       eWriteMode = csst::WritingMode_TB_RL;   break;
-        }
-        rSdrObj.SetMergedItem( SvxWritingModeItem( eWriteMode, SDRATTR_TEXTDIRECTION ) );
     }
     // base class processing
     XclImpRectObj::DoProcessSdrObj( rSdrObj );

sc/source/filter/xcl97/xcl97rec.cxx

 {
     DBG_ASSERT( mpString.get(), "XclTxo::SaveCont - missing string" );
 
-    sal_uInt16 nRunLen = 8 * mpString->GetFormatsCount();
+    // #i96858# do not save existing string formatting if text is empty
+    sal_uInt16 nRunLen = mpString->IsEmpty() ? 0 : (8 * mpString->GetFormatsCount());
     // alignment
     sal_uInt16 nFlags = 0;
     ::insert_value( nFlags, mnHorAlign, 1, 3 );