<commit_before>/***************************************************************************
 *   Copyright (c) <NAME> (<EMAIL>) 2015             *
 *                                                                         *
 *   This file is part of the FreeCAD CAx development system.              *
 *                                                                         *
 *   This library is free software; you can redistribute it and/or         *
 *   modify it under the terms of the GNU Library General Public           *
 *   License as published by the Free Software Foundation; either          *
 *   version 2 of the License, or (at your option) any later version.      *
 *                                                                         *
 *   This library  is distributed in the hope that it will be useful,      *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU Library General Public License for more details.                  *
 *                                                                         *
 *   You should have received a copy of the GNU Library General Public     *
 *   License along with this library; see the file COPYING.LIB. If not,    *
 *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
 *   Suite 330, Boston, MA  02111-1307, USA                                *
 *                                                                         *
 ***************************************************************************/

#include "PreCompiled.h"
#include "SheetObserver.h"
#include "PropertySheet.h"

using namespace Spreadsheet;
using namespace App;

/**
  * The SheetObserver constructor.
  *
  * @param document The Document we are observing
  * @param _sheet   The sheet owning this observer.
  *
  */

SheetObserver::SheetObserver(App::Document * document, PropertySheet *_sheet)
    : DocumentObserver(document)
    , refCount(1)
    , sheet(_sheet)
{
}

/**
  * Invalidate cells that depend on this document object.
  *
  */

void SheetObserver::slotCreatedObject(const DocumentObject &Obj)
{
    sheet->invalidateDependants(&Obj);
}

/**
  * Invalidate cells that depend on this document object.
  *
  */

void SheetObserver::slotDeletedObject(const DocumentObject &Obj)
{
    sheet->invalidateDependants(&Obj);
    sheet->deletedDocumentObject(&Obj);
}

/**
  * Invoke the sheets recomputeDependants when a change to a Property occurs.
  *
  */

void SheetObserver::slotChangedObject(const DocumentObject &Obj, const Property &Prop)
{
    const char * name = Obj.getPropertyName(&Prop);
    assert(name != 0);

    if (&Prop == &Obj.Label)
        sheet->renamedDocumentObject(&Obj);
    else {

        if (isUpdating.find(name) != isUpdating.end())
            return;<commit_msg>Spreadsheet: Issue #2388: The SheetObserver should ignore changed properties that don't have a name.<commit_after>/***************************************************************************
 *   Copyright (c) <NAME> (<EMAIL>) 2015             *
 *                                                                         *
 *   This file is part of the FreeCAD CAx development system.              *
 *                                                                         *
 *   This library is free software; you can redistribute it and/or         *
 *   modify it under the terms of the GNU Library General Public           *
 *   License as published by the Free Software Foundation; either          *
 *   version 2 of the License, or (at your option) any later version.      *
 *                                                                         *
 *   This library  is distributed in the hope that it will be useful,      *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU Library General Public License for more details.                  *
 *                                                                         *
 *   You should have received a copy of the GNU Library General Public     *
 *   License along with this library; see the file COPYING.LIB. If not,    *
 *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
 *   Suite 330, Boston, MA  02111-1307, USA                                *
 *                                                                         *
 ***************************************************************************/

#include "PreCompiled.h"
#include "SheetObserver.h"
#include "PropertySheet.h"

using namespace Spreadsheet;
using namespace App;

/**
  * The SheetObserver constructor.
  *
  * @param document The Document we are observing
  * @param _sheet   The sheet owning this observer.
  *
  */

SheetObserver::SheetObserver(App::Document * document, PropertySheet *_sheet)
    : DocumentObserver(document)
    , refCount(1)
    , sheet(_sheet)
{
}

/**
  * Invalidate cells that depend on this document object.
  *
  */

void SheetObserver::slotCreatedObject(const DocumentObject &Obj)
{
    sheet->invalidateDependants(&Obj);
}

/**
  * Invalidate cells that depend on this document object.
  *
  */

void SheetObserver::slotDeletedObject(const DocumentObject &Obj)
{
    sheet->invalidateDependants(&Obj);
    sheet->deletedDocumentObject(&Obj);
}

/**
  * Invoke the sheets recomputeDependants when a change to a Property occurs.
  *
  */

void SheetObserver::slotChangedObject(const DocumentObject &Obj, const Property &Prop)
{
    if (&Prop == &Obj.Label)
        sheet->renamedDocumentObject(&Obj);
    else {
        const char * name = Obj.getPropertyName(&Prop);

        if (name == 0)
            return;

        if (isUpdating.find(name) != isUpdating.end())
            return;
{'fraction_non_alphanumeric': 0.12817021276595744, 'fraction_numerical': 0.007829787234042554, 'mean_word_length': 1.8733496332518338, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 32, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6333142', 'n_tokens_mistral': 1402, 'n_tokens_neox': 1330, 'n_words': 478}