[Libreoffice-commits] core.git: sc/Library_scfilt.mk sc/source

Noel Grandin noel.grandin at collabora.co.uk
Thu Nov 3 06:31:24 UTC 2016


 sc/Library_scfilt.mk           |    1 
 sc/source/filter/inc/biff.hxx  |   47 --------------------
 sc/source/filter/inc/qpro.hxx  |   17 +++++--
 sc/source/filter/qpro/biff.cxx |   95 -----------------------------------------
 sc/source/filter/qpro/qpro.cxx |   64 ++++++++++++++++++++++++---
 5 files changed, 69 insertions(+), 155 deletions(-)

New commits:
commit afdd4606e947cfd564aee66ed9ce419091350482
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed Nov 2 14:32:22 2016 +0200

    merge ScBiffReader and ScQProReader
    
    Change-Id: I7267ffb4ad5c874d6c836a8d6ab823d63f8e2610
    Reviewed-on: https://gerrit.libreoffice.org/30488
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    Tested-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/Library_scfilt.mk b/sc/Library_scfilt.mk
index 308eecb..98445c8 100644
--- a/sc/Library_scfilt.mk
+++ b/sc/Library_scfilt.mk
@@ -145,7 +145,6 @@ $(eval $(call gb_Library_add_exception_objects,scfilt,\
 	sc/source/filter/lotus/op \
 	sc/source/filter/lotus/optab \
 	sc/source/filter/lotus/tool \
-	sc/source/filter/qpro/biff \
 	sc/source/filter/qpro/qpro \
 	sc/source/filter/qpro/qproform \
 	sc/source/filter/qpro/qprostyle \
diff --git a/sc/source/filter/inc/biff.hxx b/sc/source/filter/inc/biff.hxx
deleted file mode 100644
index 29735fe..0000000
--- a/sc/source/filter/inc/biff.hxx
+++ /dev/null
@@ -1,47 +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 INCLUDED_SC_SOURCE_FILTER_INC_BIFF_HXX
-#define INCLUDED_SC_SOURCE_FILTER_INC_BIFF_HXX
-
-#include <sal/config.h>
-#include "filter.hxx"
-
-#include "flttypes.hxx"
-#include "ftools.hxx"
-
-// Stream wrapper class
-class ScBiffReader
-{
-protected:
-    sal_uInt16 mnId;
-    sal_uInt16 mnLength;
-    sal_uInt32 mnOffset;
-    SvStream *mpStream;
-    bool mbEndOfFile;
-
-public:
-    ScBiffReader( SfxMedium& rMedium );
-    ~ScBiffReader();
-    bool recordsLeft() { return mpStream && !mpStream->IsEof(); }
-    bool nextRecord();
-};
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/inc/qpro.hxx b/sc/source/filter/inc/qpro.hxx
index b2b7c3e..751ec85 100644
--- a/sc/source/filter/inc/qpro.hxx
+++ b/sc/source/filter/inc/qpro.hxx
@@ -27,22 +27,29 @@
 #include "flttypes.hxx"
 #include "ftools.hxx"
 #include "qprostyle.hxx"
-#include "biff.hxx"
 
 class ScDocument;
 
 // Stream wrapper class
-class ScQProReader : public ScBiffReader
+class ScQProReader
 {
-    public:
+    sal_uInt16 mnId;
+    sal_uInt16 mnLength;
+    sal_uInt32 mnOffset;
+    SvStream *mpStream;
+    bool mbEndOfFile;
+
+public:
+    ScQProReader( SfxMedium &rMedium );
+    ~ScQProReader();
+
     bool recordsLeft();
     void SetEof( bool bValue ){ mbEndOfFile = bValue; }
     bool nextRecord();
     sal_uInt16 getId() { return mnId; }
     sal_uInt16 getLength() { return mnLength; }
     void readString( OUString &rString, sal_uInt16 nLength );
-    ScQProReader( SfxMedium &rMedium );
-    ~ScQProReader(){ };
+
     FltError import( ScDocument *pDoc );
     FltError readSheet( SCTAB nTab, ScDocument* pDoc, ScQProStyle *pStyle );
 };
diff --git a/sc/source/filter/qpro/biff.cxx b/sc/source/filter/qpro/biff.cxx
deleted file mode 100644
index ce02767..0000000
--- a/sc/source/filter/qpro/biff.cxx
+++ /dev/null
@@ -1,95 +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 <sal/config.h>
-#include <stdio.h>
-#include <sfx2/docfile.hxx>
-
-#include "global.hxx"
-#include "scerrors.hxx"
-#include "docpool.hxx"
-#include "patattr.hxx"
-#include "filter.hxx"
-#include "document.hxx"
-#include "formulacell.hxx"
-#include "biff.hxx"
-
-ScBiffReader::ScBiffReader(SfxMedium& rMedium)
-    : mnId(0)
-    , mnLength(0)
-    , mnOffset(0)
-    , mbEndOfFile(false)
-{
-    mpStream = rMedium.GetInStream();
-    if( mpStream )
-    {
-        mpStream->SetBufferSize( 65535 );
-        mpStream->SetStreamCharSet( RTL_TEXTENCODING_MS_1252 );
-    }
-}
-
-ScBiffReader::~ScBiffReader()
-{
-    if( mpStream )
-        mpStream->SetBufferSize( 0 );
-}
-
-bool ScBiffReader::nextRecord()
-{
-    if( !recordsLeft() )
-        return false;
-
-    if( mbEndOfFile )
-        return false;
-
-    sal_uInt32 nPos = mpStream->Tell();
-    if( nPos != mnOffset + mnLength )
-        mpStream->Seek( mnOffset + mnLength );
-
-    mnLength = mnId = 0;
-    mpStream->ReadUInt16( mnId ).ReadUInt16( mnLength );
-
-    mnOffset = mpStream->Tell();
-#ifdef DEBUG_SC_QPRO
-    fprintf( stderr, "Read record 0x%x length 0x%x at offset 0x%x\n",
-        (unsigned)mnId, (unsigned)mnLength, (unsigned)mnOffset );
-
-#if 1  // rather verbose
-    int len = mnLength;
-    while (len > 0) {
-        int i, chunk = len < 16 ? len : 16;
-        unsigned char data[16];
-        mpStream->Read( data, chunk );
-
-        for (i = 0; i < chunk; i++)
-            fprintf( stderr, "%.2x ", data[i] );
-        fprintf( stderr, "| " );
-        for (i = 0; i < chunk; i++)
-            fprintf( stderr, "%c", data[i] < 127 && data[i] > 30 ? data[i] : '.' );
-        fprintf( stderr, "\n" );
-
-        len -= chunk;
-    }
-    mpStream->Seek( mnOffset );
-#endif
-#endif
-    return true;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/qpro/qpro.cxx b/sc/source/filter/qpro/qpro.cxx
index 77334a2..96c9acf 100644
--- a/sc/source/filter/qpro/qpro.cxx
+++ b/sc/source/filter/qpro/qpro.cxx
@@ -31,7 +31,6 @@
 #include "filter.hxx"
 #include "document.hxx"
 #include "formulacell.hxx"
-#include "biff.hxx"
 #include <tools/stream.hxx>
 #include <memory>
 
@@ -131,11 +130,27 @@ FltError ScFormatFilterPluginImpl::ScImportQuattroPro( SfxMedium &rMedium, ScDoc
     return eRet;
 }
 
-ScQProReader::ScQProReader( SfxMedium &rMedium ):
-    ScBiffReader( rMedium )
+ScQProReader::ScQProReader( SfxMedium &rMedium )
+    : mnId(0)
+    , mnLength(0)
+    , mnOffset(0)
+    , mbEndOfFile(false)
 {
+    mpStream = rMedium.GetInStream();
+    if( mpStream )
+    {
+        mpStream->SetBufferSize( 65535 );
+        mpStream->SetStreamCharSet( RTL_TEXTENCODING_MS_1252 );
+    }
+}
+
+ScQProReader::~ScQProReader()
+{
+    if( mpStream )
+        mpStream->SetBufferSize( 0 );
 }
 
+
 FltError ScQProReader::import( ScDocument *pDoc )
 {
     FltError eRet = eERR_OK;
@@ -211,14 +226,49 @@ FltError ScQProReader::import( ScDocument *pDoc )
 
 bool ScQProReader::recordsLeft()
 {
-    bool bValue = ScBiffReader::recordsLeft();
-    return bValue;
+    return mpStream && !mpStream->IsEof();
 }
 
 bool ScQProReader::nextRecord()
 {
-    bool bValue = ScBiffReader::nextRecord();
-    return bValue;
+    if( !recordsLeft() )
+        return false;
+
+    if( mbEndOfFile )
+        return false;
+
+    sal_uInt32 nPos = mpStream->Tell();
+    if( nPos != mnOffset + mnLength )
+        mpStream->Seek( mnOffset + mnLength );
+
+    mnLength = mnId = 0;
+    mpStream->ReadUInt16( mnId ).ReadUInt16( mnLength );
+
+    mnOffset = mpStream->Tell();
+#ifdef DEBUG_SC_QPRO
+    fprintf( stderr, "Read record 0x%x length 0x%x at offset 0x%x\n",
+        (unsigned)mnId, (unsigned)mnLength, (unsigned)mnOffset );
+
+#if 1  // rather verbose
+    int len = mnLength;
+    while (len > 0) {
+        int i, chunk = len < 16 ? len : 16;
+        unsigned char data[16];
+        mpStream->Read( data, chunk );
+
+        for (i = 0; i < chunk; i++)
+            fprintf( stderr, "%.2x ", data[i] );
+        fprintf( stderr, "| " );
+        for (i = 0; i < chunk; i++)
+            fprintf( stderr, "%c", data[i] < 127 && data[i] > 30 ? data[i] : '.' );
+        fprintf( stderr, "\n" );
+
+        len -= chunk;
+    }
+    mpStream->Seek( mnOffset );
+#endif
+#endif
+    return true;
 }
 
 void ScQProReader::readString( OUString &rString, sal_uInt16 nLength )


More information about the Libreoffice-commits mailing list