diff options
Diffstat (limited to 'binfilter/bf_sc/source/filter/xml')
93 files changed, 35627 insertions, 0 deletions
diff --git a/binfilter/bf_sc/source/filter/xml/XMLCalculationSettingsContext.hxx b/binfilter/bf_sc/source/filter/xml/XMLCalculationSettingsContext.hxx new file mode 100644 index 000000000000..7404c72a2260 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/XMLCalculationSettingsContext.hxx @@ -0,0 +1,117 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SC_XMLCALCULATIONSETTINGSCONTEXT_HXX +#define _SC_XMLCALCULATIONSETTINGSCONTEXT_HXX + +#include <bf_xmloff/xmlictxt.hxx> + +#include <com/sun/star/util/Date.hpp> +namespace binfilter { + +class ScXMLImport; + +class ScXMLCalculationSettingsContext : public SvXMLImportContext +{ + ::com::sun::star::util::Date aNullDate; + double fIterationEpsilon; + sal_Int32 nIterationCount; + sal_uInt16 nYear2000; + sal_Bool bIsIterationEnabled : 1; + sal_Bool bCalcAsShown : 1; + sal_Bool bIgnoreCase : 1; + sal_Bool bLookUpLabels : 1; + sal_Bool bMatchWholeCell : 1; + sal_Bool bUseRegularExpressions : 1; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } +public: + ScXMLCalculationSettingsContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList); + + virtual ~ScXMLCalculationSettingsContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + void SetNullDate(const ::com::sun::star::util::Date& aDate) { aNullDate = aDate; } + void SetIterationStatus(const sal_Bool bValue) { bIsIterationEnabled = bValue; } + void SetIterationCount(const sal_Int32 nValue) { nIterationCount = nValue; } + void SetIterationEpsilon(const double fValue) { fIterationEpsilon = fValue; } + virtual void EndElement(); +}; + +class ScXMLNullDateContext : public SvXMLImportContext +{ + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } +public: + ScXMLNullDateContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, ScXMLCalculationSettingsContext* pCalcSet); + + virtual ~ScXMLNullDateContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +class ScXMLIterationContext : public SvXMLImportContext +{ + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } +public: + ScXMLIterationContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, ScXMLCalculationSettingsContext* pCalcSet); + + virtual ~ScXMLIterationContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/XMLCellRangeSourceContext.hxx b/binfilter/bf_sc/source/filter/xml/XMLCellRangeSourceContext.hxx new file mode 100644 index 000000000000..90a537cf28eb --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/XMLCellRangeSourceContext.hxx @@ -0,0 +1,84 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SC_XMLCELLRANGESOURCECONTEXT_HXX +#define _SC_XMLCELLRANGESOURCECONTEXT_HXX + +#include <bf_xmloff/xmlimp.hxx> +namespace binfilter { + +class ScXMLImport; + + +//___________________________________________________________________ + +struct ScMyImpCellRangeSource +{ + ::rtl::OUString sSourceStr; + ::rtl::OUString sFilterName; + ::rtl::OUString sFilterOptions; + ::rtl::OUString sURL; + sal_Int32 nColumns; + sal_Int32 nRows; + sal_Int32 nRefresh; + + ScMyImpCellRangeSource(); +}; + + +//___________________________________________________________________ + +class ScXMLCellRangeSourceContext : public SvXMLImportContext +{ +private: + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + ScXMLCellRangeSourceContext( + ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList, + ScMyImpCellRangeSource* pCellRangeSource + ); + virtual ~ScXMLCellRangeSourceContext(); + + virtual SvXMLImportContext* CreateChildContext( + USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList + ); + virtual void EndElement(); +}; + + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/XMLChangeTrackingExportHelper.hxx b/binfilter/bf_sc/source/filter/xml/XMLChangeTrackingExportHelper.hxx new file mode 100644 index 000000000000..e43edcd2a2bf --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/XMLChangeTrackingExportHelper.hxx @@ -0,0 +1,107 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SC_XMLCHANGETRACKINGEXPORTHELPER_HXX +#define _SC_XMLCHANGETRACKINGEXPORTHELPER_HXX + +#include <bf_xmloff/xmltoken.hxx> +#ifndef __SGI_STL_LIST +#include <list> +#endif +#include <com/sun/star/text/XText.hpp> +#include <rtl/ustrbuf.hxx> + +class DateTime; +class String; + +namespace binfilter { + +class ScChangeAction; +class ScChangeTrack; +class ScXMLExport; +class ScBaseCell; +class ScChangeActionDel; +class ScBigRange; +class ScEditEngineTextObj; +class ScChangeActionTable; + +typedef std::list<ScChangeActionDel*> ScMyDeletionsList; + +class ScChangeTrackingExportHelper +{ + ScXMLExport& rExport; + + ScChangeTrack* pChangeTrack; + ScEditEngineTextObj* pEditTextObj; + ScChangeActionTable* pDependings; + ::rtl::OUString sChangeIDPrefix; + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText> xText; + + ::rtl::OUString GetChangeID(const sal_uInt32 nActionNumber); + void GetAcceptanceState(const ScChangeAction* pAction); + + void WriteBigRange(const ScBigRange& rBigRange, xmloff::token::XMLTokenEnum aName); + void WriteChangeInfo(const ScChangeAction* pAction); + void WriteGenerated(const ScChangeAction* pDependAction); + void WriteDeleted(const ScChangeAction* pDependAction); + void WriteDepending(const ScChangeAction* pDependAction); + void WriteDependings(ScChangeAction* pAction); + + void WriteEmptyCell(); + void SetValueAttributes(const double& fValue, const String& sValue); + void WriteValueCell(const ScBaseCell* pCell, const String& sValue); + void WriteStringCell(const ScBaseCell* pCell); + void WriteEditCell(const ScBaseCell* pCell); + void WriteFormulaCell(const ScBaseCell* pCell, const String& sValue); + void WriteCell(const ScBaseCell* pCell, const String& sValue); + + void WriteContentChange(ScChangeAction* pAction); + void AddInsertionAttributes(const ScChangeAction* pAction); + void WriteInsertion(ScChangeAction* pAction); + void AddDeletionAttributes(const ScChangeActionDel* pAction, const ScChangeActionDel* pLastAction); + void WriteDeletionCells(ScChangeActionDel* pAction); + void WriteCutOffs(const ScChangeActionDel* pAction); + void WriteDeletion(ScChangeAction* pAction); + void WriteMovement(ScChangeAction* pAction); + void WriteRejection(ScChangeAction* pAction); + + void CollectCellAutoStyles(const ScBaseCell* pBaseCell); + void CollectActionAutoStyles(ScChangeAction* pAction); + void WorkWithChangeAction(ScChangeAction* pAction); +public: + ScChangeTrackingExportHelper(ScXMLExport& rExport); + ~ScChangeTrackingExportHelper(); + + void CollectAutoStyles(); + void CollectAndWriteChanges(); +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/XMLChangeTrackingImportHelper.hxx b/binfilter/bf_sc/source/filter/xml/XMLChangeTrackingImportHelper.hxx new file mode 100644 index 000000000000..be68800cde72 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/XMLChangeTrackingImportHelper.hxx @@ -0,0 +1,251 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SC_XMLCHANGETRACKINGIMPORTHELPER_HXX +#define _SC_XMLCHANGETRACKINGIMPORTHELPER_HXX + +#include "chgtrack.hxx" + +#ifndef __SGI_STL_LIST +#include <list> +#endif +#include <sal/types.h> +#include <com/sun/star/util/DateTime.hpp> +class DateTime; +namespace binfilter { + +class ScBaseCell; +class ScDocument; + +struct ScMyActionInfo +{ + ::rtl::OUString sUser; + ::rtl::OUString sComment; + ::com::sun::star::util::DateTime aDateTime; +}; + +struct ScMyCellInfo +{ + ScBaseCell* pCell; + ::rtl::OUString sFormulaAddress; + ::rtl::OUString sFormula; + String sResult; + double fValue; + sal_Int32 nMatrixCols; + sal_Int32 nMatrixRows; + sal_uInt16 nType; + sal_uInt8 nMatrixFlag; + + ScMyCellInfo(ScBaseCell* pCell, const ::rtl::OUString& sFormulaAddress, const ::rtl::OUString& sFormula, + const double& fValue, const sal_uInt16 nType, const sal_uInt8 nMatrixFlag, const sal_Int32 nMatrixCols, + const sal_Int32 nMatrixRows); + ~ScMyCellInfo(); + + ScBaseCell* CreateCell(ScDocument* pDoc); +}; + +struct ScMyDeleted +{ + sal_uInt32 nID; + ScMyCellInfo* pCellInfo; + + ScMyDeleted(); + ~ScMyDeleted(); +}; + +typedef std::list<ScMyDeleted*> ScMyDeletedList; + +struct ScMyGenerated +{ + ScBigRange aBigRange; + sal_uInt32 nID; + ScMyCellInfo* pCellInfo; + + ScMyGenerated(ScMyCellInfo* pCellInfo, const ScBigRange& aBigRange); + ~ScMyGenerated(); +}; + +typedef std::list<ScMyGenerated*> ScMyGeneratedList; + +struct ScMyInsertionCutOff +{ + sal_uInt32 nID; + sal_Int32 nPosition; + + ScMyInsertionCutOff(const sal_uInt32 nTempID, const sal_Int32 nTempPosition) : + nID(nTempID), nPosition(nTempPosition) {} +}; + +struct ScMyMoveCutOff +{ + sal_uInt32 nID; + sal_Int32 nStartPosition; + sal_Int32 nEndPosition; + + ScMyMoveCutOff(const sal_uInt32 nTempID, const sal_Int32 nStartPos, const sal_Int32 nEndPos) : + nID(nTempID), nStartPosition(nStartPos), nEndPosition(nEndPos) {} +}; + +typedef std::list<ScMyMoveCutOff> ScMyMoveCutOffs; + +struct ScMyMoveRanges +{ + ScBigRange aSourceRange; + ScBigRange aTargetRange; + + ScMyMoveRanges(const ScBigRange& aSource, const ScBigRange aTarget) : + aSourceRange(aSource), aTargetRange(aTarget) {} +}; + +typedef std::list<sal_uInt32> ScMyDependences; + +struct ScMyBaseAction +{ + ScMyActionInfo aInfo; + ScBigRange aBigRange; + ScMyDependences aDependences; + ScMyDeletedList aDeletedList; + sal_uInt32 nActionNumber; + sal_uInt32 nRejectingNumber; + sal_uInt32 nPreviousAction; + ScChangeActionType nActionType; + ScChangeActionState nActionState; + + ScMyBaseAction(const ScChangeActionType nActionType); + ~ScMyBaseAction(); +}; + +struct ScMyInsAction : public ScMyBaseAction +{ + ScMyInsAction(const ScChangeActionType nActionType); +}; + +struct ScMyDelAction : public ScMyBaseAction +{ + ScMyGeneratedList aGeneratedList; + ScMyInsertionCutOff* pInsCutOff; + ScMyMoveCutOffs aMoveCutOffs; + sal_Int16 nD; + + ScMyDelAction(const ScChangeActionType nActionType); + ~ScMyDelAction(); +}; + +struct ScMyMoveAction : public ScMyBaseAction +{ + ScMyGeneratedList aGeneratedList; + ScMyMoveRanges* pMoveRanges; + + ScMyMoveAction(); + ~ScMyMoveAction(); +}; + +struct ScMyContentAction : public ScMyBaseAction +{ + ScMyCellInfo* pCellInfo; + + ScMyContentAction(); + ~ScMyContentAction(); +}; + +struct ScMyRejAction : public ScMyBaseAction +{ + ScMyRejAction(); +}; + +typedef std::list<ScMyBaseAction*> ScMyActions; + +class ScChangeViewSettings; + +class ScXMLChangeTrackingImportHelper +{ + StrCollection aUsers; + ScMyActions aActions; + ::com::sun::star::uno::Sequence<sal_Int8> aProtect; + ScDocument* pDoc; + ScChangeTrack* pTrack; + ScMyBaseAction* pCurrentAction; + ::rtl::OUString sIDPrefix; + sal_uInt32 nPrefixLength; + sal_Int16 nMultiSpanned; + sal_Int16 nMultiSpannedSlaveCount; + sal_Bool bChangeTrack : 1; + +private: + void ConvertInfo(const ScMyActionInfo& aInfo, String& rUser, DateTime& aDateTime); + ScChangeAction* CreateInsertAction(ScMyInsAction* pAction); + ScChangeAction* CreateDeleteAction(ScMyDelAction* pAction); + ScChangeAction* CreateMoveAction(ScMyMoveAction* pAction); + ScChangeAction* CreateRejectionAction(ScMyRejAction* pAction); + ScChangeAction* CreateContentAction(ScMyContentAction* pAction); + + void CreateGeneratedActions(ScMyGeneratedList& rList); + +public: + ScXMLChangeTrackingImportHelper(); + ~ScXMLChangeTrackingImportHelper(); + + void SetChangeTrack(sal_Bool bValue) { bChangeTrack = bValue; } + void SetProtection(const ::com::sun::star::uno::Sequence<sal_Int8>& rProtect) { aProtect = rProtect; } + void StartChangeAction(const ScChangeActionType nActionType); + + sal_uInt32 GetIDFromString(const ::rtl::OUString& sID); + + void SetActionNumber(const sal_uInt32 nActionNumber) { pCurrentAction->nActionNumber = nActionNumber; } + void SetActionState(const ScChangeActionState nActionState) { pCurrentAction->nActionState = nActionState; } + void SetRejectingNumber(const sal_uInt32 nRejectingNumber) { pCurrentAction->nRejectingNumber = nRejectingNumber; } + void SetActionInfo(const ScMyActionInfo& aInfo); + void SetBigRange(const ScBigRange& aBigRange) { pCurrentAction->aBigRange = aBigRange; } + void SetPreviousChange(const sal_uInt32 nPreviousAction, ScMyCellInfo* pCellInfo); + void SetPosition(const sal_Int32 nPosition, const sal_Int32 nCount, const sal_Int32 nTable); + void AddDependence(const sal_uInt32 nID) { pCurrentAction->aDependences.push_front(nID); } + void AddDeleted(const sal_uInt32 nID); + void AddDeleted(const sal_uInt32 nID, ScMyCellInfo* pCellInfo); + void SetMultiSpanned(const sal_Int16 nMultiSpanned); + void SetInsertionCutOff(const sal_uInt32 nID, const sal_Int32 nPosition); + void AddMoveCutOff(const sal_uInt32 nID, const sal_Int32 nStartPosition, const sal_Int32 nEndPosition); + void SetMoveRanges(const ScBigRange& aSourceRange, const ScBigRange& aTargetRange); + void GetMultiSpannedRange(); + void AddGenerated(ScMyCellInfo* pCellInfo, const ScBigRange& aBigRange); + + void EndChangeAction(); + + void SetDeletionDependences(ScMyDelAction* pAction, ScChangeActionDel* pDelAct); + void SetMovementDependences(ScMyMoveAction* pAction, ScChangeActionMove* pMoveAct); + void SetContentDependences(ScMyContentAction* pAction, ScChangeActionContent* pActContent); + void SetDependences(ScMyBaseAction* pAction); + + void SetNewCell(ScMyContentAction* pAction); + + void CreateChangeTrack(ScDocument* pDoc); +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/XMLColumnRowGroupExport.hxx b/binfilter/bf_sc/source/filter/xml/XMLColumnRowGroupExport.hxx new file mode 100644 index 000000000000..d60be36a81cd --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/XMLColumnRowGroupExport.hxx @@ -0,0 +1,80 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SC_XMLCOLUMNROWGROUPEXPORT_HXX +#define _SC_XMLCOLUMNROWGROUPEXPORT_HXX + +#ifndef __SGI_STL_LIST +#include <list> +#endif +#include <rtl/ustring.hxx> + +#include <sal/types.h> +namespace binfilter { + +struct ScMyColumnRowGroup +{ + sal_Int32 nField; + sal_Int16 nLevel; + sal_Bool bDisplay : 1; + + ScMyColumnRowGroup(); + sal_Bool operator< (const ScMyColumnRowGroup& rGroup) const; +}; + +typedef std::list <ScMyColumnRowGroup> ScMyColumnRowGroupVec; +typedef std::list <sal_Int32> ScMyFieldGroupVec; + +class ScXMLExport; +class ScMyOpenCloseColumnRowGroup +{ + ScXMLExport& rExport; + const ::rtl::OUString rName; + ScMyColumnRowGroupVec aTableStart; + ScMyFieldGroupVec aTableEnd; + + void OpenGroup(const ScMyColumnRowGroup& rGroup); + void CloseGroup(); +public: + ScMyOpenCloseColumnRowGroup(ScXMLExport& rExport, sal_uInt32 nToken); + ~ScMyOpenCloseColumnRowGroup(); + + void NewTable(); + void AddGroup(const ScMyColumnRowGroup& aGroup, const sal_Int32 nEndField); + sal_Bool IsGroupStart(const sal_Int32 nField); + void OpenGroups(const sal_Int32 nField); + sal_Bool IsGroupEnd(const sal_Int32 nField); + void CloseGroups(const sal_Int32 nField); + sal_Int32 GetLast(); + void Sort(); +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/XMLConsolidationContext.hxx b/binfilter/bf_sc/source/filter/xml/XMLConsolidationContext.hxx new file mode 100644 index 000000000000..085523e44c0c --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/XMLConsolidationContext.hxx @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SC_XMLCONSOLIDATIONCONTEXT_HXX +#define _SC_XMLCONSOLIDATIONCONTEXT_HXX + +#include "global.hxx" + +#include <bf_xmloff/xmlimp.hxx> +namespace binfilter { + +class ScXMLImport; + + +//___________________________________________________________________ + +class ScXMLConsolidationContext : public SvXMLImportContext +{ +private: + ::rtl::OUString sSourceList; + ::rtl::OUString sUseLabel; + ScAddress aTargetAddr; + ScSubTotalFunc eFunction; + sal_Bool bLinkToSource : 1; + sal_Bool bTargetAddr : 1; + +protected: + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + ScXMLConsolidationContext( + ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList + ); + virtual ~ScXMLConsolidationContext(); + + virtual SvXMLImportContext* CreateChildContext( + USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList + ); + virtual void EndElement(); +}; + + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/XMLConverter.hxx b/binfilter/bf_sc/source/filter/xml/XMLConverter.hxx new file mode 100644 index 000000000000..e438fbd83e5c --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/XMLConverter.hxx @@ -0,0 +1,234 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SC_XMLCONVERTER_HXX +#define _SC_XMLCONVERTER_HXX + +#include "global.hxx" +#include "detfunc.hxx" +#include "detdata.hxx" + +#include <rtl/ustrbuf.hxx> + +#include <com/sun/star/frame/XModel.hpp> + +#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp> +#include <com/sun/star/sheet/GeneralFunction.hpp> + +#include <com/sun/star/table/CellAddress.hpp> +#include <com/sun/star/table/CellRangeAddress.hpp> +#include <com/sun/star/util/DateTime.hpp> +class DateTime; +namespace binfilter { + +class ScArea; +class ScDocument; +class ScRangeList; +class SvXMLUnitConverter; + +//___________________________________________________________________ + +class ScXMLConverter +{ +protected: + static void AssignString( + ::rtl::OUString& rString, + const ::rtl::OUString& rNewStr, + sal_Bool bAppendStr ); + + static sal_Int32 IndexOf( + const ::rtl::OUString& rString, + sal_Unicode cSearchChar, + sal_Int32 nOffset, + sal_Unicode cQuote = '\'' ); + + static sal_Int32 IndexOfDifferent( + const ::rtl::OUString& rString, + sal_Unicode cSearchChar, + sal_Int32 nOffset ); + +public: + inline ScXMLConverter() {} + inline ~ScXMLConverter() {} + +// helper methods + static sal_Int32 GetTokenCount( + const ::rtl::OUString& rString ); + static void GetTokenByOffset( + ::rtl::OUString& rToken, + const ::rtl::OUString& rString, + sal_Int32& nOffset, + sal_Unicode cQuote = '\'' ); + + static ScDocument* GetScDocument( + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > xModel ); + +// IMPORT: CellAddress / CellRange + static sal_Bool GetAddressFromString( + ScAddress& rAddress, + const ::rtl::OUString& rAddressStr, + const ScDocument* pDocument, + sal_Int32& nOffset ); + static sal_Bool GetRangeFromString( + ScRange& rRange, + const ::rtl::OUString& rRangeStr, + const ScDocument* pDocument, + sal_Int32& nOffset ); + static void GetRangeListFromString( + ScRangeList& rRangeList, + const ::rtl::OUString& rRangeListStr, + const ScDocument* pDocument ); + + static sal_Bool GetAreaFromString( + ScArea& rArea, + const ::rtl::OUString& rRangeStr, + const ScDocument* pDocument, + sal_Int32& nOffset ); + + static sal_Bool GetAddressFromString( + ::com::sun::star::table::CellAddress& rAddress, + const ::rtl::OUString& rAddressStr, + const ScDocument* pDocument, + sal_Int32& nOffset ); + static sal_Bool GetRangeFromString( + ::com::sun::star::table::CellRangeAddress& rRange, + const ::rtl::OUString& rRangeStr, + const ScDocument* pDocument, + sal_Int32& nOffset ); + static void GetRangeListFromString( + ::com::sun::star::uno::Sequence< ::com::sun::star::table::CellRangeAddress >& rRangeSeq, + const ::rtl::OUString& rRangeListStr, + const ScDocument* pDocument ); + +// EXPORT: CellAddress / CellRange + static void GetStringFromAddress( + ::rtl::OUString& rString, + const ScAddress& rAddress, + const ScDocument* pDocument, + sal_Bool bAppendStr = sal_False, + sal_uInt16 nFormatFlags = (SCA_VALID | SCA_TAB_3D) ); + static void GetStringFromRange( + ::rtl::OUString& rString, + const ScRange& rRange, + const ScDocument* pDocument, + sal_Bool bAppendStr = sal_False, + sal_uInt16 nFormatFlags = (SCA_VALID | SCA_TAB_3D) ); + static void GetStringFromRangeList( + ::rtl::OUString& rString, + const ScRangeList* pRangeList, + const ScDocument* pDocument, + sal_uInt16 nFormatFlags = (SCA_VALID | SCA_TAB_3D) ); + + static void GetStringFromArea( + ::rtl::OUString& rString, + const ScArea& rArea, + const ScDocument* pDocument, + sal_Bool bAppendStr = sal_False, + sal_uInt16 nFormatFlags = (SCA_VALID | SCA_TAB_3D) ); + + static void GetStringFromAddress( + ::rtl::OUString& rString, + const ::com::sun::star::table::CellAddress& rAddress, + const ScDocument* pDocument, + sal_Bool bAppendStr = sal_False, + sal_uInt16 nFormatFlags = (SCA_VALID | SCA_TAB_3D) ); + static void GetStringFromRange( + ::rtl::OUString& rString, + const ::com::sun::star::table::CellRangeAddress& rRange, + const ScDocument* pDocument, + sal_Bool bAppendStr = sal_False, + sal_uInt16 nFormatFlags = (SCA_VALID | SCA_TAB_3D) ); + static void GetStringFromRangeList( + ::rtl::OUString& rString, + const ::com::sun::star::uno::Sequence< ::com::sun::star::table::CellRangeAddress >& rRangeSeq, + const ScDocument* pDocument, + sal_uInt16 nFormatFlags = (SCA_VALID | SCA_TAB_3D) ); + +// IMPORT: GeneralFunction / ScSubTotalFunc + static ::com::sun::star::sheet::GeneralFunction + GetFunctionFromString( + const ::rtl::OUString& rString ); + static ScSubTotalFunc GetSubTotalFuncFromString( + const ::rtl::OUString& rString ); + +// EXPORT: GeneralFunction / ScSubTotalFunc + static void GetStringFromFunction( + ::rtl::OUString& rString, + const ::com::sun::star::sheet::GeneralFunction eFunction, + sal_Bool bAppendStr = sal_False ); + static void GetStringFromFunction( + ::rtl::OUString& rString, + const ScSubTotalFunc eFunction, + sal_Bool bAppendStr = sal_False ); + +// IMPORT: DataPilotFieldOrientation + static ::com::sun::star::sheet::DataPilotFieldOrientation + GetOrientationFromString( + const ::rtl::OUString& rString ); + +// EXPORT: DataPilotFieldOrientation + static void GetStringFromOrientation( + ::rtl::OUString& rString, + const ::com::sun::star::sheet::DataPilotFieldOrientation eOrientation, + sal_Bool bAppendStr = sal_False ); + +// IMPORT: Detective + static ScDetectiveObjType + GetDetObjTypeFromString( + const ::rtl::OUString& rString ); + static sal_Bool GetDetOpTypeFromString( + ScDetOpType& rDetOpType, + const ::rtl::OUString& rString ); + +// EXPORT: Detective + static void GetStringFromDetObjType( + ::rtl::OUString& rString, + const ScDetectiveObjType eObjType, + sal_Bool bAppendStr = sal_False ); + static void GetStringFromDetOpType( + ::rtl::OUString& rString, + const ScDetOpType eOpType, + sal_Bool bAppendStr = sal_False ); + +// IMPORT: Formulas + static void ParseFormula( + ::rtl::OUString& sFormula, + const sal_Bool bIsFormula = sal_True); +// EXPORT: Core Date Time + static void ConvertDateTimeToString(const DateTime& aDateTime, ::rtl::OUStringBuffer& sDate); + + static void ConvertCoreToAPIDateTime(const DateTime& aDateTime, ::com::sun::star::util::DateTime& rDateTime); + + static void ConvertAPIToCoreDateTime(const ::com::sun::star::util::DateTime& aDateTime, DateTime& rDateTime); +}; + + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/XMLDDELinksContext.hxx b/binfilter/bf_sc/source/filter/xml/XMLDDELinksContext.hxx new file mode 100644 index 000000000000..602ee71556f4 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/XMLDDELinksContext.hxx @@ -0,0 +1,237 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SC_XMLDDELINKSCONTEXT_HXX +#define _SC_XMLDDELINKSCONTEXT_HXX + +#include <bf_xmloff/xmlictxt.hxx> + +#ifndef __SGI_STL_LIST +#include <list> +#endif +namespace binfilter { + +class ScXMLImport; + +class ScXMLDDELinksContext : public SvXMLImportContext +{ + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } +public: + ScXMLDDELinksContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList); + + virtual ~ScXMLDDELinksContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +struct ScDDELinkCell +{ + ::rtl::OUString sValue; + double fValue; + sal_Bool bString : 1; + sal_Bool bEmpty : 1; +}; + +typedef std::list<ScDDELinkCell> ScDDELinkCells; + +class ScXMLDDELinkContext : public SvXMLImportContext +{ + ScDDELinkCells aDDELinkTable; + ScDDELinkCells aDDELinkRow; + ::rtl::OUString sApplication; + ::rtl::OUString sTopic; + ::rtl::OUString sItem; + sal_Int32 nPosition; + sal_Int32 nColumns; + sal_Int32 nRows; + sal_uInt8 nMode; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } +public: + ScXMLDDELinkContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList); + + virtual ~ScXMLDDELinkContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + void SetApplication(const ::rtl::OUString& sValue) { sApplication = sValue; } + void SetTopic(const ::rtl::OUString& sValue) { sTopic = sValue; } + void SetItem(const ::rtl::OUString& sValue) { sItem = sValue; } + void SetMode(const sal_uInt8 nValue) { nMode = nValue; } + void CreateDDELink(); + void AddColumns(const sal_Int32 nValue) { nColumns += nValue; } + void AddRows(const sal_Int32 nValue) { nRows += nValue; } + void AddCellToRow(const ScDDELinkCell& aCell); + void AddRowsToTable(const sal_Int32 nRows); + + virtual void EndElement(); +}; + +class ScXMLDDESourceContext : public SvXMLImportContext +{ + ScXMLDDELinkContext* pDDELink; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } +public: + ScXMLDDESourceContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDDELinkContext* pDDELink); + + virtual ~ScXMLDDESourceContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +class ScXMLDDETableContext : public SvXMLImportContext +{ + ScXMLDDELinkContext* pDDELink; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } +public: + ScXMLDDETableContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDDELinkContext* pDDELink); + + virtual ~ScXMLDDETableContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +class ScXMLDDEColumnContext : public SvXMLImportContext +{ + ScXMLDDELinkContext* pDDELink; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } +public: + ScXMLDDEColumnContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDDELinkContext* pDDELink); + + virtual ~ScXMLDDEColumnContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +class ScXMLDDERowContext : public SvXMLImportContext +{ + ScXMLDDELinkContext* pDDELink; + sal_Int32 nRows; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } +public: + ScXMLDDERowContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDDELinkContext* pDDELink); + + virtual ~ScXMLDDERowContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +class ScXMLDDECellContext : public SvXMLImportContext +{ + ::rtl::OUString sValue; + double fValue; + sal_Int32 nCells; + sal_Bool bString : 1; + sal_Bool bString2 : 1; + sal_Bool bEmpty : 1; + + ScXMLDDELinkContext* pDDELink; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } +public: + ScXMLDDECellContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDDELinkContext* pDDELink); + + virtual ~ScXMLDDECellContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/XMLDetectiveContext.hxx b/binfilter/bf_sc/source/filter/xml/XMLDetectiveContext.hxx new file mode 100644 index 000000000000..164cd53c6987 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/XMLDetectiveContext.hxx @@ -0,0 +1,183 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SC_XMLDETECTIVECONTEXT_HXX +#define _SC_XMLDETECTIVECONTEXT_HXX + +#include <bf_xmloff/xmlimp.hxx> + +#include <com/sun/star/table/CellRangeAddress.hpp> + +#include "detfunc.hxx" +#include "detdata.hxx" + +#ifndef __SGI_STL_LIST +#include <list> +#endif +namespace binfilter { + +class ScXMLImport; + + +//___________________________________________________________________ + +struct ScMyImpDetectiveObj +{ + ScRange aSourceRange; + ScDetectiveObjType eObjType; + sal_Bool bHasError : 1; + + ScMyImpDetectiveObj(); +}; + +typedef ::std::vector< ScMyImpDetectiveObj > ScMyImpDetectiveObjVec; + + +//___________________________________________________________________ + +struct ScMyImpDetectiveOp +{ + ScAddress aPosition; + ScDetOpType eOpType; + sal_Int32 nIndex; + + inline ScMyImpDetectiveOp() : nIndex( -1 ) {} + sal_Bool operator<(const ScMyImpDetectiveOp& rDetOp) const; +}; + +typedef ::std::list< ScMyImpDetectiveOp > ScMyImpDetectiveOpList; + +class ScMyImpDetectiveOpArray +{ +private: + ScMyImpDetectiveOpList aDetectiveOpList; + +public: + inline ScMyImpDetectiveOpArray() : + aDetectiveOpList() {} + + inline void AddDetectiveOp( const ScMyImpDetectiveOp& rDetOp ) + { aDetectiveOpList.push_back( rDetOp ); } + + void Sort(); + sal_Bool GetFirstOp( ScMyImpDetectiveOp& rDetOp ); +}; + + +//___________________________________________________________________ + +class ScXMLDetectiveContext : public SvXMLImportContext +{ +private: + ScMyImpDetectiveObjVec* pDetectiveObjVec; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + ScXMLDetectiveContext( + ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + ScMyImpDetectiveObjVec* pNewDetectiveObjVec + ); + virtual ~ScXMLDetectiveContext(); + + virtual SvXMLImportContext* CreateChildContext( + USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList + ); + virtual void EndElement(); +}; + + +//___________________________________________________________________ + +class ScXMLDetectiveHighlightedContext : public SvXMLImportContext +{ +private: + ScMyImpDetectiveObjVec* pDetectiveObjVec; + ScMyImpDetectiveObj aDetectiveObj; + sal_Bool bValid : 1; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + ScXMLDetectiveHighlightedContext( + ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList, + ScMyImpDetectiveObjVec* pNewDetectiveObjVec + ); + virtual ~ScXMLDetectiveHighlightedContext(); + + virtual SvXMLImportContext* CreateChildContext( + USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList + ); + virtual void EndElement(); +}; + + +//___________________________________________________________________ + +class ScXMLDetectiveOperationContext : public SvXMLImportContext +{ +private: + ScMyImpDetectiveOp aDetectiveOp; + sal_Bool bHasType : 1; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + ScXMLDetectiveOperationContext( + ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList + ); + virtual ~ScXMLDetectiveOperationContext(); + + virtual SvXMLImportContext* CreateChildContext( + USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList + ); + virtual void EndElement(); +}; + + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/XMLEmptyContext.hxx b/binfilter/bf_sc/source/filter/xml/XMLEmptyContext.hxx new file mode 100644 index 000000000000..2ba7df650b2a --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/XMLEmptyContext.hxx @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef SC_XMLEMPTYCONTEXT_HXX +#define SC_XMLEMPTYCONTEXT_HXX + +#include <bf_xmloff/xmlictxt.hxx> +namespace binfilter { + +class ScXMLImport; + +class ScXMLEmptyContext : public SvXMLImportContext +{ + ::rtl::OUString sPrintRanges; + sal_Bool bStartFormPage : 1; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLEmptyContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName); + + virtual ~ScXMLEmptyContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/XMLExportDDELinks.hxx b/binfilter/bf_sc/source/filter/xml/XMLExportDDELinks.hxx new file mode 100644 index 000000000000..abeeb172de21 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/XMLExportDDELinks.hxx @@ -0,0 +1,58 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SC_XMLEXPORTDDELINKS_HXX +#define _SC_XMLEXPORTDDELINKS_HXX + +#include <com/sun/star/sheet/XSpreadsheetDocument.hpp> + +class String; + +namespace binfilter { + +class ScXMLExport; + +class ScXMLExportDDELinks +{ + ScXMLExport& rExport; + + sal_Bool CellsEqual(const sal_Bool bPrevEmpty, const sal_Bool bPrevString, const String& sPrevValue, const double& fPrevValue, + const sal_Bool bEmpty, const sal_Bool bString, const String& sValue, const double& fValue); + void WriteCell(const sal_Bool bEmpty, const sal_Bool bString, const String& sValue, const double& fValue, const sal_Int32 nRepeat); + void WriteTable(const sal_Int32 nPos); +public: + ScXMLExportDDELinks(ScXMLExport& rExport); + ~ScXMLExportDDELinks(); + void WriteDDELinks(::com::sun::star::uno::Reference < ::com::sun::star::sheet::XSpreadsheetDocument >& xSpreadDoc); +}; + +} //namespace binfilter +#endif + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/XMLExportDataPilot.hxx b/binfilter/bf_sc/source/filter/xml/XMLExportDataPilot.hxx new file mode 100644 index 000000000000..4bf682f730f5 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/XMLExportDataPilot.hxx @@ -0,0 +1,60 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SC_XMLEXPORTDATAPILOT_HXX +#define _SC_XMLEXPORTDATAPILOT_HXX + +#include <com/sun/star/sheet/XSpreadsheetDocument.hpp> + +#include <rtl/ustring.hxx> + +#include "global.hxx" +namespace binfilter { + +class ScXMLExport; +class ScDocument; + +class ScXMLExportDataPilot +{ + ScXMLExport& rExport; + ScDocument* pDoc; + + ::rtl::OUString getDPOperatorXML(const ScQueryOp aFilterOperator, const sal_Bool bUseRegularExpressions, + const sal_Bool bIsString, const double dVal, const String& sVal) const; + void WriteDPCondition(const ScQueryEntry& aQueryEntry, sal_Bool bIsCaseSensitive, sal_Bool bUseRegularExpressions); + void WriteDPFilter(const ScQueryParam& aQueryParam); +public: + ScXMLExportDataPilot(ScXMLExport& rExport); + ~ScXMLExportDataPilot(); + void WriteDataPilots(const ::com::sun::star::uno::Reference < ::com::sun::star::sheet::XSpreadsheetDocument>& xSpreaDoc); +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/XMLExportDatabaseRanges.hxx b/binfilter/bf_sc/source/filter/xml/XMLExportDatabaseRanges.hxx new file mode 100644 index 000000000000..f56bf901e409 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/XMLExportDatabaseRanges.hxx @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SC_XMLEXPORTDATABASERANGES_HXX +#define SC_XMLEXPORTDATABASERANGES_HXX + +#include <com/sun/star/uno/Sequence.h> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/sheet/XSheetFilterDescriptor.hpp> +#include <com/sun/star/sheet/XSubTotalDescriptor.hpp> +#include <com/sun/star/sheet/XSpreadsheetDocument.hpp> +namespace binfilter { + +class ScXMLExport; +class ScDocument; +class ScMyEmptyDatabaseRangesContainer; + +class ScXMLExportDatabaseRanges +{ + ScXMLExport& rExport; + ScDocument* pDoc; + + void WriteImportDescriptor(const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue> aImportDescriptor); + ::rtl::OUString getOperatorXML(const ::com::sun::star::sheet::FilterOperator aFilterOperator, const sal_Bool bUseRegularExpressions) const; + void WriteCondition(const ::com::sun::star::sheet::TableFilterField& aFilterField, sal_Bool bIsCaseSensitive, sal_Bool bUseRegularExpressions); + void WriteFilterDescriptor(const ::com::sun::star::uno::Reference < ::com::sun::star::sheet::XSheetFilterDescriptor>& xSheetFilterDescriptor, const ::rtl::OUString sDatabaseRangeName); + void WriteSortDescriptor(const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue> aSortProperties); + void WriteSubTotalDescriptor(const ::com::sun::star::uno::Reference < ::com::sun::star::sheet::XSubTotalDescriptor> xSubTotalDescriptor, const ::rtl::OUString sDatabaseRangeName); +public: + ScXMLExportDatabaseRanges(ScXMLExport& rExport); + ~ScXMLExportDatabaseRanges(); + ScMyEmptyDatabaseRangesContainer GetEmptyDatabaseRanges(); + void WriteDatabaseRanges(const ::com::sun::star::uno::Reference < ::com::sun::star::sheet::XSpreadsheetDocument>& xSpreadDoc); +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/XMLExportIterator.hxx b/binfilter/bf_sc/source/filter/xml/XMLExportIterator.hxx new file mode 100644 index 000000000000..81d608c864b8 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/XMLExportIterator.hxx @@ -0,0 +1,381 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SC_XMLEXPORTITERATOR_HXX +#define _SC_XMLEXPORTITERATOR_HXX + +#ifndef __SGI_STL_VECTOR +#include <vector> +#endif +#ifndef __SGI_STL_LIST +#include <list> +#endif + +#include <com/sun/star/sheet/XSpreadsheet.hpp> + +#include <com/sun/star/table/CellAddress.hpp> +#include <com/sun/star/table/CellRangeAddress.hpp> +#include <com/sun/star/table/XCell.hpp> +#include <com/sun/star/text/XText.hpp> +#include <com/sun/star/sheet/XSheetAnnotation.hpp> +#include <com/sun/star/drawing/XShape.hpp> + +#include "global.hxx" +#include "detfunc.hxx" +#include "detdata.hxx" +namespace binfilter { + +class ScHorizontalCellIterator; +struct ScMyCell; +class ScXMLExport; +class ScFormatRangeStyles; + +//============================================================================== + +class ScMyIteratorBase +{ +protected: + virtual sal_Bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress ) = 0; + +public: + ScMyIteratorBase(); + virtual ~ScMyIteratorBase(); + + virtual void SetCellData( ScMyCell& rMyCell ) = 0; + virtual void Sort() = 0; + + virtual void UpdateAddress( ::com::sun::star::table::CellAddress& rCellAddress ); +}; + +//============================================================================== + +struct ScMyShape +{ + ScAddress aAddress; + ScAddress aEndAddress; + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape> xShape; + sal_Int16 nLayerID; + + sal_Bool operator<(const ScMyShape& aShape) const; +}; + +typedef std::list<ScMyShape> ScMyShapeList; + +class ScMyShapesContainer : ScMyIteratorBase +{ +private: + ScMyShapeList aShapeList; +protected: + virtual sal_Bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress ); +public: + ScMyShapesContainer(); + virtual ~ScMyShapesContainer(); + + ScMyIteratorBase::UpdateAddress; + void AddNewShape(const ScMyShape& aShape); + sal_Bool HasShapes() { return !aShapeList.empty(); } + const ScMyShapeList* GetShapes() { return &aShapeList; } + virtual void SetCellData( ScMyCell& rMyCell ); + virtual void Sort(); +}; + +//============================================================================== + +struct ScMyMergedRange +{ + ::com::sun::star::table::CellRangeAddress aCellRange; + sal_Int32 nRows; + sal_Bool bIsFirst : 1; + sal_Bool operator<(const ScMyMergedRange& aRange) const; +}; + +typedef std::list<ScMyMergedRange> ScMyMergedRangeList; + +class ScMyMergedRangesContainer : ScMyIteratorBase +{ +private: + ScMyMergedRangeList aRangeList; +protected: + virtual sal_Bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress ); +public: + ScMyMergedRangesContainer(); + virtual ~ScMyMergedRangesContainer(); + void AddRange(const ::com::sun::star::table::CellRangeAddress aMergedRange); + + ScMyIteratorBase::UpdateAddress; + virtual void SetCellData( ScMyCell& rMyCell ); + virtual void Sort(); // + remove doublets +}; + +//============================================================================== + +struct ScMyAreaLink +{ + ::rtl::OUString sFilter; + ::rtl::OUString sFilterOptions; + ::rtl::OUString sURL; + ::rtl::OUString sSourceStr; + ::com::sun::star::table::CellRangeAddress aDestRange; + sal_Int32 nRefresh; + + inline ScMyAreaLink() : nRefresh( 0 ) {} + + inline sal_Int32 GetColCount() const { return aDestRange.EndColumn - aDestRange.StartColumn + 1; } + inline sal_Int32 GetRowCount() const { return aDestRange.EndRow - aDestRange.StartRow + 1; } + + sal_Bool Compare( const ScMyAreaLink& rAreaLink ) const; + sal_Bool operator<(const ScMyAreaLink& rAreaLink ) const; +}; + +typedef ::std::list< ScMyAreaLink > ScMyAreaLinkList; + +class ScMyAreaLinksContainer : ScMyIteratorBase +{ +private: + ScMyAreaLinkList aAreaLinkList; +protected: + virtual sal_Bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress ); +public: + ScMyAreaLinksContainer(); + virtual ~ScMyAreaLinksContainer(); + + inline void AddNewAreaLink( const ScMyAreaLink& rAreaLink ) + { aAreaLinkList.push_back( rAreaLink ); } + + ScMyIteratorBase::UpdateAddress; + virtual void SetCellData( ScMyCell& rMyCell ); + virtual void Sort(); +}; + +//============================================================================== + +struct ScMyCellRangeAddress : ::com::sun::star::table::CellRangeAddress +{ + ScMyCellRangeAddress(const ::com::sun::star::table::CellRangeAddress& rRange); + sal_Bool operator<(const ScMyCellRangeAddress& rCellRangeAddress ) const; +}; + +typedef std::list<ScMyCellRangeAddress> ScMyEmptyDatabaseRangeList; + +class ScMyEmptyDatabaseRangesContainer : ScMyIteratorBase +{ +private: + ScMyEmptyDatabaseRangeList aDatabaseList; +protected: + virtual sal_Bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress ); +public: + ScMyEmptyDatabaseRangesContainer(); + virtual ~ScMyEmptyDatabaseRangesContainer(); + void AddNewEmptyDatabaseRange(const ::com::sun::star::table::CellRangeAddress& aCellRangeAddress); + + ScMyIteratorBase::UpdateAddress; + virtual void SetCellData( ScMyCell& rMyCell ); + virtual void Sort(); +}; + +//============================================================================== + +struct ScMyDetectiveObj +{ + ::com::sun::star::table::CellAddress aPosition; + ::com::sun::star::table::CellRangeAddress aSourceRange; + ScDetectiveObjType eObjType; + sal_Bool bHasError : 1; + sal_Bool operator<(const ScMyDetectiveObj& rDetObj) const; +}; + +typedef ::std::list< ScMyDetectiveObj > ScMyDetectiveObjList; +typedef ::std::vector< ScMyDetectiveObj > ScMyDetectiveObjVec; + +class ScMyDetectiveObjContainer : ScMyIteratorBase +{ +private: + ScMyDetectiveObjList aDetectiveObjList; +protected: + virtual sal_Bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress ); +public: + ScMyDetectiveObjContainer(); + virtual ~ScMyDetectiveObjContainer(); + + void AddObject( + ScDetectiveObjType eObjType, + const ScAddress& rPosition, + const ScRange& rSourceRange, + sal_Bool bHasError ); + + ScMyIteratorBase::UpdateAddress; + virtual void SetCellData( ScMyCell& rMyCell ); + virtual void Sort(); +}; + +//============================================================================== + +struct ScMyDetectiveOp +{ + ::com::sun::star::table::CellAddress aPosition; + ScDetOpType eOpType; + sal_Int32 nIndex; + sal_Bool operator<(const ScMyDetectiveOp& rDetOp) const; +}; + +typedef ::std::list< ScMyDetectiveOp > ScMyDetectiveOpList; +typedef ::std::vector< ScMyDetectiveOp > ScMyDetectiveOpVec; + +class ScMyDetectiveOpContainer : ScMyIteratorBase +{ +private: + ScMyDetectiveOpList aDetectiveOpList; +protected: + virtual sal_Bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress ); +public: + ScMyDetectiveOpContainer(); + virtual ~ScMyDetectiveOpContainer(); + + void AddOperation( ScDetOpType eOpType, const ScAddress& rPosition, sal_uInt32 nIndex ); + + ScMyIteratorBase::UpdateAddress; + virtual void SetCellData( ScMyCell& rMyCell ); + virtual void Sort(); +}; + +//============================================================================== + +// contains data to export for the current cell position +struct ScMyCell +{ + ::com::sun::star::uno::Reference< ::com::sun::star::table::XCell> xCell; + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText> xText; + ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSheetAnnotation> xAnnotation; + ::com::sun::star::table::CellAddress aCellAddress; + ::com::sun::star::table::CellRangeAddress aMergeRange; + ::com::sun::star::table::CellRangeAddress aMatrixRange; + + ::rtl::OUString sStringValue; + ::rtl::OUString sAnnotationText; + + ScMyAreaLink aAreaLink; + ScMyShapeList aShapeList; + ScMyDetectiveObjVec aDetectiveObjVec; + ScMyDetectiveOpVec aDetectiveOpVec; + + double fValue; + sal_Int32 nValidationIndex; + sal_Int32 nStyleIndex; + sal_Int32 nNumberFormat; + ::com::sun::star::table::CellContentType nType; + + sal_Bool bIsAutoStyle : 1; + + sal_Bool bHasShape : 1; + sal_Bool bIsMergedBase : 1; + sal_Bool bIsCovered : 1; + sal_Bool bHasAreaLink : 1; + sal_Bool bHasEmptyDatabase : 1; + sal_Bool bHasDetectiveObj : 1; + sal_Bool bHasDetectiveOp : 1; + + sal_Bool bIsEditCell : 1; + sal_Bool bKnowWhetherIsEditCell : 1; + sal_Bool bHasStringValue : 1; + sal_Bool bHasDoubleValue : 1; + sal_Bool bHasXText : 1; + + sal_Bool bIsMatrixBase : 1; + sal_Bool bIsMatrixCovered : 1; + sal_Bool bHasAnnotation : 1; + + ScMyCell(); + ~ScMyCell(); +}; + +//============================================================================== + +struct ScMyExportAnnotation +{ + ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSheetAnnotation> xAnnotation; + ::com::sun::star::table::CellAddress aCellAddress; + sal_Bool operator<(const ScMyExportAnnotation& rAnno) const; +}; + +typedef ::std::list< ScMyExportAnnotation > ScMyExportAnnotationList; + +class ScMyNotEmptyCellsIterator +{ + ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet> xTable; + ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange> xCellRange; + ::com::sun::star::table::CellAddress aLastAddress; + ScMyExportAnnotationList aAnnotations; + + ScMyShapesContainer* pShapes; + ScMyEmptyDatabaseRangesContainer* pEmptyDatabaseRanges; + ScMyMergedRangesContainer* pMergedRanges; + ScMyAreaLinksContainer* pAreaLinks; + ScMyDetectiveObjContainer* pDetectiveObj; + ScMyDetectiveOpContainer* pDetectiveOp; + + ScXMLExport& rExport; + ScHorizontalCellIterator* pCellItr; + + sal_uInt16 nCellCol; + sal_uInt16 nCellRow; + sal_Int16 nCurrentTable; + + void UpdateAddress( ::com::sun::star::table::CellAddress& rAddress ); + void SetCellData( ScMyCell& rMyCell, ::com::sun::star::table::CellAddress& rAddress ); + + void SetMatrixCellData( ScMyCell& rMyCell ); + void HasAnnotation( ScMyCell& aCell ); +public: + ScMyNotEmptyCellsIterator(ScXMLExport& rExport); + ~ScMyNotEmptyCellsIterator(); + + void Clear(); + + inline void SetShapes(ScMyShapesContainer* pNewShapes) + { pShapes = pNewShapes; } + inline void SetEmptyDatabaseRanges(ScMyEmptyDatabaseRangesContainer* pNewEmptyDatabaseRanges) + { pEmptyDatabaseRanges = pNewEmptyDatabaseRanges; } + inline void SetMergedRanges(ScMyMergedRangesContainer* pNewMergedRanges) + { pMergedRanges = pNewMergedRanges; } + inline void SetAreaLinks(ScMyAreaLinksContainer* pNewAreaLinks) + { pAreaLinks = pNewAreaLinks; } + inline void SetDetectiveObj(ScMyDetectiveObjContainer* pNewDetectiveObj) + { pDetectiveObj = pNewDetectiveObj; } + inline void SetDetectiveOp(ScMyDetectiveOpContainer* pNewDetectiveOp) + { pDetectiveOp = pNewDetectiveOp; } + + void SetCurrentTable(const sal_Int32 nTable, + ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet>& rxTable); + + sal_Bool GetNext(ScMyCell& aCell, ScFormatRangeStyles* pCellStyles); +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/XMLExportSharedData.hxx b/binfilter/bf_sc/source/filter/xml/XMLExportSharedData.hxx new file mode 100644 index 000000000000..a7942d520372 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/XMLExportSharedData.hxx @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SC_XMLEXPORTSHAREDDATA_HXX +#define SC_XMLEXPORTSHAREDDATA_HXX + +#include <com/sun/star/drawing/XDrawPage.hpp> + +#ifndef __SGI_STL_VECTOR +#include <vector> +#endif +#ifndef __SGI_STL_LIST +#include <list> +#endif +namespace binfilter { + +struct ScMyDrawPage +{ + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage> xDrawPage; + sal_Bool bHasForms : 1; + + ScMyDrawPage() : bHasForms(sal_False) {} +}; + +typedef std::list< ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape> > ScMyTableXShapes; +typedef std::vector<ScMyTableXShapes> ScMyTableShapes; +typedef std::vector<ScMyDrawPage> ScMyDrawPages; + +class ScMyShapesContainer; +class ScMyDetectiveObjContainer; +struct ScMyShape; + +class ScMySharedData +{ + std::vector<sal_Int32> nLastColumns; + std::vector<sal_Int32> nLastRows; + ScMyTableShapes* pTableShapes; + ScMyDrawPages* pDrawPages; + ScMyShapesContainer* pShapesContainer; + ScMyDetectiveObjContainer* pDetectiveObjContainer; + sal_Int32 nTableCount; +public: + ScMySharedData(const sal_Int32 nTableCount); + ~ScMySharedData(); + + void SetLastColumn(const sal_Int32 nTable, const sal_Int32 nCol); + void SetLastRow(const sal_Int32 nTable, const sal_Int32 nRow); + sal_Int32 GetLastColumn(const sal_Int32 nTable); + sal_Int32 GetLastRow(const sal_Int32 nTable); + void AddDrawPage(const ScMyDrawPage& aDrawPage, const sal_Int32 nTable); + void SetDrawPageHasForms(const sal_Int32 nTable, sal_Bool bHasForms); + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage> GetDrawPage(const sal_Int32 nTable); + sal_Bool HasDrawPage() { return pDrawPages != NULL; } + sal_Bool HasForm(const sal_Int32 nTable, ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage>& xDrawPage); + void AddNewShape(const ScMyShape& aMyShape); + void SortShapesContainer(); + ScMyShapesContainer* GetShapesContainer() { return pShapesContainer; } + sal_Bool HasShapes(); + void AddTableShape(const sal_Int32 nTable, const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape>& xShape); + ScMyTableShapes* GetTableShapes() { return pTableShapes; } + ScMyDetectiveObjContainer* GetDetectiveObjContainer() { return pDetectiveObjContainer; } +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/XMLStylesExportHelper.hxx b/binfilter/bf_sc/source/filter/xml/XMLStylesExportHelper.hxx new file mode 100644 index 000000000000..3b3ec80991d1 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/XMLStylesExportHelper.hxx @@ -0,0 +1,299 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SC_XMLSTYLESEXPORTHELPER_HXX +#define _SC_XMLSTYLESEXPORTHELPER_HXX + +#ifndef __SGI_STL_VECTOR +#include <vector> +#endif +#ifndef __SGI_STL_LIST +#include <list> +#endif + +#include <com/sun/star/uno/Any.h> +#include <com/sun/star/table/CellRangeAddress.hpp> +#include <com/sun/star/table/CellAddress.hpp> +#include <com/sun/star/sheet/ConditionOperator.hpp> +#include <com/sun/star/sheet/ValidationAlertStyle.hpp> +#include <com/sun/star/sheet/ValidationType.hpp> +namespace binfilter { + +class ScDocument; +class ScXMLExport; + +struct ScMyValidation +{ + ::rtl::OUString sName; + ::rtl::OUString sErrorMessage; + ::rtl::OUString sErrorTitle; + ::rtl::OUString sImputMessage; + ::rtl::OUString sImputTitle; + ::rtl::OUString sFormula1; + ::rtl::OUString sFormula2; + ::com::sun::star::table::CellAddress aBaseCell; + ::com::sun::star::sheet::ValidationAlertStyle aAlertStyle; + ::com::sun::star::sheet::ValidationType aValidationType; + ::com::sun::star::sheet::ConditionOperator aOperator; + sal_Bool bShowErrorMessage : 1; + sal_Bool bShowImputMessage : 1; + sal_Bool bIgnoreBlanks : 1; + + ScMyValidation(); + ~ScMyValidation(); + + sal_Bool IsEqual(const ScMyValidation& aVal) const; +}; + +typedef std::vector<ScMyValidation> ScMyValidationVec; + +class ScMyValidationsContainer +{ +private: + ScMyValidationVec aValidationVec; + const ::rtl::OUString sEmptyString; + const ::rtl::OUString sERRALSTY; + const ::rtl::OUString sIGNOREBL; + const ::rtl::OUString sTYPE; + const ::rtl::OUString sSHOWINP; + const ::rtl::OUString sSHOWERR; + const ::rtl::OUString sINPTITLE; + const ::rtl::OUString sINPMESS; + const ::rtl::OUString sERRTITLE; + const ::rtl::OUString sERRMESS; + const ::rtl::OUString sOnError; + const ::rtl::OUString sEventType; + const ::rtl::OUString sStarBasic; + const ::rtl::OUString sLibrary; + const ::rtl::OUString sMacroName; + +public: + ScMyValidationsContainer(); + ~ScMyValidationsContainer(); + sal_Bool AddValidation(const ::com::sun::star::uno::Any& aAny, + sal_Int32& nValidationIndex); + ::rtl::OUString GetCondition(const ScMyValidation& aValidation); + ::rtl::OUString GetBaseCellAddress(ScDocument* pDoc, const ::com::sun::star::table::CellAddress& aCell); + void WriteMessage(ScXMLExport& rExport, + const ::rtl::OUString& sTitle, const ::rtl::OUString& sMessage, + const sal_Bool bShowMessage, const sal_Bool bIsHelpMessage); + void WriteValidations(ScXMLExport& rExport); + const ::rtl::OUString& GetValidationName(const sal_Int32 nIndex); +}; + +//============================================================================== + +struct ScMyDefaultStyle +{ + sal_Int32 nIndex; + sal_Int32 nRepeat; + sal_Bool bIsAutoStyle; + + ScMyDefaultStyle() : nIndex(-1), bIsAutoStyle(sal_True), + nRepeat(1) {} +}; + +typedef std::vector<ScMyDefaultStyle> ScMyDefaultStyleList; + +class ScFormatRangeStyles; + +class ScMyDefaultStyles +{ + ScMyDefaultStyleList* pRowDefaults; + ScMyDefaultStyleList* pColDefaults; + + sal_Int32 GetStyleNameIndex(const ScFormatRangeStyles* pCellStyles, + const sal_uInt16 nTable, const sal_Int32 nPos, + const sal_Int32 i, const sal_Bool bRow, sal_Bool& bIsAutoStyle); + void FillDefaultStyles(const sal_uInt16 nTable, + const sal_Int32 nLastRow, const sal_Int32 nLastCol, + const ScFormatRangeStyles* pCellStyles, ScDocument* pDoc, + const sal_Bool bRow); +public: + ScMyDefaultStyles() : pRowDefaults(NULL), pColDefaults(NULL) {} + ~ScMyDefaultStyles(); + + void FillDefaultStyles(const sal_uInt16 nTable, + const sal_Int32 nLastRow, const sal_Int32 nLastCol, + const ScFormatRangeStyles* pCellStyles, ScDocument* pDoc); + + const ScMyDefaultStyleList* GetRowDefaults() { return pRowDefaults; } + const ScMyDefaultStyleList* GetColDefaults() { return pColDefaults; } +}; + +struct ScMyRowFormatRange +{ + sal_Int32 nStartColumn; + sal_Int32 nRepeatColumns; + sal_Int32 nRepeatRows; + sal_Int32 nIndex; + sal_Int32 nValidationIndex; + sal_Bool bIsAutoStyle : 1; + + ScMyRowFormatRange(); + sal_Bool operator<(const ScMyRowFormatRange& rRange) const; +}; + +typedef std::list<ScMyRowFormatRange> ScMyRowFormatRangesList; + +class ScRowFormatRanges +{ + ScMyRowFormatRangesList aRowFormatRanges; + const ScMyDefaultStyleList* pRowDefaults; + const ScMyDefaultStyleList* pColDefaults; + sal_uInt32 nSize; + + void AddRange(const sal_Int32 nPrevStartCol, const sal_Int32 nRepeat, const sal_Int32 nPrevIndex, + const sal_Bool bPrevAutoStyle, const ScMyRowFormatRange& rFormatRange); + +public: + ScRowFormatRanges(); + ScRowFormatRanges(const ScRowFormatRanges* pRanges); + ~ScRowFormatRanges(); + + void SetRowDefaults(const ScMyDefaultStyleList* pDefaults) { pRowDefaults = pDefaults; } + void SetColDefaults(const ScMyDefaultStyleList* pDefaults) { pColDefaults = pDefaults; } + void Clear(); + void AddRange(ScMyRowFormatRange& rFormatRange, const sal_Int32 nStartRow); + sal_Bool GetNext(ScMyRowFormatRange& rFormatRange); + sal_Int32 GetMaxRows(); + sal_Int32 GetSize(); + void Sort(); +}; + +typedef std::vector<rtl::OUString*> ScMyOUStringVec; + +struct ScMyFormatRange +{ + ::com::sun::star::table::CellRangeAddress aRangeAddress; + sal_Int32 nStyleNameIndex; + sal_Int32 nValidationIndex; + sal_Int32 nNumberFormat; + sal_Bool bIsAutoStyle : 1; + + ScMyFormatRange(); + sal_Bool operator< (const ScMyFormatRange& rRange) const; +}; + +typedef std::list<ScMyFormatRange> ScMyFormatRangeAddresses; +typedef std::vector<ScMyFormatRangeAddresses*> ScMyFormatRangeListVec; + +class ScFormatRangeStyles +{ + ScMyFormatRangeListVec aTables; + ScMyOUStringVec aStyleNames; + ScMyOUStringVec aAutoStyleNames; + const ScMyDefaultStyleList* pRowDefaults; + const ScMyDefaultStyleList* pColDefaults; + +public: + ScFormatRangeStyles(); + ~ScFormatRangeStyles(); + + void SetRowDefaults(const ScMyDefaultStyleList* pDefaults) { pRowDefaults = pDefaults; } + void SetColDefaults(const ScMyDefaultStyleList* pDefaults) { pColDefaults = pDefaults; } + void AddNewTable(const sal_Int16 nTable); + sal_Bool AddStyleName(::rtl::OUString* pString, sal_Int32& rIndex, const sal_Bool bIsAutoStyle = sal_True); + sal_Int32 GetIndexOfStyleName(const ::rtl::OUString& rString, const ::rtl::OUString& rPrefix, sal_Bool& bIsAutoStyle); + // does not delete ranges + sal_Int32 GetStyleNameIndex(const sal_uInt16 nTable, const sal_Int32 nColumn, const sal_Int32 nRow, + sal_Bool& bIsAutoStyle) const; + // deletes not necessary ranges if wanted + sal_Int32 GetStyleNameIndex(const sal_uInt16 nTable, const sal_Int32 nColumn, const sal_Int32 nRow, + sal_Bool& bIsAutoStyle, sal_Int32& nValidationIndex, sal_Int32& nNumberFormat, const sal_Bool bRemoveRange = sal_True ); + void GetFormatRanges(const sal_Int32 nStartColumn, const sal_Int32 nEndColumn, const sal_Int32 nRow, + const sal_Int16 nTable, ScRowFormatRanges* pFormatRanges); + void AddRangeStyleName(const ::com::sun::star::table::CellRangeAddress aCellRangeAddress, const sal_Int32 nStringIndex, + const sal_Bool bIsAutoStyle, const sal_Int32 nValidationIndex, const sal_Int32 nNumberFormat); + ::rtl::OUString* GetStyleNameByIndex(const sal_Int32 nIndex, const sal_Bool bIsAutoStyle); + void Sort(); +}; + +class ScColumnRowStylesBase +{ + ScMyOUStringVec aStyleNames; + +public: + ScColumnRowStylesBase(); + ~ScColumnRowStylesBase(); + + virtual void AddNewTable(const sal_Int16 nTable, const sal_Int32 nFields) = 0; + sal_Int32 AddStyleName(::rtl::OUString* pString); + sal_Int32 GetIndexOfStyleName(const ::rtl::OUString& rString, const ::rtl::OUString& rPrefix); + virtual ::rtl::OUString* GetStyleName(const sal_Int16 nTable, const sal_Int32 nField) = 0; + ::rtl::OUString* GetStyleNameByIndex(const sal_Int32 nIndex); +}; + +struct ScColumnStyle +{ + sal_Int32 nIndex; + sal_Bool bIsVisible : 1; + + ScColumnStyle() : nIndex(-1), bIsVisible(sal_True) {} +}; + + +typedef std::vector<ScColumnStyle> ScMyColumnStyleVec; +typedef std::vector<ScMyColumnStyleVec> ScMyColumnVectorVec; + +class ScColumnStyles : public ScColumnRowStylesBase +{ + ScMyColumnVectorVec aTables; + +public: + ScColumnStyles(); + ~ScColumnStyles(); + + virtual void AddNewTable(const sal_Int16 nTable, const sal_Int32 nFields); + sal_Int32 GetStyleNameIndex(const sal_Int16 nTable, const sal_Int32 nField, + sal_Bool& bIsVisible); + void AddFieldStyleName(const sal_Int16 nTable, const sal_Int32 nField, const sal_Int32 nStringIndex, const sal_Bool bIsVisible); + virtual ::rtl::OUString* GetStyleName(const sal_Int16 nTable, const sal_Int32 nField); +}; + +typedef std::vector<sal_Int32> ScMysalInt32Vec; +typedef std::vector<ScMysalInt32Vec> ScMyRowVectorVec; + +class ScRowStyles : public ScColumnRowStylesBase +{ + ScMyRowVectorVec aTables; + +public: + ScRowStyles(); + ~ScRowStyles(); + + virtual void AddNewTable(const sal_Int16 nTable, const sal_Int32 nFields); + sal_Int32 GetStyleNameIndex(const sal_Int16 nTable, const sal_Int32 nField); + void AddFieldStyleName(const sal_Int16 nTable, const sal_Int32 nField, const sal_Int32 nStringIndex); + virtual ::rtl::OUString* GetStyleName(const sal_Int16 nTable, const sal_Int32 nField); +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/XMLStylesImportHelper.hxx b/binfilter/bf_sc/source/filter/xml/XMLStylesImportHelper.hxx new file mode 100644 index 000000000000..388e51449a01 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/XMLStylesImportHelper.hxx @@ -0,0 +1,205 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SC_XMLSTYLESIMPORTHELPER_HXX +#define _SC_XMLSTYLESIMPORTHELPER_HXX + +#include "rangelst.hxx" + +#include <rtl/ustring.hxx> + +#include <com/sun/star/table/CellRangeAddress.hpp> +#include <com/sun/star/table/CellAddress.hpp> + +#ifndef __SGI_STL_SET +#include <set> +#endif +#ifndef __SGI_STL_VECTOR +#include <vector> +#endif +namespace binfilter { + +class ScXMLImport; + +struct ScMyStyleNumberFormat +{ + ::rtl::OUString sStyleName; + sal_Int32 nNumberFormat; + + ScMyStyleNumberFormat() : nNumberFormat(-1) {} + ScMyStyleNumberFormat(const ::rtl::OUString& rStyleName) : + sStyleName(rStyleName), nNumberFormat(-1) {} + ScMyStyleNumberFormat(const ::rtl::OUString& rStyleName, const sal_Int32 nFormat) : + sStyleName(rStyleName), nNumberFormat(nFormat) {} +}; + +struct LessStyleNumberFormat +{ + sal_Bool operator() (const ScMyStyleNumberFormat& rValue1, const ScMyStyleNumberFormat& rValue2) const + { + return rValue1.sStyleName < rValue2.sStyleName; + } +}; + +typedef std::set< ScMyStyleNumberFormat, LessStyleNumberFormat > ScMyStyleNumberFormatSet; + +class ScMyStyleNumberFormats +{ + ScMyStyleNumberFormatSet aSet; + +public: + void AddStyleNumberFormat(const ::rtl::OUString& rStyleName, const sal_Int32 nNumberFormat); + sal_Int32 GetStyleNumberFormat(const ::rtl::OUString& rStyleName); +}; + +struct ScMyCurrencyStyle +{ + ::rtl::OUString sCurrency; + ScRangeListRef xRanges; + + ScMyCurrencyStyle() : xRanges(new ScRangeList()) {} + ~ScMyCurrencyStyle() {} +}; + +struct LessCurrencyStyle +{ + sal_Bool operator() (const ScMyCurrencyStyle& rValue1, const ScMyCurrencyStyle& rValue2) const + { + return rValue1.sCurrency < rValue2.sCurrency; + } +}; + +typedef std::set<ScMyCurrencyStyle, LessCurrencyStyle> ScMyCurrencyStylesSet; + +class ScMyStyleRanges : public SvRefBase +{ + ScRangeList* pTextList; + ScRangeList* pNumberList; + ScRangeList* pTimeList; + ScRangeList* pDateTimeList; + ScRangeList* pPercentList; + ScRangeList* pLogicalList; + ScRangeList* pUndefinedList; + ScMyCurrencyStylesSet* pCurrencyList; + + void AddRange(const ScRange& rRange, ScRangeList* pList, + const ::rtl::OUString* pStyleName, const sal_Int16 nType, + ScXMLImport& rImport, const sal_uInt32 nMaxRanges); + void AddCurrencyRange(const ScRange& rRange, ScRangeListRef xList, + const ::rtl::OUString* pStyleName, const ::rtl::OUString* pCurrency, + ScXMLImport& rImport, const sal_uInt32 nMaxRanges); + void InsertColRow(const ScRange& rRange, const sal_Int16 nDx, const sal_Int16 nDy, + const sal_Int16 nDz, ScDocument* pDoc); + void SetStylesToRanges(ScRangeList* pList, + const ::rtl::OUString* pStyleName, const sal_Int16 nCellType, + const ::rtl::OUString* pCurrency, ScXMLImport& rImport); + void SetStylesToRanges(ScRangeListRef xList, + const ::rtl::OUString* pStyleName, const sal_Int16 nCellType, + const ::rtl::OUString* pCurrency, ScXMLImport& rImport); +public: + ScMyStyleRanges(); + ~ScMyStyleRanges(); + void AddRange(const ScRange& rRange, + const ::rtl::OUString* pStyleName, const sal_Int16 nType, + ScXMLImport& rImport, const sal_uInt32 nMaxRanges); + void AddCurrencyRange(const ScRange& rRange, + const ::rtl::OUString* pStyleName, const ::rtl::OUString* pCurrency, + ScXMLImport& rImport, const sal_uInt32 nMaxRanges); + void InsertRow(const sal_Int32 nRow, const sal_Int32 nTab, ScDocument* pDoc); + void InsertCol(const sal_Int32 nCol, const sal_Int32 nTab, ScDocument* pDoc); + void SetStylesToRanges(const ::rtl::OUString* pStyleName, ScXMLImport& rImport); +}; +SV_DECL_IMPL_REF( ScMyStyleRanges ); + +struct ScMyStyle +{ + ::rtl::OUString sStyleName; + ScMyStyleRangesRef xRanges; + + ScMyStyle() : xRanges(new ScMyStyleRanges()) {} + ~ScMyStyle() {} +}; + +struct LessStyle +{ + sal_Bool operator() (const ScMyStyle& rValue1, const ScMyStyle& rValue2) const + { + return rValue1.sStyleName < rValue2.sStyleName; + } +}; + +typedef std::set<ScMyStyle, LessStyle> ScMyStylesSet; +typedef std::vector<ScMyStylesSet::iterator> ScMyStyles; + +class ScMyStylesImportHelper +{ + ScMyStylesSet aCellStyles; + ScMyStyles aColDefaultStyles; + ScMyStylesSet::iterator aRowDefaultStyle; + ScXMLImport& rImport; + ::rtl::OUString* pStyleName; + ::rtl::OUString* pPrevStyleName; + ::rtl::OUString* pCurrency; + ::rtl::OUString* pPrevCurrency; + ScRange aPrevRange; + sal_uInt32 nMaxRanges; + sal_Int16 nCellType; + sal_Int16 nPrevCellType; + sal_Bool bPrevRangeAdded; + + void ResetAttributes(); + ScMyStylesSet::iterator GetIterator(const ::rtl::OUString* pStyleName); + void AddDefaultRange(const ScRange& rRange); + void AddSingleRange(const ScRange& rRange); + void AddRange(); + sal_Bool IsEqual(const ::rtl::OUString* pFirst, const ::rtl::OUString* pSecond) + { + return ((pFirst && pSecond && pFirst->equals(*pSecond)) || + (!pFirst && !pSecond) || + (!pFirst && pSecond && !pSecond->getLength()) || + (!pSecond && pFirst && !pFirst->getLength())); + } +public: + ScMyStylesImportHelper(ScXMLImport& rImport); + ~ScMyStylesImportHelper(); + void AddColumnStyle(const ::rtl::OUString& rStyleName, const sal_Int32 nColumn, const sal_Int32 nRepeat); + void SetRowStyle(const ::rtl::OUString& rStyleName); + void SetAttributes(::rtl::OUString* pStyleName, + ::rtl::OUString* pCurrency, const sal_Int16 nCellType); + void AddRange(const ScRange& rRange); + void AddCell(const ::com::sun::star::table::CellAddress& rAddress); + void InsertRow(const sal_Int32 nRow, const sal_Int32 nTab, ScDocument* pDoc); // a row is inserted before nRow + void InsertCol(const sal_Int32 nCol, const sal_Int32 nTab, ScDocument* pDoc); // a col is inserted before nCol + void EndTable(); + void SetStylesToRanges(); +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/XMLTableHeaderFooterContext.hxx b/binfilter/bf_sc/source/filter/xml/XMLTableHeaderFooterContext.hxx new file mode 100644 index 000000000000..d777767fa44a --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/XMLTableHeaderFooterContext.hxx @@ -0,0 +1,120 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _SC_XMLTABLEHEADERFOOTERCONTEXT_HXX_ +#define _SC_XMLTABLEHEADERFOOTERCONTEXT_HXX_ + + +#include <bf_xmloff/xmlictxt.hxx> + +#include <bf_xmloff/xmlimp.hxx> +#include <com/sun/star/sheet/XHeaderFooterContent.hpp> +namespace binfilter { + +namespace com { namespace sun { namespace star { + namespace text { class XTextCursor; } + namespace beans { class XPropertySet; } +} } } + +class XMLTableHeaderFooterContext: public SvXMLImportContext +{ + ::com::sun::star::uno::Reference < + ::com::sun::star::text::XTextCursor > xTextCursor; + ::com::sun::star::uno::Reference < + ::com::sun::star::text::XTextCursor > xOldTextCursor; + ::com::sun::star::uno::Reference < + ::com::sun::star::beans::XPropertySet > xPropSet; + ::com::sun::star::uno::Reference < + ::com::sun::star::sheet::XHeaderFooterContent > xHeaderFooterContent; + + const ::rtl::OUString sOn; + const ::rtl::OUString sShareContent; + const ::rtl::OUString sContent; + const ::rtl::OUString sContentLeft; + const ::rtl::OUString sEmpty; + ::rtl::OUString sCont; + + sal_Bool bDisplay : 1; + sal_Bool bInsertContent : 1; + sal_Bool bLeft : 1; + sal_Bool bContainsLeft : 1; + sal_Bool bContainsRight : 1; + sal_Bool bContainsCenter : 1; + +public: + TYPEINFO(); + + XMLTableHeaderFooterContext( SvXMLImport& rImport, sal_uInt16 nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList > & xAttrList, + const ::com::sun::star::uno::Reference < + ::com::sun::star::beans::XPropertySet > & rPageStylePropSet, + sal_Bool bFooter, sal_Bool bLft ); + + virtual ~XMLTableHeaderFooterContext(); + + virtual SvXMLImportContext *CreateChildContext( + sal_uInt16 nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); + + virtual void EndElement(); +}; + +class XMLHeaderFooterRegionContext: public SvXMLImportContext +{ +private: + ::com::sun::star::uno::Reference < + ::com::sun::star::text::XTextCursor >& xTextCursor; + ::com::sun::star::uno::Reference < + ::com::sun::star::text::XTextCursor > xOldTextCursor; + +public: + TYPEINFO(); + + XMLHeaderFooterRegionContext( SvXMLImport& rImport, sal_uInt16 nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList > & xAttrList, + ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor >& xCursor ); + + virtual ~XMLHeaderFooterRegionContext(); + + virtual SvXMLImportContext *CreateChildContext( + sal_uInt16 nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); + + virtual void EndElement(); +}; + + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/XMLTableMasterPageExport.hxx b/binfilter/bf_sc/source/filter/xml/XMLTableMasterPageExport.hxx new file mode 100644 index 000000000000..e38535c59b6e --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/XMLTableMasterPageExport.hxx @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SC_XMLTABLEMASTERPAGEEXPORT_HXX +#define _SC_XMLTABLEMASTERPAGEEXPORT_HXX + +#include <rtl/ustring.hxx> + +#include <bf_xmloff/xmltoken.hxx> +#include <bf_xmloff/XMLTextMasterPageExport.hxx> + +#include <com/sun/star/sheet/XHeaderFooterContent.hpp> + +#include "xmlexprt.hxx" +namespace binfilter { + +namespace com { namespace sun { namespace star { + namespace text { class XText; } +} } } + +class XMLTableMasterPageExport : public XMLTextMasterPageExport +{ + void exportHeaderFooter(const ::com::sun::star::uno::Reference < ::com::sun::star::sheet::XHeaderFooterContent >& xHeaderFooter, + const xmloff::token::XMLTokenEnum aName, + const sal_Bool bDisplay); + +protected: + virtual void exportHeaderFooterContent( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XText >& rText, + sal_Bool bAutoStyles, sal_Bool bProgress ); + + virtual void exportMasterPageContent( + const ::com::sun::star::uno::Reference < + ::com::sun::star::beans::XPropertySet > & rPropSet, + sal_Bool bAutoStyles ); + +public: + XMLTableMasterPageExport( ScXMLExport& rExp ); + ~XMLTableMasterPageExport(); +}; + + +} //namespace binfilter +#endif // _XMLOFF_XMLTABLEMASTERPAGEEXPORT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/XMLTableShapeImportHelper.hxx b/binfilter/bf_sc/source/filter/xml/XMLTableShapeImportHelper.hxx new file mode 100644 index 000000000000..36883d658920 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/XMLTableShapeImportHelper.hxx @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SC_XMLTABLESHAPEIMPORTHELPER_HXX +#define _SC_XMLTABLESHAPEIMPORTHELPER_HXX + +#include <bf_xmloff/shapeimport.hxx> +#include <com/sun/star/table/CellAddress.hpp> +namespace binfilter { + +class ScXMLImport; + +class XMLTableShapeImportHelper : public XMLShapeImportHelper +{ + ::com::sun::star::table::CellAddress aStartCell; + sal_Bool bOnTable : 1; + +public: + + XMLTableShapeImportHelper( ScXMLImport& rImp, SvXMLImportPropertyMapper *pImpMapper=0 ); + ~XMLTableShapeImportHelper(); + + void SetLayer(::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape>& rShape, sal_Int16 nLayerID, const ::rtl::OUString& sType) const; + virtual void finishShape(::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rShape, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList, + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rShapes); + + + void SetCell (const ::com::sun::star::table::CellAddress& rAddress) { aStartCell = rAddress; } + void SetOnTable (const sal_Bool bTempOnTable) { bOnTable = bTempOnTable; } +}; + + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/XMLTableShapeResizer.hxx b/binfilter/bf_sc/source/filter/xml/XMLTableShapeResizer.hxx new file mode 100644 index 000000000000..2805fb04a1b3 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/XMLTableShapeResizer.hxx @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SC_XMLTABLESHAPERESIZER_HXX +#define _SC_XMLTABLESHAPERESIZER_HXX + +#include <com/sun/star/drawing/XShape.hpp> +#include <com/sun/star/table/CellAddress.hpp> +#ifndef __SGI_STL_LIST +#include <list> +#endif +class Rectangle; +namespace binfilter { + +class ScXMLImport; +class ScChartListenerCollection; +class ScDocument; + +struct ScMyToResizeShape +{ + ::com::sun::star::uno::Reference < ::com::sun::star::drawing::XShape> xShape; + ::rtl::OUString* pRangeList; + ::com::sun::star::table::CellAddress aEndCell; + ::com::sun::star::table::CellAddress aStartCell; + sal_Int32 nEndX; + sal_Int32 nEndY; + + ScMyToResizeShape() : pRangeList(NULL) {} +}; + +typedef std::list<ScMyToResizeShape> ScMyToResizeShapes; + +class ScMyShapeResizer +{ + ScXMLImport& rImport; + ScMyToResizeShapes aShapes; + ScChartListenerCollection* pCollection; + + sal_Bool IsOLE(::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rShape) const; + void CreateChartListener(ScDocument* pDoc, + const ::rtl::OUString& rName, + const ::rtl::OUString* pRangeList); + void GetNewShapeSizePos(ScDocument* pDoc, const Rectangle& rStartRect, + const ::com::sun::star::table::CellAddress& rEndCell, + ::com::sun::star::awt::Point& rPoint, ::com::sun::star::awt::Size& rSize, + sal_Int32& rEndX, sal_Int32& rEndY) const; +public: + ScMyShapeResizer(ScXMLImport& rImport); + ~ScMyShapeResizer(); + + void AddShape(::com::sun::star::uno::Reference < ::com::sun::star::drawing::XShape>& rShape, + ::rtl::OUString* pRangeList, + ::com::sun::star::table::CellAddress& rStartAddress, + ::com::sun::star::table::CellAddress& rEndAddress, + sal_Int32 nEndX, sal_Int32 nEndY); + void ResizeShapes(); +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/XMLTableShapesContext.hxx b/binfilter/bf_sc/source/filter/xml/XMLTableShapesContext.hxx new file mode 100644 index 000000000000..5c48a036601f --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/XMLTableShapesContext.hxx @@ -0,0 +1,60 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SC_XMLTABLESHAPESCONTEXT_HXX +#define _SC_XMLTABLESHAPESCONTEXT_HXX + +#include <bf_xmloff/xmlictxt.hxx> +namespace binfilter { + +class ScXMLImport; + +class ScXMLTableShapesContext : public SvXMLImportContext +{ + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } +public: + ScXMLTableShapesContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList); + + virtual ~ScXMLTableShapesContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/XMLTableSourceContext.hxx b/binfilter/bf_sc/source/filter/xml/XMLTableSourceContext.hxx new file mode 100644 index 000000000000..1b595a0f2c53 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/XMLTableSourceContext.hxx @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SC_XMLTABLESOURCECONTEXT_HXX +#define _SC_XMLTABLESOURCECONTEXT_HXX + +#include <bf_xmloff/xmlictxt.hxx> + +#include <com/sun/star/sheet/SheetLinkMode.hpp> +namespace binfilter { + +class ScXMLImport; + +class ScXMLTableSourceContext : public SvXMLImportContext +{ + ::rtl::OUString sLink; + ::rtl::OUString sTableName; + ::rtl::OUString sFilterName; + ::rtl::OUString sFilterOptions; + sal_Int32 nRefresh; + ::com::sun::star::sheet::SheetLinkMode nMode; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } +public: + ScXMLTableSourceContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList); + + virtual ~ScXMLTableSourceContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/XMLTextPContext.hxx b/binfilter/bf_sc/source/filter/xml/XMLTextPContext.hxx new file mode 100644 index 000000000000..d02cf386f2b4 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/XMLTextPContext.hxx @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SC_XMLTEXTPCONTEXT_HXX +#define _SC_XMLTEXTPCONTEXT_HXX + +#include <bf_xmloff/xmlictxt.hxx> +#include <rtl/ustrbuf.hxx> +namespace binfilter { + +class ScXMLImport; +class ScXMLTableRowCellContext; + +class ScXMLTextPContext : public SvXMLImportContext +{ + ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList> xAttrList; + SvXMLImportContext* pTextPContext; + ScXMLTableRowCellContext* pCellContext; + ::rtl::OUString sLName; + ::rtl::OUStringBuffer sOUText; + USHORT nPrefix; + sal_Bool bIsOwn : 1; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + ScXMLTextPContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLTableRowCellContext* pCellContext); + + virtual ~ScXMLTextPContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void Characters( const ::rtl::OUString& rChars ); + + virtual void EndElement(); + + void AddSpaces(sal_Int32 nSpaceCount); +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/XMLTrackedChangesContext.hxx b/binfilter/bf_sc/source/filter/xml/XMLTrackedChangesContext.hxx new file mode 100644 index 000000000000..3acd443e1b24 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/XMLTrackedChangesContext.hxx @@ -0,0 +1,68 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SC_XMLTRACKEDCHANGESCONTEXT_HXX +#define _SC_XMLTRACKEDCHANGESCONTEXT_HXX + +#include "XMLChangeTrackingImportHelper.hxx" +#include "chgtrack.hxx" + +#include <bf_xmloff/xmlictxt.hxx> + +#include <rtl/ustrbuf.hxx> +namespace binfilter { + +class ScXMLImport; +class ScXMLChangeTrackingImportHelper; +class ScEditEngineTextObj; + +class ScXMLTrackedChangesContext : public SvXMLImportContext +{ + ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + ScXMLTrackedChangesContext( ScXMLImport& rImport, USHORT nPrfx, const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper); + virtual ~ScXMLTrackedChangesContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + virtual void EndElement(); +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/makefile.mk b/binfilter/bf_sc/source/filter/xml/makefile.mk new file mode 100644 index 000000000000..be7ab413b140 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/makefile.mk @@ -0,0 +1,152 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org 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 version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +EXTERNAL_WARNINGS_NOT_ERRORS := TRUE +PRJ=..$/..$/..$/.. +BFPRJ=..$/..$/.. + +PRJNAME=binfilter +TARGET=sc_xml + +NO_HIDS=TRUE + +ENABLE_EXCEPTIONS=TRUE + +PROJECTPCH4DLL=TRUE +PROJECTPCH=filt_pch +PROJECTPCHSOURCE=..\pch\sc_filt_pch + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk +.INCLUDE : $(BFPRJ)$/util$/makefile.pmk +INC+= -I$(PRJ)$/inc$/bf_sc +# --- Files -------------------------------------------------------- + +CXXFILES = \ + sc_xmlwrap.cxx \ + sc_xmlimprt.cxx \ + sc_xmlexprt.cxx \ + sc_xmlbodyi.cxx \ + sc_xmltabi.cxx \ + sc_xmlrowi.cxx \ + sc_xmlcelli.cxx \ + sc_xmlconti.cxx \ + sc_xmlcoli.cxx \ + sc_xmlsubti.cxx \ + sc_xmlnexpi.cxx \ + sc_xmldrani.cxx \ + sc_xmlfilti.cxx \ + sc_xmlsorti.cxx \ + sc_xmlstyle.cxx \ + sc_xmlstyli.cxx \ + sc_xmldpimp.cxx \ + sc_xmlannoi.cxx \ + sc_xmlsceni.cxx \ + sc_xmlcvali.cxx \ + sc_XMLTableMasterPageExport.cxx \ + sc_xmllabri.cxx \ + sc_XMLTableHeaderFooterContext.cxx \ + sc_XMLDetectiveContext.cxx \ + sc_XMLCellRangeSourceContext.cxx \ + sc_XMLConsolidationContext.cxx \ + sc_XMLConverter.cxx \ + sc_XMLExportIterator.cxx \ + sc_XMLColumnRowGroupExport.cxx \ + sc_XMLStylesExportHelper.cxx \ + sc_XMLStylesImportHelper.cxx \ + sc_XMLExportDataPilot.cxx \ + sc_XMLExportDatabaseRanges.cxx \ + sc_XMLTableShapeImportHelper.cxx \ + sc_XMLTableShapesContext.cxx \ + sc_XMLExportDDELinks.cxx \ + sc_XMLDDELinksContext.cxx \ + sc_XMLCalculationSettingsContext.cxx \ + sc_XMLTableSourceContext.cxx \ + sc_XMLTextPContext.cxx \ + sc_XMLTableShapeResizer.cxx \ + sc_XMLChangeTrackingExportHelper.cxx \ + sc_xmlfonte.cxx \ + sc_XMLChangeTrackingImportHelper.cxx \ + sc_XMLTrackedChangesContext.cxx \ + sc_XMLExportSharedData.cxx \ + sc_XMLEmptyContext.cxx + +SLOFILES = \ + $(SLO)$/sc_xmlwrap.obj \ + $(SLO)$/sc_xmlimprt.obj \ + $(SLO)$/sc_xmlexprt.obj \ + $(SLO)$/sc_xmlbodyi.obj \ + $(SLO)$/sc_xmltabi.obj \ + $(SLO)$/sc_xmlrowi.obj \ + $(SLO)$/sc_xmlcelli.obj \ + $(SLO)$/sc_xmlconti.obj \ + $(SLO)$/sc_xmlcoli.obj \ + $(SLO)$/sc_xmlsubti.obj \ + $(SLO)$/sc_xmlnexpi.obj \ + $(SLO)$/sc_xmldrani.obj \ + $(SLO)$/sc_xmlfilti.obj \ + $(SLO)$/sc_xmlsorti.obj \ + $(SLO)$/sc_xmlstyle.obj \ + $(SLO)$/sc_xmlstyli.obj \ + $(SLO)$/sc_xmldpimp.obj \ + $(SLO)$/sc_xmlannoi.obj \ + $(SLO)$/sc_xmlsceni.obj \ + $(SLO)$/sc_xmlcvali.obj \ + $(SLO)$/sc_XMLTableMasterPageExport.obj \ + $(SLO)$/sc_xmllabri.obj \ + $(SLO)$/sc_XMLTableHeaderFooterContext.obj \ + $(SLO)$/sc_XMLDetectiveContext.obj \ + $(SLO)$/sc_XMLCellRangeSourceContext.obj \ + $(SLO)$/sc_XMLConsolidationContext.obj \ + $(SLO)$/sc_XMLConverter.obj \ + $(SLO)$/sc_XMLExportIterator.obj \ + $(SLO)$/sc_XMLColumnRowGroupExport.obj \ + $(SLO)$/sc_XMLStylesExportHelper.obj \ + $(SLO)$/sc_XMLStylesImportHelper.obj \ + $(SLO)$/sc_XMLExportDataPilot.obj \ + $(SLO)$/sc_XMLExportDatabaseRanges.obj \ + $(SLO)$/sc_XMLTableShapeImportHelper.obj \ + $(SLO)$/sc_XMLTableShapesContext.obj \ + $(SLO)$/sc_XMLExportDDELinks.obj \ + $(SLO)$/sc_XMLDDELinksContext.obj \ + $(SLO)$/sc_XMLCalculationSettingsContext.obj \ + $(SLO)$/sc_XMLTableSourceContext.obj \ + $(SLO)$/sc_XMLTextPContext.obj \ + $(SLO)$/sc_XMLTableShapeResizer.obj \ + $(SLO)$/sc_XMLChangeTrackingExportHelper.obj \ + $(SLO)$/sc_xmlfonte.obj \ + $(SLO)$/sc_XMLChangeTrackingImportHelper.obj \ + $(SLO)$/sc_XMLTrackedChangesContext.obj \ + $(SLO)$/sc_XMLExportSharedData.obj \ + $(SLO)$/sc_XMLEmptyContext.obj + + +# --- Tagets ------------------------------------------------------- + +.INCLUDE : target.mk + diff --git a/binfilter/bf_sc/source/filter/xml/sc_XMLCalculationSettingsContext.cxx b/binfilter/bf_sc/source/filter/xml/sc_XMLCalculationSettingsContext.cxx new file mode 100644 index 000000000000..d0776e813ca2 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_XMLCalculationSettingsContext.cxx @@ -0,0 +1,292 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "XMLCalculationSettingsContext.hxx" +#include "xmlimprt.hxx" +#include "unonames.hxx" +#include "docoptio.hxx" +#include "document.hxx" + +#include <bf_xmloff/xmlnmspe.hxx> +#include <bf_xmloff/xmluconv.hxx> +#include <bf_xmloff/nmspmap.hxx> + +#include <com/sun/star/sheet/XSpreadsheetDocument.hpp> +#include <comphelper/extract.hxx> +namespace binfilter { + +using namespace ::com::sun::star; +using namespace xmloff::token; + +//------------------------------------------------------------------ + +ScXMLCalculationSettingsContext::ScXMLCalculationSettingsContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList) : + SvXMLImportContext( rImport, nPrfx, rLName ), + fIterationEpsilon(0.001), + nIterationCount(100), + nYear2000(1930), + bIsIterationEnabled(sal_False), + bCalcAsShown(sal_False), + bIgnoreCase(sal_False), + bLookUpLabels(sal_True), + bMatchWholeCell(sal_True), + bUseRegularExpressions(sal_True) +{ + aNullDate.Day = 30; + aNullDate.Month = 12; + aNullDate.Year = 1899; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + if (nPrefix == XML_NAMESPACE_TABLE) + { + if (IsXMLToken(aLocalName, XML_CASE_SENSITIVE)) + { + if (IsXMLToken(sValue, XML_FALSE)) + bIgnoreCase = sal_True; + } + else if (IsXMLToken(aLocalName, XML_PRECISION_AS_SHOWN)) + { + if (IsXMLToken(sValue, XML_TRUE)) + bCalcAsShown = sal_True; + } + else if (IsXMLToken(aLocalName, XML_SEARCH_CRITERIA_MUST_APPLY_TO_WHOLE_CELL)) + { + if (IsXMLToken(sValue, XML_FALSE)) + bMatchWholeCell = sal_False; + } + else if (IsXMLToken(aLocalName, XML_AUTOMATIC_FIND_LABELS)) + { + if (IsXMLToken(sValue, XML_FALSE)) + bLookUpLabels = sal_False; + } + else if (IsXMLToken(aLocalName, XML_NULL_YEAR)) + { + sal_Int32 nTemp; + GetScImport().GetMM100UnitConverter().convertNumber(nTemp, sValue); + nYear2000 = static_cast<sal_uInt16>(nTemp); + } + else if (IsXMLToken(aLocalName, XML_USE_REGULAR_EXPRESSIONS)) + { + if (IsXMLToken(sValue, XML_FALSE)) + bUseRegularExpressions = sal_False; + } + } + } +} + +ScXMLCalculationSettingsContext::~ScXMLCalculationSettingsContext() +{ +} + +SvXMLImportContext *ScXMLCalculationSettingsContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if (nPrefix == XML_NAMESPACE_TABLE) + { + if (IsXMLToken(rLName, XML_NULL_DATE)) + pContext = new ScXMLNullDateContext(GetScImport(), nPrefix, rLName, xAttrList, this); + else if (IsXMLToken(rLName, XML_ITERATION)) + pContext = new ScXMLIterationContext(GetScImport(), nPrefix, rLName, xAttrList, this); + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLCalculationSettingsContext::EndElement() +{ + if (GetScImport().GetModel().is()) + { + uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc (GetScImport().GetModel(), uno::UNO_QUERY); + if (xSpreadDoc.is()) + { + uno::Reference <beans::XPropertySet> xPropertySet (xSpreadDoc, uno::UNO_QUERY); + if (xPropertySet.is()) + { + uno::Any aAny = ::cppu::bool2any( bCalcAsShown ); + xPropertySet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_CALCASSHOWN)), aAny ); + aAny = ::cppu::bool2any( bIgnoreCase ); + xPropertySet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_IGNORECASE)), aAny ); + aAny = ::cppu::bool2any( bLookUpLabels ); + xPropertySet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_LOOKUPLABELS)), aAny ); + aAny = ::cppu::bool2any( bMatchWholeCell ); + xPropertySet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_MATCHWHOLE)), aAny ); + aAny = ::cppu::bool2any( bUseRegularExpressions ); + xPropertySet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_REGEXENABLED)), aAny ); + aAny = ::cppu::bool2any( bIsIterationEnabled ); + xPropertySet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_ITERENABLED)), aAny ); + aAny <<= nIterationCount; + xPropertySet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_ITERCOUNT)), aAny); + aAny <<= fIterationEpsilon; + xPropertySet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_ITEREPSILON)), aAny); + aAny <<= aNullDate; + xPropertySet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_NULLDATE)), aAny); + if (GetScImport().GetDocument()) + { + GetScImport().LockSolarMutex(); + ScDocOptions aDocOptions (GetScImport().GetDocument()->GetDocOptions()); + aDocOptions.SetYear2000(nYear2000); + GetScImport().GetDocument()->SetDocOptions(aDocOptions); + GetScImport().UnlockSolarMutex(); + } + } + } + } +} + +ScXMLNullDateContext::ScXMLNullDateContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLCalculationSettingsContext* pCalcSet) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + if (nPrefix == XML_NAMESPACE_TABLE && IsXMLToken(aLocalName, XML_DATE_VALUE)) + { + util::DateTime aDateTime; + GetScImport().GetMM100UnitConverter().convertDateTime(aDateTime, sValue); + util::Date aDate; + aDate.Day = aDateTime.Day; + aDate.Month = aDateTime.Month; + aDate.Year = aDateTime.Year; + pCalcSet->SetNullDate(aDate); + } + } +} + +ScXMLNullDateContext::~ScXMLNullDateContext() +{ +} + +SvXMLImportContext *ScXMLNullDateContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLNullDateContext::EndElement() +{ +} + +ScXMLIterationContext::ScXMLIterationContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLCalculationSettingsContext* pCalcSet) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + if (nPrefix == XML_NAMESPACE_TABLE) + { + if (IsXMLToken(aLocalName, XML_STATUS)) + { + if (IsXMLToken(sValue, XML_ENABLE)) + pCalcSet->SetIterationStatus(sal_True); + } + else if (IsXMLToken(aLocalName, XML_STEPS)) + { + sal_Int32 nSteps; + GetScImport().GetMM100UnitConverter().convertNumber(nSteps, sValue); + pCalcSet->SetIterationCount(nSteps); + } + else if (IsXMLToken(aLocalName, XML_MAXIMUM_DIFFERENCE)) + { + double fDif; + GetScImport().GetMM100UnitConverter().convertDouble(fDif, sValue); + pCalcSet->SetIterationEpsilon(fDif); + } + } + } +} + +ScXMLIterationContext::~ScXMLIterationContext() +{ +} + +SvXMLImportContext *ScXMLIterationContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLIterationContext::EndElement() +{ +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_XMLCellRangeSourceContext.cxx b/binfilter/bf_sc/source/filter/xml/sc_XMLCellRangeSourceContext.cxx new file mode 100644 index 000000000000..dbcd5fe7a72c --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_XMLCellRangeSourceContext.cxx @@ -0,0 +1,140 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +//___________________________________________________________________ + +#include "XMLCellRangeSourceContext.hxx" + +#include <bf_xmloff/nmspmap.hxx> +#include <bf_xmloff/xmluconv.hxx> + +#include "xmlimprt.hxx" +namespace binfilter { + +using namespace ::rtl; +using namespace ::com::sun::star; + + +//___________________________________________________________________ + +ScMyImpCellRangeSource::ScMyImpCellRangeSource() : + nColumns( 0 ), + nRows( 0 ), + nRefresh( 0 ) +{ +} + + +//___________________________________________________________________ + +ScXMLCellRangeSourceContext::ScXMLCellRangeSourceContext( + ScXMLImport& rImport, + USHORT nPrfx, + const OUString& rLName, + const uno::Reference< xml::sax::XAttributeList >& xAttrList, + ScMyImpCellRangeSource* pCellRangeSource ) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + if( !xAttrList.is() ) return; + + sal_Int16 nAttrCount = xAttrList->getLength(); + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetTableCellRangeSourceAttrTokenMap(); + + for( sal_Int16 nIndex = 0; nIndex < nAttrCount; nIndex++ ) + { + OUString sAttrName = xAttrList->getNameByIndex( nIndex ); + OUString sValue = xAttrList->getValueByIndex( nIndex ); + OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_NAME: + pCellRangeSource->sSourceStr = sValue; + break; + case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_FILTER_NAME: + pCellRangeSource->sFilterName = sValue; + break; + case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_FILTER_OPTIONS: + pCellRangeSource->sFilterOptions = sValue; + break; + case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_HREF: + pCellRangeSource->sURL = GetScImport().GetAbsoluteReference(sValue); + break; + case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_LAST_COLUMN: + { + sal_Int32 nValue; + if( SvXMLUnitConverter::convertNumber( nValue, sValue, 1 ) ) + pCellRangeSource->nColumns = nValue; + else + pCellRangeSource->nColumns = 1; + } + break; + case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_LAST_ROW: + { + sal_Int32 nValue; + if( SvXMLUnitConverter::convertNumber( nValue, sValue, 1 ) ) + pCellRangeSource->nRows = nValue; + else + pCellRangeSource->nRows = 1; + } + break; + case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_REFRESH_DELAY: + { + double fTime; + if( SvXMLUnitConverter::convertTime( fTime, sValue ) ) + pCellRangeSource->nRefresh = Max( (sal_Int32)(fTime * 86400.0), (sal_Int32)0 ); + } + break; + } + } +} + +ScXMLCellRangeSourceContext::~ScXMLCellRangeSourceContext() +{ +} + +SvXMLImportContext *ScXMLCellRangeSourceContext::CreateChildContext( + USHORT nPrefix, + const OUString& rLName, + const uno::Reference< xml::sax::XAttributeList>& xAttrList ) +{ + return new SvXMLImportContext( GetImport(), nPrefix, rLName ); +} + +void ScXMLCellRangeSourceContext::EndElement() +{ +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_XMLChangeTrackingExportHelper.cxx b/binfilter/bf_sc/source/filter/xml/sc_XMLChangeTrackingExportHelper.cxx new file mode 100644 index 000000000000..12da0a73b7d9 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_XMLChangeTrackingExportHelper.cxx @@ -0,0 +1,780 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "XMLChangeTrackingExportHelper.hxx" + +#include "xmlexprt.hxx" +#include "XMLConverter.hxx" +#include "chgtrack.hxx" +#include "chgviset.hxx" +#include "cell.hxx" +#include "textuno.hxx" + +#include <bf_xmloff/xmlnmspe.hxx> +#include <bf_xmloff/xmluconv.hxx> + +#include <bf_svtools/zforlist.hxx> +namespace binfilter { + +#define SC_CHANGE_ID_PREFIX "ct" + +using namespace ::com::sun::star; +using namespace ::binfilter::xmloff::token; + +ScChangeTrackingExportHelper::ScChangeTrackingExportHelper(ScXMLExport& rTempExport) + : rExport(rTempExport), + pChangeTrack(NULL), + sChangeIDPrefix(RTL_CONSTASCII_USTRINGPARAM(SC_CHANGE_ID_PREFIX)), + pEditTextObj(NULL), + pDependings(NULL) +{ + pChangeTrack = rExport.GetDocument() ? rExport.GetDocument()->GetChangeTrack() : NULL; + pDependings = new ScChangeActionTable(); +} + +ScChangeTrackingExportHelper::~ScChangeTrackingExportHelper() +{ + if (pDependings) + delete pDependings; +} + +rtl::OUString ScChangeTrackingExportHelper::GetChangeID(const sal_uInt32 nActionNumber) +{ + ::rtl::OUStringBuffer sBuffer(sChangeIDPrefix); + SvXMLUnitConverter::convertNumber(sBuffer, static_cast<sal_Int32>(nActionNumber)); + return sBuffer.makeStringAndClear(); +} + +void ScChangeTrackingExportHelper::GetAcceptanceState(const ScChangeAction* pAction) +{ + if (pAction->IsRejected()) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ACCEPTANCE_STATE, XML_REJECTED); + else if (pAction->IsAccepted()) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ACCEPTANCE_STATE, XML_ACCEPTED); +} + +void ScChangeTrackingExportHelper::WriteBigRange(const ScBigRange& rBigRange, XMLTokenEnum aName) +{ + sal_Int32 nStartColumn; + sal_Int32 nEndColumn; + sal_Int32 nStartRow; + sal_Int32 nEndRow; + sal_Int32 nStartSheet; + sal_Int32 nEndSheet; + rBigRange.GetVars(nStartColumn, nStartRow, nStartSheet, + nEndColumn, nEndRow, nEndSheet); + if ((nStartColumn == nEndColumn) && (nStartRow == nEndRow) && (nStartSheet == nEndSheet)) + { + ::rtl::OUStringBuffer sBuffer; + SvXMLUnitConverter::convertNumber(sBuffer, nStartColumn); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_COLUMN, sBuffer.makeStringAndClear()); + SvXMLUnitConverter::convertNumber(sBuffer, nStartRow); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ROW, sBuffer.makeStringAndClear()); + SvXMLUnitConverter::convertNumber(sBuffer, nStartSheet); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_TABLE, sBuffer.makeStringAndClear()); + } + else + { + ::rtl::OUStringBuffer sBuffer; + SvXMLUnitConverter::convertNumber(sBuffer, nStartColumn); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_START_COLUMN, sBuffer.makeStringAndClear()); + SvXMLUnitConverter::convertNumber(sBuffer, nStartRow); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_START_ROW, sBuffer.makeStringAndClear()); + SvXMLUnitConverter::convertNumber(sBuffer, nStartSheet); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_START_TABLE, sBuffer.makeStringAndClear()); + SvXMLUnitConverter::convertNumber(sBuffer, nEndColumn); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_END_COLUMN, sBuffer.makeStringAndClear()); + SvXMLUnitConverter::convertNumber(sBuffer, nEndRow); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_END_ROW, sBuffer.makeStringAndClear()); + SvXMLUnitConverter::convertNumber(sBuffer, nEndSheet); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_END_TABLE, sBuffer.makeStringAndClear()); + } + SvXMLElementExport aBigRangeElem(rExport, XML_NAMESPACE_TABLE, aName, sal_True, sal_True); +} + +void ScChangeTrackingExportHelper::WriteChangeInfo(const ScChangeAction* pAction) +{ + ::rtl::OUString sAuthor(pAction->GetUser()); + rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_CHG_AUTHOR, sAuthor); + ::rtl::OUStringBuffer sDate; + ScXMLConverter::ConvertDateTimeToString(pAction->GetDateTimeUTC(), sDate); + rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_CHG_DATE_TIME, sDate.makeStringAndClear()); + SvXMLElementExport aElemInfo (rExport, XML_NAMESPACE_OFFICE, XML_CHANGE_INFO, sal_True, sal_True); + ::rtl::OUString sComment(pAction->GetComment()); + if (sComment.getLength()) + { + SvXMLElementExport aElemC(rExport, XML_NAMESPACE_TEXT, XML_P, sal_True, sal_False); + sal_Bool bPrevCharWasSpace(sal_True); + rExport.GetTextParagraphExport()->exportText(sComment, bPrevCharWasSpace); + } +} + +void ScChangeTrackingExportHelper::WriteGenerated(const ScChangeAction* pGeneratedAction) +{ + sal_uInt32 nActionNumber(pGeneratedAction->GetActionNumber()); + DBG_ASSERT(pChangeTrack->IsGenerated(nActionNumber), "a not generated action found"); + SvXMLElementExport aElemPrev(rExport, XML_NAMESPACE_TABLE, XML_CELL_CONTENT_DELETION, sal_True, sal_True); + WriteBigRange(pGeneratedAction->GetBigRange(), XML_CELL_ADDRESS); + String sValue; + static_cast<const ScChangeActionContent*>(pGeneratedAction)->GetNewString(sValue); + WriteCell(static_cast<const ScChangeActionContent*>(pGeneratedAction)->GetNewCell(), sValue); +} + +void ScChangeTrackingExportHelper::WriteDeleted(const ScChangeAction* pDeletedAction) +{ + sal_uInt32 nActionNumber(pDeletedAction->GetActionNumber()); + if (pDeletedAction->GetType() == SC_CAT_CONTENT) + { + const ScChangeActionContent* pContentAction = static_cast<const ScChangeActionContent*>(pDeletedAction); + if (pContentAction) + { + if (!pChangeTrack->IsGenerated(nActionNumber)) + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ID, GetChangeID(nActionNumber)); + SvXMLElementExport aElemPrev(rExport, XML_NAMESPACE_TABLE, XML_CELL_CONTENT_DELETION, sal_True, sal_True); + if (static_cast<const ScChangeActionContent*>(pDeletedAction)->IsTopContent() && pDeletedAction->IsDeletedIn()) + { + String sValue; + pContentAction->GetNewString(sValue); + WriteCell(pContentAction->GetNewCell(), sValue); + } + } + else + WriteGenerated(pContentAction); + } + } + else + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ID, GetChangeID(nActionNumber)); + SvXMLElementExport aElemPrev(rExport, XML_NAMESPACE_TABLE, XML_CHANGE_DELETION, sal_True, sal_True); + } +} + +void ScChangeTrackingExportHelper::WriteDepending(const ScChangeAction* pDependAction) +{ + sal_uInt32 nActionNumber(pDependAction->GetActionNumber()); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ID, GetChangeID(nActionNumber)); + SvXMLElementExport aDependElem(rExport, XML_NAMESPACE_TABLE, XML_DEPENDENCE, sal_True, sal_True); +} + +void ScChangeTrackingExportHelper::WriteDependings(ScChangeAction* pAction) +{ + if (pAction->HasDependent()) + { + SvXMLElementExport aDependingsElem (rExport, XML_NAMESPACE_TABLE, XML_DEPENDENCES, sal_True, sal_True); + const ScChangeActionLinkEntry* pEntry = pAction->GetFirstDependentEntry(); + while (pEntry) + { + WriteDepending(pEntry->GetAction()); + pEntry = pEntry->GetNext(); + } + } + if (pAction->HasDeleted()) + { + SvXMLElementExport aDependingsElem (rExport, XML_NAMESPACE_TABLE, XML_DELETIONS, sal_True, sal_True); + const ScChangeActionLinkEntry* pEntry = pAction->GetFirstDeletedEntry(); + while (pEntry) + { + WriteDeleted(pEntry->GetAction()); + pEntry = pEntry->GetNext(); + } + /*if (pAction->IsDeleteType()) + { + ScChangeActionDel* pDelAction = static_cast<ScChangeActionDel*> (pAction); + if (pDelAction) + { + const ScChangeActionCellListEntry* pCellEntry = pDelAction->GetFirstCellEntry(); + while (pCellEntry) + { + WriteGenerated(pCellEntry->GetContent()); + pCellEntry = pCellEntry->GetNext(); + } + } + } + else if (pAction->GetType() == SC_CAT_MOVE) + { + ScChangeActionMove* pMoveAction = static_cast<ScChangeActionMove*> (pAction); + if (pMoveAction) + { + const ScChangeActionCellListEntry* pCellEntry = pMoveAction->GetFirstCellEntry(); + while (pCellEntry) + { + WriteGenerated(pCellEntry->GetContent()); + pCellEntry = pCellEntry->GetNext(); + } + } + }*/ + } +} + +/*void ScChangeTrackingExportHelper::WriteDependings(ScChangeAction* pAction) +{ + pChangeTrack->GetDependents(pAction, *pDependings); + if (pDependings->Count()) + { + SvXMLElementExport aDependingsElem (rExport, XML_NAMESPACE_TABLE, XML_DEPENDENCES, sal_True, sal_True); + ScChangeAction* pDependAction = pDependings->First(); + while (pDependAction != NULL) + { + WriteDepending(pDependAction); + pDependAction = pDependings->Next(); + } + } +}*/ + +void ScChangeTrackingExportHelper::WriteEmptyCell() +{ + SvXMLElementExport aElemEmptyCell(rExport, XML_NAMESPACE_TABLE, XML_CHANGE_TRACK_TABLE_CELL, sal_True, sal_True); +} + +void ScChangeTrackingExportHelper::SetValueAttributes(const double& fValue, const String& sValue) +{ + sal_Bool bSetAttributes(sal_False); + if (sValue.Len()) + { + sal_uInt32 nIndex; + double fTempValue; + if (rExport.GetDocument() && rExport.GetDocument()->GetFormatTable()->IsNumberFormat(sValue, nIndex, fTempValue)) + { + sal_uInt16 nType = rExport.GetDocument()->GetFormatTable()->GetType(nIndex); + switch(nType & NUMBERFORMAT_DEFINED) + { + case NUMBERFORMAT_DATE: + { + if ( rExport.GetMM100UnitConverter().setNullDate(rExport.GetModel()) ) + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_VALUE_TYPE, XML_DATE); + ::rtl::OUStringBuffer sBuffer; + rExport.GetMM100UnitConverter().convertDateTime(sBuffer, fTempValue); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATE_VALUE, sBuffer.makeStringAndClear()); + bSetAttributes = sal_True; + } + } + break; + case NUMBERFORMAT_TIME: + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_VALUE_TYPE, XML_TIME); + ::rtl::OUStringBuffer sBuffer; + rExport.GetMM100UnitConverter().convertTime(sBuffer, fTempValue); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_TIME_VALUE, sBuffer.makeStringAndClear()); + bSetAttributes = sal_True; + } + break; + } + } + } + if (!bSetAttributes) + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_VALUE_TYPE, XML_FLOAT); + ::rtl::OUStringBuffer sBuffer; + SvXMLUnitConverter::convertDouble(sBuffer, fValue); + ::rtl::OUString sValue(sBuffer.makeStringAndClear()); + if (sValue.getLength()) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_VALUE, sValue); + } +} + + +void ScChangeTrackingExportHelper::WriteValueCell(const ScBaseCell* pCell, const String& sValue) +{ + const ScValueCell* pValueCell = static_cast<const ScValueCell*>(pCell); + if (pValueCell) + { + SetValueAttributes(pValueCell->GetValue(), sValue); + SvXMLElementExport aElemC(rExport, XML_NAMESPACE_TABLE, XML_CHANGE_TRACK_TABLE_CELL, sal_True, sal_True); + /*if (sText.getLength()) + { + SvXMLElementExport aElemC(rExport, XML_NAMESPACE_TEXT, XML_P, sal_True, sal_False); + sal_Bool bPrevCharWasSpace(sal_True); + rExport.GetTextParagraphExport()->exportText(sText, bPrevCharWasSpace); + }*/ + } +} + +void ScChangeTrackingExportHelper::WriteStringCell(const ScBaseCell* pCell) +{ + const ScStringCell* pStringCell = static_cast<const ScStringCell*>(pCell); + if (pStringCell) + { + String sString; + pStringCell->GetString(sString); + ::rtl::OUString sOUString(sString); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_VALUE_TYPE, XML_STRING); + SvXMLElementExport aElemC(rExport, XML_NAMESPACE_TABLE, XML_CHANGE_TRACK_TABLE_CELL, sal_True, sal_True); + if (sOUString.getLength()) + { + SvXMLElementExport aElemC(rExport, XML_NAMESPACE_TEXT, XML_P, sal_True, sal_False); + sal_Bool bPrevCharWasSpace(sal_True); + rExport.GetTextParagraphExport()->exportText(sOUString, bPrevCharWasSpace); + } + } +} + +void ScChangeTrackingExportHelper::WriteEditCell(const ScBaseCell* pCell) +{ + const ScEditCell* pEditCell = static_cast<const ScEditCell*>(pCell); + if (pEditCell) + { + String sString; + pEditCell->GetString(sString); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_VALUE_TYPE, XML_STRING); + SvXMLElementExport aElemC(rExport, XML_NAMESPACE_TABLE, XML_CHANGE_TRACK_TABLE_CELL, sal_True, sal_True); + if (sString.Len()) + { + if (!pEditTextObj) + { + pEditTextObj = new ScEditEngineTextObj(); + xText = pEditTextObj; + } + pEditTextObj->SetText(*(pEditCell->GetData())); + if (xText.is()) + rExport.GetTextParagraphExport()->exportText(xText, sal_False, sal_False); + } + } +} + +void ScChangeTrackingExportHelper::WriteFormulaCell(const ScBaseCell* pCell, const String& sValue) +{ + ScBaseCell* pBaseCell = const_cast<ScBaseCell*>(pCell); + ScFormulaCell* pFormulaCell = static_cast<ScFormulaCell*>(pBaseCell); + if (pFormulaCell) + { + ::rtl::OUString sAddress; + ScXMLConverter::GetStringFromAddress(sAddress, pFormulaCell->aPos, rExport.GetDocument()); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CELL_ADDRESS, sAddress); + String sFormula; + pFormulaCell->GetEnglishFormula(sFormula, sal_True); + ::rtl::OUString sOUFormula(sFormula); + sal_uInt8 nMatrixFlag(pFormulaCell->GetMatrixFlag()); + if (nMatrixFlag) + { + if (nMatrixFlag == MM_FORMULA) + { + sal_uInt16 nColumns, nRows; + pFormulaCell->GetMatColsRows(nColumns, nRows); + ::rtl::OUStringBuffer sColumns; + ::rtl::OUStringBuffer sRows; + SvXMLUnitConverter::convertNumber(sColumns, static_cast<sal_Int32>(nColumns)); + SvXMLUnitConverter::convertNumber(sRows, static_cast<sal_Int32>(nRows)); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_MATRIX_COLUMNS_SPANNED, sColumns.makeStringAndClear()); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_MATRIX_ROWS_SPANNED, sRows.makeStringAndClear()); + } + else + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_MATRIX_COVERED, XML_TRUE); + } + ::rtl::OUString sMatrixFormula = sOUFormula.copy(1, sOUFormula.getLength() - 2); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_FORMULA, sMatrixFormula); + } + else + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_FORMULA, sFormula); + if (pFormulaCell->IsValue()) + { + SetValueAttributes(pFormulaCell->GetValue(), sValue); + SvXMLElementExport aElemC(rExport, XML_NAMESPACE_TABLE, XML_CHANGE_TRACK_TABLE_CELL, sal_True, sal_True); + } + else + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_VALUE_TYPE, XML_STRING); + String sValue; + pFormulaCell->GetString(sValue); + ::rtl::OUString sOUValue(sValue); + SvXMLElementExport aElemC(rExport, XML_NAMESPACE_TABLE, XML_CHANGE_TRACK_TABLE_CELL, sal_True, sal_True); + if (sOUValue.getLength()) + { + SvXMLElementExport aElemC(rExport, XML_NAMESPACE_TEXT, XML_P, sal_True, sal_False); + sal_Bool bPrevCharWasSpace(sal_True); + rExport.GetTextParagraphExport()->exportText(sOUValue, bPrevCharWasSpace); + } + } + } +} + +void ScChangeTrackingExportHelper::WriteCell(const ScBaseCell* pCell, const String& sValue) +{ + if (pCell) + { + switch (pCell->GetCellType()) + { + case CELLTYPE_NONE: + WriteEmptyCell(); + break; + case CELLTYPE_VALUE: + WriteValueCell(pCell, sValue); + break; + case CELLTYPE_STRING: + WriteStringCell(pCell); + break; + case CELLTYPE_EDIT: + WriteEditCell(pCell); + break; + case CELLTYPE_FORMULA: + WriteFormulaCell(pCell, sValue); + break; + } + } + else + WriteEmptyCell(); +} + +void ScChangeTrackingExportHelper::WriteContentChange(ScChangeAction* pAction) +{ + SvXMLElementExport aElemChange(rExport, XML_NAMESPACE_TABLE, XML_CELL_CONTENT_CHANGE, sal_True, sal_True); + const ScChangeAction* pConstAction = pAction; + WriteBigRange(pConstAction->GetBigRange(), XML_CELL_ADDRESS); + WriteChangeInfo(pAction); + WriteDependings(pAction); + { + ScChangeActionContent* pPrevAction = static_cast<ScChangeActionContent*>(pAction)->GetPrevContent(); + if (pPrevAction) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ID, GetChangeID(pPrevAction->GetActionNumber())); + SvXMLElementExport aElemPrev(rExport, XML_NAMESPACE_TABLE, XML_PREVIOUS, sal_True, sal_True); + String sValue; + static_cast<ScChangeActionContent*>(pAction)->GetOldString(sValue); + WriteCell(static_cast<ScChangeActionContent*>(pAction)->GetOldCell(), sValue); + } +} + +void ScChangeTrackingExportHelper::AddInsertionAttributes(const ScChangeAction* pConstAction) +{ + sal_Int32 nPosition(0); + sal_Int32 nCount(0); + sal_Int32 nStartPosition(0); + sal_Int32 nEndPosition(0); + sal_Int32 nStartColumn; + sal_Int32 nEndColumn; + sal_Int32 nStartRow; + sal_Int32 nEndRow; + sal_Int32 nStartSheet; + sal_Int32 nEndSheet; + const ScBigRange& rBigRange = pConstAction->GetBigRange(); + rBigRange.GetVars(nStartColumn, nStartRow, nStartSheet, + nEndColumn, nEndRow, nEndSheet); + switch (pConstAction->GetType()) + { + case SC_CAT_INSERT_COLS : + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_TYPE, XML_COLUMN); + nStartPosition = nStartColumn; + nEndPosition = nEndColumn; + } + break; + case SC_CAT_INSERT_ROWS : + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_TYPE, XML_ROW); + nStartPosition = nStartRow; + nEndPosition = nEndRow; + } + break; + case SC_CAT_INSERT_TABS : + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_TYPE, XML_TABLE); + nStartPosition = nStartSheet; + nEndPosition = nEndSheet; + } + break; + default : + { + DBG_ERROR("wrong insertion type"); + } + break; + } + nPosition = nStartPosition; + nCount = nEndPosition - nStartPosition + 1; + ::rtl::OUStringBuffer sBuffer; + SvXMLUnitConverter::convertNumber(sBuffer, nPosition); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_POSITION, sBuffer.makeStringAndClear()); + DBG_ASSERT(nCount > 0, "wrong insertion count"); + if (nCount > 1) + { + SvXMLUnitConverter::convertNumber(sBuffer, nCount); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_COUNT, sBuffer.makeStringAndClear()); + } + if (pConstAction->GetType() != SC_CAT_INSERT_TABS) + { + SvXMLUnitConverter::convertNumber(sBuffer, nStartSheet); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_TABLE, sBuffer.makeStringAndClear()); + } +} + +void ScChangeTrackingExportHelper::WriteInsertion(ScChangeAction* pAction) +{ + AddInsertionAttributes(pAction); + SvXMLElementExport aElemChange(rExport, XML_NAMESPACE_TABLE, XML_INSERTION, sal_True, sal_True); + WriteChangeInfo(pAction); + WriteDependings(pAction); +} + +void ScChangeTrackingExportHelper::AddDeletionAttributes(const ScChangeActionDel* pDelAction, const ScChangeActionDel* pLastAction) +{ + sal_Int32 nPosition(0); + const ScBigRange& rBigRange = pDelAction->GetBigRange(); + sal_Int32 nStartColumn(0); + sal_Int32 nEndColumn(0); + sal_Int32 nStartRow(0); + sal_Int32 nEndRow(0); + sal_Int32 nStartSheet(0); + sal_Int32 nEndSheet(0); + rBigRange.GetVars(nStartColumn, nStartRow, nStartSheet, + nEndColumn, nEndRow, nEndSheet); + switch (pDelAction->GetType()) + { + case SC_CAT_DELETE_COLS : + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_TYPE, XML_COLUMN); + nPosition = nStartColumn; + } + break; + case SC_CAT_DELETE_ROWS : + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_TYPE, XML_ROW); + nPosition = nStartRow; + } + break; + case SC_CAT_DELETE_TABS : + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_TYPE, XML_TABLE); + nPosition = nStartSheet; + //DBG_ERROR("not implemented feature"); + } + break; + default : + { + DBG_ERROR("wrong deletion type"); + } + break; + } + ::rtl::OUStringBuffer sBuffer; + SvXMLUnitConverter::convertNumber(sBuffer, nPosition); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_POSITION, sBuffer.makeStringAndClear()); + if (pDelAction->GetType() != SC_CAT_DELETE_TABS) + { + SvXMLUnitConverter::convertNumber(sBuffer, nStartSheet); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_TABLE, sBuffer.makeStringAndClear()); + if (pDelAction->IsMultiDelete() && !pDelAction->GetDx() && !pDelAction->GetDy()) + { + const ScChangeAction* p = pDelAction->GetNext(); + sal_Bool bAll(sal_False); + sal_Int32 nSlavesCount (1); + while (!bAll && p) + { + if ( !p || p->GetType() != pDelAction->GetType() ) + bAll = sal_True; + else + { + const ScChangeActionDel* pDel = (const ScChangeActionDel*) p; + if ( (pDel->GetDx() > pDelAction->GetDx() || pDel->GetDy() > pDelAction->GetDy()) && + pDel->GetBigRange() == pDelAction->GetBigRange() ) + { + nSlavesCount++; + p = p->GetNext(); + } + else + bAll = sal_True; + } + } + + SvXMLUnitConverter::convertNumber(sBuffer, nSlavesCount); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_MULTI_DELETION_SPANNED, sBuffer.makeStringAndClear()); + } + } +} + +void ScChangeTrackingExportHelper::WriteCutOffs(const ScChangeActionDel* pAction) +{ + const ScChangeActionIns* pCutOffIns = pAction->GetCutOffInsert(); + const ScChangeActionDelMoveEntry* pLinkMove = pAction->GetFirstMoveEntry(); + if (pCutOffIns || pLinkMove) + { + SvXMLElementExport aCutOffsElem (rExport, XML_NAMESPACE_TABLE, XML_CUT_OFFS, sal_True, sal_True); + ::rtl::OUStringBuffer sBuffer; + if (pCutOffIns) + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ID, GetChangeID(pCutOffIns->GetActionNumber())); + SvXMLUnitConverter::convertNumber(sBuffer, static_cast<sal_Int32>(pAction->GetCutOffCount())); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_POSITION, sBuffer.makeStringAndClear()); + SvXMLElementExport aInsertCutOffElem (rExport, XML_NAMESPACE_TABLE, XML_INSERTION_CUT_OFF, sal_True, sal_True); + } + while (pLinkMove) + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ID, GetChangeID(pLinkMove->GetAction()->GetActionNumber())); + if (pLinkMove->GetCutOffFrom() == pLinkMove->GetCutOffTo()) + { + SvXMLUnitConverter::convertNumber(sBuffer, static_cast<sal_Int32>(pLinkMove->GetCutOffFrom())); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_POSITION, sBuffer.makeStringAndClear()); + } + else + { + SvXMLUnitConverter::convertNumber(sBuffer, static_cast<sal_Int32>(pLinkMove->GetCutOffFrom())); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_START_POSITION, sBuffer.makeStringAndClear()); + SvXMLUnitConverter::convertNumber(sBuffer, static_cast<sal_Int32>(pLinkMove->GetCutOffTo())); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_END_POSITION, sBuffer.makeStringAndClear()); + } + SvXMLElementExport aMoveCutOffElem (rExport, XML_NAMESPACE_TABLE, XML_MOVEMENT_CUT_OFF, sal_True, sal_True); + pLinkMove = pLinkMove->GetNext(); + } + } +} + +void ScChangeTrackingExportHelper::WriteDeletion(ScChangeAction* pAction) +{ + ScChangeActionDel* pDelAction = static_cast<ScChangeActionDel*> (pAction); + AddDeletionAttributes(pDelAction, pDelAction); + SvXMLElementExport aElemChange(rExport, XML_NAMESPACE_TABLE, XML_DELETION, sal_True, sal_True); + WriteChangeInfo(pDelAction); + WriteDependings(pDelAction); + WriteCutOffs(pDelAction); +} + +void ScChangeTrackingExportHelper::WriteMovement(ScChangeAction* pAction) +{ + const ScChangeActionMove* pMoveAction = static_cast<ScChangeActionMove*> (pAction); + SvXMLElementExport aElemChange(rExport, XML_NAMESPACE_TABLE, XML_MOVEMENT, sal_True, sal_True); + WriteBigRange(pMoveAction->GetFromRange(), XML_SOURCE_RANGE_ADDRESS); + WriteBigRange(pMoveAction->GetBigRange(), XML_TARGET_RANGE_ADDRESS); + WriteChangeInfo(pAction); + WriteDependings(pAction); +} + +void ScChangeTrackingExportHelper::WriteRejection(ScChangeAction* pAction) +{ + SvXMLElementExport aElemChange(rExport, XML_NAMESPACE_TABLE, XML_REJECTION, sal_True, sal_True); + WriteChangeInfo(pAction); + WriteDependings(pAction); +} + +void ScChangeTrackingExportHelper::CollectCellAutoStyles(const ScBaseCell* pBaseCell) +{ + if (pBaseCell && (pBaseCell->GetCellType() == CELLTYPE_EDIT)) + { + const ScEditCell* pEditCell = static_cast<const ScEditCell*>(pBaseCell); + if (pEditCell) + { + if (!pEditTextObj) + { + pEditTextObj = new ScEditEngineTextObj(); + xText = pEditTextObj; + } + pEditTextObj->SetText(*(pEditCell->GetData())); + if (xText.is()) + rExport.GetTextParagraphExport()->collectTextAutoStyles(xText, sal_False, sal_False); + } + } +} + +void ScChangeTrackingExportHelper::CollectActionAutoStyles(ScChangeAction* pAction) +{ + if (pAction->GetType() == SC_CAT_CONTENT) + { + if (pChangeTrack->IsGenerated(pAction->GetActionNumber())) + CollectCellAutoStyles(static_cast<ScChangeActionContent*>(pAction)->GetNewCell()); + else + { + CollectCellAutoStyles(static_cast<ScChangeActionContent*>(pAction)->GetOldCell()); + if (static_cast<ScChangeActionContent*>(pAction)->IsTopContent() && pAction->IsDeletedIn()) + CollectCellAutoStyles(static_cast<ScChangeActionContent*>(pAction)->GetNewCell()); + } + } +} + +void ScChangeTrackingExportHelper::WorkWithChangeAction(ScChangeAction* pAction) +{ + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ID, GetChangeID(pAction->GetActionNumber())); + GetAcceptanceState(pAction); + if (pAction->IsRejecting()) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_REJECTING_CHANGE_ID, GetChangeID(pAction->GetRejectAction())); + if (pAction->GetType() == SC_CAT_CONTENT) + WriteContentChange(pAction); + else if (pAction->IsInsertType()) + WriteInsertion(pAction); + else if (pAction->IsDeleteType()) + WriteDeletion(pAction); + else if (pAction->GetType() == SC_CAT_MOVE) + WriteMovement(pAction); + else if (pAction->GetType() == SC_CAT_REJECT) + WriteRejection(pAction); + else + DBG_ERROR("not a writeable type"); + rExport.CheckAttrList(); +} + +void ScChangeTrackingExportHelper::CollectAutoStyles() +{ + if (pChangeTrack) + { + sal_uInt32 nCount (pChangeTrack->GetActionMax()); + if (nCount) + { + ScChangeAction* pAction = pChangeTrack->GetFirst(); + CollectActionAutoStyles(pAction); + ScChangeAction* pLastAction = pChangeTrack->GetLast(); + while (pAction != pLastAction) + { + pAction = pAction->GetNext(); + CollectActionAutoStyles(pAction); + } + pAction = pChangeTrack->GetFirstGenerated(); + while (pAction) + { + CollectActionAutoStyles(pAction); + pAction = pAction->GetNext(); + } + } + } +} + +void ScChangeTrackingExportHelper::CollectAndWriteChanges() +{ + if (pChangeTrack) + { + if (pChangeTrack->IsProtected()) + { + ::rtl::OUStringBuffer aBuffer; + SvXMLUnitConverter::encodeBase64(aBuffer, pChangeTrack->GetProtection()); + if (aBuffer.getLength()) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTION_KEY, aBuffer.makeStringAndClear()); + } + SvXMLElementExport aCangeListElem(rExport, XML_NAMESPACE_TABLE, XML_TRACKED_CHANGES, sal_True, sal_True); + { + ScChangeAction* pAction = pChangeTrack->GetFirst(); + if (pAction) + { + WorkWithChangeAction(pAction); + ScChangeAction* pLastAction = pChangeTrack->GetLast(); + while (pAction != pLastAction) + { + pAction = pAction->GetNext(); + WorkWithChangeAction(pAction); + } + } + } + } +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_XMLChangeTrackingImportHelper.cxx b/binfilter/bf_sc/source/filter/xml/sc_XMLChangeTrackingImportHelper.cxx new file mode 100644 index 000000000000..e8410ae1c180 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_XMLChangeTrackingImportHelper.cxx @@ -0,0 +1,836 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "XMLChangeTrackingImportHelper.hxx" +#include "XMLConverter.hxx" +#include "cell.hxx" + +#include <bf_svtools/zforlist.hxx> + +#include <bf_xmloff/xmluconv.hxx> +namespace binfilter { + +#define SC_CHANGE_ID_PREFIX "ct" + +ScMyCellInfo::ScMyCellInfo(ScBaseCell* pTempCell, const ::rtl::OUString& rFormulaAddress, const ::rtl::OUString& rFormula, + const double& rValue, const sal_uInt16 nTempType, const sal_uInt8 nTempMatrixFlag, const sal_Int32 nTempMatrixCols, + const sal_Int32 nTempMatrixRows) + : pCell(pTempCell), + sFormulaAddress(rFormulaAddress), + sFormula(rFormula), + fValue(rValue), + nType(nTempType), + nMatrixFlag(nTempMatrixFlag), + nMatrixCols(nTempMatrixCols), + nMatrixRows(nTempMatrixRows) +{ +} + +ScMyCellInfo::~ScMyCellInfo() +{ + if (pCell) + pCell->Delete(); +} + +ScBaseCell* ScMyCellInfo::CreateCell(ScDocument* pDoc) +{ + if (pDoc) + { + if (!pCell && sFormula.getLength() && sFormulaAddress.getLength()) + { + ScAddress aPos; + sal_Int32 nOffset(0); + ScXMLConverter::GetAddressFromString(aPos, sFormulaAddress, pDoc, nOffset); + pCell = new ScFormulaCell(pDoc, aPos, sFormula, nMatrixFlag); + static_cast<ScFormulaCell*>(pCell)->SetMatColsRows(static_cast<sal_uInt16>(nMatrixCols), static_cast<sal_uInt16>(nMatrixRows)); + } + + if (nType != NUMBERFORMAT_ALL) + { + if (nType == NUMBERFORMAT_DATE) + pDoc->GetFormatTable()->GetInputLineString(fValue, NF_DATE_SYS_DDMMYYYY, sResult); + else if (nType == NUMBERFORMAT_TIME) + pDoc->GetFormatTable()->GetInputLineString(fValue, NF_TIME_HHMMSS, sResult); + } + } + + if (pCell) + return pCell->Clone(pDoc); + else + return NULL; +} + +ScMyDeleted::ScMyDeleted() + : pCellInfo(NULL) +{ +} + +ScMyDeleted::~ScMyDeleted() +{ + if (pCellInfo) + delete pCellInfo; +} + +ScMyGenerated::ScMyGenerated(ScMyCellInfo* pTempCellInfo, const ScBigRange& aTempBigRange) + : aBigRange(aTempBigRange), + nID(0), + pCellInfo(pTempCellInfo) +{ +} + +ScMyGenerated::~ScMyGenerated() +{ + if (pCellInfo) + delete pCellInfo; +} + +ScMyBaseAction::ScMyBaseAction(const ScChangeActionType nTempActionType) + : aDependences(), + aDeletedList(), + nActionNumber(0), + nRejectingNumber(0), + nPreviousAction(0), + nActionType(nTempActionType), + nActionState(SC_CAS_VIRGIN) +{ +} + +ScMyBaseAction::~ScMyBaseAction() +{ +} + +ScMyInsAction::ScMyInsAction(const ScChangeActionType nActionType) + : ScMyBaseAction(nActionType) +{ +} + +ScMyDelAction::ScMyDelAction(const ScChangeActionType nActionType) + : ScMyBaseAction(nActionType), + pInsCutOff(NULL), + aMoveCutOffs(), + aGeneratedList(), + nD(0) +{ +} + +ScMyDelAction::~ScMyDelAction() +{ + if (pInsCutOff) + delete pInsCutOff; +} + +ScMyMoveAction::ScMyMoveAction() + : ScMyBaseAction(SC_CAT_MOVE), + pMoveRanges(NULL), + aGeneratedList() +{ +} + +ScMyMoveAction::~ScMyMoveAction() +{ + if (pMoveRanges) + delete pMoveRanges; +} + + +ScMyContentAction::ScMyContentAction() + : ScMyBaseAction(SC_CAT_CONTENT), + pCellInfo(NULL) +{ +} + +ScMyContentAction::~ScMyContentAction() +{ + if (pCellInfo) + delete pCellInfo; +} + +ScMyRejAction::ScMyRejAction() + : ScMyBaseAction(SC_CAT_REJECT) +{ +} + +ScXMLChangeTrackingImportHelper::ScXMLChangeTrackingImportHelper() + : sIDPrefix(RTL_CONSTASCII_USTRINGPARAM(SC_CHANGE_ID_PREFIX)), + aActions(), + aUsers(), + nMultiSpanned(0), + nMultiSpannedSlaveCount(0), + pCurrentAction(NULL), + pDoc(NULL), + pTrack(NULL), + bChangeTrack(sal_False) +{ + nPrefixLength = sIDPrefix.getLength(); +} + +ScXMLChangeTrackingImportHelper::~ScXMLChangeTrackingImportHelper() +{ +} + +void ScXMLChangeTrackingImportHelper::StartChangeAction(const ScChangeActionType nActionType) +{ + DBG_ASSERT(!pCurrentAction, "a not inserted action"); + switch (nActionType) + { + case SC_CAT_INSERT_COLS: + case SC_CAT_INSERT_ROWS: + case SC_CAT_INSERT_TABS: + { + pCurrentAction = new ScMyInsAction(nActionType); + } + break; + case SC_CAT_DELETE_COLS: + case SC_CAT_DELETE_ROWS: + case SC_CAT_DELETE_TABS: + { + pCurrentAction = new ScMyDelAction(nActionType); + } + break; + case SC_CAT_MOVE: + { + pCurrentAction = new ScMyMoveAction(); + } + break; + case SC_CAT_CONTENT: + { + pCurrentAction = new ScMyContentAction(); + } + break; + case SC_CAT_REJECT: + { + pCurrentAction = new ScMyRejAction(); + } + break; + } +} + +sal_uInt32 ScXMLChangeTrackingImportHelper::GetIDFromString(const ::rtl::OUString& sID) +{ + sal_uInt32 nResult(0); + sal_uInt32 nLength(sID.getLength()); + if (nLength) + { + if (sID.compareTo(sIDPrefix, nPrefixLength) == 0) + { + ::rtl::OUString sValue(sID.copy(nPrefixLength, nLength - nPrefixLength)); + sal_Int32 nValue; + SvXMLUnitConverter::convertNumber(nValue, sValue); + DBG_ASSERT(nValue > 0, "wrong change action ID"); + nResult = nValue; + } + else + DBG_ERROR("wrong change action ID"); + } + return nResult; +} + +void ScXMLChangeTrackingImportHelper::SetActionInfo(const ScMyActionInfo& aInfo) +{ + pCurrentAction->aInfo = aInfo; + String aUser(aInfo.sUser); + StrData* pStrData = new StrData( aUser ); + if ( !aUsers.Insert( pStrData ) ) + delete pStrData; +} + +void ScXMLChangeTrackingImportHelper::SetPreviousChange(const sal_uInt32 nPreviousAction, + ScMyCellInfo* pCellInfo) +{ + DBG_ASSERT(pCurrentAction->nActionType == SC_CAT_CONTENT, "wrong action type"); + ScMyContentAction* pAction = static_cast<ScMyContentAction*>(pCurrentAction); + pAction->nPreviousAction = nPreviousAction; + pAction->pCellInfo = pCellInfo; +} + +void ScXMLChangeTrackingImportHelper::SetPosition(const sal_Int32 nPosition, const sal_Int32 nCount, const sal_Int32 nTable) +{ + DBG_ASSERT(((pCurrentAction->nActionType != SC_CAT_MOVE) && + (pCurrentAction->nActionType != SC_CAT_CONTENT) && + (pCurrentAction->nActionType != SC_CAT_REJECT)), "wrong action type"); + DBG_ASSERT(nCount > 0, "wrong count"); + switch(pCurrentAction->nActionType) + { + case SC_CAT_INSERT_COLS: + case SC_CAT_DELETE_COLS: + { + pCurrentAction->aBigRange.Set(nPosition, nInt32Min, nTable, + nPosition + nCount - 1, nInt32Max, nTable); + } + break; + case SC_CAT_INSERT_ROWS: + case SC_CAT_DELETE_ROWS: + { + pCurrentAction->aBigRange.Set(nInt32Min, nPosition, nTable, + nInt32Max, nPosition + nCount - 1, nTable); + } + break; + case SC_CAT_INSERT_TABS: + case SC_CAT_DELETE_TABS: + { + pCurrentAction->aBigRange.Set(nInt32Min, nInt32Min, nPosition, + nInt32Max, nInt32Max, nPosition + nCount - 1); + } + break; + } +} + +void ScXMLChangeTrackingImportHelper::AddDeleted(const sal_uInt32 nID) +{ + ScMyDeleted* pDeleted = new ScMyDeleted(); + pDeleted->nID = nID; + pCurrentAction->aDeletedList.push_front(pDeleted); +} + +void ScXMLChangeTrackingImportHelper::AddDeleted(const sal_uInt32 nID, ScMyCellInfo* pCellInfo) +{ + ScMyDeleted* pDeleted = new ScMyDeleted(); + pDeleted->nID = nID; + pDeleted->pCellInfo = pCellInfo; + pCurrentAction->aDeletedList.push_front(pDeleted); +} + +void ScXMLChangeTrackingImportHelper::SetMultiSpanned(const sal_Int16 nTempMultiSpanned) +{ + if (nTempMultiSpanned) + { + DBG_ASSERT(((pCurrentAction->nActionType == SC_CAT_DELETE_COLS) || + (pCurrentAction->nActionType == SC_CAT_DELETE_ROWS)), "wrong action type"); + nMultiSpanned = nTempMultiSpanned; + nMultiSpannedSlaveCount = 0; + } +} + +void ScXMLChangeTrackingImportHelper::SetInsertionCutOff(const sal_uInt32 nID, const sal_Int32 nPosition) +{ + if ((pCurrentAction->nActionType == SC_CAT_DELETE_COLS) || + (pCurrentAction->nActionType == SC_CAT_DELETE_ROWS)) + { + static_cast<ScMyDelAction*>(pCurrentAction)->pInsCutOff = new ScMyInsertionCutOff(nID, nPosition); + } + else + DBG_ERROR("wrong action type"); +} + +void ScXMLChangeTrackingImportHelper::AddMoveCutOff(const sal_uInt32 nID, const sal_Int32 nStartPosition, const sal_Int32 nEndPosition) +{ + if ((pCurrentAction->nActionType == SC_CAT_DELETE_COLS) || + (pCurrentAction->nActionType == SC_CAT_DELETE_ROWS)) + { + static_cast<ScMyDelAction*>(pCurrentAction)->aMoveCutOffs.push_front(ScMyMoveCutOff(nID, nStartPosition, nEndPosition)); + } + else + DBG_ERROR("wrong action type"); +} + +void ScXMLChangeTrackingImportHelper::SetMoveRanges(const ScBigRange& aSourceRange, const ScBigRange& aTargetRange) +{ + if (pCurrentAction->nActionType == SC_CAT_MOVE) + { + static_cast<ScMyMoveAction*>(pCurrentAction)->pMoveRanges = new ScMyMoveRanges(aSourceRange, aTargetRange); + } + else + DBG_ERROR("wrong action type"); +} + +void ScXMLChangeTrackingImportHelper::GetMultiSpannedRange() +{ + if ((pCurrentAction->nActionType == SC_CAT_DELETE_COLS) || + (pCurrentAction->nActionType == SC_CAT_DELETE_ROWS)) + { + if (nMultiSpannedSlaveCount) + { + static_cast<ScMyDelAction*>(pCurrentAction)->nD = nMultiSpannedSlaveCount; + } + nMultiSpannedSlaveCount++; + if (nMultiSpannedSlaveCount >= nMultiSpanned) + { + nMultiSpanned = 0; + nMultiSpannedSlaveCount = 0; + } + } + else + DBG_ERROR("wrong action type"); +} + +void ScXMLChangeTrackingImportHelper::AddGenerated(ScMyCellInfo* pCellInfo, const ScBigRange& aBigRange) +{ + ScMyGenerated* pGenerated = new ScMyGenerated(pCellInfo, aBigRange); + if (pCurrentAction->nActionType == SC_CAT_MOVE) + { + static_cast<ScMyMoveAction*>(pCurrentAction)->aGeneratedList.push_back(pGenerated); + } + else if ((pCurrentAction->nActionType == SC_CAT_DELETE_COLS) || + (pCurrentAction->nActionType == SC_CAT_DELETE_ROWS)) + { + static_cast<ScMyDelAction*>(pCurrentAction)->aGeneratedList.push_back(pGenerated); + } + else + DBG_ERROR("try to insert a generated action to a wrong action"); +} + +void ScXMLChangeTrackingImportHelper::EndChangeAction() +{ + if ((pCurrentAction->nActionType == SC_CAT_DELETE_COLS) || + (pCurrentAction->nActionType == SC_CAT_DELETE_ROWS)) + GetMultiSpannedRange(); + if (pCurrentAction && pCurrentAction->nActionNumber > 0) + aActions.push_back(pCurrentAction); + else + DBG_ERROR("no current action"); + pCurrentAction = NULL; +} + +void ScXMLChangeTrackingImportHelper::ConvertInfo(const ScMyActionInfo& aInfo, String& rUser, DateTime& aDateTime) +{ + Date aDate(aInfo.aDateTime.Day, aInfo.aDateTime.Month, aInfo.aDateTime.Year); + Time aTime(aInfo.aDateTime.Hours, aInfo.aDateTime.Minutes, aInfo.aDateTime.Seconds, aInfo.aDateTime.HundredthSeconds); + aDateTime.SetDate( aDate.GetDate() ); + aDateTime.SetTime( aTime.GetTime() ); + + // #97286# old files didn't store 100th seconds, enable again + if ( aInfo.aDateTime.HundredthSeconds ) + pTrack->SetTime100thSeconds( TRUE ); + + StrData aStrData( aInfo.sUser ); + USHORT nPos; + if ( pTrack->GetUserCollection().Search( &aStrData, nPos ) ) + { + const StrData* pUser = static_cast<const StrData*>( pTrack->GetUserCollection().At( nPos ) ); + if ( pUser ) + rUser = pUser->GetString(); + else + rUser = aInfo.sUser; // shouldn't happen + } + else + rUser = aInfo.sUser; // shouldn't happen +} + +ScChangeAction* ScXMLChangeTrackingImportHelper::CreateInsertAction(ScMyInsAction* pAction) +{ + DateTime aDateTime( Date(0), Time(0) ); + String aUser; + ConvertInfo(pAction->aInfo, aUser, aDateTime); + + String sComment (pAction->aInfo.sComment); + + ScChangeAction* pNewAction = new ScChangeActionIns(pAction->nActionNumber, pAction->nActionState, pAction->nRejectingNumber, + pAction->aBigRange, aUser, aDateTime, sComment, pAction->nActionType); + return pNewAction; +} + +ScChangeAction* ScXMLChangeTrackingImportHelper::CreateDeleteAction(ScMyDelAction* pAction) +{ + DateTime aDateTime( Date(0), Time(0) ); + String aUser; + ConvertInfo(pAction->aInfo, aUser, aDateTime); + + String sComment (pAction->aInfo.sComment); + + ScChangeAction* pNewAction = new ScChangeActionDel(pAction->nActionNumber, pAction->nActionState, pAction->nRejectingNumber, + pAction->aBigRange, aUser, aDateTime, sComment, pAction->nActionType, pAction->nD, pTrack); + return pNewAction; +} + +ScChangeAction* ScXMLChangeTrackingImportHelper::CreateMoveAction(ScMyMoveAction* pAction) +{ + DBG_ASSERT(pAction->pMoveRanges, "no move ranges"); + if (pAction->pMoveRanges) + { + DateTime aDateTime( Date(0), Time(0) ); + String aUser; + ConvertInfo(pAction->aInfo, aUser, aDateTime); + + String sComment (pAction->aInfo.sComment); + + ScChangeAction* pNewAction = new ScChangeActionMove(pAction->nActionNumber, pAction->nActionState, pAction->nRejectingNumber, + pAction->pMoveRanges->aTargetRange, aUser, aDateTime, sComment, pAction->pMoveRanges->aSourceRange , pTrack); + return pNewAction; + } + return NULL; +} + +ScChangeAction* ScXMLChangeTrackingImportHelper::CreateRejectionAction(ScMyRejAction* pAction) +{ + DateTime aDateTime( Date(0), Time(0) ); + String aUser; + ConvertInfo(pAction->aInfo, aUser, aDateTime); + + String sComment (pAction->aInfo.sComment); + + ScChangeAction* pNewAction = new ScChangeActionReject(pAction->nActionNumber, pAction->nActionState, pAction->nRejectingNumber, + pAction->aBigRange, aUser, aDateTime, sComment); + return pNewAction; +} + +ScChangeAction* ScXMLChangeTrackingImportHelper::CreateContentAction(ScMyContentAction* pAction) +{ + ScBaseCell* pCell = NULL; + if (pAction->pCellInfo) + pCell = pAction->pCellInfo->CreateCell(pDoc); + + DateTime aDateTime( Date(0), Time(0) ); + String aUser; + ConvertInfo(pAction->aInfo, aUser, aDateTime); + + String sComment (pAction->aInfo.sComment); + + ScChangeAction* pNewAction = new ScChangeActionContent(pAction->nActionNumber, pAction->nActionState, pAction->nRejectingNumber, + pAction->aBigRange, aUser, aDateTime, sComment, pCell, pDoc, pAction->pCellInfo->sResult); + return pNewAction; +} + +void ScXMLChangeTrackingImportHelper::CreateGeneratedActions(ScMyGeneratedList& rList) +{ + if (!rList.empty()) + { + ScMyGeneratedList::iterator aItr = rList.begin(); + while (aItr != rList.end()) + { + if (((*aItr)->nID == 0)) + { + ScBaseCell* pCell = NULL; + if ((*aItr)->pCellInfo) + pCell = (*aItr)->pCellInfo->CreateCell(pDoc); + + if (pCell) + { + (*aItr)->nID = pTrack->AddLoadedGenerated(pCell, (*aItr)->aBigRange ); + DBG_ASSERT((*aItr)->nID, "could not insert generated action"); + } + } + aItr++; + } + } +} + +void ScXMLChangeTrackingImportHelper::SetDeletionDependences(ScMyDelAction* pAction, ScChangeActionDel* pDelAct) +{ + if (!pAction->aGeneratedList.empty()) + { + DBG_ASSERT(((pAction->nActionType == SC_CAT_DELETE_COLS) || + (pAction->nActionType == SC_CAT_DELETE_ROWS) || + (pAction->nActionType == SC_CAT_DELETE_TABS)), "wrong action type"); + if (pDelAct) + { + ScMyGeneratedList::iterator aItr = pAction->aGeneratedList.begin(); + while (aItr != pAction->aGeneratedList.end()) + { + DBG_ASSERT((*aItr)->nID, "a not inserted generated action"); + pDelAct->SetDeletedInThis((*aItr)->nID, pTrack); + if (*aItr) + delete *aItr; + aItr = pAction->aGeneratedList.erase(aItr); + } + } + } + if (pAction->pInsCutOff) + { + DBG_ASSERT(((pAction->nActionType == SC_CAT_DELETE_COLS) || + (pAction->nActionType == SC_CAT_DELETE_ROWS) || + (pAction->nActionType == SC_CAT_DELETE_TABS)), "wrong action type"); + ScChangeAction* pChangeAction = pTrack->GetAction(pAction->pInsCutOff->nID); + if (pChangeAction && pChangeAction->IsInsertType()) + { + ScChangeActionIns* pInsAction = static_cast<ScChangeActionIns*>(pChangeAction); + if (pInsAction && pDelAct) + pDelAct->SetCutOffInsert(pInsAction, static_cast<sal_Int16>(pAction->pInsCutOff->nPosition)); + } + else + DBG_ERROR("no cut off insert action"); + } + if (!pAction->aMoveCutOffs.empty()) + { + DBG_ASSERT(((pAction->nActionType == SC_CAT_DELETE_COLS) || + (pAction->nActionType == SC_CAT_DELETE_ROWS) || + (pAction->nActionType == SC_CAT_DELETE_TABS)), "wrong action type"); + ScMyMoveCutOffs::iterator aItr = pAction->aMoveCutOffs.begin(); + while(aItr != pAction->aMoveCutOffs.end()) + { + ScChangeAction* pChangeAction = pTrack->GetAction(aItr->nID); + if (pChangeAction && (pChangeAction->GetType() == SC_CAT_MOVE)) + { + ScChangeActionMove* pMoveAction = static_cast<ScChangeActionMove*>(pChangeAction); + if (pMoveAction && pDelAct) + pDelAct->AddCutOffMove(pMoveAction, static_cast<sal_Int16>(aItr->nStartPosition), + static_cast<sal_Int16>(aItr->nEndPosition)); + } + else + DBG_ERROR("no cut off move action"); + aItr = pAction->aMoveCutOffs.erase(aItr); + } + } +} + +void ScXMLChangeTrackingImportHelper::SetMovementDependences(ScMyMoveAction* pAction, ScChangeActionMove* pMoveAct) +{ + if (!pAction->aGeneratedList.empty()) + { + if (pAction->nActionType == SC_CAT_MOVE) + { + if (pMoveAct) + { + ScMyGeneratedList::iterator aItr = pAction->aGeneratedList.begin(); + while (aItr != pAction->aGeneratedList.end()) + { + DBG_ASSERT((*aItr)->nID, "a not inserted generated action"); + pMoveAct->SetDeletedInThis((*aItr)->nID, pTrack); + if (*aItr) + delete *aItr; + aItr = pAction->aGeneratedList.erase(aItr); + } + } + } + } +} + +void ScXMLChangeTrackingImportHelper::SetContentDependences(ScMyContentAction* pAction, ScChangeActionContent* pActContent) +{ + if (pAction->nPreviousAction) + { + DBG_ASSERT(pAction->nActionType == SC_CAT_CONTENT, "wrong action type"); + ScChangeAction* pPrevAct = pTrack->GetAction(pAction->nPreviousAction); + if (pPrevAct) + { + ScChangeActionContent* pPrevActContent = static_cast<ScChangeActionContent*>(pPrevAct); + if (pPrevActContent && pActContent) + { + pActContent->SetPrevContent(pPrevActContent); + pPrevActContent->SetNextContent(pActContent); + const ScBaseCell* pOldCell = pActContent->GetOldCell(); + if (pOldCell) + { + ScBaseCell* pNewCell = pOldCell->Clone(pDoc); + if (pNewCell) + pPrevActContent->SetNewCell(pNewCell, pDoc); + } + } + } + } +} + +void ScXMLChangeTrackingImportHelper::SetDependences(ScMyBaseAction* pAction) +{ + ScChangeAction* pAct = pTrack->GetAction(pAction->nActionNumber); + if (pAct) + { + if (!pAction->aDependences.empty()) + { + ScMyDependences::iterator aItr = pAction->aDependences.begin(); + while(aItr != pAction->aDependences.end()) + { + pAct->AddDependent(*aItr, pTrack); + aItr = pAction->aDependences.erase(aItr); + } + } + if (!pAction->aDeletedList.empty()) + { + ScMyDeletedList::iterator aItr = pAction->aDeletedList.begin(); + while(aItr != pAction->aDeletedList.end()) + { + pAct->SetDeletedInThis((*aItr)->nID, pTrack); + ScChangeAction* pDeletedAct = pTrack->GetAction((*aItr)->nID); + if ((pDeletedAct->GetType() == SC_CAT_CONTENT) && (*aItr)->pCellInfo) + { + ScChangeActionContent* pContentAct = static_cast<ScChangeActionContent*>(pDeletedAct); + if (pContentAct && (*aItr)->pCellInfo) + { + ScBaseCell* pCell = (*aItr)->pCellInfo->CreateCell(pDoc); + if (!ScBaseCell::CellEqual(pCell, pContentAct->GetNewCell())) + pContentAct->SetNewCell(pCell, pDoc); + } + } + if (*aItr) + delete *aItr; + aItr = pAction->aDeletedList.erase(aItr); + } + } + if ((pAction->nActionType == SC_CAT_DELETE_COLS) || + (pAction->nActionType == SC_CAT_DELETE_ROWS)) + SetDeletionDependences(static_cast<ScMyDelAction*>(pAction), static_cast<ScChangeActionDel*>(pAct)); + else if (pAction->nActionType == SC_CAT_MOVE) + SetMovementDependences(static_cast<ScMyMoveAction*>(pAction), static_cast<ScChangeActionMove*>(pAct)); + else if (pAction->nActionType == SC_CAT_CONTENT) + SetContentDependences(static_cast<ScMyContentAction*>(pAction), static_cast<ScChangeActionContent*>(pAct)); + } + else + DBG_ERROR("could not find the action"); +} + +void ScXMLChangeTrackingImportHelper::SetNewCell(ScMyContentAction* pAction) +{ + ScChangeAction* pChangeAction = pTrack->GetAction(pAction->nActionNumber); + if (pChangeAction) + { + ScChangeActionContent* pChangeActionContent = static_cast<ScChangeActionContent*>(pChangeAction); + if (pChangeActionContent) + { + if (pChangeActionContent->IsTopContent() && !pChangeActionContent->IsDeletedIn()) + { + sal_Int32 nCol, nRow, nTab, nCol2, nRow2, nTab2; + pAction->aBigRange.GetVars(nCol, nRow, nTab, nCol2, nRow2, nTab2); + if ((nCol >= 0) && (nCol <= MAXCOL) && + (nRow >= 0) && (nRow <= MAXROW) && + (nTab >= 0) && (nTab <= MAXTAB)) + { + ScAddress aAddress (static_cast<sal_uInt16>(nCol), + static_cast<sal_uInt16>(nRow), + static_cast<sal_uInt16>(nTab)); + ScBaseCell* pCell = pDoc->GetCell(aAddress); + if (pCell) + { + ScBaseCell* pNewCell = NULL; + if (pCell->GetCellType() != CELLTYPE_FORMULA) + pNewCell = pCell->Clone(pDoc); + else + { + sal_uInt8 nMatrixFlag = static_cast<ScFormulaCell*>(pCell)->GetMatrixFlag(); + String sFormula; + static_cast<ScFormulaCell*>(pCell)->GetFormula(sFormula); + ::rtl::OUString sOUFormula(sFormula); + ::rtl::OUString sOUFormula2(sOUFormula.copy(2, sOUFormula.getLength() - 3)); + String sFormula2(sOUFormula2); + pNewCell = new ScFormulaCell(pDoc, aAddress, sFormula2, nMatrixFlag); + if (pNewCell) + { + if (nMatrixFlag == MM_FORMULA) + { + sal_uInt16 nCols, nRows; + static_cast<ScFormulaCell*>(pCell)->GetMatColsRows(nCols, nRows); + static_cast<ScFormulaCell*>(pNewCell)->SetMatColsRows(nCols, nRows); + } + static_cast<ScFormulaCell*>(pNewCell)->SetInChangeTrack(sal_True); + } + } + pChangeActionContent->SetNewCell(pNewCell, pDoc); + } + } + else + DBG_ERROR("wrong cell position"); + } + } + } +} + +void ScXMLChangeTrackingImportHelper::CreateChangeTrack(ScDocument* pTempDoc) +{ + pDoc = pTempDoc; + if (pDoc) + { + pTrack = new ScChangeTrack(pDoc, aUsers); + // #97286# old files didn't store 100th seconds, disable until encountered + pTrack->SetTime100thSeconds( FALSE ); + + ScMyActions::iterator aItr = aActions.begin(); + while (aItr != aActions.end()) + { + ScChangeAction* pAction = NULL; + + switch ((*aItr)->nActionType) + { + case SC_CAT_INSERT_COLS: + case SC_CAT_INSERT_ROWS: + case SC_CAT_INSERT_TABS: + { + pAction = CreateInsertAction(static_cast<ScMyInsAction*>(*aItr)); + } + break; + case SC_CAT_DELETE_COLS: + case SC_CAT_DELETE_ROWS: + case SC_CAT_DELETE_TABS: + { + ScMyDelAction* pDelAct = static_cast<ScMyDelAction*>(*aItr); + pAction = CreateDeleteAction(pDelAct); + CreateGeneratedActions(pDelAct->aGeneratedList); + } + break; + case SC_CAT_MOVE: + { + ScMyMoveAction* pMovAct = static_cast<ScMyMoveAction*>(*aItr); + pAction = CreateMoveAction(pMovAct); + CreateGeneratedActions(pMovAct->aGeneratedList); + } + break; + case SC_CAT_CONTENT: + { + pAction = CreateContentAction(static_cast<ScMyContentAction*>(*aItr)); + } + break; + case SC_CAT_REJECT: + { + pAction = CreateRejectionAction(static_cast<ScMyRejAction*>(*aItr)); + } + break; + } + + if (pAction) + pTrack->AppendLoaded(pAction); + else + DBG_ERROR("no action"); + + aItr++; + } + if (pTrack->GetLast()) + pTrack->SetActionMax(pTrack->GetLast()->GetActionNumber()); + + aItr = aActions.begin(); + while (aItr != aActions.end()) + { + SetDependences(*aItr); + + if ((*aItr)->nActionType == SC_CAT_CONTENT) + aItr++; + else + { + if (*aItr) + delete (*aItr); + aItr = aActions.erase(aItr); + } + } + + aItr = aActions.begin(); + while (aItr != aActions.end()) + { + DBG_ASSERT((*aItr)->nActionType == SC_CAT_CONTENT, "wrong action type"); + SetNewCell(static_cast<ScMyContentAction*>(*aItr)); + if (*aItr) + delete (*aItr); + aItr = aActions.erase(aItr); + } + if (aProtect.getLength()) + pTrack->SetProtection(aProtect); + + if ( pTrack->GetLast() ) + pTrack->SetLastSavedActionNumber(pTrack->GetLast()->GetActionNumber()); + + pDoc->SetChangeTrack(pTrack); + } +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_XMLColumnRowGroupExport.cxx b/binfilter/bf_sc/source/filter/xml/sc_XMLColumnRowGroupExport.cxx new file mode 100644 index 000000000000..2e1e371bcb84 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_XMLColumnRowGroupExport.cxx @@ -0,0 +1,185 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "XMLColumnRowGroupExport.hxx" +#include "xmlexprt.hxx" + +#include <bf_xmloff/nmspmap.hxx> +#include <bf_xmloff/xmlnmspe.hxx> + +#include <algorithm> +namespace binfilter { + +using namespace xmloff::token; + +ScMyColumnRowGroup::ScMyColumnRowGroup() +{ +} + +sal_Bool ScMyColumnRowGroup::operator<(const ScMyColumnRowGroup& rGroup) const +{ + if (rGroup.nField > nField) + return sal_True; + else + if (rGroup.nField == nField && rGroup.nLevel > nLevel) + return sal_True; + else + return sal_False; +} + +ScMyOpenCloseColumnRowGroup::ScMyOpenCloseColumnRowGroup(ScXMLExport& rTempExport, sal_uInt32 nToken) + : rExport(rTempExport), + aTableStart(), + aTableEnd(), + rName(rExport.GetNamespaceMap().GetQNameByKey(XML_NAMESPACE_TABLE, GetXMLToken(XMLTokenEnum(nToken)))) +{ +} + +ScMyOpenCloseColumnRowGroup::~ScMyOpenCloseColumnRowGroup() +{ +} + +void ScMyOpenCloseColumnRowGroup::NewTable() +{ + aTableStart.clear(); + aTableEnd.clear(); +} + +void ScMyOpenCloseColumnRowGroup::AddGroup(const ScMyColumnRowGroup& aGroup, const sal_Int32 nEndField) +{ + aTableStart.push_back(aGroup); + aTableEnd.push_back(nEndField); +} + +sal_Bool ScMyOpenCloseColumnRowGroup::IsGroupStart(const sal_Int32 nField) +{ + sal_Bool bGroupStart(sal_False); + if (!aTableStart.empty()) + { + ScMyColumnRowGroupVec::iterator aItr = aTableStart.begin(); + sal_Int32 nItrField = aItr->nField; + if ( nItrField < nField ) + { + // #103327# when used to find repeated rows at the beginning of a group, + // aTableStart may contain entries before nField. They must be skipped here + // (they will be used for OpenGroups later in the right order). + + ScMyColumnRowGroupVec::iterator aEnd = aTableStart.end(); + while ( aItr != aEnd && nItrField < nField ) + { + aItr++; + if ( aItr != aEnd ) + nItrField = aItr->nField; + } + } + + if (nItrField == nField) + bGroupStart = sal_True; + } + return bGroupStart; +} + +void ScMyOpenCloseColumnRowGroup::OpenGroup(const ScMyColumnRowGroup& rGroup) +{ + if (!rGroup.bDisplay) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY, XML_FALSE); + rExport.StartElement( rName, sal_True); +} + +void ScMyOpenCloseColumnRowGroup::OpenGroups(const sal_Int32 nField) +{ + ScMyColumnRowGroupVec::iterator aItr = aTableStart.begin(); + sal_Bool bReady(sal_False); + while(!bReady && aItr != aTableStart.end()) + { + if (aItr->nField == nField) + { + OpenGroup(*aItr); + aItr = aTableStart.erase(aItr); + } + else + bReady = sal_True; + } +} + +sal_Bool ScMyOpenCloseColumnRowGroup::IsGroupEnd(const sal_Int32 nField) +{ + sal_Bool bGroupEnd(sal_False); + if (!aTableEnd.empty()) + { + if (*(aTableEnd.begin()) == nField) + bGroupEnd = sal_True; + } + return bGroupEnd; +} + +void ScMyOpenCloseColumnRowGroup::CloseGroup() +{ + rExport.EndElement( rName, sal_True ); +} + +void ScMyOpenCloseColumnRowGroup::CloseGroups(const sal_Int32 nField) +{ + ScMyFieldGroupVec::iterator aItr = aTableEnd.begin(); + sal_Bool bReady(sal_False); + while(!bReady && aItr != aTableEnd.end()) + { + if (*aItr == nField) + { + CloseGroup(); + aItr = aTableEnd.erase(aItr); + } + else + bReady = sal_True; + } +} + +sal_Int32 ScMyOpenCloseColumnRowGroup::GetLast() +{ + sal_Int32 maximum(-1); + for (ScMyFieldGroupVec::iterator i = aTableEnd.begin(); i != aTableEnd.end(); i++) + if (*i > maximum) + maximum = *i; + return maximum; +} + +void ScMyOpenCloseColumnRowGroup::Sort() +{ + aTableStart.sort(); + aTableEnd.sort(); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_XMLConsolidationContext.cxx b/binfilter/bf_sc/source/filter/xml/sc_XMLConsolidationContext.cxx new file mode 100644 index 000000000000..b020f2a3ad77 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_XMLConsolidationContext.cxx @@ -0,0 +1,166 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +//___________________________________________________________________ + +#include "XMLConsolidationContext.hxx" + +#include "document.hxx" +#include "rangeutl.hxx" +#include "xmlimprt.hxx" +#include "XMLConverter.hxx" + +#include <bf_xmloff/nmspmap.hxx> +namespace binfilter { + +using namespace ::rtl; +using namespace ::com::sun::star; +using namespace xmloff::token; + + +//___________________________________________________________________ + +ScXMLConsolidationContext::ScXMLConsolidationContext( + ScXMLImport& rImport, + USHORT nPrfx, + const OUString& rLName, + const uno::Reference< xml::sax::XAttributeList >& xAttrList ) : + SvXMLImportContext( rImport, nPrfx, rLName ), + eFunction( SUBTOTAL_FUNC_NONE ), + bLinkToSource( sal_False ), + bTargetAddr(sal_False) +{ + rImport.LockSolarMutex(); + if( !xAttrList.is() ) return; + + sal_Int16 nAttrCount = xAttrList->getLength(); + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetConsolidationAttrTokenMap(); + + for( sal_Int16 nIndex = 0; nIndex < nAttrCount; nIndex++ ) + { + OUString sAttrName = xAttrList->getNameByIndex( nIndex ); + OUString sValue = xAttrList->getValueByIndex( nIndex ); + OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_CONSOLIDATION_ATTR_FUNCTION: + eFunction = ScXMLConverter::GetSubTotalFuncFromString( sValue ); + break; + case XML_TOK_CONSOLIDATION_ATTR_SOURCE_RANGES: + sSourceList = sValue; + break; + case XML_TOK_CONSOLIDATION_ATTR_TARGET_ADDRESS: + { + sal_Int32 nOffset(0); + bTargetAddr = ScXMLConverter::GetAddressFromString( + aTargetAddr, sValue, GetScImport().GetDocument(), nOffset ); + } + break; + case XML_TOK_CONSOLIDATION_ATTR_USE_LABEL: + sUseLabel = sValue; + break; + case XML_TOK_CONSOLIDATION_ATTR_LINK_TO_SOURCE: + bLinkToSource = IsXMLToken(sValue, XML_TRUE); + break; + } + } +} + +ScXMLConsolidationContext::~ScXMLConsolidationContext() +{ +} + +SvXMLImportContext *ScXMLConsolidationContext::CreateChildContext( + USHORT nPrefix, + const OUString& rLName, + const uno::Reference< xml::sax::XAttributeList>& xAttrList ) +{ + return new SvXMLImportContext( GetImport(), nPrefix, rLName ); +} + +void ScXMLConsolidationContext::EndElement() +{ + if (bTargetAddr) + { + ScConsolidateParam aConsParam; + aConsParam.nCol = aTargetAddr.Col(); + aConsParam.nRow = aTargetAddr.Row(); + aConsParam.nTab = aTargetAddr.Tab(); + aConsParam.eFunction = eFunction; + + sal_Bool bError = sal_False; + USHORT nCount = (USHORT) Min( ScXMLConverter::GetTokenCount( sSourceList ), (sal_Int32)0xFFFF ); + ScArea** ppAreas = nCount ? new ScArea*[ nCount ] : NULL; + if( ppAreas ) + { + sal_Int32 nOffset = 0; + USHORT nIndex; + for( nIndex = 0; nIndex < nCount; nIndex++ ) + { + ppAreas[ nIndex ] = new ScArea; + if ( !ScXMLConverter::GetAreaFromString( + *ppAreas[ nIndex ], sSourceList, GetScImport().GetDocument(), nOffset ) ) + { + bError = sal_True; //! handle error + } + } + + aConsParam.SetAreas( ppAreas, nCount ); + + // array is copied in SetAreas + for( nIndex = 0; nIndex < nCount; nIndex++ ) + delete ppAreas[nIndex]; + delete[] ppAreas; + } + + aConsParam.bByCol = aConsParam.bByRow = FALSE; + if( IsXMLToken(sUseLabel, XML_COLUMN ) ) + aConsParam.bByCol = TRUE; + else if( IsXMLToken( sUseLabel, XML_ROW ) ) + aConsParam.bByRow = TRUE; + else if( IsXMLToken( sUseLabel, XML_BOTH ) ) + aConsParam.bByCol = aConsParam.bByRow = TRUE; + + aConsParam.bReferenceData = bLinkToSource; + + ScDocument* pDoc = GetScImport().GetDocument(); + if( pDoc ) + pDoc->SetConsolidateDlgData( &aConsParam ); + } + GetScImport().UnlockSolarMutex(); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_XMLConverter.cxx b/binfilter/bf_sc/source/filter/xml/sc_XMLConverter.cxx new file mode 100644 index 000000000000..1e1c1117dbad --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_XMLConverter.cxx @@ -0,0 +1,719 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + + +//___________________________________________________________________ + +#include "XMLConverter.hxx" + +#include "rangeutl.hxx" +#include "docuno.hxx" +#include "convuno.hxx" +#include "document.hxx" + +#include <tools/datetime.hxx> + +#include <bf_xmloff/xmluconv.hxx> + +namespace binfilter { + +using namespace ::rtl; +using namespace ::com::sun::star; +using namespace xmloff::token; + + +//___________________________________________________________________ + +void ScXMLConverter::AssignString( + OUString& rString, + const OUString& rNewStr, + sal_Bool bAppendStr ) +{ + if( bAppendStr ) + { + if( rNewStr.getLength() ) + { + if( rString.getLength() ) + rString += GetXMLToken( XML_WS ); + rString += rNewStr; + } + } + else + rString = rNewStr; +} + +sal_Int32 ScXMLConverter::IndexOf( + const OUString& rString, + sal_Unicode cSearchChar, + sal_Int32 nOffset, + sal_Unicode cQuote ) +{ + sal_Int32 nLength = rString.getLength(); + sal_Int32 nIndex = nOffset; + sal_Bool bQuoted = sal_False; + sal_Bool bExitLoop = sal_False; + + while( !bExitLoop && (nIndex < nLength) ) + { + sal_Unicode cCode = rString[ nIndex ]; + bExitLoop = (cCode == cSearchChar) && !bQuoted; + bQuoted = (bQuoted != (cCode == cQuote)); + if( !bExitLoop ) + nIndex++; + } + return (nIndex < nLength) ? nIndex : -1; +} + +sal_Int32 ScXMLConverter::IndexOfDifferent( + const OUString& rString, + sal_Unicode cSearchChar, + sal_Int32 nOffset ) +{ + sal_Int32 nLength = rString.getLength(); + sal_Int32 nIndex = nOffset; + sal_Bool bExitLoop = sal_False; + + while( !bExitLoop && (nIndex < nLength) ) + { + bExitLoop = (rString[ nIndex ] != cSearchChar); + if( !bExitLoop ) + nIndex++; + } + return (nIndex < nLength) ? nIndex : -1; +} + + +//___________________________________________________________________ + +void ScXMLConverter::GetTokenByOffset( + OUString& rToken, + const OUString& rString, + sal_Int32& nOffset, + sal_Unicode cQuote ) +{ + sal_Int32 nLength = rString.getLength(); + if( nOffset >= nLength ) + { + rToken = OUString(); + nOffset = -1; + } + else + { + sal_Int32 nTokenEnd = IndexOf( rString, ' ', nOffset ); + if( nTokenEnd < 0 ) + nTokenEnd = nLength; + rToken = rString.copy( nOffset, nTokenEnd - nOffset ); + + sal_Int32 nNextBegin = IndexOfDifferent( rString, ' ', nTokenEnd ); + nOffset = (nNextBegin < 0) ? nLength : nNextBegin; + } +} + +sal_Int32 ScXMLConverter::GetTokenCount( const OUString& rString ) +{ + OUString sToken; + sal_Int32 nCount = 0; + sal_Int32 nOffset = 0; + while( nOffset >= 0 ) + { + GetTokenByOffset( sToken, rString, nOffset ); + if( nOffset >= 0 ) + nCount++; + } + return nCount; +} + +ScDocument* ScXMLConverter::GetScDocument( uno::Reference< frame::XModel > xModel ) +{ + if (xModel.is()) + { + ScModelObj* pDocObj = ScModelObj::getImplementation( xModel ); + return pDocObj ? pDocObj->GetDocument() : NULL; + } + return NULL; +} + + +//___________________________________________________________________ + +sal_Bool ScXMLConverter::GetAddressFromString( + ScAddress& rAddress, + const OUString& rAddressStr, + const ScDocument* pDocument, + sal_Int32& nOffset ) +{ + OUString sToken; + GetTokenByOffset( sToken, rAddressStr, nOffset ); + if( nOffset >= 0 ) + return ((rAddress.Parse( sToken, (ScDocument*) pDocument ) & SCA_VALID) == SCA_VALID); + return sal_False; +} + +sal_Bool ScXMLConverter::GetRangeFromString( + ScRange& rRange, + const OUString& rRangeStr, + const ScDocument* pDocument, + sal_Int32& nOffset ) +{ + OUString sToken; + sal_Bool bResult(sal_False); + GetTokenByOffset( sToken, rRangeStr, nOffset ); + if( nOffset >= 0 ) + { + sal_Int32 nIndex = IndexOf( sToken, GetXMLToken(XML__COLON)[0], 0 ); + if( nIndex < 0 ) + { + bResult = ((rRange.aStart.Parse( sToken, (ScDocument*) pDocument ) & SCA_VALID) == SCA_VALID); + rRange.aEnd = rRange.aStart; + } + else + { + bResult = (((rRange.aStart.Parse( sToken.copy( 0, nIndex ), (ScDocument*) pDocument ) & SCA_VALID) == SCA_VALID) && + ((rRange.aEnd.Parse( sToken.copy( nIndex + 1 ), (ScDocument*) pDocument ) & SCA_VALID) == SCA_VALID)); + } + } + return bResult; +} + +void ScXMLConverter::GetRangeListFromString( + ScRangeList& rRangeList, + const OUString& rRangeListStr, + const ScDocument* pDocument ) +{ + DBG_ASSERT( rRangeListStr.getLength(), "ScXMLConverter::GetRangeListFromString - empty string!" ); + sal_Int32 nOffset = 0; + while( nOffset >= 0 ) + { + ScRange* pRange = new ScRange; + if( GetRangeFromString( *pRange, rRangeListStr, pDocument, nOffset ) && (nOffset >= 0) ) + rRangeList.Insert( pRange, LIST_APPEND ); + } +} + + +//___________________________________________________________________ + +sal_Bool ScXMLConverter::GetAreaFromString( + ScArea& rArea, + const OUString& rRangeStr, + const ScDocument* pDocument, + sal_Int32& nOffset ) +{ + ScRange aScRange; + sal_Bool bResult(sal_False); + if( GetRangeFromString( aScRange, rRangeStr, pDocument, nOffset ) && (nOffset >= 0) ) + { + rArea.nTab = aScRange.aStart.Tab(); + rArea.nColStart = aScRange.aStart.Col(); + rArea.nRowStart = aScRange.aStart.Row(); + rArea.nColEnd = aScRange.aEnd.Col(); + rArea.nRowEnd = aScRange.aEnd.Row(); + bResult = sal_True; + } + return bResult; +} + + +//___________________________________________________________________ + +sal_Bool ScXMLConverter::GetAddressFromString( + table::CellAddress& rAddress, + const OUString& rAddressStr, + const ScDocument* pDocument, + sal_Int32& nOffset ) +{ + ScAddress aScAddress; + sal_Bool bResult(sal_False); + if( GetAddressFromString( aScAddress, rAddressStr, pDocument, nOffset ) && (nOffset >= 0) ) + { + ScUnoConversion::FillApiAddress( rAddress, aScAddress ); + bResult = sal_True; + } + return bResult; +} + +sal_Bool ScXMLConverter::GetRangeFromString( + table::CellRangeAddress& rRange, + const OUString& rRangeStr, + const ScDocument* pDocument, + sal_Int32& nOffset ) +{ + ScRange aScRange; + sal_Bool bResult(sal_False); + if( GetRangeFromString( aScRange, rRangeStr, pDocument, nOffset ) && (nOffset >= 0) ) + { + ScUnoConversion::FillApiRange( rRange, aScRange ); + bResult = sal_True; + } + return bResult; +} + +void ScXMLConverter::GetRangeListFromString( + uno::Sequence< table::CellRangeAddress >& rRangeSeq, + const OUString& rRangeListStr, + const ScDocument* pDocument ) +{ + DBG_ASSERT( rRangeListStr.getLength(), "ScXMLConverter::GetRangeListFromString - empty string!" ); + table::CellRangeAddress aRange; + sal_Int32 nOffset = 0; + while( nOffset >= 0 ) + { + if( GetRangeFromString( aRange, rRangeListStr, pDocument, nOffset ) && (nOffset >= 0) ) + { + rRangeSeq.realloc( rRangeSeq.getLength() + 1 ); + rRangeSeq[ rRangeSeq.getLength() - 1 ] = aRange; + } + } +} + + +//___________________________________________________________________ + +void ScXMLConverter::GetStringFromAddress( + OUString& rString, + const ScAddress& rAddress, + const ScDocument* pDocument, + sal_Bool bAppendStr, + sal_uInt16 nFormatFlags ) +{ + if (pDocument && pDocument->HasTable(rAddress.Tab())) + { + String sAddress; + rAddress.Format( sAddress, nFormatFlags, (ScDocument*) pDocument ); + AssignString( rString, sAddress, bAppendStr ); + } +} + +void ScXMLConverter::GetStringFromRange( + OUString& rString, + const ScRange& rRange, + const ScDocument* pDocument, + sal_Bool bAppendStr, + sal_uInt16 nFormatFlags ) +{ + if (pDocument && pDocument->HasTable(rRange.aStart.Tab())) + { + ScAddress aStartAddress( rRange.aStart ); + ScAddress aEndAddress( rRange.aEnd ); + String sStartAddress; + String sEndAddress; + aStartAddress.Format( sStartAddress, nFormatFlags, (ScDocument*) pDocument ); + aEndAddress.Format( sEndAddress, nFormatFlags, (ScDocument*) pDocument ); + OUString sOUStartAddress( sStartAddress ); + sOUStartAddress += GetXMLToken( XML__COLON ); + sOUStartAddress += OUString( sEndAddress ); + AssignString( rString, sOUStartAddress, bAppendStr ); + } +} + +void ScXMLConverter::GetStringFromRangeList( + OUString& rString, + const ScRangeList* pRangeList, + const ScDocument* pDocument, + sal_uInt16 nFormatFlags ) +{ + OUString sRangeListStr; + if( pRangeList ) + { + sal_Int32 nCount = pRangeList->Count(); + for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ ) + { + const ScRange* pRange = pRangeList->GetObject( nIndex ); + if( pRange ) + GetStringFromRange( sRangeListStr, *pRange, pDocument, sal_True, nFormatFlags ); + } + } + rString = sRangeListStr; +} + + +//___________________________________________________________________ + +void ScXMLConverter::GetStringFromArea( + OUString& rString, + const ScArea& rArea, + const ScDocument* pDocument, + sal_Bool bAppendStr, + sal_uInt16 nFormatFlags ) +{ + ScRange aRange( rArea.nColStart, rArea.nRowStart, rArea.nTab, rArea.nColEnd, rArea.nRowEnd, rArea.nTab ); + GetStringFromRange( rString, aRange, pDocument, bAppendStr, nFormatFlags ); +} + + +//___________________________________________________________________ + +void ScXMLConverter::GetStringFromAddress( + OUString& rString, + const table::CellAddress& rAddress, + const ScDocument* pDocument, + sal_Bool bAppendStr, + sal_uInt16 nFormatFlags ) +{ + ScAddress aScAddress( static_cast<USHORT>(rAddress.Column), static_cast<USHORT>(rAddress.Row), rAddress.Sheet ); + GetStringFromAddress( rString, aScAddress, pDocument, bAppendStr, nFormatFlags ); +} + +void ScXMLConverter::GetStringFromRange( + OUString& rString, + const table::CellRangeAddress& rRange, + const ScDocument* pDocument, + sal_Bool bAppendStr, + sal_uInt16 nFormatFlags ) +{ + ScRange aScRange( static_cast<USHORT>(rRange.StartColumn), static_cast<USHORT>(rRange.StartRow), rRange.Sheet, + static_cast<USHORT>(rRange.EndColumn), static_cast<USHORT>(rRange.EndRow), rRange.Sheet ); + GetStringFromRange( rString, aScRange, pDocument, bAppendStr, nFormatFlags ); +} + +void ScXMLConverter::GetStringFromRangeList( + OUString& rString, + const uno::Sequence< table::CellRangeAddress >& rRangeSeq, + const ScDocument* pDocument, + sal_uInt16 nFormatFlags ) +{ + OUString sRangeListStr; + sal_Int32 nCount = rRangeSeq.getLength(); + for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ ) + { + const table::CellRangeAddress& rRange = rRangeSeq[ nIndex ]; + GetStringFromRange( sRangeListStr, rRange, pDocument, sal_True, nFormatFlags ); + } + rString = sRangeListStr; +} + + +//___________________________________________________________________ + +sheet::GeneralFunction ScXMLConverter::GetFunctionFromString( const OUString& sFunction ) +{ + if( IsXMLToken(sFunction, XML_SUM ) ) + return sheet::GeneralFunction_SUM; + if( IsXMLToken(sFunction, XML_AUTO ) ) + return sheet::GeneralFunction_AUTO; + if( IsXMLToken(sFunction, XML_COUNT ) ) + return sheet::GeneralFunction_COUNT; + if( IsXMLToken(sFunction, XML_COUNTNUMS ) ) + return sheet::GeneralFunction_COUNTNUMS; + if( IsXMLToken(sFunction, XML_PRODUCT ) ) + return sheet::GeneralFunction_PRODUCT; + if( IsXMLToken(sFunction, XML_AVERAGE ) ) + return sheet::GeneralFunction_AVERAGE; + if( IsXMLToken(sFunction, XML_MAX ) ) + return sheet::GeneralFunction_MAX; + if( IsXMLToken(sFunction, XML_MIN ) ) + return sheet::GeneralFunction_MIN; + if( IsXMLToken(sFunction, XML_STDEV ) ) + return sheet::GeneralFunction_STDEV; + if( IsXMLToken(sFunction, XML_STDEVP ) ) + return sheet::GeneralFunction_STDEVP; + if( IsXMLToken(sFunction, XML_VAR ) ) + return sheet::GeneralFunction_VAR; + if( IsXMLToken(sFunction, XML_VARP ) ) + return sheet::GeneralFunction_VARP; + return sheet::GeneralFunction_NONE; +} + +ScSubTotalFunc ScXMLConverter::GetSubTotalFuncFromString( const OUString& sFunction ) +{ + if( IsXMLToken(sFunction, XML_SUM ) ) + return SUBTOTAL_FUNC_SUM; + if( IsXMLToken(sFunction, XML_COUNT ) ) + return SUBTOTAL_FUNC_CNT; + if( IsXMLToken(sFunction, XML_COUNTNUMS ) ) + return SUBTOTAL_FUNC_CNT2; + if( IsXMLToken(sFunction, XML_PRODUCT ) ) + return SUBTOTAL_FUNC_PROD; + if( IsXMLToken(sFunction, XML_AVERAGE ) ) + return SUBTOTAL_FUNC_AVE; + if( IsXMLToken(sFunction, XML_MAX ) ) + return SUBTOTAL_FUNC_MAX; + if( IsXMLToken(sFunction, XML_MIN ) ) + return SUBTOTAL_FUNC_MIN; + if( IsXMLToken(sFunction, XML_STDEV ) ) + return SUBTOTAL_FUNC_STD; + if( IsXMLToken(sFunction, XML_STDEVP ) ) + return SUBTOTAL_FUNC_STDP; + if( IsXMLToken(sFunction, XML_VAR ) ) + return SUBTOTAL_FUNC_VAR; + if( IsXMLToken(sFunction, XML_VARP ) ) + return SUBTOTAL_FUNC_VARP; + return SUBTOTAL_FUNC_NONE; +} + + +//___________________________________________________________________ + +void ScXMLConverter::GetStringFromFunction( + OUString& rString, + const sheet::GeneralFunction eFunction, + sal_Bool bAppendStr ) +{ + OUString sFuncStr; + switch( eFunction ) + { + case sheet::GeneralFunction_AUTO: sFuncStr = GetXMLToken( XML_AUTO ); break; + case sheet::GeneralFunction_AVERAGE: sFuncStr = GetXMLToken( XML_AVERAGE ); break; + case sheet::GeneralFunction_COUNT: sFuncStr = GetXMLToken( XML_COUNT ); break; + case sheet::GeneralFunction_COUNTNUMS: sFuncStr = GetXMLToken( XML_COUNTNUMS ); break; + case sheet::GeneralFunction_MAX: sFuncStr = GetXMLToken( XML_MAX ); break; + case sheet::GeneralFunction_MIN: sFuncStr = GetXMLToken( XML_MIN ); break; + case sheet::GeneralFunction_NONE: sFuncStr = GetXMLToken( XML_NONE ); break; + case sheet::GeneralFunction_PRODUCT: sFuncStr = GetXMLToken( XML_PRODUCT ); break; + case sheet::GeneralFunction_STDEV: sFuncStr = GetXMLToken( XML_STDEV ); break; + case sheet::GeneralFunction_STDEVP: sFuncStr = GetXMLToken( XML_STDEVP ); break; + case sheet::GeneralFunction_SUM: sFuncStr = GetXMLToken( XML_SUM ); break; + case sheet::GeneralFunction_VAR: sFuncStr = GetXMLToken( XML_VAR ); break; + case sheet::GeneralFunction_VARP: sFuncStr = GetXMLToken( XML_VARP ); break; + } + AssignString( rString, sFuncStr, bAppendStr ); +} + +void ScXMLConverter::GetStringFromFunction( + OUString& rString, + const ScSubTotalFunc eFunction, + sal_Bool bAppendStr ) +{ + OUString sFuncStr; + switch( eFunction ) + { + case SUBTOTAL_FUNC_AVE: sFuncStr = GetXMLToken( XML_AVERAGE ); break; + case SUBTOTAL_FUNC_CNT: sFuncStr = GetXMLToken( XML_COUNT ); break; + case SUBTOTAL_FUNC_CNT2: sFuncStr = GetXMLToken( XML_COUNTNUMS ); break; + case SUBTOTAL_FUNC_MAX: sFuncStr = GetXMLToken( XML_MAX ); break; + case SUBTOTAL_FUNC_MIN: sFuncStr = GetXMLToken( XML_MIN ); break; + case SUBTOTAL_FUNC_NONE: sFuncStr = GetXMLToken( XML_NONE ); break; + case SUBTOTAL_FUNC_PROD: sFuncStr = GetXMLToken( XML_PRODUCT ); break; + case SUBTOTAL_FUNC_STD: sFuncStr = GetXMLToken( XML_STDEV ); break; + case SUBTOTAL_FUNC_STDP: sFuncStr = GetXMLToken( XML_STDEVP ); break; + case SUBTOTAL_FUNC_SUM: sFuncStr = GetXMLToken( XML_SUM ); break; + case SUBTOTAL_FUNC_VAR: sFuncStr = GetXMLToken( XML_VAR ); break; + case SUBTOTAL_FUNC_VARP: sFuncStr = GetXMLToken( XML_VARP ); break; + } + AssignString( rString, sFuncStr, bAppendStr ); +} + + +//___________________________________________________________________ + +sheet::DataPilotFieldOrientation ScXMLConverter::GetOrientationFromString( + const OUString& rString ) +{ + if( IsXMLToken(rString, XML_COLUMN ) ) + return sheet::DataPilotFieldOrientation_COLUMN; + if( IsXMLToken(rString, XML_ROW ) ) + return sheet::DataPilotFieldOrientation_ROW; + if( IsXMLToken(rString, XML_PAGE ) ) + return sheet::DataPilotFieldOrientation_PAGE; + if( IsXMLToken(rString, XML_DATA ) ) + return sheet::DataPilotFieldOrientation_DATA; + return sheet::DataPilotFieldOrientation_HIDDEN; +} + + +//___________________________________________________________________ + +void ScXMLConverter::GetStringFromOrientation( + OUString& rString, + const sheet::DataPilotFieldOrientation eOrientation, + sal_Bool bAppendStr ) +{ + OUString sOrientStr; + switch( eOrientation ) + { + case sheet::DataPilotFieldOrientation_HIDDEN: + sOrientStr = GetXMLToken( XML_HIDDEN ); + break; + case sheet::DataPilotFieldOrientation_COLUMN: + sOrientStr = GetXMLToken( XML_COLUMN ); + break; + case sheet::DataPilotFieldOrientation_ROW: + sOrientStr = GetXMLToken( XML_ROW ); + break; + case sheet::DataPilotFieldOrientation_PAGE: + sOrientStr = GetXMLToken( XML_PAGE ); + break; + case sheet::DataPilotFieldOrientation_DATA: + sOrientStr = GetXMLToken( XML_DATA ); + break; + } + AssignString( rString, sOrientStr, bAppendStr ); +} + + +//___________________________________________________________________ + +ScDetectiveObjType ScXMLConverter::GetDetObjTypeFromString( const OUString& rString ) +{ + if( IsXMLToken(rString, XML_FROM_SAME_TABLE ) ) + return SC_DETOBJ_ARROW; + if( IsXMLToken(rString, XML_FROM_ANOTHER_TABLE ) ) + return SC_DETOBJ_FROMOTHERTAB; + if( IsXMLToken(rString, XML_TO_ANOTHER_TABLE ) ) + return SC_DETOBJ_TOOTHERTAB; + return SC_DETOBJ_NONE; +} + +sal_Bool ScXMLConverter::GetDetOpTypeFromString( ScDetOpType& rDetOpType, const OUString& rString ) +{ + if( IsXMLToken(rString, XML_TRACE_DEPENDENTS ) ) + rDetOpType = SCDETOP_ADDSUCC; + else if( IsXMLToken(rString, XML_TRACE_PRECEDENTS ) ) + rDetOpType = SCDETOP_ADDPRED; + else if( IsXMLToken(rString, XML_TRACE_ERRORS ) ) + rDetOpType = SCDETOP_ADDERROR; + else if( IsXMLToken(rString, XML_REMOVE_DEPENDENTS ) ) + rDetOpType = SCDETOP_DELSUCC; + else if( IsXMLToken(rString, XML_REMOVE_PRECEDENTS ) ) + rDetOpType = SCDETOP_DELPRED; + else + return sal_False; + return sal_True; +} + + +//___________________________________________________________________ + +void ScXMLConverter::GetStringFromDetObjType( + OUString& rString, + const ScDetectiveObjType eObjType, + sal_Bool bAppendStr ) +{ + OUString sTypeStr; + switch( eObjType ) + { + case SC_DETOBJ_ARROW: + sTypeStr = GetXMLToken( XML_FROM_SAME_TABLE ); + break; + case SC_DETOBJ_FROMOTHERTAB: + sTypeStr = GetXMLToken( XML_FROM_ANOTHER_TABLE ); + break; + case SC_DETOBJ_TOOTHERTAB: + sTypeStr = GetXMLToken( XML_TO_ANOTHER_TABLE ); + break; + } + AssignString( rString, sTypeStr, bAppendStr ); +} + +void ScXMLConverter::GetStringFromDetOpType( + OUString& rString, + const ScDetOpType eOpType, + sal_Bool bAppendStr ) +{ + OUString sTypeStr; + switch( eOpType ) + { + case SCDETOP_ADDSUCC: + sTypeStr = GetXMLToken( XML_TRACE_DEPENDENTS ); + break; + case SCDETOP_ADDPRED: + sTypeStr = GetXMLToken( XML_TRACE_PRECEDENTS ); + break; + case SCDETOP_ADDERROR: + sTypeStr = GetXMLToken( XML_TRACE_ERRORS ); + break; + case SCDETOP_DELSUCC: + sTypeStr = GetXMLToken( XML_REMOVE_DEPENDENTS ); + break; + case SCDETOP_DELPRED: + sTypeStr = GetXMLToken( XML_REMOVE_PRECEDENTS ); + break; + } + AssignString( rString, sTypeStr, bAppendStr ); +} + + +//___________________________________________________________________ + +void ScXMLConverter::ParseFormula(OUString& sFormula, const sal_Bool bIsFormula) +{ + OUStringBuffer sBuffer(sFormula.getLength()); + sal_Bool bInQuotationMarks(sal_False); + sal_Bool bInDoubleQuotationMarks(sal_False); + sal_Int16 nCountBraces(0); + sal_Unicode chPrevious('='); + for (sal_Int32 i = 0; i < sFormula.getLength(); i++) + { + if (sFormula[i] == '\'' && !bInDoubleQuotationMarks && + chPrevious != '\\') + bInQuotationMarks = !bInQuotationMarks; + else if (sFormula[i] == '"' && !bInQuotationMarks) + bInDoubleQuotationMarks = !bInDoubleQuotationMarks; + if (bInQuotationMarks || bInDoubleQuotationMarks) + sBuffer.append(sFormula[i]); + else if (sFormula[i] == '[') + nCountBraces++; + else if (sFormula[i] == ']') + nCountBraces--; + else if ((sFormula[i] != '.') || + ((nCountBraces == 0) && bIsFormula) || + !((chPrevious == '[') || (chPrevious == ':') || (chPrevious == ' ') || (chPrevious == '='))) + sBuffer.append(sFormula[i]); + chPrevious = sFormula[i]; + } + + DBG_ASSERT(nCountBraces == 0, "there are some braces still open"); + sFormula = sBuffer.makeStringAndClear(); +} + + +//_____________________________________________________________________ + +void ScXMLConverter::ConvertDateTimeToString(const DateTime& aDateTime, ::rtl::OUStringBuffer& sDate) +{ + util::DateTime aAPIDateTime; + ConvertCoreToAPIDateTime(aDateTime, aAPIDateTime); + SvXMLUnitConverter::convertDateTime(sDate, aAPIDateTime); +} + +void ScXMLConverter::ConvertCoreToAPIDateTime(const DateTime& aDateTime, util::DateTime& rDateTime) +{ + rDateTime.Year = aDateTime.GetYear(); + rDateTime.Month = aDateTime.GetMonth(); + rDateTime.Day = aDateTime.GetDay(); + rDateTime.Hours = aDateTime.GetHour(); + rDateTime.Minutes = aDateTime.GetMin(); + rDateTime.Seconds = aDateTime.GetSec(); + rDateTime.HundredthSeconds = aDateTime.Get100Sec(); +} + +void ScXMLConverter::ConvertAPIToCoreDateTime(const util::DateTime& aDateTime, DateTime& rDateTime) +{ + Date aDate(aDateTime.Day, aDateTime.Month, aDateTime.Year); + Time aTime(aDateTime.Hours, aDateTime.Minutes, aDateTime.Seconds, aDateTime.HundredthSeconds); + DateTime aTempDateTime (aDate, aTime); + rDateTime = aTempDateTime; +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_XMLDDELinksContext.cxx b/binfilter/bf_sc/source/filter/xml/sc_XMLDDELinksContext.cxx new file mode 100644 index 000000000000..fd9838367ad1 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_XMLDDELinksContext.cxx @@ -0,0 +1,471 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "XMLDDELinksContext.hxx" +#include "xmlimprt.hxx" +#include "document.hxx" + +#include <bf_xmloff/xmlnmspe.hxx> +#include <bf_xmloff/nmspmap.hxx> +#include <bf_xmloff/xmluconv.hxx> + +#include <tools/debug.hxx> +namespace binfilter { + +using namespace ::com::sun::star; +using namespace xmloff::token; + +using rtl::OUString; + +//------------------------------------------------------------------ + +ScXMLDDELinksContext::ScXMLDDELinksContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + // here are no attributes + rImport.LockSolarMutex(); +} + +ScXMLDDELinksContext::~ScXMLDDELinksContext() +{ + GetScImport().UnlockSolarMutex(); +} + +SvXMLImportContext *ScXMLDDELinksContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if ((nPrefix == XML_NAMESPACE_TABLE) && IsXMLToken(rLName, XML_DDE_LINK)) + pContext = new ScXMLDDELinkContext(GetScImport(), nPrefix, rLName, xAttrList); + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLDDELinksContext::EndElement() +{ +} + +ScXMLDDELinkContext::ScXMLDDELinkContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList) : + SvXMLImportContext( rImport, nPrfx, rLName ), + aDDELinkTable(), + aDDELinkRow(), + sApplication(), + sTopic(), + sItem(), + nMode(SC_DDE_DEFAULT), + nPosition(-1), + nColumns(0), + nRows(0) +{ + // here are no attributes +} + +ScXMLDDELinkContext::~ScXMLDDELinkContext() +{ +} + +SvXMLImportContext *ScXMLDDELinkContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if ((nPrefix == XML_NAMESPACE_OFFICE) && IsXMLToken(rLName, XML_DDE_SOURCE)) + pContext = new ScXMLDDESourceContext(GetScImport(), nPrefix, rLName, xAttrList, this); + else if ((nPrefix == XML_NAMESPACE_TABLE) && IsXMLToken(rLName, XML_TABLE)) + pContext = new ScXMLDDETableContext(GetScImport(), nPrefix, rLName, xAttrList, this); + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLDDELinkContext::CreateDDELink() +{ + if (GetScImport().GetDocument() && + sApplication.getLength() && + sTopic.getLength() && + sItem.getLength()) + { + String sAppl(sApplication); + String sTop(sTopic); + String sIt(sItem); + GetScImport().GetDocument()->CreateDdeLink(sAppl, sTop, sIt, nMode); + sal_uInt16 nPos; + if(GetScImport().GetDocument()->FindDdeLink(sAppl, sTop, sIt, nMode, nPos)) + nPosition = nPos; + else + nPosition = -1; + DBG_ASSERT(nPosition > -1, "DDE Link not inserted"); + } +} + +void ScXMLDDELinkContext::AddCellToRow(const ScDDELinkCell& aCell) +{ + aDDELinkRow.push_back(aCell); +} + +void ScXMLDDELinkContext::AddRowsToTable(const sal_Int32 nRows) +{ + for (sal_Int32 i = 0; i < nRows; i++) + aDDELinkTable.insert(aDDELinkTable.end(), aDDELinkRow.begin(), aDDELinkRow.end()); + aDDELinkRow.clear(); +} + +void ScXMLDDELinkContext::EndElement() +{ + if (nPosition > -1 && nColumns && nRows) + { + ScMatrix* pMatrix; + if (GetScImport().GetDocument() && + GetScImport().GetDocument()->CreateDdeLinkResultDimension(static_cast<USHORT>(nPosition), + static_cast<USHORT>(nColumns), static_cast<USHORT>(nRows), pMatrix)) + { + if (pMatrix) + { + DBG_ASSERT(static_cast<sal_uInt32>(nColumns * nRows) == aDDELinkTable.size(), "there is a wrong cells count"); + sal_Int32 nCol(0); + sal_Int32 nRow(-1); + sal_Int32 nIndex(0); + for (ScDDELinkCells::iterator aItr = aDDELinkTable.begin(); aItr != aDDELinkTable.end(); aItr++) + { + if (nIndex % nColumns == 0) + { + nRow++; + nCol = 0; + } + else + nCol++; + String sValue(aItr->sValue); + GetScImport().GetDocument()->SetDdeLinkResult(pMatrix, static_cast<USHORT>(nCol), static_cast<USHORT>(nRow), + sValue, aItr->fValue, aItr->bString, aItr->bEmpty); + nIndex++; + } + } + } + } +} + +ScXMLDDESourceContext::ScXMLDDESourceContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDDELinkContext* pTempDDELink) : + SvXMLImportContext( rImport, nPrfx, rLName ), + pDDELink(pTempDDELink) +{ + if( !xAttrList.is() ) return; + + sal_Int16 nAttrCount = xAttrList->getLength(); + + for( sal_Int16 nIndex = 0; nIndex < nAttrCount; nIndex++ ) + { + OUString sAttrName = xAttrList->getNameByIndex( nIndex ); + OUString sValue = xAttrList->getValueByIndex( nIndex ); + OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); + + if (nPrefix == XML_NAMESPACE_OFFICE) + { + if (IsXMLToken(aLocalName, XML_DDE_APPLICATION)) + pDDELink->SetApplication(sValue); + else if (IsXMLToken(aLocalName, XML_DDE_TOPIC)) + pDDELink->SetTopic(sValue); + else if (IsXMLToken(aLocalName, XML_DDE_ITEM)) + pDDELink->SetItem(sValue); + } + else if ((nPrefix == XML_NAMESPACE_TABLE) && IsXMLToken(aLocalName, XML_CONVERSION_MODE)) + if (IsXMLToken(sValue, XML_INTO_ENGLISH_NUMBER)) + pDDELink->SetMode(SC_DDE_ENGLISH); + else if (IsXMLToken(sValue, XML_LET_TEXT)) + pDDELink->SetMode(SC_DDE_TEXT); + else + pDDELink->SetMode(SC_DDE_DEFAULT); + } +} + +ScXMLDDESourceContext::~ScXMLDDESourceContext() +{ +} + +SvXMLImportContext *ScXMLDDESourceContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLDDESourceContext::EndElement() +{ + pDDELink->CreateDDELink(); +} + +ScXMLDDETableContext::ScXMLDDETableContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDDELinkContext* pTempDDELink) : + SvXMLImportContext( rImport, nPrfx, rLName ), + pDDELink(pTempDDELink) +{ + // here are no attributes +} + +ScXMLDDETableContext::~ScXMLDDETableContext() +{ +} + +SvXMLImportContext *ScXMLDDETableContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = NULL; + + if (nPrefix == XML_NAMESPACE_TABLE) + if (IsXMLToken(rLName, XML_TABLE_COLUMN)) + pContext = new ScXMLDDEColumnContext(GetScImport(), nPrefix, rLName, xAttrList, pDDELink); + else if (IsXMLToken(rLName, XML_TABLE_ROW)) + pContext = new ScXMLDDERowContext(GetScImport(), nPrefix, rLName, xAttrList, pDDELink); + + if (!pContext) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLDDETableContext::EndElement() +{ +} + +ScXMLDDEColumnContext::ScXMLDDEColumnContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDDELinkContext* pTempDDELink) : + SvXMLImportContext( rImport, nPrfx, rLName ), + pDDELink(pTempDDELink) +{ + if( !xAttrList.is() ) return; + sal_Int32 nCols(1); + + sal_Int16 nAttrCount = xAttrList->getLength(); + + for( sal_Int16 nIndex = 0; nIndex < nAttrCount; nIndex++ ) + { + OUString sAttrName = xAttrList->getNameByIndex( nIndex ); + OUString sValue = xAttrList->getValueByIndex( nIndex ); + OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); + + if (nPrefix == XML_NAMESPACE_TABLE) + if (IsXMLToken(aLocalName, XML_NUMBER_COLUMNS_REPEATED)) + GetScImport().GetMM100UnitConverter().convertNumber(nCols, sValue); + } + pDDELink->AddColumns(nCols); +} + +ScXMLDDEColumnContext::~ScXMLDDEColumnContext() +{ +} + +SvXMLImportContext *ScXMLDDEColumnContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLDDEColumnContext::EndElement() +{ +} + +ScXMLDDERowContext::ScXMLDDERowContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDDELinkContext* pTempDDELink) : + SvXMLImportContext( rImport, nPrfx, rLName ), + pDDELink(pTempDDELink), + nRows(1) +{ + if( !xAttrList.is() ) return; + + sal_Int16 nAttrCount = xAttrList->getLength(); + + for( sal_Int16 nIndex = 0; nIndex < nAttrCount; nIndex++ ) + { + OUString sAttrName = xAttrList->getNameByIndex( nIndex ); + OUString sValue = xAttrList->getValueByIndex( nIndex ); + OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); + + if (nPrefix == XML_NAMESPACE_TABLE) + if (IsXMLToken(aLocalName, XML_NUMBER_ROWS_REPEATED)) + GetScImport().GetMM100UnitConverter().convertNumber(nRows, sValue); + } + pDDELink->AddRows(nRows); +} + +ScXMLDDERowContext::~ScXMLDDERowContext() +{ +} + +SvXMLImportContext *ScXMLDDERowContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = NULL; + + if (nPrefix == XML_NAMESPACE_TABLE) + if (IsXMLToken(rLName, XML_TABLE_CELL)) + pContext = new ScXMLDDECellContext(GetScImport(), nPrefix, rLName, xAttrList, pDDELink); + + if (!pContext) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLDDERowContext::EndElement() +{ + pDDELink->AddRowsToTable(nRows); +} + +ScXMLDDECellContext::ScXMLDDECellContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDDELinkContext* pTempDDELink) : + SvXMLImportContext( rImport, nPrfx, rLName ), + pDDELink(pTempDDELink), + sValue(), + fValue(), + nCells(1), + bString(sal_True), + bString2(sal_True), + bEmpty(sal_True) +{ + if( !xAttrList.is() ) return; + + sal_Int16 nAttrCount = xAttrList->getLength(); + + for( sal_Int16 nIndex = 0; nIndex < nAttrCount; nIndex++ ) + { + OUString sAttrName = xAttrList->getNameByIndex( nIndex ); + OUString sTempValue = xAttrList->getValueByIndex( nIndex ); + OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); + + if (nPrefix == XML_NAMESPACE_TABLE) + if (IsXMLToken(aLocalName, XML_VALUE_TYPE)) + { + if (IsXMLToken(sTempValue, XML_STRING)) + bString = sal_True; + else + bString = sal_False; + } + else if (IsXMLToken(aLocalName, XML_STRING_VALUE)) + { + sValue = sTempValue; + bEmpty = sal_False; + bString2 = sal_True; + } + else if (IsXMLToken(aLocalName, XML_VALUE)) + { + GetScImport().GetMM100UnitConverter().convertDouble(fValue, sTempValue); + bEmpty = sal_False; + bString2 = sal_False; + } + else if (IsXMLToken(aLocalName, XML_NUMBER_COLUMNS_REPEATED)) + GetScImport().GetMM100UnitConverter().convertNumber(nCells, sTempValue); + } +} + +ScXMLDDECellContext::~ScXMLDDECellContext() +{ +} + +SvXMLImportContext *ScXMLDDECellContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLDDECellContext::EndElement() +{ + DBG_ASSERT(bString == bString2, "something wrong with this type"); + ScDDELinkCell aCell; + aCell.sValue = sValue; + aCell.fValue = fValue; + aCell.bEmpty = bEmpty; + aCell.bString = bString2; + for(sal_Int32 i = 0; i < nCells; i++) + pDDELink->AddCellToRow(aCell); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_XMLDetectiveContext.cxx b/binfilter/bf_sc/source/filter/xml/sc_XMLDetectiveContext.cxx new file mode 100644 index 000000000000..7cfd4b2e41dd --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_XMLDetectiveContext.cxx @@ -0,0 +1,269 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +//___________________________________________________________________ + + +#include <bf_xmloff/nmspmap.hxx> +#include <bf_xmloff/xmluconv.hxx> + +#include "convuno.hxx" +#include "xmlimprt.hxx" +#include "XMLConverter.hxx" + +#include <algorithm> +namespace binfilter { + +using namespace ::rtl; +using namespace ::com::sun::star; +using namespace xmloff::token; + + +//___________________________________________________________________ + +ScMyImpDetectiveObj::ScMyImpDetectiveObj() : + aSourceRange(), + eObjType( SC_DETOBJ_NONE ), + bHasError( sal_False ) +{ +} + +//___________________________________________________________________ + +sal_Bool ScMyImpDetectiveOp::operator<(const ScMyImpDetectiveOp& rDetOp) const +{ + return (nIndex < rDetOp.nIndex); +} + +void ScMyImpDetectiveOpArray::Sort() +{ + aDetectiveOpList.sort(); +} + +sal_Bool ScMyImpDetectiveOpArray::GetFirstOp( ScMyImpDetectiveOp& rDetOp ) +{ + if( aDetectiveOpList.empty() ) + return sal_False; + ScMyImpDetectiveOpList::iterator aItr = aDetectiveOpList.begin(); + rDetOp = *aItr; + aDetectiveOpList.erase( aItr ); + return sal_True; +} + + +//___________________________________________________________________ + +ScXMLDetectiveContext::ScXMLDetectiveContext( + ScXMLImport& rImport, + USHORT nPrfx, + const OUString& rLName, + ScMyImpDetectiveObjVec* pNewDetectiveObjVec ) : + SvXMLImportContext( rImport, nPrfx, rLName ), + pDetectiveObjVec( pNewDetectiveObjVec ) +{ +} + +ScXMLDetectiveContext::~ScXMLDetectiveContext() +{ +} + +SvXMLImportContext *ScXMLDetectiveContext::CreateChildContext( + USHORT nPrefix, + const OUString& rLName, + const uno::Reference< xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext* pContext = NULL; + const SvXMLTokenMap& rTokenMap = GetScImport().GetDetectiveElemTokenMap(); + + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + case XML_TOK_DETECTIVE_ELEM_HIGHLIGHTED: + pContext = new ScXMLDetectiveHighlightedContext( GetScImport(), nPrefix, rLName, xAttrList, pDetectiveObjVec ); + break; + case XML_TOK_DETECTIVE_ELEM_OPERATION: + pContext = new ScXMLDetectiveOperationContext( GetScImport(), nPrefix, rLName, xAttrList ); + break; + } + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLDetectiveContext::EndElement() +{ +} + + +//___________________________________________________________________ + +ScXMLDetectiveHighlightedContext::ScXMLDetectiveHighlightedContext( + ScXMLImport& rImport, + USHORT nPrfx, + const OUString& rLName, + const uno::Reference< xml::sax::XAttributeList >& xAttrList, + ScMyImpDetectiveObjVec* pNewDetectiveObjVec ): + SvXMLImportContext( rImport, nPrfx, rLName ), + pDetectiveObjVec( pNewDetectiveObjVec ), + aDetectiveObj(), + bValid( sal_False ) +{ + if( !xAttrList.is() ) return; + + sal_Int16 nAttrCount = xAttrList->getLength(); + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDetectiveHighlightedAttrTokenMap(); + + for( sal_Int16 nIndex = 0; nIndex < nAttrCount; nIndex++ ) + { + OUString sAttrName = xAttrList->getNameByIndex( nIndex ); + OUString sValue = xAttrList->getValueByIndex( nIndex ); + OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_DETECTIVE_HIGHLIGHTED_ATTR_CELL_RANGE: + { + sal_Int32 nOffset(0); + GetScImport().LockSolarMutex(); + bValid = ScXMLConverter::GetRangeFromString( aDetectiveObj.aSourceRange, sValue, GetScImport().GetDocument(), nOffset ); + GetScImport().UnlockSolarMutex(); + } + break; + case XML_TOK_DETECTIVE_HIGHLIGHTED_ATTR_DIRECTION: + aDetectiveObj.eObjType = ScXMLConverter::GetDetObjTypeFromString( sValue ); + break; + case XML_TOK_DETECTIVE_HIGHLIGHTED_ATTR_CONTAINS_ERROR: + aDetectiveObj.bHasError = IsXMLToken(sValue, XML_TRUE); + break; + case XML_TOK_DETECTIVE_HIGHLIGHTED_ATTR_MARKED_INVALID: + { + if (IsXMLToken(sValue, XML_TRUE)) + aDetectiveObj.eObjType = SC_DETOBJ_CIRCLE; + } + break; + } + } +} + +ScXMLDetectiveHighlightedContext::~ScXMLDetectiveHighlightedContext() +{ +} + +SvXMLImportContext *ScXMLDetectiveHighlightedContext::CreateChildContext( + USHORT nPrefix, + const OUString& rLName, + const uno::Reference< xml::sax::XAttributeList>& xAttrList ) +{ + return new SvXMLImportContext( GetImport(), nPrefix, rLName ); +} + +void ScXMLDetectiveHighlightedContext::EndElement() +{ + switch( aDetectiveObj.eObjType ) + { + case SC_DETOBJ_ARROW: + case SC_DETOBJ_TOOTHERTAB: + break; + case SC_DETOBJ_FROMOTHERTAB: + case SC_DETOBJ_CIRCLE: + bValid = sal_True; + break; + default: + bValid = sal_False; + } + if( bValid ) + pDetectiveObjVec->push_back( aDetectiveObj ); +} + + +//___________________________________________________________________ + +ScXMLDetectiveOperationContext::ScXMLDetectiveOperationContext( + ScXMLImport& rImport, + USHORT nPrfx, + const OUString& rLName, + const uno::Reference< xml::sax::XAttributeList >& xAttrList ) : + SvXMLImportContext( rImport, nPrfx, rLName ), + aDetectiveOp(), + bHasType( sal_False ) +{ + if( !xAttrList.is() ) return; + + sal_Int16 nAttrCount = xAttrList->getLength(); + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDetectiveOperationAttrTokenMap(); + + for( sal_Int16 nIndex = 0; nIndex < nAttrCount; nIndex++ ) + { + OUString sAttrName = xAttrList->getNameByIndex( nIndex ); + OUString sValue = xAttrList->getValueByIndex( nIndex ); + OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_DETECTIVE_OPERATION_ATTR_NAME: + bHasType = ScXMLConverter::GetDetOpTypeFromString( aDetectiveOp.eOpType, sValue ); + break; + case XML_TOK_DETECTIVE_OPERATION_ATTR_INDEX: + { + sal_Int32 nValue; + if( SvXMLUnitConverter::convertNumber( nValue, sValue, 0 ) ) + aDetectiveOp.nIndex = nValue; + } + break; + } + } + ScUnoConversion::FillScAddress( aDetectiveOp.aPosition, rImport.GetTables().GetRealCellPos() ); +} + +ScXMLDetectiveOperationContext::~ScXMLDetectiveOperationContext() +{ +} + +SvXMLImportContext *ScXMLDetectiveOperationContext::CreateChildContext( + USHORT nPrefix, + const OUString& rLName, + const uno::Reference< xml::sax::XAttributeList>& xAttrList ) +{ + return new SvXMLImportContext( GetImport(), nPrefix, rLName ); +} + +void ScXMLDetectiveOperationContext::EndElement() +{ + if( bHasType && (aDetectiveOp.nIndex >= 0) ) + GetScImport().GetDetectiveOpArray()->AddDetectiveOp( aDetectiveOp ); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_XMLEmptyContext.cxx b/binfilter/bf_sc/source/filter/xml/sc_XMLEmptyContext.cxx new file mode 100644 index 000000000000..21f7ad1a87b4 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_XMLEmptyContext.cxx @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "XMLEmptyContext.hxx" +#include "xmlimprt.hxx" +namespace binfilter { + +//------------------------------------------------------------------ + +ScXMLEmptyContext::ScXMLEmptyContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ +} + +ScXMLEmptyContext::~ScXMLEmptyContext() +{ +} + +SvXMLImportContext *ScXMLEmptyContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = new ScXMLEmptyContext(GetScImport(), nPrefix, rLName); + + return pContext; +} + +void ScXMLEmptyContext::EndElement() +{ +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_XMLExportDDELinks.cxx b/binfilter/bf_sc/source/filter/xml/sc_XMLExportDDELinks.cxx new file mode 100644 index 000000000000..a36095d0a597 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_XMLExportDDELinks.cxx @@ -0,0 +1,209 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "XMLExportDDELinks.hxx" + +#include <bf_xmloff/xmlnmspe.hxx> +#include <bf_xmloff/xmluconv.hxx> + +#include "xmlexprt.hxx" +#include "unonames.hxx" +#include "document.hxx" + +#include <com/sun/star/sheet/XDDELink.hpp> +namespace binfilter { + +class ScMatrix; + +using namespace ::com::sun::star; +using namespace xmloff::token; + +ScXMLExportDDELinks::ScXMLExportDDELinks(ScXMLExport& rTempExport) + : rExport(rTempExport) +{ +} + +ScXMLExportDDELinks::~ScXMLExportDDELinks() +{ +} + +sal_Bool ScXMLExportDDELinks::CellsEqual(const sal_Bool bPrevEmpty, const sal_Bool bPrevString, const String& sPrevValue, const double& fPrevValue, + const sal_Bool bEmpty, const sal_Bool bString, const String& sValue, const double& fValue) +{ + if (bEmpty == bPrevEmpty) + if (bEmpty) + return sal_True; + else if (bString == bPrevString) + if (bString) + return (sPrevValue == sValue); + else + return (fPrevValue == fValue); + else + return sal_False; + else + return sal_False; +} + +void ScXMLExportDDELinks::WriteCell(const sal_Bool bEmpty, const sal_Bool bString, const String& sValue, const double& fValue, const sal_Int32 nRepeat) +{ + ::rtl::OUStringBuffer sBuffer; + if (!bEmpty) + if (bString) + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_VALUE_TYPE, XML_STRING); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_STRING_VALUE, ::rtl::OUString(sValue)); + } + else + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_VALUE_TYPE, XML_FLOAT); + rExport.GetMM100UnitConverter().convertDouble(sBuffer, fValue); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_VALUE, sBuffer.makeStringAndClear()); + } + if (nRepeat > 1) + { + rExport.GetMM100UnitConverter().convertNumber(sBuffer, nRepeat); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED, sBuffer.makeStringAndClear()); + } + SvXMLElementExport(rExport, XML_NAMESPACE_TABLE, XML_TABLE_CELL, sal_True, sal_True); +} + +void ScXMLExportDDELinks::WriteTable(const sal_Int32 nPos) +{ + sal_Int32 nRowCount; + sal_Int32 nColCount; + ScMatrix* pMatrix = NULL; + sal_uInt16 nuRow, nuCol; + if (rExport.GetDocument() && + rExport.GetDocument()->GetDdeLinkResultDimension(static_cast<USHORT>(nPos), nuCol, nuRow, pMatrix)) + { + nRowCount = nuRow; + nColCount = nuCol; + SvXMLElementExport aTableElem(rExport, XML_NAMESPACE_TABLE, XML_TABLE, sal_True, sal_True); + ::rtl::OUStringBuffer sBuffer; + if (nColCount > 1) + { + rExport.GetMM100UnitConverter().convertNumber(sBuffer, nColCount); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED, sBuffer.makeStringAndClear()); + } + { + SvXMLElementExport aElemCol(rExport, XML_NAMESPACE_TABLE, XML_TABLE_COLUMN, sal_True, sal_True); + } + sal_Bool bPrevString(sal_True); + sal_Bool bPrevEmpty(sal_True); + double fPrevValue; + String sPrevValue; + sal_Int32 nRepeatColsCount(1); + for(sal_Int32 nRow = 0; nRow < nRowCount; nRow++) + { + SvXMLElementExport aElemRow(rExport, XML_NAMESPACE_TABLE, XML_TABLE_ROW, sal_True, sal_True); + for(sal_Int32 nColumn = 0; nColumn < nColCount; nColumn++) + { + if (nColumn == 0) + bPrevEmpty = rExport.GetDocument()->GetDdeLinkResult(pMatrix, static_cast<USHORT>(nColumn), static_cast<USHORT>(nRow), + sPrevValue, fPrevValue, bPrevString); + else + { + double fValue; + String sValue; + sal_Bool bString(sal_True); + sal_Bool bEmpty = rExport.GetDocument()->GetDdeLinkResult(pMatrix, static_cast<USHORT>(nColumn), static_cast<USHORT>(nRow), + sValue, fValue, bString); + if (CellsEqual(bPrevEmpty, bPrevString, sPrevValue, fPrevValue, + bEmpty, bString, sValue, fValue)) + nRepeatColsCount++; + else + { + WriteCell(bPrevEmpty, bPrevString, sPrevValue, fPrevValue, nRepeatColsCount); + nRepeatColsCount = 1; + bPrevEmpty = bEmpty; + fPrevValue = fValue; + sPrevValue = sValue; + } + } + } + WriteCell(bPrevEmpty, bPrevString, sPrevValue, fPrevValue, nRepeatColsCount); + nRepeatColsCount = 1; + } + } +} + +void ScXMLExportDDELinks::WriteDDELinks(uno::Reference<sheet::XSpreadsheetDocument>& xSpreadDoc) +{ + uno::Reference <beans::XPropertySet> xPropertySet (xSpreadDoc, uno::UNO_QUERY); + if (xPropertySet.is()) + { + uno::Any aDDELinks = xPropertySet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DDELINKS))); + uno::Reference<container::XIndexAccess> xIndex; + if (aDDELinks >>= xIndex) + { + sal_Int32 nCount = xIndex->getCount(); + if (nCount) + { + SvXMLElementExport aElemDDEs(rExport, XML_NAMESPACE_TABLE, XML_DDE_LINKS, sal_True, sal_True); + for (sal_uInt16 nDDELink = 0; nDDELink < nCount; nDDELink++) + { + uno::Any aDDELink = xIndex->getByIndex(nDDELink); + uno::Reference<sheet::XDDELink> xDDELink; + if (aDDELink >>= xDDELink) + { + SvXMLElementExport aElemDDE(rExport, XML_NAMESPACE_TABLE, XML_DDE_LINK, sal_True, sal_True); + { + rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_DDE_APPLICATION, xDDELink->getApplication()); + rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_DDE_TOPIC, xDDELink->getTopic()); + rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_DDE_ITEM, xDDELink->getItem()); + rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_AUTOMATIC_UPDATE, XML_TRUE); + sal_uInt16 nMode; + if (rExport.GetDocument() && + rExport.GetDocument()->GetDdeLinkMode(nDDELink, nMode)) + { + switch (nMode) + { + case SC_DDE_ENGLISH : + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CONVERSION_MODE, XML_INTO_ENGLISH_NUMBER); + case SC_DDE_TEXT : + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CONVERSION_MODE, XML_LET_TEXT); + } + } + SvXMLElementExport(rExport, XML_NAMESPACE_OFFICE, XML_DDE_SOURCE, sal_True, sal_True); + } + WriteTable(nDDELink); + } + } + } + } + } +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_XMLExportDataPilot.cxx b/binfilter/bf_sc/source/filter/xml/sc_XMLExportDataPilot.cxx new file mode 100644 index 000000000000..67d455f83478 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_XMLExportDataPilot.cxx @@ -0,0 +1,473 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "XMLExportDataPilot.hxx" + +#include <bf_xmloff/xmlnmspe.hxx> +#include <bf_xmloff/xmluconv.hxx> +#include <bf_xmloff/nmspmap.hxx> + +#include "xmlexprt.hxx" +#include "XMLConverter.hxx" +#include "document.hxx" +#include "dpobject.hxx" +#include "dociter.hxx" +#include "attrib.hxx" +#include "patattr.hxx" +#include "scitems.hxx" +#include "dpsave.hxx" +#include "dpshttab.hxx" +#include "dpsdbtab.hxx" + +#include <com/sun/star/sheet/DataImportMode.hpp> +namespace binfilter { + +using namespace ::com::sun::star; +using namespace xmloff::token; + +ScXMLExportDataPilot::ScXMLExportDataPilot(ScXMLExport& rTempExport) + : rExport(rTempExport), + pDoc( NULL ) +{ +} + +ScXMLExportDataPilot::~ScXMLExportDataPilot() +{ +} + +rtl::OUString ScXMLExportDataPilot::getDPOperatorXML(const ScQueryOp aFilterOperator, const sal_Bool bUseRegularExpressions, + const sal_Bool bIsString, const double dVal, const String& sVal) const +{ + switch (aFilterOperator) + { + case SC_EQUAL : + { + ::rtl::OUString sReturn; + if (bUseRegularExpressions) + sReturn = GetXMLToken(XML_MATCH); + else + sReturn = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=")); + + if (!bIsString && sVal == EMPTY_STRING) + { + if (dVal == SC_EMPTYFIELDS) + sReturn = GetXMLToken(XML_EMPTY); + else if (dVal == SC_NONEMPTYFIELDS) + sReturn = GetXMLToken(XML_NOEMPTY); + } + + return sReturn; + } + break; + case SC_NOT_EQUAL : + { + if (bUseRegularExpressions) + return GetXMLToken(XML_NOMATCH); + else + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("!=")); + } + break; + case SC_BOTPERC : + return GetXMLToken(XML_BOTTOM_PERCENT); + break; + case SC_BOTVAL : + return GetXMLToken(XML_BOTTOM_VALUES); + break; + case SC_GREATER : + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(">")); + break; + case SC_GREATER_EQUAL : + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(">=")); + break; + case SC_LESS : + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("<")); + break; + case SC_LESS_EQUAL : + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("<=")); + break; + case SC_TOPPERC : + return GetXMLToken(XML_TOP_PERCENT); + break; + case SC_TOPVAL : + return GetXMLToken(XML_TOP_VALUES); + break; + default: + DBG_ERROR("This FilterOperator is not supported."); + } + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=")); +} + +void ScXMLExportDataPilot::WriteDPCondition(const ScQueryEntry& aQueryEntry, sal_Bool bIsCaseSensitive, sal_Bool bUseRegularExpressions) +{ + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_FIELD_NUMBER, ::rtl::OUString::valueOf(sal_Int32(aQueryEntry.nField))); + if (bIsCaseSensitive) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CASE_SENSITIVE, XML_TRUE); + if (aQueryEntry.bQueryByString) + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_VALUE, *aQueryEntry.pStr); + } + else + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATA_TYPE, XML_NUMBER); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_VALUE, ::rtl::OUString(*aQueryEntry.pStr)); + } + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_OPERATOR, getDPOperatorXML(aQueryEntry.eOp, bUseRegularExpressions, + aQueryEntry.bQueryByString, aQueryEntry.nVal, *aQueryEntry.pStr)); + SvXMLElementExport aElemC(rExport, XML_NAMESPACE_TABLE, XML_FILTER_CONDITION, sal_True, sal_True); +} + +void ScXMLExportDataPilot::WriteDPFilter(const ScQueryParam& aQueryParam) +{ + sal_Int16 nQueryEntryCount = aQueryParam.GetEntryCount(); + if (nQueryEntryCount > 0) + { + sal_Bool bAnd(sal_False); + sal_Bool bOr(sal_False); + sal_Bool bHasEntries(sal_True); + sal_Int16 nEntries(0); + sal_Int32 j; + + for (j = 0; (j < nQueryEntryCount) && bHasEntries; j++) + { + ScQueryEntry aEntry = aQueryParam.GetEntry(static_cast<USHORT>(j)); + if (aEntry.bDoQuery) + { + if (nEntries > 0) + { + if (aEntry.eConnect == SC_AND) + bAnd = sal_True; + else + bOr = sal_True; + } + nEntries++; + } + else + bHasEntries = sal_False; + } + nQueryEntryCount = nEntries; + if (nQueryEntryCount) + { + // There is never a target range in a data pilot. +/* if (!aQueryParam.bInplace) + { + ScAddress aTargetAddress(aQueryParam.nDestCol, aQueryParam.nDestRow, aQueryParam.nDestTab); + ::rtl::OUString sAddress; + ScXMLConverter::GetStringFromAddress( sAddress, aTargetAddress, pDoc ); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_TARGET_RANGE_ADDRESS, sAddress); + }*/ + if(!((aQueryParam.nCol1 == aQueryParam.nCol2) && (aQueryParam.nRow1 == aQueryParam.nRow2) && (aQueryParam.nCol1 == aQueryParam.nRow1) + && (aQueryParam.nCol1 == 0) && (aQueryParam.nTab == USHRT_MAX))) + { + ScRange aConditionRange(aQueryParam.nCol1, aQueryParam.nRow1, aQueryParam.nTab, + aQueryParam.nCol2, aQueryParam.nRow2, aQueryParam.nTab); + ::rtl::OUString sConditionRange; + ScXMLConverter::GetStringFromRange( sConditionRange, aConditionRange, pDoc ); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CONDITION_SOURCE_RANGE_ADDRESS, sConditionRange); + } + if (!aQueryParam.bDuplicate) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY_DUPLICATES, XML_FALSE); + SvXMLElementExport aElemDPF(rExport, XML_NAMESPACE_TABLE, XML_FILTER, sal_True, sal_True); + rExport.CheckAttrList(); + if (nQueryEntryCount == 1) + { + WriteDPCondition(aQueryParam.GetEntry(0), aQueryParam.bCaseSens, aQueryParam.bRegExp); + } + else if (bOr && !bAnd) + { + SvXMLElementExport aElemOr(rExport, XML_NAMESPACE_TABLE, XML_FILTER_OR, sal_True, sal_True); + for (j = 0; j < nQueryEntryCount; j++) + { + WriteDPCondition(aQueryParam.GetEntry(static_cast<USHORT>(j)), aQueryParam.bCaseSens, aQueryParam.bRegExp); + } + } + else if (bAnd && !bOr) + { + SvXMLElementExport aElemAnd(rExport, XML_NAMESPACE_TABLE, XML_FILTER_AND, sal_True, sal_True); + for (j = 0; j < nQueryEntryCount; j++) + { + WriteDPCondition(aQueryParam.GetEntry(static_cast<USHORT>(j)), aQueryParam.bCaseSens, aQueryParam.bRegExp); + } + } + else + { + SvXMLElementExport aElemC(rExport, XML_NAMESPACE_TABLE, XML_FILTER_OR, sal_True, sal_True); + ScQueryEntry aPrevFilterField = aQueryParam.GetEntry(0); + ScQueryConnect aConnection = aQueryParam.GetEntry(1).eConnect; + sal_Bool bOpenAndElement; + ::rtl::OUString aName = rExport.GetNamespaceMap().GetQNameByKey(XML_NAMESPACE_TABLE, GetXMLToken(XML_FILTER_AND)); + if (aConnection == SC_AND) + { + rExport.StartElement( aName, sal_True ); + bOpenAndElement = sal_True; + } + else + bOpenAndElement = sal_False; + for (j = 1; j < nQueryEntryCount; j++) + { + if (aConnection != aQueryParam.GetEntry(static_cast<USHORT>(j)).eConnect) + { + aConnection = aQueryParam.GetEntry(static_cast<USHORT>(j)).eConnect; + if (aQueryParam.GetEntry(static_cast<USHORT>(j)).eConnect == SC_AND) + { + rExport.StartElement( aName, sal_True ); + bOpenAndElement = sal_True; + WriteDPCondition(aPrevFilterField, aQueryParam.bCaseSens, aQueryParam.bRegExp); + aPrevFilterField = aQueryParam.GetEntry(static_cast<USHORT>(j)); + if (j == nQueryEntryCount - 1) + { + WriteDPCondition(aPrevFilterField, aQueryParam.bCaseSens, aQueryParam.bRegExp); + rExport.EndElement(aName, sal_True); + bOpenAndElement = sal_False; + } + } + else + { + WriteDPCondition(aPrevFilterField, aQueryParam.bCaseSens, aQueryParam.bRegExp); + aPrevFilterField = aQueryParam.GetEntry(static_cast<USHORT>(j)); + if (bOpenAndElement) + { + rExport.EndElement(aName, sal_True); + bOpenAndElement = sal_False; + } + if (j == nQueryEntryCount - 1) + { + WriteDPCondition(aPrevFilterField, aQueryParam.bCaseSens, aQueryParam.bRegExp); + } + } + } + else + { + WriteDPCondition(aPrevFilterField, aQueryParam.bCaseSens, aQueryParam.bRegExp); + aPrevFilterField = aQueryParam.GetEntry(static_cast<USHORT>(j)); + if (j == nQueryEntryCount - 1) + WriteDPCondition(aPrevFilterField, aQueryParam.bCaseSens, aQueryParam.bRegExp); + } + } + } + } + } +} + +void ScXMLExportDataPilot::WriteDataPilots(const uno::Reference <sheet::XSpreadsheetDocument>& xSpreadDoc) +{ + pDoc = rExport.GetDocument(); + if (pDoc) + { + ScDPCollection* pDPs = pDoc->GetDPCollection(); + if (pDPs) + { + sal_Int16 nDPCount = pDPs->GetCount(); + if (nDPCount > 0) + { + SvXMLElementExport aElemDPs(rExport, XML_NAMESPACE_TABLE, XML_DATA_PILOT_TABLES, sal_True, sal_True); + rExport.CheckAttrList(); + for (sal_Int16 i = 0; i < nDPCount; i++) + { + ScDPSaveData* pDPSave = (*pDPs)[i]->GetSaveData(); + if (pDPSave) + { + ScRange aOutRange = (*pDPs)[i]->GetOutRange(); + ::rtl::OUString sTargetRangeAddress; + ScXMLConverter::GetStringFromRange( sTargetRangeAddress, aOutRange, pDoc ); + ScDocAttrIterator aAttrItr(pDoc, aOutRange.aStart.Tab(), + aOutRange.aStart.Col(), aOutRange.aStart.Row(), + aOutRange.aEnd.Col(), aOutRange.aEnd.Row()); + sal_uInt16 nCol, nRow1, nRow2; + ::rtl::OUString sOUButtonList; + const ScPatternAttr* pAttr = aAttrItr.GetNext(nCol, nRow1, nRow2); + while (pAttr) + { + ScMergeFlagAttr& rItem = (ScMergeFlagAttr&)pAttr->GetItem(ATTR_MERGE_FLAG); + if (rItem.HasButton()) + { + for (sal_uInt16 nButtonRow = nRow1; nButtonRow <= nRow2; nButtonRow++) + { + ScAddress aButtonAddr(nCol, nButtonRow, aOutRange.aStart.Tab()); + ScXMLConverter::GetStringFromAddress( + sOUButtonList, aButtonAddr, pDoc, sal_True ); + } + } + pAttr = aAttrItr.GetNext(nCol, nRow1, nRow2); + } + ::rtl::OUString sName((*pDPs)[i]->GetName()); + ::rtl::OUString sApplicationData((*pDPs)[i]->GetTag()); + sal_Bool bRowGrand = pDPSave->GetRowGrand(); + sal_Bool bColumnGrand = pDPSave->GetColumnGrand(); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, sName); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_APPLICATION_DATA, sApplicationData); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_TARGET_RANGE_ADDRESS, sTargetRangeAddress); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_BUTTONS, sOUButtonList); + if (!(bRowGrand && bColumnGrand)) + { + if (bRowGrand) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_GRAND_TOTAL, XML_ROW); + else if (bColumnGrand) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_GRAND_TOTAL, XML_COLUMN); + else + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_GRAND_TOTAL, XML_NONE); + } + if (pDPSave->GetIgnoreEmptyRows()) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_IGNORE_EMPTY_ROWS, XML_TRUE); + if (pDPSave->GetRepeatIfEmpty()) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_IDENTIFY_CATEGORIES, XML_TRUE); + SvXMLElementExport aElemDP(rExport, XML_NAMESPACE_TABLE, XML_DATA_PILOT_TABLE, sal_True, sal_True); + rExport.CheckAttrList(); + if ((*pDPs)[i]->IsSheetData()) + { + const ScSheetSourceDesc* pSheetSource = (*pDPs)[i]->GetSheetDesc(); + ::rtl::OUString sCellRangeAddress; + ScXMLConverter::GetStringFromRange( sCellRangeAddress, pSheetSource->aSourceRange, pDoc ); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, sCellRangeAddress); + SvXMLElementExport aElemSCR(rExport, XML_NAMESPACE_TABLE, XML_SOURCE_CELL_RANGE, sal_True, sal_True); + rExport.CheckAttrList(); + WriteDPFilter(pSheetSource->aQueryParam); + } + else if ((*pDPs)[i]->IsImportData()) + { + const ScImportSourceDesc* pImpSource = (*pDPs)[i]->GetImportSourceDesc(); + switch (pImpSource->nType) + { + case sheet::DataImportMode_NONE : break; + case sheet::DataImportMode_QUERY : + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATABASE_NAME, ::rtl::OUString(pImpSource->aDBName)); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_QUERY_NAME, ::rtl::OUString(pImpSource->aObject)); + SvXMLElementExport aElemID(rExport, XML_NAMESPACE_TABLE, XML_DATABASE_SOURCE_QUERY, sal_True, sal_True); + rExport.CheckAttrList(); + } + break; + case sheet::DataImportMode_TABLE : + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATABASE_NAME, ::rtl::OUString(pImpSource->aDBName)); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_TABLE_NAME, ::rtl::OUString(pImpSource->aObject)); + SvXMLElementExport aElemID(rExport, XML_NAMESPACE_TABLE, XML_DATABASE_SOURCE_TABLE, sal_True, sal_True); + rExport.CheckAttrList(); + } + break; + case sheet::DataImportMode_SQL : + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATABASE_NAME, ::rtl::OUString(pImpSource->aDBName)); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_SQL_STATEMENT, ::rtl::OUString(pImpSource->aObject)); + if (!pImpSource->bNative) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_PARSE_SQL_STATEMENT, XML_TRUE); + SvXMLElementExport aElemID(rExport, XML_NAMESPACE_TABLE, XML_DATABASE_SOURCE_SQL, sal_True, sal_True); + rExport.CheckAttrList(); + } + break; + } + } + else if ((*pDPs)[i]->IsServiceData()) + { + const ScDPServiceDesc* pServSource = (*pDPs)[i]->GetDPServiceDesc(); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, ::rtl::OUString(pServSource->aServiceName)); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_SOURCE_NAME, ::rtl::OUString(pServSource->aParSource)); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_OBJECT_NAME, ::rtl::OUString(pServSource->aParName)); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_USERNAME, ::rtl::OUString(pServSource->aParUser)); + // How to write the Passwort? We must know, whether the passwort shoulb be written encrypted and how or not + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_PASSWORT, ::rtl::OUString(pServSource->aParPass)); + SvXMLElementExport aElemSD(rExport, XML_NAMESPACE_TABLE, XML_SOURCE_SERVICE, sal_True, sal_True); + rExport.CheckAttrList(); + } + List aDimensions = pDPSave->GetDimensions(); + sal_Int32 nDimCount = aDimensions.Count(); + for (sal_Int32 nDim = 0; nDim < nDimCount; nDim++) + { + ScDPSaveDimension* pDim = (ScDPSaveDimension*)aDimensions.GetObject(nDim); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_SOURCE_FIELD_NAME, ::rtl::OUString(pDim->GetName())); + if (pDim->IsDataLayout()) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_IS_DATA_LAYOUT_FIELD, XML_TRUE); + ::rtl::OUString sValueStr; + ScXMLConverter::GetStringFromOrientation( sValueStr, + (sheet::DataPilotFieldOrientation) pDim->GetOrientation() ); + if( sValueStr.getLength() ) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ORIENTATION, sValueStr ); + if (pDim->GetUsedHierarchy() != 1) + { + ::rtl::OUStringBuffer sBuffer; + SvXMLUnitConverter::convertNumber(sBuffer, pDim->GetUsedHierarchy()); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_USED_HIERARCHY, sBuffer.makeStringAndClear()); + } + ScXMLConverter::GetStringFromFunction( sValueStr, + (sheet::GeneralFunction) pDim->GetFunction() ); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_FUNCTION, sValueStr); + SvXMLElementExport aElemDPF(rExport, XML_NAMESPACE_TABLE, XML_DATA_PILOT_FIELD, sal_True, sal_True); + rExport.CheckAttrList(); + { + ::rtl::OUStringBuffer sBuffer; + SvXMLUnitConverter::convertBool(sBuffer, pDim->GetShowEmpty()); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY_EMPTY, sBuffer.makeStringAndClear()); + SvXMLElementExport aElemDPL(rExport, XML_NAMESPACE_TABLE, XML_DATA_PILOT_LEVEL, sal_True, sal_True); + rExport.CheckAttrList(); + sal_Int32 nSubTotalCount = pDim->GetSubTotalsCount(); + if (nSubTotalCount > 0) + { + SvXMLElementExport aElemSTs(rExport, XML_NAMESPACE_TABLE, XML_DATA_PILOT_SUBTOTALS, sal_True, sal_True); + rExport.CheckAttrList(); + for (sal_Int32 nSubTotal = 0; nSubTotal < nSubTotalCount; nSubTotal++) + { + ::rtl::OUString sFunction; + ScXMLConverter::GetStringFromFunction( sFunction, (sheet::GeneralFunction)pDim->GetSubTotalFunc(nSubTotal) ); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_FUNCTION, sFunction); + SvXMLElementExport aElemST(rExport, XML_NAMESPACE_TABLE, XML_DATA_PILOT_SUBTOTAL, sal_True, sal_True); + } + } + List aMembers = pDim->GetMembers(); + sal_Int32 nMemberCount = aMembers.Count(); + if (nMemberCount > 0) + { + SvXMLElementExport aElemDPMs(rExport, XML_NAMESPACE_TABLE, XML_DATA_PILOT_MEMBERS, sal_True, sal_True); + rExport.CheckAttrList(); + for (sal_Int32 nMember = 0; nMember < nMemberCount; nMember++) + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, ::rtl::OUString(((ScDPSaveMember*)aMembers.GetObject(nMember))->GetName())); + ::rtl::OUStringBuffer sBuffer; + SvXMLUnitConverter::convertBool(sBuffer, ((ScDPSaveMember*)aMembers.GetObject(nMember))->GetIsVisible()); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY, sBuffer.makeStringAndClear()); + SvXMLUnitConverter::convertBool(sBuffer, ((ScDPSaveMember*)aMembers.GetObject(nMember))->GetShowDetails()); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY_DETAILS, sBuffer.makeStringAndClear()); + SvXMLElementExport aElemDPM(rExport, XML_NAMESPACE_TABLE, XML_DATA_PILOT_MEMBER, sal_True, sal_True); + rExport.CheckAttrList(); + } + } + } + } + } + } + } + } + } +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_XMLExportDatabaseRanges.cxx b/binfilter/bf_sc/source/filter/xml/sc_XMLExportDatabaseRanges.cxx new file mode 100644 index 000000000000..4de6802aec47 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_XMLExportDatabaseRanges.cxx @@ -0,0 +1,768 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "XMLExportDatabaseRanges.hxx" + +#include <bf_xmloff/xmlnmspe.hxx> +#include <bf_xmloff/xmluconv.hxx> +#include <bf_xmloff/nmspmap.hxx> + +#include "xmlexprt.hxx" +#include "XMLExportIterator.hxx" +#include "XMLConverter.hxx" +#include "unonames.hxx" +#include "dbcolect.hxx" +#include "document.hxx" +#include "globstr.hrc" +#include "XMLExportSharedData.hxx" + +#include <com/sun/star/sheet/DataImportMode.hpp> +#include <com/sun/star/table/TableSortField.hpp> +#include <com/sun/star/sheet/XSubTotalField.hpp> +#include <com/sun/star/sheet/XDatabaseRanges.hpp> +#include <com/sun/star/sheet/XDatabaseRange.hpp> + +#include <tools/debug.hxx> +#include <comphelper/extract.hxx> +namespace binfilter { + +//! not found in unonames.hxx +#define SC_USERLIST "UserList" +#define SC_SORTASCENDING "SortAscending" +#define SC_ENABLEUSERSORTLIST "EnableUserSortList" +#define SC_USERSORTLISTINDEX "UserSortListIndex" + +using namespace ::com::sun::star; +using namespace xmloff::token; + +ScXMLExportDatabaseRanges::ScXMLExportDatabaseRanges(ScXMLExport& rTempExport) + : rExport(rTempExport), + pDoc( NULL ) +{ +} + +ScXMLExportDatabaseRanges::~ScXMLExportDatabaseRanges() +{ +} + +ScMyEmptyDatabaseRangesContainer ScXMLExportDatabaseRanges::GetEmptyDatabaseRanges() +{ + ScMyEmptyDatabaseRangesContainer aSkipRanges; + if (rExport.GetModel().is()) + { + sal_Int32 nSkipRangesCount = 0; + uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( rExport.GetModel(), uno::UNO_QUERY ); + if ( xSpreadDoc.is() ) + { + uno::Reference <beans::XPropertySet> xPropertySet (xSpreadDoc, uno::UNO_QUERY); + if (xPropertySet.is()) + { + uno::Any aDatabaseRanges = xPropertySet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DATABASERNG))); + uno::Reference <sheet::XDatabaseRanges> xDatabaseRanges; + rExport.CheckAttrList(); + if (aDatabaseRanges >>= xDatabaseRanges) + { + uno::Sequence <rtl::OUString> aRanges = xDatabaseRanges->getElementNames(); + sal_Int32 nDatabaseRangesCount = aRanges.getLength(); + for (sal_Int32 i = 0; i < nDatabaseRangesCount; i++) + { + ::rtl::OUString sDatabaseRangeName = aRanges[i]; + uno::Any aDatabaseRange = xDatabaseRanges->getByName(sDatabaseRangeName); + uno::Reference <sheet::XDatabaseRange> xDatabaseRange; + if (aDatabaseRange >>= xDatabaseRange) + { + uno::Reference <beans::XPropertySet> xDatabaseRangePropertySet (xDatabaseRange, uno::UNO_QUERY); + if (xDatabaseRangePropertySet.is()) + { + uno::Any aStripDataProperty = xDatabaseRangePropertySet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_STRIPDAT))); + sal_Bool bStripData = sal_False; + if (aStripDataProperty >>= bStripData) + if (bStripData) + { + uno::Sequence <beans::PropertyValue> aImportProperties = xDatabaseRange->getImportDescriptor(); + sal_Int32 nLength = aImportProperties.getLength(); + sheet::DataImportMode nSourceType = sheet::DataImportMode_NONE; + for (sal_Int32 j = 0; j < nLength; j++) + if (aImportProperties[j].Name == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_SRCTYPE))) + { + uno::Any aSourceType = aImportProperties[j].Value; + aSourceType >>= nSourceType; + } + if (nSourceType != sheet::DataImportMode_NONE) + { + table::CellRangeAddress aArea = xDatabaseRange->getDataArea(); + aSkipRanges.AddNewEmptyDatabaseRange(aArea); + + // #105276#; set last row/column so default styles are collected + rExport.GetSharedData()->SetLastColumn(aArea.Sheet, aArea.EndColumn); + rExport.GetSharedData()->SetLastRow(aArea.Sheet, aArea.EndRow); + } + } + } + } + } + if (nSkipRangesCount > 1) + aSkipRanges.Sort(); + } + } + } + } + return aSkipRanges; +} + +void ScXMLExportDatabaseRanges::WriteImportDescriptor(const uno::Sequence <beans::PropertyValue> aImportDescriptor) +{ + sal_Int32 nProperties = aImportDescriptor.getLength(); + ::rtl::OUString sDatabaseName; + ::rtl::OUString sSourceObject; + sheet::DataImportMode nSourceType; + sal_Bool bNative = sal_False; + for (sal_Int16 i = 0; i < nProperties; i++) + { + if (aImportDescriptor[i].Name == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_DBNAME))) + { + uno::Any aDatabaseName = aImportDescriptor[i].Value; + aDatabaseName >>= sDatabaseName; + } + else if (aImportDescriptor[i].Name == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_SRCOBJ))) + { + uno::Any aSourceObject = aImportDescriptor[i].Value; + aSourceObject >>= sSourceObject; + } + else if (aImportDescriptor[i].Name == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_SRCTYPE))) + { + uno::Any aSourceType = aImportDescriptor[i].Value; + aSourceType >>= nSourceType; + } + else if (aImportDescriptor[i].Name == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_NATIVE))) + { + uno::Any aNative = aImportDescriptor[i].Value; + aNative >>= bNative; + } + } + switch (nSourceType) + { + case sheet::DataImportMode_NONE : break; + case sheet::DataImportMode_QUERY : + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATABASE_NAME, sDatabaseName); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_QUERY_NAME, sSourceObject); + SvXMLElementExport aElemID(rExport, XML_NAMESPACE_TABLE, XML_DATABASE_SOURCE_QUERY, sal_True, sal_True); + rExport.CheckAttrList(); + } + break; + case sheet::DataImportMode_TABLE : + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATABASE_NAME, sDatabaseName); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_TABLE_NAME, sSourceObject); + SvXMLElementExport aElemID(rExport, XML_NAMESPACE_TABLE, XML_DATABASE_SOURCE_TABLE, sal_True, sal_True); + rExport.CheckAttrList(); + } + break; + case sheet::DataImportMode_SQL : + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATABASE_NAME, sDatabaseName); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_SQL_STATEMENT, sSourceObject); + if (!bNative) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_PARSE_SQL_STATEMENT, XML_TRUE); + SvXMLElementExport aElemID(rExport, XML_NAMESPACE_TABLE, XML_DATABASE_SOURCE_SQL, sal_True, sal_True); + rExport.CheckAttrList(); + } + break; + } +} + +rtl::OUString ScXMLExportDatabaseRanges::getOperatorXML(const sheet::FilterOperator aFilterOperator, const sal_Bool bUseRegularExpressions) const +{ + switch (aFilterOperator) + { + case sheet::FilterOperator_EQUAL : + { + if (bUseRegularExpressions) + return GetXMLToken(XML_MATCH); + else + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=")); + } + break; + case sheet::FilterOperator_NOT_EQUAL : + { + if (bUseRegularExpressions) + return GetXMLToken(XML_NOMATCH); + else + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("!=")); + } + break; + case sheet::FilterOperator_BOTTOM_PERCENT : + return GetXMLToken(XML_BOTTOM_PERCENT); + break; + case sheet::FilterOperator_BOTTOM_VALUES : + return GetXMLToken(XML_BOTTOM_VALUES); + break; + case sheet::FilterOperator_EMPTY : + return GetXMLToken(XML_EMPTY); + break; + case sheet::FilterOperator_GREATER : + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(">")); + break; + case sheet::FilterOperator_GREATER_EQUAL : + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(">=")); + break; + case sheet::FilterOperator_LESS : + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("<")); + break; + case sheet::FilterOperator_LESS_EQUAL : + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("<=")); + break; + case sheet::FilterOperator_NOT_EMPTY : + return GetXMLToken(XML_NOEMPTY); + break; + case sheet::FilterOperator_TOP_PERCENT : + return GetXMLToken(XML_TOP_PERCENT); + break; + case sheet::FilterOperator_TOP_VALUES : + return GetXMLToken(XML_TOP_VALUES); + break; + } + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=")); +} + +void ScXMLExportDatabaseRanges::WriteCondition(const sheet::TableFilterField& aFilterField, sal_Bool bIsCaseSensitive, sal_Bool bUseRegularExpressions) +{ + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_FIELD_NUMBER, ::rtl::OUString::valueOf(aFilterField.Field)); + if (bIsCaseSensitive) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CASE_SENSITIVE, XML_TRUE); + if (aFilterField.IsNumeric) + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATA_TYPE, XML_NUMBER); + ::rtl::OUStringBuffer sBuffer; + rExport.GetMM100UnitConverter().convertDouble(sBuffer, aFilterField.NumericValue); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_VALUE, sBuffer.makeStringAndClear()); + } + else + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_VALUE, aFilterField.StringValue); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_OPERATOR, getOperatorXML(aFilterField.Operator, bUseRegularExpressions)); + SvXMLElementExport aElemC(rExport, XML_NAMESPACE_TABLE, XML_FILTER_CONDITION, sal_True, sal_True); +} + +void ScXMLExportDatabaseRanges::WriteFilterDescriptor(const uno::Reference <sheet::XSheetFilterDescriptor>& xSheetFilterDescriptor, const ::rtl::OUString sDatabaseRangeName) +{ + uno::Sequence <sheet::TableFilterField> aTableFilterFields = xSheetFilterDescriptor->getFilterFields(); + sal_Int32 nTableFilterFields = aTableFilterFields.getLength(); + if (nTableFilterFields > 0) + { + uno::Reference <beans::XPropertySet> xPropertySet (xSheetFilterDescriptor, uno::UNO_QUERY); + if (xPropertySet.is()) + { + sal_Bool bCopyOutputData; + uno::Any aCopyOutputData = xPropertySet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_COPYOUT))); + if (aCopyOutputData >>= bCopyOutputData) + if (bCopyOutputData) + { + table::CellAddress aOutputPosition; + uno::Any aTempOutputPosition = xPropertySet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_OUTPOS))); + if (aTempOutputPosition >>= aOutputPosition) + { + ::rtl::OUString sOUCellAddress; + ScXMLConverter::GetStringFromAddress( sOUCellAddress, aOutputPosition, pDoc ); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_TARGET_RANGE_ADDRESS, sOUCellAddress); + } + } + ScDBCollection* pDBCollection = pDoc->GetDBCollection(); + sal_uInt16 nIndex; + pDBCollection->SearchName(sDatabaseRangeName, nIndex); + ScDBData* pDBData = (*pDBCollection)[nIndex]; + ScRange aAdvSource; + if (pDBData->GetAdvancedQuerySource(aAdvSource)) + { + ::rtl::OUString sOUCellAddress; + ScXMLConverter::GetStringFromRange( sOUCellAddress, aAdvSource, pDoc ); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CONDITION_SOURCE_RANGE_ADDRESS, sOUCellAddress); + } + + sal_Bool bSkipDuplicates; + uno::Any aSkipDuplicates = xPropertySet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_SKIPDUP))); + if (aSkipDuplicates >>= bSkipDuplicates) + if (bSkipDuplicates) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY_DUPLICATES, XML_FALSE); + SvXMLElementExport aElemF(rExport, XML_NAMESPACE_TABLE, XML_FILTER, sal_True, sal_True); + rExport.CheckAttrList(); + sal_Bool bIsCaseSensitive = sal_False; + uno::Any aIsCaseSensitive = xPropertySet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ISCASE))); + aIsCaseSensitive >>= bIsCaseSensitive; + sal_Bool bUseRegularExpressions = sal_False; + uno::Any aUseRegularExpressions = xPropertySet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_USEREGEX))); + aUseRegularExpressions >>= bUseRegularExpressions; + sal_Bool bAnd = sal_False; + sal_Bool bOr = sal_False; + sal_Int32 i; + + for (i = 1; i < nTableFilterFields; i++) + { + if (aTableFilterFields[i].Connection == sheet::FilterConnection_AND) + bAnd = sal_True; + else + bOr = sal_True; + } + if (bOr && !bAnd) + { + SvXMLElementExport aElemOr(rExport, XML_NAMESPACE_TABLE, XML_FILTER_OR, sal_True, sal_True); + for (i = 0; i < nTableFilterFields; i++) + { + WriteCondition(aTableFilterFields[i], bIsCaseSensitive, bUseRegularExpressions); + } + } + else if (bAnd && !bOr) + { + SvXMLElementExport aElemAnd(rExport, XML_NAMESPACE_TABLE, XML_FILTER_AND, sal_True, sal_True); + for (i = 0; i < nTableFilterFields; i++) + { + WriteCondition(aTableFilterFields[i], bIsCaseSensitive, bUseRegularExpressions); + } + } + else if (nTableFilterFields == 1) + { + WriteCondition(aTableFilterFields[0], bIsCaseSensitive, bUseRegularExpressions); + } + else + { + SvXMLElementExport aElemC(rExport, XML_NAMESPACE_TABLE, XML_FILTER_OR, sal_True, sal_True); + sheet::TableFilterField aPrevFilterField = aTableFilterFields[0]; + sheet::FilterConnection aConnection = aTableFilterFields[1].Connection; + sal_Bool bOpenAndElement; + ::rtl::OUString aName = rExport.GetNamespaceMap().GetQNameByKey(XML_NAMESPACE_TABLE, GetXMLToken(XML_FILTER_AND)); + if (aConnection == sheet::FilterConnection_AND) + { + rExport.StartElement( aName, sal_True); + bOpenAndElement = sal_True; + } + else + bOpenAndElement = sal_False; + for (i = 1; i < nTableFilterFields; i++) + { + if (aConnection != aTableFilterFields[i].Connection) + { + aConnection = aTableFilterFields[i].Connection; + if (aTableFilterFields[i].Connection == sheet::FilterConnection_AND) + { + rExport.StartElement( aName, sal_True ); + bOpenAndElement = sal_True; + WriteCondition(aPrevFilterField, bIsCaseSensitive, bUseRegularExpressions); + aPrevFilterField = aTableFilterFields[i]; + if (i == nTableFilterFields - 1) + { + WriteCondition(aPrevFilterField, bIsCaseSensitive, bUseRegularExpressions); + rExport.EndElement(aName, sal_True); + bOpenAndElement = sal_False; + } + } + else + { + WriteCondition(aPrevFilterField, bIsCaseSensitive, bUseRegularExpressions); + aPrevFilterField = aTableFilterFields[i]; + if (bOpenAndElement) + { + rExport.EndElement(aName, sal_True); + bOpenAndElement = sal_False; + } + if (i == nTableFilterFields - 1) + { + WriteCondition(aPrevFilterField, bIsCaseSensitive, bUseRegularExpressions); + } + } + } + else + { + WriteCondition(aPrevFilterField, bIsCaseSensitive, bUseRegularExpressions); + aPrevFilterField = aTableFilterFields[i]; + if (i == nTableFilterFields - 1) + WriteCondition(aPrevFilterField, bIsCaseSensitive, bUseRegularExpressions); + } + } + } + } + } +} + +void ScXMLExportDatabaseRanges::WriteSortDescriptor(const uno::Sequence <beans::PropertyValue> aSortProperties) +{ + uno::Sequence <table::TableSortField> aSortFields; + sal_Bool bBindFormatsToContent (sal_True); + sal_Bool bCopyOutputData (sal_False); + sal_Bool bIsCaseSensitive (sal_False); + sal_Bool bIsUserListEnabled (sal_False); + table::CellAddress aOutputPosition; + sal_Int32 nUserListIndex = 0; + sal_Int32 nProperties = aSortProperties.getLength(); + sal_Int32 i; + + for (i = 0; i < nProperties; i++) + { + if (aSortProperties[i].Name.compareToAscii(SC_UNONAME_BINDFMT) == 0) + { + uno::Any aBindFormatsToContent = aSortProperties[i].Value; + aBindFormatsToContent >>= bBindFormatsToContent; + } + else if (aSortProperties[i].Name.compareToAscii(SC_UNONAME_COPYOUT) == 0) + { + uno::Any aCopyOutputData = aSortProperties[i].Value; + aCopyOutputData >>= bCopyOutputData; + } +// no longer supported +/* else if (aSortProperties[i].Name.compareToAscii(SC_UNONAME_ISCASE) == 0) + { + uno::Any aIsCaseSensitive = aSortProperties[i].Value; + aIsCaseSensitive >>= bIsCaseSensitive; + }*/ + else if (aSortProperties[i].Name.compareToAscii(SC_UNONAME_ISULIST) == 0) + { + uno::Any aIsUserListEnabled = aSortProperties[i].Value; + aIsUserListEnabled >>= bIsUserListEnabled; + } + else if (aSortProperties[i].Name.compareToAscii(SC_UNONAME_OUTPOS) == 0) + { + uno::Any aTempOutputPosition = aSortProperties[i].Value; + aTempOutputPosition >>= aOutputPosition; + } + else if (aSortProperties[i].Name.compareToAscii(SC_UNONAME_UINDEX) == 0) + { + uno::Any aUserListIndex = aSortProperties[i].Value; + aUserListIndex >>= nUserListIndex; + } + else if (aSortProperties[i].Name.compareToAscii(SC_UNONAME_SORTFLD) == 0) + { + uno::Any aTempSortFields = aSortProperties[i].Value; + aTempSortFields >>= aSortFields; + } +// no longer supported +/* else if (aSortProperties[i].Name.compareToAscii(SC_UNONAME_COLLLOC) == 0) + { + uno::Any aTemp = aSortProperties[i].Value; + aTemp >>= aCollatorLocale; + } + else if (aSortProperties[i].Name.compareToAscii(SC_UNONAME_COLLALG) == 0) + { + uno::Any aTemp = aSortProperties[i].Value; + aTemp >>= sCollatorAlgorithm; + }*/ + } + sal_Int32 nSortFields = aSortFields.getLength(); + if (nSortFields > 0) + { + if (!bBindFormatsToContent) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_BIND_STYLES_TO_CONTENT, XML_FALSE); + if (bCopyOutputData) + { + ::rtl::OUString sOUCellAddress; + ScXMLConverter::GetStringFromAddress( sOUCellAddress, aOutputPosition, pDoc ); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_TARGET_RANGE_ADDRESS, sOUCellAddress); + } +// no longer supported +// if (bIsCaseSensitive) +// rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CASE_SENSITIVE, XML_TRUE); + + if (aSortFields[0].IsCaseSensitive) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CASE_SENSITIVE, XML_TRUE); +#ifdef DBG_UTIL + sal_Bool bCaseSensitive(aSortFields[0].IsCaseSensitive); + for (i = 1; i < nSortFields; i++) + { + DBG_ASSERT(bCaseSensitive == aSortFields[i].IsCaseSensitive, "seems that it is now possible to have every field case sensitive"); + } +#endif +// no longer supported +/* if (aCollatorLocale.Language.getLength()) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_LANGUAGE, aCollatorLocale.Language); + if (aCollatorLocale.Country.getLength()) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_COUNTRY, aCollatorLocale.Country); + if (sCollatorAlgorithm.getLength()) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ALGORITHM, sCollatorAlgorithm);*/ + if (aSortFields[0].CollatorLocale.Language.getLength()) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_LANGUAGE, aSortFields[0].CollatorLocale.Language); + if (aSortFields[0].CollatorLocale.Country.getLength()) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_COUNTRY, aSortFields[0].CollatorLocale.Country); + if (aSortFields[0].CollatorAlgorithm.getLength()) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ALGORITHM, aSortFields[0].CollatorAlgorithm); +#ifdef DBG_UTIL + ::rtl::OUString sLanguage(aSortFields[0].CollatorLocale.Language); + ::rtl::OUString sCountry(aSortFields[0].CollatorLocale.Country); + ::rtl::OUString sAlgorithm(aSortFields[0].CollatorAlgorithm); + for (i = 1; i < nSortFields; i++) + { + DBG_ASSERT(sLanguage == aSortFields[i].CollatorLocale.Language, "seems that it is now possible to have every field localized"); + DBG_ASSERT(sCountry == aSortFields[i].CollatorLocale.Country, "seems that it is now possible to have every field localized"); + DBG_ASSERT(sAlgorithm == aSortFields[i].CollatorAlgorithm, "seems that it is now possible to have every field localized"); + } +#endif + SvXMLElementExport aElemS(rExport, XML_NAMESPACE_TABLE, XML_SORT, sal_True, sal_True); + rExport.CheckAttrList(); + for (i = 0; i < nSortFields; i++) + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_FIELD_NUMBER, ::rtl::OUString::valueOf(aSortFields[i].Field)); + if (!aSortFields[i].IsAscending) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ORDER, XML_DESCENDING); + if (!bIsUserListEnabled) + { + switch (aSortFields[i].FieldType) + { + case table::TableSortFieldType_ALPHANUMERIC : + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATA_TYPE, XML_TEXT); + break; + case table::TableSortFieldType_AUTOMATIC : + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATA_TYPE, XML_AUTOMATIC); + break; + case table::TableSortFieldType_NUMERIC : + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATA_TYPE, XML_NUMBER); + break; + } + } + else + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATA_TYPE, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_USERLIST)) + ::rtl::OUString::valueOf(nUserListIndex)); + SvXMLElementExport aElemSb(rExport, XML_NAMESPACE_TABLE, XML_SORT_BY, sal_True, sal_True); + rExport.CheckAttrList(); + } + } +} + +void ScXMLExportDatabaseRanges::WriteSubTotalDescriptor(const ::com::sun::star::uno::Reference < ::com::sun::star::sheet::XSubTotalDescriptor> xSubTotalDescriptor, const ::rtl::OUString sDatabaseRangeName) +{ + uno::Reference <container::XIndexAccess> xIndexAccess (xSubTotalDescriptor, uno::UNO_QUERY); + if (xIndexAccess.is()) + { + sal_Int32 nSubTotalFields = xIndexAccess->getCount(); + if (nSubTotalFields > 0) + { + uno::Reference <beans::XPropertySet> xPropertySet (xSubTotalDescriptor, uno::UNO_QUERY); + sal_Bool bEnableUserSortList = sal_False; + sal_Bool bSortAscending = sal_True; + sal_Int32 nUserSortListIndex = 0; + if (xPropertySet.is()) + { + sal_Bool bBindFormatsToContent; + uno::Any aBindFormatsToContent = xPropertySet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_BINDFMT))); + if (aBindFormatsToContent >>= bBindFormatsToContent) + if (!bBindFormatsToContent) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_BIND_STYLES_TO_CONTENT, XML_FALSE); + sal_Bool bInsertPageBreaks; + uno::Any aInsertPageBreaks = xPropertySet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_INSBRK))); + if (aInsertPageBreaks >>= bInsertPageBreaks) + if (bInsertPageBreaks) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_PAGE_BREAKS_ON_GROUP_CHANGE, XML_TRUE); + sal_Bool bIsCaseSensitive; + uno::Any aIsCaseSensitive = xPropertySet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ISCASE))); + if (aIsCaseSensitive >>= bIsCaseSensitive) + if (bIsCaseSensitive) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CASE_SENSITIVE, XML_TRUE); + uno::Any aSortAscending = xPropertySet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_SORTASCENDING))); + aSortAscending >>= bSortAscending; + uno::Any aEnabledUserSortList = xPropertySet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ENABLEUSERSORTLIST))); + if (aEnabledUserSortList >>= bEnableUserSortList) + if (bEnableUserSortList) + { + uno::Any aUserSortListIndex = xPropertySet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_USERSORTLISTINDEX))); + aUserSortListIndex >>= nUserSortListIndex; + } + } + SvXMLElementExport aElemSTRs(rExport, XML_NAMESPACE_TABLE, XML_SUBTOTAL_RULES, sal_True, sal_True); + rExport.CheckAttrList(); + { + ScDBCollection* pDBCollection = pDoc->GetDBCollection(); + sal_uInt16 nIndex; + pDBCollection->SearchName(sDatabaseRangeName, nIndex); + ScDBData* pDBData = (*pDBCollection)[nIndex]; + ScSubTotalParam aSubTotalParam; + pDBData->GetSubTotalParam(aSubTotalParam); + if (aSubTotalParam.bDoSort) + { + if (!aSubTotalParam.bAscending) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ORDER, XML_DESCENDING); + if (aSubTotalParam.bUserDef) + { + ::rtl::OUString sUserList = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_USERLIST)); + sUserList += ::rtl::OUString::valueOf(aSubTotalParam.nUserIndex); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATA_TYPE, sUserList); + } + SvXMLElementExport aElemSGs(rExport, XML_NAMESPACE_TABLE, XML_SORT_GROUPS, sal_True, sal_True); + rExport.CheckAttrList(); + } + } + for (sal_Int32 i = 0; i < nSubTotalFields; i++) + { + uno::Reference <sheet::XSubTotalField> xSubTotalField; + uno::Any aSubTotalField = xIndexAccess->getByIndex(i); + if (aSubTotalField >>= xSubTotalField) + { + sal_Int32 nGroupColumn = xSubTotalField->getGroupColumn(); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_GROUP_BY_FIELD_NUMBER, ::rtl::OUString::valueOf(nGroupColumn)); + SvXMLElementExport aElemSTR(rExport, XML_NAMESPACE_TABLE, XML_SUBTOTAL_RULE, sal_True, sal_True); + rExport.CheckAttrList(); + uno::Sequence <sheet::SubTotalColumn> aSubTotalColumns = xSubTotalField->getSubTotalColumns(); + sal_Int32 nSubTotalColumns = aSubTotalColumns.getLength(); + for (sal_Int32 j = 0; j < nSubTotalColumns; j++) + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_FIELD_NUMBER, ::rtl::OUString::valueOf(aSubTotalColumns[j].Column)); + ::rtl::OUString sFunction; + ScXMLConverter::GetStringFromFunction( sFunction, aSubTotalColumns[j].Function ); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_FUNCTION, sFunction); + SvXMLElementExport aElemSTF(rExport, XML_NAMESPACE_TABLE, XML_SUBTOTAL_FIELD, sal_True, sal_True); + rExport.CheckAttrList(); + } + } + } + } + } +} + +void ScXMLExportDatabaseRanges::WriteDatabaseRanges(const ::com::sun::star::uno::Reference < ::com::sun::star::sheet::XSpreadsheetDocument>& xSpreadDoc) +{ + pDoc = rExport.GetDocument(); + if (pDoc) + { + uno::Reference <beans::XPropertySet> xPropertySet (xSpreadDoc, uno::UNO_QUERY); + if (xPropertySet.is()) + { + uno::Any aDatabaseRanges = xPropertySet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DATABASERNG))); + uno::Reference <sheet::XDatabaseRanges> xDatabaseRanges; + rExport.CheckAttrList(); + if (aDatabaseRanges >>= xDatabaseRanges) + { + uno::Sequence <rtl::OUString> aRanges = xDatabaseRanges->getElementNames(); + sal_Int32 nDatabaseRangesCount = aRanges.getLength(); + if (nDatabaseRangesCount > 0) + { + SvXMLElementExport aElemDRs(rExport, XML_NAMESPACE_TABLE, XML_DATABASE_RANGES, sal_True, sal_True); + for (sal_Int32 i = 0; i < nDatabaseRangesCount; i++) + { + ::rtl::OUString sDatabaseRangeName = aRanges[i]; + uno::Any aDatabaseRange = xDatabaseRanges->getByName(sDatabaseRangeName); + uno::Reference <sheet::XDatabaseRange> xDatabaseRange; + if (aDatabaseRange >>= xDatabaseRange) + { + String sUnbenannt = ScGlobal::GetRscString(STR_DB_NONAME); + ::rtl::OUString sOUUnbenannt (sUnbenannt); + if (sOUUnbenannt != sDatabaseRangeName) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, sDatabaseRangeName); + table::CellRangeAddress aRangeAddress = xDatabaseRange->getDataArea(); + ::rtl::OUString sOUAddress; + ScXMLConverter::GetStringFromRange( sOUAddress, aRangeAddress, pDoc ); + rExport.AddAttribute (XML_NAMESPACE_TABLE, XML_TARGET_RANGE_ADDRESS, sOUAddress); + ScDBCollection* pDBCollection = pDoc->GetDBCollection(); + sal_uInt16 nIndex; + pDBCollection->SearchName(sDatabaseRangeName, nIndex); + ScDBData* pDBData = (*pDBCollection)[nIndex]; + if (pDBData->HasImportSelection()) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_IS_SELECTION, XML_TRUE); + if (pDBData->HasAutoFilter()) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY_FILTER_BUTTONS, XML_TRUE); + uno::Reference <beans::XPropertySet> xPropertySetDatabaseRange (xDatabaseRange, uno::UNO_QUERY); + if (xPropertySetDatabaseRange.is()) + { + uno::Any aKeepFormatsProperty = xPropertySetDatabaseRange->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_KEEPFORM))); + sal_Bool bKeepFormats = sal_False; + if (aKeepFormatsProperty >>= bKeepFormats) + if (bKeepFormats) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ON_UPDATE_KEEP_STYLES, XML_TRUE); + uno::Any aMoveCellsProperty = xPropertySetDatabaseRange->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_MOVCELLS))); + sal_Bool bMoveCells = sal_False; + if (aMoveCellsProperty >>= bMoveCells) + if (bMoveCells) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ON_UPDATE_KEEP_SIZE, XML_FALSE); + uno::Any aStripDataProperty = xPropertySetDatabaseRange->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_STRIPDAT))); + sal_Bool bStripData = sal_False; + if (aStripDataProperty >>= bStripData) + if (bStripData) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_HAS_PERSISTENT_DATA, XML_FALSE); + } + uno::Reference <sheet::XSheetFilterDescriptor> xSheetFilterDescriptor = xDatabaseRange->getFilterDescriptor(); + uno::Sequence <beans::PropertyValue> aSortProperties = xDatabaseRange->getSortDescriptor(); + if (xSheetFilterDescriptor.is()) + { + uno::Reference <beans::XPropertySet> xFilterProperties (xSheetFilterDescriptor, uno::UNO_QUERY); + if (xFilterProperties.is()) + { + uno::Any aContainsHeaderProperty = xFilterProperties->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_CONTHDR))); + sal_Bool bContainsHeader = sal_True; + if (aContainsHeaderProperty >>= bContainsHeader) + if (!bContainsHeader) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CONTAINS_HEADER, XML_FALSE); + + // #98317#; there is no orientation on the filter +/* uno::Any aOrientationProperty = xFilterProperties->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ORIENT))); + sal_Bool bOrientation = sal_False; + table::TableOrientation eFilterOrient(table::TableOrientation_ROWS); + if (aOrientationProperty >>= bOrientation) + if (bOrientation) + eFilterOrient = table::TableOrientation_ROWS;*/ + + sal_Bool bSortColumns(sal_True); + sal_Bool bFound(sal_False); + sal_uInt32 nProperty(0); + while (!bFound && (nProperty < aSortProperties.getLength())) + { + if (aSortProperties[nProperty].Name.compareToAscii(SC_UNONAME_ISSORTCOLUMNS) == 0) + { + bSortColumns = ::cppu::any2bool(aSortProperties[nProperty].Value); + bFound = sal_True; + } + else + ++nProperty; + } + + if (bSortColumns) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ORIENTATION, XML_COLUMN); + } + } + sal_Int32 nRefresh( pDBData->GetRefreshDelay() ); + if( nRefresh ) + { + ::rtl::OUStringBuffer sBuffer; + SvXMLUnitConverter::convertTime( sBuffer, (double)nRefresh / 86400 ); + rExport.AddAttribute( XML_NAMESPACE_TABLE, XML_REFRESH_DELAY, sBuffer.makeStringAndClear() ); + } + SvXMLElementExport aElemDR(rExport, XML_NAMESPACE_TABLE, XML_DATABASE_RANGE, sal_True, sal_True); + rExport.CheckAttrList(); + WriteImportDescriptor(xDatabaseRange->getImportDescriptor()); + if (xSheetFilterDescriptor.is()) + WriteFilterDescriptor(xSheetFilterDescriptor, sDatabaseRangeName); + WriteSortDescriptor(aSortProperties); + WriteSubTotalDescriptor(xDatabaseRange->getSubTotalDescriptor(), sDatabaseRangeName); + } + } + } + } + } + } +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_XMLExportIterator.cxx b/binfilter/bf_sc/source/filter/xml/sc_XMLExportIterator.cxx new file mode 100644 index 000000000000..e5ec50672852 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_XMLExportIterator.cxx @@ -0,0 +1,720 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "XMLExportIterator.hxx" + +#include <com/sun/star/sheet/XCellRangesQuery.hpp> +#include <com/sun/star/sheet/XSheetAnnotationsSupplier.hpp> + +#include <tools/debug.hxx> + + +#include "dociter.hxx" +#include "convuno.hxx" +#include "xmlexprt.hxx" +#include "XMLExportSharedData.hxx" +#include "XMLStylesExportHelper.hxx" + +#include <algorithm> +namespace binfilter { + +using namespace ::rtl; +using namespace ::com::sun::star; + +//============================================================================== + +ScMyIteratorBase::ScMyIteratorBase() +{ +} + +ScMyIteratorBase::~ScMyIteratorBase() +{ +} + +void ScMyIteratorBase::UpdateAddress( table::CellAddress& rCellAddress ) +{ + table::CellAddress aNewAddr( rCellAddress ); + if( GetFirstAddress( aNewAddr ) ) + { + if( (aNewAddr.Sheet == rCellAddress.Sheet) && + ((aNewAddr.Row < rCellAddress.Row) || + ((aNewAddr.Row == rCellAddress.Row) && (aNewAddr.Column < rCellAddress.Column))) ) + rCellAddress = aNewAddr; + } +} + + +//============================================================================== + +sal_Bool ScMyShape::operator<(const ScMyShape& aShape) const +{ + if( aAddress.Tab() != aShape.aAddress.Tab() ) + return (aAddress.Tab() < aShape.aAddress.Tab()); + else if( aAddress.Row() != aShape.aAddress.Row() ) + return (aAddress.Row() < aShape.aAddress.Row()); + else + return (aAddress.Col() < aShape.aAddress.Col()); +} + +ScMyShapesContainer::ScMyShapesContainer() + : aShapeList() +{ +} + +ScMyShapesContainer::~ScMyShapesContainer() +{ +} + +void ScMyShapesContainer::AddNewShape( const ScMyShape& aShape ) +{ + aShapeList.push_back(aShape); +} + +sal_Bool ScMyShapesContainer::GetFirstAddress( table::CellAddress& rCellAddress ) +{ + sal_Int16 nTable = rCellAddress.Sheet; + if( !aShapeList.empty() ) + { + ScUnoConversion::FillApiAddress( rCellAddress, aShapeList.begin()->aAddress ); + return (nTable == rCellAddress.Sheet); + } + return sal_False; +} + +void ScMyShapesContainer::SetCellData( ScMyCell& rMyCell ) +{ + rMyCell.aShapeList.clear(); + ScAddress aAddress; + ScUnoConversion::FillScAddress( aAddress, rMyCell.aCellAddress ); + + ScMyShapeList::iterator aItr = aShapeList.begin(); + while( (aItr != aShapeList.end()) && (aItr->aAddress == aAddress) ) + { + rMyCell.aShapeList.push_back(*aItr); + aItr = aShapeList.erase(aItr); + } + rMyCell.bHasShape = !rMyCell.aShapeList.empty(); +} + +void ScMyShapesContainer::Sort() +{ + aShapeList.sort(); +} + +//============================================================================== + +sal_Bool ScMyMergedRange::operator<(const ScMyMergedRange& aRange) const +{ + if( aCellRange.Sheet != aRange.aCellRange.Sheet ) + return (aCellRange.Sheet < aRange.aCellRange.Sheet); + else if( aCellRange.StartRow != aRange.aCellRange.StartRow ) + return (aCellRange.StartRow < aRange.aCellRange.StartRow); + else + return (aCellRange.StartColumn < aRange.aCellRange.StartColumn); +} + + +ScMyMergedRangesContainer::ScMyMergedRangesContainer() + : aRangeList() +{ +} + +ScMyMergedRangesContainer::~ScMyMergedRangesContainer() +{ +} + +void ScMyMergedRangesContainer::AddRange(const table::CellRangeAddress aMergedRange) +{ + sal_Int32 nStartRow = aMergedRange.StartRow; + sal_Int32 nEndRow = aMergedRange.EndRow; + + ScMyMergedRange aRange; + aRange.bIsFirst = sal_True; + aRange.aCellRange = aMergedRange; + aRange.aCellRange.EndRow = nStartRow; + aRange.nRows = nEndRow - nStartRow + 1; + aRangeList.push_back( aRange ); + + aRange.bIsFirst = sal_False; + aRange.nRows = 0; + for( sal_Int32 nRow = nStartRow + 1; nRow <= nEndRow; nRow++ ) + { + aRange.aCellRange.StartRow = aRange.aCellRange.EndRow = nRow; + aRangeList.push_back(aRange); + } +} + +sal_Bool ScMyMergedRangesContainer::GetFirstAddress( table::CellAddress& rCellAddress ) +{ + sal_Int16 nTable = rCellAddress.Sheet; + if( !aRangeList.empty() ) + { + ScUnoConversion::FillApiStartAddress( rCellAddress, aRangeList.begin()->aCellRange ); + return (nTable == rCellAddress.Sheet); + } + return sal_False; +} + +void ScMyMergedRangesContainer::SetCellData( ScMyCell& rMyCell ) +{ + rMyCell.bIsMergedBase = rMyCell.bIsCovered = sal_False; + ScMyMergedRangeList::iterator aItr = aRangeList.begin(); + if( aItr != aRangeList.end() ) + { + table::CellAddress aFirstAddress; + ScUnoConversion::FillApiStartAddress( aFirstAddress, aItr->aCellRange ); + if( aFirstAddress == rMyCell.aCellAddress ) + { + rMyCell.aMergeRange = aItr->aCellRange; + if (aItr->bIsFirst) + rMyCell.aMergeRange.EndRow = rMyCell.aMergeRange.StartRow + aItr->nRows - 1; + rMyCell.bIsMergedBase = aItr->bIsFirst; + rMyCell.bIsCovered = !aItr->bIsFirst; + if( aItr->aCellRange.StartColumn < aItr->aCellRange.EndColumn ) + { + aItr->aCellRange.StartColumn++; + aItr->bIsFirst = sal_False; + } + else + aRangeList.erase(aItr); + } + } +} + +void ScMyMergedRangesContainer::Sort() +{ + aRangeList.sort(); +} + +//============================================================================== + +sal_Bool ScMyAreaLink::Compare( const ScMyAreaLink& rAreaLink ) const +{ + return (GetRowCount() == rAreaLink.GetRowCount()) && + (sFilter == rAreaLink.sFilter) && + (sFilterOptions == rAreaLink.sFilterOptions) && + (sURL == rAreaLink.sURL) && + (sSourceStr == rAreaLink.sSourceStr); +} + +sal_Bool ScMyAreaLink::operator<(const ScMyAreaLink& rAreaLink ) const +{ + if( aDestRange.Sheet != rAreaLink.aDestRange.Sheet ) + return (aDestRange.Sheet < rAreaLink.aDestRange.Sheet); + else if( aDestRange.StartRow != rAreaLink.aDestRange.StartRow ) + return (aDestRange.StartRow < rAreaLink.aDestRange.StartRow); + else + return (aDestRange.StartColumn < rAreaLink.aDestRange.StartColumn); +} + +ScMyAreaLinksContainer::ScMyAreaLinksContainer() : + aAreaLinkList() +{ +} + +ScMyAreaLinksContainer::~ScMyAreaLinksContainer() +{ +} + +sal_Bool ScMyAreaLinksContainer::GetFirstAddress( table::CellAddress& rCellAddress ) +{ + sal_Int16 nTable = rCellAddress.Sheet; + if( !aAreaLinkList.empty() ) + { + ScUnoConversion::FillApiStartAddress( rCellAddress, aAreaLinkList.begin()->aDestRange ); + return (nTable == rCellAddress.Sheet); + } + return sal_False; +} + +void ScMyAreaLinksContainer::SetCellData( ScMyCell& rMyCell ) +{ + rMyCell.bHasAreaLink = sal_False; + ScMyAreaLinkList::iterator aItr = aAreaLinkList.begin(); + if( aItr != aAreaLinkList.end() ) + { + table::CellAddress aAddress; + ScUnoConversion::FillApiStartAddress( aAddress, aItr->aDestRange ); + if( aAddress == rMyCell.aCellAddress ) + { + rMyCell.bHasAreaLink = sal_True; + rMyCell.aAreaLink = *aItr; + aAreaLinkList.erase( aItr ); + } + } +} + +void ScMyAreaLinksContainer::Sort() +{ + aAreaLinkList.sort(); +} + +//============================================================================== + +ScMyCellRangeAddress::ScMyCellRangeAddress(const table::CellRangeAddress& rRange) + : table::CellRangeAddress(rRange) +{ +} + +sal_Bool ScMyCellRangeAddress::operator<(const ScMyCellRangeAddress& rRange ) const +{ + if( Sheet != rRange.Sheet ) + return (Sheet < rRange.Sheet); + else if( StartRow != rRange.StartRow ) + return (StartRow < rRange.StartRow); + else + return (StartColumn < rRange.StartColumn); +} + +ScMyEmptyDatabaseRangesContainer::ScMyEmptyDatabaseRangesContainer() + : aDatabaseList() +{ +} + +ScMyEmptyDatabaseRangesContainer::~ScMyEmptyDatabaseRangesContainer() +{ +} + +void ScMyEmptyDatabaseRangesContainer::AddNewEmptyDatabaseRange(const table::CellRangeAddress& aCellRange) +{ + sal_Int32 nStartRow = aCellRange.StartRow; + sal_Int32 nEndRow = aCellRange.EndRow; + ScMyCellRangeAddress aRange( aCellRange ); + for( sal_Int32 nRow = nStartRow; nRow <= nEndRow; nRow++ ) + { + aRange.StartRow = aRange.EndRow = nRow; + aDatabaseList.push_back( aRange ); + } +} + +sal_Bool ScMyEmptyDatabaseRangesContainer::GetFirstAddress( table::CellAddress& rCellAddress ) +{ + sal_Int16 nTable = rCellAddress.Sheet; + if( !aDatabaseList.empty() ) + { + ScUnoConversion::FillApiStartAddress( rCellAddress, *(aDatabaseList.begin()) ); + return (nTable == rCellAddress.Sheet); + } + return sal_False; +} + +void ScMyEmptyDatabaseRangesContainer::SetCellData( ScMyCell& rMyCell ) +{ + rMyCell.bHasEmptyDatabase = sal_False; + sal_Int16 nTable = rMyCell.aCellAddress.Sheet; + ScMyEmptyDatabaseRangeList::iterator aItr = aDatabaseList.begin(); + if( aItr != aDatabaseList.end() ) + { + table::CellAddress aFirstAddress; + ScUnoConversion::FillApiStartAddress( aFirstAddress, *aItr ); + if( aFirstAddress == rMyCell.aCellAddress ) + { + rMyCell.bHasEmptyDatabase = sal_True; + if( aItr->StartColumn < aItr->EndColumn ) + aItr->StartColumn++; + else + aDatabaseList.erase(aItr); + } + } +} + +void ScMyEmptyDatabaseRangesContainer::Sort() +{ + aDatabaseList.sort(); +} + +//============================================================================== + +sal_Bool ScMyDetectiveObj::operator<( const ScMyDetectiveObj& rDetObj) const +{ + if( aPosition.Sheet != rDetObj.aPosition.Sheet ) + return (aPosition.Sheet < rDetObj.aPosition.Sheet); + else if( aPosition.Row != rDetObj.aPosition.Row ) + return (aPosition.Row < rDetObj.aPosition.Row); + else + return (aPosition.Column < rDetObj.aPosition.Column); +} + +ScMyDetectiveObjContainer::ScMyDetectiveObjContainer() : + aDetectiveObjList() +{ +} + +ScMyDetectiveObjContainer::~ScMyDetectiveObjContainer() +{ +} + +void ScMyDetectiveObjContainer::AddObject( ScDetectiveObjType eObjType, const ScAddress& rPosition, + const ScRange& rSourceRange, sal_Bool bHasError ) +{ + if( (eObjType == SC_DETOBJ_ARROW) || + (eObjType == SC_DETOBJ_FROMOTHERTAB) || + (eObjType == SC_DETOBJ_TOOTHERTAB) || + (eObjType == SC_DETOBJ_CIRCLE) ) + { + ScMyDetectiveObj aDetObj; + aDetObj.eObjType = eObjType; + if( eObjType == SC_DETOBJ_TOOTHERTAB ) + ScUnoConversion::FillApiAddress( aDetObj.aPosition, rSourceRange.aStart ); + else + ScUnoConversion::FillApiAddress( aDetObj.aPosition, rPosition ); + ScUnoConversion::FillApiRange( aDetObj.aSourceRange, rSourceRange ); + aDetObj.bHasError = bHasError; + aDetectiveObjList.push_back( aDetObj ); + } +} + +sal_Bool ScMyDetectiveObjContainer::GetFirstAddress( table::CellAddress& rCellAddress ) +{ + sal_Int16 nTable = rCellAddress.Sheet; + if( !aDetectiveObjList.empty() ) + { + rCellAddress = aDetectiveObjList.begin()->aPosition; + return (nTable == rCellAddress.Sheet); + } + return sal_False; +} + +void ScMyDetectiveObjContainer::SetCellData( ScMyCell& rMyCell ) +{ + rMyCell.aDetectiveObjVec.clear(); + ScMyDetectiveObjList::iterator aItr = aDetectiveObjList.begin(); + while( (aItr != aDetectiveObjList.end()) && (aItr->aPosition == rMyCell.aCellAddress) ) + { + rMyCell.aDetectiveObjVec.push_back( *aItr ); + aItr = aDetectiveObjList.erase( aItr ); + } + rMyCell.bHasDetectiveObj = (rMyCell.aDetectiveObjVec.size() != 0); +} + +void ScMyDetectiveObjContainer::Sort() +{ + aDetectiveObjList.sort(); +} + +//============================================================================== + +sal_Bool ScMyDetectiveOp::operator<( const ScMyDetectiveOp& rDetOp) const +{ + if( aPosition.Sheet != rDetOp.aPosition.Sheet ) + return (aPosition.Sheet < rDetOp.aPosition.Sheet); + else if( aPosition.Row != rDetOp.aPosition.Row ) + return (aPosition.Row < rDetOp.aPosition.Row); + else + return (aPosition.Column < rDetOp.aPosition.Column); +} + +ScMyDetectiveOpContainer::ScMyDetectiveOpContainer() : + aDetectiveOpList() +{ +} + +ScMyDetectiveOpContainer::~ScMyDetectiveOpContainer() +{ +} + +void ScMyDetectiveOpContainer::AddOperation( ScDetOpType eOpType, const ScAddress& rPosition, sal_uInt32 nIndex ) +{ + ScMyDetectiveOp aDetOp; + aDetOp.eOpType = eOpType; + ScUnoConversion::FillApiAddress( aDetOp.aPosition, rPosition ); + aDetOp.nIndex = nIndex; + aDetectiveOpList.push_back( aDetOp ); +} + +sal_Bool ScMyDetectiveOpContainer::GetFirstAddress( table::CellAddress& rCellAddress ) +{ + sal_Int16 nTable = rCellAddress.Sheet; + if( !aDetectiveOpList.empty() ) + { + rCellAddress = aDetectiveOpList.begin()->aPosition; + return (nTable == rCellAddress.Sheet); + } + return sal_False; +} + +void ScMyDetectiveOpContainer::SetCellData( ScMyCell& rMyCell ) +{ + rMyCell.aDetectiveOpVec.clear(); + ScMyDetectiveOpList::iterator aItr = aDetectiveOpList.begin(); + while( (aItr != aDetectiveOpList.end()) && (aItr->aPosition == rMyCell.aCellAddress) ) + { + rMyCell.aDetectiveOpVec.push_back( *aItr ); + aItr = aDetectiveOpList.erase( aItr ); + } + rMyCell.bHasDetectiveOp = (rMyCell.aDetectiveOpVec.size() != 0); +} + +void ScMyDetectiveOpContainer::Sort() +{ + aDetectiveOpList.sort(); +} + +//============================================================================== + +ScMyCell::ScMyCell() : + aShapeList(), + aDetectiveObjVec(), + bHasShape( sal_False ), + bIsMergedBase( sal_False ), + bIsCovered( sal_False ), + bHasAreaLink( sal_False ), + bHasEmptyDatabase( sal_False ), + bHasDetectiveObj( sal_False ), + bHasDetectiveOp( sal_False ), + bIsMatrixBase( sal_False ), + bIsMatrixCovered( sal_False ), + bHasAnnotation( sal_False ), + bIsAutoStyle( sal_False ), + bIsEditCell( sal_False ), + bKnowWhetherIsEditCell( sal_False ), + bHasStringValue( sal_False ), + bHasDoubleValue( sal_False ), + bHasXText( sal_False ) +{ +} + +ScMyCell::~ScMyCell() +{ +} + +//============================================================================== + +sal_Bool ScMyExportAnnotation::operator<(const ScMyExportAnnotation& rAnno) const +{ + if( aCellAddress.Row != rAnno.aCellAddress.Row ) + return (aCellAddress.Row < rAnno.aCellAddress.Row); + else + return (aCellAddress.Column < rAnno.aCellAddress.Column); +} + + +ScMyNotEmptyCellsIterator::ScMyNotEmptyCellsIterator(ScXMLExport& rTempXMLExport) + : rExport(rTempXMLExport), + pCellItr(NULL), + pShapes(NULL), + pMergedRanges(NULL), + pAreaLinks(NULL), + pEmptyDatabaseRanges(NULL), + pDetectiveObj(NULL), + pDetectiveOp(NULL), + nCurrentTable(-1) +{ +} + +ScMyNotEmptyCellsIterator::~ScMyNotEmptyCellsIterator() +{ + Clear(); +} + +void ScMyNotEmptyCellsIterator::Clear() +{ + if (pCellItr) + delete pCellItr; + if (!aAnnotations.empty()) + { + DBG_ERROR("not all Annotations saved"); + aAnnotations.clear(); + } + pCellItr = NULL; + pShapes = NULL; + pMergedRanges = NULL; + pAreaLinks = NULL; + pEmptyDatabaseRanges = NULL; + pDetectiveObj = NULL; + pDetectiveOp = NULL; + nCurrentTable = -1; +} + +void ScMyNotEmptyCellsIterator::UpdateAddress( table::CellAddress& rAddress ) +{ + if( pCellItr->ReturnNext( nCellCol, nCellRow ) ) + { + rAddress.Column = nCellCol; + rAddress.Row = nCellRow; + } +} + +void ScMyNotEmptyCellsIterator::SetCellData( ScMyCell& rMyCell, table::CellAddress& rAddress ) +{ + rMyCell.aCellAddress = rAddress; + rMyCell.bHasStringValue = sal_False; + rMyCell.bHasDoubleValue = sal_False; + rMyCell.bHasXText = sal_False; + rMyCell.bKnowWhetherIsEditCell = sal_False; + rMyCell.bIsEditCell = sal_False; + if( (nCellCol == rAddress.Column) && (nCellRow == rAddress.Row) ) + pCellItr->GetNext( nCellCol, nCellRow ); +} + +void ScMyNotEmptyCellsIterator::SetMatrixCellData( ScMyCell& rMyCell ) +{ + rMyCell.bIsMatrixCovered = sal_False; + rMyCell.bIsMatrixBase = sal_False; + + sal_Bool bIsMatrixBase(sal_False); + rMyCell.nType = rMyCell.xCell->getType(); + if (rMyCell.nType == table::CellContentType_FORMULA) + if( rExport.IsMatrix( rMyCell.xCell, xTable, rMyCell.aCellAddress.Column, rMyCell.aCellAddress.Row, + rMyCell.aMatrixRange, bIsMatrixBase ) ) + { + rMyCell.bIsMatrixBase = bIsMatrixBase; + rMyCell.bIsMatrixCovered = !bIsMatrixBase; + } +} + +void ScMyNotEmptyCellsIterator::HasAnnotation(ScMyCell& aCell) +{ + aCell.bHasAnnotation = sal_False; + if (!aAnnotations.empty()) + { + ScMyExportAnnotationList::iterator aItr = aAnnotations.begin(); + if ((aCell.aCellAddress.Column == aItr->aCellAddress.Column) && + (aCell.aCellAddress.Row == aItr->aCellAddress.Row)) + { + aCell.xAnnotation = aItr->xAnnotation; + uno::Reference<text::XSimpleText> xSimpleText(aCell.xAnnotation, uno::UNO_QUERY); + if (aCell.xAnnotation.is() && xSimpleText.is()) + { + aCell.sAnnotationText = xSimpleText->getString(); + if (aCell.sAnnotationText.getLength()) + aCell.bHasAnnotation = sal_True; + } + aAnnotations.erase(aItr); + } + } + if (xCellRange.is()) + aCell.xCell = xCellRange->getCellByPosition(aCell.aCellAddress.Column, aCell.aCellAddress.Row); +} + +void ScMyNotEmptyCellsIterator::SetCurrentTable(const sal_Int32 nTable, + uno::Reference<sheet::XSpreadsheet>& rxTable) +{ + DBG_ASSERT(aAnnotations.empty(), "not all Annotations saved"); + aLastAddress.Row = 0; + aLastAddress.Column = 0; + aLastAddress.Sheet = static_cast<sal_Int16>(nTable); + if (nCurrentTable != nTable) + { + nCurrentTable = static_cast<sal_Int16>(nTable); + if (pCellItr) + delete pCellItr; + pCellItr = new ScHorizontalCellIterator(rExport.GetDocument(), nCurrentTable, 0, 0, + static_cast<USHORT>(rExport.GetSharedData()->GetLastColumn(nCurrentTable)), static_cast<USHORT>(rExport.GetSharedData()->GetLastRow(nCurrentTable))); + xTable = rxTable; + xCellRange = uno::Reference<table::XCellRange>(xTable, uno::UNO_QUERY); + uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery (xTable, uno::UNO_QUERY); + uno::Reference<sheet::XSheetAnnotationsSupplier> xSheetAnnotationsSupplier (xTable, uno::UNO_QUERY); + if (xSheetAnnotationsSupplier.is()) + { + uno::Reference<container::XEnumerationAccess> xAnnotationAccess ( xSheetAnnotationsSupplier->getAnnotations(), uno::UNO_QUERY); + if (xAnnotationAccess.is()) + { + uno::Reference<container::XEnumeration> xAnnotations = xAnnotationAccess->createEnumeration(); + if (xAnnotations.is()) + { + while (xAnnotations->hasMoreElements()) + { + uno::Any aAny = xAnnotations->nextElement(); + ScMyExportAnnotation aAnnotation; + if (aAny >>= aAnnotation.xAnnotation) + { + aAnnotation.aCellAddress = aAnnotation.xAnnotation->getPosition(); + aAnnotations.push_back(aAnnotation); + } + } + if (!aAnnotations.empty()) + aAnnotations.sort(); + } + } + } + } +} + +sal_Bool ScMyNotEmptyCellsIterator::GetNext(ScMyCell& aCell, ScFormatRangeStyles* pCellStyles) +{ + table::CellAddress aAddress( nCurrentTable, MAXCOL + 1, MAXROW + 1 ); + + UpdateAddress( aAddress ); + if( pShapes ) + pShapes->UpdateAddress( aAddress ); + if( pEmptyDatabaseRanges ) + pEmptyDatabaseRanges->UpdateAddress( aAddress ); + if( pMergedRanges ) + pMergedRanges->UpdateAddress( aAddress ); + if( pAreaLinks ) + pAreaLinks->UpdateAddress( aAddress ); + if( pDetectiveObj ) + pDetectiveObj->UpdateAddress( aAddress ); + if( pDetectiveOp ) + pDetectiveOp->UpdateAddress( aAddress ); + + sal_Bool bFoundCell = (aAddress.Column <= MAXCOL) && (aAddress.Row <= MAXROW); + if( bFoundCell ) + { + SetCellData( aCell, aAddress ); + if( pShapes ) + pShapes->SetCellData( aCell ); + if( pEmptyDatabaseRanges ) + pEmptyDatabaseRanges->SetCellData( aCell ); + if( pMergedRanges ) + pMergedRanges->SetCellData( aCell ); + if( pAreaLinks ) + pAreaLinks->SetCellData( aCell ); + if( pDetectiveObj ) + pDetectiveObj->SetCellData( aCell ); + if( pDetectiveOp ) + pDetectiveOp->SetCellData( aCell ); + + HasAnnotation( aCell ); + SetMatrixCellData( aCell ); + sal_Bool bIsAutoStyle; + sal_Bool bRemoveStyleRange((aLastAddress.Row == aCell.aCellAddress.Row) && + (aLastAddress.Column + 1 == aCell.aCellAddress.Column)); + aCell.nStyleIndex = pCellStyles->GetStyleNameIndex(aCell.aCellAddress.Sheet, + aCell.aCellAddress.Column, aCell.aCellAddress.Row, + bIsAutoStyle, aCell.nValidationIndex, aCell.nNumberFormat, bRemoveStyleRange); + aLastAddress = aCell.aCellAddress; + aCell.bIsAutoStyle = bIsAutoStyle; + + //#102799#; if the cell is in a DatabaseRange which should saved empty, the cell should have the type empty + if (aCell.bHasEmptyDatabase) + aCell.nType = table::CellContentType_EMPTY; + } + return bFoundCell; +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_XMLExportSharedData.cxx b/binfilter/bf_sc/source/filter/xml/sc_XMLExportSharedData.cxx new file mode 100644 index 000000000000..9cde3afc022c --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_XMLExportSharedData.cxx @@ -0,0 +1,150 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- +#include "XMLExportSharedData.hxx" +#include "XMLExportIterator.hxx" + +#include <tools/debug.hxx> +namespace binfilter { + +using namespace ::com::sun::star; + +ScMySharedData::ScMySharedData(const sal_Int32 nTempTableCount) : + nLastColumns(nTempTableCount, 0), + nLastRows(nTempTableCount, 0), + pTableShapes(NULL), + pDrawPages(NULL), + pShapesContainer(NULL), + pDetectiveObjContainer(NULL), + nTableCount(nTempTableCount) +{ + pDetectiveObjContainer = new ScMyDetectiveObjContainer(); +} + +ScMySharedData::~ScMySharedData() +{ + if (pShapesContainer) + delete pShapesContainer; + if (pTableShapes) + delete pTableShapes; + if (pDrawPages) + delete pDrawPages; + if (pDetectiveObjContainer) + delete pDetectiveObjContainer; +} + +void ScMySharedData::SetLastColumn(const sal_Int32 nTable, const sal_Int32 nCol) +{ + if(nCol > nLastColumns[nTable]) nLastColumns[nTable] = nCol; +} + +sal_Int32 ScMySharedData::GetLastColumn(const sal_Int32 nTable) +{ + return nLastColumns[nTable]; +} + +void ScMySharedData::SetLastRow(const sal_Int32 nTable, const sal_Int32 nRow) +{ + if(nRow > nLastRows[nTable]) nLastRows[nTable] = nRow; +} + +sal_Int32 ScMySharedData::GetLastRow(const sal_Int32 nTable) +{ + return nLastRows[nTable]; +} + +void ScMySharedData::AddDrawPage(const ScMyDrawPage& aDrawPage, const sal_Int32 nTable) +{ + if (!pDrawPages) + pDrawPages = new ScMyDrawPages(nTableCount, ScMyDrawPage()); + (*pDrawPages)[nTable] = aDrawPage; +} + +void ScMySharedData::SetDrawPageHasForms(const sal_Int32 nTable, sal_Bool bHasForms) +{ + DBG_ASSERT(pDrawPages, "DrawPages not collected"); + if (pDrawPages) + (*pDrawPages)[nTable].bHasForms = bHasForms; +} + +uno::Reference<drawing::XDrawPage> ScMySharedData::GetDrawPage(const sal_Int32 nTable) +{ + DBG_ASSERT(pDrawPages, "DrawPages not collected"); + if (pDrawPages) + return (*pDrawPages)[nTable].xDrawPage; + else + return uno::Reference<drawing::XDrawPage>(); +} + +sal_Bool ScMySharedData::HasForm(const sal_Int32 nTable, uno::Reference<drawing::XDrawPage>& xDrawPage) +{ + sal_Bool bResult(sal_False); + if (pDrawPages) + { + if ((*pDrawPages)[nTable].bHasForms) + { + bResult = sal_True; + xDrawPage = (*pDrawPages)[nTable].xDrawPage; + } + } + return bResult; +} + +void ScMySharedData::AddNewShape(const ScMyShape& aMyShape) +{ + if (!pShapesContainer) + pShapesContainer = new ScMyShapesContainer(); + pShapesContainer->AddNewShape(aMyShape); +} + +void ScMySharedData::SortShapesContainer() +{ + if (pShapesContainer) + pShapesContainer->Sort(); +} + +sal_Bool ScMySharedData::HasShapes() +{ + return ((pShapesContainer && pShapesContainer->HasShapes()) || + (pTableShapes && !pTableShapes->empty())); +} + +void ScMySharedData::AddTableShape(const sal_Int32 nTable, const uno::Reference<drawing::XShape>& xShape) +{ + if (!pTableShapes) + pTableShapes = new ScMyTableShapes(nTableCount); + (*pTableShapes)[nTable].push_back(xShape); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_XMLStylesExportHelper.cxx b/binfilter/bf_sc/source/filter/xml/sc_XMLStylesExportHelper.cxx new file mode 100644 index 000000000000..2bce8af44163 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_XMLStylesExportHelper.cxx @@ -0,0 +1,1185 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "XMLStylesExportHelper.hxx" + +#include "unonames.hxx" +#include "XMLConverter.hxx" +#include "xmlexprt.hxx" +#include "document.hxx" + +#include <bf_xmloff/xmlnmspe.hxx> +#include <bf_xmloff/XMLEventExport.hxx> + +#include <tools/debug.hxx> +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/sheet/XSheetCondition.hpp> + +#include <algorithm> +namespace binfilter { + +using namespace ::com::sun::star; +using namespace xmloff::token; + +ScMyValidation::ScMyValidation() + : sName(), + sErrorMessage(), + sErrorTitle(), + sImputMessage(), + sImputTitle(), + sFormula1(), + sFormula2(), + bShowErrorMessage(sal_False), + bShowImputMessage(sal_False), + bIgnoreBlanks(sal_False) +{ +} + +ScMyValidation::~ScMyValidation() +{ +} + +sal_Bool ScMyValidation::IsEqual(const ScMyValidation& aVal) const +{ + if (aVal.bIgnoreBlanks == bIgnoreBlanks && + aVal.bShowImputMessage == bShowImputMessage && + aVal.bShowErrorMessage == bShowErrorMessage && + aVal.aBaseCell.Sheet == aBaseCell.Sheet && + aVal.aBaseCell.Column == aBaseCell.Column && + aVal.aBaseCell.Row == aBaseCell.Row && + aVal.aAlertStyle == aAlertStyle && + aVal.aValidationType == aValidationType && + aVal.aOperator == aOperator && + aVal.sErrorTitle == sErrorTitle && + aVal.sImputTitle == sImputTitle && + aVal.sErrorMessage == sErrorMessage && + aVal.sImputMessage == sImputMessage && + aVal.sFormula1 == sFormula1 && + aVal.sFormula2 == sFormula2) + return sal_True; + else + return sal_False; +} + +ScMyValidationsContainer::ScMyValidationsContainer() + : aValidationVec(), + sEmptyString(), + sERRALSTY(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ERRALSTY)), + sIGNOREBL(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_IGNOREBL)), + sTYPE(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_TYPE)), + sSHOWINP(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_SHOWINP)), + sSHOWERR(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_SHOWERR)), + sINPTITLE(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_INPTITLE)), + sINPMESS(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_INPMESS)), + sERRTITLE(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ERRTITLE)), + sERRMESS(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ERRMESS)), + sOnError(RTL_CONSTASCII_USTRINGPARAM("OnError")), + sEventType(RTL_CONSTASCII_USTRINGPARAM("EventType")), + sStarBasic(RTL_CONSTASCII_USTRINGPARAM("StarBasic")), + sLibrary(RTL_CONSTASCII_USTRINGPARAM("Library")), + sMacroName(RTL_CONSTASCII_USTRINGPARAM("MacroName")) +{ +} + +ScMyValidationsContainer::~ScMyValidationsContainer() +{ +} + +sal_Bool ScMyValidationsContainer::AddValidation(const uno::Any& aTempAny, + sal_Int32& nValidationIndex) +{ + sal_Bool bAdded(sal_False); + uno::Reference<beans::XPropertySet> xPropertySet; + if (aTempAny >>= xPropertySet) + { + uno::Any aAny = xPropertySet->getPropertyValue(sERRMESS); + ::rtl::OUString sErrorMessage; + aAny >>= sErrorMessage; + aAny = xPropertySet->getPropertyValue(sERRTITLE); + ::rtl::OUString sErrorTitle; + aAny >>= sErrorTitle; + aAny = xPropertySet->getPropertyValue(sINPMESS); + ::rtl::OUString sImputMessage; + aAny >>= sImputMessage; + aAny = xPropertySet->getPropertyValue(sINPTITLE); + ::rtl::OUString sImputTitle; + aAny >>= sImputTitle; + aAny = xPropertySet->getPropertyValue(sSHOWERR); + sal_Bool bShowErrorMessage; + aAny >>= bShowErrorMessage; + aAny = xPropertySet->getPropertyValue(sSHOWINP); + sal_Bool bShowImputMessage; + aAny >>= bShowImputMessage; + aAny = xPropertySet->getPropertyValue(sTYPE); + sheet::ValidationType aValidationType; + aAny >>= aValidationType; + if (bShowErrorMessage || bShowImputMessage || aValidationType != sheet::ValidationType_ANY || + sErrorMessage.getLength() || sErrorTitle.getLength() || sImputMessage.getLength() || sImputTitle.getLength()) + { + ScMyValidation aValidation; + aValidation.sErrorMessage = sErrorMessage; + aValidation.sErrorTitle = sErrorTitle; + aValidation.sImputMessage = sImputMessage; + aValidation.sImputTitle = sImputTitle; + aValidation.bShowErrorMessage = bShowErrorMessage; + aValidation.bShowImputMessage = bShowImputMessage; + aValidation.aValidationType = aValidationType; + aAny = xPropertySet->getPropertyValue(sIGNOREBL); + sal_Bool bIgnoreBlanks(sal_False); + aAny >>= bIgnoreBlanks; + aValidation.bIgnoreBlanks = bIgnoreBlanks; + aAny = xPropertySet->getPropertyValue(sERRALSTY); + aAny >>= aValidation.aAlertStyle; + uno::Reference<sheet::XSheetCondition> xCondition(xPropertySet, uno::UNO_QUERY); + if (xCondition.is()) + { + aValidation.sFormula1 = xCondition->getFormula1(); + aValidation.sFormula2 = xCondition->getFormula2(); + aValidation.aOperator = xCondition->getOperator(); + aValidation.aBaseCell = xCondition->getSourcePosition(); + } + //ScMyValidationRange aValidationRange; + sal_Bool bEqualFound(sal_False); + sal_Int32 i = 0; + sal_Int32 nCount = aValidationVec.size(); + while (i < nCount && !bEqualFound) + { + bEqualFound = aValidationVec[i].IsEqual(aValidation); + if (!bEqualFound) + i++; + } + if (bEqualFound) + nValidationIndex = i; + else + { + sal_Int32 nNameIndex = nCount + 1; + ::rtl::OUString sCount = ::rtl::OUString::valueOf(nNameIndex); + ::rtl::OUString sPrefix(RTL_CONSTASCII_USTRINGPARAM("val")); + aValidation.sName += sPrefix; + aValidation.sName += sCount; + aValidationVec.push_back(aValidation); + nValidationIndex = nCount; + bAdded = sal_True; + } + } + } + return bAdded; +} + +rtl::OUString ScMyValidationsContainer::GetCondition(const ScMyValidation& aValidation) +{ + ::rtl::OUString sCondition; + if (aValidation.aValidationType != sheet::ValidationType_ANY) + { + switch (aValidation.aValidationType) + { + //case sheet::ValidationType_CUSTOM + case sheet::ValidationType_DATE : + sCondition += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-date()")); + break; + case sheet::ValidationType_DECIMAL : + sCondition += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-decimal-number()")); + break; + //case sheet::ValidationType_LIST : + case sheet::ValidationType_TEXT_LEN : + if (aValidation.aOperator != sheet::ConditionOperator_BETWEEN && + aValidation.aOperator != sheet::ConditionOperator_NOT_BETWEEN) + sCondition += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length()")); + break; + case sheet::ValidationType_TIME : + sCondition += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-time()")); + break; + case sheet::ValidationType_WHOLE : + sCondition += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-whole-number()")); + break; + } + if (aValidation.sFormula1.getLength() || + (aValidation.aOperator == sheet::ConditionOperator_BETWEEN && + aValidation.aOperator == sheet::ConditionOperator_NOT_BETWEEN && + aValidation.sFormula2.getLength())) + { + if (aValidation.aValidationType != sheet::ValidationType_TEXT_LEN) + sCondition += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" and ")); + if (aValidation.aOperator != sheet::ConditionOperator_BETWEEN && + aValidation.aOperator != sheet::ConditionOperator_NOT_BETWEEN) + { + if (aValidation.aValidationType != sheet::ValidationType_TEXT_LEN) + sCondition += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content()")); + switch (aValidation.aOperator) + { + case sheet::ConditionOperator_EQUAL : + sCondition += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=")); + break; + case sheet::ConditionOperator_GREATER : + sCondition += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(">")); + break; + case sheet::ConditionOperator_GREATER_EQUAL : + sCondition += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(">=")); + break; + case sheet::ConditionOperator_LESS : + sCondition += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("<")); + break; + case sheet::ConditionOperator_LESS_EQUAL : + sCondition += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("<=")); + break; + case sheet::ConditionOperator_NOT_EQUAL : + sCondition += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("!=")); + break; + } + sCondition += aValidation.sFormula1; + } + else + { + if (aValidation.aValidationType == sheet::ValidationType_TEXT_LEN) + { + if (aValidation.aOperator == sheet::ConditionOperator_BETWEEN) + sCondition += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length-is-between(")); + else + sCondition += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length-is-not-between(")); + } + else + { + if (aValidation.aOperator == sheet::ConditionOperator_BETWEEN) + sCondition += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-between(")); + else + sCondition += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-not-between(")); + } + sCondition += aValidation.sFormula1; + sCondition += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(",")); + sCondition += aValidation.sFormula2; + sCondition += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")")); + } + } + else + if (aValidation.aValidationType == sheet::ValidationType_TEXT_LEN) + sCondition = ::rtl::OUString(); + } + return sCondition; +} + +rtl::OUString ScMyValidationsContainer::GetBaseCellAddress(ScDocument* pDoc, const table::CellAddress& aCell) +{ + ::rtl::OUString sAddress; + ScXMLConverter::GetStringFromAddress( sAddress, aCell, pDoc ); + return sAddress; +} + +void ScMyValidationsContainer::WriteMessage(ScXMLExport& rExport, + const ::rtl::OUString& sTitle, const ::rtl::OUString& sOUMessage, + const sal_Bool bShowMessage, const sal_Bool bIsHelpMessage) +{ + if (sTitle.getLength()) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_TITLE, sTitle); + if (bShowMessage) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY, XML_TRUE); + else + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY, XML_FALSE); + SvXMLElementExport* pMessage = NULL; + if (bIsHelpMessage) + pMessage = new SvXMLElementExport(rExport, XML_NAMESPACE_TABLE, XML_HELP_MESSAGE, sal_True, sal_True); + else + pMessage = new SvXMLElementExport(rExport, XML_NAMESPACE_TABLE, XML_ERROR_MESSAGE, sal_True, sal_True); + if (sOUMessage.getLength()) + { + sal_Int32 i = 0; + ::rtl::OUStringBuffer sTemp; + String sMessage(sOUMessage); + ::rtl::OUString sText (sMessage.ConvertLineEnd(LINEEND_LF)); + sal_Bool bPrevCharWasSpace(sal_True); + while(i < sText.getLength()) + { + if ((sText[i] == '\n')) + { + SvXMLElementExport aElemP(rExport, XML_NAMESPACE_TEXT, XML_P, sal_True, sal_False); + rExport.GetTextParagraphExport()->exportText(sTemp.makeStringAndClear(), bPrevCharWasSpace); + } + else + sTemp.append(sText[i]); + i++; + } + if (sTemp.getLength()) + { + SvXMLElementExport aElemP(rExport, XML_NAMESPACE_TEXT, XML_P, sal_True, sal_False); + rExport.GetTextParagraphExport()->exportText(sTemp.makeStringAndClear(), bPrevCharWasSpace); + } + } + if (pMessage) + delete pMessage; +} + +void ScMyValidationsContainer::WriteValidations(ScXMLExport& rExport) +{ + if (aValidationVec.size()) + { + SvXMLElementExport aElemVs(rExport, XML_NAMESPACE_TABLE, XML_CONTENT_VALIDATIONS, sal_True, sal_True); + ScMyValidationVec::iterator aItr = aValidationVec.begin(); + while (aItr != aValidationVec.end()) + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, aItr->sName); + ::rtl::OUString sCondition = GetCondition(*aItr); + if (sCondition.getLength()) + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CONDITION, sCondition); + if (aItr->bIgnoreBlanks) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ALLOW_EMPTY_CELL, XML_FALSE); + else + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ALLOW_EMPTY_CELL, XML_TRUE); + } + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_BASE_CELL_ADDRESS, GetBaseCellAddress(rExport.GetDocument(), aItr->aBaseCell)); + SvXMLElementExport aElemV(rExport, XML_NAMESPACE_TABLE, XML_CONTENT_VALIDATION, sal_True, sal_True); + if (aItr->bShowImputMessage || aItr->sImputMessage.getLength() || aItr->sImputTitle.getLength()) + { + WriteMessage(rExport, aItr->sImputTitle, aItr->sImputMessage, aItr->bShowImputMessage, sal_True); + } + if (aItr->bShowErrorMessage || aItr->sErrorMessage.getLength() || aItr->sErrorTitle.getLength()) + { + switch (aItr->aAlertStyle) + { + case sheet::ValidationAlertStyle_INFO : + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_MESSAGE_TYPE, XML_INFORMATION); + WriteMessage(rExport, aItr->sErrorTitle, aItr->sErrorMessage, aItr->bShowErrorMessage, sal_False); + } + break; + case sheet::ValidationAlertStyle_WARNING : + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_MESSAGE_TYPE, XML_WARNING); + WriteMessage(rExport, aItr->sErrorTitle, aItr->sErrorMessage, aItr->bShowErrorMessage, sal_False); + } + break; + case sheet::ValidationAlertStyle_STOP : + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_MESSAGE_TYPE, XML_STOP); + WriteMessage(rExport, aItr->sErrorTitle, aItr->sErrorMessage, aItr->bShowErrorMessage, sal_False); + } + break; + case sheet::ValidationAlertStyle_MACRO : + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, aItr->sErrorTitle); + if (aItr->bShowErrorMessage) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_EXECUTE, XML_TRUE); + else + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_EXECUTE, XML_FALSE); + SvXMLElementExport(rExport, XML_NAMESPACE_TABLE, XML_ERROR_MACRO, sal_True, sal_True); + { + uno::Sequence<beans::PropertyValue> aSeq(3); + beans::PropertyValue* pArr = aSeq.getArray(); + pArr[0].Name = sEventType; + pArr[0].Value <<= sStarBasic; + pArr[1].Name = sLibrary; + pArr[1].Value <<= sEmptyString; + pArr[2].Name = sMacroName; + pArr[2].Value <<= aItr->sErrorTitle; + + // 2) export the sequence + rExport.GetEventExport().ExportSingleEvent( aSeq, sOnError); + } + } + break; + } + } + aItr++; + } + } +} + +const ::rtl::OUString& ScMyValidationsContainer::GetValidationName(const sal_Int32 nIndex) +{ + DBG_ASSERT( static_cast<sal_uInt32>(nIndex) < aValidationVec.size(), "out of range" ); + return aValidationVec[nIndex].sName; +} + +//============================================================================== + +sal_Int32 ScMyDefaultStyles::GetStyleNameIndex(const ScFormatRangeStyles* pCellStyles, + const sal_uInt16 nTable, const sal_Int32 nPos, + const sal_Int32 i, const sal_Bool bRow, sal_Bool& bIsAutoStyle) +{ + if (bRow) + return pCellStyles->GetStyleNameIndex(nTable, nPos, i, + bIsAutoStyle); + else + return pCellStyles->GetStyleNameIndex(nTable, i, nPos, + bIsAutoStyle); +} + +void ScMyDefaultStyles::FillDefaultStyles(const sal_uInt16 nTable, + const sal_Int32 nLastRow, const sal_Int32 nLastCol, + const ScFormatRangeStyles* pCellStyles, ScDocument* pDoc, + const sal_Bool bRow) +{ + if (pDoc) + { + sal_uInt16 nPos; + sal_Int32 nLast; + ScMyDefaultStyleList* pDefaults; + if (bRow) + { + pDefaults = pRowDefaults; + nLast = nLastRow; + } + else + { + pDefaults = pColDefaults; + nLast = nLastCol; + } + sal_Bool bPrevAutoStyle; + sal_Bool bIsAutoStyle; + sal_Bool bResult; + sal_Int32 nPrevIndex; + sal_Int32 nIndex; + sal_Int32 nRepeat(0); + sal_Int32 nEmptyRepeat(0); + for (sal_Int32 i = nLast; i >= 0; i--) + { + if (bRow) + bResult = pDoc->GetRowDefault(nTable, + static_cast<sal_uInt16>(i), static_cast<sal_uInt16>(nLastCol), nPos); + else + bResult = pDoc->GetColDefault(nTable, + static_cast<sal_uInt16>(i), static_cast<sal_uInt16>(nLastRow), nPos); + if (bResult) + { + nEmptyRepeat = 0; + if (!nRepeat) + { + nPrevIndex = GetStyleNameIndex(pCellStyles, nTable, static_cast<sal_Int32>(nPos), i, + bRow, bPrevAutoStyle); + (*pDefaults)[i].nIndex = nPrevIndex; + (*pDefaults)[i].bIsAutoStyle = bPrevAutoStyle; + nRepeat = 1; + } + else + { + nIndex = GetStyleNameIndex(pCellStyles, nTable, static_cast<sal_Int32>(nPos), i, + bRow, bIsAutoStyle); + if ((nIndex != nPrevIndex) || (bIsAutoStyle != bPrevAutoStyle)) + { + nRepeat = 1; + nPrevIndex = GetStyleNameIndex(pCellStyles, nTable, static_cast<sal_Int32>(nPos), i, + bRow, bPrevAutoStyle); + (*pDefaults)[i].nIndex = nPrevIndex; + (*pDefaults)[i].bIsAutoStyle = bPrevAutoStyle; + } + else + { + (*pDefaults)[i].nIndex = nPrevIndex; + (*pDefaults)[i].bIsAutoStyle = bPrevAutoStyle; + nRepeat++; + if (nRepeat > 1) + (*pDefaults)[i].nRepeat = nRepeat; + } + } + } + else + { + nRepeat = 0; + if (!nEmptyRepeat) + nEmptyRepeat = 1; + else + { + nEmptyRepeat++; + if (nEmptyRepeat > 1) + (*pDefaults)[i].nRepeat = nEmptyRepeat; + } + } + } + } +} + +void ScMyDefaultStyles::FillDefaultStyles(const sal_uInt16 nTable, + const sal_Int32 nLastRow, const sal_Int32 nLastCol, + const ScFormatRangeStyles* pCellStyles, ScDocument* pDoc) +{ + if (pRowDefaults) + delete pRowDefaults; + pRowDefaults = new ScMyDefaultStyleList(nLastRow + 1); + FillDefaultStyles(nTable, nLastRow, nLastCol, pCellStyles, pDoc, sal_True); + if (pColDefaults) + delete pColDefaults; + pColDefaults = new ScMyDefaultStyleList(nLastCol + 1); + FillDefaultStyles(nTable, nLastRow, nLastCol, pCellStyles, pDoc, sal_False); +} + +ScMyDefaultStyles::~ScMyDefaultStyles() +{ + if (pRowDefaults) + delete pRowDefaults; + if (pColDefaults) + delete pColDefaults; +} + +ScMyRowFormatRange::ScMyRowFormatRange() + : nStartColumn(0), + nRepeatColumns(0), + nRepeatRows(0), + nIndex(-1), + nValidationIndex(-1), + bIsAutoStyle(sal_True) +{ +} + +sal_Bool ScMyRowFormatRange::operator< (const ScMyRowFormatRange& rRange) const +{ + return (nStartColumn < rRange.nStartColumn); +} + +ScRowFormatRanges::ScRowFormatRanges() + : pRowDefaults(NULL), + pColDefaults(NULL), + aRowFormatRanges(), + nSize(0) +{ +} + +ScRowFormatRanges::ScRowFormatRanges(const ScRowFormatRanges* pRanges) + : pRowDefaults(pRanges->pRowDefaults), + pColDefaults(pRanges->pColDefaults), + aRowFormatRanges(pRanges->aRowFormatRanges), + nSize(pRanges->nSize) +{ +} + +ScRowFormatRanges::~ScRowFormatRanges() +{ +} + +void ScRowFormatRanges::Clear() +{ + aRowFormatRanges.clear(); + nSize = 0; +} + +void ScRowFormatRanges::AddRange(const sal_Int32 nPrevStartCol, const sal_Int32 nRepeat, const sal_Int32 nPrevIndex, + const sal_Bool bPrevAutoStyle, const ScMyRowFormatRange& rFormatRange) +{ + sal_Int32 nIndex(-1); + if ((nPrevIndex != rFormatRange.nIndex) || + (bPrevAutoStyle != rFormatRange.bIsAutoStyle)) + nIndex = rFormatRange.nIndex; + + sal_Bool bInserted(sal_False); + if (!aRowFormatRanges.empty()) + { + ScMyRowFormatRange* pRange = &aRowFormatRanges.back(); + if (pRange) + { + if ((nPrevStartCol == (pRange->nStartColumn + pRange->nRepeatColumns)) && + (pRange->bIsAutoStyle == rFormatRange.bIsAutoStyle) && + (pRange->nIndex == nIndex) && + (pRange->nValidationIndex == rFormatRange.nValidationIndex)) + { + if (rFormatRange.nRepeatRows < pRange->nRepeatRows) + pRange->nRepeatRows = rFormatRange.nRepeatRows; + pRange->nRepeatColumns += nRepeat; + bInserted = sal_True; + } + } + } + if (!bInserted) + { + ScMyRowFormatRange aRange; + aRange.nStartColumn = nPrevStartCol; + aRange.nRepeatColumns = nRepeat; + aRange.nRepeatRows = rFormatRange.nRepeatRows; + aRange.nValidationIndex = rFormatRange.nValidationIndex; + aRange.bIsAutoStyle = rFormatRange.bIsAutoStyle; + aRange.nIndex = nIndex; + aRowFormatRanges.push_back(aRange); + nSize++; + } +} + +void ScRowFormatRanges::AddRange(ScMyRowFormatRange& rFormatRange, + const sal_Int32 nRow) +{ + DBG_ASSERT(pRowDefaults, "no row defaults"); + DBG_ASSERT(pColDefaults, "no column defaults"); + sal_uInt32 nEnd (rFormatRange.nRepeatRows + nRow - 1); + sal_Int32 nPrevIndex((*pRowDefaults)[nRow].nIndex); + sal_Bool bPrevAutoStyle((*pRowDefaults)[nRow].bIsAutoStyle); + sal_uInt32 i(nRow + 1); + sal_Bool bReady(sal_False); + while ((i < nEnd) && !bReady && (i < pRowDefaults->size())) + { + if ((nPrevIndex != (*pRowDefaults)[i].nIndex) || + (bPrevAutoStyle != (*pRowDefaults)[i].bIsAutoStyle)) + bReady = sal_True; + else + i += (*pRowDefaults)[i].nRepeat; + } + if (i > nEnd) + i = nEnd; + if (bReady) + rFormatRange.nRepeatRows = i - nRow + 1; + if (nPrevIndex == -1) + { + nPrevIndex = (*pColDefaults)[rFormatRange.nStartColumn].nIndex; + bPrevAutoStyle = (*pColDefaults)[rFormatRange.nStartColumn].bIsAutoStyle; + sal_uInt32 nPrevStartCol(rFormatRange.nStartColumn); + sal_uInt32 nRepeat((*pColDefaults)[rFormatRange.nStartColumn].nRepeat); + nEnd = rFormatRange.nStartColumn + rFormatRange.nRepeatColumns; + for(i = nPrevStartCol + nRepeat; i < nEnd; i += (*pColDefaults)[i].nRepeat) + { + DBG_ASSERT(sal_uInt32(nPrevStartCol + nRepeat) <= nEnd, "something wents wrong"); + if ((nPrevIndex != (*pColDefaults)[i].nIndex) || + (bPrevAutoStyle != (*pColDefaults)[i].bIsAutoStyle)) + { + AddRange(nPrevStartCol, nRepeat, nPrevIndex, bPrevAutoStyle, rFormatRange); + nPrevStartCol = i; + nRepeat = (*pColDefaults)[i].nRepeat; + nPrevIndex = (*pColDefaults)[i].nIndex; + bPrevAutoStyle = (*pColDefaults)[i].bIsAutoStyle; + } + else + nRepeat += (*pColDefaults)[i].nRepeat; + } + if (sal_uInt32(nPrevStartCol + nRepeat) > nEnd) + nRepeat = nEnd - nPrevStartCol; + AddRange(nPrevStartCol, nRepeat, nPrevIndex, bPrevAutoStyle, rFormatRange); + } + else if ((nPrevIndex == rFormatRange.nIndex) && + (bPrevAutoStyle == rFormatRange.bIsAutoStyle)) + { + rFormatRange.nIndex = -1; + aRowFormatRanges.push_back(rFormatRange); + nSize++; + } +} + +sal_Bool ScRowFormatRanges::GetNext(ScMyRowFormatRange& aFormatRange) +{ + ScMyRowFormatRangesList::iterator aItr = aRowFormatRanges.begin(); + if (aItr != aRowFormatRanges.end()) + { + aFormatRange = (*aItr); + aRowFormatRanges.erase(aItr); + nSize--; + return sal_True; + } + return sal_False; +} + +sal_Int32 ScRowFormatRanges::GetMaxRows() +{ + ScMyRowFormatRangesList::iterator aItr = aRowFormatRanges.begin(); + sal_Int32 nMaxRows = MAXROW + 1; + if (aItr != aRowFormatRanges.end()) + while (aItr != aRowFormatRanges.end()) + { + if ((*aItr).nRepeatRows < nMaxRows) + nMaxRows = (*aItr).nRepeatRows; + aItr++; + } + else + DBG_ERROR("no ranges found"); + return nMaxRows; +} + +sal_Int32 ScRowFormatRanges::GetSize() +{ + return nSize; +} + +void ScRowFormatRanges::Sort() +{ + aRowFormatRanges.sort(); +} + +// ============================================================================ +ScMyFormatRange::ScMyFormatRange() + : nStyleNameIndex(-1), + nValidationIndex(-1), + bIsAutoStyle(sal_True) +{ +} + +sal_Bool ScMyFormatRange::operator<(const ScMyFormatRange& rRange) const +{ + if (aRangeAddress.StartRow < rRange.aRangeAddress.StartRow) + return sal_True; + else + if (aRangeAddress.StartRow == rRange.aRangeAddress.StartRow) + return (aRangeAddress.StartColumn < rRange.aRangeAddress.StartColumn); + else + return sal_False; +} + +ScFormatRangeStyles::ScFormatRangeStyles() + : aTables(), + aStyleNames(), + aAutoStyleNames() +{ +} + +ScFormatRangeStyles::~ScFormatRangeStyles() +{ + ScMyOUStringVec::iterator i = aStyleNames.begin(); + while (i != aStyleNames.end()) + { + delete *i; + i++; + } + i = aAutoStyleNames.begin(); + while (i != aAutoStyleNames.end()) + { + delete *i; + i++; + } + ScMyFormatRangeListVec::iterator j = aTables.begin(); + while (j != aTables.end()) + { + delete *j; + j++; + } +} + +void ScFormatRangeStyles::AddNewTable(const sal_Int16 nTable) +{ + sal_Int16 nSize = aTables.size() - 1; + if (nTable > nSize) + for (sal_Int16 i = nSize; i < nTable; i++) + { + ScMyFormatRangeAddresses* aRangeAddresses = new ScMyFormatRangeAddresses; + aTables.push_back(aRangeAddresses); + } +} + +sal_Bool ScFormatRangeStyles::AddStyleName(::rtl::OUString* rpString, sal_Int32& rIndex, const sal_Bool bIsAutoStyle) +{ + if (bIsAutoStyle) + { + aAutoStyleNames.push_back(rpString); + rIndex = aAutoStyleNames.size() - 1; + return sal_True; + } + else + { + sal_Int32 nCount = aStyleNames.size(); + sal_Bool bFound(sal_False); + sal_Int32 i = nCount - 1; + while ((i >= 0) && (!bFound)) + { + if (aStyleNames.at(i)->equals(*rpString)) + bFound = sal_True; + else + i--; + } + if (bFound) + { + rIndex = i; + return sal_False; + } + else + { + aStyleNames.push_back(rpString); + rIndex = aStyleNames.size() - 1; + return sal_True; + } + } +} + +sal_Int32 ScFormatRangeStyles::GetIndexOfStyleName(const ::rtl::OUString& rString, const ::rtl::OUString& rPrefix, sal_Bool& bIsAutoStyle) +{ + sal_Int32 nPrefixLength = rPrefix.getLength(); + ::rtl::OUString sTemp = rString.copy(nPrefixLength); + sal_Int32 nIndex = sTemp.toInt32(); + if (aAutoStyleNames.at(nIndex - 1)->equals(rString)) + { + bIsAutoStyle = sal_True; + return nIndex - 1; + } + else + { + sal_Int32 i = 0; + sal_Bool bFound(sal_False); + while (!bFound && static_cast<sal_uInt32>(i) < aStyleNames.size()) + { + if (aStyleNames[i]->equals(rString)) + bFound = sal_True; + else + i++; + } + if (bFound) + { + bIsAutoStyle = sal_False; + return i; + } + else + { + i = 0; + while (!bFound && static_cast<sal_uInt32>(i) < aAutoStyleNames.size()) + { + if (aAutoStyleNames[i]->equals(rString)) + bFound = sal_True; + else + i++; + } + if (bFound) + { + bIsAutoStyle = sal_True; + return i; + } + else + return -1; + } + } +} + +sal_Int32 ScFormatRangeStyles::GetStyleNameIndex(const sal_uInt16 nTable, + const sal_Int32 nColumn, const sal_Int32 nRow, sal_Bool& bIsAutoStyle) const +{ + DBG_ASSERT(static_cast<sal_uInt32>(nTable) < aTables.size(), "wrong table"); + ScMyFormatRangeAddresses* pFormatRanges = aTables[nTable]; + ScMyFormatRangeAddresses::iterator aItr = pFormatRanges->begin(); + while (aItr != pFormatRanges->end()) + { + if (((*aItr).aRangeAddress.StartColumn <= nColumn) && + ((*aItr).aRangeAddress.EndColumn >= nColumn) && + ((*aItr).aRangeAddress.StartRow <= nRow) && + ((*aItr).aRangeAddress.EndRow >= nRow)) + { + bIsAutoStyle = aItr->bIsAutoStyle; + return (*aItr).nStyleNameIndex; + } + else + aItr++; + } + return -1; +} + +sal_Int32 ScFormatRangeStyles::GetStyleNameIndex(const sal_uInt16 nTable, const sal_Int32 nColumn, const sal_Int32 nRow, + sal_Bool& bIsAutoStyle, sal_Int32& nValidationIndex, sal_Int32& nNumberFormat, const sal_Bool bRemoveRange) +{ + DBG_ASSERT(static_cast<sal_uInt32>(nTable) < aTables.size(), "wrong table"); + ScMyFormatRangeAddresses* pFormatRanges = aTables[nTable]; + ScMyFormatRangeAddresses::iterator aItr = pFormatRanges->begin(); + while (aItr != pFormatRanges->end()) + { + if (((*aItr).aRangeAddress.StartColumn <= nColumn) && + ((*aItr).aRangeAddress.EndColumn >= nColumn) && + ((*aItr).aRangeAddress.StartRow <= nRow) && + ((*aItr).aRangeAddress.EndRow >= nRow)) + { + bIsAutoStyle = aItr->bIsAutoStyle; + nValidationIndex = aItr->nValidationIndex; + nNumberFormat = aItr->nNumberFormat; + if (((*pRowDefaults)[nRow].nIndex != -1)) + { + if (((*pRowDefaults)[nRow].nIndex == (*aItr).nStyleNameIndex) && + ((*pRowDefaults)[nRow].bIsAutoStyle == (*aItr).bIsAutoStyle)) + return -1; + else + return (*aItr).nStyleNameIndex; + } + else if (((*pColDefaults)[nColumn].nIndex != -1) && + ((*pColDefaults)[nColumn].nIndex == (*aItr).nStyleNameIndex) && + ((*pColDefaults)[nColumn].bIsAutoStyle == (*aItr).bIsAutoStyle)) + return -1; + else + return (*aItr).nStyleNameIndex; + } + else + { + if (bRemoveRange && (*aItr).aRangeAddress.EndRow < nRow) + aItr = pFormatRanges->erase(aItr); + else + aItr++; + } + } + return -1; +} + +void ScFormatRangeStyles::GetFormatRanges(const sal_Int32 nStartColumn, const sal_Int32 nEndColumn, const sal_Int32 nRow, + const sal_Int16 nTable, ScRowFormatRanges* pRowFormatRanges) +{ + sal_Int32 nTotalColumns = nEndColumn - nStartColumn + 1; + DBG_ASSERT(static_cast<sal_uInt32>(nTable) < aTables.size(), "wrong table"); + ScMyFormatRangeAddresses* pFormatRanges = aTables[nTable]; + ScMyFormatRangeAddresses::iterator aItr = pFormatRanges->begin(); + sal_Int32 nColumns = 0; + while (aItr != pFormatRanges->end() && nColumns < nTotalColumns) + { +#if OSL_DEBUG_LEVEL > 1 + table::CellRangeAddress aTempRangeAddress = (*aItr).aRangeAddress; +#endif + if (((*aItr).aRangeAddress.StartRow <= nRow) && + ((*aItr).aRangeAddress.EndRow >= nRow)) + { + if ((((*aItr).aRangeAddress.StartColumn <= nStartColumn) && + ((*aItr).aRangeAddress.EndColumn >= nStartColumn)) || + (((*aItr).aRangeAddress.StartColumn <= nEndColumn) && + ((*aItr).aRangeAddress.EndColumn >= nEndColumn)) || + (((*aItr).aRangeAddress.StartColumn >= nStartColumn) && + ((*aItr).aRangeAddress.EndColumn <= nEndColumn))) + { + ScMyRowFormatRange aRange; + aRange.nIndex = aItr->nStyleNameIndex; + aRange.nValidationIndex = aItr->nValidationIndex; + aRange.bIsAutoStyle = aItr->bIsAutoStyle; + if ((aItr->aRangeAddress.StartColumn < nStartColumn) && + (aItr->aRangeAddress.EndColumn >= nStartColumn)) + { + if (aItr->aRangeAddress.EndColumn >= nEndColumn) + aRange.nRepeatColumns = nTotalColumns; + else + aRange.nRepeatColumns = aItr->aRangeAddress.EndColumn - nStartColumn + 1; + aRange.nStartColumn = nStartColumn; + } + else if ((aItr->aRangeAddress.StartColumn >= nStartColumn) && + (aItr->aRangeAddress.EndColumn <= nEndColumn)) + { + aRange.nRepeatColumns = aItr->aRangeAddress.EndColumn - aItr->aRangeAddress.StartColumn + 1; + aRange.nStartColumn = aItr->aRangeAddress.StartColumn; + } + else if ((aItr->aRangeAddress.StartColumn >= nStartColumn) && + (aItr->aRangeAddress.StartColumn <= nEndColumn) && + (aItr->aRangeAddress.EndColumn > nEndColumn)) + { + aRange.nRepeatColumns = nEndColumn - aItr->aRangeAddress.StartColumn + 1; + aRange.nStartColumn = aItr->aRangeAddress.StartColumn; + } + aRange.nRepeatRows = aItr->aRangeAddress.EndRow - nRow + 1; + pRowFormatRanges->AddRange(aRange, nRow); + nColumns += aRange.nRepeatColumns; + } + aItr++; + } + else + if(aItr->aRangeAddress.EndRow < nRow) + aItr = pFormatRanges->erase(aItr); + else + aItr++; + } + pRowFormatRanges->Sort(); +} + +void ScFormatRangeStyles::AddRangeStyleName(const table::CellRangeAddress aCellRangeAddress, + const sal_Int32 nStringIndex, const sal_Bool bIsAutoStyle, const sal_Int32 nValidationIndex, + const sal_Int32 nNumberFormat) +{ + ScMyFormatRange aFormatRange; + aFormatRange.aRangeAddress = aCellRangeAddress; + aFormatRange.nStyleNameIndex = nStringIndex; + aFormatRange.nValidationIndex = nValidationIndex; + aFormatRange.nNumberFormat = nNumberFormat; + aFormatRange.bIsAutoStyle = bIsAutoStyle; + DBG_ASSERT(static_cast<sal_uInt32>(aCellRangeAddress.Sheet) < aTables.size(), "wrong table"); + ScMyFormatRangeAddresses* pFormatRanges = aTables[aCellRangeAddress.Sheet]; + pFormatRanges->push_back(aFormatRange); +} + +rtl::OUString* ScFormatRangeStyles::GetStyleNameByIndex(const sal_Int32 nIndex, const sal_Bool bIsAutoStyle) +{ + if (bIsAutoStyle) + return aAutoStyleNames[nIndex]; + else + return aStyleNames[nIndex]; +} + +void ScFormatRangeStyles::Sort() +{ + sal_Int16 nTables = aTables.size(); + for (sal_Int16 i = 0; i < nTables; i++) + if (!aTables[i]->empty()) + aTables[i]->sort(); +} + +//=========================================================================== + +ScColumnRowStylesBase::ScColumnRowStylesBase() + : aStyleNames() +{ +} + +ScColumnRowStylesBase::~ScColumnRowStylesBase() +{ + ScMyOUStringVec::iterator i = aStyleNames.begin(); + while (i != aStyleNames.end()) + { + delete *i; + i++; + } +} + +sal_Int32 ScColumnRowStylesBase::AddStyleName(::rtl::OUString* pString) +{ + aStyleNames.push_back(pString); + return aStyleNames.size() - 1; +} + +sal_Int32 ScColumnRowStylesBase::GetIndexOfStyleName(const ::rtl::OUString& rString, const ::rtl::OUString& rPrefix) +{ + sal_Int32 nPrefixLength = rPrefix.getLength(); + ::rtl::OUString sTemp = rString.copy(nPrefixLength); + sal_Int32 nIndex = sTemp.toInt32(); + if (aStyleNames.at(nIndex - 1)->equals(rString)) + return nIndex - 1; + else + { + sal_Int32 i = 0; + sal_Bool bFound(sal_False); + while (!bFound && static_cast<sal_uInt32>(i) < aStyleNames.size()) + { + if (aStyleNames.at(i)->equals(rString)) + bFound = sal_True; + else + i++; + } + if (bFound) + return i; + else + return -1; + } +} + +rtl::OUString* ScColumnRowStylesBase::GetStyleNameByIndex(const sal_Int32 nIndex) +{ + if ( nIndex < 0 || nIndex >= (sal_Int32)aStyleNames.size() ) + { + // #i61888# should no longer happen, use first style then + DBG_ERRORFILE("GetStyleNameByIndex: invalid index"); + return aStyleNames[0]; + } + + return aStyleNames[nIndex]; +} + +//=========================================================================== + +ScColumnStyles::ScColumnStyles() + : ScColumnRowStylesBase(), + aTables() +{ +} + +ScColumnStyles::~ScColumnStyles() +{ +} + +void ScColumnStyles::AddNewTable(const sal_Int16 nTable, const sal_Int32 nFields) +{ + sal_Int16 nSize = aTables.size() - 1; + if (nTable > nSize) + for (sal_Int32 i = nSize; i < nTable; i++) + { + ScMyColumnStyleVec aFieldsVec(nFields + 1, ScColumnStyle()); + aTables.push_back(aFieldsVec); + } +} + +sal_Int32 ScColumnStyles::GetStyleNameIndex(const sal_Int16 nTable, const sal_Int32 nField, + sal_Bool& bIsVisible) +{ + DBG_ASSERT(static_cast<sal_uInt32>(nTable) < aTables.size(), "wrong table"); + if (static_cast<sal_uInt32>(nField) < aTables[nTable].size()) + { + bIsVisible = aTables[nTable][nField].bIsVisible; + return aTables[nTable][nField].nIndex; + } + else + { + bIsVisible = aTables[nTable][aTables[nTable].size() - 1].bIsVisible; + return aTables[nTable][aTables[nTable].size() - 1].nIndex; + } +} + +void ScColumnStyles::AddFieldStyleName(const sal_Int16 nTable, const sal_Int32 nField, + const sal_Int32 nStringIndex, const sal_Bool bIsVisible) +{ + DBG_ASSERT(static_cast<sal_uInt32>(nTable) < aTables.size(), "wrong table"); + DBG_ASSERT(aTables[nTable].size() >= static_cast<sal_uInt32>(nField), "wrong field"); + ScColumnStyle aStyle; + aStyle.nIndex = nStringIndex; + aStyle.bIsVisible = bIsVisible; + if (aTables[nTable].size() == static_cast<sal_uInt32>(nField)) + aTables[nTable].push_back(aStyle); + aTables[nTable][nField] = aStyle; +} + +rtl::OUString* ScColumnStyles::GetStyleName(const sal_Int16 nTable, const sal_Int32 nField) +{ + sal_Bool bTemp; + return GetStyleNameByIndex(GetStyleNameIndex(nTable, nField, bTemp)); +} + +//=========================================================================== + +ScRowStyles::ScRowStyles() + : ScColumnRowStylesBase(), + aTables() +{ +} + +ScRowStyles::~ScRowStyles() +{ +} + +void ScRowStyles::AddNewTable(const sal_Int16 nTable, const sal_Int32 nFields) +{ + sal_Int16 nSize = aTables.size() - 1; + if (nTable > nSize) + for (sal_Int32 i = nSize; i < nTable; i++) + { + ScMysalInt32Vec aFieldsVec(nFields + 1, -1); + aTables.push_back(aFieldsVec); + } +} + +sal_Int32 ScRowStyles::GetStyleNameIndex(const sal_Int16 nTable, const sal_Int32 nField) +{ + DBG_ASSERT(static_cast<sal_uInt32>(nTable) < aTables.size(), "wrong table"); + if (static_cast<sal_uInt32>(nField) < aTables[nTable].size()) + return aTables[nTable][nField]; + else + return aTables[nTable][aTables[nTable].size() - 1]; +} + +void ScRowStyles::AddFieldStyleName(const sal_Int16 nTable, const sal_Int32 nField, + const sal_Int32 nStringIndex) +{ + DBG_ASSERT(static_cast<sal_uInt32>(nTable) < aTables.size(), "wrong table"); + DBG_ASSERT(aTables[nTable].size() >= static_cast<sal_uInt32>(nField), "wrong field"); + if (aTables[nTable].size() == static_cast<sal_uInt32>(nField)) + aTables[nTable].push_back(nStringIndex); + aTables[nTable][nField] = nStringIndex; +} + +rtl::OUString* ScRowStyles::GetStyleName(const sal_Int16 nTable, const sal_Int32 nField) +{ + return GetStyleNameByIndex(GetStyleNameIndex(nTable, nField)); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_XMLStylesImportHelper.cxx b/binfilter/bf_sc/source/filter/xml/sc_XMLStylesImportHelper.cxx new file mode 100644 index 000000000000..54c13a037799 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_XMLStylesImportHelper.cxx @@ -0,0 +1,584 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "XMLStylesImportHelper.hxx" +#include "xmlimprt.hxx" + +#include <tools/debug.hxx> + +#include <com/sun/star/util/NumberFormat.hpp> +namespace binfilter { + +using namespace ::com::sun::star; + +void ScMyStyleNumberFormats::AddStyleNumberFormat(const ::rtl::OUString& rStyleName, const sal_Int32 nNumberFormat) +{ + ScMyStyleNumberFormat aFormat(rStyleName, nNumberFormat); + aSet.insert(aFormat); +} + +sal_Int32 ScMyStyleNumberFormats::GetStyleNumberFormat(const ::rtl::OUString& rStyleName) +{ + ScMyStyleNumberFormat aStyleNumberFormat(rStyleName); + ScMyStyleNumberFormatSet::iterator aItr = aSet.find(aStyleNumberFormat); + if (aItr == aSet.end()) + return -1; + else + return aItr->nNumberFormat; +} + +ScMyStyleRanges::ScMyStyleRanges() + : + pTextList(NULL), + pNumberList(NULL), + pTimeList(NULL), + pDateTimeList(NULL), + pPercentList(NULL), + pLogicalList(NULL), + pUndefinedList(NULL), + pCurrencyList(NULL) +{ +} + +ScMyStyleRanges::~ScMyStyleRanges() +{ + if (pTextList) + delete pTextList; + if (pNumberList) + delete pNumberList; + if (pTimeList) + delete pTimeList; + if (pDateTimeList) + delete pDateTimeList; + if (pPercentList) + delete pPercentList; + if (pLogicalList) + delete pLogicalList; + if (pUndefinedList) + delete pUndefinedList; + if (pCurrencyList) + delete pCurrencyList; +} + +void ScMyStyleRanges::AddRange(const ScRange& rRange, ScRangeList* pList, + const ::rtl::OUString* pStyleName, const sal_Int16 nType, + ScXMLImport& rImport, const sal_uInt32 nMaxRanges) +{ + pList->Join(rRange); + DBG_ASSERT(nMaxRanges > 0, "MaxRanges to less"); + if (pList->Count() > nMaxRanges) + { + sal_Int32 nCount(pList->Count()); + ScRange* pRange = NULL; + for (sal_Int32 i = 0; i < nCount; i++) + { + pRange = pList->GetObject(i); + if (pRange && (pRange->aEnd.Row() + 1 < rRange.aStart.Row())) + { + rImport.SetStyleToRange(*pRange, pStyleName, nType, NULL); + delete pRange; + pRange = NULL; + pList->Remove(i); + } + } + } +} + +void ScMyStyleRanges::AddCurrencyRange(const ScRange& rRange, ScRangeListRef xList, + const ::rtl::OUString* pStyleName, const ::rtl::OUString* pCurrency, + ScXMLImport& rImport, const sal_uInt32 nMaxRanges) +{ + xList->Join(rRange); + DBG_ASSERT(nMaxRanges > 0, "MaxRanges to less"); + if (xList->Count() > nMaxRanges) + { + sal_Int32 nCount(xList->Count()); + ScRange* pRange = NULL; + for (sal_Int32 i = 0; i < nCount; i++) + { + pRange = xList->GetObject(i); + if (pRange && (pRange->aEnd.Row() + 1 < rRange.aStart.Row())) + { + rImport.SetStyleToRange(*pRange, pStyleName, util::NumberFormat::CURRENCY, pCurrency); + delete pRange; + pRange = NULL; + xList->Remove(i); + } + } + } +} + +void ScMyStyleRanges::AddRange(const ScRange& rRange, + const ::rtl::OUString* pStyleName, const sal_Int16 nType, + ScXMLImport& rImport, const sal_uInt32 nMaxRanges) +{ + switch (nType) + { + case util::NumberFormat::NUMBER: + { + if (!pNumberList) + pNumberList = new ScRangeList(); + AddRange(rRange, pNumberList, pStyleName, nType, rImport, nMaxRanges); + } + break; + case util::NumberFormat::TEXT: + { + if (!pTextList) + pTextList = new ScRangeList(); + AddRange(rRange, pTextList, pStyleName, nType, rImport, nMaxRanges); + } + break; + case util::NumberFormat::TIME: + { + if (!pTimeList) + pTimeList = new ScRangeList(); + AddRange(rRange, pTimeList, pStyleName, nType, rImport, nMaxRanges); + } + break; + case util::NumberFormat::DATETIME: + { + if (!pDateTimeList) + pDateTimeList = new ScRangeList(); + AddRange(rRange, pDateTimeList, pStyleName, nType, rImport, nMaxRanges); + } + break; + case util::NumberFormat::PERCENT: + { + if (!pPercentList) + pPercentList = new ScRangeList(); + AddRange(rRange, pPercentList, pStyleName, nType, rImport, nMaxRanges); + } + break; + case util::NumberFormat::LOGICAL: + { + if (!pLogicalList) + pLogicalList = new ScRangeList(); + AddRange(rRange, pLogicalList, pStyleName, nType, rImport, nMaxRanges); + } + break; + case util::NumberFormat::UNDEFINED: + { + if (!pUndefinedList) + pUndefinedList = new ScRangeList(); + AddRange(rRange, pUndefinedList, pStyleName, nType, rImport, nMaxRanges); + } + break; + default: + { + DBG_ERROR("wrong type"); + } + break; + } +} + +void ScMyStyleRanges::AddCurrencyRange(const ScRange& rRange, + const ::rtl::OUString* pStyleName, const ::rtl::OUString* pCurrency, + ScXMLImport& rImport, const sal_uInt32 nMaxRanges) +{ + if (!pCurrencyList) + pCurrencyList = new ScMyCurrencyStylesSet(); + ScMyCurrencyStyle aStyle; + if (pCurrency) + aStyle.sCurrency = *pCurrency; + ScMyCurrencyStylesSet::iterator aItr = pCurrencyList->find(aStyle); + if (aItr == pCurrencyList->end()) + { + std::pair<ScMyCurrencyStylesSet::iterator, bool> aPair = pCurrencyList->insert(aStyle); + if (aPair.second) + { + aItr = aPair.first; + AddCurrencyRange(rRange, aItr->xRanges, pStyleName, pCurrency, rImport, nMaxRanges); + } + } + else + aItr->xRanges->Join(rRange); +} + +void ScMyStyleRanges::InsertColRow(const ScRange& rRange, const sal_Int16 nDx, const sal_Int16 nDy, + const sal_Int16 nDz, ScDocument* pDoc) +{ + UpdateRefMode aRefMode = URM_INSDEL; + if (pNumberList) + pNumberList->UpdateReference(aRefMode, pDoc, rRange, nDx, nDy, nDz); + if (pTextList) + pTextList->UpdateReference(aRefMode, pDoc, rRange, nDx, nDy, nDz); + if (pTimeList) + pTimeList->UpdateReference(aRefMode, pDoc, rRange, nDx, nDy, nDz); + if (pDateTimeList) + pDateTimeList->UpdateReference(aRefMode, pDoc, rRange, nDx, nDy, nDz); + if (pPercentList) + pPercentList->UpdateReference(aRefMode, pDoc, rRange, nDx, nDy, nDz); + if (pLogicalList) + pLogicalList->UpdateReference(aRefMode, pDoc, rRange, nDx, nDy, nDz); + if (pUndefinedList) + pUndefinedList->UpdateReference(aRefMode, pDoc, rRange, nDx, nDy, nDz); + if (pCurrencyList) + { + ScMyCurrencyStylesSet::iterator aItr = pCurrencyList->begin(); + while (aItr != pCurrencyList->end()) + { + aItr->xRanges->UpdateReference(aRefMode, pDoc, rRange, nDx, nDy, nDz); + aItr++; + } + } +} + +void ScMyStyleRanges::InsertRow(const sal_Int32 nRow, const sal_Int32 nTab, ScDocument* pDoc) +{ + InsertColRow(ScRange(0, static_cast<sal_uInt16>(nRow), static_cast<sal_uInt16>(nTab), + MAXCOL, MAXROW, static_cast<sal_uInt16>(nTab)), 0, 1, 0, pDoc); +} + +void ScMyStyleRanges::InsertCol(const sal_Int32 nCol, const sal_Int32 nTab, ScDocument* pDoc) +{ + InsertColRow(ScRange(static_cast<sal_uInt16>(nCol), 0, static_cast<sal_uInt16>(nTab), + MAXCOL, MAXROW, static_cast<sal_uInt16>(nTab)), 1, 0, 0, pDoc); +} + +void ScMyStyleRanges::SetStylesToRanges(ScRangeList* pList, + const ::rtl::OUString* pStyleName, const sal_Int16 nCellType, + const ::rtl::OUString* pCurrency, ScXMLImport& rImport) +{ + sal_Int32 nCount(pList->Count()); + for (sal_Int32 i = 0; i < nCount; i++) + rImport.SetStyleToRange(*pList->GetObject(i), pStyleName, nCellType, pCurrency); +} + +void ScMyStyleRanges::SetStylesToRanges(ScRangeListRef xList, + const ::rtl::OUString* pStyleName, const sal_Int16 nCellType, + const ::rtl::OUString* pCurrency, ScXMLImport& rImport) +{ + sal_Int32 nCount(xList->Count()); + for (sal_Int32 i = 0; i < nCount; i++) + rImport.SetStyleToRange(*xList->GetObject(i), pStyleName, nCellType, pCurrency); +} + +void ScMyStyleRanges::SetStylesToRanges(const ::rtl::OUString* pStyleName, ScXMLImport& rImport) +{ + if (pNumberList) + SetStylesToRanges(pNumberList, pStyleName, util::NumberFormat::NUMBER, NULL, rImport); + if (pTextList) + SetStylesToRanges(pTextList, pStyleName, util::NumberFormat::TEXT, NULL, rImport); + if (pTimeList) + SetStylesToRanges(pTimeList, pStyleName, util::NumberFormat::TIME, NULL, rImport); + if (pDateTimeList) + SetStylesToRanges(pDateTimeList, pStyleName, util::NumberFormat::DATETIME, NULL, rImport); + if (pPercentList) + SetStylesToRanges(pPercentList, pStyleName, util::NumberFormat::PERCENT, NULL, rImport); + if (pLogicalList) + SetStylesToRanges(pLogicalList, pStyleName, util::NumberFormat::LOGICAL, NULL, rImport); + if (pUndefinedList) + SetStylesToRanges(pUndefinedList, pStyleName, util::NumberFormat::UNDEFINED, NULL, rImport); + if (pCurrencyList) + { + ScMyCurrencyStylesSet::iterator aItr = pCurrencyList->begin(); + while (aItr != pCurrencyList->end()) + { + SetStylesToRanges(aItr->xRanges, pStyleName, util::NumberFormat::CURRENCY, &aItr->sCurrency, rImport); + aItr++; + } + } +} + +//---------------------------------------------------------------------------- + +ScMyStylesImportHelper::ScMyStylesImportHelper(ScXMLImport& rTempImport) + : + aCellStyles(), + aColDefaultStyles(), + bPrevRangeAdded(sal_True), + rImport(rTempImport), + nMaxRanges(0), + pPrevStyleName(NULL), + pPrevCurrency(NULL), + pStyleName(NULL), + pCurrency(NULL) +{ + aRowDefaultStyle = aCellStyles.end(); +} + +ScMyStylesImportHelper::~ScMyStylesImportHelper() +{ + if (pPrevStyleName) + delete pPrevStyleName; + if (pPrevCurrency) + delete pPrevCurrency; + if (pStyleName) + delete pStyleName; + if (pCurrency) + delete pCurrency; +} + +void ScMyStylesImportHelper::ResetAttributes() +{ + if (pPrevStyleName) + delete pPrevStyleName; + if (pPrevCurrency) + delete pPrevCurrency; + pPrevStyleName = pStyleName; + pPrevCurrency = pCurrency; + nPrevCellType = nCellType; + pStyleName = NULL; + pCurrency = NULL; + nCellType = 0; +} + +ScMyStylesSet::iterator ScMyStylesImportHelper::GetIterator(const ::rtl::OUString* pStyleName) +{ + ScMyStyle aStyle; + if (pStyleName) + aStyle.sStyleName = *pStyleName; + else + DBG_ERROR("here is no stylename given"); + ScMyStylesSet::iterator aItr = aCellStyles.find(aStyle); + if (aItr == aCellStyles.end()) + { + std::pair<ScMyStylesSet::iterator, bool> aPair = aCellStyles.insert(aStyle); + if (aPair.second) + aItr = aPair.first; + else + { + DBG_ERROR("not possible to insert style"); + return aCellStyles.end(); + } + } + return aItr; +} + +void ScMyStylesImportHelper::AddDefaultRange(const ScRange& rRange) +{ + DBG_ASSERT(aRowDefaultStyle != aCellStyles.end(), "no row default style"); + if (!aRowDefaultStyle->sStyleName.getLength()) + { + sal_uInt32 nStartCol(rRange.aStart.Col()); + sal_uInt32 nEndCol(rRange.aEnd.Col()); + if (aColDefaultStyles.size() > nStartCol) + { + ScMyStylesSet::iterator aPrevItr = aColDefaultStyles[nStartCol]; + DBG_ASSERT(aColDefaultStyles.size() > nEndCol, "to much columns"); + for (sal_uInt32 i = nStartCol + 1; (i <= nEndCol) && (i < aColDefaultStyles.size()); i++) + { + if (aPrevItr != aColDefaultStyles[i]) + { + DBG_ASSERT(aPrevItr != aCellStyles.end(), "no column default style"); + ScRange aRange(rRange); + aRange.aStart.SetCol(static_cast<sal_uInt16>(nStartCol)); + aRange.aEnd.SetCol(static_cast<sal_uInt16>(i - 1)); + if (pPrevStyleName) + delete pPrevStyleName; + pPrevStyleName = new ::rtl::OUString(aPrevItr->sStyleName); + AddSingleRange(aRange); + nStartCol = i; + aPrevItr = aColDefaultStyles[i]; + } + } + if (aPrevItr != aCellStyles.end()) + { + ScRange aRange(rRange); + aRange.aStart.SetCol(static_cast<sal_uInt16>(nStartCol)); + if (pPrevStyleName) + delete pPrevStyleName; + pPrevStyleName = new ::rtl::OUString(aPrevItr->sStyleName); + AddSingleRange(aRange); + } + else + DBG_ERRORFILE("no column default style"); + } + else + DBG_ERRORFILE("to much columns"); + } + else + { + if (pPrevStyleName) + delete pPrevStyleName; + pPrevStyleName = new ::rtl::OUString(aRowDefaultStyle->sStyleName); + AddSingleRange(rRange); + } +} + +void ScMyStylesImportHelper::AddSingleRange(const ScRange& rRange) +{ + if (nMaxRanges == 0) + nMaxRanges = aColDefaultStyles.size(); + ScMyStylesSet::iterator aItr = GetIterator(pPrevStyleName); + if (aItr != aCellStyles.end()) + { + if (nPrevCellType != util::NumberFormat::CURRENCY) + aItr->xRanges->AddRange(rRange, pPrevStyleName, nPrevCellType, + rImport, nMaxRanges); + else + aItr->xRanges->AddCurrencyRange(rRange, pPrevStyleName, pPrevCurrency, + rImport, nMaxRanges); + } +} + +void ScMyStylesImportHelper::AddRange() +{ + if (pPrevStyleName && pPrevStyleName->getLength()) + AddSingleRange(aPrevRange); + else + AddDefaultRange(aPrevRange); + ResetAttributes(); +} + +void ScMyStylesImportHelper::AddColumnStyle(const ::rtl::OUString& sStyleName, const sal_Int32 nColumn, const sal_Int32 nRepeat) +{ + DBG_ASSERT(static_cast<sal_uInt32>(nColumn) == aColDefaultStyles.size(), "some columns are absent"); + ScMyStylesSet::iterator aItr = GetIterator(&sStyleName); + DBG_ASSERT(aItr != aCellStyles.end(), "no column default style"); + for (sal_Int32 i = 0; i < nRepeat; i++) + aColDefaultStyles.push_back(aItr); +} + +void ScMyStylesImportHelper::SetRowStyle(const ::rtl::OUString& sStyleName) +{ + aRowDefaultStyle = GetIterator(&sStyleName); +} + +void ScMyStylesImportHelper::SetAttributes(::rtl::OUString* pStyleName, + ::rtl::OUString* pCurrency, const sal_Int16 nCellType) +{ + if (this->pStyleName) + delete this->pStyleName; + if (this->pCurrency) + delete this->pCurrency; + this->pStyleName = pStyleName; + this->pCurrency = pCurrency; + this->nCellType = nCellType; +} + +void ScMyStylesImportHelper::AddRange(const ScRange& rRange) +{ + if (!bPrevRangeAdded) + { + sal_Bool bAddRange(sal_False); + if (nCellType == nPrevCellType && + IsEqual(pStyleName, pPrevStyleName) && + IsEqual(pCurrency, pPrevCurrency)) + { + if (rRange.aStart.Row() == aPrevRange.aStart.Row()) + { + if (rRange.aEnd.Row() == aPrevRange.aEnd.Row()) + { + DBG_ASSERT(aPrevRange.aEnd.Col() + 1 == rRange.aStart.Col(), "something wents wrong"); + aPrevRange.aEnd.SetCol(rRange.aEnd.Col()); + } + else + bAddRange = sal_True; + } + else + { + if (rRange.aStart.Col() == aPrevRange.aStart.Col() && + rRange.aEnd.Col() == aPrevRange.aEnd.Col()) + { + DBG_ASSERT(aPrevRange.aEnd.Row() + 1 == rRange.aStart.Row(), "something wents wrong"); + aPrevRange.aEnd.SetRow(rRange.aEnd.Row()); + } + else + bAddRange = sal_True; + } + } + else + bAddRange = sal_True; + if (bAddRange) + { + AddRange(); + aPrevRange = rRange; + } + } + else + { + aPrevRange = rRange; + ResetAttributes(); + bPrevRangeAdded = sal_False; + } +} + +void ScMyStylesImportHelper::AddCell(const ::com::sun::star::table::CellAddress& rAddress) +{ + ScAddress aScAddress( static_cast<USHORT>(rAddress.Column), static_cast<USHORT>(rAddress.Row), rAddress.Sheet ); + ScRange aScRange( aScAddress, aScAddress ); + AddRange(aScRange); +} + +void ScMyStylesImportHelper::InsertRow(const sal_Int32 nRow, const sal_Int32 nTab, ScDocument* pDoc) +{ + rImport.LockSolarMutex(); + ScMyStylesSet::iterator aItr = aCellStyles.begin(); + while (aItr != aCellStyles.end()) + { + aItr->xRanges->InsertRow(nRow, nTab, pDoc); + aItr++; + } + rImport.UnlockSolarMutex(); +} + +void ScMyStylesImportHelper::InsertCol(const sal_Int32 nCol, const sal_Int32 nTab, ScDocument* pDoc) +{ + rImport.LockSolarMutex(); + ScMyStylesSet::iterator aItr = aCellStyles.begin(); + while (aItr != aCellStyles.end()) + { + aItr->xRanges->InsertCol(nCol, nTab, pDoc); + aItr++; + } + rImport.UnlockSolarMutex(); +} + +void ScMyStylesImportHelper::EndTable() +{ + if (!bPrevRangeAdded) + { + AddRange(); + bPrevRangeAdded = sal_True; + } + nMaxRanges = 0; +} + +void ScMyStylesImportHelper::SetStylesToRanges() +{ + ScMyStylesSet::iterator aItr = aCellStyles.begin(); + while (aItr != aCellStyles.end()) + { + aItr->xRanges->SetStylesToRanges(&aItr->sStyleName, rImport); + aItr++; + } + aCellStyles.clear(); + aColDefaultStyles.clear(); + nMaxRanges = 0; +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_XMLTableHeaderFooterContext.cxx b/binfilter/bf_sc/source/filter/xml/sc_XMLTableHeaderFooterContext.cxx new file mode 100644 index 000000000000..d3efe1839642 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_XMLTableHeaderFooterContext.cxx @@ -0,0 +1,298 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <bf_xmloff/nmspmap.hxx> +#include <bf_xmloff/xmlnmspe.hxx> +#include "XMLTableHeaderFooterContext.hxx" + +#include "unonames.hxx" +namespace binfilter { + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::xml::sax; +using namespace ::com::sun::star::text; +using namespace ::com::sun::star::beans; +using namespace xmloff::token; + +using rtl::OUString; + + +TYPEINIT1( XMLTableHeaderFooterContext, SvXMLImportContext ); + +XMLTableHeaderFooterContext::XMLTableHeaderFooterContext( SvXMLImport& rImport, sal_uInt16 nPrfx, + const OUString& rLName, + const uno::Reference< + xml::sax::XAttributeList > & xAttrList, + const Reference < XPropertySet > & rPageStylePropSet, + sal_Bool bFooter, sal_Bool bLft ) : + SvXMLImportContext( rImport, nPrfx, rLName ), + xPropSet( rPageStylePropSet ), + sOn( OUString::createFromAscii( bFooter ? SC_UNO_PAGE_FTRON : SC_UNO_PAGE_HDRON ) ), + sShareContent( OUString::createFromAscii( bFooter ? SC_UNO_PAGE_FTRSHARED : SC_UNO_PAGE_HDRSHARED ) ), + sContent( OUString::createFromAscii( bFooter ? SC_UNO_PAGE_RIGHTFTRCON : SC_UNO_PAGE_RIGHTHDRCON ) ), + sContentLeft( OUString::createFromAscii( bFooter ? SC_UNO_PAGE_LEFTFTRCONT : SC_UNO_PAGE_LEFTHDRCONT ) ), + bInsertContent( sal_True ), + bLeft( bLft ), + bDisplay( sal_True ), + bContainsLeft(sal_False), + bContainsRight(sal_False), + bContainsCenter(sal_False) +{ + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + const OUString& rAttrName = xAttrList->getNameByIndex( i ); + OUString aLName; + sal_uInt16 nPrefix = + GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, + &aLName ); + const OUString& rValue = xAttrList->getValueByIndex( i ); + + // TODO: use a map here + if( XML_NAMESPACE_STYLE == nPrfx ) + { + if( IsXMLToken(aLName, XML_DISPLAY ) ) + bDisplay = IsXMLToken(rValue, XML_TRUE); + } + } + if( bLeft ) + { + Any aAny; + + aAny = xPropSet->getPropertyValue( sOn ); + sal_Bool bOn = *(sal_Bool *)aAny.getValue(); + + if( bOn && bDisplay ) + { + aAny = xPropSet->getPropertyValue( sShareContent ); + sal_Bool bShared = *(sal_Bool *)aAny.getValue(); + if( bShared ) + { + // Don't share headers any longer + bShared = sal_False; + aAny.setValue( &bShared, ::getBooleanCppuType() ); + xPropSet->setPropertyValue( sShareContent, aAny ); + } + } + else + { + aAny = xPropSet->getPropertyValue( sShareContent ); + sal_Bool bShared = *(sal_Bool *)aAny.getValue(); + if( !bShared ) + { + // share headers + bShared = sal_True; + aAny.setValue( &bShared, ::getBooleanCppuType() ); + xPropSet->setPropertyValue( sShareContent, aAny ); + } + } + } + else + { + Any aAny; + + aAny = xPropSet->getPropertyValue( sOn ); + sal_Bool bOn = *(sal_Bool *)aAny.getValue(); + if ( bOn != bDisplay ) + { + sal_Bool bTempDisplay(bDisplay); + aAny.setValue( &bTempDisplay, ::getBooleanCppuType() ); + bDisplay = bTempDisplay; + xPropSet->setPropertyValue( sOn, aAny ); + } + } + if (bLeft) + sCont = sContentLeft; + else + sCont = sContent; + Any aAny; + aAny = xPropSet->getPropertyValue( sCont ); + aAny >>= xHeaderFooterContent; +} + +XMLTableHeaderFooterContext::~XMLTableHeaderFooterContext() +{ +} + +SvXMLImportContext *XMLTableHeaderFooterContext::CreateChildContext( + sal_uInt16 nPrefix, + const OUString& rLocalName, + const uno::Reference< xml::sax::XAttributeList > & xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if ((nPrefix == XML_NAMESPACE_TEXT) && + IsXMLToken(rLocalName, XML_P)) + { + if (!xTextCursor.is()) + { + if( xHeaderFooterContent.is() ) + { + uno::Reference < text::XText > xText = xHeaderFooterContent->getCenterText(); + xText->setString(sEmpty); + xTextCursor = xText->createTextCursor(); + xOldTextCursor = GetImport().GetTextImport()->GetCursor(); + GetImport().GetTextImport()->SetCursor( xTextCursor ); + bContainsCenter = sal_True; + } + } + pContext = + GetImport().GetTextImport()->CreateTextChildContext(GetImport(), + nPrefix, + rLocalName, + xAttrList); + } + else + { + if (nPrefix == XML_NAMESPACE_STYLE) + { + if (xHeaderFooterContent.is()) + { + uno::Reference < text::XText > xText; + if (IsXMLToken(rLocalName, XML_REGION_LEFT )) + { + xText = xHeaderFooterContent->getLeftText(); + bContainsLeft = sal_True; + } + else if (IsXMLToken(rLocalName, XML_REGION_CENTER )) + { + xText = xHeaderFooterContent->getCenterText(); + bContainsCenter = sal_True; + } + else if (IsXMLToken(rLocalName, XML_REGION_RIGHT )) + { + xText = xHeaderFooterContent->getRightText(); + bContainsRight = sal_True; + } + if (xText.is()) + { + xText->setString(sEmpty); + //SvXMLImport aSvXMLImport( GetImport() ); + uno::Reference<text::XTextCursor> xTextCursor( xText->createTextCursor() ); + pContext = new XMLHeaderFooterRegionContext( GetImport(), nPrefix, rLocalName, xAttrList, xTextCursor); + } + } + } + } + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + + return pContext; +} + +void XMLTableHeaderFooterContext::EndElement() +{ + if( GetImport().GetTextImport()->GetCursor().is() ) + { + //GetImport().GetTextImport()->GetCursor()->gotoEnd(sal_False); + if( GetImport().GetTextImport()->GetCursor()->goLeft( 1, sal_True ) ) + { + GetImport().GetTextImport()->GetText()->insertString( + GetImport().GetTextImport()->GetCursorAsRange(), sEmpty, + sal_True ); + } + GetImport().GetTextImport()->ResetCursor(); + } + if (xOldTextCursor.is()) + GetImport().GetTextImport()->SetCursor(xOldTextCursor); + if (xHeaderFooterContent.is()) + { + if (!bContainsLeft) + xHeaderFooterContent->getLeftText()->setString(sEmpty); + if (!bContainsCenter) + xHeaderFooterContent->getCenterText()->setString(sEmpty); + if (!bContainsRight) + xHeaderFooterContent->getRightText()->setString(sEmpty); + + Any aAny; + aAny <<= xHeaderFooterContent; + xPropSet->setPropertyValue( sCont, aAny ); + } +} + +TYPEINIT1( XMLHeaderFooterRegionContext, SvXMLImportContext ); + +XMLHeaderFooterRegionContext::XMLHeaderFooterRegionContext( SvXMLImport& rImport, sal_uInt16 nPrfx, + const OUString& rLName, + const uno::Reference< + xml::sax::XAttributeList > & xAttrList, + uno::Reference< text::XTextCursor >& xCursor ) : + SvXMLImportContext( rImport, nPrfx, rLName ), + xTextCursor ( xCursor ) +{ + xOldTextCursor = GetImport().GetTextImport()->GetCursor(); + GetImport().GetTextImport()->SetCursor( xTextCursor ); +} + +XMLHeaderFooterRegionContext::~XMLHeaderFooterRegionContext() +{ +} + +SvXMLImportContext *XMLHeaderFooterRegionContext::CreateChildContext( + sal_uInt16 nPrefix, + const OUString& rLocalName, + const uno::Reference< xml::sax::XAttributeList > & xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if ((nPrefix == XML_NAMESPACE_TEXT) && + IsXMLToken(rLocalName, XML_P)) + { + pContext = + GetImport().GetTextImport()->CreateTextChildContext(GetImport(), + nPrefix, + rLocalName, + xAttrList); + } + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + + return pContext; +} + +void XMLHeaderFooterRegionContext::EndElement() +{ + if( GetImport().GetTextImport()->GetCursor().is() ) + { + //GetImport().GetTextImport()->GetCursor()->gotoEnd(sal_False); + if( GetImport().GetTextImport()->GetCursor()->goLeft( 1, sal_True ) ) + { + OUString sEmpty; + GetImport().GetTextImport()->GetText()->insertString( + GetImport().GetTextImport()->GetCursorAsRange(), sEmpty, + sal_True ); + } + GetImport().GetTextImport()->ResetCursor(); + } + if (xOldTextCursor.is()) + GetImport().GetTextImport()->SetCursor(xOldTextCursor); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_XMLTableMasterPageExport.cxx b/binfilter/bf_sc/source/filter/xml/sc_XMLTableMasterPageExport.cxx new file mode 100644 index 000000000000..09e909747182 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_XMLTableMasterPageExport.cxx @@ -0,0 +1,195 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <tools/debug.hxx> + +#include <bf_xmloff/xmlnmspe.hxx> + + + +#include "XMLTableMasterPageExport.hxx" + +#include "unonames.hxx" +namespace binfilter { + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::text; +using namespace ::com::sun::star::beans; +using namespace xmloff::token; + +using rtl::OUString; + +XMLTableMasterPageExport::XMLTableMasterPageExport( ScXMLExport& rExp ) : + XMLTextMasterPageExport ( rExp ) +{ +} + +XMLTableMasterPageExport::~XMLTableMasterPageExport() +{ +} + +void XMLTableMasterPageExport::exportHeaderFooterContent( + const Reference< XText >& rText, + sal_Bool bAutoStyles, sal_Bool bProgress ) +{ + DBG_ASSERT( rText.is(), "There is the text" ); + + if( bAutoStyles ) + GetExport().GetTextParagraphExport() + ->collectTextAutoStyles( rText, bProgress, sal_False ); + else + { + GetExport().GetTextParagraphExport()->exportTextDeclarations( rText ); + GetExport().GetTextParagraphExport()->exportText( rText, bProgress, sal_False ); + } +} + +void XMLTableMasterPageExport::exportHeaderFooter(const ::com::sun::star::uno::Reference < ::com::sun::star::sheet::XHeaderFooterContent >& xHeaderFooter, + const XMLTokenEnum aName, + const sal_Bool bDisplay) +{ + if( xHeaderFooter.is() ) + { + Reference < XText > xCenter = xHeaderFooter->getCenterText(); + Reference < XText > xLeft = xHeaderFooter->getLeftText(); + Reference < XText > xRight = xHeaderFooter->getRightText(); + if (xCenter.is() && xLeft.is() && xRight.is()) + { + ::rtl::OUString sCenter (xCenter->getString()); + ::rtl::OUString sLeft (xLeft->getString()); + ::rtl::OUString sRight (xRight->getString()); + + if( !bDisplay ) + GetExport().AddAttribute( XML_NAMESPACE_STYLE, + XML_DISPLAY, XML_FALSE ); + SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE, + aName, sal_True, sal_True ); + if (sCenter.getLength() && !sLeft.getLength() && !sRight.getLength()) + exportHeaderFooterContent( xCenter, sal_False, sal_False ); + else + { + if (sLeft.getLength()) + { + SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE, + XML_REGION_LEFT, sal_True, sal_True ); + exportHeaderFooterContent( xLeft, sal_False, sal_False ); + } + if (sCenter.getLength()) + { + SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE, + XML_REGION_CENTER, sal_True, sal_True ); + exportHeaderFooterContent( xCenter, sal_False, sal_False ); + } + if (sRight.getLength()) + { + SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE, + XML_REGION_RIGHT, sal_True, sal_True ); + exportHeaderFooterContent( xRight, sal_False, sal_False ); + } + } + } + } +} + +void XMLTableMasterPageExport::exportMasterPageContent( + const Reference < XPropertySet > & rPropSet, + sal_Bool bAutoStyles ) +{ + Any aAny; + + Reference < sheet::XHeaderFooterContent > xHeader; + aAny = rPropSet->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_UNO_PAGE_RIGHTHDRCON ) ) ); + aAny >>= xHeader; + + Reference < sheet::XHeaderFooterContent > xHeaderLeft; + aAny = rPropSet->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_UNO_PAGE_LEFTHDRCONT ) ) ); + aAny >>= xHeaderLeft; + + Reference < sheet::XHeaderFooterContent > xFooter; + aAny = rPropSet->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_UNO_PAGE_RIGHTFTRCON ) ) ); + aAny >>= xFooter; + + Reference < sheet::XHeaderFooterContent > xFooterLeft; + aAny = rPropSet->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_UNO_PAGE_LEFTFTRCONT ) ) ); + aAny >>= xFooterLeft; + + if( bAutoStyles ) + { + if( xHeader.is() ) + { + exportHeaderFooterContent( xHeader->getCenterText(), sal_True, sal_False ); + exportHeaderFooterContent( xHeader->getLeftText(), sal_True, sal_False ); + exportHeaderFooterContent( xHeader->getRightText(), sal_True, sal_False ); + } + if( xHeaderLeft.is()) + { + exportHeaderFooterContent( xHeaderLeft->getCenterText(), sal_True, sal_False ); + exportHeaderFooterContent( xHeaderLeft->getLeftText(), sal_True, sal_False ); + exportHeaderFooterContent( xHeaderLeft->getRightText(), sal_True, sal_False ); + } + if( xFooter.is() ) + { + exportHeaderFooterContent( xFooter->getCenterText(), sal_True, sal_False ); + exportHeaderFooterContent( xFooter->getLeftText(), sal_True, sal_False ); + exportHeaderFooterContent( xFooter->getRightText(), sal_True, sal_False ); + } + if( xFooterLeft.is()) + { + exportHeaderFooterContent( xFooterLeft->getCenterText(), sal_True, sal_False ); + exportHeaderFooterContent( xFooterLeft->getLeftText(), sal_True, sal_False ); + exportHeaderFooterContent( xFooterLeft->getRightText(), sal_True, sal_False ); + } + } + else + { + aAny = rPropSet->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_UNO_PAGE_HDRON ) ) ); + sal_Bool bHeader = *(sal_Bool *)aAny.getValue(); + + exportHeaderFooter(xHeader, XML_HEADER, bHeader ); + + aAny = rPropSet->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_UNO_PAGE_HDRSHARED ) ) ); + sal_Bool bLeftHeader = !(*(sal_Bool *)aAny.getValue()) && bHeader; + + exportHeaderFooter( xHeaderLeft, XML_HEADER_LEFT, bLeftHeader ); + + aAny = rPropSet->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_UNO_PAGE_FTRON ) ) ); + sal_Bool bFooter = *(sal_Bool *)aAny.getValue(); + + exportHeaderFooter( xFooter, XML_FOOTER, bFooter ); + + aAny = rPropSet->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_UNO_PAGE_FTRSHARED ) ) ); + sal_Bool bLeftFooter = !(*(sal_Bool *)aAny.getValue()) && bFooter; + + exportHeaderFooter( xFooterLeft, XML_FOOTER_LEFT, bLeftFooter ); + } +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_XMLTableShapeImportHelper.cxx b/binfilter/bf_sc/source/filter/xml/sc_XMLTableShapeImportHelper.cxx new file mode 100644 index 000000000000..16aeb70685af --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_XMLTableShapeImportHelper.cxx @@ -0,0 +1,169 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "XMLTableShapeImportHelper.hxx" + +#include "xmlimprt.hxx" +#include "XMLConverter.hxx" +#include "drwlayer.hxx" + +#include <bf_xmloff/nmspmap.hxx> +#include <bf_xmloff/xmlnmspe.hxx> +#include <bf_xmloff/xmluconv.hxx> + +#include <bf_svx/unoshape.hxx> + +namespace binfilter { + +#define SC_LAYERID "LayerID" + +using namespace ::com::sun::star; +using namespace xmloff::token; + +using rtl::OUString; + +XMLTableShapeImportHelper::XMLTableShapeImportHelper( + ScXMLImport& rImp, SvXMLImportPropertyMapper *pImpMapper ) : + XMLShapeImportHelper(rImp, rImp.GetModel(), pImpMapper ) +{ +} + +XMLTableShapeImportHelper::~XMLTableShapeImportHelper() +{ +} + +void XMLTableShapeImportHelper::SetLayer(uno::Reference<drawing::XShape>& rShape, sal_Int16 nLayerID, const ::rtl::OUString& sType) const +{ + if (sType.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ControlShape")))) + nLayerID = SC_LAYER_CONTROLS; + if (nLayerID != -1) + { + uno::Reference< beans::XPropertySet > xShapeProp( rShape, uno::UNO_QUERY ); + if( xShapeProp.is() ) + xShapeProp->setPropertyValue(OUString( RTL_CONSTASCII_USTRINGPARAM( SC_LAYERID ) ), uno::makeAny(nLayerID) ); + } +} + +void XMLTableShapeImportHelper::finishShape( + uno::Reference< drawing::XShape >& rShape, + const uno::Reference< xml::sax::XAttributeList >& xAttrList, + uno::Reference< drawing::XShapes >& rShapes ) +{ + XMLShapeImportHelper::finishShape( rShape, xAttrList, rShapes ); + static_cast<ScXMLImport&>(mrImporter).LockSolarMutex(); + if (rShapes == static_cast<ScXMLImport&>(mrImporter).GetTables().GetCurrentXShapes()) + { + Rectangle* pRect = NULL; + sal_Int32 nEndX(-1); + sal_Int32 nEndY(-1); + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + table::CellAddress aEndCell; + ::rtl::OUString* pRangeList = NULL; + sal_Int16 nLayerID(-1); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + const ::rtl::OUString& rAttrName = xAttrList->getNameByIndex( i ); + const ::rtl::OUString& rValue = xAttrList->getValueByIndex( i ); + + ::rtl::OUString aLocalName; + sal_uInt16 nPrefix = + static_cast<ScXMLImport&>(mrImporter).GetNamespaceMap().GetKeyByAttrName( rAttrName, + &aLocalName ); + if(nPrefix == XML_NAMESPACE_TABLE) + { + if (IsXMLToken(aLocalName, XML_END_CELL_ADDRESS)) + { + sal_Int32 nOffset(0); + ScXMLConverter::GetAddressFromString(aEndCell, rValue, static_cast<ScXMLImport&>(mrImporter).GetDocument(), nOffset); + } + else if (IsXMLToken(aLocalName, XML_END_X)) + static_cast<ScXMLImport&>(mrImporter).GetMM100UnitConverter().convertMeasure(nEndX, rValue); + else if (IsXMLToken(aLocalName, XML_END_Y)) + static_cast<ScXMLImport&>(mrImporter).GetMM100UnitConverter().convertMeasure(nEndY, rValue); + else if (IsXMLToken(aLocalName, XML_TABLE_BACKGROUND)) + if (IsXMLToken(rValue, XML_TRUE)) + nLayerID = SC_LAYER_BACK; + } + else if(nPrefix == XML_NAMESPACE_DRAW) + { + if (IsXMLToken(aLocalName, XML_NOTIFY_ON_UPDATE_OF_RANGES)) + pRangeList = new ::rtl::OUString(rValue); + } + } + SetLayer(rShape, nLayerID, rShape->getShapeType()); + + if (!bOnTable) + { + static_cast<ScXMLImport&>(mrImporter).GetTables().AddShape(rShape, + pRangeList, aStartCell, aEndCell, nEndX, nEndY); + SvxShape* pShapeImp = SvxShape::getImplementation(rShape); + if (pShapeImp) + { + SdrObject *pSdrObj = pShapeImp->GetSdrObject(); + if (pSdrObj) + ScDrawLayer::SetAnchor(pSdrObj, SCA_CELL); + } + } + else + { + SvxShape* pShapeImp = SvxShape::getImplementation(rShape); + if (pShapeImp) + { + SdrObject *pSdrObj = pShapeImp->GetSdrObject(); + if (pSdrObj) + ScDrawLayer::SetAnchor(pSdrObj, SCA_PAGE); + } + } + } + else //#99532# this are grouped shapes which should also get the layerid + { + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + sal_Int16 nLayerID(-1); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + const ::rtl::OUString& rAttrName = xAttrList->getNameByIndex( i ); + const ::rtl::OUString& rValue = xAttrList->getValueByIndex( i ); + + ::rtl::OUString aLocalName; + sal_uInt16 nPrefix = + static_cast<ScXMLImport&>(mrImporter).GetNamespaceMap().GetKeyByAttrName( rAttrName, + &aLocalName ); + if(nPrefix == XML_NAMESPACE_TABLE) + { + if (IsXMLToken(aLocalName, XML_TABLE_BACKGROUND)) + if (IsXMLToken(rValue, XML_TRUE)) + nLayerID = SC_LAYER_BACK; + } + } + SetLayer(rShape, nLayerID, rShape->getShapeType()); + } + static_cast<ScXMLImport&>(mrImporter).UnlockSolarMutex(); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_XMLTableShapeResizer.cxx b/binfilter/bf_sc/source/filter/xml/sc_XMLTableShapeResizer.cxx new file mode 100644 index 000000000000..f25f94dc32fc --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_XMLTableShapeResizer.cxx @@ -0,0 +1,348 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "unonames.hxx" +#include "document.hxx" +#include "xmlimprt.hxx" +#include "chartlis.hxx" +#include "XMLConverter.hxx" + +#include <tools/debug.hxx> + +#include <com/sun/star/sheet/XSpreadsheetDocument.hpp> +#include <com/sun/star/table/XColumnRowRange.hpp> +namespace binfilter { + +using namespace ::com::sun::star; + +ScMyShapeResizer::ScMyShapeResizer(ScXMLImport& rTempImport) + : aShapes(), + rImport(rTempImport), + pCollection(NULL) +{ +} + +ScMyShapeResizer::~ScMyShapeResizer() +{ +} + +sal_Bool ScMyShapeResizer::IsOLE(uno::Reference< drawing::XShape >& rShape) const +{ + return rShape->getShapeType().equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.OLE2Shape"))); +} + +void ScMyShapeResizer::CreateChartListener(ScDocument* pDoc, + const ::rtl::OUString& rName, + const ::rtl::OUString* pRangeList) +{ + if(pDoc) + { + if (pRangeList) + { + if (pRangeList->getLength()) + { + if (!pCollection) + pCollection = pDoc->GetChartListenerCollection();//new ScChartListenerCollection(pDoc); + if (pCollection) + { + ScRangeListRef aRangeListRef = new ScRangeList(); + ScXMLConverter::GetRangeListFromString(*aRangeListRef, *pRangeList, pDoc); + if (aRangeListRef->Count()) + { + ScChartListener* pCL = new ScChartListener( + rName, pDoc, aRangeListRef ); + pCollection->Insert( pCL ); + pCL->StartListeningTo(); + } + } + } + else + { + pDoc->AddOLEObjectToCollection(rName); + } + } + } +} + +void ScMyShapeResizer::AddShape(uno::Reference <drawing::XShape>& rShape, + ::rtl::OUString* pRangeList, + table::CellAddress& rStartAddress, table::CellAddress& rEndAddress, + sal_Int32 nEndX, sal_Int32 nEndY) +{ + ScMyToResizeShape aShape; + aShape.xShape = rShape; + aShape.pRangeList = pRangeList; + aShape.aEndCell = rEndAddress; + aShape.aStartCell = rStartAddress; + aShape.nEndY = nEndY; + aShape.nEndX = nEndX; + aShapes.push_back(aShape); +} + +void ScMyShapeResizer::GetNewShapeSizePos(ScDocument* pDoc, const Rectangle& rStartRect, + const table::CellAddress& rEndCell, + awt::Point& rPoint, awt::Size& rSize, + sal_Int32& rEndX, sal_Int32& rEndY) const +{ + awt::Point aRefPoint; + aRefPoint.X = rStartRect.Left(); + aRefPoint.Y = rStartRect.Top(); + Rectangle* pRect = new Rectangle(pDoc->GetMMRect( + static_cast<USHORT>(rEndCell.Column), static_cast<USHORT>(rEndCell.Row), + static_cast<USHORT>(rEndCell.Column), static_cast<USHORT>(rEndCell.Row), rEndCell.Sheet )); + rEndX += pRect->Left(); + rEndY += pRect->Top(); + rPoint.X += aRefPoint.X; + if (rPoint.X > rStartRect.Right()) + rPoint.X = rStartRect.Right() - 2; // decrement by 2 100th_mm because the cellheight is internal in twips + rPoint.Y += aRefPoint.Y; + if (rPoint.Y > rStartRect.Bottom()) + rPoint.Y = rStartRect.Bottom() - 2; // decrement by 2 100th_mm because the cellheight is internal in twips + rSize.Width = rEndX - rPoint.X; + rSize.Height = rEndY - rPoint.Y; + delete pRect; +} + +void ScMyShapeResizer::ResizeShapes() +{ + if (!aShapes.empty() && rImport.GetModel().is()) + { + ::rtl::OUString sRowHeight(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_CELLHGT)); + ::rtl::OUString sPersistName (RTL_CONSTASCII_USTRINGPARAM("PersistName")); + ::rtl::OUString sCaptionPoint( RTL_CONSTASCII_USTRINGPARAM( "CaptionPoint" )); + ::rtl::OUString sConnectorShape( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ConnectorShape") ); + ::rtl::OUString sCaptionShape( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.CaptionShape") ); + ::rtl::OUString sStartShape(RTL_CONSTASCII_USTRINGPARAM("StartShape")); + ::rtl::OUString sEndShape(RTL_CONSTASCII_USTRINGPARAM("EndShape")); + ::rtl::OUString sStartPosition(RTL_CONSTASCII_USTRINGPARAM("StartPosition")); + ::rtl::OUString sEndPosition(RTL_CONSTASCII_USTRINGPARAM("EndPosition")); + uno::Reference<table::XCellRange> xTableRow; + uno::Reference<sheet::XSpreadsheet> xSheet; + uno::Reference<table::XTableRows> xTableRows; + sal_Int32 nOldRow(-1); + sal_Int32 nOldSheet(-1); + ScMyToResizeShapes::iterator aItr = aShapes.begin(); + uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( rImport.GetModel(), uno::UNO_QUERY ); + if ( xSpreadDoc.is() ) + { + uno::Reference<sheet::XSpreadsheets> xSheets = xSpreadDoc->getSheets(); + uno::Reference<container::XIndexAccess> xIndex( xSheets, uno::UNO_QUERY ); + ScDocument* pDoc = rImport.GetDocument(); + if ( pDoc && xIndex.is() ) + { + rImport.LockSolarMutex(); + while (aItr != aShapes.end()) + { + if ((nOldSheet != aItr->aEndCell.Sheet) || !xSheet.is()) + { + nOldSheet = aItr->aEndCell.Sheet; + uno::Any aTable = xIndex->getByIndex(nOldSheet); + if (aTable>>=xSheet) + { + uno::Reference<table::XColumnRowRange> xColumnRowRange (xSheet, uno::UNO_QUERY); + if (xColumnRowRange.is()) + xTableRows = xColumnRowRange->getRows(); + } + } + if (xTableRows.is()) + { + if (nOldRow != aItr->aEndCell.Row || !xTableRow.is()) + { + nOldRow = aItr->aEndCell.Row; + uno::Any aRow = xTableRows->getByIndex(nOldRow); + 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) + { + Rectangle aRec = pDoc->GetMMRect(static_cast<USHORT>(aItr->aStartCell.Column), static_cast<USHORT>(aItr->aStartCell.Row), + static_cast<USHORT>(aItr->aStartCell.Column), static_cast<USHORT>(aItr->aStartCell.Row), aItr->aStartCell.Sheet); + awt::Point aPoint(aItr->xShape->getPosition()); + awt::Size aSize(aItr->xShape->getSize()); + if (aItr->nEndY >= 0 && aItr->nEndX >= 0) + { + if (aItr->xShape->getShapeType().equals(sConnectorShape)) + { + //#103122#; handle connected Connectorshapes + uno::Reference<beans::XPropertySet> xShapeProps (aItr->xShape, uno::UNO_QUERY); + if(xShapeProps.is()) + { + uno::Any aAny = xShapeProps->getPropertyValue( sStartShape ); + uno::Reference<drawing::XShape> xStartShape; + aAny >>= xStartShape; + aAny = xShapeProps->getPropertyValue( sEndShape ); + uno::Reference<drawing::XShape> xEndShape; + aAny >>= xEndShape; + if (!xStartShape.is() && !xEndShape.is()) + { + awt::Size aOldSize(aSize); + GetNewShapeSizePos(pDoc, aRec, aItr->aEndCell, aPoint, aSize, aItr->nEndX, aItr->nEndY); + aItr->xShape->setPosition(aPoint); + if( (aSize.Width != aOldSize.Width) || + (aSize.Height != aOldSize.Height) ) + aItr->xShape->setSize(aSize); + } + else if (xStartShape.is() && xEndShape.is()) + { + // do nothing, because they are connected + } + else + { + // only one point is connected, the other should be moved + + ::rtl::OUString sProperty; + if (xStartShape.is()) + { + awt::Point aEndPoint; + uno::Any aAny = xShapeProps->getPropertyValue(sEndPosition); + aAny >>= aEndPoint; + aPoint.X = aRec.Left() + aEndPoint.X; + aPoint.Y = aRec.Top() + aEndPoint.Y; + sProperty = sEndPosition; + } + else + { + awt::Point aStartPoint; + uno::Any aAny = xShapeProps->getPropertyValue(sStartPosition); + aAny >>= aStartPoint; + aPoint.X = aRec.Left() + aStartPoint.X; + aPoint.Y = aRec.Top() + aStartPoint.Y; + sProperty = sStartPosition; + } + uno::Any aAny; + aAny <<= aPoint; + xShapeProps->setPropertyValue(sProperty, aAny); + } + } + } + else + { + awt::Size aOldSize(aSize); + GetNewShapeSizePos(pDoc, aRec, aItr->aEndCell, aPoint, aSize, aItr->nEndX, aItr->nEndY); + aItr->xShape->setPosition(aPoint); + if( (aSize.Width != aOldSize.Width) || + (aSize.Height != aOldSize.Height) ) + aItr->xShape->setSize(aSize); + } + } + else + { + if (aItr->xShape->getShapeType().equals(sCaptionShape)) + { + Rectangle aRectangle(aPoint.X, aPoint.Y, aPoint.X + aSize.Width, aPoint.Y + aSize.Height); + + awt::Point aCaptionPoint; + uno::Reference< beans::XPropertySet > xShapeProps(aItr->xShape, uno::UNO_QUERY); + if (xShapeProps.is()) + { + try + { + xShapeProps->getPropertyValue( sCaptionPoint ) >>= aCaptionPoint; + } + catch ( uno::Exception& ) + { + DBG_ERROR("This Captionshape has no CaptionPoint property."); + } + } + Point aCorePoint(aPoint.X, aPoint.Y); + Point aCoreCaptionPoint(aCaptionPoint.X, aCaptionPoint.Y); + aCoreCaptionPoint += aCorePoint; + aRectangle.Union(Rectangle(aCoreCaptionPoint, aCoreCaptionPoint)); + + Point aBeforeRightBottomPoint(aRectangle.BottomRight()); + + aRectangle += aRec.TopLeft(); + if (aRectangle.Left() > aRec.Right()) + aRectangle -= (Point(aRectangle.Left() - aRec.Right() + 2, 0)); + if (aRectangle.Top() > aRec.Bottom()) + aRectangle -= (Point(0, aRectangle.Top() - aRec.Bottom() + 2)); + + Point aDifferencePoint(aRectangle.BottomRight() - aBeforeRightBottomPoint); + aPoint.X += aDifferencePoint.X(); + aPoint.Y += aDifferencePoint.Y(); + + aItr->xShape->setPosition(aPoint); + } + else + { + // #96159# it is possible, that shapes have a negative position + // this is now handled here + DBG_ERROR("no or negative end address of this shape"); + awt::Point aRefPoint; + aRefPoint.X = aRec.Left(); + aRefPoint.Y = aRec.Top(); + aPoint.X += aRefPoint.X; + if (aPoint.X > aRec.Right()) + aPoint.X = aRec.Right() - 2; // decrement by 2 100th_mm because the cellheight is internal in twips + aPoint.Y += aRefPoint.Y; + if (aPoint.Y > aRec.Bottom()) + aPoint.Y = aRec.Bottom() - 2; // decrement by 2 100th_mm because the cellheight is internal in twips + aItr->xShape->setPosition(aPoint); + } + } + } + } + } + } + else + DBG_ERROR("something wents wrong"); + if (IsOLE(aItr->xShape)) + { + uno::Reference < beans::XPropertySet > xShapeProps ( aItr->xShape, uno::UNO_QUERY ); + uno::Reference < beans::XPropertySetInfo > xShapeInfo = xShapeProps->getPropertySetInfo(); + if (xShapeProps.is() && xShapeInfo.is()) + { + if (xShapeInfo->hasPropertyByName(sPersistName)) + { + uno::Any aAny = xShapeProps->getPropertyValue(sPersistName); + ::rtl::OUString sName; + if (aAny >>= sName) + CreateChartListener(pDoc, sName, aItr->pRangeList); + } + } + } + if (aItr->pRangeList) + delete aItr->pRangeList; + aItr = aShapes.erase(aItr); + } + rImport.UnlockSolarMutex(); +// if (pCollection) +// pDoc->SetChartListenerCollection(pCollection); + } + } + } +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_XMLTableShapesContext.cxx b/binfilter/bf_sc/source/filter/xml/sc_XMLTableShapesContext.cxx new file mode 100644 index 000000000000..6460914d4792 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_XMLTableShapesContext.cxx @@ -0,0 +1,91 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "XMLTableShapesContext.hxx" +#include "XMLTableShapeImportHelper.hxx" +#include "xmlimprt.hxx" + +namespace binfilter { + +using namespace ::com::sun::star; + +//------------------------------------------------------------------ + +ScXMLTableShapesContext::ScXMLTableShapesContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + // here are no attributes +} + +ScXMLTableShapesContext::~ScXMLTableShapesContext() +{ +} + +SvXMLImportContext *ScXMLTableShapesContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if (!pContext) + { + ScXMLImport& rXMLImport = GetScImport(); + uno::Reference<drawing::XShapes> xShapes (rXMLImport.GetTables().GetCurrentXShapes()); + if (xShapes.is()) + { + XMLTableShapeImportHelper* pTableShapeImport = (XMLTableShapeImportHelper*)rXMLImport.GetShapeImport().get(); + pTableShapeImport->SetOnTable(sal_True); + pContext = rXMLImport.GetShapeImport()->CreateGroupChildContext( + rXMLImport, nPrefix, rLName, xAttrList, xShapes); + } + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLTableShapesContext::EndElement() +{ +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_XMLTableSourceContext.cxx b/binfilter/bf_sc/source/filter/xml/sc_XMLTableSourceContext.cxx new file mode 100644 index 000000000000..b6f4ec046d80 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_XMLTableSourceContext.cxx @@ -0,0 +1,152 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "XMLTableSourceContext.hxx" +#include "xmlimprt.hxx" +#include "document.hxx" +#include "tablink.hxx" + +#include <bf_xmloff/xmlnmspe.hxx> +#include <bf_xmloff/nmspmap.hxx> +#include <bf_xmloff/xmluconv.hxx> + +#include <com/sun/star/sheet/XSheetLinkable.hpp> +namespace binfilter { + +using namespace ::com::sun::star; +using namespace xmloff::token; + +//------------------------------------------------------------------ + +ScXMLTableSourceContext::ScXMLTableSourceContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList) : + SvXMLImportContext( rImport, nPrfx, rLName ), + sLink(), + sTableName(), + sFilterName(), + sFilterOptions(), + nRefresh(0), + nMode(sheet::SheetLinkMode_NORMAL) +{ + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + if(nPrefix == XML_NAMESPACE_XLINK) + { + if (IsXMLToken(aLocalName, XML_HREF)) + sLink = GetScImport().GetAbsoluteReference(sValue); + } + else if (nPrefix == XML_NAMESPACE_TABLE) + { + if (IsXMLToken(aLocalName, XML_TABLE_NAME)) + sTableName = sValue; + else if (IsXMLToken(aLocalName, XML_FILTER_NAME)) + sFilterName = sValue; + else if (IsXMLToken(aLocalName, XML_FILTER_OPTIONS)) + sFilterOptions = sValue; + else if (IsXMLToken(aLocalName, XML_MODE)) + { + if (IsXMLToken(sValue, XML_COPY_RESULTS_ONLY)) + nMode = sheet::SheetLinkMode_VALUE; + } + else if (IsXMLToken(aLocalName, XML_REFRESH_DELAY)) + { + double fTime; + if( SvXMLUnitConverter::convertTime( fTime, sValue ) ) + nRefresh = Max( (sal_Int32)(fTime * 86400.0), (sal_Int32)0 ); + } + } + } +} + +ScXMLTableSourceContext::~ScXMLTableSourceContext() +{ +} + +SvXMLImportContext *ScXMLTableSourceContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + return pContext; +} + +void ScXMLTableSourceContext::EndElement() +{ + if (sLink.getLength()) + { + uno::Reference <sheet::XSheetLinkable> xLinkable (GetScImport().GetTables().GetCurrentXSheet(), uno::UNO_QUERY); + ScDocument* pDoc = GetScImport().GetDocument(); + if (xLinkable.is() && pDoc) + { + GetScImport().LockSolarMutex(); + if (pDoc->RenameTab( GetScImport().GetTables().GetCurrentSheet(), + GetScImport().GetTables().GetCurrentSheetName(), sal_False, sal_True)) + { + String aFileString(sLink); + String aFilterString(sFilterName); + String aOptString(sFilterOptions); + String aSheetString(sTableName); + + aFileString = ScGlobal::GetAbsDocName( aFileString, pDoc->GetDocumentShell() ); + if ( !aFilterString.Len() ) + ScDocumentLoader::GetFilterName( aFileString, aFilterString, aOptString ); + + BYTE nLinkMode = SC_LINK_NONE; + if ( nMode == sheet::SheetLinkMode_NORMAL ) + nLinkMode = SC_LINK_NORMAL; + else if ( nMode == sheet::SheetLinkMode_VALUE ) + nLinkMode = SC_LINK_VALUE; + + pDoc->SetLink( GetScImport().GetTables().GetCurrentSheet(), + nLinkMode, aFileString, aFilterString, aOptString, + aSheetString, nRefresh ); + } + GetScImport().UnlockSolarMutex(); + } + } +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_XMLTextPContext.cxx b/binfilter/bf_sc/source/filter/xml/sc_XMLTextPContext.cxx new file mode 100644 index 000000000000..961d06711547 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_XMLTextPContext.cxx @@ -0,0 +1,176 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "XMLTextPContext.hxx" +#include "xmlimprt.hxx" +#include "xmlcelli.hxx" + +#include <bf_xmloff/xmlnmspe.hxx> +#include <bf_xmloff/nmspmap.hxx> + +namespace binfilter { + +using namespace ::com::sun::star; +using namespace xmloff::token; + +class ScXMLTextTContext : public SvXMLImportContext +{ + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } +public: + ScXMLTextTContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLTextPContext* pTextPContext); + + virtual ~ScXMLTextTContext(); +}; + + +ScXMLTextTContext::ScXMLTextTContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLTextPContext* pTextPContext) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + if (pTextPContext) + { + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + ::rtl::OUString aLocalName; + ::rtl::OUString sValue; + sal_Int32 nCount(1); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + xAttrList->getNameByIndex( i ), &aLocalName ); + sValue = xAttrList->getValueByIndex( i ); + + if ((nPrefix == XML_NAMESPACE_TEXT) && IsXMLToken(aLocalName, XML_C)) + nCount = sValue.toInt32(); + } + pTextPContext->AddSpaces(nCount); + } +} + +ScXMLTextTContext::~ScXMLTextTContext() +{ +} + +//------------------------------------------------------------------ + +ScXMLTextPContext::ScXMLTextPContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xTempAttrList, + ScXMLTableRowCellContext* pTempCellContext) : + SvXMLImportContext( rImport, nPrfx, rLName ), + pTextPContext(NULL), + pCellContext(pTempCellContext), + sOUText(), + sLName(rLName), + xAttrList(xTempAttrList), + nPrefix(nPrfx), + bIsOwn(sal_True) +{ + // here are no attributes +} + +ScXMLTextPContext::~ScXMLTextPContext() +{ + if (pTextPContext) + delete pTextPContext; +} + +void ScXMLTextPContext::AddSpaces(sal_Int32 nSpaceCount) +{ + sal_Char* pChars = new sal_Char[nSpaceCount]; + memset(pChars, ' ', nSpaceCount); + sOUText.appendAscii(pChars, nSpaceCount); +} + +SvXMLImportContext *ScXMLTextPContext::CreateChildContext( USHORT nTempPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xTempAttrList ) +{ + SvXMLImportContext *pContext = NULL; + if (!pTextPContext && + (nTempPrefix == XML_NAMESPACE_TEXT) && + IsXMLToken(rLName, XML_S)) + pContext = new ScXMLTextTContext( GetScImport(), nTempPrefix, rLName, xTempAttrList, this); + else + { + if (!pTextPContext) + { + pCellContext->SetCursorOnTextImport(sOUText.makeStringAndClear()); + pTextPContext = GetScImport().GetTextImport()->CreateTextChildContext( + GetScImport(), nPrefix, sLName, xAttrList); + } + if (pTextPContext) + pContext = pTextPContext->CreateChildContext(nTempPrefix, rLName, xTempAttrList); + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetScImport(), nTempPrefix, rLName ); + + return pContext; +} + +void ScXMLTextPContext::Characters( const ::rtl::OUString& rChars ) +{ + if (!pTextPContext) + sOUText.append(rChars); + else + pTextPContext->Characters(rChars); +} + +void ScXMLTextPContext::EndElement() +{ + if (!pTextPContext) + pCellContext->SetString(sOUText.makeStringAndClear()); +// GetScImport().GetTextImport()->GetCursor()->setString(sOUText.makeStringAndClear()); + else + { + pTextPContext->EndElement(); + GetScImport().SetRemoveLastChar(sal_True); + } +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_XMLTrackedChangesContext.cxx b/binfilter/bf_sc/source/filter/xml/sc_XMLTrackedChangesContext.cxx new file mode 100644 index 000000000000..078e5fb80c84 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_XMLTrackedChangesContext.cxx @@ -0,0 +1,2024 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "XMLTrackedChangesContext.hxx" +#include "xmlimprt.hxx" +#include "xmlconti.hxx" +#include "XMLConverter.hxx" +#include "cell.hxx" +#include "textuno.hxx" +#include "editutil.hxx" + +#include <bf_xmloff/xmlnmspe.hxx> +#include <bf_xmloff/nmspmap.hxx> +#include <bf_xmloff/xmluconv.hxx> + +#include <bf_svtools/zforlist.hxx> + +#include <com/sun/star/text/ControlCharacter.hpp> +namespace binfilter { + +using namespace ::com::sun::star; +using namespace xmloff::token; + +using rtl::OUString; + +//----------------------------------------------------------------------------- + +class ScXMLChangeInfoContext : public SvXMLImportContext +{ + ScMyActionInfo aInfo; + ::rtl::OUStringBuffer sBuffer; + ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper; + sal_uInt32 nParagraphCount; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + ScXMLChangeInfoContext( ScXMLImport& rImport, USHORT nPrfx, const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper); + virtual ~ScXMLChangeInfoContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +//----------------------------------------------------------------------------- + +class ScXMLBigRangeContext : public SvXMLImportContext +{ + ScBigRange& rBigRange; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + ScXMLBigRangeContext( ScXMLImport& rImport, USHORT nPrfx, const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScBigRange& rBigRange); + virtual ~ScXMLBigRangeContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +//----------------------------------------------------------------------------- + +class ScXMLCellContentDeletionContext : public SvXMLImportContext +{ + ::rtl::OUString sFormulaAddress; + ::rtl::OUString sFormula; + ScBigRange aBigRange; + double fValue; + ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper; + ScBaseCell* pCell; + sal_uInt32 nID; + sal_Int32 nMatrixCols; + sal_Int32 nMatrixRows; + sal_uInt16 nType; + sal_uInt8 nMatrixFlag; + sal_Bool bBigRange : 1; + sal_Bool bContainsCell : 1; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + ScXMLCellContentDeletionContext( ScXMLImport& rImport, USHORT nPrfx, const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper); + virtual ~ScXMLCellContentDeletionContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +//----------------------------------------------------------------------------- + +class ScXMLDependenceContext : public SvXMLImportContext +{ + ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + ScXMLDependenceContext( ScXMLImport& rImport, USHORT nPrfx, const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper); + virtual ~ScXMLDependenceContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +//----------------------------------------------------------------------------- + +class ScXMLDependingsContext : public SvXMLImportContext +{ + ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + ScXMLDependingsContext( ScXMLImport& rImport, USHORT nPrfx, const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper); + virtual ~ScXMLDependingsContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +//----------------------------------------------------------------------------- + +class ScXMLChangeDeletionContext : public SvXMLImportContext +{ + ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + ScXMLChangeDeletionContext( ScXMLImport& rImport, USHORT nPrfx, const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper); + virtual ~ScXMLChangeDeletionContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +//----------------------------------------------------------------------------- + +class ScXMLDeletionsContext : public SvXMLImportContext +{ + ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + ScXMLDeletionsContext( ScXMLImport& rImport, USHORT nPrfx, const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper); + virtual ~ScXMLDeletionsContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +//----------------------------------------------------------------------------- + +class ScXMLChangeCellContext; + +class ScXMLChangeTextPContext : public SvXMLImportContext +{ + ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList> xAttrList; + ::rtl::OUString sLName; + ::rtl::OUStringBuffer sText; + ScXMLChangeCellContext* pChangeCellContext; + SvXMLImportContext* pTextPContext; + USHORT nPrefix; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLChangeTextPContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLChangeCellContext* pChangeCellContext); + + virtual ~ScXMLChangeTextPContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void Characters( const ::rtl::OUString& rChars ); + + virtual void EndElement(); +}; + +//----------------------------------------------------------------------------- + +class ScXMLChangeCellContext : public SvXMLImportContext +{ + ::rtl::OUString sText; + ScBaseCell*& rOldCell; + ScEditEngineTextObj* pEditTextObj; + double& rDateTimeValue; + double fValue; + sal_uInt16& rType; + sal_Bool bIsMatrix : 1; + sal_Bool bIsCoveredMatrix : 1; + sal_Bool bEmpty : 1; + sal_Bool bFirstParagraph : 1; + sal_Bool bString : 1; + sal_Bool bFormula : 1; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + ScXMLChangeCellContext( ScXMLImport& rImport, USHORT nPrfx, const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScBaseCell*& rOldCell, ::rtl::OUString& sAddress, ::rtl::OUString& sFormula, + double& fValue, sal_uInt16& nType, + sal_uInt8& nMatrixFlag, sal_Int32& nMatrixCols, sal_Int32& nMatrixRows); + virtual ~ScXMLChangeCellContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + void CreateTextPContext(sal_Bool bIsNewParagraph); + sal_Bool IsEditCell() { return pEditTextObj != 0; } + void SetText(const ::rtl::OUString& sTempText) { sText = sTempText; } + + virtual void EndElement(); +}; + +//----------------------------------------------------------------------------- + +class ScXMLPreviousContext : public SvXMLImportContext +{ + ::rtl::OUString sFormulaAddress; + ::rtl::OUString sFormula; + double fValue; + ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper; + ScBaseCell* pOldCell; + sal_uInt32 nID; + sal_Int32 nMatrixCols; + sal_Int32 nMatrixRows; + sal_uInt16 nType; + sal_uInt8 nMatrixFlag; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + ScXMLPreviousContext( ScXMLImport& rImport, USHORT nPrfx, const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper); + virtual ~ScXMLPreviousContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +//----------------------------------------------------------------------------- + +class ScXMLContentChangeContext : public SvXMLImportContext +{ + ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper; + ScBigRange aBigRange; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + ScXMLContentChangeContext( ScXMLImport& rImport, USHORT nPrfx, const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper); + virtual ~ScXMLContentChangeContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + virtual void EndElement(); +}; + +//----------------------------------------------------------------------------- + +class ScXMLInsertionContext : public SvXMLImportContext +{ + ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + ScXMLInsertionContext( ScXMLImport& rImport, USHORT nPrfx, const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper); + virtual ~ScXMLInsertionContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + virtual void EndElement(); +}; + +//----------------------------------------------------------------------------- + +class ScXMLInsertionCutOffContext : public SvXMLImportContext +{ + ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + ScXMLInsertionCutOffContext( ScXMLImport& rImport, USHORT nPrfx, const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper); + virtual ~ScXMLInsertionCutOffContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + virtual void EndElement(); +}; + +//----------------------------------------------------------------------------- + +class ScXMLMovementCutOffContext : public SvXMLImportContext +{ + ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + ScXMLMovementCutOffContext( ScXMLImport& rImport, USHORT nPrfx, const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper); + virtual ~ScXMLMovementCutOffContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + virtual void EndElement(); +}; + +//----------------------------------------------------------------------------- + +class ScXMLCutOffsContext : public SvXMLImportContext +{ + ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + ScXMLCutOffsContext( ScXMLImport& rImport, USHORT nPrfx, const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper); + virtual ~ScXMLCutOffsContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + virtual void EndElement(); +}; + +//----------------------------------------------------------------------------- + +class ScXMLDeletionContext : public SvXMLImportContext +{ + ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + ScXMLDeletionContext( ScXMLImport& rImport, USHORT nPrfx, const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper); + virtual ~ScXMLDeletionContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + virtual void EndElement(); +}; + +//----------------------------------------------------------------------------- + +class ScXMLMovementContext : public SvXMLImportContext +{ + ScBigRange aSourceRange; + ScBigRange aTargetRange; + ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + ScXMLMovementContext( ScXMLImport& rImport, USHORT nPrfx, const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper); + virtual ~ScXMLMovementContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + virtual void EndElement(); +}; + +//----------------------------------------------------------------------------- + +class ScXMLRejectionContext : public SvXMLImportContext +{ + ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + ScXMLRejectionContext( ScXMLImport& rImport, USHORT nPrfx, const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper); + virtual ~ScXMLRejectionContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + virtual void EndElement(); +}; + +//------------------------------------------------------------------ + +ScXMLTrackedChangesContext::ScXMLTrackedChangesContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList, + ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + rImport.LockSolarMutex(); + pChangeTrackingImportHelper = pTempChangeTrackingImportHelper; + pChangeTrackingImportHelper->SetChangeTrack(sal_True); + + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + if (nPrefix == XML_NAMESPACE_TABLE) + { + if (IsXMLToken(aLocalName, XML_PROTECTION_KEY)) + { + if (sValue.getLength()) + { + uno::Sequence<sal_Int8> aPass; + SvXMLUnitConverter::decodeBase64(aPass, sValue); + pChangeTrackingImportHelper->SetProtection(aPass); + } + } + } + } +} + +ScXMLTrackedChangesContext::~ScXMLTrackedChangesContext() +{ + GetScImport().UnlockSolarMutex(); +} + +SvXMLImportContext *ScXMLTrackedChangesContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if (nPrefix == XML_NAMESPACE_TABLE) + { + if (IsXMLToken(rLocalName, XML_CELL_CONTENT_CHANGE)) + { + pContext = new ScXMLContentChangeContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper); + } + else if (IsXMLToken(rLocalName, XML_INSERTION)) + { + pContext = new ScXMLInsertionContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper); + } + else if (IsXMLToken(rLocalName, XML_DELETION)) + { + pContext = new ScXMLDeletionContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper); + } + else if (IsXMLToken(rLocalName, XML_MOVEMENT)) + { + pContext = new ScXMLMovementContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper); + } + else if (IsXMLToken(rLocalName, XML_REJECTION)) + { + pContext = new ScXMLRejectionContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper); + } + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + + return pContext; +} + +void ScXMLTrackedChangesContext::EndElement() +{ +} + +ScXMLChangeInfoContext::ScXMLChangeInfoContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList, + ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) : + SvXMLImportContext( rImport, nPrfx, rLName ), + aInfo(), + nParagraphCount(0) +{ + pChangeTrackingImportHelper = pTempChangeTrackingImportHelper; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + if (nPrefix == XML_NAMESPACE_OFFICE) + { + if (IsXMLToken(aLocalName, XML_CHG_AUTHOR)) + { + aInfo.sUser = sValue; + } + else if (IsXMLToken(aLocalName, XML_CHG_DATE_TIME)) + { + GetScImport().GetMM100UnitConverter().convertDateTime(aInfo.aDateTime, sValue); + } + } + } +} + +ScXMLChangeInfoContext::~ScXMLChangeInfoContext() +{ +} + +SvXMLImportContext *ScXMLChangeInfoContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if ((nPrefix == XML_NAMESPACE_TEXT) && (IsXMLToken(rLocalName, XML_P)) ) + { + if(nParagraphCount) + sBuffer.append(static_cast<sal_Unicode>('\n')); + nParagraphCount++; + pContext = new ScXMLContentContext( GetScImport(), nPrefix, rLocalName, xAttrList, sBuffer); + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + + return pContext; +} + +void ScXMLChangeInfoContext::EndElement() +{ + aInfo.sComment = sBuffer.makeStringAndClear(); + pChangeTrackingImportHelper->SetActionInfo(aInfo); +} + +ScXMLBigRangeContext::ScXMLBigRangeContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList, + ScBigRange& rTempBigRange ) : + SvXMLImportContext( rImport, nPrfx, rLName ), + rBigRange(rTempBigRange) +{ + sal_Bool bColumn(sal_False); + sal_Bool bRow(sal_False); + sal_Bool bTable(sal_False); + sal_Int32 nColumn; + sal_Int32 nRow; + sal_Int32 nTable; + sal_Int32 nStartColumn; + sal_Int32 nEndColumn; + sal_Int32 nStartRow; + sal_Int32 nEndRow; + sal_Int32 nStartTable; + sal_Int32 nEndTable; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + if (nPrefix == XML_NAMESPACE_TABLE) + { + if (IsXMLToken(aLocalName, XML_COLUMN)) + { + SvXMLUnitConverter::convertNumber(nColumn, sValue); + bColumn = sal_True; + } + else if (IsXMLToken(aLocalName, XML_ROW)) + { + SvXMLUnitConverter::convertNumber(nRow, sValue); + bRow = sal_True; + } + else if (IsXMLToken(aLocalName, XML_TABLE)) + { + SvXMLUnitConverter::convertNumber(nTable, sValue); + bTable = sal_True; + } + else if (IsXMLToken(aLocalName, XML_START_COLUMN)) + SvXMLUnitConverter::convertNumber(nStartColumn, sValue); + else if (IsXMLToken(aLocalName, XML_END_COLUMN)) + SvXMLUnitConverter::convertNumber(nEndColumn, sValue); + else if (IsXMLToken(aLocalName, XML_START_ROW)) + SvXMLUnitConverter::convertNumber(nStartRow, sValue); + else if (IsXMLToken(aLocalName, XML_END_ROW)) + SvXMLUnitConverter::convertNumber(nEndRow, sValue); + else if (IsXMLToken(aLocalName, XML_START_TABLE)) + SvXMLUnitConverter::convertNumber(nStartTable, sValue); + else if (IsXMLToken(aLocalName, XML_END_TABLE)) + SvXMLUnitConverter::convertNumber(nEndTable, sValue); + } + } + if (bColumn) + nStartColumn = nEndColumn = nColumn; + if (bRow) + nStartRow = nEndRow = nRow; + if (bTable) + nStartTable = nEndTable = nTable; + rBigRange.Set(nStartColumn, nStartRow, nStartTable, + nEndColumn, nEndRow, nEndTable); +} + +ScXMLBigRangeContext::~ScXMLBigRangeContext() +{ +} + +SvXMLImportContext *ScXMLBigRangeContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + + return pContext; +} + +void ScXMLBigRangeContext::EndElement() +{ +} + +ScXMLCellContentDeletionContext::ScXMLCellContentDeletionContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList, + ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper) : + SvXMLImportContext( rImport, nPrfx, rLName ), + pCell(NULL), + nMatrixFlag(MM_NONE), + nID(0), + bBigRange(sal_False), + nType(NUMBERFORMAT_ALL), + bContainsCell(sal_False), + nMatrixCols(0), + nMatrixRows(0) +{ + pChangeTrackingImportHelper = pTempChangeTrackingImportHelper; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + if (nPrefix == XML_NAMESPACE_TABLE) + { + if (IsXMLToken(aLocalName, XML_ID)) + nID = pChangeTrackingImportHelper->GetIDFromString(sValue); + } + } +} + +ScXMLCellContentDeletionContext::~ScXMLCellContentDeletionContext() +{ +} + +SvXMLImportContext *ScXMLCellContentDeletionContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if (nPrefix == XML_NAMESPACE_TABLE) + { + if (IsXMLToken(rLocalName, XML_CHANGE_TRACK_TABLE_CELL)) + { + bContainsCell = sal_True; + pContext = new ScXMLChangeCellContext(GetScImport(), nPrefix, rLocalName, xAttrList, + pCell, sFormulaAddress, sFormula, fValue, nType, nMatrixFlag, nMatrixCols, nMatrixRows ); + } + else if (IsXMLToken(rLocalName, XML_CELL_ADDRESS)) + { + DBG_ASSERT(!nID, "a action with a ID should not contain a BigRange"); + bBigRange = sal_True; + pContext = new ScXMLBigRangeContext(GetScImport(), nPrefix, rLocalName, xAttrList, aBigRange); + } + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + + return pContext; +} + +void ScXMLCellContentDeletionContext::EndElement() +{ + ScMyCellInfo* pCellInfo = new ScMyCellInfo(pCell, sFormulaAddress, sFormula, fValue, nType, + nMatrixFlag, nMatrixCols, nMatrixRows); + if (nID) + pChangeTrackingImportHelper->AddDeleted(nID, pCellInfo); + else + pChangeTrackingImportHelper->AddGenerated(pCellInfo, aBigRange); +} + +ScXMLDependenceContext::ScXMLDependenceContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList, + ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + pChangeTrackingImportHelper = pTempChangeTrackingImportHelper; + sal_uInt32 nID; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + if (nPrefix == XML_NAMESPACE_TABLE) + { + if (IsXMLToken(aLocalName, XML_ID)) + nID = pChangeTrackingImportHelper->GetIDFromString(sValue); + } + } + pChangeTrackingImportHelper->AddDependence(nID); +} + +ScXMLDependenceContext::~ScXMLDependenceContext() +{ +} + +SvXMLImportContext *ScXMLDependenceContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + // here are no elements + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + + return pContext; +} + +void ScXMLDependenceContext::EndElement() +{ +} + +ScXMLDependingsContext::ScXMLDependingsContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList, + ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + pChangeTrackingImportHelper = pTempChangeTrackingImportHelper; + // here are no attributes +} + +ScXMLDependingsContext::~ScXMLDependingsContext() +{ +} + +SvXMLImportContext *ScXMLDependingsContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if (nPrefix == XML_NAMESPACE_TABLE) + { + if (IsXMLToken(rLocalName, XML_DEPENDENCE)) + pContext = new ScXMLDependenceContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper); + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + + return pContext; +} + +void ScXMLDependingsContext::EndElement() +{ +} + +ScXMLChangeDeletionContext::ScXMLChangeDeletionContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList, + ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + pChangeTrackingImportHelper = pTempChangeTrackingImportHelper; + sal_uInt32 nID; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + if (nPrefix == XML_NAMESPACE_TABLE) + { + if (IsXMLToken(aLocalName, XML_ID)) + nID = pChangeTrackingImportHelper->GetIDFromString(sValue); + } + } + pChangeTrackingImportHelper->AddDeleted(nID); +} + +ScXMLChangeDeletionContext::~ScXMLChangeDeletionContext() +{ +} + +SvXMLImportContext *ScXMLChangeDeletionContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + // here are no elements + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + + return pContext; +} + +void ScXMLChangeDeletionContext::EndElement() +{ +} + +ScXMLDeletionsContext::ScXMLDeletionsContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList, + ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + pChangeTrackingImportHelper = pTempChangeTrackingImportHelper; + // here are no attributes +} + +ScXMLDeletionsContext::~ScXMLDeletionsContext() +{ +} + +SvXMLImportContext *ScXMLDeletionsContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if (nPrefix == XML_NAMESPACE_TABLE) + { + if (IsXMLToken(rLocalName, XML_CHANGE_DELETION)) + pContext = new ScXMLChangeDeletionContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper); + else if (IsXMLToken(rLocalName, XML_CELL_CONTENT_DELETION)) + pContext = new ScXMLCellContentDeletionContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper); + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + + return pContext; +} + +void ScXMLDeletionsContext::EndElement() +{ +} + +ScXMLChangeTextPContext::ScXMLChangeTextPContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xTempAttrList, + ScXMLChangeCellContext* pTempChangeCellContext) : + SvXMLImportContext( rImport, nPrfx, rLName ), + pTextPContext(NULL), + sLName(rLName), + xAttrList(xTempAttrList), + nPrefix(nPrfx), + sText() +{ + pChangeCellContext = pTempChangeCellContext; + // here are no attributes +} + +ScXMLChangeTextPContext::~ScXMLChangeTextPContext() +{ + if (pTextPContext) + delete pTextPContext; +} + +SvXMLImportContext *ScXMLChangeTextPContext::CreateChildContext( USHORT nTempPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xTempAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if ((nPrefix == XML_NAMESPACE_TEXT) && (IsXMLToken(rLName, XML_S)) && !pTextPContext) + { + sal_Int32 nRepeat(0); + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrfx = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + if ((nPrfx == XML_NAMESPACE_TEXT) && (IsXMLToken(aLocalName, XML_C))) + nRepeat = sValue.toInt32(); + } + if (nRepeat) + for (sal_Int32 j = 0; j < nRepeat; j++) + sText.append(static_cast<sal_Unicode>(' ')); + else + sText.append(static_cast<sal_Unicode>(' ')); + } + else + { + if (!pChangeCellContext->IsEditCell()) + pChangeCellContext->CreateTextPContext(sal_False); + sal_Bool bWasContext (sal_True); + if (!pTextPContext) + { + bWasContext = sal_False; + pTextPContext = GetScImport().GetTextImport()->CreateTextChildContext( + GetScImport(), nPrefix, sLName, xAttrList); + } + if (pTextPContext) + { + if (!bWasContext) + pTextPContext->Characters(sText.makeStringAndClear()); + pContext = pTextPContext->CreateChildContext(nTempPrefix, rLName, xTempAttrList); + } + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLChangeTextPContext::Characters( const ::rtl::OUString& rChars ) +{ + if (!pTextPContext) + sText.append(rChars); + else + pTextPContext->Characters(rChars); +} + +void ScXMLChangeTextPContext::EndElement() +{ + if (!pTextPContext) + pChangeCellContext->SetText(sText.makeStringAndClear()); +} + +ScXMLChangeCellContext::ScXMLChangeCellContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList, + ScBaseCell*& rTempOldCell, ::rtl::OUString& rAddress, ::rtl::OUString& rFormula, + double& fDateTimeValue, sal_uInt16& nType, + sal_uInt8& nMatrixFlag, sal_Int32& nMatrixCols, sal_Int32& nMatrixRows ) : + SvXMLImportContext( rImport, nPrfx, rLName ), + bEmpty(sal_True), + bFirstParagraph(sal_True), + bFormula(sal_False), + bString(sal_True), + pEditTextObj(NULL), + rOldCell(rTempOldCell), + rType(nType), + rDateTimeValue(fDateTimeValue) +{ + sal_Bool bIsMatrix(sal_False); + sal_Bool bIsCoveredMatrix(sal_False); + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + if (nPrefix == XML_NAMESPACE_TABLE) + { + if (IsXMLToken(aLocalName, XML_VALUE_TYPE)) + { + if (IsXMLToken(sValue, XML_FLOAT)) + bString = sal_False; + else if (IsXMLToken(sValue, XML_DATE)) + rType = NUMBERFORMAT_DATE; + else if (IsXMLToken(sValue, XML_TIME)) + rType = NUMBERFORMAT_TIME; + } + else if (IsXMLToken(aLocalName, XML_VALUE)) + { + SvXMLUnitConverter::convertDouble(fValue, sValue); + bEmpty = sal_False; + } + else if (IsXMLToken(aLocalName, XML_DATE_VALUE)) + { + if (GetScImport().GetMM100UnitConverter().setNullDate(GetScImport().GetModel())) + GetScImport().GetMM100UnitConverter().convertDateTime(rDateTimeValue, sValue); + } + else if (IsXMLToken(aLocalName, XML_TIME_VALUE)) + { + GetScImport().GetMM100UnitConverter().convertTime(rDateTimeValue, sValue); + } + else if (IsXMLToken(aLocalName, XML_FORMULA)) + { + bEmpty = sal_False; + rFormula = sValue; + ScXMLConverter::ParseFormula(rFormula); + bFormula = sal_True; + } + else if (IsXMLToken(aLocalName, XML_CELL_ADDRESS)) + { + rAddress = sValue; + } + else if (IsXMLToken(aLocalName, XML_MATRIX_COVERED)) + { + bIsCoveredMatrix = IsXMLToken(sValue, XML_TRUE); + } + else if (IsXMLToken(aLocalName, XML_NUMBER_MATRIX_COLUMNS_SPANNED)) + { + bIsMatrix = sal_True; + SvXMLUnitConverter::convertNumber(nMatrixCols, sValue); + } + else if (IsXMLToken(aLocalName, XML_NUMBER_MATRIX_ROWS_SPANNED)) + { + bIsMatrix = sal_True; + SvXMLUnitConverter::convertNumber(nMatrixRows, sValue); + } + } + } + if (bIsCoveredMatrix) + nMatrixFlag = MM_REFERENCE; + else if (bIsMatrix && nMatrixRows && nMatrixCols) + nMatrixFlag = MM_FORMULA; +} + +ScXMLChangeCellContext::~ScXMLChangeCellContext() +{ +} + +SvXMLImportContext *ScXMLChangeCellContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if ((nPrefix == XML_NAMESPACE_TEXT) && (IsXMLToken(rLocalName, XML_P))) + { + bEmpty = sal_False; + if (bFirstParagraph) + { + pContext = new ScXMLChangeTextPContext(GetScImport(), nPrefix, rLocalName, xAttrList, this); + bFirstParagraph = sal_False; + } + else + { + if (!pEditTextObj) + CreateTextPContext(sal_True); + pContext = GetScImport().GetTextImport()->CreateTextChildContext( + GetScImport(), nPrefix, rLocalName, xAttrList); + } + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + + return pContext; +} + +void ScXMLChangeCellContext::CreateTextPContext(sal_Bool bIsNewParagraph) +{ + if (GetScImport().GetDocument()) + { + pEditTextObj = new ScEditEngineTextObj(); + pEditTextObj->acquire(); + pEditTextObj->GetEditEngine()->SetEditTextObjectPool(GetScImport().GetDocument()->GetEditPool()); + uno::Reference <text::XText> xText = pEditTextObj; + if (xText.is()) + { + uno::Reference<text::XTextCursor> xTextCursor = xText->createTextCursor(); + if (bIsNewParagraph) + { + xText->setString(sText); + xTextCursor->gotoEnd(sal_False); + uno::Reference < text::XTextRange > xTextRange (xTextCursor, uno::UNO_QUERY); + if (xTextRange.is()) + xText->insertControlCharacter(xTextRange, text::ControlCharacter::PARAGRAPH_BREAK, sal_False); + } + GetScImport().GetTextImport()->SetCursor(xTextCursor); + } + } +} + +void ScXMLChangeCellContext::EndElement() +{ + if (!bEmpty) + { + if (pEditTextObj) + { + if (GetImport().GetTextImport()->GetCursor().is()) + { + //GetImport().GetTextImport()->GetCursor()->gotoEnd(sal_False); + if( GetImport().GetTextImport()->GetCursor()->goLeft( 1, sal_True ) ) + { + OUString sEmpty; + GetImport().GetTextImport()->GetText()->insertString( + GetImport().GetTextImport()->GetCursorAsRange(), sEmpty, + sal_True ); + } + } + if (GetScImport().GetDocument()) + rOldCell = new ScEditCell(pEditTextObj->CreateTextObject(), GetScImport().GetDocument(), GetScImport().GetDocument()->GetEditPool()); + GetScImport().GetTextImport()->ResetCursor(); + // delete pEditTextObj; + pEditTextObj->release(); + } + else + { + if (!bFormula) + { + if (sText.getLength() && bString) + rOldCell = new ScStringCell(sText); + else + rOldCell = new ScValueCell(fValue); + } + else + { + // do nothing, this has to do later (on another place) + /*ScAddress aCellPos; + rOldCell = new ScFormulaCell(GetScImport().GetDocument(), aCellPos, sFormula); + if (bString) + static_cast<ScFormulaCell*>(rOldCell)->SetString(sValue); + else + static_cast<ScFormulaCell*>(rOldCell)->SetDouble(fValue); + static_cast<ScFormulaCell*>(rOldCell)->SetInChangeTrack(sal_True); + if (bIsCoveredMatrix) + static_cast<ScFormulaCell*>(rOldCell)->SetMatrixFlag(MM_REFERENCE); + else if (bIsMatrix && nMatrixRows && nMatrixCols) + { + static_cast<ScFormulaCell*>(rOldCell)->SetMatrixFlag(MM_FORMULA); + static_cast<ScFormulaCell*>(rOldCell)->SetMatColsRows(static_cast<sal_uInt16>(nMatrixCols), static_cast<sal_uInt16>(nMatrixRows)); + }*/ + } + } + } + else + rOldCell = NULL; +} + +ScXMLPreviousContext::ScXMLPreviousContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList, + ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) : + SvXMLImportContext( rImport, nPrfx, rLName ), + nID(0), + sFormulaAddress(), + sFormula(), + nMatrixFlag(MM_NONE), + pOldCell(NULL), + nType(NUMBERFORMAT_ALL), + nMatrixCols(0), + nMatrixRows(0) +{ + pChangeTrackingImportHelper = pTempChangeTrackingImportHelper; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + if (nPrefix == XML_NAMESPACE_TABLE) + { + if (IsXMLToken(aLocalName, XML_ID)) + nID = pChangeTrackingImportHelper->GetIDFromString(sValue); + } + } +} + +ScXMLPreviousContext::~ScXMLPreviousContext() +{ +} + +SvXMLImportContext *ScXMLPreviousContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if ((nPrefix == XML_NAMESPACE_TABLE) && (IsXMLToken(rLocalName, XML_CHANGE_TRACK_TABLE_CELL))) + pContext = new ScXMLChangeCellContext(GetScImport(), nPrefix, rLocalName, xAttrList, + pOldCell, sFormulaAddress, sFormula, fValue, nType, nMatrixFlag, nMatrixCols, nMatrixRows); + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + + return pContext; +} + +void ScXMLPreviousContext::EndElement() +{ + ScMyCellInfo* pCellInfo = new ScMyCellInfo(pOldCell, sFormulaAddress, sFormula, fValue, nType, + nMatrixFlag, nMatrixCols, nMatrixRows); + pChangeTrackingImportHelper->SetPreviousChange(nID, pCellInfo); +} + +ScXMLContentChangeContext::ScXMLContentChangeContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList, + ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + sal_uInt32 nActionNumber(0); + sal_uInt32 nRejectingNumber(0); + ScChangeActionState nActionState(SC_CAS_VIRGIN); + + pChangeTrackingImportHelper = pTempChangeTrackingImportHelper; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + if (nPrefix == XML_NAMESPACE_TABLE) + { + if (IsXMLToken(aLocalName, XML_ID)) + { + nActionNumber = pChangeTrackingImportHelper->GetIDFromString(sValue); + } + else if (IsXMLToken(aLocalName, XML_ACCEPTANCE_STATE)) + { + if (IsXMLToken(sValue, XML_ACCEPTED)) + nActionState = SC_CAS_ACCEPTED; + else if (IsXMLToken(sValue, XML_REJECTED)) + nActionState = SC_CAS_REJECTED; + } + else if (IsXMLToken(aLocalName, XML_REJECTING_CHANGE_ID)) + { + nRejectingNumber = pChangeTrackingImportHelper->GetIDFromString(sValue); + } + } + } + + pChangeTrackingImportHelper->StartChangeAction(SC_CAT_CONTENT); + pChangeTrackingImportHelper->SetActionNumber(nActionNumber); + pChangeTrackingImportHelper->SetActionState(nActionState); + pChangeTrackingImportHelper->SetRejectingNumber(nRejectingNumber); +} + +ScXMLContentChangeContext::~ScXMLContentChangeContext() +{ +} + +SvXMLImportContext *ScXMLContentChangeContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if ((nPrefix == XML_NAMESPACE_OFFICE) && (IsXMLToken(rLocalName, XML_CHANGE_INFO))) + { + pContext = new ScXMLChangeInfoContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper); + } + else if (nPrefix == XML_NAMESPACE_TABLE) + { + if (IsXMLToken(rLocalName, XML_CELL_ADDRESS)) + { + pContext = new ScXMLBigRangeContext(GetScImport(), nPrefix, rLocalName, xAttrList, aBigRange); + } + else if (IsXMLToken(rLocalName, XML_DEPENDENCES)) + { + pContext = new ScXMLDependingsContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper); + } + else if (IsXMLToken(rLocalName, XML_DELETIONS)) + pContext = new ScXMLDeletionsContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper); + else if (IsXMLToken(rLocalName, XML_PREVIOUS)) + { + pContext = new ScXMLPreviousContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper); + } + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + + return pContext; +} + +void ScXMLContentChangeContext::EndElement() +{ + pChangeTrackingImportHelper->SetBigRange(aBigRange); + pChangeTrackingImportHelper->EndChangeAction(); +} + +ScXMLInsertionContext::ScXMLInsertionContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList, + ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + sal_uInt32 nActionNumber(0); + sal_uInt32 nRejectingNumber(0); + sal_Int32 nPosition(0); + sal_Int32 nCount(1); + sal_Int32 nTable(0); + ScChangeActionState nActionState(SC_CAS_VIRGIN); + ScChangeActionType nActionType(SC_CAT_INSERT_COLS); + + pChangeTrackingImportHelper = pTempChangeTrackingImportHelper; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + if (nPrefix == XML_NAMESPACE_TABLE) + { + if (IsXMLToken(aLocalName, XML_ID)) + { + nActionNumber = pChangeTrackingImportHelper->GetIDFromString(sValue); + } + else if (IsXMLToken(aLocalName, XML_ACCEPTANCE_STATE)) + { + if (IsXMLToken(sValue, XML_ACCEPTED)) + nActionState = SC_CAS_ACCEPTED; + else if (IsXMLToken(sValue, XML_REJECTED)) + nActionState = SC_CAS_REJECTED; + } + else if (IsXMLToken(aLocalName, XML_REJECTING_CHANGE_ID)) + { + nRejectingNumber = pChangeTrackingImportHelper->GetIDFromString(sValue); + } + else if (IsXMLToken(aLocalName, XML_TYPE)) + { + if (IsXMLToken(sValue, XML_ROW)) + nActionType = SC_CAT_INSERT_ROWS; + else if (IsXMLToken(sValue, XML_TABLE)) + nActionType = SC_CAT_INSERT_TABS; + } + else if (IsXMLToken(aLocalName, XML_POSITION)) + { + SvXMLUnitConverter::convertNumber(nPosition, sValue); + } + else if (IsXMLToken(aLocalName, XML_TABLE)) + { + SvXMLUnitConverter::convertNumber(nTable, sValue); + } + else if (IsXMLToken(aLocalName, XML_COUNT)) + { + SvXMLUnitConverter::convertNumber(nCount, sValue); + } + } + } + + pChangeTrackingImportHelper->StartChangeAction(nActionType); + pChangeTrackingImportHelper->SetActionNumber(nActionNumber); + pChangeTrackingImportHelper->SetActionState(nActionState); + pChangeTrackingImportHelper->SetRejectingNumber(nRejectingNumber); + pChangeTrackingImportHelper->SetPosition(nPosition, nCount, nTable); +} + +ScXMLInsertionContext::~ScXMLInsertionContext() +{ +} + +SvXMLImportContext *ScXMLInsertionContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if ((nPrefix == XML_NAMESPACE_OFFICE) && (IsXMLToken(rLocalName, XML_CHANGE_INFO))) + { + pContext = new ScXMLChangeInfoContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper); + } + else if (nPrefix == XML_NAMESPACE_TABLE) + { + if (IsXMLToken(rLocalName, XML_DEPENDENCES)) + pContext = new ScXMLDependingsContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper); + else if (IsXMLToken(rLocalName, XML_DELETIONS)) + pContext = new ScXMLDeletionsContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper); + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + + return pContext; +} + +void ScXMLInsertionContext::EndElement() +{ + pChangeTrackingImportHelper->EndChangeAction(); +} + +ScXMLInsertionCutOffContext::ScXMLInsertionCutOffContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList, + ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + sal_uInt32 nID(0); + sal_Int32 nPosition(0); + pChangeTrackingImportHelper = pTempChangeTrackingImportHelper; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + if (nPrefix == XML_NAMESPACE_TABLE) + { + if (IsXMLToken(aLocalName, XML_ID)) + { + nID = pChangeTrackingImportHelper->GetIDFromString(sValue); + } + else if (IsXMLToken(aLocalName, XML_POSITION)) + { + SvXMLUnitConverter::convertNumber(nPosition, sValue); + } + } + } + pChangeTrackingImportHelper->SetInsertionCutOff(nID, nPosition); +} + +ScXMLInsertionCutOffContext::~ScXMLInsertionCutOffContext() +{ +} + +SvXMLImportContext *ScXMLInsertionCutOffContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + + return pContext; +} + +void ScXMLInsertionCutOffContext::EndElement() +{ +} + +ScXMLMovementCutOffContext::ScXMLMovementCutOffContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList, + ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + pChangeTrackingImportHelper = pTempChangeTrackingImportHelper; + sal_uInt32 nID(0); + sal_Int32 nPosition(0); + sal_Int32 nStartPosition(0); + sal_Int32 nEndPosition(0); + sal_Bool bPosition(sal_False); + pChangeTrackingImportHelper = pTempChangeTrackingImportHelper; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + if (nPrefix == XML_NAMESPACE_TABLE) + { + if (IsXMLToken(aLocalName, XML_ID)) + { + nID = pChangeTrackingImportHelper->GetIDFromString(sValue); + } + else if (IsXMLToken(aLocalName, XML_POSITION)) + { + bPosition = sal_True; + SvXMLUnitConverter::convertNumber(nPosition, sValue); + } + else if (IsXMLToken(aLocalName, XML_START_POSITION)) + { + SvXMLUnitConverter::convertNumber(nStartPosition, sValue); + } + else if (IsXMLToken(aLocalName, XML_END_POSITION)) + { + SvXMLUnitConverter::convertNumber(nEndPosition, sValue); + } + } + } + if (bPosition) + nStartPosition = nEndPosition = nPosition; + pChangeTrackingImportHelper->AddMoveCutOff(nID, nStartPosition, nEndPosition); +} + +ScXMLMovementCutOffContext::~ScXMLMovementCutOffContext() +{ +} + +SvXMLImportContext *ScXMLMovementCutOffContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + + return pContext; +} + +void ScXMLMovementCutOffContext::EndElement() +{ +} + +ScXMLCutOffsContext::ScXMLCutOffsContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList, + ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + pChangeTrackingImportHelper = pTempChangeTrackingImportHelper; + // here are no attributes +} + +ScXMLCutOffsContext::~ScXMLCutOffsContext() +{ +} + +SvXMLImportContext *ScXMLCutOffsContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if (nPrefix == XML_NAMESPACE_TABLE) + { + if (IsXMLToken(rLocalName, XML_INSERTION_CUT_OFF)) + pContext = new ScXMLInsertionCutOffContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper); + else if (IsXMLToken(rLocalName, XML_MOVEMENT_CUT_OFF)) + pContext = new ScXMLMovementCutOffContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper); + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + + return pContext; +} + +void ScXMLCutOffsContext::EndElement() +{ +} + +ScXMLDeletionContext::ScXMLDeletionContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList, + ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + sal_uInt32 nActionNumber(0); + sal_uInt32 nRejectingNumber(0); + sal_Int32 nPosition(0); + sal_Int32 nMultiSpanned(0); + sal_Int32 nTable(0); + ScChangeActionState nActionState(SC_CAS_VIRGIN); + ScChangeActionType nActionType(SC_CAT_DELETE_COLS); + + pChangeTrackingImportHelper = pTempChangeTrackingImportHelper; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + if (nPrefix == XML_NAMESPACE_TABLE) + { + if (IsXMLToken(aLocalName, XML_ID)) + { + nActionNumber = pChangeTrackingImportHelper->GetIDFromString(sValue); + } + else if (IsXMLToken(aLocalName, XML_ACCEPTANCE_STATE)) + { + if (IsXMLToken(sValue, XML_ACCEPTED)) + nActionState = SC_CAS_ACCEPTED; + else if (IsXMLToken(sValue, XML_REJECTED)) + nActionState = SC_CAS_REJECTED; + } + else if (IsXMLToken(aLocalName, XML_REJECTING_CHANGE_ID)) + { + nRejectingNumber = pChangeTrackingImportHelper->GetIDFromString(sValue); + } + else if (IsXMLToken(aLocalName, XML_TYPE)) + { + if (IsXMLToken(sValue, XML_ROW)) + { + nActionType = SC_CAT_DELETE_ROWS; + } + else if (IsXMLToken(aLocalName, XML_TABLE)) + { + nActionType = SC_CAT_DELETE_TABS; + } + } + else if (IsXMLToken(aLocalName, XML_POSITION)) + { + SvXMLUnitConverter::convertNumber(nPosition, sValue); + } + else if (IsXMLToken(aLocalName, XML_TABLE)) + { + SvXMLUnitConverter::convertNumber(nTable, sValue); + } + else if (IsXMLToken(aLocalName, XML_MULTI_DELETION_SPANNED)) + { + SvXMLUnitConverter::convertNumber(nMultiSpanned, sValue); + } + } + } + + pChangeTrackingImportHelper->StartChangeAction(nActionType); + pChangeTrackingImportHelper->SetActionNumber(nActionNumber); + pChangeTrackingImportHelper->SetActionState(nActionState); + pChangeTrackingImportHelper->SetRejectingNumber(nRejectingNumber); + pChangeTrackingImportHelper->SetPosition(nPosition, 1, nTable); + pChangeTrackingImportHelper->SetMultiSpanned(static_cast<sal_Int16>(nMultiSpanned)); +} + +ScXMLDeletionContext::~ScXMLDeletionContext() +{ +} + +SvXMLImportContext *ScXMLDeletionContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if ((nPrefix == XML_NAMESPACE_OFFICE) && (IsXMLToken(rLocalName, XML_CHANGE_INFO))) + { + pContext = new ScXMLChangeInfoContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper); + } + else if (nPrefix == XML_NAMESPACE_TABLE) + { + if (IsXMLToken(rLocalName, XML_DEPENDENCES)) + pContext = new ScXMLDependingsContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper); + else if (IsXMLToken(rLocalName, XML_DELETIONS)) + pContext = new ScXMLDeletionsContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper); + else if (IsXMLToken(rLocalName, XML_CUT_OFFS) || rLocalName.equalsAsciiL("cut_offs", 8)) + pContext = new ScXMLCutOffsContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper); + else + DBG_ERROR("don't know this"); + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + + return pContext; +} + +void ScXMLDeletionContext::EndElement() +{ + pChangeTrackingImportHelper->EndChangeAction(); +} + +ScXMLMovementContext::ScXMLMovementContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList, + ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + sal_uInt32 nActionNumber(0); + sal_uInt32 nRejectingNumber(0); + ScChangeActionState nActionState(SC_CAS_VIRGIN); + + pChangeTrackingImportHelper = pTempChangeTrackingImportHelper; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + if (nPrefix == XML_NAMESPACE_TABLE) + { + if (IsXMLToken(aLocalName, XML_ID)) + { + nActionNumber = pChangeTrackingImportHelper->GetIDFromString(sValue); + } + else if (IsXMLToken(aLocalName, XML_ACCEPTANCE_STATE)) + { + if (IsXMLToken(sValue, XML_ACCEPTED)) + nActionState = SC_CAS_ACCEPTED; + else if (IsXMLToken(sValue, XML_REJECTED)) + nActionState = SC_CAS_REJECTED; + } + else if (IsXMLToken(aLocalName, XML_REJECTING_CHANGE_ID)) + { + nRejectingNumber = pChangeTrackingImportHelper->GetIDFromString(sValue); + } + } + } + + pChangeTrackingImportHelper->StartChangeAction(SC_CAT_MOVE); + pChangeTrackingImportHelper->SetActionNumber(nActionNumber); + pChangeTrackingImportHelper->SetActionState(nActionState); + pChangeTrackingImportHelper->SetRejectingNumber(nRejectingNumber); +} + +ScXMLMovementContext::~ScXMLMovementContext() +{ +} + +SvXMLImportContext *ScXMLMovementContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if ((nPrefix == XML_NAMESPACE_OFFICE) && (IsXMLToken(rLocalName, XML_CHANGE_INFO))) + { + pContext = new ScXMLChangeInfoContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper); + } + else if (nPrefix == XML_NAMESPACE_TABLE) + { + if (IsXMLToken(rLocalName, XML_DEPENDENCES)) + pContext = new ScXMLDependingsContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper); + else if (IsXMLToken(rLocalName, XML_DELETIONS)) + pContext = new ScXMLDeletionsContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper); + else if (IsXMLToken(rLocalName, XML_SOURCE_RANGE_ADDRESS)) + pContext = new ScXMLBigRangeContext(GetScImport(), nPrefix, rLocalName, xAttrList, aSourceRange); + else if (IsXMLToken(rLocalName, XML_TARGET_RANGE_ADDRESS)) + pContext = new ScXMLBigRangeContext(GetScImport(), nPrefix, rLocalName, xAttrList, aTargetRange); + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + + return pContext; +} + +void ScXMLMovementContext::EndElement() +{ + pChangeTrackingImportHelper->SetMoveRanges(aSourceRange, aTargetRange); + pChangeTrackingImportHelper->EndChangeAction(); +} + +ScXMLRejectionContext::ScXMLRejectionContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList, + ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + sal_uInt32 nActionNumber(0); + sal_uInt32 nRejectingNumber(0); + ScChangeActionState nActionState(SC_CAS_VIRGIN); + + pChangeTrackingImportHelper = pTempChangeTrackingImportHelper; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + if (nPrefix == XML_NAMESPACE_TABLE) + { + if (IsXMLToken(aLocalName, XML_ID)) + { + nActionNumber = pChangeTrackingImportHelper->GetIDFromString(sValue); + } + else if (IsXMLToken(aLocalName, XML_ACCEPTANCE_STATE)) + { + if (IsXMLToken(sValue, XML_ACCEPTED)) + nActionState = SC_CAS_ACCEPTED; + else if (IsXMLToken(sValue, XML_REJECTED)) + nActionState = SC_CAS_REJECTED; + } + else if (IsXMLToken(aLocalName, XML_REJECTING_CHANGE_ID)) + { + nRejectingNumber = pChangeTrackingImportHelper->GetIDFromString(sValue); + } + } + } + + pChangeTrackingImportHelper->StartChangeAction(SC_CAT_MOVE); + pChangeTrackingImportHelper->SetActionNumber(nActionNumber); + pChangeTrackingImportHelper->SetActionState(nActionState); + pChangeTrackingImportHelper->SetRejectingNumber(nRejectingNumber); +} + +ScXMLRejectionContext::~ScXMLRejectionContext() +{ +} + +SvXMLImportContext *ScXMLRejectionContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if ((nPrefix == XML_NAMESPACE_OFFICE) && (IsXMLToken(rLocalName, XML_CHANGE_INFO))) + { + pContext = new ScXMLChangeInfoContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper); + } + else if (nPrefix == XML_NAMESPACE_TABLE) + { + if (IsXMLToken(rLocalName, XML_DEPENDENCES)) + pContext = new ScXMLDependingsContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper); + else if (IsXMLToken(rLocalName, XML_DELETIONS)) + pContext = new ScXMLDeletionsContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper); + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + + return pContext; +} + +void ScXMLRejectionContext::EndElement() +{ + pChangeTrackingImportHelper->EndChangeAction(); +} + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_xmlannoi.cxx b/binfilter/bf_sc/source/filter/xml/sc_xmlannoi.cxx new file mode 100644 index 000000000000..e6c06a54bb36 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_xmlannoi.cxx @@ -0,0 +1,145 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "xmlannoi.hxx" +#include "xmlimprt.hxx" +#include "xmlcelli.hxx" +#include "xmlconti.hxx" + +#include <bf_xmloff/nmspmap.hxx> +#include <bf_xmloff/xmlnmspe.hxx> +namespace binfilter { + +using namespace ::com::sun::star; +using namespace xmloff::token; + +//------------------------------------------------------------------ + +ScXMLAnnotationContext::ScXMLAnnotationContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList, + ScXMLTableRowCellContext* pTempCellContext) : + SvXMLImportContext( rImport, nPrfx, rLName ), + nParagraphCount(0), + bDisplay(sal_False), + bHasTextP(sal_False) +{ + pCellContext = pTempCellContext; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetTableAnnotationAttrTokenMap(); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_TABLE_ANNOTATION_ATTR_AUTHOR: + { + sAuthor = sValue; + } + break; + case XML_TOK_TABLE_ANNOTATION_ATTR_CREATE_DATE: + { + sCreateDate = sValue; + } + break; + case XML_TOK_TABLE_ANNOTATION_ATTR_CREATE_DATE_STRING: + { + if (!sCreateDate.getLength()) + sCreateDate = sValue; + } + break; + case XML_TOK_TABLE_ANNOTATION_ATTR_DISPLAY: + { + bDisplay = IsXMLToken(sValue, XML_TRUE); + } + break; + } + } +} + +ScXMLAnnotationContext::~ScXMLAnnotationContext() +{ +} + +SvXMLImportContext *ScXMLAnnotationContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if ((nPrefix == XML_NAMESPACE_TEXT) && IsXMLToken(rLName, XML_P) ) + { + if (!bHasTextP) + { + bHasTextP = sal_True; + sOUText.setLength(0); + } + if(nParagraphCount) + sOUText.append(static_cast<sal_Unicode>('\n')); + nParagraphCount++; + pContext = new ScXMLContentContext( GetScImport(), nPrefix, rLName, xAttrList, sOUText); + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLAnnotationContext::Characters( const ::rtl::OUString& rChars ) +{ + if (!bHasTextP) + sOUText.append(rChars); +} + +void ScXMLAnnotationContext::EndElement() +{ + ScMyImportAnnotation* pMyAnnotation = new ScMyImportAnnotation(); + pMyAnnotation->sAuthor = sAuthor; + pMyAnnotation->sCreateDate = sCreateDate; + pMyAnnotation->sText = sOUText.makeStringAndClear(); + pMyAnnotation->bDisplay = bDisplay; + pCellContext->AddAnnotation(pMyAnnotation); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_xmlbodyi.cxx b/binfilter/bf_sc/source/filter/xml/sc_xmlbodyi.cxx new file mode 100644 index 000000000000..a88de64f85e7 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_xmlbodyi.cxx @@ -0,0 +1,246 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + + +#include "xmlbodyi.hxx" +#include "xmltabi.hxx" +#include "xmlnexpi.hxx" +#include "xmldrani.hxx" +#include "xmldpimp.hxx" +#include "xmlcvali.hxx" +#include "xmlstyli.hxx" + +#include "xmllabri.hxx" +#include "XMLConsolidationContext.hxx" +#include "XMLDDELinksContext.hxx" +#include "XMLCalculationSettingsContext.hxx" +#include "XMLTrackedChangesContext.hxx" +#include "XMLEmptyContext.hxx" +#include "scerrors.hxx" + +#include <bf_xmloff/xmlnmspe.hxx> +#include <bf_xmloff/nmspmap.hxx> +#include <bf_xmloff/xmluconv.hxx> + +#include <com/sun/star/sheet/XSpreadsheetDocument.hpp> + +#include <sal/types.h> +namespace binfilter { + +using namespace ::com::sun::star; +using namespace ::binfilter::xmloff::token; + +//------------------------------------------------------------------ + +ScXMLBodyContext::ScXMLBodyContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList ) : + SvXMLImportContext( rImport, nPrfx, rLName ), + pChangeTrackingImportHelper(NULL), + bProtected(sal_False), + sPassword() +{ + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + if (nPrefix == XML_NAMESPACE_TABLE) + { + if (IsXMLToken(aLocalName, XML_STRUCTURE_PROTECTED)) + bProtected = IsXMLToken(sValue, XML_TRUE); + else if (IsXMLToken(aLocalName, XML_PROTECTION_KEY)) + sPassword = sValue; + } + } +} + +ScXMLBodyContext::~ScXMLBodyContext() +{ +} + +SvXMLImportContext *ScXMLBodyContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + const SvXMLTokenMap& rTokenMap = GetScImport().GetBodyElemTokenMap(); + sal_Bool bOrdered = sal_False; + sal_Bool bHeading = sal_False; + switch( rTokenMap.Get( nPrefix, rLocalName ) ) + { +// case XML_TOK_TEXT_H: +// bHeading = TRUE; +// case XML_TOK_TEXT_P: +// pContext = new SwXMLParaContext( GetSwImport(),nPrefix, rLocalName, +// xAttrList, bHeading ); +// break; +// case XML_TOK_TEXT_ORDERED_LIST: +// bOrdered = TRUE; +// case XML_TOK_TEXT_UNORDERED_LIST: +// pContext = new SwXMLListBlockContext( GetSwImport(),nPrefix, rLocalName, +// xAttrList, bOrdered ); +// break; + case XML_TOK_BODY_TRACKED_CHANGES : + { + pChangeTrackingImportHelper = GetScImport().GetChangeTrackingImportHelper(); + if (pChangeTrackingImportHelper) + pContext = new ScXMLTrackedChangesContext( GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper); + } + break; + case XML_TOK_BODY_CALCULATION_SETTINGS : + pContext = new ScXMLCalculationSettingsContext( GetScImport(), nPrefix, rLocalName, xAttrList ); + break; + case XML_TOK_BODY_CONTENT_VALIDATIONS : + pContext = new ScXMLContentValidationsContext( GetScImport(), nPrefix, rLocalName, xAttrList ); + break; + case XML_TOK_BODY_LABEL_RANGES: + pContext = new ScXMLLabelRangesContext( GetScImport(), nPrefix, rLocalName, xAttrList ); + break; + case XML_TOK_BODY_TABLE: + { + if (GetScImport().GetTables().GetCurrentSheet() >= MAXTAB) + { + GetScImport().SetRangeOverflowType(SCWARN_IMPORT_SHEET_OVERFLOW); + pContext = new ScXMLEmptyContext(GetScImport(), nPrefix, rLocalName); + } + else + { + pContext = new ScXMLTableContext( GetScImport(),nPrefix, rLocalName, + xAttrList ); + } + } + break; + case XML_TOK_BODY_NAMED_EXPRESSIONS: + pContext = new ScXMLNamedExpressionsContext ( GetScImport(), nPrefix, rLocalName, + xAttrList ); + break; + case XML_TOK_BODY_DATABASE_RANGES: + pContext = new ScXMLDatabaseRangesContext ( GetScImport(), nPrefix, rLocalName, + xAttrList ); + break; + case XML_TOK_BODY_DATABASE_RANGE: + pContext = new ScXMLDatabaseRangeContext ( GetScImport(), nPrefix, rLocalName, + xAttrList ); + break; + case XML_TOK_BODY_DATA_PILOT_TABLES: + pContext = new ScXMLDataPilotTablesContext ( GetScImport(), nPrefix, rLocalName, + xAttrList ); + break; + case XML_TOK_BODY_CONSOLIDATION: + pContext = new ScXMLConsolidationContext ( GetScImport(), nPrefix, rLocalName, + xAttrList ); + break; + case XML_TOK_BODY_DDE_LINKS: + pContext = new ScXMLDDELinksContext ( GetScImport(), nPrefix, rLocalName, + xAttrList ); + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + + return pContext; +} + +void ScXMLBodyContext::EndElement() +{ + GetScImport().LockSolarMutex(); + ScMyImpDetectiveOpArray* pDetOpArray = GetScImport().GetDetectiveOpArray(); + ScDocument* pDoc = GetScImport().GetDocument(); + ScMyImpDetectiveOp aDetOp; + + if (pDoc && GetScImport().GetModel().is()) + { + if (pDetOpArray) + { + pDetOpArray->Sort(); + while( pDetOpArray->GetFirstOp( aDetOp ) ) + { + ScDetOpData aOpData( aDetOp.aPosition, aDetOp.eOpType ); + pDoc->AddDetectiveOperation( aOpData ); + } + } + + if (pChangeTrackingImportHelper) + pChangeTrackingImportHelper->CreateChangeTrack(GetScImport().GetDocument()); + + if (bProtected) + { + uno::Sequence<sal_Int8> aPass; + if (sPassword.getLength()) + SvXMLUnitConverter::decodeBase64(aPass, sPassword); + pDoc->SetDocProtection(bProtected, aPass); + } + uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( GetScImport().GetModel(), uno::UNO_QUERY ); + if ( xSpreadDoc.is() ) + { + uno::Reference<sheet::XSpreadsheets> xSheets = xSpreadDoc->getSheets(); + uno::Reference <container::XIndexAccess> xIndex( xSheets, uno::UNO_QUERY ); + if ( xIndex.is() ) + { + uno::Any aSheet = xIndex->getByIndex(0); + uno::Reference< sheet::XSpreadsheet > xSheet; + if ( aSheet >>= xSheet ) + { + uno::Reference <beans::XPropertySet> xProperties(xSheet, uno::UNO_QUERY); + if (xProperties.is()) + { + XMLTableStylesContext *pStyles = (XMLTableStylesContext *)GetScImport().GetAutoStyles(); + ::rtl::OUString sTableStyleName(GetScImport().GetFirstTableStyle()); + if (sTableStyleName.getLength()) + { + XMLTableStyleContext* pStyle = (XMLTableStyleContext *)pStyles->FindStyleChildContext( + XML_STYLE_FAMILY_TABLE_TABLE, sTableStyleName, sal_True); + if (pStyle) + pStyle->FillPropertySet(xProperties); + } + } + } + } + } + } + GetScImport().UnlockSolarMutex(); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_xmlcelli.cxx b/binfilter/bf_sc/source/filter/xml/sc_xmlcelli.cxx new file mode 100644 index 000000000000..d2da7b6cf930 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_xmlcelli.cxx @@ -0,0 +1,1045 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "xmlcelli.hxx" +#include "xmltabi.hxx" +#include "xmlstyli.hxx" +#include "xmlannoi.hxx" +#include "document.hxx" +#include "cellsuno.hxx" +#include "XMLTableShapeImportHelper.hxx" +#include "XMLTextPContext.hxx" +#include "XMLStylesImportHelper.hxx" + +#include "unonames.hxx" +// core implementation +#include "arealink.hxx" +// core implementation +#include <bf_svx/linkmgr.hxx> +#include "convuno.hxx" +#include "XMLConverter.hxx" +#include "scerrors.hxx" + +#include <bf_xmloff/nmspmap.hxx> +#include <bf_xmloff/xmluconv.hxx> +#include <bf_xmloff/xmlnmspe.hxx> +#include <bf_svtools/zforlist.hxx> + + +#include <com/sun/star/sheet/XSheetCondition.hpp> +#include <com/sun/star/util/NumberFormat.hpp> +#include <com/sun/star/text/ControlCharacter.hpp> +#include <comphelper/extract.hxx> +namespace binfilter { + +#define SC_CURRENCYSYMBOL "CurrencySymbol" + +using namespace ::com::sun::star; +using namespace xmloff::token; + +//------------------------------------------------------------------ + +ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + const sal_Bool bTempIsCovered, + const sal_Int32 nTempRepeatedRows ) : + SvXMLImportContext( rImport, nPrfx, rLName ), + bIsMerged(sal_False), + bIsMatrix(sal_False), + bHasSubTable(sal_False), + bIsCovered(bTempIsCovered), + nRepeatedRows(nTempRepeatedRows), + bIsEmpty(sal_True), + bHasTextImport(sal_False), + bIsFirstTextImport(sal_False), + pDetectiveObjVec(NULL), + pCellRangeSource(NULL), + pMyAnnotation(NULL), + pOUTextValue(NULL), + pOUTextContent(NULL), + pOUFormula(NULL), + pContentValidationName(NULL), + nCellType(util::NumberFormat::TEXT), + nMergedCols(1), + nMergedRows(1), + nCellsRepeated(1), + fValue(0.0), + rXMLImport((ScXMLImport&)rImport), + bSolarMutexLocked(sal_False), + bFormulaTextResult(sal_False) +{ + rXMLImport.SetRemoveLastChar(sal_False); + rXMLImport.GetTables().AddColumn(bTempIsCovered); + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + ::rtl::OUString aLocalName; + ::rtl::OUString sValue; + ::rtl::OUString* pStyleName = NULL; + ::rtl::OUString* pCurrencySymbol = NULL; + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + sal_uInt16 nPrefix = rXMLImport.GetNamespaceMap().GetKeyByAttrName( + xAttrList->getNameByIndex( i ), &aLocalName ); + sValue = xAttrList->getValueByIndex( i ); + + if (nPrefix == XML_NAMESPACE_TABLE) + { + sal_uInt32 nLength(aLocalName.getLength()); + + switch (nLength) + { + case 5 : + { + if (IsXMLToken(aLocalName, XML_VALUE)) + { + if (sValue.getLength()) + { + rXMLImport.GetMM100UnitConverter().convertDouble(fValue, sValue); + bIsEmpty = sal_False; + } + } + } + break; + case 7 : + { + if (IsXMLToken(aLocalName, XML_FORMULA)) + { + if (sValue.getLength()) + { + DBG_ASSERT(!pOUFormula, "here should be only one formula"); + pOUFormula = new ::rtl::OUString(sValue); + } + } + } + break; + case 8 : + { + if (IsXMLToken(aLocalName, XML_CURRENCY)) + pCurrencySymbol = new ::rtl::OUString(sValue); + } + break; + case 10 : + { + if (IsXMLToken(aLocalName, XML_VALUE_TYPE)) + { + nCellType = GetCellType(sValue); + bIsEmpty = sal_False; + } + else if (IsXMLToken(aLocalName, XML_STYLE_NAME)) + pStyleName = new ::rtl::OUString(sValue); + else if (IsXMLToken(aLocalName, XML_DATE_VALUE)) + { + if (sValue.getLength() && rXMLImport.SetNullDateOnUnitConverter()) + { + rXMLImport.GetMM100UnitConverter().convertDateTime(fValue, sValue); + bIsEmpty = sal_False; + } + } + else if (IsXMLToken(aLocalName, XML_TIME_VALUE)) + { + if (sValue.getLength()) + { + rXMLImport.GetMM100UnitConverter().convertTime(fValue, sValue); + bIsEmpty = sal_False; + } + } + } + break; + case 12 : + { + if (IsXMLToken(aLocalName, XML_STRING_VALUE)) + { + if (sValue.getLength()) + { + DBG_ASSERT(!pOUTextValue, "here should be only one string value"); + pOUTextValue = new ::rtl::OUString(sValue); + bIsEmpty = sal_False; + } + } + } + break; + case 13 : + { + if (IsXMLToken(aLocalName, XML_BOOLEAN_VALUE)) + { + if (sValue.getLength()) + { + if ( IsXMLToken(sValue, XML_TRUE) ) + fValue = 1.0; + else if ( IsXMLToken(sValue, XML_FALSE) ) + fValue = 0.0; + else + rXMLImport.GetMM100UnitConverter().convertDouble(fValue, sValue); + bIsEmpty = sal_False; + } + } + } + break; + case 15 : + { + if (IsXMLToken(aLocalName, XML_CONTENT_VALIDATION_NAME)) //#109340# the string in this constant is different to the name; should be changed ASAP + { + DBG_ASSERT(!pContentValidationName, "here should be only one Validation Name"); + pContentValidationName = new ::rtl::OUString(sValue); + } + } + break; + case 19 : + { + if (IsXMLToken(aLocalName, XML_NUMBER_ROWS_SPANNED)) + { + bIsMerged = sal_True; + nMergedRows = sValue.toInt32(); + } + } + break; + case 22 : + { + if (IsXMLToken(aLocalName, XML_NUMBER_COLUMNS_SPANNED)) + { + bIsMerged = sal_True; + nMergedCols = sValue.toInt32(); + } + } + break; + case 23 : + { + if (IsXMLToken(aLocalName, XML_NUMBER_COLUMNS_REPEATED)) + nCellsRepeated = sValue.toInt32(); + } + break; + case 26 : + { + if (IsXMLToken(aLocalName, XML_NUMBER_MATRIX_ROWS_SPANNED)) + { + bIsMatrix = sal_True; + nMatrixRows = sValue.toInt32(); + } + } + break; + case 29 : + { + if (IsXMLToken(aLocalName, XML_NUMBER_MATRIX_COLUMNS_SPANNED)) + { + bIsMatrix = sal_True; + nMatrixCols = sValue.toInt32(); + } + } + break; + } + } + } + if (pOUFormula) + { + if (nCellType == util::NumberFormat::TEXT) + bFormulaTextResult = sal_True; + nCellType = util::NumberFormat::UNDEFINED; + } + rXMLImport.GetStylesImportHelper()->SetAttributes(pStyleName, pCurrencySymbol, nCellType); +} + +sal_Int16 ScXMLTableRowCellContext::GetCellType(const ::rtl::OUString& sOUValue) const +{ + if (IsXMLToken(sOUValue, XML_FLOAT)) + return util::NumberFormat::NUMBER; + else + if (IsXMLToken(sOUValue, XML_STRING)) + return util::NumberFormat::TEXT; + else + if (IsXMLToken(sOUValue, XML_TIME)) + return util::NumberFormat::TIME; + else + if (IsXMLToken(sOUValue, XML_DATE)) + return util::NumberFormat::DATETIME; + else + if (IsXMLToken(sOUValue, XML_PERCENTAGE)) + return util::NumberFormat::PERCENT; + else + if (IsXMLToken(sOUValue, XML_CURRENCY)) + return util::NumberFormat::CURRENCY; + else + if (IsXMLToken(sOUValue, XML_BOOLEAN)) + return util::NumberFormat::LOGICAL; + else + return util::NumberFormat::UNDEFINED; +} + +ScXMLTableRowCellContext::~ScXMLTableRowCellContext() +{ + if (pOUTextValue) + delete pOUTextValue; + if (pOUTextContent) + delete pOUTextContent; + if (pOUFormula) + delete pOUFormula; + if (pContentValidationName) + delete pContentValidationName; + if (pMyAnnotation) + delete pMyAnnotation; + if (pDetectiveObjVec) + delete pDetectiveObjVec; + if (pCellRangeSource) + delete pCellRangeSource; +} + +void ScXMLTableRowCellContext::LockSolarMutex() +{ + if (!bSolarMutexLocked) + { + GetScImport().LockSolarMutex(); + bSolarMutexLocked = sal_True; + } +} + +void ScXMLTableRowCellContext::UnlockSolarMutex() +{ + if (bSolarMutexLocked) + { + GetScImport().UnlockSolarMutex(); + bSolarMutexLocked = sal_False; + } +} + +void ScXMLTableRowCellContext::SetCursorOnTextImport(const ::rtl::OUString& rOUTempText) +{ + ::com::sun::star::table::CellAddress aCellPos = rXMLImport.GetTables().GetRealCellPos(); + if (CellExists(aCellPos)) + { + uno::Reference<table::XCellRange> xCellRange = rXMLImport.GetTables().GetCurrentXCellRange(); + if (xCellRange.is()) + { + xBaseCell = xCellRange->getCellByPosition(aCellPos.Column, aCellPos.Row); + if (xBaseCell.is()) + { + xLockable = uno::Reference<document::XActionLockable>(xBaseCell, uno::UNO_QUERY); + if (xLockable.is()) + xLockable->addActionLock(); + uno::Reference<text::XText> xText(xBaseCell, uno::UNO_QUERY); + if (xText.is()) + { + uno::Reference<text::XTextCursor> xTextCursor = xText->createTextCursor(); + if (xTextCursor.is()) + { + xTextCursor->setString(rOUTempText); + xTextCursor->gotoEnd(sal_False); + rXMLImport.GetTextImport()->SetCursor(xTextCursor); + } + } + } + } + } + else + DBG_ERRORFILE("this method should only be called for a existing cell"); +} + +SvXMLImportContext *ScXMLTableRowCellContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + const SvXMLTokenMap& rTokenMap = rXMLImport.GetTableRowCellElemTokenMap(); + sal_Bool bHeader(sal_False); + sal_Bool bTextP(sal_False); + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + case XML_TOK_TABLE_ROW_CELL_P: + { + bIsEmpty = sal_False; + bTextP = sal_True; + ::com::sun::star::table::CellAddress aCellPos = rXMLImport.GetTables().GetRealCellPos(); + if (((nCellType == util::NumberFormat::TEXT) || bFormulaTextResult) && + !rXMLImport.GetTables().IsPartOfMatrix(aCellPos.Column, aCellPos.Row)) + { + if (!bHasTextImport) + { + bIsFirstTextImport = sal_True; + bHasTextImport = sal_True; + pContext = new ScXMLTextPContext(rXMLImport, nPrefix, rLName, xAttrList, this); + } + else + { + ::com::sun::star::table::CellAddress aCellPos = rXMLImport.GetTables().GetRealCellPos(); + if (CellExists(aCellPos)) + { + if (bIsFirstTextImport && !rXMLImport.GetRemoveLastChar()) + { + if (pOUTextContent) + { + SetCursorOnTextImport(*pOUTextContent); + delete pOUTextContent; + pOUTextContent = NULL; + } + else + SetCursorOnTextImport(::rtl::OUString()); + rXMLImport.SetRemoveLastChar(sal_True); + uno::Reference<text::XTextCursor> xTextCursor = rXMLImport.GetTextImport()->GetCursor(); + uno::Reference < text::XText > xText (xTextCursor->getText()); + uno::Reference < text::XTextRange > xTextRange (xTextCursor, uno::UNO_QUERY); + if (xText.is() && xTextRange.is()) + xText->insertControlCharacter(xTextRange, text::ControlCharacter::PARAGRAPH_BREAK, sal_False); + } + pContext = rXMLImport.GetTextImport()->CreateTextChildContext( + rXMLImport, nPrefix, rLName, xAttrList); + bIsFirstTextImport = sal_False; + } + } + } + } + break; + case XML_TOK_TABLE_ROW_CELL_SUBTABLE: + { + bHasSubTable = sal_True; + pContext = new ScXMLTableContext( rXMLImport , nPrefix, + rLName, xAttrList, + sal_True, nMergedCols); + nMergedCols = 1; + bIsMerged = sal_False; + } + break; + case XML_TOK_TABLE_ROW_CELL_ANNOTATION: + { + bIsEmpty = sal_False; + pContext = new ScXMLAnnotationContext( rXMLImport, nPrefix, rLName, + xAttrList, this); + } + break; + case XML_TOK_TABLE_ROW_CELL_DETECTIVE: + { + bIsEmpty = sal_False; + if (!pDetectiveObjVec) + pDetectiveObjVec = new ScMyImpDetectiveObjVec(); + pContext = new ScXMLDetectiveContext( + rXMLImport, nPrefix, rLName, pDetectiveObjVec ); + } + break; + case XML_TOK_TABLE_ROW_CELL_CELL_RANGE_SOURCE: + { + bIsEmpty = sal_False; + if (!pCellRangeSource) + pCellRangeSource = new ScMyImpCellRangeSource(); + pContext = new ScXMLCellRangeSourceContext( + rXMLImport, nPrefix, rLName, xAttrList, pCellRangeSource ); + } + break; + } + + if (!pContext && !bTextP) + { + ::com::sun::star::table::CellAddress aCellPos = rXMLImport.GetTables().GetRealCellPos(); + uno::Reference<drawing::XShapes> xShapes (rXMLImport.GetTables().GetCurrentXShapes()); + if (xShapes.is()) + { + if (aCellPos.Column > MAXCOL) + aCellPos.Column = MAXCOL; + if (aCellPos.Row > MAXROW) + aCellPos.Row = MAXROW; + XMLTableShapeImportHelper* pTableShapeImport = (XMLTableShapeImportHelper*)rXMLImport.GetShapeImport().get(); + pTableShapeImport->SetOnTable(sal_False); + pTableShapeImport->SetCell(aCellPos); + pContext = rXMLImport.GetShapeImport()->CreateGroupChildContext( + rXMLImport, nPrefix, rLName, xAttrList, xShapes); + if (pContext) + { + bIsEmpty = sal_False; + rXMLImport.GetProgressBarHelper()->Increment(); + } + } + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +sal_Bool ScXMLTableRowCellContext::IsMerged (const uno::Reference <table::XCellRange>& xCellRange, const sal_Int32 nCol, const sal_Int32 nRow, + table::CellRangeAddress& aCellAddress) const +{ + table::CellAddress aCell; // don't need to set the sheet, because every sheet can contain the same count of cells. + aCell.Column = nCol; + aCell.Row = nRow; + if (CellExists(aCell)) + { + uno::Reference <table::XCellRange> xMergeCellRange = xCellRange->getCellRangeByPosition(nCol,nRow,nCol,nRow); + uno::Reference <util::XMergeable> xMergeable (xMergeCellRange, uno::UNO_QUERY); + if (xMergeable.is()) + { + uno::Reference<sheet::XSheetCellRange> xMergeSheetCellRange (xMergeCellRange, 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 sal_False; + else + return sal_True; + } + } + } + } + return sal_False; +} + +void ScXMLTableRowCellContext::DoMerge(const ::com::sun::star::table::CellAddress& aCellPos, + const sal_Int32 nCols, const sal_Int32 nRows) +{ + if (CellExists(aCellPos)) + { + uno::Reference<table::XCellRange> xCellRange = rXMLImport.GetTables().GetCurrentXCellRange(); + if ( xCellRange.is() ) + { + table::CellRangeAddress aCellAddress; + if (IsMerged(xCellRange, aCellPos.Column, aCellPos.Row, aCellAddress)) + { + //unmerge + uno::Reference <table::XCellRange> xMergeCellRange = + xCellRange->getCellRangeByPosition(aCellAddress.StartColumn, aCellAddress.StartRow, + aCellAddress.EndColumn, aCellAddress.EndRow); + uno::Reference <util::XMergeable> xMergeable (xMergeCellRange, uno::UNO_QUERY); + if (xMergeable.is()) + xMergeable->merge(sal_False); + } + + //merge + uno::Reference <table::XCellRange> xMergeCellRange = + xCellRange->getCellRangeByPosition(aCellAddress.StartColumn, aCellAddress.StartRow, + aCellAddress.EndColumn + nCols, aCellAddress.EndRow + nRows); + uno::Reference <util::XMergeable> xMergeable (xMergeCellRange, uno::UNO_QUERY); + if (xMergeable.is()) + xMergeable->merge(sal_True); + } + } +} + +void ScXMLTableRowCellContext::SetContentValidation(::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& xPropSet) +{ + if (pContentValidationName) + { + ScMyImportValidation aValidation; + if (rXMLImport.GetValidation(*pContentValidationName, aValidation)) + { + uno::Any aAny = xPropSet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_VALIDAT))); + uno::Reference<beans::XPropertySet> xPropertySet; + if (aAny >>= xPropertySet) + { + if (aValidation.sErrorMessage.getLength()) + { + aAny <<= aValidation.sErrorMessage; + xPropertySet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ERRMESS)), aAny); + } + if (aValidation.sErrorTitle.getLength()) + { + aAny <<= aValidation.sErrorTitle; + xPropertySet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ERRTITLE)), aAny); + } + if (aValidation.sImputMessage.getLength()) + { + aAny <<= aValidation.sImputMessage; + xPropertySet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_INPMESS)), aAny); + } + if (aValidation.sImputTitle.getLength()) + { + aAny <<= aValidation.sImputTitle; + xPropertySet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_INPTITLE)), aAny); + } + aAny = ::cppu::bool2any(aValidation.bShowErrorMessage); + xPropertySet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_SHOWERR)), aAny); + aAny = ::cppu::bool2any(aValidation.bShowImputMessage); + xPropertySet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_SHOWINP)), aAny); + aAny <<= aValidation.aValidationType; + xPropertySet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_TYPE)), aAny); + aAny = ::cppu::bool2any(aValidation.bIgnoreBlanks); + xPropertySet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_IGNOREBL)), aAny); + aAny <<= aValidation.aAlertStyle; + xPropertySet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ERRALSTY)), aAny); + uno::Reference<sheet::XSheetCondition> xCondition(xPropertySet, uno::UNO_QUERY); + if (xCondition.is()) + { + xCondition->setFormula1(aValidation.sFormula1); + xCondition->setFormula2(aValidation.sFormula2); + xCondition->setOperator(aValidation.aOperator); + xCondition->setSourcePosition(aValidation.aBaseCellAddress); + } + } + aAny <<= xPropertySet; + xPropSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_VALIDAT)), aAny); + } + } +} + +void ScXMLTableRowCellContext::SetCellProperties(const uno::Reference<table::XCellRange>& xCellRange, + const table::CellAddress& aCellAddress) +{ + if (CellExists(aCellAddress) && pContentValidationName && pContentValidationName->getLength()) + { + sal_Int32 nBottom = aCellAddress.Row + nRepeatedRows - 1; + sal_Int32 nRight = aCellAddress.Column + nCellsRepeated - 1; + if (nBottom > MAXROW) + nBottom = MAXROW; + if (nRight > MAXCOL) + nRight = MAXCOL; + uno::Reference <table::XCellRange> xPropCellRange = xCellRange->getCellRangeByPosition(aCellAddress.Column, aCellAddress.Row, + nRight, nBottom); + if (xPropCellRange.is()) + { + uno::Reference <beans::XPropertySet> xProperties (xPropCellRange, uno::UNO_QUERY); + if (xProperties.is()) + SetContentValidation(xProperties); + } + } +} + +void ScXMLTableRowCellContext::SetCellProperties(const uno::Reference<table::XCell>& xCell) +{ + if (pContentValidationName && pContentValidationName->getLength()) + { + uno::Reference <beans::XPropertySet> xProperties (xCell, uno::UNO_QUERY); + if (xProperties.is()) + SetContentValidation(xProperties); + } +} + +void ScXMLTableRowCellContext::SetAnnotation(const uno::Reference<table::XCell>& xCell) +{ + /*uno::Reference<sheet::XSheetAnnotationAnchor> xSheetAnnotationAnchor(xCell, uno::UNO_QUERY); + if (xSheetAnnotationAnchor.is()) + { + uno::Reference <sheet::XSheetAnnotation> xSheetAnnotation = xSheetAnnotationAnchor->getAnnotation(); + uno::Reference<text::XSimpleText> xSimpleText(xSheetAnnotation, uno::UNO_QUERY); + if (xSheetAnnotation.is() && xSimpleText.is()) + { + xSimpleText->setString(aMyAnnotation.sText); + //xSheetAnnotation->setAuthor(aMyAnnotation.sAuthor); + //xSheetAnnotation->setDate(); + xSheetAnnotation->setIsVisible(aMyAnnotation.bDisplay); + } + }*/ + if( pMyAnnotation ) + { + uno::Reference<sheet::XCellAddressable> xCellAddressable(xCell, uno::UNO_QUERY); + if (xCellAddressable.is()) + { + table::CellAddress aCellAddress = xCellAddressable->getCellAddress(); + double fDate; + rXMLImport.GetMM100UnitConverter().convertDateTime(fDate, pMyAnnotation->sCreateDate); + ScDocument* pDoc = rXMLImport.GetDocument(); + if (pDoc) + { + LockSolarMutex(); + SvNumberFormatter* pNumForm = pDoc->GetFormatTable(); + sal_uInt32 nfIndex = pNumForm->GetFormatIndex(NF_DATE_SYS_DDMMYYYY, LANGUAGE_SYSTEM); + String sDate; + Color* pColor = NULL; + Color** ppColor = &pColor; + pNumForm->GetOutputString(fDate, nfIndex, sDate, ppColor); + ScPostIt aNote(String(pMyAnnotation->sText), sDate, String(pMyAnnotation->sAuthor)); + aNote.SetShown(pMyAnnotation->bDisplay); + pDoc->SetNote(static_cast<USHORT>(aCellAddress.Column), static_cast<USHORT>(aCellAddress.Row), aCellAddress.Sheet, aNote); + if (pMyAnnotation->bDisplay) + { + uno::Reference < drawing::XShapes > xShapes (rXMLImport.GetTables().GetCurrentXShapes()); // make draw page + ScDetectiveFunc aDetFunc(pDoc, aCellAddress.Sheet); + aDetFunc.ShowComment(static_cast<USHORT>(aCellAddress.Column), static_cast<USHORT>(aCellAddress.Row), sal_False); + uno::Reference<container::XIndexAccess> xShapesIndex (xShapes, uno::UNO_QUERY); + if (xShapesIndex.is()) + { + sal_Int32 nShapes = xShapesIndex->getCount(); + uno::Reference < drawing::XShape > xShape; + rXMLImport.GetShapeImport()->shapeWithZIndexAdded(xShape, nShapes); + } + } + } + } + } +} + +// core implementation +void ScXMLTableRowCellContext::SetDetectiveObj( const table::CellAddress& rPosition ) +{ + if( CellExists(rPosition) && pDetectiveObjVec && pDetectiveObjVec->size() ) + { + LockSolarMutex(); + ScDetectiveFunc aDetFunc( rXMLImport.GetDocument(), rPosition.Sheet ); + uno::Reference < drawing::XShapes > xShapes (rXMLImport.GetTables().GetCurrentXShapes()); // make draw page + for( ScMyImpDetectiveObjVec::iterator aItr = pDetectiveObjVec->begin(); aItr != pDetectiveObjVec->end(); aItr++ ) + { + ScAddress aScAddress; + ScUnoConversion::FillScAddress( aScAddress, rPosition ); + aDetFunc.InsertObject( aItr->eObjType, aScAddress, aItr->aSourceRange, aItr->bHasError ); + uno::Reference<container::XIndexAccess> xShapesIndex (xShapes, uno::UNO_QUERY); + if (xShapesIndex.is()) + { + sal_Int32 nShapes = xShapesIndex->getCount(); + uno::Reference < drawing::XShape > xShape; + rXMLImport.GetShapeImport()->shapeWithZIndexAdded(xShape, nShapes); + } + } + } +} + +// core implementation +void ScXMLTableRowCellContext::SetCellRangeSource( const table::CellAddress& rPosition ) +{ + if( CellExists(rPosition) && pCellRangeSource && pCellRangeSource->sSourceStr.getLength() && + pCellRangeSource->sFilterName.getLength() && pCellRangeSource->sURL.getLength() ) + { + ScDocument* pDoc = rXMLImport.GetDocument(); + if (pDoc) + { + LockSolarMutex(); + ScRange aDestRange( static_cast<USHORT>(rPosition.Column), static_cast<USHORT>(rPosition.Row), rPosition.Sheet, + rPosition.Column + pCellRangeSource->nColumns - 1, + rPosition.Row + pCellRangeSource->nRows - 1, rPosition.Sheet ); + String sFilterName( pCellRangeSource->sFilterName ); + String sSourceStr( pCellRangeSource->sSourceStr ); + ScAreaLink* pLink = new ScAreaLink( pDoc->GetDocumentShell(), pCellRangeSource->sURL, + sFilterName, pCellRangeSource->sFilterOptions, sSourceStr, aDestRange, pCellRangeSource->nRefresh ); + SvxLinkManager* pLinkManager = pDoc->GetLinkManager(); + pLinkManager->InsertFileLink( *pLink, OBJECT_CLIENT_FILE, pCellRangeSource->sURL, &sFilterName, &sSourceStr ); + } + } +} + +void ScXMLTableRowCellContext::EndElement() +{ + if (!bHasSubTable) + { + if (bHasTextImport && rXMLImport.GetRemoveLastChar()) + { + if (GetImport().GetTextImport()->GetCursor().is()) + { + //GetImport().GetTextImport()->GetCursor()->gotoEnd(sal_False); + if( GetImport().GetTextImport()->GetCursor()->goLeft( 1, sal_True ) ) + { + GetImport().GetTextImport()->GetText()->insertString( + GetImport().GetTextImport()->GetCursorAsRange(), ::rtl::OUString(), + sal_True ); + } + rXMLImport.GetTextImport()->ResetCursor(); + } + } + table::CellAddress aCellPos = rXMLImport.GetTables().GetRealCellPos(); + if (aCellPos.Column > 0 && nRepeatedRows > 1) + aCellPos.Row -= (nRepeatedRows - 1); + uno::Reference<table::XCellRange> xCellRange = rXMLImport.GetTables().GetCurrentXCellRange(); + if (xCellRange.is()) + { + if (bIsMerged) + DoMerge(aCellPos, nMergedCols - 1, nMergedRows - 1); + if ( !pOUFormula ) + { + ::rtl::OUString* pOUText = NULL; + if(nCellType == util::NumberFormat::TEXT) + { + if (xLockable.is()) + xLockable->removeActionLock(); + if (CellExists(aCellPos) && ((nCellsRepeated > 1) || (nRepeatedRows > 1))) + { + if (!xBaseCell.is()) + { + try + { + xBaseCell = xCellRange->getCellByPosition(aCellPos.Column, aCellPos.Row); + } + catch (lang::IndexOutOfBoundsException&) + { + DBG_ERRORFILE("It seems here are to many columns or rows"); + } + } + uno::Reference <text::XText> xTempText (xBaseCell, uno::UNO_QUERY); + if (xTempText.is()) + { + ::rtl::OUString sBla(xTempText->getString()); + pOUText = new ::rtl::OUString(sBla); + } + } + if (!pOUTextContent && !pOUText && !pOUTextValue) + bIsEmpty = sal_True; + else if ( (pOUTextContent && !pOUTextContent->getLength()) || !pOUTextContent ) + if ( (pOUText && !pOUText->getLength()) || !pOUText ) + if ( (pOUTextValue && !pOUTextValue->getLength()) || !pOUTextValue ) + bIsEmpty = sal_True; + } + sal_Bool bWasEmpty = bIsEmpty; + uno::Reference <table::XCell> xCell; + table::CellAddress aCurrentPos( aCellPos ); + if ((pContentValidationName && pContentValidationName->getLength()) || + pMyAnnotation || pDetectiveObjVec || pCellRangeSource) + bIsEmpty = sal_False; + for (sal_Int32 i = 0; i < nCellsRepeated; i++) + { + aCurrentPos.Column = aCellPos.Column + i; + if (i > 0) + rXMLImport.GetTables().AddColumn(sal_False); + if (!bIsEmpty) + { + for (sal_Int32 j = 0; j < nRepeatedRows; j++) + { + aCurrentPos.Row = aCellPos.Row + j; + if ((aCurrentPos.Column == 0) && (j > 0)) + { + rXMLImport.GetTables().AddRow(); + rXMLImport.GetTables().AddColumn(sal_False); + } + if (CellExists(aCurrentPos)) + { + if (xBaseCell.is() && (aCurrentPos == aCellPos)) + xCell = xBaseCell; + else + { + try + { + xCell = xCellRange->getCellByPosition(aCurrentPos.Column, aCurrentPos.Row); + } + catch (lang::IndexOutOfBoundsException&) + { + DBG_ERRORFILE("It seems here are to many columns or rows"); + } + } + if ((!(bIsCovered) || (xCell->getType() == table::CellContentType_EMPTY))) + { + switch (nCellType) + { + case util::NumberFormat::TEXT: + { + sal_Bool bDoIncrement = sal_True; + if (rXMLImport.GetTables().IsPartOfMatrix(aCurrentPos.Column, aCurrentPos.Row)) + { + LockSolarMutex(); + ScCellObj* pCellObj = (ScCellObj*)ScCellRangesBase::getImplementation(xCell); + if (pCellObj) + { + if(pOUTextValue && pOUTextValue->getLength()) + pCellObj->SetFormulaResultString(*pOUTextValue); + else if (pOUTextContent && pOUTextContent->getLength()) + pCellObj->SetFormulaResultString(*pOUTextContent); + else if ( i > 0 && pOUText && pOUText->getLength() ) + { + pCellObj->SetFormulaResultString(*pOUText); + } + else + bDoIncrement = sal_False; + } + else + bDoIncrement = sal_False; + } + else + { + uno::Reference <text::XText> xText (xCell, uno::UNO_QUERY); + if (xText.is()) + { + if(pOUTextValue && pOUTextValue->getLength()) + xText->setString(*pOUTextValue); + else if (pOUTextContent && pOUTextContent->getLength()) + xText->setString(*pOUTextContent); + else if ( i > 0 && pOUText && pOUText->getLength() ) + { + xText->setString(*pOUText); + } + else + bDoIncrement = sal_False; + } + } + if (bDoIncrement || bHasTextImport) + rXMLImport.GetProgressBarHelper()->Increment(); + } + break; + case util::NumberFormat::NUMBER: + case util::NumberFormat::PERCENT: + case util::NumberFormat::CURRENCY: + case util::NumberFormat::TIME: + case util::NumberFormat::DATETIME: + case util::NumberFormat::LOGICAL: + { + if (rXMLImport.GetTables().IsPartOfMatrix(aCurrentPos.Column, aCurrentPos.Row)) + { + LockSolarMutex(); + ScCellObj* pCellObj = (ScCellObj*)ScCellRangesBase::getImplementation(xCell); + if (pCellObj) + pCellObj->SetFormulaResultDouble(fValue); + } + else + { + xCell->setValue(fValue); + } + rXMLImport.GetProgressBarHelper()->Increment(); + } + break; + default: + { + DBG_ERROR("no cell type given"); + } + break; + } + } + SetAnnotation(xCell); + SetDetectiveObj( aCurrentPos ); + SetCellRangeSource( aCurrentPos ); + } + else + { + if (!bWasEmpty || (pMyAnnotation)) + { + if (aCurrentPos.Row > MAXROW) + rXMLImport.SetRangeOverflowType(SCWARN_IMPORT_ROW_OVERFLOW); + else + rXMLImport.SetRangeOverflowType(SCWARN_IMPORT_COLUMN_OVERFLOW); + } + } + } + } + else + { + if (bHasTextImport) + rXMLImport.GetProgressBarHelper()->Increment(); + if ((i == 0) && (aCellPos.Column == 0)) + for (sal_Int32 j = 1; j < nRepeatedRows; j++) + { + rXMLImport.GetTables().AddRow(); + rXMLImport.GetTables().AddColumn(sal_False); + } + } + } + if (nCellsRepeated > 1 || nRepeatedRows > 1) + { + SetCellProperties(xCellRange, aCellPos); // set now only the validation for the complete range with the given cell as start cell + //SetType(xCellRange, aCellPos); + USHORT nStartCol(aCellPos.Column < MAXCOL ? aCellPos.Column : MAXCOL); + USHORT nStartRow(aCellPos.Row < MAXROW ? aCellPos.Row : MAXROW); + USHORT nEndCol(aCellPos.Column + nCellsRepeated - 1 < MAXCOL ? aCellPos.Column + nCellsRepeated - 1 : MAXCOL); + USHORT nEndRow(aCellPos.Row + nRepeatedRows - 1 < MAXROW ? aCellPos.Row + nRepeatedRows - 1 : MAXROW); + ScRange aScRange( nStartCol, nStartRow, aCellPos.Sheet, + nEndCol, nEndRow, aCellPos.Sheet ); + rXMLImport.GetStylesImportHelper()->AddRange(aScRange); + } + else if (CellExists(aCellPos)) + { + rXMLImport.GetStylesImportHelper()->AddCell(aCellPos); + SetCellProperties(xCell); // set now only the validation + //SetType(xTempCell); + } + if (pOUText) + delete pOUText; + } + else + { + if (CellExists(aCellPos)) + { + uno::Reference <table::XCell> xCell; + try + { + xCell = xCellRange->getCellByPosition(aCellPos.Column , aCellPos.Row); + } + catch (lang::IndexOutOfBoundsException&) + { + DBG_ERRORFILE("It seems here are to many columns or rows"); + } + if (xCell.is()) + { + SetCellProperties(xCell); // set now only the validation + DBG_ASSERT(((nCellsRepeated == 1) && (nRepeatedRows == 1)), "repeated cells with formula not possible now"); + rXMLImport.GetStylesImportHelper()->AddCell(aCellPos); + ScXMLConverter::ParseFormula(*pOUFormula); + if (!bIsMatrix) + { + xCell->setFormula(*pOUFormula); + if (bFormulaTextResult && pOUTextValue && pOUTextValue->getLength()) + { + LockSolarMutex(); + ScCellObj* pCellObj = (ScCellObj*)ScCellRangesBase::getImplementation(xCell); + if (pCellObj) + pCellObj->SetFormulaResultString(*pOUTextValue); + } + else if (fValue != 0.0) + { + LockSolarMutex(); + ScCellObj* pCellObj = (ScCellObj*)ScCellRangesBase::getImplementation(xCell); + if (pCellObj) + pCellObj->SetFormulaResultDouble(fValue); + } + } + else + { + if (nMatrixCols > 0 && nMatrixRows > 0) + { + rXMLImport.GetTables().AddMatrixRange(aCellPos.Column, aCellPos.Row, + aCellPos.Column + nMatrixCols - 1, aCellPos.Row + nMatrixRows - 1); + uno::Reference <table::XCellRange> xMatrixCellRange = + xCellRange->getCellRangeByPosition(aCellPos.Column, aCellPos.Row, + aCellPos.Column + nMatrixCols - 1, aCellPos.Row + nMatrixRows - 1); + if (xMatrixCellRange.is()) + { + uno::Reference <sheet::XArrayFormulaRange> xArrayFormulaRange(xMatrixCellRange, uno::UNO_QUERY); + if (xArrayFormulaRange.is()) + xArrayFormulaRange->setArrayFormula(*pOUFormula); + } + } + } + SetAnnotation(xCell); + SetDetectiveObj( aCellPos ); + SetCellRangeSource( aCellPos ); + rXMLImport.GetProgressBarHelper()->Increment(); + } + } + else + { + if (aCellPos.Row > MAXROW) + rXMLImport.SetRangeOverflowType(SCWARN_IMPORT_ROW_OVERFLOW); + else + rXMLImport.SetRangeOverflowType(SCWARN_IMPORT_COLUMN_OVERFLOW); + } + + } + } + UnlockSolarMutex(); + } + bIsMerged = sal_False; + bHasSubTable = sal_False; + nMergedCols = 1; + nMergedRows = 1; + nCellsRepeated = 1; +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_xmlcoli.cxx b/binfilter/bf_sc/source/filter/xml/sc_xmlcoli.cxx new file mode 100644 index 000000000000..946f35dafee5 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_xmlcoli.cxx @@ -0,0 +1,333 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "xmlcoli.hxx" +#include "xmlstyli.hxx" +#include "document.hxx" +#include "olinetab.hxx" + +#include "unonames.hxx" + +#include <bf_xmloff/nmspmap.hxx> +#include <bf_xmloff/xmlnmspe.hxx> + +#include <com/sun/star/table/XColumnRowRange.hpp> +#include <com/sun/star/sheet/XPrintAreas.hpp> +namespace binfilter { + +using namespace ::com::sun::star; +using namespace xmloff::token; + +//------------------------------------------------------------------ + +ScXMLTableColContext::ScXMLTableColContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) : + SvXMLImportContext( rImport, nPrfx, rLName ), + sVisibility(GetXMLToken(XML_VISIBLE)) +{ + nColCount = 1; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetTableColAttrTokenMap(); + + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_TABLE_COL_ATTR_REPEATED: + { + nColCount = sValue.toInt32(); + } + break; + case XML_TOK_TABLE_COL_ATTR_STYLE_NAME: + { + sStyleName = sValue; + } + break; + case XML_TOK_TABLE_COL_ATTR_VISIBILITY: + { + sVisibility = sValue; + } + break; + case XML_TOK_TABLE_COL_ATTR_DEFAULT_CELL_STYLE_NAME: + { + sCellStyleName = sValue; + } + break; + } + } +} + +ScXMLTableColContext::~ScXMLTableColContext() +{ +} + +SvXMLImportContext *ScXMLTableColContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; +/* + const SvXMLTokenMap& rTokenMap = GetScImport().GetTableRowElemTokenMap(); + sal_Bool bHeader = sal_False; + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + case XML_TOK_TABLE_ROW_CELL: +// if( IsInsertCellPossible() ) + pContext = new ScXMLTableRowCellContext( GetScImport(), nPrefix, + rLName, xAttrList//, + //this + ); + break; + case XML_TOK_TABLE_ROW_COVERED_CELL: +// if( IsInsertCellPossible() ) + pContext = new ScXMLTableRowCellContext( GetScImport(), nPrefix, + rLName, xAttrList//, + //this + ); + break; + }*/ + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLTableColContext::EndElement() +{ + ScXMLImport& rXMLImport = GetScImport(); + //sal_Int16 nSheet = rXMLImport.GetTables().GetCurrentSheet(); + sal_Int32 nCurrentColumn = rXMLImport.GetTables().GetCurrentColumn(); + uno::Reference<sheet::XSpreadsheet> xSheet = rXMLImport.GetTables().GetCurrentXSheet(); + if(xSheet.is()) + { + sal_Int32 nLastColumn(nCurrentColumn + nColCount - 1); + if (nLastColumn > MAXCOL) + nLastColumn = MAXCOL; + if (nCurrentColumn > MAXCOL) + nCurrentColumn = MAXCOL; + uno::Reference <table::XCellRange> xCellRange = xSheet->getCellRangeByPosition(nCurrentColumn, 0, nLastColumn, 0); + if (xCellRange.is()) + { + uno::Reference<table::XColumnRowRange> xColumnRowRange (xCellRange, uno::UNO_QUERY); + if (xColumnRowRange.is()) + { + uno::Reference<table::XTableColumns> xTableColumns = xColumnRowRange->getColumns(); + if (xTableColumns.is()) + { + uno::Reference <beans::XPropertySet> xColumnProperties(xTableColumns, uno::UNO_QUERY); + if (xColumnProperties.is()) + { + if (sStyleName.getLength()) + { + XMLTableStylesContext *pStyles = (XMLTableStylesContext *)rXMLImport.GetAutoStyles(); + XMLTableStyleContext* pStyle = (XMLTableStyleContext *)pStyles->FindStyleChildContext( + XML_STYLE_FAMILY_TABLE_COLUMN, sStyleName, sal_True); + if (pStyle) + pStyle->FillPropertySet(xColumnProperties); + } + ::rtl::OUString sVisible(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_CELLVIS)); + uno::Any aAny = xColumnProperties->getPropertyValue(sVisible); + if (IsXMLToken(sVisibility, XML_VISIBLE)) + { + sal_Bool bValue = sal_True; + aAny <<= bValue; + } + else + { + sal_Bool bValue = sal_False; + aAny <<= bValue; + } + xColumnProperties->setPropertyValue(sVisible, aAny); + } + } + } + } + } + GetScImport().GetTables().AddColCount(nColCount); + GetScImport().GetTables().AddColStyle(nColCount, sCellStyleName); +} + +ScXMLTableColsContext::ScXMLTableColsContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + const sal_Bool bTempHeader, const sal_Bool bTempGroup) : + SvXMLImportContext( rImport, nPrfx, rLName ), + nHeaderStartCol(0), + nHeaderEndCol(0), + nGroupStartCol(0), + nGroupEndCol(0), + bHeader(bTempHeader), + bGroup(bTempGroup), + bGroupDisplay(sal_True) +{ + // don't have any attributes + if (bHeader) + nHeaderStartCol = rImport.GetTables().GetCurrentColumn(); + else if (bGroup) + { + nGroupStartCol = rImport.GetTables().GetCurrentColumn(); + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + if (nPrfx == XML_NAMESPACE_TABLE && IsXMLToken(aLocalName, XML_DISPLAY)) + { + if (IsXMLToken(sValue, XML_FALSE)) + bGroupDisplay = sal_False; + } + } + } +} + +ScXMLTableColsContext::~ScXMLTableColsContext() +{ +} + +SvXMLImportContext *ScXMLTableColsContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + const SvXMLTokenMap& rTokenMap = GetScImport().GetTableColsElemTokenMap(); + sal_Bool bHeader = sal_False; + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + case XML_TOK_TABLE_COLS_COL_GROUP: + pContext = new ScXMLTableColsContext( GetScImport(), nPrefix, + rLName, xAttrList, + sal_False, sal_True ); + break; + case XML_TOK_TABLE_COLS_HEADER_COLS: + pContext = new ScXMLTableColsContext( GetScImport(), nPrefix, + rLName, xAttrList, + sal_True, sal_False ); + break; + case XML_TOK_TABLE_COLS_COLS: + pContext = new ScXMLTableColsContext( GetScImport(), nPrefix, + rLName, xAttrList, + sal_False, sal_False ); + break; + case XML_TOK_TABLE_COLS_COL: + pContext = new ScXMLTableColContext( GetScImport(), nPrefix, + rLName, xAttrList//, + //this + ); + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLTableColsContext::EndElement() +{ + ScXMLImport& rXMLImport = GetScImport(); + if (bHeader) + { + nHeaderEndCol = rXMLImport.GetTables().GetCurrentColumn(); + nHeaderEndCol--; + if (nHeaderStartCol <= nHeaderEndCol) + { + uno::Reference<sheet::XSpreadsheet> xSheet = rXMLImport.GetTables().GetCurrentXSheet(); + if(xSheet.is()) + { + uno::Reference <sheet::XPrintAreas> xPrintAreas (xSheet, uno::UNO_QUERY); + if (xPrintAreas.is()) + { + if (!xPrintAreas->getPrintTitleColumns()) + { + xPrintAreas->setPrintTitleColumns(sal_True); + table::CellRangeAddress aColumnHeaderRange; + aColumnHeaderRange.StartColumn = nHeaderStartCol; + aColumnHeaderRange.EndColumn = nHeaderEndCol; + xPrintAreas->setTitleColumns(aColumnHeaderRange); + } + else + { + table::CellRangeAddress aColumnHeaderRange = xPrintAreas->getTitleColumns(); + aColumnHeaderRange.EndColumn = nHeaderEndCol; + xPrintAreas->setTitleColumns(aColumnHeaderRange); + } + } + } + } + } + else if (bGroup) + { + sal_Int16 nSheet = rXMLImport.GetTables().GetCurrentSheet(); + nGroupEndCol = rXMLImport.GetTables().GetCurrentColumn(); + nGroupEndCol--; + if (nGroupStartCol <= nGroupEndCol) + { + ScDocument* pDoc = GetScImport().GetDocument(); + if (pDoc) + { + rXMLImport.LockSolarMutex(); + ScOutlineTable* pOutlineTable = pDoc->GetOutlineTable(nSheet, sal_True); + ScOutlineArray* pColArray = pOutlineTable ? pOutlineTable->GetColArray() : NULL; + if (pColArray) + { + sal_Bool bResized; + pColArray->Insert(static_cast<USHORT>(nGroupStartCol), static_cast<USHORT>(nGroupEndCol), bResized, !bGroupDisplay, sal_True); + } + rXMLImport.UnlockSolarMutex(); + } + } + } +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_xmlconti.cxx b/binfilter/bf_sc/source/filter/xml/sc_xmlconti.cxx new file mode 100644 index 000000000000..e182b0f84765 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_xmlconti.cxx @@ -0,0 +1,107 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "xmlconti.hxx" +#include "xmlimprt.hxx" + +#include <bf_xmloff/nmspmap.hxx> +#include <bf_xmloff/xmlnmspe.hxx> +namespace binfilter { + +using namespace xmloff::token; + +//------------------------------------------------------------------ + +ScXMLContentContext::ScXMLContentContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ::rtl::OUStringBuffer& sTempValue) : + SvXMLImportContext( rImport, nPrfx, rLName ), + sOUText(), + sValue(sTempValue) +{ +} + +ScXMLContentContext::~ScXMLContentContext() +{ +} + +SvXMLImportContext *ScXMLContentContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if ((nPrefix == XML_NAMESPACE_TEXT) && IsXMLToken(rLName, XML_S)) + { + sal_Int32 nRepeat(0); + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrfx = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + if ((nPrfx == XML_NAMESPACE_TEXT) && IsXMLToken(aLocalName, XML_C)) + nRepeat = sValue.toInt32(); + } + if (nRepeat) + for (sal_Int32 j = 0; j < nRepeat; j++) + sOUText.append(static_cast<sal_Unicode>(' ')); + else + sOUText.append(static_cast<sal_Unicode>(' ')); + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLContentContext::Characters( const ::rtl::OUString& rChars ) +{ + sOUText.append(rChars); +} + +void ScXMLContentContext::EndElement() +{ + sValue.append(sOUText); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_xmlcvali.cxx b/binfilter/bf_sc/source/filter/xml/sc_xmlcvali.cxx new file mode 100644 index 000000000000..38d47ab49ccc --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_xmlcvali.cxx @@ -0,0 +1,740 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "xmlcvali.hxx" +#include "xmlimprt.hxx" +#include "xmlconti.hxx" +#include "XMLConverter.hxx" + +#include <bf_xmloff/nmspmap.hxx> +#include <bf_xmloff/xmlnmspe.hxx> +#include <bf_xmloff/XMLEventsImportContext.hxx> + +#include <tools/debug.hxx> +namespace binfilter { + +using namespace ::com::sun::star; +using namespace xmloff::token; + +class ScXMLContentValidationContext : public SvXMLImportContext +{ + ::rtl::OUString sName; + ::rtl::OUString sHelpTitle; + ::rtl::OUString sHelpMessage; + ::rtl::OUString sErrorTitle; + ::rtl::OUString sErrorMessage; + ::rtl::OUString sErrorMessageType; + ::rtl::OUString sBaseCellAddress; + ::rtl::OUString sCondition; + sal_Bool bAllowEmptyCell : 1; + sal_Bool bDisplayHelp : 1; + sal_Bool bDisplayError : 1; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + + void GetAlertStyle(const ::rtl::OUString& sMessageType, ::com::sun::star::sheet::ValidationAlertStyle& aAlertStyle); + void SetFormulas(const ::rtl::OUString& sFormulas, ::rtl::OUString& sFormula1, ::rtl::OUString& sFormula2) const; + void GetCondition(const ::rtl::OUString& sCondition, ::rtl::OUString& sFormula1, ::rtl::OUString& sFormula2, + ::com::sun::star::sheet::ValidationType& aValidationType, + ::com::sun::star::sheet::ConditionOperator& aOperator); + +public: + + ScXMLContentValidationContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList); + + virtual ~ScXMLContentValidationContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); + + void SetHelpMessage(const ::rtl::OUString& sTitle, const ::rtl::OUString& sMessage, const sal_Bool bDisplay); + void SetErrorMessage(const ::rtl::OUString& sTitle, const ::rtl::OUString& sMessage, const ::rtl::OUString& sMessageType, const sal_Bool bDisplay); + void SetErrorMacro(const ::rtl::OUString& sName, const sal_Bool bExecute); +}; + +class ScXMLHelpMessageContext : public SvXMLImportContext +{ + ::rtl::OUString sTitle; + ::rtl::OUStringBuffer sMessage; + sal_Int32 nParagraphCount; + sal_Bool bDisplay : 1; + + ScXMLContentValidationContext* pValidationContext; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLHelpMessageContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLContentValidationContext* pValidationContext); + + virtual ~ScXMLHelpMessageContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +class ScXMLErrorMessageContext : public SvXMLImportContext +{ + ::rtl::OUString sTitle; + ::rtl::OUStringBuffer sMessage; + ::rtl::OUString sMessageType; + sal_Int32 nParagraphCount; + sal_Bool bDisplay : 1; + + ScXMLContentValidationContext* pValidationContext; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLErrorMessageContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLContentValidationContext* pValidationContext); + + virtual ~ScXMLErrorMessageContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +class ScXMLErrorMacroContext : public SvXMLImportContext +{ + ::rtl::OUString sName; + sal_Bool bExecute : 1; + + ScXMLContentValidationContext* pValidationContext; + SvXMLImportContextRef xEventContext; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLErrorMacroContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLContentValidationContext* pValidationContext); + + virtual ~ScXMLErrorMacroContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +//------------------------------------------------------------------ + +ScXMLContentValidationsContext::ScXMLContentValidationsContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + // here are no attributes +} + +ScXMLContentValidationsContext::~ScXMLContentValidationsContext() +{ +} + +SvXMLImportContext *ScXMLContentValidationsContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + const SvXMLTokenMap& rTokenMap = GetScImport().GetContentValidationsElemTokenMap(); + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + case XML_TOK_CONTENT_VALIDATION: + pContext = new ScXMLContentValidationContext( GetScImport(), nPrefix, rLName, xAttrList); + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLContentValidationsContext::EndElement() +{ +} + +ScXMLContentValidationContext::ScXMLContentValidationContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList) : + SvXMLImportContext( rImport, nPrfx, rLName ), + sName(), + sHelpTitle(), + sHelpMessage(), + sErrorTitle(), + sErrorMessage(), + sErrorMessageType(), + sCondition(), + sBaseCellAddress(), + bAllowEmptyCell(sal_True), + bDisplayHelp(sal_False), + bDisplayError(sal_False) +{ + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetContentValidationAttrTokenMap(); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_CONTENT_VALIDATION_NAME: + sName = sValue; + break; + case XML_TOK_CONTENT_VALIDATION_CONDITION: + sCondition = sValue; + break; + case XML_TOK_CONTENT_VALIDATION_BASE_CELL_ADDRESS: + sBaseCellAddress = sValue; + break; + case XML_TOK_CONTENT_VALIDATION_ALLOW_EMPTY_CELL: + if (IsXMLToken(sValue, XML_FALSE)) + bAllowEmptyCell = sal_True; + break; + } + } +} + +ScXMLContentValidationContext::~ScXMLContentValidationContext() +{ +} + +SvXMLImportContext *ScXMLContentValidationContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + const SvXMLTokenMap& rTokenMap = GetScImport().GetContentValidationElemTokenMap(); + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + case XML_TOK_CONTENT_VALIDATION_ELEM_HELP_MESSAGE: + pContext = new ScXMLHelpMessageContext( GetScImport(), nPrefix, rLName, xAttrList, this); + break; + case XML_TOK_CONTENT_VALIDATION_ELEM_ERROR_MESSAGE: + pContext = new ScXMLErrorMessageContext( GetScImport(), nPrefix, rLName, xAttrList, this); + break; + case XML_TOK_CONTENT_VALIDATION_ELEM_ERROR_MACRO: + pContext = new ScXMLErrorMacroContext( GetScImport(), nPrefix, rLName, xAttrList, this); + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLContentValidationContext::GetAlertStyle(const ::rtl::OUString& sMessageType, ::com::sun::star::sheet::ValidationAlertStyle& aAlertStyle) +{ + if (IsXMLToken(sMessageType, XML_MACRO)) + aAlertStyle = sheet::ValidationAlertStyle_MACRO; + else if (IsXMLToken(sMessageType, XML_STOP)) + aAlertStyle = sheet::ValidationAlertStyle_STOP; + else if (IsXMLToken(sMessageType, XML_WARNING)) + aAlertStyle = sheet::ValidationAlertStyle_WARNING; + else if (IsXMLToken(sMessageType, XML_INFORMATION)) + aAlertStyle = sheet::ValidationAlertStyle_INFO; +} + +void ScXMLContentValidationContext::SetFormulas(const ::rtl::OUString& sFormulas, ::rtl::OUString& sFormula1, ::rtl::OUString& sFormula2) const +{ + sal_Int32 i = 0; + sal_Bool bString = sal_False; + sal_Int32 nBrakes = 0; + while ((sFormulas[i] != ',' || nBrakes > 0 || bString) && i < sFormulas.getLength()) + { + if (sFormulas[i] == '(') + nBrakes++; + if (sFormulas[i] == ')') + nBrakes--; + if (sFormulas[i] == '"') + bString = !bString; + i++; + } + if (sFormulas[i] == ',') + { + sFormula1 = sFormulas.copy(0, i); + sFormula2 = sFormulas.copy(i + 1); + } +} + +void ScXMLContentValidationContext::GetCondition(const ::rtl::OUString& sTempCondition, ::rtl::OUString& sFormula1, ::rtl::OUString& sFormula2, + ::com::sun::star::sheet::ValidationType& aValidationType, + ::com::sun::star::sheet::ConditionOperator& aOperator) +{ + ::rtl::OUString sCondition = sTempCondition; + if (sCondition.getLength()) + { + // ToDo: erase all blanks in the condition, but not in formulas or strings + ::rtl::OUString scell_content(RTL_CONSTASCII_USTRINGPARAM("cell_content")); + ::rtl::OUString scell_content_is_date(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-date")); + ::rtl::OUString scell_content_is_time(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-time")); + ::rtl::OUString scell_content_is_between(RTL_CONSTASCII_USTRINGPARAM("cell_content_is_between")); + ::rtl::OUString scell_content_text_length(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length")); + ::rtl::OUString scell_content_is_not_between(RTL_CONSTASCII_USTRINGPARAM("cell_content_is_not_between")); + ::rtl::OUString scell_content_is_whole_number(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-whole-number")); + ::rtl::OUString scell_content_is_decimal_number(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-decimal-number")); + ::rtl::OUString scell_content_text_length_is_between(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length-is-between")); + ::rtl::OUString scell_content_text_length_is_not_between(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length-is-not-between")); + sal_Int32 i = 0; + sal_Bool bAnd(sal_True); + while (sCondition[i] != '(' && i < sCondition.getLength()) + i++; + if (sCondition[i] == '(') + { + if (i != scell_content_text_length.getLength() && + i != scell_content_text_length_is_between.getLength() && + i != scell_content_text_length_is_not_between.getLength()) + { + if (i == scell_content_is_time.getLength()) + { + ::rtl::OUString sTemp = sCondition.copy(0, i); + if (sTemp == scell_content_is_time) + aValidationType = sheet::ValidationType_TIME; + else + aValidationType = sheet::ValidationType_DATE; + } + else if (i == scell_content_is_whole_number.getLength()) + aValidationType = sheet::ValidationType_WHOLE; + else if (i == scell_content_is_decimal_number.getLength()) + aValidationType = sheet::ValidationType_DECIMAL; + sCondition = sCondition.copy(i + 2); + ::rtl::OUString sTemp = sCondition.copy(0, 5); + if (sTemp.compareToAscii(" and ") == 0) + sCondition = sCondition.copy(5); + else + bAnd = sal_False; + } + if (sCondition.getLength() && bAnd) + { + i = 0; + while (sCondition[i] != '(' && i < sCondition.getLength()) + i++; + if (sCondition[i] == '(') + { + sCondition = sCondition.copy(i + 1); + if (i == scell_content_is_between.getLength() || + i == scell_content_text_length_is_between.getLength()) + { + if (i == scell_content_text_length_is_between.getLength()) + aValidationType = sheet::ValidationType_TEXT_LEN; + aOperator = sheet::ConditionOperator_BETWEEN; + sCondition = sCondition.copy(0, sCondition.getLength() - 1); + SetFormulas(sCondition, sFormula1, sFormula2); + } + else if (i == scell_content_is_not_between.getLength() || + i == scell_content_text_length_is_not_between.getLength()) + { + if (i == scell_content_text_length_is_not_between.getLength()) + aValidationType = sheet::ValidationType_TEXT_LEN; + aOperator = sheet::ConditionOperator_NOT_BETWEEN; + sCondition = sCondition.copy(0, sCondition.getLength() - 1); + SetFormulas(sCondition, sFormula1, sFormula2); + } + else if (i == scell_content.getLength() || + i == scell_content_text_length.getLength()) + { + if (i == scell_content_text_length.getLength()) + aValidationType = sheet::ValidationType_TEXT_LEN; + sCondition = sCondition.copy(1); + switch (sCondition[0]) + { + case '<' : + { + if (sCondition[1] == '=') + { + aOperator = sheet::ConditionOperator_LESS_EQUAL; + sCondition = sCondition.copy(2); + } + else + { + aOperator = sheet::ConditionOperator_LESS; + sCondition = sCondition.copy(1); + } + } + break; + case '>' : + { + if (sCondition[1] == '=') + { + aOperator = sheet::ConditionOperator_GREATER_EQUAL; + sCondition = sCondition.copy(2); + } + else + { + aOperator = sheet::ConditionOperator_GREATER; + sCondition = sCondition.copy(1); + } + } + break; + case '=' : + { + aOperator = sheet::ConditionOperator_EQUAL; + sCondition = sCondition.copy(1); + } + break; + case '!' : + { + aOperator = sheet::ConditionOperator_NOT_EQUAL; + sCondition = sCondition.copy(1); + } + break; + } + sFormula1 = sCondition; + } + } + } + } + } +} + +void ScXMLContentValidationContext::EndElement() +{ + ScMyImportValidation aValidation; + sal_Int32 nOffset(0); + aValidation.sName = sName; + aValidation.sBaseCellAddress = sBaseCellAddress; + aValidation.sImputTitle = sHelpTitle; + aValidation.sImputMessage = sHelpMessage; + aValidation.sErrorTitle = sErrorTitle; + aValidation.sErrorMessage = sErrorMessage; + GetCondition(sCondition, aValidation.sFormula1, aValidation.sFormula2, aValidation.aValidationType, aValidation.aOperator); + if (aValidation.sFormula1.getLength()) + ScXMLConverter::ParseFormula(aValidation.sFormula1); + if (aValidation.sFormula2.getLength()) + ScXMLConverter::ParseFormula(aValidation.sFormula2); + GetAlertStyle(sErrorMessageType, aValidation.aAlertStyle); + aValidation.bShowErrorMessage = bDisplayError; + aValidation.bShowImputMessage = bDisplayHelp; + aValidation.bIgnoreBlanks = bAllowEmptyCell; + GetScImport().AddValidation(aValidation); +} + +void ScXMLContentValidationContext::SetHelpMessage(const ::rtl::OUString& sTitle, const ::rtl::OUString& sMessage, const sal_Bool bDisplay) +{ + sHelpTitle = sTitle; + sHelpMessage = sMessage; + bDisplayHelp = bDisplay; +} + +void ScXMLContentValidationContext::SetErrorMessage(const ::rtl::OUString& sTitle, const ::rtl::OUString& sMessage, + const ::rtl::OUString& sMessageType, const sal_Bool bDisplay) +{ + sErrorTitle = sTitle; + sErrorMessage = sMessage; + sErrorMessageType = sMessageType; + bDisplayError = bDisplay; +} + +void ScXMLContentValidationContext::SetErrorMacro(const ::rtl::OUString& sName, const sal_Bool bExecute) +{ + sErrorTitle = sName; + sErrorMessageType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("macro")); + bDisplayError = bExecute; +} + +ScXMLHelpMessageContext::ScXMLHelpMessageContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLContentValidationContext* pTempValidationContext) : + SvXMLImportContext( rImport, nPrfx, rLName ), + sTitle(), + sMessage(), + nParagraphCount(0), + bDisplay(sal_False) +{ + pValidationContext = pTempValidationContext; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetContentValidationHelpMessageAttrTokenMap(); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_HELP_MESSAGE_ATTR_TITLE: + sTitle = sValue; + break; + case XML_TOK_HELP_MESSAGE_ATTR_DISPLAY: + bDisplay = IsXMLToken(sValue, XML_TRUE); + break; + } + } +} + +ScXMLHelpMessageContext::~ScXMLHelpMessageContext() +{ +} + +SvXMLImportContext *ScXMLHelpMessageContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + const SvXMLTokenMap& rTokenMap = GetScImport().GetContentValidationMessageElemTokenMap(); + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + case XML_TOK_P: + { + if(nParagraphCount) + sMessage.append(static_cast<sal_Unicode>('\n')); + nParagraphCount++; + pContext = new ScXMLContentContext( GetScImport(), nPrefix, rLName, xAttrList, sMessage); + } + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLHelpMessageContext::EndElement() +{ + pValidationContext->SetHelpMessage(sTitle, sMessage.makeStringAndClear(), bDisplay); +} + +ScXMLErrorMessageContext::ScXMLErrorMessageContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLContentValidationContext* pTempValidationContext) : + SvXMLImportContext( rImport, nPrfx, rLName ), + sTitle(), + sMessage(), + sMessageType(), + nParagraphCount(0), + bDisplay(sal_False) +{ + pValidationContext = pTempValidationContext; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetContentValidationErrorMessageAttrTokenMap(); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_ERROR_MESSAGE_ATTR_TITLE: + sTitle = sValue; + break; + case XML_TOK_ERROR_MESSAGE_ATTR_MESSAGE_TYPE: + sMessageType = sValue; + break; + case XML_TOK_ERROR_MESSAGE_ATTR_DISPLAY: + bDisplay = IsXMLToken(sValue, XML_TRUE); + break; + } + } +} + +ScXMLErrorMessageContext::~ScXMLErrorMessageContext() +{ +} + +SvXMLImportContext *ScXMLErrorMessageContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + const SvXMLTokenMap& rTokenMap = GetScImport().GetContentValidationMessageElemTokenMap(); + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + case XML_TOK_P: + { + if(nParagraphCount) + sMessage.append(static_cast<sal_Unicode>('\n')); + nParagraphCount++; + pContext = new ScXMLContentContext( GetScImport(), nPrefix, rLName, xAttrList, sMessage); + } + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLErrorMessageContext::EndElement() +{ + pValidationContext->SetErrorMessage(sTitle, sMessage.makeStringAndClear(), sMessageType, bDisplay); +} + +ScXMLErrorMacroContext::ScXMLErrorMacroContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLContentValidationContext* pTempValidationContext) : + SvXMLImportContext( rImport, nPrfx, rLName ), + sName(), + bExecute(sal_False) +{ + pValidationContext = pTempValidationContext; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetContentValidationErrorMacroAttrTokenMap(); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_ERROR_MACRO_ATTR_NAME: + sName = sValue; + break; + case XML_TOK_ERROR_MACRO_ATTR_EXECUTE: + bExecute = IsXMLToken(sValue, XML_TRUE); + break; + } + } +} + +ScXMLErrorMacroContext::~ScXMLErrorMacroContext() +{ +} + +SvXMLImportContext *ScXMLErrorMacroContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = NULL; + + if ((nPrefix == XML_NAMESPACE_SCRIPT) && IsXMLToken(rLName, XML_EVENTS)) + { + DBG_ASSERT(!sName.getLength(), "here is something wrong in the file"); + pContext = new XMLEventsImportContext(GetImport(), nPrefix, rLName); + xEventContext = pContext; + } + if (!pContext) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLErrorMacroContext::EndElement() +{ + if (xEventContext.Is()) + { + ::rtl::OUString sOnError(RTL_CONSTASCII_USTRINGPARAM("OnError")); + XMLEventsImportContext* pEvents = + (XMLEventsImportContext*)&xEventContext; + uno::Sequence<beans::PropertyValue> aValues; + pEvents->GetEventSequence( sOnError, aValues ); + + const beans::PropertyValue* pValues = aValues.getConstArray(); + sal_Int32 nLength = aValues.getLength(); + for( sal_Int32 i = 0; i < nLength; i++ ) + { + if ( aValues[i].Name.equalsAsciiL( "MacroName", + sizeof("MacroName")-1 ) ) + { + aValues[i].Value >>= sName; + break; + } + } + } + else + DBG_ASSERT(sName.getLength(), "no macro name given"); + pValidationContext->SetErrorMacro(sName, bExecute); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_xmldpimp.cxx b/binfilter/bf_sc/source/filter/xml/sc_xmldpimp.cxx new file mode 100644 index 000000000000..cd4a9fadce30 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_xmldpimp.cxx @@ -0,0 +1,1036 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include "xmlimprt.hxx" +#include "xmlfilti.hxx" +#include "document.hxx" +#include "dpshttab.hxx" +#include "dpsdbtab.hxx" +#include "attrib.hxx" + +#include "XMLConverter.hxx" + +#include <bf_xmloff/nmspmap.hxx> +namespace binfilter { + +using namespace ::com::sun::star; +using namespace xmloff::token; + +using rtl::OUString; + +ScXMLDataPilotTablesContext::ScXMLDataPilotTablesContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + // has no Attributes + rImport.LockSolarMutex(); +} + +ScXMLDataPilotTablesContext::~ScXMLDataPilotTablesContext() +{ + GetScImport().UnlockSolarMutex(); +} + +SvXMLImportContext *ScXMLDataPilotTablesContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + const SvXMLTokenMap& rTokenMap = GetScImport().GetDataPilotTablesElemTokenMap(); + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + case XML_TOK_DATA_PILOT_TABLE : + { + pContext = new ScXMLDataPilotTableContext( GetScImport(), nPrefix, + rLName, xAttrList); + } + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLDataPilotTablesContext::EndElement() +{ +} + +ScXMLDataPilotTableContext::ScXMLDataPilotTableContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList) : + SvXMLImportContext( rImport, nPrfx, rLName ), + sDataPilotTableName(), + sApplicationData(), + sGrandTotal(GetXMLToken(XML_BOTH)), + bIsNative(sal_True), + bIgnoreEmptyRows(sal_False), + bIdentifyCategories(sal_False), + bTargetRangeAddress(sal_False), + bSourceCellRange(sal_False), + pDoc(GetScImport().GetDocument()), + pDPObject(NULL), + pDPSave(NULL) +{ + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataPilotTableAttrTokenMap(); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_DATA_PILOT_TABLE_ATTR_NAME : + { + sDataPilotTableName = sValue; + } + break; + case XML_TOK_DATA_PILOT_TABLE_ATTR_APPLICATION_DATA : + { + sApplicationData = sValue; + } + break; + case XML_TOK_DATA_PILOT_TABLE_ATTR_GRAND_TOTAL : + { + sGrandTotal = sValue; + } + break; + case XML_TOK_DATA_PILOT_TABLE_ATTR_IGNORE_EMPTY_ROWS : + { + bIgnoreEmptyRows = IsXMLToken(sValue, XML_TRUE); + } + break; + case XML_TOK_DATA_PILOT_TABLE_ATTR_IDENTIFY_CATEGORIES : + { + bIdentifyCategories = IsXMLToken(sValue, XML_TRUE); + } + break; + case XML_TOK_DATA_PILOT_TABLE_ATTR_TARGET_RANGE_ADDRESS : + { + sal_Int32 nOffset(0); + bTargetRangeAddress = ScXMLConverter::GetRangeFromString( aTargetRangeAddress, sValue, pDoc, nOffset ); + } + break; + case XML_TOK_DATA_PILOT_TABLE_ATTR_BUTTONS : + { + sButtons = sValue; + } + break; + } + } + + pDPObject = new ScDPObject(pDoc); + pDPSave = new ScDPSaveData(); +} + +ScXMLDataPilotTableContext::~ScXMLDataPilotTableContext() +{ +} + +SvXMLImportContext *ScXMLDataPilotTableContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + const SvXMLTokenMap& rTokenMap = GetScImport().GetDataPilotTableElemTokenMap(); + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + case XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_SQL : + { + pContext = new ScXMLDPSourceSQLContext(GetScImport(), nPrefix, rLName, xAttrList, this); + nSourceType = SQL; + } + break; + case XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_TABLE : + { + pContext = new ScXMLDPSourceTableContext(GetScImport(), nPrefix, rLName, xAttrList, this); + nSourceType = TABLE; + } + break; + case XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_QUERY : + { + pContext = new ScXMLDPSourceQueryContext(GetScImport(), nPrefix, rLName, xAttrList, this); + nSourceType = QUERY; + } + break; + case XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_SERVICE : + { + pContext = new ScXMLSourceServiceContext(GetScImport(), nPrefix, rLName, xAttrList, this); + nSourceType = SERVICE; + } + break; + case XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_CELL_RANGE : + { + pContext = new ScXMLSourceCellRangeContext(GetScImport(), nPrefix, rLName, xAttrList, this); + nSourceType = CELLRANGE; + } + break; + case XML_TOK_DATA_PILOT_TABLE_ELEM_DATA_PILOT_FIELD : + pContext = new ScXMLDataPilotFieldContext(GetScImport(), nPrefix, rLName, xAttrList, this); + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLDataPilotTableContext::SetButtons() +{ + OUString sAddress; + sal_Int32 nOffset = 0; + while( nOffset >= 0 ) + { + ScXMLConverter::GetTokenByOffset( sAddress, sButtons, nOffset ); + if( nOffset >= 0 ) + { + ScAddress aScAddress; + sal_Int32 nOffset(0); + if (pDoc && ScXMLConverter::GetAddressFromString( aScAddress, sAddress, pDoc, nOffset )) + { + ScMergeFlagAttr aAttr( SC_MF_BUTTON ); + pDoc->ApplyAttr( aScAddress.Col(), aScAddress.Row(), aScAddress.Tab(), aAttr ); + } + } + } +} + +void ScXMLDataPilotTableContext::AddDimension(ScDPSaveDimension* pDim) +{ + if (pDPSave) + { + // #91045# if a dimension with that name has already been inserted, + // mark the new one as duplicate + if ( !pDim->IsDataLayout() && + pDPSave->GetExistingDimensionByName(pDim->GetName()) ) + pDim->SetDupFlag( TRUE ); + + pDPSave->AddDimension(pDim); + } +} + +void ScXMLDataPilotTableContext::EndElement() +{ + if (bTargetRangeAddress) + { + pDPObject->SetName(sDataPilotTableName); + pDPObject->SetTag(sApplicationData); + pDPObject->SetOutRange(aTargetRangeAddress); + switch (nSourceType) + { + case SQL : + { + ScImportSourceDesc aImportDesc; + aImportDesc.aDBName = sDatabaseName; + aImportDesc.aObject = sSourceObject; + aImportDesc.nType = sheet::DataImportMode_SQL; + aImportDesc.bNative = bIsNative; + pDPObject->SetImportDesc(aImportDesc); + } + break; + case TABLE : + { + ScImportSourceDesc aImportDesc; + aImportDesc.aDBName = sDatabaseName; + aImportDesc.aObject = sSourceObject; + aImportDesc.nType = sheet::DataImportMode_TABLE; + pDPObject->SetImportDesc(aImportDesc); + } + break; + case QUERY : + { + ScImportSourceDesc aImportDesc; + aImportDesc.aDBName = sDatabaseName; + aImportDesc.aObject = sSourceObject; + aImportDesc.nType = sheet::DataImportMode_QUERY; + pDPObject->SetImportDesc(aImportDesc); + } + break; + case SERVICE : + { + ScDPServiceDesc aServiceDesk(sServiceName, sServiceSourceObject, sServiceSourceName, + sServiceUsername, sServicePassword); + pDPObject->SetServiceData(aServiceDesk); + } + break; + case CELLRANGE : + { + if (bSourceCellRange) + { + ScSheetSourceDesc aSheetDesc; + aSheetDesc.aSourceRange = aSourceCellRangeAddress; + aSheetDesc.aQueryParam = aSourceQueryParam; + pDPObject->SetSheetDesc(aSheetDesc); + } + } + break; + } + if (IsXMLToken(sGrandTotal, XML_BOTH)) + { + pDPSave->SetRowGrand(sal_True); + pDPSave->SetColumnGrand(sal_True); + } + else if (IsXMLToken(sGrandTotal, XML_ROW)) + { + pDPSave->SetRowGrand(sal_True); + pDPSave->SetColumnGrand(sal_False); + } + else if (IsXMLToken(sGrandTotal, XML_COLUMN)) + { + pDPSave->SetRowGrand(sal_False); + pDPSave->SetColumnGrand(sal_True); + } + else + { + pDPSave->SetRowGrand(sal_False); + pDPSave->SetColumnGrand(sal_False); + } + pDPSave->SetIgnoreEmptyRows(bIgnoreEmptyRows); + pDPSave->SetRepeatIfEmpty(bIdentifyCategories); + pDPObject->SetSaveData(*pDPSave); + if (pDoc) + { + ScDPCollection* pDPCollection = pDoc->GetDPCollection(); + pDPObject->SetAlive(sal_True); + pDPCollection->Insert(pDPObject); + } + SetButtons(); + } +} + +ScXMLDPSourceSQLContext::ScXMLDPSourceSQLContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDataPilotTableContext* pTempDataPilotTable) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + pDataPilotTable = pTempDataPilotTable; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDatabaseRangeSourceSQLAttrTokenMap(); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_SOURCE_SQL_ATTR_DATABASE_NAME : + { + pDataPilotTable->SetDatabaseName(sValue); + } + break; + case XML_TOK_SOURCE_SQL_ATTR_SQL_STATEMENT : + { + pDataPilotTable->SetSourceObject(sValue); + } + break; + case XML_TOK_SOURCE_SQL_ATTR_PARSE_SQL_STATEMENT : + { + pDataPilotTable->SetNative(!IsXMLToken(sValue, XML_TRUE)); + } + break; + } + } +} + +ScXMLDPSourceSQLContext::~ScXMLDPSourceSQLContext() +{ +} + +SvXMLImportContext *ScXMLDPSourceSQLContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLDPSourceSQLContext::EndElement() +{ +} + +ScXMLDPSourceTableContext::ScXMLDPSourceTableContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDataPilotTableContext* pTempDataPilotTable) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + pDataPilotTable = pTempDataPilotTable; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDatabaseRangeSourceTableAttrTokenMap(); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_SOURCE_TABLE_ATTR_DATABASE_NAME : + { + pDataPilotTable->SetDatabaseName(sValue); + } + break; + case XML_TOK_SOURCE_TABLE_ATTR_TABLE_NAME : + { + pDataPilotTable->SetSourceObject(sValue); + } + break; + } + } +} + +ScXMLDPSourceTableContext::~ScXMLDPSourceTableContext() +{ +} + +SvXMLImportContext *ScXMLDPSourceTableContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLDPSourceTableContext::EndElement() +{ +} + +ScXMLDPSourceQueryContext::ScXMLDPSourceQueryContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDataPilotTableContext* pTempDataPilotTable) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + pDataPilotTable = pTempDataPilotTable; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDatabaseRangeSourceQueryAttrTokenMap(); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_SOURCE_QUERY_ATTR_DATABASE_NAME : + { + pDataPilotTable->SetDatabaseName(sValue); + } + break; + case XML_TOK_SOURCE_QUERY_ATTR_QUERY_NAME : + { + pDataPilotTable->SetSourceObject(sValue); + } + break; + } + } +} + +ScXMLDPSourceQueryContext::~ScXMLDPSourceQueryContext() +{ +} + +SvXMLImportContext *ScXMLDPSourceQueryContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLDPSourceQueryContext::EndElement() +{ +} + +ScXMLSourceServiceContext::ScXMLSourceServiceContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDataPilotTableContext* pTempDataPilotTable) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + pDataPilotTable = pTempDataPilotTable; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataPilotTableSourceServiceAttrTokenMap(); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_SOURCE_SERVICE_ATTR_NAME : + { + pDataPilotTable->SetServiceName(sValue); + } + break; + case XML_TOK_SOURCE_SERVICE_ATTR_SOURCE_NAME : + { + pDataPilotTable->SetServiceSourceName(sValue); + } + break; + case XML_TOK_SOURCE_SERVICE_ATTR_OBJECT_NAME : + { + pDataPilotTable->SetServiceSourceObject(sValue); + } + break; + case XML_TOK_SOURCE_SERVICE_ATTR_USERNAME : + { + pDataPilotTable->SetServiceUsername(sValue); + } + break; + case XML_TOK_SOURCE_SERVICE_ATTR_PASSWORD : + { + pDataPilotTable->SetServicePassword(sValue); + } + break; + } + } +} + +ScXMLSourceServiceContext::~ScXMLSourceServiceContext() +{ +} + +SvXMLImportContext *ScXMLSourceServiceContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLSourceServiceContext::EndElement() +{ +} + +ScXMLSourceCellRangeContext::ScXMLSourceCellRangeContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDataPilotTableContext* pTempDataPilotTable) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + pDataPilotTable = pTempDataPilotTable; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataPilotTableSourceCellRangeAttrTokenMap(); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_SOURCE_CELL_RANGE_ATTR_CELL_RANGE_ADDRESS : + { + ScRange aSourceRangeAddress; + sal_Int32 nOffset(0); + if (ScXMLConverter::GetRangeFromString( aSourceRangeAddress, sValue, GetScImport().GetDocument(), nOffset )) + pDataPilotTable->SetSourceCellRangeAddress(aSourceRangeAddress); + } + break; + } + } +} + +ScXMLSourceCellRangeContext::~ScXMLSourceCellRangeContext() +{ +} + +SvXMLImportContext *ScXMLSourceCellRangeContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + const SvXMLTokenMap& rTokenMap = GetScImport().GetDataPilotTableSourceCellRangeElemTokenMap(); + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + case XML_TOK_SOURCE_CELL_RANGE_ELEM_FILTER : + pContext = new ScXMLDPFilterContext(GetScImport(), nPrefix, rLName, xAttrList, pDataPilotTable); + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLSourceCellRangeContext::EndElement() +{ +} + +ScXMLDataPilotFieldContext::ScXMLDataPilotFieldContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDataPilotTableContext* pTempDataPilotTable) : + SvXMLImportContext( rImport, nPrfx, rLName ), + pDim(NULL) +{ + pDataPilotTable = pTempDataPilotTable; + ::rtl::OUString sName; + sal_Bool bHasName(sal_False); + sal_Bool bDataLayout(sal_False); + nUsedHierarchy = 1; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataPilotFieldAttrTokenMap(); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_DATA_PILOT_FIELD_ATTR_SOURCE_FIELD_NAME : + { + sName = sValue; + bHasName = sal_True; + } + break; + case XML_TOK_DATA_PILOT_FIELD_ATTR_IS_DATA_LAYOUT_FIELD : + { + bDataLayout = IsXMLToken(sValue, XML_TRUE); + } + break; + case XML_TOK_DATA_PILOT_FIELD_ATTR_FUNCTION : + { + nFunction = (sal_Int16) ScXMLConverter::GetFunctionFromString( sValue ); + } + break; + case XML_TOK_DATA_PILOT_FIELD_ATTR_ORIENTATION : + { + nOrientation = (sal_Int16) ScXMLConverter::GetOrientationFromString( sValue ); + } + break; + case XML_TOK_DATA_PILOT_FIELD_ATTR_USED_HIERARCHY : + { + nUsedHierarchy = sValue.toInt32(); + } + break; + } + } + if (bHasName) + pDim = new ScDPSaveDimension(String(sName), bDataLayout); +} + +ScXMLDataPilotFieldContext::~ScXMLDataPilotFieldContext() +{ +} + +SvXMLImportContext *ScXMLDataPilotFieldContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + const SvXMLTokenMap& rTokenMap = GetScImport().GetDataPilotFieldElemTokenMap(); + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + case XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_LEVEL : + pContext = new ScXMLDataPilotLevelContext(GetScImport(), nPrefix, rLName, xAttrList, this); + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLDataPilotFieldContext::EndElement() +{ + if (pDim) + { + pDim->SetUsedHierarchy(nUsedHierarchy); + pDim->SetFunction(nFunction); + pDim->SetOrientation(nOrientation); + pDataPilotTable->AddDimension(pDim); + } +} + +ScXMLDataPilotLevelContext::ScXMLDataPilotLevelContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDataPilotFieldContext* pTempDataPilotField) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + pDataPilotField = pTempDataPilotField; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataPilotLevelAttrTokenMap(); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_DATA_PILOT_LEVEL_ATTR_DISPLAY_EMPTY : + { + pDataPilotField->SetShowEmpty(IsXMLToken(sValue, XML_TRUE)); + } + break; + } + } +} + +ScXMLDataPilotLevelContext::~ScXMLDataPilotLevelContext() +{ +} + +SvXMLImportContext *ScXMLDataPilotLevelContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + const SvXMLTokenMap& rTokenMap = GetScImport().GetDataPilotLevelElemTokenMap(); + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + case XML_TOK_DATA_PILOT_LEVEL_ELEM_DATA_PILOT_SUBTOTALS : + pContext = new ScXMLDataPilotSubTotalsContext(GetScImport(), nPrefix, rLName, xAttrList, pDataPilotField); + break; + case XML_TOK_DATA_PILOT_LEVEL_ELEM_DATA_PILOT_MEMBERS : + pContext = new ScXMLDataPilotMembersContext(GetScImport(), nPrefix, rLName, xAttrList, pDataPilotField); + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLDataPilotLevelContext::EndElement() +{ +} + +ScXMLDataPilotSubTotalsContext::ScXMLDataPilotSubTotalsContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDataPilotFieldContext* pTempDataPilotField) : + SvXMLImportContext( rImport, nPrfx, rLName ), + pFunctions(NULL), + nFunctionCount(0) +{ + pDataPilotField = pTempDataPilotField; + + // has no attributes +} + +ScXMLDataPilotSubTotalsContext::~ScXMLDataPilotSubTotalsContext() +{ +} + +SvXMLImportContext *ScXMLDataPilotSubTotalsContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + const SvXMLTokenMap& rTokenMap = GetScImport().GetDataPilotSubTotalsElemTokenMap(); + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + case XML_TOK_DATA_PILOT_SUBTOTALS_ELEM_DATA_PILOT_SUBTOTAL : + pContext = new ScXMLDataPilotSubTotalContext(GetScImport(), nPrefix, rLName, xAttrList, this); + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLDataPilotSubTotalsContext::EndElement() +{ + pDataPilotField->SetSubTotals(pFunctions, nFunctionCount); +} + +void ScXMLDataPilotSubTotalsContext::AddFunction(sal_Int16 nFunction) +{ + if (nFunctionCount) + { + nFunctionCount++; + sal_uInt16* pTemp = new sal_uInt16[nFunctionCount]; + for (sal_Int16 i = 0; i < nFunctionCount - 1; i++) + pTemp[i] = pFunctions[i]; + pTemp[nFunctionCount - 1] = nFunction; + delete[] pFunctions; + pFunctions = pTemp; + } + else + { + nFunctionCount = 1; + pFunctions = new sal_uInt16[nFunctionCount]; + pFunctions[0] = nFunction; + } +} + +ScXMLDataPilotSubTotalContext::ScXMLDataPilotSubTotalContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDataPilotSubTotalsContext* pTempDataPilotSubTotals) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + pDataPilotSubTotals = pTempDataPilotSubTotals; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataPilotSubTotalAttrTokenMap(); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_DATA_PILOT_SUBTOTAL_ATTR_FUNCTION : + { + pDataPilotSubTotals->AddFunction( ScXMLConverter::GetFunctionFromString( sValue ) ); + } + break; + } + } +} + +ScXMLDataPilotSubTotalContext::~ScXMLDataPilotSubTotalContext() +{ +} + +SvXMLImportContext *ScXMLDataPilotSubTotalContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLDataPilotSubTotalContext::EndElement() +{ +} + +ScXMLDataPilotMembersContext::ScXMLDataPilotMembersContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDataPilotFieldContext* pTempDataPilotField) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + pDataPilotField = pTempDataPilotField; + + // has no attributes +} + +ScXMLDataPilotMembersContext::~ScXMLDataPilotMembersContext() +{ +} + +SvXMLImportContext *ScXMLDataPilotMembersContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + const SvXMLTokenMap& rTokenMap = GetScImport().GetDataPilotMembersElemTokenMap(); + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + case XML_TOK_DATA_PILOT_MEMBERS_ELEM_DATA_PILOT_MEMBER : + pContext = new ScXMLDataPilotMemberContext(GetScImport(), nPrefix, rLName, xAttrList, pDataPilotField); + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLDataPilotMembersContext::EndElement() +{ +} + +ScXMLDataPilotMemberContext::ScXMLDataPilotMemberContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDataPilotFieldContext* pTempDataPilotField) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + pDataPilotField = pTempDataPilotField; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataPilotMemberAttrTokenMap(); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_DATA_PILOT_MEMBER_ATTR_NAME : + { + sName = sValue; + } + break; + case XML_TOK_DATA_PILOT_MEMBER_ATTR_DISPLAY : + { + bDisplay = IsXMLToken(sValue, XML_TRUE); + } + break; + case XML_TOK_DATA_PILOT_MEMBER_ATTR_DISPLAY_DETAILS : + { + bDisplayDetails = IsXMLToken(sValue, XML_TRUE); + } + break; + } + } +} + +ScXMLDataPilotMemberContext::~ScXMLDataPilotMemberContext() +{ +} + +SvXMLImportContext *ScXMLDataPilotMemberContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLDataPilotMemberContext::EndElement() +{ + if (sName.getLength()) + { + ScDPSaveMember* pMember = new ScDPSaveMember(String(sName)); + pMember->SetIsVisible(bDisplay); + pMember->SetShowDetails(bDisplayDetails); + pDataPilotField->AddMember(pMember); + } +} + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_xmldrani.cxx b/binfilter/bf_sc/source/filter/xml/sc_xmldrani.cxx new file mode 100644 index 000000000000..10fe9d6d6b36 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_xmldrani.cxx @@ -0,0 +1,923 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "xmlimprt.hxx" +#include "xmlfilti.hxx" +#include "xmlsorti.hxx" +#include "document.hxx" +#include "globstr.hrc" +#include "dbcolect.hxx" +#include "datauno.hxx" + +#include "attrib.hxx" +#include "unonames.hxx" +#include "convuno.hxx" +#include "XMLConverter.hxx" + +#include <bf_xmloff/nmspmap.hxx> +#include <bf_xmloff/xmluconv.hxx> +#include <bf_xmloff/xmlerror.hxx> +#include <comphelper/extract.hxx> +namespace binfilter { + +#define SC_ENABLEUSERSORTLIST "EnableUserSortList" +#define SC_USERSORTLISTINDEX "UserSortListIndex" +#define SC_USERLIST "UserList" + +using namespace ::com::sun::star; +using namespace xmloff::token; + +//------------------------------------------------------------------ + +ScXMLDatabaseRangesContext::ScXMLDatabaseRangesContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + // has no attributes + rImport.LockSolarMutex(); +} + +ScXMLDatabaseRangesContext::~ScXMLDatabaseRangesContext() +{ + GetScImport().UnlockSolarMutex(); +} + +SvXMLImportContext *ScXMLDatabaseRangesContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + const SvXMLTokenMap& rTokenMap = GetScImport().GetDatabaseRangesElemTokenMap(); + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + case XML_TOK_DATABASE_RANGE : + { + pContext = new ScXMLDatabaseRangeContext( GetScImport(), nPrefix, + rLName, xAttrList); + } + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLDatabaseRangesContext::EndElement() +{ +} + +ScXMLDatabaseRangeContext::ScXMLDatabaseRangeContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList) : + SvXMLImportContext( rImport, nPrfx, rLName ), + nRefresh(0), + nSubTotalsUserListIndex(0), + nSubTotalRuleGroupFieldNumber(0), + bContainsSort(sal_False), + bContainsSubTotal(sal_False), + bIsSelection(sal_False), + bKeepFormats(sal_False), + bMoveCells(sal_False), + bStripData(sal_False), + eOrientation(table::TableOrientation_ROWS), + bContainsHeader(sal_True), + bAutoFilter(sal_False), + bFilterCopyOutputData(sal_False), + bFilterIsCaseSensitive(sal_False), + bFilterSkipDuplicates(sal_False), + bFilterUseRegularExpressions(sal_False), + bFilterConditionSourceRange(sal_False), + bSubTotalsBindFormatsToContent(sal_False), + bSubTotalsIsCaseSensitive(sal_False), + bSubTotalsInsertPageBreaks(sal_False), + bSubTotalsSortGroups(sal_False), + bSubTotalsEnabledUserList(sal_False), + bSubTotalsAscending(sal_True), + bNative(sal_True), + aSubTotalColumns(), + aSortSequence() +{ + nSourceType = sheet::DataImportMode_NONE; + String sUnbenannt = ScGlobal::GetRscString(STR_DB_NONAME); + ::rtl::OUString sOUUnbenannt (sUnbenannt); + sDatabaseRangeName = sOUUnbenannt; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDatabaseRangeAttrTokenMap(); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_DATABASE_RANGE_ATTR_NAME : + { + sDatabaseRangeName = sValue; + } + break; + case XML_TOK_DATABASE_RANGE_ATTR_IS_SELECTION : + { + bIsSelection = IsXMLToken(sValue, XML_TRUE); + } + break; + case XML_TOK_DATABASE_RANGE_ATTR_ON_UPDATE_KEEP_STYLES : + { + bKeepFormats = IsXMLToken(sValue, XML_TRUE); + } + break; + case XML_TOK_DATABASE_RANGE_ATTR_ON_UPDATE_KEEP_SIZE : + { + bMoveCells = !IsXMLToken(sValue, XML_TRUE); + } + break; + case XML_TOK_DATABASE_RANGE_ATTR_HAS_PERSISTENT_DATA : + { + bStripData = !IsXMLToken(sValue, XML_TRUE); + } + break; + case XML_TOK_DATABASE_RANGE_ATTR_ORIENTATION : + { + if (IsXMLToken(sValue, XML_COLUMN)) + eOrientation = table::TableOrientation_COLUMNS; + } + break; + case XML_TOK_DATABASE_RANGE_ATTR_CONTAINS_HEADER : + { + bContainsHeader = IsXMLToken(sValue, XML_TRUE); + } + break; + case XML_TOK_DATABASE_RANGE_ATTR_DISPLAY_FILTER_BUTTONS : + { + bAutoFilter = IsXMLToken(sValue, XML_TRUE); + } + break; + case XML_TOK_DATABASE_RANGE_ATTR_TARGET_RANGE_ADDRESS : + { + sRangeAddress = sValue; + } + break; + case XML_TOK_DATABASE_RANGE_ATTR_REFRESH_DELAY : + { + double fTime; + if( SvXMLUnitConverter::convertTime( fTime, sValue ) ) + nRefresh = Max( (sal_Int32)(fTime * 86400.0), (sal_Int32)0 ); + } + break; + } + } +} + +ScXMLDatabaseRangeContext::~ScXMLDatabaseRangeContext() +{ +} + +SvXMLImportContext *ScXMLDatabaseRangeContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + const SvXMLTokenMap& rTokenMap = GetScImport().GetDatabaseRangeElemTokenMap(); + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + case XML_TOK_DATABASE_RANGE_SOURCE_SQL : + { + pContext = new ScXMLSourceSQLContext( GetScImport(), nPrefix, + rLName, xAttrList, this); + } + break; + case XML_TOK_DATABASE_RANGE_SOURCE_TABLE : + { + pContext = new ScXMLSourceTableContext( GetScImport(), nPrefix, + rLName, xAttrList, this); + } + break; + case XML_TOK_DATABASE_RANGE_SOURCE_QUERY : + { + pContext = new ScXMLSourceQueryContext( GetScImport(), nPrefix, + rLName, xAttrList, this); + } + break; + case XML_TOK_FILTER : + { + pContext = new ScXMLFilterContext( GetScImport(), nPrefix, + rLName, xAttrList, this); + } + break; + case XML_TOK_SORT : + { + bContainsSort = sal_True; + pContext = new ScXMLSortContext( GetScImport(), nPrefix, + rLName, xAttrList, this); + } + break; + case XML_TOK_DATABASE_RANGE_SUBTOTAL_RULES : + { + bContainsSubTotal = sal_True; + pContext = new ScXMLSubTotalRulesContext( GetScImport(), nPrefix, + rLName, xAttrList, this); + } + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLDatabaseRangeContext::EndElement() +{ + if (GetScImport().GetModel().is()) + { + uno::Reference <beans::XPropertySet> xPropertySet( GetScImport().GetModel(), uno::UNO_QUERY ); + ScDocument* pDoc = GetScImport().GetDocument(); + if (pDoc && xPropertySet.is()) + { + uno::Any aDatabaseRanges = xPropertySet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DATABASERNG))); + uno::Reference <sheet::XDatabaseRanges> xDatabaseRanges; + if (aDatabaseRanges >>= xDatabaseRanges) + { + table::CellRangeAddress aCellRangeAddress; + sal_Int32 nOffset(0); + if (ScXMLConverter::GetRangeFromString( aCellRangeAddress, sRangeAddress, pDoc, nOffset )) + { + sal_Bool bInsert(sal_True); + try + { + xDatabaseRanges->addNewByName(sDatabaseRangeName, aCellRangeAddress); + } + catch ( uno::RuntimeException& rRuntimeException ) + { + bInsert = sal_False; + ::rtl::OUString sErrorMessage(RTL_CONSTASCII_USTRINGPARAM("DatabaseRange ")); + sErrorMessage += sDatabaseRangeName; + sErrorMessage += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" could not be created with the range ")); + sErrorMessage += sRangeAddress; + uno::Sequence<rtl::OUString> aSeq(1); + aSeq[0] = sErrorMessage; + uno::Reference<xml::sax::XLocator> xLocator; + GetScImport().SetError(XMLERROR_API | XMLERROR_FLAG_ERROR, aSeq, rRuntimeException.Message, xLocator); + } + if (bInsert) + { + uno::Any aDatabaseRange = xDatabaseRanges->getByName(sDatabaseRangeName); + uno::Reference <sheet::XDatabaseRange> xDatabaseRange; + if (aDatabaseRange >>= xDatabaseRange) + { + uno::Reference <beans::XPropertySet> xDatabaseRangePropertySet (xDatabaseRange, uno::UNO_QUERY); + if (xDatabaseRangePropertySet.is()) + { + uno::Any aTempValue; + aTempValue = ::cppu::bool2any(bKeepFormats); + xDatabaseRangePropertySet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_KEEPFORM)), aTempValue); + aTempValue = ::cppu::bool2any(bMoveCells); + xDatabaseRangePropertySet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_MOVCELLS)), aTempValue); + aTempValue = ::cppu::bool2any(bStripData); + xDatabaseRangePropertySet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_STRIPDAT)), aTempValue); + } + uno::Sequence <beans::PropertyValue> aImportDescriptor = xDatabaseRange->getImportDescriptor(); + sal_Int32 nImportProperties = aImportDescriptor.getLength(); + for (sal_Int16 i = 0; i < nImportProperties; i++) + { + if (aImportDescriptor[i].Name == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_DBNAME))) + { + uno::Any aDatabaseName; + aDatabaseName <<= sDatabaseName; + aImportDescriptor[i].Value = aDatabaseName; + } + else if (aImportDescriptor[i].Name == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_SRCOBJ))) + { + uno::Any aSourceObject; + aSourceObject <<= sSourceObject; + aImportDescriptor[i].Value = aSourceObject; + } + else if (aImportDescriptor[i].Name == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_SRCTYPE))) + { + uno::Any aSourceType; + aSourceType <<= nSourceType; + aImportDescriptor[i].Value = aSourceType; + } + else if (aImportDescriptor[i].Name == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_NATIVE))) + { + uno::Any aNative; + aNative = ::cppu::bool2any(bNative); + aImportDescriptor[i].Value = aNative; + } + } + ScDBCollection* pDBCollection = pDoc->GetDBCollection(); + sal_uInt16 nIndex; + pDBCollection->SearchName(sDatabaseRangeName, nIndex); + ScDBData* pDBData = (*pDBCollection)[nIndex]; + pDBData->SetImportSelection(bIsSelection); + pDBData->SetAutoFilter(bAutoFilter); + if (bAutoFilter) + pDoc->ApplyFlagsTab( static_cast<USHORT>(aCellRangeAddress.StartColumn), static_cast<USHORT>(aCellRangeAddress.StartRow), + static_cast<USHORT>(aCellRangeAddress.EndColumn), static_cast<USHORT>(aCellRangeAddress.StartRow), + aCellRangeAddress.Sheet, SC_MF_AUTO ); + ScImportParam aImportParam; + ScImportDescriptor::FillImportParam(aImportParam, aImportDescriptor); + pDBData->SetImportParam(aImportParam); + if (bContainsSort) + { + sal_uInt32 nOldSize(aSortSequence.getLength()); + aSortSequence.realloc(nOldSize + 1); + beans::PropertyValue aProperty; + aProperty.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ORIENT)); + aProperty.Value <<= eOrientation; + aSortSequence[nOldSize] = aProperty; + ScSortParam aSortParam; + ScSortDescriptor::FillSortParam(aSortParam, aSortSequence); + + //#98317#; until now the Fields are relative to the left top edge of the range, but the + // core wants to have the absolute position (column/row) + sal_uInt16 nFieldStart = aSortParam.bByRow ? aCellRangeAddress.StartColumn : aCellRangeAddress.StartRow; + for (sal_uInt16 i = 0; i < MAXSORT; ++i) + { + if (aSortParam.bDoSort[i]) + aSortParam.nField[i] += nFieldStart; + } + + pDBData->SetSortParam(aSortParam); + } + uno::Reference <sheet::XSheetFilterDescriptor> xSheetFilterDescriptor = xDatabaseRange->getFilterDescriptor(); + if (xSheetFilterDescriptor.is()) + { + uno::Reference <beans::XPropertySet> xFilterPropertySet (xSheetFilterDescriptor, uno::UNO_QUERY); + if (xFilterPropertySet.is()) + { + uno::Any aTemp; + sal_Bool bOrientation(table::TableOrientation_COLUMNS == eOrientation); + aTemp = ::cppu::bool2any(bOrientation); + xFilterPropertySet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ORIENT)), aTemp); + aTemp = ::cppu::bool2any(bContainsHeader); + xFilterPropertySet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_CONTHDR)), aTemp); + aTemp = ::cppu::bool2any(bFilterCopyOutputData); + xFilterPropertySet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_COPYOUT)), aTemp); + aTemp = ::cppu::bool2any(bFilterIsCaseSensitive); + xFilterPropertySet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ISCASE)), aTemp); + aTemp = ::cppu::bool2any(bFilterSkipDuplicates); + xFilterPropertySet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_SKIPDUP)), aTemp); + aTemp = ::cppu::bool2any(bFilterUseRegularExpressions); + xFilterPropertySet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_USEREGEX)), aTemp); + aTemp <<= aFilterOutputPosition; + xFilterPropertySet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_OUTPOS)), aTemp); + } + xSheetFilterDescriptor->setFilterFields(aFilterFields); + if (bFilterConditionSourceRange) + { + ScRange aAdvSource; + ScUnoConversion::FillScRange( aAdvSource, aFilterConditionSourceRangeAddress ); + pDBData->SetAdvancedQuerySource(&aAdvSource); + } + } + if (bContainsSubTotal) + { + uno::Reference <sheet::XSubTotalDescriptor> xSubTotalDescriptor = xDatabaseRange->getSubTotalDescriptor(); + if (xSubTotalDescriptor.is()) + { + uno::Reference <beans::XPropertySet> xSubTotalPropertySet (xSubTotalDescriptor, uno::UNO_QUERY); + if( xSubTotalPropertySet.is()) + { + uno::Any aTemp; + aTemp = ::cppu::bool2any(bSubTotalsBindFormatsToContent); + xSubTotalPropertySet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_BINDFMT)), aTemp); + aTemp = ::cppu::bool2any(bSubTotalsEnabledUserList); + xSubTotalPropertySet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ENABLEUSERSORTLIST)), aTemp); + aTemp <<= nSubTotalsUserListIndex; + xSubTotalPropertySet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_USERSORTLISTINDEX)), aTemp); + aTemp = ::cppu::bool2any(bSubTotalsInsertPageBreaks); + xSubTotalPropertySet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_INSBRK)), aTemp); + aTemp = ::cppu::bool2any(bSubTotalsIsCaseSensitive); + xSubTotalPropertySet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ISCASE)), aTemp); + } + ScSubTotalParam aSubTotalParam; + aSubTotalParam.bDoSort = bSubTotalsSortGroups; + aSubTotalParam.bAscending = bSubTotalsAscending; + aSubTotalParam.bUserDef = bSubTotalsEnabledUserList; + aSubTotalParam.nUserIndex = nSubTotalsUserListIndex; + pDBData->SetSubTotalParam(aSubTotalParam); + xSubTotalDescriptor->addNew(aSubTotalColumns, nSubTotalRuleGroupFieldNumber); + } + } + if ( pDBData->HasImportParam() && !pDBData->HasImportSelection() ) + { + pDBData->SetRefreshDelay( nRefresh ); + pDBData->SetRefreshHandler( pDBCollection->GetRefreshHandler() ); + pDBData->SetRefreshControl( pDoc->GetRefreshTimerControlAddress() ); + } + } + } + } + } + } + } +} + +ScXMLSourceSQLContext::ScXMLSourceSQLContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDatabaseRangeContext* pTempDatabaseRangeContext) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + pDatabaseRangeContext = pTempDatabaseRangeContext; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDatabaseRangeSourceSQLAttrTokenMap(); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_SOURCE_SQL_ATTR_DATABASE_NAME : + { + pDatabaseRangeContext->SetDatabaseName(sValue); + } + break; + case XML_TOK_SOURCE_SQL_ATTR_SQL_STATEMENT : + { + pDatabaseRangeContext->SetSourceObject(sValue); + } + break; + case XML_TOK_SOURCE_SQL_ATTR_PARSE_SQL_STATEMENT : + { + pDatabaseRangeContext->SetNative(IsXMLToken(sValue, XML_TRUE)); + } + break; + } + } + pDatabaseRangeContext->SetSourceType(sheet::DataImportMode_SQL); +} + +ScXMLSourceSQLContext::~ScXMLSourceSQLContext() +{ +} + +SvXMLImportContext *ScXMLSourceSQLContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLSourceSQLContext::EndElement() +{ +} + +ScXMLSourceTableContext::ScXMLSourceTableContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDatabaseRangeContext* pTempDatabaseRangeContext) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + pDatabaseRangeContext = pTempDatabaseRangeContext; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDatabaseRangeSourceTableAttrTokenMap(); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_SOURCE_TABLE_ATTR_DATABASE_NAME : + { + pDatabaseRangeContext->SetDatabaseName(sValue); + } + break; + case XML_TOK_SOURCE_TABLE_ATTR_TABLE_NAME : + { + pDatabaseRangeContext->SetSourceObject(sValue); + } + break; + } + } + pDatabaseRangeContext->SetSourceType(sheet::DataImportMode_TABLE); +} + +ScXMLSourceTableContext::~ScXMLSourceTableContext() +{ +} + +SvXMLImportContext *ScXMLSourceTableContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLSourceTableContext::EndElement() +{ +} + +ScXMLSourceQueryContext::ScXMLSourceQueryContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDatabaseRangeContext* pTempDatabaseRangeContext) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + pDatabaseRangeContext = pTempDatabaseRangeContext; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDatabaseRangeSourceQueryAttrTokenMap(); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_SOURCE_QUERY_ATTR_DATABASE_NAME : + { + pDatabaseRangeContext->SetDatabaseName(sValue); + } + break; + case XML_TOK_SOURCE_QUERY_ATTR_QUERY_NAME : + { + pDatabaseRangeContext->SetSourceObject(sValue); + } + break; + } + } + pDatabaseRangeContext->SetSourceType(sheet::DataImportMode_QUERY); +} + +ScXMLSourceQueryContext::~ScXMLSourceQueryContext() +{ +} + +SvXMLImportContext *ScXMLSourceQueryContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLSourceQueryContext::EndElement() +{ +} + +ScXMLSubTotalRulesContext::ScXMLSubTotalRulesContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDatabaseRangeContext* pTempDatabaseRangeContext) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + pDatabaseRangeContext = pTempDatabaseRangeContext; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDatabaseRangeSubTotalRulesAttrTokenMap(); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_SUBTOTAL_RULES_ATTR_BIND_STYLES_TO_CONTENT : + { + pDatabaseRangeContext->SetSubTotalsBindFormatsToContent(IsXMLToken(sValue, XML_TRUE)); + } + break; + case XML_TOK_SUBTOTAL_RULES_ATTR_CASE_SENSITIVE : + { + pDatabaseRangeContext->SetSubTotalsIsCaseSensitive(IsXMLToken(sValue, XML_TRUE)); + } + break; + case XML_TOK_SUBTOTAL_RULES_ATTR_PAGE_BREAKS_ON_GROUP_CHANGE : + { + pDatabaseRangeContext->SetSubTotalsInsertPageBreaks(IsXMLToken(sValue, XML_TRUE)); + } + break; + } + } +} + +ScXMLSubTotalRulesContext::~ScXMLSubTotalRulesContext() +{ +} + +SvXMLImportContext *ScXMLSubTotalRulesContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + const SvXMLTokenMap& rTokenMap = GetScImport().GetDatabaseRangeSubTotalRulesElemTokenMap(); + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + case XML_TOK_SUBTOTAL_RULES_SORT_GROUPS : + { + pContext = new ScXMLSortGroupsContext( GetScImport(), nPrefix, + rLName, xAttrList, pDatabaseRangeContext); + } + break; + case XML_TOK_SUBTOTAL_RULES_SUBTOTAL_RULE : + { + pContext = new ScXMLSubTotalRuleContext( GetScImport(), nPrefix, + rLName, xAttrList, pDatabaseRangeContext); + } + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLSubTotalRulesContext::EndElement() +{ +} + +ScXMLSortGroupsContext::ScXMLSortGroupsContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDatabaseRangeContext* pTempDatabaseRangeContext) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + pDatabaseRangeContext = pTempDatabaseRangeContext; + pDatabaseRangeContext->SetSubTotalsSortGroups(sal_True); + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetSubTotalRulesSortGroupsAttrTokenMap(); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_SORT_GROUPS_ATTR_DATA_TYPE : + { + if (sValue.getLength() > 8) + { + ::rtl::OUString sTemp = sValue.copy(0, 8); + if (sTemp.compareToAscii(SC_USERLIST) == 0) + { + pDatabaseRangeContext->SetSubTotalsEnabledUserList(sal_True); + sTemp = sValue.copy(8); + pDatabaseRangeContext->SetSubTotalsUserListIndex(static_cast<sal_Int16>(sTemp.toInt32())); + } + else + { + //if (IsXMLToken(sValue, XML_AUTOMATIC)) + //aSortField.FieldType = util::SortFieldType_AUTOMATIC; + // is not supported by StarOffice + } + } + else + { + //if (IsXMLToken(sValue, XML_TEXT)) + //aSortField.FieldType = util::SortFieldType_ALPHANUMERIC; + // is not supported by StarOffice + //else if (IsXMLToken(sValue, XML_NUMBER)) + //aSortField.FieldType = util::SortFieldType_NUMERIC; + // is not supported by StarOffice + } + } + break; + case XML_TOK_SORT_GROUPS_ATTR_ORDER : + { + if (IsXMLToken(sValue, XML_ASCENDING)) + pDatabaseRangeContext->SetSubTotalsAscending(sal_True); + else + pDatabaseRangeContext->SetSubTotalsAscending(sal_False); + } + break; + } + } +} + +ScXMLSortGroupsContext::~ScXMLSortGroupsContext() +{ +} + +SvXMLImportContext *ScXMLSortGroupsContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLSortGroupsContext::EndElement() +{ +} + +ScXMLSubTotalRuleContext::ScXMLSubTotalRuleContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDatabaseRangeContext* pTempDatabaseRangeContext) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + pDatabaseRangeContext = pTempDatabaseRangeContext; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetSubTotalRulesSubTotalRuleAttrTokenMap(); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_SUBTOTAL_RULE_ATTR_GROUP_BY_FIELD_NUMBER : + { + pDatabaseRangeContext->SetSubTotalRuleGroupFieldNumber(static_cast<sal_Int16>(sValue.toInt32())); + } + break; + } + } +} + +ScXMLSubTotalRuleContext::~ScXMLSubTotalRuleContext() +{ +} + +SvXMLImportContext *ScXMLSubTotalRuleContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + const SvXMLTokenMap& rTokenMap = GetScImport().GetSubTotalRulesSubTotalRuleElemTokenMap(); + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + case XML_TOK_SUBTOTAL_RULE_SUBTOTAL_FIELD : + { + pContext = new ScXMLSubTotalFieldContext( GetScImport(), nPrefix, + rLName, xAttrList, pDatabaseRangeContext); + } + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLSubTotalRuleContext::EndElement() +{ +} + +ScXMLSubTotalFieldContext::ScXMLSubTotalFieldContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDatabaseRangeContext* pTempDatabaseRangeContext) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + pDatabaseRangeContext = pTempDatabaseRangeContext; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetSubTotalRuleSubTotalFieldAttrTokenMap(); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_SUBTOTAL_FIELD_ATTR_FIELD_NUMBER : + { + sFieldNumber = sValue; + } + break; + case XML_TOK_SUBTOTAL_FIELD_ATTR_FUNCTION : + { + sFunction = sValue; + } + break; + } + } +} + +ScXMLSubTotalFieldContext::~ScXMLSubTotalFieldContext() +{ +} + +SvXMLImportContext *ScXMLSubTotalFieldContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLSubTotalFieldContext::EndElement() +{ + sheet::SubTotalColumn aSubTotalColumn; + aSubTotalColumn.Column = sFieldNumber.toInt32(); + aSubTotalColumn.Function = ScXMLConverter::GetFunctionFromString( sFunction ); + pDatabaseRangeContext->AddSubTotalColumn(aSubTotalColumn); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_xmlexprt.cxx b/binfilter/bf_sc/source/filter/xml/sc_xmlexprt.cxx new file mode 100644 index 000000000000..3f28816f69e1 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_xmlexprt.cxx @@ -0,0 +1,3211 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#define ITEMID_FIELD EE_FEATURE_FIELD + + +#include "XMLConverter.hxx" +#include "xmlstyle.hxx" +#include "unonames.hxx" +#include "document.hxx" +#include "olinetab.hxx" +#include "cellsuno.hxx" +#include "cell.hxx" +#include "rangenam.hxx" +#include "XMLTableMasterPageExport.hxx" +#include "drwlayer.hxx" +#include "XMLExportDataPilot.hxx" +#include "XMLExportDatabaseRanges.hxx" +#include "XMLExportDDELinks.hxx" +#include "XMLExportIterator.hxx" +#include "XMLColumnRowGroupExport.hxx" +#include "XMLStylesExportHelper.hxx" +#include "XMLChangeTrackingExportHelper.hxx" +#include "docoptio.hxx" +#include "XMLExportSharedData.hxx" +#include "chgviset.hxx" +#include "docuno.hxx" +#include "chartlis.hxx" +#include "scitems.hxx" +#include "docpool.hxx" + +#include <bf_xmloff/xmlnmspe.hxx> +#include <bf_xmloff/nmspmap.hxx> +#include <bf_xmloff/numehelp.hxx> +#include <bf_xmloff/xmluconv.hxx> +#include <bf_xmloff/xmlcnitm.hxx> + + +#include <rtl/math.hxx> +#include <bf_svtools/zforlist.hxx> +#include <bf_svx/unoshape.hxx> +#include <comphelper/extract.hxx> +#include <bf_so3/embobj.hxx> +#include <vcl/svapp.hxx> + +#include <com/sun/star/sheet/XUsedAreaCursor.hpp> +#include <com/sun/star/sheet/XAreaLinks.hpp> +#include <com/sun/star/sheet/XAreaLink.hpp> +#include <com/sun/star/sheet/CellFlags.hpp> +#include <com/sun/star/sheet/XLabelRanges.hpp> +#include <com/sun/star/sheet/XLabelRange.hpp> +#include <com/sun/star/sheet/XNamedRanges.hpp> +#include <com/sun/star/sheet/XNamedRange.hpp> +#include <com/sun/star/sheet/XCellRangeReferrer.hpp> +#include <com/sun/star/sheet/NamedRangeFlag.hpp> +#include <com/sun/star/form/XFormsSupplier.hpp> +#include <legacysmgr/legacy_binfilters_smgr.hxx> //STRIP002 +namespace binfilter { +//! not found in unonames.hxx +#define SC_STANDARDFORMAT "StandardFormat" +#define SC_LAYERID "LayerID" + +#define SC_DEFAULT_TABLE_COUNT 3 +#define SC_VIEWCHANGES_COUNT 13 +#define SC_SHOW_CHANGES 0 +#define SC_SHOW_ACCEPTED_CHANGES 1 +#define SC_SHOW_REJECTED_CHANGES 2 +#define SC_SHOW_CHANGES_BY_DATETIME 3 +#define SC_SHOW_CHANGES_BY_DATETIME_MODE 4 +#define SC_SHOW_CHANGES_BY_DATETIME_FIRST_DATETIME 5 +#define SC_SHOW_CHANGES_BY_DATETIME_SECOND_DATETIME 6 +#define SC_SHOW_CHANGES_BY_AUTHOR 7 +#define SC_SHOW_CHANGES_BY_AUTHOR_NAME 8 +#define SC_SHOW_CHANGES_BY_COMMENT 9 +#define SC_SHOW_CHANGES_BY_COMMENT_TEXT 10 +#define SC_SHOW_CHANGES_BY_RANGES 11 +#define SC_SHOW_CHANGES_BY_RANGES_LIST 12 + +using namespace ::rtl; +using namespace ::com::sun::star; +using namespace ::binfilter::xmloff::token; + +//---------------------------------------------------------------------------- + +OUString SAL_CALL ScXMLExport_getImplementationName() throw() +{ + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Calc.XMLExporter" ) ); +} + +uno::Sequence< ::rtl::OUString > SAL_CALL ScXMLExport_getSupportedServiceNames() throw() +{ + const ::rtl::OUString aServiceName( ScXMLExport_getImplementationName() ); + const uno::Sequence< ::rtl::OUString > aSeq( &aServiceName, 1 ); + return aSeq; +} + +uno::Reference< uno::XInterface > SAL_CALL ScXMLExport_createInstance( + const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception ) +{ + // #110680# + // return (cppu::OWeakObject*)new ScXMLExport(EXPORT_ALL); + return (cppu::OWeakObject*)new ScXMLExport( rSMgr, EXPORT_ALL ); +} + +OUString SAL_CALL ScXMLExport_Meta_getImplementationName() throw() +{ + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Calc.XMLMetaExporter" ) ); +} + +uno::Sequence< ::rtl::OUString > SAL_CALL ScXMLExport_Meta_getSupportedServiceNames() throw() +{ + const ::rtl::OUString aServiceName( ScXMLExport_Meta_getImplementationName() ); + const uno::Sequence< ::rtl::OUString > aSeq( &aServiceName, 1 ); + return aSeq; +} + +uno::Reference< uno::XInterface > SAL_CALL ScXMLExport_Meta_createInstance( + const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception ) +{ + // #110680# + // return (cppu::OWeakObject*)new ScXMLExport(EXPORT_META); + return (cppu::OWeakObject*)new ScXMLExport( rSMgr, EXPORT_META ); +} + +OUString SAL_CALL ScXMLExport_Styles_getImplementationName() throw() +{ + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Calc.XMLStylesExporter" ) ); +} + +uno::Sequence< ::rtl::OUString > SAL_CALL ScXMLExport_Styles_getSupportedServiceNames() throw() +{ + const ::rtl::OUString aServiceName( ScXMLExport_Styles_getImplementationName() ); + const uno::Sequence< ::rtl::OUString > aSeq( &aServiceName, 1 ); + return aSeq; +} + +uno::Reference< uno::XInterface > SAL_CALL ScXMLExport_Styles_createInstance( + const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception ) +{ + // #110680# + // return (cppu::OWeakObject*)new ScXMLExport(EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_FONTDECLS); + return (cppu::OWeakObject*)new ScXMLExport( rSMgr, EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_FONTDECLS); +} + +OUString SAL_CALL ScXMLExport_Content_getImplementationName() throw() +{ + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Calc.XMLContentExporter" ) ); +} + +uno::Sequence< ::rtl::OUString > SAL_CALL ScXMLExport_Content_getSupportedServiceNames() throw() +{ + const ::rtl::OUString aServiceName( ScXMLExport_Content_getImplementationName() ); + const uno::Sequence< ::rtl::OUString > aSeq( &aServiceName, 1 ); + return aSeq; +} + +uno::Reference< uno::XInterface > SAL_CALL ScXMLExport_Content_createInstance( + const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception ) +{ + // #110680# + // return (cppu::OWeakObject*)new ScXMLExport(EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_FONTDECLS); + return (cppu::OWeakObject*)new ScXMLExport( rSMgr, EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_FONTDECLS); +} + +OUString SAL_CALL ScXMLExport_Settings_getImplementationName() throw() +{ + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Calc.XMLSettingsExporter" ) ); +} + +uno::Sequence< ::rtl::OUString > SAL_CALL ScXMLExport_Settings_getSupportedServiceNames() throw() +{ + const ::rtl::OUString aServiceName( ScXMLExport_Settings_getImplementationName() ); + const uno::Sequence< ::rtl::OUString > aSeq( &aServiceName, 1 ); + return aSeq; +} + +uno::Reference< uno::XInterface > SAL_CALL ScXMLExport_Settings_createInstance( + const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception ) +{ + // #110680# + // return (cppu::OWeakObject*)new ScXMLExport(EXPORT_SETTINGS); + return (cppu::OWeakObject*)new ScXMLExport( rSMgr, EXPORT_SETTINGS ); +} + +//---------------------------------------------------------------------------- + +class ScXMLShapeExport : public XMLShapeExport +{ +public: + ScXMLShapeExport(SvXMLExport& rExp) : XMLShapeExport(rExp) {} + ~ScXMLShapeExport(); + + /** is called before a shape element for the given XShape is exported */ + virtual void onExport( const uno::Reference < drawing::XShape >& xShape ); +}; + +ScXMLShapeExport::~ScXMLShapeExport() +{ +} + +void ScXMLShapeExport::onExport( const uno::Reference < drawing::XShape >& xShape ) +{ + uno::Reference< beans::XPropertySet > xShapeProp( xShape, uno::UNO_QUERY ); + if( xShapeProp.is() ) + { + sal_Int16 nLayerID; + if( (xShapeProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_LAYERID ))) >>= nLayerID) && (nLayerID == SC_LAYER_BACK) ) + GetExport().AddAttribute(XML_NAMESPACE_TABLE, XML_TABLE_BACKGROUND, XML_TRUE); + } +} + +//---------------------------------------------------------------------------- + +sal_Int16 ScXMLExport::GetFieldUnit() +{ + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> xProperties( + ::legacy_binfilters::getLegacyProcessServiceFactory()->createInstance( + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.GlobalSheetSettings" )) ), + ::com::sun::star::uno::UNO_QUERY); + if (xProperties.is()) + { + ::com::sun::star::uno::Any aAny = xProperties->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Metric"))); + sal_Int16 nFieldUnit; + if (aAny >>= nFieldUnit) + return nFieldUnit; + } + return 0; +} + + +// #110680# +ScXMLExport::ScXMLExport( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory, + const sal_uInt16 nExportFlag) +: SvXMLExport( xServiceFactory, SvXMLUnitConverter::GetMapUnit(GetFieldUnit()), XML_SPREADSHEET, nExportFlag ), + pDoc(NULL), + mbShowProgress( sal_False ), + pSharedData(NULL), + pColumnStyles(NULL), + pRowStyles(NULL), + pCellStyles(NULL), + pMergedRangesContainer(NULL), + pValidationsContainer(NULL), + pRowFormatRanges(NULL), + pCellsItr(NULL), + pChangeTrackingExportHelper(NULL), + pDefaults(NULL), + pNumberFormatAttributesExportHelper(NULL), + pGroupColumns (NULL), + pGroupRows (NULL), + nOpenRow(-1), + nCurrentTable(0), + aTableStyles(), + bHasRowHeader(sal_False), + bRowHeaderOpen(sal_False), + sLayerID(RTL_CONSTASCII_USTRINGPARAM( SC_LAYERID )), + sCaptionShape(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.CaptionShape")), + pChartListener(NULL) +{ + if (getExportFlags() & EXPORT_CONTENT) + { + pGroupColumns = new ScMyOpenCloseColumnRowGroup(*this, XML_TABLE_COLUMN_GROUP); + pGroupRows = new ScMyOpenCloseColumnRowGroup(*this, XML_TABLE_ROW_GROUP); + pColumnStyles = new ScColumnStyles(); + pRowStyles = new ScRowStyles(); + pRowFormatRanges = new ScRowFormatRanges(); + pMergedRangesContainer = new ScMyMergedRangesContainer(); + pValidationsContainer = new ScMyValidationsContainer(); + pCellsItr = new ScMyNotEmptyCellsIterator(*this); + pDefaults = new ScMyDefaultStyles(); + } + pCellStyles = new ScFormatRangeStyles(); + + // document is not set here - create ScChangeTrackingExportHelper later + + xScPropHdlFactory = new XMLScPropHdlFactory; + xCellStylesPropertySetMapper = new XMLPropertySetMapper((XMLPropertyMapEntry*)aXMLScCellStylesProperties, xScPropHdlFactory); + xColumnStylesPropertySetMapper = new XMLPropertySetMapper((XMLPropertyMapEntry*)aXMLScColumnStylesProperties, xScPropHdlFactory); + xRowStylesPropertySetMapper = new XMLPropertySetMapper((XMLPropertyMapEntry*)aXMLScRowStylesProperties, xScPropHdlFactory); + xTableStylesPropertySetMapper = new XMLPropertySetMapper((XMLPropertyMapEntry*)aXMLScTableStylesProperties, xScPropHdlFactory); + xCellStylesExportPropertySetMapper = new ScXMLCellExportPropertyMapper(xCellStylesPropertySetMapper); + xCellStylesExportPropertySetMapper->ChainExportMapper(XMLTextParagraphExport::CreateCharExtPropMapper(*this)); + xColumnStylesExportPropertySetMapper = new ScXMLColumnExportPropertyMapper(xColumnStylesPropertySetMapper); + xRowStylesExportPropertySetMapper = new ScXMLRowExportPropertyMapper(xRowStylesPropertySetMapper); + xTableStylesExportPropertySetMapper = new ScXMLTableExportPropertyMapper(xTableStylesPropertySetMapper); + + GetAutoStylePool()->AddFamily(XML_STYLE_FAMILY_TABLE_CELL, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_CELL_STYLES_NAME)), + xCellStylesExportPropertySetMapper, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_CELL_STYLES_PREFIX))); + GetAutoStylePool()->AddFamily(XML_STYLE_FAMILY_TABLE_COLUMN, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_NAME)), + xColumnStylesExportPropertySetMapper, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_PREFIX))); + GetAutoStylePool()->AddFamily(XML_STYLE_FAMILY_TABLE_ROW, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_ROW_STYLES_NAME)), + xRowStylesExportPropertySetMapper, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_ROW_STYLES_PREFIX))); + GetAutoStylePool()->AddFamily(XML_STYLE_FAMILY_TABLE_TABLE, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_TABLE_STYLES_NAME)), + xTableStylesExportPropertySetMapper, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_TABLE_STYLES_PREFIX))); + + if( (getExportFlags() & (EXPORT_STYLES|EXPORT_AUTOSTYLES|EXPORT_MASTERSTYLES|EXPORT_CONTENT) ) != 0 ) + { + sAttrName = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_NAME)); + sAttrStyleName = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_STYLE_NAME)); + sAttrColumnsRepeated = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_NUMBER_COLUMNS_REPEATED)); + sAttrFormula = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_FORMULA)); + sAttrStringValue = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_STRING_VALUE)); + sElemCell = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_TABLE_CELL)); + sElemCoveredCell = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_COVERED_TABLE_CELL)); + sElemCol = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_TABLE_COLUMN)); + sElemRow = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_TABLE_ROW)); + sElemTab = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_TABLE)); + sElemP = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TEXT, GetXMLToken(XML_P)); + } +} + + +ScXMLExport::~ScXMLExport() +{ + if (pGroupColumns) + delete pGroupColumns; + if (pGroupRows) + delete pGroupRows; + if (pColumnStyles) + delete pColumnStyles; + if (pRowStyles) + delete pRowStyles; + if (pCellStyles) + delete pCellStyles; + if (pRowFormatRanges) + delete pRowFormatRanges; + if (pMergedRangesContainer) + delete pMergedRangesContainer; + if (pValidationsContainer) + delete pValidationsContainer; + if (pChangeTrackingExportHelper) + delete pChangeTrackingExportHelper; + if (pChartListener) + delete pChartListener; + if (pCellsItr) + delete pCellsItr; + if (pDefaults) + delete pDefaults; + if (pNumberFormatAttributesExportHelper) + delete pNumberFormatAttributesExportHelper; +} + +sal_Bool ScXMLExport::HasDrawPages(uno::Reference <sheet::XSpreadsheetDocument>& xDoc) +{ + sal_Bool bRet(sal_False); + uno::Reference <beans::XPropertySet> xDocProps( xDoc, uno::UNO_QUERY ); + if (xDocProps.is()) + { + uno::Any aAny(xDocProps->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_HASDRAWPAGES)))); + bRet = ::cppu::any2bool( aAny ); + } + return bRet; +} + +void ScXMLExport::CollectSharedData(sal_Int32& nTableCount, sal_Int32& nShapesCount, const sal_Int32 nCellCount) +{ + if (GetModel().is()) + { + uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( GetModel(), uno::UNO_QUERY ); + if ( xSpreadDoc.is()) + { + uno::Reference<sheet::XSpreadsheets> xSheets = xSpreadDoc->getSheets(); + uno::Reference<container::XIndexAccess> xIndex( xSheets, uno::UNO_QUERY ); + if ( xIndex.is() ) + { + nTableCount = xIndex->getCount(); + if (!pSharedData) + CreateSharedData(nTableCount); + pCellStyles->AddNewTable(nTableCount - 1); + if (HasDrawPages(xSpreadDoc)) + { + ::rtl::OUString sCaptionPoint( RTL_CONSTASCII_USTRINGPARAM( "CaptionPoint" )); + for (sal_Int32 nTable = 0; nTable < nTableCount; nTable++) + { + uno::Any aTable = xIndex->getByIndex(nTable); + uno::Reference<sheet::XSpreadsheet> xTable; + if (aTable>>=xTable) + { + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xTable, uno::UNO_QUERY); + if (xDrawPageSupplier.is()) + { + uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); + ScMyDrawPage aDrawPage; + aDrawPage.bHasForms = sal_False; + aDrawPage.xDrawPage = xDrawPage; + pSharedData->AddDrawPage(aDrawPage, nTable); + uno::Reference<container::XIndexAccess> xShapesIndex (xDrawPage, uno::UNO_QUERY); + if (xShapesIndex.is()) + { + sal_Int32 nShapes = xShapesIndex->getCount(); + for (sal_Int32 nShape = 0; nShape < nShapes; nShape++) + { + uno::Any aShape = xShapesIndex->getByIndex(nShape); + uno::Reference<drawing::XShape> xShape; + if (aShape >>= xShape) + { + uno::Reference< beans::XPropertySet > xShapeProp( xShape, uno::UNO_QUERY ); + if( xShapeProp.is() ) + { + uno::Any aPropAny = xShapeProp->getPropertyValue(sLayerID); + sal_Int16 nLayerID; + if( aPropAny >>= nLayerID ) + { + if( nLayerID == SC_LAYER_INTERN ) + CollectInternalShape( xShape ); + else + { + nShapesCount++; + SvxShape* pShapeImp = SvxShape::getImplementation(xShape); + if (pShapeImp) + { + SdrObject *pSdrObj = pShapeImp->GetSdrObject(); + if (pSdrObj) + { + if (ScDrawLayer::GetAnchor(pSdrObj) == SCA_CELL) + { + if (pDoc) + { + + awt::Point aPoint(xShape->getPosition()); + awt::Size aSize(xShape->getSize()); + ::rtl::OUString sType(xShape->getShapeType()); + Rectangle aRectangle(aPoint.X, aPoint.Y, aPoint.X + aSize.Width, aPoint.Y + aSize.Height); + if ( sType.equals(sCaptionShape) ) + { + awt::Point aRelativeCaptionPoint; + xShapeProp->getPropertyValue( sCaptionPoint ) >>= aRelativeCaptionPoint; + Point aCoreRelativeCaptionPoint(aRelativeCaptionPoint.X, aRelativeCaptionPoint.Y); + Point aCoreAbsoluteCaptionPoint(aPoint.X, aPoint.Y); + aCoreAbsoluteCaptionPoint += aCoreRelativeCaptionPoint; + aRectangle.Union(Rectangle(aCoreAbsoluteCaptionPoint, aCoreAbsoluteCaptionPoint)); + } + ScRange aRange = pDoc->GetRange(static_cast<USHORT>(nTable), aRectangle); + ScMyShape aMyShape; + aMyShape.aAddress = aRange.aStart; + aMyShape.aEndAddress = aRange.aEnd; + aMyShape.xShape = xShape; + aMyShape.nLayerID = nLayerID; + pSharedData->AddNewShape(aMyShape); + pSharedData->SetLastColumn(nTable, aRange.aStart.Col()); + pSharedData->SetLastRow(nTable, aRange.aStart.Row()); + } + } + else + pSharedData->AddTableShape(nTable, xShape); + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + sal_Int32 nRef(nCellCount + (2 * nTableCount) + (2 * nShapesCount)); + GetProgressBarHelper()->SetReference(nRef); + GetProgressBarHelper()->SetValue(0); +} + +void ScXMLExport::CollectShapesAutoStyles(const sal_Int32 nTableCount) +{ + pSharedData->SortShapesContainer(); + const ScMyShapeList* pShapeList = NULL; + ScMyShapeList::const_iterator aShapeItr; + if (pSharedData->GetShapesContainer()) + { + pShapeList = pSharedData->GetShapesContainer()->GetShapes(); + aShapeItr = pShapeList->begin(); + } + if (pSharedData->HasDrawPage()) + { + for (sal_Int32 nTable = 0; nTable < nTableCount; nTable++) + { + uno::Reference<drawing::XDrawPage> xDrawPage(pSharedData->GetDrawPage(nTable)); + uno::Reference<drawing::XShapes> xShapes (xDrawPage, uno::UNO_QUERY); + if (xShapes.is()) + { + GetShapeExport()->seekShapes(xShapes); + uno::Reference< form::XFormsSupplier > xFormsSupplier( xDrawPage, uno::UNO_QUERY ); + if( xFormsSupplier.is() ) + { + uno::Reference< container::XNameContainer > xForms( xFormsSupplier->getForms() ); + if( xForms.is() && xForms->hasElements() ) + { + GetFormExport()->examineForms(xDrawPage); + pSharedData->SetDrawPageHasForms(nTable, sal_True); + } + } + ScMyTableShapes* pTableShapes = pSharedData->GetTableShapes(); + if (pTableShapes) + { + ScMyTableXShapes::iterator aItr = (*pTableShapes)[nTable].begin(); + while (aItr != (*pTableShapes)[nTable].end()) + { + GetShapeExport()->collectShapeAutoStyles(*aItr); + GetProgressBarHelper()->Increment(); + aItr++; + } + } + if (pShapeList) + { + while (aShapeItr != pShapeList->end() && (static_cast<sal_Int32>(aShapeItr->aAddress.Tab()) == nTable)) + { + GetShapeExport()->collectShapeAutoStyles(aShapeItr->xShape); + GetProgressBarHelper()->Increment(); + aShapeItr++; + } + } + } + } + } +} + +void ScXMLExport::_ExportMeta() +{ + SvXMLExport::_ExportMeta(); + sal_Int32 nCellCount(pDoc ? pDoc->GetCellCount() : 0); + sal_Int32 nTableCount(0); + sal_Int32 nShapesCount(0); + GetAutoStylePool()->ClearEntries(); + CollectSharedData(nTableCount, nShapesCount, nCellCount); + ::rtl::OUStringBuffer sBuffer; + if (nTableCount) + { + GetMM100UnitConverter().convertNumber(sBuffer, nTableCount); + AddAttribute(XML_NAMESPACE_META, XML_TABLE_COUNT, sBuffer.makeStringAndClear()); + } + if (nCellCount) + { + GetMM100UnitConverter().convertNumber(sBuffer, nCellCount); + AddAttribute(XML_NAMESPACE_META, XML_CELL_COUNT, sBuffer.makeStringAndClear()); + } + if (nShapesCount) + { + GetMM100UnitConverter().convertNumber(sBuffer, nShapesCount); + AddAttribute(XML_NAMESPACE_META, XML_OBJECT_COUNT, sBuffer.makeStringAndClear()); + } + { + SvXMLElementExport aElemStat(*this, XML_NAMESPACE_META, XML_DOCUMENT_STATISTIC, sal_True, sal_True); + } +} + +void ScXMLExport::_ExportFontDecls() +{ + GetFontAutoStylePool(); // make sure the pool is created + SvXMLExport::_ExportFontDecls(); +} + +table::CellRangeAddress ScXMLExport::GetEndAddress(uno::Reference<sheet::XSpreadsheet>& xTable,const sal_uInt16 nTable) +{ + table::CellRangeAddress aCellAddress; + uno::Reference<sheet::XSheetCellCursor> xCursor = xTable->createCursor(); + uno::Reference<sheet::XUsedAreaCursor> xUsedArea (xCursor, uno::UNO_QUERY); + uno::Reference<sheet::XCellRangeAddressable> xCellAddress (xCursor, uno::UNO_QUERY); + if (xUsedArea.is() && xCellAddress.is()) + { + xUsedArea->gotoEndOfUsedArea(sal_True); + aCellAddress = xCellAddress->getRangeAddress(); + } + return aCellAddress; +} + +void ScXMLExport::GetAreaLinks( uno::Reference< sheet::XSpreadsheetDocument>& xSpreadDoc, + ScMyAreaLinksContainer& rAreaLinks ) +{ + uno::Reference< beans::XPropertySet > xPropSet( xSpreadDoc, uno::UNO_QUERY ); + if( !xPropSet.is() ) return; + + uno::Reference< sheet::XAreaLinks > xAreaLinks; + uno::Any aAny( xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_AREALINKS ) ) ) ); + if( aAny >>= xAreaLinks ) + { + uno::Reference< container::XIndexAccess > xLinksIAccess( xAreaLinks, uno::UNO_QUERY ); + if( xLinksIAccess.is() ) + { + const OUString sFilter( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_FILTER ) ); + const OUString sFilterOpt( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_FILTOPT ) ); + const OUString sURL( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_LINKURL ) ); + const OUString sRefresh( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_REFDELAY ) ); + + sal_Int32 nCount = xLinksIAccess->getCount(); + for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ ) + { + uno::Reference< sheet::XAreaLink > xAreaLink; + uno::Any aLinkAny( xLinksIAccess->getByIndex( nIndex ) ); + if( aLinkAny >>= xAreaLink ) + { + ScMyAreaLink aAreaLink; + aAreaLink.aDestRange = xAreaLink->getDestArea(); + aAreaLink.sSourceStr = xAreaLink->getSourceArea(); + uno::Reference< beans::XPropertySet > xLinkProp( xAreaLink, uno::UNO_QUERY ); + if( xLinkProp.is() ) + { + aLinkAny = xLinkProp->getPropertyValue( sFilter ); + aLinkAny >>= aAreaLink.sFilter; + aLinkAny = xLinkProp->getPropertyValue( sFilterOpt ); + aLinkAny >>= aAreaLink.sFilterOptions; + aLinkAny = xLinkProp->getPropertyValue( sURL ); + aLinkAny >>= aAreaLink.sURL; + aLinkAny = xLinkProp->getPropertyValue( sRefresh ); + aLinkAny >>= aAreaLink.nRefresh; + } + rAreaLinks.AddNewAreaLink( aAreaLink ); + } + } + } + } + rAreaLinks.Sort(); +} + +// core implementation +void ScXMLExport::GetDetectiveOpList( ScMyDetectiveOpContainer& rDetOp ) +{ + if (pDoc) + { + ScDetOpList* pOpList = pDoc->GetDetOpList(); + if( pOpList ) + { + sal_uInt32 nCount = pOpList->Count(); + for( sal_uInt32 nIndex = 0; nIndex < nCount; nIndex++ ) + { + ScDetOpData* pDetData = pOpList->GetObject( static_cast<USHORT>(nIndex) ); + if( pDetData ) + { + const ScAddress& rDetPos = pDetData->GetPos(); + sal_uInt16 nTab = rDetPos.Tab(); + if ( nTab < pDoc->GetTableCount() ) + { + rDetOp.AddOperation( pDetData->GetOperation(), rDetPos, nIndex ); + + // #i61888# cells with detective operations are written even if empty + pSharedData->SetLastColumn( nTab, rDetPos.Col() ); + pSharedData->SetLastRow( nTab, rDetPos.Row() ); + } + } + } + rDetOp.Sort(); + } + } +} + +void ScXMLExport::WriteSingleColumn(const sal_Int32 nRepeatColumns, const sal_Int32 nStyleIndex, + const sal_Int32 nIndex, const sal_Bool bIsAutoStyle, const sal_Bool bIsVisible) +{ + CheckAttrList(); + AddAttribute(sAttrStyleName, *pColumnStyles->GetStyleNameByIndex(nStyleIndex)); + if (!bIsVisible) + AddAttribute(XML_NAMESPACE_TABLE, XML_VISIBILITY, XML_COLLAPSE); + if (nRepeatColumns > 1) + { + OUString sOUEndCol = OUString::valueOf(static_cast <sal_Int32> (nRepeatColumns)); + AddAttribute(sAttrColumnsRepeated, sOUEndCol); + } + if (nIndex != -1) + AddAttribute(XML_NAMESPACE_TABLE, XML_DEFAULT_CELL_STYLE_NAME, *pCellStyles->GetStyleNameByIndex(nIndex, bIsAutoStyle)); + SvXMLElementExport aElemC(*this, sElemCol, sal_True, sal_True); +} + +void ScXMLExport::WriteColumn(const sal_Int32 nColumn, const sal_Int32 nRepeatColumns, + const sal_Int32 nStyleIndex, const sal_Bool bIsVisible) +{ + sal_Int32 nRepeat(1); + sal_Int32 nPrevIndex((*pDefaults->GetColDefaults())[nColumn].nIndex); + sal_Bool bPrevAutoStyle((*pDefaults->GetColDefaults())[nColumn].bIsAutoStyle); + for (sal_Int32 i = nColumn + 1; i < nColumn + nRepeatColumns; i++) + { + if (((*pDefaults->GetColDefaults())[i].nIndex != nPrevIndex) || + ((*pDefaults->GetColDefaults())[i].bIsAutoStyle != bPrevAutoStyle)) + { + WriteSingleColumn(nRepeat, nStyleIndex, nPrevIndex, bPrevAutoStyle, bIsVisible); + nPrevIndex = (*pDefaults->GetColDefaults())[i].nIndex; + bPrevAutoStyle = (*pDefaults->GetColDefaults())[i].bIsAutoStyle; + nRepeat = 1; + } + else + nRepeat++; + } + WriteSingleColumn(nRepeat, nStyleIndex, nPrevIndex, bPrevAutoStyle, bIsVisible); +} + +void ScXMLExport::OpenHeaderColumn() +{ + StartElement( XML_NAMESPACE_TABLE, XML_TABLE_HEADER_COLUMNS, sal_True ); +} + +void ScXMLExport::CloseHeaderColumn() +{ + EndElement(XML_NAMESPACE_TABLE, XML_TABLE_HEADER_COLUMNS, sal_True); +} + +void ScXMLExport::ExportColumns(const sal_uInt16 nTable, const table::CellRangeAddress& aColumnHeaderRange, const sal_Bool bHasColumnHeader) +{ + sal_Int32 nColsRepeated (1); + ::rtl::OUString sParent; + sal_Int32 nIndex; + sal_Int32 nPrevColumn(0); + sal_Bool bPrevIsVisible (sal_True); + sal_Bool bWasHeader (sal_False); + sal_Bool bIsHeader (sal_False); + sal_Bool bIsClosed (sal_True); + sal_Bool bIsFirst (sal_False); + sal_Int32 nPrevIndex (-1); + sal_Int32 nColumn; + + for (nColumn = 0; nColumn <= pSharedData->GetLastColumn(nTable); nColumn++) + { + CheckAttrList(); + sal_Bool bIsVisible(sal_True); + nIndex = pColumnStyles->GetStyleNameIndex(nTable, nColumn, bIsVisible); + + bIsHeader = bHasColumnHeader && (aColumnHeaderRange.StartColumn <= nColumn) && (nColumn <= aColumnHeaderRange.EndColumn); + if (bIsHeader != bWasHeader) + { + if (bIsHeader) + { + bIsFirst = sal_False; + if (nColumn > 0) + { + WriteColumn(nPrevColumn, nColsRepeated, nPrevIndex, bPrevIsVisible); + if (pGroupColumns->IsGroupEnd(nColumn - 1)) + pGroupColumns->CloseGroups(nColumn - 1); + } + bPrevIsVisible = bIsVisible; + nPrevIndex = nIndex; + nPrevColumn = nColumn; + nColsRepeated = 1; + bIsFirst = sal_True; + if(pGroupColumns->IsGroupStart(nColumn)) + pGroupColumns->OpenGroups(nColumn); + OpenHeaderColumn(); + bWasHeader = sal_True; + bIsClosed = sal_False; + } + else + { + WriteColumn(nPrevColumn, nColsRepeated, nPrevIndex, bPrevIsVisible); + CloseHeaderColumn(); + if (pGroupColumns->IsGroupEnd(nColumn - 1)) + pGroupColumns->CloseGroups(nColumn - 1); + if(pGroupColumns->IsGroupStart(nColumn)) + pGroupColumns->OpenGroups(nColumn); + bPrevIsVisible = bIsVisible; + nPrevIndex = nIndex; + nPrevColumn = nColumn; + nColsRepeated = 1; + bWasHeader = sal_False; + bIsClosed = sal_True; + } + } + else if (nColumn == 0) + { + if (pGroupColumns->IsGroupStart(nColumn)) + pGroupColumns->OpenGroups(nColumn); + bPrevIsVisible = bIsVisible; + nPrevIndex = nIndex; + bIsFirst = sal_True; + } + else if ((bIsVisible == bPrevIsVisible) && (nIndex == nPrevIndex) && + !pGroupColumns->IsGroupStart(nColumn) && !pGroupColumns->IsGroupEnd(nColumn - 1)) + nColsRepeated++; + else + { + bIsFirst = sal_False; + WriteColumn(nPrevColumn, nColsRepeated, nPrevIndex, bPrevIsVisible); + if (pGroupColumns->IsGroupEnd(nColumn - 1)) + { + if (bIsHeader) + CloseHeaderColumn(); + pGroupColumns->CloseGroups(nColumn - 1); + if (bIsHeader) + OpenHeaderColumn(); + } + if (pGroupColumns->IsGroupStart(nColumn)) + { + if (bIsHeader) + CloseHeaderColumn(); + pGroupColumns->OpenGroups(nColumn); + if (bIsHeader) + OpenHeaderColumn(); + } + bPrevIsVisible = bIsVisible; + nPrevIndex = nIndex; + nPrevColumn = nColumn; + nColsRepeated = 1; + } + } + //if (nColsRepeated > 1 || bIsFirst) + WriteColumn(nPrevColumn, nColsRepeated, nPrevIndex, bPrevIsVisible); + if (!bIsClosed) + CloseHeaderColumn(); + if (pGroupColumns->IsGroupEnd(nColumn - 1)) + pGroupColumns->CloseGroups(nColumn - 1); +} + +void ScXMLExport::WriteRowContent() +{ + ScMyRowFormatRange aRange; + sal_Int32 nIndex(-1); +#ifdef DBG_UTIL + sal_Int32 nPrevCol(0); +#endif + sal_Int32 nCols(0); + sal_Int32 nPrevValidationIndex(-1); + sal_Bool bIsAutoStyle(sal_True); + sal_Bool bIsFirst(sal_True); + while (pRowFormatRanges->GetNext(aRange)) + { +#ifdef DBG_UTIL + DBG_ASSERT(bIsFirst || (!bIsFirst && (nPrevCol + nCols == aRange.nStartColumn)), "here are some columns missing"); +#endif + if (bIsFirst) + { + nIndex = aRange.nIndex; + nPrevValidationIndex = aRange.nValidationIndex; + bIsAutoStyle = aRange.bIsAutoStyle; + nCols = aRange.nRepeatColumns; + bIsFirst = sal_False; +#ifdef DBG_UTIL + nPrevCol = aRange.nStartColumn; +#endif + } + else + { + if (((aRange.nIndex == nIndex && aRange.bIsAutoStyle == bIsAutoStyle) || + (aRange.nIndex == nIndex && nIndex == -1)) && + nPrevValidationIndex == aRange.nValidationIndex) + nCols += aRange.nRepeatColumns; + else + { + if (nIndex != -1) + AddAttribute(sAttrStyleName, *pCellStyles->GetStyleNameByIndex(nIndex, bIsAutoStyle)); + if (nPrevValidationIndex > -1) + AddAttribute(XML_NAMESPACE_TABLE, XML_CONTENT_VALIDATION_NAME, pValidationsContainer->GetValidationName(nPrevValidationIndex)); + if (nCols > 1) + { + ::rtl::OUStringBuffer aBuf; + GetMM100UnitConverter().convertNumber(aBuf, nCols); + AddAttribute(sAttrColumnsRepeated, aBuf.makeStringAndClear()); + } + SvXMLElementExport aElemC(*this, sElemCell, sal_True, sal_True); + nIndex = aRange.nIndex; + bIsAutoStyle = aRange.bIsAutoStyle; + nCols = aRange.nRepeatColumns; + nPrevValidationIndex = aRange.nValidationIndex; +#ifdef DBG_UTIL + nPrevCol = aRange.nStartColumn; +#endif + } + } + } + if (!bIsFirst) + { + table::CellAddress aCellAddress; + if (nIndex != -1) + AddAttribute(sAttrStyleName, *pCellStyles->GetStyleNameByIndex(nIndex, bIsAutoStyle)); + if (nPrevValidationIndex > -1) + AddAttribute(XML_NAMESPACE_TABLE, XML_CONTENT_VALIDATION_NAME, pValidationsContainer->GetValidationName(nPrevValidationIndex)); + if (nCols > 1) + { + ::rtl::OUStringBuffer aBuf; + GetMM100UnitConverter().convertNumber(aBuf, nCols); + AddAttribute(sAttrColumnsRepeated, aBuf.makeStringAndClear()); + } + SvXMLElementExport aElemC(*this, sElemCell, sal_True, sal_True); + } +} + +void ScXMLExport::WriteRowStartTag(sal_Int32 nRow, const sal_Int32 nIndex, + const sal_Int8 nFlag, const sal_Int32 nEqualRows) +{ + AddAttribute(sAttrStyleName, *pRowStyles->GetStyleNameByIndex(nIndex)); + if (nFlag) + if (nFlag & CR_HIDDEN) + { + if (nFlag & CR_FILTERED) + AddAttribute(XML_NAMESPACE_TABLE, XML_VISIBILITY, XML_FILTER); + else + AddAttribute(XML_NAMESPACE_TABLE, XML_VISIBILITY, XML_COLLAPSE); + } + if (nEqualRows > 1) + { + ::rtl::OUStringBuffer aBuf; + GetMM100UnitConverter().convertNumber(aBuf, nEqualRows); + AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_REPEATED, aBuf.makeStringAndClear()); + } + + const ScMyDefaultStyleList& rRowDefaults = *pDefaults->GetRowDefaults(); + if ( nRow >= rRowDefaults.size() ) + { + // #i61888# used to happen with detective operations - if there are more cases, use the last row's style + DBG_ERRORFILE("WriteRowStartTag: not enough defaults"); + nRow = rRowDefaults.size() - 1; + } + sal_Int32 nCellStyleIndex(rRowDefaults[nRow].nIndex); + if (nCellStyleIndex != -1) + AddAttribute(XML_NAMESPACE_TABLE, XML_DEFAULT_CELL_STYLE_NAME, + *pCellStyles->GetStyleNameByIndex(nCellStyleIndex, + (*pDefaults->GetRowDefaults())[nRow].bIsAutoStyle)); + StartElement( sElemRow, sal_True); +} + +void ScXMLExport::OpenHeaderRows() +{ + StartElement( XML_NAMESPACE_TABLE, XML_TABLE_HEADER_ROWS, sal_True); + bRowHeaderOpen = sal_True; +} + +void ScXMLExport::CloseHeaderRows() +{ + EndElement(XML_NAMESPACE_TABLE, XML_TABLE_HEADER_ROWS, sal_True); +} + +void ScXMLExport::OpenNewRow(const sal_Int32 nIndex, const sal_Int8 nFlag, const sal_Int32 nStartRow, const sal_Int32 nEqualRows) +{ + nOpenRow = nStartRow; + if (pGroupRows->IsGroupStart(nStartRow)) + { + if (bHasRowHeader && bRowHeaderOpen) + CloseHeaderRows(); + pGroupRows->OpenGroups(nStartRow); + if (bHasRowHeader && bRowHeaderOpen) + OpenHeaderRows(); + } + if (bHasRowHeader && !bRowHeaderOpen && nStartRow >= aRowHeaderRange.StartRow && nStartRow <= aRowHeaderRange.EndRow) + { + if (nStartRow == aRowHeaderRange.StartRow) + OpenHeaderRows(); + sal_Int32 nEquals; + if (aRowHeaderRange.EndRow < nStartRow + nEqualRows - 1) + nEquals = aRowHeaderRange.EndRow - nStartRow + 1; + else + nEquals = nEqualRows; + WriteRowStartTag(nStartRow, nIndex, nFlag, nEquals); + nOpenRow = nStartRow + nEquals - 1; + if (nEquals < nEqualRows) + { + CloseRow(nStartRow + nEquals - 1); + WriteRowStartTag(nStartRow, nIndex, nFlag, nEqualRows - nEquals); + nOpenRow = nStartRow + nEqualRows - 1; + } + } + else + WriteRowStartTag(nStartRow, nIndex, nFlag, nEqualRows); +} + +void ScXMLExport::OpenAndCloseRow(const sal_Int32 nIndex, const sal_Int8 nFlag, + const sal_Int32 nStartRow, const sal_Int32 nEqualRows) +{ + OpenNewRow(nIndex, nFlag, nStartRow, nEqualRows); + WriteRowContent(); + CloseRow(nStartRow + nEqualRows - 1); + pRowFormatRanges->Clear(); +} + +void ScXMLExport::OpenRow(const sal_uInt16 nTable, const sal_Int32 nStartRow, const sal_Int32 nRepeatRow) +{ + if (nRepeatRow > 1) + { + sal_Int32 nPrevIndex(0), nIndex; + sal_Int8 nPrevFlag(0); + sal_Int8 nFlag(0); + sal_Int32 nEqualRows(1); + sal_Int32 nEndRow(nStartRow + nRepeatRow); + sal_Int32 nRow; + + for (nRow = nStartRow; nRow < nEndRow; nRow++) + { + if (nRow == nStartRow) + { + nPrevIndex = pRowStyles->GetStyleNameIndex(nTable, nRow); + if (pDoc) + nPrevFlag = (pDoc->GetRowFlags(static_cast<USHORT>(nRow), nTable)) & (CR_HIDDEN | CR_FILTERED); + } + else + { + nIndex = pRowStyles->GetStyleNameIndex(nTable, nRow); + if (pDoc) + nFlag = (pDoc->GetRowFlags(static_cast<USHORT>(nRow), nTable)) & (CR_HIDDEN | CR_FILTERED); + if (nIndex == nPrevIndex && nFlag == nPrevFlag && + !(bHasRowHeader && ((nRow == aRowHeaderRange.StartRow) || (nRow - 1 == aRowHeaderRange.EndRow))) && + !(pGroupRows->IsGroupStart(nRow)) && + !(pGroupRows->IsGroupEnd(nRow - 1))) + nEqualRows++; + else + { + if (nRow < nEndRow) + { + ScRowFormatRanges* pTempRowFormatRanges = new ScRowFormatRanges(pRowFormatRanges); + OpenAndCloseRow(nPrevIndex, nPrevFlag, nRow - nEqualRows, nEqualRows); + delete pRowFormatRanges; + pRowFormatRanges = pTempRowFormatRanges; + } + else + OpenAndCloseRow(nPrevIndex, nPrevFlag, nRow - nEqualRows, nEqualRows); + nEqualRows = 1; + nPrevIndex = nIndex; + nPrevFlag = nFlag; + } + } + } + OpenNewRow(nPrevIndex, nPrevFlag, nRow - nEqualRows, nEqualRows); + } + else + { + sal_Int32 nIndex = pRowStyles->GetStyleNameIndex(nTable, nStartRow); + sal_Int8 nFlag(0); + if (pDoc) + nFlag = (pDoc->GetRowFlags(static_cast<USHORT>(nStartRow), nTable)) & (CR_HIDDEN | CR_FILTERED); + OpenNewRow(nIndex, nFlag, nStartRow, 1); + } + nOpenRow = nStartRow + nRepeatRow - 1; +} + +void ScXMLExport::CloseRow(const sal_Int32 nRow) +{ + if (nOpenRow > -1) + { + EndElement(sElemRow, sal_True); + if (bHasRowHeader && nRow == aRowHeaderRange.EndRow) + { + CloseHeaderRows(); + bRowHeaderOpen = sal_False; + } + if (pGroupRows->IsGroupEnd(nRow)) + { + if (bHasRowHeader && bRowHeaderOpen) + CloseHeaderRows(); + pGroupRows->CloseGroups(nRow); + if (bHasRowHeader && bRowHeaderOpen) + OpenHeaderRows(); + } + } + nOpenRow = -1; +} + +void ScXMLExport::ExportFormatRanges(const sal_Int32 nStartCol, const sal_Int32 nStartRow, + const sal_Int32 nEndCol, const sal_Int32 nEndRow, const sal_uInt16 nSheet) +{ + pRowFormatRanges->Clear(); + if (nStartRow == nEndRow) + { + pCellStyles->GetFormatRanges(nStartCol, nEndCol, nStartRow, nSheet, pRowFormatRanges); + if (nOpenRow == - 1) + OpenRow(nSheet, nStartRow, 1); + WriteRowContent(); + pRowFormatRanges->Clear(); + } + else + { + if (nOpenRow > -1) + { + pCellStyles->GetFormatRanges(nStartCol, pSharedData->GetLastColumn(nSheet), nStartRow, nSheet, pRowFormatRanges); + WriteRowContent(); + CloseRow(nStartRow); + sal_Int32 nRows = 1; + sal_Int32 nTotalRows = nEndRow - nStartRow + 1 - 1; + while (nRows < nTotalRows) + { + pRowFormatRanges->Clear(); + pCellStyles->GetFormatRanges(0, pSharedData->GetLastColumn(nSheet), nStartRow + nRows, nSheet, pRowFormatRanges); + sal_Int32 nMaxRows = pRowFormatRanges->GetMaxRows(); + DBG_ASSERT(nMaxRows, "something wents wrong"); + if (nMaxRows >= nTotalRows - nRows) + { + OpenRow(nSheet, nStartRow + nRows, nTotalRows - nRows); + nRows += nTotalRows - nRows; + } + else + { + OpenRow(nSheet, nStartRow + nRows, nMaxRows); + nRows += nMaxRows; + } + if (!pRowFormatRanges->GetSize()) + pCellStyles->GetFormatRanges(0, pSharedData->GetLastColumn(nSheet), nStartRow + nRows, nSheet, pRowFormatRanges); + WriteRowContent(); + CloseRow(nStartRow + nRows - 1); + } + if (nTotalRows == 1) + CloseRow(nStartRow); + OpenRow(nSheet, nEndRow, 1); + pRowFormatRanges->Clear(); + pCellStyles->GetFormatRanges(0, nEndCol, nEndRow, nSheet, pRowFormatRanges); + WriteRowContent(); + } + else + { + sal_Int32 nRows = 0; + sal_Int32 nTotalRows = nEndRow - nStartRow + 1 - 1; + while (nRows < nTotalRows) + { + pCellStyles->GetFormatRanges(0, pSharedData->GetLastColumn(nSheet), nStartRow + nRows, nSheet, pRowFormatRanges); + sal_Int32 nMaxRows = pRowFormatRanges->GetMaxRows(); + if (nMaxRows >= nTotalRows - nRows) + { + OpenRow(nSheet, nStartRow + nRows, nTotalRows - nRows); + nRows += nTotalRows - nRows; + } + else + { + OpenRow(nSheet, nStartRow + nRows, nMaxRows); + nRows += nMaxRows; + } + if (!pRowFormatRanges->GetSize()) + pCellStyles->GetFormatRanges(0, pSharedData->GetLastColumn(nSheet), nStartRow + nRows, nSheet, pRowFormatRanges); + WriteRowContent(); + CloseRow(nStartRow + nRows - 1); + } + OpenRow(nSheet, nEndRow, 1); + pRowFormatRanges->Clear(); + pCellStyles->GetFormatRanges(0, nEndCol, nEndRow, nSheet, pRowFormatRanges); + WriteRowContent(); + } + } +} + +sal_Bool ScXMLExport::GetColumnHeader(::com::sun::star::table::CellRangeAddress& aColumnHeaderRange) const +{ + sal_Bool bResult(sal_False); + uno::Reference <sheet::XPrintAreas> xPrintAreas (xCurrentTable, uno::UNO_QUERY); + if (xPrintAreas.is()) + { + bResult = xPrintAreas->getPrintTitleColumns(); + aColumnHeaderRange = xPrintAreas->getTitleColumns(); + } + return bResult; +} + +sal_Bool ScXMLExport::GetRowHeader(::com::sun::star::table::CellRangeAddress& aRowHeaderRange) const +{ + sal_Bool bResult(sal_False); + uno::Reference <sheet::XPrintAreas> xPrintAreas (xCurrentTable, uno::UNO_QUERY); + if (xPrintAreas.is()) + { + bResult = xPrintAreas->getPrintTitleRows(); + aRowHeaderRange = xPrintAreas->getTitleRows(); + } + return bResult; +} + +void ScXMLExport::FillFieldGroup(ScOutlineArray* pFields, ScMyOpenCloseColumnRowGroup* pGroups) +{ + sal_Int32 nDepth = pFields->GetDepth(); + for(sal_Int32 i = 0; i < nDepth; i++) + { + sal_Int32 nFields = pFields->GetCount(static_cast<USHORT>(i)); + for (sal_Int32 j = 0; j < nFields; j++) + { + ScMyColumnRowGroup aGroup; + ScOutlineEntry* pEntry = pFields->GetEntry(static_cast<USHORT>(i), static_cast<USHORT>(j)); + aGroup.nField = pEntry->GetStart(); + aGroup.nLevel = static_cast<sal_Int16>(i); + aGroup.bDisplay = !(pEntry->IsHidden()); + pGroups->AddGroup(aGroup, pEntry->GetEnd()); + } + } + if (nDepth) + pGroups->Sort(); +} + +void ScXMLExport::FillColumnRowGroups() +{ + if (pDoc) + { + ScOutlineTable* pOutlineTable = pDoc->GetOutlineTable( nCurrentTable, sal_False ); + if(pOutlineTable) + { + ScOutlineArray* pCols = pOutlineTable->GetColArray(); + ScOutlineArray* pRows = pOutlineTable->GetRowArray(); + if (pCols) + FillFieldGroup(pCols, pGroupColumns); + if (pRows) + FillFieldGroup(pRows, pGroupRows); + pSharedData->SetLastColumn(nCurrentTable, pGroupColumns->GetLast()); + pSharedData->SetLastRow(nCurrentTable, pGroupRows->GetLast()); + } + } +} + +void ScXMLExport::SetBodyAttributes() +{ + if (pDoc && pDoc->IsDocProtected()) + { + AddAttribute(XML_NAMESPACE_TABLE, XML_STRUCTURE_PROTECTED, XML_TRUE); + ::rtl::OUStringBuffer aBuffer; + SvXMLUnitConverter::encodeBase64(aBuffer, pDoc->GetDocPassword()); + if (aBuffer.getLength()) + AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTION_KEY, aBuffer.makeStringAndClear()); + } +} + +void ScXMLExport::_ExportContent() +{ + if (!pSharedData) + { + sal_Int32 nTableCount(0); + sal_Int32 nShapesCount(0); + sal_Int32 nCellCount(pDoc ? pDoc->GetCellCount() : 0); + CollectSharedData(nTableCount, nShapesCount, nCellCount); + DBG_ERROR("no shared data setted"); + } + ScXMLExportDatabaseRanges aExportDatabaseRanges(*this); + if (GetModel().is()) + { + uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( GetModel(), uno::UNO_QUERY ); + if ( xSpreadDoc.is() ) + { + uno::Reference<sheet::XSpreadsheets> xSheets = xSpreadDoc->getSheets(); + uno::Reference<container::XIndexAccess> xIndex( xSheets, uno::UNO_QUERY ); + if ( xIndex.is() ) + { + //_GetNamespaceMap().ClearQNamesCache(); + pChangeTrackingExportHelper->CollectAndWriteChanges(); + WriteCalculationSettings(xSpreadDoc); + sal_Int32 nTableCount = xIndex->getCount(); + ScMyAreaLinksContainer aAreaLinks; + GetAreaLinks( xSpreadDoc, aAreaLinks ); + ScMyEmptyDatabaseRangesContainer aEmptyRanges = aExportDatabaseRanges.GetEmptyDatabaseRanges(); + ScMyDetectiveOpContainer aDetectiveOpContainer; + GetDetectiveOpList( aDetectiveOpContainer ); + + pCellStyles->Sort(); + pMergedRangesContainer->Sort(); + pSharedData->GetDetectiveObjContainer()->Sort(); + + pCellsItr->Clear(); + pCellsItr->SetShapes( pSharedData->GetShapesContainer() ); + pCellsItr->SetMergedRanges( pMergedRangesContainer ); + pCellsItr->SetAreaLinks( &aAreaLinks ); + pCellsItr->SetEmptyDatabaseRanges( &aEmptyRanges ); + pCellsItr->SetDetectiveObj( pSharedData->GetDetectiveObjContainer() ); + pCellsItr->SetDetectiveOp( &aDetectiveOpContainer ); + + if (nTableCount > 0) + pValidationsContainer->WriteValidations(*this); + WriteTheLabelRanges( xSpreadDoc ); + for (sal_uInt16 nTable = 0; nTable < nTableCount; nTable++) + { + uno::Any aTable = xIndex->getByIndex(nTable); + uno::Reference<sheet::XSpreadsheet> xTable; + if (aTable>>=xTable) + { + xCurrentTable = xTable; + uno::Reference<container::XNamed> xName (xTable, uno::UNO_QUERY ); + if ( xName.is() ) + { + nCurrentTable = nTable; + ::rtl::OUString sOUTableName = xName->getName(); + AddAttribute(sAttrName, sOUTableName); + AddAttribute(sAttrStyleName, aTableStyles[nTable]); + uno::Reference<util::XProtectable> xProtectable (xTable, uno::UNO_QUERY); + if (xProtectable.is()) + if (xProtectable->isProtected()) + { + AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTED, XML_TRUE); + ::rtl::OUStringBuffer aBuffer; + if (pDoc) + SvXMLUnitConverter::encodeBase64(aBuffer, pDoc->GetTabPassword(nTable)); + if (aBuffer.getLength()) + AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTION_KEY, aBuffer.makeStringAndClear()); + } + ::rtl::OUString sPrintRanges( GetPrintRanges() ); + if( sPrintRanges.getLength() ) + AddAttribute( XML_NAMESPACE_TABLE, XML_PRINT_RANGES, sPrintRanges ); + SvXMLElementExport aElemT(*this, sElemTab, sal_True, sal_True); + CheckAttrList(); + WriteTableSource(); + WriteScenario(); + uno::Reference<drawing::XDrawPage> xDrawPage; + if (pSharedData->HasForm(nTable, xDrawPage) && xDrawPage.is()) + { + ::binfilter::xmloff::OOfficeFormsExport aForms(*this); + GetFormExport()->exportForms( xDrawPage ); + sal_Bool bRet = GetFormExport()->seekPage( xDrawPage ); + DBG_ASSERT( bRet, "OFormLayerXMLExport::seekPage failed!" ); + } + if (pSharedData->HasDrawPage()) + { + GetShapeExport()->seekShapes(uno::Reference<drawing::XShapes>(pSharedData->GetDrawPage(nTable), uno::UNO_QUERY)); + WriteTableShapes(); + } + table::CellRangeAddress aRange = GetEndAddress(xTable, nTable); + pSharedData->SetLastColumn(nTable, aRange.EndColumn); + pSharedData->SetLastRow(nTable, aRange.EndRow); + pCellsItr->SetCurrentTable(nTable, xCurrentTable); + pGroupColumns->NewTable(); + pGroupRows->NewTable(); + FillColumnRowGroups(); + table::CellRangeAddress aColumnHeaderRange; + sal_Bool bHasColumnHeader(GetColumnHeader(aColumnHeaderRange)); + if (bHasColumnHeader) + pSharedData->SetLastColumn(nTable, aColumnHeaderRange.EndColumn); + bHasRowHeader = GetRowHeader(aRowHeaderRange); + bRowHeaderOpen = sal_False; + if (bHasRowHeader) + pSharedData->SetLastRow(nTable, aRowHeaderRange.EndRow); + pDefaults->FillDefaultStyles(nTable, pSharedData->GetLastRow(nTable), + pSharedData->GetLastColumn(nTable), pCellStyles, pDoc); + pRowFormatRanges->SetRowDefaults(pDefaults->GetRowDefaults()); + pRowFormatRanges->SetColDefaults(pDefaults->GetColDefaults()); + pCellStyles->SetRowDefaults(pDefaults->GetRowDefaults()); + pCellStyles->SetColDefaults(pDefaults->GetColDefaults()); + ExportColumns(nTable, aColumnHeaderRange, bHasColumnHeader); + sal_Bool bIsFirst(sal_True); + sal_Int32 nEqualCells(0); + ScMyCell aCell; + ScMyCell aPrevCell; + while(pCellsItr->GetNext(aCell, pCellStyles)) + { + if (bIsFirst) + { + ExportFormatRanges(0, 0, aCell.aCellAddress.Column - 1, aCell.aCellAddress.Row, nTable); + aPrevCell = aCell; + bIsFirst = sal_False; + } + else + { + if ((aPrevCell.aCellAddress.Row == aCell.aCellAddress.Row) && + (aPrevCell.aCellAddress.Column + nEqualCells + 1 == aCell.aCellAddress.Column)) + { + if(IsCellEqual(aPrevCell, aCell)) + nEqualCells++; + else + { + SetRepeatAttribute(nEqualCells); + WriteCell(aPrevCell); + nEqualCells = 0; + aPrevCell = aCell; + } + } + else + { + SetRepeatAttribute(nEqualCells); + WriteCell(aPrevCell); + ExportFormatRanges(aPrevCell.aCellAddress.Column + nEqualCells + 1, aPrevCell.aCellAddress.Row, + aCell.aCellAddress.Column - 1, aCell.aCellAddress.Row, nTable); + nEqualCells = 0; + aPrevCell = aCell; + } + } + } + if (!bIsFirst) + { + SetRepeatAttribute(nEqualCells); + WriteCell(aPrevCell); + ExportFormatRanges(aPrevCell.aCellAddress.Column + nEqualCells + 1, aPrevCell.aCellAddress.Row, + pSharedData->GetLastColumn(nTable), pSharedData->GetLastRow(nTable), nTable); + } + else + ExportFormatRanges(0, 0, pSharedData->GetLastColumn(nTable), pSharedData->GetLastRow(nTable), nTable); + CloseRow(pSharedData->GetLastRow(nTable)); + nEqualCells = 0; + } + } + GetProgressBarHelper()->Increment(); + } + } + WriteNamedExpressions(xSpreadDoc); + aExportDatabaseRanges.WriteDatabaseRanges(xSpreadDoc); + ScXMLExportDataPilot aExportDataPilot(*this); + aExportDataPilot.WriteDataPilots(xSpreadDoc); + WriteConsolidation(); + ScXMLExportDDELinks aExportDDELinks(*this); + aExportDDELinks.WriteDDELinks(xSpreadDoc); + GetProgressBarHelper()->SetValue(GetProgressBarHelper()->GetReference()); + } + } +} + +void ScXMLExport::_ExportStyles( sal_Bool bUsed ) +{ + if (!pSharedData) + { + sal_Int32 nTableCount(0); + sal_Int32 nShapesCount(0); + sal_Int32 nCellCount(pDoc ? pDoc->GetCellCount() : 0); + CollectSharedData(nTableCount, nShapesCount, nCellCount); + //DBG_ERROR("no shared data setted"); + } + ScXMLStyleExport aStylesExp(*this, ::rtl::OUString(), GetAutoStylePool().get()); + if (GetModel().is()) + { + uno::Reference <lang::XMultiServiceFactory> xMultiServiceFactory(GetModel(), uno::UNO_QUERY); + if (xMultiServiceFactory.is()) + { + uno::Reference <uno::XInterface> xInterface = xMultiServiceFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.Defaults"))); + uno::Reference <beans::XPropertySet> xProperties(xInterface, uno::UNO_QUERY); + if (xProperties.is()) + aStylesExp.exportDefaultStyle(xProperties, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_CELL_STYLES_NAME)), xCellStylesExportPropertySetMapper); + if (pSharedData->HasShapes()) + { + GetShapeExport()->ExportGraphicDefaults(); +/* xInterface = xMultiServiceFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.Defaults"))); + uno::Reference <beans::XPropertySet> xDrawProperties(xInterface, uno::UNO_QUERY); + if (xDrawProperties.is()) + aStylesExp.exportDefaultStyle(xDrawProperties, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_GRAPHICS_NAME)), GetShapeExport()->CreateShapePropMapper(*this));*/ + } + } + uno::Reference <style::XStyleFamiliesSupplier> xStyleFamiliesSupplier (GetModel(), uno::UNO_QUERY); + if (xStyleFamiliesSupplier.is()) + { + uno::Reference <container::XNameAccess> aStylesFamilies = xStyleFamiliesSupplier->getStyleFamilies(); + if (aStylesFamilies.is()) + { + uno::Any aStyleFamily = aStylesFamilies->getByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CellStyles"))); + uno::Reference <container::XIndexAccess> aCellStyles; + if (aStyleFamily >>= aCellStyles) + { + sal_Int32 nCount = aCellStyles->getCount(); + ::rtl::OUString sNumberFormat(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_NUMFMT)); + for (sal_Int32 i = 0; i < nCount; i++) + { + uno::Any aCellStyle = aCellStyles->getByIndex(i); + uno::Reference <beans::XPropertySet> xCellProperties; + if (aCellStyle >>= xCellProperties) + { + uno::Any aNumberFormat = xCellProperties->getPropertyValue(sNumberFormat); + sal_Int32 nNumberFormat; + if (aNumberFormat >>= nNumberFormat) + addDataStyle(nNumberFormat); + } + } + } + } + } + } + exportDataStyles(); + + aStylesExp.exportStyleFamily(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CellStyles")), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_CELL_STYLES_NAME)), xCellStylesExportPropertySetMapper, FALSE, XML_STYLE_FAMILY_TABLE_CELL); + + SvXMLExport::_ExportStyles(bUsed); +} + +void ScXMLExport::_ExportAutoStyles() +{ + if (GetModel().is()) + { + uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( GetModel(), uno::UNO_QUERY ); + if ( xSpreadDoc.is() ) + { + uno::Reference<sheet::XSpreadsheets> xSheets = xSpreadDoc->getSheets(); + uno::Reference<container::XIndexAccess> xIndex( xSheets, uno::UNO_QUERY ); + if ( xIndex.is() ) + { + if (getExportFlags() & EXPORT_CONTENT) + { + if (!pSharedData) + { + sal_Int32 nTableCount(0); + sal_Int32 nShapesCount(0); + sal_Int32 nCellCount(pDoc ? pDoc->GetCellCount() : 0); + CollectSharedData(nTableCount, nShapesCount, nCellCount); + //DBG_ERROR("no shared data setted"); + } + ::rtl::OUString SC_SCOLUMNPREFIX(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_PREFIX)); + ::rtl::OUString SC_SROWPREFIX(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_ROW_STYLES_PREFIX)); + ::rtl::OUString SC_SCELLPREFIX(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_CELL_STYLES_PREFIX)); + ::rtl::OUString SC_NUMBERFORMAT(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_NUMFMT)); + sal_Int32 nTableCount = xIndex->getCount(); + pCellStyles->AddNewTable(nTableCount - 1); + CollectShapesAutoStyles(nTableCount); + for (sal_uInt16 nTable = 0; nTable < nTableCount; nTable++) + { + uno::Any aTable = xIndex->getByIndex(nTable); + uno::Reference<sheet::XSpreadsheet> xTable; + if (aTable>>=xTable) + { + uno::Reference<beans::XPropertySet> xTableProperties(xTable, uno::UNO_QUERY); + if (xTableProperties.is()) + { + std::vector<XMLPropertyState> xPropStates = xTableStylesExportPropertySetMapper->Filter(xTableProperties); + if(xPropStates.size()) + { + ::rtl::OUString sParent; + ::rtl::OUString sName; + GetAutoStylePool()->Add(sName, XML_STYLE_FAMILY_TABLE_TABLE, sParent, xPropStates); + aTableStyles.push_back(sName); + } + } + uno::Reference<sheet::XUniqueCellFormatRangesSupplier> xCellFormatRanges ( xTable, uno::UNO_QUERY ); + if ( xCellFormatRanges.is() ) + { + uno::Reference<container::XIndexAccess> xFormatRangesIndex = xCellFormatRanges->getUniqueCellFormatRanges(); + if (xFormatRangesIndex.is()) + { + sal_Int32 nFormatRangesCount = xFormatRangesIndex->getCount(); + GetProgressBarHelper()->ChangeReference(GetProgressBarHelper()->GetReference() + nFormatRangesCount); + for (sal_Int32 nFormatRange = 0; nFormatRange < nFormatRangesCount; nFormatRange++) + { + uno::Any aFormatRange = xFormatRangesIndex->getByIndex(nFormatRange); + uno::Reference< sheet::XSheetCellRanges> xCellRanges; + if (aFormatRange >>= xCellRanges) + { + uno::Reference <beans::XPropertySet> xProperties (xCellRanges, uno::UNO_QUERY); + if (xProperties.is()) + { + ::rtl::OUString sStyleName; + sal_Int32 nNumberFormat(-1); + sal_Int32 nValidationIndex(-1); + std::vector< XMLPropertyState > xPropStates = xCellStylesExportPropertySetMapper->Filter( xProperties ); + std::vector< XMLPropertyState >::iterator aItr = xPropStates.begin(); + sal_Int32 nCount(0); + while (aItr != xPropStates.end()) + { + if (aItr->mnIndex != -1) + { + switch (xCellStylesPropertySetMapper->GetEntryContextId(aItr->mnIndex)) + { + case CTF_SC_VALIDATION : + { + pValidationsContainer->AddValidation(aItr->maValue, nValidationIndex); + // this is not very slow, because it is most the last property or + // if it is not the last property it is the property before the last property, + // so in the worst case only one property has to be copied, but in the best case no + // property has to be copied + aItr = xPropStates.erase(aItr); + } + break; + case CTF_SC_CELLSTYLE : + { + aItr->maValue >>= sStyleName; + aItr->mnIndex = -1; + aItr++; + nCount++; + } + break; + case CTF_SC_NUMBERFORMAT : + { + if (aItr->maValue >>= nNumberFormat) + addDataStyle(nNumberFormat); + aItr++; + nCount++; + } + break; + default: + { + aItr++; + nCount++; + } + break; + } + } + else + { + aItr++; + nCount++; + } + } + if (nCount == 1) // this is the CellStyle and should be removed if alone + xPropStates.clear(); + if (nNumberFormat == -1) + { + uno::Any aAny = xProperties->getPropertyValue(SC_NUMBERFORMAT); + aAny >>= nNumberFormat; + } + if (sStyleName.getLength()) + { + if (xPropStates.size()) + { + sal_Int32 nIndex; + ::rtl::OUString sName; + sal_Bool bIsAutoStyle = sal_True; + if (GetAutoStylePool()->Add(sName, XML_STYLE_FAMILY_TABLE_CELL, sStyleName, xPropStates)) + { + ::rtl::OUString* pTemp = new ::rtl::OUString(sName); + if (!pCellStyles->AddStyleName(pTemp, nIndex)) + delete pTemp; + } + else + nIndex = pCellStyles->GetIndexOfStyleName(sName, SC_SCELLPREFIX, bIsAutoStyle); + uno::Sequence<table::CellRangeAddress> aAddresses = xCellRanges->getRangeAddresses(); + table::CellRangeAddress* pAddresses = aAddresses.getArray(); + sal_Bool bGetMerge(sal_True); + for (sal_Int32 i = 0; i < aAddresses.getLength(); i++, pAddresses++) + { + pSharedData->SetLastColumn(nTable, pAddresses->EndColumn); + pSharedData->SetLastRow(nTable, pAddresses->EndRow); + pCellStyles->AddRangeStyleName(*pAddresses, nIndex, bIsAutoStyle, nValidationIndex, nNumberFormat); + if (bGetMerge) + bGetMerge = GetMerged(pAddresses, xTable); + } + } + else + { + ::rtl::OUString* pTemp = new ::rtl::OUString(sStyleName); + sal_Int32 nIndex(0); + if (!pCellStyles->AddStyleName(pTemp, nIndex, sal_False)) + { + delete pTemp; + pTemp = NULL; + } + uno::Sequence<table::CellRangeAddress> aAddresses = xCellRanges->getRangeAddresses(); + table::CellRangeAddress* pAddresses = aAddresses.getArray(); + sal_Bool bGetMerge(sal_True); + for (sal_Int32 i = 0; i < aAddresses.getLength(); i++, pAddresses++) + { + if (bGetMerge) + bGetMerge = GetMerged(pAddresses, xTable); + pCellStyles->AddRangeStyleName(*pAddresses, nIndex, sal_False, nValidationIndex, nNumberFormat); + if (!sStyleName.equalsAsciiL("Default", 7) || nValidationIndex != -1) + { + pSharedData->SetLastColumn(nTable, pAddresses->EndColumn); + pSharedData->SetLastRow(nTable, pAddresses->EndRow); + } + } + } + } + GetProgressBarHelper()->Increment(); + } + } + } + } + } + uno::Reference<table::XColumnRowRange> xColumnRowRange (xTable, uno::UNO_QUERY); + if (xColumnRowRange.is()) + { + if (pDoc) + { + uno::Reference<table::XTableColumns> xTableColumns = xColumnRowRange->getColumns(); + if (xTableColumns.is()) + { + sal_Int32 nColumns = pDoc->GetLastChangedCol(nTable); + pSharedData->SetLastColumn(nTable, nColumns); + table::CellRangeAddress aCellAddress = GetEndAddress(xTable, nTable); + if (aCellAddress.EndColumn > nColumns) + { + nColumns++; + pColumnStyles->AddNewTable(nTable, aCellAddress.EndColumn); + } + // else if (nColumns < MAXCOL) + // pColumnStyles->AddNewTable(nTable, ++nColumns); + else + pColumnStyles->AddNewTable(nTable, nColumns); + sal_Int32 nColumn = 0; + while (/*nColumn <= nColumns && */nColumn <= MAXCOL) + { + sal_Int32 nIndex(-1); + sal_Bool bIsVisible(sal_True); + uno::Any aColumn = xTableColumns->getByIndex(nColumn); + uno::Reference<table::XCellRange> xTableColumn; + if (aColumn >>= xTableColumn) + { + uno::Reference <beans::XPropertySet> xColumnProperties(xTableColumn, uno::UNO_QUERY); + if (xColumnProperties.is()) + { + std::vector<XMLPropertyState> xPropStates = xColumnStylesExportPropertySetMapper->Filter(xColumnProperties); + if(xPropStates.size()) + { + std::vector< XMLPropertyState >::iterator aItr = xPropStates.begin(); + while (aItr != xPropStates.end()) + { + if (xColumnStylesPropertySetMapper->GetEntryContextId(aItr->mnIndex) == CTF_SC_ISVISIBLE) + { + aItr->maValue >>= bIsVisible; + break; + } + aItr++; + } + ::rtl::OUString sParent; + ::rtl::OUString sName; + if (GetAutoStylePool()->Add(sName, XML_STYLE_FAMILY_TABLE_COLUMN, sParent, xPropStates)) + { + ::rtl::OUString* pTemp = new ::rtl::OUString(sName); + nIndex = pColumnStyles->AddStyleName(pTemp); + } + else + nIndex = pColumnStyles->GetIndexOfStyleName(sName, SC_SCOLUMNPREFIX); + pColumnStyles->AddFieldStyleName(nTable, nColumn, nIndex, bIsVisible); + } + } + } + sal_Int32 nOld = nColumn; + nColumn = pDoc->GetNextDifferentChangedCol(nTable, static_cast<USHORT>(nColumn)); + if (nColumn == MAXCOL) + nColumn++; + for (sal_Int32 i = nOld + 1; i < nColumn; i++) + pColumnStyles->AddFieldStyleName(nTable, i, nIndex, bIsVisible); + } + if (aCellAddress.EndColumn > nColumns) + { + sal_Bool bIsVisible(sal_True); + sal_Int32 nIndex = pColumnStyles->GetStyleNameIndex(nTable, nColumns, bIsVisible); + for (sal_Int32 i = nColumns + 1; i <= aCellAddress.EndColumn; i++) + pColumnStyles->AddFieldStyleName(nTable, i, nIndex, bIsVisible); + } + } + uno::Reference<table::XTableRows> xTableRows = xColumnRowRange->getRows(); + if (xTableRows.is()) + { + sal_Int32 nRows = pDoc->GetLastChangedRow(nTable); + pSharedData->SetLastRow(nTable, nRows); + table::CellRangeAddress aCellAddress = GetEndAddress(xTable, nTable); + if (aCellAddress.EndRow > nRows) + { + nRows++; + pRowStyles->AddNewTable(nTable, aCellAddress.EndRow); + } + // else if (nRows < MAXROW) + // pRowStyles->AddNewTable(nTable, ++nRows); + else + pRowStyles->AddNewTable(nTable, nRows); + sal_Int32 nRow = 0; + while ( /*nRow <= nRows && */nRow <= MAXROW) + { + sal_Int32 nIndex; + uno::Any aRow = xTableRows->getByIndex(nRow); + uno::Reference<table::XCellRange> xTableRow; + if (aRow >>= xTableRow) + { + uno::Reference <beans::XPropertySet> xRowProperties(xTableRow, uno::UNO_QUERY); + if(xRowProperties.is()) + { + std::vector<XMLPropertyState> xPropStates = xRowStylesExportPropertySetMapper->Filter(xRowProperties); + if(xPropStates.size()) + { + ::rtl::OUString sParent; + ::rtl::OUString sName; + if (GetAutoStylePool()->Add(sName, XML_STYLE_FAMILY_TABLE_ROW, sParent, xPropStates)) + { + ::rtl::OUString* pTemp = new ::rtl::OUString(sName); + nIndex = pRowStyles->AddStyleName(pTemp); + } + else + nIndex = pRowStyles->GetIndexOfStyleName(sName, SC_SROWPREFIX); + pRowStyles->AddFieldStyleName(nTable, nRow, nIndex); + } + } + } + sal_Int32 nOld = nRow; + nRow = pDoc->GetNextDifferentChangedRow(nTable, static_cast<USHORT>(nRow), false); + if (nRow == MAXROW) + nRow++; + for (sal_Int32 i = nOld + 1; i < nRow; i++) + pRowStyles->AddFieldStyleName(nTable, i, nIndex); + } + if (aCellAddress.EndRow > nRows) + { + sal_Int32 nIndex = pRowStyles->GetStyleNameIndex(nTable, nRows); + for (sal_Int32 i = nRows + 1; i <= aCellAddress.EndRow; i++) + pRowStyles->AddFieldStyleName(nTable, i, nIndex); + } + } + } + } + uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery (xTable, uno::UNO_QUERY); + if (xCellRangesQuery.is()) + { + uno::Reference<sheet::XSheetCellRanges> xSheetCellRanges = xCellRangesQuery->queryContentCells(sheet::CellFlags::STRING); + uno::Reference<sheet::XSheetOperation> xSheetOperation(xSheetCellRanges, uno::UNO_QUERY); + if (xSheetCellRanges.is() && xSheetOperation.is()) + { + sal_uInt32 nCount(sal_uInt32(xSheetOperation->computeFunction(sheet::GeneralFunction_COUNT))); + uno::Reference<container::XEnumerationAccess> xCellsAccess = xSheetCellRanges->getCells(); + if (xCellsAccess.is()) + { + GetProgressBarHelper()->ChangeReference(GetProgressBarHelper()->GetReference() + nCount); + uno::Reference<container::XEnumeration>xCells = xCellsAccess->createEnumeration(); + if (xCells.is()) + { + sal_uInt32 nCount2(0); + while (xCells->hasMoreElements()) + { + uno::Any aCell = xCells->nextElement(); + uno::Reference<table::XCell> xCell; + if (aCell >>= xCell) + { + if (IsEditCell(xCell)) + { + uno::Reference<text::XText> xText(xCell, uno::UNO_QUERY); + if (xText.is()) + GetTextParagraphExport()->collectTextAutoStyles(xText, sal_False, sal_False); + } + } + nCount2++; + GetProgressBarHelper()->Increment(); + } + if(nCount2 > nCount) + GetProgressBarHelper()->SetReference(GetProgressBarHelper()->GetReference() + nCount2 - nCount); + } + } + } + } + } + GetProgressBarHelper()->Increment(); + } + pChangeTrackingExportHelper->CollectAutoStyles(); + + GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_COLUMN, + GetDocHandler(), GetMM100UnitConverter(), GetNamespaceMap()); + GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_ROW, + GetDocHandler(), GetMM100UnitConverter(), GetNamespaceMap()); + GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_TABLE, + GetDocHandler(), GetMM100UnitConverter(), GetNamespaceMap()); + exportAutoDataStyles(); + GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_CELL, + GetDocHandler(), GetMM100UnitConverter(), GetNamespaceMap()); + GetTextParagraphExport()->exportTextAutoStyles(); + + GetShapeExport()->exportAutoStyles(); + GetFormExport()->exportAutoStyles( ); + } + if ((getExportFlags() & EXPORT_ALL) == EXPORT_ALL) + GetChartExport()->exportAutoStyles(); + if (getExportFlags() & EXPORT_MASTERSTYLES) + { + GetPageExport()->collectAutoStyles(sal_True); + GetTextParagraphExport()->exportTextAutoStyles(); + GetPageExport()->exportAutoStyles(); + } + } + } + } +} + +void ScXMLExport::_ExportMasterStyles() +{ + GetPageExport()->exportMasterStyles( sal_True ); +} + +void ScXMLExport::CollectInternalShape( uno::Reference< drawing::XShape > xShape ) +{ + // detective objects + SvxShape* pShapeImp = SvxShape::getImplementation( xShape ); + if( pShapeImp ) + { + SdrObject *pObject = pShapeImp->GetSdrObject(); + if( pObject ) + { + ScDetectiveFunc aDetFunc( pDoc, nCurrentTable ); + ScAddress aPosition; + ScRange aSourceRange; + sal_Bool bRedLine; + ScDetectiveObjType eObjType = aDetFunc.GetDetectiveObjectType( + pObject, aPosition, aSourceRange, bRedLine ); + pSharedData->GetDetectiveObjContainer()->AddObject( eObjType, aPosition, aSourceRange, bRedLine ); + } + } +} + +sal_Bool ScXMLExport::GetMerged (const table::CellRangeAddress* pCellAddress, + const uno::Reference <sheet::XSpreadsheet>& xTable) +{ + sal_Bool bReady(sal_False); + sal_Int32 nRow(pCellAddress->StartRow); + sal_Int32 nCol(pCellAddress->StartColumn); + sal_Int32 nEndRow(pCellAddress->EndRow); + sal_Int32 nEndCol(pCellAddress->EndColumn); + sal_Bool bRowInc(nEndRow > nRow); + while(!bReady && nRow <= nEndRow && nCol <= nEndCol) + { + uno::Reference<table::XCellRange> xCellRange = xTable->getCellRangeByPosition( + nCol, nRow, nCol, nRow); + if (xCellRange.is()) + { + uno::Reference<sheet::XSheetCellRange> xSheetCellRange(xCellRange, uno::UNO_QUERY); + if (xSheetCellRange.is()) + { + uno::Reference<sheet::XSheetCellCursor> xCursor = xTable->createCursorByRange(xSheetCellRange); + if(xCursor.is()) + { + uno::Reference<sheet::XCellRangeAddressable> xCellAddress (xCursor, uno::UNO_QUERY); + xCursor->collapseToMergedArea(); + table::CellRangeAddress aCellAddress2 = xCellAddress->getRangeAddress(); + if ((aCellAddress2.EndRow > nRow || + aCellAddress2.EndColumn > nCol) && + aCellAddress2.StartRow == nRow && + aCellAddress2.StartColumn == nCol) + { + pMergedRangesContainer->AddRange(aCellAddress2); + pSharedData->SetLastColumn(aCellAddress2.Sheet, aCellAddress2.EndColumn); + pSharedData->SetLastRow(aCellAddress2.Sheet, aCellAddress2.EndRow); + } + else + bReady = sal_True; + } + } + } + if (!bReady) + { + if (bRowInc) + nRow++; + else + nCol++; + } + } + DBG_ASSERT(!(!bReady && nEndRow > nRow && nEndCol > nCol), "should not be possible"); + return !bReady; +} + +sal_Bool ScXMLExport::IsMatrix (const uno::Reference <table::XCell>& xCell, + const uno::Reference <sheet::XSpreadsheet>& xTable, + const sal_Int32 nCol, const sal_Int32 nRow, + table::CellRangeAddress& aCellAddress, sal_Bool& bIsFirst) const +{ + bIsFirst = sal_False; + uno::Reference <sheet::XArrayFormulaRange> xArrayFormulaRange (xCell, uno::UNO_QUERY); + if (xArrayFormulaRange.is()) + { + ::rtl::OUString sArrayFormula = xArrayFormulaRange->getArrayFormula(); + if (sArrayFormula.getLength()) + { + uno::Reference<sheet::XSheetCellRange> xMatrixSheetCellRange (xCell, uno::UNO_QUERY); + if (xMatrixSheetCellRange.is()) + { + uno::Reference<sheet::XSheetCellCursor> xMatrixSheetCursor = xTable->createCursorByRange(xMatrixSheetCellRange); + if (xMatrixSheetCursor.is()) + { + xMatrixSheetCursor->collapseToCurrentArray(); + uno::Reference<sheet::XCellRangeAddressable> xMatrixCellAddress (xMatrixSheetCursor, uno::UNO_QUERY); + if (xMatrixCellAddress.is()) + { + aCellAddress = xMatrixCellAddress->getRangeAddress(); + if ((aCellAddress.StartColumn == nCol && aCellAddress.StartRow == nRow) && + (aCellAddress.EndColumn > nCol || aCellAddress.EndRow > nRow)) + { + bIsFirst = sal_True; + return sal_True; + } + else if (aCellAddress.StartColumn != nCol || aCellAddress.StartRow != nRow || + aCellAddress.EndColumn != nCol || aCellAddress.EndRow != nRow) + return sal_True; + else + { + bIsFirst = sal_True; + return sal_True; + } + } + } + } + } + } + return sal_False; +} + +sal_Bool ScXMLExport::GetCellText (ScMyCell& rMyCell) const +{ + if (rMyCell.bHasStringValue) + return sal_True; + else + { + if (!rMyCell.bHasXText) + { + rMyCell.xText = uno::Reference <text::XText>(rMyCell.xCell, uno::UNO_QUERY); + rMyCell.bHasXText = sal_True; + } + if (rMyCell.xText.is()) + { + rMyCell.sStringValue = rMyCell.xText->getString(); + rMyCell.bHasStringValue = sal_True; + return sal_True; + } + } + return sal_False; +} + +OUString ScXMLExport::GetPrintRanges() +{ + ::rtl::OUString sPrintRanges; + uno::Reference< sheet::XPrintAreas > xPrintAreas( xCurrentTable, uno::UNO_QUERY ); + if( xPrintAreas.is() ) + { + uno::Sequence< table::CellRangeAddress > aRangeList( xPrintAreas->getPrintAreas() ); + ScXMLConverter::GetStringFromRangeList( sPrintRanges, aRangeList, pDoc ); + } + return sPrintRanges; +} + +void ScXMLExport::WriteCell (ScMyCell& aCell) +{ + if (aCell.nStyleIndex != -1) + AddAttribute(sAttrStyleName, *pCellStyles->GetStyleNameByIndex(aCell.nStyleIndex, aCell.bIsAutoStyle)); + if (aCell.nValidationIndex > -1) + AddAttribute(XML_NAMESPACE_TABLE, XML_CONTENT_VALIDATION_NAME, pValidationsContainer->GetValidationName(aCell.nValidationIndex)); + sal_Bool bIsMatrix(aCell.bIsMatrixBase || aCell.bIsMatrixCovered); + sal_Bool bIsFirstMatrixCell(aCell.bIsMatrixBase); + if (bIsFirstMatrixCell) + { + sal_Int32 nColumns = aCell.aMatrixRange.EndColumn - aCell.aMatrixRange.StartColumn + 1; + sal_Int32 nRows = aCell.aMatrixRange.EndRow - aCell.aMatrixRange.StartRow + 1; + ::rtl::OUStringBuffer sColumns; + ::rtl::OUStringBuffer sRows; + SvXMLUnitConverter::convertNumber(sColumns, nColumns); + SvXMLUnitConverter::convertNumber(sRows, nRows); + AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_MATRIX_COLUMNS_SPANNED, sColumns.makeStringAndClear()); + AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_MATRIX_ROWS_SPANNED, sRows.makeStringAndClear()); + } + sal_Bool bIsEmpty = sal_False; + switch (aCell.nType) + { + case table::CellContentType_EMPTY : + { + bIsEmpty = sal_True; + } + break; + case table::CellContentType_VALUE : + { + if (!aCell.bHasDoubleValue) + { + aCell.fValue = aCell.xCell->getValue(); + aCell.bHasDoubleValue = sal_True; + } + GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes( + aCell.nNumberFormat, aCell.fValue); + } + break; + case table::CellContentType_TEXT : + { + if (GetCellText(aCell)) + { + ::rtl::OUString sFormula(aCell.xCell->getFormula()); + if (sFormula[0] == '\'') + sFormula = sFormula.copy(1); + GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes( + sFormula, aCell.sStringValue, sal_True, sal_False); + } + } + break; + case table::CellContentType_FORMULA : + { + ScAddress aCoreAddress(static_cast<sal_uInt16>(aCell.aCellAddress.Column), + static_cast<sal_uInt16>(aCell.aCellAddress.Row), + static_cast<sal_uInt16>(aCell.aCellAddress.Sheet)); + ScBaseCell* pBaseCell = GetDocument() ? GetDocument()->GetCell(aCoreAddress) : NULL; + if (pBaseCell && pBaseCell->GetCellType() == CELLTYPE_FORMULA) + { + ::rtl::OUStringBuffer sFormula; + ScFormulaCell* pFormulaCell = (ScFormulaCell*) pBaseCell; + if (!bIsMatrix || (bIsMatrix && bIsFirstMatrixCell)) + { + pFormulaCell->GetEnglishFormula(sFormula, sal_True); + ::rtl::OUString sOUFormula(sFormula.makeStringAndClear()); + if (!bIsMatrix) + AddAttribute(sAttrFormula, sOUFormula); + else + { + ::rtl::OUString sMatrixFormula = sOUFormula.copy(1, sOUFormula.getLength() - 2); + AddAttribute(sAttrFormula, sMatrixFormula); + } + } + if (pFormulaCell->IsValue()) + { + sal_Bool bIsStandard; + ::rtl::OUString sCurrency; + GetNumberFormatAttributesExportHelper()->GetCellType(aCell.nNumberFormat, sCurrency, bIsStandard); + if (bIsStandard) + { + if (pDoc) + GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes( + pFormulaCell->GetStandardFormat(*pDoc->GetFormatTable(), 0), + aCell.xCell->getValue()); + } + else + GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes( + aCell.nNumberFormat, aCell.xCell->getValue()); + } + else + { + if (GetCellText(aCell)) + if (aCell.sStringValue.getLength()) + AddAttribute(sAttrStringValue, aCell.sStringValue); + } + } + } + break; + } + ::rtl::OUString* pCellString = &sElemCell; + if (aCell.bIsCovered) + { + pCellString = &sElemCoveredCell; + } + else + { + if (aCell.bIsMergedBase) + { + sal_Int32 nColumns = aCell.aMergeRange.EndColumn - aCell.aMergeRange.StartColumn + 1; + sal_Int32 nRows = aCell.aMergeRange.EndRow - aCell.aMergeRange.StartRow + 1; + ::rtl::OUStringBuffer sColumns; + ::rtl::OUStringBuffer sRows; + SvXMLUnitConverter::convertNumber(sColumns, nColumns); + SvXMLUnitConverter::convertNumber(sRows, nRows); + AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_SPANNED, sColumns.makeStringAndClear()); + AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_SPANNED, sRows.makeStringAndClear()); + } + } + SvXMLElementExport aElemC(*this, *pCellString, sal_True, sal_True); + CheckAttrList(); + WriteAreaLink(aCell); + WriteAnnotation(aCell); + WriteDetective(aCell); + if (!bIsEmpty) + { + if ((aCell.nType == table::CellContentType_TEXT) && IsEditCell(aCell)) + { + if (!aCell.bHasXText) + { + aCell.xText = uno::Reference<text::XText>(aCell.xCell, uno::UNO_QUERY); + aCell.bHasXText = sal_True; + } + if ( aCell.xText.is()) + GetTextParagraphExport()->exportText(aCell.xText, sal_False, sal_False); + } + else + { + SvXMLElementExport aElemC(*this, sElemP, sal_True, sal_False); + sal_Bool bPrevCharWasSpace(sal_True); + if (GetCellText(aCell)) + GetTextParagraphExport()->exportText(aCell.sStringValue, bPrevCharWasSpace); + } + } + WriteShapes(aCell); + if (!bIsEmpty) + GetProgressBarHelper()->Increment(); +} + +void ScXMLExport::ExportShape(const uno::Reference < drawing::XShape >& xShape, awt::Point* pPoint) +{ + uno::Reference < beans::XPropertySet > xShapeProps ( xShape, uno::UNO_QUERY ); + sal_Bool bMemChart(sal_False); + ::rtl::OUString sPropCLSID (RTL_CONSTASCII_USTRINGPARAM("CLSID")); + ::rtl::OUString sPersistName (RTL_CONSTASCII_USTRINGPARAM("PersistName")); + if (xShapeProps.is()) + { + uno::Any aAny = xShapeProps->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ZOrder"))); + sal_Int32 nZOrder; + if (aAny >>= nZOrder) + { + ::rtl::OUStringBuffer sBuffer; + GetMM100UnitConverter().convertNumber(sBuffer, nZOrder); + AddAttribute(XML_NAMESPACE_DRAW, XML_ZINDEX, sBuffer.makeStringAndClear()); + } + uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xShapeProps->getPropertySetInfo(); + if( xPropSetInfo->hasPropertyByName( sPropCLSID ) ) + { + uno::Any aAny = xShapeProps->getPropertyValue( sPropCLSID ); + ::rtl::OUString sCLSID; + if (aAny >>= sCLSID) + { + if ( sCLSID.equalsIgnoreAsciiCase(GetChartExport()->getChartCLSID()) ) + { + aAny = xShapeProps->getPropertyValue(sPersistName); + ::rtl::OUString sOUName; + aAny >>= sOUName; + String sName(sOUName); + if (!pChartListener) + { + String aEmptyString; + ScRange aRange; + pChartListener = new ScChartListener ( aEmptyString, GetDocument(), aRange ); + } + if(pChartListener) + { + USHORT nIndex(0); + pChartListener->SetString( sName ); + if ( GetDocument() && GetDocument()->GetChartListenerCollection()->Search( pChartListener, nIndex ) ) + { + const ScRangeListRef& rRangeListRef = ((ScChartListener*) + (GetDocument()->GetChartListenerCollection()-> + At( nIndex )))->GetRangeList(); + if (rRangeListRef.Is()) + { + bMemChart = sal_True; + ::rtl::OUString sRanges; + ScXMLConverter::GetStringFromRangeList(sRanges, rRangeListRef, GetDocument()); + if (sRanges.getLength()) + AddAttribute(XML_NAMESPACE_DRAW, XML_NOTIFY_ON_UPDATE_OF_RANGES, sRanges); + GetShapeExport()->exportShape(xShape, SEF_EXPORT_NO_CHART_DATA | SEF_DEFAULT, pPoint); + } + } + else + { + bMemChart = sal_True; + AddAttribute(XML_NAMESPACE_DRAW, XML_NOTIFY_ON_UPDATE_OF_RANGES, ::rtl::OUString()); + GetShapeExport()->exportShape(xShape, SEF_EXPORT_NO_CHART_DATA | SEF_DEFAULT, pPoint); + } + } +/* SchMemChart* pMemChart = pDoc->FindChartData(sName); + if (pMemChart && pMemChart->GetSeriesAddresses().getLength()) + { + bMemChart = sal_True; + ::rtl::OUString sRanges(pMemChart->getXMLStringForChartRange()); + if (sRanges.getLength()) + AddAttribute(XML_NAMESPACE_DRAW, XML_NOTIFY_ON_UPDATE_OF_RANGES, sRanges); + GetShapeExport()->exportShape(xShape, SEF_EXPORT_NO_CHART_DATA | SEF_DEFAULT, pPoint); + }*/ + } + } + } + } + if (!bMemChart) + GetShapeExport()->exportShape(xShape, SEF_DEFAULT, pPoint); + GetProgressBarHelper()->Increment(); +} + +void ScXMLExport::WriteShapes(const ScMyCell& rMyCell) +{ + if( rMyCell.bHasShape && !rMyCell.aShapeList.empty() && pDoc ) + { + awt::Point aPoint; + Rectangle aRec = pDoc->GetMMRect(static_cast<USHORT>(rMyCell.aCellAddress.Column), static_cast<USHORT>(rMyCell.aCellAddress.Row), + static_cast<USHORT>(rMyCell.aCellAddress.Column), static_cast<USHORT>(rMyCell.aCellAddress.Row), rMyCell.aCellAddress.Sheet); + aPoint.X = aRec.Left(); + aPoint.Y = aRec.Top(); + awt::Point* pPoint = &aPoint; + ScMyShapeList::const_iterator aItr = rMyCell.aShapeList.begin(); + while (aItr != rMyCell.aShapeList.end()) + { + if (aItr->xShape.is()) + { + if ( !aItr->xShape->getShapeType().equals(sCaptionShape) ) + { + awt::Point aEndPoint; + Rectangle aEndRec = pDoc->GetMMRect(aItr->aEndAddress.Col(), aItr->aEndAddress.Row(), + aItr->aEndAddress.Col(), aItr->aEndAddress.Row(), aItr->aEndAddress.Tab()); + ::rtl::OUString sEndAddress; + ScXMLConverter::GetStringFromAddress(sEndAddress, aItr->aEndAddress, pDoc); + AddAttribute(XML_NAMESPACE_TABLE, XML_END_CELL_ADDRESS, sEndAddress); + aEndPoint.X = aEndRec.Left(); + aEndPoint.Y = aEndRec.Top(); + awt::Point aStartPoint = aItr->xShape->getPosition(); + awt::Size aSize = aItr->xShape->getSize(); + sal_Int32 nEndX = aStartPoint.X + aSize.Width - aEndPoint.X; + sal_Int32 nEndY = aStartPoint.Y + aSize.Height - aEndPoint.Y; + ::rtl::OUStringBuffer sBuffer; + GetMM100UnitConverter().convertMeasure(sBuffer, nEndX); + AddAttribute(XML_NAMESPACE_TABLE, XML_END_X, sBuffer.makeStringAndClear()); + GetMM100UnitConverter().convertMeasure(sBuffer, nEndY); + AddAttribute(XML_NAMESPACE_TABLE, XML_END_Y, sBuffer.makeStringAndClear()); + } + ExportShape(aItr->xShape, pPoint); + } + aItr++; + } + } +} + +void ScXMLExport::WriteTableShapes() +{ + ScMyTableShapes* pTableShapes = pSharedData->GetTableShapes(); + if (pTableShapes && !(*pTableShapes)[nCurrentTable].empty()) + { + DBG_ASSERT(pTableShapes->size() > static_cast<sal_uInt32>(nCurrentTable), "wrong Table"); + SvXMLElementExport aShapesElem(*this, XML_NAMESPACE_TABLE, XML_SHAPES, sal_True, sal_False); + ScMyTableXShapes::iterator aItr = (*pTableShapes)[nCurrentTable].begin(); + while (aItr != (*pTableShapes)[nCurrentTable].end()) + { + if (aItr->is()) + { + ExportShape(*aItr, NULL); + } + aItr = (*pTableShapes)[nCurrentTable].erase(aItr); + } + } +} + +void ScXMLExport::WriteAreaLink( const ScMyCell& rMyCell ) +{ + if( rMyCell.bHasAreaLink ) + { + const ScMyAreaLink& rAreaLink = rMyCell.aAreaLink; + AddAttribute( XML_NAMESPACE_TABLE, XML_NAME, rAreaLink.sSourceStr ); + AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, GetRelativeReference(rAreaLink.sURL) ); + AddAttribute( XML_NAMESPACE_TABLE, XML_FILTER_NAME, rAreaLink.sFilter ); + if( rAreaLink.sFilterOptions.getLength() ) + AddAttribute( XML_NAMESPACE_TABLE, XML_FILTER_OPTIONS, rAreaLink.sFilterOptions ); + OUStringBuffer sValue; + SvXMLUnitConverter::convertNumber( sValue, rAreaLink.GetColCount() ); + AddAttribute( XML_NAMESPACE_TABLE, XML_LAST_COLUMN_SPANNED, sValue.makeStringAndClear() ); + SvXMLUnitConverter::convertNumber( sValue, rAreaLink.GetRowCount() ); + AddAttribute( XML_NAMESPACE_TABLE, XML_LAST_ROW_SPANNED, sValue.makeStringAndClear() ); + if( rAreaLink.nRefresh ) + { + SvXMLUnitConverter::convertTime( sValue, (double)rAreaLink.nRefresh / 86400 ); + AddAttribute( XML_NAMESPACE_TABLE, XML_REFRESH_DELAY, sValue.makeStringAndClear() ); + } + SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, XML_CELL_RANGE_SOURCE, sal_True, sal_True ); + } +} + +void ScXMLExport::WriteAnnotation(const ScMyCell& rMyCell) +{ + if( rMyCell.bHasAnnotation && rMyCell.xAnnotation.is()) + { + ::rtl::OUString sAuthor(rMyCell.xAnnotation->getAuthor()); + if (sAuthor.getLength()) + AddAttribute(XML_NAMESPACE_OFFICE, XML_AUTHOR, sAuthor); + String aDate(rMyCell.xAnnotation->getDate()); + if (pDoc) + { + SvNumberFormatter* pNumForm = pDoc->GetFormatTable(); + double fDate; + sal_uInt32 nfIndex = pNumForm->GetFormatIndex(NF_DATE_SYS_DDMMYYYY, LANGUAGE_SYSTEM); + if (pNumForm->IsNumberFormat(aDate, nfIndex, fDate)) + { + ::rtl::OUStringBuffer sBuf; + GetMM100UnitConverter().convertDateTime(sBuf, fDate); + AddAttribute(XML_NAMESPACE_OFFICE, XML_CREATE_DATE, sBuf.makeStringAndClear()); + } + else + AddAttribute(XML_NAMESPACE_OFFICE, XML_CREATE_DATE_STRING, ::rtl::OUString(aDate)); + } + else + AddAttribute(XML_NAMESPACE_OFFICE, XML_CREATE_DATE_STRING, ::rtl::OUString(aDate)); + if (rMyCell.xAnnotation->getIsVisible()) + AddAttribute(XML_NAMESPACE_OFFICE, XML_DISPLAY, XML_TRUE); + SvXMLElementExport aElemA(*this, XML_NAMESPACE_OFFICE, XML_ANNOTATION, sal_True, sal_True); + sal_Int32 i = 0; + ::rtl::OUStringBuffer sTemp; + sal_Bool bPrevCharWasSpace(sal_True); + String sText(rMyCell.sAnnotationText); + ::rtl::OUString sOUText2 (sText.ConvertLineEnd(LINEEND_LF)); + while(i < sOUText2.getLength()) + { + if (sOUText2[i] == '\n') + { + SvXMLElementExport aElemP(*this, sElemP, sal_True, sal_False); + GetTextParagraphExport()->exportText(sTemp.makeStringAndClear(), bPrevCharWasSpace); + } + else + sTemp.append(sOUText2[i]); + i++; + } + if (sTemp.getLength()) + { + SvXMLElementExport aElemP(*this, sElemP, sal_True, sal_False); + GetTextParagraphExport()->exportText(sTemp.makeStringAndClear(), bPrevCharWasSpace); + } + CheckAttrList(); + } +} + +void ScXMLExport::WriteDetective( const ScMyCell& rMyCell ) +{ + if( rMyCell.bHasDetectiveObj || rMyCell.bHasDetectiveOp ) + { + const ScMyDetectiveObjVec& rObjVec = rMyCell.aDetectiveObjVec; + const ScMyDetectiveOpVec& rOpVec = rMyCell.aDetectiveOpVec; + sal_Int32 nObjCount = rObjVec.size(); + sal_Int32 nOpCount = rOpVec.size(); + if( nObjCount || nOpCount ) + { + SvXMLElementExport aDetElem( *this, XML_NAMESPACE_TABLE, XML_DETECTIVE, sal_True, sal_True ); + OUString sString; + for( ScMyDetectiveObjVec::const_iterator aObjItr = rObjVec.begin(); aObjItr != rObjVec.end(); aObjItr++ ) + { + if (aObjItr->eObjType != SC_DETOBJ_CIRCLE) + { + if( (aObjItr->eObjType == SC_DETOBJ_ARROW) || (aObjItr->eObjType == SC_DETOBJ_TOOTHERTAB)) + { + ScXMLConverter::GetStringFromRange( sString, aObjItr->aSourceRange, pDoc ); + AddAttribute( XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, sString ); + } + ScXMLConverter::GetStringFromDetObjType( sString, aObjItr->eObjType ); + AddAttribute( XML_NAMESPACE_TABLE, XML_DIRECTION, sString ); + if( aObjItr->bHasError ) + AddAttribute( XML_NAMESPACE_TABLE, XML_CONTAINS_ERROR, XML_TRUE ); + } + else + AddAttribute( XML_NAMESPACE_TABLE, XML_MARKED_INVALID, XML_TRUE ); + SvXMLElementExport aRangeElem( *this, XML_NAMESPACE_TABLE, XML_HIGHLIGHTED_RANGE, sal_True, sal_True ); + } + OUStringBuffer aBuffer; + for( ScMyDetectiveOpVec::const_iterator aOpItr = rOpVec.begin(); aOpItr != rOpVec.end(); aOpItr++ ) + { + OUString sString; + ScXMLConverter::GetStringFromDetOpType( sString, aOpItr->eOpType ); + AddAttribute( XML_NAMESPACE_TABLE, XML_NAME, sString ); + SvXMLUnitConverter::convertNumber( aBuffer, aOpItr->nIndex ); + AddAttribute( XML_NAMESPACE_TABLE, XML_INDEX, aBuffer.makeStringAndClear() ); + SvXMLElementExport aRangeElem( *this, XML_NAMESPACE_TABLE, XML_OPERATION, sal_True, sal_True ); + } + } + } +} + +void ScXMLExport::SetRepeatAttribute (const sal_Int32 nEqualCellCount) +{ + if (nEqualCellCount > 0) + { + sal_Int32 nTemp = nEqualCellCount + 1; + OUString sOUEqualCellCount = OUString::valueOf(nTemp); + AddAttribute(sAttrColumnsRepeated, sOUEqualCellCount); + GetProgressBarHelper()->Increment(nEqualCellCount); + } +} + +sal_Bool ScXMLExport::IsCellTypeEqual (const ScMyCell& aCell1, const ScMyCell& aCell2) const +{ + return (aCell1.nType == aCell2.nType); +} + +sal_Bool ScXMLExport::IsEditCell(const ::com::sun::star::table::CellAddress& aAddress) const +{ + ScAddress aCoreAddress(static_cast<sal_uInt16>(aAddress.Column), + static_cast<sal_uInt16>(aAddress.Row), + static_cast<sal_uInt16>(aAddress.Sheet)); + ScBaseCell* pBaseCell = GetDocument() ? GetDocument()->GetCell(aCoreAddress) : NULL; + if (pBaseCell) + return (pBaseCell->GetCellType() == CELLTYPE_EDIT); + return sal_False; +} + +sal_Bool ScXMLExport::IsEditCell(const ::com::sun::star::uno::Reference < ::com::sun::star::table::XCell>& xCell) const +{ + uno::Reference<sheet::XCellAddressable> xAddressable (xCell, uno::UNO_QUERY); + if ( xAddressable.is() ) + return IsEditCell(xAddressable->getCellAddress()); + return sal_False; +} + +sal_Bool ScXMLExport::IsEditCell(ScMyCell& rCell) const +{ + if (rCell.bKnowWhetherIsEditCell) + return rCell.bIsEditCell; + else + { + rCell.bIsEditCell = IsEditCell(rCell.aCellAddress); + rCell.bKnowWhetherIsEditCell = sal_True; + return rCell.bIsEditCell; + } +} + +sal_Bool ScXMLExport::IsAnnotationEqual(const uno::Reference<table::XCell>& xCell1, + const uno::Reference<table::XCell>& xCell2) +{ + uno::Reference<sheet::XSheetAnnotationAnchor> xSheetAnnotationAnchor1(xCell1, uno::UNO_QUERY); + uno::Reference<sheet::XSheetAnnotationAnchor> xSheetAnnotationAnchor2(xCell2, uno::UNO_QUERY); + if (xSheetAnnotationAnchor1.is() && xSheetAnnotationAnchor2.is()) + { + uno::Reference <sheet::XSheetAnnotation> xSheetAnnotation1 = xSheetAnnotationAnchor1->getAnnotation(); + uno::Reference <sheet::XSheetAnnotation> xSheetAnnotation2 = xSheetAnnotationAnchor2->getAnnotation(); + uno::Reference<text::XSimpleText> xSimpleText1(xSheetAnnotation1, uno::UNO_QUERY); + uno::Reference<text::XSimpleText> xSimpleText2(xSheetAnnotation2, uno::UNO_QUERY); + if (xSheetAnnotation1.is() && xSimpleText1.is() && + xSheetAnnotation2.is() && xSimpleText2.is()) + { + ::rtl::OUString sText1 = xSimpleText1->getString(); + ::rtl::OUString sText2 = xSimpleText2->getString(); + sal_Int32 nLength1 = sText1.getLength(); + sal_Int32 nLength2 = sText2.getLength(); + if (nLength1 && nLength2) + if (sText1 == sText2 && + xSheetAnnotation1->getAuthor() == xSheetAnnotation2->getAuthor() && + xSheetAnnotation1->getDate() == xSheetAnnotation2->getDate() && + xSheetAnnotation1->getIsVisible() == xSheetAnnotation2->getIsVisible()) + return sal_True; + else + return sal_False; + else + if (nLength1 || nLength2) + return sal_False; + else + return sal_True; + } + } + return sal_False; +} + +sal_Bool ScXMLExport::IsCellEqual (ScMyCell& aCell1, ScMyCell& aCell2) +{ + sal_Bool bIsEqual = sal_False; + if( !aCell1.bIsMergedBase && !aCell2.bIsMergedBase && + aCell1.bIsCovered == aCell2.bIsCovered && + !aCell1.bIsMatrixBase && !aCell2.bIsMatrixBase && + aCell1.bIsMatrixCovered == aCell2.bIsMatrixCovered && + aCell1.bHasAnnotation == aCell2.bHasAnnotation && + !aCell1.bHasShape && !aCell2.bHasShape && + aCell1.bHasAreaLink == aCell2.bHasAreaLink && + !aCell1.bHasDetectiveObj && !aCell2.bHasDetectiveObj) + { + if( (aCell1.bHasAreaLink && + (aCell1.aAreaLink.GetColCount() == 1) && + (aCell2.aAreaLink.GetColCount() == 1) && + aCell1.aAreaLink.Compare( aCell2.aAreaLink ) ) || + !aCell1.bHasAreaLink ) + { + if (!aCell1.bHasAnnotation || (aCell1.bHasAnnotation && IsAnnotationEqual(aCell1.xCell, aCell2.xCell))) + { + if (((aCell1.nStyleIndex == aCell2.nStyleIndex) && (aCell1.bIsAutoStyle == aCell2.bIsAutoStyle) || + (aCell1.nStyleIndex == aCell2.nStyleIndex) && (aCell1.nStyleIndex == -1)) && + (aCell1.nValidationIndex == aCell2.nValidationIndex) && + IsCellTypeEqual(aCell1, aCell2)) + { + switch ( aCell1.nType ) + { + case table::CellContentType_EMPTY : + { + bIsEqual = sal_True; + } + break; + case table::CellContentType_VALUE : + { + if(!aCell1.bHasDoubleValue) + { + aCell1.fValue = aCell1.xCell->getValue(); + aCell1.bHasDoubleValue = sal_True; + } + if (!aCell2.bHasDoubleValue) + { + aCell2.fValue = aCell2.xCell->getValue(); + aCell2.bHasDoubleValue = sal_True; + } + bIsEqual = (aCell1.fValue == aCell2.fValue); + } + break; + case table::CellContentType_TEXT : + { + if (IsEditCell(aCell1) || IsEditCell(aCell2)) + bIsEqual = sal_False; + else + { + if (GetCellText(aCell1) && GetCellText(aCell2)) + { + bIsEqual = (aCell1.sStringValue == aCell2.sStringValue) && + (aCell1.xCell->getFormula() == aCell2.xCell->getFormula()); + } + else + bIsEqual = sal_False; + } + } + break; + case table::CellContentType_FORMULA : + { + bIsEqual = sal_False; + } + break; + default : + { + bIsEqual = sal_False; + } + break; + } + } + } + } + } + return bIsEqual; +} + +void ScXMLExport::WriteCalculationSettings(const uno::Reference <sheet::XSpreadsheetDocument>& xSpreadDoc) +{ + uno::Reference<beans::XPropertySet> xPropertySet(xSpreadDoc, uno::UNO_QUERY); + if (xPropertySet.is()) + { + sal_Bool bCalcAsShown (::cppu::any2bool( xPropertySet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_CALCASSHOWN))) )); + sal_Bool bIgnoreCase (::cppu::any2bool( xPropertySet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_IGNORECASE))) )); + sal_Bool bLookUpLabels (::cppu::any2bool( xPropertySet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_LOOKUPLABELS))) )); + sal_Bool bMatchWholeCell (::cppu::any2bool( xPropertySet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_MATCHWHOLE))) )); + sal_Bool bUseRegularExpressions (::cppu::any2bool( xPropertySet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_REGEXENABLED))) )); + sal_Bool bIsIterationEnabled (::cppu::any2bool( xPropertySet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_ITERENABLED))) )); + sal_uInt16 nYear2000 (pDoc ? pDoc->GetDocOptions().GetYear2000() : 0); + uno::Any aAny = xPropertySet->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_ITERCOUNT))); + sal_Int32 nIterationCount(100); + aAny >>= nIterationCount; + aAny = xPropertySet->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_ITEREPSILON))); + double fIterationEpsilon; + aAny >>= fIterationEpsilon; + aAny = xPropertySet->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_NULLDATE))); + util::Date aNullDate; + aAny >>= aNullDate; + if (bCalcAsShown || bIgnoreCase || !bLookUpLabels || !bMatchWholeCell || !bUseRegularExpressions || + bIsIterationEnabled || nIterationCount != 100 || !::rtl::math::approxEqual(fIterationEpsilon, 0.001) || + aNullDate.Day != 30 || aNullDate.Month != 12 || aNullDate.Year != 1899 || nYear2000 != 1930) + { + if (bIgnoreCase) + AddAttribute(XML_NAMESPACE_TABLE, XML_CASE_SENSITIVE, XML_FALSE); + if (bCalcAsShown) + AddAttribute(XML_NAMESPACE_TABLE, XML_PRECISION_AS_SHOWN, XML_TRUE); + if (!bMatchWholeCell) + AddAttribute(XML_NAMESPACE_TABLE, XML_SEARCH_CRITERIA_MUST_APPLY_TO_WHOLE_CELL, XML_FALSE); + if (!bLookUpLabels) + AddAttribute(XML_NAMESPACE_TABLE, XML_AUTOMATIC_FIND_LABELS, XML_FALSE); + if (!bUseRegularExpressions) + AddAttribute(XML_NAMESPACE_TABLE, XML_USE_REGULAR_EXPRESSIONS, XML_FALSE); + if (nYear2000 != 1930) + { + ::rtl::OUStringBuffer sBuffer; + GetMM100UnitConverter().convertNumber(sBuffer, nYear2000); + AddAttribute(XML_NAMESPACE_TABLE, XML_NULL_YEAR, sBuffer.makeStringAndClear()); + } + SvXMLElementExport aCalcSettings(*this, XML_NAMESPACE_TABLE, XML_CALCULATION_SETTINGS, sal_True, sal_True); + { + if (aNullDate.Day != 30 || aNullDate.Month != 12 || aNullDate.Year != 1899) + { + ::rtl::OUStringBuffer sDate; + GetMM100UnitConverter().convertDateTime(sDate, 0.0, aNullDate); + AddAttribute(XML_NAMESPACE_TABLE, XML_DATE_VALUE, sDate.makeStringAndClear()); + SvXMLElementExport aElemNullDate(*this, XML_NAMESPACE_TABLE, XML_NULL_DATE, sal_True, sal_True); + } + if (bIsIterationEnabled || nIterationCount != 100 || !::rtl::math::approxEqual(fIterationEpsilon, 0.001)) + { + ::rtl::OUStringBuffer sBuffer; + if (bIsIterationEnabled) + AddAttribute(XML_NAMESPACE_TABLE, XML_STATUS, XML_ENABLE); + if (nIterationCount != 100) + { + GetMM100UnitConverter().convertNumber(sBuffer, nIterationCount); + AddAttribute(XML_NAMESPACE_TABLE, XML_STEPS, sBuffer.makeStringAndClear()); + } + if (!::rtl::math::approxEqual(fIterationEpsilon, 0.001)) + { + GetMM100UnitConverter().convertDouble(sBuffer, fIterationEpsilon); + AddAttribute(XML_NAMESPACE_TABLE, XML_MAXIMUM_DIFFERENCE, sBuffer.makeStringAndClear()); + } + SvXMLElementExport aElemIteration(*this, XML_NAMESPACE_TABLE, XML_ITERATION, sal_True, sal_True); + } + } + } + } +} + +void ScXMLExport::WriteTableSource() +{ + uno::Reference <sheet::XSheetLinkable> xLinkable (xCurrentTable, uno::UNO_QUERY); + if (xLinkable.is() && GetModel().is()) + { + sheet::SheetLinkMode nMode (xLinkable->getLinkMode()); + if (nMode != sheet::SheetLinkMode_NONE) + { + ::rtl::OUString sLink (xLinkable->getLinkUrl()); + uno::Reference <beans::XPropertySet> xProps (GetModel(), uno::UNO_QUERY); + if (xProps.is()) + { + uno::Any aAny = xProps->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SHEETLINKS))); + uno::Reference <container::XIndexAccess> xIndex; + if (aAny >>= xIndex) + { + sal_Int32 nCount = xIndex->getCount(); + if (nCount) + { + sal_Bool bFound(sal_False); + uno::Reference <beans::XPropertySet> xLinkProps; + for (sal_Int32 i = 0; (i < nCount) && !bFound; i++) + { + uno::Any aSheetLink = xIndex->getByIndex(i); + if (aSheetLink >>= xLinkProps) + { + aAny = xLinkProps->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_LINKURL))); + ::rtl::OUString sNewLink; + if (aAny >>= sNewLink) + bFound = sLink.equals(sNewLink); + } + } + if (bFound && xLinkProps.is()) + { + ::rtl::OUString sFilter; + ::rtl::OUString sFilterOptions; + ::rtl::OUString sTableName (xLinkable->getLinkSheetName()); + sal_Int32 nRefresh(0); + aAny = xLinkProps->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_FILTER))); + aAny >>= sFilter; + aAny = xLinkProps->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_FILTOPT))); + aAny >>= sFilterOptions; + aAny = xLinkProps->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_REFDELAY))); + aAny >>= nRefresh; + if (sLink.getLength()) + { + AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, GetRelativeReference(sLink)); + if (sTableName.getLength()) + AddAttribute(XML_NAMESPACE_TABLE, XML_TABLE_NAME, sTableName); + if (sFilter.getLength()) + AddAttribute(XML_NAMESPACE_TABLE, XML_FILTER_NAME, sFilter); + if (sFilterOptions.getLength()) + AddAttribute(XML_NAMESPACE_TABLE, XML_FILTER_OPTIONS, sFilterOptions); + if (nMode != sheet::SheetLinkMode_NORMAL) + AddAttribute(XML_NAMESPACE_TABLE, XML_MODE, XML_COPY_RESULTS_ONLY); + if( nRefresh ) + { + ::rtl::OUStringBuffer sBuffer; + SvXMLUnitConverter::convertTime( sBuffer, (double)nRefresh / 86400 ); + AddAttribute( XML_NAMESPACE_TABLE, XML_REFRESH_DELAY, sBuffer.makeStringAndClear() ); + } + SvXMLElementExport aSourceElem(*this, XML_NAMESPACE_TABLE, XML_TABLE_SOURCE, sal_True, sal_True); + } + } + } + } + } + } + } +} + +// core implementation +void ScXMLExport::WriteScenario() +{ + if (pDoc && pDoc->IsScenario(nCurrentTable)) + { + String sComment; + Color aColor; + sal_uInt16 nFlags; + pDoc->GetScenarioData(nCurrentTable, sComment, aColor, nFlags); + if (!(nFlags & SC_SCENARIO_SHOWFRAME)) + AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY_BORDER, XML_FALSE); + ::rtl::OUStringBuffer aBuffer; + SvXMLUnitConverter::convertColor(aBuffer, aColor); + AddAttribute(XML_NAMESPACE_TABLE, XML_BORDER_COLOR, aBuffer.makeStringAndClear()); + if (!(nFlags & SC_SCENARIO_TWOWAY)) + AddAttribute(XML_NAMESPACE_TABLE, XML_COPY_BACK, XML_FALSE); + if (!(nFlags & SC_SCENARIO_ATTRIB)) + AddAttribute(XML_NAMESPACE_TABLE, XML_COPY_STYLES, XML_FALSE); + if (nFlags & SC_SCENARIO_VALUE) + AddAttribute(XML_NAMESPACE_TABLE, XML_COPY_FORMULAS, XML_FALSE); + SvXMLUnitConverter::convertBool(aBuffer, pDoc->IsActiveScenario(nCurrentTable)); + AddAttribute(XML_NAMESPACE_TABLE, XML_IS_ACTIVE, aBuffer.makeStringAndClear()); + const ScRangeList* pRangeList = pDoc->GetScenarioRanges(nCurrentTable); + ::rtl::OUString sRangeListStr; + ScXMLConverter::GetStringFromRangeList( sRangeListStr, pRangeList, pDoc ); + AddAttribute(XML_NAMESPACE_TABLE, XML_SCENARIO_RANGES, sRangeListStr); + if (sComment.Len()) + AddAttribute(XML_NAMESPACE_TABLE, XML_COMMENT, ::rtl::OUString(sComment)); + SvXMLElementExport aElem(*this, XML_NAMESPACE_TABLE, XML_SCENARIO, sal_True, sal_True); + } +} + +void ScXMLExport::WriteTheLabelRanges( const uno::Reference< sheet::XSpreadsheetDocument >& xSpreadDoc ) +{ + uno::Reference< beans::XPropertySet > xDocProp( xSpreadDoc, uno::UNO_QUERY ); + if( !xDocProp.is() ) return; + + sal_Int32 nCount = 0; + uno::Any aAny = xDocProp->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_COLLABELRNG ) ) ); + uno::Reference< sheet::XLabelRanges > xLabelRanges; + uno::Reference< container::XIndexAccess > xColRangesIAccess; + if( aAny >>= xLabelRanges ) + xColRangesIAccess = uno::Reference< container::XIndexAccess >( xLabelRanges, uno::UNO_QUERY ); + if( xColRangesIAccess.is() ) + nCount += xColRangesIAccess->getCount(); + + aAny = xDocProp->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_ROWLABELRNG ) ) ); + uno::Reference< container::XIndexAccess > xRowRangesIAccess; + if( aAny >>= xLabelRanges ) + xRowRangesIAccess = uno::Reference< container::XIndexAccess >( xLabelRanges, uno::UNO_QUERY ); + if( xRowRangesIAccess.is() ) + nCount += xRowRangesIAccess->getCount(); + + if( nCount ) + { + SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, XML_LABEL_RANGES, sal_True, sal_True ); + WriteLabelRanges( xColRangesIAccess, sal_True ); + WriteLabelRanges( xRowRangesIAccess, sal_False ); + } +} + +void ScXMLExport::WriteLabelRanges( const uno::Reference< container::XIndexAccess >& xRangesIAccess, sal_Bool bColumn ) +{ + if( !xRangesIAccess.is() ) return; + + sal_Int32 nCount = xRangesIAccess->getCount(); + for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ ) + { + uno::Any aRangeAny = xRangesIAccess->getByIndex( nIndex ); + uno::Reference< sheet::XLabelRange > xRange; + if( aRangeAny >>= xRange ) + { + OUString sRangeStr; + table::CellRangeAddress aCellRange( xRange->getLabelArea() ); + ScXMLConverter::GetStringFromRange( sRangeStr, aCellRange, pDoc ); + AddAttribute( XML_NAMESPACE_TABLE, XML_LABEL_CELL_RANGE_ADDRESS, sRangeStr ); + aCellRange = xRange->getDataArea(); + ScXMLConverter::GetStringFromRange( sRangeStr, aCellRange, pDoc ); + AddAttribute( XML_NAMESPACE_TABLE, XML_DATA_CELL_RANGE_ADDRESS, sRangeStr ); + AddAttribute( XML_NAMESPACE_TABLE, XML_ORIENTATION, bColumn ? XML_COLUMN : XML_ROW ); + SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, XML_LABEL_RANGE, sal_True, sal_True ); + } + } +} + +void ScXMLExport::WriteNamedExpressions(const ::com::sun::star::uno::Reference < ::com::sun::star::sheet::XSpreadsheetDocument>& xSpreadDoc) +{ + uno::Reference <beans::XPropertySet> xPropertySet (xSpreadDoc, uno::UNO_QUERY); + if (xPropertySet.is()) + { + uno::Any aNamedRanges = xPropertySet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_NAMEDRANGES))); + uno::Reference <sheet::XNamedRanges> xNamedRanges; + CheckAttrList(); + if (aNamedRanges >>= xNamedRanges) + { + uno::Sequence <rtl::OUString> aRangesNames = xNamedRanges->getElementNames(); + sal_Int32 nNamedRangesCount = aRangesNames.getLength(); + if (nNamedRangesCount > 0) + { + if (pDoc) + { + ScRangeName* pNamedRanges = pDoc->GetRangeName(); + SvXMLElementExport aElemNEs(*this, XML_NAMESPACE_TABLE, XML_NAMED_EXPRESSIONS, sal_True, sal_True); + for (sal_Int32 i = 0; i < nNamedRangesCount; i++) + { + CheckAttrList(); + ::rtl::OUString sNamedRange = aRangesNames[i]; + uno::Any aNamedRange = xNamedRanges->getByName(sNamedRange); + uno::Reference <sheet::XNamedRange> xNamedRange; + if (aNamedRange >>= xNamedRange) + { + uno::Reference <container::XNamed> xNamed (xNamedRange, uno::UNO_QUERY); + uno::Reference <sheet::XCellRangeReferrer> xCellRangeReferrer (xNamedRange, uno::UNO_QUERY); + if (xNamed.is() && xCellRangeReferrer.is()) + { + ::rtl::OUString sOUName = xNamed->getName(); + AddAttribute(sAttrName, sOUName); + + OUString sOUBaseCellAddress; + ScXMLConverter::GetStringFromAddress( sOUBaseCellAddress, + xNamedRange->getReferencePosition(), pDoc, sal_False, SCA_ABS_3D ); + AddAttribute(XML_NAMESPACE_TABLE, XML_BASE_CELL_ADDRESS, sOUBaseCellAddress); + + sal_uInt16 nRangeIndex; + String sName(sOUName); + pNamedRanges->SearchName(sName, nRangeIndex); + ScRangeData* pNamedRange = (*pNamedRanges)[nRangeIndex]; //should get directly and not with ScDocument + String sContent(xNamedRange->getContent()); + pNamedRange->GetEnglishSymbol(sContent, sal_True); + ::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(); + ::rtl::OUStringBuffer sBufferRangeType; + if ((nRangeType & sheet::NamedRangeFlag::COLUMN_HEADER) == sheet::NamedRangeFlag::COLUMN_HEADER) + sBufferRangeType.append(GetXMLToken(XML_REPEAT_COLUMN)); + if ((nRangeType & sheet::NamedRangeFlag::ROW_HEADER) == sheet::NamedRangeFlag::ROW_HEADER) + { + if (sBufferRangeType.getLength() > 0) + sBufferRangeType.appendAscii(" "); + sBufferRangeType.append(GetXMLToken(XML_REPEAT_ROW)); + } + if ((nRangeType & sheet::NamedRangeFlag::FILTER_CRITERIA) == sheet::NamedRangeFlag::FILTER_CRITERIA) + { + if (sBufferRangeType.getLength() > 0) + sBufferRangeType.appendAscii(" "); + sBufferRangeType.append(GetXMLToken(XML_FILTER)); + } + if ((nRangeType & sheet::NamedRangeFlag::PRINT_AREA) == sheet::NamedRangeFlag::PRINT_AREA) + { + if (sBufferRangeType.getLength() > 0) + sBufferRangeType.appendAscii(" "); + sBufferRangeType.append(GetXMLToken(XML_PRINT_RANGE)); + } + ::rtl::OUString sRangeType = sBufferRangeType.makeStringAndClear(); + 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); + SvXMLElementExport aElemNE(*this, XML_NAMESPACE_TABLE, XML_NAMED_EXPRESSION, sal_True, sal_True); + } + } + } + } + } + } + } + } +} + +// core implementation +void ScXMLExport::WriteConsolidation() +{ + if (pDoc) + { + const ScConsolidateParam* pCons = pDoc->GetConsolidateDlgData(); + if( pCons ) + { + OUString sStrData; + + ScXMLConverter::GetStringFromFunction( sStrData, pCons->eFunction ); + AddAttribute( XML_NAMESPACE_TABLE, XML_FUNCTION, sStrData ); + + sStrData = OUString(); + for( sal_Int32 nIndex = 0; nIndex < pCons->nDataAreaCount; nIndex++ ) + ScXMLConverter::GetStringFromArea( sStrData, *pCons->ppDataAreas[ nIndex ], pDoc, sal_True ); + AddAttribute( XML_NAMESPACE_TABLE, XML_SOURCE_CELL_RANGE_ADDRESSES, sStrData ); + + ScXMLConverter::GetStringFromAddress( sStrData, ScAddress( pCons->nCol, pCons->nRow, pCons->nTab ), pDoc ); + AddAttribute( XML_NAMESPACE_TABLE, XML_TARGET_CELL_ADDRESS, sStrData ); + + if( pCons->bByCol && !pCons->bByRow ) + AddAttribute( XML_NAMESPACE_TABLE, XML_USE_LABEL, XML_COLUMN ); + else if( !pCons->bByCol && pCons->bByRow ) + AddAttribute( XML_NAMESPACE_TABLE, XML_USE_LABEL, XML_ROW ); + else if( pCons->bByCol && pCons->bByRow ) + AddAttribute( XML_NAMESPACE_TABLE, XML_USE_LABEL, XML_BOTH ); + + if( pCons->bReferenceData ) + AddAttribute( XML_NAMESPACE_TABLE, XML_LINK_TO_SOURCE_DATA, XML_TRUE ); + + SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, XML_CONSOLIDATION, sal_True, sal_True ); + } + } +} + +SvXMLAutoStylePoolP* ScXMLExport::CreateAutoStylePool() +{ + return new ScXMLAutoStylePoolP(*this); +} + +XMLPageExport* ScXMLExport::CreatePageExport() +{ + return new XMLTableMasterPageExport( *this ); +} + +void ScXMLExport::GetChangeTrackViewSettings(uno::Sequence<beans::PropertyValue>& rProps) +{ + ScChangeViewSettings* pViewSettings = GetDocument() ? GetDocument()->GetChangeViewSettings() : NULL; + if (pViewSettings) + { + sal_Int32 nChangePos(rProps.getLength()); + rProps.realloc(nChangePos + 1); + beans::PropertyValue* pProps = rProps.getArray(); + if (pProps) + { + uno::Sequence<beans::PropertyValue> aChangeProps(SC_VIEWCHANGES_COUNT); + beans::PropertyValue* pChangeProps = aChangeProps.getArray(); + if (pChangeProps) + { + pChangeProps[SC_SHOW_CHANGES].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowChanges")); + pChangeProps[SC_SHOW_CHANGES].Value <<= pViewSettings->ShowChanges(); + pChangeProps[SC_SHOW_ACCEPTED_CHANGES].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowAcceptedChanges")); + pChangeProps[SC_SHOW_ACCEPTED_CHANGES].Value <<= pViewSettings->IsShowAccepted(); + pChangeProps[SC_SHOW_REJECTED_CHANGES].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowRejectedChanges")); + pChangeProps[SC_SHOW_REJECTED_CHANGES].Value <<= pViewSettings->IsShowRejected(); + pChangeProps[SC_SHOW_CHANGES_BY_DATETIME].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowChangesByDatetime")); + pChangeProps[SC_SHOW_CHANGES_BY_DATETIME].Value <<= pViewSettings->HasDate(); + pChangeProps[SC_SHOW_CHANGES_BY_DATETIME_MODE].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowChangesByDatetimeMode")); + pChangeProps[SC_SHOW_CHANGES_BY_DATETIME_MODE].Value <<= static_cast<sal_Int16>(pViewSettings->GetTheDateMode()); + util::DateTime aDateTime; + ScXMLConverter::ConvertCoreToAPIDateTime(pViewSettings->GetTheFirstDateTime(), aDateTime); + pChangeProps[SC_SHOW_CHANGES_BY_DATETIME_FIRST_DATETIME].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowChangesByDatetimeFirstDatetime")); + pChangeProps[SC_SHOW_CHANGES_BY_DATETIME_FIRST_DATETIME].Value <<= aDateTime; + ScXMLConverter::ConvertCoreToAPIDateTime(pViewSettings->GetTheLastDateTime(), aDateTime); + pChangeProps[SC_SHOW_CHANGES_BY_DATETIME_SECOND_DATETIME].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowChangesByDatetimeSecondDatetime")); + pChangeProps[SC_SHOW_CHANGES_BY_DATETIME_SECOND_DATETIME].Value <<= aDateTime; + pChangeProps[SC_SHOW_CHANGES_BY_AUTHOR].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowChangesByAuthor")); + pChangeProps[SC_SHOW_CHANGES_BY_AUTHOR].Value <<= pViewSettings->HasAuthor(); + pChangeProps[SC_SHOW_CHANGES_BY_AUTHOR_NAME].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowChangesByAuthorName")); + pChangeProps[SC_SHOW_CHANGES_BY_AUTHOR_NAME].Value <<= ::rtl::OUString (pViewSettings->GetTheAuthorToShow()); + pChangeProps[SC_SHOW_CHANGES_BY_COMMENT].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowChangesByComment")); + pChangeProps[SC_SHOW_CHANGES_BY_COMMENT].Value <<= pViewSettings->HasComment(); + pChangeProps[SC_SHOW_CHANGES_BY_COMMENT_TEXT].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowChangesByCommentText")); + pChangeProps[SC_SHOW_CHANGES_BY_COMMENT_TEXT].Value <<= ::rtl::OUString (pViewSettings->GetTheComment()); + pChangeProps[SC_SHOW_CHANGES_BY_RANGES].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowChangesByRanges")); + pChangeProps[SC_SHOW_CHANGES_BY_RANGES].Value <<= pViewSettings->HasRange(); + ::rtl::OUString sRangeList; + ScXMLConverter::GetStringFromRangeList(sRangeList, &(pViewSettings->GetTheRangeList()), GetDocument()); + pChangeProps[SC_SHOW_CHANGES_BY_RANGES_LIST].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowChangesByRangesList")); + pChangeProps[SC_SHOW_CHANGES_BY_RANGES_LIST].Value <<= sRangeList; + + pProps[nChangePos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TrackedChangesViewSettings")); + pProps[nChangePos].Value <<= aChangeProps; + } + } + } +} + +void ScXMLExport::GetViewSettings(uno::Sequence<beans::PropertyValue>& rProps) +{ + rProps.realloc(4); + beans::PropertyValue* pProps = rProps.getArray(); + if(pProps) + { + if (GetModel().is()) + { + ScModelObj* pDocObj = ScModelObj::getImplementation( GetModel() ); + if (pDocObj) + { + SvEmbeddedObject* pEmbeddedObj = pDocObj->GetEmbeddedObject(); + if (pEmbeddedObj) + { + Rectangle aRect(pEmbeddedObj->GetVisArea()); + sal_uInt16 i(0); + pProps[i].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VisibleAreaTop")); + pProps[i++].Value <<= aRect.getY(); + pProps[i].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VisibleAreaLeft")); + pProps[i++].Value <<= aRect.getX(); + pProps[i].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VisibleAreaWidth")); + pProps[i++].Value <<= aRect.getWidth(); + pProps[i].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VisibleAreaHeight")); + pProps[i++].Value <<= aRect.getHeight(); + } + } + } + } + GetChangeTrackViewSettings(rProps); +} + +void ScXMLExport::GetConfigurationSettings(uno::Sequence<beans::PropertyValue>& rProps) +{ + if (GetModel().is()) + { + uno::Reference <lang::XMultiServiceFactory> xMultiServiceFactory(GetModel(), uno::UNO_QUERY); + if (xMultiServiceFactory.is()) + { + uno::Reference <uno::XInterface> xInterface = xMultiServiceFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.SpreadsheetSettings"))); + uno::Reference <beans::XPropertySet> xProperties(xInterface, uno::UNO_QUERY); + if (xProperties.is()) + SvXMLUnitConverter::convertPropertySet(rProps, xProperties); + } + } +} + +XMLShapeExport* ScXMLExport::CreateShapeExport() +{ + return new ScXMLShapeExport(*this); +} + +void ScXMLExport::CreateSharedData(const sal_Int32 nTableCount) +{ + pSharedData = new ScMySharedData(nTableCount); +} + +XMLNumberFormatAttributesExportHelper* ScXMLExport::GetNumberFormatAttributesExportHelper() +{ + if (!pNumberFormatAttributesExportHelper) + pNumberFormatAttributesExportHelper = new XMLNumberFormatAttributesExportHelper(GetNumberFormatsSupplier(), *this, XML_NAMESPACE_TABLE); + return pNumberFormatAttributesExportHelper; +} + +void ScXMLExport::CollectUserDefinedNamespaces(const SfxItemPool* pPool, sal_uInt16 nAttrib) +{ + const SfxPoolItem* pItem; + sal_uInt16 nItems = pPool->GetItemCount( nAttrib ); + for( sal_uInt16 i = 0; i < nItems; ++i ) + { + if( 0 != (pItem = pPool->GetItem( nAttrib, i ) ) ) + { + const SvXMLAttrContainerItem *pUnknown = + (const SvXMLAttrContainerItem *)pItem; + if( (pUnknown->GetAttrCount() > 0) ) + { + sal_uInt16 nIdx = pUnknown->GetFirstNamespaceIndex(); + while( USHRT_MAX != nIdx ) + { + if( (XML_NAMESPACE_UNKNOWN_FLAG & nIdx) != 0 ) + { + const OUString& rPrefix = pUnknown->GetPrefix( nIdx ); + // Add namespace declaration for unknown attributes if + // there aren't existing ones for the prefix used by the + // attibutes + _GetNamespaceMap().Add( rPrefix, + pUnknown->GetNamespace( nIdx ), + XML_NAMESPACE_UNKNOWN ); + } + nIdx = pUnknown->GetNextNamespaceIndex( nIdx ); + } + } + } + } +} + +sal_uInt32 ScXMLExport::exportDoc( enum XMLTokenEnum eClass ) +{ + if( (getExportFlags() & (EXPORT_FONTDECLS|EXPORT_STYLES| + EXPORT_MASTERSTYLES|EXPORT_CONTENT)) != 0 ) + { + if (GetDocument()) + { + CollectUserDefinedNamespaces(GetDocument()->GetPool(), ATTR_USERDEF); + CollectUserDefinedNamespaces(GetDocument()->GetEditPool(), EE_PARA_XMLATTRIBS); + CollectUserDefinedNamespaces(GetDocument()->GetEditPool(), EE_CHAR_XMLATTRIBS); + ScDrawLayer* pDrawLayer = GetDocument()->GetDrawLayer(); + if (pDrawLayer) + { + CollectUserDefinedNamespaces(&pDrawLayer->GetItemPool(), EE_PARA_XMLATTRIBS); + CollectUserDefinedNamespaces(&pDrawLayer->GetItemPool(), EE_CHAR_XMLATTRIBS); + CollectUserDefinedNamespaces(&pDrawLayer->GetItemPool(), SDRATTR_XMLATTRIBUTES); + } + } + } + return SvXMLExport::exportDoc( eClass ); +} + +// XExporter +void SAL_CALL ScXMLExport::setSourceDocument( const uno::Reference<lang::XComponent>& xComponent ) + throw(lang::IllegalArgumentException, uno::RuntimeException) +{ + SolarMutexGuard aGuard; + SvXMLExport::setSourceDocument( xComponent ); + + pDoc = ScXMLConverter::GetScDocument( GetModel() ); + DBG_ASSERT( pDoc, "ScXMLExport::setSourceDocument - no ScDocument!" ); + if (!pDoc) + throw lang::IllegalArgumentException(); + + // create ScChangeTrackingExportHelper after document is known + pChangeTrackingExportHelper = new ScChangeTrackingExportHelper(*this); +} + +// XFilter +sal_Bool SAL_CALL ScXMLExport::filter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor ) + throw(::com::sun::star::uno::RuntimeException) +{ + SolarMutexGuard aGuard; + return SvXMLExport::filter(aDescriptor); +} + +void SAL_CALL ScXMLExport::cancel() + throw(::com::sun::star::uno::RuntimeException) +{ + SolarMutexGuard aGuard; + SvXMLExport::cancel(); +} + +// XInitialization +void SAL_CALL ScXMLExport::initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) + throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) +{ + SolarMutexGuard aGuard; + SvXMLExport::initialize(aArguments); +} + +// XServiceInfo +::rtl::OUString SAL_CALL ScXMLExport::getImplementationName( ) + throw(::com::sun::star::uno::RuntimeException) +{ + SolarMutexGuard aGuard; + switch( getExportFlags() ) + { + case EXPORT_ALL: + return ScXMLExport_getImplementationName(); + break; + case (EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_FONTDECLS): + return ScXMLExport_Styles_getImplementationName(); + break; + case (EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_FONTDECLS): + return ScXMLExport_Content_getImplementationName(); + break; + case EXPORT_META: + return ScXMLExport_Meta_getImplementationName(); + break; + case EXPORT_SETTINGS: + return ScXMLExport_Settings_getImplementationName(); + break; + default: + // generic name for 'unknown' cases + return ScXMLExport_getImplementationName(); + break; + } + return SvXMLExport::getImplementationName(); +} + +sal_Bool SAL_CALL ScXMLExport::supportsService( const ::rtl::OUString& ServiceName ) + throw(::com::sun::star::uno::RuntimeException) +{ + SolarMutexGuard aGuard; + return SvXMLExport::supportsService( ServiceName ); +} + +::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL ScXMLExport::getSupportedServiceNames( ) + throw(::com::sun::star::uno::RuntimeException) +{ + SolarMutexGuard aGuard; + return SvXMLExport::getSupportedServiceNames(); +} + +// XUnoTunnel +sal_Int64 SAL_CALL ScXMLExport::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) + throw(::com::sun::star::uno::RuntimeException) +{ + SolarMutexGuard aGuard; + return SvXMLExport::getSomething(aIdentifier); +} + +void ScXMLExport::DisposingModel() +{ + SvXMLExport::DisposingModel(); + pDoc = NULL; + xCurrentTable = 0; +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_xmlfilti.cxx b/binfilter/bf_sc/source/filter/xml/sc_xmlfilti.cxx new file mode 100644 index 000000000000..2288a7810d5c --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_xmlfilti.cxx @@ -0,0 +1,785 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "xmlfilti.hxx" +#include "xmlimprt.hxx" + +#include "convuno.hxx" +#include "XMLConverter.hxx" + +#include <bf_xmloff/nmspmap.hxx> +namespace binfilter { + +using namespace ::com::sun::star; +using namespace xmloff::token; + +//------------------------------------------------------------------ + +ScXMLFilterContext::ScXMLFilterContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDatabaseRangeContext* pTempDatabaseRangeContext) : + bSkipDuplicates(sal_False), + bUseRegularExpressions(sal_False), + bConnectionOr(sal_True), + bNextConnectionOr(sal_True), + bCopyOutputData(sal_False), + bConditionSourceRange(sal_False), + aFilterFields(), + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + ScDocument* pDoc = GetScImport().GetDocument(); + pDatabaseRangeContext = pTempDatabaseRangeContext; + + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetFilterAttrTokenMap(); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_FILTER_ATTR_TARGET_RANGE_ADDRESS : + { + ScRange aScRange; + sal_Int32 nOffset(0); + if (ScXMLConverter::GetRangeFromString( aScRange, sValue, pDoc, nOffset )) + { + ScUnoConversion::FillApiAddress( aOutputPosition, aScRange.aStart ); + bCopyOutputData = sal_True; + } + } + break; + case XML_TOK_FILTER_ATTR_CONDITION_SOURCE_RANGE_ADDRESS : + { + sal_Int32 nOffset(0); + if (ScXMLConverter::GetRangeFromString( aConditionSourceRangeAddress, sValue, pDoc, nOffset )) + bConditionSourceRange = sal_True; + } + break; + case XML_TOK_FILTER_ATTR_CONDITION_SOURCE : + { + // not supported by StarOffice + } + break; + case XML_TOK_FILTER_ATTR_DISPLAY_DUPLICATES : + { + bSkipDuplicates = !IsXMLToken(sValue, XML_TRUE); + } + break; + } + } +} + +ScXMLFilterContext::~ScXMLFilterContext() +{ +} + +SvXMLImportContext *ScXMLFilterContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + const SvXMLTokenMap& rTokenMap = GetScImport().GetFilterElemTokenMap(); + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + case XML_TOK_FILTER_AND: + { + pContext = new ScXMLAndContext( GetScImport(), nPrefix, + rLName, xAttrList, this); + } + break; + case XML_TOK_FILTER_OR: + { + pContext = new ScXMLOrContext( GetScImport(), nPrefix, + rLName, xAttrList, this); + } + break; + case XML_TOK_FILTER_CONDITION: + { + pContext = new ScXMLConditionContext( GetScImport(), nPrefix, + rLName, xAttrList, this); + } + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLFilterContext::EndElement() +{ + pDatabaseRangeContext->SetFilterUseRegularExpressions(bUseRegularExpressions); + if (bCopyOutputData) + { + pDatabaseRangeContext->SetFilterOutputPosition(aOutputPosition); + pDatabaseRangeContext->SetFilterCopyOutputData(bCopyOutputData); + } + else + pDatabaseRangeContext->SetFilterCopyOutputData(sal_False); + pDatabaseRangeContext->SetFilterIsCaseSensitive(bIsCaseSensitive); + pDatabaseRangeContext->SetFilterSkipDuplicates(bSkipDuplicates); + pDatabaseRangeContext->SetFilterFields(aFilterFields); + if (bConditionSourceRange) + pDatabaseRangeContext->SetFilterConditionSourceRangeAddress(aConditionSourceRangeAddress); +} + +ScXMLAndContext::ScXMLAndContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLFilterContext* pTempFilterContext) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + pFilterContext = pTempFilterContext; + pFilterContext->OpenConnection(sal_False); +} + +ScXMLAndContext::~ScXMLAndContext() +{ +} + +SvXMLImportContext *ScXMLAndContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + const SvXMLTokenMap& rTokenMap = GetScImport().GetFilterElemTokenMap(); + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + case XML_TOK_FILTER_OR: + { + // not supported in StarOffice + } + break; + case XML_TOK_FILTER_CONDITION: + { + pContext = new ScXMLConditionContext( GetScImport(), nPrefix, + rLName, xAttrList, pFilterContext); + } + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLAndContext::EndElement() +{ + pFilterContext->CloseConnection(); +} + +ScXMLOrContext::ScXMLOrContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLFilterContext* pTempFilterContext) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + pFilterContext = pTempFilterContext; + pFilterContext->OpenConnection(sal_True); +} + +ScXMLOrContext::~ScXMLOrContext() +{ +} + +SvXMLImportContext *ScXMLOrContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + const SvXMLTokenMap& rTokenMap = GetScImport().GetFilterElemTokenMap(); + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + case XML_TOK_FILTER_AND: + { + pContext = new ScXMLAndContext( GetScImport(), nPrefix, + rLName, xAttrList, pFilterContext); + } + break; + case XML_TOK_FILTER_CONDITION: + { + pContext = new ScXMLConditionContext( GetScImport(), nPrefix, + rLName, xAttrList, pFilterContext); + } + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLOrContext::EndElement() +{ + pFilterContext->CloseConnection(); +} + +ScXMLConditionContext::ScXMLConditionContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLFilterContext* pTempFilterContext) : + bIsCaseSensitive(sal_False), + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + pFilterContext = pTempFilterContext; + sDataType = GetXMLToken(XML_TEXT); + + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetFilterConditionAttrTokenMap(); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_CONDITION_ATTR_FIELD_NUMBER : + { + nField = sValue.toInt32(); + } + break; + case XML_TOK_CONDITION_ATTR_CASE_SENSITIVE : + { + bIsCaseSensitive = IsXMLToken(sValue, XML_TRUE); + } + break; + case XML_TOK_CONDITION_ATTR_DATA_TYPE : + { + sDataType = sValue; + } + break; + case XML_TOK_CONDITION_ATTR_VALUE : + { + sConditionValue = sValue; + } + break; + case XML_TOK_CONDITION_ATTR_OPERATOR : + { + sOperator = sValue; + } + break; + } + } +} + +ScXMLConditionContext::~ScXMLConditionContext() +{ +} + +SvXMLImportContext *ScXMLConditionContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLConditionContext::getOperatorXML(const ::rtl::OUString sTempOperator, sheet::FilterOperator& aFilterOperator, sal_Bool& bUseRegularExpressions) const +{ + bUseRegularExpressions = sal_False; + if (IsXMLToken(sTempOperator, XML_MATCH)) + { + bUseRegularExpressions = sal_True; + aFilterOperator = sheet::FilterOperator_EQUAL; + } + else if (IsXMLToken(sTempOperator, XML_NOMATCH)) + { + bUseRegularExpressions = sal_True; + aFilterOperator = sheet::FilterOperator_NOT_EQUAL; + } + else if (sTempOperator.compareToAscii("=") == 0) + aFilterOperator = sheet::FilterOperator_EQUAL; + else if (sTempOperator.compareToAscii("!=") == 0) + aFilterOperator = sheet::FilterOperator_NOT_EQUAL; + else if (IsXMLToken(sTempOperator, XML_BOTTOM_PERCENT)) + aFilterOperator = sheet::FilterOperator_BOTTOM_PERCENT; + else if (IsXMLToken(sTempOperator, XML_BOTTOM_VALUES)) + aFilterOperator = sheet::FilterOperator_BOTTOM_VALUES; + else if (IsXMLToken(sTempOperator, XML_EMPTY)) + aFilterOperator = sheet::FilterOperator_EMPTY; + else if (sTempOperator.compareToAscii(">") == 0) + aFilterOperator = sheet::FilterOperator_GREATER; + else if (sTempOperator.compareToAscii(">=") == 0) + aFilterOperator = sheet::FilterOperator_GREATER_EQUAL; + else if (sTempOperator.compareToAscii("<") == 0) + aFilterOperator = sheet::FilterOperator_LESS; + else if (sTempOperator.compareToAscii("<=") == 0) + aFilterOperator = sheet::FilterOperator_LESS_EQUAL; + else if (IsXMLToken(sTempOperator, XML_NOEMPTY)) + aFilterOperator = sheet::FilterOperator_NOT_EMPTY; + else if (IsXMLToken(sTempOperator, XML_TOP_PERCENT)) + aFilterOperator = sheet::FilterOperator_TOP_PERCENT; + else if (IsXMLToken(sTempOperator, XML_TOP_VALUES)) + aFilterOperator = sheet::FilterOperator_TOP_VALUES; +} + +void ScXMLConditionContext::EndElement() +{ + sheet::TableFilterField aFilterField; + if (pFilterContext->GetConnection()) + aFilterField.Connection = sheet::FilterConnection_OR; + else + aFilterField.Connection = sheet::FilterConnection_AND; + pFilterContext->SetIsCaseSensitive(bIsCaseSensitive); + sal_Bool bUseRegularExpressions; + getOperatorXML(sOperator, aFilterField.Operator, bUseRegularExpressions); + pFilterContext->SetUseRegularExpressions(bUseRegularExpressions); + aFilterField.Field = nField; + if (IsXMLToken(sDataType, XML_NUMBER)) + { + aFilterField.NumericValue = sConditionValue.toDouble(); + aFilterField.IsNumeric = sal_True; + } + else + { + aFilterField.StringValue = sConditionValue; + aFilterField.IsNumeric = sal_False; + } + pFilterContext->AddFilterField(aFilterField); +} + +//========================================================================== + +ScXMLDPFilterContext::ScXMLDPFilterContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDataPilotTableContext* pTempDataPilotTableContext) : + bSkipDuplicates(sal_False), + bUseRegularExpressions(sal_False), + bConnectionOr(sal_True), + bNextConnectionOr(sal_True), + bCopyOutputData(sal_False), + bConditionSourceRange(sal_False), + aFilterFields(), + SvXMLImportContext( rImport, nPrfx, rLName ), + nFilterFieldCount(0) +{ + ScDocument* pDoc = GetScImport().GetDocument(); + pDataPilotTable = pTempDataPilotTableContext; + + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetFilterAttrTokenMap(); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_FILTER_ATTR_TARGET_RANGE_ADDRESS : + { + ScRange aScRange; + sal_Int32 nOffset(0); + if (ScXMLConverter::GetRangeFromString( aScRange, sValue, pDoc, nOffset )) + { + aOutputPosition = aScRange.aStart; + bCopyOutputData = sal_True; + } + } + break; + case XML_TOK_FILTER_ATTR_CONDITION_SOURCE_RANGE_ADDRESS : + { + sal_Int32 nOffset(0); + if(ScXMLConverter::GetRangeFromString( aConditionSourceRangeAddress, sValue, pDoc, nOffset )) + bConditionSourceRange = sal_True; + } + break; + case XML_TOK_FILTER_ATTR_CONDITION_SOURCE : + { + // not supported by StarOffice + } + break; + case XML_TOK_FILTER_ATTR_DISPLAY_DUPLICATES : + { + bSkipDuplicates = !IsXMLToken(sValue, XML_TRUE); + } + break; + } + } +} + +ScXMLDPFilterContext::~ScXMLDPFilterContext() +{ +} + +SvXMLImportContext *ScXMLDPFilterContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + const SvXMLTokenMap& rTokenMap = GetScImport().GetFilterElemTokenMap(); + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + case XML_TOK_FILTER_AND: + { + pContext = new ScXMLDPAndContext( GetScImport(), nPrefix, + rLName, xAttrList, this); + } + break; + case XML_TOK_FILTER_OR: + { + pContext = new ScXMLDPOrContext( GetScImport(), nPrefix, + rLName, xAttrList, this); + } + break; + case XML_TOK_FILTER_CONDITION: + { + pContext = new ScXMLDPConditionContext( GetScImport(), nPrefix, + rLName, xAttrList, this); + } + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLDPFilterContext::EndElement() +{ + aFilterFields.bRegExp = bUseRegularExpressions; + aFilterFields.bCaseSens = bIsCaseSensitive; + aFilterFields.bDuplicate = !bSkipDuplicates; +// pDataPilotTable->SetFilterUseRegularExpressions(bUseRegularExpressions); + if (bCopyOutputData) + { + pDataPilotTable->SetFilterOutputPosition(aOutputPosition); + pDataPilotTable->SetFilterCopyOutputData(bCopyOutputData); + } + else + pDataPilotTable->SetFilterCopyOutputData(sal_False); +// pDataPilotTable->SetFilterIsCaseSensitive(bIsCaseSensitive); +// pDataPilotTable->SetFilterSkipDuplicates(bSkipDuplicates); + pDataPilotTable->SetSourceQueryParam(aFilterFields); + if (bConditionSourceRange) + pDataPilotTable->SetFilterSourceRange(aConditionSourceRangeAddress); +} + +void ScXMLDPFilterContext::AddFilterField (const ScQueryEntry& aFilterField) +{ + aFilterFields.Resize(nFilterFieldCount + 1); + ScQueryEntry& rEntry = aFilterFields.GetEntry(nFilterFieldCount); + rEntry = aFilterField; + rEntry.bDoQuery = sal_True; + nFilterFieldCount++; +} + +ScXMLDPAndContext::ScXMLDPAndContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDPFilterContext* pTempFilterContext) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + pFilterContext = pTempFilterContext; + pFilterContext->OpenConnection(sal_False); +} + +ScXMLDPAndContext::~ScXMLDPAndContext() +{ +} + +SvXMLImportContext *ScXMLDPAndContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + const SvXMLTokenMap& rTokenMap = GetScImport().GetFilterElemTokenMap(); + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + case XML_TOK_FILTER_OR: + { + // not supported in StarOffice + } + break; + case XML_TOK_FILTER_CONDITION: + { + pContext = new ScXMLDPConditionContext( GetScImport(), nPrefix, + rLName, xAttrList, pFilterContext); + } + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLDPAndContext::EndElement() +{ + pFilterContext->CloseConnection(); +} + +ScXMLDPOrContext::ScXMLDPOrContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDPFilterContext* pTempFilterContext) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + pFilterContext = pTempFilterContext; + pFilterContext->OpenConnection(sal_True); +} + +ScXMLDPOrContext::~ScXMLDPOrContext() +{ +} + +SvXMLImportContext *ScXMLDPOrContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + const SvXMLTokenMap& rTokenMap = GetScImport().GetFilterElemTokenMap(); + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + case XML_TOK_FILTER_AND: + { + pContext = new ScXMLDPAndContext( GetScImport(), nPrefix, + rLName, xAttrList, pFilterContext); + } + break; + case XML_TOK_FILTER_CONDITION: + { + pContext = new ScXMLDPConditionContext( GetScImport(), nPrefix, + rLName, xAttrList, pFilterContext); + } + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLDPOrContext::EndElement() +{ + pFilterContext->CloseConnection(); +} + +ScXMLDPConditionContext::ScXMLDPConditionContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDPFilterContext* pTempFilterContext) : + bIsCaseSensitive(sal_False), + SvXMLImportContext( rImport, nPrfx, rLName ), + sDataType(GetXMLToken(XML_TEXT)) +{ + pFilterContext = pTempFilterContext; + + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetFilterConditionAttrTokenMap(); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_CONDITION_ATTR_FIELD_NUMBER : + { + nField = sValue.toInt32(); + } + break; + case XML_TOK_CONDITION_ATTR_CASE_SENSITIVE : + { + bIsCaseSensitive = IsXMLToken(sValue, XML_TRUE); + } + break; + case XML_TOK_CONDITION_ATTR_DATA_TYPE : + { + sDataType = sValue; + } + break; + case XML_TOK_CONDITION_ATTR_VALUE : + { + sConditionValue = sValue; + } + break; + case XML_TOK_CONDITION_ATTR_OPERATOR : + { + sOperator = sValue; + } + break; + } + } +} + +ScXMLDPConditionContext::~ScXMLDPConditionContext() +{ +} + +SvXMLImportContext *ScXMLDPConditionContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLDPConditionContext::getOperatorXML(const ::rtl::OUString sTempOperator, ScQueryOp& aFilterOperator, sal_Bool& bUseRegularExpressions, + double& dVal) const +{ + bUseRegularExpressions = sal_False; + if (IsXMLToken(sTempOperator, XML_MATCH)) + { + bUseRegularExpressions = sal_True; + aFilterOperator = SC_EQUAL; + } + else if (IsXMLToken(sTempOperator, XML_NOMATCH)) + { + bUseRegularExpressions = sal_True; + aFilterOperator = SC_NOT_EQUAL; + } + else if (sTempOperator.compareToAscii("=") == 0) + aFilterOperator = SC_EQUAL; + else if (sTempOperator.compareToAscii("!=") == 0) + aFilterOperator = SC_NOT_EQUAL; + else if (IsXMLToken(sTempOperator, XML_BOTTOM_PERCENT)) + aFilterOperator = SC_BOTPERC; + else if (IsXMLToken(sTempOperator, XML_BOTTOM_VALUES)) + aFilterOperator = SC_BOTVAL; + else if (IsXMLToken(sTempOperator, XML_EMPTY)) + dVal = SC_EMPTYFIELDS; + else if (sTempOperator.compareToAscii(">") == 0) + aFilterOperator = SC_GREATER; + else if (sTempOperator.compareToAscii(">=") == 0) + aFilterOperator = SC_GREATER_EQUAL; + else if (sTempOperator.compareToAscii("<") == 0) + aFilterOperator = SC_LESS; + else if (sTempOperator.compareToAscii("<=") == 0) + aFilterOperator = SC_LESS_EQUAL; + else if (IsXMLToken(sTempOperator, XML_NOEMPTY)) + dVal = SC_NONEMPTYFIELDS; + else if (IsXMLToken(sTempOperator, XML_TOP_PERCENT)) + aFilterOperator = SC_TOPPERC; + else if (IsXMLToken(sTempOperator, XML_TOP_VALUES)) + aFilterOperator = SC_TOPVAL; +} + +void ScXMLDPConditionContext::EndElement() +{ + ScQueryEntry aFilterField; + if (pFilterContext->GetConnection()) + aFilterField.eConnect = SC_OR; + else + aFilterField.eConnect = SC_AND; + pFilterContext->SetIsCaseSensitive(bIsCaseSensitive); + sal_Bool bUseRegularExpressions; + double dVal(0.0); + getOperatorXML(sOperator, aFilterField.eOp, bUseRegularExpressions, dVal); + pFilterContext->SetUseRegularExpressions(bUseRegularExpressions); + aFilterField.nField = static_cast<USHORT>(nField); + if (IsXMLToken(sDataType, XML_NUMBER)) + { + aFilterField.nVal = sConditionValue.toDouble(); + *aFilterField.pStr = sConditionValue; + aFilterField.bQueryByString = sal_False; + if (dVal != 0.0) + { + aFilterField.nVal = dVal; + *aFilterField.pStr = EMPTY_STRING; + } + } + else + { + aFilterField.pStr = new String(sConditionValue); + aFilterField.bQueryByString = sal_True; + aFilterField.nVal = 0; + } + pFilterContext->AddFilterField(aFilterField); +} + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_xmlfonte.cxx b/binfilter/bf_sc/source/filter/xml/sc_xmlfonte.cxx new file mode 100644 index 000000000000..31aea1906465 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_xmlfonte.cxx @@ -0,0 +1,156 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef PRECOMPILED +#endif + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include "scitems.hxx" + +#define ITEMID_FIELD EE_FEATURE_FIELD + +#include <bf_svx/fontitem.hxx> +#include <bf_svx/eeitem.hxx> +#include <bf_svx/editeng.hxx> + +#include "document.hxx" +#include "docpool.hxx" +#include "xmlexprt.hxx" +#include "stlpool.hxx" +#include "attrib.hxx" +namespace binfilter { + +class ScXMLFontAutoStylePool_Impl: public XMLFontAutoStylePool +{ + void AddFontItems(sal_uInt16* pWhichIds, sal_uInt8 nIdCount, const SfxItemPool* pPool, const sal_Bool bExportDefaults); + public: + + ScXMLFontAutoStylePool_Impl( ScXMLExport& rExport ); + +}; + +void ScXMLFontAutoStylePool_Impl::AddFontItems(sal_uInt16* pWhichIds, sal_uInt8 nIdCount, const SfxItemPool* pPool, const sal_Bool bExportDefaults) +{ + const SfxPoolItem* pItem; + for( sal_uInt16 i=0; i < nIdCount; i++ ) + { + sal_uInt16 nWhichId = pWhichIds[i]; + if (bExportDefaults && (0 != (pItem = &pPool->GetDefaultItem(nWhichId)))) + { + const SvxFontItem *pFont = + (const SvxFontItem *)pItem; + Add( pFont->GetFamilyName(), pFont->GetStyleName(), + pFont->GetFamily(), pFont->GetPitch(), + pFont->GetCharSet() ); + } + sal_uInt16 nItems = pPool->GetItemCount( nWhichId ); + for( sal_uInt16 j = 0; j < nItems; ++j ) + { + if( 0 != (pItem = pPool->GetItem( nWhichId, j ) ) ) + { + const SvxFontItem *pFont = + (const SvxFontItem *)pItem; + Add( pFont->GetFamilyName(), pFont->GetStyleName(), + pFont->GetFamily(), pFont->GetPitch(), + pFont->GetCharSet() ); + } + } + } +} + +ScXMLFontAutoStylePool_Impl::ScXMLFontAutoStylePool_Impl( + ScXMLExport& rExport ) : + XMLFontAutoStylePool( rExport ) +{ + sal_uInt16 aWhichIds[3] = { ATTR_FONT, ATTR_CJK_FONT, + ATTR_CTL_FONT }; + sal_uInt16 aEditWhichIds[3] = { EE_CHAR_FONTINFO, EE_CHAR_FONTINFO_CJK, + EE_CHAR_FONTINFO_CTL }; + sal_uInt16 aPageWhichIds[4] = { ATTR_PAGE_HEADERLEFT, ATTR_PAGE_FOOTERLEFT, + ATTR_PAGE_HEADERRIGHT, ATTR_PAGE_FOOTERRIGHT }; + + const SfxItemPool* pPool = rExport.GetDocument() ? rExport.GetDocument()->GetPool() : NULL; + AddFontItems(aWhichIds, 3, pPool, sal_True); + const SfxItemPool* pEditPool = rExport.GetDocument()->GetEditPool(); + AddFontItems(aEditWhichIds, 3, pEditPool, sal_False); + + SfxStyleSheetIterator* pItr = rExport.GetDocument() ? rExport.GetDocument()->GetStyleSheetPool()->CreateIterator(SFX_STYLE_FAMILY_PAGE, 0xFFFF) : NULL; + if(pItr) + { + SfxStyleSheetBase* pStyle = pItr->First(); + SfxItemPool* pPageEditPool = EditEngine::CreatePool(); + EditEngine aEditEngine(pPageEditPool); + while (pStyle) + { + const SfxItemPool& rPagePool = pStyle->GetPool().GetPool(); + for (sal_uInt8 j = 0; j < 4; j++) + { + sal_uInt16 nPageWhichId = aPageWhichIds[j]; + sal_uInt16 nPageHFItems = rPagePool.GetItemCount(nPageWhichId); + const ScPageHFItem* pPageItem; + for (sal_uInt16 k = 0; k < nPageHFItems; k++) + { + if (0 != (pPageItem = static_cast<const ScPageHFItem*>(rPagePool.GetItem(nPageWhichId, k)))) + { + const EditTextObject* pLeftArea = pPageItem->GetLeftArea(); + if (pLeftArea) + { + aEditEngine.SetText(*pLeftArea); + AddFontItems(aEditWhichIds, 3, pPageEditPool, sal_False); + } + const EditTextObject* pCenterArea = pPageItem->GetCenterArea(); + if (pCenterArea) + { + aEditEngine.SetText(*pCenterArea); + AddFontItems(aEditWhichIds, 3, pPageEditPool, sal_False); + } + const EditTextObject* pRightArea = pPageItem->GetRightArea(); + if (pRightArea) + { + aEditEngine.SetText(*pRightArea); + AddFontItems(aEditWhichIds, 3, pPageEditPool, sal_False); + } + } + } + } + pStyle = pItr->Next(); + } + } +} + + +XMLFontAutoStylePool* ScXMLExport::CreateFontAutoStylePool() +{ + return new ScXMLFontAutoStylePool_Impl( *this ); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_xmlimprt.cxx b/binfilter/bf_sc/source/filter/xml/sc_xmlimprt.cxx new file mode 100644 index 000000000000..a6ecfbef9aed --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_xmlimprt.cxx @@ -0,0 +1,2205 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include <bf_xmloff/nmspmap.hxx> +#include <bf_xmloff/xmlnmspe.hxx> +#include <bf_xmloff/xmlmetai.hxx> +#include <bf_xmloff/xmlnumfi.hxx> +#include <bf_xmloff/xmlscripti.hxx> +#include <bf_xmloff/XMLFontStylesContext.hxx> +#include <bf_xmloff/DocumentSettingsContext.hxx> +#include <bf_xmloff/xmluconv.hxx> +#include <bf_xmloff/numehelp.hxx> +#include <bf_xmloff/xmlerror.hxx> + +#include <vcl/svapp.hxx> +#include "docuno.hxx" +#include "xmlbodyi.hxx" +#include "xmlstyli.hxx" +#include "ViewSettingsSequenceDefines.hxx" + +#include "XMLConverter.hxx" +#include "XMLTableShapeImportHelper.hxx" +#include "XMLChangeTrackingImportHelper.hxx" +#include "chgviset.hxx" +#include "XMLStylesImportHelper.hxx" +#include "unonames.hxx" +#include <comphelper/extract.hxx> + +#include <com/sun/star/util/NumberFormat.hpp> +#include <bf_so3/embobj.hxx> +namespace binfilter { + +#define SC_LOCALE "Locale" +#define SC_STANDARDFORMAT "StandardFormat" +#define SC_CURRENCYSYMBOL "CurrencySymbol" + +using namespace ::com::sun::star; +using namespace ::binfilter::xmloff::token; + +using rtl::OUString; + +OUString SAL_CALL ScXMLImport_getImplementationName() throw() +{ + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Calc.XMLImporter" ) ); +} + +uno::Sequence< ::rtl::OUString > SAL_CALL ScXMLImport_getSupportedServiceNames() throw() +{ + const ::rtl::OUString aServiceName( ScXMLImport_getImplementationName() ); + const uno::Sequence< ::rtl::OUString > aSeq( &aServiceName, 1 ); + return aSeq; +} + +uno::Reference< uno::XInterface > SAL_CALL ScXMLImport_createInstance( + const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception ) +{ + // #110680# + // return (cppu::OWeakObject*)new ScXMLImport(IMPORT_ALL); + return (cppu::OWeakObject*)new ScXMLImport( rSMgr, IMPORT_ALL ); +} + +OUString SAL_CALL ScXMLImport_Meta_getImplementationName() throw() +{ + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Calc.XMLMetaImporter" ) ); +} + +uno::Sequence< ::rtl::OUString > SAL_CALL ScXMLImport_Meta_getSupportedServiceNames() throw() +{ + const ::rtl::OUString aServiceName( ScXMLImport_Meta_getImplementationName() ); + const uno::Sequence< ::rtl::OUString > aSeq( &aServiceName, 1 ); + return aSeq; +} + +uno::Reference< uno::XInterface > SAL_CALL ScXMLImport_Meta_createInstance( + const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception ) +{ + // #110680# + // return (cppu::OWeakObject*)new ScXMLImport(IMPORT_META); + return (cppu::OWeakObject*)new ScXMLImport( rSMgr, IMPORT_META ); +} + +OUString SAL_CALL ScXMLImport_Styles_getImplementationName() throw() +{ + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Calc.XMLStylesImporter" ) ); +} + +uno::Sequence< ::rtl::OUString > SAL_CALL ScXMLImport_Styles_getSupportedServiceNames() throw() +{ + const ::rtl::OUString aServiceName( ScXMLImport_Styles_getImplementationName() ); + const uno::Sequence< ::rtl::OUString > aSeq( &aServiceName, 1 ); + return aSeq; +} + +uno::Reference< uno::XInterface > SAL_CALL ScXMLImport_Styles_createInstance( + const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception ) +{ + // #110680# + // return (cppu::OWeakObject*)new ScXMLImport(IMPORT_STYLES|IMPORT_AUTOSTYLES|IMPORT_MASTERSTYLES|IMPORT_FONTDECLS); + return (cppu::OWeakObject*)new ScXMLImport( rSMgr, IMPORT_STYLES|IMPORT_AUTOSTYLES|IMPORT_MASTERSTYLES|IMPORT_FONTDECLS); +} + +OUString SAL_CALL ScXMLImport_Content_getImplementationName() throw() +{ + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Calc.XMLContentImporter" ) ); +} + +uno::Sequence< ::rtl::OUString > SAL_CALL ScXMLImport_Content_getSupportedServiceNames() throw() +{ + const ::rtl::OUString aServiceName( ScXMLImport_Content_getImplementationName() ); + const uno::Sequence< ::rtl::OUString > aSeq( &aServiceName, 1 ); + return aSeq; +} + +uno::Reference< uno::XInterface > SAL_CALL ScXMLImport_Content_createInstance( + const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception ) +{ + // #110680# + // return (cppu::OWeakObject*)new ScXMLImport(IMPORT_META|IMPORT_STYLES|IMPORT_MASTERSTYLES|IMPORT_AUTOSTYLES|IMPORT_CONTENT|IMPORT_SCRIPTS|IMPORT_SETTINGS|IMPORT_FONTDECLS); + return (cppu::OWeakObject*)new ScXMLImport( rSMgr, IMPORT_META|IMPORT_STYLES|IMPORT_MASTERSTYLES|IMPORT_AUTOSTYLES|IMPORT_CONTENT|IMPORT_SCRIPTS|IMPORT_SETTINGS|IMPORT_FONTDECLS); +} + +OUString SAL_CALL ScXMLImport_Settings_getImplementationName() throw() +{ + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Calc.XMLSettingsImporter" ) ); +} + +uno::Sequence< ::rtl::OUString > SAL_CALL ScXMLImport_Settings_getSupportedServiceNames() throw() +{ + const ::rtl::OUString aServiceName( ScXMLImport_Settings_getImplementationName() ); + const uno::Sequence< ::rtl::OUString > aSeq( &aServiceName, 1 ); + return aSeq; +} + +uno::Reference< uno::XInterface > SAL_CALL ScXMLImport_Settings_createInstance( + const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception ) +{ + // #110680# + // return (cppu::OWeakObject*)new ScXMLImport(IMPORT_SETTINGS); + return (cppu::OWeakObject*)new ScXMLImport( rSMgr, IMPORT_SETTINGS ); +} + +//---------------------------------------------------------------------------- + +static __FAR_DATA SvXMLTokenMapEntry aDocTokenMap[] = +{ + { XML_NAMESPACE_OFFICE, XML_FONT_DECLS, XML_TOK_DOC_FONTDECLS }, + { XML_NAMESPACE_OFFICE, XML_STYLES, XML_TOK_DOC_STYLES }, + { XML_NAMESPACE_OFFICE, XML_AUTOMATIC_STYLES, XML_TOK_DOC_AUTOSTYLES }, + { XML_NAMESPACE_OFFICE, XML_MASTER_STYLES, XML_TOK_DOC_MASTERSTYLES }, + { XML_NAMESPACE_OFFICE, XML_META, XML_TOK_DOC_META }, + { XML_NAMESPACE_OFFICE, XML_SCRIPT, XML_TOK_DOC_SCRIPTS }, + { XML_NAMESPACE_OFFICE, XML_BODY, XML_TOK_DOC_BODY }, + { XML_NAMESPACE_OFFICE, XML_SETTINGS, XML_TOK_DOC_SETTINGS }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aBodyTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_TRACKED_CHANGES, XML_TOK_BODY_TRACKED_CHANGES }, + { XML_NAMESPACE_TABLE, XML_CALCULATION_SETTINGS, XML_TOK_BODY_CALCULATION_SETTINGS }, + { XML_NAMESPACE_TABLE, XML_CONTENT_VALIDATIONS, XML_TOK_BODY_CONTENT_VALIDATIONS }, + { XML_NAMESPACE_TABLE, XML_LABEL_RANGES, XML_TOK_BODY_LABEL_RANGES }, + { XML_NAMESPACE_TABLE, XML_TABLE, XML_TOK_BODY_TABLE }, + { XML_NAMESPACE_TABLE, XML_NAMED_EXPRESSIONS, XML_TOK_BODY_NAMED_EXPRESSIONS }, + { XML_NAMESPACE_TABLE, XML_DATABASE_RANGES, XML_TOK_BODY_DATABASE_RANGES }, + { XML_NAMESPACE_TABLE, XML_DATABASE_RANGE, XML_TOK_BODY_DATABASE_RANGE }, + { XML_NAMESPACE_TABLE, XML_DATA_PILOT_TABLES, XML_TOK_BODY_DATA_PILOT_TABLES }, + { XML_NAMESPACE_TABLE, XML_CONSOLIDATION, XML_TOK_BODY_CONSOLIDATION }, + { XML_NAMESPACE_TABLE, XML_DDE_LINKS, XML_TOK_BODY_DDE_LINKS }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aContentValidationsElemTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_CONTENT_VALIDATION, XML_TOK_CONTENT_VALIDATION }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aContentValidationElemTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_HELP_MESSAGE, XML_TOK_CONTENT_VALIDATION_ELEM_HELP_MESSAGE }, + { XML_NAMESPACE_TABLE, XML_ERROR_MESSAGE, XML_TOK_CONTENT_VALIDATION_ELEM_ERROR_MESSAGE }, + { XML_NAMESPACE_TABLE, XML_ERROR_MACRO, XML_TOK_CONTENT_VALIDATION_ELEM_ERROR_MACRO }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aContentValidationAttrTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_CONTENT_VALIDATION_NAME }, + { XML_NAMESPACE_TABLE, XML_CONDITION, XML_TOK_CONTENT_VALIDATION_CONDITION }, + { XML_NAMESPACE_TABLE, XML_BASE_CELL_ADDRESS, XML_TOK_CONTENT_VALIDATION_BASE_CELL_ADDRESS }, + { XML_NAMESPACE_TABLE, XML_ALLOW_EMPTY_CELL, XML_TOK_CONTENT_VALIDATION_ALLOW_EMPTY_CELL }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aContentValidationMessageElemTokenMap[] = +{ + { XML_NAMESPACE_TEXT, XML_P, XML_TOK_P }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aContentValidationHelpMessageAttrTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_TITLE, XML_TOK_HELP_MESSAGE_ATTR_TITLE }, + { XML_NAMESPACE_TABLE, XML_DISPLAY, XML_TOK_HELP_MESSAGE_ATTR_DISPLAY }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aContentValidationErrorMessageAttrTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_TITLE, XML_TOK_ERROR_MESSAGE_ATTR_TITLE }, + { XML_NAMESPACE_TABLE, XML_DISPLAY, XML_TOK_ERROR_MESSAGE_ATTR_DISPLAY }, + { XML_NAMESPACE_TABLE, XML_MESSAGE_TYPE, XML_TOK_ERROR_MESSAGE_ATTR_MESSAGE_TYPE }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aContentValidationErrorMacroAttrTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_ERROR_MACRO_ATTR_NAME }, + { XML_NAMESPACE_TABLE, XML_EXECUTE, XML_TOK_ERROR_MACRO_ATTR_EXECUTE }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aLabelRangesElemTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_LABEL_RANGE, XML_TOK_LABEL_RANGE_ELEM }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aLabelRangeAttrTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_LABEL_CELL_RANGE_ADDRESS, XML_TOK_LABEL_RANGE_ATTR_LABEL_RANGE }, + { XML_NAMESPACE_TABLE, XML_DATA_CELL_RANGE_ADDRESS, XML_TOK_LABEL_RANGE_ATTR_DATA_RANGE }, + { XML_NAMESPACE_TABLE, XML_ORIENTATION, XML_TOK_LABEL_RANGE_ATTR_ORIENTATION }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aTableTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_TABLE_COLUMN_GROUP, XML_TOK_TABLE_COL_GROUP }, + { XML_NAMESPACE_TABLE, XML_TABLE_HEADER_COLUMNS, XML_TOK_TABLE_HEADER_COLS }, + { XML_NAMESPACE_TABLE, XML_TABLE_COLUMNS, XML_TOK_TABLE_COLS }, + { XML_NAMESPACE_TABLE, XML_TABLE_COLUMN, XML_TOK_TABLE_COL }, + { XML_NAMESPACE_TABLE, XML_TABLE_ROW_GROUP, XML_TOK_TABLE_ROW_GROUP }, + { XML_NAMESPACE_TABLE, XML_TABLE_HEADER_ROWS, XML_TOK_TABLE_HEADER_ROWS }, + { XML_NAMESPACE_TABLE, XML_TABLE_ROWS, XML_TOK_TABLE_ROWS }, + { XML_NAMESPACE_TABLE, XML_TABLE_ROW, XML_TOK_TABLE_ROW }, + { XML_NAMESPACE_TABLE, XML_TABLE_SOURCE, XML_TOK_TABLE_SOURCE }, + { XML_NAMESPACE_TABLE, XML_SCENARIO, XML_TOK_TABLE_SCENARIO }, + { XML_NAMESPACE_TABLE, XML_SHAPES, XML_TOK_TABLE_SHAPES }, + { XML_NAMESPACE_OFFICE, XML_FORMS, XML_TOK_TABLE_FORMS }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aTableRowsElemTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_TABLE_ROW_GROUP, XML_TOK_TABLE_ROWS_ROW_GROUP }, + { XML_NAMESPACE_TABLE, XML_TABLE_HEADER_ROWS, XML_TOK_TABLE_ROWS_HEADER_ROWS }, + { XML_NAMESPACE_TABLE, XML_TABLE_ROWS, XML_TOK_TABLE_ROWS_ROWS }, + { XML_NAMESPACE_TABLE, XML_TABLE_ROW, XML_TOK_TABLE_ROWS_ROW }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aTableColsElemTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_TABLE_COLUMN_GROUP, XML_TOK_TABLE_COLS_COL_GROUP }, + { XML_NAMESPACE_TABLE, XML_TABLE_HEADER_COLUMNS, XML_TOK_TABLE_COLS_HEADER_COLS }, + { XML_NAMESPACE_TABLE, XML_TABLE_COLUMNS, XML_TOK_TABLE_COLS_COLS }, + { XML_NAMESPACE_TABLE, XML_TABLE_COLUMN, XML_TOK_TABLE_COLS_COL }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aTableAttrTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_TABLE_NAME }, + { XML_NAMESPACE_TABLE, XML_STYLE_NAME, XML_TOK_TABLE_STYLE_NAME }, + { XML_NAMESPACE_TABLE, XML_PROTECTED, XML_TOK_TABLE_PROTECTION }, + { XML_NAMESPACE_TABLE, XML_PRINT_RANGES, XML_TOK_TABLE_PRINT_RANGES }, + { XML_NAMESPACE_TABLE, XML_PROTECTION_KEY, XML_TOK_TABLE_PASSWORD }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aTableScenarioAttrTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_DISPLAY_BORDER, XML_TOK_TABLE_SCENARIO_ATTR_DISPLAY_BORDER }, + { XML_NAMESPACE_TABLE, XML_BORDER_COLOR, XML_TOK_TABLE_SCENARIO_ATTR_BORDER_COLOR }, + { XML_NAMESPACE_TABLE, XML_COPY_BACK, XML_TOK_TABLE_SCENARIO_ATTR_COPY_BACK }, + { XML_NAMESPACE_TABLE, XML_COPY_STYLES, XML_TOK_TABLE_SCENARIO_ATTR_COPY_STYLES }, + { XML_NAMESPACE_TABLE, XML_COPY_FORMULAS, XML_TOK_TABLE_SCENARIO_ATTR_COPY_FORMULAS }, + { XML_NAMESPACE_TABLE, XML_IS_ACTIVE, XML_TOK_TABLE_SCENARIO_ATTR_IS_ACTIVE }, + { XML_NAMESPACE_TABLE, XML_SCENARIO_RANGES, XML_TOK_TABLE_SCENARIO_ATTR_SCENARIO_RANGES }, + { XML_NAMESPACE_TABLE, XML_COMMENT, XML_TOK_TABLE_SCENARIO_ATTR_COMMENT }, + XML_TOKEN_MAP_END +}; + + +static __FAR_DATA SvXMLTokenMapEntry aTableColAttrTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_STYLE_NAME, XML_TOK_TABLE_COL_ATTR_STYLE_NAME }, + { XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED, XML_TOK_TABLE_COL_ATTR_REPEATED }, + { XML_NAMESPACE_TABLE, XML_VISIBILITY, XML_TOK_TABLE_COL_ATTR_VISIBILITY }, + { XML_NAMESPACE_TABLE, XML_DEFAULT_CELL_STYLE_NAME, XML_TOK_TABLE_COL_ATTR_DEFAULT_CELL_STYLE_NAME }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aTableRowTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_TABLE_CELL, XML_TOK_TABLE_ROW_CELL }, + { XML_NAMESPACE_TABLE, XML_COVERED_TABLE_CELL, XML_TOK_TABLE_ROW_COVERED_CELL }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aTableRowAttrTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_STYLE_NAME, XML_TOK_TABLE_ROW_ATTR_STYLE_NAME }, + { XML_NAMESPACE_TABLE, XML_VISIBILITY, XML_TOK_TABLE_ROW_ATTR_VISIBILITY }, + { XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_REPEATED, XML_TOK_TABLE_ROW_ATTR_REPEATED }, + { XML_NAMESPACE_TABLE, XML_DEFAULT_CELL_STYLE_NAME, XML_TOK_TABLE_ROW_ATTR_DEFAULT_CELL_STYLE_NAME }, +// { XML_NAMESPACE_TABLE, XML_USE_OPTIMAL_HEIGHT, XML_TOK_TABLE_ROW_ATTR_USE_OPTIMAL_HEIGHT }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aTableRowCellTokenMap[] = +{ + { XML_NAMESPACE_TEXT, XML_P, XML_TOK_TABLE_ROW_CELL_P }, + { XML_NAMESPACE_TABLE, XML_SUB_TABLE, XML_TOK_TABLE_ROW_CELL_SUBTABLE }, + { XML_NAMESPACE_OFFICE, XML_ANNOTATION, XML_TOK_TABLE_ROW_CELL_ANNOTATION }, + { XML_NAMESPACE_TABLE, XML_DETECTIVE, XML_TOK_TABLE_ROW_CELL_DETECTIVE }, + { XML_NAMESPACE_TABLE, XML_CELL_RANGE_SOURCE, XML_TOK_TABLE_ROW_CELL_CELL_RANGE_SOURCE }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aTableAnnotationAttrTokenMap[] = +{ + { XML_NAMESPACE_OFFICE, XML_AUTHOR, XML_TOK_TABLE_ANNOTATION_ATTR_AUTHOR }, + { XML_NAMESPACE_OFFICE, XML_CREATE_DATE, XML_TOK_TABLE_ANNOTATION_ATTR_CREATE_DATE }, + { XML_NAMESPACE_OFFICE, XML_CREATE_DATE_STRING, XML_TOK_TABLE_ANNOTATION_ATTR_CREATE_DATE_STRING }, + { XML_NAMESPACE_OFFICE, XML_DISPLAY, XML_TOK_TABLE_ANNOTATION_ATTR_DISPLAY }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aDetectiveElemTokenMap[]= +{ + { XML_NAMESPACE_TABLE, XML_HIGHLIGHTED_RANGE, XML_TOK_DETECTIVE_ELEM_HIGHLIGHTED }, + { XML_NAMESPACE_TABLE, XML_OPERATION, XML_TOK_DETECTIVE_ELEM_OPERATION }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aDetectiveHighlightedAttrTokenMap[]= +{ + { XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, XML_TOK_DETECTIVE_HIGHLIGHTED_ATTR_CELL_RANGE }, + { XML_NAMESPACE_TABLE, XML_DIRECTION, XML_TOK_DETECTIVE_HIGHLIGHTED_ATTR_DIRECTION }, + { XML_NAMESPACE_TABLE, XML_CONTAINS_ERROR, XML_TOK_DETECTIVE_HIGHLIGHTED_ATTR_CONTAINS_ERROR }, + { XML_NAMESPACE_TABLE, XML_MARKED_INVALID, XML_TOK_DETECTIVE_HIGHLIGHTED_ATTR_MARKED_INVALID }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aDetectiveOperationAttrTokenMap[]= +{ + { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_DETECTIVE_OPERATION_ATTR_NAME }, + { XML_NAMESPACE_TABLE, XML_INDEX, XML_TOK_DETECTIVE_OPERATION_ATTR_INDEX }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aTableCellRangeSourceAttrTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_NAME }, + { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_HREF }, + { XML_NAMESPACE_TABLE, XML_FILTER_NAME, XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_FILTER_NAME }, + { XML_NAMESPACE_TABLE, XML_FILTER_OPTIONS, XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_FILTER_OPTIONS }, + { XML_NAMESPACE_TABLE, XML_LAST_COLUMN_SPANNED, XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_LAST_COLUMN }, + { XML_NAMESPACE_TABLE, XML_LAST_ROW_SPANNED, XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_LAST_ROW }, + { XML_NAMESPACE_TABLE, XML_REFRESH_DELAY, XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_REFRESH_DELAY }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aNamedExpressionsTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_NAMED_RANGE, XML_TOK_NAMED_EXPRESSIONS_NAMED_RANGE }, + { XML_NAMESPACE_TABLE, XML_NAMED_EXPRESSION, XML_TOK_NAMED_EXPRESSIONS_NAMED_EXPRESSION }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aNamedRangeAttrTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_NAMED_RANGE_ATTR_NAME }, + { XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, XML_TOK_NAMED_RANGE_ATTR_CELL_RANGE_ADDRESS }, + { XML_NAMESPACE_TABLE, XML_BASE_CELL_ADDRESS, XML_TOK_NAMED_RANGE_ATTR_BASE_CELL_ADDRESS }, + { XML_NAMESPACE_TABLE, XML_RANGE_USABLE_AS, XML_TOK_NAMED_RANGE_ATTR_RANGE_USABLE_AS }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aNamedExpressionAttrTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_NAMED_EXPRESSION_ATTR_NAME }, + { XML_NAMESPACE_TABLE, XML_BASE_CELL_ADDRESS, XML_TOK_NAMED_EXPRESSION_ATTR_BASE_CELL_ADDRESS }, + { XML_NAMESPACE_TABLE, XML_EXPRESSION, XML_TOK_NAMED_EXPRESSION_ATTR_EXPRESSION }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aDatabaseRangesTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_DATABASE_RANGE, XML_TOK_DATABASE_RANGE }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aDatabaseRangeTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_DATABASE_SOURCE_SQL, XML_TOK_DATABASE_RANGE_SOURCE_SQL }, + { XML_NAMESPACE_TABLE, XML_DATABASE_SOURCE_TABLE, XML_TOK_DATABASE_RANGE_SOURCE_TABLE }, + { XML_NAMESPACE_TABLE, XML_DATABASE_SOURCE_QUERY, XML_TOK_DATABASE_RANGE_SOURCE_QUERY }, + { XML_NAMESPACE_TABLE, XML_FILTER, XML_TOK_FILTER }, + { XML_NAMESPACE_TABLE, XML_SORT, XML_TOK_SORT }, + { XML_NAMESPACE_TABLE, XML_SUBTOTAL_RULES, XML_TOK_DATABASE_RANGE_SUBTOTAL_RULES }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aDatabaseRangeAttrTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_DATABASE_RANGE_ATTR_NAME }, + { XML_NAMESPACE_TABLE, XML_IS_SELECTION, XML_TOK_DATABASE_RANGE_ATTR_IS_SELECTION }, + { XML_NAMESPACE_TABLE, XML_ON_UPDATE_KEEP_STYLES, XML_TOK_DATABASE_RANGE_ATTR_ON_UPDATE_KEEP_STYLES }, + { XML_NAMESPACE_TABLE, XML_ON_UPDATE_KEEP_SIZE, XML_TOK_DATABASE_RANGE_ATTR_ON_UPDATE_KEEP_SIZE }, + { XML_NAMESPACE_TABLE, XML_HAS_PERSISTENT_DATA, XML_TOK_DATABASE_RANGE_ATTR_HAS_PERSISTENT_DATA }, + { XML_NAMESPACE_TABLE, XML_ORIENTATION, XML_TOK_DATABASE_RANGE_ATTR_ORIENTATION }, + { XML_NAMESPACE_TABLE, XML_CONTAINS_HEADER, XML_TOK_DATABASE_RANGE_ATTR_CONTAINS_HEADER }, + { XML_NAMESPACE_TABLE, XML_DISPLAY_FILTER_BUTTONS, XML_TOK_DATABASE_RANGE_ATTR_DISPLAY_FILTER_BUTTONS }, + { XML_NAMESPACE_TABLE, XML_TARGET_RANGE_ADDRESS, XML_TOK_DATABASE_RANGE_ATTR_TARGET_RANGE_ADDRESS }, + { XML_NAMESPACE_TABLE, XML_REFRESH_DELAY, XML_TOK_DATABASE_RANGE_ATTR_REFRESH_DELAY }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aDatabaseRangeSourceSQLAttrTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_DATABASE_NAME, XML_TOK_SOURCE_SQL_ATTR_DATABASE_NAME }, + { XML_NAMESPACE_TABLE, XML_SQL_STATEMENT, XML_TOK_SOURCE_SQL_ATTR_SQL_STATEMENT }, + { XML_NAMESPACE_TABLE, XML_PARSE_SQL_STATEMENT, XML_TOK_SOURCE_SQL_ATTR_PARSE_SQL_STATEMENT }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aDatabaseRangeSourceTableAttrTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_DATABASE_NAME, XML_TOK_SOURCE_TABLE_ATTR_DATABASE_NAME }, + { XML_NAMESPACE_TABLE, XML_TABLE_NAME, XML_TOK_SOURCE_TABLE_ATTR_TABLE_NAME }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aDatabaseRangeSourceQueryAttrTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_DATABASE_NAME, XML_TOK_SOURCE_QUERY_ATTR_DATABASE_NAME }, + { XML_NAMESPACE_TABLE, XML_QUERY_NAME, XML_TOK_SOURCE_QUERY_ATTR_QUERY_NAME }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aFilterTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_FILTER_AND, XML_TOK_FILTER_AND }, + { XML_NAMESPACE_TABLE, XML_FILTER_OR, XML_TOK_FILTER_OR }, + { XML_NAMESPACE_TABLE, XML_FILTER_CONDITION, XML_TOK_FILTER_CONDITION }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aFilterAttrTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_TARGET_RANGE_ADDRESS, XML_TOK_FILTER_ATTR_TARGET_RANGE_ADDRESS }, + { XML_NAMESPACE_TABLE, XML_CONDITION_SOURCE_RANGE_ADDRESS, XML_TOK_FILTER_ATTR_CONDITION_SOURCE_RANGE_ADDRESS }, + { XML_NAMESPACE_TABLE, XML_CONDITION_SOURCE, XML_TOK_FILTER_ATTR_CONDITION_SOURCE }, + { XML_NAMESPACE_TABLE, XML_DISPLAY_DUPLICATES, XML_TOK_FILTER_ATTR_DISPLAY_DUPLICATES }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aFilterConditionAttrTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_FIELD_NUMBER, XML_TOK_CONDITION_ATTR_FIELD_NUMBER }, + { XML_NAMESPACE_TABLE, XML_CASE_SENSITIVE, XML_TOK_CONDITION_ATTR_CASE_SENSITIVE }, + { XML_NAMESPACE_TABLE, XML_DATA_TYPE, XML_TOK_CONDITION_ATTR_DATA_TYPE }, + { XML_NAMESPACE_TABLE, XML_VALUE, XML_TOK_CONDITION_ATTR_VALUE }, + { XML_NAMESPACE_TABLE, XML_OPERATOR, XML_TOK_CONDITION_ATTR_OPERATOR }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aSortTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_SORT_BY, XML_TOK_SORT_SORT_BY }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aSortAttrTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_BIND_STYLES_TO_CONTENT, XML_TOK_SORT_ATTR_BIND_STYLES_TO_CONTENT }, + { XML_NAMESPACE_TABLE, XML_TARGET_RANGE_ADDRESS, XML_TOK_SORT_ATTR_TARGET_RANGE_ADDRESS }, + { XML_NAMESPACE_TABLE, XML_CASE_SENSITIVE, XML_TOK_SORT_ATTR_CASE_SENSITIVE }, + { XML_NAMESPACE_TABLE, XML_LANGUAGE, XML_TOK_SORT_ATTR_LANGUAGE }, + { XML_NAMESPACE_TABLE, XML_COUNTRY, XML_TOK_SORT_ATTR_COUNTRY }, + { XML_NAMESPACE_TABLE, XML_ALGORITHM, XML_TOK_SORT_ATTR_ALGORITHM }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aSortSortByAttrTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_FIELD_NUMBER, XML_TOK_SORT_BY_ATTR_FIELD_NUMBER }, + { XML_NAMESPACE_TABLE, XML_DATA_TYPE, XML_TOK_SORT_BY_ATTR_DATA_TYPE }, + { XML_NAMESPACE_TABLE, XML_ORDER, XML_TOK_SORT_BY_ATTR_ORDER }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aDatabaseRangeSubTotalRulesTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_SORT_GROUPS, XML_TOK_SUBTOTAL_RULES_SORT_GROUPS }, + { XML_NAMESPACE_TABLE, XML_SUBTOTAL_RULE, XML_TOK_SUBTOTAL_RULES_SUBTOTAL_RULE }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aDatabaseRangeSubTotalRulesAttrTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_BIND_STYLES_TO_CONTENT, XML_TOK_SUBTOTAL_RULES_ATTR_BIND_STYLES_TO_CONTENT }, + { XML_NAMESPACE_TABLE, XML_CASE_SENSITIVE, XML_TOK_SUBTOTAL_RULES_ATTR_CASE_SENSITIVE }, + { XML_NAMESPACE_TABLE, XML_PAGE_BREAKS_ON_GROUP_CHANGE, XML_TOK_SUBTOTAL_RULES_ATTR_PAGE_BREAKS_ON_GROUP_CHANGE }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aSubTotalRulesSortGroupsAttrTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_DATA_TYPE, XML_TOK_SORT_GROUPS_ATTR_DATA_TYPE }, + { XML_NAMESPACE_TABLE, XML_ORDER, XML_TOK_SORT_GROUPS_ATTR_ORDER }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aSubTotalRulesSubTotalRuleTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_SUBTOTAL_FIELD, XML_TOK_SUBTOTAL_RULE_SUBTOTAL_FIELD }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aSubTotalRulesSubTotalRuleAttrTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_GROUP_BY_FIELD_NUMBER, XML_TOK_SUBTOTAL_RULE_ATTR_GROUP_BY_FIELD_NUMBER }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aSubTotalRuleSubTotalFieldAttrTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_FIELD_NUMBER, XML_TOK_SUBTOTAL_FIELD_ATTR_FIELD_NUMBER }, + { XML_NAMESPACE_TABLE, XML_FUNCTION, XML_TOK_SUBTOTAL_FIELD_ATTR_FUNCTION }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aDataPilotTablesElemTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_DATA_PILOT_TABLE, XML_TOK_DATA_PILOT_TABLE }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aDataPilotTableAttrTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_DATA_PILOT_TABLE_ATTR_NAME }, + { XML_NAMESPACE_TABLE, XML_APPLICATION_DATA, XML_TOK_DATA_PILOT_TABLE_ATTR_APPLICATION_DATA }, + { XML_NAMESPACE_TABLE, XML_GRAND_TOTAL, XML_TOK_DATA_PILOT_TABLE_ATTR_GRAND_TOTAL }, + { XML_NAMESPACE_TABLE, XML_IGNORE_EMPTY_ROWS, XML_TOK_DATA_PILOT_TABLE_ATTR_IGNORE_EMPTY_ROWS }, + { XML_NAMESPACE_TABLE, XML_IDENTIFY_CATEGORIES, XML_TOK_DATA_PILOT_TABLE_ATTR_IDENTIFY_CATEGORIES }, + { XML_NAMESPACE_TABLE, XML_TARGET_RANGE_ADDRESS, XML_TOK_DATA_PILOT_TABLE_ATTR_TARGET_RANGE_ADDRESS }, + { XML_NAMESPACE_TABLE, XML_BUTTONS, XML_TOK_DATA_PILOT_TABLE_ATTR_BUTTONS }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aDataPilotTableElemTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_DATABASE_SOURCE_SQL, XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_SQL }, + { XML_NAMESPACE_TABLE, XML_DATABASE_SOURCE_TABLE, XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_TABLE }, + { XML_NAMESPACE_TABLE, XML_DATABASE_SOURCE_QUERY, XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_QUERY }, + { XML_NAMESPACE_TABLE, XML_SOURCE_SERVICE, XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_SERVICE }, + { XML_NAMESPACE_TABLE, XML_SOURCE_CELL_RANGE, XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_CELL_RANGE }, + { XML_NAMESPACE_TABLE, XML_DATA_PILOT_FIELD, XML_TOK_DATA_PILOT_TABLE_ELEM_DATA_PILOT_FIELD }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aDataPilotTableSourceServiceAttrTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_SOURCE_SERVICE_ATTR_NAME }, + { XML_NAMESPACE_TABLE, XML_SOURCE_NAME, XML_TOK_SOURCE_SERVICE_ATTR_SOURCE_NAME }, + { XML_NAMESPACE_TABLE, XML_OBJECT_NAME, XML_TOK_SOURCE_SERVICE_ATTR_OBJECT_NAME }, + { XML_NAMESPACE_TABLE, XML_USERNAME, XML_TOK_SOURCE_SERVICE_ATTR_USERNAME }, + { XML_NAMESPACE_TABLE, XML_PASSWORT, XML_TOK_SOURCE_SERVICE_ATTR_PASSWORD }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aDataPilotTableSourceCellRangeAttrTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, XML_TOK_SOURCE_CELL_RANGE_ATTR_CELL_RANGE_ADDRESS}, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aDataPilotTableSourceCellRangeElemTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_FILTER, XML_TOK_SOURCE_CELL_RANGE_ELEM_FILTER}, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aDataPilotFieldAttrTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_SOURCE_FIELD_NAME, XML_TOK_DATA_PILOT_FIELD_ATTR_SOURCE_FIELD_NAME }, + { XML_NAMESPACE_TABLE, XML_IS_DATA_LAYOUT_FIELD, XML_TOK_DATA_PILOT_FIELD_ATTR_IS_DATA_LAYOUT_FIELD }, + { XML_NAMESPACE_TABLE, XML_FUNCTION, XML_TOK_DATA_PILOT_FIELD_ATTR_FUNCTION }, + { XML_NAMESPACE_TABLE, XML_ORIENTATION, XML_TOK_DATA_PILOT_FIELD_ATTR_ORIENTATION }, + { XML_NAMESPACE_TABLE, XML_USED_HIERARCHY, XML_TOK_DATA_PILOT_FIELD_ATTR_USED_HIERARCHY }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aDataPilotFieldElemTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_DATA_PILOT_LEVEL, XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_LEVEL }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aDataPilotLevelAttrTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_DISPLAY_EMPTY, XML_TOK_DATA_PILOT_LEVEL_ATTR_DISPLAY_EMPTY }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aDataPilotLevelElemTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_DATA_PILOT_SUBTOTALS, XML_TOK_DATA_PILOT_LEVEL_ELEM_DATA_PILOT_SUBTOTALS }, + { XML_NAMESPACE_TABLE, XML_DATA_PILOT_MEMBERS, XML_TOK_DATA_PILOT_LEVEL_ELEM_DATA_PILOT_MEMBERS }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aDataPilotSubTotalsElemTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_DATA_PILOT_SUBTOTAL, XML_TOK_DATA_PILOT_SUBTOTALS_ELEM_DATA_PILOT_SUBTOTAL }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aDataPilotSubTotalAttrTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_FUNCTION, XML_TOK_DATA_PILOT_SUBTOTAL_ATTR_FUNCTION }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aDataPilotMembersElemTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_DATA_PILOT_MEMBER, XML_TOK_DATA_PILOT_MEMBERS_ELEM_DATA_PILOT_MEMBER }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aDataPilotMemberAttrTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_DATA_PILOT_MEMBER_ATTR_NAME }, + { XML_NAMESPACE_TABLE, XML_DISPLAY, XML_TOK_DATA_PILOT_MEMBER_ATTR_DISPLAY }, + { XML_NAMESPACE_TABLE, XML_DISPLAY_DETAILS, XML_TOK_DATA_PILOT_MEMBER_ATTR_DISPLAY_DETAILS }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aConsolidationAttrTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_FUNCTION, XML_TOK_CONSOLIDATION_ATTR_FUNCTION }, + { XML_NAMESPACE_TABLE, XML_SOURCE_CELL_RANGE_ADDRESSES, XML_TOK_CONSOLIDATION_ATTR_SOURCE_RANGES }, + { XML_NAMESPACE_TABLE, XML_TARGET_CELL_ADDRESS, XML_TOK_CONSOLIDATION_ATTR_TARGET_ADDRESS }, + { XML_NAMESPACE_TABLE, XML_USE_LABEL, XML_TOK_CONSOLIDATION_ATTR_USE_LABEL }, + { XML_NAMESPACE_TABLE, XML_LINK_TO_SOURCE_DATA, XML_TOK_CONSOLIDATION_ATTR_LINK_TO_SOURCE }, + XML_TOKEN_MAP_END +}; + + +class ScXMLDocContext_Impl : public SvXMLImportContext +{ + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLDocContext_Impl( ScXMLImport& rImport, + USHORT nPrfx, + const OUString& rLName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList ); + virtual ~ScXMLDocContext_Impl(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList ); +}; + +ScXMLDocContext_Impl::ScXMLDocContext_Impl( ScXMLImport& rImport, USHORT nPrfx, + const OUString& rLName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList ) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + +} + +ScXMLDocContext_Impl::~ScXMLDocContext_Impl() +{ +} + +SvXMLImportContext *ScXMLDocContext_Impl::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + const SvXMLTokenMap& rTokenMap = GetScImport().GetDocElemTokenMap(); + switch( rTokenMap.Get( nPrefix, rLocalName ) ) + { + case XML_TOK_DOC_FONTDECLS: + if (GetScImport().getImportFlags() & IMPORT_FONTDECLS) + pContext = GetScImport().CreateFontDeclsContext(nPrefix, rLocalName, xAttrList); + break; + case XML_TOK_DOC_STYLES: + if (GetScImport().getImportFlags() & IMPORT_STYLES) + pContext = GetScImport().CreateStylesContext( rLocalName, xAttrList, sal_False); + break; + case XML_TOK_DOC_AUTOSTYLES: + if (GetScImport().getImportFlags() & IMPORT_AUTOSTYLES) + pContext = GetScImport().CreateStylesContext( rLocalName, xAttrList, sal_True); + break; + break; + case XML_TOK_DOC_MASTERSTYLES: + if (GetScImport().getImportFlags() & IMPORT_MASTERSTYLES) + pContext = new ScXMLMasterStylesContext( GetImport(), nPrefix, rLocalName, + xAttrList ); + break; + case XML_TOK_DOC_META: + if (GetScImport().getImportFlags() & IMPORT_META) + pContext = GetScImport().CreateMetaContext( rLocalName ); + break; + case XML_TOK_DOC_SCRIPTS: + if (GetScImport().getImportFlags() & IMPORT_SCRIPTS) + pContext = GetScImport().CreateScriptContext( rLocalName ); + break; + case XML_TOK_DOC_BODY: + if (GetScImport().getImportFlags() & IMPORT_CONTENT) + pContext = GetScImport().CreateBodyContext( rLocalName, xAttrList ); + break; + case XML_TOK_DOC_SETTINGS: + if (GetScImport().getImportFlags() & IMPORT_SETTINGS) + pContext = new XMLDocumentSettingsContext(GetScImport(), nPrefix, rLocalName, xAttrList ); + break; + } + + if(!pContext) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + + return pContext; +} + +const SvXMLTokenMap& ScXMLImport::GetDocElemTokenMap() +{ + if( !pDocElemTokenMap ) + pDocElemTokenMap = new SvXMLTokenMap( aDocTokenMap ); + + return *pDocElemTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetBodyElemTokenMap() +{ + if( !pBodyElemTokenMap ) + pBodyElemTokenMap = new SvXMLTokenMap( aBodyTokenMap ); + return *pBodyElemTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetContentValidationsElemTokenMap() +{ + if( !pContentValidationsElemTokenMap ) + pContentValidationsElemTokenMap = new SvXMLTokenMap( aContentValidationsElemTokenMap ); + return *pContentValidationsElemTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetContentValidationElemTokenMap() +{ + if( !pContentValidationElemTokenMap ) + pContentValidationElemTokenMap = new SvXMLTokenMap( aContentValidationElemTokenMap ); + return *pContentValidationElemTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetContentValidationAttrTokenMap() +{ + if( !pContentValidationAttrTokenMap ) + pContentValidationAttrTokenMap = new SvXMLTokenMap( aContentValidationAttrTokenMap ); + return *pContentValidationAttrTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetContentValidationMessageElemTokenMap() +{ + if( !pContentValidationMessageElemTokenMap ) + pContentValidationMessageElemTokenMap = new SvXMLTokenMap( aContentValidationMessageElemTokenMap ); + return *pContentValidationMessageElemTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetContentValidationHelpMessageAttrTokenMap() +{ + if( !pContentValidationHelpMessageAttrTokenMap ) + pContentValidationHelpMessageAttrTokenMap = new SvXMLTokenMap( aContentValidationHelpMessageAttrTokenMap ); + return *pContentValidationHelpMessageAttrTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetContentValidationErrorMessageAttrTokenMap() +{ + if( !pContentValidationErrorMessageAttrTokenMap ) + pContentValidationErrorMessageAttrTokenMap = new SvXMLTokenMap( aContentValidationErrorMessageAttrTokenMap ); + return *pContentValidationErrorMessageAttrTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetContentValidationErrorMacroAttrTokenMap() +{ + if( !pContentValidationErrorMacroAttrTokenMap ) + pContentValidationErrorMacroAttrTokenMap = new SvXMLTokenMap( aContentValidationErrorMacroAttrTokenMap ); + return *pContentValidationErrorMacroAttrTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetLabelRangesElemTokenMap() +{ + if( !pLabelRangesElemTokenMap ) + pLabelRangesElemTokenMap = new SvXMLTokenMap( aLabelRangesElemTokenMap ); + return *pLabelRangesElemTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetLabelRangeAttrTokenMap() +{ + if( !pLabelRangeAttrTokenMap ) + pLabelRangeAttrTokenMap = new SvXMLTokenMap( aLabelRangeAttrTokenMap ); + return *pLabelRangeAttrTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetTableElemTokenMap() +{ + if( !pTableElemTokenMap ) + pTableElemTokenMap = new SvXMLTokenMap( aTableTokenMap ); + return *pTableElemTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetTableRowsElemTokenMap() +{ + if( !pTableRowsElemTokenMap ) + pTableRowsElemTokenMap = new SvXMLTokenMap( aTableRowsElemTokenMap ); + return *pTableRowsElemTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetTableColsElemTokenMap() +{ + if( !pTableColsElemTokenMap ) + pTableColsElemTokenMap = new SvXMLTokenMap( aTableColsElemTokenMap ); + return *pTableColsElemTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetTableAttrTokenMap() +{ + if( !pTableAttrTokenMap ) + pTableAttrTokenMap = new SvXMLTokenMap( aTableAttrTokenMap ); + return *pTableAttrTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetTableScenarioAttrTokenMap() +{ + if( !pTableScenarioAttrTokenMap ) + pTableScenarioAttrTokenMap = new SvXMLTokenMap( aTableScenarioAttrTokenMap ); + return *pTableScenarioAttrTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetTableColAttrTokenMap() +{ + if( !pTableColAttrTokenMap ) + pTableColAttrTokenMap = new SvXMLTokenMap( aTableColAttrTokenMap ); + return *pTableColAttrTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetTableRowElemTokenMap() +{ + if( !pTableRowElemTokenMap ) + pTableRowElemTokenMap = new SvXMLTokenMap( aTableRowTokenMap ); + return *pTableRowElemTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetTableRowAttrTokenMap() +{ + if( !pTableRowAttrTokenMap ) + pTableRowAttrTokenMap = new SvXMLTokenMap( aTableRowAttrTokenMap ); + return *pTableRowAttrTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetTableRowCellElemTokenMap() +{ + if( !pTableRowCellElemTokenMap ) + pTableRowCellElemTokenMap = new SvXMLTokenMap( aTableRowCellTokenMap ); + return *pTableRowCellElemTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetTableAnnotationAttrTokenMap() +{ + if( !pTableAnnotationAttrTokenMap ) + pTableAnnotationAttrTokenMap = new SvXMLTokenMap( aTableAnnotationAttrTokenMap ); + return *pTableAnnotationAttrTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetDetectiveElemTokenMap() +{ + if( !pDetectiveElemTokenMap ) + pDetectiveElemTokenMap = new SvXMLTokenMap( aDetectiveElemTokenMap ); + return *pDetectiveElemTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetDetectiveHighlightedAttrTokenMap() +{ + if( !pDetectiveHighlightedAttrTokenMap ) + pDetectiveHighlightedAttrTokenMap = new SvXMLTokenMap( aDetectiveHighlightedAttrTokenMap ); + return *pDetectiveHighlightedAttrTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetDetectiveOperationAttrTokenMap() +{ + if( !pDetectiveOperationAttrTokenMap ) + pDetectiveOperationAttrTokenMap = new SvXMLTokenMap( aDetectiveOperationAttrTokenMap ); + return *pDetectiveOperationAttrTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetTableCellRangeSourceAttrTokenMap() +{ + if( !pTableCellRangeSourceAttrTokenMap ) + pTableCellRangeSourceAttrTokenMap = new SvXMLTokenMap( aTableCellRangeSourceAttrTokenMap ); + return *pTableCellRangeSourceAttrTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetNamedExpressionsElemTokenMap() +{ + if( !pNamedExpressionsElemTokenMap ) + pNamedExpressionsElemTokenMap = new SvXMLTokenMap( aNamedExpressionsTokenMap ); + return *pNamedExpressionsElemTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetNamedRangeAttrTokenMap() +{ + if( !pNamedRangeAttrTokenMap ) + pNamedRangeAttrTokenMap = new SvXMLTokenMap( aNamedRangeAttrTokenMap ); + return *pNamedRangeAttrTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetNamedExpressionAttrTokenMap() +{ + if( !pNamedExpressionAttrTokenMap ) + pNamedExpressionAttrTokenMap = new SvXMLTokenMap( aNamedExpressionAttrTokenMap ); + return *pNamedExpressionAttrTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetDatabaseRangesElemTokenMap() +{ + if( !pDatabaseRangesElemTokenMap ) + pDatabaseRangesElemTokenMap = new SvXMLTokenMap( aDatabaseRangesTokenMap ); + return *pDatabaseRangesElemTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetDatabaseRangeElemTokenMap() +{ + if( !pDatabaseRangeElemTokenMap ) + pDatabaseRangeElemTokenMap = new SvXMLTokenMap( aDatabaseRangeTokenMap ); + return *pDatabaseRangeElemTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetDatabaseRangeAttrTokenMap() +{ + if( !pDatabaseRangeAttrTokenMap ) + pDatabaseRangeAttrTokenMap = new SvXMLTokenMap( aDatabaseRangeAttrTokenMap ); + return *pDatabaseRangeAttrTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetDatabaseRangeSourceSQLAttrTokenMap() +{ + if( !pDatabaseRangeSourceSQLAttrTokenMap ) + pDatabaseRangeSourceSQLAttrTokenMap = new SvXMLTokenMap( aDatabaseRangeSourceSQLAttrTokenMap ); + return *pDatabaseRangeSourceSQLAttrTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetDatabaseRangeSourceTableAttrTokenMap() +{ + if( !pDatabaseRangeSourceTableAttrTokenMap ) + pDatabaseRangeSourceTableAttrTokenMap = new SvXMLTokenMap( aDatabaseRangeSourceTableAttrTokenMap ); + return *pDatabaseRangeSourceTableAttrTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetDatabaseRangeSourceQueryAttrTokenMap() +{ + if( !pDatabaseRangeSourceQueryAttrTokenMap ) + pDatabaseRangeSourceQueryAttrTokenMap = new SvXMLTokenMap( aDatabaseRangeSourceQueryAttrTokenMap ); + return *pDatabaseRangeSourceQueryAttrTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetFilterElemTokenMap() +{ + if( !pFilterElemTokenMap ) + pFilterElemTokenMap = new SvXMLTokenMap( aFilterTokenMap ); + return *pFilterElemTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetFilterAttrTokenMap() +{ + if( !pFilterAttrTokenMap ) + pFilterAttrTokenMap = new SvXMLTokenMap( aFilterAttrTokenMap ); + return *pFilterAttrTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetFilterConditionAttrTokenMap() +{ + if( !pFilterConditionAttrTokenMap ) + pFilterConditionAttrTokenMap = new SvXMLTokenMap( aFilterConditionAttrTokenMap ); + return *pFilterConditionAttrTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetSortElemTokenMap() +{ + if( !pSortElemTokenMap ) + pSortElemTokenMap = new SvXMLTokenMap( aSortTokenMap ); + return *pSortElemTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetSortAttrTokenMap() +{ + if( !pSortAttrTokenMap ) + pSortAttrTokenMap = new SvXMLTokenMap( aSortAttrTokenMap ); + return *pSortAttrTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetSortSortByAttrTokenMap() +{ + if( !pSortSortByAttrTokenMap ) + pSortSortByAttrTokenMap = new SvXMLTokenMap( aSortSortByAttrTokenMap ); + return *pSortSortByAttrTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetDatabaseRangeSubTotalRulesElemTokenMap() +{ + if( !pDatabaseRangeSubTotalRulesElemTokenMap ) + pDatabaseRangeSubTotalRulesElemTokenMap = new SvXMLTokenMap( aDatabaseRangeSubTotalRulesTokenMap ); + return *pDatabaseRangeSubTotalRulesElemTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetDatabaseRangeSubTotalRulesAttrTokenMap() +{ + if( !pDatabaseRangeSubTotalRulesAttrTokenMap ) + pDatabaseRangeSubTotalRulesAttrTokenMap = new SvXMLTokenMap( aDatabaseRangeSubTotalRulesAttrTokenMap ); + return *pDatabaseRangeSubTotalRulesAttrTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetSubTotalRulesSortGroupsAttrTokenMap() +{ + if( !pSubTotalRulesSortGroupsAttrTokenMap ) + pSubTotalRulesSortGroupsAttrTokenMap = new SvXMLTokenMap( aSubTotalRulesSortGroupsAttrTokenMap ); + return *pSubTotalRulesSortGroupsAttrTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetSubTotalRulesSubTotalRuleElemTokenMap() +{ + if( !pSubTotalRulesSubTotalRuleElemTokenMap ) + pSubTotalRulesSubTotalRuleElemTokenMap = new SvXMLTokenMap( aSubTotalRulesSubTotalRuleTokenMap ); + return *pSubTotalRulesSubTotalRuleElemTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetSubTotalRulesSubTotalRuleAttrTokenMap() +{ + if( !pSubTotalRulesSubTotalRuleAttrTokenMap ) + pSubTotalRulesSubTotalRuleAttrTokenMap = new SvXMLTokenMap( aSubTotalRulesSubTotalRuleAttrTokenMap ); + return *pSubTotalRulesSubTotalRuleAttrTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetSubTotalRuleSubTotalFieldAttrTokenMap() +{ + if( !pSubTotalRuleSubTotalFieldAttrTokenMap ) + pSubTotalRuleSubTotalFieldAttrTokenMap = new SvXMLTokenMap( aSubTotalRuleSubTotalFieldAttrTokenMap ); + return *pSubTotalRuleSubTotalFieldAttrTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetDataPilotTablesElemTokenMap() +{ + if( !pDataPilotTablesElemTokenMap ) + pDataPilotTablesElemTokenMap = new SvXMLTokenMap( aDataPilotTablesElemTokenMap ); + return *pDataPilotTablesElemTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetDataPilotTableAttrTokenMap() +{ + if( !pDataPilotTableAttrTokenMap ) + pDataPilotTableAttrTokenMap = new SvXMLTokenMap( aDataPilotTableAttrTokenMap ); + return *pDataPilotTableAttrTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetDataPilotTableElemTokenMap() +{ + if( !pDataPilotTableElemTokenMap ) + pDataPilotTableElemTokenMap = new SvXMLTokenMap( aDataPilotTableElemTokenMap ); + return *pDataPilotTableElemTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetDataPilotTableSourceServiceAttrTokenMap() +{ + if( !pDataPilotTableSourceServiceAttrTokenMap ) + pDataPilotTableSourceServiceAttrTokenMap = new SvXMLTokenMap( aDataPilotTableSourceServiceAttrTokenMap ); + return *pDataPilotTableSourceServiceAttrTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetDataPilotTableSourceCellRangeAttrTokenMap() +{ + if( !pDataPilotTableSourceCellRangeAttrTokenMap ) + pDataPilotTableSourceCellRangeAttrTokenMap = new SvXMLTokenMap( aDataPilotTableSourceCellRangeAttrTokenMap ); + return *pDataPilotTableSourceCellRangeAttrTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetDataPilotTableSourceCellRangeElemTokenMap() +{ + if( !pDataPilotTableSourceCellRangeElemTokenMap ) + pDataPilotTableSourceCellRangeElemTokenMap = new SvXMLTokenMap( aDataPilotTableSourceCellRangeElemTokenMap ); + return *pDataPilotTableSourceCellRangeElemTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetDataPilotFieldAttrTokenMap() +{ + if( !pDataPilotFieldAttrTokenMap ) + pDataPilotFieldAttrTokenMap = new SvXMLTokenMap( aDataPilotFieldAttrTokenMap ); + return *pDataPilotFieldAttrTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetDataPilotFieldElemTokenMap() +{ + if( !pDataPilotFieldElemTokenMap ) + pDataPilotFieldElemTokenMap = new SvXMLTokenMap( aDataPilotFieldElemTokenMap ); + return *pDataPilotFieldElemTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetDataPilotLevelAttrTokenMap() +{ + if( !pDataPilotLevelAttrTokenMap ) + pDataPilotLevelAttrTokenMap = new SvXMLTokenMap( aDataPilotLevelAttrTokenMap ); + return *pDataPilotLevelAttrTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetDataPilotLevelElemTokenMap() +{ + if( !pDataPilotLevelElemTokenMap ) + pDataPilotLevelElemTokenMap = new SvXMLTokenMap( aDataPilotLevelElemTokenMap ); + return *pDataPilotLevelElemTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetDataPilotSubTotalsElemTokenMap() +{ + if( !pDataPilotSubTotalsElemTokenMap ) + pDataPilotSubTotalsElemTokenMap = new SvXMLTokenMap( aDataPilotSubTotalsElemTokenMap ); + return *pDataPilotSubTotalsElemTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetDataPilotSubTotalAttrTokenMap() +{ + if( !pDataPilotSubTotalAttrTokenMap ) + pDataPilotSubTotalAttrTokenMap = new SvXMLTokenMap( aDataPilotSubTotalAttrTokenMap ); + return *pDataPilotSubTotalAttrTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetDataPilotMembersElemTokenMap() +{ + if( !pDataPilotMembersElemTokenMap ) + pDataPilotMembersElemTokenMap = new SvXMLTokenMap( aDataPilotMembersElemTokenMap ); + return *pDataPilotMembersElemTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetDataPilotMemberAttrTokenMap() +{ + if( !pDataPilotMemberAttrTokenMap ) + pDataPilotMemberAttrTokenMap = new SvXMLTokenMap( aDataPilotMemberAttrTokenMap ); + return *pDataPilotMemberAttrTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetConsolidationAttrTokenMap() +{ + if( !pConsolidationAttrTokenMap ) + pConsolidationAttrTokenMap = new SvXMLTokenMap( aConsolidationAttrTokenMap ); + return *pConsolidationAttrTokenMap; +} + + +SvXMLImportContext *ScXMLImport::CreateContext( USHORT nPrefix, + const OUString& rLocalName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if( (XML_NAMESPACE_OFFICE == nPrefix) && + ( IsXMLToken(rLocalName, XML_DOCUMENT) || + IsXMLToken(rLocalName, XML_DOCUMENT_META) || + IsXMLToken(rLocalName, XML_DOCUMENT_STYLES) || + IsXMLToken(rLocalName, XML_DOCUMENT_CONTENT) || + IsXMLToken(rLocalName, XML_DOCUMENT_SETTINGS) )) + pContext = new ScXMLDocContext_Impl( *this, nPrefix, rLocalName, + xAttrList ); + else + pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList ); + + return pContext; +} + +// #110680# +ScXMLImport::ScXMLImport( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory, + const sal_uInt16 nImportFlag) +: SvXMLImport( xServiceFactory, nImportFlag ), + pDoc( NULL ), + bLoadDoc( sal_True ), + nStyleFamilyMask( 0 ), +// rDoc( rD ), +// pI18NMap( new SvI18NMap ), + pDocElemTokenMap( 0 ), + pStylesElemTokenMap( 0 ), + pStylesAttrTokenMap( 0 ), + pStyleElemTokenMap( 0 ), + pBodyElemTokenMap( 0 ), + pContentValidationsElemTokenMap( 0 ), + pContentValidationElemTokenMap( 0 ), + pContentValidationAttrTokenMap( 0 ), + pContentValidationMessageElemTokenMap( 0 ), + pContentValidationHelpMessageAttrTokenMap( 0 ), + pContentValidationErrorMessageAttrTokenMap( 0 ), + pContentValidationErrorMacroAttrTokenMap( 0 ), + pLabelRangesElemTokenMap( 0 ), + pLabelRangeAttrTokenMap( 0 ), + pTableElemTokenMap( 0 ), + pTableRowsElemTokenMap( 0 ), + pTableColsElemTokenMap( 0 ), + pTableAttrTokenMap( 0 ), + pTableScenarioAttrTokenMap( 0 ), + pTableColAttrTokenMap( 0 ), + pTableRowElemTokenMap( 0 ), + pTableRowAttrTokenMap( 0 ), + pTableRowCellElemTokenMap( 0 ), + pTableRowCellAttrTokenMap( 0 ), + pTableAnnotationAttrTokenMap( 0 ), + pDetectiveElemTokenMap( 0 ), + pDetectiveHighlightedAttrTokenMap( 0 ), + pDetectiveOperationAttrTokenMap( 0 ), + pTableCellRangeSourceAttrTokenMap( 0 ), + pNamedExpressionsElemTokenMap( 0 ), + pNamedRangeAttrTokenMap( 0 ), + pNamedExpressionAttrTokenMap( 0 ), + pDatabaseRangesElemTokenMap( 0 ), + pDatabaseRangeElemTokenMap( 0 ), + pDatabaseRangeAttrTokenMap( 0 ), + pDatabaseRangeSourceSQLAttrTokenMap( 0 ), + pDatabaseRangeSourceTableAttrTokenMap( 0 ), + pDatabaseRangeSourceQueryAttrTokenMap( 0 ), + pFilterElemTokenMap( 0 ), + pFilterAttrTokenMap( 0 ), + pFilterConditionAttrTokenMap( 0 ), + pSortElemTokenMap( 0 ), + pSortAttrTokenMap( 0 ), + pSortSortByAttrTokenMap( 0 ), + pDatabaseRangeSubTotalRulesElemTokenMap( 0 ), + pDatabaseRangeSubTotalRulesAttrTokenMap( 0 ), + pSubTotalRulesSortGroupsAttrTokenMap( 0 ), + pSubTotalRulesSubTotalRuleElemTokenMap( 0 ), + pSubTotalRulesSubTotalRuleAttrTokenMap( 0 ), + pSubTotalRuleSubTotalFieldAttrTokenMap( 0 ), + pDataPilotTablesElemTokenMap( 0 ), + pDataPilotTableAttrTokenMap( 0 ), + pDataPilotTableElemTokenMap( 0 ), + pDataPilotTableSourceServiceAttrTokenMap( 0 ), + pDataPilotTableSourceCellRangeElemTokenMap( 0 ), + pDataPilotTableSourceCellRangeAttrTokenMap( 0 ), + pDataPilotFieldAttrTokenMap( 0 ), + pDataPilotFieldElemTokenMap( 0 ), + pDataPilotLevelAttrTokenMap( 0 ), + pDataPilotLevelElemTokenMap( 0 ), + pDataPilotSubTotalsElemTokenMap( 0 ), + pDataPilotSubTotalAttrTokenMap( 0 ), + pDataPilotMembersElemTokenMap( 0 ), + pDataPilotMemberAttrTokenMap( 0 ), + pConsolidationAttrTokenMap( 0 ), + aTables(*this), + pMyNamedExpressions(NULL), + pValidations(NULL), + pDetectiveOpArray(NULL), +// pScAutoStylePool(new SvXMLAutoStylePoolP), + bRemoveLastChar(sal_False), + pChangeTrackingImportHelper(NULL), + pStylesImportHelper(NULL), + sNumberFormat(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_NUMFMT)), + sLocale(RTL_CONSTASCII_USTRINGPARAM(SC_LOCALE)), + sCellStyle(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_CELLSTYL)), + sStandardFormat(RTL_CONSTASCII_USTRINGPARAM(SC_STANDARDFORMAT)), + sType(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_TYPE)), + bNullDateSetted(sal_False), + pNumberFormatAttributesExportHelper(NULL), + pStyleNumberFormats(NULL), + sPrevStyleName(), + sPrevCurrency(), + nPrevCellType(0), + nSolarMutexLocked(0), + pSolarMutexGuard(NULL), + nRangeOverflowType(0), + bSelfImportingXMLSet(sal_False) + +// pParaItemMapper( 0 ), +{ + pStylesImportHelper = new ScMyStylesImportHelper(*this); + + xScPropHdlFactory = new XMLScPropHdlFactory; + xCellStylesPropertySetMapper = new XMLPropertySetMapper((XMLPropertyMapEntry*)aXMLScCellStylesProperties, xScPropHdlFactory); + xColumnStylesPropertySetMapper = new XMLPropertySetMapper((XMLPropertyMapEntry*)aXMLScColumnStylesProperties, xScPropHdlFactory); + xRowStylesPropertySetMapper = new XMLPropertySetMapper((XMLPropertyMapEntry*)aXMLScRowStylesProperties, xScPropHdlFactory); + xTableStylesPropertySetMapper = new XMLPropertySetMapper((XMLPropertyMapEntry*)aXMLScTableStylesProperties, xScPropHdlFactory); +} + +ScXMLImport::~ScXMLImport() throw() +{ +// RemoveUnusedNumRules(); + +// delete pI18NMap; + delete pDocElemTokenMap; + delete pStylesElemTokenMap; + delete pStylesAttrTokenMap; + delete pStyleElemTokenMap; + delete pBodyElemTokenMap; + delete pContentValidationsElemTokenMap; + delete pContentValidationElemTokenMap; + delete pContentValidationAttrTokenMap; + delete pContentValidationMessageElemTokenMap; + delete pContentValidationHelpMessageAttrTokenMap; + delete pContentValidationErrorMessageAttrTokenMap; + delete pContentValidationErrorMacroAttrTokenMap; + delete pLabelRangesElemTokenMap; + delete pLabelRangeAttrTokenMap; + delete pTableElemTokenMap; + delete pTableRowsElemTokenMap; + delete pTableColsElemTokenMap; + delete pTableAttrTokenMap; + delete pTableScenarioAttrTokenMap; + delete pTableColAttrTokenMap; + delete pTableRowElemTokenMap; + delete pTableRowAttrTokenMap; + delete pTableRowCellElemTokenMap; + delete pTableRowCellAttrTokenMap; + delete pTableAnnotationAttrTokenMap; + delete pDetectiveElemTokenMap; + delete pDetectiveHighlightedAttrTokenMap; + delete pDetectiveOperationAttrTokenMap; + delete pTableCellRangeSourceAttrTokenMap; + delete pNamedExpressionsElemTokenMap; + delete pNamedRangeAttrTokenMap; + delete pNamedExpressionAttrTokenMap; + delete pDatabaseRangesElemTokenMap; + delete pDatabaseRangeElemTokenMap; + delete pDatabaseRangeAttrTokenMap; + delete pDatabaseRangeSourceSQLAttrTokenMap; + delete pDatabaseRangeSourceTableAttrTokenMap; + delete pDatabaseRangeSourceQueryAttrTokenMap; + delete pFilterElemTokenMap; + delete pFilterAttrTokenMap; + delete pFilterConditionAttrTokenMap; + delete pSortElemTokenMap; + delete pSortAttrTokenMap; + delete pSortSortByAttrTokenMap; + delete pDatabaseRangeSubTotalRulesElemTokenMap; + delete pDatabaseRangeSubTotalRulesAttrTokenMap; + delete pSubTotalRulesSortGroupsAttrTokenMap; + delete pSubTotalRulesSubTotalRuleElemTokenMap; + delete pSubTotalRulesSubTotalRuleAttrTokenMap; + delete pSubTotalRuleSubTotalFieldAttrTokenMap; + delete pDataPilotTablesElemTokenMap; + delete pDataPilotTableAttrTokenMap; + delete pDataPilotTableElemTokenMap; + delete pDataPilotTableSourceServiceAttrTokenMap; + delete pDataPilotTableSourceCellRangeAttrTokenMap; + delete pDataPilotTableSourceCellRangeElemTokenMap; + delete pDataPilotFieldAttrTokenMap; + delete pDataPilotFieldElemTokenMap; + delete pDataPilotLevelAttrTokenMap; + delete pDataPilotLevelElemTokenMap; + delete pDataPilotSubTotalsElemTokenMap; + delete pDataPilotSubTotalAttrTokenMap; + delete pDataPilotMembersElemTokenMap; + delete pDataPilotMemberAttrTokenMap; + delete pConsolidationAttrTokenMap; + +// if (pScAutoStylePool) +// delete pScAutoStylePool; + if (pChangeTrackingImportHelper) + delete pChangeTrackingImportHelper; + if (pNumberFormatAttributesExportHelper) + delete pNumberFormatAttributesExportHelper; + if (pStyleNumberFormats) + delete pStyleNumberFormats; + if (pStylesImportHelper) + delete pStylesImportHelper; + + if (pSolarMutexGuard) + delete pSolarMutexGuard; + + if (pMyNamedExpressions) + delete pMyNamedExpressions; + if (pValidations) + delete pValidations; + if (pDetectiveOpArray) + delete pDetectiveOpArray; +} + +// --------------------------------------------------------------------- + +SvXMLImportContext *ScXMLImport::CreateFontDeclsContext(const USHORT nPrefix, const ::rtl::OUString& rLocalName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList) +{ + SvXMLImportContext *pContext = NULL; + if (!pContext) + { + XMLFontStylesContext *pFSContext = + new XMLFontStylesContext( *this, nPrefix, + rLocalName, xAttrList, + gsl_getSystemTextEncoding() ); + SetFontDecls( pFSContext ); + pContext = pFSContext; + } + return pContext; +} + +SvXMLImportContext *ScXMLImport::CreateStylesContext(const ::rtl::OUString& rLocalName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList, sal_Bool bIsAutoStyle ) +{ + SvXMLImportContext *pContext = NULL; + if (!pContext) + { + pContext = new XMLTableStylesContext(*this, XML_NAMESPACE_OFFICE, rLocalName, xAttrList, bIsAutoStyle); + if (bIsAutoStyle) + //xAutoStyles = pContext; + SetAutoStyles((SvXMLStylesContext*)pContext); + else + //xStyles = pContext; + SetStyles((SvXMLStylesContext*)pContext); + } + return pContext; +} + +SvXMLImportContext *ScXMLImport::CreateBodyContext(const ::rtl::OUString& rLocalName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList) +{ + //GetShapeImport()->SetAutoStylesContext((XMLTableStylesContext *)&xAutoStyles); + //GetChartImport()->SetAutoStylesContext(GetAutoStyles()/*(XMLTableStylesContext *)&xAutoStyles*/); + + SvXMLImportContext *pContext = 0; + pContext = new ScXMLBodyContext(*this, XML_NAMESPACE_OFFICE, rLocalName, xAttrList); + return pContext; +} + +SvXMLImportContext *ScXMLImport::CreateMetaContext( + const OUString& rLocalName ) +{ + SvXMLImportContext *pContext = 0; + + if( !IsStylesOnlyMode() ) + { + pContext = new SfxXMLMetaContext( *this, + XML_NAMESPACE_OFFICE, rLocalName, + GetModel() ); + } + + if( !pContext ) + pContext = new SvXMLImportContext( *this, XML_NAMESPACE_OFFICE, + rLocalName ); + + return pContext; +} + +SvXMLImportContext *ScXMLImport::CreateScriptContext( + const OUString& rLocalName ) +{ + SvXMLImportContext *pContext = 0; + + if( !(IsStylesOnlyMode()) ) + { + pContext = new XMLScriptContext( *this, + XML_NAMESPACE_OFFICE, rLocalName, + GetModel() ); + } + + if( !pContext ) + pContext = new SvXMLImportContext( *this, XML_NAMESPACE_OFFICE, + rLocalName ); + + return pContext; +} + +void ScXMLImport::SetStatisticAttributes( const uno::Reference<xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImport::SetStatisticAttributes(xAttrList); + + sal_uInt32 nCount(0); + INT16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for( INT16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + sal_uInt16 nPrefix = GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + if ( nPrefix == XML_NAMESPACE_META) + { + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + sal_Int32 nValue(0); + if (IsXMLToken(aLocalName, XML_TABLE_COUNT)) + { + if (GetMM100UnitConverter().convertNumber(nValue, sValue)) + nCount += nValue; + } + else if (IsXMLToken(aLocalName, XML_CELL_COUNT)) + { + if (GetMM100UnitConverter().convertNumber(nValue, sValue)) + nCount += nValue; + } + else if (IsXMLToken(aLocalName, XML_OBJECT_COUNT)) + { + if (GetMM100UnitConverter().convertNumber(nValue, sValue)) + nCount += nValue; + } + } + } + if (nCount) + { + GetProgressBarHelper()->SetReference(nCount); + GetProgressBarHelper()->SetValue(0); + } +} + +XMLShapeImportHelper* ScXMLImport::CreateShapeImport() +{ + /*UniReference < XMLPropertySetMapper > xShapeStylesPropertySetMapper = new XMLPropertySetMapper((XMLPropertyMapEntry*)aXMLScShapeStylesProperties, xScPropHdlFactory); + SvXMLImportPropertyMapper *pShapeStylesImportPropertySetMapper = new SvXMLImportPropertyMapper( xShapeStylesPropertySetMapper );*/ + + return new XMLTableShapeImportHelper( *this/*, pShapeStylesImportPropertySetMapper*/ ); +} + +sal_Bool ScXMLImport::GetValidation(const ::rtl::OUString& sName, ScMyImportValidation& aValidation) +{ + if (pValidations) + { + sal_Bool bFound(sal_False); + ::rtl::OUString sEmpty; + ScMyImportValidations::iterator aItr = pValidations->begin(); + while(aItr != pValidations->end() && !bFound) + { + if (aItr->sName == sName) + { + if (aItr->sBaseCellAddress.getLength()) + { + sal_Int32 nOffset(0); + LockSolarMutex(); + if (ScXMLConverter::GetAddressFromString( + aItr->aBaseCellAddress, aItr->sBaseCellAddress, GetDocument(), nOffset )) + aItr->sBaseCellAddress = sEmpty; + UnlockSolarMutex(); + } + bFound = sal_True; + } + else + aItr++; + } + if (bFound) + aValidation = *aItr; + return bFound; + } + return sal_False; +} + +ScXMLChangeTrackingImportHelper* ScXMLImport::GetChangeTrackingImportHelper() +{ + if (!pChangeTrackingImportHelper) + pChangeTrackingImportHelper = new ScXMLChangeTrackingImportHelper(); + return pChangeTrackingImportHelper; +} + +void ScXMLImport::InsertStyles() +{ + GetStyles()->CopyStylesToDoc(sal_True); +} + +void ScXMLImport::SetChangeTrackingViewSettings(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& rChangeProps) +{ + if (pDoc) + { + sal_Int32 nCount(rChangeProps.getLength()); + if (nCount) + { + LockSolarMutex(); + sal_Int32 nTemp32(0); + sal_Int16 nTemp16(0); + ScChangeViewSettings* pViewSettings = new ScChangeViewSettings(); + for (sal_Int32 i = 0; i < nCount; i++) + { + ::rtl::OUString sName(rChangeProps[i].Name); + if (sName.compareToAscii("ShowChanges") == 0) + pViewSettings->SetShowChanges(::cppu::any2bool(rChangeProps[i].Value)); + else if (sName.compareToAscii("ShowAcceptedChanges") == 0) + pViewSettings->SetShowAccepted(::cppu::any2bool(rChangeProps[i].Value)); + else if (sName.compareToAscii("ShowRejectedChanges") == 0) + pViewSettings->SetShowRejected(::cppu::any2bool(rChangeProps[i].Value)); + else if (sName.compareToAscii("ShowChangesByDatetime") == 0) + pViewSettings->SetHasDate(::cppu::any2bool(rChangeProps[i].Value)); + else if (sName.compareToAscii("ShowChangesByDatetimeMode") == 0) + { + if (rChangeProps[i].Value >>= nTemp16) + pViewSettings->SetTheDateMode(ScChgsDateMode(nTemp16)); + } + else if (sName.compareToAscii("ShowChangesByDatetimeFirstDatetime") == 0) + { + util::DateTime aDateTime; + if (rChangeProps[i].Value >>= aDateTime) + { + DateTime aCoreDateTime; + ScXMLConverter::ConvertAPIToCoreDateTime(aDateTime, aCoreDateTime); + pViewSettings->SetTheFirstDateTime(aCoreDateTime); + } + } + else if (sName.compareToAscii("ShowChangesByDatetimeSecondDatetime") == 0) + { + util::DateTime aDateTime; + if (rChangeProps[i].Value >>= aDateTime) + { + DateTime aCoreDateTime; + ScXMLConverter::ConvertAPIToCoreDateTime(aDateTime, aCoreDateTime); + pViewSettings->SetTheLastDateTime(aCoreDateTime); + } + } + else if (sName.compareToAscii("ShowChangesByAuthor") == 0) + pViewSettings->SetHasAuthor(::cppu::any2bool(rChangeProps[i].Value)); + else if (sName.compareToAscii("ShowChangesByAuthorName") == 0) + { + ::rtl::OUString sOUName; + if (rChangeProps[i].Value >>= sOUName) + { + String sName(sOUName); + pViewSettings->SetTheAuthorToShow(sName); + } + } + else if (sName.compareToAscii("ShowChangesByComment") == 0) + pViewSettings->SetHasComment(::cppu::any2bool(rChangeProps[i].Value)); + else if (sName.compareToAscii("ShowChangesByCommentText") == 0) + { + ::rtl::OUString sOUComment; + if (rChangeProps[i].Value >>= sOUComment) + { + String sComment(sOUComment); + pViewSettings->SetTheComment(sComment); + } + } + else if (sName.compareToAscii("ShowChangesByRanges") == 0) + pViewSettings->SetHasRange(::cppu::any2bool(rChangeProps[i].Value)); + else if (sName.compareToAscii("ShowChangesByRangesList") == 0) + { + ::rtl::OUString sRanges; + if ((rChangeProps[i].Value >>= sRanges) && sRanges.getLength()) + { + ScRangeList aRangeList; + ScXMLConverter::GetRangeListFromString(aRangeList, sRanges, GetDocument()); + pViewSettings->SetTheRangeList(aRangeList); + } + } + } + pDoc->SetChangeViewSettings(*pViewSettings); + UnlockSolarMutex(); + } + } +} + +void ScXMLImport::SetViewSettings(const uno::Sequence<beans::PropertyValue>& aViewProps) +{ + sal_Int32 nCount(aViewProps.getLength()); + sal_Int32 nHeight(0); + sal_Int32 nLeft(0); + sal_Int32 nTop(0); + sal_Int32 nWidth(0); + for (sal_Int32 i = 0; i < nCount; i++) + { + ::rtl::OUString sName(aViewProps[i].Name); + if (sName.compareToAscii("VisibleAreaHeight") == 0) + aViewProps[i].Value >>= nHeight; + else if (sName.compareToAscii("VisibleAreaLeft") == 0) + aViewProps[i].Value >>= nLeft; + else if (sName.compareToAscii("VisibleAreaTop") == 0) + aViewProps[i].Value >>= nTop; + else if (sName.compareToAscii("VisibleAreaWidth") == 0) + aViewProps[i].Value >>= nWidth; + else if (sName.compareToAscii("TrackedChangesViewSettings") == 0) + { + uno::Sequence<beans::PropertyValue> aChangeProps; + if(aViewProps[i].Value >>= aChangeProps) + SetChangeTrackingViewSettings(aChangeProps); + } + } + if (nHeight && nWidth) + { + if (GetModel().is()) + { + ScModelObj* pDocObj = ScModelObj::getImplementation( GetModel() ); + if (pDocObj) + { + SvEmbeddedObject* pEmbeddedObj = pDocObj->GetEmbeddedObject(); + if (pEmbeddedObj) + { + Rectangle aRect; + aRect.setX( nLeft ); + aRect.setY( nTop ); + aRect.setWidth( nWidth ); + aRect.setHeight( nHeight ); + pEmbeddedObj->SetVisArea(aRect); + } + } + } + } +} + +void ScXMLImport::SetConfigurationSettings(const uno::Sequence<beans::PropertyValue>& aConfigProps) +{ + if (GetModel().is()) + { + uno::Reference <lang::XMultiServiceFactory> xMultiServiceFactory(GetModel(), uno::UNO_QUERY); + if (xMultiServiceFactory.is()) + { + uno::Reference <uno::XInterface> xInterface = xMultiServiceFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.SpreadsheetSettings"))); + uno::Reference <beans::XPropertySet> xProperties(xInterface, uno::UNO_QUERY); + if (xProperties.is()) + SvXMLUnitConverter::convertPropertySet(xProperties, aConfigProps); + } + } +} + +sal_Int32 ScXMLImport::SetCurrencySymbol(const sal_Int32 nKey, const ::rtl::OUString& rCurrency) +{ + uno::Reference <util::XNumberFormatsSupplier> xNumberFormatsSupplier = GetNumberFormatsSupplier(); + if (xNumberFormatsSupplier.is()) + { + uno::Reference <util::XNumberFormats> xNumberFormats = xNumberFormatsSupplier->getNumberFormats(); + if (xNumberFormats.is()) + { + ::rtl::OUString sFormatString; + try + { + uno::Reference <beans::XPropertySet> xProperties = xNumberFormats->getByKey(nKey); + if (xProperties.is()) + { + uno::Any aAny = xProperties->getPropertyValue(sLocale); + lang::Locale aLocale; + if (GetDocument() && (aAny >>= aLocale)) + { + LockSolarMutex(); + LocaleDataWrapper aLocaleData( GetDocument()->GetServiceManager(), aLocale ); + ::rtl::OUStringBuffer aBuffer(15); + aBuffer.appendAscii("#"); + aBuffer.append( aLocaleData.getNumThousandSep() ); + aBuffer.appendAscii("##0"); + aBuffer.append( aLocaleData.getNumDecimalSep() ); + aBuffer.appendAscii("00 [$"); + aBuffer.append(rCurrency); + aBuffer.appendAscii("]"); + UnlockSolarMutex(); + sFormatString = aBuffer.makeStringAndClear(); + sal_Int32 nNewKey = xNumberFormats->queryKey(sFormatString, aLocale, sal_True); + if (nNewKey == -1) + nNewKey = xNumberFormats->addNew(sFormatString, aLocale); + return nNewKey; + } + } + } + catch ( util::MalformedNumberFormatException& rException ) + { + ::rtl::OUString sErrorMessage(RTL_CONSTASCII_USTRINGPARAM("Fehler im Formatstring ")); + sErrorMessage += sFormatString; + sErrorMessage += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" an Position ")); + sErrorMessage += ::rtl::OUString::valueOf(rException.CheckPos); + uno::Sequence<rtl::OUString> aSeq(1); + aSeq[0] = sErrorMessage; + uno::Reference<xml::sax::XLocator> xLocator; + SetError(XMLERROR_API | XMLERROR_FLAG_ERROR, aSeq, rException.Message, xLocator); + } + } + } + return nKey; +} + +sal_Bool ScXMLImport::IsCurrencySymbol(const sal_Int32 nNumberFormat, const ::rtl::OUString& sCurrencySymbol) +{ + uno::Reference <util::XNumberFormatsSupplier> xNumberFormatsSupplier = GetNumberFormatsSupplier(); + if (xNumberFormatsSupplier.is()) + { + uno::Reference <util::XNumberFormats> xNumberFormats = xNumberFormatsSupplier->getNumberFormats(); + if (xNumberFormats.is()) + { + try + { + uno::Reference <beans::XPropertySet> xNumberPropertySet = xNumberFormats->getByKey(nNumberFormat); + if (xNumberPropertySet.is()) + { + uno::Any aCurrencySymbol = xNumberPropertySet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_CURRENCYSYMBOL))); + ::rtl::OUString sTemp; + if ( aCurrencySymbol >>= sTemp) + return sCurrencySymbol.equals(sTemp); + } + } + catch ( uno::Exception& ) + { + DBG_ERROR("Numberformat not found"); + } + } + } + return sal_False; +} + +void ScXMLImport::SetType(uno::Reference <beans::XPropertySet>& rProperties, + sal_Int32& rNumberFormat, + const sal_Int16 nCellType, + const ::rtl::OUString& rCurrency) +{ + if ((nCellType != util::NumberFormat::TEXT) && (nCellType != util::NumberFormat::UNDEFINED)) + { + if (rNumberFormat == -1) + { + uno::Any aKey = rProperties->getPropertyValue( sNumberFormat ); + aKey >>= rNumberFormat; + } + DBG_ASSERT(rNumberFormat != -1, "no NumberFormat"); + sal_Bool bIsStandard; + ::rtl::OUString sCurrentBankCurrency; + sal_Int32 nCurrentCellType( + GetNumberFormatAttributesExportHelper()->GetCellType( + rNumberFormat, sCurrentBankCurrency, bIsStandard) & ~util::NumberFormat::DEFINED); + if ((nCellType != nCurrentCellType) && !(nCellType == util::NumberFormat::NUMBER && + ((nCurrentCellType == util::NumberFormat::SCIENTIFIC) || + (nCurrentCellType == util::NumberFormat::FRACTION) || + (nCurrentCellType == 0)) || (nCurrentCellType == util::NumberFormat::TEXT)) && !((nCellType == util::NumberFormat::DATETIME) && + (nCurrentCellType == util::NumberFormat::DATE))) + { + if (!xNumberFormats.is()) + { + uno::Reference <util::XNumberFormatsSupplier> xNumberFormatsSupplier = GetNumberFormatsSupplier(); + if (xNumberFormatsSupplier.is()) + xNumberFormats = xNumberFormatsSupplier->getNumberFormats(); + } + if (xNumberFormats.is()) + { + try + { + uno::Reference < beans::XPropertySet> xNumberFormatProperties = xNumberFormats->getByKey(rNumberFormat); + if (xNumberFormatProperties.is()) + { + if (nCellType != util::NumberFormat::CURRENCY) + { + uno::Any aNumberLocale = xNumberFormatProperties->getPropertyValue(sLocale); + lang::Locale aLocale; + if ( aNumberLocale >>= aLocale ) + { + if (!xNumberFormatTypes.is()) + xNumberFormatTypes = uno::Reference <util::XNumberFormatTypes>(xNumberFormats, uno::UNO_QUERY); + sal_Int32 nNumberFormatPropertyKey = xNumberFormatTypes->getStandardFormat(nCellType, aLocale); + uno::Any aNumberFormatPropertyKey; + aNumberFormatPropertyKey <<= nNumberFormatPropertyKey; + rProperties->setPropertyValue( sNumberFormat, aNumberFormatPropertyKey ); + } + } + else if (rCurrency.getLength() && sCurrentBankCurrency.getLength()) + { + if (!sCurrentBankCurrency.equals(rCurrency)) + { + if (!IsCurrencySymbol(rNumberFormat, rCurrency)) + { + sal_Int32 nKey = SetCurrencySymbol(rNumberFormat, rCurrency); + uno::Any aAny; + aAny <<= nKey; + rProperties->setPropertyValue( sNumberFormat, aAny); + } + } + } + } + } + catch ( uno::Exception& ) + { + DBG_ERROR("Numberformat not found"); + } + } + } + else + { + if ((nCellType == util::NumberFormat::CURRENCY) && rCurrency.getLength() && sCurrentBankCurrency.getLength()) + { + if (!sCurrentBankCurrency.equals(rCurrency)) + { + if (!IsCurrencySymbol(rNumberFormat, rCurrency)) + { + sal_Int32 nKey = SetCurrencySymbol(rNumberFormat, rCurrency); + uno::Any aAny; + aAny <<= nKey; + rProperties->setPropertyValue( sNumberFormat, aAny); + } + } + } + } + } +} + +void ScXMLImport::AddStyleRange(const table::CellRangeAddress& rCellRange) +{ + if (!xSheetCellRanges.is() && GetModel().is()) + { + uno::Reference <lang::XMultiServiceFactory> xMultiServiceFactory(GetModel(), uno::UNO_QUERY); + if (xMultiServiceFactory.is()) + xSheetCellRanges = uno::Reference <sheet::XSheetCellRangeContainer>(xMultiServiceFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SheetCellRanges"))), uno::UNO_QUERY); + DBG_ASSERT(xSheetCellRanges.is(), "didn't get SheetCellRanges"); + + } + xSheetCellRanges->addRangeAddress(rCellRange, sal_False); +} + +void ScXMLImport::SetStyleToRanges() +{ + if (sPrevStyleName.getLength()) + { + uno::Reference <beans::XPropertySet> xProperties (xSheetCellRanges, uno::UNO_QUERY); + if (xProperties.is()) + { + XMLTableStylesContext *pStyles = (XMLTableStylesContext *)GetAutoStyles(); + XMLTableStyleContext* pStyle = (XMLTableStyleContext *)pStyles->FindStyleChildContext( + XML_STYLE_FAMILY_TABLE_CELL, sPrevStyleName, sal_True); + if (pStyle) + { + pStyle->FillPropertySet(xProperties); + sal_Int32 nNumberFormat(pStyle->GetNumberFormat()); + SetType(xProperties, nNumberFormat, nPrevCellType, sPrevCurrency); + } + else + { + uno::Any aStyleName; + aStyleName <<= sPrevStyleName; + xProperties->setPropertyValue(sCellStyle, aStyleName); + sal_Int32 nNumberFormat(GetStyleNumberFormats()->GetStyleNumberFormat(sPrevStyleName)); + sal_Bool bInsert(nNumberFormat == -1); + SetType(xProperties, nNumberFormat, nPrevCellType, sPrevCurrency); + if (bInsert) + GetStyleNumberFormats()->AddStyleNumberFormat(sPrevStyleName, nNumberFormat); + } + } + } + if (GetModel().is()) + { + uno::Reference <lang::XMultiServiceFactory> xMultiServiceFactory(GetModel(), uno::UNO_QUERY); + if (xMultiServiceFactory.is()) + xSheetCellRanges = uno::Reference <sheet::XSheetCellRangeContainer>( + xMultiServiceFactory->createInstance( + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SheetCellRanges"))), + uno::UNO_QUERY); + } + DBG_ASSERT(xSheetCellRanges.is(), "didn't get SheetCellRanges"); +} + +void ScXMLImport::SetStyleToRange(const ScRange& rRange, const ::rtl::OUString* pStyleName, + const sal_Int16 nCellType, const ::rtl::OUString* pCurrency) +{ + if (!sPrevStyleName.getLength()) + { + nPrevCellType = nCellType; + if (pStyleName) + sPrevStyleName = *pStyleName; + if (pCurrency) + sPrevCurrency = *pCurrency; + else if (sPrevCurrency.getLength()) + sPrevCurrency = sEmpty; + } + else if ((nCellType != nPrevCellType) || + ((pStyleName && !pStyleName->equals(sPrevStyleName)) || + (!pStyleName && sPrevStyleName.getLength())) || + ((pCurrency && !pCurrency->equals(sPrevCurrency)) || + (!pCurrency && sPrevCurrency.getLength()))) + { + SetStyleToRanges(); + nPrevCellType = nCellType; + if (pStyleName) + sPrevStyleName = *pStyleName; + else if(sPrevStyleName.getLength()) + sPrevStyleName = sEmpty; + if (pCurrency) + sPrevCurrency = *pCurrency; + else if(sPrevCurrency.getLength()) + sPrevCurrency = sEmpty; + } + table::CellRangeAddress aCellRange; + aCellRange.StartColumn = rRange.aStart.Col(); + aCellRange.StartRow = rRange.aStart.Row(); + aCellRange.Sheet = rRange.aStart.Tab(); + aCellRange.EndColumn = rRange.aEnd.Col(); + aCellRange.EndRow = rRange.aEnd.Row(); + AddStyleRange(aCellRange); +} + +sal_Bool ScXMLImport::SetNullDateOnUnitConverter() +{ + if (!bNullDateSetted) + bNullDateSetted = GetMM100UnitConverter().setNullDate(GetModel()); + DBG_ASSERT(bNullDateSetted, "could not set the null date"); + return bNullDateSetted; +} + +XMLNumberFormatAttributesExportHelper* ScXMLImport::GetNumberFormatAttributesExportHelper() +{ + if (!pNumberFormatAttributesExportHelper) + pNumberFormatAttributesExportHelper = new XMLNumberFormatAttributesExportHelper(GetNumberFormatsSupplier()); + return pNumberFormatAttributesExportHelper; +} + +ScMyStyleNumberFormats* ScXMLImport::GetStyleNumberFormats() +{ + if (!pStyleNumberFormats) + pStyleNumberFormats = new ScMyStyleNumberFormats(); + return pStyleNumberFormats; +} + +void ScXMLImport::SetStylesToRangesFinished() +{ + SetStyleToRanges(); + sPrevStyleName = sEmpty; +} + +// XImporter +void SAL_CALL ScXMLImport::setTargetDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc ) + throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) +{ + LockSolarMutex(); + SvXMLImport::setTargetDocument( xDoc ); + + uno::Reference<frame::XModel> xModel(xDoc, uno::UNO_QUERY); + pDoc = ScXMLConverter::GetScDocument( xModel ); + DBG_ASSERT( pDoc, "ScXMLImport::setTargetDocument - no ScDocument!" ); + if (!pDoc) + throw lang::IllegalArgumentException(); + + uno::Reference<document::XActionLockable> xActionLockable(xDoc, uno::UNO_QUERY); + if (xActionLockable.is()) + xActionLockable->addActionLock(); + UnlockSolarMutex(); +} + +// XServiceInfo +::rtl::OUString SAL_CALL ScXMLImport::getImplementationName( ) + throw(::com::sun::star::uno::RuntimeException) +{ + switch( getImportFlags() ) + { + case IMPORT_ALL: + return ScXMLImport_getImplementationName(); + break; + case (IMPORT_STYLES|IMPORT_MASTERSTYLES|IMPORT_AUTOSTYLES|IMPORT_FONTDECLS): + return ScXMLImport_Styles_getImplementationName(); + break; + case (IMPORT_AUTOSTYLES|IMPORT_CONTENT|IMPORT_SCRIPTS|IMPORT_FONTDECLS): + return ScXMLImport_Content_getImplementationName(); + break; + case IMPORT_META: + return ScXMLImport_Meta_getImplementationName(); + break; + case IMPORT_SETTINGS: + return ScXMLImport_Settings_getImplementationName(); + break; + default: + // generic name for 'unknown' cases + return ScXMLImport_getImplementationName(); + break; + } + return SvXMLImport::getImplementationName(); +} + +// ::com::sun::star::xml::sax::XDocumentHandler +void SAL_CALL ScXMLImport::startDocument(void) + throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ) +{ + LockSolarMutex(); + SvXMLImport::startDocument(); + if (pDoc && !pDoc->IsImportingXML()) + { + ScModelObj::getImplementation(GetModel())->BeforeXMLLoading(); + bSelfImportingXMLSet = sal_True; + } + UnlockSolarMutex(); +} + +void SAL_CALL ScXMLImport::endDocument(void) + throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ) +{ + LockSolarMutex(); + if (getImportFlags() & IMPORT_CONTENT) + { + if (GetModel().is()) + { + uno::Reference<document::XViewDataSupplier> xViewDataSupplier(GetModel(), uno::UNO_QUERY); + if (xViewDataSupplier.is()) + { + uno::Reference<container::XIndexAccess> xIndexAccess = xViewDataSupplier->getViewData(); + if (xIndexAccess.is() && xIndexAccess->getCount() > 0) + { + uno::Any aAny = xIndexAccess->getByIndex(0); + uno::Sequence< beans::PropertyValue > aSeq; + if (aAny >>= aSeq) + { + sal_Int32 nCount (aSeq.getLength()); + for (sal_Int32 i = 0; i < nCount; ++i) + { + ::rtl::OUString sName(aSeq[i].Name); + if (sName.compareToAscii(SC_ACTIVETABLE) == 0) + { + ::rtl::OUString sName; + if(aSeq[i].Value >>= sName) + { + String sTabName(sName); + sal_uInt16 nTab(0); + if (pDoc->GetTable(sTabName, nTab)) + { + pDoc->SetVisibleTab(nTab); + i = nCount; + } + } + } + } + } + } + } + } + GetProgressBarHelper()->End(); // make room for subsequent SfxProgressBars + if (pDoc) + pDoc->CompileXML(); + aTables.UpdateRowHeights(); + aTables.ResizeShapes(); + } + if (GetModel().is()) + { + uno::Reference<document::XActionLockable> xActionLockable(GetModel(), uno::UNO_QUERY); + if (xActionLockable.is()) + xActionLockable->removeActionLock(); + } + SvXMLImport::endDocument(); + + if (pDoc && bSelfImportingXMLSet) + { + ScModelObj::getImplementation(GetModel())->AfterXMLLoading(sal_True); + } + + UnlockSolarMutex(); +} + +// XEventListener +void ScXMLImport::DisposingModel() +{ + SvXMLImport::DisposingModel(); + pDoc = NULL; +} + +void ScXMLImport::LockSolarMutex() +{ + if (nSolarMutexLocked == 0) + { + DBG_ASSERT(!pSolarMutexGuard, "Solar Mutex is locked"); + pSolarMutexGuard = new SolarMutexGuard(); + } + nSolarMutexLocked++; +} + +void ScXMLImport::UnlockSolarMutex() +{ + if (nSolarMutexLocked > 0) + { + nSolarMutexLocked--; + if (nSolarMutexLocked == 0) + { + DBG_ASSERT(pSolarMutexGuard, "Solar Mutex is always unlocked"); + delete pSolarMutexGuard; + pSolarMutexGuard = NULL; + } + } +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_xmllabri.cxx b/binfilter/bf_sc/source/filter/xml/sc_xmllabri.cxx new file mode 100644 index 000000000000..4bb0480b684e --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_xmllabri.cxx @@ -0,0 +1,167 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +//___________________________________________________________________ + +#include "xmllabri.hxx" + +#include <bf_xmloff/nmspmap.hxx> + +#include <com/sun/star/sheet/XLabelRanges.hpp> + +#include "XMLConverter.hxx" +#include "unonames.hxx" +#include "xmlimprt.hxx" +namespace binfilter { + +using namespace ::com::sun::star; +using namespace ::rtl; +using namespace xmloff::token; + + +//___________________________________________________________________ + +ScXMLLabelRangesContext::ScXMLLabelRangesContext( + ScXMLImport& rImport, + USHORT nPrefix, + const OUString& rLName, + const uno::Reference< xml::sax::XAttributeList >& xAttrList ): + SvXMLImportContext( rImport, nPrefix, rLName ) +{ + rImport.LockSolarMutex(); +} + +ScXMLLabelRangesContext::~ScXMLLabelRangesContext() +{ + GetScImport().UnlockSolarMutex(); +} + +SvXMLImportContext* ScXMLLabelRangesContext::CreateChildContext( + USHORT nPrefix, + const OUString& rLName, + const uno::Reference< xml::sax::XAttributeList >& xAttrList ) +{ + SvXMLImportContext* pContext = NULL; + const SvXMLTokenMap& rTokenMap = GetScImport().GetLabelRangesElemTokenMap(); + + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + case XML_TOK_LABEL_RANGE_ELEM: + pContext = new ScXMLLabelRangeContext( GetScImport(), nPrefix, rLName, xAttrList ); + break; + } + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLLabelRangesContext::EndElement() +{ +} + + +//___________________________________________________________________ + +ScXMLLabelRangeContext::ScXMLLabelRangeContext( + ScXMLImport& rImport, + USHORT nPrfx, + const OUString& rLName, + const uno::Reference< xml::sax::XAttributeList >& xAttrList ) : + SvXMLImportContext( rImport, nPrfx, rLName ), + bColumnOrientation( sal_False ) +{ + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetLabelRangeAttrTokenMap(); + + for( sal_Int16 nIndex = 0; nIndex < nAttrCount; nIndex++ ) + { + OUString sAttrName = xAttrList->getNameByIndex( nIndex ); + OUString sValue = xAttrList->getValueByIndex( nIndex ); + OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_LABEL_RANGE_ATTR_LABEL_RANGE: + sLabelRangeStr = sValue; + break; + case XML_TOK_LABEL_RANGE_ATTR_DATA_RANGE: + sDataRangeStr = sValue; + break; + case XML_TOK_LABEL_RANGE_ATTR_ORIENTATION: + bColumnOrientation = IsXMLToken(sValue, XML_COLUMN ); + break; + } + } +} + +ScXMLLabelRangeContext::~ScXMLLabelRangeContext() +{ +} + +SvXMLImportContext* ScXMLLabelRangeContext::CreateChildContext( + USHORT nPrefix, + const OUString& rLName, + const uno::Reference< xml::sax::XAttributeList >& xAttrList ) +{ + return new SvXMLImportContext( GetImport(), nPrefix, rLName ); +} + +void ScXMLLabelRangeContext::EndElement() +{ + if (GetScImport().GetModel().is()) + { + uno::Reference< beans::XPropertySet > xPropSet( GetScImport().GetModel(), uno::UNO_QUERY ); + if( xPropSet.is() ) + { + uno::Any aAny = xPropSet->getPropertyValue( bColumnOrientation ? + OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_COLLABELRNG ) ) : + OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_ROWLABELRNG ) ) ); + uno::Reference< sheet::XLabelRanges > xLabelRanges; + if( aAny >>= xLabelRanges ) + { + table::CellRangeAddress aLabelRange; + table::CellRangeAddress aDataRange; + sal_Int32 nOffset1(0); + sal_Int32 nOffset2(0); + if (ScXMLConverter::GetRangeFromString( aLabelRange, sLabelRangeStr, GetScImport().GetDocument(), nOffset1 ) && + ScXMLConverter::GetRangeFromString( aDataRange, sDataRangeStr, GetScImport().GetDocument(), nOffset2 )) + xLabelRanges->addNew( aLabelRange, aDataRange ); + } + } + } +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_xmlnexpi.cxx b/binfilter/bf_sc/source/filter/xml/sc_xmlnexpi.cxx new file mode 100644 index 000000000000..ebcd831df4c2 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_xmlnexpi.cxx @@ -0,0 +1,357 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include "xmlnexpi.hxx" +#include "xmlimprt.hxx" +#include "docuno.hxx" +#include "XMLConverter.hxx" + +#include <bf_xmloff/nmspmap.hxx> +#include <com/sun/star/sheet/XNamedRanges.hpp> +#include <com/sun/star/sheet/NamedRangeFlag.hpp> +#include <com/sun/star/sheet/XNamedRange.hpp> +namespace binfilter { + +#define SC_NAMEDRANGES "NamedRanges" +#define SC_REPEAT_COLUMN "repeat-column" +#define SC_REPEAT_ROW "repeat-row" +#define SC_FILTER "filter" +#define SC_PRINT_RANGE "print-range" + +using namespace ::com::sun::star; + +ScXMLNamedExpressionsContext::ScXMLNamedExpressionsContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ +/* sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetNamedRangeAttrTokenMap(); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + } + }*/ + rImport.LockSolarMutex(); +} + +ScXMLNamedExpressionsContext::~ScXMLNamedExpressionsContext() +{ + GetScImport().UnlockSolarMutex(); +} + +SvXMLImportContext *ScXMLNamedExpressionsContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + const SvXMLTokenMap& rTokenMap = GetScImport().GetNamedExpressionsElemTokenMap(); + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + case XML_TOK_NAMED_EXPRESSIONS_NAMED_RANGE: + pContext = new ScXMLNamedRangeContext( GetScImport(), nPrefix, + rLName, xAttrList//, + //this + ); + break; + case XML_TOK_NAMED_EXPRESSIONS_NAMED_EXPRESSION: + pContext = new ScXMLNamedExpressionContext( GetScImport(), nPrefix, + rLName, xAttrList//, + //this + ); + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +sal_Int32 ScXMLNamedExpressionsContext::GetRangeType(const ::rtl::OUString sRangeType) const +{ + sal_Int32 nRangeType = 0; + ::rtl::OUStringBuffer sBuffer; + sal_Int16 i = 0; + while (i <= sRangeType.getLength()) + { + if ((sRangeType[i] == ' ') || (i == sRangeType.getLength())) + { + ::rtl::OUString sTemp = sBuffer.makeStringAndClear(); + if (sTemp.compareToAscii(SC_REPEAT_COLUMN) == 0) + nRangeType |= sheet::NamedRangeFlag::COLUMN_HEADER; + else if (sTemp.compareToAscii(SC_REPEAT_ROW) == 0) + nRangeType |= sheet::NamedRangeFlag::ROW_HEADER; + else if (sTemp.compareToAscii(SC_FILTER) == 0) + nRangeType |= sheet::NamedRangeFlag::FILTER_CRITERIA; + else if (sTemp.compareToAscii(SC_PRINT_RANGE) == 0) + nRangeType |= sheet::NamedRangeFlag::PRINT_AREA; + } + else if (i < sRangeType.getLength()) + sBuffer.append(sRangeType[i]); + i++; + } + return nRangeType; +} + +void ScXMLNamedExpressionsContext::EndElement() +{ + if (GetScImport().GetModel().is()) + { + uno::Reference <beans::XPropertySet> xPropertySet (GetScImport().GetModel(), uno::UNO_QUERY); + if (xPropertySet.is()) + { + uno::Any aNamedRanges = xPropertySet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_NAMEDRANGES))); + uno::Reference <sheet::XNamedRanges> xNamedRanges; + if (aNamedRanges >>= xNamedRanges) + { + ScMyNamedExpressions* pNamedExpressions = GetScImport().GetNamedExpressions(); + ScMyNamedExpressions::iterator aItr = pNamedExpressions->begin(); + ScMyNamedExpressions::const_iterator aEndItr = pNamedExpressions->end(); + table::CellAddress aCellAddress; + ::rtl::OUString sTempContent(RTL_CONSTASCII_USTRINGPARAM("0")); + while (aItr != aEndItr) + { + sal_Int32 nOffset(0); + if (ScXMLConverter::GetAddressFromString( + aCellAddress, (*aItr)->sBaseCellAddress, GetScImport().GetDocument(), nOffset )) + { + try + { + xNamedRanges->addNewByName((*aItr)->sName, sTempContent, aCellAddress, GetRangeType((*aItr)->sRangeType)); + } + catch( uno::RuntimeException& r ) + { + DBG_ERROR("here are some Named Ranges with the same name"); + uno::Reference < container::XIndexAccess > xIndex(xNamedRanges, uno::UNO_QUERY); + if (xIndex.is()) + { + sal_Int32 nMax(xIndex->getCount()); + sal_Bool bInserted(sal_False); + sal_Int32 nCount(1); + ::rtl::OUStringBuffer sName((*aItr)->sName); + sName.append(sal_Unicode('_')); + while (!bInserted && nCount <= nMax) + { + ::rtl::OUStringBuffer sTemp(sName); + sTemp.append(::rtl::OUString::valueOf(nCount)); + try + { + xNamedRanges->addNewByName(sTemp.makeStringAndClear(), sTempContent, aCellAddress, GetRangeType((*aItr)->sRangeType)); + bInserted = sal_True; + } + catch( uno::RuntimeException& rE ) + { + ++nCount; + } + } + } + } + } + aItr++; + } + aItr = pNamedExpressions->begin(); + while (aItr != aEndItr) + { + sal_Int32 nOffset(0); + if (ScXMLConverter::GetAddressFromString( + aCellAddress, (*aItr)->sBaseCellAddress, GetScImport().GetDocument(), nOffset )) + { + sTempContent = (*aItr)->sContent; + ScXMLConverter::ParseFormula(sTempContent, (*aItr)->bIsExpression); + uno::Any aNamedRange = xNamedRanges->getByName((*aItr)->sName); + uno::Reference <sheet::XNamedRange> xNamedRange; + if (aNamedRange >>= xNamedRange) + xNamedRange->setContent(sTempContent); + } + delete *aItr; + aItr = pNamedExpressions->erase(aItr); + } + } + } + } +} + +ScXMLNamedRangeContext::ScXMLNamedRangeContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + ScMyNamedExpression* pNamedExpression = new ScMyNamedExpression; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetNamedRangeAttrTokenMap(); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_NAMED_RANGE_ATTR_NAME : + { + pNamedExpression->sName = sValue; + } + break; + case XML_TOK_NAMED_RANGE_ATTR_CELL_RANGE_ADDRESS : + { + pNamedExpression->sContent = sValue; + } + break; + case XML_TOK_NAMED_RANGE_ATTR_BASE_CELL_ADDRESS : + { + pNamedExpression->sBaseCellAddress = sValue; + } + break; + case XML_TOK_NAMED_RANGE_ATTR_RANGE_USABLE_AS : + { + pNamedExpression->sRangeType = sValue; + } + break; + } + } + pNamedExpression->bIsExpression = sal_False; + GetScImport().AddNamedExpression(pNamedExpression); +} + +ScXMLNamedRangeContext::~ScXMLNamedRangeContext() +{ +} + +SvXMLImportContext *ScXMLNamedRangeContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + +/* const SvXMLTokenMap& rTokenMap = GetScImport().GetTableElemTokenMap(); + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + }*/ + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLNamedRangeContext::EndElement() +{ +} + +ScXMLNamedExpressionContext::ScXMLNamedExpressionContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + ScMyNamedExpression* pNamedExpression = new ScMyNamedExpression; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetNamedExpressionAttrTokenMap(); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_NAMED_EXPRESSION_ATTR_NAME : + { + pNamedExpression->sName = sValue; + } + break; + case XML_TOK_NAMED_EXPRESSION_ATTR_EXPRESSION : + { + pNamedExpression->sContent = sValue; + } + break; + case XML_TOK_NAMED_EXPRESSION_ATTR_BASE_CELL_ADDRESS : + { + pNamedExpression->sBaseCellAddress = sValue; + } + break; + } + } + pNamedExpression->bIsExpression = sal_True; + GetScImport().AddNamedExpression(pNamedExpression); +} + +ScXMLNamedExpressionContext::~ScXMLNamedExpressionContext() +{ +} + +SvXMLImportContext *ScXMLNamedExpressionContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + +/* const SvXMLTokenMap& rTokenMap = GetScImport().GetTableElemTokenMap(); + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + }*/ + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLNamedExpressionContext::EndElement() +{ +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_xmlrowi.cxx b/binfilter/bf_sc/source/filter/xml/sc_xmlrowi.cxx new file mode 100644 index 000000000000..e1e11c1530f1 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_xmlrowi.cxx @@ -0,0 +1,359 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "xmlrowi.hxx" +#include "xmlcelli.hxx" +#include "xmlstyli.hxx" +#include "document.hxx" +#include "docuno.hxx" +#include "olinetab.hxx" + +#include <bf_xmloff/nmspmap.hxx> +#include <bf_xmloff/xmlnmspe.hxx> + +#include <com/sun/star/table/XColumnRowRange.hpp> +#include <com/sun/star/sheet/XPrintAreas.hpp> + +namespace binfilter { + +#define SC_ISVISIBLE "IsVisible" +#define SC_OPTIMALHEIGHT "OptimalHeight" +#define SC_ISFILTERED "IsFiltered" + +using namespace ::com::sun::star; +using namespace xmloff::token; + +//------------------------------------------------------------------ + +ScXMLTableRowContext::ScXMLTableRowContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) : + SvXMLImportContext( rImport, nPrfx, rLName ), + sVisibility(GetXMLToken(XML_VISIBLE)), + nRepeatedRows(1), + bHasCell(sal_False) +{ + ::rtl::OUString sCellStyleName; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetTableRowAttrTokenMap(); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_TABLE_ROW_ATTR_STYLE_NAME: + { + sStyleName = sValue; + } + break; + case XML_TOK_TABLE_ROW_ATTR_VISIBILITY: + { + sVisibility = sValue; + } + break; + case XML_TOK_TABLE_ROW_ATTR_REPEATED: + { + nRepeatedRows = sValue.toInt32(); + } + break; + case XML_TOK_TABLE_ROW_ATTR_DEFAULT_CELL_STYLE_NAME: + { + sCellStyleName = sValue; + } + break; + /*case XML_TOK_TABLE_ROW_ATTR_USE_OPTIMAL_HEIGHT: + { + sOptimalHeight = sValue; + } + break;*/ + } + } + GetScImport().GetTables().AddRow(); + GetScImport().GetTables().SetRowStyle(sCellStyleName); +} + +ScXMLTableRowContext::~ScXMLTableRowContext() +{ +} + +SvXMLImportContext *ScXMLTableRowContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + const SvXMLTokenMap& rTokenMap = GetScImport().GetTableRowElemTokenMap(); + sal_Bool bHeader = sal_False; + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + case XML_TOK_TABLE_ROW_CELL: +// if( IsInsertCellPossible() ) + { + bHasCell = sal_True; + pContext = new ScXMLTableRowCellContext( GetScImport(), nPrefix, + rLName, xAttrList, sal_False, nRepeatedRows + //this + ); + } + break; + case XML_TOK_TABLE_ROW_COVERED_CELL: +// if( IsInsertCellPossible() ) + { + bHasCell = sal_True; + pContext = new ScXMLTableRowCellContext( GetScImport(), nPrefix, + rLName, xAttrList, sal_True, nRepeatedRows + //this + ); + } + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLTableRowContext::EndElement() +{ + ScXMLImport& rXMLImport = GetScImport(); + if (!bHasCell && nRepeatedRows > 1) + { + for (sal_Int32 i = 0; i < nRepeatedRows - 1; ++i) //one row is always added + GetScImport().GetTables().AddRow(); + DBG_ERRORFILE("it seems here is a nonvalid file; possible missing of table:table-cell element"); + } + sal_Int32 nCurrentRow = rXMLImport.GetTables().GetCurrentRow(); + uno::Reference<sheet::XSpreadsheet> xSheet = rXMLImport.GetTables().GetCurrentXSheet(); + if(xSheet.is()) + { + sal_Int32 nFirstRow(nCurrentRow - nRepeatedRows + 1); + if (nFirstRow > MAXROW) + nFirstRow = MAXROW; + if (nCurrentRow > MAXROW) + nCurrentRow = MAXROW; + uno::Reference <table::XCellRange> xCellRange = xSheet->getCellRangeByPosition(0, nFirstRow, 0, nCurrentRow); + if (xCellRange.is()) + { + uno::Reference<table::XColumnRowRange> xColumnRowRange (xCellRange, uno::UNO_QUERY); + if (xColumnRowRange.is()) + { + uno::Reference<table::XTableRows> xTableRows = xColumnRowRange->getRows(); + if (xTableRows.is()) + { + uno::Reference <beans::XPropertySet> xRowProperties(xTableRows, uno::UNO_QUERY); + if (xRowProperties.is()) + { + if (sStyleName.getLength()) + { + XMLTableStylesContext *pStyles = (XMLTableStylesContext *)rXMLImport.GetAutoStyles(); + XMLTableStyleContext* pStyle = (XMLTableStyleContext *)pStyles->FindStyleChildContext( + XML_STYLE_FAMILY_TABLE_ROW, sStyleName, sal_True); + if (pStyle) + pStyle->FillPropertySet(xRowProperties); + } + uno::Any aVisibleAny; + uno::Any aFilteredAny; + sal_Bool bVisible (sal_True); + sal_Bool bFiltered (sal_False); + if (IsXMLToken(sVisibility, XML_COLLAPSE)) + { + bVisible = sal_False; + aVisibleAny <<= bVisible; + aFilteredAny <<= bFiltered; + } + else if (IsXMLToken(sVisibility, XML_FILTER)) + { + bVisible = sal_False; + aVisibleAny <<= bVisible; + bFiltered = sal_True; + aFilteredAny <<= bFiltered; + } + if (!bVisible) + xRowProperties->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ISVISIBLE)), aVisibleAny); + if (bFiltered) + xRowProperties->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ISFILTERED)), aFilteredAny); + } + } + } + } + } +} + +ScXMLTableRowsContext::ScXMLTableRowsContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + const sal_Bool bTempHeader, const sal_Bool bTempGroup ) : + SvXMLImportContext( rImport, nPrfx, rLName ), + nHeaderStartRow(0), + nHeaderEndRow(0), + nGroupStartRow(0), + nGroupEndRow(0), + bHeader(bTempHeader), + bGroup(bTempGroup), + bGroupDisplay(sal_True) +{ + // don't have any attributes + if (bHeader) + { + nHeaderStartRow = rImport.GetTables().GetCurrentRow(); + nHeaderStartRow++; + } + else if (bGroup) + { + nGroupStartRow = rImport.GetTables().GetCurrentRow(); + nGroupStartRow++; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + if ((nPrfx == XML_NAMESPACE_TABLE) && IsXMLToken(aLocalName, XML_DISPLAY)) + bGroupDisplay = IsXMLToken(sValue, XML_TRUE); + } + } +} + +ScXMLTableRowsContext::~ScXMLTableRowsContext() +{ +} + +SvXMLImportContext *ScXMLTableRowsContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + const SvXMLTokenMap& rTokenMap = GetScImport().GetTableRowsElemTokenMap(); + sal_Bool bHeader = sal_False; + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + case XML_TOK_TABLE_ROWS_ROW_GROUP: + pContext = new ScXMLTableRowsContext( GetScImport(), nPrefix, + rLName, xAttrList, + sal_False, sal_True ); + break; + case XML_TOK_TABLE_ROWS_HEADER_ROWS: + pContext = new ScXMLTableRowsContext( GetScImport(), nPrefix, + rLName, xAttrList, + sal_True, sal_False ); + break; + case XML_TOK_TABLE_ROWS_ROWS: + pContext = new ScXMLTableRowsContext( GetScImport(), nPrefix, + rLName, xAttrList, + sal_False, sal_False ); + break; + case XML_TOK_TABLE_ROWS_ROW: + pContext = new ScXMLTableRowContext( GetScImport(), nPrefix, + rLName, xAttrList//, + //this + ); + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLTableRowsContext::EndElement() +{ + ScXMLImport& rXMLImport = GetScImport(); + if (bHeader) + { + nHeaderEndRow = rXMLImport.GetTables().GetCurrentRow(); + if (nHeaderStartRow <= nHeaderEndRow) + { + uno::Reference<sheet::XSpreadsheet> xSheet = rXMLImport.GetTables().GetCurrentXSheet(); + if(xSheet.is()) + { + uno::Reference <sheet::XPrintAreas> xPrintAreas (xSheet, uno::UNO_QUERY); + if (xPrintAreas.is()) + { + if (!xPrintAreas->getPrintTitleRows()) + { + xPrintAreas->setPrintTitleRows(sal_True); + table::CellRangeAddress aRowHeaderRange; + aRowHeaderRange.StartRow = nHeaderStartRow; + aRowHeaderRange.EndRow = nHeaderEndRow; + xPrintAreas->setTitleRows(aRowHeaderRange); + } + else + { + table::CellRangeAddress aRowHeaderRange = xPrintAreas->getTitleRows(); + aRowHeaderRange.EndRow = nHeaderEndRow; + xPrintAreas->setTitleRows(aRowHeaderRange); + } + } + } + } + } + else if (bGroup) + { + nGroupEndRow = rXMLImport.GetTables().GetCurrentRow(); + sal_Int16 nSheet = rXMLImport.GetTables().GetCurrentSheet(); + if (nGroupStartRow <= nGroupEndRow) + { + ScDocument* pDoc = GetScImport().GetDocument(); + if (pDoc) + { + GetScImport().LockSolarMutex(); + ScOutlineTable* pOutlineTable = pDoc->GetOutlineTable(nSheet, sal_True); + ScOutlineArray* pRowArray = pOutlineTable->GetRowArray(); + sal_Bool bResized; + pRowArray->Insert(static_cast<USHORT>(nGroupStartRow), static_cast<USHORT>(nGroupEndRow), bResized, !bGroupDisplay, sal_True); + GetScImport().UnlockSolarMutex(); + } + } + } +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_xmlsceni.cxx b/binfilter/bf_sc/source/filter/xml/sc_xmlsceni.cxx new file mode 100644 index 000000000000..c4d58426dc58 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_xmlsceni.cxx @@ -0,0 +1,167 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "document.hxx" +#include "xmlimprt.hxx" +#include "xmlsceni.hxx" +#include "attrib.hxx" + +#include "XMLConverter.hxx" + +#include <bf_xmloff/nmspmap.hxx> +#include <bf_xmloff/xmluconv.hxx> +namespace binfilter { + +using namespace ::com::sun::star; +using namespace xmloff::token; + +using rtl::OUString; + +//------------------------------------------------------------------ + +ScXMLTableScenarioContext::ScXMLTableScenarioContext( + ScXMLImport& rImport, + USHORT nPrfx, + const OUString& rLName, + const uno::Reference< xml::sax::XAttributeList >& xAttrList ): + SvXMLImportContext( rImport, nPrfx, rLName ), + aBorderColor( COL_BLACK ), + bDisplayBorder( sal_True ), + bCopyBack( sal_True ), + bCopyStyles( sal_True ), + bCopyFormulas( sal_True ), + bIsActive( sal_False ) +{ + rImport.LockSolarMutex(); + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetTableScenarioAttrTokenMap(); + for( sal_Int16 i = 0; i < nAttrCount; i++ ) + { + OUString sAttrName = xAttrList->getNameByIndex( i ); + OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + OUString sValue = xAttrList->getValueByIndex( i ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_TABLE_SCENARIO_ATTR_DISPLAY_BORDER: + { + bDisplayBorder = IsXMLToken(sValue, XML_TRUE); + } + break; + case XML_TOK_TABLE_SCENARIO_ATTR_BORDER_COLOR: + { + SvXMLUnitConverter::convertColor(aBorderColor, sValue); + } + break; + case XML_TOK_TABLE_SCENARIO_ATTR_COPY_BACK: + { + bCopyBack = IsXMLToken(sValue, XML_TRUE); + } + break; + case XML_TOK_TABLE_SCENARIO_ATTR_COPY_STYLES: + { + bCopyStyles = IsXMLToken(sValue, XML_TRUE); + } + break; + case XML_TOK_TABLE_SCENARIO_ATTR_COPY_FORMULAS: + { + bCopyFormulas = IsXMLToken(sValue, XML_TRUE); + } + break; + case XML_TOK_TABLE_SCENARIO_ATTR_IS_ACTIVE: + { + bIsActive = IsXMLToken(sValue, XML_TRUE); + } + break; + case XML_TOK_TABLE_SCENARIO_ATTR_SCENARIO_RANGES: + { + ScXMLConverter::GetRangeListFromString( + aScenarioRanges, sValue, GetScImport().GetDocument() ); + } + break; + case XML_TOK_TABLE_SCENARIO_ATTR_COMMENT: + { + sComment = sValue; + } + break; + } + } +} + +ScXMLTableScenarioContext::~ScXMLTableScenarioContext() +{ + GetScImport().UnlockSolarMutex(); +} + +SvXMLImportContext *ScXMLTableScenarioContext::CreateChildContext( + USHORT nPrefix, + const OUString& rLName, + const uno::Reference< xml::sax::XAttributeList >& xAttrList ) +{ + return new SvXMLImportContext( GetImport(), nPrefix, rLName ); +} + +void ScXMLTableScenarioContext::EndElement() +{ + sal_Int16 nCurrTable( GetScImport().GetTables().GetCurrentSheet() ); + ScDocument* pDoc = GetScImport().GetDocument(); + if (pDoc) + { + pDoc->SetScenario( nCurrTable, TRUE ); + USHORT nFlags( 0 ); + if( bDisplayBorder ) + nFlags |= SC_SCENARIO_SHOWFRAME; + if( bCopyBack ) + nFlags |= SC_SCENARIO_TWOWAY; + if( bCopyStyles ) + nFlags |= SC_SCENARIO_ATTRIB; + if( !bCopyFormulas ) + nFlags |= SC_SCENARIO_VALUE; + pDoc->SetScenarioData( nCurrTable, String( sComment ), aBorderColor, nFlags ); + for( sal_Int32 i = 0; i < static_cast<sal_Int32>(aScenarioRanges.Count()); i++ ) + { + ScRange* pRange = aScenarioRanges.GetObject( i ); + if( pRange ) + pDoc->ApplyFlagsTab( pRange->aStart.Col(), pRange->aStart.Row(), + pRange->aEnd.Col(), pRange->aEnd.Row(), nCurrTable, SC_MF_SCENARIO ); + } + pDoc->SetActiveScenario( nCurrTable, bIsActive ); + } +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_xmlsorti.cxx b/binfilter/bf_sc/source/filter/xml/sc_xmlsorti.cxx new file mode 100644 index 000000000000..01e290768d9d --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_xmlsorti.cxx @@ -0,0 +1,306 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "xmlsorti.hxx" +#include "xmlimprt.hxx" + +#include "convuno.hxx" +#include "XMLConverter.hxx" +#include "unonames.hxx" + +#include <bf_xmloff/nmspmap.hxx> +#include <comphelper/extract.hxx> +namespace binfilter { + +#define SC_USERLIST "UserList" + +using namespace ::com::sun::star; +using namespace xmloff::token; + +//------------------------------------------------------------------ + +ScXMLSortContext::ScXMLSortContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDatabaseRangeContext* pTempDatabaseRangeContext) : + bEnabledUserList(sal_False), + bBindFormatsToContent(sal_True), + bIsCaseSensitive(sal_False), + bCopyOutputData(sal_False), + sCountry(), + sLanguage(), + sAlgorithm(), + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + pDatabaseRangeContext = pTempDatabaseRangeContext; + nUserListIndex = 0; + + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetSortAttrTokenMap(); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_SORT_ATTR_BIND_STYLES_TO_CONTENT : + { + bBindFormatsToContent = IsXMLToken(sValue, XML_TRUE); + } + break; + case XML_TOK_SORT_ATTR_TARGET_RANGE_ADDRESS : + { + ScRange aScRange; + sal_Int32 nOffset(0); + if (ScXMLConverter::GetRangeFromString( aScRange, sValue, GetScImport().GetDocument(), nOffset )) + { + ScUnoConversion::FillApiAddress( aOutputPosition, aScRange.aStart ); + bCopyOutputData = sal_True; + } + } + break; + case XML_TOK_SORT_ATTR_CASE_SENSITIVE : + { + bIsCaseSensitive = IsXMLToken(sValue, XML_TRUE); + } + break; + case XML_TOK_SORT_ATTR_LANGUAGE : + sLanguage = sValue; + break; + case XML_TOK_SORT_ATTR_COUNTRY : + sCountry = sValue; + break; + case XML_TOK_SORT_ATTR_ALGORITHM : + sAlgorithm = sValue; + break; + } + } +} + +ScXMLSortContext::~ScXMLSortContext() +{ +} + +SvXMLImportContext *ScXMLSortContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + const SvXMLTokenMap& rTokenMap = GetScImport().GetSortElemTokenMap(); + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + case XML_TOK_SORT_SORT_BY : + { + pContext = new ScXMLSortByContext( GetScImport(), nPrefix, + rLName, xAttrList, this); + } + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLSortContext::EndElement() +{ + sal_Int32 nLangLength(sLanguage.getLength()); + sal_Int32 nCountryLength(sCountry.getLength()); + sal_Int32 nAlgoLength(sAlgorithm.getLength()); + sal_uInt8 i (0); + if (nLangLength || nCountryLength) + i++; + if (nAlgoLength) + i++; + uno::Sequence <beans::PropertyValue> aSortDescriptor(7 + i); + uno::Any aTemp; + beans::PropertyValue aPropertyValue; + aTemp = ::cppu::bool2any(bBindFormatsToContent); + aPropertyValue.Name = ::rtl::OUString::createFromAscii(SC_UNONAME_BINDFMT); + aPropertyValue.Value = aTemp; + aSortDescriptor[0] = aPropertyValue; + aTemp = ::cppu::bool2any(bCopyOutputData); + aPropertyValue.Name = ::rtl::OUString::createFromAscii(SC_UNONAME_COPYOUT); + aPropertyValue.Value = aTemp; + aSortDescriptor[1] = aPropertyValue; + aTemp = ::cppu::bool2any(bIsCaseSensitive); + aPropertyValue.Name = ::rtl::OUString::createFromAscii(SC_UNONAME_ISCASE); + aPropertyValue.Value = aTemp; + aSortDescriptor[2] = aPropertyValue; + aTemp = ::cppu::bool2any(bEnabledUserList); + aPropertyValue.Name = ::rtl::OUString::createFromAscii(SC_UNONAME_ISULIST); + aPropertyValue.Value = aTemp; + aSortDescriptor[3] = aPropertyValue; + aTemp <<= aOutputPosition; + aPropertyValue.Name = ::rtl::OUString::createFromAscii(SC_UNONAME_OUTPOS); + aPropertyValue.Value = aTemp; + aSortDescriptor[4] = aPropertyValue; + aTemp <<= nUserListIndex; + aPropertyValue.Name = ::rtl::OUString::createFromAscii(SC_UNONAME_UINDEX); + aPropertyValue.Value = aTemp; + aSortDescriptor[5] = aPropertyValue; + aTemp <<= aSortFields; + aPropertyValue.Name = ::rtl::OUString::createFromAscii(SC_UNONAME_SORTFLD); + aPropertyValue.Value = aTemp; + aSortDescriptor[6] = aPropertyValue; + if (nLangLength || nCountryLength) + { + lang::Locale aLocale; + aLocale.Language = sLanguage; + aLocale.Country = sCountry; + aTemp <<= aLocale; + aPropertyValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_COLLLOC)); + aPropertyValue.Value = aTemp; + aSortDescriptor[7] = aPropertyValue; + } + if (nAlgoLength) + { + aTemp <<= sAlgorithm; + aPropertyValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_COLLALG)); + aPropertyValue.Value = aTemp; + aSortDescriptor[6 + i] = aPropertyValue; + } + pDatabaseRangeContext->SetSortSequence(aSortDescriptor); +} + +void ScXMLSortContext::AddSortField(const ::rtl::OUString& sFieldNumber, const ::rtl::OUString& sDataType, const ::rtl::OUString& sOrder) +{ + util::SortField aSortField; + aSortField.Field = sFieldNumber.toInt32(); + if (IsXMLToken(sOrder, XML_ASCENDING)) + aSortField.SortAscending = sal_True; + else + aSortField.SortAscending = sal_False; + if (sDataType.getLength() > 8) + { + ::rtl::OUString sTemp = sDataType.copy(0, 8); + if (sTemp.compareToAscii(SC_USERLIST) == 0) + { + bEnabledUserList = sal_True; + sTemp = sDataType.copy(8); + nUserListIndex = static_cast<sal_Int16>(sTemp.toInt32()); + } + else + { + if (IsXMLToken(sDataType, XML_AUTOMATIC)) + aSortField.FieldType = util::SortFieldType_AUTOMATIC; + } + } + else + { + if (IsXMLToken(sDataType, XML_TEXT)) + aSortField.FieldType = util::SortFieldType_ALPHANUMERIC; + else if (IsXMLToken(sDataType, XML_NUMBER)) + aSortField.FieldType = util::SortFieldType_NUMERIC; + } + aSortFields.realloc(aSortFields.getLength() + 1); + aSortFields[aSortFields.getLength() - 1] = aSortField; +} + +ScXMLSortByContext::ScXMLSortByContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLSortContext* pTempSortContext) : + SvXMLImportContext( rImport, nPrfx, rLName ), + sOrder(GetXMLToken(XML_ASCENDING)), + sDataType(GetXMLToken(XML_AUTOMATIC)) +{ + pSortContext = pTempSortContext; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetSortSortByAttrTokenMap(); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_SORT_BY_ATTR_FIELD_NUMBER : + { + sFieldNumber = sValue; + } + break; + case XML_TOK_SORT_BY_ATTR_DATA_TYPE : + { + sDataType = sValue; + } + break; + case XML_TOK_SORT_BY_ATTR_ORDER : + { + sOrder = sValue; + } + break; + } + } +} + +ScXMLSortByContext::~ScXMLSortByContext() +{ +} + +SvXMLImportContext *ScXMLSortByContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLSortByContext::EndElement() +{ + pSortContext->AddSortField(sFieldNumber, sDataType, sOrder); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_xmlstyle.cxx b/binfilter/bf_sc/source/filter/xml/sc_xmlstyle.cxx new file mode 100644 index 000000000000..8894b3deeebd --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_xmlstyle.cxx @@ -0,0 +1,1577 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include "xmlexprt.hxx" +#include "xmlimprt.hxx" + +/*#ifndef _PROPIMP0_HXX +#endif*/ +#include "XMLConverter.hxx" + +#include <bf_xmloff/xmlnmspe.hxx> +#include <bf_xmloff/xmluconv.hxx> + +#include <tools/debug.hxx> + +#include <com/sun/star/util/CellProtection.hpp> +#include <com/sun/star/table/CellOrientation.hpp> +#include <com/sun/star/table/CellVertJustify.hpp> +#include <com/sun/star/table/CellHoriJustify.hpp> +#include <com/sun/star/table/TableBorder.hpp> +#include <com/sun/star/sheet/XSheetConditionalEntries.hpp> +#include <com/sun/star/sheet/XSheetConditionalEntry.hpp> +#include <com/sun/star/sheet/XSheetCondition.hpp> +#include <com/sun/star/beans/XPropertyState.hpp> +#include <comphelper/extract.hxx> + +namespace binfilter { + +using namespace ::com::sun::star; +using namespace ::binfilter::xmloff::token; + +using rtl::OUString; + +#define MAP(name,prefix,token,type,context) { name, sizeof(name)-1, prefix, token, type, context } +#define MAP_END() { NULL, 0, 0, XML_TOKEN_INVALID, 0 } + +const XMLPropertyMapEntry aXMLScCellStylesProperties[] = +{ + MAP( "AsianVerticalMode", XML_NAMESPACE_STYLE, XML_GLYPH_ORIENTATION_VERTICAL, XML_SC_TYPE_VERTICAL, 0), + MAP( "BottomBorder", XML_NAMESPACE_FO, XML_BORDER_BOTTOM, XML_TYPE_BORDER, CTF_SC_BOTTOMBORDER ), + MAP( "BottomBorder", XML_NAMESPACE_STYLE, XML_BORDER_LINE_WIDTH_BOTTOM, XML_TYPE_BORDER_WIDTH, CTF_SC_BOTTOMBORDERWIDTH ), + MAP( "CellBackColor", XML_NAMESPACE_FO, XML_BACKGROUND_COLOR, XML_TYPE_COLORTRANSPARENT|MID_FLAG_MULTI_PROPERTY|MID_FLAG_MERGE_ATTRIBUTE, 0 ), + MAP( "CellProtection", XML_NAMESPACE_STYLE, XML_CELL_PROTECT, XML_SC_TYPE_CELLPROTECTION|MID_FLAG_MERGE_PROPERTY, 0 ), + MAP( "CellProtection", XML_NAMESPACE_STYLE, XML_PRINT_CONTENT, XML_SC_TYPE_PRINTCONTENT|MID_FLAG_MERGE_PROPERTY, 0 ), + MAP( "CellStyle", XML_NAMESPACE_STYLE, XML_STYLE, XML_TYPE_STRING, CTF_SC_CELLSTYLE ), + MAP( "ConditionalFormat", XML_NAMESPACE_STYLE, XML_MAP, XML_TYPE_STRING|MID_FLAG_SPECIAL_ITEM, CTF_SC_IMPORT_MAP ), + MAP( "ConditionalFormatXML", XML_NAMESPACE_STYLE, XML_MAP, XML_TYPE_STRING|MID_FLAG_SPECIAL_ITEM, CTF_SC_MAP ), + MAP( "HoriJustify", XML_NAMESPACE_FO, XML_TEXT_ALIGN, XML_SC_TYPE_HORIJUSTIFY|MID_FLAG_MERGE_PROPERTY, 0 ), + MAP( "HoriJustify", XML_NAMESPACE_STYLE, XML_TEXT_ALIGN_SOURCE, XML_SC_TYPE_HORIJUSTIFYSOURCE|MID_FLAG_MERGE_PROPERTY, 0 ), + MAP( "IsCellBackgroundTransparent", XML_NAMESPACE_FO, XML_BACKGROUND_COLOR, XML_TYPE_ISTRANSPARENT|MID_FLAG_MULTI_PROPERTY|MID_FLAG_MERGE_ATTRIBUTE, 0 ), + MAP( "IsTextWrapped", XML_NAMESPACE_FO, XML_WRAP_OPTION, XML_SC_ISTEXTWRAPPED, 0 ), + MAP( "LeftBorder", XML_NAMESPACE_FO, XML_BORDER, XML_TYPE_BORDER, CTF_SC_ALLBORDER ), + MAP( "LeftBorder", XML_NAMESPACE_FO, XML_BORDER_LEFT, XML_TYPE_BORDER, CTF_SC_LEFTBORDER ), + MAP( "LeftBorder", XML_NAMESPACE_STYLE, XML_BORDER_LINE_WIDTH, XML_TYPE_BORDER_WIDTH, CTF_SC_ALLBORDERWIDTH ), + MAP( "LeftBorder", XML_NAMESPACE_STYLE, XML_BORDER_LINE_WIDTH_LEFT, XML_TYPE_BORDER_WIDTH, CTF_SC_LEFTBORDERWIDTH ), + MAP( "NumberFormat", XML_NAMESPACE_STYLE, XML_DATA_STYLE_NAME, XML_TYPE_NUMBER|MID_FLAG_SPECIAL_ITEM, CTF_SC_NUMBERFORMAT), + MAP( "Orientation", XML_NAMESPACE_FO, XML_DIRECTION, XML_SC_TYPE_ORIENTATION, 0 ), + MAP( "ParaBottomMargin", XML_NAMESPACE_FO, XML_PADDING, XML_TYPE_MEASURE, CTF_SC_ALLPADDING ), + MAP( "ParaBottomMargin", XML_NAMESPACE_FO, XML_PADDING_BOTTOM, XML_TYPE_MEASURE, CTF_SC_BOTTOMPADDING ), + MAP( "ParaIndent", XML_NAMESPACE_FO, XML_MARGIN_LEFT, XML_TYPE_MEASURE16, 0 ), + MAP( "ParaIsHyphenation", XML_NAMESPACE_FO, XML_HYPHENATE, XML_TYPE_BOOL, 0 ), + MAP( "ParaLeftMargin", XML_NAMESPACE_FO, XML_PADDING_LEFT, XML_TYPE_MEASURE, CTF_SC_LEFTPADDING ), + MAP( "ParaRightMargin", XML_NAMESPACE_FO, XML_PADDING_RIGHT, XML_TYPE_MEASURE, CTF_SC_RIGHTPADDING ), + MAP( "ParaTopMargin", XML_NAMESPACE_FO, XML_PADDING_TOP, XML_TYPE_MEASURE, CTF_SC_TOPPADDING ), + MAP( "RightBorder", XML_NAMESPACE_FO, XML_BORDER_RIGHT, XML_TYPE_BORDER, CTF_SC_RIGHTBORDER ), + MAP( "RightBorder", XML_NAMESPACE_STYLE, XML_BORDER_LINE_WIDTH_RIGHT, XML_TYPE_BORDER_WIDTH, CTF_SC_RIGHTBORDERWIDTH ), + MAP( "RotateAngle", XML_NAMESPACE_STYLE, XML_ROTATION_ANGLE, XML_SC_TYPE_ROTATEANGLE, 0 ), + MAP( "RotateReference", XML_NAMESPACE_STYLE, XML_ROTATION_ALIGN, XML_SC_TYPE_ROTATEREFERENCE, 0), + MAP( "ShadowFormat", XML_NAMESPACE_STYLE, XML_SHADOW, XML_TYPE_TEXT_SHADOW, 0 ), + MAP( "StandardDecimals", XML_NAMESPACE_STYLE, XML_DECIMAL_PLACES, XML_TYPE_NUMBER16, 0 ), + MAP( "TopBorder", XML_NAMESPACE_FO, XML_BORDER_TOP, XML_TYPE_BORDER, CTF_SC_TOPBORDER ), + MAP( "TopBorder", XML_NAMESPACE_STYLE, XML_BORDER_LINE_WIDTH_TOP, XML_TYPE_BORDER_WIDTH, CTF_SC_TOPBORDERWIDTH ), + MAP( "UserDefinedAttributes", XML_NAMESPACE_TEXT, XML_XMLNS, XML_TYPE_ATTRIBUTE_CONTAINER | MID_FLAG_SPECIAL_ITEM, 0 ), + MAP( "ValidationXML", XML_NAMESPACE_TABLE, XML_CONTENT_VALIDATION, XML_TYPE_BUILDIN_CMP_ONLY, CTF_SC_VALIDATION ), + MAP( "VertJustify", XML_NAMESPACE_FO, XML_VERTICAL_ALIGN, XML_SC_TYPE_VERTJUSTIFY, 0), + MAP( "WritingMode", XML_NAMESPACE_STYLE, XML_WRITING_MODE, XML_TYPE_TEXT_WRITING_MODE_WITH_DEFAULT, 0 ), + { 0L } +}; + +const XMLPropertyMapEntry aXMLScColumnStylesProperties[] = +{ + MAP( "IsManualPageBreak", XML_NAMESPACE_FO, XML_BREAK_BEFORE, XML_SC_TYPE_BREAKBEFORE, 0), + MAP( "IsVisible", XML_NAMESPACE_TABLE, XML_DISPLAY, XML_SC_TYPE_EQUAL|MID_FLAG_SPECIAL_ITEM, CTF_SC_ISVISIBLE ), + MAP( "Width", XML_NAMESPACE_STYLE, XML_COLUMN_WIDTH, XML_TYPE_MEASURE, 0 ), +// MAP( "OptimalWidth", XML_NAMESPACE_STYLE, XML_USE_OPTIMAL_COLUMN_WIDTH, XML_TYPE_BOOL, 0), + { 0L } +}; + +const XMLPropertyMapEntry aXMLScRowStylesProperties[] = +{ + MAP( "Height", XML_NAMESPACE_STYLE, XML_ROW_HEIGHT, XML_TYPE_MEASURE, CTF_SC_ROWHEIGHT), + MAP( "IsManualPageBreak", XML_NAMESPACE_FO, XML_BREAK_BEFORE, XML_SC_TYPE_BREAKBEFORE, CTF_SC_ROWBREAKBEFORE), + MAP( "OptimalHeight", XML_NAMESPACE_STYLE, XML_USE_OPTIMAL_ROW_HEIGHT, XML_TYPE_BOOL, CTF_SC_ROWOPTIMALHEIGHT), + { 0L } +}; + +const XMLPropertyMapEntry aXMLScTableStylesProperties[] = +{ + MAP( "IsVisible", XML_NAMESPACE_TABLE, XML_DISPLAY, XML_TYPE_BOOL, 0 ), + MAP( "PageStyle", XML_NAMESPACE_STYLE, XML_MASTER_PAGE_NAME, XML_TYPE_STRING|MID_FLAG_SPECIAL_ITEM, CTF_SC_MASTERPAGENAME ), + { 0L } +}; + +ScXMLCellExportPropertyMapper::ScXMLCellExportPropertyMapper( + const UniReference< XMLPropertySetMapper >& rMapper ) + : SvXMLExportPropertyMapper(rMapper) +{ +} + +ScXMLCellExportPropertyMapper::~ScXMLCellExportPropertyMapper() +{ +} + +void ScXMLCellExportPropertyMapper::ContextFilter( + ::std::vector< XMLPropertyState >& rProperties, + uno::Reference< beans::XPropertySet > rPropSet ) const +{ + XMLPropertyState* pPadding = NULL; + XMLPropertyState* pPadding_Bottom = NULL; + XMLPropertyState* pPadding_Left = NULL; + XMLPropertyState* pPadding_Right = NULL; + XMLPropertyState* pPadding_Top = NULL; + + XMLPropertyState* pBorder = NULL; + XMLPropertyState* pBorder_Bottom = NULL; + XMLPropertyState* pBorder_Left = NULL; + XMLPropertyState* pBorder_Right = NULL; + XMLPropertyState* pBorder_Top = NULL; + + XMLPropertyState* pAllBorderWidthState = NULL; + XMLPropertyState* pLeftBorderWidthState = NULL; + XMLPropertyState* pRightBorderWidthState = NULL; + XMLPropertyState* pTopBorderWidthState = NULL; + XMLPropertyState* pBottomBorderWidthState = NULL; + + for( ::std::vector< XMLPropertyState >::iterator aIter = rProperties.begin(); + aIter != rProperties.end(); + ++aIter ) + { + XMLPropertyState *propertie = &(*aIter); + switch( getPropertySetMapper()->GetEntryContextId( propertie->mnIndex ) ) + { + case CTF_SC_ALLPADDING: pPadding = propertie; break; + case CTF_SC_BOTTOMPADDING: pPadding_Bottom = propertie; break; + case CTF_SC_LEFTPADDING: pPadding_Left = propertie; break; + case CTF_SC_RIGHTPADDING: pPadding_Right = propertie; break; + case CTF_SC_TOPPADDING: pPadding_Top = propertie; break; + case CTF_SC_ALLBORDER: pBorder = propertie; break; + case CTF_SC_LEFTBORDER: pBorder_Left = propertie; break; + case CTF_SC_RIGHTBORDER: pBorder_Right = propertie; break; + case CTF_SC_BOTTOMBORDER: pBorder_Bottom = propertie; break; + case CTF_SC_TOPBORDER: pBorder_Top = propertie; break; + case CTF_SC_ALLBORDERWIDTH: pAllBorderWidthState = propertie; break; + case CTF_SC_LEFTBORDERWIDTH: pLeftBorderWidthState = propertie; break; + case CTF_SC_RIGHTBORDERWIDTH: pRightBorderWidthState = propertie; break; + case CTF_SC_TOPBORDERWIDTH: pTopBorderWidthState = propertie; break; + case CTF_SC_BOTTOMBORDERWIDTH: pBottomBorderWidthState = propertie; break; + } + } + + if (pPadding && pPadding_Bottom && pPadding_Left && pPadding_Right && pPadding_Top) + { + sal_Int32 nBottom, nTop, nLeft, nRight; + if ((pPadding_Bottom->maValue >>= nBottom) && + (pPadding_Left->maValue >>= nLeft) && + (pPadding_Right->maValue >>= nRight) && + (pPadding_Top->maValue >>= nTop)) + { + if ((nBottom == nTop) && (nLeft == nRight) && (nTop == nLeft)) + { + pPadding_Bottom->mnIndex = -1; + pPadding_Bottom->maValue.clear(); + pPadding_Left->mnIndex = -1; + pPadding_Left->maValue.clear(); + pPadding_Right->mnIndex = -1; + pPadding_Right->maValue.clear(); + pPadding_Top->mnIndex = -1; + pPadding_Top->maValue.clear(); + } + else + { + pPadding->mnIndex = -1; + pPadding->maValue.clear(); + } + } + } + if( pBorder ) + { + if( pBorder_Left && pBorder_Right && pBorder_Top && pBorder_Bottom ) + { + table::BorderLine aLeft, aRight, aTop, aBottom; + + pBorder_Left->maValue >>= aLeft; + pBorder_Right->maValue >>= aRight; + pBorder_Top->maValue >>= aTop; + pBorder_Bottom->maValue >>= aBottom; + if( aLeft.Color == aRight.Color && aLeft.InnerLineWidth == aRight.InnerLineWidth && + aLeft.OuterLineWidth == aRight.OuterLineWidth && aLeft.LineDistance == aRight.LineDistance && + aLeft.Color == aTop.Color && aLeft.InnerLineWidth == aTop.InnerLineWidth && + aLeft.OuterLineWidth == aTop.OuterLineWidth && aLeft.LineDistance == aTop.LineDistance && + aLeft.Color == aBottom.Color && aLeft.InnerLineWidth == aBottom.InnerLineWidth && + aLeft.OuterLineWidth == aBottom.OuterLineWidth && aLeft.LineDistance == aBottom.LineDistance ) + { + pBorder_Left->mnIndex = -1; + pBorder_Left->maValue.clear(); + pBorder_Right->mnIndex = -1; + pBorder_Right->maValue.clear(); + pBorder_Top->mnIndex = -1; + pBorder_Top->maValue.clear(); + pBorder_Bottom->mnIndex = -1; + pBorder_Bottom->maValue.clear(); + } + else + { + pBorder->mnIndex = -1; + pBorder->maValue.clear(); + } + } + else + { + pBorder->mnIndex = -1; + pBorder->maValue.clear(); + } + } + if( pAllBorderWidthState ) + { + if( pLeftBorderWidthState && pRightBorderWidthState && pTopBorderWidthState && pBottomBorderWidthState ) + { + table::BorderLine aLeft, aRight, aTop, aBottom; + + pLeftBorderWidthState->maValue >>= aLeft; + pRightBorderWidthState->maValue >>= aRight; + pTopBorderWidthState->maValue >>= aTop; + pBottomBorderWidthState->maValue >>= aBottom; + if( aLeft.InnerLineWidth == aRight.InnerLineWidth && aLeft.OuterLineWidth == aRight.OuterLineWidth && + aLeft.LineDistance == aRight.LineDistance && aLeft.InnerLineWidth == aTop.InnerLineWidth && + aLeft.OuterLineWidth == aTop.OuterLineWidth && aLeft.LineDistance == aTop.LineDistance && + aLeft.InnerLineWidth == aBottom.InnerLineWidth && aLeft.OuterLineWidth == aBottom.OuterLineWidth && + aLeft.LineDistance == aBottom.LineDistance ) + { + pLeftBorderWidthState->mnIndex = -1; + pLeftBorderWidthState->maValue.clear(); + pRightBorderWidthState->mnIndex = -1; + pRightBorderWidthState->maValue.clear(); + pTopBorderWidthState->mnIndex = -1; + pTopBorderWidthState->maValue.clear(); + pBottomBorderWidthState->mnIndex = -1; + pBottomBorderWidthState->maValue.clear(); + } + else + { + pAllBorderWidthState->mnIndex = -1; + pAllBorderWidthState->maValue.clear(); + } + } + else + { + pAllBorderWidthState->mnIndex = -1; + pAllBorderWidthState->maValue.clear(); + } + } + SvXMLExportPropertyMapper::ContextFilter(rProperties, rPropSet); +} + +/** this method is called for every item that has the MID_FLAG_SPECIAL_ITEM_EXPORT flag set */ +void ScXMLCellExportPropertyMapper::handleSpecialItem( + SvXMLAttributeList& rAttrList, + const XMLPropertyState& rProperty, + const SvXMLUnitConverter& rUnitConverter, + const SvXMLNamespaceMap& rNamespaceMap, + const ::std::vector< XMLPropertyState > *pProperties, + sal_uInt32 nIdx ) const +{ + // the SpecialItem NumberFormat must not be handled by this method + // the SpecialItem ConditionlaFormat must not be handled by this method + // the SpecialItem CharBackColor must not be handled by this method +} + +ScXMLRowExportPropertyMapper::ScXMLRowExportPropertyMapper( + const UniReference< XMLPropertySetMapper >& rMapper ) + : SvXMLExportPropertyMapper(rMapper) +{ +} + +ScXMLRowExportPropertyMapper::~ScXMLRowExportPropertyMapper() +{ +} + +void ScXMLRowExportPropertyMapper::ContextFilter( + ::std::vector< XMLPropertyState >& rProperties, + uno::Reference< beans::XPropertySet > rPropSet ) const +{ + //#108550#; don't filter the height, so other applications know the calculated height + +/* XMLPropertyState* pHeight = NULL; + XMLPropertyState* pOptimalHeight = NULL; + + for( ::std::vector< XMLPropertyState >::iterator propertie = rProperties.begin(); + propertie != rProperties.end(); + propertie++ ) + { + switch( getPropertySetMapper()->GetEntryContextId( propertie->mnIndex ) ) + { + case CTF_SC_ROWHEIGHT: pHeight = propertie; break; + case CTF_SC_ROWOPTIMALHEIGHT: pOptimalHeight = propertie; break; + } + } + if ((pHeight && pOptimalHeight && ::cppu::any2bool( pOptimalHeight->maValue )) || + (pHeight && !pOptimalHeight)) + { + pHeight->mnIndex = -1; + pHeight->maValue.clear(); + } + if (pOptimalHeight) + { + pOptimalHeight->mnIndex = -1; + pOptimalHeight->maValue.clear(); + }*/ +} + +ScXMLColumnExportPropertyMapper::ScXMLColumnExportPropertyMapper( + const UniReference< XMLPropertySetMapper >& rMapper ) + : SvXMLExportPropertyMapper(rMapper) +{ +} + +ScXMLColumnExportPropertyMapper::~ScXMLColumnExportPropertyMapper() +{ +} + +/** this method is called for every item that has the MID_FLAG_SPECIAL_ITEM_EXPORT flag set */ +void ScXMLColumnExportPropertyMapper::handleSpecialItem( + SvXMLAttributeList& rAttrList, + const XMLPropertyState& rProperty, + const SvXMLUnitConverter& rUnitConverter, + const SvXMLNamespaceMap& rNamespaceMap, + const ::std::vector< XMLPropertyState > *pProperties, + sal_uInt32 nIdx ) const +{ + // the SpecialItem IsVisible must not be handled by this method +} + +ScXMLTableExportPropertyMapper::ScXMLTableExportPropertyMapper( + const UniReference< XMLPropertySetMapper >& rMapper ) + : SvXMLExportPropertyMapper(rMapper) +{ +} + +ScXMLTableExportPropertyMapper::~ScXMLTableExportPropertyMapper() +{ +} + +/** this method is called for every item that has the MID_FLAG_SPECIAL_ITEM_EXPORT flag set */ +void ScXMLTableExportPropertyMapper::handleSpecialItem( + SvXMLAttributeList& rAttrList, + const XMLPropertyState& rProperty, + const SvXMLUnitConverter& rUnitConverter, + const SvXMLNamespaceMap& rNamespaceMap, + const ::std::vector< XMLPropertyState > *pProperties, + sal_uInt32 nIdx ) const +{ + // the SpecialItem PageStyle must not be handled by this method +} + +void ScXMLAutoStylePoolP::exportStyleAttributes( + SvXMLAttributeList& rAttrList, + sal_Int32 nFamily, + const ::std::vector< XMLPropertyState >& rProperties, + const SvXMLExportPropertyMapper& rPropExp + , const SvXMLUnitConverter& rUnitConverter, + const SvXMLNamespaceMap& rNamespaceMap + ) const +{ + SvXMLAutoStylePoolP::exportStyleAttributes( rAttrList, nFamily, rProperties, rPropExp, rUnitConverter, rNamespaceMap ); + if (nFamily == XML_STYLE_FAMILY_TABLE_CELL) + { + ::std::vector< XMLPropertyState >::const_iterator i = rProperties.begin(); + for (i; (i != rProperties.end()); i++) + { + UniReference< XMLPropertySetMapper > aPropMapper = + rScXMLExport.GetCellStylesPropertySetMapper(); + sal_Int16 nContextID = aPropMapper->GetEntryContextId(i->mnIndex); + switch (nContextID) + { + case CTF_SC_NUMBERFORMAT : + { + sal_Int32 nNumberFormat; + if (i->maValue >>= nNumberFormat) + { + ::rtl::OUString sAttrValue = rScXMLExport.getDataStyleName(nNumberFormat); + if (sAttrValue.getLength()) + { + GetExport().AddAttribute( + aPropMapper->GetEntryNameSpace(i->mnIndex), + aPropMapper->GetEntryXMLName(i->mnIndex), + sAttrValue ); + } + } + } + break; + } + } + } + else if (nFamily == XML_STYLE_FAMILY_TABLE_TABLE) + { + ::std::vector< XMLPropertyState >::const_iterator i = rProperties.begin(); + for (i; (i != rProperties.end()); i++) + { + UniReference< XMLPropertySetMapper > aPropMapper = + rScXMLExport.GetTableStylesPropertySetMapper(); + sal_Int16 nContextID = aPropMapper->GetEntryContextId(i->mnIndex); + switch (nContextID) + { + case CTF_SC_MASTERPAGENAME : + { + ::rtl::OUString sName; + if (i->maValue >>= sName) + { + GetExport().AddAttribute( + aPropMapper->GetEntryNameSpace(i->mnIndex), + aPropMapper->GetEntryXMLName(i->mnIndex), + sName ); + } + } + break; + } + } + } +} + +void ScXMLAutoStylePoolP::exportStyleContent( + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > & rHandler, + sal_Int32 nFamily, + const std::vector< XMLPropertyState >& rProperties, + const SvXMLExportPropertyMapper& rPropExp + , const SvXMLUnitConverter& rUnitConverter, + const SvXMLNamespaceMap& rNamespaceMap + ) const +{ + SvXMLAutoStylePoolP::exportStyleContent( rHandler, nFamily, rProperties, rPropExp, rUnitConverter, rNamespaceMap ); + if (nFamily == XML_STYLE_FAMILY_TABLE_CELL) + { + sal_Bool bNotFound = sal_True; + ::std::vector< XMLPropertyState >::const_iterator i = rProperties.begin(); + for (i; (i != rProperties.end()) && bNotFound; i++) + { + sal_Int16 nContextID = rScXMLExport.GetCellStylesPropertySetMapper()->GetEntryContextId(i->mnIndex); + switch (nContextID) + { + case CTF_SC_MAP : + { + uno::Reference <sheet::XSheetConditionalEntries> xSheetConditionalEntries; + if (i->maValue >>= xSheetConditionalEntries) + { + uno::Reference<container::XIndexAccess> xIndex( xSheetConditionalEntries, uno::UNO_QUERY ); + if ( xIndex.is() ) + { + sal_Int32 nConditionCount = xIndex->getCount(); + for (sal_Int32 nCondition = 0; nCondition < nConditionCount; nCondition++) + { + uno::Any aSheetConditionalEntry = xIndex->getByIndex(nCondition); + uno::Reference <sheet::XSheetConditionalEntry> xSheetConditionalEntry; + if (aSheetConditionalEntry >>= xSheetConditionalEntry) + { + ::rtl::OUString sStyleName = xSheetConditionalEntry->getStyleName(); + uno::Reference <sheet::XSheetCondition> xSheetCondition(xSheetConditionalEntry, uno::UNO_QUERY); + if (xSheetCondition.is()) + { + sheet::ConditionOperator aOperator = xSheetCondition->getOperator(); + if (aOperator != sheet::ConditionOperator_NONE) + { + if (aOperator == sheet::ConditionOperator_FORMULA) + { + ::rtl::OUString sCondition(RTL_CONSTASCII_USTRINGPARAM("is-true-formula(")); + sCondition += xSheetCondition->getFormula1(); + sCondition += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")")); + rScXMLExport.AddAttribute(XML_NAMESPACE_STYLE, XML_CONDITION, sCondition); + rScXMLExport.AddAttribute(XML_NAMESPACE_STYLE, XML_APPLY_STYLE_NAME, sStyleName); + OUString sOUBaseAddress; + ScXMLConverter::GetStringFromAddress( sOUBaseAddress, + xSheetCondition->getSourcePosition(), rScXMLExport.GetDocument() ); + rScXMLExport.AddAttribute(XML_NAMESPACE_STYLE, XML_BASE_CELL_ADDRESS, sOUBaseAddress); + SvXMLElementExport aMElem(rScXMLExport, XML_NAMESPACE_STYLE, XML_MAP, sal_True, sal_True); + } + else + { + ::rtl::OUString sCondition; + if (aOperator == sheet::ConditionOperator_BETWEEN || + aOperator == sheet::ConditionOperator_NOT_BETWEEN) + { + if (aOperator == sheet::ConditionOperator_BETWEEN) + sCondition = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-between(")); + else + sCondition = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-not-between(")); + sCondition += xSheetCondition->getFormula1(); + sCondition += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(",")); + sCondition += xSheetCondition->getFormula2(); + sCondition += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")")); + } + else + { + sCondition = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content()")); + switch (aOperator) + { + case sheet::ConditionOperator_LESS: + sCondition += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("<")); + break; + case sheet::ConditionOperator_GREATER: + sCondition += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(">")); + break; + case sheet::ConditionOperator_LESS_EQUAL: + sCondition += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("<=")); + break; + case sheet::ConditionOperator_GREATER_EQUAL: + sCondition += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(">=")); + break; + case sheet::ConditionOperator_EQUAL: + sCondition += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=")); + break; + case sheet::ConditionOperator_NOT_EQUAL: + sCondition += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("!=")); + break; + } + sCondition += xSheetCondition->getFormula1(); + } + rScXMLExport.AddAttribute(XML_NAMESPACE_STYLE, XML_CONDITION, sCondition); + rScXMLExport.AddAttribute(XML_NAMESPACE_STYLE, XML_APPLY_STYLE_NAME, sStyleName); + OUString sOUBaseAddress; + ScXMLConverter::GetStringFromAddress( sOUBaseAddress, + xSheetCondition->getSourcePosition(), rScXMLExport.GetDocument() ); + rScXMLExport.AddAttribute(XML_NAMESPACE_STYLE, XML_BASE_CELL_ADDRESS, sOUBaseAddress); + SvXMLElementExport aMElem(rScXMLExport, XML_NAMESPACE_STYLE, XML_MAP, sal_True, sal_True); + } + } + } + } + } + } + } + } + break; + } + } + } +} + +ScXMLAutoStylePoolP::ScXMLAutoStylePoolP(ScXMLExport& rTempScXMLExport): + SvXMLAutoStylePoolP(rTempScXMLExport), + rScXMLExport(rTempScXMLExport) +{ +} + +ScXMLAutoStylePoolP::~ScXMLAutoStylePoolP() +{ +} + + +void ScXMLStyleExport::exportStyleAttributes( + const ::com::sun::star::uno::Reference< + ::com::sun::star::style::XStyle > & rStyle ) +{ + uno::Reference< beans::XPropertySet > xPropSet( rStyle, uno::UNO_QUERY ); + uno::Reference< beans::XPropertySetInfo > xPropSetInfo = + xPropSet->getPropertySetInfo(); + ::rtl::OUString sNumberFormat(RTL_CONSTASCII_USTRINGPARAM("NumberFormat")); + if( xPropSetInfo->hasPropertyByName( sNumberFormat ) ) + { + uno::Reference< beans::XPropertyState > xPropState( xPropSet, uno::UNO_QUERY ); + if( xPropState.is() && (beans::PropertyState_DIRECT_VALUE == + xPropState->getPropertyState( sNumberFormat )) ) + { + uno::Any aAny = xPropSet->getPropertyValue( sNumberFormat ); + sal_Int32 nNumberFormat; + if (aAny >>= nNumberFormat) + { + ::rtl::OUString sDataStyleName = GetExport().getDataStyleName(nNumberFormat); + GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_DATA_STYLE_NAME, + sDataStyleName ); + + } + } + } +} + +void ScXMLStyleExport::exportStyleContent( + const ::com::sun::star::uno::Reference< + ::com::sun::star::style::XStyle > & rStyle ) +{ +} + +ScXMLStyleExport::ScXMLStyleExport( + SvXMLExport& rExp, + const ::rtl::OUString& rPoolStyleName, + SvXMLAutoStylePoolP *pAutoStyleP ) + : XMLStyleExport(rExp, rPoolStyleName, pAutoStyleP) +{ +} + +ScXMLStyleExport::~ScXMLStyleExport() +{ +} + +XMLScPropHdlFactory::XMLScPropHdlFactory() + : XMLPropertyHandlerFactory() +{ +} + +XMLScPropHdlFactory::~XMLScPropHdlFactory() +{ +} + +const XMLPropertyHandler* XMLScPropHdlFactory::GetPropertyHandler( sal_Int32 nType ) const +{ + nType &= MID_FLAG_MASK; + + XMLPropertyHandler* pHdl = (XMLPropertyHandler*)XMLPropertyHandlerFactory::GetPropertyHandler( nType ); + if(!pHdl) + { + switch(nType) + { + case XML_SC_TYPE_CELLPROTECTION : + { + pHdl = new XmlScPropHdl_CellProtection; + } + break; + case XML_SC_TYPE_PRINTCONTENT : + { + pHdl = new XmlScPropHdl_PrintContent; + } + break; + case XML_SC_TYPE_HORIJUSTIFY : + { + pHdl = new XmlScPropHdl_HoriJustify; + } + break; + case XML_SC_TYPE_HORIJUSTIFYSOURCE : + { + pHdl = new XmlScPropHdl_HoriJustifySource; + } + break; + case XML_SC_TYPE_ORIENTATION : + { + pHdl = new XmlScPropHdl_Orientation; + } + break; + case XML_SC_TYPE_ROTATEANGLE : + { + pHdl = new XmlScPropHdl_RotateAngle; + } + break; + case XML_SC_TYPE_ROTATEREFERENCE : + { + pHdl = new XmlScPropHdl_RotateReference; + } + break; + case XML_SC_TYPE_VERTJUSTIFY : + { + pHdl = new XmlScPropHdl_VertJustify; + } + break; + case XML_SC_TYPE_BREAKBEFORE : + { + pHdl = new XmlScPropHdl_BreakBefore; + } + break; + case XML_SC_ISTEXTWRAPPED : + { + pHdl = new XmlScPropHdl_IsTextWrapped; + } + break; + case XML_SC_TYPE_EQUAL : + { + pHdl = new XmlScPropHdl_IsEqual; + } + break; + case XML_SC_TYPE_VERTICAL : + { + pHdl = new XmlScPropHdl_Vertical; + } + break; + } + + if(pHdl) + PutHdlCache(nType, pHdl); + } + + return pHdl; +} + +XmlScPropHdl_CellProtection::~XmlScPropHdl_CellProtection() +{ +} + +sal_Bool XmlScPropHdl_CellProtection::equals( + const ::com::sun::star::uno::Any& r1, + const ::com::sun::star::uno::Any& r2 ) const +{ + util::CellProtection aCellProtection1, aCellProtection2; + + if((r1 >>= aCellProtection1) && (r2 >>= aCellProtection2)) + { + return ((aCellProtection1.IsHidden == aCellProtection2.IsHidden) && + (aCellProtection1.IsLocked == aCellProtection2.IsLocked) && + (aCellProtection1.IsFormulaHidden == aCellProtection2.IsFormulaHidden)); + } + return sal_False; +} + +sal_Bool XmlScPropHdl_CellProtection::importXML( + const ::rtl::OUString& rStrImpValue, + ::com::sun::star::uno::Any& rValue, + const SvXMLUnitConverter& rUnitConverter ) const +{ + sal_Bool bRetval(sal_False); + + util::CellProtection aCellProtection; + sal_Bool bDefault = sal_False; + if (!rValue.hasValue()) + { + aCellProtection.IsHidden = sal_False; + aCellProtection.IsLocked = sal_True; + aCellProtection.IsFormulaHidden = sal_False; + aCellProtection.IsPrintHidden = sal_False; + bDefault = sal_True; + } + if ((rValue >>= aCellProtection) || bDefault) + { + if (!IsXMLToken(rStrImpValue, XML_NONE)) + { + if (!IsXMLToken(rStrImpValue, XML_HIDDEN_AND_PROTECTED)) + { + if (!IsXMLToken(rStrImpValue, XML_PROTECTED)) + { + if (!IsXMLToken(rStrImpValue, XML_FORMULA_HIDDEN)) + { + sal_Int16 i = 0; + while (i < rStrImpValue.getLength() && rStrImpValue[i] != ' ') + i++; + ::rtl::OUString sFirst = rStrImpValue.copy(0, i); + ::rtl::OUString sSecond = rStrImpValue.copy(i + 1); + aCellProtection.IsFormulaHidden = sal_False; + aCellProtection.IsHidden = sal_False; + aCellProtection.IsLocked = sal_False; + if ((IsXMLToken(sFirst, XML_PROTECTED)) || (IsXMLToken(sSecond, XML_PROTECTED))) + aCellProtection.IsLocked = sal_True; + if ((IsXMLToken(sFirst, XML_FORMULA_HIDDEN)) || (IsXMLToken(sSecond, XML_FORMULA_HIDDEN))) + aCellProtection.IsFormulaHidden = sal_True; + rValue <<= aCellProtection; + bRetval = sal_True; + } + else + { + aCellProtection.IsFormulaHidden = sal_True; + aCellProtection.IsHidden = sal_False; + aCellProtection.IsLocked = sal_False; + rValue <<= aCellProtection; + bRetval = sal_True; + } + } + else + { + aCellProtection.IsFormulaHidden = sal_False; + aCellProtection.IsHidden = sal_False; + aCellProtection.IsLocked = sal_True; + rValue <<= aCellProtection; + bRetval = sal_True; + } + } + else + { + aCellProtection.IsFormulaHidden = sal_True; + aCellProtection.IsHidden = sal_True; + aCellProtection.IsLocked = sal_True; + rValue <<= aCellProtection; + bRetval = sal_True; + } + } + else + { + aCellProtection.IsFormulaHidden = sal_False; + aCellProtection.IsHidden = sal_False; + aCellProtection.IsLocked = sal_False; + rValue <<= aCellProtection; + bRetval = sal_True; + } + } + + return bRetval; +} + +sal_Bool XmlScPropHdl_CellProtection::exportXML( + ::rtl::OUString& rStrExpValue, + const ::com::sun::star::uno::Any& rValue, + const SvXMLUnitConverter& rUnitConverter ) const +{ + sal_Bool bRetval(sal_False); + util::CellProtection aCellProtection; + + if(rValue >>= aCellProtection) + { + if (!(aCellProtection.IsFormulaHidden || aCellProtection.IsHidden || aCellProtection.IsLocked)) + { + rStrExpValue = GetXMLToken(XML_NONE); + bRetval = sal_True; + } + else if (aCellProtection.IsHidden && aCellProtection.IsLocked) + { + rStrExpValue = GetXMLToken(XML_HIDDEN_AND_PROTECTED); + bRetval = sal_True; + } + else if (aCellProtection.IsLocked && !(aCellProtection.IsFormulaHidden || aCellProtection.IsHidden)) + { + rStrExpValue = GetXMLToken(XML_PROTECTED); + bRetval = sal_True; + } + else if (aCellProtection.IsFormulaHidden && !(aCellProtection.IsLocked || aCellProtection.IsHidden)) + { + rStrExpValue = GetXMLToken(XML_FORMULA_HIDDEN); + bRetval = sal_True; + } + else if (aCellProtection.IsFormulaHidden && aCellProtection.IsLocked) + { + rStrExpValue = GetXMLToken(XML_PROTECTED); + rStrExpValue += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ")); + rStrExpValue += GetXMLToken(XML_FORMULA_HIDDEN); + bRetval = sal_True; + } + } + + return bRetval; +} + +XmlScPropHdl_PrintContent::~XmlScPropHdl_PrintContent() +{ +} + +sal_Bool XmlScPropHdl_PrintContent::equals( + const ::com::sun::star::uno::Any& r1, + const ::com::sun::star::uno::Any& r2 ) const +{ + util::CellProtection aCellProtection1, aCellProtection2; + + if((r1 >>= aCellProtection1) && (r2 >>= aCellProtection2)) + { + return (aCellProtection1.IsPrintHidden == aCellProtection2.IsPrintHidden); + } + return sal_False; +} + +sal_Bool XmlScPropHdl_PrintContent::importXML( + const ::rtl::OUString& rStrImpValue, + ::com::sun::star::uno::Any& rValue, + const SvXMLUnitConverter& rUnitConverter ) const +{ + sal_Bool bRetval(sal_False); + util::CellProtection aCellProtection; + sal_Bool bDefault = sal_False; + if (!rValue.hasValue()) + { + aCellProtection.IsHidden = sal_False; + aCellProtection.IsLocked = sal_True; + aCellProtection.IsFormulaHidden = sal_False; + aCellProtection.IsPrintHidden = sal_False; + bDefault = sal_True; + } + if ((rValue >>= aCellProtection) || bDefault) + { + sal_Bool bValue; + if (rUnitConverter.convertBool(bValue, rStrImpValue)) + { + aCellProtection.IsPrintHidden = !bValue; + rValue <<= aCellProtection; + bRetval = sal_True; + } + } + + return bRetval; +} + +sal_Bool XmlScPropHdl_PrintContent::exportXML( + ::rtl::OUString& rStrExpValue, + const ::com::sun::star::uno::Any& rValue, + const SvXMLUnitConverter& rUnitConverter ) const +{ + sal_Bool bRetval(sal_False); + + util::CellProtection aCellProtection; + if(rValue >>= aCellProtection) + { + ::rtl::OUStringBuffer sValue; + rUnitConverter.convertBool(sValue, !aCellProtection.IsPrintHidden); + rStrExpValue = sValue.makeStringAndClear(); + bRetval = sal_True; + } + + return bRetval; +} + +XmlScPropHdl_HoriJustify::~XmlScPropHdl_HoriJustify() +{ +} + +sal_Bool XmlScPropHdl_HoriJustify::equals( + const ::com::sun::star::uno::Any& r1, + const ::com::sun::star::uno::Any& r2 ) const +{ + table::CellHoriJustify aHoriJustify1, aHoriJustify2; + + if((r1 >>= aHoriJustify1) && (r2 >>= aHoriJustify2)) + return (aHoriJustify1 == aHoriJustify2); + return sal_False; +} + +sal_Bool XmlScPropHdl_HoriJustify::importXML( + const ::rtl::OUString& rStrImpValue, + ::com::sun::star::uno::Any& rValue, + const SvXMLUnitConverter& rUnitConverter ) const +{ + sal_Bool bRetval(sal_False); + + table::CellHoriJustify nValue; + if (IsXMLToken(rStrImpValue, XML_START)) + { + nValue = table::CellHoriJustify_LEFT; + rValue <<= nValue; + bRetval = sal_True; + } + else if (IsXMLToken(rStrImpValue, XML_END)) + { + nValue = table::CellHoriJustify_RIGHT; + rValue <<= nValue; + bRetval = sal_True; + } + else if (IsXMLToken(rStrImpValue, XML_CENTER)) + { + nValue = table::CellHoriJustify_CENTER; + rValue <<= nValue; + bRetval = sal_True; + } + else if (IsXMLToken(rStrImpValue, XML_JUSTIFY)) + { + nValue = table::CellHoriJustify_BLOCK; + rValue <<= nValue; + bRetval = sal_True; + } + + return bRetval; +} + +sal_Bool XmlScPropHdl_HoriJustify::exportXML( + ::rtl::OUString& rStrExpValue, + const ::com::sun::star::uno::Any& rValue, + const SvXMLUnitConverter& rUnitConverter ) const +{ + table::CellHoriJustify nVal; + sal_Bool bRetval(sal_False); + + if(rValue >>= nVal) + { + switch (nVal) + { + case table::CellHoriJustify_REPEAT: + case table::CellHoriJustify_LEFT: + { + rStrExpValue = GetXMLToken(XML_START); + bRetval = sal_True; + } + break; + case table::CellHoriJustify_RIGHT: + { + rStrExpValue = GetXMLToken(XML_END); + bRetval = sal_True; + } + break; + case table::CellHoriJustify_CENTER: + { + rStrExpValue = GetXMLToken(XML_CENTER); + bRetval = sal_True; + } + break; + case table::CellHoriJustify_BLOCK: + { + rStrExpValue = GetXMLToken(XML_JUSTIFY); + bRetval = sal_True; + } + break; + } + } + + return bRetval; +} + +XmlScPropHdl_HoriJustifySource::~XmlScPropHdl_HoriJustifySource() +{ +} + +sal_Bool XmlScPropHdl_HoriJustifySource::equals( + const ::com::sun::star::uno::Any& r1, + const ::com::sun::star::uno::Any& r2 ) const +{ + table::CellHoriJustify aHoriJustify1, aHoriJustify2; + + if((r1 >>= aHoriJustify1) && (r2 >>= aHoriJustify2)) + return (aHoriJustify1 == aHoriJustify2); + return sal_False; +} + +sal_Bool XmlScPropHdl_HoriJustifySource::importXML( + const ::rtl::OUString& rStrImpValue, + ::com::sun::star::uno::Any& rValue, + const SvXMLUnitConverter& rUnitConverter ) const +{ + sal_Bool bRetval(sal_False); + + if (IsXMLToken(rStrImpValue, XML_FIX)) + { + bRetval = sal_True; + } + else if (IsXMLToken(rStrImpValue, XML_VALUE_TYPE)) + { + table::CellHoriJustify nValue = table::CellHoriJustify_STANDARD; + rValue <<= nValue; + bRetval = sal_True; + } + + return bRetval; +} + +sal_Bool XmlScPropHdl_HoriJustifySource::exportXML( + ::rtl::OUString& rStrExpValue, + const ::com::sun::star::uno::Any& rValue, + const SvXMLUnitConverter& rUnitConverter ) const +{ + table::CellHoriJustify nVal; + sal_Bool bRetval(sal_False); + + if(rValue >>= nVal) + { + if (nVal == table::CellHoriJustify_STANDARD) + { + rStrExpValue = GetXMLToken(XML_VALUE_TYPE); + bRetval = sal_True; + } + else + { + rStrExpValue = GetXMLToken(XML_FIX); + bRetval = sal_True; + } + } + + return bRetval; +} + +XmlScPropHdl_Orientation::~XmlScPropHdl_Orientation() +{ +} + +sal_Bool XmlScPropHdl_Orientation::equals( + const ::com::sun::star::uno::Any& r1, + const ::com::sun::star::uno::Any& r2 ) const +{ + table::CellOrientation aOrientation1, aOrientation2; + + if((r1 >>= aOrientation1) && (r2 >>= aOrientation2)) + return (aOrientation1 == aOrientation2); + return sal_False; +} + +sal_Bool XmlScPropHdl_Orientation::importXML( + const ::rtl::OUString& rStrImpValue, + ::com::sun::star::uno::Any& rValue, + const SvXMLUnitConverter& rUnitConverter ) const +{ + sal_Bool bRetval(sal_False); + + table::CellOrientation nValue; + if (IsXMLToken(rStrImpValue, XML_LTR)) + { + nValue = table::CellOrientation_STANDARD; + rValue <<= nValue; + bRetval = sal_True; + } + else if (IsXMLToken(rStrImpValue, XML_TTB)) + { + nValue = table::CellOrientation_STACKED; + rValue <<= nValue; + bRetval = sal_True; + } + + return bRetval; +} + +sal_Bool XmlScPropHdl_Orientation::exportXML( + ::rtl::OUString& rStrExpValue, + const ::com::sun::star::uno::Any& rValue, + const SvXMLUnitConverter& rUnitConverter ) const +{ + table::CellOrientation nVal; + sal_Bool bRetval(sal_False); + + if(rValue >>= nVal) + { + switch (nVal) + { + case table::CellOrientation_STACKED : + { + rStrExpValue = GetXMLToken(XML_TTB); + bRetval = sal_True; + } + break; + default: + { + rStrExpValue = GetXMLToken(XML_LTR); + bRetval = sal_True; + } + break; + } + } + + return bRetval; +} + +XmlScPropHdl_RotateAngle::~XmlScPropHdl_RotateAngle() +{ +} + +sal_Bool XmlScPropHdl_RotateAngle::equals( + const ::com::sun::star::uno::Any& r1, + const ::com::sun::star::uno::Any& r2 ) const +{ + sal_Int32 aAngle1, aAngle2; + + if((r1 >>= aAngle1) && (r2 >>= aAngle2)) + return (aAngle1 == aAngle2); + return sal_False; +} + +sal_Bool XmlScPropHdl_RotateAngle::importXML( + const ::rtl::OUString& rStrImpValue, + ::com::sun::star::uno::Any& rValue, + const SvXMLUnitConverter& rUnitConverter ) const +{ + sal_Bool bRetval(sal_False); + + sal_Int32 nValue; + if (rUnitConverter.convertNumber(nValue, rStrImpValue)) + { + nValue *= 100; + rValue <<= nValue; + bRetval = sal_True; + } + + return bRetval; +} + +sal_Bool XmlScPropHdl_RotateAngle::exportXML( + ::rtl::OUString& rStrExpValue, + const ::com::sun::star::uno::Any& rValue, + const SvXMLUnitConverter& rUnitConverter ) const +{ + sal_Int32 nVal; + sal_Bool bRetval(sal_False); + + if(rValue >>= nVal) + { + ::rtl::OUStringBuffer sValue; + rUnitConverter.convertNumber(sValue, sal_Int32(nVal / 100)); + rStrExpValue = sValue.makeStringAndClear(); + bRetval = sal_True; + } + + return bRetval; +} + +XmlScPropHdl_RotateReference::~XmlScPropHdl_RotateReference() +{ +} + +sal_Bool XmlScPropHdl_RotateReference::equals( + const ::com::sun::star::uno::Any& r1, + const ::com::sun::star::uno::Any& r2 ) const +{ + table::CellVertJustify aReference1, aReference2; + + if((r1 >>= aReference1) && (r2 >>= aReference2)) + return (aReference1 == aReference2); + return sal_False; +} + +sal_Bool XmlScPropHdl_RotateReference::importXML( + const ::rtl::OUString& rStrImpValue, + ::com::sun::star::uno::Any& rValue, + const SvXMLUnitConverter& rUnitConverter ) const +{ + sal_Bool bRetval(sal_False); + + table::CellVertJustify nValue; + if (IsXMLToken(rStrImpValue, XML_NONE)) + { + nValue = table::CellVertJustify_STANDARD; + rValue <<= nValue; + bRetval = sal_True; + } + else if (IsXMLToken(rStrImpValue, XML_BOTTOM)) + { + nValue = table::CellVertJustify_BOTTOM; + rValue <<= nValue; + bRetval = sal_True; + } + else if (IsXMLToken(rStrImpValue, XML_TOP)) + { + nValue = table::CellVertJustify_TOP; + rValue <<= nValue; + bRetval = sal_True; + } + else if (IsXMLToken(rStrImpValue, XML_CENTER)) + { + nValue = table::CellVertJustify_CENTER; + rValue <<= nValue; + bRetval = sal_True; + } + + return bRetval; +} + +sal_Bool XmlScPropHdl_RotateReference::exportXML( + ::rtl::OUString& rStrExpValue, + const ::com::sun::star::uno::Any& rValue, + const SvXMLUnitConverter& rUnitConverter ) const +{ + table::CellVertJustify nVal; + sal_Bool bRetval(sal_False); + + if(rValue >>= nVal) + { + switch (nVal) + { + case table::CellVertJustify_BOTTOM : + { + rStrExpValue = GetXMLToken(XML_BOTTOM); + bRetval = sal_True; + } + break; + case table::CellVertJustify_CENTER : + { + rStrExpValue = GetXMLToken(XML_CENTER); + bRetval = sal_True; + } + break; + case table::CellVertJustify_STANDARD : + { + rStrExpValue = GetXMLToken(XML_NONE); + bRetval = sal_True; + } + break; + case table::CellVertJustify_TOP : + { + rStrExpValue = GetXMLToken(XML_TOP); + bRetval = sal_True; + } + break; + } + } + + return bRetval; +} + +XmlScPropHdl_VertJustify::~XmlScPropHdl_VertJustify() +{ +} + +sal_Bool XmlScPropHdl_VertJustify::equals( + const ::com::sun::star::uno::Any& r1, + const ::com::sun::star::uno::Any& r2 ) const +{ + table::CellVertJustify aReference1, aReference2; + + if((r1 >>= aReference1) && (r2 >>= aReference2)) + return (aReference1 == aReference2); + return sal_False; +} + +sal_Bool XmlScPropHdl_VertJustify::importXML( + const ::rtl::OUString& rStrImpValue, + ::com::sun::star::uno::Any& rValue, + const SvXMLUnitConverter& rUnitConverter ) const +{ + sal_Bool bRetval(sal_False); + + table::CellVertJustify nValue; + if (IsXMLToken(rStrImpValue, XML_AUTOMATIC)) + { + nValue = table::CellVertJustify_STANDARD; + rValue <<= nValue; + bRetval = sal_True; + } + else if (IsXMLToken(rStrImpValue, XML_BOTTOM)) + { + nValue = table::CellVertJustify_BOTTOM; + rValue <<= nValue; + bRetval = sal_True; + } + else if (IsXMLToken(rStrImpValue, XML_TOP)) + { + nValue = table::CellVertJustify_TOP; + rValue <<= nValue; + bRetval = sal_True; + } + else if (IsXMLToken(rStrImpValue, XML_MIDDLE)) + { + nValue = table::CellVertJustify_CENTER; + rValue <<= nValue; + bRetval = sal_True; + } + + return bRetval; +} + +sal_Bool XmlScPropHdl_VertJustify::exportXML( + ::rtl::OUString& rStrExpValue, + const ::com::sun::star::uno::Any& rValue, + const SvXMLUnitConverter& rUnitConverter ) const +{ + table::CellVertJustify nVal; + sal_Bool bRetval(sal_False); + + if(rValue >>= nVal) + { + switch (nVal) + { + case table::CellVertJustify_BOTTOM : + { + rStrExpValue = GetXMLToken(XML_BOTTOM); + bRetval = sal_True; + } + break; + case table::CellVertJustify_CENTER : + { + rStrExpValue = GetXMLToken(XML_MIDDLE); + bRetval = sal_True; + } + break; + case table::CellVertJustify_STANDARD : + { + rStrExpValue = GetXMLToken(XML_AUTOMATIC); + bRetval = sal_True; + } + break; + case table::CellVertJustify_TOP : + { + rStrExpValue = GetXMLToken(XML_TOP); + bRetval = sal_True; + } + break; + } + } + + return bRetval; +} + +XmlScPropHdl_BreakBefore::~XmlScPropHdl_BreakBefore() +{ +} + +sal_Bool XmlScPropHdl_BreakBefore::equals( + const ::com::sun::star::uno::Any& r1, + const ::com::sun::star::uno::Any& r2 ) const +{ + sal_Bool aBreak1, aBreak2; + + if((r1 >>= aBreak1) && (r2 >>= aBreak2)) + return (aBreak1 == aBreak2); + return sal_False; +} + +sal_Bool XmlScPropHdl_BreakBefore::importXML( + const ::rtl::OUString& rStrImpValue, + ::com::sun::star::uno::Any& rValue, + const SvXMLUnitConverter& rUnitConverter ) const +{ + sal_Bool bRetval(sal_False); + + sal_Bool bValue; + if (IsXMLToken(rStrImpValue, XML_AUTO)) + { + bValue = sal_False; + rValue = ::cppu::bool2any(bValue); + bRetval = sal_True; + } + else if (IsXMLToken(rStrImpValue, XML_PAGE)) + { + bValue = sal_True; + rValue = ::cppu::bool2any(bValue); + bRetval = sal_True; + } + + return bRetval; +} + +sal_Bool XmlScPropHdl_BreakBefore::exportXML( + ::rtl::OUString& rStrExpValue, + const ::com::sun::star::uno::Any& rValue, + const SvXMLUnitConverter& rUnitConverter ) const +{ + sal_Bool bVal; + sal_Bool bRetval(sal_False); + + if(rValue >>= bVal) + { + if (bVal) + { + rStrExpValue = GetXMLToken(XML_PAGE); + bRetval = sal_True; + } + else + { + rStrExpValue = GetXMLToken(XML_AUTO); + bRetval = sal_True; + } + } + + return bRetval; +} + +XmlScPropHdl_IsTextWrapped::~XmlScPropHdl_IsTextWrapped() +{ +} + +sal_Bool XmlScPropHdl_IsTextWrapped::equals( + const ::com::sun::star::uno::Any& r1, + const ::com::sun::star::uno::Any& r2 ) const +{ + return (::cppu::any2bool(r1) == ::cppu::any2bool(r2)); +} + +sal_Bool XmlScPropHdl_IsTextWrapped::importXML( + const ::rtl::OUString& rStrImpValue, + ::com::sun::star::uno::Any& rValue, + const SvXMLUnitConverter& rUnitConverter ) const +{ + sal_Bool bRetval(sal_False); + + if (IsXMLToken(rStrImpValue, XML_WRAP)) + { + rValue = ::cppu::bool2any(sal_True); + bRetval = sal_True; + } + else if (IsXMLToken(rStrImpValue, XML_NO_WRAP)) + { + rValue = ::cppu::bool2any(sal_False); + bRetval = sal_True; + } + + return bRetval; +} + +sal_Bool XmlScPropHdl_IsTextWrapped::exportXML( + ::rtl::OUString& rStrExpValue, + const ::com::sun::star::uno::Any& rValue, + const SvXMLUnitConverter& rUnitConverter ) const +{ + sal_Bool bRetval(sal_False); + + if (::cppu::any2bool(rValue)) + { + rStrExpValue = GetXMLToken(XML_WRAP); + bRetval = sal_True; + } + else + { + rStrExpValue = GetXMLToken(XML_NO_WRAP); + bRetval = sal_True; + } + + return bRetval; +} + +sal_Bool XmlScPropHdl_IsEqual::importXML( const ::rtl::OUString& rStrImpValue, + ::com::sun::star::uno::Any& rValue, + const SvXMLUnitConverter& rUnitConverter ) const +{ + DBG_ERROR("should never be called"); + return sal_False; +} + +sal_Bool XmlScPropHdl_IsEqual::exportXML( ::rtl::OUString& rStrExpValue, + const ::com::sun::star::uno::Any& rValue, + const SvXMLUnitConverter& rUnitConverter ) const +{ + DBG_ERROR("should never be called"); + return sal_False; +} + +XmlScPropHdl_Vertical::~XmlScPropHdl_Vertical() +{ +} + +sal_Bool XmlScPropHdl_Vertical::equals( + const ::com::sun::star::uno::Any& r1, + const ::com::sun::star::uno::Any& r2 ) const +{ + return (::cppu::any2bool(r1) == ::cppu::any2bool(r2)); +} + +sal_Bool XmlScPropHdl_Vertical::importXML( + const ::rtl::OUString& rStrImpValue, + ::com::sun::star::uno::Any& rValue, + const SvXMLUnitConverter& rUnitConverter ) const +{ + sal_Bool bRetval(sal_False); + + if (IsXMLToken(rStrImpValue, XML_AUTO)) + { + rValue = ::cppu::bool2any(sal_True); + bRetval = sal_True; + } + else if (IsXMLToken(rStrImpValue, XML_0)) + { + rValue = ::cppu::bool2any(sal_False); + bRetval = sal_True; + } + + return bRetval; +} + +sal_Bool XmlScPropHdl_Vertical::exportXML( + ::rtl::OUString& rStrExpValue, + const ::com::sun::star::uno::Any& rValue, + const SvXMLUnitConverter& rUnitConverter ) const +{ + sal_Bool bRetval(sal_False); + + if (::cppu::any2bool(rValue)) + { + rStrExpValue = GetXMLToken(XML_AUTO); + bRetval = sal_True; + } + else + { + rStrExpValue = GetXMLToken(XML_0); + bRetval = sal_True; + } + + return bRetval; +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_xmlstyli.cxx b/binfilter/bf_sc/source/filter/xml/sc_xmlstyli.cxx new file mode 100644 index 000000000000..9e1f3cab070a --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_xmlstyli.cxx @@ -0,0 +1,1009 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include "xmlstyli.hxx" +#include <bf_xmloff/nmspmap.hxx> +#include <bf_xmloff/xmlnmspe.hxx> +#include <bf_xmloff/xmlnumfi.hxx> +#include <bf_xmloff/XMLGraphicsDefaultStyle.hxx> + +#include <com/sun/star/sheet/XSheetConditionalEntries.hpp> +#include <com/sun/star/table/BorderLine.hpp> +#include <comphelper/extract.hxx> +#include "XMLTableHeaderFooterContext.hxx" +#include "XMLConverter.hxx" + +#include "docuno.hxx" +#include "unonames.hxx" +namespace binfilter { + +//#define SC_NUMBERFORMAT "NumberFormat" +#define SC_CONDITIONALFORMAT "ConditionalFormat" + +#define XML_LINE_LEFT 0 +#define XML_LINE_RIGHT 1 +#define XML_LINE_TOP 2 +#define XML_LINE_BOTTOM 3 + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::xml::sax; +using namespace ::com::sun::star::style; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::container; +using namespace xmloff::token; + +using rtl::OUString; +//using namespace ::com::sun::star::text; + +ScXMLCellImportPropertyMapper::ScXMLCellImportPropertyMapper( + const UniReference< XMLPropertySetMapper >& rMapper, + SvXMLImport& rImport) : + SvXMLImportPropertyMapper( rMapper, rImport ) +{ +} + +ScXMLCellImportPropertyMapper::~ScXMLCellImportPropertyMapper() +{ +} + +void ScXMLCellImportPropertyMapper::finished(::std::vector< XMLPropertyState >& rProperties, sal_Int32 nStartIndex, sal_Int32 nEndIndex ) const +{ + static const sal_Int16 aPaddingCTF[4] = { CTF_SC_LEFTPADDING, CTF_SC_RIGHTPADDING, + CTF_SC_TOPPADDING, CTF_SC_BOTTOMPADDING }; + static const sal_Int16 aBorderCTF[4] = { CTF_SC_LEFTBORDER, CTF_SC_RIGHTBORDER, + CTF_SC_TOPBORDER, CTF_SC_BOTTOMBORDER }; + + SvXMLImportPropertyMapper::finished(rProperties, nStartIndex, nEndIndex); + XMLPropertyState* pAllPaddingProperty = NULL; + XMLPropertyState* pPadding[4] = { NULL, NULL, NULL, NULL }; + XMLPropertyState* pNewPadding[4] = { NULL, NULL, NULL, NULL }; + XMLPropertyState* pAllBorderProperty = NULL; + XMLPropertyState* pBorders[4] = { NULL, NULL, NULL, NULL }; + XMLPropertyState* pNewBorders[4] = { NULL, NULL, NULL, NULL }; + XMLPropertyState* pAllBorderWidthProperty = NULL; + XMLPropertyState* pBorderWidths[4] = { NULL, NULL, NULL, NULL }; + for (::std::vector< XMLPropertyState >::iterator aIter = rProperties.begin(); aIter != rProperties.end(); ++aIter) + { + XMLPropertyState *property = &(*aIter); + sal_Int16 nContextID = getPropertySetMapper()->GetEntryContextId(property->mnIndex); + switch (nContextID) + { + case CTF_SC_ALLPADDING : pAllPaddingProperty = property; break; + case CTF_SC_LEFTPADDING : pPadding[XML_LINE_LEFT] = property; break; + case CTF_SC_RIGHTPADDING : pPadding[XML_LINE_RIGHT] = property; break; + case CTF_SC_TOPPADDING : pPadding[XML_LINE_TOP] = property; break; + case CTF_SC_BOTTOMPADDING : pPadding[XML_LINE_BOTTOM] = property; break; + case CTF_SC_ALLBORDER : pAllBorderProperty = property; break; + case CTF_SC_LEFTBORDER : pBorders[XML_LINE_LEFT] = property; break; + case CTF_SC_RIGHTBORDER : pBorders[XML_LINE_RIGHT] = property; break; + case CTF_SC_TOPBORDER : pBorders[XML_LINE_TOP] = property; break; + case CTF_SC_BOTTOMBORDER : pBorders[XML_LINE_BOTTOM] = property; break; + case CTF_SC_ALLBORDERWIDTH : pAllBorderWidthProperty = property; break; + case CTF_SC_LEFTBORDERWIDTH : pBorderWidths[XML_LINE_LEFT] = property; break; + case CTF_SC_RIGHTBORDERWIDTH : pBorderWidths[XML_LINE_RIGHT] = property; break; + case CTF_SC_TOPBORDERWIDTH : pBorderWidths[XML_LINE_TOP] = property; break; + case CTF_SC_BOTTOMBORDERWIDTH : pBorderWidths[XML_LINE_BOTTOM] = property; break; + } + } + sal_uInt16 i; + for (i = 0; i < 4; i++) + { + if (pAllPaddingProperty && !pPadding[i]) + pNewPadding[i] = new XMLPropertyState(maPropMapper->FindEntryIndex(aPaddingCTF[i]), pAllPaddingProperty->maValue); + if (pAllBorderProperty && !pBorders[i]) + { + pNewBorders[i] = new XMLPropertyState(maPropMapper->FindEntryIndex(aBorderCTF[i]), pAllBorderProperty->maValue); + pBorders[i] = pNewBorders[i]; + } + if( !pBorderWidths[i] ) + pBorderWidths[i] = pAllBorderWidthProperty; + else + pBorderWidths[i]->mnIndex = -1; + if( pBorders[i] ) + { + table::BorderLine aBorderLine; + pBorders[i]->maValue >>= aBorderLine; + if( pBorderWidths[i] ) + { + table::BorderLine aBorderLineWidth; + pBorderWidths[i]->maValue >>= aBorderLineWidth; + aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth; + aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth; + aBorderLine.LineDistance = aBorderLineWidth.LineDistance; + pBorders[i]->maValue <<= aBorderLine; + } + } + } + for (i = 0; i < 4; i++) + { + if (pNewPadding[i]) + { + rProperties.push_back(*pNewPadding[i]); + delete pNewPadding[i]; + } + if (pNewBorders[i]) + { + rProperties.push_back(*pNewBorders[i]); + delete pNewBorders[i]; + } + } +} + +ScXMLRowImportPropertyMapper::ScXMLRowImportPropertyMapper( + const UniReference< XMLPropertySetMapper >& rMapper, + SvXMLImport& rImport) : + SvXMLImportPropertyMapper( rMapper, rImport ) +{ +} + +ScXMLRowImportPropertyMapper::~ScXMLRowImportPropertyMapper() +{ +} + +void ScXMLRowImportPropertyMapper::finished(::std::vector< XMLPropertyState >& rProperties, sal_Int32 nStartIndex, sal_Int32 nEndIndex ) const +{ + SvXMLImportPropertyMapper::finished(rProperties, nStartIndex, nEndIndex); + XMLPropertyState* pHeight = NULL; + XMLPropertyState* pOptimalHeight = NULL; + XMLPropertyState* pPageBreak = NULL; + for (::std::vector< XMLPropertyState >::iterator aIter = rProperties.begin(); aIter != rProperties.end(); ++aIter) + { + XMLPropertyState *property = &(*aIter); + sal_Int16 nContextID = getPropertySetMapper()->GetEntryContextId(property->mnIndex); + switch (nContextID) + { + case CTF_SC_ROWHEIGHT : pHeight = property; break; + case CTF_SC_ROWOPTIMALHEIGHT : pOptimalHeight = property; break; + case CTF_SC_ROWBREAKBEFORE : pPageBreak = property; break; + } + } + if (pPageBreak) + { + if(!(::cppu::any2bool(pPageBreak->maValue))) + pPageBreak->mnIndex = -1; + } + if (pOptimalHeight) + { + sal_Bool bOptimalHeight = ::cppu::any2bool(pOptimalHeight->maValue); + if (bOptimalHeight) + { + if (pHeight) + pHeight->mnIndex = -1; + pOptimalHeight->mnIndex = -1; + } + } + else if (pHeight) + { + pOptimalHeight = new XMLPropertyState(maPropMapper->FindEntryIndex(CTF_SC_ROWOPTIMALHEIGHT), ::cppu::bool2any( sal_False )); + rProperties.push_back(*pOptimalHeight); + delete pOptimalHeight; + } + // don't access pointers to rProperties elements after push_back! +} + +class ScXMLMapContext : public SvXMLImportContext +{ + ::rtl::OUString sApplyStyle; + ::rtl::OUString sCondition; + ::rtl::OUString sBaseCell; +public: + + ScXMLMapContext( + SvXMLImport& rImport, sal_uInt16 nPrfx, + const ::rtl::OUString& rLName, + const Reference< xml::sax::XAttributeList > & xAttrList ); + virtual ~ScXMLMapContext(); + + const ::rtl::OUString& GetApplyStyle() const { return sApplyStyle; } + const ::rtl::OUString& GetCondition() const { return sCondition; } + const ::rtl::OUString& GetBaseCell() const { return sBaseCell; } +}; + +ScXMLMapContext::ScXMLMapContext(SvXMLImport& rImport, sal_uInt16 nPrfx, + const OUString& rLName, const Reference< xml::sax::XAttributeList > & xAttrList ) + : SvXMLImportContext( rImport, nPrfx, rLName ), + sCondition(), + sApplyStyle(), + sBaseCell() +{ + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + const OUString& rAttrName = xAttrList->getNameByIndex( i ); + OUString aLocalName; + sal_uInt16 nPrefix = + GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, + &aLocalName ); + const OUString& rValue = xAttrList->getValueByIndex( i ); + + // TODO: use a map here + if( XML_NAMESPACE_STYLE == nPrefix ) + { + if( IsXMLToken(aLocalName, XML_CONDITION ) ) + sCondition = rValue; + else if( IsXMLToken(aLocalName, XML_APPLY_STYLE_NAME ) ) + sApplyStyle = rValue; + else if ( IsXMLToken(aLocalName, XML_BASE_CELL_ADDRESS ) ) + sBaseCell = rValue; + } + } +} + +ScXMLMapContext::~ScXMLMapContext() +{ +} + +void XMLTableStyleContext::SetOperator(::com::sun::star::uno::Sequence<beans::PropertyValue>& aProps, + const ::com::sun::star::sheet::ConditionOperator aOp) const +{ + aProps.realloc(aProps.getLength() + 1); + beans::PropertyValue aProp; + aProp.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_OPERATOR)); + uno::Any aAnyOp; + aAnyOp <<= aOp; + aProp.Value = aAnyOp; + aProps[aProps.getLength() - 1] = aProp; +} + +void XMLTableStyleContext::SetBaseCellAddress(::com::sun::star::uno::Sequence<beans::PropertyValue>& aProps, + const ::rtl::OUString& sBaseCell) const +{ + aProps.realloc(aProps.getLength() + 1); + beans::PropertyValue aProp; + table::CellAddress aBaseAddress; + sal_Int32 nOffset(0); + if ( ScXMLConverter::GetAddressFromString( aBaseAddress, sBaseCell, GetScImport().GetDocument(), nOffset )) + { + uno::Any aAnyBase; + aAnyBase <<= aBaseAddress; + aProp.Value = aAnyBase; + aProp.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_SOURCEPOS)); + aProps[aProps.getLength() - 1] = aProp; + } +} + +void XMLTableStyleContext::SetStyle(::com::sun::star::uno::Sequence<beans::PropertyValue>& aProps, + const ::rtl::OUString& sApplyStyle) const +{ + aProps.realloc(aProps.getLength() + 1); + beans::PropertyValue aProp; + aProp.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_STYLENAME)); + uno::Any aAnyApplyStyle; + aAnyApplyStyle <<= sApplyStyle; + aProp.Value = aAnyApplyStyle; + aProps[aProps.getLength() - 1] = aProp; +} + +void XMLTableStyleContext::SetFormula1(::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aProps, + const ::rtl::OUString& sFormula) const +{ + aProps.realloc(aProps.getLength() + 1); + beans::PropertyValue aProp; + aProp.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_FORMULA1)); + ::rtl::OUString sRealFormula(sFormula); + ScXMLConverter::ParseFormula(sRealFormula); + uno::Any aAnyFormula; + aAnyFormula <<= sRealFormula; + aProp.Value = aAnyFormula; + aProps[aProps.getLength() - 1] = aProp; +} + +void XMLTableStyleContext::SetFormula2(::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aProps, + const ::rtl::OUString& sFormula) const +{ + aProps.realloc(aProps.getLength() + 1); + beans::PropertyValue aProp; + aProp.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_FORMULA2)); + ::rtl::OUString sRealFormula(sFormula); + ScXMLConverter::ParseFormula(sRealFormula); + uno::Any aAnyFormula; + aAnyFormula <<= sRealFormula; + aProp.Value = aAnyFormula; + aProps[aProps.getLength() - 1] = aProp; +} + +void XMLTableStyleContext::SetFormulas(::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aProps, + const ::rtl::OUString& sFormulas) const +{ + sal_Int32 i = 0; + sal_Bool bString = sal_False; + sal_Int32 nBrakes = 0; + while ((sFormulas[i] != ',' || nBrakes > 0 || bString) && i < sFormulas.getLength()) + { + if (sFormulas[i] == '(') + nBrakes++; + if (sFormulas[i] == ')') + nBrakes--; + if (sFormulas[i] == '"') + bString = !bString; + i++; + } + if (sFormulas[i] == ',') + { + ::rtl::OUString sFormula1 = sFormulas.copy(0, i); + ::rtl::OUString sFormula2 = sFormulas.copy(i + 1); + SetFormula1(aProps, sFormula1); + SetFormula2(aProps, sFormula2); + } +} + +void XMLTableStyleContext::GetConditionalFormat(uno::Any& aAny, + const ::rtl::OUString& sTempCondition, + const ::rtl::OUString& sApplyStyle, const ::rtl::OUString& sBaseCell) const +{ + ::rtl::OUString sCondition = sTempCondition; + if (sCondition.getLength() && sApplyStyle.getLength()) + { + uno::Reference<sheet::XSheetConditionalEntries> xConditionalEntries; + if (aAny >>= xConditionalEntries) + { + // ToDo: erase all blanks in the condition, but not in formulas or strings + ::rtl::OUString scell_content(RTL_CONSTASCII_USTRINGPARAM("cell_content")); + ::rtl::OUString scell_content_is_between(RTL_CONSTASCII_USTRINGPARAM("cell_content_is_between")); + ::rtl::OUString scell_content_is_not_between(RTL_CONSTASCII_USTRINGPARAM("cell_content_is_not_between")); + ::rtl::OUString sis_true_formula(RTL_CONSTASCII_USTRINGPARAM("is_true_formula")); + uno::Sequence<beans::PropertyValue> aProps; + if (sBaseCell.getLength()) + SetBaseCellAddress(aProps, sBaseCell); + SetStyle(aProps, sApplyStyle); + sal_Int32 i = 0; + while (sCondition[i] != '(' && i < sCondition.getLength()) + i++; + if (sCondition[i] == '(') + { + sCondition = sCondition.copy(i + 1); + if (i == scell_content.getLength()) + { + sCondition = sCondition.copy(1); + switch (sCondition[0]) + { + case '<' : + { + if (sCondition[1] == '=') + { + SetOperator(aProps, sheet::ConditionOperator_LESS_EQUAL); + sCondition = sCondition.copy(2); + } + else + { + SetOperator(aProps, sheet::ConditionOperator_LESS); + sCondition = sCondition.copy(1); + } + } + break; + case '>' : + { + if (sCondition[1] == '=') + { + SetOperator(aProps, sheet::ConditionOperator_GREATER_EQUAL); + sCondition = sCondition.copy(2); + } + else + { + SetOperator(aProps, sheet::ConditionOperator_GREATER); + sCondition = sCondition.copy(1); + } + } + break; + case '=' : + { + SetOperator(aProps, sheet::ConditionOperator_EQUAL); + sCondition = sCondition.copy(1); + } + break; + case '!' : + { + SetOperator(aProps, sheet::ConditionOperator_NOT_EQUAL); + sCondition = sCondition.copy(1); + } + break; + } + SetFormula1(aProps, sCondition); + } + else if (i == scell_content_is_between.getLength()) + { + SetOperator(aProps, sheet::ConditionOperator_BETWEEN); + sCondition = sCondition.copy(0, sCondition.getLength() - 1); + SetFormulas(aProps, sCondition); + } + else if (i == scell_content_is_not_between.getLength()) + { + SetOperator(aProps, sheet::ConditionOperator_NOT_BETWEEN); + sCondition = sCondition.copy(0, sCondition.getLength() - 1); + SetFormulas(aProps, sCondition); + } + else if (i == sis_true_formula.getLength()) + { + SetOperator(aProps, sheet::ConditionOperator_FORMULA); + sCondition = sCondition.copy(0, sCondition.getLength() - 1); + SetFormula1(aProps, sCondition); + } + } + xConditionalEntries->addNew(aProps); + aAny <<= xConditionalEntries; + } + } +} + +void XMLTableStyleContext::SetAttribute( sal_uInt16 nPrefixKey, + const OUString& rLocalName, + const OUString& rValue ) +{ + // TODO: use a map here + if( IsXMLToken(rLocalName, XML_DATA_STYLE_NAME ) ) + sDataStyleName = rValue; + else if ( IsXMLToken(rLocalName, XML_MASTER_PAGE_NAME ) ) + sPageStyle = rValue; + else + XMLPropStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue ); +} + +struct ScXMLMapContent +{ + ::rtl::OUString sCondition; + ::rtl::OUString sApplyStyle; + ::rtl::OUString sBaseCell; +}; + +TYPEINIT1( XMLTableStyleContext, XMLPropStyleContext ); + +XMLTableStyleContext::XMLTableStyleContext( ScXMLImport& rImport, + sal_uInt16 nPrfx, const OUString& rLName, + const Reference< XAttributeList > & xAttrList, + SvXMLStylesContext& rStyles, sal_uInt16 nFamily, sal_Bool bDefaultStyle ) : + XMLPropStyleContext( rImport, nPrfx, rLName, xAttrList, rStyles, nFamily, bDefaultStyle ), + sNumberFormat(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NumberFormat"))), + sDataStyleName(), + pStyles(&rStyles), + nNumberFormat(-1), + bParentSet(sal_False), + bConditionalFormatCreated(sal_False) +{ +} + +XMLTableStyleContext::~XMLTableStyleContext() +{ +} + +SvXMLImportContext *XMLTableStyleContext::CreateChildContext( + sal_uInt16 nPrefix, + const OUString& rLocalName, + const Reference< XAttributeList > & xAttrList ) +{ + SvXMLImportContext *pContext = NULL; + + if( (XML_NAMESPACE_STYLE == nPrefix) && + IsXMLToken(rLocalName, XML_MAP ) ) + { + pContext = new ScXMLMapContext(GetImport(), nPrefix, rLocalName, xAttrList); + + ScXMLMapContent aMap; + aMap.sCondition = ((ScXMLMapContext*)pContext)->GetCondition(); + aMap.sApplyStyle = ((ScXMLMapContext*)pContext)->GetApplyStyle(); + aMap.sBaseCell = ((ScXMLMapContext*)pContext)->GetBaseCell(); + aMaps.push_back(aMap); + } + if (!pContext) + pContext = XMLPropStyleContext::CreateChildContext( nPrefix, rLocalName, + xAttrList ); + return pContext; +} + +void XMLTableStyleContext::FillPropertySet( + const Reference< XPropertySet > & rPropSet ) +{ + if (!IsDefaultStyle()) + { + if (GetFamily() == XML_STYLE_FAMILY_TABLE_CELL) + { + if (!bParentSet) + { + ::rtl::OUString sParentName = GetParent(); + uno::Any aStyleName; + aStyleName <<= sParentName; + AddProperty(CTF_SC_CELLSTYLE, aStyleName); + bParentSet = sal_True; + } + if ((nNumberFormat == -1) && sDataStyleName.getLength()) + { + SvXMLNumFormatContext* pStyle = (SvXMLNumFormatContext *)pStyles->FindStyleChildContext( + XML_STYLE_FAMILY_DATA_STYLE, sDataStyleName, sal_True); + if (!pStyle) + { + XMLTableStylesContext* pMyStyles = (XMLTableStylesContext *)GetScImport().GetStyles(); + if (pMyStyles) + pStyle = (SvXMLNumFormatContext *)pMyStyles-> + FindStyleChildContext(XML_STYLE_FAMILY_DATA_STYLE, sDataStyleName, sal_True); + else + DBG_ERROR("not possible to get style"); + } + if (pStyle) + { + uno::Any aNumberFormat; + nNumberFormat = pStyle->GetKey(); + aNumberFormat <<= nNumberFormat; + //rPropSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_NUMBERFORMAT)), aNumberFormat); + AddProperty(CTF_SC_NUMBERFORMAT, aNumberFormat); + } + } + if (!bConditionalFormatCreated && (aMaps.size() > 0)) + { + aConditionalFormat = rPropSet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_CONDITIONALFORMAT))); + std::vector<ScXMLMapContent>::iterator aItr = aMaps.begin(); + while(aItr != aMaps.end()) + { + //rPropSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_CONDITIONALFORMAT)), + GetConditionalFormat(aConditionalFormat, aItr->sCondition, aItr->sApplyStyle, aItr->sBaseCell); + + aItr++; + } + AddProperty(CTF_SC_IMPORT_MAP, aConditionalFormat); + bConditionalFormatCreated = sal_True; + } + } + else if (GetFamily() == XML_STYLE_FAMILY_TABLE_TABLE) + { + if (sPageStyle.getLength()) + { + uno::Any aAny; + aAny <<= sPageStyle; + AddProperty(CTF_SC_MASTERPAGENAME, aAny); + } + } + } + XMLPropStyleContext::FillPropertySet(rPropSet); +} + +void XMLTableStyleContext::SetDefaults() +{ + if ((GetFamily() == XML_STYLE_FAMILY_TABLE_CELL) && GetImport().GetModel().is()) + { + uno::Reference <lang::XMultiServiceFactory> xMultiServiceFactory(GetImport().GetModel(), uno::UNO_QUERY); + if (xMultiServiceFactory.is()) + { + uno::Reference <uno::XInterface> xInterface = xMultiServiceFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.Defaults"))); + uno::Reference <beans::XPropertySet> xProperties(xInterface, uno::UNO_QUERY); + if (xProperties.is()) + FillPropertySet(xProperties); + } + } +} + +void XMLTableStyleContext::AddProperty(const sal_Int16 nContextID, const uno::Any& rValue) +{ + sal_Int32 nIndex(static_cast<XMLTableStylesContext *>(pStyles)->GetIndex(nContextID)); + DBG_ASSERT(nIndex != -1, "Property not found in Map"); + XMLPropertyState aPropState(nIndex, rValue); + GetProperties().push_back(aPropState); // has to be insertes in a sort order later +} + +// ---------------------------------------------------------------------------- + +SvXMLStyleContext *XMLTableStylesContext::CreateStyleStyleChildContext( + sal_uInt16 nFamily, sal_uInt16 nPrefix, const OUString& rLocalName, + const Reference< xml::sax::XAttributeList > & xAttrList ) +{ + SvXMLStyleContext *pStyle = SvXMLStylesContext::CreateStyleStyleChildContext( nFamily, nPrefix, + rLocalName, + xAttrList ); + if (!pStyle) + { + switch( nFamily ) + { + case XML_STYLE_FAMILY_TABLE_CELL: + case XML_STYLE_FAMILY_TABLE_COLUMN: + case XML_STYLE_FAMILY_TABLE_ROW: + case XML_STYLE_FAMILY_TABLE_TABLE: + pStyle = new XMLTableStyleContext( GetScImport(), nPrefix, rLocalName, + xAttrList, *this, nFamily ); + break; + } + } + + return pStyle; +} + +SvXMLStyleContext *XMLTableStylesContext::CreateDefaultStyleStyleChildContext( + sal_uInt16 nFamily, sal_uInt16 nPrefix, const OUString& rLocalName, + const uno::Reference< xml::sax::XAttributeList > & xAttrList ) +{ + SvXMLStyleContext *pStyle = SvXMLStylesContext::CreateDefaultStyleStyleChildContext( nFamily, nPrefix, + rLocalName, + xAttrList ); + if (!pStyle) + { + switch( nFamily ) + { + case XML_STYLE_FAMILY_TABLE_CELL: + pStyle = new XMLTableStyleContext( GetScImport(), nPrefix, rLocalName, + xAttrList, *this, nFamily, sal_True); + break; + case XML_STYLE_FAMILY_SD_GRAPHICS_ID: + pStyle = new XMLGraphicsDefaultStyle( GetScImport(), nPrefix, rLocalName, + xAttrList, *this); + break; + } + } + + return pStyle; +} + +XMLTableStylesContext::XMLTableStylesContext( SvXMLImport& rImport, + sal_uInt16 nPrfx , + const OUString& rLName , + const Reference< XAttributeList > & xAttrList, + const sal_Bool bTempAutoStyles ) : + SvXMLStylesContext( rImport, nPrfx, rLName, xAttrList ), + sCellStyleServiceName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.style.CellStyle" ) )), + sColumnStyleServiceName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_NAME ))), + sRowStyleServiceName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( XML_STYLE_FAMILY_TABLE_ROW_STYLES_NAME ))), + sTableStyleServiceName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( XML_STYLE_FAMILY_TABLE_TABLE_STYLES_NAME ))), + nNumberFormatIndex(-1), + nConditionalFormatIndex(-1), + nCellStyleIndex(-1), + nMasterPageNameIndex(-1), + bAutoStyles(bTempAutoStyles) +{ +} + +XMLTableStylesContext::~XMLTableStylesContext() +{ +} + +void XMLTableStylesContext::EndElement() +{ + SvXMLStylesContext::EndElement(); + if (bAutoStyles) + GetImport().GetTextImport()->SetAutoStyles( this ); + else + ((ScXMLImport&)GetImport()).InsertStyles(); +} + +UniReference < SvXMLImportPropertyMapper > + XMLTableStylesContext::GetImportPropertyMapper( + sal_uInt16 nFamily ) const +{ + UniReference < SvXMLImportPropertyMapper > xMapper = + SvXMLStylesContext::GetImportPropertyMapper(nFamily); + + if (!xMapper.is()) + { + switch( nFamily ) + { + case XML_STYLE_FAMILY_TABLE_CELL: + { + if( !xCellImpPropMapper.is() ) + { + ((XMLTableStylesContext *)this)->xCellImpPropMapper = + new ScXMLCellImportPropertyMapper( GetScImport().GetCellStylesPropertySetMapper(), const_cast<SvXMLImport&>(GetImport()) ); + xCellImpPropMapper->ChainImportMapper(XMLTextImportHelper::CreateCharExtPropMapper(const_cast<SvXMLImport&>(GetImport()), const_cast<XMLFontStylesContext*>(GetScImport().GetFontDecls()))); + } + xMapper = xCellImpPropMapper; + } + break; + case XML_STYLE_FAMILY_TABLE_COLUMN: + { + if( !xColumnImpPropMapper.is() ) + ((XMLTableStylesContext *)this)->xColumnImpPropMapper = + new SvXMLImportPropertyMapper( GetScImport().GetColumnStylesPropertySetMapper(), const_cast<SvXMLImport&>(GetImport()) ); + xMapper = xColumnImpPropMapper; + } + break; + case XML_STYLE_FAMILY_TABLE_ROW: + { + if( !xRowImpPropMapper.is() ) + ((XMLTableStylesContext *)this)->xRowImpPropMapper = + new ScXMLRowImportPropertyMapper( GetScImport().GetRowStylesPropertySetMapper(), const_cast<SvXMLImport&>(GetImport()) ); + xMapper = xRowImpPropMapper; + } + break; + case XML_STYLE_FAMILY_TABLE_TABLE: + { + if( !xTableImpPropMapper.is() ) + ((XMLTableStylesContext *)this)->xTableImpPropMapper = + new SvXMLImportPropertyMapper( GetScImport().GetTableStylesPropertySetMapper(), const_cast<SvXMLImport&>(GetImport()) ); + xMapper = xTableImpPropMapper; + } + break; + } + } + + return xMapper; +} + +Reference < XNameContainer > + XMLTableStylesContext::GetStylesContainer( sal_uInt16 nFamily ) const +{ + Reference < XNameContainer > xStyles = SvXMLStylesContext::GetStylesContainer(nFamily); + if (!xStyles.is()) + { + OUString sName; + switch( nFamily ) + { + case XML_STYLE_FAMILY_TABLE_TABLE: + { + if( xTableStyles.is() ) + xStyles = xTableStyles; + else + sName = + OUString( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "TableStyles" ) )); + } + break; + case XML_STYLE_FAMILY_TABLE_CELL: + { + if( xCellStyles.is() ) + xStyles = xCellStyles; + else + sName = + OUString( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "CellStyles" ) )); + } + break; + case XML_STYLE_FAMILY_TABLE_COLUMN: + { + if( xColumnStyles.is() ) + xStyles = xColumnStyles; + else + sName = + OUString( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ColumnStyles" ) )); + } + break; + case XML_STYLE_FAMILY_TABLE_ROW: + { + if( xRowStyles.is() ) + xStyles = xRowStyles; + else + sName = + OUString( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "RowStyles" ) )); + } + break; + } + if( !xStyles.is() && sName.getLength() && GetScImport().GetModel().is() ) + { + Reference< XStyleFamiliesSupplier > xFamiliesSupp( + GetScImport().GetModel(), UNO_QUERY ); + if (xFamiliesSupp.is()) + { + Reference< XNameAccess > xFamilies = xFamiliesSupp->getStyleFamilies(); + Any aAny = xFamilies->getByName( sName ); + + xStyles = *(Reference<XNameContainer>*)aAny.getValue(); + switch( nFamily ) + { + case XML_STYLE_FAMILY_TABLE_TABLE: + ((XMLTableStylesContext *)this)->xTableStyles = xStyles; + break; + case XML_STYLE_FAMILY_TABLE_CELL: + ((XMLTableStylesContext *)this)->xCellStyles = xStyles; + break; + case XML_STYLE_FAMILY_TABLE_COLUMN: + ((XMLTableStylesContext *)this)->xColumnStyles = xStyles; + break; + case XML_STYLE_FAMILY_TABLE_ROW: + ((XMLTableStylesContext *)this)->xRowStyles = xStyles; + break; + } + } + } + } + + return xStyles; +} + +OUString XMLTableStylesContext::GetServiceName( sal_uInt16 nFamily ) const +{ + ::rtl::OUString sServiceName = SvXMLStylesContext::GetServiceName(nFamily); + if (!sServiceName.getLength()) + { + switch( nFamily ) + { + case XML_STYLE_FAMILY_TABLE_COLUMN: + sServiceName = sColumnStyleServiceName; + break; + case XML_STYLE_FAMILY_TABLE_ROW: + sServiceName = sRowStyleServiceName; + break; + case XML_STYLE_FAMILY_TABLE_CELL: + sServiceName = sCellStyleServiceName; + break; + case XML_STYLE_FAMILY_TABLE_TABLE: + sServiceName = sTableStyleServiceName; + break; + } + } + return sServiceName; +} + +sal_Int32 XMLTableStylesContext::GetIndex(const sal_Int16 nContextID) +{ + if (nContextID == CTF_SC_CELLSTYLE) + { + if (nCellStyleIndex == -1) + nCellStyleIndex = + GetImportPropertyMapper(XML_STYLE_FAMILY_TABLE_CELL)->getPropertySetMapper()->FindEntryIndex(nContextID); + return nCellStyleIndex; + } + else if (nContextID == CTF_SC_NUMBERFORMAT) + { + if (nNumberFormatIndex == -1) + nNumberFormatIndex = + GetImportPropertyMapper(XML_STYLE_FAMILY_TABLE_CELL)->getPropertySetMapper()->FindEntryIndex(nContextID); + return nNumberFormatIndex; + } + else if (nContextID == CTF_SC_IMPORT_MAP) + { + if (nConditionalFormatIndex == -1) + nConditionalFormatIndex = + GetImportPropertyMapper(XML_STYLE_FAMILY_TABLE_CELL)->getPropertySetMapper()->FindEntryIndex(nContextID); + return nConditionalFormatIndex; + } + else if (nContextID == CTF_SC_MASTERPAGENAME) + { + if (nMasterPageNameIndex == -1) + nMasterPageNameIndex = + GetImportPropertyMapper(XML_STYLE_FAMILY_TABLE_TABLE)->getPropertySetMapper()->FindEntryIndex(nContextID); + return nMasterPageNameIndex; + } + else + return -1; +} + +// --------------------------------------------------------------------------- +TYPEINIT1( ScXMLMasterStylesContext, SvXMLStylesContext ); + +sal_Bool ScXMLMasterStylesContext::InsertStyleFamily( sal_uInt16 ) const +{ + return sal_True; +} + +ScXMLMasterStylesContext::ScXMLMasterStylesContext( + SvXMLImport& rImport, + sal_uInt16 nPrfx, const OUString& rLName, + const Reference< XAttributeList > & xAttrList ) : + SvXMLStylesContext( rImport, nPrfx, rLName, xAttrList ) +{ +} + +ScXMLMasterStylesContext::~ScXMLMasterStylesContext() +{ +} + +SvXMLStyleContext *ScXMLMasterStylesContext::CreateStyleChildContext( + sal_uInt16 nPrefix, + const OUString& rLocalName, + const Reference< XAttributeList > & xAttrList ) +{ + SvXMLStyleContext *pContext = 0; + + if( (XML_NAMESPACE_STYLE == nPrefix) && + IsXMLToken(rLocalName, XML_MASTER_PAGE) && + InsertStyleFamily( XML_STYLE_FAMILY_MASTER_PAGE ) ) + pContext = new ScMasterPageContext( + GetImport(), nPrefix, rLocalName, xAttrList, + !GetImport().GetTextImport()->IsInsertMode() ); + + // any other style will be ignored here! + + return pContext; +} + +SvXMLStyleContext *ScXMLMasterStylesContext::CreateStyleStyleChildContext( + sal_uInt16 nFamily, + sal_uInt16 nPrefix, + const OUString& rLocalName, + const Reference< XAttributeList > & xAttrList ) +{ + return 0; +} + +void ScXMLMasterStylesContext::EndElement() +{ + FinishStyles(sal_True); +} + +TYPEINIT1( ScMasterPageContext, XMLTextMasterPageContext ); + +ScMasterPageContext::ScMasterPageContext( SvXMLImport& rImport, + sal_uInt16 nPrfx, const OUString& rLName, + const Reference< XAttributeList > & xAttrList, + sal_Bool bOverwrite ) : + XMLTextMasterPageContext( rImport, nPrfx, rLName, xAttrList, bOverwrite ), + bContainsRightHeader(sal_False), + bContainsRightFooter(sal_False) +{ +} + +ScMasterPageContext::~ScMasterPageContext() +{ +} + +SvXMLImportContext *ScMasterPageContext::CreateChildContext( + sal_uInt16 nPrefix, + const OUString& rLocalName, + const Reference< XAttributeList > & xAttrList ) +{ + SvXMLImportContext *pContext = XMLTextMasterPageContext::CreateChildContext( nPrefix, rLocalName, + xAttrList ); + return pContext; +} + +SvXMLImportContext *ScMasterPageContext::CreateHeaderFooterContext( + sal_uInt16 nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList, + const sal_Bool bFooter, + const sal_Bool bLeft ) +{ + if (!bLeft) + if (bFooter) + bContainsRightFooter = sal_True; + else + bContainsRightHeader = sal_True; + if (!xPropSet.is()) + xPropSet = Reference < XPropertySet > ( GetStyle(), UNO_QUERY ); + return new XMLTableHeaderFooterContext( GetImport(), + nPrefix, rLocalName, + xAttrList, + xPropSet, + bFooter, bLeft ); +} + +void ScMasterPageContext::ClearContent(const ::rtl::OUString& rContent) +{ + if (!xPropSet.is()) + xPropSet = Reference < XPropertySet > ( GetStyle(), UNO_QUERY ); + + Any aAny; + aAny = xPropSet->getPropertyValue( rContent ); + Reference < sheet::XHeaderFooterContent > xHeaderFooterContent; + if (aAny >>= xHeaderFooterContent) + { + xHeaderFooterContent->getLeftText()->setString(sEmpty); + xHeaderFooterContent->getCenterText()->setString(sEmpty); + xHeaderFooterContent->getRightText()->setString(sEmpty); + aAny <<= xHeaderFooterContent; + xPropSet->setPropertyValue( rContent, aAny ); + } +} + +void ScMasterPageContext::Finish( sal_Bool bOverwrite ) +{ + XMLTextMasterPageContext::Finish(bOverwrite); + if (!bContainsRightFooter) + ClearContent(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_PAGE_RIGHTFTRCON))); + if (!bContainsRightHeader) + ClearContent(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_PAGE_RIGHTHDRCON))); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_xmlsubti.cxx b/binfilter/bf_sc/source/filter/xml/sc_xmlsubti.cxx new file mode 100644 index 000000000000..b5889aa5ddb0 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_xmlsubti.cxx @@ -0,0 +1,747 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "xmlstyli.hxx" +#include "document.hxx" +#include "XMLConverter.hxx" +#include "docuno.hxx" +#include "XMLStylesImportHelper.hxx" + +#include <bf_xmloff/xmluconv.hxx> +#include <bf_xmloff/xmlerror.hxx> + +#include <com/sun/star/util/XMergeable.hpp> +#include <com/sun/star/sheet/XCellRangeAddressable.hpp> +#include <com/sun/star/sheet/XCellRangeMovement.hpp> +#include <com/sun/star/drawing/XDrawPageSupplier.hpp> +namespace binfilter { + +//------------------------------------------------------------------ + +using namespace ::com::sun::star; + +ScMyTableData::ScMyTableData(sal_Int16 nSheet, sal_Int32 nCol, sal_Int32 nRow) + : nColsPerCol(nDefaultColCount, 1), + nRealCols(nDefaultColCount + 1, 0), + nRowsPerRow(nDefaultRowCount, 1), + nRealRows(nDefaultRowCount + 1, 0), + nChangedCols() +{ + aTableCellPos.Sheet = nSheet; + aTableCellPos.Column = nCol; + aTableCellPos.Row = nRow; + sal_Int32 i; + + for (i = 0; i < 3; i++) + nRealCols[i] = i; + for (i = 0; i < 3; i++) + nRealRows[i] = i; + + nSpannedCols = 1; + nColCount = 0; + nSubTableSpanned = 1; +} + +ScMyTableData::~ScMyTableData() +{ +} + +void ScMyTableData::AddRow() +{ + aTableCellPos.Row++; + if (static_cast<sal_uInt32>(aTableCellPos.Row) >= nRowsPerRow.size()) + { + nRowsPerRow.resize(nRowsPerRow.size() + nDefaultRowCount, 1); + nRealRows.resize(nRowsPerRow.size() + nDefaultRowCount + 1, 0); + } + nRealRows[aTableCellPos.Row + 1] = nRealRows[aTableCellPos.Row] + nRowsPerRow[aTableCellPos.Row]; +} + +void ScMyTableData::AddColumn() +{ + aTableCellPos.Column++; + if (static_cast<sal_uInt32>(aTableCellPos.Column) >= nColsPerCol.size()) + { + nColsPerCol.resize(nColsPerCol.size() + nDefaultColCount, 1); + nRealCols.resize(nColsPerCol.size() + nDefaultColCount + 1, 0); + } + nRealCols[aTableCellPos.Column + 1] = nRealCols[aTableCellPos.Column] + nColsPerCol[aTableCellPos.Column]; +} + +sal_Int32 ScMyTableData::GetRealCols(const sal_Int32 nIndex, const sal_Bool bIsNormal) const +{ + return (nIndex < 0) ? 0 : nRealCols[nIndex]; +} + +sal_Int32 ScMyTableData::GetChangedCols(const sal_Int32 nFromIndex, const sal_Int32 nToIndex) const +{ + ScMysalIntList::const_iterator i = nChangedCols.begin(); + while ((i != nChangedCols.end()) && ((*i < nToIndex) && !(*i >= nFromIndex))) + i++; + if (i == nChangedCols.end()) + return -1; + else + if ((*i >= nFromIndex) && (*i < nToIndex)) + return *i; + else + return -1; +} + +void ScMyTableData::SetChangedCols(const sal_Int32 nValue) +{ + ScMysalIntList::iterator i = nChangedCols.begin(); + while ((i != nChangedCols.end()) && (*i < nValue)) + { + sal_Int32 nTemp = *i; + i++; + } + if ((i == nChangedCols.end()) || (*i != nValue)) + nChangedCols.insert(i, nValue); +} + +/*******************************************************************************************************************************/ + +ScMyTables::ScMyTables(ScXMLImport& rTempImport) + : rImport(rTempImport), + nTableCount( 0 ), + nCurrentSheet( -1 ), + nCurrentDrawPage( -1 ), + nCurrentXShapes( -1 ), + aResizeShapes(rTempImport), + nCurrentColStylePos(0) +{ + aTableVec.resize(nDefaultTabCount, NULL); +} + +ScMyTables::~ScMyTables() +{ + ScMyTableData* pTable; + while (nTableCount > 0) + { + pTable = aTableVec[nTableCount - 1]; + delete pTable; + aTableVec[nTableCount - 1] = NULL; + nTableCount--; + } +} + +void ScMyTables::NewSheet(const ::rtl::OUString& sTableName, const ::rtl::OUString& sStyleName, + const sal_Bool bTempProtection, const ::rtl::OUString& sTempPassword) +{ + if (rImport.GetModel().is()) + { + nCurrentColStylePos = 0; + sCurrentSheetName = sTableName; + ScMyTableData* aTable; + while (nTableCount > 0) + { + aTable = aTableVec[nTableCount - 1]; + delete aTable; + aTableVec[nTableCount - 1] = NULL; + nTableCount--; + } + nCurrentSheet++; + + bProtection = bTempProtection; + sPassword = sTempPassword; + uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( rImport.GetModel(), uno::UNO_QUERY ); + if ( xSpreadDoc.is() ) + { + uno::Reference <sheet::XSpreadsheets> xSheets = xSpreadDoc->getSheets(); + if (xSheets.is()) + { + if (nCurrentSheet > 0) + { + try + { + xSheets->insertNewByName(sTableName, nCurrentSheet); + } + catch ( uno::RuntimeException& ) + { + ScDocument *pDoc = ScXMLConverter::GetScDocument(rImport.GetModel()); + if (pDoc) + { + rImport.LockSolarMutex(); + String sTabName = String::CreateFromAscii("Table"); + pDoc->CreateValidTabName(sTabName); + ::rtl::OUString sOUTabName(sTabName); + xSheets->insertNewByName(sOUTabName, nCurrentSheet); + rImport.UnlockSolarMutex(); + } + } + } + uno::Reference <container::XIndexAccess> xIndex( xSheets, uno::UNO_QUERY ); + if ( xIndex.is() ) + { + uno::Any aSheet = xIndex->getByIndex(nCurrentSheet); + if ( aSheet >>= xCurrentSheet ) + { + xCurrentCellRange = uno::Reference<table::XCellRange>(xCurrentSheet, uno::UNO_QUERY); + if (!(nCurrentSheet > 0)) + { + uno::Reference < container::XNamed > xNamed(xCurrentSheet, uno::UNO_QUERY ); + if ( xNamed.is() ) + try + { + xNamed->setName(sTableName); + } + catch ( uno::RuntimeException& ) + { + ScDocument *pDoc = ScXMLConverter::GetScDocument(rImport.GetModel()); + if (pDoc) + { + rImport.LockSolarMutex(); + String sTabName = String::CreateFromAscii("Table"); + pDoc->CreateValidTabName(sTabName); + ::rtl::OUString sOUTabName(sTabName); + xNamed->setName(sOUTabName); + rImport.UnlockSolarMutex(); + } + } + } + if (nCurrentSheet > 0 && sStyleName.getLength()) + { + uno::Reference <beans::XPropertySet> xProperties(xCurrentSheet, uno::UNO_QUERY); + if (xProperties.is()) + { + XMLTableStylesContext *pStyles = (XMLTableStylesContext *)rImport.GetAutoStyles(); + XMLTableStyleContext* pStyle = (XMLTableStyleContext *)pStyles->FindStyleChildContext( + XML_STYLE_FAMILY_TABLE_TABLE, sStyleName, sal_True); + if (pStyle) + pStyle->FillPropertySet(xProperties); + } + } + else + rImport.SetFirstTableStyle(sStyleName); + } + + } + } + } + } + + NewTable(1); +} + +sal_Bool ScMyTables::IsMerged (const uno::Reference <table::XCellRange>& xCellRange, const sal_Int32 nCol, const sal_Int32 nRow, + table::CellRangeAddress& aCellAddress) const +{ + uno::Reference <table::XCellRange> xMergeCellRange = xCellRange->getCellRangeByPosition(nCol,nRow,nCol,nRow); + uno::Reference <util::XMergeable> xMergeable (xMergeCellRange, uno::UNO_QUERY); + if (xMergeable.is()) + { + uno::Reference<sheet::XSheetCellRange> xMergeSheetCellRange (xMergeCellRange, 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 sal_False; + else + return sal_True; + } + } + } + return sal_False; +} + +void ScMyTables::UnMerge() +{ + if ( xCurrentCellRange.is() ) + { + table::CellRangeAddress aCellAddress; + if (IsMerged(xCurrentCellRange, GetRealCellPos().Column, GetRealCellPos().Row, aCellAddress)) + { + //unmerge + uno::Reference <table::XCellRange> xMergeCellRange = + xCurrentCellRange->getCellRangeByPosition(aCellAddress.StartColumn, aCellAddress.StartRow, + aCellAddress.EndColumn, aCellAddress.EndRow); + uno::Reference <util::XMergeable> xMergeable (xMergeCellRange, uno::UNO_QUERY); + if (xMergeable.is()) + xMergeable->merge(sal_False); + } + } +} + +void ScMyTables::DoMerge(sal_Int32 nCount) +{ + if ( xCurrentCellRange.is() ) + { + table::CellRangeAddress aCellAddress; + if (IsMerged(xCurrentCellRange, GetRealCellPos().Column, GetRealCellPos().Row, aCellAddress)) + { + //unmerge + uno::Reference <table::XCellRange> xMergeCellRange = + xCurrentCellRange->getCellRangeByPosition(aCellAddress.StartColumn, aCellAddress.StartRow, + aCellAddress.EndColumn, aCellAddress.EndRow); + uno::Reference <util::XMergeable> xMergeable (xMergeCellRange, uno::UNO_QUERY); + if (xMergeable.is()) + xMergeable->merge(sal_False); + } + + //merge + uno::Reference <table::XCellRange> xMergeCellRange; + if (nCount == -1) + xMergeCellRange = + xCurrentCellRange->getCellRangeByPosition(aCellAddress.StartColumn, aCellAddress.StartRow, + aCellAddress.EndColumn + + aTableVec[nTableCount - 1]->GetColsPerCol(aTableVec[nTableCount - 1]->GetColumn()) - 1, + aCellAddress.EndRow + + aTableVec[nTableCount - 1]->GetRowsPerRow(aTableVec[nTableCount - 1]->GetRow()) - 1); + else + xMergeCellRange = + 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(sal_True); + } +} + +void ScMyTables::InsertRow() +{ + if ( xCurrentCellRange.is() ) + { + table::CellRangeAddress aCellAddress; + sal_Int32 nRow(GetRealCellPos().Row); + for (sal_Int32 j = 0; j < GetRealCellPos().Column - aTableVec[nTableCount - 1]->GetColumn() - 1; j++) + { + if (IsMerged(xCurrentCellRange, j, nRow - 1, aCellAddress)) + { + //unmerge + uno::Reference <table::XCellRange> xMergeCellRange = + xCurrentCellRange->getCellRangeByPosition(aCellAddress.StartColumn, aCellAddress.StartRow, + aCellAddress.EndColumn, aCellAddress.EndRow); + uno::Reference <util::XMergeable> xMergeable (xMergeCellRange, uno::UNO_QUERY); + if (xMergeable.is()) + xMergeable->merge(sal_False); + } + + //merge + uno::Reference <table::XCellRange> xMergeCellRange = + xCurrentCellRange->getCellRangeByPosition(aCellAddress.StartColumn, aCellAddress.StartRow, + aCellAddress.EndColumn, aCellAddress.EndRow + 1); + uno::Reference <util::XMergeable> xMergeable (xMergeCellRange, uno::UNO_QUERY); + if (xMergeable.is()) + xMergeable->merge(sal_True); + j += aCellAddress.EndColumn - aCellAddress.StartColumn; + } + rImport.GetStylesImportHelper()->InsertRow(nRow, nCurrentSheet, rImport.GetDocument()); + } +} + +void ScMyTables::NewRow() +{ + if (nTableCount > 1) + if (aTableVec[nTableCount - 1]->GetRealRows(aTableVec[nTableCount - 1]->GetRow()) > + aTableVec[nTableCount - 2]->GetRowsPerRow(aTableVec[nTableCount - 2]->GetRow()) - 1) + { + if (GetRealCellPos().Column > 0) + InsertRow(); + for (sal_Int16 i = nTableCount - 1; i > 0; i--) + { + sal_Int32 nRow = aTableVec[i - 1]->GetRow(); + aTableVec[i - 1]->SetRowsPerRow(nRow, + aTableVec[i - 1]->GetRowsPerRow(nRow) + 1); + aTableVec[i - 1]->SetRealRows(nRow + 1, + aTableVec[i - 1]->GetRealRows(nRow) + + aTableVec[i - 1]->GetRowsPerRow(nRow)); + } + } +} + +void ScMyTables::AddRow() +{ + aTableVec[nTableCount - 1]->AddRow(); + aTableVec[nTableCount - 1]->SetFirstColumn(); + sal_Int32 nRow = aTableVec[nTableCount - 1]->GetRow(); + if (nRow > 0) + NewRow(); + aTableVec[nTableCount - 1]->SetRealRows(nRow + 1, + aTableVec[nTableCount - 1]->GetRealRows(nRow) + + aTableVec[nTableCount - 1]->GetRowsPerRow(nRow)); +} + +void ScMyTables::SetRowStyle(const ::rtl::OUString& rCellStyleName) +{ + rImport.GetStylesImportHelper()->SetRowStyle(rCellStyleName); +} + +void ScMyTables::InsertColumn() +{ + if ( xCurrentCellRange.is() ) + { + table::CellRangeAddress aCellAddress; + sal_Int32 nCol(GetRealCellPos().Column); + for (sal_Int32 j = 0; j <= GetRealCellPos().Row - aTableVec[nTableCount - 1]->GetRow() - 1; j++) + { + table::CellRangeAddress aTempCellAddress; + if (IsMerged(xCurrentCellRange, nCol - 1, j, aCellAddress)) + { + //unmerge + uno::Reference <table::XCellRange> xMergeCellRange = + xCurrentCellRange->getCellRangeByPosition(aCellAddress.StartColumn, aCellAddress.StartRow, + aCellAddress.EndColumn, aCellAddress.EndRow); + uno::Reference <util::XMergeable> xMergeable (xMergeCellRange, uno::UNO_QUERY); + if (xMergeable.is()) + xMergeable->merge(sal_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 <table::XCellRange> xMergeCellRange = + xCurrentCellRange->getCellRangeByPosition(aCellAddress.StartColumn, aCellAddress.StartRow, + aCellAddress.EndColumn + 1, aCellAddress.EndRow); + uno::Reference <util::XMergeable> xMergeable (xMergeCellRange, uno::UNO_QUERY); + if (xMergeable.is()) + xMergeable->merge(sal_True); + j += aCellAddress.EndRow - aCellAddress.StartRow; + } + rImport.GetStylesImportHelper()->InsertCol(nCol, nCurrentSheet, rImport.GetDocument()); + } +} + +void ScMyTables::NewColumn(sal_Bool bIsCovered) +{ + if (!bIsCovered) + { + sal_Int32 nColCount = aTableVec[nTableCount - 1]->GetColCount(); + sal_Int32 nSpannedCols = aTableVec[nTableCount - 1]->GetSpannedCols(); + if ( (nSpannedCols > nColCount) && + (aTableVec[nTableCount - 1]->GetRow() == 0) && + (aTableVec[nTableCount - 1]->GetColumn() == 0) ) + { + if (nColCount > 0) + { + sal_Int32 FirstColsSpanned = nSpannedCols / nColCount; + sal_Int32 LastColSpanned = FirstColsSpanned + + (nSpannedCols % nColCount); + for (sal_Int32 i = 0; i < nColCount - 1; i++) + { + aTableVec[nTableCount - 1]->SetColsPerCol(i, FirstColsSpanned); + aTableVec[nTableCount - 1]->SetRealCols(i + 1, + aTableVec[nTableCount - 1]->GetRealCols(i) + + FirstColsSpanned); + } + aTableVec[nTableCount - 1]->SetColsPerCol(nColCount - 1, LastColSpanned); + aTableVec[nTableCount - 1]->SetRealCols(nColCount - 1 + 1, + aTableVec[nTableCount - 1]->GetRealCols(nColCount - 1) + + LastColSpanned); + } + } + sal_Int32 nTemp = aTableVec[nTableCount - 1]->GetRealCols(aTableVec[nTableCount - 1]->GetColumn()); + if (aTableVec[nTableCount - 1]->GetRealCols(aTableVec[nTableCount - 1]->GetColumn()) > nSpannedCols - 1) + { + if ( aTableVec[nTableCount - 1]->GetRow() == 0) + { + InsertColumn(); + for (sal_Int16 i = nTableCount - 1; i > 0; i--) + { + sal_Int32 nColPos = aTableVec[i - 1]->GetColumn() + + aTableVec[i]->GetSpannedCols() - 1; + aTableVec[i - 1]->SetColsPerCol(nColPos, + aTableVec[i - 1]->GetColsPerCol(nColPos) + + aTableVec[nTableCount - 1]->GetColsPerCol(aTableVec[nTableCount - 1]->GetColumn())); + aTableVec[i - 1]->SetRealCols(nColPos + 1, + aTableVec[i - 1]->GetRealCols(nColPos) + + aTableVec[i - 1]->GetColsPerCol(nColPos)); + aTableVec[i - 1]->SetChangedCols(nColPos); + } + } + } + } +} + +void ScMyTables::AddColumn(sal_Bool bIsCovered) +{ + aTableVec[nTableCount - 1]->AddColumn(); + if (aTableVec[nTableCount - 1]->GetSubTableSpanned() > 1) + aTableVec[nTableCount - 1]->SetSubTableSpanned(aTableVec[nTableCount - 1]->GetSubTableSpanned() - 1); + else + { + NewColumn(bIsCovered); + // if (!bIsCovered) + aTableVec[nTableCount - 1]->SetRealCols(aTableVec[nTableCount - 1]->GetColumn() + 1, + aTableVec[nTableCount - 1]->GetRealCols(aTableVec[nTableCount - 1]->GetColumn()) + + aTableVec[nTableCount - 1]->GetColsPerCol(aTableVec[nTableCount - 1]->GetColumn())); + if ((!bIsCovered) || (bIsCovered && + (aTableVec[nTableCount - 1]->GetColsPerCol(aTableVec[nTableCount - 1]->GetColumn()) > 1))) + { + if ((aTableVec[nTableCount - 1]->GetRowsPerRow(aTableVec[nTableCount - 1]->GetRow()) > 1) || + (aTableVec[nTableCount - 1]->GetColsPerCol(aTableVec[nTableCount - 1]->GetColumn()) > 1)) + DoMerge(); + } + } +} + +void ScMyTables::NewTable(sal_Int32 nTempSpannedCols) +{ + nTableCount++; + if (static_cast<sal_uInt32>(nTableCount) >= aTableVec.size()) + aTableVec.resize(aTableVec.size() + nDefaultTabCount); + ScMyTableData* aTable = new ScMyTableData(nCurrentSheet); + if (nTableCount > 1) + { + sal_Int32 nCol = aTableVec[nTableCount - 2]->GetColumn(); + sal_Int32 nColCount = aTableVec[nTableCount - 2]->GetColCount(); + sal_Int32 nColsPerCol = aTableVec[nTableCount - 2]->GetColsPerCol(nCol); + sal_Int32 nSpannedCols = aTableVec[nTableCount - 2]->GetSpannedCols(); + sal_Int32 nTemp = nSpannedCols - nColCount; + sal_Int32 nTemp2 = nCol - (nColCount - 1); + if ((nTemp > 0) && (nTemp2 == 0)) + nTempSpannedCols *= (nTemp + 1); + else + if (nColsPerCol > 1) + nTempSpannedCols *= nColsPerCol; + + sal_Int32 nToMerge; + if (nSpannedCols > nColCount) + nToMerge = aTableVec[nTableCount - 2]->GetChangedCols(nCol, nCol + nColsPerCol + nSpannedCols - nColCount); + else + nToMerge = aTableVec[nTableCount - 2]->GetChangedCols(nCol, nCol + nColsPerCol); + if (nToMerge > nCol) + nTempSpannedCols += nToMerge; + } + aTable->SetSpannedCols(nTempSpannedCols); + aTableVec[nTableCount - 1] = aTable; + if (nTableCount > 1) + { + aTableVec[nTableCount - 2]->SetSubTableSpanned(aTable->GetSpannedCols()); + UnMerge(); + } +} + +void ScMyTables::UpdateRowHeights() +{ + if (rImport.GetModel().is()) + { + rImport.LockSolarMutex(); + // update automatic row heights + sal_Int16 nTableCount(rImport.GetDocument() ? rImport.GetDocument()->GetTableCount() : 0); + for (sal_Int16 i = 0; i < nTableCount; i++) + ScModelObj::getImplementation(rImport.GetModel())->AdjustRowHeight( 0, MAXROW, i ); + rImport.UnlockSolarMutex(); + } +} + +void ScMyTables::DeleteTable() +{ + rImport.LockSolarMutex(); + + nCurrentColStylePos = 0; + if (nTableCount > 0) + { + ScMyTableData* aTable = aTableVec[nTableCount - 1]; + delete aTable; + aTableVec[nTableCount - 1] = NULL; + nTableCount--; + } + if (nTableCount == 0) // only set the styles if all subtables are importet and the table is finished + { + rImport.GetStylesImportHelper()->SetStylesToRanges(); + rImport.SetStylesToRangesFinished(); + } + if (rImport.GetDocument() && bProtection) + { + uno::Sequence<sal_Int8> aPass; + SvXMLUnitConverter::decodeBase64(aPass, sPassword); + rImport.GetDocument()->SetTabProtection(nCurrentSheet, bProtection, aPass); + /*uno::Reference <util::XProtectable> xProtectable(xCurrentSheet, uno::UNO_QUERY); + if (xProtectable.is()) + { + ::rtl::OUString sKey; + xProtectable->protect(sKey); + }*/ + } + + rImport.UnlockSolarMutex(); + + //#95582#; find out whether it was possible to set the sheet name + // test it here, because if it is a linked table the name is changed by importing + // the linking informations + uno::Reference < container::XNamed > xNamed(xCurrentSheet, uno::UNO_QUERY ); + if ( xNamed.is() ) + { + ::rtl::OUString sCurrentName = xNamed->getName(); + if (sCurrentName != sCurrentSheetName) + { + ::rtl::OUString sErrorMessage(RTL_CONSTASCII_USTRINGPARAM("Could not create a table with the name ")); + sErrorMessage += sCurrentSheetName; + sErrorMessage += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(". The new name is ")); + sErrorMessage += sCurrentName; + uno::Sequence<rtl::OUString> aSeq(1); + aSeq[0] = sErrorMessage; + uno::Reference<xml::sax::XLocator> xLocator; + rImport.SetError(XMLERROR_API | XMLERROR_FLAG_ERROR, aSeq, ::rtl::OUString(), xLocator); + } + } +} + +table::CellAddress ScMyTables::GetRealCellPos() +{ + sal_Int32 nRow, nCol; + nRow = 0; + nCol = 0; + for (sal_Int32 i = 1; i <= nTableCount; i++) + { + nCol += aTableVec[i - 1]->GetRealCols(aTableVec[i - 1]->GetColumn()); + nRow += aTableVec[i - 1]->GetRealRows(aTableVec[i - 1]->GetRow()); + } + aRealCellPos.Row = nRow; + aRealCellPos.Column = nCol; + aRealCellPos.Sheet = nCurrentSheet; + return aRealCellPos; +} + +void ScMyTables::AddColCount(sal_Int32 nTempColCount) +{ + aTableVec[nTableCount - 1]->SetColCount(aTableVec[nTableCount - 1]->GetColCount() + nTempColCount); +} + +void ScMyTables::AddColStyle(const sal_Int32 nRepeat, const ::rtl::OUString& rCellStyleName) +{ + DBG_ASSERT(nTableCount == 1, "not possible to use default styles on columns in subtables"); + rImport.GetStylesImportHelper()->AddColumnStyle(rCellStyleName, nCurrentColStylePos, nRepeat); + nCurrentColStylePos += nRepeat; +} + +uno::Reference< drawing::XDrawPage > ScMyTables::GetCurrentXDrawPage() +{ + if( (nCurrentSheet != nCurrentDrawPage) || !xDrawPage.is() ) + { + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier( xCurrentSheet, uno::UNO_QUERY ); + if( xDrawPageSupplier.is() ) + xDrawPage = xDrawPageSupplier->getDrawPage(); + nCurrentDrawPage = nCurrentSheet; + } + return xDrawPage; +} + +uno::Reference< drawing::XShapes > ScMyTables::GetCurrentXShapes() +{ + if( (nCurrentSheet != nCurrentXShapes) || !xShapes.is() ) + { + uno::Reference <drawing::XShapes > xTempShapes ( GetCurrentXDrawPage(), uno::UNO_QUERY ); + xShapes = xTempShapes; + rImport.GetShapeImport()->startPage(xShapes); + rImport.GetShapeImport()->pushGroupForSorting ( xShapes ); + nCurrentXShapes = nCurrentSheet; + return xShapes; + } + else + return xShapes; +} + +sal_Bool ScMyTables::HasDrawPage() +{ + return !((nCurrentSheet != nCurrentDrawPage) || !xDrawPage.is()); +} + +sal_Bool ScMyTables::HasXShapes() +{ + return !((nCurrentSheet != nCurrentXShapes) || !xShapes.is()); +} + +void ScMyTables::AddShape(uno::Reference <drawing::XShape>& rShape, + ::rtl::OUString* pRangeList, + table::CellAddress& rStartAddress, table::CellAddress& rEndAddress, + sal_Int32 nEndX, sal_Int32 nEndY) +{ + aResizeShapes.AddShape(rShape, pRangeList, rStartAddress, rEndAddress, nEndX, nEndY); +} + +void ScMyTables::AddMatrixRange(sal_uInt32 nStartColumn, sal_uInt32 nStartRow, sal_uInt32 nEndColumn, sal_uInt32 nEndRow) +{ + DBG_ASSERT(nEndRow >= nStartRow, "wrong row order"); + DBG_ASSERT(nEndColumn >= nStartColumn, "wrong column order"); + table::CellRangeAddress aRange; + aRange.StartColumn = nStartColumn; + aRange.StartRow = nStartRow; + aRange.EndColumn = nEndColumn; + aRange.EndRow = nEndRow; + aRange.Sheet = nCurrentSheet; + aMatrixRangeList.push_back(aRange); +} + +sal_Bool ScMyTables::IsPartOfMatrix(sal_uInt32 nColumn, sal_uInt32 nRow) +{ + sal_Bool bResult(sal_False); + if (!aMatrixRangeList.empty()) + { + ScMyMatrixRangeList::iterator aItr = aMatrixRangeList.begin(); + ScMyMatrixRangeList::iterator aEndItr = aMatrixRangeList.end(); + sal_Bool bReady(sal_False); + while(!bReady && aItr != aEndItr) + { + if (nCurrentSheet > aItr->Sheet) + aItr = aMatrixRangeList.erase(aItr); + else if ((nRow >= aItr->EndRow) && (nColumn > aItr->EndColumn)) + aItr = aMatrixRangeList.erase(aItr); + else if (nColumn < aItr->StartColumn) + bReady = sal_True; + else if (nColumn >= aItr->StartColumn && nColumn <= aItr->EndColumn && nRow >= aItr->StartRow && nRow <= aItr->EndRow) + { + bReady = sal_True; + bResult = sal_True; + } + else + ++aItr; + } + } + return bResult; +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_xmltabi.cxx b/binfilter/bf_sc/source/filter/xml/sc_xmltabi.cxx new file mode 100644 index 000000000000..dfb3878b3533 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_xmltabi.cxx @@ -0,0 +1,268 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "xmltabi.hxx" +#include "xmlimprt.hxx" +#include "xmlrowi.hxx" +#include "xmlcoli.hxx" +#include "xmlsceni.hxx" +#include "document.hxx" +#include "olinetab.hxx" + +#include "XMLConverter.hxx" +#include "XMLTableShapesContext.hxx" +#include "XMLTableSourceContext.hxx" +#include "XMLStylesImportHelper.hxx" + +#include <bf_xmloff/nmspmap.hxx> + +#include <com/sun/star/sheet/XPrintAreas.hpp> +namespace binfilter { + +using namespace ::com::sun::star; +using namespace xmloff::token; + +//------------------------------------------------------------------ + +ScXMLTableContext::ScXMLTableContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + const sal_Bool bTempIsSubTable, + const sal_Int32 nSpannedCols) : + SvXMLImportContext( rImport, nPrfx, rLName ), + bStartFormPage(sal_False) +{ + if (!bTempIsSubTable) + { + sal_Bool bProtection(sal_False); + ::rtl::OUString sName; + ::rtl::OUString sStyleName; + ::rtl::OUString sPassword; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetTableAttrTokenMap(); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + ::rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + ::rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + ::rtl::OUString sValue = xAttrList->getValueByIndex( i ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_TABLE_NAME: + sName = sValue; + break; + case XML_TOK_TABLE_STYLE_NAME: + sStyleName = sValue; + break; + case XML_TOK_TABLE_PROTECTION: + bProtection = IsXMLToken(sValue, XML_TRUE); + break; + case XML_TOK_TABLE_PRINT_RANGES: + sPrintRanges = sValue; + break; + case XML_TOK_TABLE_PASSWORD: + sPassword = sValue; + break; + } + } + GetScImport().GetTables().NewSheet(sName, sStyleName, bProtection, sPassword); + } + else + { + GetScImport().GetTables().NewTable(nSpannedCols); + } +} + +ScXMLTableContext::~ScXMLTableContext() +{ +} + +SvXMLImportContext *ScXMLTableContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + const SvXMLTokenMap& rTokenMap = GetScImport().GetTableElemTokenMap(); + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + case XML_TOK_TABLE_COL_GROUP: + pContext = new ScXMLTableColsContext( GetScImport(), nPrefix, + rLName, xAttrList, + sal_False, sal_True ); + break; + case XML_TOK_TABLE_HEADER_COLS: + pContext = new ScXMLTableColsContext( GetScImport(), nPrefix, + rLName, xAttrList, + sal_True, sal_False ); + break; + case XML_TOK_TABLE_COLS: + pContext = new ScXMLTableColsContext( GetScImport(), nPrefix, + rLName, xAttrList, + sal_False, sal_False ); + break; + case XML_TOK_TABLE_COL: + pContext = new ScXMLTableColContext( GetScImport(), nPrefix, + rLName, xAttrList ); + break; + case XML_TOK_TABLE_ROW_GROUP: + pContext = new ScXMLTableRowsContext( GetScImport(), nPrefix, + rLName, xAttrList, + sal_False, sal_True ); + break; + case XML_TOK_TABLE_HEADER_ROWS: + pContext = new ScXMLTableRowsContext( GetScImport(), nPrefix, + rLName, xAttrList, + sal_True, sal_False ); + break; + case XML_TOK_TABLE_ROWS: + pContext = new ScXMLTableRowsContext( GetScImport(), nPrefix, + rLName, xAttrList, + sal_False, sal_False ); + break; + case XML_TOK_TABLE_ROW: + pContext = new ScXMLTableRowContext( GetScImport(), nPrefix, + rLName, xAttrList//, + //this + ); + break; + case XML_TOK_TABLE_SOURCE: + pContext = new ScXMLTableSourceContext( GetScImport(), nPrefix, rLName, xAttrList); + break; + case XML_TOK_TABLE_SCENARIO: + pContext = new ScXMLTableScenarioContext( GetScImport(), nPrefix, rLName, xAttrList); + break; + case XML_TOK_TABLE_SHAPES: + pContext = new ScXMLTableShapesContext( GetScImport(), nPrefix, rLName, xAttrList); + break; + case XML_TOK_TABLE_FORMS: + { + GetScImport().GetFormImport()->startPage(GetScImport().GetTables().GetCurrentXDrawPage()); + bStartFormPage = sal_True; + pContext = GetScImport().GetFormImport()->createOfficeFormsContext( GetScImport(), nPrefix, rLName ); + } + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLTableContext::EndElement() +{ + GetScImport().LockSolarMutex(); + GetScImport().GetStylesImportHelper()->EndTable(); + ScDocument* pDoc = GetScImport().GetDocument(); + if (pDoc) + { + if (sPrintRanges.getLength()) + { + uno::Reference< sheet::XSpreadsheet > xTable = GetScImport().GetTables().GetCurrentXSheet(); + if( xTable.is() ) + { + uno::Reference< sheet::XPrintAreas > xPrintAreas( xTable, uno::UNO_QUERY ); + if( xPrintAreas.is() ) + { + uno::Sequence< table::CellRangeAddress > aRangeList; + ScXMLConverter::GetRangeListFromString( aRangeList, sPrintRanges, pDoc ); + xPrintAreas->setPrintAreas( aRangeList ); + } + } + } + + ScOutlineTable* pOutlineTable = pDoc->GetOutlineTable(GetScImport().GetTables().GetCurrentSheet(), sal_False); + if (pOutlineTable) + { + ScOutlineArray* pColArray = pOutlineTable->GetColArray(); + sal_Int32 nDepth = pColArray->GetDepth(); + sal_Int32 i; + for (i = 0; i < nDepth; i++) + { + sal_Int32 nCount = pColArray->GetCount(static_cast<USHORT>(i)); + sal_Bool bChanged(sal_False); + for (sal_Int32 j = 0; j < nCount && !bChanged; j++) + { + ScOutlineEntry* pEntry = pColArray->GetEntry(static_cast<USHORT>(i), static_cast<USHORT>(j)); + if (pEntry->IsHidden()) + { + pColArray->SetVisibleBelow(static_cast<USHORT>(i), static_cast<USHORT>(j), sal_False); + bChanged = sal_True; + } + } + } + ScOutlineArray* pRowArray = pOutlineTable->GetRowArray(); + nDepth = pRowArray->GetDepth(); + for (i = 0; i < nDepth; i++) + { + sal_Int32 nCount = pRowArray->GetCount(static_cast<USHORT>(i)); + sal_Bool bChanged(sal_False); + for (sal_Int32 j = 0; j < nCount && !bChanged; j++) + { + ScOutlineEntry* pEntry = pRowArray->GetEntry(static_cast<USHORT>(i), static_cast<USHORT>(j)); + if (pEntry->IsHidden()) + { + pRowArray->SetVisibleBelow(static_cast<USHORT>(i), static_cast<USHORT>(j), sal_False); + bChanged = sal_True; + } + } + } + } + if (GetScImport().GetTables().HasDrawPage()) + { + if (GetScImport().GetTables().HasXShapes()) + { + GetScImport().GetShapeImport()->popGroupAndSort(); + uno::Reference<drawing::XShapes> xXShapes(GetScImport().GetTables().GetCurrentXShapes()); + GetScImport().GetShapeImport()->endPage(xXShapes); + } + if (bStartFormPage) + GetScImport().GetFormImport()->endPage(); + } + + GetScImport().GetTables().DeleteTable(); + GetScImport().GetProgressBarHelper()->Increment(); + } + GetScImport().UnlockSolarMutex(); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/sc_xmlwrap.cxx b/binfilter/bf_sc/source/filter/xml/sc_xmlwrap.cxx new file mode 100644 index 000000000000..7e37c7a5adb3 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/sc_xmlwrap.cxx @@ -0,0 +1,770 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +// INCLUDE --------------------------------------------------------------- + +#include <bf_sfx2/docfile.hxx> +#include <bf_sfx2/objsh.hxx> +#include <unotools/streamwrap.hxx> +#include <bf_svx/xmlgrhlp.hxx> +#include <bf_svtools/sfxecode.hxx> +#include <bf_sfx2/appuno.hxx> +#include <bf_svtools/itemset.hxx> +#include <bf_sfx2/sfxsids.hrc> + +#include <com/sun/star/xml/sax/XParser.hpp> +#include <com/sun/star/io/XActiveDataSource.hpp> +#include <com/sun/star/io/XActiveDataControl.hpp> +#include <com/sun/star/task/XStatusIndicatorFactory.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <comphelper/extract.hxx> +#include <comphelper/genericpropertyset.hxx> +#include <com/sun/star/lang/DisposedException.hpp> +#include <com/sun/star/packages/zip/ZipIOException.hpp> + +#include <bf_svx/xmleohlp.hxx> +#include <rtl/logfile.hxx> +#include <bf_svtools/saveopt.hxx> + +#include "document.hxx" +#include "xmlwrap.hxx" +#include "xmlimprt.hxx" +#include "xmlexprt.hxx" +#include "globstr.hrc" +#include "scerrors.hxx" +#include "XMLExportSharedData.hxx" +#include <legacysmgr/legacy_binfilters_smgr.hxx> //STRIP002 +#ifndef SEQTYPE +namespace binfilter { + #if defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500) + #define SEQTYPE(x) (new ::com::sun::star::uno::Type( x )) + #else + #define SEQTYPE(x) &(x) + #endif +#endif + +#define MAP_LEN(x) x, sizeof(x) - 1 + +using namespace ::com::sun::star; + +using rtl::OUString; + +// ----------------------------------------------------------------------- + +ScXMLImportWrapper::ScXMLImportWrapper(ScDocument& rD, SfxMedium* pM, SvStorage* pS) : + rDoc(rD), + pMedium(pM), + pStorage(pS) +{ + DBG_ASSERT( pMedium || pStorage, "ScXMLImportWrapper: Medium or Storage must be set" ); +} + +uno::Reference <task::XStatusIndicator> ScXMLImportWrapper::GetStatusIndicator( + uno::Reference < frame::XModel> & rModel) +{ + uno::Reference<task::XStatusIndicator> xStatusIndicator; + if (rModel.is()) + { + uno::Reference<frame::XController> xController( rModel->getCurrentController()); + if( xController.is()) + { + uno::Reference<frame::XFrame> xFrame( xController->getFrame()); + if( xFrame.is()) + { + uno::Reference<task::XStatusIndicatorFactory> xFactory( xFrame, uno::UNO_QUERY ); + if( xFactory.is()) + { + try + { + xStatusIndicator = xFactory->createStatusIndicator(); + } + catch( lang::DisposedException e ) + { + DBG_ERROR("Exception while trying to get a Status Indicator"); + } + } + } + } + } + return xStatusIndicator; +} + +uno::Reference <task::XStatusIndicator> ScXMLImportWrapper::GetStatusIndicator() +{ + uno::Reference<task::XStatusIndicator> xStatusIndicator; + if (pMedium) + { + SfxItemSet* pSet = pMedium->GetItemSet(); + if (pSet) + { + const SfxUnoAnyItem* pItem = static_cast<const SfxUnoAnyItem*>(pSet->GetItem(SID_PROGRESS_STATUSBAR_CONTROL)); + if (pItem) + { + uno::Any aAny(pItem->GetValue()); + aAny >>= xStatusIndicator; + } + } + } + return xStatusIndicator; +} + +sal_uInt32 ScXMLImportWrapper::ImportFromComponent(uno::Reference<lang::XMultiServiceFactory>& xServiceFactory, + uno::Reference<frame::XModel>& xModel, uno::Reference<uno::XInterface>& xXMLParser, + xml::sax::InputSource& aParserInput, + const ::rtl::OUString& sComponentName, const ::rtl::OUString& sDocName, + const ::rtl::OUString& sOldDocName, uno::Sequence<uno::Any>& aArgs, + sal_Bool bMustBeSuccessfull) +{ + SvStorageStreamRef xDocStream; + if ( !pStorage && pMedium ) + pStorage = pMedium->GetStorage(); + + // Get data source ... + + uno::Reference< uno::XInterface > xPipe; + uno::Reference< io::XActiveDataSource > xSource; + + sal_Bool bEncrypted = sal_False; + if( pStorage ) + { + if (pStorage->IsStream(sDocName)) + xDocStream = pStorage->OpenStream( sDocName, + STREAM_READ | STREAM_NOCREATE ); + else if (sOldDocName.getLength() && pStorage->IsStream(sOldDocName)) + xDocStream = pStorage->OpenStream( sOldDocName, + STREAM_READ | STREAM_NOCREATE ); + else + return sal_False; + xDocStream->SetBufferSize( 16*1024 ); + aParserInput.aInputStream = xDocStream->GetXInputStream(); + + uno::Any aAny; + bEncrypted = xDocStream->GetProperty( + OUString( RTL_CONSTASCII_USTRINGPARAM("Encrypted") ), aAny ) && + aAny.getValueType() == ::getBooleanCppuType() && + *(sal_Bool *)aAny.getValue(); + } + // #99667#; no longer necessary +/* else if ( pMedium ) + { + // if there is a medium and if this medium has a load environment, + // we get an active data source from the medium. + pMedium->GetInStream()->Seek( 0 ); + xSource = pMedium->GetDataSource(); + DBG_ASSERT( xSource.is(), "got no data source from medium" ); + if( !xSource.is() ) + return sal_False; + + // get a pipe for connecting the data source to the parser + xPipe = xServiceFactory->createInstance( + OUString::createFromAscii("com.sun.star.io.Pipe") ); + DBG_ASSERT( xPipe.is(), + "XMLReader::Read: com.sun.star.io.Pipe service missing" ); + if( !xPipe.is() ) + return sal_False; + + // connect pipe's output stream to the data source + uno::Reference<io::XOutputStream> xPipeOutput( xPipe, uno::UNO_QUERY ); + xSource->setOutputStream( xPipeOutput ); + + aParserInput.aInputStream = + uno::Reference< io::XInputStream >( xPipe, uno::UNO_QUERY ); + }*/ + else + return SCERR_IMPORT_UNKNOWN; + + sal_uInt32 nReturn(0); + uno::Reference<xml::sax::XDocumentHandler> xDocHandler( + xServiceFactory->createInstanceWithArguments( + sComponentName, aArgs ), + uno::UNO_QUERY ); + DBG_ASSERT( xDocHandler.is(), "can't get Calc importer" ); + uno::Reference<document::XImporter> xImporter( xDocHandler, uno::UNO_QUERY ); + uno::Reference<lang::XComponent> xComponent( xModel, uno::UNO_QUERY ); + if (xImporter.is()) + xImporter->setTargetDocument( xComponent ); + + // connect parser and filter + uno::Reference<xml::sax::XParser> xParser( xXMLParser, uno::UNO_QUERY ); + xParser->setDocumentHandler( xDocHandler ); + + // parse + if( xSource.is() ) + { + uno::Reference<io::XActiveDataControl> xSourceControl( xSource, uno::UNO_QUERY ); + if( xSourceControl.is() ) + xSourceControl->start(); + } + + sal_Bool bFormatError = sal_False; + try + { + xParser->parseStream( aParserInput ); + } + catch( xml::sax::SAXParseException& r ) + { + if( bEncrypted ) + nReturn = ERRCODE_SFX_WRONGPASSWORD; + else + { + +#ifdef DBG_UTIL + ByteString aError( "SAX parse exception catched while importing:\n" ); + aError += ByteString( String( r.Message), RTL_TEXTENCODING_ASCII_US ); + DBG_ERROR( aError.GetBuffer() ); +#endif + + String sErr( String::CreateFromInt32( r.LineNumber )); + sErr += ','; + sErr += String::CreateFromInt32( r.ColumnNumber ); + + if( sDocName.getLength() ) + { + nReturn = *new TwoStringErrorInfo( + (bMustBeSuccessfull ? SCERR_IMPORT_FILE_ROWCOL + : SCWARN_IMPORT_FILE_ROWCOL), + sDocName, sErr, + ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR ); + } + else + { + DBG_ASSERT( bMustBeSuccessfull, "Warnings are not supported" ); + nReturn = *new StringErrorInfo( SCERR_IMPORT_FORMAT_ROWCOL, sErr, + ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR ); + } + } + } + catch( xml::sax::SAXException& r ) + { + if( bEncrypted ) + nReturn = ERRCODE_SFX_WRONGPASSWORD; + else + { + +#ifdef DBG_UTIL + ByteString aError( "SAX exception catched while importing:\n" ); + aError += ByteString( String( r.Message), RTL_TEXTENCODING_ASCII_US ); + DBG_ERROR( aError.GetBuffer() ); +#endif + nReturn = SCERR_IMPORT_FORMAT; + } + } + catch( packages::zip::ZipIOException& r ) + { +#ifdef DBG_UTIL + ByteString aError( "Zip exception catched while importing:\n" ); + aError += ByteString( String( r.Message), RTL_TEXTENCODING_ASCII_US ); + DBG_ERROR( aError.GetBuffer() ); +#endif + nReturn = ERRCODE_IO_BROKENPACKAGE; + } + catch( io::IOException& r ) + { +#ifdef DBG_UTIL + ByteString aError( "IO exception catched while importing:\n" ); + aError += ByteString( String( r.Message), RTL_TEXTENCODING_ASCII_US ); + DBG_ERROR( aError.GetBuffer() ); +#endif + nReturn = SCERR_IMPORT_OPEN; + } + catch( uno::Exception& r ) + { +#ifdef DBG_UTIL + ByteString aError( "uno exception catched while importing:\n" ); + aError += ByteString( String( r.Message), RTL_TEXTENCODING_ASCII_US ); + DBG_ERROR( aError.GetBuffer() ); +#endif + nReturn = SCERR_IMPORT_UNKNOWN; + } + + if ( xDocHandler.is() ) + { + ScXMLImport* pImport = static_cast<ScXMLImport*>(SvXMLImport::getImplementation(xDocHandler)); + + if (pImport && pImport->HasRangeOverflow() && !nReturn) + nReturn = pImport->GetRangeOverflowType(); + } + + // free the component + xParser->setDocumentHandler( NULL ); + + // success! + return nReturn; +} + +sal_Bool ScXMLImportWrapper::Import(sal_Bool bStylesOnly) +{ + RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "sb99857", "ScXMLImportWrapper::Import" ); + + uno::Reference<lang::XMultiServiceFactory> xServiceFactory = + ::legacy_binfilters::getLegacyProcessServiceFactory(); + DBG_ASSERT( xServiceFactory.is(), "got no service manager" ); + if( !xServiceFactory.is() ) + return sal_False; + + xml::sax::InputSource aParserInput; + if (pMedium) + aParserInput.sSystemId = OUString(pMedium->GetName()); + + + // get parser + uno::Reference<uno::XInterface> xXMLParser = + xServiceFactory->createInstance( + OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.sax.Parser" )) ); + DBG_ASSERT( xXMLParser.is(), "com.sun.star.xml.sax.Parser service missing" ); + if( !xXMLParser.is() ) + return sal_False; + + // get filter + SfxObjectShell* pObjSh = rDoc.GetDocumentShell(); + if ( pObjSh ) + { + ::rtl::OUString sEmpty; + uno::Reference<frame::XModel> xModel = pObjSh->GetModel(); + + /** property map for export info set */ + ::comphelper::PropertyMapEntry aImportInfoMap[] = + { + { MAP_LEN( "ProgressRange" ), 0, &::getCppuType((sal_Int32*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0}, + { MAP_LEN( "ProgressMax" ), 0, &::getCppuType((sal_Int32*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0}, + { MAP_LEN( "ProgressCurrent" ), 0, &::getCppuType((sal_Int32*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0}, + { MAP_LEN( "NumberStyles" ), 0, &::getCppuType((uno::Reference<container::XNameAccess> *)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0}, + { NULL, 0, 0, NULL, 0, 0 } + }; + uno::Reference< beans::XPropertySet > xInfoSet( comphelper::GenericPropertySet_CreateInstance( new comphelper::PropertySetInfo( aImportInfoMap ) ) ); + + uno::Reference<task::XStatusIndicator> xStatusIndicator(GetStatusIndicator()); + if (xStatusIndicator.is()) + { + sal_Int32 nProgressRange(1000000); + xStatusIndicator->start(::rtl::OUString(ScGlobal::GetRscString(STR_LOAD_DOC)), nProgressRange); + uno::Any aProgRange; + aProgRange <<= nProgressRange; + xInfoSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ProgressRange")), aProgRange); + } + + sal_uInt32 nMetaRetval(0); + if(!bStylesOnly) + { + uno::Sequence<uno::Any> aMetaArgs(1); + uno::Any* pMetaArgs = aMetaArgs.getArray(); + pMetaArgs[0] <<= xInfoSet; + + RTL_LOGFILE_CONTEXT_TRACE( aLog, "meta import start" ); + + nMetaRetval = ImportFromComponent(xServiceFactory, xModel, xXMLParser, aParserInput, + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Calc.XMLMetaImporter")), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("meta.xml")), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Meta.xml")), aMetaArgs, + sal_False); + + RTL_LOGFILE_CONTEXT_TRACE( aLog, "meta import end" ); + } + + SvXMLGraphicHelper* pGraphicHelper = NULL; + uno::Reference< document::XGraphicObjectResolver > xGrfContainer; + + uno::Reference< document::XEmbeddedObjectResolver > xObjectResolver; + SvXMLEmbeddedObjectHelper *pObjectHelper = NULL; + + if( pStorage ) + { + pGraphicHelper = SvXMLGraphicHelper::Create( *pStorage, GRAPHICHELPER_MODE_READ ); + xGrfContainer = pGraphicHelper; + + SvPersist *pPersist = pObjSh; + if( pPersist ) + { + pObjectHelper = SvXMLEmbeddedObjectHelper::Create(*pStorage, *pPersist, EMBEDDEDOBJECTHELPER_MODE_READ, sal_False ); + xObjectResolver = pObjectHelper; + } + } + uno::Sequence<uno::Any> aStylesArgs(4); + uno::Any* pStylesArgs = aStylesArgs.getArray(); + pStylesArgs[0] <<= xGrfContainer; + pStylesArgs[1] <<= xStatusIndicator; + pStylesArgs[2] <<= xObjectResolver; + pStylesArgs[3] <<= xInfoSet; + + sal_uInt32 nSettingsRetval(0); + if (!bStylesOnly) + { + // Settings must be loaded first because of the printer setting, + // which is needed in the page styles (paper tray). + + uno::Sequence<uno::Any> aSettingsArgs(0); + + RTL_LOGFILE_CONTEXT_TRACE( aLog, "settings import start" ); + + nSettingsRetval = ImportFromComponent(xServiceFactory, xModel, xXMLParser, aParserInput, + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Calc.XMLSettingsImporter")), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("settings.xml")), + sEmpty, aSettingsArgs, sal_False); + + RTL_LOGFILE_CONTEXT_TRACE( aLog, "settings import end" ); + } + + sal_uInt32 nStylesRetval(0); + { + RTL_LOGFILE_CONTEXT_TRACE( aLog, "styles import start" ); + + nStylesRetval = ImportFromComponent(xServiceFactory, xModel, xXMLParser, aParserInput, + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Calc.XMLStylesImporter")), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("styles.xml")), + sEmpty, aStylesArgs, sal_True); + + RTL_LOGFILE_CONTEXT_TRACE( aLog, "styles import end" ); + } + + sal_uInt32 nDocRetval(0); + if (!bStylesOnly) + { + uno::Sequence<uno::Any> aDocArgs(4); + uno::Any* pDocArgs = aDocArgs.getArray(); + pDocArgs[0] <<= xGrfContainer; + pDocArgs[1] <<= xStatusIndicator; + pDocArgs[2] <<= xObjectResolver; + pDocArgs[3] <<= xInfoSet; + + RTL_LOGFILE_CONTEXT_TRACE( aLog, "content import start" ); + + nDocRetval = ImportFromComponent(xServiceFactory, xModel, xXMLParser, aParserInput, + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Calc.XMLContentImporter")), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("content.xml")), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Content.xml")), aDocArgs, + sal_True); + + RTL_LOGFILE_CONTEXT_TRACE( aLog, "content import end" ); + } + if( pGraphicHelper ) + SvXMLGraphicHelper::Destroy( pGraphicHelper ); + + if( pObjectHelper ) + SvXMLEmbeddedObjectHelper::Destroy( pObjectHelper ); + + if (xStatusIndicator.is()) + xStatusIndicator->end(); + + sal_Bool bRet(sal_False); + if (bStylesOnly) + { + if (nStylesRetval) + pStorage->SetError(nStylesRetval); + else + bRet = sal_True; + } + else + { + if (nDocRetval) + { + pStorage->SetError(nDocRetval); + if (nDocRetval == SCWARN_IMPORT_RANGE_OVERFLOW || + nDocRetval == SCWARN_IMPORT_ROW_OVERFLOW || + nDocRetval == SCWARN_IMPORT_COLUMN_OVERFLOW || + nDocRetval == SCWARN_IMPORT_SHEET_OVERFLOW) + bRet = sal_True; + } + else if (nStylesRetval) + pStorage->SetError(nStylesRetval); + else if (nMetaRetval) + pStorage->SetError(nMetaRetval); + else if (nSettingsRetval) + pStorage->SetError(nSettingsRetval); + else + bRet = sal_True; + } + + // Don't test bStylesRetval and bMetaRetval, because it could be an older file which not contain such streams + return bRet;//!bStylesOnly ? bDocRetval : bStylesRetval; + } + return sal_False; +} + +sal_Bool ScXMLImportWrapper::ExportToComponent(uno::Reference<lang::XMultiServiceFactory>& xServiceFactory, + uno::Reference<frame::XModel>& xModel, uno::Reference<uno::XInterface>& xWriter, + uno::Sequence<beans::PropertyValue>& aDescriptor, const ::rtl::OUString& sName, + const ::rtl::OUString& sMediaType, const ::rtl::OUString& sComponentName, + const sal_Bool bPlainText, uno::Sequence<uno::Any>& aArgs, ScMySharedData*& pSharedData) +{ + sal_Bool bRet(sal_False); + uno::Reference<io::XOutputStream> xOut; + SvStorageStreamRef xStream; + + if( pStorage ) + { + // #96807#; trunc stream before use, because it could be an existing stream + // and the new content could be shorter than the old content. In this case + // would not all be over written by the new content and the xml file + // would not be valid. + xStream = pStorage->OpenStream( sName, + STREAM_WRITE | STREAM_SHARE_DENYWRITE | STREAM_TRUNC ); + uno::Any aAny; aAny <<= sMediaType; + xStream->SetProperty(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MediaType")), aAny); + if (bPlainText) + { + aAny = ::cppu::bool2any(sal_False); + xStream->SetProperty(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Compressed")), aAny); + } + else + { + aAny = ::cppu::bool2any(sal_True); + xStream->SetProperty(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Encrypted")), aAny); + } + xStream->SetBufferSize( 16*1024 ); + xOut = new ::utl::OOutputStreamWrapper( *xStream ); + } + // #99667#; no longer necessary +/* else if ( pMedium ) + { + xOut = pMedium->GetDataSink(); + }*/ + + uno::Reference<io::XActiveDataSource> xSrc( xWriter, uno::UNO_QUERY ); + xSrc->setOutputStream( xOut ); + + + uno::Reference<document::XFilter> xFilter( + xServiceFactory->createInstanceWithArguments( sComponentName , aArgs ), + uno::UNO_QUERY ); + DBG_ASSERT( xFilter.is(), "can't get exporter" ); + uno::Reference<document::XExporter> xExporter( xFilter, uno::UNO_QUERY ); + uno::Reference<lang::XComponent> xComponent( xModel, uno::UNO_QUERY ); + if (xExporter.is()) + xExporter->setSourceDocument( xComponent ); + + if ( xFilter.is() ) + { + ScXMLExport* pExport = static_cast<ScXMLExport*>(SvXMLExport::getImplementation(xFilter)); + pExport->SetSharedData(pSharedData); + bRet = xFilter->filter( aDescriptor ); + pSharedData = pExport->GetSharedData(); + + if (xStream.Is()) + xStream->Commit(); + } + return bRet; +} + +sal_Bool ScXMLImportWrapper::Export(sal_Bool bStylesOnly) +{ + RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "sb99857", "ScXMLImportWrapper::Export" ); + + uno::Reference<lang::XMultiServiceFactory> xServiceFactory = + ::legacy_binfilters::getLegacyProcessServiceFactory(); + DBG_ASSERT( xServiceFactory.is(), "got no service manager" ); + if( !xServiceFactory.is() ) + return sal_False; + + uno::Reference<uno::XInterface> xWriter = + xServiceFactory->createInstance( + OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.sax.Writer" )) ); + DBG_ASSERT( xWriter.is(), "com.sun.star.xml.sax.Writer service missing" ); + if(!xWriter.is()) + return sal_False; + + if ( !pStorage && pMedium ) + pStorage = pMedium->GetOutputStorage( sal_True ); + + uno::Reference<xml::sax::XDocumentHandler> xHandler( xWriter, uno::UNO_QUERY ); + + OUString sFileName; + OUString sTextMediaType(RTL_CONSTASCII_USTRINGPARAM("text/xml")); + if (pMedium) + sFileName = pMedium->GetName(); + SfxObjectShell* pObjSh = rDoc.GetDocumentShell(); + uno::Sequence<beans::PropertyValue> aDescriptor(1); + beans::PropertyValue* pProps = aDescriptor.getArray(); + pProps[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "FileName" ) ); + pProps[0].Value <<= sFileName; + + /** property map for export info set */ + ::comphelper::PropertyMapEntry aExportInfoMap[] = + { + { MAP_LEN( "ProgressRange" ), 0, &::getCppuType((sal_Int32*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0}, + { MAP_LEN( "ProgressMax" ), 0, &::getCppuType((sal_Int32*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0}, + { MAP_LEN( "ProgressCurrent" ), 0, &::getCppuType((sal_Int32*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0}, + { MAP_LEN( "WrittenNumberStyles" ), 0, &::getCppuType((uno::Sequence<sal_Int32>*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0}, + { MAP_LEN( "UsePrettyPrinting" ), 0, &::getCppuType((sal_Bool*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0}, + { NULL, 0, 0, NULL, 0, 0 } + }; + uno::Reference< beans::XPropertySet > xInfoSet( comphelper::GenericPropertySet_CreateInstance( new comphelper::PropertySetInfo( aExportInfoMap ) ) ); + + if ( pObjSh && pStorage) + { + pObjSh->UpdateDocInfoForSave(); // update information + + uno::Reference<frame::XModel> xModel = pObjSh->GetModel(); + uno::Reference<task::XStatusIndicator> xStatusIndicator = GetStatusIndicator(xModel); + sal_Int32 nProgressRange(1000000); + if(xStatusIndicator.is()) + xStatusIndicator->start(::rtl::OUString(ScGlobal::GetRscString(STR_SAVE_DOC)), nProgressRange); + uno::Any aProgRange; + aProgRange <<= nProgressRange; + xInfoSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ProgressRange")), aProgRange); + + SvtSaveOptions aSaveOpt; + sal_Bool bUsePrettyPrinting(aSaveOpt.IsPrettyPrinting()); + uno::Any aUsePrettyPrinting; + aUsePrettyPrinting <<= bUsePrettyPrinting; + xInfoSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UsePrettyPrinting")), aUsePrettyPrinting); + + sal_Bool bMetaRet(pObjSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED); + sal_Bool bStylesRet (sal_False); + sal_Bool bDocRet(sal_False); + sal_Bool bSettingsRet(sal_False); + ScMySharedData* pSharedData = NULL; + + // meta export + if (!bStylesOnly && !bMetaRet) + { + uno::Sequence<uno::Any> aMetaArgs(3); + uno::Any* pMetaArgs = aMetaArgs.getArray(); + pMetaArgs[0] <<= xHandler; + pMetaArgs[1] <<= xStatusIndicator; + pMetaArgs[2] <<= xInfoSet; + + RTL_LOGFILE_CONTEXT_TRACE( aLog, "meta export start" ); + + bMetaRet = ExportToComponent(xServiceFactory, xModel, xWriter, aDescriptor, + ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("meta.xml")), + sTextMediaType, ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Calc.XMLMetaExporter")), + sal_True, aMetaArgs, pSharedData); + + RTL_LOGFILE_CONTEXT_TRACE( aLog, "meta export end" ); + } + + uno::Reference< document::XEmbeddedObjectResolver > xObjectResolver; + SvXMLEmbeddedObjectHelper *pObjectHelper = 0; + + uno::Reference< document::XGraphicObjectResolver > xGrfContainer; + SvXMLGraphicHelper* pGraphicHelper = 0; + + if( pStorage ) + { + pGraphicHelper = SvXMLGraphicHelper::Create( *pStorage, GRAPHICHELPER_MODE_WRITE, FALSE ); + xGrfContainer = pGraphicHelper; + } + + SvPersist *pPersist = pObjSh; + if( pPersist ) + { + pObjectHelper = SvXMLEmbeddedObjectHelper::Create( *pStorage, *pPersist, EMBEDDEDOBJECTHELPER_MODE_WRITE, sal_False ); + xObjectResolver = pObjectHelper; + } + + // styles export + + { + uno::Sequence<uno::Any> aStylesArgs(5); + uno::Any* pStylesArgs = aStylesArgs.getArray(); + pStylesArgs[0] <<= xGrfContainer; + pStylesArgs[1] <<= xStatusIndicator; + pStylesArgs[2] <<= xHandler; + pStylesArgs[3] <<= xObjectResolver; + pStylesArgs[4] <<= xInfoSet; + + RTL_LOGFILE_CONTEXT_TRACE( aLog, "styles export start" ); + + bStylesRet = ExportToComponent(xServiceFactory, xModel, xWriter, aDescriptor, + ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("styles.xml")), + sTextMediaType, ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Calc.XMLStylesExporter")), + sal_False, aStylesArgs, pSharedData); + + RTL_LOGFILE_CONTEXT_TRACE( aLog, "styles export end" ); + } + + // content export + + if (!bStylesOnly) + { + uno::Sequence<uno::Any> aDocArgs(5); + uno::Any* pDocArgs = aDocArgs.getArray(); + pDocArgs[0] <<= xGrfContainer; + pDocArgs[1] <<= xStatusIndicator; + pDocArgs[2] <<= xHandler; + pDocArgs[3] <<= xObjectResolver; + pDocArgs[4] <<= xInfoSet; + + RTL_LOGFILE_CONTEXT_TRACE( aLog, "content export start" ); + + bDocRet = ExportToComponent(xServiceFactory, xModel, xWriter, aDescriptor, + ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("content.xml")), + sTextMediaType, ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Calc.XMLContentExporter")), + sal_False, aDocArgs, pSharedData); + + RTL_LOGFILE_CONTEXT_TRACE( aLog, "content export end" ); + } + + if( pGraphicHelper ) + SvXMLGraphicHelper::Destroy( pGraphicHelper ); + + if( pObjectHelper ) + SvXMLEmbeddedObjectHelper::Destroy( pObjectHelper ); + + // settings export + + if (!bStylesOnly) + { + uno::Sequence<uno::Any> aSettingsArgs(3); + uno::Any* pSettingsArgs = aSettingsArgs.getArray(); + pSettingsArgs[0] <<= xHandler; + pSettingsArgs[1] <<= xStatusIndicator; + pSettingsArgs[2] <<= xInfoSet; + + RTL_LOGFILE_CONTEXT_TRACE( aLog, "settings export start" ); + + bSettingsRet = ExportToComponent(xServiceFactory, xModel, xWriter, aDescriptor, + ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("settings.xml")), + sTextMediaType, ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Calc.XMLSettingsExporter")), + sal_False, aSettingsArgs, pSharedData); + + RTL_LOGFILE_CONTEXT_TRACE( aLog, "settings export end" ); + } + + if (pSharedData) + delete pSharedData; + + if (xStatusIndicator.is()) + xStatusIndicator->end(); + return bStylesRet && ((!bStylesOnly && bDocRet && bMetaRet && bSettingsRet) || bStylesOnly); + } + + // later: give string descriptor as parameter for doc type + + return sal_False; +} + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/xmlannoi.hxx b/binfilter/bf_sc/source/filter/xml/xmlannoi.hxx new file mode 100644 index 000000000000..925fbb7e03ef --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/xmlannoi.hxx @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef SC_XMLANNOI_HXX +#define SC_XMLANNOI_HXX + +#include <bf_xmloff/xmlictxt.hxx> +#include <bf_xmloff/xmlimp.hxx> +#include <rtl/ustrbuf.hxx> +namespace binfilter { + +class ScXMLImport; +class ScXMLTableRowCellContext; + +class ScXMLAnnotationContext : public SvXMLImportContext +{ + ::rtl::OUStringBuffer sOUText; + ::rtl::OUString sAuthor; + ::rtl::OUString sCreateDate; + sal_Int32 nParagraphCount; + sal_Bool bDisplay : 1; + sal_Bool bHasTextP : 1; + ScXMLTableRowCellContext* pCellContext; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLAnnotationContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLTableRowCellContext* pCellContext); + + virtual ~ScXMLAnnotationContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void Characters( const ::rtl::OUString& rChars ); + + virtual void EndElement(); +}; + + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/xmlbodyi.hxx b/binfilter/bf_sc/source/filter/xml/xmlbodyi.hxx new file mode 100644 index 000000000000..d30b70a93c7c --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/xmlbodyi.hxx @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SC_XMLBODYI_HXX +#define SC_XMLBODYI_HXX + +#include <bf_xmloff/xmlictxt.hxx> + +#include <bf_xmloff/xmlimp.hxx> +namespace binfilter { + +class ScXMLImport; +class ScXMLChangeTrackingImportHelper; + +class ScXMLBodyContext : public SvXMLImportContext +{ + ::rtl::OUString sPassword; + sal_Bool bProtected : 1; + + ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper; + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + ScXMLBodyContext( ScXMLImport& rImport, USHORT nPrfx, const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + virtual ~ScXMLBodyContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + virtual void EndElement(); +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/xmlcelli.hxx b/binfilter/bf_sc/source/filter/xml/xmlcelli.hxx new file mode 100644 index 000000000000..64249f8d1d34 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/xmlcelli.hxx @@ -0,0 +1,143 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef SC_XMLCELLI_HXX +#define SC_XMLCELLI_HXX + +#include "XMLDetectiveContext.hxx" +#include "XMLCellRangeSourceContext.hxx" + +#include <bf_xmloff/xmlictxt.hxx> + +#include <bf_xmloff/xmlimp.hxx> +#include <com/sun/star/table/XCell.hpp> +#include <tools/time.hxx> +#include <com/sun/star/util/DateTime.hpp> +#include <sal/types.h> +#include <com/sun/star/table/XCellRange.hpp> +#include <com/sun/star/table/CellRangeAddress.hpp> +#include <com/sun/star/table/CellAddress.hpp> +#include <com/sun/star/sheet/XSpreadsheetDocument.hpp> +#include <com/sun/star/document/XActionLockable.hpp> +namespace binfilter { + +class ScXMLImport; + +struct ScMyImportAnnotation +{ + ::rtl::OUString sAuthor; + ::rtl::OUString sCreateDate; + ::rtl::OUString sText; + sal_Bool bDisplay : 1; +}; + +class ScXMLTableRowCellContext : public SvXMLImportContext +{ + ::com::sun::star::uno::Reference< ::com::sun::star::table::XCell> xBaseCell; + ::com::sun::star::uno::Reference< ::com::sun::star::document::XActionLockable> xLockable; + ::rtl::OUString* pOUTextValue; + ::rtl::OUString* pOUTextContent; + ::rtl::OUString* pOUFormula; + ::rtl::OUString* pContentValidationName; + ScMyImportAnnotation* pMyAnnotation; + ScMyImpDetectiveObjVec* pDetectiveObjVec; + ScMyImpCellRangeSource* pCellRangeSource; + double fValue; + sal_Int32 nMergedRows, nMergedCols; + sal_Int32 nMatrixRows, nMatrixCols; + sal_Int32 nRepeatedRows; + sal_Int32 nCellsRepeated; + ScXMLImport& rXMLImport; + sal_Int16 nCellType; + sal_Bool bIsMerged : 1; + sal_Bool bIsMatrix : 1; + sal_Bool bHasSubTable : 1; + sal_Bool bIsCovered : 1; + sal_Bool bIsEmpty : 1; + sal_Bool bHasTextImport : 1; + sal_Bool bIsFirstTextImport : 1; + sal_Bool bSolarMutexLocked : 1; + sal_Bool bFormulaTextResult : 1; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + + sal_Int16 GetCellType(const ::rtl::OUString& sOUValue) const; + + sal_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 DoMerge(const ::com::sun::star::table::CellAddress& aCellPos, + const sal_Int32 nCols, const sal_Int32 nRows); + + void SetContentValidation(::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& xPropSet); + void SetCellProperties(const ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange>& xCellRange, + const ::com::sun::star::table::CellAddress& aCellAddress); + void SetCellProperties(const ::com::sun::star::uno::Reference< ::com::sun::star::table::XCell>& xCell); + + void LockSolarMutex(); + void UnlockSolarMutex(); + + sal_Bool CellExists(const ::com::sun::star::table::CellAddress& aCellPos) const + { + return (aCellPos.Column <= MAXCOL && aCellPos.Row <= MAXROW); + } + +public: + + ScXMLTableRowCellContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + const sal_Bool bIsCovered, const sal_Int32 nRepeatedRows ); + + virtual ~ScXMLTableRowCellContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + void SetString(const ::rtl::OUString& rOUTempText) { + if (pOUTextContent) + delete pOUTextContent; + pOUTextContent = new ::rtl::OUString(rOUTempText); } + void SetCursorOnTextImport(const ::rtl::OUString& rOUTempText); + + void SetAnnotation(const ::com::sun::star::uno::Reference< ::com::sun::star::table::XCell>& xCell); + void SetDetectiveObj( const ::com::sun::star::table::CellAddress& rPosition ); + void SetCellRangeSource( const ::com::sun::star::table::CellAddress& rPosition ); + + virtual void EndElement(); + + void AddAnnotation(ScMyImportAnnotation* pValue) { pMyAnnotation = pValue; } +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/xmlcoli.hxx b/binfilter/bf_sc/source/filter/xml/xmlcoli.hxx new file mode 100644 index 000000000000..b4deb8f5bc34 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/xmlcoli.hxx @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef SC_XMLCOLI_HXX +#define SC_XMLCOLI_HXX + +#include <bf_xmloff/xmlictxt.hxx> + +#include <bf_xmloff/xmlimp.hxx> +namespace binfilter { + +class ScXMLImport; + +class ScXMLTableColContext : public SvXMLImportContext +{ + sal_Int32 nColCount; + ::rtl::OUString sStyleName; + ::rtl::OUString sVisibility; + ::rtl::OUString sCellStyleName; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLTableColContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual ~ScXMLTableColContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +class ScXMLTableColsContext : public SvXMLImportContext +{ + sal_Int32 nHeaderStartCol; + sal_Int32 nHeaderEndCol; + sal_Int32 nGroupStartCol; + sal_Int32 nGroupEndCol; + sal_Bool bHeader : 1; + sal_Bool bGroup : 1; + sal_Bool bGroupDisplay : 1; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLTableColsContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + const sal_Bool bHeader, const sal_Bool bGroup); + + virtual ~ScXMLTableColsContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/xmlconti.hxx b/binfilter/bf_sc/source/filter/xml/xmlconti.hxx new file mode 100644 index 000000000000..98840e9c2cdc --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/xmlconti.hxx @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef SC_XMLCONTI_HXX +#define SC_XMLCONTI_HXX + +#include <bf_xmloff/xmlimp.hxx> +#include <rtl/ustrbuf.hxx> + +namespace binfilter { + +class ScXMLImport; + +class ScXMLContentContext : public SvXMLImportContext +{ + ::rtl::OUStringBuffer sOUText; + ::rtl::OUStringBuffer& sValue; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLContentContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ::rtl::OUStringBuffer& sValue); + + virtual ~ScXMLContentContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void Characters( const ::rtl::OUString& rChars ); + + virtual void EndElement(); +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/xmlcvali.hxx b/binfilter/bf_sc/source/filter/xml/xmlcvali.hxx new file mode 100644 index 000000000000..26e802f9a333 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/xmlcvali.hxx @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef SC_XMLCVALI_HXX +#define SC_XMLCVALI_HXX + +#include <bf_xmloff/xmlictxt.hxx> + +#include <bf_xmloff/xmlimp.hxx> +#include <com/sun/star/sheet/ValidationAlertStyle.hpp> +#include <com/sun/star/sheet/ValidationType.hpp> +#include <com/sun/star/sheet/ConditionOperator.hpp> +#include <rtl/ustrbuf.hxx> +namespace binfilter { + +class ScXMLImport; + +class ScXMLContentValidationsContext : public SvXMLImportContext +{ + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLContentValidationsContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList); + + virtual ~ScXMLContentValidationsContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/xmldpimp.hxx b/binfilter/bf_sc/source/filter/xml/xmldpimp.hxx new file mode 100644 index 000000000000..08c13fb839d3 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/xmldpimp.hxx @@ -0,0 +1,443 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef SC_XMLDPIMP_HXX +#define SC_XMLDPIMP_HXX + +#include <bf_xmloff/xmlictxt.hxx> +#include <bf_xmloff/xmlimp.hxx> + +#include "global.hxx" +#include "dpobject.hxx" +#include "dpsave.hxx" +namespace binfilter { + +class ScXMLImport; + +enum ScMySourceType +{ + SQL, + TABLE, + QUERY, + SERVICE, + CELLRANGE +}; + +class ScXMLDataPilotTablesContext : public SvXMLImportContext +{ + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLDataPilotTablesContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList); + + virtual ~ScXMLDataPilotTablesContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +class ScXMLDataPilotTableContext : public SvXMLImportContext +{ + ScDocument* pDoc; + ScDPObject* pDPObject; + ScDPSaveData* pDPSave; + ::rtl::OUString sDataPilotTableName; + ::rtl::OUString sApplicationData; + ::rtl::OUString sGrandTotal; + ::rtl::OUString sDatabaseName; + ::rtl::OUString sSourceObject; + ::rtl::OUString sServiceName; + ::rtl::OUString sServiceSourceName; + ::rtl::OUString sServiceSourceObject; + ::rtl::OUString sServiceUsername; + ::rtl::OUString sServicePassword; + ::rtl::OUString sButtons; + ScRange aSourceCellRangeAddress; + ScRange aTargetRangeAddress; + ScRange aFilterSourceRange; + ScAddress aFilterOutputPosition; + ScQueryParam aSourceQueryParam; + ScMySourceType nSourceType; + sal_Bool bIsNative : 1; + sal_Bool bIgnoreEmptyRows : 1; + sal_Bool bIdentifyCategories : 1; + sal_Bool bUseRegularExpression : 1; + sal_Bool bIsCaseSensitive : 1; + sal_Bool bSkipDuplicates : 1; + sal_Bool bFilterCopyOutputData : 1; + sal_Bool bTargetRangeAddress : 1; + sal_Bool bSourceCellRange : 1; + + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLDataPilotTableContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList); + + virtual ~ScXMLDataPilotTableContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); + + void SetDatabaseName(const ::rtl::OUString& sValue) { sDatabaseName = sValue; } + void SetSourceObject(const ::rtl::OUString& sValue) { sSourceObject = sValue; } + void SetNative(const sal_Bool bValue) { bIsNative = bValue; } + void SetServiceName(const ::rtl::OUString& sValue) { sServiceName = sValue; } + void SetServiceSourceName(const ::rtl::OUString& sValue) { sServiceSourceName = sValue; } + void SetServiceSourceObject(const ::rtl::OUString& sValue) { sServiceSourceObject = sValue; } + void SetServiceUsername(const ::rtl::OUString& sValue) { sServiceUsername = sValue; } + void SetServicePassword(const ::rtl::OUString& sValue) { sServicePassword = sValue; } + void SetSourceCellRangeAddress(const ScRange& aValue) { aSourceCellRangeAddress = aValue; bSourceCellRange = sal_True; } + void SetSourceQueryParam(const ScQueryParam& aValue) { aSourceQueryParam = aValue; } +// void SetFilterUseRegularExpressions(const sal_Bool bValue) { aSourceQueryParam.bRegExp = bValue; } + void SetFilterOutputPosition(const ScAddress& aValue) { aFilterOutputPosition = aValue; } + void SetFilterCopyOutputData(const sal_Bool bValue) { bFilterCopyOutputData = bValue; } + void SetFilterSourceRange(const ScRange& aValue) { aFilterSourceRange = aValue; } +// void SetFilterIsCaseSensitive(const sal_Bool bValue) { aSourceQueryParam.bCaseSens = bValue; } +// void SetFilterSkipDuplicates(const sal_Bool bValue) { aSourceQueryParam.bDuplicate = !bValue; } + void AddDimension(ScDPSaveDimension* pDim); + void SetButtons(); +}; + +class ScXMLDPSourceSQLContext : public SvXMLImportContext +{ + ScXMLDataPilotTableContext* pDataPilotTable; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLDPSourceSQLContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDataPilotTableContext* pDataPilotTable); + + virtual ~ScXMLDPSourceSQLContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +class ScXMLDPSourceTableContext : public SvXMLImportContext +{ + ScXMLDataPilotTableContext* pDataPilotTable; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLDPSourceTableContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDataPilotTableContext* pDataPilotTable); + + virtual ~ScXMLDPSourceTableContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +class ScXMLDPSourceQueryContext : public SvXMLImportContext +{ + ScXMLDataPilotTableContext* pDataPilotTable; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLDPSourceQueryContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDataPilotTableContext* pDataPilotTable); + + virtual ~ScXMLDPSourceQueryContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +class ScXMLSourceServiceContext : public SvXMLImportContext +{ + ScXMLDataPilotTableContext* pDataPilotTable; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLSourceServiceContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDataPilotTableContext* pDataPilotTable); + + virtual ~ScXMLSourceServiceContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +class ScXMLSourceCellRangeContext : public SvXMLImportContext +{ + ScXMLDataPilotTableContext* pDataPilotTable; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLSourceCellRangeContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDataPilotTableContext* pDataPilotTable); + + virtual ~ScXMLSourceCellRangeContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +class ScXMLDataPilotFieldContext : public SvXMLImportContext +{ + ScXMLDataPilotTableContext* pDataPilotTable; + ScDPSaveDimension* pDim; + + sal_Int32 nUsedHierarchy; + sal_Int16 nFunction; + sal_Int16 nOrientation; + sal_Bool bShowEmpty : 1; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLDataPilotFieldContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDataPilotTableContext* pDataPilotTable); + + virtual ~ScXMLDataPilotFieldContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); + + void SetShowEmpty(const sal_Bool bValue) { if (pDim) pDim->SetShowEmpty(bValue); } + void SetSubTotals(const sal_uInt16* pFunctions, const sal_Int16 nCount) { if(pDim) pDim->SetSubTotals(nCount, pFunctions); } + void AddMember(ScDPSaveMember* pMember) { if (pDim) pDim->AddMember(pMember); } +}; + +class ScXMLDataPilotLevelContext : public SvXMLImportContext +{ + ScXMLDataPilotFieldContext* pDataPilotField; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLDataPilotLevelContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDataPilotFieldContext* pDataPilotField); + + virtual ~ScXMLDataPilotLevelContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +class ScXMLDataPilotSubTotalsContext : public SvXMLImportContext +{ + ScXMLDataPilotFieldContext* pDataPilotField; + + sal_Int16 nFunctionCount; + sal_uInt16* pFunctions; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLDataPilotFieldContext* GetDataPilotField() { return pDataPilotField; } + + ScXMLDataPilotSubTotalsContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDataPilotFieldContext* pDataPilotField); + + virtual ~ScXMLDataPilotSubTotalsContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); + void AddFunction(sal_Int16 nFunction); +}; + +class ScXMLDataPilotSubTotalContext : public SvXMLImportContext +{ + ScXMLDataPilotSubTotalsContext* pDataPilotSubTotals; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLDataPilotSubTotalContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDataPilotSubTotalsContext* pDataPilotSubTotals); + + virtual ~ScXMLDataPilotSubTotalContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +class ScXMLDataPilotMembersContext : public SvXMLImportContext +{ + ScXMLDataPilotFieldContext* pDataPilotField; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLDataPilotMembersContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDataPilotFieldContext* pDataPilotField); + + virtual ~ScXMLDataPilotMembersContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +class ScXMLDataPilotMemberContext : public SvXMLImportContext +{ + ScXMLDataPilotFieldContext* pDataPilotField; + + ::rtl::OUString sName; + sal_Bool bDisplay : 1; + sal_Bool bDisplayDetails : 1; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLDataPilotMemberContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDataPilotFieldContext* pDataPilotField); + + virtual ~ScXMLDataPilotMemberContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/xmldrani.hxx b/binfilter/bf_sc/source/filter/xml/xmldrani.hxx new file mode 100644 index 000000000000..8cea675ea2ac --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/xmldrani.hxx @@ -0,0 +1,328 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef SC_XMLDRANI_HXX +#define SC_XMLDRANI_HXX + +#include <bf_xmloff/xmlictxt.hxx> +#include <bf_xmloff/xmlimp.hxx> +#include <com/sun/star/sheet/DataImportMode.hpp> +#include <com/sun/star/sheet/SubTotalColumn.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/sheet/TableFilterField.hpp> +#include <com/sun/star/table/CellAddress.hpp> +#include <com/sun/star/table/CellRangeAddress.hpp> +#include <com/sun/star/table/TableOrientation.hpp> +namespace binfilter { + +class ScXMLImport; + +class ScXMLDatabaseRangesContext : public SvXMLImportContext +{ + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLDatabaseRangesContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList); + + virtual ~ScXMLDatabaseRangesContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +class ScXMLDatabaseRangeContext : public SvXMLImportContext +{ + ::rtl::OUString sDatabaseRangeName; + ::rtl::OUString sRangeAddress; + ::rtl::OUString sDatabaseName; + ::rtl::OUString sSourceObject; + ::com::sun::star::uno::Sequence < ::com::sun::star::sheet::SubTotalColumn> aSubTotalColumns; + ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue> aSortSequence; + ::com::sun::star::uno::Sequence < ::com::sun::star::sheet::TableFilterField> aFilterFields; + ::com::sun::star::table::CellAddress aFilterOutputPosition; + ::com::sun::star::table::CellRangeAddress aFilterConditionSourceRangeAddress; + ::com::sun::star::sheet::DataImportMode nSourceType; + ::com::sun::star::table::TableOrientation eOrientation; + sal_Int32 nRefresh; + sal_Int16 nSubTotalsUserListIndex; + sal_Int16 nSubTotalRuleGroupFieldNumber; + sal_Bool bContainsSort : 1; + sal_Bool bContainsSubTotal : 1; + sal_Bool bNative : 1; + sal_Bool bIsSelection : 1; + sal_Bool bKeepFormats : 1; + sal_Bool bMoveCells : 1; + sal_Bool bStripData : 1; + sal_Bool bContainsHeader : 1; + sal_Bool bAutoFilter : 1; + sal_Bool bSubTotalsBindFormatsToContent : 1; + sal_Bool bSubTotalsIsCaseSensitive : 1; + sal_Bool bSubTotalsInsertPageBreaks : 1; + sal_Bool bSubTotalsSortGroups : 1; + sal_Bool bSubTotalsEnabledUserList : 1; + sal_Bool bSubTotalsAscending : 1; + sal_Bool bFilterCopyOutputData : 1; + sal_Bool bFilterIsCaseSensitive : 1; + sal_Bool bFilterSkipDuplicates : 1; + sal_Bool bFilterUseRegularExpressions : 1; + sal_Bool bFilterConditionSourceRange : 1; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLDatabaseRangeContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList); + + virtual ~ScXMLDatabaseRangeContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); + + void SetDatabaseName(const ::rtl::OUString sTempDatabaseName) { sDatabaseName = sTempDatabaseName; } + void SetSourceObject(const ::rtl::OUString sTempSourceObject) { sSourceObject = sTempSourceObject; } + void SetSourceType(const ::com::sun::star::sheet::DataImportMode nTempSourceType) { nSourceType = nTempSourceType; } + void SetNative(const sal_Bool bTempNative) { bNative = bTempNative; } + void SetSubTotalsBindFormatsToContent(const sal_Bool bTemp ) { bSubTotalsBindFormatsToContent = bTemp; } + void SetSubTotalsIsCaseSensitive(const sal_Bool bTemp) { bSubTotalsIsCaseSensitive = bTemp; } + void SetSubTotalsInsertPageBreaks(const sal_Bool bTemp) { bSubTotalsInsertPageBreaks = bTemp; } + void SetSubTotalsEnabledUserList(const sal_Bool bTemp) { bSubTotalsEnabledUserList = bTemp; } + void SetSubTotalsUserListIndex(const sal_Int16 nTemp) { nSubTotalsUserListIndex = nTemp; } + void SetSubTotalsAscending(const sal_Bool bTemp) { bSubTotalsAscending = bTemp; } + void SetSubTotalsSortGroups(const sal_Bool bTemp) { bSubTotalsSortGroups = bTemp; } + void SetSubTotalRuleGroupFieldNumber(const sal_Int16 nTemp) { nSubTotalRuleGroupFieldNumber = nTemp; } + void AddSubTotalColumn(const ::com::sun::star::sheet::SubTotalColumn aSubTotalColumn) + { aSubTotalColumns.realloc(aSubTotalColumns.getLength() + 1); aSubTotalColumns[aSubTotalColumns.getLength() - 1] = aSubTotalColumn; } + void SetSortSequence(const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue>& aTempSortSequence) { aSortSequence = aTempSortSequence; } + void SetFilterCopyOutputData(const sal_Bool bTemp) { bFilterCopyOutputData = bTemp; } + void SetFilterIsCaseSensitive(const sal_Bool bTemp) { bFilterIsCaseSensitive = bTemp; } + void SetFilterSkipDuplicates(const sal_Bool bTemp) { bFilterSkipDuplicates = bTemp; } + void SetFilterUseRegularExpressions(const sal_Bool bTemp) { bFilterUseRegularExpressions = bTemp; } + void SetFilterFields(const ::com::sun::star::uno::Sequence < ::com::sun::star::sheet::TableFilterField>& aTemp) { aFilterFields = aTemp; } + void SetFilterOutputPosition(const ::com::sun::star::table::CellAddress& aTemp) { aFilterOutputPosition = aTemp; } + void SetFilterConditionSourceRangeAddress(const ::com::sun::star::table::CellRangeAddress& aTemp) { aFilterConditionSourceRangeAddress = aTemp; + bFilterConditionSourceRange = sal_True; } +}; + +class ScXMLSourceSQLContext : public SvXMLImportContext +{ + ScXMLDatabaseRangeContext* pDatabaseRangeContext; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLSourceSQLContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDatabaseRangeContext* pTempDatabaseRangeContext); + + virtual ~ScXMLSourceSQLContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +class ScXMLSourceTableContext : public SvXMLImportContext +{ + ScXMLDatabaseRangeContext* pDatabaseRangeContext; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLSourceTableContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDatabaseRangeContext* pTempDatabaseRangeContext); + + virtual ~ScXMLSourceTableContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +class ScXMLSourceQueryContext : public SvXMLImportContext +{ + ScXMLDatabaseRangeContext* pDatabaseRangeContext; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLSourceQueryContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDatabaseRangeContext* pTempDatabaseRangeContext); + + virtual ~ScXMLSourceQueryContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +class ScXMLSubTotalRulesContext : public SvXMLImportContext +{ + ScXMLDatabaseRangeContext* pDatabaseRangeContext; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLSubTotalRulesContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDatabaseRangeContext* pTempDatabaseRangeContext); + + virtual ~ScXMLSubTotalRulesContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +class ScXMLSortGroupsContext : public SvXMLImportContext +{ + ScXMLDatabaseRangeContext* pDatabaseRangeContext; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLSortGroupsContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDatabaseRangeContext* pTempDatabaseRangeContext); + + virtual ~ScXMLSortGroupsContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +class ScXMLSubTotalRuleContext : public SvXMLImportContext +{ + ScXMLDatabaseRangeContext* pDatabaseRangeContext; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLSubTotalRuleContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDatabaseRangeContext* pTempDatabaseRangeContext); + + virtual ~ScXMLSubTotalRuleContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +class ScXMLSubTotalFieldContext : public SvXMLImportContext +{ + ScXMLDatabaseRangeContext* pDatabaseRangeContext; + ::rtl::OUString sFieldNumber; + ::rtl::OUString sFunction; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLSubTotalFieldContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDatabaseRangeContext* pTempDatabaseRangeContext); + + virtual ~ScXMLSubTotalFieldContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/xmlexprt.hxx b/binfilter/bf_sc/source/filter/xml/xmlexprt.hxx new file mode 100644 index 000000000000..817137745398 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/xmlexprt.hxx @@ -0,0 +1,252 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SC_XMLEXPRT_HXX +#define SC_XMLEXPRT_HXX + +#include <bf_xmloff/xmlexp.hxx> + +#include <com/sun/star/sheet/XSpreadsheet.hpp> +#include <com/sun/star/sheet/XSpreadsheetDocument.hpp> +#include <com/sun/star/table/CellRangeAddress.hpp> +#include <com/sun/star/table/CellAddress.hpp> +#include <com/sun/star/drawing/XShapes.hdl> +namespace binfilter { + +class SfxItemPool; +class ScOutlineArray; +class ScMyShapesContainer; +class ScMyMergedRangesContainer; +class ScMyValidationsContainer; +class ScMyNotEmptyCellsIterator; +class ScChangeTrackingExportHelper; +class ScColumnStyles; +class ScRowStyles; +class ScFormatRangeStyles; +class ScRowFormatRanges; +class ScMyOpenCloseColumnRowGroup; +class ScMyAreaLinksContainer; +class ScMyDetectiveOpContainer; +struct ScMyCell; +class ScDocument; +class ScMySharedData; +class ScMyDefaultStyles; +class ScChartListener; +class SvXMLExportPropertyMapper; +class XMLNumberFormatAttributesExportHelper; + +typedef std::vector< ::com::sun::star::uno::Reference < ::com::sun::star::drawing::XShapes > > ScMyXShapesVec; + +class ScXMLExport : public SvXMLExport +{ + ScDocument* pDoc; + ::com::sun::star::uno::Reference < ::com::sun::star::sheet::XSpreadsheet> xCurrentTable; + + UniReference < XMLPropertyHandlerFactory > xScPropHdlFactory; + UniReference < XMLPropertySetMapper > xCellStylesPropertySetMapper; + UniReference < XMLPropertySetMapper > xColumnStylesPropertySetMapper; + UniReference < XMLPropertySetMapper > xRowStylesPropertySetMapper; + UniReference < XMLPropertySetMapper > xTableStylesPropertySetMapper; + UniReference < SvXMLExportPropertyMapper > xCellStylesExportPropertySetMapper; + UniReference < SvXMLExportPropertyMapper > xColumnStylesExportPropertySetMapper; + UniReference < SvXMLExportPropertyMapper > xRowStylesExportPropertySetMapper; + UniReference < SvXMLExportPropertyMapper > xTableStylesExportPropertySetMapper; + XMLNumberFormatAttributesExportHelper* pNumberFormatAttributesExportHelper; + ScMySharedData* pSharedData; + ScColumnStyles* pColumnStyles; + ScRowStyles* pRowStyles; + ScFormatRangeStyles* pCellStyles; + ScRowFormatRanges* pRowFormatRanges; + std::vector<rtl::OUString> aTableStyles; + ::com::sun::star::table::CellRangeAddress aRowHeaderRange; + ScMyOpenCloseColumnRowGroup* pGroupColumns; + ScMyOpenCloseColumnRowGroup* pGroupRows; + ScMyDefaultStyles* pDefaults; + ScChartListener* pChartListener; + + ScMyMergedRangesContainer* pMergedRangesContainer; + ScMyValidationsContainer* pValidationsContainer; + ScMyNotEmptyCellsIterator* pCellsItr; + ScChangeTrackingExportHelper* pChangeTrackingExportHelper; + const ::rtl::OUString sLayerID; + const ::rtl::OUString sCaptionShape; + ::rtl::OUString sAttrName; + ::rtl::OUString sAttrStyleName; + ::rtl::OUString sAttrColumnsRepeated; + ::rtl::OUString sAttrFormula; + ::rtl::OUString sAttrStringValue; + ::rtl::OUString sElemCell; + ::rtl::OUString sElemCoveredCell; + ::rtl::OUString sElemCol; + ::rtl::OUString sElemRow; + ::rtl::OUString sElemTab; + ::rtl::OUString sElemP; + sal_Int32 nOpenRow; + sal_uInt16 nCurrentTable; + sal_Bool bHasRowHeader : 1; + sal_Bool bRowHeaderOpen : 1; + sal_Bool mbShowProgress : 1; + + + sal_Bool HasDrawPages(::com::sun::star::uno::Reference < ::com::sun::star::sheet::XSpreadsheetDocument>& xDoc); + void CollectSharedData(sal_Int32& nTableCount, sal_Int32& nShapesCount, const sal_Int32 nCellCount); + void CollectShapesAutoStyles(const sal_Int32 nTableCount); + void WriteTablesView(const ::com::sun::star::uno::Any& aTableView); + void WriteView(const ::com::sun::star::uno::Any& aView); + virtual void _ExportFontDecls(); + virtual void _ExportStyles( sal_Bool bUsed ); + virtual void _ExportAutoStyles(); + virtual void _ExportMasterStyles(); + virtual void SetBodyAttributes(); + virtual void _ExportContent(); + virtual void _ExportMeta(); + + void CollectInternalShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape ); + + ::com::sun::star::table::CellRangeAddress GetEndAddress(::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet>& xTable, + const sal_uInt16 nTable); +// ScMyEmptyDatabaseRangesContainer GetEmptyDatabaseRanges(); + void GetAreaLinks( ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument>& xSpreadDoc, ScMyAreaLinksContainer& rAreaLinks ); + void GetDetectiveOpList( ScMyDetectiveOpContainer& rDetOp ); + void WriteSingleColumn(const sal_Int32 nRepeatColumns, const sal_Int32 nStyleIndex, + const sal_Int32 nIndex, const sal_Bool bIsAutoStyle, const sal_Bool bIsVisible); + void WriteColumn(const sal_Int32 nColumn, const sal_Int32 nRepeatColumns, + const sal_Int32 nStyleIndex, const sal_Bool bIsVisible); + void OpenHeaderColumn(); + void CloseHeaderColumn(); + void ExportColumns(const sal_uInt16 nTable, const ::com::sun::star::table::CellRangeAddress& aColumnHeaderRange, const sal_Bool bHasColumnHeader); + void ExportFormatRanges(const sal_Int32 nStartCol, const sal_Int32 nStartRow, + const sal_Int32 nEndCol, const sal_Int32 nEndRow, const sal_uInt16 nSheet); + void WriteRowContent(); + void WriteRowStartTag(sal_Int32 nRow, const sal_Int32 nIndex, const sal_Int8 nFlag, const sal_Int32 nEmptyRows); + void OpenHeaderRows(); + void CloseHeaderRows(); + void OpenNewRow(const sal_Int32 nIndex, const sal_Int8 nFlag, const sal_Int32 nStartRow, const sal_Int32 nEmptyRows); + void OpenAndCloseRow(const sal_Int32 nIndex, const sal_Int8 nFlag, + const sal_Int32 nStartRow, const sal_Int32 nEmptyRows); + void OpenRow(const sal_uInt16 nTable, const sal_Int32 nStartRow, const sal_Int32 nRepeatRow); + void CloseRow(const sal_Int32 nRow); + sal_Bool GetColumnHeader(::com::sun::star::table::CellRangeAddress& aColumnHeaderRange) const; + sal_Bool GetRowHeader(::com::sun::star::table::CellRangeAddress& aRowHeaderRange) const; + void FillFieldGroup(ScOutlineArray* pFields, ScMyOpenCloseColumnRowGroup* pGroups); + void FillColumnRowGroups(); + + sal_Bool GetMerged (const ::com::sun::star::table::CellRangeAddress* pCellRange, + const ::com::sun::star::uno::Reference < ::com::sun::star::sheet::XSpreadsheet>& xTable); + + sal_Bool GetCellText (ScMyCell& rMyCell) const; + + ::rtl::OUString GetPrintRanges(); + + void WriteCell (ScMyCell& aCell); + void WriteAreaLink(const ScMyCell& rMyCell); + void WriteAnnotation(const ScMyCell& rMyCell); + void WriteDetective(const ScMyCell& rMyCell); + void ExportShape(const ::com::sun::star::uno::Reference < ::com::sun::star::drawing::XShape >& xShape, ::com::sun::star::awt::Point* pPoint); + void WriteShapes(const ScMyCell& rMyCell); + void WriteTableShapes(); + void SetRepeatAttribute (const sal_Int32 nEqualCellCount); + + sal_Bool IsCellTypeEqual (const ScMyCell& aCell1, const ScMyCell& aCell2) const; + sal_Bool IsEditCell(const ::com::sun::star::table::CellAddress& aAddress) const; + sal_Bool IsEditCell(const ::com::sun::star::uno::Reference < ::com::sun::star::table::XCell>& xCell) const; + sal_Bool IsEditCell(ScMyCell& rCell) const; + sal_Bool IsAnnotationEqual(const ::com::sun::star::uno::Reference< ::com::sun::star::table::XCell>& xCell1, + const ::com::sun::star::uno::Reference< ::com::sun::star::table::XCell>& xCell2); + sal_Bool IsCellEqual (ScMyCell& aCell1, ScMyCell& aCell2); + + void WriteCalculationSettings(const ::com::sun::star::uno::Reference < ::com::sun::star::sheet::XSpreadsheetDocument>& xSpreadDoc); + void WriteTableSource(); + 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 WriteConsolidation(); // core implementation + + void CollectUserDefinedNamespaces(const SfxItemPool* pPool, sal_uInt16 nAttrib); +protected: + virtual SvXMLAutoStylePoolP* CreateAutoStylePool(); + virtual XMLPageExport* CreatePageExport(); + virtual XMLShapeExport* CreateShapeExport(); + virtual XMLFontAutoStylePool* CreateFontAutoStylePool(); +public: + // #110680# + ScXMLExport( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory, + const sal_uInt16 nExportFlag); + + virtual ~ScXMLExport(); + + static sal_Int16 GetFieldUnit(); + inline ScDocument* GetDocument() { return pDoc; } + inline const ScDocument* GetDocument() const { return pDoc; } + sal_Bool IsMatrix (const ::com::sun::star::uno::Reference < ::com::sun::star::table::XCell>& xCell, + const ::com::sun::star::uno::Reference < ::com::sun::star::sheet::XSpreadsheet>& xTable, + const sal_Int32 nCol, const sal_Int32 nRow, + ::com::sun::star::table::CellRangeAddress& aCellAddress, sal_Bool& bIsFirst) const; + + UniReference < XMLPropertySetMapper > GetCellStylesPropertySetMapper() { return xCellStylesPropertySetMapper; } + UniReference < XMLPropertySetMapper > GetTableStylesPropertySetMapper() { return xTableStylesPropertySetMapper; } + + void GetChangeTrackViewSettings(::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& rProps); + virtual void GetViewSettings(::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& rProps); + virtual void GetConfigurationSettings(::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& rProps); + + void CreateSharedData(const sal_Int32 nTableCount); + void SetSharedData(ScMySharedData* pTemp) { pSharedData = pTemp; } + ScMySharedData* GetSharedData() { return pSharedData; } + XMLNumberFormatAttributesExportHelper* GetNumberFormatAttributesExportHelper(); + + // Export the document. + virtual sal_uInt32 exportDoc( enum ::binfilter::xmloff::token::XMLTokenEnum eClass = ::binfilter::xmloff::token::XML_TOKEN_INVALID ); + + // XExporter + virtual void SAL_CALL setSourceDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + + // XFilter + virtual sal_Bool SAL_CALL filter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL cancel() throw(::com::sun::star::uno::RuntimeException); + + // XInitialization + virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); + + // XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); + + virtual void DisposingModel(); +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/xmlfilti.hxx b/binfilter/bf_sc/source/filter/xml/xmlfilti.hxx new file mode 100644 index 000000000000..b9d5b8ba41df --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/xmlfilti.hxx @@ -0,0 +1,313 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef SC_XMLFILTI_HXX +#define SC_XMLFILTI_HXX + +#include <bf_xmloff/xmlictxt.hxx> +#include <bf_xmloff/xmlimp.hxx> +#include <com/sun/star/table/CellAddress.hpp> +#include <com/sun/star/table/CellRangeAddress.hpp> +#include <com/sun/star/sheet/FilterOperator.hpp> +#include <com/sun/star/sheet/TableFilterField.hpp> +#include <tools/stack.hxx> + +#include "xmldrani.hxx" +#include "xmldpimp.hxx" +namespace binfilter { + +class ScXMLImport; + +class ScXMLFilterContext : public SvXMLImportContext +{ + ScXMLDatabaseRangeContext* pDatabaseRangeContext; + + ::com::sun::star::uno::Sequence < ::com::sun::star::sheet::TableFilterField> aFilterFields; + ::com::sun::star::table::CellAddress aOutputPosition; + ::com::sun::star::table::CellRangeAddress aConditionSourceRangeAddress; + sal_Int16 nUserListIndex; + sal_Bool bSkipDuplicates : 1; + sal_Bool bCopyOutputData : 1; + sal_Bool bUseRegularExpressions : 1; + sal_Bool bIsCaseSensitive : 1; + sal_Bool bEnabledUserList : 1; + sal_Bool bConnectionOr : 1; + sal_Bool bNextConnectionOr : 1; + sal_Bool bConditionSourceRange : 1; + Stack aConnectionOrStack; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLFilterContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDatabaseRangeContext* pTempDatabaseRangeContext); + + virtual ~ScXMLFilterContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); + + void SetIsCaseSensitive(const sal_Bool bTemp) { bIsCaseSensitive = bTemp; } + void SetUseRegularExpressions(const sal_Bool bTemp) { if (!bUseRegularExpressions) bUseRegularExpressions = bTemp;} + void OpenConnection(const sal_Bool bTemp) { sal_Bool* pTemp = new sal_Bool; *pTemp = bConnectionOr; + bConnectionOr = bNextConnectionOr; bNextConnectionOr = bTemp; + aConnectionOrStack.Push(pTemp);} + void CloseConnection() { sal_Bool* pTemp = static_cast <sal_Bool*> (aConnectionOrStack.Pop()); bConnectionOr = *pTemp; bNextConnectionOr = *pTemp; delete pTemp;} + sal_Bool GetConnection() { sal_Bool bTemp = bConnectionOr; bConnectionOr = bNextConnectionOr; return bTemp; } + void AddFilterField (const ::com::sun::star::sheet::TableFilterField aFilterField) { aFilterFields.realloc(aFilterFields.getLength() + 1); + aFilterFields[aFilterFields.getLength() - 1] = aFilterField; } +}; + +class ScXMLAndContext : public SvXMLImportContext +{ + ScXMLFilterContext* pFilterContext; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLAndContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLFilterContext* pTempFilterContext); + + virtual ~ScXMLAndContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +class ScXMLOrContext : public SvXMLImportContext +{ + ScXMLFilterContext* pFilterContext; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLOrContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLFilterContext* pTempFilterContext); + + virtual ~ScXMLOrContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +class ScXMLConditionContext : public SvXMLImportContext +{ + ScXMLFilterContext* pFilterContext; + + ::rtl::OUString sDataType; + ::rtl::OUString sConditionValue; + ::rtl::OUString sOperator; + sal_Int32 nField; + sal_Bool bIsCaseSensitive : 1; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLConditionContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLFilterContext* pTempFilterContext); + + virtual ~ScXMLConditionContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + void getOperatorXML(const ::rtl::OUString sTempOperator, ::com::sun::star::sheet::FilterOperator& aFilterOperator, sal_Bool& bUseRegularExpressions) const; + virtual void EndElement(); +}; + +// Datapilot (Core) + +class ScXMLDPFilterContext : public SvXMLImportContext +{ + ScXMLDataPilotTableContext* pDataPilotTable; + + ScQueryParam aFilterFields; + ScAddress aOutputPosition; + ScRange aConditionSourceRangeAddress; + sal_uInt8 nFilterFieldCount; + sal_Int16 nUserListIndex; + sal_Bool bSkipDuplicates : 1; + sal_Bool bCopyOutputData : 1; + sal_Bool bUseRegularExpressions : 1; + sal_Bool bIsCaseSensitive : 1; + sal_Bool bEnabledUserList : 1; + sal_Bool bConnectionOr : 1; + sal_Bool bNextConnectionOr : 1; + sal_Bool bConditionSourceRange : 1; + Stack aConnectionOrStack; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLDPFilterContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDataPilotTableContext* pTempDataPilotTableContext); + + virtual ~ScXMLDPFilterContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); + + void SetIsCaseSensitive(const sal_Bool bTemp) { bIsCaseSensitive = bTemp; } + void SetUseRegularExpressions(const sal_Bool bTemp) { if (!bUseRegularExpressions) bUseRegularExpressions = bTemp;} + void OpenConnection(const sal_Bool bTemp) { sal_Bool* pTemp = new sal_Bool; *pTemp = bConnectionOr; + bConnectionOr = bNextConnectionOr; bNextConnectionOr = bTemp; + aConnectionOrStack.Push(pTemp);} + void CloseConnection() { sal_Bool* pTemp = static_cast <sal_Bool*> (aConnectionOrStack.Pop()); bConnectionOr = *pTemp; bNextConnectionOr = *pTemp; delete pTemp;} + sal_Bool GetConnection() { sal_Bool bTemp = bConnectionOr; bConnectionOr = bNextConnectionOr; return bTemp; } + void AddFilterField (const ScQueryEntry& aFilterField); +}; + +class ScXMLDPAndContext : public SvXMLImportContext +{ + ScXMLDPFilterContext* pFilterContext; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLDPAndContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDPFilterContext* pTempFilterContext); + + virtual ~ScXMLDPAndContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +class ScXMLDPOrContext : public SvXMLImportContext +{ + ScXMLDPFilterContext* pFilterContext; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLDPOrContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDPFilterContext* pTempFilterContext); + + virtual ~ScXMLDPOrContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +class ScXMLDPConditionContext : public SvXMLImportContext +{ + ScXMLDPFilterContext* pFilterContext; + + ::rtl::OUString sDataType; + ::rtl::OUString sConditionValue; + ::rtl::OUString sOperator; + sal_Int32 nField; + sal_Bool bIsCaseSensitive : 1; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLDPConditionContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDPFilterContext* pTempFilterContext); + + virtual ~ScXMLDPConditionContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + void getOperatorXML(const ::rtl::OUString sTempOperator, ScQueryOp& aFilterOperator, sal_Bool& bUseRegularExpressions, + double& dVal) const; + virtual void EndElement(); +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/xmlimprt.hxx b/binfilter/bf_sc/source/filter/xml/xmlimprt.hxx new file mode 100644 index 000000000000..bff1da179c1f --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/xmlimprt.hxx @@ -0,0 +1,926 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SC_XMLIMPRT_HXX +#define SC_XMLIMPRT_HXX + +#include <rsc/rscsfx.hxx> +#include <bf_xmloff/xmlictxt.hxx> +#include <bf_xmloff/xmlimp.hxx> +#include <bf_xmloff/xmltkmap.hxx> +#include <bf_xmloff/xmlaustp.hxx> +#include <bf_xmloff/xmlstyle.hxx> +#include <vcl/svapp.hxx> +#include <com/sun/star/frame/XModel.hpp> +#include <tools/time.hxx> +#include <com/sun/star/util/DateTime.hpp> +#ifndef __SGI_STL_VECTOR +#include <vector> +#endif +#include "xmlsubti.hxx" +#include "global.hxx" +#include "xmlstyle.hxx" +#include "XMLDetectiveContext.hxx" +#include <com/sun/star/sheet/ValidationAlertStyle.hpp> +#include <com/sun/star/sheet/ValidationType.hpp> +#include <com/sun/star/sheet/ConditionOperator.hpp> +#include <com/sun/star/table/CellAddress.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/util/XNumberFormatTypes.hpp> +#include <com/sun/star/sheet/XSheetCellRangeContainer.hpp> +namespace binfilter { + +class SfxItemSet; +class ScRangeList; +class ScMyStyleNumberFormats; +class XMLShapeImportHelper; +class XMLNumberFormatAttributesExportHelper; +class SvXMLTokenMap; +class SvXMLStyleContext; + +enum ScXMLDocTokens +{ + XML_TOK_DOC_FONTDECLS, + XML_TOK_DOC_STYLES, + XML_TOK_DOC_AUTOSTYLES, + XML_TOK_DOC_MASTERSTYLES, + XML_TOK_DOC_META, + XML_TOK_DOC_SCRIPTS, + XML_TOK_DOC_BODY, + XML_TOK_DOC_SETTINGS, + XML_TOK_OFFICE_END=XML_TOK_UNKNOWN +}; + +enum ScXMLStylesTokens +{ + XML_TOK_STYLES_STYLE +}; + +enum ScXMLStylesAttrTokens +{ + XML_TOK_STYLES_STYLE_NAME, + XML_TOK_STYLES_STYLE_FAMILY, + XML_TOK_STYLES_STYLE_PARENT_STYLE_NAME +}; + +enum ScXMLStyleTokens +{ + XML_TOK_STYLE_PROPERTIES +}; + +enum ScXMLBodyTokens +{ + XML_TOK_BODY_TRACKED_CHANGES, + XML_TOK_BODY_CALCULATION_SETTINGS, + XML_TOK_BODY_CONTENT_VALIDATIONS, + XML_TOK_BODY_LABEL_RANGES, + XML_TOK_BODY_TABLE, + XML_TOK_BODY_NAMED_EXPRESSIONS, + XML_TOK_BODY_DATABASE_RANGES, + XML_TOK_BODY_DATABASE_RANGE, + XML_TOK_BODY_DATA_PILOT_TABLES, + XML_TOK_BODY_CONSOLIDATION, + XML_TOK_BODY_DDE_LINKS +}; + +enum ScXMLContentValidationsElemTokens +{ + XML_TOK_CONTENT_VALIDATION +}; + +enum ScXMLContentValidationElemTokens +{ + XML_TOK_CONTENT_VALIDATION_ELEM_HELP_MESSAGE, + XML_TOK_CONTENT_VALIDATION_ELEM_ERROR_MESSAGE, + XML_TOK_CONTENT_VALIDATION_ELEM_ERROR_MACRO +}; + +enum ScXMLContentValidationAttrTokens +{ + XML_TOK_CONTENT_VALIDATION_NAME, + XML_TOK_CONTENT_VALIDATION_CONDITION, + XML_TOK_CONTENT_VALIDATION_BASE_CELL_ADDRESS, + XML_TOK_CONTENT_VALIDATION_ALLOW_EMPTY_CELL +}; + +enum ScXMLContentValidationMessageElemTokens +{ + XML_TOK_P +}; + +enum ScXMLContentValidationHelpMessageAttrTokens +{ + XML_TOK_HELP_MESSAGE_ATTR_TITLE, + XML_TOK_HELP_MESSAGE_ATTR_DISPLAY +}; + +enum ScXMLContentValidationErrorMessageAttrTokens +{ + XML_TOK_ERROR_MESSAGE_ATTR_TITLE, + XML_TOK_ERROR_MESSAGE_ATTR_DISPLAY, + XML_TOK_ERROR_MESSAGE_ATTR_MESSAGE_TYPE +}; + +enum ScXMLContentValidationErrorMacroAttrTokens +{ + XML_TOK_ERROR_MACRO_ATTR_NAME, + XML_TOK_ERROR_MACRO_ATTR_EXECUTE +}; + +enum ScXMLLabelRangesElemTokens +{ + XML_TOK_LABEL_RANGE_ELEM +}; + +enum ScXMLLabelRangeAttrTokens +{ + XML_TOK_LABEL_RANGE_ATTR_LABEL_RANGE, + XML_TOK_LABEL_RANGE_ATTR_DATA_RANGE, + XML_TOK_LABEL_RANGE_ATTR_ORIENTATION +}; + +enum ScXMLTableTokens +{ + XML_TOK_TABLE_COL_GROUP, + XML_TOK_TABLE_HEADER_COLS, + XML_TOK_TABLE_COLS, + XML_TOK_TABLE_COL, + XML_TOK_TABLE_ROW_GROUP, + XML_TOK_TABLE_HEADER_ROWS, + XML_TOK_TABLE_ROWS, + XML_TOK_TABLE_ROW, + XML_TOK_TABLE_SOURCE, + XML_TOK_TABLE_SCENARIO, + XML_TOK_TABLE_SHAPES, + XML_TOK_TABLE_FORMS +}; + +enum ScXMLTableRowsTokens +{ + XML_TOK_TABLE_ROWS_ROW_GROUP, + XML_TOK_TABLE_ROWS_HEADER_ROWS, + XML_TOK_TABLE_ROWS_ROWS, + XML_TOK_TABLE_ROWS_ROW +}; + +enum ScXMLTableColsTokens +{ + XML_TOK_TABLE_COLS_COL_GROUP, + XML_TOK_TABLE_COLS_HEADER_COLS, + XML_TOK_TABLE_COLS_COLS, + XML_TOK_TABLE_COLS_COL +}; + +enum ScXMLTableAttrTokens +{ + XML_TOK_TABLE_NAME, + XML_TOK_TABLE_STYLE_NAME, + XML_TOK_TABLE_PROTECTION, + XML_TOK_TABLE_PRINT_RANGES, + XML_TOK_TABLE_PASSWORD +}; + +enum ScXMLTableScenarioAttrTokens +{ + XML_TOK_TABLE_SCENARIO_ATTR_DISPLAY_BORDER, + XML_TOK_TABLE_SCENARIO_ATTR_BORDER_COLOR, + XML_TOK_TABLE_SCENARIO_ATTR_COPY_BACK, + XML_TOK_TABLE_SCENARIO_ATTR_COPY_STYLES, + XML_TOK_TABLE_SCENARIO_ATTR_COPY_FORMULAS, + XML_TOK_TABLE_SCENARIO_ATTR_IS_ACTIVE, + XML_TOK_TABLE_SCENARIO_ATTR_SCENARIO_RANGES, + XML_TOK_TABLE_SCENARIO_ATTR_COMMENT +}; + +enum ScXMLTableColAttrTokens +{ + XML_TOK_TABLE_COL_ATTR_STYLE_NAME, + XML_TOK_TABLE_COL_ATTR_REPEATED, + XML_TOK_TABLE_COL_ATTR_VISIBILITY, + XML_TOK_TABLE_COL_ATTR_DEFAULT_CELL_STYLE_NAME +}; + +enum ScXMLTableRowTokens +{ + XML_TOK_TABLE_ROW_CELL, + XML_TOK_TABLE_ROW_COVERED_CELL +}; + +enum ScXMLTableRowAttrTokens +{ + XML_TOK_TABLE_ROW_ATTR_STYLE_NAME, + XML_TOK_TABLE_ROW_ATTR_VISIBILITY, + XML_TOK_TABLE_ROW_ATTR_REPEATED, + XML_TOK_TABLE_ROW_ATTR_DEFAULT_CELL_STYLE_NAME +// XML_TOK_TABLE_ROW_ATTR_USE_OPTIMAL_HEIGHT +}; + +enum ScXMLTableRowCellTokens +{ + XML_TOK_TABLE_ROW_CELL_P, + XML_TOK_TABLE_ROW_CELL_SUBTABLE, + XML_TOK_TABLE_ROW_CELL_ANNOTATION, + XML_TOK_TABLE_ROW_CELL_DETECTIVE, + XML_TOK_TABLE_ROW_CELL_CELL_RANGE_SOURCE +}; + +enum ScXMLTableRowCellAttrTokens +{ + XML_TOK_TABLE_ROW_CELL_ATTR_STYLE_NAME, + XML_TOK_TABLE_ROW_CELL_ATTR_CONTENT_VALIDATION_NAME, + XML_TOK_TABLE_ROW_CELL_ATTR_SPANNED_ROWS, + XML_TOK_TABLE_ROW_CELL_ATTR_SPANNED_COLS, + XML_TOK_TABLE_ROW_CELL_ATTR_SPANNED_MATRIX_COLS, + XML_TOK_TABLE_ROW_CELL_ATTR_SPANNED_MATRIX_ROWS, + XML_TOK_TABLE_ROW_CELL_ATTR_REPEATED, + XML_TOK_TABLE_ROW_CELL_ATTR_VALUE_TYPE, + XML_TOK_TABLE_ROW_CELL_ATTR_VALUE, + XML_TOK_TABLE_ROW_CELL_ATTR_DATE_VALUE, + XML_TOK_TABLE_ROW_CELL_ATTR_TIME_VALUE, + XML_TOK_TABLE_ROW_CELL_ATTR_STRING_VALUE, + XML_TOK_TABLE_ROW_CELL_ATTR_BOOLEAN_VALUE, + XML_TOK_TABLE_ROW_CELL_ATTR_FORMULA, + XML_TOK_TABLE_ROW_CELL_ATTR_CURRENCY +}; + +enum ScXMLAnnotationAttrTokens +{ + XML_TOK_TABLE_ANNOTATION_ATTR_AUTHOR, + XML_TOK_TABLE_ANNOTATION_ATTR_CREATE_DATE, + XML_TOK_TABLE_ANNOTATION_ATTR_CREATE_DATE_STRING, + XML_TOK_TABLE_ANNOTATION_ATTR_DISPLAY +}; + +enum ScXMLDetectiveElemTokens +{ + XML_TOK_DETECTIVE_ELEM_HIGHLIGHTED, + XML_TOK_DETECTIVE_ELEM_OPERATION +}; + +enum ScXMLDetectiveHighlightedAttrTokens +{ + XML_TOK_DETECTIVE_HIGHLIGHTED_ATTR_CELL_RANGE, + XML_TOK_DETECTIVE_HIGHLIGHTED_ATTR_DIRECTION, + XML_TOK_DETECTIVE_HIGHLIGHTED_ATTR_CONTAINS_ERROR, + XML_TOK_DETECTIVE_HIGHLIGHTED_ATTR_MARKED_INVALID +}; + +enum ScXMLDetectiveOperationAttrTokens +{ + XML_TOK_DETECTIVE_OPERATION_ATTR_NAME, + XML_TOK_DETECTIVE_OPERATION_ATTR_INDEX +}; + +enum ScXMLCellRangeSourceAttrTokens +{ + XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_NAME, + XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_HREF, + XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_FILTER_NAME, + XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_FILTER_OPTIONS, + XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_LAST_COLUMN, + XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_LAST_ROW, + XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_REFRESH_DELAY +}; + +enum ScXMLNamedExpressionsTokens +{ + XML_TOK_NAMED_EXPRESSIONS_NAMED_RANGE, + XML_TOK_NAMED_EXPRESSIONS_NAMED_EXPRESSION +}; + +enum ScXMLNamedRangeAttrTokens +{ + XML_TOK_NAMED_RANGE_ATTR_NAME, + XML_TOK_NAMED_RANGE_ATTR_CELL_RANGE_ADDRESS, + XML_TOK_NAMED_RANGE_ATTR_BASE_CELL_ADDRESS, + XML_TOK_NAMED_RANGE_ATTR_RANGE_USABLE_AS +}; + +enum ScXMLNamedExpressionAttrTokens +{ + XML_TOK_NAMED_EXPRESSION_ATTR_NAME, + XML_TOK_NAMED_EXPRESSION_ATTR_BASE_CELL_ADDRESS, + XML_TOK_NAMED_EXPRESSION_ATTR_EXPRESSION +}; + +enum ScXMLDatabaseRangesTokens +{ + XML_TOK_DATABASE_RANGE +}; + +enum ScXMLDatabaseRangeTokens +{ + XML_TOK_DATABASE_RANGE_SOURCE_SQL, + XML_TOK_DATABASE_RANGE_SOURCE_TABLE, + XML_TOK_DATABASE_RANGE_SOURCE_QUERY, + XML_TOK_FILTER, + XML_TOK_SORT, + XML_TOK_DATABASE_RANGE_SUBTOTAL_RULES +}; + +enum ScXMLDatabaseRangeAttrTokens +{ + XML_TOK_DATABASE_RANGE_ATTR_NAME, + XML_TOK_DATABASE_RANGE_ATTR_IS_SELECTION, + XML_TOK_DATABASE_RANGE_ATTR_ON_UPDATE_KEEP_STYLES, + XML_TOK_DATABASE_RANGE_ATTR_ON_UPDATE_KEEP_SIZE, + XML_TOK_DATABASE_RANGE_ATTR_HAS_PERSISTENT_DATA, + XML_TOK_DATABASE_RANGE_ATTR_ORIENTATION, + XML_TOK_DATABASE_RANGE_ATTR_CONTAINS_HEADER, + XML_TOK_DATABASE_RANGE_ATTR_DISPLAY_FILTER_BUTTONS, + XML_TOK_DATABASE_RANGE_ATTR_TARGET_RANGE_ADDRESS, + XML_TOK_DATABASE_RANGE_ATTR_REFRESH_DELAY +}; + +enum ScXMLDatabaseRangeSourceSQLAttrTokens +{ + XML_TOK_SOURCE_SQL_ATTR_DATABASE_NAME, + XML_TOK_SOURCE_SQL_ATTR_SQL_STATEMENT, + XML_TOK_SOURCE_SQL_ATTR_PARSE_SQL_STATEMENT +}; + +enum ScXMLDatabaseRangeSourceTableAttrTokens +{ + XML_TOK_SOURCE_TABLE_ATTR_DATABASE_NAME, + XML_TOK_SOURCE_TABLE_ATTR_TABLE_NAME +}; + +enum ScXMLDatabaseRangeSourceQueryAttrTokens +{ + XML_TOK_SOURCE_QUERY_ATTR_DATABASE_NAME, + XML_TOK_SOURCE_QUERY_ATTR_QUERY_NAME +}; + +enum ScXMLFilterTokens +{ + XML_TOK_FILTER_AND, + XML_TOK_FILTER_OR, + XML_TOK_FILTER_CONDITION +}; + +enum ScXMLFilterAttrTokens +{ + XML_TOK_FILTER_ATTR_TARGET_RANGE_ADDRESS, + XML_TOK_FILTER_ATTR_CONDITION_SOURCE_RANGE_ADDRESS, + XML_TOK_FILTER_ATTR_CONDITION_SOURCE, + XML_TOK_FILTER_ATTR_DISPLAY_DUPLICATES +}; + +enum ScXMLFilterConditionAttrTokens +{ + XML_TOK_CONDITION_ATTR_FIELD_NUMBER, + XML_TOK_CONDITION_ATTR_CASE_SENSITIVE, + XML_TOK_CONDITION_ATTR_DATA_TYPE, + XML_TOK_CONDITION_ATTR_VALUE, + XML_TOK_CONDITION_ATTR_OPERATOR +}; + +enum ScXMLSortTokens +{ + XML_TOK_SORT_SORT_BY +}; + +enum ScXMLSortAttrTokens +{ + XML_TOK_SORT_ATTR_BIND_STYLES_TO_CONTENT, + XML_TOK_SORT_ATTR_TARGET_RANGE_ADDRESS, + XML_TOK_SORT_ATTR_CASE_SENSITIVE, + XML_TOK_SORT_ATTR_LANGUAGE, + XML_TOK_SORT_ATTR_COUNTRY, + XML_TOK_SORT_ATTR_ALGORITHM +}; + +enum ScXMLSortSortByAttrTokens +{ + XML_TOK_SORT_BY_ATTR_FIELD_NUMBER, + XML_TOK_SORT_BY_ATTR_DATA_TYPE, + XML_TOK_SORT_BY_ATTR_ORDER +}; + +enum ScXMLDatabaseRangeSubTotalRulesTokens +{ + XML_TOK_SUBTOTAL_RULES_SORT_GROUPS, + XML_TOK_SUBTOTAL_RULES_SUBTOTAL_RULE +}; + +enum ScXMLDatabaseRangeSubTotalRulesAttrTokens +{ + XML_TOK_SUBTOTAL_RULES_ATTR_BIND_STYLES_TO_CONTENT, + XML_TOK_SUBTOTAL_RULES_ATTR_CASE_SENSITIVE, + XML_TOK_SUBTOTAL_RULES_ATTR_PAGE_BREAKS_ON_GROUP_CHANGE +}; + +enum ScXMLSubTotalRulesSortGroupsAttrTokens +{ + XML_TOK_SORT_GROUPS_ATTR_DATA_TYPE, + XML_TOK_SORT_GROUPS_ATTR_ORDER +}; + +enum ScXMLSubTotalRulesSubTotalRuleTokens +{ + XML_TOK_SUBTOTAL_RULE_SUBTOTAL_FIELD +}; + +enum ScXMLSubTotalRulesSubTotalRuleAttrTokens +{ + XML_TOK_SUBTOTAL_RULE_ATTR_GROUP_BY_FIELD_NUMBER +}; + +enum ScXMLSubTotalRuleSubTotalField +{ + XML_TOK_SUBTOTAL_FIELD_ATTR_FIELD_NUMBER, + XML_TOK_SUBTOTAL_FIELD_ATTR_FUNCTION +}; + +enum ScXMLDataPilotTablesElemTokens +{ + XML_TOK_DATA_PILOT_TABLE +}; + +enum ScXMLDataPilotTableAttrTokens +{ + XML_TOK_DATA_PILOT_TABLE_ATTR_NAME, + XML_TOK_DATA_PILOT_TABLE_ATTR_APPLICATION_DATA, + XML_TOK_DATA_PILOT_TABLE_ATTR_GRAND_TOTAL, + XML_TOK_DATA_PILOT_TABLE_ATTR_IGNORE_EMPTY_ROWS, + XML_TOK_DATA_PILOT_TABLE_ATTR_IDENTIFY_CATEGORIES, + XML_TOK_DATA_PILOT_TABLE_ATTR_TARGET_RANGE_ADDRESS, + XML_TOK_DATA_PILOT_TABLE_ATTR_BUTTONS +}; + +enum ScXMLDataPilotTableElemTokens +{ + XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_SQL, + XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_TABLE, + XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_QUERY, + XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_SERVICE, + XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_CELL_RANGE, + XML_TOK_DATA_PILOT_TABLE_ELEM_DATA_PILOT_FIELD +}; + +enum ScXMLDataPilotTableSourceServiceAttrTokens +{ + XML_TOK_SOURCE_SERVICE_ATTR_NAME, + XML_TOK_SOURCE_SERVICE_ATTR_SOURCE_NAME, + XML_TOK_SOURCE_SERVICE_ATTR_OBJECT_NAME, + XML_TOK_SOURCE_SERVICE_ATTR_USERNAME, + XML_TOK_SOURCE_SERVICE_ATTR_PASSWORD +}; + +enum ScXMLDataPilotTableSourceCellRangeElemTokens +{ + XML_TOK_SOURCE_CELL_RANGE_ELEM_FILTER +}; + +enum ScXMLDataPilotTableSourceCellRangeAttrTokens +{ + XML_TOK_SOURCE_CELL_RANGE_ATTR_CELL_RANGE_ADDRESS +}; + +enum ScXMLDataPilotFieldAttrTokens +{ + XML_TOK_DATA_PILOT_FIELD_ATTR_SOURCE_FIELD_NAME, + XML_TOK_DATA_PILOT_FIELD_ATTR_IS_DATA_LAYOUT_FIELD, + XML_TOK_DATA_PILOT_FIELD_ATTR_FUNCTION, + XML_TOK_DATA_PILOT_FIELD_ATTR_ORIENTATION, + XML_TOK_DATA_PILOT_FIELD_ATTR_USED_HIERARCHY +}; + +enum ScXMLDataPilotFieldElemTokens +{ + XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_LEVEL +}; + +enum ScXMLDataPilotLevelAttrTokens +{ + XML_TOK_DATA_PILOT_LEVEL_ATTR_DISPLAY_EMPTY +}; + +enum ScXMLDataPilotLevelElemTokens +{ + XML_TOK_DATA_PILOT_LEVEL_ELEM_DATA_PILOT_SUBTOTALS, + XML_TOK_DATA_PILOT_LEVEL_ELEM_DATA_PILOT_MEMBERS +}; + +enum ScXMLDataPilotSubTotalsElemTokens +{ + XML_TOK_DATA_PILOT_SUBTOTALS_ELEM_DATA_PILOT_SUBTOTAL +}; + +enum ScXMLDataPilotSubTotalAttrTokens +{ + XML_TOK_DATA_PILOT_SUBTOTAL_ATTR_FUNCTION +}; + +enum ScXMLDataPilotMembersElemTokens +{ + XML_TOK_DATA_PILOT_MEMBERS_ELEM_DATA_PILOT_MEMBER +}; + +enum ScXMLDataPilotMemberAttrTokens +{ + XML_TOK_DATA_PILOT_MEMBER_ATTR_NAME, + XML_TOK_DATA_PILOT_MEMBER_ATTR_DISPLAY, + XML_TOK_DATA_PILOT_MEMBER_ATTR_DISPLAY_DETAILS +}; + +enum ScXMLConsolidationAttrTokens +{ + XML_TOK_CONSOLIDATION_ATTR_FUNCTION, + XML_TOK_CONSOLIDATION_ATTR_SOURCE_RANGES, + XML_TOK_CONSOLIDATION_ATTR_TARGET_ADDRESS, + XML_TOK_CONSOLIDATION_ATTR_USE_LABEL, + XML_TOK_CONSOLIDATION_ATTR_LINK_TO_SOURCE +}; + + +class SvI18NMap; +//class SvXMLImportItemMapper; +class SvXMLNumFmtHelper; +class ScXMLChangeTrackingImportHelper; + +struct tScMyCellRange +{ + sal_Int16 Sheet; + sal_Int32 StartColumn, EndColumn; + sal_Int32 StartRow, EndRow; +}; + +struct ScMyNamedExpression +{ + ::rtl::OUString sName; + ::rtl::OUString sContent; + ::rtl::OUString sBaseCellAddress; + ::rtl::OUString sRangeType; + sal_Bool bIsExpression : 1; +}; + +typedef std::list<const ScMyNamedExpression*> ScMyNamedExpressions; + +struct ScMyImportValidation +{ + ::rtl::OUString sName; + ::rtl::OUString sImputTitle; + ::rtl::OUString sImputMessage; + ::rtl::OUString sErrorTitle; + ::rtl::OUString sErrorMessage; + ::rtl::OUString sFormula1; + ::rtl::OUString sFormula2; + ::rtl::OUString sBaseCellAddress; + ::com::sun::star::table::CellAddress aBaseCellAddress; + ::com::sun::star::sheet::ValidationAlertStyle aAlertStyle; + ::com::sun::star::sheet::ValidationType aValidationType; + ::com::sun::star::sheet::ConditionOperator aOperator; + sal_Bool bShowErrorMessage : 1; + sal_Bool bShowImputMessage : 1; + sal_Bool bIgnoreBlanks : 1; +}; + +typedef std::vector<ScMyImportValidation> ScMyImportValidations; +typedef std::list<SvXMLImportContext*> ScMyViewContextList; +class ScMyStylesImportHelper; + +class ScXMLImport: public SvXMLImport +{ + ScDocument* pDoc; + ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper; + ScMyViewContextList aViewContextList; + ScMyStylesImportHelper* pStylesImportHelper; + ::rtl::OUString sNumberFormat; + ::rtl::OUString sLocale; + ::rtl::OUString sCellStyle; + ::rtl::OUString sStandardFormat; + ::rtl::OUString sType; + +// SvXMLAutoStylePoolP *pScAutoStylePool; + UniReference < XMLPropertyHandlerFactory > xScPropHdlFactory; + UniReference < XMLPropertySetMapper > xCellStylesPropertySetMapper; + UniReference < XMLPropertySetMapper > xColumnStylesPropertySetMapper; + UniReference < XMLPropertySetMapper > xRowStylesPropertySetMapper; + UniReference < XMLPropertySetMapper > xTableStylesPropertySetMapper; +// SvXMLImportContextRef xStyles; +// SvXMLImportContextRef xAutoStyles; + +// SvXMLImportItemMapper *pParaItemMapper;// paragraph item import +// SvI18NMap *pI18NMap; // name mapping for I18N + SvXMLTokenMap *pDocElemTokenMap; + SvXMLTokenMap *pStylesElemTokenMap; + SvXMLTokenMap *pStylesAttrTokenMap; + SvXMLTokenMap *pStyleElemTokenMap; + SvXMLTokenMap *pBodyElemTokenMap; + SvXMLTokenMap *pContentValidationsElemTokenMap; + SvXMLTokenMap *pContentValidationElemTokenMap; + SvXMLTokenMap *pContentValidationAttrTokenMap; + SvXMLTokenMap *pContentValidationMessageElemTokenMap; + SvXMLTokenMap *pContentValidationHelpMessageAttrTokenMap; + SvXMLTokenMap *pContentValidationErrorMessageAttrTokenMap; + SvXMLTokenMap *pContentValidationErrorMacroAttrTokenMap; + SvXMLTokenMap *pLabelRangesElemTokenMap; + SvXMLTokenMap *pLabelRangeAttrTokenMap; + SvXMLTokenMap *pTableElemTokenMap; + SvXMLTokenMap *pTableRowsElemTokenMap; + SvXMLTokenMap *pTableColsElemTokenMap; + SvXMLTokenMap *pTableScenarioAttrTokenMap; + SvXMLTokenMap *pTableAttrTokenMap; + SvXMLTokenMap *pTableColAttrTokenMap; + SvXMLTokenMap *pTableRowElemTokenMap; + SvXMLTokenMap *pTableRowAttrTokenMap; + SvXMLTokenMap *pTableRowCellElemTokenMap; + SvXMLTokenMap *pTableRowCellAttrTokenMap; + SvXMLTokenMap *pTableAnnotationAttrTokenMap; + SvXMLTokenMap *pDetectiveElemTokenMap; + SvXMLTokenMap *pDetectiveHighlightedAttrTokenMap; + SvXMLTokenMap *pDetectiveOperationAttrTokenMap; + SvXMLTokenMap *pTableCellRangeSourceAttrTokenMap; + SvXMLTokenMap *pNamedExpressionsElemTokenMap; + SvXMLTokenMap *pNamedRangeAttrTokenMap; + SvXMLTokenMap *pNamedExpressionAttrTokenMap; + SvXMLTokenMap *pDatabaseRangesElemTokenMap; + SvXMLTokenMap *pDatabaseRangeElemTokenMap; + SvXMLTokenMap *pDatabaseRangeAttrTokenMap; + SvXMLTokenMap *pDatabaseRangeSourceSQLAttrTokenMap; + SvXMLTokenMap *pDatabaseRangeSourceTableAttrTokenMap; + SvXMLTokenMap *pDatabaseRangeSourceQueryAttrTokenMap; + SvXMLTokenMap *pFilterElemTokenMap; + SvXMLTokenMap *pFilterAttrTokenMap; + SvXMLTokenMap *pFilterConditionAttrTokenMap; + SvXMLTokenMap *pSortElemTokenMap; + SvXMLTokenMap *pSortAttrTokenMap; + SvXMLTokenMap *pSortSortByAttrTokenMap; + SvXMLTokenMap *pDatabaseRangeSubTotalRulesElemTokenMap; + SvXMLTokenMap *pDatabaseRangeSubTotalRulesAttrTokenMap; + SvXMLTokenMap *pSubTotalRulesSortGroupsAttrTokenMap; + SvXMLTokenMap *pSubTotalRulesSubTotalRuleElemTokenMap; + SvXMLTokenMap *pSubTotalRulesSubTotalRuleAttrTokenMap; + SvXMLTokenMap *pSubTotalRuleSubTotalFieldAttrTokenMap; + SvXMLTokenMap *pDataPilotTablesElemTokenMap; + SvXMLTokenMap *pDataPilotTableAttrTokenMap; + SvXMLTokenMap *pDataPilotTableElemTokenMap; + SvXMLTokenMap *pDataPilotTableSourceServiceAttrTokenMap; + SvXMLTokenMap *pDataPilotTableSourceCellRangeElemTokenMap; + SvXMLTokenMap *pDataPilotTableSourceCellRangeAttrTokenMap; + SvXMLTokenMap *pDataPilotFieldAttrTokenMap; + SvXMLTokenMap *pDataPilotFieldElemTokenMap; + SvXMLTokenMap *pDataPilotLevelAttrTokenMap; + SvXMLTokenMap *pDataPilotLevelElemTokenMap; + SvXMLTokenMap *pDataPilotSubTotalsElemTokenMap; + SvXMLTokenMap *pDataPilotSubTotalAttrTokenMap; + SvXMLTokenMap *pDataPilotMembersElemTokenMap; + SvXMLTokenMap *pDataPilotMemberAttrTokenMap; + SvXMLTokenMap *pConsolidationAttrTokenMap; + + ScMyTables aTables; + + ScMyNamedExpressions* pMyNamedExpressions; + ScMyImportValidations* pValidations; + ScMyImpDetectiveOpArray* pDetectiveOpArray; + SolarMutexGuard* pSolarMutexGuard; + + ::rtl::OUString sFirstTableStyle; + XMLNumberFormatAttributesExportHelper* pNumberFormatAttributesExportHelper; + ScMyStyleNumberFormats* pStyleNumberFormats; + ::com::sun::star::uno::Reference < ::com::sun::star::util::XNumberFormats> xNumberFormats; + ::com::sun::star::uno::Reference < ::com::sun::star::util::XNumberFormatTypes> xNumberFormatTypes; + + ::com::sun::star::uno::Reference < ::com::sun::star::sheet::XSheetCellRangeContainer> xSheetCellRanges; + + ::rtl::OUString sEmpty; + ::rtl::OUString sPrevStyleName; + ::rtl::OUString sPrevCurrency; + sal_uInt32 nSolarMutexLocked; + sal_uInt16 nStyleFamilyMask;// Mask of styles to load + sal_Int16 nPrevCellType; + sal_Bool bLoadDoc; // Load doc or styles only + sal_Bool bRemoveLastChar; + sal_Bool bNullDateSetted; + sal_Bool bSelfImportingXMLSet; + sal_uInt32 nRangeOverflowType; + + +protected: + + // This method is called after the namespace map has been updated, but + // before a context for the current element has been pushed. + virtual SvXMLImportContext *CreateContext(USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + virtual XMLShapeImportHelper* CreateShapeImport(); + +public: + // #110680# + ScXMLImport( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory, + const sal_uInt16 nImportFlag); + + ~ScXMLImport() throw(); + + // namespace office + SvXMLImportContext *CreateMetaContext( + const ::rtl::OUString& rLocalName ); + SvXMLImportContext *CreateFontDeclsContext(const USHORT nPrefix, const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList>& xAttrList); + SvXMLImportContext *CreateScriptContext( + const ::rtl::OUString& rLocalName ); + SvXMLImportContext *CreateStylesContext(const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList>& xAttrList, sal_Bool bAutoStyles ); +// SvXMLImportContext *CreateUseStylesContext(const ::rtl::OUString& rLocalName , +// const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList>& xAttrList); + SvXMLImportContext *CreateBodyContext( + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void SetStatisticAttributes( const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + inline ScDocument* GetDocument() { return pDoc; } + inline const ScDocument* GetDocument() const { return pDoc; } + + ScMyTables& GetTables() { return aTables; } + + sal_uInt16 GetStyleFamilyMask() const { return nStyleFamilyMask; } + sal_Bool IsStylesOnlyMode() const { return !bLoadDoc; } + +// SvI18NMap& GetI18NMap() { return *pI18NMap; } + +// inline const SvXMLImportItemMapper& GetParaItemMapper() const; +// SvXMLImportContext *CreateParaItemImportContext( USHORT nPrefix, +// const ::rtl::OUString& rLocalName, +// const ::com::sun::star::uno::Reference< +// ::com::sun::star::xml::sax::XAttributeList& xAttrList, +// SfxItemSet& rItemSet ); + + UniReference < XMLPropertySetMapper > GetCellStylesPropertySetMapper() const { return xCellStylesPropertySetMapper; } + UniReference < XMLPropertySetMapper > GetColumnStylesPropertySetMapper() const { return xColumnStylesPropertySetMapper; } + UniReference < XMLPropertySetMapper > GetRowStylesPropertySetMapper() const { return xRowStylesPropertySetMapper; } + UniReference < XMLPropertySetMapper > GetTableStylesPropertySetMapper() const { return xTableStylesPropertySetMapper; } +// SvXMLImportContextRef GetAutoStyles() const { return xAutoStyles; } +// SvXMLImportContextRef GetStyles() const { return xStyles; } + + const SvXMLTokenMap& GetDocElemTokenMap(); + const SvXMLTokenMap& GetBodyElemTokenMap(); + const SvXMLTokenMap& GetContentValidationsElemTokenMap(); + const SvXMLTokenMap& GetContentValidationElemTokenMap(); + const SvXMLTokenMap& GetContentValidationAttrTokenMap(); + const SvXMLTokenMap& GetContentValidationMessageElemTokenMap(); + const SvXMLTokenMap& GetContentValidationHelpMessageAttrTokenMap(); + const SvXMLTokenMap& GetContentValidationErrorMessageAttrTokenMap(); + const SvXMLTokenMap& GetContentValidationErrorMacroAttrTokenMap(); + const SvXMLTokenMap& GetLabelRangesElemTokenMap(); + const SvXMLTokenMap& GetLabelRangeAttrTokenMap(); + const SvXMLTokenMap& GetTableElemTokenMap(); + const SvXMLTokenMap& GetTableRowsElemTokenMap(); + const SvXMLTokenMap& GetTableColsElemTokenMap(); + const SvXMLTokenMap& GetTableAttrTokenMap(); + const SvXMLTokenMap& GetTableScenarioAttrTokenMap(); + const SvXMLTokenMap& GetTableColAttrTokenMap(); + const SvXMLTokenMap& GetTableRowElemTokenMap(); + const SvXMLTokenMap& GetTableRowAttrTokenMap(); + const SvXMLTokenMap& GetTableRowCellElemTokenMap(); + const SvXMLTokenMap& GetTableAnnotationAttrTokenMap(); + const SvXMLTokenMap& GetDetectiveElemTokenMap(); + const SvXMLTokenMap& GetDetectiveHighlightedAttrTokenMap(); + const SvXMLTokenMap& GetDetectiveOperationAttrTokenMap(); + const SvXMLTokenMap& GetTableCellRangeSourceAttrTokenMap(); + const SvXMLTokenMap& GetNamedExpressionsElemTokenMap(); + const SvXMLTokenMap& GetNamedRangeAttrTokenMap(); + const SvXMLTokenMap& GetNamedExpressionAttrTokenMap(); + const SvXMLTokenMap& GetDatabaseRangesElemTokenMap(); + const SvXMLTokenMap& GetDatabaseRangeElemTokenMap(); + const SvXMLTokenMap& GetDatabaseRangeAttrTokenMap(); + const SvXMLTokenMap& GetDatabaseRangeSourceSQLAttrTokenMap(); + const SvXMLTokenMap& GetDatabaseRangeSourceTableAttrTokenMap(); + const SvXMLTokenMap& GetDatabaseRangeSourceQueryAttrTokenMap(); + const SvXMLTokenMap& GetFilterElemTokenMap(); + const SvXMLTokenMap& GetFilterAttrTokenMap(); + const SvXMLTokenMap& GetFilterConditionAttrTokenMap(); + const SvXMLTokenMap& GetSortElemTokenMap(); + const SvXMLTokenMap& GetSortAttrTokenMap(); + const SvXMLTokenMap& GetSortSortByAttrTokenMap(); + const SvXMLTokenMap& GetDatabaseRangeSubTotalRulesElemTokenMap(); + const SvXMLTokenMap& GetDatabaseRangeSubTotalRulesAttrTokenMap(); + const SvXMLTokenMap& GetSubTotalRulesSortGroupsAttrTokenMap(); + const SvXMLTokenMap& GetSubTotalRulesSubTotalRuleElemTokenMap(); + const SvXMLTokenMap& GetSubTotalRulesSubTotalRuleAttrTokenMap(); + const SvXMLTokenMap& GetSubTotalRuleSubTotalFieldAttrTokenMap(); + const SvXMLTokenMap& GetDataPilotTablesElemTokenMap(); + const SvXMLTokenMap& GetDataPilotTableAttrTokenMap(); + const SvXMLTokenMap& GetDataPilotTableElemTokenMap(); + const SvXMLTokenMap& GetDataPilotTableSourceServiceAttrTokenMap(); + const SvXMLTokenMap& GetDataPilotTableSourceCellRangeElemTokenMap(); + const SvXMLTokenMap& GetDataPilotTableSourceCellRangeAttrTokenMap(); + const SvXMLTokenMap& GetDataPilotFieldAttrTokenMap(); + const SvXMLTokenMap& GetDataPilotFieldElemTokenMap(); + const SvXMLTokenMap& GetDataPilotLevelAttrTokenMap(); + const SvXMLTokenMap& GetDataPilotLevelElemTokenMap(); + const SvXMLTokenMap& GetDataPilotSubTotalsElemTokenMap(); + const SvXMLTokenMap& GetDataPilotSubTotalAttrTokenMap(); + const SvXMLTokenMap& GetDataPilotMembersElemTokenMap(); + const SvXMLTokenMap& GetDataPilotMemberAttrTokenMap(); + const SvXMLTokenMap& GetConsolidationAttrTokenMap(); +// const SvXMLTokenMap& GetTextPElemTokenMap(); +// const SvXMLTokenMap& GetTextPAttrTokenMap(); +// const SvXMLTokenMap& GetStyleStylesElemTokenMap(); +// const SvXMLTokenMap& GetTextListBlockAttrTokenMap(); +// const SvXMLTokenMap& GetTextListBlockElemTokenMap(); + + void AddNamedExpression(const ScMyNamedExpression* pMyNamedExpression) { + if (!pMyNamedExpressions) + pMyNamedExpressions = new ScMyNamedExpressions(); + pMyNamedExpressions->push_back(pMyNamedExpression); } + ScMyNamedExpressions* GetNamedExpressions() { return pMyNamedExpressions; } + + void AddValidation(const ScMyImportValidation& rValidation) { + if (!pValidations) + pValidations = new ScMyImportValidations(); + pValidations->push_back(rValidation); } + sal_Bool GetValidation(const ::rtl::OUString& sName, ScMyImportValidation& aValidation); + + inline ScMyImpDetectiveOpArray* GetDetectiveOpArray() { + if (!pDetectiveOpArray) + pDetectiveOpArray = new ScMyImpDetectiveOpArray(); + return pDetectiveOpArray; } + + void SetRemoveLastChar(sal_Bool bValue) { bRemoveLastChar = bValue; } + sal_Bool GetRemoveLastChar() { return bRemoveLastChar; } + + ScXMLChangeTrackingImportHelper* GetChangeTrackingImportHelper(); + void AddViewContext(SvXMLImportContext* pContext) { aViewContextList.push_back(pContext); } + void InsertStyles(); + + void SetChangeTrackingViewSettings(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& rChangeProps); + virtual void SetViewSettings(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aViewProps); + virtual void SetConfigurationSettings(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aConfigProps); + + void SetFirstTableStyle(const ::rtl::OUString& rValue) { sFirstTableStyle = rValue; } + ::rtl::OUString GetFirstTableStyle() { return sFirstTableStyle; } + ScMyStylesImportHelper* GetStylesImportHelper() { return pStylesImportHelper; } + sal_Int32 SetCurrencySymbol(const sal_Int32 nKey, const ::rtl::OUString& rCurrency); + sal_Bool IsCurrencySymbol(const sal_Int32 nNumberFormat, const ::rtl::OUString& sCurrencySymbol); + void SetType(::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet>& rProperties, + sal_Int32& rNumberFormat, + const sal_Int16 nCellType, + const ::rtl::OUString& rCurrency); +private: + void AddStyleRange(const ::com::sun::star::table::CellRangeAddress& rCellRange); + void SetStyleToRanges(); +public: + void SetStyleToRange(const ScRange& rRange, const ::rtl::OUString* pStyleName, + const sal_Int16 nCellType, const ::rtl::OUString* pCurrency); + sal_Bool SetNullDateOnUnitConverter(); + XMLNumberFormatAttributesExportHelper* GetNumberFormatAttributesExportHelper(); + ScMyStyleNumberFormats* GetStyleNumberFormats(); + + void SetStylesToRangesFinished(); + + // XImporter + virtual void SAL_CALL setTargetDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::xml::sax::XDocumentHandler + virtual void SAL_CALL startDocument(void) + throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL endDocument(void) + throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + + virtual void DisposingModel(); + + void LockSolarMutex(); + void UnlockSolarMutex(); + + void SetRangeOverflowType(sal_uInt32 nType) { nRangeOverflowType = nType; } + sal_Bool HasRangeOverflow() const { return nRangeOverflowType != 0; } + sal_uInt32 GetRangeOverflowType() const { return nRangeOverflowType; } +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/xmllabri.hxx b/binfilter/bf_sc/source/filter/xml/xmllabri.hxx new file mode 100644 index 000000000000..77e0cc16dbbd --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/xmllabri.hxx @@ -0,0 +1,95 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef SC_XMLLABRI_HXX +#define SC_XMLLABRI_HXX + +#include <bf_xmloff/xmlictxt.hxx> +namespace binfilter { + +class ScXMLImport; + + +//___________________________________________________________________ + +class ScXMLLabelRangesContext : public SvXMLImportContext +{ +private: + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + ScXMLLabelRangesContext( + ScXMLImport& rImport, + USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList>& xAttrList + ); + virtual ~ScXMLLabelRangesContext(); + + virtual SvXMLImportContext* CreateChildContext( + USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList>& xAttrList + ); + virtual void EndElement(); +}; + + +//___________________________________________________________________ + +class ScXMLLabelRangeContext : public SvXMLImportContext +{ +private: + ::rtl::OUString sLabelRangeStr; + ::rtl::OUString sDataRangeStr; + sal_Bool bColumnOrientation : 1; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + ScXMLLabelRangeContext( + ScXMLImport& rImport, + USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList>& xAttrList + ); + virtual ~ScXMLLabelRangeContext(); + + virtual SvXMLImportContext* CreateChildContext( + USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList>& xAttrList + ); + virtual void EndElement(); +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/xmlnexpi.hxx b/binfilter/bf_sc/source/filter/xml/xmlnexpi.hxx new file mode 100644 index 000000000000..b7e93d28fedd --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/xmlnexpi.hxx @@ -0,0 +1,108 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef SC_XMLNEXPI_HXX +#define SC_XMLNEXPI_HXX + +#include <bf_xmloff/xmlictxt.hxx> + +#include <bf_xmloff/xmlimp.hxx> +namespace binfilter { + +class ScXMLImport; + +class ScXMLNamedExpressionsContext : public SvXMLImportContext +{ + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLNamedExpressionsContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList); + + virtual ~ScXMLNamedExpressionsContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + sal_Int32 GetRangeType(const ::rtl::OUString sRangeType) const; + virtual void EndElement(); +}; + +class ScXMLNamedRangeContext : public SvXMLImportContext +{ + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLNamedRangeContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList); + + virtual ~ScXMLNamedRangeContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +class ScXMLNamedExpressionContext : public SvXMLImportContext +{ + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLNamedExpressionContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList); + + virtual ~ScXMLNamedExpressionContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/xmlrowi.hxx b/binfilter/bf_sc/source/filter/xml/xmlrowi.hxx new file mode 100644 index 000000000000..e0e2ef7bd6cf --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/xmlrowi.hxx @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef SC_XMLROWI_HXX +#define SC_XMLROWI_HXX + +#include <bf_xmloff/xmlictxt.hxx> + +#include <bf_xmloff/xmlimp.hxx> +namespace binfilter { + +class ScXMLImport; + +class ScXMLTableRowContext : public SvXMLImportContext +{ + ::rtl::OUString sStyleName; + ::rtl::OUString sVisibility; + sal_Int32 nRepeatedRows; + sal_Bool bHasCell; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLTableRowContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual ~ScXMLTableRowContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +class ScXMLTableRowsContext : public SvXMLImportContext +{ + sal_Int32 nHeaderStartRow; + sal_Int32 nHeaderEndRow; + sal_Int32 nGroupStartRow; + sal_Int32 nGroupEndRow; + sal_Bool bHeader; + sal_Bool bGroup; + sal_Bool bGroupDisplay; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLTableRowsContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + const sal_Bool bHeader, const sal_Bool bGroup); + + virtual ~ScXMLTableRowsContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/xmlsceni.hxx b/binfilter/bf_sc/source/filter/xml/xmlsceni.hxx new file mode 100644 index 000000000000..929415571fe3 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/xmlsceni.hxx @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef SC_XMLSCENI_HXX +#define SC_XMLSCENI_HXX + +#include <bf_xmloff/xmlictxt.hxx> + +#include <bf_xmloff/xmlimp.hxx> + +#include <tools/color.hxx> + +#include "rangelst.hxx" +namespace binfilter { + +class ScXMLImport; + +class ScXMLTableScenarioContext : public SvXMLImportContext +{ +private: + ::rtl::OUString sComment; + Color aBorderColor; + ScRangeList aScenarioRanges; + sal_Bool bDisplayBorder : 1; + sal_Bool bCopyBack : 1; + sal_Bool bCopyStyles : 1; + sal_Bool bCopyFormulas : 1; + sal_Bool bIsActive : 1; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLTableScenarioContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual ~ScXMLTableScenarioContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/xmlsorti.hxx b/binfilter/bf_sc/source/filter/xml/xmlsorti.hxx new file mode 100644 index 000000000000..3b5a533834c3 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/xmlsorti.hxx @@ -0,0 +1,111 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef SC_XMLSORTI_HXX +#define SC_XMLSORTI_HXX + +#include <bf_xmloff/xmlictxt.hxx> +#include <bf_xmloff/xmlimp.hxx> +#include <com/sun/star/util/SortField.hpp> +#include <com/sun/star/table/CellAddress.hpp> + +#include "xmldrani.hxx" +namespace binfilter { + +class ScXMLImport; + +class ScXMLSortContext : public SvXMLImportContext +{ + ScXMLDatabaseRangeContext* pDatabaseRangeContext; + + ::com::sun::star::uno::Sequence < ::com::sun::star::util::SortField> aSortFields; + ::com::sun::star::table::CellAddress aOutputPosition; + ::rtl::OUString sCountry; + ::rtl::OUString sLanguage; + ::rtl::OUString sAlgorithm; + sal_Int16 nUserListIndex; + sal_Bool bCopyOutputData : 1; + sal_Bool bBindFormatsToContent : 1; + sal_Bool bIsCaseSensitive : 1; + sal_Bool bEnabledUserList : 1; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLSortContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLDatabaseRangeContext* pTempDatabaseRangeContext); + + virtual ~ScXMLSortContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); + + void AddSortField(const ::rtl::OUString& sFieldNumber, const ::rtl::OUString& sDataType, const ::rtl::OUString& sOrder); +}; + +class ScXMLSortByContext : public SvXMLImportContext +{ + ScXMLSortContext* pSortContext; + + ::rtl::OUString sFieldNumber; + ::rtl::OUString sDataType; + ::rtl::OUString sOrder; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLSortByContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + ScXMLSortContext* pTempSortContext); + + virtual ~ScXMLSortByContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/xmlstyle.hxx b/binfilter/bf_sc/source/filter/xml/xmlstyle.hxx new file mode 100644 index 000000000000..758df10afe5e --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/xmlstyle.hxx @@ -0,0 +1,336 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SC_XMLSTYLE_HXX +#define _SC_XMLSTYLE_HXX + +#include <bf_xmloff/maptype.hxx> +#include <bf_xmloff/xmlaustp.hxx> +#include <bf_xmloff/xmltypes.hxx> +#include <bf_xmloff/xmlprmap.hxx> +#include <bf_xmloff/prhdlfac.hxx> +#include <bf_xmloff/styleexp.hxx> +#include <bf_xmloff/xmlexppr.hxx> +#include <bf_xmloff/contextid.hxx> +namespace binfilter { + +extern const XMLPropertyMapEntry aXMLScCellStylesProperties[]; +extern const XMLPropertyMapEntry aXMLScColumnStylesProperties[]; +extern const XMLPropertyMapEntry aXMLScRowStylesProperties[]; +extern const XMLPropertyMapEntry aXMLScTableStylesProperties[]; + +//CellStyles +#define XML_SC_TYPE_CELLPROTECTION (XML_SC_TYPES_START + 1) +#define XML_SC_TYPE_PRINTCONTENT (XML_SC_TYPES_START + 2) +#define XML_SC_TYPE_HORIJUSTIFY (XML_SC_TYPES_START + 3) +#define XML_SC_TYPE_HORIJUSTIFYSOURCE (XML_SC_TYPES_START + 4) +#define XML_SC_TYPE_ORIENTATION (XML_SC_TYPES_START + 6) +#define XML_SC_TYPE_ROTATEANGLE (XML_SC_TYPES_START + 7) +#define XML_SC_TYPE_ROTATEREFERENCE (XML_SC_TYPES_START + 8) +#define XML_SC_TYPE_BORDERLEFT (XML_SC_TYPES_START + 9) +#define XML_SC_TYPE_BORDERRIGHT (XML_SC_TYPES_START + 10) +#define XML_SC_TYPE_BORDERTOP (XML_SC_TYPES_START + 11) +#define XML_SC_TYPE_BORDERBOTTOM (XML_SC_TYPES_START + 12) +#define XML_SC_TYPE_VERTJUSTIFY (XML_SC_TYPES_START + 13) +#define XML_SC_ISTEXTWRAPPED (XML_SC_TYPES_START + 14) +#define XML_SC_TYPE_EQUAL (XML_SC_TYPES_START + 15) +#define XML_SC_TYPE_VERTICAL (XML_SC_TYPES_START + 16) + +#define CTF_SC_HORIJUSTIFY (XML_SC_CTF_START + 1) +#define CTF_SC_HORIJUSTIFY_SOURCE (XML_SC_CTF_START + 2) +#define CTF_SC_ALLPADDING (XML_SC_CTF_START + 3) +#define CTF_SC_BOTTOMPADDING (XML_SC_CTF_START + 4) +#define CTF_SC_LEFTPADDING (XML_SC_CTF_START + 5) +#define CTF_SC_RIGHTPADDING (XML_SC_CTF_START + 6) +#define CTF_SC_TOPPADDING (XML_SC_CTF_START + 7) +#define CTF_SC_ALLBORDER (XML_SC_CTF_START + 8) +#define CTF_SC_LEFTBORDER (XML_SC_CTF_START + 9) +#define CTF_SC_RIGHTBORDER (XML_SC_CTF_START + 10) +#define CTF_SC_TOPBORDER (XML_SC_CTF_START + 11) +#define CTF_SC_BOTTOMBORDER (XML_SC_CTF_START + 12) +#define CTF_SC_ALLBORDERWIDTH (XML_SC_CTF_START + 13) +#define CTF_SC_LEFTBORDERWIDTH (XML_SC_CTF_START + 14) +#define CTF_SC_RIGHTBORDERWIDTH (XML_SC_CTF_START + 15) +#define CTF_SC_TOPBORDERWIDTH (XML_SC_CTF_START + 16) +#define CTF_SC_BOTTOMBORDERWIDTH (XML_SC_CTF_START + 17) +#define CTF_SC_NUMBERFORMAT (XML_SC_CTF_START + 18) +#define CTF_SC_MAP (XML_SC_CTF_START + 19) +#define CTF_SC_PARAINDENT (XML_SC_CTF_START + 20) +#define CTF_SC_OLDTEXTBACKGROUND (XML_SC_CTF_START + 21) +#define CTF_SC_IMPORT_MAP (XML_SC_CTF_START + 22) +#define CTF_SC_CELLSTYLE (XML_SC_CTF_START + 23) +#define CTF_SC_VALIDATION (XML_SC_CTF_START + 24) + +#define CTF_SC_ROWHEIGHT (XML_SC_CTF_START + 50) +#define CTF_SC_ROWOPTIMALHEIGHT (XML_SC_CTF_START + 51) +#define CTF_SC_ROWBREAKBEFORE (XML_SC_CTF_START + 52) +#define CTF_SC_ISVISIBLE (XML_SC_CTF_START + 53) + +#define CTF_SC_MASTERPAGENAME (XML_SC_CTF_START + 53) + +//ColumnStyles +#define XML_SC_TYPE_BREAKBEFORE (XML_SC_TYPES_START + 50) + +class ScXMLExport; +class ScXMLImport; + +class ScXMLCellExportPropertyMapper : public SvXMLExportPropertyMapper +{ +protected: + /** Application-specific filter. By default do nothing. */ + virtual void ContextFilter( + ::std::vector< XMLPropertyState >& rProperties, + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > rPropSet ) const; +public: + ScXMLCellExportPropertyMapper( + const UniReference< XMLPropertySetMapper >& rMapper ); + virtual ~ScXMLCellExportPropertyMapper(); + + /** this method is called for every item that has the MID_FLAG_SPECIAL_ITEM_EXPORT flag set */ + virtual void handleSpecialItem( + SvXMLAttributeList& rAttrList, + const XMLPropertyState& rProperty, + const SvXMLUnitConverter& rUnitConverter, + const SvXMLNamespaceMap& rNamespaceMap, + const ::std::vector< XMLPropertyState > *pProperties = 0, + sal_uInt32 nIdx = 0 ) const; +}; + +class ScXMLRowExportPropertyMapper : public SvXMLExportPropertyMapper +{ +protected: + /** Application-specific filter. By default do nothing. */ + virtual void ContextFilter( + ::std::vector< XMLPropertyState >& rProperties, + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > rPropSet ) const; +public: + ScXMLRowExportPropertyMapper( + const UniReference< XMLPropertySetMapper >& rMapper ); + virtual ~ScXMLRowExportPropertyMapper(); +}; + +class ScXMLColumnExportPropertyMapper : public SvXMLExportPropertyMapper +{ +public: + ScXMLColumnExportPropertyMapper( + const UniReference< XMLPropertySetMapper >& rMapper ); + virtual ~ScXMLColumnExportPropertyMapper(); + + /** this method is called for every item that has the MID_FLAG_SPECIAL_ITEM_EXPORT flag set */ + virtual void handleSpecialItem( + SvXMLAttributeList& rAttrList, + const XMLPropertyState& rProperty, + const SvXMLUnitConverter& rUnitConverter, + const SvXMLNamespaceMap& rNamespaceMap, + const ::std::vector< XMLPropertyState > *pProperties = 0, + sal_uInt32 nIdx = 0 ) const; +}; + +class ScXMLTableExportPropertyMapper : public SvXMLExportPropertyMapper +{ +protected: +public: + ScXMLTableExportPropertyMapper( + const UniReference< XMLPropertySetMapper >& rMapper ); + virtual ~ScXMLTableExportPropertyMapper(); + + /** this method is called for every item that has the MID_FLAG_SPECIAL_ITEM_EXPORT flag set */ + virtual void handleSpecialItem( + SvXMLAttributeList& rAttrList, + const XMLPropertyState& rProperty, + const SvXMLUnitConverter& rUnitConverter, + const SvXMLNamespaceMap& rNamespaceMap, + const ::std::vector< XMLPropertyState > *pProperties = 0, + sal_uInt32 nIdx = 0 ) const; +}; + +class ScXMLAutoStylePoolP : public SvXMLAutoStylePoolP +{ + ScXMLExport& rScXMLExport; + + virtual void exportStyleAttributes( + SvXMLAttributeList& rAttrList, + sal_Int32 nFamily, + const ::std::vector< XMLPropertyState >& rProperties, + const SvXMLExportPropertyMapper& rPropExp, + const SvXMLUnitConverter& rUnitConverter, + const SvXMLNamespaceMap& rNamespaceMap + ) const; + + virtual void exportStyleContent( + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > & rHandler, + sal_Int32 nFamily, + const ::std::vector< XMLPropertyState >& rProperties, + const SvXMLExportPropertyMapper& rPropExp + , const SvXMLUnitConverter& rUnitConverter, + const SvXMLNamespaceMap& rNamespaceMap + ) const; + +public: + ScXMLAutoStylePoolP(ScXMLExport& rScXMLExport); + virtual ~ScXMLAutoStylePoolP(); +}; + +class ScXMLStyleExport : public XMLStyleExport +{ + virtual void exportStyleAttributes( + const ::com::sun::star::uno::Reference< + ::com::sun::star::style::XStyle > & rStyle ); + virtual void exportStyleContent( + const ::com::sun::star::uno::Reference< + ::com::sun::star::style::XStyle > & rStyle ); +public: + ScXMLStyleExport( + SvXMLExport& rExp, + const ::rtl::OUString& rPoolStyleName, + SvXMLAutoStylePoolP *pAutoStyleP=0 ); + virtual ~ScXMLStyleExport(); +}; + +class XMLScPropHdlFactory : public XMLPropertyHandlerFactory +{ +public: + XMLScPropHdlFactory(); + virtual ~XMLScPropHdlFactory(); + virtual const XMLPropertyHandler* GetPropertyHandler( sal_Int32 nType ) const; +}; + +class XmlScPropHdl_CellProtection : public XMLPropertyHandler +{ +public: + virtual ~XmlScPropHdl_CellProtection(); + virtual sal_Bool equals( const ::com::sun::star::uno::Any& r1, const ::com::sun::star::uno::Any& r2 ) const; + virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const; + virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const; +}; + +class XmlScPropHdl_PrintContent : public XMLPropertyHandler +{ +public: + virtual ~XmlScPropHdl_PrintContent(); + virtual sal_Bool equals( const ::com::sun::star::uno::Any& r1, const ::com::sun::star::uno::Any& r2 ) const; + virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const; + virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const; +}; + +class XmlScPropHdl_HoriJustify : public XMLPropertyHandler +{ +public: + virtual ~XmlScPropHdl_HoriJustify(); + virtual sal_Bool equals( const ::com::sun::star::uno::Any& r1, const ::com::sun::star::uno::Any& r2 ) const; + virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const; + virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const; +}; + +class XmlScPropHdl_HoriJustifySource : public XMLPropertyHandler +{ +public: + virtual ~XmlScPropHdl_HoriJustifySource(); + virtual sal_Bool equals( const ::com::sun::star::uno::Any& r1, const ::com::sun::star::uno::Any& r2 ) const; + virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const; + virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const; +}; + +class XmlScPropHdl_Orientation : public XMLPropertyHandler +{ +public: + virtual ~XmlScPropHdl_Orientation(); + virtual sal_Bool equals( const ::com::sun::star::uno::Any& r1, const ::com::sun::star::uno::Any& r2 ) const; + virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const; + virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const; +}; + +class XmlScPropHdl_RotateAngle : public XMLPropertyHandler +{ +public: + virtual ~XmlScPropHdl_RotateAngle(); + virtual sal_Bool equals( const ::com::sun::star::uno::Any& r1, const ::com::sun::star::uno::Any& r2 ) const; + virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const; + virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const; +}; + +class XmlScPropHdl_RotateReference : public XMLPropertyHandler +{ +public: + virtual ~XmlScPropHdl_RotateReference(); + virtual sal_Bool equals( const ::com::sun::star::uno::Any& r1, const ::com::sun::star::uno::Any& r2 ) const; + virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const; + virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const; +}; + +class XmlScPropHdl_VertJustify : public XMLPropertyHandler +{ +public: + virtual ~XmlScPropHdl_VertJustify(); + virtual sal_Bool equals( const ::com::sun::star::uno::Any& r1, const ::com::sun::star::uno::Any& r2 ) const; + virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const; + virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const; +}; + +class XmlScPropHdl_BreakBefore : public XMLPropertyHandler +{ +public: + virtual ~XmlScPropHdl_BreakBefore(); + virtual sal_Bool equals( const ::com::sun::star::uno::Any& r1, const ::com::sun::star::uno::Any& r2 ) const; + virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const; + virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const; +}; + +class XmlScPropHdl_IsTextWrapped : public XMLPropertyHandler +{ +public: + virtual ~XmlScPropHdl_IsTextWrapped(); + virtual sal_Bool equals( const ::com::sun::star::uno::Any& r1, const ::com::sun::star::uno::Any& r2 ) const; + virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const; + virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const; +}; + +class XmlScPropHdl_IsEqual : public XMLPropertyHandler +{ +public: + virtual ~XmlScPropHdl_IsEqual() {} + virtual sal_Bool equals( const ::com::sun::star::uno::Any& r1, const ::com::sun::star::uno::Any& r2 ) const { return sal_True; } + virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const; + virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const; +}; + +class XmlScPropHdl_Vertical : public XMLPropertyHandler +{ +public: + virtual ~XmlScPropHdl_Vertical(); + virtual sal_Bool equals( const ::com::sun::star::uno::Any& r1, const ::com::sun::star::uno::Any& r2 ) const; + virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const; + virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const; +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/xmlstyli.hxx b/binfilter/bf_sc/source/filter/xml/xmlstyli.hxx new file mode 100644 index 000000000000..07dad6bc151a --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/xmlstyli.hxx @@ -0,0 +1,297 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _XMLSTYLI_HXX +#define _XMLSTYLI_HXX + +#include <rtl/ustring.hxx> +#ifndef __SGI_STL_VECTOR +#include <vector> +#endif +#include <bf_xmloff/xmlimp.hxx> +#include <bf_xmloff/xmlictxt.hxx> +#include <bf_xmloff/maptype.hxx> +#include <bf_xmloff/prstylei.hxx> +#include <bf_xmloff/xmlimppr.hxx> +#include <bf_xmloff/XMLTextMasterPageContext.hxx> +#include <bf_xmloff/XMLTextMasterStylesContext.hxx> +#include <com/sun/star/sheet/ConditionOperator.hpp> +#include "xmlimprt.hxx" +namespace binfilter { + +class ScXMLCellImportPropertyMapper : public SvXMLImportPropertyMapper +{ +protected: + +public: + + ScXMLCellImportPropertyMapper( + const UniReference< XMLPropertySetMapper >& rMapper, + SvXMLImport& rImport); + virtual ~ScXMLCellImportPropertyMapper(); + + /** this method is called for every item that has the MID_FLAG_SPECIAL_ITEM_IMPORT flag set */ +/* virtual sal_Bool handleSpecialItem( + XMLPropertyState& rProperty, + ::std::vector< XMLPropertyState >& rProperties, + const ::rtl::OUString& rValue, + const SvXMLUnitConverter& rUnitConverter, + const SvXMLNamespaceMap& rNamespaceMap ) const;*/ + + /** this method is called for every item that has the MID_FLAG_NO_ITEM_IMPORT flag set */ +/* virtual sal_Bool handleNoItem( + sal_Int32 nIndex, + ::std::vector< XMLPropertyState >& rProperties, + const ::rtl::OUString& rValue, + const SvXMLUnitConverter& rUnitConverter, + const SvXMLNamespaceMap& rNamespaceMap ) const;*/ + + /** This method is called when all attributes have been processed. It may be used to remove items that are incomplete */ + virtual void finished( + ::std::vector< XMLPropertyState >& rProperties, sal_Int32 nStartIndex, sal_Int32 nEndIndex ) const; +}; + +class ScXMLRowImportPropertyMapper : public SvXMLImportPropertyMapper +{ +protected: + +public: + + ScXMLRowImportPropertyMapper( + const UniReference< XMLPropertySetMapper >& rMapper, + SvXMLImport& rImport); + virtual ~ScXMLRowImportPropertyMapper(); + + /** This method is called when all attributes have been processed. It may be used to remove items that are incomplete */ + virtual void finished( + ::std::vector< XMLPropertyState >& rProperties, sal_Int32 nStartIndex, sal_Int32 nEndIndex ) const; +}; +struct ScXMLMapContent; + +class XMLTableStyleContext : public XMLPropStyleContext +{ + ::rtl::OUString sDataStyleName; + ::rtl::OUString sPageStyle; + const ::rtl::OUString sNumberFormat; + SvXMLStylesContext* pStyles; + std::vector<ScXMLMapContent> aMaps; + ::com::sun::star::uno::Any aConditionalFormat; + sal_Int32 nNumberFormat; + sal_Bool bConditionalFormatCreated : 1; + sal_Bool bParentSet : 1; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + + void SetOperator(::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aProps, + const ::com::sun::star::sheet::ConditionOperator aOp) const; + void SetBaseCellAddress(::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aProps, + const ::rtl::OUString& sBaseCell) const; + void SetStyle(::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aProps, + const ::rtl::OUString& sApplyStyle) const; + void SetFormula1(::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aProps, + const ::rtl::OUString& sFormula) const; + void SetFormula2(::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aProps, + const ::rtl::OUString& sFormula) const; + void SetFormulas(::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aProps, + const ::rtl::OUString& sFormulas) const; + + void GetConditionalFormat( + ::com::sun::star::uno::Any& aAny, const ::rtl::OUString& sCondition, + const ::rtl::OUString& sApplyStyle, const ::rtl::OUString& sBaseCell) const; +protected: + + virtual void SetAttribute( sal_uInt16 nPrefixKey, + const ::rtl::OUString& rLocalName, + const ::rtl::OUString& rValue ); + +public: + + TYPEINFO(); + + XMLTableStyleContext( ScXMLImport& rImport, sal_uInt16 nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList, + SvXMLStylesContext& rStyles, sal_uInt16 nFamily, sal_Bool bDefaultStyle = sal_False ); + virtual ~XMLTableStyleContext(); + + virtual SvXMLImportContext *CreateChildContext( + sal_uInt16 nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); + + virtual void FillPropertySet(const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > & rPropSet ); + + virtual void SetDefaults(); + + void AddProperty(sal_Int16 nContextID, const ::com::sun::star::uno::Any& aValue); + + sal_Int32 GetNumberFormat() { return nNumberFormat; } +}; + +class XMLTableStylesContext : public SvXMLStylesContext +{ + ::com::sun::star::uno::Reference < + ::com::sun::star::container::XNameContainer > xCellStyles; + ::com::sun::star::uno::Reference < + ::com::sun::star::container::XNameContainer > xColumnStyles; + ::com::sun::star::uno::Reference < + ::com::sun::star::container::XNameContainer > xRowStyles; + ::com::sun::star::uno::Reference < + ::com::sun::star::container::XNameContainer > xTableStyles; + const ::rtl::OUString sCellStyleServiceName; + const ::rtl::OUString sColumnStyleServiceName; + const ::rtl::OUString sRowStyleServiceName; + const ::rtl::OUString sTableStyleServiceName; + sal_Int32 nNumberFormatIndex; + sal_Int32 nConditionalFormatIndex; + sal_Int32 nCellStyleIndex; + sal_Int32 nMasterPageNameIndex; + sal_Bool bAutoStyles : 1; + + UniReference < SvXMLImportPropertyMapper > xCellImpPropMapper; + UniReference < SvXMLImportPropertyMapper > xColumnImpPropMapper; + UniReference < SvXMLImportPropertyMapper > xRowImpPropMapper; + UniReference < SvXMLImportPropertyMapper > xTableImpPropMapper; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +protected: + + // Create a style context. + virtual SvXMLStyleContext *CreateStyleStyleChildContext( + sal_uInt16 nFamily, + sal_uInt16 nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); + + virtual SvXMLStyleContext *CreateDefaultStyleStyleChildContext( + sal_uInt16 nFamily, sal_uInt16 nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); + +// virtual SvXMLImportPropertyMapper *GetImpPropMapper(); + +public: + + XMLTableStylesContext( SvXMLImport& rImport, sal_uInt16 nPrfx , + const ::rtl::OUString& rLName , + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList, + const sal_Bool bAutoStyles ); + virtual ~XMLTableStylesContext(); + + // Create child element. +/* virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList > & xAttrList );*/ + + virtual void EndElement(); + + virtual UniReference < SvXMLImportPropertyMapper > GetImportPropertyMapper( + sal_uInt16 nFamily ) const; + virtual ::com::sun::star::uno::Reference < + ::com::sun::star::container::XNameContainer > + GetStylesContainer( sal_uInt16 nFamily ) const; + virtual ::rtl::OUString GetServiceName( sal_uInt16 nFamily ) const; + + sal_Int32 GetIndex(const sal_Int16 nContextID); +}; + +class ScXMLMasterStylesContext : public SvXMLStylesContext +{ +protected: + virtual SvXMLStyleContext *CreateStyleChildContext( sal_uInt16 nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); + + virtual SvXMLStyleContext *CreateStyleStyleChildContext( sal_uInt16 nFamily, + sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); + + virtual sal_Bool InsertStyleFamily( sal_uInt16 nFamily ) const; + +public: + TYPEINFO(); + + ScXMLMasterStylesContext( SvXMLImport& rImport, sal_uInt16 nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList > & xAttrList); + + virtual ~ScXMLMasterStylesContext(); + virtual void EndElement(); +}; + +namespace com { namespace sun { namespace star { + namespace style { class XStyle; } +} } } + +class ScMasterPageContext : public XMLTextMasterPageContext +{ + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> xPropSet; + const ::rtl::OUString sEmpty; + sal_Bool bContainsRightHeader : 1; + sal_Bool bContainsRightFooter : 1; + + void ClearContent(const ::rtl::OUString& rContent); +public: + + TYPEINFO(); + + ScMasterPageContext( SvXMLImport& rImport, sal_uInt16 nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList > & xAttrList, + sal_Bool bOverwrite ); + virtual ~ScMasterPageContext(); + + virtual SvXMLImportContext *CreateChildContext( + sal_uInt16 nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); + + virtual SvXMLImportContext *CreateHeaderFooterContext( + sal_uInt16 nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList, + const sal_Bool bFooter, + const sal_Bool bLeft ); + + virtual void Finish( sal_Bool bOverwrite ); +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/xmlsubti.hxx b/binfilter/bf_sc/source/filter/xml/xmlsubti.hxx new file mode 100644 index 000000000000..49fc27292d27 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/xmlsubti.hxx @@ -0,0 +1,175 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef SC_XMLSUBTI_HXX +#define SC_XMLSUBTI_HXX + +#include <bf_xmloff/xmlictxt.hxx> +#include <bf_xmloff/xmlimp.hxx> + +#include <com/sun/star/sheet/XSpreadsheet.hpp> +#include <com/sun/star/drawing/XDrawPage.hpp> +#include <com/sun/star/table/CellAddress.hpp> +#include <com/sun/star/table/XCellRange.hpp> +#include <com/sun/star/table/CellRangeAddress.hpp> +#include <com/sun/star/frame/XModel.hpp> + +#ifndef __SGI_STL_VECTOR +#include <vector> +#endif +#include <list> + +#include "XMLTableShapeResizer.hxx" +namespace binfilter { + +class ScXMLImport; + +const int nDefaultRowCount = 20; +const int nDefaultColCount = 20; +const int nDefaultTabCount = 10; + +typedef std::vector<sal_Int32> ScMysalIntVec; +typedef std::list<sal_Int32> ScMysalIntList; + +class ScMyTableData +{ +private: + ::com::sun::star::table::CellAddress aTableCellPos; + ScMysalIntVec nColsPerCol; + ScMysalIntVec nRealCols; + ScMysalIntVec nRowsPerRow; + ScMysalIntVec nRealRows; + sal_Int32 nSpannedCols; + sal_Int32 nColCount; + sal_Int32 nSubTableSpanned; + ScMysalIntList nChangedCols; +public: + ScMyTableData(sal_Int16 nSheet = -1, sal_Int32 nCol = -1, sal_Int32 nRow = -1); + ~ScMyTableData(); + ::com::sun::star::table::CellAddress GetCellPos() const { return aTableCellPos; } + sal_Int32 GetRow() const { return aTableCellPos.Row; } + sal_Int32 GetColumn() const { return aTableCellPos.Column; } + void AddRow(); + void AddColumn(); + void SetFirstColumn() { aTableCellPos.Column = -1; } + sal_Int32 GetColsPerCol(const sal_Int32 nIndex) const { return nColsPerCol[nIndex]; } + void SetColsPerCol(const sal_Int32 nIndex, sal_Int32 nValue = 1) { nColsPerCol[nIndex] = nValue; } + sal_Int32 GetRealCols(const sal_Int32 nIndex, const sal_Bool bIsNormal = sal_True) const; + void SetRealCols(const sal_Int32 nIndex, const sal_Int32 nValue) { nRealCols[nIndex] = nValue; } + sal_Int32 GetRowsPerRow(const sal_Int32 nIndex) const { return nRowsPerRow[nIndex]; } + void SetRowsPerRow(const sal_Int32 nIndex, const sal_Int32 nValue = 1) { nRowsPerRow[nIndex] = nValue; } + sal_Int32 GetRealRows(const sal_Int32 nIndex) const { return nIndex < 0 ? 0 : nRealRows[nIndex]; } + void SetRealRows(const sal_Int32 nIndex, const sal_Int32 nValue) { nRealRows[nIndex] = nValue; } + sal_Int32 GetSpannedCols() const { return nSpannedCols; } + void SetSpannedCols(const sal_Int32 nTempSpannedCols) { nSpannedCols = nTempSpannedCols; } + sal_Int32 GetColCount() const { return nColCount; } + void SetColCount(const sal_Int32 nTempColCount) { nColCount = nTempColCount; } + sal_Int32 GetSubTableSpanned() const { return nSubTableSpanned; } + void SetSubTableSpanned(const sal_Int32 nValue) { nSubTableSpanned = nValue; } + sal_Int32 GetChangedCols(const sal_Int32 nFromIndex, const sal_Int32 nToIndex) const; + void SetChangedCols(const sal_Int32 nValue); +}; + +//******************************************************************************************************************************* + +class ScMyTables +{ +private: + typedef std::list< ::com::sun::star::table::CellRangeAddress> ScMyMatrixRangeList; + + ScXMLImport& rImport; + + ScMyShapeResizer aResizeShapes; + + ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet > xCurrentSheet; + ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange > xCurrentCellRange; + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > xDrawPage; + ::com::sun::star::uno::Reference < ::com::sun::star::drawing::XShapes > xShapes; + ::rtl::OUString sCurrentSheetName; + ::rtl::OUString sPassword; + std::vector<ScMyTableData*> aTableVec; + ScMyMatrixRangeList aMatrixRangeList; + ::com::sun::star::table::CellAddress aRealCellPos; + sal_Int32 nCurrentColStylePos; + sal_Int16 nCurrentDrawPage; + sal_Int16 nCurrentXShapes; + sal_Int16 nTableCount; + sal_Int16 nCurrentSheet; + sal_Bool bProtection : 1; + + sal_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(sal_Bool bIsCovered); +public: + ScMyTables(ScXMLImport& rImport); + ~ScMyTables(); + void NewSheet(const ::rtl::OUString& sTableName, const ::rtl::OUString& sStyleName, + const sal_Bool bProtection, const ::rtl::OUString& sPassword); + void AddRow(); + void SetRowStyle(const ::rtl::OUString& rCellStyleName); + void AddColumn(sal_Bool bIsCovered); + void NewTable(sal_Int32 nTempSpannedCols); + void UpdateRowHeights(); + void ResizeShapes() { aResizeShapes.ResizeShapes(); } + void DeleteTable(); + ::com::sun::star::table::CellAddress GetRealCellPos(); + void AddColCount(sal_Int32 nTempColCount); + void AddColStyle(const sal_Int32 nRepeat, const ::rtl::OUString& rCellStyleName); + ::rtl::OUString GetCurrentSheetName() const { return sCurrentSheetName; } + sal_Int16 GetCurrentSheet() const { return nCurrentSheet; } + sal_Int32 GetCurrentColumn() const { return aTableVec[nTableCount - 1]->GetColCount(); } + sal_Int32 GetCurrentRow() const { return aTableVec[nTableCount - 1]->GetRow(); } + ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet > + GetCurrentXSheet() { return xCurrentSheet; } + ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange > + GetCurrentXCellRange() { return xCurrentCellRange; } + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > + GetCurrentXDrawPage(); + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > + GetCurrentXShapes(); + sal_Bool HasDrawPage(); + sal_Bool HasXShapes(); + void AddShape(::com::sun::star::uno::Reference < ::com::sun::star::drawing::XShape>& rShape, + ::rtl::OUString* pRangeList, + ::com::sun::star::table::CellAddress& rStartAddress, + ::com::sun::star::table::CellAddress& rEndAddress, + sal_Int32 nEndX, sal_Int32 nEndY); + + void AddMatrixRange(sal_uInt32 nStartColumn, sal_uInt32 nStartRow, sal_uInt32 nEndColumn, sal_uInt32 nEndRow); + sal_Bool IsPartOfMatrix(sal_uInt32 nColumn, sal_uInt32 nRow); +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sc/source/filter/xml/xmltabi.hxx b/binfilter/bf_sc/source/filter/xml/xmltabi.hxx new file mode 100644 index 000000000000..1e8638719922 --- /dev/null +++ b/binfilter/bf_sc/source/filter/xml/xmltabi.hxx @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef SC_XMLTABI_HXX +#define SC_XMLTABI_HXX + +#include <bf_xmloff/xmlictxt.hxx> +namespace binfilter { + +class ScXMLImport; + +class ScXMLTableContext : public SvXMLImportContext +{ + ::rtl::OUString sPrintRanges; + sal_Bool bStartFormPage : 1; + + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } + ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + +public: + + ScXMLTableContext( ScXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList, + const sal_Bool bTempIsSubTable = sal_False, + const sal_Int32 nSpannedCols = 0); + + virtual ~ScXMLTableContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |