On 06/01/2012 02:56 AM, Daniel Bankston wrote:
I think before I can move forward, I need to know what to do about
ScMyTables::IsMerged(), ScMyTables::DoMerge(), and
ScMyTables::UnMerge(). ScMyTables references its own merge methods,
but I'm not sure what would cause these methods to be actually be
called. They aren't called on the test files I've tried so far. As
we have discovered, the merge methods in ScXMLTableRowCellContext are
called, though. What do you sc gurus think?
I need to figure out what to do with the merge methods because the
ScMyTables add/new/insert row/column methods reference the ScMyTables
merge methods (although the code path that references them never seems
to be taken.)
Hi, Kohei and Markus,
With the attached diff (diff to the latest pushed commit on
feature/gsoc-calc-perf), I was able to build and open my test ods files
with merged cells and content without problems. The patch removes the
ScMyTables merge methods and adjusts the add/new/insert row/column
methods. The big thing here is in ScMyTables::InsertColumn/Row(), there
is a for loop that never seems to be entered that contains calls to
IsMerged() and UNO interfaces. If the logic in the for loop isn't
needed, then ScMyTables::InsertColumn/Row() is unnecessary, and we can
just directly call ScMyStylesImportHelper::InsertCol/Row() from
ScMyTables::NewColumn/Row().
I won't commit this until you guys have had a chance to give input and
guidance on it.
Respectfully,
Daniel Bankston
diff --git a/sc/source/filter/xml/xmlsubti.cxx b/sc/source/filter/xml/xmlsubti.cxx
index 2876309..950cbbd 100644
--- a/sc/source/filter/xml/xmlsubti.cxx
+++ b/sc/source/filter/xml/xmlsubti.cxx
@@ -49,7 +49,6 @@
#include <xmloff/nmspmap.hxx>
#include <xmloff/xmlerror.hxx>
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
-#include <com/sun/star/util/XMergeable.hpp>
#include <com/sun/star/sheet/XSheetCellRange.hpp>
#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
#include <com/sun/star/sheet/CellInsertMode.hpp>
@@ -265,126 +264,6 @@ void ScMyTables::SetTableStyle(const rtl::OUString& sStyleName)
}
}
-bool ScMyTables::IsMerged (const uno::Reference <table::XCellRange>& xCellRange, const sal_Int32
nCol, const sal_Int32 nRow,
- table::CellRangeAddress& aCellAddress) const
-{
- uno::Reference <util::XMergeable> xMergeable
(xCellRange->getCellRangeByPosition(nCol,nRow,nCol,nRow), uno::UNO_QUERY);
- if (xMergeable.is())
- {
- uno::Reference<sheet::XSheetCellRange> xMergeSheetCellRange (xMergeable, uno::UNO_QUERY);
- uno::Reference<sheet::XSpreadsheet> xTable(xMergeSheetCellRange->getSpreadsheet());
- uno::Reference<sheet::XSheetCellCursor>
xMergeSheetCursor(xTable->createCursorByRange(xMergeSheetCellRange));
- if (xMergeSheetCursor.is())
- {
- xMergeSheetCursor->collapseToMergedArea();
- uno::Reference<sheet::XCellRangeAddressable> xMergeCellAddress (xMergeSheetCursor,
uno::UNO_QUERY);
- if (xMergeCellAddress.is())
- {
- aCellAddress = xMergeCellAddress->getRangeAddress();
- if (aCellAddress.StartColumn == nCol && aCellAddress.EndColumn == nCol &&
- aCellAddress.StartRow == nRow && aCellAddress.EndRow == nRow)
- return false;
- else
- return true;
- }
- }
- }
- return false;
-}
-
-void ScMyTables::UnMerge()
-{
- if ( xCurrentCellRange.is() )
- {
- //extra step here until this area is fully converted
- com::sun::star::table::CellAddress aCellPos;
- ScAddress aScCellPos = GetRealScCellPos();
- ScUnoConversion::FillApiAddress( aCellPos, aScCellPos );
-
- table::CellRangeAddress aCellAddress;
- if (IsMerged(xCurrentCellRange, aCellPos.Column, aCellPos.Row, aCellAddress))
- {
- //unmerge
- uno::Reference <util::XMergeable> xMergeable
(xCurrentCellRange->getCellRangeByPosition(aCellAddress.StartColumn, aCellAddress.StartRow,
- aCellAddress.EndColumn, aCellAddress.EndRow),
uno::UNO_QUERY);
- if (xMergeable.is())
- xMergeable->merge(false);
- }
- }
-}
-
-void ScMyTables::DoMerge(sal_Int32 nCount)
-{
- if ( xCurrentCellRange.is() )
- {
- //extra step here until this area is fully converted
- com::sun::star::table::CellAddress aCellPos;
- ScAddress aScCellPos = GetRealScCellPos();
- ScUnoConversion::FillApiAddress( aCellPos, aScCellPos );
-
- table::CellRangeAddress aCellAddress;
- if (IsMerged(xCurrentCellRange, aCellPos.Column, aCellPos.Row, aCellAddress))
- {
- //unmerge
- uno::Reference <util::XMergeable> xMergeable
(xCurrentCellRange->getCellRangeByPosition(aCellAddress.StartColumn, aCellAddress.StartRow,
- aCellAddress.EndColumn, aCellAddress.EndRow),
uno::UNO_QUERY);
- if (xMergeable.is())
- xMergeable->merge(false);
- }
-
- //merge
- uno::Reference <table::XCellRange> xMergeCellRange;
- if (nCount == -1)
- {
- const ScMyTableData& r = *pCurrentTab;
- xMergeCellRange.set(
- xCurrentCellRange->getCellRangeByPosition(
- aCellAddress.StartColumn, aCellAddress.StartRow,
- aCellAddress.EndColumn + r.GetColsPerCol(r.GetColumn()) - 1,
- aCellAddress.EndRow + r.GetRowsPerRow(r.GetRow()) - 1));
- }
- else
- xMergeCellRange.set(
- xCurrentCellRange->getCellRangeByPosition(
- aCellAddress.StartColumn, aCellAddress.StartRow,
- aCellAddress.StartColumn + nCount - 1,
- aCellAddress.EndRow));
-
- uno::Reference <util::XMergeable> xMergeable (xMergeCellRange, uno::UNO_QUERY);
- if (xMergeable.is())
- xMergeable->merge(true);
- }
-}
-
-void ScMyTables::InsertRow()
-{
- if ( xCurrentCellRange.is() )
- {
- ScAddress aScCellPos = GetRealScCellPos();
- table::CellRangeAddress aCellAddress;
- SCROW nRow(aScCellPos.Row());
- for (sal_Int32 j = 0; j < aScCellPos.Col() - pCurrentTab->GetColumn() - 1; ++j)
- {
- if (IsMerged(xCurrentCellRange, j, nRow - 1, aCellAddress))
- {
- //unmerge
- uno::Reference <util::XMergeable> xMergeable
(xCurrentCellRange->getCellRangeByPosition(aCellAddress.StartColumn, aCellAddress.StartRow,
- aCellAddress.EndColumn,
aCellAddress.EndRow), uno::UNO_QUERY);
- if (xMergeable.is())
- xMergeable->merge(false);
- }
-
- //merge
- uno::Reference <util::XMergeable> xMergeable
(xCurrentCellRange->getCellRangeByPosition(aCellAddress.StartColumn, aCellAddress.StartRow,
- aCellAddress.EndColumn, aCellAddress.EndRow +
1), uno::UNO_QUERY);
- if (xMergeable.is())
- xMergeable->merge(true);
- j += aCellAddress.EndColumn - aCellAddress.StartColumn;
- }
- rImport.GetStylesImportHelper()->InsertRow(nRow, nCurrentSheet, rImport.GetDocument());
- }
-}
-
void ScMyTables::NewRow()
{
size_t n = maTables.size();
@@ -395,7 +274,7 @@ void ScMyTables::NewRow()
maTables[n-2].GetRowsPerRow(maTables[n-2].GetRow()) - 1)
{
if (GetRealScCellPos().Col() > 0)
- InsertRow();
+ rImport.GetStylesImportHelper()->InsertRow(GetRealScCellPos().Row(), nCurrentSheet,
rImport.GetDocument());
for (size_t i = n - 1; i > 0; --i)
{
@@ -428,55 +307,6 @@ void ScMyTables::SetRowStyle(const rtl::OUString& rCellStyleName)
rImport.GetStylesImportHelper()->SetRowStyle(rCellStyleName);
}
-void ScMyTables::InsertColumn()
-{
- if ( xCurrentCellRange.is() )
- {
- //extra step here until this area is fully converted
- com::sun::star::table::CellAddress aCellPos;
- ScAddress aScCellPos = GetRealScCellPos();
- ScUnoConversion::FillApiAddress( aCellPos, aScCellPos );
-
- table::CellRangeAddress aCellAddress;
- sal_Int32 nCol(aCellPos.Column);
- sal_Int32 n = aCellPos.Row - pCurrentTab->GetRow() - 1;
- for (sal_Int32 j = 0; j <= n; ++j)
- {
- table::CellRangeAddress aTempCellAddress;
- if (IsMerged(xCurrentCellRange, nCol - 1, j, aCellAddress))
- {
- //unmerge
- uno::Reference <util::XMergeable> xMergeable
(xCurrentCellRange->getCellRangeByPosition(aCellAddress.StartColumn, aCellAddress.StartRow,
- aCellAddress.EndColumn,
aCellAddress.EndRow), uno::UNO_QUERY);
- if (xMergeable.is())
- xMergeable->merge(false);
- aTempCellAddress = aCellAddress;
- aTempCellAddress.StartColumn = aTempCellAddress.EndColumn + 1;
- aTempCellAddress.EndColumn = aTempCellAddress.StartColumn;
- }
- else
- {
- aTempCellAddress = aCellAddress;
- aTempCellAddress.StartColumn += 1;
- aTempCellAddress.EndColumn = aTempCellAddress.StartColumn;
- }
-
- //insert Cell
- sheet::CellInsertMode aCellInsertMode(sheet::CellInsertMode_RIGHT);
- uno::Reference <sheet::XCellRangeMovement> xCellRangeMovement (xCurrentSheet,
uno::UNO_QUERY);
- xCellRangeMovement->insertCells(aTempCellAddress, aCellInsertMode);
-
- //merge
- uno::Reference <util::XMergeable> xMergeable
(xCurrentCellRange->getCellRangeByPosition(aCellAddress.StartColumn, aCellAddress.StartRow,
- aCellAddress.EndColumn + 1,
aCellAddress.EndRow), uno::UNO_QUERY);
- if (xMergeable.is())
- xMergeable->merge(true);
- j += aCellAddress.EndRow - aCellAddress.StartRow;
- }
- rImport.GetStylesImportHelper()->InsertCol(nCol, nCurrentSheet, rImport.GetDocument());
- }
-}
-
void ScMyTables::NewColumn(bool bIsCovered)
{
if (bIsCovered)
@@ -507,7 +337,7 @@ void ScMyTables::NewColumn(bool bIsCovered)
{
if (pCurrentTab->GetRow() == 0)
{
- InsertColumn();
+ rImport.GetStylesImportHelper()->InsertCol(GetRealScCellPos().Col(), nCurrentSheet,
rImport.GetDocument());
size_t n = maTables.size();
for (size_t i = n - 1; i > 0; --i)
{
@@ -537,15 +367,8 @@ void ScMyTables::AddColumn(bool bIsCovered)
{
NewColumn(bIsCovered);
sal_Int32 nCol = pCurrentTab->GetColumn();
- sal_Int32 nRow = pCurrentTab->GetRow();
pCurrentTab->SetRealCols(
nCol + 1, pCurrentTab->GetRealCols(nCol) + pCurrentTab->GetColsPerCol(nCol));
-
- if ((!bIsCovered) || (bIsCovered && (pCurrentTab->GetColsPerCol(nCol) > 1)))
- {
- if ((pCurrentTab->GetRowsPerRow(nRow) > 1) || (pCurrentTab->GetColsPerCol(nCol) > 1))
- DoMerge();
- }
}
}
@@ -582,12 +405,6 @@ void ScMyTables::NewTable(sal_Int32 nTempSpannedCols)
}
pCurrentTab->SetSpannedCols(nTempSpannedCols);
-
- if (nTables > 1)
- {
- maTables[nTables-2].SetSubTableSpanned(pCurrentTab->GetSpannedCols());
- UnMerge();
- }
}
void ScMyTables::UpdateRowHeights()
diff --git a/sc/source/filter/xml/xmlsubti.hxx b/sc/source/filter/xml/xmlsubti.hxx
index 352a7d3..edab1bd 100644
--- a/sc/source/filter/xml/xmlsubti.hxx
+++ b/sc/source/filter/xml/xmlsubti.hxx
@@ -143,14 +143,7 @@ private:
SCTAB nCurrentSheet;
ScMyTableData* pCurrentTab;
- bool IsMerged (const com::sun::star::uno::Reference
<com::sun::star::table::XCellRange>& xCellRange,
- const sal_Int32 nCol, const sal_Int32 nRow,
- com::sun::star::table::CellRangeAddress&
aCellAddress) const;
- void UnMerge();
- void DoMerge(sal_Int32 nCount = -1);
- void InsertRow();
void NewRow();
- void InsertColumn();
void NewColumn(bool bIsCovered);
void SetTableStyle(const rtl::OUString& sStyleName);
Context
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.