Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/LibreOffice/sc/inc/   (Office von Apache Version 25.8.3.2©)  Datei vom 5.10.2025 mit Größe 4 kB image not shown  

Quelle  formulalogger.hxx   Sprache: C

 
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * 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/.
 */


#pragma once

#include <rtl/ustring.hxx>

#include <memory>
#include <string_view>
#include <vector>

#include <config_options_calc.h>

class ScFormulaCell;
class ScDocument;
class ScAddress;
struct ScFormulaCellGroup;

namespace formula {

class FormulaToken;
struct VectorRefArray;

}

namespace osl { class File; }

namespace sc {

#if ENABLE_FORMULA_LOGGER

/**
 * Outputs formula calculation log outputs to specified file.
 */

class FormulaLogger
{
    std::unique_ptr<osl::File> mpLogFile;

    sal_Int32 mnNestLevel = 0;
    const ScFormulaCellGroup* mpLastGroup = nullptr;

    void writeAscii( const char* s );
    void writeAscii( const char* s, size_t n );
    void write( std::u16string_view ou );
    void write( sal_Int32 n );

    void sync();

    void writeNestLevel();

public:

    static FormulaLogger& get();

    /**
     * This class is only moveable.
     */

    class GroupScope
    {
        friend class FormulaLogger;

        struct Impl;
        std::unique_ptr<Impl> mpImpl;

    public:
        GroupScope() = delete;
        GroupScope( const GroupScope& ) = delete;
        GroupScope& operator= ( const GroupScope& ) = delete;

    private:
        GroupScope(
            FormulaLogger& rLogger, const OUString& rPrefix,
            const ScDocument& rDoc, const ScFormulaCell& rCell,
            bool bOutputEnabled );

    public:
        GroupScope(GroupScope&& r) noexcept;
        ~GroupScope();

        /**
         * Add an arbitrary message to dump to the log.
         */

        void addMessage( const OUString& rMsg );

        /**
         * Add to the log a vector reference information for a single
         * reference.
         */

        void addRefMessage(
            const ScAddress& rCellPos, const ScAddress& rRefPos, size_t nLen,
            const formula::VectorRefArray& rArray );

        /**
         * Add to the log a vector reference information for a range
         * reference.
         */

        void addRefMessage(
            const ScAddress& rCellPos, const ScAddress& rRefPos, size_t nLen,
            const std::vector<formula::VectorRefArray>& rArrays );

        /**
         * Add to the log a single cell reference information.
         */

        void addRefMessage(
            const ScAddress& rCellPos, const ScAddress& rRefPos,
            const formula::FormulaToken& rToken );

        void addGroupSizeThresholdMessage( const ScFormulaCell& rCell );

        /**
         * Call this when the group calculation has finished successfully.
         */

        void setCalcComplete();
    };

    FormulaLogger( const FormulaLogger& ) = delete;
    FormulaLogger& operator= ( const FormulaLogger& ) = delete;

    FormulaLogger();
    ~FormulaLogger();

    GroupScope enterGroup( const ScDocument& rDoc, const ScFormulaCell& rCell );
};

#else

/**
 * Dummy class with all empty inline methods.
 */

class FormulaLogger
{
public:

    static FormulaLogger get()
    {
        return FormulaLogger();
    }

    class GroupScope
    {
    public:
        void addMessage( [[maybe_unused]] const OUString& /*rMsg*/ ) { (void) this; /* loplugin:staticmethods */ }

        void addRefMessage(
            const ScAddress& /*rCellPos*/, const ScAddress& /*rRefPos*/, size_t /*nLen*/,
            const formula::VectorRefArray& /*rArray*/ )
        {
            (voidthis/* loplugin:staticmethods */
        }

        void addRefMessage(
            const ScAddress& /*rCellPos*/, const ScAddress& /*rRefPos*/, size_t /*nLen*/,
            const std::vector<formula::VectorRefArray>& /*rArrays*/ )
        {
            (voidthis/* loplugin:staticmethods */
        }

        void addRefMessage(
            const ScAddress& /*rCellPos*/, const ScAddress& /*rRefPos*/,
            const formula::FormulaToken& /*rToken*/ )
        {
            (voidthis/* loplugin:staticmethods */
        }

        void addGroupSizeThresholdMessage( const ScFormulaCell& /*rCell*/ )
        {
            (voidthis/* loplugin:staticmethods */
        }

        void setCalcComplete() { (voidthis/* loplugin:staticmethods */ }
    };

    GroupScope enterGroup( const ScDocument& /*rDoc*/, const ScFormulaCell& /*rCell*/ )
    {
        (voidthis/* loplugin:staticmethods */
        return GroupScope();
    }
};

#endif // ENABLE_FORMULA_LOGGER

}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Messung V0.5
C=96 H=95 G=95

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.