[Libreoffice-commits] .: 2 commits - sc/inc sc/source
Markus Mohrhard
mmohrhard at kemper.freedesktop.org
Wed Aug 10 13:38:49 PDT 2011
sc/inc/rangenam.hxx | 1
sc/source/core/tool/rangenam.cxx | 11 ++++
sc/source/filter/xml/xmlexprt.cxx | 100 +++++++++++---------------------------
sc/source/filter/xml/xmlexprt.hxx | 5 +
sc/source/ui/namedlg/namedlg.cxx | 4 +
5 files changed, 50 insertions(+), 71 deletions(-)
New commits:
commit bc126204338b0a64062ad3466234b8082684168d
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed Aug 10 22:30:59 2011 +0200
remove uno from range name export and some clean up
diff --git a/sc/inc/rangenam.hxx b/sc/inc/rangenam.hxx
index a3b3bc7..4411b48 100644
--- a/sc/inc/rangenam.hxx
+++ b/sc/inc/rangenam.hxx
@@ -127,6 +127,7 @@ public:
void AddType( RangeType nType ) { eType = eType|nType; }
RangeType GetType() const { return eType; }
bool HasType( RangeType nType ) const;
+ sal_uInt32 GetUnoType() const;
SC_DLLPUBLIC void GetSymbol( String& rSymbol, const formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_DEFAULT ) const;
SC_DLLPUBLIC void GetSymbol( rtl::OUString& rSymbol, const formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_DEFAULT ) const;
void UpdateSymbol( rtl::OUStringBuffer& rBuffer, const ScAddress&,
diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index eab59f8..14c1833 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -36,6 +36,7 @@
#include <memory>
#include <unotools/collatorwrapper.hxx>
#include <unotools/transliterationwrapper.hxx>
+#include <com/sun/star/sheet/NamedRangeFlag.hpp>
#include "token.hxx"
#include "tokenarray.hxx"
@@ -532,6 +533,16 @@ bool ScRangeData::HasReferences() const
return pCode->GetNextReference() != NULL;
}
+sal_uInt32 ScRangeData::GetUnoType() const
+{
+ sal_uInt32 nUnoType = 0;
+ if ( HasType(RT_CRITERIA) ) nUnoType |= com::sun::star::sheet::NamedRangeFlag::FILTER_CRITERIA;
+ if ( HasType(RT_PRINTAREA) ) nUnoType |= com::sun::star::sheet::NamedRangeFlag::PRINT_AREA;
+ if ( HasType(RT_COLHEADER) ) nUnoType |= com::sun::star::sheet::NamedRangeFlag::COLUMN_HEADER;
+ if ( HasType(RT_ROWHEADER) ) nUnoType |= com::sun::star::sheet::NamedRangeFlag::ROW_HEADER;
+ return nUnoType;
+}
+
// bei TransferTab von einem in ein anderes Dokument anpassen,
// um Referenzen auf die eigene Tabelle mitzubekommen
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 5ef06cf..782a7b1 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -1730,7 +1730,7 @@ void ScXMLExport::_ExportContent()
}
}
WriteExternalRefCaches();
- WriteNamedExpressions(xSpreadDoc);
+ WriteNamedExpressions();
aExportDatabaseRanges.WriteDatabaseRanges();
ScXMLExportDataPilot aExportDataPilot(*this);
aExportDataPilot.WriteDataPilots(xSpreadDoc);
@@ -2837,31 +2837,12 @@ void ScXMLExport::WriteTable(sal_Int32 nTable, const Reference<sheet::XSpreadshe
if (pDoc)
{
// Export sheet-local named ranges.
- ScRangeName* pRN = pDoc->GetRangeName(nTable);
- if (pRN && !pRN->empty())
+ ScRangeName* pRangeName = pDoc->GetRangeName(nTable);
+ if (pRangeName && !pRangeName->empty())
{
- SvXMLElementExport aElemNEs(*this, XML_NAMESPACE_TABLE, XML_NAMED_EXPRESSIONS, sal_True, sal_True);
- ScRangeName::const_iterator itr = pRN->begin(), itrEnd = pRN->end();
- for (; itr != itrEnd; ++itr)
- {
- CheckAttrList();
-
- // name
- OUString aStr = itr->GetName();
- AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, aStr);
-
- // base cell
- ScAddress aPos = itr->GetPos();
- aPos.Format(aStr, SCA_ABS_3D, pDoc, FormulaGrammar::CONV_OOO);
- AddAttribute(XML_NAMESPACE_TABLE, XML_BASE_CELL_ADDRESS, aStr);
-
- // expression
- itr->GetSymbol(aStr, pDoc->GetStorageGrammar());
- AddAttribute(XML_NAMESPACE_TABLE, XML_EXPRESSION, aStr);
-
- SvXMLElementExport aElemNR(*this, XML_NAMESPACE_TABLE, XML_NAMED_EXPRESSION, sal_True, sal_True);
- }
+ WriteNamedRange(pRangeName);
}
+
}
}
@@ -3728,58 +3709,38 @@ void ScXMLExport::WriteLabelRanges( const uno::Reference< container::XIndexAcces
}
}
-void ScXMLExport::WriteNamedExpressions(const com::sun::star::uno::Reference <com::sun::star::sheet::XSpreadsheetDocument>& xSpreadDoc)
+void ScXMLExport::WriteNamedExpressions()
{
- uno::Reference <beans::XPropertySet> xPropertySet (xSpreadDoc, uno::UNO_QUERY);
- if (!xPropertySet.is())
- return;
-
- uno::Reference <sheet::XNamedRanges> xNamedRanges(xPropertySet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_NAMEDRANGES))), uno::UNO_QUERY);
- CheckAttrList();
- if (!xNamedRanges.is())
- return;
-
- uno::Sequence <rtl::OUString> aRangesNames(xNamedRanges->getElementNames());
- sal_Int32 nNamedRangesCount = aRangesNames.getLength();
- if (nNamedRangesCount <= 0)
- return;
-
if (!pDoc)
return;
-
ScRangeName* pNamedRanges = pDoc->GetRangeName();
+ WriteNamedRange(pNamedRanges);
+}
+
+void ScXMLExport::WriteNamedRange(ScRangeName* pRangeName)
+{
+ //write a global or local ScRangeName
SvXMLElementExport aElemNEs(*this, XML_NAMESPACE_TABLE, XML_NAMED_EXPRESSIONS, sal_True, sal_True);
- for (sal_Int32 i = 0; i < nNamedRangesCount; ++i)
+ for (ScRangeName::iterator it = pRangeName->begin(); it != pRangeName->end(); ++it)
{
- CheckAttrList();
- rtl::OUString sNamedRange(aRangesNames[i]);
- uno::Reference <sheet::XNamedRange> xNamedRange(xNamedRanges->getByName(sNamedRange), uno::UNO_QUERY);
- if (!xNamedRange.is())
- continue;
-
- uno::Reference <container::XNamed> xNamed (xNamedRange, uno::UNO_QUERY);
- uno::Reference <sheet::XCellRangeReferrer> xCellRangeReferrer (xNamedRange, uno::UNO_QUERY);
- if (!xNamed.is() || !xCellRangeReferrer.is())
- continue;
-
- rtl::OUString sOUName(xNamed->getName());
- AddAttribute(sAttrName, sOUName);
+ AddAttribute(sAttrName, it->GetName());
+
+ rtl::OUString sBaseCellAddress;
+ ScRangeStringConverter::GetStringFromAddress( sBaseCellAddress, it->GetPos(), pDoc,
+ FormulaGrammar::CONV_OOO, ' ', false, SCA_ABS_3D);
+ AddAttribute(XML_NAMESPACE_TABLE, XML_BASE_CELL_ADDRESS, sBaseCellAddress);
+
+ String sSymbol;
+ it->GetSymbol(sSymbol, pDoc->GetStorageGrammar());
+ rtl::OUString sTempSymbol(sSymbol);
+ ScRange aRange;
+ if (it->IsReference(aRange))
+ {
- OUString sOUBaseCellAddress;
- ScRangeStringConverter::GetStringFromAddress( sOUBaseCellAddress,
- xNamedRange->getReferencePosition(), pDoc, FormulaGrammar::CONV_OOO, ' ', sal_False, SCA_ABS_3D );
- AddAttribute(XML_NAMESPACE_TABLE, XML_BASE_CELL_ADDRESS, sOUBaseCellAddress);
+ rtl::OUString sContent(sTempSymbol.copy(1, sTempSymbol.getLength() -2 ));
+ AddAttribute(XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, sContent);
- const ScRangeData* pNamedRange = pNamedRanges->findByName(sOUName);
- String sContent;
- pNamedRange->GetSymbol(sContent, pDoc->GetStorageGrammar());
- rtl::OUString sOUTempContent(sContent);
- uno::Reference <table::XCellRange> xCellRange(xCellRangeReferrer->getReferredCells());
- if(xCellRange.is())
- {
- rtl::OUString sOUContent(sOUTempContent.copy(1, sOUTempContent.getLength() - 2));
- AddAttribute(XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, sOUContent);
- sal_Int32 nRangeType(xNamedRange->getType());
+ sal_Int32 nRangeType = it->GetUnoType();
rtl::OUStringBuffer sBufferRangeType;
if ((nRangeType & sheet::NamedRangeFlag::COLUMN_HEADER) == sheet::NamedRangeFlag::COLUMN_HEADER)
sBufferRangeType.append(GetXMLToken(XML_REPEAT_COLUMN));
@@ -3805,10 +3766,11 @@ void ScXMLExport::WriteNamedExpressions(const com::sun::star::uno::Reference <co
if (sRangeType.getLength())
AddAttribute(XML_NAMESPACE_TABLE, XML_RANGE_USABLE_AS, sRangeType);
SvXMLElementExport aElemNR(*this, XML_NAMESPACE_TABLE, XML_NAMED_RANGE, sal_True, sal_True);
+
}
else
{
- AddAttribute(XML_NAMESPACE_TABLE, XML_EXPRESSION, sOUTempContent);
+ AddAttribute(XML_NAMESPACE_TABLE, XML_EXPRESSION, sTempSymbol);
SvXMLElementExport aElemNE(*this, XML_NAMESPACE_TABLE, XML_NAMED_EXPRESSION, sal_True, sal_True);
}
}
diff --git a/sc/source/filter/xml/xmlexprt.hxx b/sc/source/filter/xml/xmlexprt.hxx
index 7dcd400..3cefa47 100644
--- a/sc/source/filter/xml/xmlexprt.hxx
+++ b/sc/source/filter/xml/xmlexprt.hxx
@@ -66,6 +66,7 @@ class SfxItemPool;
class ScAddress;
class ScBaseCell;
class ScXMLCachedRowAttrAccess;
+class ScRangeName;
typedef std::vector< com::sun::star::uno::Reference < com::sun::star::drawing::XShapes > > ScMyXShapesVec;
@@ -202,10 +203,12 @@ class ScXMLExport : public SvXMLExport
void WriteScenario(); // core implementation
void WriteTheLabelRanges(const com::sun::star::uno::Reference< com::sun::star::sheet::XSpreadsheetDocument >& xSpreadDoc);
void WriteLabelRanges( const com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess >& xRangesIAccess, sal_Bool bColumn );
- void WriteNamedExpressions(const com::sun::star::uno::Reference <com::sun::star::sheet::XSpreadsheetDocument>& xSpreadDoc);
+ void WriteNamedExpressions();
+ void WriteNamedRange(ScRangeName* pRangeName);
void WriteExternalRefCaches();
void WriteConsolidation(); // core implementation
+
void CollectUserDefinedNamespaces(const SfxItemPool* pPool, sal_uInt16 nAttrib);
void AddStyleFromCells(
commit 644976fe93528f2c222f18f22861d6e90ba4f69e
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed Aug 10 02:55:36 2011 +0200
fix for fdo#39915: defining named ranges should be case insensitive
diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx
index 6a6053c..89fd95c 100644
--- a/sc/source/ui/namedlg/namedlg.cxx
+++ b/sc/source/ui/namedlg/namedlg.cxx
@@ -388,7 +388,9 @@ bool ScNameDlg::AddPushed()
// in ein Token-Array uebersetzt werden?)
if ( 0 == pNewEntry->GetErrCode() )
{
- ScRangeData* pData = mpCurRangeName->findByName(aNewEntry);
+ rtl::OUString aUpper = aNewEntry;
+ aUpper.toAsciiUpperCase();
+ ScRangeData* pData = mpCurRangeName->findByUpperName(aUpper);
if (pData)
{
pNewEntry->SetIndex(pData->GetIndex());
More information about the Libreoffice-commits
mailing list