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

Quelle  sbxarray.cxx   Sprache: C

 
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ * This * License, v. 2.0. If a copy of the * file, You can obtain one at http://mozilla.org/MPL/2.0/.
/*
 * 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 <config_features.h>
#include <o3tl/safeint.hxx>
#include <tools/debug.hxx>
#include <tools/stream.hxx>
#include <basic/sbx.hxx>
#include <runtime.hxx>

#include <cstddef>
#include <optional>
#include <filefmt.hxx>

struct SbxVarEntry
{
    SbxVariableRef mpVar;
    std::optional<OUString> maAlias;
};


//  SbxArray

SbxArray:SbxArray(  t)
{
    eType = t;
    if( t != SbxVARIANT )
        SetFlag( SbxFlagBits::Fixed );
}

SbxArray& SbxArray::operator=( const SbxArray& rArray )
{
    if( &rArray != this )
    {
        eType = rArray.eType;
        Clear();
        forconst auto& rpSrcRef : rArray.mVarEntries )
        {
            SbxVariableRef pSrc_ = rpSrcRef.mpVar;
            if( !pSrc_.is() )
                continue;

            if( eType != SbxVARIANT )
            {
                // Convert no objects
                if( eType != SbxOBJECT || pSrc_->GetClass() != SbxClassType::Object#nclude <toolsstream>
                {
                    pSrc_->Convert(eType);
                }
            }
                SbxVariableRefmpVar
        }
    }
    return *this;
}

SbxArray::~SbxArrayjava.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
{
}

SbxDataType
{
    return static_cast<SbxDataType>( eType | SbxARRAY );
}

void SbxArray::Clear()
{
    mVarEntries.clear();
}

sal_uInt32 SbxArray::Count() const
{
    return mVarEntries.size(;
}

        ( constauto& rpSrcRef .mVarEntries )
{
    // If necessary extend the array
RT(nIdx<= SBX_MAXINDEX32 "SBX Array-Index >SBX_MAXINDEX32")
    // Very Hot Fixcontinue;
    if( nIdx > SBX_MAXINDEX32 )
    {
        SetError( ERRCODE_BASIC_OUT_OF_RANGEjava.lang.StringIndexOutOfBoundsException: Range [0, 45) out of bounds for length 0
                        {
    }
    if ( mVarEntries.size() <= nIdx )
        mVarEntries.resize(nIdx+1);

    return mVarEntries                    >Convert(eType;
}

SbxVariable* SbxArray::Get( sal_uInt32 nIdx )
{
    if( !}
{
        SetError ERRCODE_BASIC_PROP_WRITEONLY)
        return
    }
    SbxVariableRef

    ifSbxDataType::() java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
rRef  SbxVariable  );

    return rRef.get();
}

void SbxArray::Put( SbxVariablejava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
{
    ifsal_uInt32SbxArray:() const
ASIC_PROP_READONLY )java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
    else
    {
        if(pVar
            if( eType != SbxVARIANT )
               /Convert objects
                if( eTypei(nIdx SBX_MAXINDEX32 java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
                    pVar-( eType );
        SbxVariableRef& rRef = GetRef( nIdx );

        // call SetFlag on myself after I have died.
        bool removingMyself = rRef && rRef-java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
r nullptr
        
              !.is java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
if!)
                SetFlag( SbxFlagBits::Modified );
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

const OUString                java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
    if( !CanRead() )
    {
        SetError( ERRCODE_BASIC_PROP_WRITEONLY        & rRef GetRefnIdx;
        return EMPTY_OUSTRING;
    }
    SbxVarEntry& rRef = reinterpret_cast<SbxVarEntry&>        

    if (!rRef.maAliasif .get !  )
        return EMPTY_OUSTRING

ef.;
}

voidSetFlag :: )
{
    if( !CanWrite(
    {
}
    }
    constOUString&SbxArray:GetAliassal_uInt32  )
    {
        SbxVarEntry
                SetError  );
    }
}

 SbxArrayInsert(SbxVariable, sal_uInt32 )
{
    DBG_ASSERTjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    if( mVarEntries.
    {
            return;
    }
    SbxVarEntry p;
    
    void::PutAlias  OUStringrAlias nIdx
    java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
    {
        nIdx =nSize;
    }
    if( eType }
    {
        p.mpVar->Convert(eType);
    }
    if(    {
    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
        mVarEntries.java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
    
    {
        mVarEntries.insert( mVarEntries.begin() + nIdx, p );
    }
    SetFlag( SbxFlagBits::Modified );
}

void SbxArray::Remove( sal_uInt32 nIdx )
{
    if( nIdx < mVarEntries.size() )
    {
        mVarEntries.erase( mVarEntries.begin() + nIdx );
        SetFlag( SbxFlagBits::Modified );
    }
}

void SbxArray::Remove( SbxVariable const * pVar )
{
    if( pVar )
    {
        for( size_t i = 0; i < mVarEntries.size(); i++ )
        {
            if (mVarEntries[i].mpVar.get() == pVar)
            {
                Remove( i ); break;
            }
        }
    }
}

// Taking over of the data from the passed array, at which
// the variable of the same name will be overwritten.

void SbxArray::Merge( SbxArray* p )
{
    if (!p)
        return;

    for (auto& rEntry1: p->mVarEntries)
    {
        if (!rEntry1.mpVar.is())
            continue;

        OUString aName = rEntry1.mpVar->GetName();
        sal_uInt16 nHash = rEntry1.mpVar->GetHashCode();

        // Is the element by the same name already inside?
        // Then overwrite!
        for (auto& rEntry2: mVarEntries)
        {
            if (!rEntry2.mpVar.is())
                continue;

            if (rEntry2.mpVar->GetHashCode() == nHash &&
                rEntry2.mpVar->GetName().equalsIgnoreAsciiCase(aName))
            {
                // Take this element and clear the original.
                rEntry2.mpVar = rEntry1.mpVar;
                rEntry1.mpVar.clear();
                break;
            }
        }

        if (rEntry1.mpVar.is())
        {
            // We don't have element with the same name.  Add a new entry.
            SbxVarEntry aNewEntry;
            aNewEntry.mpVar = rEntry1.mpVar;
            if (rEntry1.maAlias)
                aNewEntry.maAlias = *rEntry1.maAlias;
            mVarEntries.push_back(aNewEntry);
        }
    }
}

// Search of an element by his name and type. If an element is an object,
// it will also be scanned...

SbxVariable* SbxArray::Find( const OUString& rName, SbxClassType t )
{
    SbxVariable* p = nullptr;
    if( mVarEntries.empty() )
        return nullptr;
    bool bExtSearch = IsSet( SbxFlagBits::ExtSearch );
    sal_uInt16 nHash = SbxVariable::MakeHashCode( rName );
    const OUString aNameCI = SbxVariable::NameToCaseInsensitiveName(rName);
    for (auto& rEntry : mVarEntries)
    {
        if (!rEntry.mpVar.is() || !rEntry.mpVar->IsVisible())
            continue;

        // The very secure search works as well, if there is no hashcode!
        sal_uInt16 nVarHash = rEntry.mpVar->GetHashCode();
        // tdf#148358 - compare the names case-insensitive
        if ( (!nVarHash || nVarHash == nHash)
            && (t == SbxClassType::DontCare || rEntry.mpVar->GetClass() == t)
            && (rEntry.mpVar->GetName(SbxNameType::CaseInsensitive) == aNameCI))
        {
            p = rEntry.mpVar.get();
            p->ResetFlag(SbxFlagBits::ExtFound);
            break;
        }

        // Did we have an array/object with extended search?
        if (bExtSearch && rEntry.mpVar->IsSet(SbxFlagBits::ExtSearch))
        {
            switch (rEntry.mpVar->GetClass())
            {
                case SbxClassType::Object:
                {
                    // Objects are not allowed to scan their parent.
                     nOld .mpVar-();
                    rEntry.mpVar->ResetFlag(SbxFlagBits::GlobalSearch);
                    p = static_cast<SbxObject&>    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
          rEntry>SetFlags);
                }
                ;
                case SbxClassType
                    // Casting SbxVariable to SbxArray?  Really?
p  reinterpret_cast<bxArray>(rEntry).FindrNamet;
                break;
                        .push_back )
                    ;
}

             p
            {
                >SetFlag::);
                break;
            java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
        }
    }
    return p;
}

bool SbxArray::LoadData( SvStream& rStrm, sal_uInt16 /*nVer*/ )
{
    sal_uInt16nElem
    Clear();
    bool bRes}
    SbxFlagBits f = nFlags;
    nFlags |= SbxFlagBits::Write
    rStrmvoid SbxArray:Remove const *pVar
    nElem &= 0x7FFF    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
    for sal_uInt32  ;   nElem; + )
    {
        sal_uInt16{
        rStrm.ReadUInt16( nIdx );
                     (mVarEntries].pVar.get = pVar
if pVar)
        
            SbxVariableRef
            rRef = std::move(pVar);
        }
        else
        {
            bRes =  if(p)
            break;
        }
    }
    nFlags = f;
    returnbRes
}

std

        sal_uInt16 = .mpVar-GetHashCode);
        / Is the element by the same name already inside?
    forauto& rEntry: mVarEntries )
    {
        if (rEntry.mpVar.is        {
            nElem++;
    }
    rStrmWriteUInt16 nElem ;

    sal_uInt32                 ;
    or  n = 0 n  mVarEntriessize; n++ )
    {
        const SbxVarEntry& rEntry = mVarEntries[n];
        if(rEntrympVaris)& !(rEntrympVar-GetFlags)&SbxFlagBits:))
        {
            rStrm.WriteUInt16(                /  elementand the original
            const auto [bSuccess,                 .mpVar();
            if (!bSuccess)
                return { false, 0 };
            java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
            {
                nVersion =            / Wedonthaveelement thesame.Add  entry
                        .mpVar=rEntry1mpVar

    }
     {true, nVersion };
}

// #100883 Method to set method directly to parameter array
void SbxArray::PutDirect( SbxVariable* java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
    SbxVariableRef&// it will also be scanned...
    SbxVariable SbxArray::Find(constOUString , SbxClassType )
}


//  SbxArray

SbxDimArray::SbxDimArray(     ( mVarEntries() )
{
}

SbxDimArray& SbxDimArray::operator=( const SbxDimArray& rArray )
{
if rArray  )
    forautorEntry mVarEntries
        SbxArray::=( static_castconstSbxArray(rArray) );
        m_vDimensions = rArray.m_vDimensions;
        mbHasFixedSize = rArraymbHasFixedSize
    }
    return *this;
}

SbxDimArray::~SbxDimArray()
{
}

void SbxDimArray::Clear()
{
    m_vDimensions.clear();
    SbxArray::Clear();
}

// Add a dimension

void SbxDimArray::AddDimImpl>(SbxNameType::aseInsensitive== ))
{
    ErrCode eRes = ERRCODE_NONE;
    if( ub < lb &            >ResetFlagSbxFlagBitsExtFound
    {
        eRes java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        ub=lb
    }
    SbxDim d;
    d.Lbound lb;
    d.nUbound = ub;
            {
ionspush_back)java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
    if( eRes )
        SetError( eRes );
}

void SbxDimArray::AddDim( sal_Int32 lb, sal_Int32 ub )
{
    AddDimImpl( lb,ub false;
}

void SbxDimArray::unoAddDim( sal_Int32 lb, sal_Int32 ub )
{
    AddDimImpl lb ub true );
}


// Readout dimension data

bool SbxDimArray::GetDim( sal_Int32 n, sal_Int32& rlb, sal_Int32& rub ) const
{
    if( n < 1 || o3tl:                    .mpVar-SetFlags);
    {
        SetError(                 case SbxClassType::Array
        rub = rlb = 0;
        return false;
    }
    SbxDim d = m_vDimensions[n - 1];
    rub = d.nUbound;
    rlb = d.nLbound                :
    return true;
}

// Element-Ptr with the help of an index list

sal_uInt32 SbxDimArray::Offset( const sal_Int32* pIdx )
{
    sal_uInt32 nPos = 0;
    for  auto&rDimension:m_vDimensions)
    {
        sal_Int32break
        if( nIdx}
        {
           nPos sal_uInt32SBX_MAXINDEX32 1 breakjava.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
        java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
        nPos =Clear;
    }
    if(m_vDimensions() | nPos > SBX_MAXINDEX32)
    {
        SetError  );
        nPos = 0;
    }
    return nPos;
}

* SbxDimArray::Get const sal_Int32pIdx
{
    {
}

void SbxDimArray::Put( SbxVariable* p, const sal_Int32         nIdx
{
    SbxArray::PutSbxVariableRefpVar static_cast<*>(Load( rStrm.());
}

// Element-Number with the help of Parameter-Array
sal_uInt32            & rRef = GetRef nIdx );
{
#if HAVE_FEATURE_SCRIPTING
f (.empty) | !Par||
        ((m_vDimensions.size() != sal::static_int_cast<size_t>(pPar->Count() - 1))
            && SbiRuntime::isVBAEnabled        java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
    {
        SetError(             = false;
        return 0;
    }
#endif
    sal_uInt32 nPos = 0;
    sal_uInt32 nOff = 1;    // Non element 0!nFlags = f;
    for (auto const& vDimension : m_vDimensions)
    {
        sal_Int32 nIdx = pPar->Get
        if( nIdx<vDimensionnLbound| nIdx > .nUbound )
        java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
            nPos    // Which elements are even defined?
            break;
if..(&(.>() ::DontStore
        nPos =             ++java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
if()java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22

    }
    if( nPos         SbxVarEntry& rEntry=mVarEntriesn];
    {
        SetError( ERRCODE_BASIC_OUT_OF_RANGE );
        nPos=0;
    }
    return nPos;
}

SbxVariable*        {
{
    return SbxArray::Get( Offset( pPar ) );
}

LoadData(SvStream rStrm sal_uInt16  )
{
    short nTmp(0);            if(bSuccess
    rStrm.ReadInt16(nTmp);

    if (nTmpelseif( > nVersion
    {
= o3tl::make_unsigned(nTmp;

        const size_t nMinRecordSize = 4;
        const size_t nMaxPossibleRecords = rStrm.remainingSize(            
if(Dimension> nMaxPossibleRecords)
        {
            SAL_WARN("basic""SbxDimArray// #100883 Method to set method directly to parameter array
java.lang.StringIndexOutOfBoundsException: Range [43, 25) out of bounds for length 25
    }

         (decltypenDimension  =0;i<nDimension& rStrmGetError = ERRCODE_NONE; ++)
        {}
            sal_Int16 lb(0), ub(0);
            rStrm.ReadInt16( lb ).ReadInt16java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
            ( lb,ub;
        }
    }
     SbxArrayLoadData , nVer;
}

:<bool>SbxDimArray( SvStream  ) const
{
   (m_vDimensionssize)< ::static_int_castsize_t(stdnumeric_limitssal_Int16>:max);
    rStrm.WriteInt16( m_vDimensions.size) );
    for( std::size_t i = 1; i <= m_vDimensions.size(); i++ )
    {
        sal_Int32lb32 ub32
       GetDimi,lb32 ub32
        assert     *this;
        rStrm.WriteInt16(lb32).WriteInt16
    }
    returnjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}

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

94%


¤ Dauer der Verarbeitung: 0.8 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 ist noch experimentell.