[PATCH] sax: add methods to duplicate current top marker and reapply...

Pierre-Eric Pelloux-Prayer (via Code Review) gerrit at gerrit.libreoffice.org
Fri Jan 11 05:44:11 PST 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/1648

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/48/1648/1

sax: add methods to duplicate current top marker and reapply it later

The need for this is ooxml: we need to have a duplicate entry (rPr)
like this:
<p>
  <pPr>
     <rPr>...</rPr>
  </pPr>
  <r>
     <rPr>...</rPR>
  </r>
</p>
This patch allows to do that by setting aside a copy of the <rPr> line,
and then merging the copy when needed.

Change-Id: I3868a822aa9e5210f3d814c68398a38f95072cd5
---
M sax/inc/sax/fshelper.hxx
M sax/source/tools/fastserializer.cxx
M sax/source/tools/fastserializer.hxx
M sax/source/tools/fshelper.cxx
4 files changed, 29 insertions(+), 0 deletions(-)



diff --git a/sax/inc/sax/fshelper.hxx b/sax/inc/sax/fshelper.hxx
index b0b8b09..2e9d07b 100644
--- a/sax/inc/sax/fshelper.hxx
+++ b/sax/inc/sax/fshelper.hxx
@@ -142,6 +142,8 @@
     void mark( ::com::sun::star::uno::Sequence< sal_Int32 > aOrder =
             ::com::sun::star::uno::Sequence< sal_Int32 >() );
     void mergeTopMarks( MergeMarksEnum eMergeType = MERGE_MARKS_APPEND );
+    void copyTopMarkPush();
+    void copyTopMarkPop();
 
     /*
       Now create all the overloads in a typesafe way (i.e. without varargs) by creating a number of overloads
diff --git a/sax/source/tools/fastserializer.cxx b/sax/source/tools/fastserializer.cxx
index bc2b12e..31aac1e 100644
--- a/sax/source/tools/fastserializer.cxx
+++ b/sax/source/tools/fastserializer.cxx
@@ -265,6 +265,20 @@
         }
     }
 
+    void FastSaxSerializer::copyTopMarkPush()
+    {
+        assert (!maMarkStack.empty());
+        maSavedMarkStack.push(boost::shared_ptr< ForMerge > ( new ForMerge(*maMarkStack.top())));
+    }
+
+    void FastSaxSerializer::copyTopMarkPop()
+    {
+        assert (!maSavedMarkStack.empty());
+        maMarkStack.push(maSavedMarkStack.top());
+        mergeTopMarks();
+        maSavedMarkStack.pop();
+    }
+
     void FastSaxSerializer::writeBytes( const Sequence< ::sal_Int8 >& aData ) throw ( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException )
     {
         if ( maMarkStack.empty() )
diff --git a/sax/source/tools/fastserializer.hxx b/sax/source/tools/fastserializer.hxx
index b80f1cc..70bc153 100644
--- a/sax/source/tools/fastserializer.hxx
+++ b/sax/source/tools/fastserializer.hxx
@@ -145,6 +145,8 @@
         @see mark()
      */
     void mergeTopMarks( sax_fastparser::MergeMarksEnum eMergeType = sax_fastparser::MERGE_MARKS_APPEND );
+    void copyTopMarkPush();
+    void copyTopMarkPop();
 
 private:
     ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > mxOutputStream;
@@ -203,6 +205,7 @@
     };
 
     ::std::stack< boost::shared_ptr< ForMerge > > maMarkStack;
+    ::std::stack< boost::shared_ptr< ForMerge > > maSavedMarkStack;
 
     void writeFastAttributeList( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs );
     void write( const ::rtl::OUString& s );
diff --git a/sax/source/tools/fshelper.cxx b/sax/source/tools/fshelper.cxx
index 2f3f7bf..37cf3d0 100644
--- a/sax/source/tools/fshelper.cxx
+++ b/sax/source/tools/fshelper.cxx
@@ -162,6 +162,16 @@
     mpSerializer->mergeTopMarks( eMergeType );
 }
 
+void FastSerializerHelper::copyTopMarkPush()
+{
+    mpSerializer->copyTopMarkPush();
+}
+
+void FastSerializerHelper::copyTopMarkPop()
+{
+    mpSerializer->copyTopMarkPop();
+}
+
 FastAttributeList * FastSerializerHelper::createAttrList()
 {
     return new FastAttributeList( mxTokenHandler );

-- 
To view, visit https://gerrit.libreoffice.org/1648
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3868a822aa9e5210f3d814c68398a38f95072cd5
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Pierre-Eric Pelloux-Prayer <pierre-eric at lanedo.com>



More information about the LibreOffice mailing list