<commit_before>/*************************************************************************
 *
 *  $RCSfile: colrowba.hxx,v $
 *
 *  $Revision: 1.2 $
 *
 *  last change: $Author: hr $ $Date: 2004-02-03 12:37:08 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  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
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (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.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

#ifndef SC_COLROWBAR_HXX
#define SC_COLROWBAR_HXX

#ifndef SC_HDRCONT_HXX
#include "hdrcont.hxx"
#endif

#ifndef SC_VIEWDATA_HXX
#include "viewdata.hxx"
#endif

class ScHeaderFunctionSet;
class ScHeaderSelectionEngine;

// ---------------------------------------------------------------------------

class ScColBar : public ScHeaderControl
{
    ScViewData*              pViewData;
    ScHSplitPos              eWhich;
    ScHeaderFunctionSet*     pFuncSet;
    ScHeaderSelectionEngine* pSelEngine;

public:
                ScColBar( Window* pParent, ScViewData* pData, ScHSplitPos eWhichPos,
                            ScHeaderFunctionSet* pFunc, ScHeaderSelectionEngine* pEng );
                ~ScColBar();

    virtual USHORT      GetPos();
    virtual USHORT      GetEntrySize( USHORT nEntryNo );
    virtual String      GetEntryText( USHORT nEntryNo );

    virtual BOOL        IsLayoutRTL();                      // only for columns

    virtual void        SetEntrySize( USHORT nPos, USHORT nNewSize );
    virtual void        HideEntries( USHORT nStart, USHORT nEnd );

    virtual void        SetMarking( BOOL bSet );
    virtual void        SelectWindow();
    virtual BOOL        IsDisabled();
    virtual BOOL        ResizeAllowed();

    virtual void        DrawInvert( long nDragPos );

    virtual String      GetDragHelp( long nVal );
};

class ScRowBar : public ScHeaderControl
{
    ScViewData*              pViewData;
    ScVSplitPos              eWhich;
    ScHeaderFunctionSet*     pFuncSet;
    ScHeaderSelectionEngine* pSelEngine;

public:
                ScRowBar( Window* pParent, ScViewData* pData, ScVSplitPos eWhichPos,
                            ScHeaderFunctionSet* pFunc, ScHeaderSelectionEngine* pEng );
                ~ScRowBar();

    virtual USHORT      GetPos();
    virtual USHORT      GetEntrySize( USHORT nEntryNo );
    virtual String      GetEntryText( USHORT nEntryNo );

    virtual BOOL        IsMirrored();                       // only for columns
    virtual USHORT      GetHiddenCount( USHORT nEntryNo );  // only for columns

    virtual void        SetEntrySize( USHORT nPos, USHORT nNewSize );
    virtual void        HideEntries( USHORT nStart, USHORT nEnd );

    virtual void        SetMarking( BOOL bSet );
    virtual void        SelectWindow();
    virtual BOOL        IsDisabled();
    virtual BOOL        ResizeAllowed();

    virtual void        DrawInvert( long nDragPos );

    virtual String      GetDragHelp( long nVal );
};

#endif

<commit_msg>INTEGRATION: CWS rowlimit (1.2.12); FILE MERGED 2004/02/26 19:13:39 jmarmion 1.2.12.1: #i1967# setp 5 changes.<commit_after>/*************************************************************************
 *
 *  $RCSfile: colrowba.hxx,v $
 *
 *  $Revision: 1.3 $
 *
 *  last change: $Author: obo $ $Date: 2004-06-04 11:30:53 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  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
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (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.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

#ifndef SC_COLROWBAR_HXX
#define SC_COLROWBAR_HXX

#ifndef SC_HDRCONT_HXX
#include "hdrcont.hxx"
#endif

#ifndef SC_VIEWDATA_HXX
#include "viewdata.hxx"
#endif

class ScHeaderFunctionSet;
class ScHeaderSelectionEngine;

// ---------------------------------------------------------------------------

class ScColBar : public ScHeaderControl
{
    ScViewData*              pViewData;
    ScHSplitPos              eWhich;
    ScHeaderFunctionSet*     pFuncSet;
    ScHeaderSelectionEngine* pSelEngine;

public:
                ScColBar( Window* pParent, ScViewData* pData, ScHSplitPos eWhichPos,
                            ScHeaderFunctionSet* pFunc, ScHeaderSelectionEngine* pEng );
                ~ScColBar();

    virtual SCCOLROW    GetPos();
    virtual USHORT      GetEntrySize( SCCOLROW nEntryNo );
    virtual String      GetEntryText( SCCOLROW nEntryNo );

    virtual BOOL        IsLayoutRTL();                      // only for columns

    virtual void        SetEntrySize( SCCOLROW nPos, USHORT nNewSize );
    virtual void        HideEntries( SCCOLROW nStart, SCCOLROW nEnd );

    virtual void        SetMarking( BOOL bSet );
    virtual void        SelectWindow();
    virtual BOOL        IsDisabled();
    virtual BOOL        ResizeAllowed();

    virtual void        DrawInvert( long nDragPos );

    virtual String      GetDragHelp( long nVal );
};

class ScRowBar : public ScHeaderControl
{
    ScViewData*              pViewData;
    ScVSplitPos              eWhich;
    ScHeaderFunctionSet*     pFuncSet;
    ScHeaderSelectionEngine* pSelEngine;

public:
                ScRowBar( Window* pParent, ScViewData* pData, ScVSplitPos eWhichPos,
                            ScHeaderFunctionSet* pFunc, ScHeaderSelectionEngine* pEng );
                ~ScRowBar();

    virtual SCCOLROW    GetPos();
    virtual USHORT      GetEntrySize( SCCOLROW nEntryNo );
    virtual String      GetEntryText( SCCOLROW nEntryNo );

    virtual BOOL        IsMirrored();                       // only for columns
    virtual SCROW       GetHiddenCount( SCROW nEntryNo );   // only for columns

    virtual void        SetEntrySize( SCCOLROW nPos, USHORT nNewSize );
    virtual void        HideEntries( SCCOLROW nStart, SCCOLROW nEnd );

    virtual void        SetMarking( BOOL bSet );
    virtual void        SelectWindow();
    virtual BOOL        IsDisabled();
    virtual BOOL        ResizeAllowed();

    virtual void        DrawInvert( long nDragPos );

    virtual String      GetDragHelp( long nVal );
};

#endif

<|endoftext|>


<commit_before>// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "indexcollection.h"
#include "indexsearchablevisitor.h"
#include <vespa/searchlib/queryeval/isourceselector.h>
#include <vespa/searchlib/queryeval/create_blueprint_visitor_helper.h>
#include <vespa/searchlib/queryeval/intermediate_blueprints.h>
#include <vespa/searchlib/queryeval/leaf_blueprints.h>

#include <vespa/log/log.h>
LOG_SETUP(".searchcorespi.index.indexcollection");

using namespace search::queryeval;
using namespace search::query;
using search::attribute::IAttributeContext;

namespace searchcorespi {

IndexCollection::IndexCollection(const ISourceSelector::SP & selector)
    : _source_selector(selector),
      _sources()
{
}

IndexCollection::IndexCollection(const ISourceSelector::SP & selector,
                                 const ISearchableIndexCollection &sources)
    : _source_selector(selector),
      _sources()
{
    for (size_t i(0), m(sources.getSourceCount()); i < m; i++) {
        append(sources.getSourceId(i), sources.getSearchableSP(i));
    }
    setCurrentIndex(sources.getCurrentIndex());
}

IndexCollection::~IndexCollection() {}

void
IndexCollection::setSource(uint32_t docId)
{
    assert( valid() );
    _source_selector->setSource(docId, getCurrentIndex());
}

ISearchableIndexCollection::UP
IndexCollection::replaceAndRenumber(const ISourceSelector::SP & selector,
                                    const ISearchableIndexCollection &fsc,
                                    uint32_t id_diff,
                                    const IndexSearchable::SP &new_source)
{
    ISearchableIndexCollection::UP new_fsc(new IndexCollection(selector));
    new_fsc->append(0, new_source);
    for (size_t i = 0; i < fsc.getSourceCount(); ++i) {
        if (fsc.getSourceId(i) > id_diff) {
            new_fsc->append(fsc.getSourceId(i) - id_diff,
                            fsc.getSearchableSP(i));
        }
    }
    return new_fsc;
}

void
IndexCollection::append(uint32_t id, const IndexSearchable::SP &fs)
{
    _sources.push_back(SourceWithId(id, fs));
}

IndexSearchable::SP
IndexCollection::getSearchableSP(uint32_t i) const
{
    return _sources[i].source_wrapper;
}

void
IndexCollection::replace(uint32_t id, const IndexSearchable::SP &fs)
{
    for (size_t i = 0; i < _sources.size(); ++i) {
        if (_sources[i].id == id) {
            _sources[i].source_wrapper = fs;
            return;
        }
    }
    LOG(warning, "Tried to replace Searchable %d, but it wasn't there.", id);
    append(id, fs);
}

const ISourceSelector &
IndexCollection::getSourceSelector() const
{
    return *_source_selector;
}

size_t
IndexCollection::getSourceCount() const
{
    return _sources.size();
}

IndexSearchable &
IndexCollection::getSearchable(uint32_t i) const
{
    return *_sources[i].source_wrapper;
}

uint32_t
IndexCollection::getSourceId(uint32_t i) const
{
    return _sources[i].id;
}

search::SearchableStats
IndexCollection::getSearchableStats() const
{
    search::SearchableStats stats;
    for (size_t i = 0; i < _sources.size(); ++i) {
        stats.add(_sources[i].source_wrapper->getSearchableStats());
    }
    return stats;
}

search::SerialNum
IndexCollection::getSerialNum() const
{
    search::SerialNum serialNum = 0;
    for (auto &source : _sources) {
        serialNum = std::max(serialNum, source.source_wrapper->getSerialNum());
    }
    return serialNum;
}

void
IndexCollection::accept(IndexSearchableVisitor &visitor) const
{
    for (auto &source : _sources) {
        source.source_wrapper->accept(visitor);
    }
}

namespace {

struct Mixer {
    const ISourceSelector                &_selector;
    std::unique_ptr<SourceBlenderBlueprint> _blender;

    Mixer(const ISourceSelector &selector)
        : _selector(selector), _blender() {}

    void addIndex(Blueprint::UP index) {
        if (_blender.get() == NULL) {
            _blender.reset(new SourceBlenderBlueprint(_selector));
        }
        _blender->addChild(std::move(index));
    }

    Blueprint::UP mix() {
        if (_blender.get() == NULL) {
            return Blueprint::UP(new EmptyBlueprint());
        }
        return Blueprint::UP(_blender.release());
    }
};

class CreateBlueprintVisitor : public search::query::QueryVisitor {
private:
    const IIndexCollection  &_indexes;
    const FieldSpecList     &_fields;
    const IRequestContext   &_requestContext;
    Blueprint::UP            _result;

    template <typename NodeType>
    void visitTerm(NodeType &n) {
        Mixer mixer(_indexes.getSourceSelector());
        for (size_t i = 0; i < _indexes.getSourceCount(); ++i) {
            Blueprint::UP blueprint = _indexes.getSearchable(i).createBlueprint(_requestContext, _fields, n);
            blueprint->setSourceId(_indexes.getSourceId(i));
            mixer.addIndex(std::move(blueprint));
        }
        _result = mixer.mix();
    }

    void visit(And &)     override { }
    void visit(AndNot &)  override { }
    void visit(Or &)      override { }
    void visit(WeakAnd &) override { }
    void visit(Equiv &)   override { }
    void visit(Rank &)    override { }
    void visit(Near &)    override { }
    void visit(ONear &)   override { }

    void visit(WeightedSetTerm &n) override { visitTerm(n); }
    void visit(DotProduct &n)      override { visitTerm(n); }
    void visit(WandTerm &n)        override { visitTerm(n); }
    void visit(Phrase &n)          override { visitTerm(n); }
    void visit(SameElement &n)     override { visitTerm(n); }
    void visit(NumberTerm &n)      override { visitTerm(n); }
    void visit(LocationTerm &n)    override { visitTerm(n); }
    void visit(PrefixTerm &n)      override { visitTerm(n); }
    void visit(RangeTerm &n)       override { visitTerm(n); }
    void visit(StringTerm &n)      override { visitTerm(n); }
    void visit(SubstringTerm &n)   override { visitTerm(n); }
    void visit(SuffixTerm &n)      override { visitTerm(n); }
    void visit(PredicateQuery &n)  override { visitTerm(n); }
    void visit(RegExpTerm &n)      override { visitTerm(n); }

public:
    CreateBlueprintVisitor(const IIndexCollection &indexes,
                           const FieldSpecList &fields,
                           const IRequestContext & requestContext)
        : _indexes(indexes),
          _fields(fields),
          _requestContext(requestContext),
          _result() {}

    Blueprint::UP getResult() { return std::move(_result); }
};

}

Blueprint::UP
IndexCollection::createBlueprint(const IRequestContext & requestContext,
                                 const FieldSpec &field,
                                 const Node &term)
{
    FieldSpecList fields;
    fields.add(field);
    return createBlueprint(requestContext, fields, term);
}

Blueprint::UP
IndexCollection::createBlueprint(const IRequestContext & requestContext,
                                 const FieldSpecList &fields,
                                 const Node &term)
{
    CreateBlueprintVisitor visitor(*this, fields, requestContext);
    const_cast<Node &>(term).accept(visitor);
    return visitor.getResult();
}

}  // namespace searchcorespi
<commit_msg>SameEelemt is not a term.<commit_after>// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "indexcollection.h"
#include "indexsearchablevisitor.h"
#include <vespa/searchlib/queryeval/isourceselector.h>
#include <vespa/searchlib/queryeval/create_blueprint_visitor_helper.h>
#include <vespa/searchlib/queryeval/intermediate_blueprints.h>
#include <vespa/searchlib/queryeval/leaf_blueprints.h>

#include <vespa/log/log.h>
LOG_SETUP(".searchcorespi.index.indexcollection");

using namespace search::queryeval;
using namespace search::query;
using search::attribute::IAttributeContext;

namespace searchcorespi {

IndexCollection::IndexCollection(const ISourceSelector::SP & selector)
    : _source_selector(selector),
      _sources()
{
}

IndexCollection::IndexCollection(const ISourceSelector::SP & selector,
                                 const ISearchableIndexCollection &sources)
    : _source_selector(selector),
      _sources()
{
    for (size_t i(0), m(sources.getSourceCount()); i < m; i++) {
        append(sources.getSourceId(i), sources.getSearchableSP(i));
    }
    setCurrentIndex(sources.getCurrentIndex());
}

IndexCollection::~IndexCollection() {}

void
IndexCollection::setSource(uint32_t docId)
{
    assert( valid() );
    _source_selector->setSource(docId, getCurrentIndex());
}

ISearchableIndexCollection::UP
IndexCollection::replaceAndRenumber(const ISourceSelector::SP & selector,
                                    const ISearchableIndexCollection &fsc,
                                    uint32_t id_diff,
                                    const IndexSearchable::SP &new_source)
{
    ISearchableIndexCollection::UP new_fsc(new IndexCollection(selector));
    new_fsc->append(0, new_source);
    for (size_t i = 0; i < fsc.getSourceCount(); ++i) {
        if (fsc.getSourceId(i) > id_diff) {
            new_fsc->append(fsc.getSourceId(i) - id_diff,
                            fsc.getSearchableSP(i));
        }
    }
    return new_fsc;
}

void
IndexCollection::append(uint32_t id, const IndexSearchable::SP &fs)
{
    _sources.push_back(SourceWithId(id, fs));
}

IndexSearchable::SP
IndexCollection::getSearchableSP(uint32_t i) const
{
    return _sources[i].source_wrapper;
}

void
IndexCollection::replace(uint32_t id, const IndexSearchable::SP &fs)
{
    for (size_t i = 0; i < _sources.size(); ++i) {
        if (_sources[i].id == id) {
            _sources[i].source_wrapper = fs;
            return;
        }
    }
    LOG(warning, "Tried to replace Searchable %d, but it wasn't there.", id);
    append(id, fs);
}

const ISourceSelector &
IndexCollection::getSourceSelector() const
{
    return *_source_selector;
}

size_t
IndexCollection::getSourceCount() const
{
    return _sources.size();
}

IndexSearchable &
IndexCollection::getSearchable(uint32_t i) const
{
    return *_sources[i].source_wrapper;
}

uint32_t
IndexCollection::getSourceId(uint32_t i) const
{
    return _sources[i].id;
}

search::SearchableStats
IndexCollection::getSearchableStats() const
{
    search::SearchableStats stats;
    for (size_t i = 0; i < _sources.size(); ++i) {
        stats.add(_sources[i].source_wrapper->getSearchableStats());
    }
    return stats;
}

search::SerialNum
IndexCollection::getSerialNum() const
{
    search::SerialNum serialNum = 0;
    for (auto &source : _sources) {
        serialNum = std::max(serialNum, source.source_wrapper->getSerialNum());
    }
    return serialNum;
}

void
IndexCollection::accept(IndexSearchableVisitor &visitor) const
{
    for (auto &source : _sources) {
        source.source_wrapper->accept(visitor);
    }
}

namespace {

struct Mixer {
    const ISourceSelector                &_selector;
    std::unique_ptr<SourceBlenderBlueprint> _blender;

    Mixer(const ISourceSelector &selector)
        : _selector(selector), _blender() {}

    void addIndex(Blueprint::UP index) {
        if (_blender.get() == NULL) {
            _blender.reset(new SourceBlenderBlueprint(_selector));
        }
        _blender->addChild(std::move(index));
    }

    Blueprint::UP mix() {
        if (_blender.get() == NULL) {
            return Blueprint::UP(new EmptyBlueprint());
        }
        return Blueprint::UP(_blender.release());
    }
};

class CreateBlueprintVisitor : public search::query::QueryVisitor {
private:
    const IIndexCollection  &_indexes;
    const FieldSpecList     &_fields;
    const IRequestContext   &_requestContext;
    Blueprint::UP            _result;

    template <typename NodeType>
    void visitTerm(NodeType &n) {
        Mixer mixer(_indexes.getSourceSelector());
        for (size_t i = 0; i < _indexes.getSourceCount(); ++i) {
            Blueprint::UP blueprint = _indexes.getSearchable(i).createBlueprint(_requestContext, _fields, n);
            blueprint->setSourceId(_indexes.getSourceId(i));
            mixer.addIndex(std::move(blueprint));
        }
        _result = mixer.mix();
    }

    void visit(And &)         override { }
    void visit(AndNot &)      override { }
    void visit(Or &)          override { }
    void visit(WeakAnd &)     override { }
    void visit(Equiv &)       override { }
    void visit(Rank &)        override { }
    void visit(Near &)        override { }
    void visit(ONear &)       override { }
    void visit(SameElement &) override { }

    void visit(WeightedSetTerm &n) override { visitTerm(n); }
    void visit(DotProduct &n)      override { visitTerm(n); }
    void visit(WandTerm &n)        override { visitTerm(n); }
    void visit(Phrase &n)          override { visitTerm(n); }
    void visit(NumberTerm &n)      override { visitTerm(n); }
    void visit(LocationTerm &n)    override { visitTerm(n); }
    void visit(PrefixTerm &n)      override { visitTerm(n); }
    void visit(RangeTerm &n)       override { visitTerm(n); }
    void visit(StringTerm &n)      override { visitTerm(n); }
    void visit(SubstringTerm &n)   override { visitTerm(n); }
    void visit(SuffixTerm &n)      override { visitTerm(n); }
    void visit(PredicateQuery &n)  override { visitTerm(n); }
    void visit(RegExpTerm &n)      override { visitTerm(n); }

public:
    CreateBlueprintVisitor(const IIndexCollection &indexes,
                           const FieldSpecList &fields,
                           const IRequestContext & requestContext)
        : _indexes(indexes),
          _fields(fields),
          _requestContext(requestContext),
          _result() {}

    Blueprint::UP getResult() { return std::move(_result); }
};

}

Blueprint::UP
IndexCollection::createBlueprint(const IRequestContext & requestContext,
                                 const FieldSpec &field,
                                 const Node &term)
{
    FieldSpecList fields;
    fields.add(field);
    return createBlueprint(requestContext, fields, term);
}

Blueprint::UP
IndexCollection::createBlueprint(const IRequestContext & requestContext,
                                 const FieldSpecList &fields,
                                 const Node &term)
{
    CreateBlueprintVisitor visitor(*this, fields, requestContext);
    const_cast<Node &>(term).accept(visitor);
    return visitor.getResult();
}

}  // namespace searchcorespi
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: drawview.hxx,v $
 *
 *  $Revision: 1.3 $
 *
 *  last change: $Author: rt $ $Date: 2003-11-24 17:26:47 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  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
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (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.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

#ifndef SC_DRAWVIEW_HXX
#define SC_DRAWVIEW_HXX

#ifndef _SVX_FMVIEW_HXX //autogen
#include <svx/fmview.hxx>
#endif

#include "global.hxx"

class ScDocument;
class ScViewData;
class SdrViewUserMarker;

class ScDrawView: public FmFormView
{
    ScViewData*             pViewData;
    OutputDevice*           pDev;                   //! noetig ?
    ScDocument*             pDoc;
    USHORT                  nTab;
    Fraction                aScaleX;                // Faktor fuer Drawing-MapMode
    Fraction                aScaleY;
    SdrViewUserMarker*      pDropMarker;
    SdrObject*              pDropMarkObj;
    BOOL                    bInConstruct;
    BOOL                    bDisableHdl;

    void            Construct();
    void            UpdateBrowser();

protected:
    virtual void    ModelHasChanged();
    virtual void    MakeVisible( const Rectangle& rRect, Window& rWin );

    // add custom handles (used by other apps, e.g. AnchorPos)
    virtual void AddCustomHdl();

public:
                    ScDrawView( OutputDevice* pOut, ScViewData* pData );
                    ScDrawView( OutputDevice* pOut, ScDocument* pDocument, USHORT nTable );
    virtual         ~ScDrawView();

    virtual void    MarkListHasChanged();
    virtual void    SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
                         const SfxHint& rHint, const TypeId& rHintType );

    void            DrawMarks( OutputDevice* pOut ) const;

    void            MarkDropObj( SdrObject* pObj );

    BOOL            IsDisableHdl() const    { return bDisableHdl; }

    void            SetMarkedToLayer( BYTE nLayerNo );

    void            InvalidateAttribs();
    void            InvalidateDrawTextAttrs();

    BOOL            BeginDrag( Window* pWindow, const Point& rStartPos );
    void            DoCut();
    void            DoCopy();

    void            GetScale( Fraction& rFractX, Fraction& rFractY ) const;
    void            RecalcScale();
    void            UpdateWorkArea();
    USHORT          GetTab() const      { return nTab; }

    void            CalcNormScale( Fraction& rFractX, Fraction& rFractY ) const;

    // #110094#-17 Not used
    // void         PaintObject( SdrObject* pObject, OutputDevice* pDev ) const;

    void            SetAnchor( ScAnchorType );
    ScAnchorType    GetAnchor() const;

    void            VCAddWin( Window* pWin );
    void            VCRemoveWin( Window* pWin );

    void            UpdateIMap( SdrObject* pObj );

    USHORT          GetPopupMenuId();
    void            UpdateUserViewOptions();

    void            SetMarkedOriginalSize();

    BOOL            SelectObject( const String& rName );
    String          GetSelectedChartName() const;
    BOOL            HasMarkedControl() const;

    FASTBOOL        InsertObjectSafe(SdrObject* pObj, SdrPageView& rPV, ULONG nOptions=0);

    SdrEndTextEditKind  ScEndTextEdit();    // ruft SetDrawTextUndo(0)
};

#endif

<commit_msg>INTEGRATION: CWS rowlimit (1.3.28); FILE MERGED 2004/01/13 20:04:13 er 1.3.28.1: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short<commit_after>/*************************************************************************
 *
 *  $RCSfile: drawview.hxx,v $
 *
 *  $Revision: 1.4 $
 *
 *  last change: $Author: obo $ $Date: 2004-06-04 11:32:40 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  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
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (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.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

#ifndef SC_DRAWVIEW_HXX
#define SC_DRAWVIEW_HXX

#ifndef _SVX_FMVIEW_HXX //autogen
#include <svx/fmview.hxx>
#endif

#include "global.hxx"

class ScDocument;
class ScViewData;
class SdrViewUserMarker;

class ScDrawView: public FmFormView
{
    ScViewData*             pViewData;
    OutputDevice*           pDev;                   //! noetig ?
    ScDocument*             pDoc;
    SCTAB                   nTab;
    Fraction                aScaleX;                // Faktor fuer Drawing-MapMode
    Fraction                aScaleY;
    SdrViewUserMarker*      pDropMarker;
    SdrObject*              pDropMarkObj;
    BOOL                    bInConstruct;
    BOOL                    bDisableHdl;

    void            Construct();
    void            UpdateBrowser();

protected:
    virtual void    ModelHasChanged();
    virtual void    MakeVisible( const Rectangle& rRect, Window& rWin );

    // add custom handles (used by other apps, e.g. AnchorPos)
    virtual void AddCustomHdl();

public:
                    ScDrawView( OutputDevice* pOut, ScViewData* pData );
                    ScDrawView( OutputDevice* pOut, ScDocument* pDocument, SCTAB nTable );
    virtual         ~ScDrawView();

    virtual void    MarkListHasChanged();
    virtual void    SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
                         const SfxHint& rHint, const TypeId& rHintType );

    void            DrawMarks( OutputDevice* pOut ) const;

    void            MarkDropObj( SdrObject* pObj );

    BOOL            IsDisableHdl() const    { return bDisableHdl; }

    void            SetMarkedToLayer( BYTE nLayerNo );

    void            InvalidateAttribs();
    void            InvalidateDrawTextAttrs();

    BOOL            BeginDrag( Window* pWindow, const Point& rStartPos );
    void            DoCut();
    void            DoCopy();

    void            GetScale( Fraction& rFractX, Fraction& rFractY ) const;
    void            RecalcScale();
    void            UpdateWorkArea();
    SCTAB           GetTab() const      { return nTab; }

    void            CalcNormScale( Fraction& rFractX, Fraction& rFractY ) const;

    // #110094#-17 Not used
    // void         PaintObject( SdrObject* pObject, OutputDevice* pDev ) const;

    void            SetAnchor( ScAnchorType );
    ScAnchorType    GetAnchor() const;

    void            VCAddWin( Window* pWin );
    void            VCRemoveWin( Window* pWin );

    void            UpdateIMap( SdrObject* pObj );

    USHORT          GetPopupMenuId();
    void            UpdateUserViewOptions();

    void            SetMarkedOriginalSize();

    BOOL            SelectObject( const String& rName );
    String          GetSelectedChartName() const;
    BOOL            HasMarkedControl() const;

    FASTBOOL        InsertObjectSafe(SdrObject* pObj, SdrPageView& rPV, ULONG nOptions=0);

    SdrEndTextEditKind  ScEndTextEdit();    // ruft SetDrawTextUndo(0)
};

#endif

<|endoftext|>


<commit_before>#pragma once
//=====================================================================//
/*!	@file
	@brief	固定サイズ文字列クラス
    @author 平松邦仁 (hira@rvf-rc45.net)
	@copyright	Copyright (C) 2017, 2020 Kunihito Hiramatsu @n
				Released under the MIT license @n
				https://github.com/hirakuni45/RX/blob/master/LICENSE
*/
//=====================================================================//
#include <algorithm>
#include <cstring>
#include <iterator>
#include "common/string_utils.hpp"

namespace utils {

	//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
	/*!
		@brief  固定サイズ文字列クラス
		@param[in]	SIZE	文字列サイズ
	*/
	//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
	template <uint32_t SIZE>
	class fixed_string {
		uint32_t	pos_;
		char		str_[SIZE + 1];

	public:
		//-----------------------------------------------------------------//
		/*!
			@brief  コンストラクタ
			@param[in]	str	初期設定文字列
		*/
		//-----------------------------------------------------------------//
		fixed_string(const char* str = nullptr) noexcept : pos_(0) {
			if(str != nullptr) {
				utils::str::strncpy_(str_, str, SIZE);
				pos_ = std::strlen(str_);
			}
			str_[pos_] = 0;
			str_[SIZE] = 0;
		}

		//-----------------------------------------------------------------//
		/*!
			@brief  格納可能な最大サイズを返す（終端の数を除外）
			@return 格納可能な最大サイズ
		*/
		//-----------------------------------------------------------------//
		uint32_t capacity() const noexcept { return SIZE; }

		//-----------------------------------------------------------------//
		/*!
			@brief  現在のサイズを返す
			@return 現在のサイズ
		*/
		//-----------------------------------------------------------------//
		uint32_t size() const noexcept { return pos_; }

		//-----------------------------------------------------------------//
		/*!
			@brief  空か調べる
			@return 空の場合「true」
		*/
		//-----------------------------------------------------------------//
		bool empty() const noexcept { return pos_ == 0; }

		//-----------------------------------------------------------------//
		/*!
			@brief  文字列をクリア（リセット）
		*/
		//-----------------------------------------------------------------//
		void clear() noexcept {
			pos_ = 0;
			str_[pos_] = 0;
		}

		//-----------------------------------------------------------------//
		/*!
			@brief	末尾の1要素を削除する。
		*/
		//-----------------------------------------------------------------//
		void pop_back() noexcept {
			if(pos_ > 0) {
				--pos_;
				str_[pos_] = 0;
			}
		}

		//-----------------------------------------------------------------//
		/*!
			@brief  配列の先頭
			@return 配列の先頭
		*/
		//-----------------------------------------------------------------//
		const char* begin() const noexcept { return &str_[0]; }

		//-----------------------------------------------------------------//
		/*!
			@brief  配列の先頭
			@return 配列の先頭
		*/
		//-----------------------------------------------------------------//
		char* begin() noexcept { return &str_[0]; }

		//-----------------------------------------------------------------//
		/*!
			@brief  配列の終端
			@return 配列の終端
		*/
		//-----------------------------------------------------------------//
		const char* end() const noexcept { return &str_[pos_]; }

		//-----------------------------------------------------------------//
		/*!
			@brief  配列の終端
			@return 配列の終端
		*/
		//-----------------------------------------------------------------//
		char* end() noexcept { return &str_[pos_]; }

  		//-----------------------------------------------------------------//
		/*!
			@brief  末尾要素への参照を取得する。
			@return 末尾要素への参照
		*/
		//-----------------------------------------------------------------//
		char& back() noexcept {
			auto pos = pos_;
			if(pos > 0) --pos;
			return str_[pos];
		}

  		//-----------------------------------------------------------------//
		/*!
			@brief  末尾要素への参照を取得する。
			@return 末尾要素への参照
		*/
		//-----------------------------------------------------------------//
		const char& back() const noexcept {
			auto pos = pos_;
			if(pos > 0) --pos;
			return str_[pos];
		}

		//-----------------------------------------------------------------//
		/*!
			@brief  文字列を返す
			@return 文字列
		*/
		//-----------------------------------------------------------------//
		const char* c_str() const noexcept { return str_; }

		//-----------------------------------------------------------------//
		/*!
			@brief  交換
			@param[in]	src	ソース
			@return 自分
		*/
		//-----------------------------------------------------------------//
		void swap(fixed_string& src) noexcept {
			std::swap(src.str_, str_);
			std::swap(src.pos_, pos_);
		}

		//-----------------------------------------------------------------//
		/*!
			@brief  代入
			@param[in]	src	ソース
			@return 自分
		*/
		//-----------------------------------------------------------------//
		fixed_string& operator = (const char* src) noexcept {
			utils::str::strncpy_(str_, src, SIZE);
			pos_ = std::strlen(str_);
			return *this;
		}

		//-----------------------------------------------------------------//
		/*!
			@brief  代入
			@param[in]	src	ソース
			@return 自分
		*/
		//-----------------------------------------------------------------//
		fixed_string& operator = (const fixed_string& src) noexcept {
			utils::str::strncpy_(str_, src.c_str(), SIZE);
			pos_ = src.pos_;
			return *this;
		}

		//-----------------------------------------------------------------//
		/*!
			@brief  文字を追加
			@param[in]	ch	文字
			@return 自分
		*/
		//-----------------------------------------------------------------//
		fixed_string& operator += (char ch) noexcept {
			if(pos_ < SIZE) {
				str_[pos_] = ch;
				++pos_;
				str_[pos_] = 0;
			}
			return *this;
		}

		//-----------------------------------------------------------------//
		/*!
			@brief  文字列を追加
			@param[in]	str	文字列
			@return 自分
		*/
		//-----------------------------------------------------------------//
		fixed_string& operator += (const char* str) noexcept {
			if(str == nullptr) {
				return *this;
			}

			uint32_t l = std::strlen(str);
			if((pos_ + l) < SIZE) {
				std::strcpy(&str_[pos_], str);
				pos_ += l;
			} else {  // バッファが許す範囲でコピー
				l = SIZE - pos_;
				utils::str::strncpy_(&str_[pos_], str, l);
				pos_ = SIZE;
			}
			str_[pos_] = 0;
			return *this;
		}

		//-----------------------------------------------------------------//
		/*!
			@brief  文字参照 @n
					※範囲外ではテンポラリを返す（例外を投げない）
			@param[in]	pos	配列位置
			@return 文字
		*/
		//-----------------------------------------------------------------//
		char& operator [] (uint32_t pos) noexcept {
			if(pos >= SIZE) {
				static char tmp = 0;
				return tmp;
			}
			return str_[pos];
		}

		//-----------------------------------------------------------------//
		/*!
			@brief  文字参照 const @n
					※範囲外ではテンポラリを返す（例外を投げない）
			@param[in]	pos	配列位置
			@return 文字
		*/
		//-----------------------------------------------------------------//
		const char& operator [] (uint32_t pos) const noexcept {
			if(pos >= SIZE) {
				static char tmp = 0;
				return tmp;
			}
			return str_[pos];
		}

		//-----------------------------------------------------------------//
		/*!
			@brief  クラス一致比較
			@param[in]	th		文字列クラス
			@return 同じなら「true」
		*/
		//-----------------------------------------------------------------//
		int cmp(const fixed_string& th) const noexcept {
			return std::strcmp(c_str(), th.c_str());
		}

		//-----------------------------------------------------------------//
		/*!
			@brief  クラス一致比較（オペレーター）
			@param[in]	th	文字列クラス
			@return 同じなら「true」
		*/
		//-----------------------------------------------------------------//
		bool operator == (const fixed_string& th) const noexcept {
			return std::strcmp(c_str(), th.c_str()) == 0;
		}

		//-----------------------------------------------------------------//
		/*!
			@brief  クラス、不一致比較（オペレーター）
			@param[in]	th	文字列クラス
			@return 同じなら「true」
		*/
		//-----------------------------------------------------------------//
		bool operator != (const fixed_string& th) const noexcept {
			return std::strcmp(c_str(), th.c_str()) != 0;
		}

		//-----------------------------------------------------------------//
		/*!
			@brief  クラス大小比較（オペレーター）
			@param[in]	th		文字列クラス
			@return 大小なら「true」
		*/
		//-----------------------------------------------------------------//
		bool operator > (const fixed_string& th) const noexcept {
			return std::strcmp(c_str(), th.c_str()) > 0;
		}

		//-----------------------------------------------------------------//
		/*!
			@brief  クラス小大比較（オペレーター）
			@param[in]	th		文字列クラス
			@return 小大なら「true」
		*/
		//-----------------------------------------------------------------//
		bool operator < (const fixed_string& th) const noexcept {
			return std::strcmp(c_str(), th.c_str()) < 0;
		}

		//-----------------------------------------------------------------//
		/*!
			@brief  クラス大小一致比較（オペレーター）
			@param[in]	th		文字列
			@return 大小一致なら「true」
		*/
		//-----------------------------------------------------------------//
		bool operator >= (const fixed_string& th) const noexcept {
			return std::strcmp(c_str(), th.c_str()) >= 0;
		}

		//-----------------------------------------------------------------//
		/*!
			@brief  クラス小大一致比較（オペレーター）
			@param[in]	th		文字列クラス
			@return 小大一致なら「true」
		*/
		//-----------------------------------------------------------------//
		bool operator <= (const fixed_string& th) const noexcept {
			return std::strcmp(c_str(), th.c_str()) <= 0;
		}
	};

	typedef fixed_string<16> STR16;
	typedef fixed_string<32> STR32;
	typedef fixed_string<64> STR64;
	typedef fixed_string<128> STR128;
	typedef fixed_string<256> STR256;
}
<commit_msg>Update: add erase api<commit_after>#pragma once
//=====================================================================//
/*!	@file
	@brief	固定サイズ文字列クラス
    @author 平松邦仁 (hira@rvf-rc45.net)
	@copyright	Copyright (C) 2017, 2020 Kunihito Hiramatsu @n
				Released under the MIT license @n
				https://github.com/hirakuni45/RX/blob/master/LICENSE
*/
//=====================================================================//
#include <algorithm>
#include <cstring>
#include <iterator>
#include "common/string_utils.hpp"

namespace utils {

	//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
	/*!
		@brief  固定サイズ文字列クラス
		@param[in]	SIZE	文字列サイズ
	*/
	//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
	template <uint32_t SIZE>
	class fixed_string {
		uint32_t	pos_;
		char		str_[SIZE + 1];

	public:
		//-----------------------------------------------------------------//
		/*!
			@brief  コンストラクタ
			@param[in]	str	初期設定文字列
		*/
		//-----------------------------------------------------------------//
		fixed_string(const char* str = nullptr) noexcept : pos_(0) {
			if(str != nullptr) {
				utils::str::strncpy_(str_, str, SIZE);
				pos_ = std::strlen(str_);
			}
			str_[pos_] = 0;
			str_[SIZE] = 0;
		}

		//-----------------------------------------------------------------//
		/*!
			@brief  格納可能な最大サイズを返す（終端の数を除外）
			@return 格納可能な最大サイズ
		*/
		//-----------------------------------------------------------------//
		uint32_t capacity() const noexcept { return SIZE; }

		//-----------------------------------------------------------------//
		/*!
			@brief  現在のサイズを返す
			@return 現在のサイズ
		*/
		//-----------------------------------------------------------------//
		uint32_t size() const noexcept { return pos_; }

		//-----------------------------------------------------------------//
		/*!
			@brief  空か調べる
			@return 空の場合「true」
		*/
		//-----------------------------------------------------------------//
		bool empty() const noexcept { return pos_ == 0; }

		//-----------------------------------------------------------------//
		/*!
			@brief  文字列をクリア（リセット）
		*/
		//-----------------------------------------------------------------//
		void clear() noexcept {
			pos_ = 0;
			str_[pos_] = 0;
		}

		//-----------------------------------------------------------------//
		/*!
			@brief	末尾の1要素を削除する。
		*/
		//-----------------------------------------------------------------//
		void pop_back() noexcept {
			if(pos_ > 0) {
				--pos_;
				str_[pos_] = 0;
			}
		}

		//-----------------------------------------------------------------//
		/*!
			@brief	要素を削除する。
			@param[in] org	先頭位置
			@param[in] num	個数
			@return 自分
		*/
		//-----------------------------------------------------------------//
		fixed_string& erase(uint32_t org, uint32_t num) noexcept {
			if(org < pos_ && (org + num) <= pos_) {
				for(auto i = org; i < (org + num); ++i) {
					str_[i] = str_[i + num];
				}
				pos_ -= num;
				str_[pos_] = 0;
			}
			return *this;
		}

		//-----------------------------------------------------------------//
		/*!
			@brief  配列の先頭
			@return 配列の先頭
		*/
		//-----------------------------------------------------------------//
		const char* begin() const noexcept { return &str_[0]; }

		//-----------------------------------------------------------------//
		/*!
			@brief  配列の先頭
			@return 配列の先頭
		*/
		//-----------------------------------------------------------------//
		char* begin() noexcept { return &str_[0]; }

		//-----------------------------------------------------------------//
		/*!
			@brief  配列の終端
			@return 配列の終端
		*/
		//-----------------------------------------------------------------//
		const char* end() const noexcept { return &str_[pos_]; }

		//-----------------------------------------------------------------//
		/*!
			@brief  配列の終端
			@return 配列の終端
		*/
		//-----------------------------------------------------------------//
		char* end() noexcept { return &str_[pos_]; }

  		//-----------------------------------------------------------------//
		/*!
			@brief  末尾要素への参照を取得する。
			@return 末尾要素への参照
		*/
		//-----------------------------------------------------------------//
		char& back() noexcept {
			auto pos = pos_;
			if(pos > 0) --pos;
			return str_[pos];
		}

  		//-----------------------------------------------------------------//
		/*!
			@brief  末尾要素への参照を取得する。
			@return 末尾要素への参照
		*/
		//-----------------------------------------------------------------//
		const char& back() const noexcept {
			auto pos = pos_;
			if(pos > 0) --pos;
			return str_[pos];
		}

		//-----------------------------------------------------------------//
		/*!
			@brief  文字列を返す
			@return 文字列
		*/
		//-----------------------------------------------------------------//
		const char* c_str() const noexcept { return str_; }

		//-----------------------------------------------------------------//
		/*!
			@brief  交換
			@param[in]	src	ソース
			@return 自分
		*/
		//-----------------------------------------------------------------//
		void swap(fixed_string& src) noexcept {
			std::swap(src.str_, str_);
			std::swap(src.pos_, pos_);
		}

		//-----------------------------------------------------------------//
		/*!
			@brief  代入
			@param[in]	src	ソース
			@return 自分
		*/
		//-----------------------------------------------------------------//
		fixed_string& operator = (const char* src) noexcept {
			utils::str::strncpy_(str_, src, SIZE);
			pos_ = std::strlen(str_);
			return *this;
		}

		//-----------------------------------------------------------------//
		/*!
			@brief  代入
			@param[in]	src	ソース
			@return 自分
		*/
		//-----------------------------------------------------------------//
		fixed_string& operator = (const fixed_string& src) noexcept {
			utils::str::strncpy_(str_, src.c_str(), SIZE);
			pos_ = src.pos_;
			return *this;
		}

		//-----------------------------------------------------------------//
		/*!
			@brief  文字を追加
			@param[in]	ch	文字
			@return 自分
		*/
		//-----------------------------------------------------------------//
		fixed_string& operator += (char ch) noexcept {
			if(pos_ < SIZE) {
				str_[pos_] = ch;
				++pos_;
				str_[pos_] = 0;
			}
			return *this;
		}

		//-----------------------------------------------------------------//
		/*!
			@brief  文字列を追加
			@param[in]	str	文字列
			@return 自分
		*/
		//-----------------------------------------------------------------//
		fixed_string& operator += (const char* str) noexcept {
			if(str == nullptr) {
				return *this;
			}

			uint32_t l = std::strlen(str);
			if((pos_ + l) < SIZE) {
				std::strcpy(&str_[pos_], str);
				pos_ += l;
			} else {  // バッファが許す範囲でコピー
				l = SIZE - pos_;
				utils::str::strncpy_(&str_[pos_], str, l);
				pos_ = SIZE;
			}
			str_[pos_] = 0;
			return *this;
		}

		//-----------------------------------------------------------------//
		/*!
			@brief  文字参照 @n
					※範囲外ではテンポラリを返す（例外を投げない）
			@param[in]	pos	配列位置
			@return 文字
		*/
		//-----------------------------------------------------------------//
		char& operator [] (uint32_t pos) noexcept {
			if(pos >= SIZE) {
				static char tmp = 0;
				return tmp;
			}
			return str_[pos];
		}

		//-----------------------------------------------------------------//
		/*!
			@brief  文字参照 const @n
					※範囲外ではテンポラリを返す（例外を投げない）
			@param[in]	pos	配列位置
			@return 文字
		*/
		//-----------------------------------------------------------------//
		const char& operator [] (uint32_t pos) const noexcept {
			if(pos >= SIZE) {
				static char tmp = 0;
				return tmp;
			}
			return str_[pos];
		}

		//-----------------------------------------------------------------//
		/*!
			@brief  クラス一致比較
			@param[in]	th		文字列クラス
			@return 同じなら「true」
		*/
		//-----------------------------------------------------------------//
		int cmp(const fixed_string& th) const noexcept {
			return std::strcmp(c_str(), th.c_str());
		}

		//-----------------------------------------------------------------//
		/*!
			@brief  クラス一致比較（オペレーター）
			@param[in]	th	文字列クラス
			@return 同じなら「true」
		*/
		//-----------------------------------------------------------------//
		bool operator == (const fixed_string& th) const noexcept {
			return std::strcmp(c_str(), th.c_str()) == 0;
		}

		//-----------------------------------------------------------------//
		/*!
			@brief  クラス、不一致比較（オペレーター）
			@param[in]	th	文字列クラス
			@return 同じなら「true」
		*/
		//-----------------------------------------------------------------//
		bool operator != (const fixed_string& th) const noexcept {
			return std::strcmp(c_str(), th.c_str()) != 0;
		}

		//-----------------------------------------------------------------//
		/*!
			@brief  クラス大小比較（オペレーター）
			@param[in]	th		文字列クラス
			@return 大小なら「true」
		*/
		//-----------------------------------------------------------------//
		bool operator > (const fixed_string& th) const noexcept {
			return std::strcmp(c_str(), th.c_str()) > 0;
		}

		//-----------------------------------------------------------------//
		/*!
			@brief  クラス小大比較（オペレーター）
			@param[in]	th		文字列クラス
			@return 小大なら「true」
		*/
		//-----------------------------------------------------------------//
		bool operator < (const fixed_string& th) const noexcept {
			return std::strcmp(c_str(), th.c_str()) < 0;
		}

		//-----------------------------------------------------------------//
		/*!
			@brief  クラス大小一致比較（オペレーター）
			@param[in]	th		文字列
			@return 大小一致なら「true」
		*/
		//-----------------------------------------------------------------//
		bool operator >= (const fixed_string& th) const noexcept {
			return std::strcmp(c_str(), th.c_str()) >= 0;
		}

		//-----------------------------------------------------------------//
		/*!
			@brief  クラス小大一致比較（オペレーター）
			@param[in]	th		文字列クラス
			@return 小大一致なら「true」
		*/
		//-----------------------------------------------------------------//
		bool operator <= (const fixed_string& th) const noexcept {
			return std::strcmp(c_str(), th.c_str()) <= 0;
		}
	};

	typedef fixed_string<16> STR16;
	typedef fixed_string<32> STR32;
	typedef fixed_string<64> STR64;
	typedef fixed_string<128> STR128;
	typedef fixed_string<256> STR256;
}
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: tphf.cxx,v $
 *
 *  $Revision: 1.8 $
 *
 *  last change: $Author: rt $ $Date: 2005-09-08 22:22:14 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    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
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

#undef SC_DLLIMPLEMENTATION

#ifdef PCH
#include "ui_pch.hxx"
#endif

#pragma hdrstop

//------------------------------------------------------------------

#define _TPHF_CXX
#include "scitems.hxx"
#include <sfx2/basedlgs.hxx>
#include <svtools/style.hxx>
#include <vcl/svapp.hxx>
#include <vcl/msgbox.hxx>

#include "tphf.hxx"
#include "sc.hrc"
#include "globstr.hrc"
#include "tabvwsh.hxx"
#include "viewdata.hxx"
#include "document.hxx"
//CHINA001 #include "tphfedit.hxx"
#include "hfedtdlg.hxx"
#include "styledlg.hxx"
#include "scresid.hxx"
#include "scuitphfedit.hxx" //CHINA001
#undef _TPHF_CXX

//==================================================================
// class ScHFPage
//==================================================================

ScHFPage::ScHFPage( Window* pParent, USHORT nResId,
                    const SfxItemSet& rSet, USHORT nSetId )

    :   SvxHFPage   ( pParent, nResId, rSet, nSetId ),
        aBtnEdit    ( this, ScResId( RID_SCBTN_HFEDIT ) ),
        aDataSet    ( *rSet.GetPool(),
                       ATTR_PAGE_HEADERLEFT, ATTR_PAGE_FOOTERRIGHT,
                       ATTR_PAGE, ATTR_PAGE, 0 ),
        nPageUsage  ( (USHORT)SVX_PAGE_ALL ),
        pStyleDlg   ( NULL )
{
    SetExchangeSupport();

    SfxViewShell*   pSh = SfxViewShell::Current();
    ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell,pSh);
    Point           aPos( aBackgroundBtn.GetPosPixel() );

    // aBackgroundBtn position not changed anymore

    aPos.X() += aBackgroundBtn.GetSizePixel().Width();
    aPos.X() += LogicToPixel( Size(3,0), MAP_APPFONT ).Width();
    aBtnEdit.SetPosPixel( aPos );
    aBtnEdit.Show();

    aDataSet.Put( rSet );

    if ( pViewSh )
    {
        ScViewData* pViewData = pViewSh->GetViewData();
        ScDocument* pDoc      = pViewData->GetDocument();

        aStrPageStyle = pDoc->GetPageStyle( pViewData->GetTabNo() );
    }

    aBtnEdit.SetClickHdl    ( LINK( this, ScHFPage, BtnHdl ) );
    aTurnOnBox.SetClickHdl  ( LINK( this, ScHFPage, TurnOnHdl ) );

    if ( nId == SID_ATTR_PAGE_HEADERSET )
        aBtnEdit.SetHelpId( HID_SC_HEADER_EDIT );
    else
        aBtnEdit.SetHelpId( HID_SC_FOOTER_EDIT );
}

//------------------------------------------------------------------

__EXPORT ScHFPage::~ScHFPage()
{
}

//------------------------------------------------------------------

void __EXPORT ScHFPage::Reset( const SfxItemSet& rSet )
{
    SvxHFPage::Reset( rSet );
    TurnOnHdl( 0 );
}

//------------------------------------------------------------------

BOOL __EXPORT ScHFPage::FillItemSet( SfxItemSet& rOutSet )
{
    BOOL bResult = SvxHFPage::FillItemSet( rOutSet );

    if ( nId == SID_ATTR_PAGE_HEADERSET )
    {
        rOutSet.Put( aDataSet.Get( ATTR_PAGE_HEADERLEFT ) );
        rOutSet.Put( aDataSet.Get( ATTR_PAGE_HEADERRIGHT ) );
    }
    else
    {
        rOutSet.Put( aDataSet.Get( ATTR_PAGE_FOOTERLEFT ) );
        rOutSet.Put( aDataSet.Get( ATTR_PAGE_FOOTERRIGHT ) );
    }

    return bResult;
}

//------------------------------------------------------------------

void __EXPORT ScHFPage::ActivatePage( const SfxItemSet& rSet )
{
    USHORT              nPageWhich = GetWhich( SID_ATTR_PAGE );
    const SvxPageItem&  rPageItem  = (const SvxPageItem&)
                                     rSet.Get(nPageWhich);

    nPageUsage = rPageItem.GetPageUsage();

    if ( pStyleDlg )
        aStrPageStyle = pStyleDlg->GetStyleSheet().GetName();

    aDataSet.Put( rSet.Get(ATTR_PAGE) );

    SvxHFPage::ActivatePage( rSet );
}

//------------------------------------------------------------------

int __EXPORT ScHFPage::DeactivatePage( SfxItemSet* pSet )
{
    if ( LEAVE_PAGE == SvxHFPage::DeactivatePage( pSet ) )
        if ( pSet )
            FillItemSet( *pSet );

    return LEAVE_PAGE;
}

//------------------------------------------------------------------
// Handler:
//------------------------------------------------------------------

IMPL_LINK( ScHFPage, TurnOnHdl, CheckBox*, EMPTYARG )
{
    SvxHFPage::TurnOnHdl( &aTurnOnBox );

    if ( aTurnOnBox.IsChecked() )
        aBtnEdit.Enable();
    else
        aBtnEdit.Disable();

    return 0;
}

//------------------------------------------------------------------

IMPL_LINK( ScHFPage, BtnHdl, PushButton*, EMPTYARG )
{
    //  Wenn der Bearbeiten-Dialog direkt aus dem Click-Handler des Buttons
    //  aufgerufen wird, funktioniert im Bearbeiten-Dialog unter OS/2 das
    //  GrabFocus nicht (Bug #41805#).
    //  Mit dem neuen StarView sollte dieser Workaround wieder raus koennen!

    Application::PostUserEvent( LINK( this, ScHFPage, HFEditHdl ) );
    return 0;
}

IMPL_LINK( ScHFPage, HFEditHdl, void*, EMPTYARG )
{
    SfxViewShell*   pViewSh = SfxViewShell::Current();

    if ( !pViewSh )
    {
        DBG_ERROR( "Current ViewShell not found." );
        return 0;
    }

    if (   aCntSharedBox.IsEnabled()
        && !aCntSharedBox.IsChecked() )
    {
        USHORT nResId = ( nId == SID_ATTR_PAGE_HEADERSET )
                            ? RID_SCDLG_HFED_HEADER
                            : RID_SCDLG_HFED_FOOTER;

        ScHFEditDlg* pDlg
             = new ScHFEditDlg( pViewSh->GetViewFrame(), this,
                                aDataSet, aStrPageStyle, nResId );

        if ( pDlg->Execute() == RET_OK )
        {
            aDataSet.Put( *pDlg->GetOutputItemSet() );
        }

        delete pDlg;
    }
    else
    {
        String              aText;
        SfxSingleTabDialog* pDlg
            = new SfxSingleTabDialog( pViewSh->GetViewFrame(), this,
                                      aDataSet, 42 );
        BOOL bRightPage =   aCntSharedBox.IsChecked()
                         || ( SVX_PAGE_LEFT != SvxPageUsage(nPageUsage) );

        if ( nId == SID_ATTR_PAGE_HEADERSET )
        {
            aText = ScGlobal::GetRscString( STR_PAGEHEADER );
            if ( bRightPage )
                pDlg->SetTabPage( ScRightHeaderEditPage::Create( pDlg, aDataSet ) );
            else
                pDlg->SetTabPage( ScLeftHeaderEditPage::Create( pDlg, aDataSet ) );
        }
        else
        {
            aText = ScGlobal::GetRscString( STR_PAGEFOOTER );
            if ( bRightPage )
                pDlg->SetTabPage( ScRightFooterEditPage::Create( pDlg, aDataSet ) );
            else
                pDlg->SetTabPage( ScLeftFooterEditPage::Create( pDlg, aDataSet ) );
        }

        SvxNumType eNumType = ((const SvxPageItem&)aDataSet.Get(ATTR_PAGE)).GetNumType();
        ((ScHFEditPage*)pDlg->GetTabPage())->SetNumType(eNumType);

        aText.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
        aText += ScGlobal::GetRscString( STR_PAGESTYLE );
        aText.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ": " ));
        aText += aStrPageStyle;
        aText += ')';

        pDlg->SetText( aText );

        if ( pDlg->Execute() == RET_OK )
        {
            aDataSet.Put( *pDlg->GetOutputItemSet() );
        }

        delete pDlg;
    }

    return 0;
}

//==================================================================
// class ScHeaderPage
//==================================================================

ScHeaderPage::ScHeaderPage( Window* pParent, const SfxItemSet& rSet )
    : ScHFPage( pParent, RID_SVXPAGE_HEADER, rSet, SID_ATTR_PAGE_HEADERSET )
{
}

//------------------------------------------------------------------

SfxTabPage* __EXPORT ScHeaderPage::Create( Window* pParent, const SfxItemSet& rCoreSet )
{
    return ( new ScHeaderPage( pParent, rCoreSet ) );
}

//------------------------------------------------------------------

USHORT* __EXPORT ScHeaderPage::GetRanges()
{
    return SvxHeaderPage::GetRanges();
}

//==================================================================
// class ScFooterPage
//==================================================================

ScFooterPage::ScFooterPage( Window* pParent, const SfxItemSet& rSet )
    : ScHFPage( pParent, RID_SVXPAGE_FOOTER, rSet, SID_ATTR_PAGE_FOOTERSET )
{
}

//------------------------------------------------------------------

SfxTabPage* __EXPORT ScFooterPage::Create( Window* pParent, const SfxItemSet& rCoreSet )
{
    return ( new ScFooterPage( pParent, rCoreSet ) );
}

//------------------------------------------------------------------

USHORT* __EXPORT ScFooterPage::GetRanges()
{
    return SvxHeaderPage::GetRanges();
}

<commit_msg>INTEGRATION: CWS pchfix01 (1.8.214); FILE MERGED 2006/07/12 10:02:50 kaib 1.8.214.1: #i67080# Converted cxx files in sc, added initial project level pch and stripped old PCH definitions.<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: tphf.cxx,v $
 *
 *  $Revision: 1.9 $
 *
 *  last change: $Author: kz $ $Date: 2006-07-21 14:21:08 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    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
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sc.hxx"

#undef SC_DLLIMPLEMENTATION

//------------------------------------------------------------------

#define _TPHF_CXX
#include "scitems.hxx"
#include <sfx2/basedlgs.hxx>
#include <svtools/style.hxx>
#include <vcl/svapp.hxx>
#include <vcl/msgbox.hxx>

#include "tphf.hxx"
#include "sc.hrc"
#include "globstr.hrc"
#include "tabvwsh.hxx"
#include "viewdata.hxx"
#include "document.hxx"
//CHINA001 #include "tphfedit.hxx"
#include "hfedtdlg.hxx"
#include "styledlg.hxx"
#include "scresid.hxx"
#include "scuitphfedit.hxx" //CHINA001
#undef _TPHF_CXX

//==================================================================
// class ScHFPage
//==================================================================

ScHFPage::ScHFPage( Window* pParent, USHORT nResId,
                    const SfxItemSet& rSet, USHORT nSetId )

    :   SvxHFPage   ( pParent, nResId, rSet, nSetId ),
        aBtnEdit    ( this, ScResId( RID_SCBTN_HFEDIT ) ),
        aDataSet    ( *rSet.GetPool(),
                       ATTR_PAGE_HEADERLEFT, ATTR_PAGE_FOOTERRIGHT,
                       ATTR_PAGE, ATTR_PAGE, 0 ),
        nPageUsage  ( (USHORT)SVX_PAGE_ALL ),
        pStyleDlg   ( NULL )
{
    SetExchangeSupport();

    SfxViewShell*   pSh = SfxViewShell::Current();
    ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell,pSh);
    Point           aPos( aBackgroundBtn.GetPosPixel() );

    // aBackgroundBtn position not changed anymore

    aPos.X() += aBackgroundBtn.GetSizePixel().Width();
    aPos.X() += LogicToPixel( Size(3,0), MAP_APPFONT ).Width();
    aBtnEdit.SetPosPixel( aPos );
    aBtnEdit.Show();

    aDataSet.Put( rSet );

    if ( pViewSh )
    {
        ScViewData* pViewData = pViewSh->GetViewData();
        ScDocument* pDoc      = pViewData->GetDocument();

        aStrPageStyle = pDoc->GetPageStyle( pViewData->GetTabNo() );
    }

    aBtnEdit.SetClickHdl    ( LINK( this, ScHFPage, BtnHdl ) );
    aTurnOnBox.SetClickHdl  ( LINK( this, ScHFPage, TurnOnHdl ) );

    if ( nId == SID_ATTR_PAGE_HEADERSET )
        aBtnEdit.SetHelpId( HID_SC_HEADER_EDIT );
    else
        aBtnEdit.SetHelpId( HID_SC_FOOTER_EDIT );
}

//------------------------------------------------------------------

__EXPORT ScHFPage::~ScHFPage()
{
}

//------------------------------------------------------------------

void __EXPORT ScHFPage::Reset( const SfxItemSet& rSet )
{
    SvxHFPage::Reset( rSet );
    TurnOnHdl( 0 );
}

//------------------------------------------------------------------

BOOL __EXPORT ScHFPage::FillItemSet( SfxItemSet& rOutSet )
{
    BOOL bResult = SvxHFPage::FillItemSet( rOutSet );

    if ( nId == SID_ATTR_PAGE_HEADERSET )
    {
        rOutSet.Put( aDataSet.Get( ATTR_PAGE_HEADERLEFT ) );
        rOutSet.Put( aDataSet.Get( ATTR_PAGE_HEADERRIGHT ) );
    }
    else
    {
        rOutSet.Put( aDataSet.Get( ATTR_PAGE_FOOTERLEFT ) );
        rOutSet.Put( aDataSet.Get( ATTR_PAGE_FOOTERRIGHT ) );
    }

    return bResult;
}

//------------------------------------------------------------------

void __EXPORT ScHFPage::ActivatePage( const SfxItemSet& rSet )
{
    USHORT              nPageWhich = GetWhich( SID_ATTR_PAGE );
    const SvxPageItem&  rPageItem  = (const SvxPageItem&)
                                     rSet.Get(nPageWhich);

    nPageUsage = rPageItem.GetPageUsage();

    if ( pStyleDlg )
        aStrPageStyle = pStyleDlg->GetStyleSheet().GetName();

    aDataSet.Put( rSet.Get(ATTR_PAGE) );

    SvxHFPage::ActivatePage( rSet );
}

//------------------------------------------------------------------

int __EXPORT ScHFPage::DeactivatePage( SfxItemSet* pSet )
{
    if ( LEAVE_PAGE == SvxHFPage::DeactivatePage( pSet ) )
        if ( pSet )
            FillItemSet( *pSet );

    return LEAVE_PAGE;
}

//------------------------------------------------------------------
// Handler:
//------------------------------------------------------------------

IMPL_LINK( ScHFPage, TurnOnHdl, CheckBox*, EMPTYARG )
{
    SvxHFPage::TurnOnHdl( &aTurnOnBox );

    if ( aTurnOnBox.IsChecked() )
        aBtnEdit.Enable();
    else
        aBtnEdit.Disable();

    return 0;
}

//------------------------------------------------------------------

IMPL_LINK( ScHFPage, BtnHdl, PushButton*, EMPTYARG )
{
    //  Wenn der Bearbeiten-Dialog direkt aus dem Click-Handler des Buttons
    //  aufgerufen wird, funktioniert im Bearbeiten-Dialog unter OS/2 das
    //  GrabFocus nicht (Bug #41805#).
    //  Mit dem neuen StarView sollte dieser Workaround wieder raus koennen!

    Application::PostUserEvent( LINK( this, ScHFPage, HFEditHdl ) );
    return 0;
}

IMPL_LINK( ScHFPage, HFEditHdl, void*, EMPTYARG )
{
    SfxViewShell*   pViewSh = SfxViewShell::Current();

    if ( !pViewSh )
    {
        DBG_ERROR( "Current ViewShell not found." );
        return 0;
    }

    if (   aCntSharedBox.IsEnabled()
        && !aCntSharedBox.IsChecked() )
    {
        USHORT nResId = ( nId == SID_ATTR_PAGE_HEADERSET )
                            ? RID_SCDLG_HFED_HEADER
                            : RID_SCDLG_HFED_FOOTER;

        ScHFEditDlg* pDlg
             = new ScHFEditDlg( pViewSh->GetViewFrame(), this,
                                aDataSet, aStrPageStyle, nResId );

        if ( pDlg->Execute() == RET_OK )
        {
            aDataSet.Put( *pDlg->GetOutputItemSet() );
        }

        delete pDlg;
    }
    else
    {
        String              aText;
        SfxSingleTabDialog* pDlg
            = new SfxSingleTabDialog( pViewSh->GetViewFrame(), this,
                                      aDataSet, 42 );
        BOOL bRightPage =   aCntSharedBox.IsChecked()
                         || ( SVX_PAGE_LEFT != SvxPageUsage(nPageUsage) );

        if ( nId == SID_ATTR_PAGE_HEADERSET )
        {
            aText = ScGlobal::GetRscString( STR_PAGEHEADER );
            if ( bRightPage )
                pDlg->SetTabPage( ScRightHeaderEditPage::Create( pDlg, aDataSet ) );
            else
                pDlg->SetTabPage( ScLeftHeaderEditPage::Create( pDlg, aDataSet ) );
        }
        else
        {
            aText = ScGlobal::GetRscString( STR_PAGEFOOTER );
            if ( bRightPage )
                pDlg->SetTabPage( ScRightFooterEditPage::Create( pDlg, aDataSet ) );
            else
                pDlg->SetTabPage( ScLeftFooterEditPage::Create( pDlg, aDataSet ) );
        }

        SvxNumType eNumType = ((const SvxPageItem&)aDataSet.Get(ATTR_PAGE)).GetNumType();
        ((ScHFEditPage*)pDlg->GetTabPage())->SetNumType(eNumType);

        aText.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
        aText += ScGlobal::GetRscString( STR_PAGESTYLE );
        aText.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ": " ));
        aText += aStrPageStyle;
        aText += ')';

        pDlg->SetText( aText );

        if ( pDlg->Execute() == RET_OK )
        {
            aDataSet.Put( *pDlg->GetOutputItemSet() );
        }

        delete pDlg;
    }

    return 0;
}

//==================================================================
// class ScHeaderPage
//==================================================================

ScHeaderPage::ScHeaderPage( Window* pParent, const SfxItemSet& rSet )
    : ScHFPage( pParent, RID_SVXPAGE_HEADER, rSet, SID_ATTR_PAGE_HEADERSET )
{
}

//------------------------------------------------------------------

SfxTabPage* __EXPORT ScHeaderPage::Create( Window* pParent, const SfxItemSet& rCoreSet )
{
    return ( new ScHeaderPage( pParent, rCoreSet ) );
}

//------------------------------------------------------------------

USHORT* __EXPORT ScHeaderPage::GetRanges()
{
    return SvxHeaderPage::GetRanges();
}

//==================================================================
// class ScFooterPage
//==================================================================

ScFooterPage::ScFooterPage( Window* pParent, const SfxItemSet& rSet )
    : ScHFPage( pParent, RID_SVXPAGE_FOOTER, rSet, SID_ATTR_PAGE_FOOTERSET )
{
}

//------------------------------------------------------------------

SfxTabPage* __EXPORT ScFooterPage::Create( Window* pParent, const SfxItemSet& rCoreSet )
{
    return ( new ScFooterPage( pParent, rCoreSet ) );
}

//------------------------------------------------------------------

USHORT* __EXPORT ScFooterPage::GetRanges()
{
    return SvxHeaderPage::GetRanges();
}

<|endoftext|>


<commit_before>// Copyright (c) 2013 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "common/node_bindings.h"

#include "base/command_line.h"
#include "base/logging.h"
#include "base/message_loop.h"
#include "common/v8_conversions.h"
#include "content/public/browser/browser_thread.h"
#include "net/base/escape.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
#include "vendor/node/src/node.h"
#include "vendor/node/src/node_internals.h"
#include "vendor/node/src/node_javascript.h"

#if defined(OS_WIN)
#include "base/strings/utf_string_conversions.h"
#endif

using content::BrowserThread;

namespace atom {

namespace {

void UvNoOp(uv_async_t* handle, int status) {
}

}  // namespace

NodeBindings::NodeBindings(bool is_browser)
    : is_browser_(is_browser),
      message_loop_(NULL),
      uv_loop_(uv_default_loop()),
      embed_closed_(false) {
}

NodeBindings::~NodeBindings() {
  // Clear uv.
  embed_closed_ = true;
  WakeupEmbedThread();
  uv_thread_join(&embed_thread_);
  uv_sem_destroy(&embed_sem_);
  uv_timer_stop(&idle_timer_);
}

void NodeBindings::Initialize() {
  CommandLine::StringVector str_argv = CommandLine::ForCurrentProcess()->argv();

#if defined(OS_WIN)
  std::vector<std::string> utf8_str_argv;
  utf8_str_argv.reserve(str_argv.size());
#endif

  // Convert string vector to char* array.
  std::vector<char*> argv(str_argv.size(), NULL);
  for (size_t i = 0; i < str_argv.size(); ++i) {
#if defined(OS_WIN)
    utf8_str_argv.push_back(UTF16ToUTF8(str_argv[i]));
    argv[i] = const_cast<char*>(utf8_str_argv[i].c_str());
#else
    argv[i] = const_cast<char*>(str_argv[i].c_str());
#endif
  }

  // Init idle GC.
  uv_timer_init(uv_default_loop(), &idle_timer_);
  uv_timer_start(&idle_timer_, IdleCallback, 5000, 5000);

  // Open node's error reporting system for browser process.
  node::g_standalone_mode = is_browser_;
  node::g_upstream_node_mode = false;

  // Init node.
  node::Init(argv.size(), &argv[0]);
  v8::V8::Initialize();

  // Load node.js.
  v8::HandleScope scope;
  node::g_context = v8::Persistent<v8::Context>::New(
      node::node_isolate, v8::Context::New(node::node_isolate));
  {
    v8::Context::Scope context_scope(node::g_context);
    v8::Handle<v8::Object> process = node::SetupProcessObject(
        argv.size(), &argv[0]);

    // Tell node.js we are in browser or renderer.
    v8::Handle<v8::String> type =
        is_browser_ ? v8::String::New("browser") : v8::String::New("renderer");
    process->Set(v8::String::New("__atom_type"), type);
  }
}

void NodeBindings::Load() {
  v8::HandleScope scope;
  v8::Context::Scope context_scope(node::g_context);
  node::Load(node::process);
}

void NodeBindings::BindTo(WebKit::WebFrame* frame) {
  v8::HandleScope handle_scope;

  v8::Handle<v8::Context> context = frame->mainWorldScriptContext();
  if (context.IsEmpty())
    return;

  v8::Context::Scope scope(context);

  // Erase security token.
  context->SetSecurityToken(node::g_context->GetSecurityToken());

  // Evaluate cefode.js.
  v8::Handle<v8::Script> script = node::CompileCefodeMainSource();
  v8::Local<v8::Value> result = script->Run();

  // Run the script of cefode.js.
  std::string script_path(GURL(frame->document().url()).path());
  script_path = net::UnescapeURLComponent(
      script_path,
      net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS);
  v8::Handle<v8::Value> args[2] = {
    v8::Local<v8::Value>::New(node::process),
    ToV8Value(script_path),
  };
  v8::Local<v8::Function>::Cast(result)->Call(context->Global(), 2, args);
}

void NodeBindings::PrepareMessageLoop() {
  DCHECK(!is_browser_ || BrowserThread::CurrentlyOn(BrowserThread::UI));

  // Add dummy handle for libuv, otherwise libuv would quit when there is
  // nothing to do.
  uv_async_init(uv_loop_, &dummy_uv_handle_, UvNoOp);

  // Start worker that will interrupt main loop when having uv events.
  uv_sem_init(&embed_sem_, 0);
  uv_thread_create(&embed_thread_, EmbedThreadRunner, this);
}

void NodeBindings::RunMessageLoop() {
  DCHECK(!is_browser_ || BrowserThread::CurrentlyOn(BrowserThread::UI));

  // The MessageLoop should have been created, remember the one in main thread.
  message_loop_ = base::MessageLoop::current();

  // Run uv loop for once to give the uv__io_poll a chance to add all events.
  UvRunOnce();
}

void NodeBindings::UvRunOnce() {
  DCHECK(!is_browser_ || BrowserThread::CurrentlyOn(BrowserThread::UI));

  // Enter node context while dealing with uv events.
  v8::HandleScope scope;
  v8::Context::Scope context_scope(node::g_context);

  // Deal with uv events.
  int r = uv_run(uv_loop_, (uv_run_mode)(UV_RUN_ONCE | UV_RUN_NOWAIT));
  if (r == 0 || uv_loop_->stop_flag != 0)
    message_loop_->QuitWhenIdle();  // Quit from uv.

  // Tell the worker thread to continue polling.
  uv_sem_post(&embed_sem_);
}

void NodeBindings::WakeupMainThread() {
  DCHECK(message_loop_);
  message_loop_->PostTask(FROM_HERE, base::Bind(&NodeBindings::UvRunOnce,
                                                base::Unretained(this)));
}

void NodeBindings::WakeupEmbedThread() {
  uv_async_send(&dummy_uv_handle_);
}

// static
void NodeBindings::EmbedThreadRunner(void *arg) {
  NodeBindings* self = static_cast<NodeBindings*>(arg);

  while (!self->embed_closed_) {
    // Wait for the main loop to deal with events.
    uv_sem_wait(&self->embed_sem_);

    self->PollEvents();

    // Deal with event in main thread.
    self->WakeupMainThread();
  }
}

// static
void NodeBindings::IdleCallback(uv_timer_t*, int) {
  v8::V8::IdleNotification();
}

}  // namespace atom
<commit_msg>Fix a possible dead lock when quiting.<commit_after>// Copyright (c) 2013 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "common/node_bindings.h"

#include "base/command_line.h"
#include "base/logging.h"
#include "base/message_loop.h"
#include "common/v8_conversions.h"
#include "content/public/browser/browser_thread.h"
#include "net/base/escape.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
#include "vendor/node/src/node.h"
#include "vendor/node/src/node_internals.h"
#include "vendor/node/src/node_javascript.h"

#if defined(OS_WIN)
#include "base/strings/utf_string_conversions.h"
#endif

using content::BrowserThread;

namespace atom {

namespace {

void UvNoOp(uv_async_t* handle, int status) {
}

}  // namespace

NodeBindings::NodeBindings(bool is_browser)
    : is_browser_(is_browser),
      message_loop_(NULL),
      uv_loop_(uv_default_loop()),
      embed_closed_(false) {
}

NodeBindings::~NodeBindings() {
  // Quit the embed thread.
  embed_closed_ = true;
  uv_sem_post(&embed_sem_);
  WakeupEmbedThread();

  // Wait for everything to be done.
  uv_thread_join(&embed_thread_);
  message_loop_->RunUntilIdle();

  // Clear uv.
  uv_sem_destroy(&embed_sem_);
  uv_timer_stop(&idle_timer_);
}

void NodeBindings::Initialize() {
  CommandLine::StringVector str_argv = CommandLine::ForCurrentProcess()->argv();

#if defined(OS_WIN)
  std::vector<std::string> utf8_str_argv;
  utf8_str_argv.reserve(str_argv.size());
#endif

  // Convert string vector to char* array.
  std::vector<char*> argv(str_argv.size(), NULL);
  for (size_t i = 0; i < str_argv.size(); ++i) {
#if defined(OS_WIN)
    utf8_str_argv.push_back(UTF16ToUTF8(str_argv[i]));
    argv[i] = const_cast<char*>(utf8_str_argv[i].c_str());
#else
    argv[i] = const_cast<char*>(str_argv[i].c_str());
#endif
  }

  // Init idle GC.
  uv_timer_init(uv_default_loop(), &idle_timer_);
  uv_timer_start(&idle_timer_, IdleCallback, 5000, 5000);

  // Open node's error reporting system for browser process.
  node::g_standalone_mode = is_browser_;
  node::g_upstream_node_mode = false;

  // Init node.
  node::Init(argv.size(), &argv[0]);
  v8::V8::Initialize();

  // Load node.js.
  v8::HandleScope scope;
  node::g_context = v8::Persistent<v8::Context>::New(
      node::node_isolate, v8::Context::New(node::node_isolate));
  {
    v8::Context::Scope context_scope(node::g_context);
    v8::Handle<v8::Object> process = node::SetupProcessObject(
        argv.size(), &argv[0]);

    // Tell node.js we are in browser or renderer.
    v8::Handle<v8::String> type =
        is_browser_ ? v8::String::New("browser") : v8::String::New("renderer");
    process->Set(v8::String::New("__atom_type"), type);
  }
}

void NodeBindings::Load() {
  v8::HandleScope scope;
  v8::Context::Scope context_scope(node::g_context);
  node::Load(node::process);
}

void NodeBindings::BindTo(WebKit::WebFrame* frame) {
  v8::HandleScope handle_scope;

  v8::Handle<v8::Context> context = frame->mainWorldScriptContext();
  if (context.IsEmpty())
    return;

  v8::Context::Scope scope(context);

  // Erase security token.
  context->SetSecurityToken(node::g_context->GetSecurityToken());

  // Evaluate cefode.js.
  v8::Handle<v8::Script> script = node::CompileCefodeMainSource();
  v8::Local<v8::Value> result = script->Run();

  // Run the script of cefode.js.
  std::string script_path(GURL(frame->document().url()).path());
  script_path = net::UnescapeURLComponent(
      script_path,
      net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS);
  v8::Handle<v8::Value> args[2] = {
    v8::Local<v8::Value>::New(node::process),
    ToV8Value(script_path),
  };
  v8::Local<v8::Function>::Cast(result)->Call(context->Global(), 2, args);
}

void NodeBindings::PrepareMessageLoop() {
  DCHECK(!is_browser_ || BrowserThread::CurrentlyOn(BrowserThread::UI));

  // Add dummy handle for libuv, otherwise libuv would quit when there is
  // nothing to do.
  uv_async_init(uv_loop_, &dummy_uv_handle_, UvNoOp);

  // Start worker that will interrupt main loop when having uv events.
  uv_sem_init(&embed_sem_, 0);
  uv_thread_create(&embed_thread_, EmbedThreadRunner, this);
}

void NodeBindings::RunMessageLoop() {
  DCHECK(!is_browser_ || BrowserThread::CurrentlyOn(BrowserThread::UI));

  // The MessageLoop should have been created, remember the one in main thread.
  message_loop_ = base::MessageLoop::current();

  // Run uv loop for once to give the uv__io_poll a chance to add all events.
  UvRunOnce();
}

void NodeBindings::UvRunOnce() {
  DCHECK(!is_browser_ || BrowserThread::CurrentlyOn(BrowserThread::UI));

  // Enter node context while dealing with uv events.
  v8::HandleScope scope;
  v8::Context::Scope context_scope(node::g_context);

  // Deal with uv events.
  int r = uv_run(uv_loop_, (uv_run_mode)(UV_RUN_ONCE | UV_RUN_NOWAIT));
  if (r == 0 || uv_loop_->stop_flag != 0)
    message_loop_->QuitWhenIdle();  // Quit from uv.

  // Tell the worker thread to continue polling.
  uv_sem_post(&embed_sem_);
}

void NodeBindings::WakeupMainThread() {
  DCHECK(message_loop_);
  message_loop_->PostTask(FROM_HERE, base::Bind(&NodeBindings::UvRunOnce,
                                                base::Unretained(this)));
}

void NodeBindings::WakeupEmbedThread() {
  uv_async_send(&dummy_uv_handle_);
}

// static
void NodeBindings::EmbedThreadRunner(void *arg) {
  NodeBindings* self = static_cast<NodeBindings*>(arg);

  while (!self->embed_closed_) {
    // Wait for the main loop to deal with events.
    uv_sem_wait(&self->embed_sem_);

    self->PollEvents();

    // Deal with event in main thread.
    self->WakeupMainThread();
  }
}

// static
void NodeBindings::IdleCallback(uv_timer_t*, int) {
  v8::V8::IdleNotification();
}

}  // namespace atom
<|endoftext|>


<commit_before><commit_msg>one more fix for fdo#58686<commit_after><|endoftext|>


<commit_before><commit_msg>Fix PetscODESolver callbacks in the matrix free case<commit_after><|endoftext|>