summaryrefslogtreecommitdiff
path: root/sc/source/filter/xml
diff options
context:
space:
mode:
authorSascha Ballach <sab@openoffice.org>2000-12-13 16:17:33 +0000
committerSascha Ballach <sab@openoffice.org>2000-12-13 16:17:33 +0000
commit0c3782dc0396178ed1954e83eb5569bbe17610a4 (patch)
treedd23ea260d4728fc3b2f38efcfe8f0be169b15c5 /sc/source/filter/xml
parent20a6af13d9d9f4f7c1a5e1a2165c0c8493ea28a5 (diff)
#81841#; the size of the shape is now set after read the complete table
Diffstat (limited to 'sc/source/filter/xml')
-rw-r--r--sc/source/filter/xml/XMLTableShapeImportHelper.cxx13
-rw-r--r--sc/source/filter/xml/XMLTableShapeResizer.cxx152
-rw-r--r--sc/source/filter/xml/XMLTableShapeResizer.hxx102
-rw-r--r--sc/source/filter/xml/makefile.mk10
-rw-r--r--sc/source/filter/xml/xmlsubti.cxx14
-rw-r--r--sc/source/filter/xml/xmlsubti.hxx12
6 files changed, 288 insertions, 15 deletions
diff --git a/sc/source/filter/xml/XMLTableShapeImportHelper.cxx b/sc/source/filter/xml/XMLTableShapeImportHelper.cxx
index 3e08e999bf06..c132ee6ab7e0 100644
--- a/sc/source/filter/xml/XMLTableShapeImportHelper.cxx
+++ b/sc/source/filter/xml/XMLTableShapeImportHelper.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: XMLTableShapeImportHelper.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: sab $ $Date: 2000-11-28 16:18:57 $
+ * last change: $Author: sab $ $Date: 2000-12-13 17:17:33 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -126,6 +126,7 @@ void XMLTableShapeImportHelper::finishShape(
sal_Int32 X(-1);
sal_Int32 Y(-1);
sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ table::CellAddress aAddress;
for( sal_Int16 i=0; i < nAttrCount; i++ )
{
const rtl::OUString& rAttrName = xAttrList->getNameByIndex( i );
@@ -137,7 +138,6 @@ void XMLTableShapeImportHelper::finishShape(
&aLocalName );
if (nPrefix = XML_NAMESPACE_TABLE && aLocalName.compareToAscii(sXML_end_cell_address) == 0)
{
- table::CellAddress aAddress;
ScXMLConverter::GetAddressFromString(aAddress, rValue, rImport.GetDocument());
pRect = new Rectangle(rImport.GetDocument()->GetMMRect( aAddress.Column, aAddress.Row, aAddress.Column, aAddress.Row, aAddress.Sheet ));
}
@@ -149,16 +149,17 @@ void XMLTableShapeImportHelper::finishShape(
if (X >= 0 && Y >= 0 && pRect)
{
X += pRect->Left();
- Y += pRect->Top();
+ //Y += pRect->Top();
awt::Point aPoint = rShape->getPosition();
awt::Size aSize = rShape->getSize();
aPoint.X += aRefPoint.X;
- aPoint.Y += aRefPoint.Y;
+ //aPoint.Y += aRefPoint.Y;
aSize.Width = X - aPoint.X;
- aSize.Height = Y - aPoint.Y;
+ //aSize.Height = Y - aPoint.Y;
rShape->setPosition(aPoint);
rShape->setSize(aSize);
delete pRect;
+ rImport.GetTables().AddShape(rShape, aAddress, Y);
}
SvxShape* pShapeImp = SvxShape::getImplementation(rShape);
if (pShapeImp)
diff --git a/sc/source/filter/xml/XMLTableShapeResizer.cxx b/sc/source/filter/xml/XMLTableShapeResizer.cxx
new file mode 100644
index 000000000000..9596e8c088b1
--- /dev/null
+++ b/sc/source/filter/xml/XMLTableShapeResizer.cxx
@@ -0,0 +1,152 @@
+/*************************************************************************
+ *
+ * $RCSfile: XMLTableShapeResizer.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: sab $ $Date: 2000-12-13 17:17:33 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _SC_XMLTABLESHAPERESIZER_HXX
+#include "XMLTableShapeResizer.hxx"
+#endif
+#ifndef SC_UNONAMES_HXX
+#include "unonames.hxx"
+#endif
+#ifndef SC_DOCUMENT_HXX
+#include "document.hxx"
+#endif
+#ifndef SC_XMLIMPRT_HXX
+#include "xmlimprt.hxx"
+#endif
+
+#ifndef _COM_SUN_STAR_TABLE_XCOLUMNROWRANGE_HPP_
+#include <com/sun/star/table/XColumnRowRange.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+
+using namespace ::com::sun::star;
+
+ScMyShapeResizer::ScMyShapeResizer(ScXMLImport& rTempImport)
+ : aShapes(),
+ rImport(rTempImport)
+{
+}
+
+ScMyShapeResizer::~ScMyShapeResizer()
+{
+}
+
+void ScMyShapeResizer::AddShape(uno::Reference <drawing::XShape>& rShape,
+ com::sun::star::table::CellAddress& rAddress, sal_Int32 nY)
+{
+ ScMyToResizeShape aShape;
+ aShape.xShape = rShape;
+ aShape.aCell = rAddress;
+ aShape.nY = nY;
+ aShapes.push_back(aShape);
+}
+
+void ScMyShapeResizer::ResizeShapes(uno::Reference< sheet::XSpreadsheet > xSheet)
+{
+ if (aShapes.size())
+ {
+ rtl::OUString sRowHeight(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_CELLHGT));
+ ScMyToResizeShapes::iterator aItr = aShapes.begin();
+ uno::Reference<table::XColumnRowRange> xColumnRowRange (xSheet, uno::UNO_QUERY);
+ if (xColumnRowRange.is())
+ {
+ uno::Reference<table::XTableRows> xTableRows = xColumnRowRange->getRows();
+ if (xTableRows.is())
+ {
+ uno::Reference<table::XCellRange> xTableRow;
+ sal_Int32 nOldRow(-1);
+ Rectangle* pRect = NULL;
+ while (aItr != aShapes.end())
+ {
+ if (nOldRow != aItr->aCell.Row || !xTableRow.is())
+ {
+ uno::Any aRow = xTableRows->getByIndex(aItr->aCell.Row);
+ aRow >>= xTableRow;
+ }
+ if (xTableRow.is())
+ {
+ uno::Reference <beans::XPropertySet> xRowProperties(xTableRow, uno::UNO_QUERY);
+ if (xRowProperties.is())
+ {
+ uno::Any aAny = xRowProperties->getPropertyValue(sRowHeight);
+ sal_Int32 nHeight;
+ if (aAny >>= nHeight)
+ {
+ pRect = new Rectangle(rImport.GetDocument()->GetMMRect(
+ aItr->aCell.Column, aItr->aCell.Row, aItr->aCell.Column, aItr->aCell.Row, aItr->aCell.Sheet ));
+ sal_Int32 Y (nHeight - aItr->nY);
+ Y = pRect->Bottom() - Y;
+ awt::Point aPoint = aItr->xShape->getPosition();
+ awt::Size aSize = aItr->xShape->getSize();
+ aSize.Height = Y - aPoint.Y;
+ aItr->xShape->setSize(aSize);
+ delete pRect;
+ }
+ }
+ }
+ aItr = aShapes.erase(aItr);
+ }
+ }
+ }
+ }
+}
diff --git a/sc/source/filter/xml/XMLTableShapeResizer.hxx b/sc/source/filter/xml/XMLTableShapeResizer.hxx
new file mode 100644
index 000000000000..3b4bac36ccf5
--- /dev/null
+++ b/sc/source/filter/xml/XMLTableShapeResizer.hxx
@@ -0,0 +1,102 @@
+/*************************************************************************
+ *
+ * $RCSfile: XMLTableShapeResizer.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: sab $ $Date: 2000-12-13 17:17:33 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _SC_XMLTABLESHAPERESIZER_HXX
+#define _SC_XMLTABLESHAPERESIZER_HXX
+
+#ifndef _COM_SUN_STAR_DRAWING_XSHAPE_HPP_
+#include <com/sun/star/drawing/XShape.hpp>
+#endif
+#ifndef _COM_SUN_STAR_TABLE_CELLADDRESS_HPP_
+#include <com/sun/star/table/CellAddress.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SHEET_XSPREADSHEET_HPP_
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#endif
+#ifndef __SGI_STL_VECTOR
+#include <stl/vector>
+#endif
+
+class ScXMLImport;
+
+struct ScMyToResizeShape
+{
+ com::sun::star::uno::Reference <com::sun::star::drawing::XShape> xShape;
+ com::sun::star::table::CellAddress aCell;
+ sal_Int32 nY;
+};
+
+typedef std::vector<ScMyToResizeShape> ScMyToResizeShapes;
+
+class ScMyShapeResizer
+{
+ ScXMLImport& rImport;
+ ScMyToResizeShapes aShapes;
+public:
+ ScMyShapeResizer(ScXMLImport& rImport);
+ ~ScMyShapeResizer();
+
+ void AddShape(com::sun::star::uno::Reference <com::sun::star::drawing::XShape>& rShape,
+ com::sun::star::table::CellAddress& rAddress, sal_Int32 nY);
+ void ResizeShapes(::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet > xSheet);
+};
+
+#endif
diff --git a/sc/source/filter/xml/makefile.mk b/sc/source/filter/xml/makefile.mk
index de951349b233..fc2ffbad2c06 100644
--- a/sc/source/filter/xml/makefile.mk
+++ b/sc/source/filter/xml/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.18 $
+# $Revision: 1.19 $
#
-# last change: $Author: sab $ $Date: 2000-12-11 18:31:08 $
+# last change: $Author: sab $ $Date: 2000-12-13 17:17:33 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -122,7 +122,8 @@ CXXFILES = \
XMLDDELinksContext.cxx \
XMLCalculationSettingsContext.cxx \
XMLTableSourceContext.cxx \
- XMLTextPContext.cxx
+ XMLTextPContext.cxx \
+ XMLTableShapeResizer.cxx
SLOFILES = \
$(SLO)$/xmlwrap.obj \
@@ -164,7 +165,8 @@ SLOFILES = \
$(SLO)$/XMLDDELinksContext.obj \
$(SLO)$/XMLCalculationSettingsContext.obj \
$(SLO)$/XMLTableSourceContext.obj \
- $(SLO)$/XMLTextPContext.obj
+ $(SLO)$/XMLTextPContext.obj \
+ $(SLO)$/XMLTableShapeResizer.obj
# --- Tagets -------------------------------------------------------
diff --git a/sc/source/filter/xml/xmlsubti.cxx b/sc/source/filter/xml/xmlsubti.cxx
index a19eacd8a97e..73708a23d85e 100644
--- a/sc/source/filter/xml/xmlsubti.cxx
+++ b/sc/source/filter/xml/xmlsubti.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: xmlsubti.cxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: sab $ $Date: 2000-12-08 14:42:50 $
+ * last change: $Author: sab $ $Date: 2000-12-13 17:17:33 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -208,7 +208,8 @@ ScMyTables::ScMyTables(ScXMLImport& rTempImport)
: rImport(rTempImport),
nTableCount( 0 ),
nCurrentSheet( -1 ),
- nCurrentDrawPage( -1 )
+ nCurrentDrawPage( -1 ),
+ aResizeShapes(rTempImport)
{
aTableVec.resize(nDefaultTabCount, NULL);
}
@@ -647,6 +648,7 @@ void ScMyTables::DeleteTable()
xProtectable->protect(sKey);
}
}
+ aResizeShapes.ResizeShapes(xCurrentSheet);
}
table::CellAddress ScMyTables::GetRealCellPos()
@@ -701,3 +703,9 @@ sal_Bool ScMyTables::HasDrawPage()
{
return !((nCurrentSheet != nCurrentDrawPage) || !xDrawPage.is());
}
+
+void ScMyTables::AddShape(uno::Reference <drawing::XShape>& rShape,
+ com::sun::star::table::CellAddress& rAddress, sal_Int32 nY)
+{
+ aResizeShapes.AddShape(rShape, rAddress, nY);
+}
diff --git a/sc/source/filter/xml/xmlsubti.hxx b/sc/source/filter/xml/xmlsubti.hxx
index 4f74642870f2..885be295193d 100644
--- a/sc/source/filter/xml/xmlsubti.hxx
+++ b/sc/source/filter/xml/xmlsubti.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: xmlsubti.hxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: sab $ $Date: 2000-12-08 14:42:50 $
+ * last change: $Author: sab $ $Date: 2000-12-13 17:17:33 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -91,6 +91,10 @@
#endif
#include <list>
+#ifndef _SC_XMLTABLESHAPERESIZER_HXX
+#include "XMLTableShapeResizer.hxx"
+#endif
+
class ScXMLImport;
const nDefaultRowCount = 20;
@@ -147,6 +151,8 @@ class ScMyTables
private:
ScXMLImport& rImport;
+ ScMyShapeResizer aResizeShapes;
+
::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet > xCurrentSheet;
::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > xDrawPage;
rtl::OUString sCurrentSheetName;
@@ -188,6 +194,8 @@ public:
::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >
GetCurrentXShapes();
sal_Bool HasDrawPage();
+ void AddShape(com::sun::star::uno::Reference <com::sun::star::drawing::XShape>& rShape,
+ com::sun::star::table::CellAddress& rAddress, sal_Int32 nY);
};
#endif