[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - 81 commits - basctl/uiconfig cppcanvas/source cui/source cui/uiconfig dbaccess/source desktop/Library_libreoffice.mk desktop/uiconfig drawinglayer/inc drawinglayer/source extras/source filter/Configuration_filter.mk filter/source filter/uiconfig framework/source helpcontent2 libmariadb/mariadb-trunk-40.patch libmariadb/UnpackedTarball_mariadb.mk libvisio/libvisio-0.0.25.patch libvisio/UnpackedTarball_visio.mk lotuswordpro/source mysqlcppconn/patches neon/Library_neon.mk neon/neon.patch odk/CustomTarget_autodoc.mk odk/CustomTarget_classes.mk odk/CustomTarget_doxygen.mk odk/CustomTarget_javadoc.mk odk/CustomTarget_odkcommon.mk odk/Zip_odkcommon.mk odk/Zip_uno_loader_classes.mk officecfg/registry padmin/uiconfig sc/inc sc/Library_sc.mk sc/qa sc/sdi sc/source sc/uiconfig sd/AllLangResTarget_sd.mk sd/source sd/uiconfig sd/UI_simpress.mk sfx2/inc sfx2/source solenv/gbuild svl/CppunitTest_svl_qa_cppunit.mk svl/Module_svl.mk s vl/qa svtools/uiconfig svx/inc svx/sdi svx/source svx/uiconfig sw/source sw/uiconfig ucb/source vcl/unx writerperfect/source

Kohei Yoshida kohei.yoshida at gmail.com
Fri Mar 15 09:38:50 PDT 2013


Rebased ref, commits from common ancestor:
commit 65c38e8024c13e2325cf5b47e261a2c75a8af2ea
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Fri Mar 15 12:39:59 2013 -0400

    Flush buffer before aborting; else we may not see the output at all.
    
    Change-Id: Iae5e604d6f947c8ab7853ef5cc2cfbe9566fea0c

diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index a1a84bb..84cc89d 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1397,12 +1397,14 @@ void ScColumn::CellStorageModified()
         if (maTextWidths.empty())
         {
             cout << "ScColumn::CellStorageModified: Text width array is empty, but shouldn't." << endl;
+            cout.flush();
             abort();
         }
 
         if (maTextWidths.block_size() != 1 || maTextWidths.begin()->type != mdds::mtv::element_type_empty)
         {
             cout << "ScColumn::CellStorageModified: When the cell array is empty, the text with array should consist of one empty block." << endl;
+            cout.flush();
             abort();
         }
 
commit 5874231b8a7fc790299e9129684271b5ca70410b
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Fri Mar 15 11:20:19 2013 -0400

    Turn off debugging and silence compiler warning.
    
    Change-Id: If2bfc9f346d7f2eee20caa30e1eb1f60d266ef90

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 666d067..dd14b6a 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -28,7 +28,7 @@
 #include <set>
 #include <vector>
 
-#define DEBUG_COLUMN_STORAGE 1
+#define DEBUG_COLUMN_STORAGE 0
 
 #if DEBUG_COLUMN_STORAGE
 #ifdef NDEBUG
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index f96515a..a1a84bb 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1449,10 +1449,12 @@ sal_uInt8 ScColumn::GetScriptType( SCROW nRow ) const
     return SC_SCRIPTTYPE_UNKNOWN;
 }
 
-void ScColumn::SetScriptType( SCROW nRow, sal_uInt8 nType )
+void ScColumn::SetScriptType( SCROW nRow, sal_uInt8 /*nType*/ )
 {
     if (!ValidRow(nRow))
         return;
+
+    // TODO: Implement this.
 }
 
 void ScColumn::FindDataAreaPos(SCROW& rRow, bool bDown) const
commit 3a78c5b9898f70ca0163501ae2b583a7cb76d51f
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Fri Mar 15 11:10:39 2013 -0400

    Oops the erase() method takes start and end positions.
    
    The second parameter has to be the absolute end position, not the size
    from the start position.
    
    Change-Id: I310ec52697d0521a82810889f6fe861471279645

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 62f0135..0ba6f01 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -262,7 +262,7 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize )
     // There are cells below the deletion point.  Shift their row positions.
 
     // Shift the text width array too (before the broadcast).
-    maTextWidths.erase(nStartRow, nSize);
+    maTextWidths.erase(nStartRow, nEndRow);
     maTextWidths.resize(MAXROW);
 
     ScAddress aAdr( nCol, 0, nTab );
commit 431c4536ce58410d6dd3e199185bd128bac624ef
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Fri Mar 15 10:57:42 2013 -0400

    Better consistency checking.
    
    Change-Id: I096282ebb9a10d212affbab32aaa49ca1815b1a7

diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 19e5e9c..f96515a 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1392,18 +1392,42 @@ SCROW ScColumn::FindNextVisibleRowWithContent(SCROW nRow, bool bForward) const
 void ScColumn::CellStorageModified()
 {
 #if DEBUG_COLUMN_STORAGE
+    if (maItems.empty())
+    {
+        if (maTextWidths.empty())
+        {
+            cout << "ScColumn::CellStorageModified: Text width array is empty, but shouldn't." << endl;
+            abort();
+        }
+
+        if (maTextWidths.block_size() != 1 || maTextWidths.begin()->type != mdds::mtv::element_type_empty)
+        {
+            cout << "ScColumn::CellStorageModified: When the cell array is empty, the text with array should consist of one empty block." << endl;
+            abort();
+        }
+
+        return;
+    }
+
+    cout << "-- begin" << endl;
+    std::vector<ColEntry>::const_iterator it = maItems.begin(), itEnd = maItems.end();
+    for (; it != itEnd; ++it)
+        cout << "ScColumn::CellStorageModified: entry: row = " << it->nRow << "; cell = " << it->pCell << endl;
+
     ScColumnTextWidthIterator aIter(*this, 0, MAXROW);
     for (; aIter.hasCell(); aIter.next())
     {
         SCROW nRow = aIter.getPos();
         ScBaseCell* pCell = GetCell(nRow);
+        cout << "ScColumn::CellStorageModified: row = " << nRow << "; cell = " << pCell << endl;
         if (!pCell)
         {
-            cout << "Cell and text width storages are out of sync!" << endl;
+            cout << "ScColumn::CellStorageModified: Cell and text width storages are out of sync!" << endl;
             cout.flush();
             abort();
         }
     }
+    cout << "-- end" << endl;
 #endif
 }
 
commit 17be36299fd59babe10de164ef2c885c21ae3a54
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Fri Mar 15 10:55:40 2013 -0400

    Fix the text width array going out of sync when shifting row positions.
    
    Change-Id: I7b9c5554e38a25dd4ff6980e6ae0d1eff241a746

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 6116780..62f0135 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -200,7 +200,9 @@ void ScColumn::FreeAll()
         maItems[i].pCell->Delete();
     maItems.clear();
 
+    // Text width should keep a logical empty range of 0-MAXROW when the cell array is empty.
     maTextWidths.clear();
+    maTextWidths.resize(MAXROW);
     CellStorageModified();
 }
 
@@ -257,6 +259,12 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize )
     else
         i = nFirstIndex;
 
+    // There are cells below the deletion point.  Shift their row positions.
+
+    // Shift the text width array too (before the broadcast).
+    maTextWidths.erase(nStartRow, nSize);
+    maTextWidths.resize(MAXROW);
+
     ScAddress aAdr( nCol, 0, nTab );
     ScHint aHint( SC_HINT_DATACHANGED, aAdr, NULL ); // only areas (ScBaseCell* == NULL)
     ScAddress& rAddress = aHint.GetAddress();
@@ -300,6 +308,7 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize )
         pDocument->AreaBroadcastInRange( aRange, aHint );
     }
 
+    CellStorageModified();
     pDocument->SetAutoCalc( bOldAutoCalc );
 }
 
commit 41afb3ecfa80e3afc907dcf77b8efd17e048309e
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Fri Mar 15 02:55:09 2013 -0400

    Delete cell segments using reverse iterator (as TODO comment said).
    
    This makes it much simpler, and less error-prone.
    
    Change-Id: I21dbe0d2bb4a71fc2ac738a5ffb03e4d959d91a5

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index f09367b..6116780 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -165,12 +165,12 @@ void ScColumn::Delete( SCROW nRow )
         {
             pNoteCell->Delete();
             maItems.erase( maItems.begin() + nIndex);
+            maTextWidths.set_empty(nRow, nRow);
             // Should we free memory here (delta)? It'll be slower!
         }
         pCell->EndListeningTo( pDocument );
         pCell->Delete();
 
-        maTextWidths.set_empty(nRow, nRow);
         CellStorageModified();
     }
 }
@@ -360,9 +360,6 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe
 
     ScHint aHint( SC_HINT_DYING, ScAddress( nCol, 0, nTab ), 0 );
 
-    SCROW nStartRow = maItems[nStartIndex].nRow;
-    SCROW nEndRow = maItems[nEndIndex].nRow;
-
     // cache all formula cells, they will be deleted at end of this function
     typedef ::std::vector< ScFormulaCell* > FormulaCellVector;
     FormulaCellVector aDelCells;
@@ -471,50 +468,40 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe
     if (nFirst <= nEndIndex)
         aRemovedSegments.insert_back(nFirst, nEndIndex + 1, true);
 
-    // Remove segments from the column array, containing pDummyCell and formula
-    // cell pointers to be deleted.
-    { // own scope for variables
-        RemovedSegments_t::const_iterator aIt(aRemovedSegments.begin());
-        RemovedSegments_t::const_iterator aEnd(aRemovedSegments.end());
-        // The indexes in aRemovedSegments denote cell positions in the
-        // original array. But as we are shifting it from the left, we have
-        // to compensate for already performed shifts for latter segments.
-        // TODO: use reverse iterators instead
-        SCSIZE nShift(0);
-        SCSIZE nStartSegment(nStartIndex);
-        bool bRemoved = false;
-        for (;aIt != aEnd; ++aIt)
+    {
+        // Remove segments from the column array, containing pDummyCell and
+        // formula cell pointers to be deleted.
+
+        RemovedSegments_t::const_reverse_iterator it = aRemovedSegments.rbegin();
+        RemovedSegments_t::const_reverse_iterator itEnd = aRemovedSegments.rend();
+
+        std::vector<ColEntry>::iterator itErase, itEraseEnd;
+        SCSIZE nEndSegment = it->first; // should equal maItems.size(). Non-inclusive.
+        // Skip the first node.
+        for (++it; it != itEnd; ++it)
         {
-            if (aIt->second)
+            if (!it->second)
             {
-                // this segment removed
-                if (!bRemoved)
-                    nStartSegment = aIt->first;
-                    // The first of removes in a row sets start (they should be
-                    // alternating removed/notremoved anyway).
-                bRemoved = true;
+                // Don't remove this segment.
+                nEndSegment = it->first;
                 continue;
             }
 
-            if (bRemoved)
-            {
-                // this segment not removed, but previous segment(s) removed, move tail.
-                SCSIZE const nEndSegment(aIt->first);
-                memmove(
-                        &maItems[nStartSegment - nShift],
-                        &maItems[nEndSegment - nShift],
-                        (maItems.size() - nEndSegment) * sizeof(ColEntry));
-                nShift += nEndSegment - nStartSegment;
-                bRemoved = false;
-            }
+            // Remove this segment.
+            SCSIZE nStartSegment = it->first;
+            SCROW nStartRow = maItems[nStartSegment].nRow;
+            SCROW nEndRow = maItems[nEndSegment-1].nRow;
+
+            itErase = maItems.begin();
+            std::advance(itErase, nStartSegment);
+            itEraseEnd = maItems.begin();
+            std::advance(itEraseEnd, nEndSegment);
+            maItems.erase(itErase, itEraseEnd);
+
+            maTextWidths.set_empty(nStartRow, nEndRow);
+
+            nEndSegment = nStartSegment;
         }
-        // The last removed segment up to aItems.size() is discarded, there's
-        // nothing following to be moved.
-        if (bRemoved)
-            nShift += maItems.size() - nStartSegment;
-        maItems.erase(maItems.end() - nShift, maItems.end());
-        maTextWidths.set_empty(nStartRow, nEndRow);
-        CellStorageModified();
     }
 
     // *** delete all formula cells ***
@@ -1666,8 +1653,8 @@ void ScColumn::RemoveProtected( SCROW nStartRow, SCROW nEndRow )
                     }
                     delete pFormula;
 
-                    CellStorageModified();
                     SetTextWidth(maItems[nIndex].nRow, TEXTWIDTH_DIRTY);
+                    CellStorageModified();
                 }
                 ++nIndex;
             }
commit feb5b164f6a371ee934049c89b3d02ca5308f68e
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Fri Mar 15 02:03:19 2013 -0400

    Don't forget to set text widths here too.
    
    Change-Id: Ieaa9bd0e4f8117e3bc7ceccc68d6f37daac61440

diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index e778f96..a53c8a8 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -879,12 +879,12 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2)
             {
                 // remove ColEntry at old position
                 maItems.erase( maItems.begin() + nIndex1 );
+                maTextWidths.set_empty(nRow1, nRow1);
             }
 
             // Empty text width at the cell 1 position.  For now, we don't
             // transfer the old value to the cell 2 position since Insert() is
             // quite complicated.
-            maTextWidths.set_empty(nRow1, nRow1);
             CellStorageModified();
 
             // insert ColEntry at new position.
@@ -1284,6 +1284,7 @@ void ScColumn::CopyStaticToDocument(SCROW nRow1, SCROW nRow2, ScColumn& rDestCol
         itEnd = std::find_if(it, rDestCol.maItems.end(), FindAboveRow(nRow2));
         std::for_each(it, itEnd, DeleteCell());
         rDestCol.maItems.erase(it, itEnd);
+        rDestCol.maTextWidths.set_empty(nRow1, nRow2);
     }
 
     // Determine the range of cells in the original column that need to be copied.
@@ -1351,6 +1352,10 @@ void ScColumn::CopyStaticToDocument(SCROW nRow1, SCROW nRow2, ScColumn& rDestCol
     // destination column shouldn't have any cells within the specified range.
     it = std::find_if(rDestCol.maItems.begin(), rDestCol.maItems.end(), FindAboveRow(nRow2));
     rDestCol.maItems.insert(it, aCopied.begin(), aCopied.end());
+    it = aCopied.begin();
+    itEnd = aCopied.end();
+    for (; it != itEnd; ++it)
+        rDestCol.maTextWidths.set<unsigned short>(it->nRow, TEXTWIDTH_DIRTY);
 }
 
 void ScColumn::CopyToColumn(
commit d71e44e78333111a02818b903699188bc372b382
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Fri Mar 15 00:54:12 2013 -0400

    Move some of the code to local functions to make it easier to read.
    
    Change-Id: Ib7ca5c04ec057dbce958d580ad3b7d52d19ed21f

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index baaaacd..f09367b 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -303,6 +303,53 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize )
     pDocument->SetAutoCalc( bOldAutoCalc );
 }
 
+namespace {
+
+bool isDate(const ScDocument& rDoc, const ScColumn& rCol, SCROW nRow)
+{
+    sal_uLong nIndex = (sal_uLong)((SfxUInt32Item*)rCol.GetAttr(nRow, ATTR_VALUE_FORMAT))->GetValue();
+    short nType = rDoc.GetFormatTable()->GetType(nIndex);
+    return (nType == NUMBERFORMAT_DATE) || (nType == NUMBERFORMAT_TIME) || (nType == NUMBERFORMAT_DATETIME);
+}
+
+bool checkDeleteCellByFlag(
+    CellType eCellType, sal_uInt16 nDelFlag, const ScDocument& rDoc, const ScColumn& rCol, const ColEntry& rEntry)
+{
+    bool bDelete = false;
+
+    switch (eCellType)
+    {
+        case CELLTYPE_VALUE:
+        {
+            sal_uInt16 nValFlags = nDelFlag & (IDF_DATETIME|IDF_VALUE);
+            // delete values and dates?
+            bDelete = nValFlags == (IDF_DATETIME|IDF_VALUE);
+            // if not, decide according to cell number format
+            if (!bDelete && (nValFlags != 0))
+            {
+                bool bIsDate = isDate(rDoc, rCol, rEntry.nRow);
+                bDelete = nValFlags == (bIsDate ? IDF_DATETIME : IDF_VALUE);
+            }
+        }
+        break;
+        case CELLTYPE_STRING:
+        case CELLTYPE_EDIT:
+            bDelete = (nDelFlag & IDF_STRING) != 0;
+        break;
+        case CELLTYPE_FORMULA:
+            bDelete = (nDelFlag & IDF_FORMULA) != 0;
+        break;
+        case CELLTYPE_NOTE:
+            // do note delete note cell with broadcaster
+            bDelete = !rEntry.pCell->GetBroadcaster();
+        break;
+        default:; // added to avoid warnings
+    }
+
+    return bDelete;
+}
+
+}
 
 void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDelFlag )
 {
@@ -323,7 +370,7 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe
 
     typedef mdds::flat_segment_tree<SCSIZE, bool> RemovedSegments_t;
     RemovedSegments_t aRemovedSegments(nStartIndex, maItems.size(), false);
-    SCSIZE nFirst(nStartIndex);
+    SCSIZE nFirst = nStartIndex;
 
     // dummy replacement for old cells, to prevent that interpreter uses old cell
     boost::scoped_ptr<ScNoteCell> pDummyCell(new ScNoteCell);
@@ -357,57 +404,27 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe
         ScBaseCell* pOldCell = maItems[nIdx].pCell;
         CellType eCellType = pOldCell->GetCellType();
         if ((nDelFlag & IDF_CONTENTS) == IDF_CONTENTS)
+            // All cell types to be deleted.
             bDelete = true;
         else
         {
-            // decide whether to delete the cell object according to passed
-            // flags
-            switch ( eCellType )
-            {
-                case CELLTYPE_VALUE:
-                {
-                    sal_uInt16 nValFlags = nDelFlag & (IDF_DATETIME|IDF_VALUE);
-                    // delete values and dates?
-                    bDelete = nValFlags == (IDF_DATETIME|IDF_VALUE);
-                    // if not, decide according to cell number format
-                    if (!bDelete && (nValFlags != 0))
-                    {
-                        sal_uLong nIndex = (sal_uLong)((SfxUInt32Item*)GetAttr(
-                                    maItems[nIdx].nRow, ATTR_VALUE_FORMAT))->GetValue();
-                        short nType = pDocument->GetFormatTable()->GetType(nIndex);
-                        bool bIsDate = (nType == NUMBERFORMAT_DATE) ||
-                            (nType == NUMBERFORMAT_TIME) || (nType == NUMBERFORMAT_DATETIME);
-                        bDelete = nValFlags == (bIsDate ? IDF_DATETIME : IDF_VALUE);
-                    }
-                }
-                break;
-                case CELLTYPE_STRING:
-                case CELLTYPE_EDIT:
-                    bDelete = (nDelFlag & IDF_STRING) != 0;
-                break;
-                case CELLTYPE_FORMULA:
-                    bDelete = (nDelFlag & IDF_FORMULA) != 0;
-                break;
-                case CELLTYPE_NOTE:
-                    // do note delete note cell with broadcaster
-                    bDelete = !pOldCell->GetBroadcaster();
-                break;
-                default:; // added to avoid warnings
-            }
+            // Decide whether to delete the cell object according to passed
+            // flags.
+            bDelete = checkDeleteCellByFlag(eCellType, nDelFlag, *pDocument, *this, maItems[nIdx]);
         }
 
         if (bDelete)
         {
-            // try to create a replacement note cell, if note or broadcaster exists
+            // Try to create a replacement "note" cell if broadcaster exists.
             ScNoteCell* pNoteCell = NULL;
             SvtBroadcaster* pBC = pOldCell->GetBroadcaster();
             if (pBC && pBC->HasListeners())
             {
-                pNoteCell = new ScNoteCell( pBC );
-                // NOTE: the broadcaster here is transferred and released
-                // only if it has listeners! If it does not, it will simply
-                // be deleted when the cell is deleted and no replacement
-                // cell is created.
+                // NOTE: the broadcaster here is transferred and released only
+                // if it has listeners! If it does not, it will simply be
+                // deleted when the cell is deleted and no replacement cell is
+                // created.
+                pNoteCell = new ScNoteCell(pBC);
                 pOldCell->ReleaseBroadcaster();
             }
 
@@ -423,16 +440,16 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe
             else
                 maItems[nIdx].pCell = pDummyCell.get();
 
-            // cache formula cells (will be deleted later), delete cell of other type
             if (eCellType == CELLTYPE_FORMULA)
             {
-                aDelCells.push_back( static_cast< ScFormulaCell* >( pOldCell ) );
+                // Cache formula cells (will be deleted later), delete cell of other type.
+                aDelCells.push_back(static_cast<ScFormulaCell*>(pOldCell));
             }
             else
             {
-                aHint.GetAddress().SetRow( nOldRow );
-                aHint.SetCell( pNoteCell ? pNoteCell : pOldCell );
-                pDocument->Broadcast( aHint );
+                aHint.GetAddress().SetRow(nOldRow);
+                aHint.SetCell(pNoteCell ? pNoteCell : pOldCell);
+                pDocument->Broadcast(aHint);
                 if (pNoteCell != pOldCell)
                 {
                     pOldCell->Delete();
commit 7b6d3e8f0cc1cc72d6b3f958957c4747b4839bcf
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Fri Mar 15 00:11:37 2013 -0400

    Reduce indentation level.
    
    Change-Id: Ia70d1dfde53e13e7d40e7cb8fa09dc401570aa93

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index cc25641..baaaacd 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -330,9 +330,10 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe
 
     for ( SCSIZE nIdx = nStartIndex; nIdx <= nEndIndex; ++nIdx )
     {
-        // all content is deleted and cell does not contain broadcaster
         if (((nDelFlag & IDF_CONTENTS) == IDF_CONTENTS) && !maItems[ nIdx ].pCell->GetBroadcaster())
         {
+            // all content is deleted and cell does not contain broadcaster
+
             ScBaseCell* pOldCell = maItems[ nIdx ].pCell;
             if (pOldCell->GetCellType() == CELLTYPE_FORMULA)
             {
@@ -348,110 +349,105 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe
                 pDocument->Broadcast( aHint );
                 pOldCell->Delete();
             }
+            continue;
         }
+
         // delete some contents of the cells, or cells with broadcaster
+        bool bDelete = false;
+        ScBaseCell* pOldCell = maItems[nIdx].pCell;
+        CellType eCellType = pOldCell->GetCellType();
+        if ((nDelFlag & IDF_CONTENTS) == IDF_CONTENTS)
+            bDelete = true;
         else
         {
-            bool bDelete = false;
-            ScBaseCell* pOldCell = maItems[nIdx].pCell;
-            CellType eCellType = pOldCell->GetCellType();
-            if ((nDelFlag & IDF_CONTENTS) == IDF_CONTENTS)
-                bDelete = true;
-            else
+            // decide whether to delete the cell object according to passed
+            // flags
+            switch ( eCellType )
             {
-                // decide whether to delete the cell object according to passed
-                // flags
-                switch ( eCellType )
+                case CELLTYPE_VALUE:
                 {
-                    case CELLTYPE_VALUE:
-                        {
-                            sal_uInt16 nValFlags = nDelFlag & (IDF_DATETIME|IDF_VALUE);
-                            // delete values and dates?
-                            bDelete = nValFlags == (IDF_DATETIME|IDF_VALUE);
-                            // if not, decide according to cell number format
-                            if( !bDelete && (nValFlags != 0) )
-                            {
-                                sal_uLong nIndex = (sal_uLong)((SfxUInt32Item*)GetAttr(
-                                            maItems[nIdx].nRow, ATTR_VALUE_FORMAT ))->GetValue();
-                                short nType = pDocument->GetFormatTable()->GetType(nIndex);
-                                bool bIsDate = (nType == NUMBERFORMAT_DATE) ||
-                                    (nType == NUMBERFORMAT_TIME) || (nType == NUMBERFORMAT_DATETIME);
-                                bDelete = nValFlags == (bIsDate ? IDF_DATETIME : IDF_VALUE);
-                            }
-                        }
-                        break;
-
-                    case CELLTYPE_STRING:
-                    case CELLTYPE_EDIT:
-                        bDelete = (nDelFlag & IDF_STRING) != 0;
-                        break;
-
-                    case CELLTYPE_FORMULA:
-                        bDelete = (nDelFlag & IDF_FORMULA) != 0;
-                        break;
-
-                    case CELLTYPE_NOTE:
-                        // do note delete note cell with broadcaster
-                        bDelete = !pOldCell->GetBroadcaster();
-                        break;
-
-                    default:; // added to avoid warnings
+                    sal_uInt16 nValFlags = nDelFlag & (IDF_DATETIME|IDF_VALUE);
+                    // delete values and dates?
+                    bDelete = nValFlags == (IDF_DATETIME|IDF_VALUE);
+                    // if not, decide according to cell number format
+                    if (!bDelete && (nValFlags != 0))
+                    {
+                        sal_uLong nIndex = (sal_uLong)((SfxUInt32Item*)GetAttr(
+                                    maItems[nIdx].nRow, ATTR_VALUE_FORMAT))->GetValue();
+                        short nType = pDocument->GetFormatTable()->GetType(nIndex);
+                        bool bIsDate = (nType == NUMBERFORMAT_DATE) ||
+                            (nType == NUMBERFORMAT_TIME) || (nType == NUMBERFORMAT_DATETIME);
+                        bDelete = nValFlags == (bIsDate ? IDF_DATETIME : IDF_VALUE);
+                    }
                 }
+                break;
+                case CELLTYPE_STRING:
+                case CELLTYPE_EDIT:
+                    bDelete = (nDelFlag & IDF_STRING) != 0;
+                break;
+                case CELLTYPE_FORMULA:
+                    bDelete = (nDelFlag & IDF_FORMULA) != 0;
+                break;
+                case CELLTYPE_NOTE:
+                    // do note delete note cell with broadcaster
+                    bDelete = !pOldCell->GetBroadcaster();
+                break;
+                default:; // added to avoid warnings
             }
+        }
 
-            if (bDelete)
+        if (bDelete)
+        {
+            // try to create a replacement note cell, if note or broadcaster exists
+            ScNoteCell* pNoteCell = NULL;
+            SvtBroadcaster* pBC = pOldCell->GetBroadcaster();
+            if (pBC && pBC->HasListeners())
             {
-                // try to create a replacement note cell, if note or broadcaster exists
-                ScNoteCell* pNoteCell = NULL;
-                SvtBroadcaster* pBC = pOldCell->GetBroadcaster();
-                if (pBC && pBC->HasListeners())
-                {
-                    pNoteCell = new ScNoteCell( pBC );
-                    // NOTE: the broadcaster here is transferred and released
-                    // only if it has listeners! If it does not, it will simply
-                    // be deleted when the cell is deleted and no replacement
-                    // cell is created.
-                    pOldCell->ReleaseBroadcaster();
-                }
+                pNoteCell = new ScNoteCell( pBC );
+                // NOTE: the broadcaster here is transferred and released
+                // only if it has listeners! If it does not, it will simply
+                // be deleted when the cell is deleted and no replacement
+                // cell is created.
+                pOldCell->ReleaseBroadcaster();
+            }
 
-                // remove cell entry in cell item list
-                SCROW nOldRow = maItems[nIdx].nRow;
-                if (pNoteCell)
-                {
-                    // replace old cell with the replacement note cell
-                    maItems[nIdx].pCell = pNoteCell;
-                    // ... so it's not really deleted
-                    bDelete = false;
-                }
-                else
-                    maItems[nIdx].pCell = pDummyCell.get();
+            // remove cell entry in cell item list
+            SCROW nOldRow = maItems[nIdx].nRow;
+            if (pNoteCell)
+            {
+                // replace old cell with the replacement note cell
+                maItems[nIdx].pCell = pNoteCell;
+                // ... so it's not really deleted
+                bDelete = false;
+            }
+            else
+                maItems[nIdx].pCell = pDummyCell.get();
 
-                // cache formula cells (will be deleted later), delete cell of other type
-                if (eCellType == CELLTYPE_FORMULA)
-                {
-                    aDelCells.push_back( static_cast< ScFormulaCell* >( pOldCell ) );
-                }
-                else
+            // cache formula cells (will be deleted later), delete cell of other type
+            if (eCellType == CELLTYPE_FORMULA)
+            {
+                aDelCells.push_back( static_cast< ScFormulaCell* >( pOldCell ) );
+            }
+            else
+            {
+                aHint.GetAddress().SetRow( nOldRow );
+                aHint.SetCell( pNoteCell ? pNoteCell : pOldCell );
+                pDocument->Broadcast( aHint );
+                if (pNoteCell != pOldCell)
                 {
-                    aHint.GetAddress().SetRow( nOldRow );
-                    aHint.SetCell( pNoteCell ? pNoteCell : pOldCell );
-                    pDocument->Broadcast( aHint );
-                    if (pNoteCell != pOldCell)
-                    {
-                        pOldCell->Delete();
-                    }
+                    pOldCell->Delete();
                 }
             }
+        }
 
-            if (!bDelete)
-            {
-                // We just came to a non-deleted cell after a segment of
-                // deleted ones. So we need to remember the segment
-                // before moving on.
-                if (nFirst < nIdx)
-                    aRemovedSegments.insert_back(nFirst, nIdx, true);
-                nFirst = nIdx + 1;
-            }
+        if (!bDelete)
+        {
+            // We just came to a non-deleted cell after a segment of
+            // deleted ones. So we need to remember the segment
+            // before moving on.
+            if (nFirst < nIdx)
+                aRemovedSegments.insert_back(nFirst, nIdx, true);
+            nFirst = nIdx + 1;
         }
     }
     // there is a segment of deleted cells at the end
@@ -470,30 +466,30 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe
         SCSIZE nShift(0);
         SCSIZE nStartSegment(nStartIndex);
         bool bRemoved = false;
-        while (aIt != aEnd)
+        for (;aIt != aEnd; ++aIt)
         {
             if (aIt->second)
-            { // this segment removed
+            {
+                // this segment removed
                 if (!bRemoved)
                     nStartSegment = aIt->first;
                     // The first of removes in a row sets start (they should be
                     // alternating removed/notremoved anyway).
                 bRemoved = true;
+                continue;
             }
-            else
-            { // this segment not removed
-                if (bRemoved)
-                { // previous segment(s) removed, move tail
-                    SCSIZE const nEndSegment(aIt->first);
-                    memmove(
-                            &maItems[nStartSegment - nShift],
-                            &maItems[nEndSegment - nShift],
-                            (maItems.size() - nEndSegment) * sizeof(ColEntry));
-                    nShift += nEndSegment - nStartSegment;
-                    bRemoved = false;
-                }
+
+            if (bRemoved)
+            {
+                // this segment not removed, but previous segment(s) removed, move tail.
+                SCSIZE const nEndSegment(aIt->first);
+                memmove(
+                        &maItems[nStartSegment - nShift],
+                        &maItems[nEndSegment - nShift],
+                        (maItems.size() - nEndSegment) * sizeof(ColEntry));
+                nShift += nEndSegment - nStartSegment;
+                bRemoved = false;
             }
-            ++aIt;
         }
         // The last removed segment up to aItems.size() is discarded, there's
         // nothing following to be moved.
commit 927da98a2a4860f926968b4704e02d58d7cf0eea
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Thu Mar 14 22:57:56 2013 -0400

    Add integrity check after column cell storage is modified.
    
    Change-Id: I8d2bd7616e0428e4e881ef0dc1012c4973e636a9

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index ca68e7f..666d067 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -28,6 +28,14 @@
 #include <set>
 #include <vector>
 
+#define DEBUG_COLUMN_STORAGE 1
+
+#if DEBUG_COLUMN_STORAGE
+#ifdef NDEBUG
+#undef NDEBUG
+#endif
+#endif
+
 #include <mdds/multi_type_vector.hpp>
 #include <mdds/multi_type_vector_trait.hpp>
 
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 9190b31..19e5e9c 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -56,6 +56,13 @@
 
 #include <math.h>
 
+#if DEBUG_COLUMN_STORAGE
+#include "columniterator.hxx"
+#include <iostream>
+using std::cout;
+using std::endl;
+#endif
+
 // -----------------------------------------------------------------------
 
 // factor from font size to optimal cell height (text width)
@@ -1384,6 +1391,20 @@ SCROW ScColumn::FindNextVisibleRowWithContent(SCROW nRow, bool bForward) const
 
 void ScColumn::CellStorageModified()
 {
+#if DEBUG_COLUMN_STORAGE
+    ScColumnTextWidthIterator aIter(*this, 0, MAXROW);
+    for (; aIter.hasCell(); aIter.next())
+    {
+        SCROW nRow = aIter.getPos();
+        ScBaseCell* pCell = GetCell(nRow);
+        if (!pCell)
+        {
+            cout << "Cell and text width storages are out of sync!" << endl;
+            cout.flush();
+            abort();
+        }
+    }
+#endif
 }
 
 unsigned short ScColumn::GetTextWidth(SCROW nRow) const
commit 632290663a9d2bc722ddfb96aec049d7362204d6
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Thu Mar 14 22:35:43 2013 -0400

    Call CellStorageModified() *after* the text widths get modified.
    
    So that I can put some integrity check code in there to test the
    integrity of cell storage.
    
    Change-Id: I0cc141ea74c27db1a014390b7abf807220e7be9f

diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 682afc6..e778f96 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -852,7 +852,6 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2)
                 be performed (but keep broadcasters and notes at old position). */
             maItems[nIndex1].pCell = pCell2;
             maItems[nIndex2].pCell = pCell1;
-            CellStorageModified();
 
             SvtBroadcaster* pBC2 = pCell2->ReleaseBroadcaster();
             pCell1->TakeBroadcaster( pBC2 );
@@ -863,6 +862,7 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2)
             unsigned short nVal2 = maTextWidths.get<unsigned short>(nRow2);
             maTextWidths.set<unsigned short>(nRow1, nVal2);
             maTextWidths.set<unsigned short>(nRow2, nVal1);
+            CellStorageModified();
         }
         else
         {
@@ -874,19 +874,18 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2)
             {
                 // insert dummy note cell (without note) containing old broadcaster
                 maItems[nIndex1].pCell = pDummyCell;
-                CellStorageModified();
             }
             else
             {
                 // remove ColEntry at old position
                 maItems.erase( maItems.begin() + nIndex1 );
-                CellStorageModified();
             }
 
             // Empty text width at the cell 1 position.  For now, we don't
             // transfer the old value to the cell 2 position since Insert() is
             // quite complicated.
             maTextWidths.set_empty(nRow1, nRow1);
+            CellStorageModified();
 
             // insert ColEntry at new position.
             Insert( nRow2, pCell1 );
@@ -1013,14 +1012,14 @@ void ScColumn::SwapCell( SCROW nRow, ScColumn& rCol)
             pFmlaCell2->UpdateReference(URM_MOVE, aRange, -dx, 0, 0);
         }
 
-        CellStorageModified();
-        rCol.CellStorageModified();
-
         // Swap the text widths.
         unsigned short nVal1 = maTextWidths.get<unsigned short>(nRow);
         unsigned short nVal2 = rCol.maTextWidths.get<unsigned short>(nRow);
         maTextWidths.set<unsigned short>(nRow, nVal2);
         rCol.maTextWidths.set<unsigned short>(nRow, nVal1);
+
+        CellStorageModified();
+        rCol.CellStorageModified();
     }
     else
     {
@@ -1037,8 +1036,9 @@ void ScColumn::SwapCell( SCROW nRow, ScColumn& rCol)
             pFmlaCell1->UpdateReference(URM_MOVE, aRange, dx, 0, 0);
         }
 
-        CellStorageModified();
         maTextWidths.set_empty(nRow, nRow);
+        CellStorageModified();
+
         // We don't transfer the text width to the destination column because
         // of Insert()'s complexity.
 
@@ -1189,8 +1189,8 @@ void ScColumn::InsertRow( SCROW nStartRow, SCSIZE nSize )
 
     pDocument->SetAutoCalc( bOldAutoCalc );
 
-    CellStorageModified();
     maTextWidths.insert_empty(nStartRow, nSize);
+    CellStorageModified();
 }
 
 
@@ -1691,8 +1691,8 @@ void ScColumn::MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol)
 
         if (bErased)
         {
-            CellStorageModified();
             maTextWidths.set_empty(nStartRow, nEndRow);
+            CellStorageModified();
         }
     }
 }
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 57b5370..cc25641 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -88,17 +88,16 @@ void ScColumn::Insert( SCROW nRow, ScBaseCell* pNewCell )
             }
             pOldCell->Delete();
             maItems[nIndex].pCell = pNewCell;
-            CellStorageModified();
         }
         else
         {
             maItems.insert(maItems.begin() + nIndex, ColEntry());
             maItems[nIndex].pCell = pNewCell;
             maItems[nIndex].nRow  = nRow;
-            CellStorageModified();
         }
 
         maTextWidths.set<unsigned short>(nRow, TEXTWIDTH_DIRTY);
+        CellStorageModified();
     }
     // When we insert from the Clipboard we still have wrong (old) References!
     // First they are rewired in CopyBlockFromClip via UpdateReference and the
@@ -142,8 +141,8 @@ void ScColumn::Append( SCROW nRow, ScBaseCell* pCell )
     maItems.back().pCell = pCell;
     maItems.back().nRow  = nRow;
 
-    CellStorageModified();
     maTextWidths.set<unsigned short>(nRow, TEXTWIDTH_DIRTY);
+    CellStorageModified();
 }
 
 
@@ -156,7 +155,6 @@ void ScColumn::Delete( SCROW nRow )
         ScBaseCell* pCell = maItems[nIndex].pCell;
         ScNoteCell* pNoteCell = new ScNoteCell;
         maItems[nIndex].pCell = pNoteCell; // Dummy for Interpret
-        CellStorageModified();
         pDocument->Broadcast( ScHint( SC_HINT_DYING,
             ScAddress( nCol, nRow, nTab ), pCell ) );
         if ( SvtBroadcaster* pBC = pCell->ReleaseBroadcaster() )
@@ -167,13 +165,13 @@ void ScColumn::Delete( SCROW nRow )
         {
             pNoteCell->Delete();
             maItems.erase( maItems.begin() + nIndex);
-            CellStorageModified();
             // Should we free memory here (delta)? It'll be slower!
         }
         pCell->EndListeningTo( pDocument );
         pCell->Delete();
 
         maTextWidths.set_empty(nRow, nRow);
+        CellStorageModified();
     }
 }
 
@@ -191,8 +189,8 @@ void ScColumn::DeleteAtIndex( SCSIZE nIndex )
     pCell->EndListeningTo( pDocument );
     pCell->Delete();
 
-    CellStorageModified();
     maTextWidths.set_empty(nRow, nRow);
+    CellStorageModified();
 }
 
 
@@ -202,8 +200,8 @@ void ScColumn::FreeAll()
         maItems[i].pCell->Delete();
     maItems.clear();
 
-    CellStorageModified();
     maTextWidths.clear();
+    CellStorageModified();
 }
 
 
@@ -502,8 +500,8 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe
         if (bRemoved)
             nShift += maItems.size() - nStartSegment;
         maItems.erase(maItems.end() - nShift, maItems.end());
-        CellStorageModified();
         maTextWidths.set_empty(nStartRow, nEndRow);
+        CellStorageModified();
     }
 
     // *** delete all formula cells ***
@@ -1430,8 +1428,8 @@ bool ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString,
 
                 pOldCell->Delete();
                 maItems[i].pCell = pNewCell; // Replace
+                maTextWidths.set<unsigned short>(nRow, TEXTWIDTH_DIRTY);
                 CellStorageModified();
-                SetTextWidth(nRow, TEXTWIDTH_DIRTY);
 
                 if ( pNewCell->GetCellType() == CELLTYPE_FORMULA )
                 {
commit 7ac77e31a54d0b0545ed039426405f2b0c96a6e3
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Thu Mar 14 17:56:51 2013 -0400

    Create skeleton accessors for cell text script types.
    
    Change-Id: I5408cdd87f06423a6bb287c855237878859da880

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 114a39b..ca68e7f 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -387,6 +387,9 @@ public:
     sal_uInt16 GetTextWidth(SCROW nRow) const;
     void SetTextWidth(SCROW nRow, sal_uInt16 nWidth);
 
+    sal_uInt8 GetScriptType( SCROW nRow ) const;
+    void SetScriptType( SCROW nRow, sal_uInt8 nType );
+
 private:
     ScBaseCell* CloneCell(SCSIZE nIndex, sal_uInt16 nFlags, ScDocument& rDestDoc, const ScAddress& rDestPos) const;
 
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 541ec05..cb8aac7 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1177,7 +1177,8 @@ public:
     bool            HasStringWeakCharacters( const rtl::OUString& rString );
     SC_DLLPUBLIC sal_uInt8          GetStringScriptType( const rtl::OUString& rString );
     SC_DLLPUBLIC sal_uInt8          GetCellScriptType( ScBaseCell* pCell, sal_uLong nNumberFormat );
-    SC_DLLPUBLIC sal_uInt8          GetScriptType( SCCOL nCol, SCROW nRow, SCTAB nTab, ScBaseCell* pCell = NULL );
+    SC_DLLPUBLIC sal_uInt8 GetScriptType( SCCOL nCol, SCROW nRow, SCTAB nTab, ScBaseCell* pCell );
+    sal_uInt8 GetScriptType( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
 
     bool            HasDetectiveOperations() const;
     void            AddDetectiveOperation( const ScDetOpData& rData );
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 3e4d1eb..25f4f7a 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -793,6 +793,9 @@ public:
 
     sal_uLong          AddCondFormat( ScConditionalFormat* pNew );
 
+    sal_uInt8 GetScriptType( SCCOL nCol, SCROW nRow ) const;
+    void SetScriptType( SCCOL nCol, SCROW nRow, sal_uInt8 nType );
+
 private:
     void        FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
                                 sal_uLong nFillCount, FillDir eFillDir, FillCmd eFillCmd,
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index c586b34..9190b31 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1396,6 +1396,20 @@ void ScColumn::SetTextWidth(SCROW nRow, unsigned short nWidth)
     maTextWidths.set(nRow, nWidth);
 }
 
+sal_uInt8 ScColumn::GetScriptType( SCROW nRow ) const
+{
+    if (!ValidRow(nRow))
+        return SC_SCRIPTTYPE_UNKNOWN;
+
+    return SC_SCRIPTTYPE_UNKNOWN;
+}
+
+void ScColumn::SetScriptType( SCROW nRow, sal_uInt8 nType )
+{
+    if (!ValidRow(nRow))
+        return;
+}
+
 void ScColumn::FindDataAreaPos(SCROW& rRow, bool bDown) const
 {
     // check if we are in a data area
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index a73cd60..ec9c7c6 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -5767,4 +5767,13 @@ void ScDocument::SetAutoNameCache(  ScAutoNameCache* pCache )
     delete pAutoNameCache;
     pAutoNameCache = pCache;
 }
+
+sal_uInt8 ScDocument::GetScriptType( SCCOL nCol, SCROW nRow, SCTAB nTab ) const
+{
+    if (!ValidTab(nTab) || nTab >= static_cast<SCTAB>(maTabs.size()) || !maTabs[nTab])
+        return SC_SCRIPTTYPE_UNKNOWN;
+
+    return maTabs[nTab]->GetScriptType(nCol, nRow);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index b50380a..cfe0e57 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -2080,6 +2080,22 @@ sal_uLong ScTable::AddCondFormat( ScConditionalFormat* pNew )
     return nMax + 1;
 }
 
+sal_uInt8 ScTable::GetScriptType( SCCOL nCol, SCROW nRow ) const
+{
+    if (!ValidCol(nCol))
+        return SC_SCRIPTTYPE_UNKNOWN;
+
+    return aCol[nCol].GetScriptType(nRow);
+}
+
+void ScTable::SetScriptType( SCCOL nCol, SCROW nRow, sal_uInt8 nType )
+{
+    if (!ValidCol(nCol))
+        return;
+
+    aCol[nCol].SetScriptType(nRow, nType);
+}
+
 void ScTable::DeleteConditionalFormat( sal_uLong nIndex )
 {
     mpCondFormatList->erase(nIndex);
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 4b7c02a..fcd76aa 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -823,7 +823,7 @@ sal_uInt8 ScViewFunc::GetSelectionScriptType()
         // no selection -> cursor
 
         nScript = pDoc->GetScriptType( GetViewData()->GetCurX(),
-                            GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
+                            GetViewData()->GetCurY(), GetViewData()->GetTabNo(), NULL );
     }
     else
     {
diff --git a/sc/source/ui/view/viewutil.cxx b/sc/source/ui/view/viewutil.cxx
index e740079..d24d080 100644
--- a/sc/source/ui/view/viewutil.cxx
+++ b/sc/source/ui/view/viewutil.cxx
@@ -71,7 +71,7 @@ sal_uInt16 ScViewUtil::GetEffLanguage( ScDocument* pDoc, const ScAddress& rPos )
 {
     //  used for thesaurus
 
-    sal_uInt8 nScript = pDoc->GetScriptType( rPos.Col(), rPos.Row(), rPos.Tab() );
+    sal_uInt8 nScript = pDoc->GetScriptType( rPos.Col(), rPos.Row(), rPos.Tab(), NULL );
     sal_uInt16 nWhich = ( nScript == SCRIPTTYPE_ASIAN ) ? ATTR_CJK_FONT_LANGUAGE :
                     ( ( nScript == SCRIPTTYPE_COMPLEX ) ? ATTR_CTL_FONT_LANGUAGE : ATTR_FONT_LANGUAGE );
     const SfxPoolItem* pItem = pDoc->GetAttr( rPos.Col(), rPos.Row(), rPos.Tab(), nWhich);
commit 188042ad5230e912f3149cc7ea1bb836e084069a
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Mar 15 14:35:20 2013 +0000

    restore enough of XOBitmap to do fore/back color setting on escher patterns
    
    i.e. restore the logic of setting the colors of imported escher patterns like
    we always did in the past. Stripping that out seems risky in the absence of
    definite test-cases.
    
    Change-Id: I16bbb451b053fd04a5154602f8f38ed799e21286

diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 71b6914..86fabbd 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -131,6 +131,7 @@
 #include <com/sun/star/beans/PropertyValues.hpp>
 #include <com/sun/star/drawing/ProjectionMode.hpp>
 #include "svx/EnhancedCustomShape2d.hxx"
+#include <svx/xbitmap.hxx>
 #include <rtl/strbuf.hxx>
 #include <rtl/ustring.hxx>
 #include <boost/scoped_array.hpp>
@@ -1371,13 +1372,36 @@ void DffPropertyReader::ApplyFillAttributes( SvStream& rIn, SfxItemSet& rSet, co
                 {
                     if ( eMSO_FillType == mso_fillPattern )
                     {
-                        Color aCol1( COL_WHITE ), aCol2( COL_WHITE );
+                        Bitmap aBmp( aGraf.GetBitmap() );
+                        if( aBmp.GetSizePixel().Width() == 8 && aBmp.GetSizePixel().Height() == 8 && aBmp.GetColorCount() == 2)
+                        {
+                            Color aCol1( COL_WHITE ), aCol2( COL_WHITE );
+
+                            if ( IsProperty( DFF_Prop_fillColor ) )
+                                aCol1 = rManager.MSO_CLR_ToColor( GetPropertyValue( DFF_Prop_fillColor ), DFF_Prop_fillColor );
+
+                            if ( IsProperty( DFF_Prop_fillBackColor ) )
+                                aCol2 = rManager.MSO_CLR_ToColor( GetPropertyValue( DFF_Prop_fillBackColor ), DFF_Prop_fillBackColor );
 
-                        if ( IsProperty( DFF_Prop_fillColor ) )
-                            aCol1 = rManager.MSO_CLR_ToColor( GetPropertyValue( DFF_Prop_fillColor ), DFF_Prop_fillColor );
+                            XOBitmap aXOBitmap( aBmp );
+                            aXOBitmap.Bitmap2Array();
+                            aXOBitmap.SetBitmapType( XBITMAP_8X8 );
+                            aXOBitmap.SetPixelSize( aBmp.GetSizePixel() );
+
+                            if( aXOBitmap.GetBackgroundColor() == COL_BLACK )
+                            {
+                                aXOBitmap.SetPixelColor( aCol1 );
+                                aXOBitmap.SetBackgroundColor( aCol2 );
+                            }
+                            else
+                            {
+                                aXOBitmap.SetPixelColor( aCol2 );
+                                aXOBitmap.SetBackgroundColor( aCol1 );
+                            }
 
-                        if ( IsProperty( DFF_Prop_fillBackColor ) )
-                            aCol2 = rManager.MSO_CLR_ToColor( GetPropertyValue( DFF_Prop_fillBackColor ), DFF_Prop_fillBackColor );
+                            aXOBitmap.Array2Bitmap();
+                            aGraf = Graphic( aXOBitmap.GetBitmap()  );
+                        }
 
                         rSet.Put(XFillBitmapItem(OUString(), aGraf));
                     }
diff --git a/lotuswordpro/source/filter/lwpbackgroundstuff.cxx b/lotuswordpro/source/filter/lwpbackgroundstuff.cxx
index 0c8deba..46bd2ed 100644
--- a/lotuswordpro/source/filter/lwpbackgroundstuff.cxx
+++ b/lotuswordpro/source/filter/lwpbackgroundstuff.cxx
@@ -65,6 +65,7 @@
 
 #include "tools/stream.hxx"
 #include "vcl/bmpacc.hxx"
+#include "svx/xbitmap.hxx"
 
 
 void LwpBackgroundStuff::Read(LwpObjectStream* pStrm)
@@ -128,9 +129,37 @@ XFBGImage* LwpBackgroundStuff::GetFillPattern()
         pPttnArray = NULL;
     }
 
-    // transfer image data from Bitmap->SvStream->BYTE-Array
+    // create XOBitmap object from bitmap object
+    XOBitmap aXOBitmap( aBmp );
+    aXOBitmap.Bitmap2Array();
+    aXOBitmap.SetBitmapType( XBITMAP_8X8 );
+
+    // set back/fore-ground colors
+    if (m_aFillColor.IsValidColor() && m_aPatternColor.IsValidColor())
+    {
+        Color aBackColor(static_cast<sal_uInt8>(m_aFillColor.GetRed()),
+            static_cast<sal_uInt8>(m_aFillColor.GetGreen()),
+            static_cast<sal_uInt8>(m_aFillColor.GetBlue()));
+        Color aForeColor(static_cast<sal_uInt8>(m_aPatternColor.GetRed()),
+            static_cast<sal_uInt8>(m_aPatternColor.GetGreen()),
+            static_cast<sal_uInt8>(m_aPatternColor.GetBlue()));
+
+        if( aXOBitmap.GetBackgroundColor() == COL_BLACK )
+        {
+            aXOBitmap.SetPixelColor( aBackColor );
+            aXOBitmap.SetBackgroundColor( aForeColor );
+        }
+        else
+        {
+            aXOBitmap.SetPixelColor( aForeColor );
+            aXOBitmap.SetBackgroundColor( aBackColor );
+        }
+    }
+
+    // transfer image data from XOBitmap->SvStream->BYTE-Array
     SvMemoryStream aPicMemStream;
-    aBmp.Write(aPicMemStream);
+    aXOBitmap.Array2Bitmap();
+    aXOBitmap.GetBitmap().Write(aPicMemStream);
     sal_uInt32 nSize = aPicMemStream.GetEndOfData();
     sal_uInt8* pImageBuff = new sal_uInt8 [nSize];
     memcpy(pImageBuff, aPicMemStream.GetData(), nSize);
diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx
index b51f7b2..2562873 100644
--- a/sc/source/filter/excel/xiescher.cxx
+++ b/sc/source/filter/excel/xiescher.cxx
@@ -78,6 +78,7 @@
 #include <svx/xlinjoit.hxx>
 #include <svx/xlntrit.hxx>
 #include <svx/xbtmpit.hxx>
+#include <svx/xbitmap.hxx>
 
 #include "document.hxx"
 #include "drwlayer.hxx"
@@ -671,6 +672,17 @@ void XclImpDrawObjBase::ConvertFillStyle( SdrObject& rSdrObj, const XclObjFillDa
             aMemStrm.Seek( STREAM_SEEK_TO_BEGIN );
             Bitmap aBitmap;
             aBitmap.Read( aMemStrm, sal_False );
+
+            XOBitmap aXOBitmap( aBitmap );
+            aXOBitmap.Bitmap2Array();
+            aXOBitmap.SetBitmapType( XBITMAP_8X8 );
+            if( aXOBitmap.GetBackgroundColor().GetColor() == COL_BLACK )
+                ::std::swap( aPattColor, aBackColor );
+            aXOBitmap.SetPixelColor( aPattColor );
+            aXOBitmap.SetBackgroundColor( aBackColor );
+            aXOBitmap.Array2Bitmap();
+            aBitmap = aXOBitmap.GetBitmap();
+
             rSdrObj.SetMergedItem(XFillStyleItem(XFILL_BITMAP));
             rSdrObj.SetMergedItem(XFillBitmapItem(EMPTY_STRING, Graphic(aBitmap)));
         }
diff --git a/svx/Package_inc.mk b/svx/Package_inc.mk
index 048c5d1..e1deeab 100644
--- a/svx/Package_inc.mk
+++ b/svx/Package_inc.mk
@@ -471,6 +471,7 @@ $(eval $(call gb_Package_add_file,svx_inc,inc/svx/sxmsitm.hxx,svx/sxmsitm.hxx))
 $(eval $(call gb_Package_add_file,svx_inc,inc/svx/sdtaditm.hxx,svx/sdtaditm.hxx))
 $(eval $(call gb_Package_add_file,svx_inc,inc/svx/svdotext.hxx,svx/svdotext.hxx))
 $(eval $(call gb_Package_add_file,svx_inc,inc/svx/chrtitem.hxx,svx/chrtitem.hxx))
+$(eval $(call gb_Package_add_file,svx_inc,inc/svx/xbitmap.hxx,svx/xbitmap.hxx))
 $(eval $(call gb_Package_add_file,svx_inc,inc/svx/sxallitm.hxx,svx/sxallitm.hxx))
 $(eval $(call gb_Package_add_file,svx_inc,inc/svx/dlgutil.hxx,svx/dlgutil.hxx))
 $(eval $(call gb_Package_add_file,svx_inc,inc/svx/unopage.hxx,svx/unopage.hxx))
diff --git a/svx/inc/svx/xbitmap.hxx b/svx/inc/svx/xbitmap.hxx
new file mode 100644
index 0000000..959ceaf
--- /dev/null
+++ b/svx/inc/svx/xbitmap.hxx
@@ -0,0 +1,66 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef _SVX_XBITMAP_HXX
+#define _SVX_XBITMAP_HXX
+
+#include <tools/color.hxx>
+#include <vcl/bitmap.hxx>
+#include <svtools/grfmgr.hxx>
+#include <svx/xenum.hxx>
+#include "svx/svxdllapi.h"
+
+class SVX_DLLPUBLIC XOBitmap
+{
+private:
+    XBitmapType     eType;
+    GraphicObject   aGraphicObject;
+    sal_uInt16*     pPixelArray;
+    Size            aArraySize;
+    Color           aPixelColor;
+    Color           aBckgrColor;
+    sal_Bool        bGraphicDirty;
+
+    const GraphicObject& GetGraphicObject() const;
+
+public:
+    XOBitmap( const Bitmap& rBitmap );
+    XOBitmap( const XOBitmap& rXBmp );
+    ~XOBitmap();
+
+    XOBitmap& operator=( const XOBitmap& rXOBitmap );
+    int      operator==( const XOBitmap& rXOBitmap ) const;
+
+    void Bitmap2Array();
+    void Array2Bitmap();
+
+    void SetBitmapType( XBitmapType eNewType )          { eType = eNewType; }
+    void SetPixelColor( const Color& rColor )           { aPixelColor = rColor; bGraphicDirty = sal_True; }
+    void SetPixelSize( const Size& rSize )              { aArraySize  = rSize;  bGraphicDirty = sal_True; }
+    void SetBackgroundColor( const Color& rColor )      { aBckgrColor = rColor; bGraphicDirty = sal_True; }
+
+    XBitmapType             GetBitmapType() const       { return eType; }
+    Bitmap                  GetBitmap() const;
+    Color                   GetPixelColor() const       { return aPixelColor; }
+    Color                   GetBackgroundColor() const  { return aBckgrColor; }
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/inc/svx/xenum.hxx b/svx/inc/svx/xenum.hxx
index 1f48327..df0b629 100644
--- a/svx/inc/svx/xenum.hxx
+++ b/svx/inc/svx/xenum.hxx
@@ -45,6 +45,7 @@ enum XFormTextStdForm   { XFTFORM_NONE = 0, XFTFORM_TOPCIRC, XFTFORM_BOTCIRC,
                           XFTFORM_BOTARC, XFTFORM_LFTARC, XFTFORM_RGTARC,
                           XFTFORM_BUTTON1, XFTFORM_BUTTON2,
                           XFTFORM_BUTTON3, XFTFORM_BUTTON4};
+enum XBitmapType        { XBITMAP_IMPORT, XBITMAP_8X8 };
 
 
 #endif      // _XENUM_HXX
diff --git a/svx/source/xoutdev/xattrbmp.cxx b/svx/source/xoutdev/xattrbmp.cxx
index 27a3dd2..1256f43 100644
--- a/svx/source/xoutdev/xattrbmp.cxx
+++ b/svx/source/xoutdev/xattrbmp.cxx
@@ -34,12 +34,228 @@
 #include <editeng/unoprnms.hxx>
 #include <svx/unoapi.hxx>
 #include <svx/svdmodel.hxx>
+#include <svx/xbitmap.hxx>
 #include <com/sun/star/beans/PropertyValue.hpp>
 #include <vcl/salbtype.hxx>
 #include <vcl/bmpacc.hxx>
 
 using namespace ::com::sun::star;
 
+/*************************************************************************
+|*
+|*    XOBitmap::XOBitmap( Bitmap aBitmap )
+|*
+*************************************************************************/
+
+XOBitmap::XOBitmap( const Bitmap& rBmp ) :
+    eType           ( XBITMAP_IMPORT ),
+    aGraphicObject  ( rBmp ),
+    pPixelArray     ( NULL ),
+    bGraphicDirty   ( sal_False )
+{
+}
+
+/*************************************************************************
+|*
+|*    XOBitmap::XOBitmap( const XOBitmap& rXBmp )
+|*
+*************************************************************************/
+
+XOBitmap::XOBitmap( const XOBitmap& rXBmp ) :
+    pPixelArray ( NULL )
+{
+    eType = rXBmp.eType;
+    aGraphicObject = rXBmp.aGraphicObject;
+    aArraySize = rXBmp.aArraySize;
+    aPixelColor = rXBmp.aPixelColor;
+    aBckgrColor = rXBmp.aBckgrColor;
+    bGraphicDirty = rXBmp.bGraphicDirty;
+
+    if( rXBmp.pPixelArray )
+    {
+        if( eType == XBITMAP_8X8 )
+        {
+            pPixelArray = new sal_uInt16[ 64 ];
+
+            for( sal_uInt16 i = 0; i < 64; i++ )
+                *( pPixelArray + i ) = *( rXBmp.pPixelArray + i );
+        }
+    }
+}
+
+/*************************************************************************
+|*
+|*    XOBitmap::XOBitmap( Bitmap aBitmap )
+|*
+*************************************************************************/
+
+XOBitmap::~XOBitmap()
+{
+    delete [] pPixelArray;
+}
+
+/*************************************************************************
+|*
+|*    XOBitmap& XOBitmap::operator=( const XOBitmap& rXBmp )
+|*
+*************************************************************************/
+
+XOBitmap& XOBitmap::operator=( const XOBitmap& rXBmp )
+{
+    eType = rXBmp.eType;
+    aGraphicObject = rXBmp.aGraphicObject;
+    aArraySize = rXBmp.aArraySize;
+    aPixelColor = rXBmp.aPixelColor;
+    aBckgrColor = rXBmp.aBckgrColor;
+    bGraphicDirty = rXBmp.bGraphicDirty;
+
+    if( rXBmp.pPixelArray )
+    {
+        if( eType == XBITMAP_8X8 )
+        {
+            pPixelArray = new sal_uInt16[ 64 ];
+
+            for( sal_uInt16 i = 0; i < 64; i++ )
+                *( pPixelArray + i ) = *( rXBmp.pPixelArray + i );
+        }
+    }
+    return( *this );
+}
+
+/*************************************************************************
+|*
+|*    int XOBitmap::operator==( const XOBitmap& rXOBitmap ) const
+|*
+*************************************************************************/
+
+int XOBitmap::operator==( const XOBitmap& rXOBitmap ) const
+{
+    if( eType != rXOBitmap.eType      ||
+        aGraphicObject != rXOBitmap.aGraphicObject ||
+        aArraySize != rXOBitmap.aArraySize     ||
+        aPixelColor != rXOBitmap.aPixelColor ||
+        aBckgrColor != rXOBitmap.aBckgrColor ||
+        bGraphicDirty != rXOBitmap.bGraphicDirty )
+    {
+        return( sal_False );
+    }
+
+    if( pPixelArray && rXOBitmap.pPixelArray )
+    {
+        sal_uInt16 nCount = (sal_uInt16) ( aArraySize.Width() * aArraySize.Height() );
+        for( sal_uInt16 i = 0; i < nCount; i++ )
+        {
+            if( *( pPixelArray + i ) != *( rXOBitmap.pPixelArray + i ) )
+                return( sal_False );
+        }
+    }
+    return( sal_True );
+}
+
+/*************************************************************************
+|*
+|*    Bitmap XOBitmap::GetBitmap()
+|*
+*************************************************************************/
+
+Bitmap XOBitmap::GetBitmap() const
+{
+    return GetGraphicObject().GetGraphic().GetBitmap();
+}
+
+/*************************************************************************
+|*
+|*    Bitmap XOBitmap::GetGraphicObject()
+|*
+*************************************************************************/
+
+const GraphicObject& XOBitmap::GetGraphicObject() const
+{
+    if( bGraphicDirty )
+        ( (XOBitmap*) this )->Array2Bitmap();
+
+    return aGraphicObject;
+}
+
+/*************************************************************************
+|*
+|*    void XOBitmap::Bitmap2Array()
+|*
+|*    Beschreibung      Umwandlung der Bitmap in Array, Hinter- u.
+|*                      Vordergrundfarbe
+|*
+*************************************************************************/
+
+void XOBitmap::Bitmap2Array()
+{
+    VirtualDevice   aVD;
+    sal_Bool            bPixelColor = sal_False;
+    const Bitmap    aBitmap( GetBitmap() );
+    const sal_uInt16    nLines = 8; // von Type abhaengig
+
+    if( !pPixelArray )
+        pPixelArray = new sal_uInt16[ nLines * nLines ];
+
+    aVD.SetOutputSizePixel( aBitmap.GetSizePixel() );
+    aVD.DrawBitmap( Point(), aBitmap );
+    aPixelColor = aBckgrColor = aVD.GetPixel( Point() );
+
+    // Aufbau des Arrays und Ermittlung der Vorder-, bzw.
+    // Hintergrundfarbe
+    for( sal_uInt16 i = 0; i < nLines; i++ )
+    {
+        for( sal_uInt16 j = 0; j < nLines; j++ )
+        {
+            if ( aVD.GetPixel( Point( j, i ) ) == aBckgrColor )
+                *( pPixelArray + j + i * nLines ) = 0;
+            else
+            {
+                *( pPixelArray + j + i * nLines ) = 1;
+                if( !bPixelColor )
+                {
+                    aPixelColor = aVD.GetPixel( Point( j, i ) );
+                    bPixelColor = sal_True;
+                }
+            }
+        }
+    }
+}
+
+/*************************************************************************
+|*
+|*    void XOBitmap::Array2Bitmap()
+|*
+|*    Beschreibung      Umwandlung des Arrays, Hinter- u.
+|*                      Vordergrundfarbe in eine Bitmap
+|*
+*************************************************************************/
+
+void XOBitmap::Array2Bitmap()
+{
+    VirtualDevice   aVD;
+    sal_uInt16          nLines = 8; // von Type abhaengig
+
+    if( !pPixelArray )
+        return;
+
+    aVD.SetOutputSizePixel( Size( nLines, nLines ) );
+
+    // Aufbau der Bitmap
+    for( sal_uInt16 i = 0; i < nLines; i++ )
+    {
+        for( sal_uInt16 j = 0; j < nLines; j++ )
+        {
+            if( *( pPixelArray + j + i * nLines ) == 0 )
+                aVD.DrawPixel( Point( j, i ), aBckgrColor );
+            else
+                aVD.DrawPixel( Point( j, i ), aPixelColor );
+        }
+    }
+
+    aGraphicObject = GraphicObject( aVD.GetBitmap( Point(), Size( nLines, nLines ) ) );
+    bGraphicDirty = sal_False;
+}
+
 // -----------------------
 // class XFillBitmapItem
 // -----------------------
@@ -146,12 +362,6 @@ XFillBitmapItem::XFillBitmapItem(SvStream& rIn, sal_uInt16 nVer)
         }
         else if(1 == nVer)
         {
-            enum XBitmapType
-            {
-                XBITMAP_IMPORT,
-                XBITMAP_8X8
-            };
-
             sal_Int16 iTmp;
 
             rIn >> iTmp; // former XBitmapStyle
commit c97aec0d2276901c20634abe53867f739f420f50
Author: Armin Le Grand <alg at apache.org>
Date:   Thu May 10 09:29:55 2012 +0000

    Related: #i119125# change XFillBitmapItem to work with GraphicObject
    
    Completely changed XFillBitmapItem to work with GraphicObject, removed XOBitmap
    class, adapted all usages (also the pretty old 8x8 pixel editor).
    
    All Bitmap fill styles will now accept transparent bitmaps as fillings in all
    variations (tiled, etc.). LoadSave is no problem, ODF defines graphic as
    content for fill.  Backward means that OOs before this change will use a white
    background of fill with transparent, same as the fallback all the time when
    using a transparent fill.
    
    This is also a preparation to e.g. offer SVG or Metafiles as fill style.
    
    Conflicts:
    	cui/source/tabpages/backgrnd.cxx
    	cui/source/tabpages/tparea.cxx
    	cui/source/tabpages/tpbitmap.cxx
    	filter/source/msfilter/msdffimp.cxx
    	filter/source/msfilter/svdfppt.cxx
    	sc/source/filter/excel/xiescher.cxx
    	sd/source/ui/func/fupage.cxx
    	svx/inc/svx/dlgctrl.hxx
    	svx/inc/svx/xbitmap.hxx
    	svx/inc/svx/xbtmpit.hxx
    	svx/inc/svx/xtable.hxx
    	svx/source/customshapes/EnhancedCustomShape2d.cxx
    	svx/source/dialog/dlgctrl.cxx
    	svx/source/svdraw/svdograf.cxx
    	svx/source/tbxctrls/fillctrl.cxx
    	svx/source/unodraw/XPropertyTable.cxx
    	svx/source/xoutdev/xattrbmp.cxx
    	svx/source/xoutdev/xtabbtmp.cxx
    
    Change-Id: Id838bfbacc863695d078fb3cf379d1c0cd951680

diff --git a/cui/source/tabpages/backgrnd.cxx b/cui/source/tabpages/backgrnd.cxx
index d84cf85..930073f 100644
--- a/cui/source/tabpages/backgrnd.cxx
+++ b/cui/source/tabpages/backgrnd.cxx
@@ -53,6 +53,8 @@
 #include <svx/xflgrit.hxx>
 #include <svl/intitem.hxx>
 #include <sfx2/request.hxx>
+#include <svtools/grfmgr.hxx>
+
 using namespace ::com::sun::star;
 // static ----------------------------------------------------------------
 
diff --git a/cui/source/tabpages/tparea.cxx b/cui/source/tabpages/tparea.cxx
index 952d612..c6716c1 100644
--- a/cui/source/tabpages/tparea.cxx
+++ b/cui/source/tabpages/tparea.cxx
@@ -1142,9 +1142,9 @@ sal_Bool SvxAreaTabPage::FillItemSet( SfxItemSet& rAttrs )
                 if( nPos != LISTBOX_ENTRY_NOTFOUND &&
                     nPos != aLbBitmap.GetSavedValue() )
                 {
-                    XOBitmap aXOBitmap = pBitmapList->GetBitmap( nPos )->GetXBitmap();
-                    String aString = aLbBitmap.GetSelectEntry();
-                    XFillBitmapItem aFillBitmapItem( aString, aXOBitmap );
+                    const XBitmapEntry* pXBitmapEntry = pBitmapList->GetBitmap(nPos);
+                    const String aString(aLbBitmap.GetSelectEntry());
+                    const XFillBitmapItem aFillBitmapItem(aString, pXBitmapEntry->GetGraphicObject());
                     pOld = GetOldItem( rAttrs, XATTR_FILLBITMAP );
                     if ( !pOld || !( *(const XFillBitmapItem*)pOld == aFillBitmapItem ) )
                     {
@@ -2225,15 +2225,15 @@ IMPL_LINK_NOARG(SvxAreaTabPage, ModifyBitmapHdl_Impl)
     if( _nPos != LISTBOX_ENTRY_NOTFOUND )
     {
         // fill ItemSet and pass it on to aCtlXRectPreview
-        XBitmapEntry* pEntry = pBitmapList->GetBitmap( _nPos );
+        const XBitmapEntry* pEntry = pBitmapList->GetBitmap(_nPos);
 
-        rXFSet.Put( XFillStyleItem( XFILL_BITMAP ) );
-        rXFSet.Put( XFillBitmapItem( String(), pEntry->GetXBitmap() ) );
+        rXFSet.Put(XFillStyleItem(XFILL_BITMAP));
+        rXFSet.Put(XFillBitmapItem(String(), pEntry->GetGraphicObject()));
     }
     else if( SFX_ITEM_SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLBITMAP ), sal_True, &pPoolItem ) )
     {
-        rXFSet.Put( XFillStyleItem( XFILL_BITMAP ) );
-        rXFSet.Put( XFillBitmapItem( String(), ( ( const XFillBitmapItem* ) pPoolItem )->GetBitmapValue() ) );
+        rXFSet.Put(XFillStyleItem(XFILL_BITMAP));
+        rXFSet.Put(XFillBitmapItem(String(), ((const XFillBitmapItem*)pPoolItem)->GetGraphicObject()));
     }
     else
         rXFSet.Put( XFillStyleItem( XFILL_NONE ) );
diff --git a/cui/source/tabpages/tpbitmap.cxx b/cui/source/tabpages/tpbitmap.cxx
index 6a4b74b..3ed60c3 100644
--- a/cui/source/tabpages/tpbitmap.cxx
+++ b/cui/source/tabpages/tpbitmap.cxx
@@ -89,7 +89,7 @@ SvxBitmapTabPage::SvxBitmapTabPage
 
     pXPool              ( (XOutdevItemPool*) rInAttrs.GetPool() ),
     aXFStyleItem        ( XFILL_BITMAP ),
-    aXBitmapItem        ( String(), XOBitmap() ),
+    aXBitmapItem        ( String(), Graphic() ),
     aXFillAttr          ( pXPool ),
     rXFSet              ( aXFillAttr.GetItemSet() )
 {
@@ -237,32 +237,26 @@ sal_Bool SvxBitmapTabPage::FillItemSet( SfxItemSet& _rOutAttrs )
 {
     if( *pDlgType == 0 && *pbAreaTP == sal_False ) // area dialog
     {
-        if( *pPageType == PT_BITMAP )
+        if(PT_BITMAP == *pPageType)
         {
-            // CheckChanges_Impl(); <-- duplicate inquiry?
-
-            XOBitmap aXOBitmap;
-            String aString;
+            _rOutAttrs.Put(XFillStyleItem(XFILL_BITMAP));
             sal_uInt16 nPos = aLbBitmaps.GetSelectEntryPos();
-            if( nPos != LISTBOX_ENTRY_NOTFOUND )
+            if(LISTBOX_ENTRY_NOTFOUND != nPos)
             {
-                aXOBitmap = pBitmapList->GetBitmap( nPos )->GetXBitmap();
-                aString = aLbBitmaps.GetSelectEntry();
+                const XBitmapEntry* pXBitmapEntry = pBitmapList->GetBitmap(nPos);
+                const String aString(aLbBitmaps.GetSelectEntry());
 
+                _rOutAttrs.Put(XFillBitmapItem(aString, pXBitmapEntry->GetGraphicObject()));
             }
             else
             {
-                aXOBitmap = aBitmapCtl.GetXBitmap();
-
-                // #85339# if it's an array, force conversion to bitmap before using it.
-                if(aXOBitmap.GetBitmapType() == XBITMAP_8X8)
-                    aXOBitmap.GetBitmap();
+                const BitmapEx aBitmapEx(aBitmapCtl.GetBitmapEx());
 
+                _rOutAttrs.Put(XFillBitmapItem(String(), Graphic(aBitmapEx)));
             }
-            _rOutAttrs.Put( XFillStyleItem( XFILL_BITMAP ) );
-            _rOutAttrs.Put( XFillBitmapItem( aString, aXOBitmap ) );
         }
     }
+
     return sal_True;
 }
 
@@ -278,7 +272,7 @@ void SvxBitmapTabPage::Reset( const SfxItemSet&  )
     aBitmapCtl.SetBmpArray( aCtlPixel.GetBitmapPixelPtr() );
 
     // get bitmap and display it
-    XFillBitmapItem aBmpItem( (const String &) String(), aBitmapCtl.GetXBitmap() );
+    const XFillBitmapItem aBmpItem(OUString(), Graphic(aBitmapCtl.GetBitmapEx()));
     rXFSet.Put( aBmpItem );
     aCtlPreview.SetAttributes( aXFillAttr.GetItemSet() );
     aCtlPreview.Invalidate();
@@ -313,145 +307,49 @@ SfxTabPage* SvxBitmapTabPage::Create( Window* pWindow,
 
 IMPL_LINK_NOARG(SvxBitmapTabPage, ChangeBitmapHdl_Impl)
 {
-    XOBitmap* pXOBitmap = NULL;
-    int nPos = aLbBitmaps.GetSelectEntryPos();
+    GraphicObject* pGraphicObject = 0;
+    int nPos(aLbBitmaps.GetSelectEntryPos());
 
-    if( nPos != LISTBOX_ENTRY_NOTFOUND )
-        pXOBitmap = new XOBitmap( ( (XBitmapEntry*) pBitmapList->GetBitmap( nPos ) )->GetXBitmap() );
+    if(LISTBOX_ENTRY_NOTFOUND != nPos)
+    {
+        pGraphicObject = new GraphicObject(pBitmapList->GetBitmap(nPos)->GetGraphicObject());
+    }
     else
     {
-        const SfxPoolItem* pPoolItem = NULL;
-        if( SFX_ITEM_SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLSTYLE ), sal_True, &pPoolItem ) )
+        const SfxPoolItem* pPoolItem = 0;
+
+        if(SFX_ITEM_SET == rOutAttrs.GetItemState(GetWhich(XATTR_FILLSTYLE), true, &pPoolItem))
         {
-            XFillStyle eXFS = (XFillStyle) ( ( const XFillStyleItem* ) pPoolItem )->GetValue();
-            if( ( XFILL_BITMAP == eXFS ) &&
-                ( SFX_ITEM_SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLBITMAP ), sal_True, &pPoolItem ) ) )
+            const XFillStyle eXFS((XFillStyle)((const XFillStyleItem*)pPoolItem)->GetValue());
+
+            if((XFILL_BITMAP == eXFS) && (SFX_ITEM_SET == rOutAttrs.GetItemState(GetWhich(XATTR_FILLBITMAP), true, &pPoolItem)))
             {
-                pXOBitmap = new XOBitmap( ( ( const XFillBitmapItem* ) pPoolItem )->GetBitmapValue() );
+                pGraphicObject = new GraphicObject(((const XFillBitmapItem*)pPoolItem)->GetGraphicObject());
             }
         }
-        if( !pXOBitmap )
+
+        if(!pGraphicObject)
         {
-            aLbBitmaps.SelectEntryPos( 0 );
+            aLbBitmaps.SelectEntryPos(0);
             nPos = aLbBitmaps.GetSelectEntryPos();
-            if( nPos != LISTBOX_ENTRY_NOTFOUND )
-                pXOBitmap = new XOBitmap( ( (XBitmapEntry*) pBitmapList->GetBitmap( nPos ) )->GetXBitmap() );
-        }
-    }
-    if( pXOBitmap )
-    {
-        // #85339# try to convert bitmapped item to array item.
-        if(pXOBitmap->GetBitmapType() == XBITMAP_IMPORT)
-        {
-            Bitmap aBitmap(pXOBitmap->GetBitmap());
-            Size aSizePixel(aBitmap.GetSizePixel());
 
-            if(8 == aSizePixel.Width() && 8 == aSizePixel.Height())
+            if(LISTBOX_ENTRY_NOTFOUND != nPos)
             {
-                sal_uInt16* pPixelArray = new sal_uInt16[64];
-                sal_uInt32 nCol1(0xffffffff); // background
-                sal_uInt32 nCol2(0xffffffff); // pixel
-                BitmapReadAccess* pAccess = aBitmap.AcquireReadAccess();
-                sal_Bool bValid(sal_True);
-
-                if(pAccess)
-                {
-                    for(sal_uInt32 a(0); bValid && a < 64; a++)
-                    {
-                        const BitmapColor aBmCol = pAccess->GetColor(a>>3, a%8);
-                        Color aRgbCol(aBmCol.GetRed(), aBmCol.GetGreen(), aBmCol.GetBlue());
-                        sal_uInt32 nColVal = aRgbCol.GetRGBColor();
-
-                        // test with nCol1
-                        if(nCol1 != nColVal)
-                        {
-                            if(0xffffffff == nCol1)
-                            {
-                                // nCol1 is used first time
-                                nCol1 = nColVal;
-                                pPixelArray[a] = 0;
-                            }
-                            else
-                            {
-                                // test with nCol2
-                                if(nCol2 != nColVal)
-                                {
-                                    if(0xffffffff == nCol2)
-                                    {
-                                        // nCol2 used first time
-                                        nCol2 = nColVal;
-                                        pPixelArray[a] = 1;
-                                    }
-                                    else
-                                    {
-                                        // Third color detected
-                                        bValid = sal_False;
-                                    }
-                                }
-                                else
-                                {
-                                    // color is pixel color
-                                    pPixelArray[a] = 1;
-                                }
-                            }
-                        }
-                        else
-                        {
-                            // color is background color
-                            pPixelArray[a] = 0;
-                        }
-                    }
-
-                    // release ReadAccess
-                    aBitmap.ReleaseAccess(pAccess);
-                }
-                else
-                {
-                    // no access -> no success
-                    bValid = sal_False;
-                }
-
-                if(bValid)
-                {
-                    Color aCol1(nCol1);
-                    Color aCol2(nCol2);
-
-                    // no pixel color found? Use opposite od background color.
-                    if(0xffffffff == nCol2)
-                    {
-                        aCol2 = Color(
-                            0xff - aCol1.GetRed(),
-                            0xff - aCol1.GetGreen(),
-                            0xff - aCol1.GetBlue());
-                    }
-
-                    // transformation did work, create a new Item
-                    delete pXOBitmap;
-                    pXOBitmap = new XOBitmap(pPixelArray, aCol2, aCol1);
-                }
-
-                // cleanup
-                delete[] pPixelArray;
+                pGraphicObject = new GraphicObject(pBitmapList->GetBitmap(nPos)->GetGraphicObject());
             }
         }
+    }
+
+    if(pGraphicObject)
+    {
+        BitmapColor aBack;
+        BitmapColor aFront;
+        bool bIs8x8(isHistorical8x8(pGraphicObject->GetGraphic().GetBitmap(), aBack, aFront));
 
         aLbColor.SetNoSelection();
         aLbBackgroundColor.SetNoSelection();
 
-        if( pXOBitmap->GetBitmapType() == XBITMAP_IMPORT )
-        {
-            aCtlPixel.Reset();
-            aCtlPixel.SetPaintable( sal_False );
-            aCtlPixel.Disable();
-            aFtPixelEdit.Disable();
-            aFtColor.Disable();
-            aLbColor.Disable();
-            aFtBackgroundColor.Disable();
-            aLbBackgroundColor.Disable();
-            aBtnModify.Disable();
-            aBtnAdd.Disable();
-        }
-        else if( pXOBitmap->GetBitmapType() == XBITMAP_8X8 )
+        if(bIs8x8)
         {
             aCtlPixel.SetPaintable( sal_True );
             aCtlPixel.Enable();
@@ -464,10 +362,10 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ChangeBitmapHdl_Impl)
             aBtnAdd.Enable();
 
             // setting the pixel control
-            aCtlPixel.SetXBitmap( *pXOBitmap );
+            aCtlPixel.SetXBitmap(pGraphicObject->GetGraphic().GetBitmapEx());
 
-            Color aPixelColor = pXOBitmap->GetPixelColor();
-            Color aBackColor  = pXOBitmap->GetBackgroundColor();
+            Color aPixelColor = aFront;
+            Color aBackColor = aBack;
 
             aBitmapCtl.SetPixelColor( aPixelColor );
             aBitmapCtl.SetBackgroundColor( aBackColor );
@@ -493,19 +391,34 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ChangeBitmapHdl_Impl)
                 aLbBackgroundColor.SelectEntry( aBackColor );
             }
         }
+        else
+        {
+            aCtlPixel.Reset();
+            aCtlPixel.SetPaintable( sal_False );
+            aCtlPixel.Disable();
+            aFtPixelEdit.Disable();
+            aFtColor.Disable();
+            aLbColor.Disable();
+            aFtBackgroundColor.Disable();
+            aLbBackgroundColor.Disable();
+            aBtnModify.Disable();
+            aBtnAdd.Disable();
+        }
+
         aCtlPixel.Invalidate();
 
         // display bitmap
-        XFillBitmapItem aXBmpItem( (const String &) String(), *pXOBitmap );
+        const XFillBitmapItem aXBmpItem(String(), *pGraphicObject);
         rXFSet.Put( aXBmpItem );
 
         aCtlPreview.SetAttributes( aXFillAttr.GetItemSet() );
         aCtlPreview.Invalidate();
 
         bBmpChanged = sal_False;
-        delete pXOBitmap;
+        delete pGraphicObject;
     }
-    return 0L;
+
+    return 0;
 }
 
 // -----------------------------------------------------------------------
@@ -624,21 +537,17 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ClickAddHdl_Impl)
         XBitmapEntry* pEntry = 0;
         if( aCtlPixel.IsEnabled() )
         {
-            XOBitmap aXOBitmap = aBitmapCtl.GetXBitmap();
+            const BitmapEx aBitmapEx(aBitmapCtl.GetBitmapEx());
 
-            // #85339# if it's an array, force conversion to bitmap before using it.
-            if(aXOBitmap.GetBitmapType() == XBITMAP_8X8)
-                aXOBitmap.GetBitmap();
-
-            pEntry = new XBitmapEntry( aXOBitmap, aName );
+            pEntry = new XBitmapEntry(Graphic(aBitmapEx), aName);
         }
         else // it must be a not existing imported bitmap
         {
-            const SfxPoolItem* pPoolItem = NULL;
-            if( SFX_ITEM_SET == rOutAttrs.GetItemState( XATTR_FILLBITMAP, sal_True, &pPoolItem ) )
+            const SfxPoolItem* pPoolItem = 0;
+
+            if(SFX_ITEM_SET == rOutAttrs.GetItemState(XATTR_FILLBITMAP, true, &pPoolItem))
             {
-                XOBitmap aXOBitmap( ( ( const XFillBitmapItem* ) pPoolItem )->GetBitmapValue() );
-                pEntry = new XBitmapEntry( aXOBitmap, aName );
+                pEntry = new XBitmapEntry(dynamic_cast< const XFillBitmapItem* >(pPoolItem)->GetGraphicObject(), aName);
             }
         }
 
@@ -746,9 +655,7 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ClickImportHdl_Impl)
 
             if( !nError )
             {
-                Bitmap aBmp( aGraphic.GetBitmap() );
-                XBitmapEntry* pEntry =
-                    new XBitmapEntry( XOBitmap( aBmp ), aName );
+                XBitmapEntry* pEntry = new XBitmapEntry( aGraphic, aName );
                 pBitmapList->Insert( pEntry );
 
                 aLbBitmaps.Append( pEntry );
@@ -819,13 +726,9 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ClickModifyHdl_Impl)
 
                 pEntry->SetName( aName );
 
-                XOBitmap aXOBitmap = aBitmapCtl.GetXBitmap();
-
-                // #85339# if it's an array, force conversion to bitmap before using it.
-                if(aXOBitmap.GetBitmapType() == XBITMAP_8X8)
-                    aXOBitmap.GetBitmap();
+                const BitmapEx aBitmapEx(aBitmapCtl.GetBitmapEx());
 
-                pEntry->SetXBitmap( aXOBitmap );
+                pEntry->SetGraphicObject(Graphic(aBitmapEx));
 
                 aLbBitmaps.Modify( pEntry, nPos );
                 aLbBitmaps.SelectEntryPos( nPos );
@@ -1043,7 +946,7 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ChangePixelColorHdl_Impl)
     aBitmapCtl.SetPixelColor( aLbColor.GetSelectEntryColor() );
 
     // get bitmap and display it
-    rXFSet.Put( XFillBitmapItem( String(), aBitmapCtl.GetXBitmap() ) );
+    rXFSet.Put(XFillBitmapItem(String(), Graphic(aBitmapCtl.GetBitmapEx())));
     aCtlPreview.SetAttributes( aXFillAttr.GetItemSet() );
     aCtlPreview.Invalidate();
 
@@ -1062,7 +965,7 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ChangeBackgrndColorHdl_Impl)
     aBitmapCtl.SetBackgroundColor( aLbBackgroundColor.GetSelectEntryColor() );
 
     // get bitmap and display it
-    rXFSet.Put( XFillBitmapItem( String(), aBitmapCtl.GetXBitmap() ) );
+    rXFSet.Put(XFillBitmapItem(String(), Graphic(aBitmapCtl.GetBitmapEx())));
     aCtlPreview.SetAttributes( aXFillAttr.GetItemSet() );
     aCtlPreview.Invalidate();
 
@@ -1080,7 +983,7 @@ void SvxBitmapTabPage::PointChanged( Window* pWindow, RECT_POINT )
         aBitmapCtl.SetBmpArray( aCtlPixel.GetBitmapPixelPtr() );
 
         // get bitmap and display it
-        rXFSet.Put( XFillBitmapItem( String(), aBitmapCtl.GetXBitmap() ) );
+        rXFSet.Put(XFillBitmapItem(String(), Graphic(aBitmapCtl.GetBitmapEx())));
         aCtlPreview.SetAttributes( aXFillAttr.GetItemSet() );
         aCtlPreview.Invalidate();
 
diff --git a/cui/source/tabpages/tpline.cxx b/cui/source/tabpages/tpline.cxx
index 77a9a00..3036474 100644
--- a/cui/source/tabpages/tpline.cxx
+++ b/cui/source/tabpages/tpline.cxx
@@ -48,7 +48,6 @@
 #include <sfx2/objsh.hxx>
 #include <editeng/brushitem.hxx>
 #include <svx/gallery.hxx>
-#include <svx/xbitmap.hxx>
 #include <unotools/localfilehelper.hxx>
 #include "paragrph.hrc"
 #include "sfx2/opengrf.hxx"
diff --git a/drawinglayer/inc/drawinglayer/attribute/sdrfillbitmapattribute.hxx b/drawinglayer/inc/drawinglayer/attribute/sdrfillbitmapattribute.hxx
index 3f04c86..602455e 100644
--- a/drawinglayer/inc/drawinglayer/attribute/sdrfillbitmapattribute.hxx
+++ b/drawinglayer/inc/drawinglayer/attribute/sdrfillbitmapattribute.hxx
@@ -25,7 +25,7 @@
 //////////////////////////////////////////////////////////////////////////////
 // predefines
 
-class Bitmap;
+class BitmapEx;
 
 namespace basegfx {
     class B2DRange;
@@ -51,7 +51,7 @@ namespace drawinglayer
         public:
             /// constructors/assignmentoperator/destructor
             SdrFillBitmapAttribute(
-                const Bitmap& rBitmap,
+                const BitmapEx& rBitmapEx,
                 const basegfx::B2DVector& rSize,
                 const basegfx::B2DVector& rOffset,
                 const basegfx::B2DVector& rOffsetPosition,
@@ -71,7 +71,7 @@ namespace drawinglayer
             bool operator==(const SdrFillBitmapAttribute& rCandidate) const;
 
             // data read access
-            const Bitmap& getBitmap() const;
+            const BitmapEx& getBitmapEx() const;
             const basegfx::B2DVector& getSize() const;
             const basegfx::B2DVector& getOffset() const;
             const basegfx::B2DVector& getOffsetPosition() const;
diff --git a/drawinglayer/source/attribute/sdrfillbitmapattribute.cxx b/drawinglayer/source/attribute/sdrfillbitmapattribute.cxx
index 6007778..5d86525 100644
--- a/drawinglayer/source/attribute/sdrfillbitmapattribute.cxx
+++ b/drawinglayer/source/attribute/sdrfillbitmapattribute.cxx
@@ -34,7 +34,7 @@ namespace drawinglayer
             sal_uInt32                              mnRefCount;
 
             // data definitions
-            Bitmap                                  maBitmap;
+            BitmapEx                                maBitmapEx;
             basegfx::B2DVector                      maSize;
             basegfx::B2DVector                      maOffset;
             basegfx::B2DVector                      maOffsetPosition;
@@ -46,7 +46,7 @@ namespace drawinglayer
             unsigned                                mbLogSize : 1;
 
             ImpSdrFillBitmapAttribute(
-                const Bitmap& rBitmap,
+                const BitmapEx& rBitmapEx,
                 const basegfx::B2DVector& rSize,
                 const basegfx::B2DVector& rOffset,
                 const basegfx::B2DVector& rOffsetPosition,
@@ -55,7 +55,7 @@ namespace drawinglayer
                 bool bStretch,
                 bool bLogSize)
             :   mnRefCount(0),
-                maBitmap(rBitmap),
+                maBitmapEx(rBitmapEx),
                 maSize(rSize),
                 maOffset(rOffset),
                 maOffsetPosition(rOffsetPosition),
@@ -67,7 +67,7 @@ namespace drawinglayer
             }
 
             // data read access
-            const Bitmap& getBitmap() const { return maBitmap; }
+            const BitmapEx& getBitmapEx() const { return maBitmapEx; }
             const basegfx::B2DVector& getSize() const { return maSize; }
             const basegfx::B2DVector& getOffset() const { return maOffset; }
             const basegfx::B2DVector& getOffsetPosition() const { return maOffsetPosition; }
@@ -78,7 +78,7 @@ namespace drawinglayer
 
             bool operator==(const ImpSdrFillBitmapAttribute& rCandidate) const
             {
-                return (getBitmap() == rCandidate.getBitmap()
+                return (getBitmapEx() == rCandidate.getBitmapEx()
                     && getSize() == rCandidate.getSize()
                     && getOffset() == rCandidate.getOffset()
                     && getOffsetPosition() == rCandidate.getOffsetPosition()
@@ -95,7 +95,7 @@ namespace drawinglayer
                 if(!pDefault)
                 {
                     pDefault = new ImpSdrFillBitmapAttribute(
-                        Bitmap(),
+                        BitmapEx(),
                         basegfx::B2DVector(),
                         basegfx::B2DVector(),
                         basegfx::B2DVector(),
@@ -113,7 +113,7 @@ namespace drawinglayer
         };
 
         SdrFillBitmapAttribute::SdrFillBitmapAttribute(
-            const Bitmap& rBitmap,
+            const BitmapEx& rBitmapEx,
             const basegfx::B2DVector& rSize,
             const basegfx::B2DVector& rOffset,
             const basegfx::B2DVector& rOffsetPosition,
@@ -121,8 +121,16 @@ namespace drawinglayer
             bool bTiling,
             bool bStretch,
             bool bLogSize)
-        :   mpSdrFillBitmapAttribute(new ImpSdrFillBitmapAttribute(
-                rBitmap, rSize, rOffset, rOffsetPosition, rRectPoint, bTiling,  bStretch, bLogSize))
+        :   mpSdrFillBitmapAttribute(
+                new ImpSdrFillBitmapAttribute(
+                    rBitmapEx,
+                    rSize,
+                    rOffset,
+                    rOffsetPosition,
+                    rRectPoint,
+                    bTiling,
+                    bStretch,
+                    bLogSize))
         {
         }
 
@@ -190,9 +198,9 @@ namespace drawinglayer
             return (*rCandidate.mpSdrFillBitmapAttribute == *mpSdrFillBitmapAttribute);
         }
 
-        const Bitmap& SdrFillBitmapAttribute::getBitmap() const
+        const BitmapEx& SdrFillBitmapAttribute::getBitmapEx() const
         {
-            return mpSdrFillBitmapAttribute->getBitmap();
+            return mpSdrFillBitmapAttribute->getBitmapEx();
         }
 
         const basegfx::B2DVector& SdrFillBitmapAttribute::getSize() const
@@ -228,8 +236,8 @@ namespace drawinglayer
         FillBitmapAttribute SdrFillBitmapAttribute::getFillBitmapAttribute(const basegfx::B2DRange& rRange) const
         {
             // get logical size of bitmap (before expanding eventually)
-            Bitmap aBitmap(getBitmap());
-            const basegfx::B2DVector aLogicalSize(aBitmap.GetPrefSize().getWidth(), aBitmap.GetPrefSize().getHeight());
+            BitmapEx aBitmapEx(getBitmapEx());
+            const basegfx::B2DVector aLogicalSize(aBitmapEx.GetPrefSize().getWidth(), aBitmapEx.GetPrefSize().getHeight());
 
             // get hor/ver shiftings and apply them eventually to the bitmap, but only
             // when tiling is on
@@ -240,45 +248,45 @@ namespace drawinglayer
             {
                 if(0.0 != getOffset().getX() || 0.0 != getOffset().getY())
                 {
-                    const sal_uInt32 nWidth(aBitmap.GetSizePixel().getWidth());
-                    const sal_uInt32 nHeight(aBitmap.GetSizePixel().getHeight());
+                    const sal_uInt32 nWidth(aBitmapEx.GetSizePixel().getWidth());
+                    const sal_uInt32 nHeight(aBitmapEx.GetSizePixel().getHeight());
 
                     if(0.0 != getOffset().getX())
                     {
                         bExpandHeight = true;
                         const sal_uInt32 nOffset(basegfx::fround(((double)nWidth * getOffset().getX()) / 100.0));
-                        aBitmap.Expand(0L, nHeight);
+                        aBitmapEx.Expand(0L, nHeight);
 
                         const Size aSizeA(nOffset, nHeight);
                         const Rectangle aDstA(Point(0L, nHeight), aSizeA);
                         const Rectangle aSrcA(Point(nWidth - nOffset, 0L), aSizeA);
-                        aBitmap.CopyPixel(aDstA, aSrcA);
+                        aBitmapEx.CopyPixel(aDstA, aSrcA);
 
                         const Size aSizeB(nWidth - nOffset, nHeight);
                         const Rectangle aDstB(Point(nOffset, nHeight), aSizeB);
                         const Rectangle aSrcB(Point(0L, 0L), aSizeB);
-                        aBitmap.CopyPixel(aDstB, aSrcB);
+                        aBitmapEx.CopyPixel(aDstB, aSrcB);
                     }
                     else
                     {
                         bExpandWidth = true;
                         const sal_uInt32 nOffset(basegfx::fround(((double)nHeight * getOffset().getY()) / 100.0));
-                        aBitmap.Expand(nWidth, 0L);
+                        aBitmapEx.Expand(nWidth, 0L);
 
                         const Size aSize(nWidth, nHeight);
                         const Rectangle aDst(Point(nWidth, 0L), aSize);
                         const Rectangle aSrc(Point(0L, 0L), aSize);
-                        aBitmap.CopyPixel(aDst, aSrc);
+                        aBitmapEx.CopyPixel(aDst, aSrc);
 
                         const Size aSizeA(nWidth, nOffset);
                         const Rectangle aDstA(Point(0L, 0L), aSizeA);
                         const Rectangle aSrcA(Point(nWidth, nHeight - nOffset), aSizeA);
-                        aBitmap.CopyPixel(aDstA, aSrcA);
+                        aBitmapEx.CopyPixel(aDstA, aSrcA);
 
                         const Size aSizeB(nWidth, nHeight - nOffset);
                         const Rectangle aDstB(Point(0L, nOffset), aSizeB);
                         const Rectangle aSrcB(Point(nWidth, 0L), aSizeB);
-                        aBitmap.CopyPixel(aDstB, aSrcB);
+                        aBitmapEx.CopyPixel(aDstB, aSrcB);
                     }
                 }
             }
@@ -379,7 +387,7 @@ namespace drawinglayer
                 aBitmapSize.setY(aBitmapSize.getY() / fRangeHeight);
             }
 
-            return FillBitmapAttribute(BitmapEx(aBitmap), aBitmapTopLeft, aBitmapSize, getTiling());
+            return FillBitmapAttribute(aBitmapEx, aBitmapTopLeft, aBitmapSize, getTiling());
         }
     } // end of namespace attribute
 } // end of namespace drawinglayer
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 3cb83e9..71b6914 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -1234,9 +1234,8 @@ void ApplyRectangularGradientAsBitmap( const SvxMSDffManager& rManager, SvStream
                 }
             }
 
-            XOBitmap aXBmp( aBitmap, XBITMAP_STRETCH );
-            rSet.Put( XFillBmpTileItem( sal_False ) );
-            rSet.Put( XFillBitmapItem( OUString(), aXBmp ) );
+            rSet.Put(XFillBmpTileItem(false));
+            rSet.Put(XFillBitmapItem(OUString(), Graphic(aBitmap)));
         }
     }
 }
@@ -1370,54 +1369,30 @@ void DffPropertyReader::ApplyFillAttributes( SvStream& rIn, SfxItemSet& rSet, co
                     bOK = SeekToContent( DFF_Prop_fillBlip, rIn ) && rManager.GetBLIPDirect( rIn, aGraf, NULL );
                 if ( bOK )
                 {
-                    Bitmap aBmp( aGraf.GetBitmap() );
-
                     if ( eMSO_FillType == mso_fillPattern )
                     {
                         Color aCol1( COL_WHITE ), aCol2( COL_WHITE );
+
                         if ( IsProperty( DFF_Prop_fillColor ) )
                             aCol1 = rManager.MSO_CLR_ToColor( GetPropertyValue( DFF_Prop_fillColor ), DFF_Prop_fillColor );
+
                         if ( IsProperty( DFF_Prop_fillBackColor ) )
                             aCol2 = rManager.MSO_CLR_ToColor( GetPropertyValue( DFF_Prop_fillBackColor ), DFF_Prop_fillBackColor );
 
-                        XOBitmap aXOBitmap;
-                        aXOBitmap.SetBitmap( aBmp );
-                        aXOBitmap.SetBitmapType( XBITMAP_IMPORT );
-
-                        if( aBmp.GetSizePixel().Width() == 8 && aBmp.GetSizePixel().Height() == 8 && aBmp.GetColorCount() == 2)
-                        {
-                            aXOBitmap.Bitmap2Array();
-                            aXOBitmap.SetBitmapType( XBITMAP_8X8 );
-                            aXOBitmap.SetPixelSize( aBmp.GetSizePixel() );
-
-                            if( aXOBitmap.GetBackgroundColor() == COL_BLACK )
-                            {
-                                aXOBitmap.SetPixelColor( aCol1 );
-                                aXOBitmap.SetBackgroundColor( aCol2 );
-                            }
-                            else
-                            {
-                                aXOBitmap.SetPixelColor( aCol2 );
-                                aXOBitmap.SetBackgroundColor( aCol1 );
-                            }
-                           aXOBitmap.Array2Bitmap();
-                        }
-                        rSet.Put( XFillBitmapItem( OUString(), aXOBitmap ) );
+                        rSet.Put(XFillBitmapItem(OUString(), aGraf));
                     }
                     else if ( eMSO_FillType == mso_fillTexture )
                     {
-                        XOBitmap aXBmp( aBmp, XBITMAP_STRETCH );
-                        rSet.Put( XFillBmpTileItem( sal_True ) );
-                        rSet.Put( XFillBitmapItem( OUString(), aXBmp ) );
-                        rSet.Put( XFillBmpSizeXItem( GetPropertyValue( DFF_Prop_fillWidth, 0 ) / 360 ) );
-                        rSet.Put( XFillBmpSizeYItem( GetPropertyValue( DFF_Prop_fillHeight, 0 ) / 360 ) );
-                        rSet.Put( XFillBmpSizeLogItem( sal_True ) );
+                        rSet.Put(XFillBmpTileItem(true));
+                        rSet.Put(XFillBitmapItem(OUString(), aGraf));
+                        rSet.Put(XFillBmpSizeXItem(GetPropertyValue(DFF_Prop_fillWidth, 0) / 360));
+                        rSet.Put(XFillBmpSizeYItem(GetPropertyValue(DFF_Prop_fillHeight, 0) / 360));
+                        rSet.Put(XFillBmpSizeLogItem(true));
                     }
                     else
                     {
-                        XOBitmap aXBmp( aBmp, XBITMAP_STRETCH );
-                        rSet.Put( XFillBitmapItem( OUString(), aXBmp ) );
-                        rSet.Put( XFillBmpTileItem( sal_False ) );
+                        rSet.Put(XFillBitmapItem(OUString(), aGraf));
+                        rSet.Put(XFillBmpTileItem(false));
                     }
                 }
             }
diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index 113d912..44a0b521 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -7315,15 +7315,13 @@ void ApplyCellAttributes( const SdrObject* pObj, Reference< XCell >& xCell )
                 {
                     eFS = com::sun::star::drawing::FillStyle_BITMAP;
 
-                    XFillBitmapItem aXFillBitmapItem((const XFillBitmapItem&)pObj->GetMergedItem( XATTR_FILLBITMAP ));
-                    XOBitmap aLocalXOBitmap( aXFillBitmapItem.GetBitmapValue() );
+                    const XFillBitmapItem aXFillBitmapItem((const XFillBitmapItem&)pObj->GetMergedItem( XATTR_FILLBITMAP ));
                     rtl::OUString aURL( RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX));
-                    aURL += rtl::OStringToOUString(
-                        aLocalXOBitmap.GetGraphicObject().GetUniqueID(),
+                    aURL += OStringToOUString(
+                        aXFillBitmapItem.GetGraphicObject().GetUniqueID(),
                         RTL_TEXTENCODING_ASCII_US);
 
-                    static const rtl::OUString sFillBitmapURL( String( RTL_CONSTASCII_USTRINGPARAM( "FillBitmapURL" ) ) );
-                    xPropSet->setPropertyValue( sFillBitmapURL, Any( aURL ) );
+                    xPropSet->setPropertyValue( OUString("FillBitmapURL"), Any( aURL ) );
                 }
             break;
             case XFILL_NONE :
diff --git a/lotuswordpro/source/filter/lwpbackgroundstuff.cxx b/lotuswordpro/source/filter/lwpbackgroundstuff.cxx
index a38d419..0c8deba 100644
--- a/lotuswordpro/source/filter/lwpbackgroundstuff.cxx
+++ b/lotuswordpro/source/filter/lwpbackgroundstuff.cxx
@@ -65,7 +65,6 @@
 
 #include "tools/stream.hxx"

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list