editeng/source/editeng/editattr.cxx | 10 +++++++ editeng/source/editeng/editattr.hxx | 2 + editeng/source/editeng/editdoc.cxx | 51 ++++++++++++++++++++++++++++++++++++ editeng/source/editeng/editdoc.hxx | 9 +++++- editeng/source/editeng/editobj.cxx | 14 +++++++++ editeng/source/editeng/impedit4.cxx | 40 +++++++++++++--------------- 6 files changed, 104 insertions(+), 22 deletions(-)
New commits: commit 5af110e20bbf3df91750e1173382ef442476603f Author: Noel Grandin <[email protected]> Date: Tue Sep 27 13:52:00 2016 +0200 variable name and indentation improvement Change-Id: Ia3a97b08e1280e3665a56cdbb25ad07687dc7040 diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx index d30d025..c994c40 100644 --- a/editeng/source/editeng/impedit4.cxx +++ b/editeng/source/editeng/impedit4.cxx @@ -1222,18 +1222,18 @@ EditSelection ImpEditEngine::InsertTextObject( const EditTextObject& rTextObject bUsePortionInfo = true; } - bool bConvertItems = false; + bool bConvertMetricOfItems = false; MapUnit eSourceUnit = MapUnit(), eDestUnit = MapUnit(); if (rTextObject.mpImpl->HasMetric()) { eSourceUnit = (MapUnit)rTextObject.mpImpl->GetMetric(); eDestUnit = (MapUnit)aEditDoc.GetItemPool().GetMetric( DEF_METRIC ); if ( eSourceUnit != eDestUnit ) - bConvertItems = true; + bConvertMetricOfItems = true; } // Before, paragraph count was of type sal_uInt16 so if nContents exceeded - // 0xFFFF this wouldn't had worked anyway, given that nPara is used to + // 0xFFFF this wouldn't have worked anyway, given that nPara is used to // number paragraphs and is fearlessly incremented. sal_Int32 nContents = static_cast<sal_Int32>(rTextObject.mpImpl->GetContents().size()); SAL_WARN_IF( nContents < 0, "editeng", "ImpEditEngine::InsertTextObject - contents overflow " << nContents); @@ -1271,7 +1271,7 @@ EditSelection ImpEditEngine::InsertTextObject( const EditTextObject& rTextObject // already in the flow DBG_ASSERT( rX.GetEnd() <= aPaM.GetNode()->Len(), "InsertBinTextObject: Attribute too large!" ); EditCharAttrib* pAttr; - if ( !bConvertItems ) + if ( !bConvertMetricOfItems ) pAttr = MakeCharAttrib( aEditDoc.GetItemPool(), *(rX.GetItem()), rX.GetStart()+nStartPos, rX.GetEnd()+nStartPos ); else { @@ -1307,24 +1307,22 @@ EditSelection ImpEditEngine::InsertTextObject( const EditTextObject& rTextObject bool bParaAttribs = false; if ( bNewContent || ( ( n > 0 ) && ( n < (nContents-1) ) ) ) { + // only style and ParaAttribs when new paragraph, or + // completely internal ... + bParaAttribs = pC->GetParaAttribs().Count() != 0; + if ( GetStyleSheetPool() && pC->GetStyle().getLength() ) { - // only style and ParaAttribs when new paragraph, or - // completely internal ... - bParaAttribs = pC->GetParaAttribs().Count() != 0; - if ( GetStyleSheetPool() && pC->GetStyle().getLength() ) - { - SfxStyleSheet* pStyle = static_cast<SfxStyleSheet*>(GetStyleSheetPool()->Find( pC->GetStyle(), pC->GetFamily() )); - DBG_ASSERT( pStyle, "InsertBinTextObject - Style not found!" ); - SetStyleSheet( nPara, pStyle ); - } - if ( !bConvertItems ) - SetParaAttribs( aEditDoc.GetPos( aPaM.GetNode() ), pC->GetParaAttribs() ); - else - { - SfxItemSet aAttribs( GetEmptyItemSet() ); - ConvertAndPutItems( aAttribs, pC->GetParaAttribs(), &eSourceUnit, &eDestUnit ); - SetParaAttribs( aEditDoc.GetPos( aPaM.GetNode() ), aAttribs ); - } + SfxStyleSheet* pStyle = static_cast<SfxStyleSheet*>(GetStyleSheetPool()->Find( pC->GetStyle(), pC->GetFamily() )); + DBG_ASSERT( pStyle, "InsertBinTextObject - Style not found!" ); + SetStyleSheet( nPara, pStyle ); + } + if ( !bConvertMetricOfItems ) + SetParaAttribs( aEditDoc.GetPos( aPaM.GetNode() ), pC->GetParaAttribs() ); + else + { + SfxItemSet aAttribs( GetEmptyItemSet() ); + ConvertAndPutItems( aAttribs, pC->GetParaAttribs(), &eSourceUnit, &eDestUnit ); + SetParaAttribs( aEditDoc.GetPos( aPaM.GetNode() ), aAttribs ); } if ( bNewContent && bUsePortionInfo ) { commit 678bdd064af207a7b90e3e44d652eb59be7db61f Author: Noel Grandin <[email protected]> Date: Tue Sep 27 13:51:40 2016 +0200 extend dumpAsXml to EditDoc Change-Id: I71464b20c5897a2af3b4069f7f0963ef55dcd8c4 diff --git a/editeng/source/editeng/editattr.cxx b/editeng/source/editeng/editattr.cxx index a274d8b..dbd428b 100644 --- a/editeng/source/editeng/editattr.cxx +++ b/editeng/source/editeng/editattr.cxx @@ -24,6 +24,7 @@ #include <vcl/svapp.hxx> #include <svl/grabbagitem.hxx> +#include <libxml/xmlwriter.h> #include <editeng/svxfont.hxx> #include <editeng/flditem.hxx> #include <editeng/fontitem.hxx> @@ -68,6 +69,15 @@ void EditCharAttrib::SetFont( SvxFont&, OutputDevice* ) { } +void EditCharAttrib::dumpAsXml(xmlTextWriterPtr pWriter) const +{ + xmlTextWriterStartElement(pWriter, BAD_CAST("editCharAttrib")); + xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("nStart"), "%d", nStart); + xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("nEnd"), "%d", nEnd); + pItem->dumpAsXml(pWriter); + xmlTextWriterEndElement(pWriter); +} + // class EditCharAttribFont diff --git a/editeng/source/editeng/editattr.hxx b/editeng/source/editeng/editattr.hxx index 3dffbe2..f49898b 100644 --- a/editeng/source/editeng/editattr.hxx +++ b/editeng/source/editeng/editattr.hxx @@ -80,6 +80,8 @@ public: EditCharAttrib(const EditCharAttrib&) = delete; EditCharAttrib& operator=(const EditCharAttrib&) = delete; + void dumpAsXml(struct _xmlTextWriter* pWriter) const; + sal_uInt16 Which() const { return pItem->Which(); } const SfxPoolItem* GetItem() const { return pItem; } diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index 2f04b71..b67c97c 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -63,6 +63,7 @@ #include <tools/stream.hxx> #include <tools/debug.hxx> #include <com/sun/star/i18n/ScriptType.hpp> +#include <libxml/xmlwriter.h> #include <cassert> #include <limits> @@ -1856,6 +1857,16 @@ void ContentNode::DestroyWrongList() mpWrongList.reset(); } +void ContentNode::dumpAsXml(struct _xmlTextWriter* pWriter) const +{ + xmlTextWriterStartElement(pWriter, BAD_CAST("contentNode")); + xmlTextWriterWriteAttribute(pWriter, BAD_CAST("maString"), BAD_CAST(maString.toUtf8().getStr())); + aContentAttribs.dumpAsXml(pWriter); + aCharAttribList.dumpAsXml(pWriter); + xmlTextWriterEndElement(pWriter); +} + + ContentAttribs::ContentAttribs( SfxItemPool& rPool ) : pStyle(nullptr) , aAttribSet( rPool, EE_PARA_START, EE_CHAR_END ) @@ -1930,6 +1941,13 @@ bool ContentAttribs::HasItem( sal_uInt16 nWhich ) const return bHasItem; } +void ContentAttribs::dumpAsXml(struct _xmlTextWriter* pWriter) const +{ + xmlTextWriterStartElement(pWriter, BAD_CAST("contentAttribs")); + aAttribSet.dumpAsXml(pWriter); + xmlTextWriterEndElement(pWriter); +} + ItemList::ItemList() : CurrentItem( 0 ) { @@ -2718,6 +2736,31 @@ void EditDoc::FindAttribs( ContentNode* pNode, sal_Int32 nStartPos, sal_Int32 nE } } +void EditDoc::dumpAsXml(struct _xmlTextWriter* pWriter) const +{ + bool bOwns = false; + if (!pWriter) + { + pWriter = xmlNewTextWriterFilename("editdoc.xml", 0); + xmlTextWriterStartDocument(pWriter, nullptr, nullptr, nullptr); + bOwns = true; + } + + xmlTextWriterStartElement(pWriter, BAD_CAST("editDoc")); + for (auto const & i : maContents) + { + i->dumpAsXml(pWriter); + } + xmlTextWriterEndElement(pWriter); + + if (bOwns) + { + xmlTextWriterEndDocument(pWriter); + xmlFreeTextWriter(pWriter); + } +} + + namespace { struct LessByStart : std::binary_function<std::unique_ptr<EditCharAttrib>, std::unique_ptr<EditCharAttrib>, bool> @@ -3017,6 +3060,14 @@ void CharAttribList::DbgCheckAttribs(CharAttribList const& rAttribs) } #endif +void CharAttribList::dumpAsXml(struct _xmlTextWriter* pWriter) const +{ + xmlTextWriterStartElement(pWriter, BAD_CAST("charAttribList")); + for (auto const & i : aAttribs) { + i->dumpAsXml(pWriter); + } + xmlTextWriterEndElement(pWriter); +} EditEngineItemPool::EditEngineItemPool( bool bPersistenRefCounts ) : SfxItemPool( "EditEngineItemPool", EE_ITEMS_START, EE_ITEMS_END, diff --git a/editeng/source/editeng/editdoc.hxx b/editeng/source/editeng/editdoc.hxx index cd3fd86..182d09f 100644 --- a/editeng/source/editeng/editdoc.hxx +++ b/editeng/source/editeng/editdoc.hxx @@ -164,6 +164,8 @@ public: ContentAttribs( const ContentAttribs& ); ~ContentAttribs(); // only for larger Tabs + void dumpAsXml(struct _xmlTextWriter* pWriter) const; + SvxTabStop FindTabStop( sal_Int32 nCurPos, sal_uInt16 nDefTab ); SfxItemSet& GetItems() { return aAttribSet; } const SfxItemSet& GetItems() const { return aAttribSet; } @@ -194,6 +196,8 @@ public: CharAttribList(); ~CharAttribList(); + void dumpAsXml(struct _xmlTextWriter* pWriter = nullptr) const; + void DeleteEmptyAttribs( SfxItemPool& rItemPool ); const EditCharAttrib* FindAttrib( sal_uInt16 nWhich, sal_Int32 nPos ) const; @@ -248,6 +252,8 @@ public: ContentNode(const ContentNode&) = delete; ContentNode& operator=(const ContentNode&) = delete; + void dumpAsXml(struct _xmlTextWriter* pWriter) const; + ContentAttribs& GetContentAttribs() { return aContentAttribs; } const ContentAttribs& GetContentAttribs() const { return aContentAttribs; } CharAttribList& GetCharAttribs() { return aCharAttribList; } @@ -747,7 +753,8 @@ public: EditDoc( SfxItemPool* pItemPool ); ~EditDoc(); - void ClearSpellErrors(); + void dumpAsXml(struct _xmlTextWriter* pWriter) const; + void ClearSpellErrors(); bool IsModified() const { return bModified; } void SetModified( bool b ); diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx index 6df0e41..8e53e3d 100644 --- a/editeng/source/editeng/editobj.cxx +++ b/editeng/source/editeng/editobj.cxx @@ -458,6 +458,14 @@ void EditTextObject::Dump() const void EditTextObject::dumpAsXml(xmlTextWriterPtr pWriter) const { + bool bOwns = false; + if (!pWriter) + { + pWriter = xmlNewTextWriterFilename("editTextObject.xml", 0); + xmlTextWriterStartDocument(pWriter, nullptr, nullptr, nullptr); + bOwns = true; + } + xmlTextWriterStartElement(pWriter, BAD_CAST("editTextObject")); sal_Int32 nCount = GetParagraphCount(); for (sal_Int32 i = 0; i < nCount; ++i) @@ -467,6 +475,12 @@ void EditTextObject::dumpAsXml(xmlTextWriterPtr pWriter) const xmlTextWriterEndElement(pWriter); } xmlTextWriterEndElement(pWriter); + + if (bOwns) + { + xmlTextWriterEndDocument(pWriter); + xmlFreeTextWriter(pWriter); + } } // from SfxItemPoolUser _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
