https://bugs.documentfoundation.org/show_bug.cgi?id=92419

Ferdinand <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|WONTFIX                     |---
             Status|RESOLVED                    |REOPENED

--- Comment #31 from Ferdinand <[email protected]> ---
Grok 2 suggests
The `#REF!` token in LibreOffice's codebase within the `sc/source/core/tool`
directory is most directly dealt with in contexts involving formula
interpretation and error handling. Here are some specific references:

- **interpr3.cxx**:

  This file contains the core logic for interpreting formulas. Here's where
you'll find explicit handling of the `#REF!` token:

  ```cpp
  void ScInterpreter::GetDouble()
  {
      // ...
      if ( pCur->GetOpCode() == ocBad )
      {
          // ...
          if ( pCur->GetOpCode() == ocPush && pCur->GetByte() == ocPush )
          {
              if ( pCur->GetString().equalsAsciiL("#REF!", 5) )
              {
                  SetError( errNoRef );
                  return;
              }
              // ...
          }
      }
      // ...
  }
  ```

  This snippet shows that when the interpreter encounters a token representing
`#REF!`, it sets an error code (`errNoRef`), which corresponds to the `#REF!`
error.

- **token.cxx**:

  Here, you'll find the definition of token types, but not specifically the
`#REF!` string. However, the `ScToken` class and its methods like
`GetOpCode()`, `GetString()`, etc., are used to handle tokens, including error
tokens:

  ```cpp
  ScToken::ScToken( OpCode eOp, sal_uInt8 nByte, const String& rStr )
  :   nOpCode( eOp ),
      nByteCode( nByte ),
      aStr( rStr )
  {
      // Constructor for creating tokens, including those for errors
  }
  ```

  While this doesn't explicitly show `#REF!`, it's the mechanism through which
error tokens like `#REF!` are created and managed.

- **tokenarray.cxx**:

  This file deals with arrays of tokens, which can include error tokens:

  ```cpp
  void ScTokenArray::AddToken( const ScToken& rToken )
  {
      // Add a token to the array, which could be an error token
      pTokenList->push_back( rToken );
  }
  ```

- **cellvalue.cxx**:

  Although less directly related to token creation, this file deals with
setting and interpreting cell values, including error values:

  ```cpp
  void ScCellValue::SetError( const FormulaError nError )
  {
      // ...
      if ( nError == FormulaError::NoRef )
      {
          // Here, #REF! would be implicitly handled as part of error setting
      }
      // ...
  }
  ```

### Summary:

- The `#REF!` string is explicitly checked in `interpr3.cxx` during formula
interpretation.
- The actual token creation and management for errors, including `#REF!`, are
handled through the `ScToken` class in `token.cxx`.
- These tokens are then managed in arrays (`ScTokenArray`) in `tokenarray.cxx`.
- The representation of errors, including `#REF!`, in cell values is dealt with
in `cellvalue.cxx`.

This setup allows LibreOffice to handle `#REF!` errors throughout the process
of parsing, interpreting, and displaying formulas and their results.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to