diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-02-07 22:27:14 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-02-11 22:33:31 -0500 |
commit | 821521f757569c96ded6004bb2cb0d003481b55b (patch) | |
tree | 17b98a5a220f67cd8faf9535e036c02923d30099 | |
parent | fb61d3f82d127d9199ead8a3042d007d134eb937 (diff) |
First cut on the re-work. Lots of things are still broken.
Change-Id: Iec54d5f04cef1e17375d7414a71bec64431905d5
-rw-r--r-- | sc/Library_sc.mk | 3 | ||||
-rw-r--r-- | sc/source/filter/xml/XMLTextPContext.cxx | 209 | ||||
-rw-r--r-- | sc/source/filter/xml/XMLTextPContext.hxx | 65 | ||||
-rw-r--r-- | sc/source/filter/xml/celltextparacontext.cxx | 98 | ||||
-rw-r--r-- | sc/source/filter/xml/celltextparacontext.hxx | 56 | ||||
-rw-r--r-- | sc/source/filter/xml/importcontext.cxx | 28 | ||||
-rw-r--r-- | sc/source/filter/xml/importcontext.hxx | 29 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlcelli.cxx | 74 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlcelli.hxx | 5 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlimprt.cxx | 16 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlimprt.hxx | 6 |
11 files changed, 257 insertions, 332 deletions
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk index 865f5f0c3e6e..a0d4bf83f66e 100644 --- a/sc/Library_sc.mk +++ b/sc/Library_sc.mk @@ -266,9 +266,10 @@ $(eval $(call gb_Library_add_exception_objects,sc,\ sc/source/filter/xml/XMLTableShapeResizer \ sc/source/filter/xml/XMLTableShapesContext \ sc/source/filter/xml/XMLTableSourceContext \ - sc/source/filter/xml/XMLTextPContext \ sc/source/filter/xml/XMLTrackedChangesContext \ sc/source/filter/xml/cachedattraccess \ + sc/source/filter/xml/celltextparacontext \ + sc/source/filter/xml/importcontext \ sc/source/filter/xml/sheetdata \ sc/source/filter/xml/xmlannoi \ sc/source/filter/xml/xmlbodyi \ diff --git a/sc/source/filter/xml/XMLTextPContext.cxx b/sc/source/filter/xml/XMLTextPContext.cxx deleted file mode 100644 index 6e850f238f53..000000000000 --- a/sc/source/filter/xml/XMLTextPContext.cxx +++ /dev/null @@ -1,209 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "XMLTextPContext.hxx" -#include "xmlimprt.hxx" -#include "xmlcelli.hxx" -#include <xmloff/xmlnmspe.hxx> -#include <xmloff/xmltoken.hxx> -#include <xmloff/nmspmap.hxx> -#include <com/sun/star/text/XTextCursor.hpp> - -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, sal_uInt16 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, - sal_uInt16 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; - sal_Int32 nCount(1); - for( sal_Int16 i=0; i < nAttrCount; ++i ) - { - sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName( - xAttrList->getNameByIndex( i ), &aLocalName )); - const rtl::OUString& 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, - sal_uInt16 nPrfx, - const ::rtl::OUString& rLName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& xTempAttrList, - ScXMLTableRowCellContext* pTempCellContext) : - SvXMLImportContext( rImport, nPrfx, rLName ), - xAttrList(xTempAttrList), - pTextPContext(NULL), - pCellContext(pTempCellContext), - sLName(rLName), - sSimpleContent(), - pContentBuffer(NULL), - nPrefix(nPrfx) -{ - // here are no attributes -} - -ScXMLTextPContext::~ScXMLTextPContext() -{ - if (pTextPContext) - delete pTextPContext; - if (pContentBuffer) - delete pContentBuffer; -} - -void ScXMLTextPContext::AddSpaces(sal_Int32 nSpaceCount) -{ - // use pContentBuffer - if ( !pContentBuffer ) - pContentBuffer = new rtl::OUStringBuffer( sSimpleContent ); - - sal_Char* pChars = new sal_Char[nSpaceCount]; - memset(pChars, ' ', nSpaceCount); - pContentBuffer->appendAscii(pChars, nSpaceCount); -} - -SvXMLImportContext *ScXMLTextPContext::CreateChildContext( sal_uInt16 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) - { - rtl::OUString sSetString; - if ( pContentBuffer ) - sSetString = pContentBuffer->makeStringAndClear(); - else - sSetString = sSimpleContent; - - sal_Unicode cNonSpace(0); - - sal_Int32 nLength = sSetString.getLength(); - if ( nLength > 0 ) - { - sal_Unicode cLast = sSetString.getStr()[ nLength - 1 ]; - if ( cLast != (sal_Unicode)' ' ) - { - // #i53253# To keep XMLParaContext's whitespace handling in sync, - // if there's a non-space character at the end of the existing string, - // it has to be processed by XMLParaContext. - - cNonSpace = cLast; - sSetString = sSetString.copy( 0, nLength - 1 ); // remove from the string for SetCursorOnTextImport - } - } - - pCellContext->SetCursorOnTextImport( sSetString ); - - pTextPContext = GetScImport().GetTextImport()->CreateTextChildContext( - GetScImport(), nPrefix, sLName, xAttrList); - - if ( cNonSpace != 0 ) - { - // pass non-space character through XMLParaContext, so a following space isn't ignored - pTextPContext->Characters( rtl::OUString( cNonSpace ) ); - } - } - 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) - { - // For the first call to an empty context, copy (ref-counted) the OUString. - // The OUStringBuffer is used only if there is more complex content. - - if ( !pContentBuffer && sSimpleContent.isEmpty() ) - sSimpleContent = rChars; - else - { - if ( !pContentBuffer ) - pContentBuffer = new rtl::OUStringBuffer( sSimpleContent ); - pContentBuffer->append(rChars); - } - } - else - pTextPContext->Characters(rChars); -} - -void ScXMLTextPContext::EndElement() -{ - if (!pTextPContext) - { - if ( pContentBuffer ) - pCellContext->SetString(pContentBuffer->makeStringAndClear()); - else - pCellContext->SetString(sSimpleContent); - } - else - { - pTextPContext->EndElement(); - GetScImport().SetRemoveLastChar(sal_True); - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/filter/xml/XMLTextPContext.hxx b/sc/source/filter/xml/XMLTextPContext.hxx deleted file mode 100644 index 23b4caa5494a..000000000000 --- a/sc/source/filter/xml/XMLTextPContext.hxx +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef SC_XMLTEXTPCONTEXT_HXX -#define SC_XMLTEXTPCONTEXT_HXX - -#include <xmloff/xmlictxt.hxx> -#include <rtl/ustrbuf.hxx> - -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::OUString sSimpleContent; // copy of the first Character call's argument - rtl::OUStringBuffer* pContentBuffer; // used if there's more than one string - sal_uInt16 nPrefix; - - const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } - ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } - -public: - ScXMLTextPContext( ScXMLImport& rImport, sal_uInt16 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( sal_uInt16 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); -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/filter/xml/celltextparacontext.cxx b/sc/source/filter/xml/celltextparacontext.cxx new file mode 100644 index 000000000000..a70143e07a53 --- /dev/null +++ b/sc/source/filter/xml/celltextparacontext.cxx @@ -0,0 +1,98 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "celltextparacontext.hxx" +#include "xmlimprt.hxx" +#include "xmlcelli.hxx" + +#include <com/sun/star/xml/sax/XAttributeList.hpp> + +using namespace com::sun::star; + +ScXMLCellTextParaContext::ScXMLCellTextParaContext( + ScXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLName, ScXMLTableRowCellContext& rParent) : + ScXMLImportContext(rImport, nPrefix, rLName), + mrParentCxt(rParent) +{ +} + +void ScXMLCellTextParaContext::StartElement(const uno::Reference<xml::sax::XAttributeList>& xAttrList) +{ +} + +void ScXMLCellTextParaContext::EndElement() +{ + OUString aPara = maContent.makeStringAndClear(); + if (aPara.isEmpty()) + return; + + mrParentCxt.PushParagraph(aPara); +} + +void ScXMLCellTextParaContext::Characters(const OUString& rChars) +{ + if (rChars.isEmpty()) + return; + + maContent.append(rChars); +} + +SvXMLImportContext* ScXMLCellTextParaContext::CreateChildContext( + sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference<xml::sax::XAttributeList>& xAttrList) +{ + const SvXMLTokenMap& rTokenMap = GetScImport().GetCellTextParaElemTokenMap(); + switch (rTokenMap.Get(nPrefix, rLocalName)) + { + case XML_TOK_CELL_TEXT_SPAN: + return new ScXMLCellTextSpanContext(GetScImport(), nPrefix, rLocalName, *this); + break; + default: + ; + } + + return new SvXMLImportContext(GetImport(), nPrefix, rLocalName); +} + +void ScXMLCellTextParaContext::PushSpan(const OUString& rSpan) +{ + if (rSpan.isEmpty()) + return; + + maContent.append(rSpan); +} + +ScXMLCellTextSpanContext::ScXMLCellTextSpanContext( + ScXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLName, ScXMLCellTextParaContext& rParent) : + ScXMLImportContext(rImport, nPrefix, rLName), + mrParentCxt(rParent) +{ +} + +void ScXMLCellTextSpanContext::StartElement(const uno::Reference<xml::sax::XAttributeList>& xAttrList) +{ +} + +void ScXMLCellTextSpanContext::EndElement() +{ + if (!maContent.isEmpty()) + mrParentCxt.PushSpan(maContent); +} + +void ScXMLCellTextSpanContext::Characters(const OUString& rChars) +{ + maContent = rChars; +} + +SvXMLImportContext* ScXMLCellTextSpanContext::CreateChildContext( + sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference<xml::sax::XAttributeList>& xAttrList) +{ + return new SvXMLImportContext(GetImport(), nPrefix, rLocalName); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/filter/xml/celltextparacontext.hxx b/sc/source/filter/xml/celltextparacontext.hxx new file mode 100644 index 000000000000..ecc68808f571 --- /dev/null +++ b/sc/source/filter/xml/celltextparacontext.hxx @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef __SC_XML_CELLTEXTPARACONTEXT_HXX__ +#define __SC_XML_CELLTEXTPARACONTEXT_HXX__ + +#include "importcontext.hxx" + +class ScXMLImport; +class ScXMLTableRowCellContext; + +/** + * This context handles <text:p> element inside <table:table-cell>. + */ +class ScXMLCellTextParaContext : public ScXMLImportContext +{ + ScXMLTableRowCellContext& mrParentCxt; + OUStringBuffer maContent; +public: + ScXMLCellTextParaContext(ScXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLName, ScXMLTableRowCellContext& rParent); + + virtual void StartElement(const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList>& xAttrList); + virtual void EndElement(); + virtual void Characters(const OUString& rChars); + virtual SvXMLImportContext* CreateChildContext( + sal_uInt16 nPrefix, const OUString& rLocalName, const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList>& xAttrList); + + void PushSpan(const OUString& rSpan); +}; + +/** + * This context handles <text:span> element inside <text:p>. + */ +class ScXMLCellTextSpanContext : public ScXMLImportContext +{ + ScXMLCellTextParaContext& mrParentCxt; + OUString maContent; +public: + ScXMLCellTextSpanContext(ScXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLName, ScXMLCellTextParaContext& rParent); + + virtual void StartElement(const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList>& xAttrList); + virtual void EndElement(); + virtual void Characters(const OUString& rChars); + virtual SvXMLImportContext* CreateChildContext( + sal_uInt16 nPrefix, const OUString& rLocalName, const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList>& xAttrList); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file diff --git a/sc/source/filter/xml/importcontext.cxx b/sc/source/filter/xml/importcontext.cxx new file mode 100644 index 000000000000..b4e120737dbb --- /dev/null +++ b/sc/source/filter/xml/importcontext.cxx @@ -0,0 +1,28 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "importcontext.hxx" +#include "xmlimprt.hxx" + +ScXMLImportContext::ScXMLImportContext(SvXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName) : + SvXMLImportContext(rImport, nPrefix, rLocalName) +{ +} + +ScXMLImport& ScXMLImportContext::GetScImport() +{ + return static_cast<ScXMLImport&>(GetImport()); +} + +const ScXMLImport& ScXMLImportContext::GetScImport() const +{ + return static_cast<const ScXMLImport&>(GetImport()); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/filter/xml/importcontext.hxx b/sc/source/filter/xml/importcontext.hxx new file mode 100644 index 000000000000..d2db48a09f03 --- /dev/null +++ b/sc/source/filter/xml/importcontext.hxx @@ -0,0 +1,29 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "xmloff/xmlictxt.hxx" +#include "xmloff/xmlimp.hxx" + +class ScXMLImport; + +/** + * This class exists only to provide GetScImport() to its derived classes. + */ +class ScXMLImportContext : public SvXMLImportContext +{ +public: + ScXMLImportContext( + SvXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName); + +protected: + ScXMLImport& GetScImport(); + const ScXMLImport& GetScImport() const; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx index cf787e9754c0..4659c2aa0780 100644 --- a/sc/source/filter/xml/xmlcelli.cxx +++ b/sc/source/filter/xml/xmlcelli.cxx @@ -37,8 +37,8 @@ #include "docpool.hxx" #include "XMLTableShapeImportHelper.hxx" -#include "XMLTextPContext.hxx" #include "XMLStylesImportHelper.hxx" +#include "celltextparacontext.hxx" #include "arealink.hxx" #include <sfx2/linkmgr.hxx> @@ -301,6 +301,11 @@ bool cellExists( const ScAddress& rCellPos ) } +void ScXMLTableRowCellContext::PushParagraph(const OUString& rPara) +{ + maParagraphs.push_back(rPara); +} + void ScXMLTableRowCellContext::SetCursorOnTextImport(const rtl::OUString& rOUTempText) { ScAddress aCellPos = rXMLImport.GetTables().GetCurrentCellPos(); @@ -353,49 +358,7 @@ SvXMLImportContext *ScXMLTableRowCellContext::CreateChildContext( sal_uInt16 nPr bIsEmpty = false; bTextP = true; - ScAddress aCellPos = rXMLImport.GetTables().GetCurrentCellPos(); - - if (((nCellType == util::NumberFormat::TEXT) || maFormula || bFormulaTextResult)) - { - if (maFormula) - { - pContext = new ScXMLTextPContext(rXMLImport, nPrefix, rLName, xAttrList, this); - } - else if (!bHasTextImport) - { - bIsFirstTextImport = true; - bHasTextImport = true; - pContext = new ScXMLTextPContext(rXMLImport, nPrefix, rLName, xAttrList, this); - } - else - { - if (cellExists(aCellPos)) - { - if (bIsFirstTextImport && !rXMLImport.GetRemoveLastChar()) - { - if (pOUTextContent) - { - SetCursorOnTextImport(*pOUTextContent); - pOUTextContent.reset(); - } - else - SetCursorOnTextImport(rtl::OUString()); - rXMLImport.SetRemoveLastChar(true); - uno::Reference < text::XTextCursor > xTextCursor(rXMLImport.GetTextImport()->GetCursor()); - if (xTextCursor.is()) - { - 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, false); - } - } - pContext = rXMLImport.GetTextImport()->CreateTextChildContext( - rXMLImport, nPrefix, rLName, xAttrList); - bIsFirstTextImport = false; - } - } - } + pContext = new ScXMLCellTextParaContext(rXMLImport, nPrefix, rLName, *this); } break; case XML_TOK_TABLE_ROW_CELL_TABLE: @@ -740,8 +703,8 @@ void ScXMLTableRowCellContext::SetFormulaCell(ScFormulaCell* pFCell) const } else if (!rtl::math::isNan(fValue)) { - if( pOUTextContent ) - pFCell->SetHybridValueString( fValue, *pOUTextContent ); + if (!maParagraphs.empty()) + pFCell->SetHybridValueString(fValue, maParagraphs.back()); else pFCell->SetHybridDouble(fValue); pFCell->ResetDirty(); @@ -766,8 +729,8 @@ void ScXMLTableRowCellContext::PutTextCell( const ScAddress& rCurrentPos, OUString aCellString; if (maStringValue && !maStringValue->isEmpty()) aCellString = *maStringValue; - else if (pOUTextContent && !pOUTextContent->isEmpty()) - aCellString = *pOUTextContent; + else if (!maParagraphs.empty()) + aCellString = maParagraphs.back(); else if ( nCurrentCol > 0 && pOUText && !pOUText->isEmpty() ) aCellString = *pOUText; else @@ -801,8 +764,8 @@ void ScXMLTableRowCellContext::PutTextCell( const ScAddress& rCurrentPos, ScDocument* pDoc = rXMLImport.GetDocument(); if (maStringValue && !maStringValue->isEmpty()) pNewCell = ScBaseCell::CreateTextCell( *maStringValue, pDoc ); - else if (pOUTextContent && !pOUTextContent->isEmpty()) - pNewCell = ScBaseCell::CreateTextCell( *pOUTextContent, pDoc ); + else if (!maParagraphs.empty()) + pNewCell = ScBaseCell::CreateTextCell(maParagraphs.back(), pDoc); else if ( nCurrentCol > 0 && pOUText && !pOUText->isEmpty() ) pNewCell = ScBaseCell::CreateTextCell( *pOUText, pDoc ); @@ -1013,7 +976,7 @@ void ScXMLTableRowCellContext::AddNonFormulaCells( const ScAddress& rCellPos ) if( cellExists(rCellPos) && CellsAreRepeated() ) pOUText.reset( getOutputString(rXMLImport.GetDocument(), rCellPos) ); - if( !pOUTextContent && !pOUText && !maStringValue ) + if (maParagraphs.empty() && !pOUText && !maStringValue) bIsEmpty = true; } @@ -1163,11 +1126,12 @@ void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rCellPos ) // - has an "Err:[###]" (where "[###]" is an error number) void ScXMLTableRowCellContext::HasSpecialCaseFormulaText() { - if( pOUTextContent ) + if (!maParagraphs.empty()) { - if ( pOUTextContent->isEmpty() || pOUTextContent->startsWith("Err:") ) + const OUString& rStr = maParagraphs.back(); + if (rStr.isEmpty() || rStr.startsWith("Err:")) mbPossibleErrorCell = true; - else if (pOUTextContent->startsWith("#")) + else if (rStr.startsWith("#")) mbCheckWithCompilerForError = true; } } @@ -1196,7 +1160,7 @@ void ScXMLTableRowCellContext::EndElement() HasSpecialCaseFormulaText(); if( bFormulaTextResult && (mbPossibleErrorCell || mbCheckWithCompilerForError) ) { - maStringValue.reset(*pOUTextContent); + maStringValue.reset(maParagraphs.back()); nCellType = util::NumberFormat::TEXT; } diff --git a/sc/source/filter/xml/xmlcelli.hxx b/sc/source/filter/xml/xmlcelli.hxx index 2f7b3e6816f1..cd0ce080f6d2 100644 --- a/sc/source/filter/xml/xmlcelli.hxx +++ b/sc/source/filter/xml/xmlcelli.hxx @@ -40,7 +40,8 @@ class ScXMLTableRowCellContext : public SvXMLImportContext boost::optional<OUString> maStringValue; /// office:string-value attribute boost::optional<OUString> maContentValidationName; - ::boost::optional< rtl::OUString > pOUTextContent; + std::vector<OUString> maParagraphs; + boost::scoped_ptr< ScXMLAnnotationData > mxAnnotationData; ScMyImpDetectiveObjVec* pDetectiveObjVec; ScMyImpCellRangeSource* pCellRangeSource; @@ -106,7 +107,7 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); - inline void SetString(const rtl::OUString& rOUTempText) { pOUTextContent.reset(rOUTempText); } + void PushParagraph(const OUString& rPara); void SetCursorOnTextImport(const rtl::OUString& rOUTempText); void SetAnnotation( const ScAddress& rPosition ); diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx index 492662d5dc77..a35b934bf959 100644 --- a/sc/source/filter/xml/xmlimprt.cxx +++ b/sc/source/filter/xml/xmlimprt.cxx @@ -1839,6 +1839,20 @@ const SvXMLTokenMap& ScXMLImport::GetConsolidationAttrTokenMap() return *pConsolidationAttrTokenMap; } +const SvXMLTokenMap& ScXMLImport::GetCellTextParaElemTokenMap() +{ + if (!pCellTextParaElemTokemMap) + { + static SvXMLTokenMapEntry aMap[] = + { + { XML_NAMESPACE_TEXT, XML_SPAN, XML_TOK_CELL_TEXT_SPAN }, + XML_TOKEN_MAP_END + }; + + pCellTextParaElemTokemMap = new SvXMLTokenMap(aMap); + } + return *pCellTextParaElemTokemMap; +} SvXMLImportContext *ScXMLImport::CreateContext( sal_uInt16 nPrefix, const OUString& rLocalName, @@ -1962,6 +1976,7 @@ ScXMLImport::ScXMLImport( pDataPilotMembersElemTokenMap( 0 ), pDataPilotMemberAttrTokenMap( 0 ), pConsolidationAttrTokenMap( 0 ), + pCellTextParaElemTokemMap(NULL), aTables(*this), pMyNamedExpressions(NULL), pMyLabelRanges(NULL), @@ -2099,6 +2114,7 @@ ScXMLImport::~ScXMLImport() throw() delete pDataPilotMembersElemTokenMap; delete pDataPilotMemberAttrTokenMap; delete pConsolidationAttrTokenMap; + delete pCellTextParaElemTokemMap; delete pChangeTrackingImportHelper; delete pNumberFormatAttributesExportHelper; diff --git a/sc/source/filter/xml/xmlimprt.hxx b/sc/source/filter/xml/xmlimprt.hxx index 532d83a31e2f..09970ad5889b 100644 --- a/sc/source/filter/xml/xmlimprt.hxx +++ b/sc/source/filter/xml/xmlimprt.hxx @@ -681,6 +681,10 @@ enum ScXMLConsolidationAttrTokens XML_TOK_CONSOLIDATION_ATTR_LINK_TO_SOURCE }; +enum ScXMLCellTextParaElemTokens +{ + XML_TOK_CELL_TEXT_SPAN +}; class SvXMLTokenMap; class XMLShapeImportHelper; @@ -847,6 +851,7 @@ class ScXMLImport: public SvXMLImport, boost::noncopyable SvXMLTokenMap *pDataPilotMembersElemTokenMap; SvXMLTokenMap *pDataPilotMemberAttrTokenMap; SvXMLTokenMap *pConsolidationAttrTokenMap; + SvXMLTokenMap *pCellTextParaElemTokemMap; ScMyTables aTables; @@ -1012,6 +1017,7 @@ public: const SvXMLTokenMap& GetDataPilotMembersElemTokenMap(); const SvXMLTokenMap& GetDataPilotMemberAttrTokenMap(); const SvXMLTokenMap& GetConsolidationAttrTokenMap(); + const SvXMLTokenMap& GetCellTextParaElemTokenMap(); void AddNamedExpression(ScMyNamedExpression* pMyNamedExpression) { |