<commit_before>#include "../../include/cl/cl.h"

#include <algorithm>
#include <map>

using namespace std;

namespace ev3cv {
namespace cl {

list<base_arg *> &args() {
  static list<base_arg *> the_args;
  return the_args;
}

base_arg *next_positional_arg() {
  list<base_arg *>::iterator i = find_if(args().begin(), args().end(), [=] (base_arg *i) {
    return i->has_flag(positional) && (i->has_flag(multi) || !i->parsed());
  });
  return i != args().end() ? *i : nullptr;
}

base_arg *find_arg(const char *name) {
  list<base_arg *>::iterator i = find_if(args().begin(), args().end(), [=] (base_arg *i) {
    return !i->has_flag(positional) && i->name() == name;
  });
  return i != args().end() ? *i : nullptr;
}

base_arg *find_arg(char flag) {
  list<base_arg *>::iterator i = find_if(args().begin(), args().end(), [=] (base_arg *i) {
    return !i->has_flag(positional) && i->flag() == flag;
  });
  return i != args().end() ? *i : nullptr;
}

boolean help(
  flag('?'),
  name("help"),
  desc("Show command line options"),
  flags(hidden));

void base_arg::register_arg(base_arg *a) {
  args().push_back(a);
}

void base_arg::unregister_arg(base_arg *a) {
  args().remove(a);
}

void usage(const char *arg0, ostream &os) {
  os << "Usage: " << endl;
  os << "  " << arg0;
  for (auto i : args()) {
    if (i->has_flag(positional)) {
      os << ' ' << i->name();
    }
  }
  os << endl << endl;

  os << "Optional arguments:" << endl;
  map<string, vector<base_arg *>> groups;
  for (auto i : args()) {
    if (!i->has_flag(hidden) && !i->has_flag(positional))
      groups[i->group()].push_back(i);
  }

  for (const auto &i : groups) {
    if (!i.first.empty())
      os << i.first << ":" << endl;
    for (auto j : i.second) {
      os << "  ";
      j->print(os);
    }
    os << endl;
  }
}

void usage(const char *arg0) {
  usage(arg0, cout);
}

void parse(list<const char *> argv) {
  while (!argv.empty()) {
    const char *argi = argv.front();

    base_arg *ai = NULL;
    if (*argi++ == '-') {
      // This is a named argument?
      if (*argi == '-')
        ai = find_arg(argi + 1);
      else
        ai = find_arg(*argi);

      // If we found the argument by name, remove it from the list.
      if (ai)
        argv.pop_front();
      else if (*argi != '-')
        ai = next_positional_arg();
    } else {
      // This is a positional argument.
      ai = next_positional_arg();
    }
    if (ai != NULL) {
      ai->parse(argv);
      ai->set_parsed();
    } else {
      cerr << "Warning: Unused command line option '" << argv.front() << "'." << endl;
      argv.pop_front();
    }
  }
}

void parse(int argc, const char **argv) {
  list<const char *> args;
  for (int i = 0; i < argc; i++) {
    args.emplace_back(argv[i]);
  }
  parse(args);
}

void parse(const char *arg0, int argc, const char **argv) {
  parse(argc, argv);

  // If the help flag was set, show usage and exit.
  if (help) {
    usage(arg0);
    exit(1);
  }
}

void parse(const string &arg) {
  list<const char *> args = { arg.c_str() };
  parse(args);
}

void parse(istream &is, char delim) {
  while (is) {
    string line;
    getline(is, line, delim);

    string::size_type space = line.find(' ');
    if (space != string::npos) {
      line[space] = '\0';
      const char *args[] = {
        &line[0],
        &line[space + 1]
      };
      parse(2, args);
    }
  }
}

}  // namespace cl
}  // namespace ev3cv

<commit_msg>Added check for duplicate command line arguments<commit_after>#include "../../include/cl/cl.h"

#include <algorithm>
#include <map>

using namespace std;

namespace ev3cv {
namespace cl {

list<base_arg *> &args() {
  static list<base_arg *> the_args;
  return the_args;
}

base_arg *next_positional_arg() {
  list<base_arg *>::iterator i = find_if(args().begin(), args().end(), [=] (base_arg *i) {
    return i->has_flag(positional) && (i->has_flag(multi) || !i->parsed());
  });
  return i != args().end() ? *i : nullptr;
}

base_arg *find_arg(const char *name) {
  list<base_arg *>::iterator i = find_if(args().begin(), args().end(), [=] (base_arg *i) {
    return !i->has_flag(positional) && i->name() == name;
  });
  return i != args().end() ? *i : nullptr;
}

base_arg *find_arg(char flag) {
  list<base_arg *>::iterator i = find_if(args().begin(), args().end(), [=] (base_arg *i) {
    return !i->has_flag(positional) && i->flag() == flag;
  });
  return i != args().end() ? *i : nullptr;
}

boolean help(
  flag('?'),
  name("help"),
  desc("Show command line options"),
  flags(hidden));

void base_arg::register_arg(base_arg *a) {
  if (!a->name().empty() && find_arg(a->name().c_str()))
    throw runtime_error("redefinition of cl::arg '" + a->name() + "'");
  if (a->flag() != 0 && find_arg(a->flag()))
    throw runtime_error("redefinition of cl::arg '" + string(1, a->flag()) + "'");
  args().push_back(a);
}

void base_arg::unregister_arg(base_arg *a) {
  args().remove(a);
}

void usage(const char *arg0, ostream &os) {
  os << "Usage: " << endl;
  os << "  " << arg0;
  for (auto i : args()) {
    if (i->has_flag(positional)) {
      os << ' ' << i->name();
    }
  }
  os << endl << endl;

  os << "Optional arguments:" << endl;
  map<string, vector<base_arg *>> groups;
  for (auto i : args()) {
    if (!i->has_flag(hidden) && !i->has_flag(positional))
      groups[i->group()].push_back(i);
  }

  for (const auto &i : groups) {
    if (!i.first.empty())
      os << i.first << ":" << endl;
    for (auto j : i.second) {
      os << "  ";
      j->print(os);
    }
    os << endl;
  }
}

void usage(const char *arg0) {
  usage(arg0, cout);
}

void parse(list<const char *> argv) {
  while (!argv.empty()) {
    const char *argi = argv.front();

    base_arg *ai = NULL;
    if (*argi++ == '-') {
      // This is a named argument?
      if (*argi == '-')
        ai = find_arg(argi + 1);
      else
        ai = find_arg(*argi);

      // If we found the argument by name, remove it from the list.
      if (ai)
        argv.pop_front();
      else if (*argi != '-')
        ai = next_positional_arg();
    } else {
      // This is a positional argument.
      ai = next_positional_arg();
    }
    if (ai != NULL) {
      ai->parse(argv);
      ai->set_parsed();
    } else {
      cerr << "Warning: Unused command line option '" << argv.front() << "'." << endl;
      argv.pop_front();
    }
  }
}

void parse(int argc, const char **argv) {
  list<const char *> args;
  for (int i = 0; i < argc; i++) {
    args.emplace_back(argv[i]);
  }
  parse(args);
}

void parse(const char *arg0, int argc, const char **argv) {
  parse(argc, argv);

  // If the help flag was set, show usage and exit.
  if (help) {
    usage(arg0);
    exit(1);
  }
}

void parse(const string &arg) {
  list<const char *> args = { arg.c_str() };
  parse(args);
}

void parse(istream &is, char delim) {
  while (is) {
    string line;
    getline(is, line, delim);

    string::size_type space = line.find(' ');
    if (space != string::npos) {
      line[space] = '\0';
      const char *args[] = {
        &line[0],
        &line[space + 1]
      };
      parse(2, args);
    }
  }
}

}  // namespace cl
}  // namespace ev3cv

<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: docchart.cxx,v $
 *
 *  $Revision: 1.12 $
 *
 *  last change: $Author: hr $ $Date: 2007-09-27 08:33: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
 *
 ************************************************************************/

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

#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_
#include <com/sun/star/frame/XModel.hpp>
#endif

#include <com/sun/star/chart2/XChartDocument.hpp>

#include <float.h>

#ifndef _HINTIDS_HXX
#include <hintids.hxx>
#endif

#ifndef _WINDOW_HXX //autogen
#include <vcl/window.hxx>
#endif

#ifndef _DOC_HXX
#include <doc.hxx>
#endif
#ifndef _DOCARY_HXX
#include <docary.hxx>
#endif
#ifndef _NDINDEX_HXX
#include <ndindex.hxx>
#endif
#ifndef _SWTABLE_HXX
#include <swtable.hxx>
#endif
#ifndef _NDTXT_HXX
#include <ndtxt.hxx>
#endif
#ifndef _NDOLE_HXX //autogen
#include <ndole.hxx>
#endif
#ifndef _CALC_HXX
#include <calc.hxx>
#endif
#ifndef _FRMFMT_HXX
#include <frmfmt.hxx>
#endif
#ifndef _CELLFML_HXX
#include <cellfml.hxx>
#endif
#ifndef _VIEWSH_HXX
#include <viewsh.hxx>
#endif
#ifndef _NDOLE_HXX
#include <ndole.hxx>
#endif
#ifndef _CALBCK_HXX
#include <calbck.hxx>
#endif
#ifndef _CNTFRM_HXX
#include <cntfrm.hxx>
#endif
#ifndef _SWTBLFMT_HXX
#include <swtblfmt.hxx>
#endif
#ifndef _TBLSEL_HXX
#include <tblsel.hxx>
#endif
#ifndef _CELLATR_HXX
#include <cellatr.hxx>
#endif
#ifndef _VOS_MUTEX_HXX_ //autogen
#include <vos/mutex.hxx>
#endif
#ifndef _SV_SVAPP_HXX //autogen
#include <vcl/svapp.hxx>
#endif

#include <unochart.hxx>

using namespace com::sun::star;
using namespace com::sun::star::uno;

void SwTable::UpdateCharts() const
{
    GetFrmFmt()->GetDoc()->UpdateCharts( GetFrmFmt()->GetName() );
}

BOOL SwTable::IsTblComplexForChart( const String& rSelection,
                                    SwChartLines* pGetCLines ) const
{
    const SwTableBox* pSttBox, *pEndBox;
    if( 2 < rSelection.Len() )
    {
        // spitze Klammern am Anfang & Ende enfernen
        String sBox( rSelection );
        if( '<' == sBox.GetChar( 0  ) ) sBox.Erase( 0, 1 );
        if( '>' == sBox.GetChar( sBox.Len()-1  ) ) sBox.Erase( sBox.Len()-1 );

        xub_StrLen nTrenner = sBox.Search( ':' );
        ASSERT( STRING_NOTFOUND != nTrenner, "keine gueltige Selektion" );

        pSttBox = GetTblBox( sBox.Copy( 0, nTrenner ));
        pEndBox = GetTblBox( sBox.Copy( nTrenner+1 ));
    }
    else
    {
        const SwTableLines* pLns = &GetTabLines();
        pSttBox = (*pLns)[ 0 ]->GetTabBoxes()[ 0 ];
        while( !pSttBox->GetSttNd() )
            // bis zur Content Box!
            pSttBox = pSttBox->GetTabLines()[ 0 ]->GetTabBoxes()[ 0 ];

        const SwTableBoxes* pBoxes = &(*pLns)[ pLns->Count()-1 ]->GetTabBoxes();
        pEndBox = (*pBoxes)[ pBoxes->Count()-1 ];
        while( !pEndBox->GetSttNd() )
        {
            // bis zur Content Box!
            pLns = &pEndBox->GetTabLines();
            pBoxes = &(*pLns)[ pLns->Count()-1 ]->GetTabBoxes();
            pEndBox = (*pBoxes)[ pBoxes->Count()-1 ];
        }
    }

    return !pSttBox || !pEndBox || !::ChkChartSel( *pSttBox->GetSttNd(),
                                        *pEndBox->GetSttNd(), pGetCLines );
}

IMPL_LINK( SwDoc, DoUpdateAllCharts, Timer *, EMPTYARG )
{
    ViewShell* pVSh;
    GetEditShell( &pVSh );
    if( pVSh )
    {
        const SwFrmFmts& rTblFmts = *GetTblFrmFmts();
        for( USHORT n = 0; n < rTblFmts.Count(); ++n )
        {
            SwTable* pTmpTbl;
            const SwTableNode* pTblNd;
            SwFrmFmt* pFmt = rTblFmts[ n ];

            if( 0 != ( pTmpTbl = SwTable::FindTable( pFmt ) ) &&
                0 != ( pTblNd = pTmpTbl->GetTableNode() ) &&
                pTblNd->GetNodes().IsDocNodes() )
            {
                _UpdateCharts( *pTmpTbl, *pVSh );
            }
        }
    }
    return 0;
}

void SwDoc::_UpdateCharts( const SwTable& rTbl, ViewShell& /*rVSh*/ ) const
{
    String aName( rTbl.GetFrmFmt()->GetName() );
    SwOLENode *pONd;
    SwStartNode *pStNd;
    SwNodeIndex aIdx( *GetNodes().GetEndOfAutotext().StartOfSectionNode(), 1 );
    while( 0 != (pStNd = aIdx.GetNode().GetStartNode()) )
    {
        aIdx++;
        SwFrm* pFrm;
        if( 0 != ( pONd = aIdx.GetNode().GetOLENode() ) &&
            aName.Equals( pONd->GetChartTblName() ) &&
            0 != ( pFrm = pONd->GetFrm() ) )
        {
            SwChartDataProvider *pPCD = GetChartDataProvider();
            if (pPCD)
                pPCD->InvalidateTable( &rTbl );
            // following this the framework will now take care of repainting
            // the chart or it's replacement image...
        }
        aIdx.Assign( *pStNd->EndOfSectionNode(), + 1 );
    }
}

void SwDoc::UpdateCharts( const String &rName ) const
{
    SwTable* pTmpTbl = SwTable::FindTable( FindTblFmtByName( rName ) );
    if( pTmpTbl )
    {
        ViewShell* pVSh;
        GetEditShell( &pVSh );

        if( pVSh )
            _UpdateCharts( *pTmpTbl, *pVSh );
    }
}

void SwDoc::SetTableName( SwFrmFmt& rTblFmt, const String &rNewName )
{
//  BOOL bStop = 1;

    const String aOldName( rTblFmt.GetName() );

    BOOL bNameFound = 0 == rNewName.Len();
    if( !bNameFound )
    {
        SwFrmFmt* pFmt;
        const SwFrmFmts& rTbl = *GetTblFrmFmts();
        for( USHORT i = rTbl.Count(); i; )
            if( !( pFmt = rTbl[ --i ] )->IsDefault() &&
                pFmt->GetName() == rNewName && IsUsed( *pFmt ) )
            {
                bNameFound = TRUE;
                break;
            }
    }

    if( !bNameFound )
        rTblFmt.SetName( rNewName, sal_True );
    else
        rTblFmt.SetName( GetUniqueTblName(), sal_True );

    SwStartNode *pStNd;
    SwNodeIndex aIdx( *GetNodes().GetEndOfAutotext().StartOfSectionNode(), 1 );
    while ( 0 != (pStNd = aIdx.GetNode().GetStartNode()) )
    {
        aIdx++;
        SwOLENode *pNd = aIdx.GetNode().GetOLENode();
        if( pNd && aOldName == pNd->GetChartTblName() )
        {
            pNd->SetChartTblName( rNewName );

            ViewShell* pVSh;
            GetEditShell( &pVSh );

            SwTable* pTable = SwTable::FindTable( &rTblFmt );
            SwChartDataProvider *pPCD = GetChartDataProvider();
            if (pPCD)
                pPCD->InvalidateTable( pTable );
            // following this the framework will now take care of repainting
            // the chart or it's replacement image...
        }
        aIdx.Assign( *pStNd->EndOfSectionNode(), + 1 );
    }
    SetModified();
}

SwChartDataProvider * SwDoc::GetChartDataProvider( bool bCreate ) const
{
    // since there must be only one instance of this object per document
    // we need a mutex here
    vos::OGuard aGuard( Application::GetSolarMutex() );

    if (bCreate && !aChartDataProviderImplRef.get())
    {
        aChartDataProviderImplRef = comphelper::ImplementationReference< SwChartDataProvider
            , chart2::data::XDataProvider >( new SwChartDataProvider( this ) );
    }
    return aChartDataProviderImplRef.get();
}

void SwDoc::CreateChartInternalDataProviders( const SwTable *pTable )
{
    if (pTable)
    {
        String aName( pTable->GetFrmFmt()->GetName() );
        SwOLENode *pONd;
        SwStartNode *pStNd;
        SwNodeIndex aIdx( *GetNodes().GetEndOfAutotext().StartOfSectionNode(), 1 );
        while (0 != (pStNd = aIdx.GetNode().GetStartNode()))
        {
            aIdx++;
            if( 0 != ( pONd = aIdx.GetNode().GetOLENode() ) &&
                aName.Equals( pONd->GetChartTblName() ) /* OLE node is chart? */ &&
                0 != (pONd->GetFrm()) /* chart frame is not hidden */ )
            {
                uno::Reference < embed::XEmbeddedObject > xIP = pONd->GetOLEObj().GetOleRef();
                if ( svt::EmbeddedObjectRef::TryRunningState( xIP ) )
                {
                    uno::Reference< chart2::XChartDocument > xChart( xIP->getComponent(), UNO_QUERY );
                    if (xChart.is())
                        xChart->createInternalDataProvider( sal_True );

                    // there may be more than one chart for each table thus we need to continue the loop...
                }
            }
            aIdx.Assign( *pStNd->EndOfSectionNode(), + 1 );
        }
    }
}

SwChartLockController_Helper & SwDoc::GetChartControllerHelper()
{
    if (!pChartControllerHelper)
    {
        pChartControllerHelper = new SwChartLockController_Helper( this );
    }
    return *pChartControllerHelper;
}

<commit_msg>INTEGRATION: CWS changefileheader (1.12.242); FILE MERGED 2008/04/01 15:56:54 thb 1.12.242.3: #i85898# Stripping all external header guards 2008/04/01 12:53:54 thb 1.12.242.2: #i85898# Stripping all external header guards 2008/03/31 16:53:46 rt 1.12.242.1: #i87441# Change license header to LPGL v3.<commit_after>/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2008 by Sun Microsystems, Inc.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * $RCSfile: docchart.cxx,v $
 * $Revision: 1.13 $
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org 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 version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

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

#include <com/sun/star/frame/XModel.hpp>

#include <com/sun/star/chart2/XChartDocument.hpp>

#include <float.h>
#include <hintids.hxx>
#include <vcl/window.hxx>
#include <doc.hxx>
#include <docary.hxx>
#include <ndindex.hxx>
#include <swtable.hxx>
#include <ndtxt.hxx>
#include <ndole.hxx>
#include <calc.hxx>
#include <frmfmt.hxx>
#include <cellfml.hxx>
#include <viewsh.hxx>
#include <ndole.hxx>
#include <calbck.hxx>
#include <cntfrm.hxx>
#include <swtblfmt.hxx>
#include <tblsel.hxx>
#include <cellatr.hxx>
#include <vos/mutex.hxx>
#include <vcl/svapp.hxx>

#include <unochart.hxx>

using namespace com::sun::star;
using namespace com::sun::star::uno;

void SwTable::UpdateCharts() const
{
    GetFrmFmt()->GetDoc()->UpdateCharts( GetFrmFmt()->GetName() );
}

BOOL SwTable::IsTblComplexForChart( const String& rSelection,
                                    SwChartLines* pGetCLines ) const
{
    const SwTableBox* pSttBox, *pEndBox;
    if( 2 < rSelection.Len() )
    {
        // spitze Klammern am Anfang & Ende enfernen
        String sBox( rSelection );
        if( '<' == sBox.GetChar( 0  ) ) sBox.Erase( 0, 1 );
        if( '>' == sBox.GetChar( sBox.Len()-1  ) ) sBox.Erase( sBox.Len()-1 );

        xub_StrLen nTrenner = sBox.Search( ':' );
        ASSERT( STRING_NOTFOUND != nTrenner, "keine gueltige Selektion" );

        pSttBox = GetTblBox( sBox.Copy( 0, nTrenner ));
        pEndBox = GetTblBox( sBox.Copy( nTrenner+1 ));
    }
    else
    {
        const SwTableLines* pLns = &GetTabLines();
        pSttBox = (*pLns)[ 0 ]->GetTabBoxes()[ 0 ];
        while( !pSttBox->GetSttNd() )
            // bis zur Content Box!
            pSttBox = pSttBox->GetTabLines()[ 0 ]->GetTabBoxes()[ 0 ];

        const SwTableBoxes* pBoxes = &(*pLns)[ pLns->Count()-1 ]->GetTabBoxes();
        pEndBox = (*pBoxes)[ pBoxes->Count()-1 ];
        while( !pEndBox->GetSttNd() )
        {
            // bis zur Content Box!
            pLns = &pEndBox->GetTabLines();
            pBoxes = &(*pLns)[ pLns->Count()-1 ]->GetTabBoxes();
            pEndBox = (*pBoxes)[ pBoxes->Count()-1 ];
        }
    }

    return !pSttBox || !pEndBox || !::ChkChartSel( *pSttBox->GetSttNd(),
                                        *pEndBox->GetSttNd(), pGetCLines );
}

IMPL_LINK( SwDoc, DoUpdateAllCharts, Timer *, EMPTYARG )
{
    ViewShell* pVSh;
    GetEditShell( &pVSh );
    if( pVSh )
    {
        const SwFrmFmts& rTblFmts = *GetTblFrmFmts();
        for( USHORT n = 0; n < rTblFmts.Count(); ++n )
        {
            SwTable* pTmpTbl;
            const SwTableNode* pTblNd;
            SwFrmFmt* pFmt = rTblFmts[ n ];

            if( 0 != ( pTmpTbl = SwTable::FindTable( pFmt ) ) &&
                0 != ( pTblNd = pTmpTbl->GetTableNode() ) &&
                pTblNd->GetNodes().IsDocNodes() )
            {
                _UpdateCharts( *pTmpTbl, *pVSh );
            }
        }
    }
    return 0;
}

void SwDoc::_UpdateCharts( const SwTable& rTbl, ViewShell& /*rVSh*/ ) const
{
    String aName( rTbl.GetFrmFmt()->GetName() );
    SwOLENode *pONd;
    SwStartNode *pStNd;
    SwNodeIndex aIdx( *GetNodes().GetEndOfAutotext().StartOfSectionNode(), 1 );
    while( 0 != (pStNd = aIdx.GetNode().GetStartNode()) )
    {
        aIdx++;
        SwFrm* pFrm;
        if( 0 != ( pONd = aIdx.GetNode().GetOLENode() ) &&
            aName.Equals( pONd->GetChartTblName() ) &&
            0 != ( pFrm = pONd->GetFrm() ) )
        {
            SwChartDataProvider *pPCD = GetChartDataProvider();
            if (pPCD)
                pPCD->InvalidateTable( &rTbl );
            // following this the framework will now take care of repainting
            // the chart or it's replacement image...
        }
        aIdx.Assign( *pStNd->EndOfSectionNode(), + 1 );
    }
}

void SwDoc::UpdateCharts( const String &rName ) const
{
    SwTable* pTmpTbl = SwTable::FindTable( FindTblFmtByName( rName ) );
    if( pTmpTbl )
    {
        ViewShell* pVSh;
        GetEditShell( &pVSh );

        if( pVSh )
            _UpdateCharts( *pTmpTbl, *pVSh );
    }
}

void SwDoc::SetTableName( SwFrmFmt& rTblFmt, const String &rNewName )
{
//  BOOL bStop = 1;

    const String aOldName( rTblFmt.GetName() );

    BOOL bNameFound = 0 == rNewName.Len();
    if( !bNameFound )
    {
        SwFrmFmt* pFmt;
        const SwFrmFmts& rTbl = *GetTblFrmFmts();
        for( USHORT i = rTbl.Count(); i; )
            if( !( pFmt = rTbl[ --i ] )->IsDefault() &&
                pFmt->GetName() == rNewName && IsUsed( *pFmt ) )
            {
                bNameFound = TRUE;
                break;
            }
    }

    if( !bNameFound )
        rTblFmt.SetName( rNewName, sal_True );
    else
        rTblFmt.SetName( GetUniqueTblName(), sal_True );

    SwStartNode *pStNd;
    SwNodeIndex aIdx( *GetNodes().GetEndOfAutotext().StartOfSectionNode(), 1 );
    while ( 0 != (pStNd = aIdx.GetNode().GetStartNode()) )
    {
        aIdx++;
        SwOLENode *pNd = aIdx.GetNode().GetOLENode();
        if( pNd && aOldName == pNd->GetChartTblName() )
        {
            pNd->SetChartTblName( rNewName );

            ViewShell* pVSh;
            GetEditShell( &pVSh );

            SwTable* pTable = SwTable::FindTable( &rTblFmt );
            SwChartDataProvider *pPCD = GetChartDataProvider();
            if (pPCD)
                pPCD->InvalidateTable( pTable );
            // following this the framework will now take care of repainting
            // the chart or it's replacement image...
        }
        aIdx.Assign( *pStNd->EndOfSectionNode(), + 1 );
    }
    SetModified();
}

SwChartDataProvider * SwDoc::GetChartDataProvider( bool bCreate ) const
{
    // since there must be only one instance of this object per document
    // we need a mutex here
    vos::OGuard aGuard( Application::GetSolarMutex() );

    if (bCreate && !aChartDataProviderImplRef.get())
    {
        aChartDataProviderImplRef = comphelper::ImplementationReference< SwChartDataProvider
            , chart2::data::XDataProvider >( new SwChartDataProvider( this ) );
    }
    return aChartDataProviderImplRef.get();
}

void SwDoc::CreateChartInternalDataProviders( const SwTable *pTable )
{
    if (pTable)
    {
        String aName( pTable->GetFrmFmt()->GetName() );
        SwOLENode *pONd;
        SwStartNode *pStNd;
        SwNodeIndex aIdx( *GetNodes().GetEndOfAutotext().StartOfSectionNode(), 1 );
        while (0 != (pStNd = aIdx.GetNode().GetStartNode()))
        {
            aIdx++;
            if( 0 != ( pONd = aIdx.GetNode().GetOLENode() ) &&
                aName.Equals( pONd->GetChartTblName() ) /* OLE node is chart? */ &&
                0 != (pONd->GetFrm()) /* chart frame is not hidden */ )
            {
                uno::Reference < embed::XEmbeddedObject > xIP = pONd->GetOLEObj().GetOleRef();
                if ( svt::EmbeddedObjectRef::TryRunningState( xIP ) )
                {
                    uno::Reference< chart2::XChartDocument > xChart( xIP->getComponent(), UNO_QUERY );
                    if (xChart.is())
                        xChart->createInternalDataProvider( sal_True );

                    // there may be more than one chart for each table thus we need to continue the loop...
                }
            }
            aIdx.Assign( *pStNd->EndOfSectionNode(), + 1 );
        }
    }
}

SwChartLockController_Helper & SwDoc::GetChartControllerHelper()
{
    if (!pChartControllerHelper)
    {
        pChartControllerHelper = new SwChartLockController_Helper( this );
    }
    return *pChartControllerHelper;
}

<|endoftext|>


<commit_before>#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE AutPreprocessor test
#include <boost/test/unit_test.hpp>
#include <string>
#include <vector>
#include <iostream>
#include "AutPreprocessor.h"

void checkStringArrayMatches(std::string model, std::string* arr, int size) {
  for(int i = 0; i < size; i++) {
    BOOST_CHECK_EQUAL(model, arr[i]);
  }
}

BOOST_AUTO_TEST_CASE(cornerCases) {
  std::string singleSemicolon = AutPreprocessor::preprocess(";");
  std::string singleCurly = AutPreprocessor::preprocess("{");
  std::string empty = AutPreprocessor::preprocess("");
  std::string singleChar = AutPreprocessor::preprocess("c");
  std::string singleWhitespace = AutPreprocessor::preprocess(" ");
  BOOST_CHECK_EQUAL(";", singleSemicolon);
  BOOST_CHECK_EQUAL("{", singleCurly);
  BOOST_CHECK_EQUAL("", empty);
  BOOST_CHECK_EQUAL("c", singleChar);
  BOOST_CHECK_EQUAL("", singleWhitespace);
}

BOOST_AUTO_TEST_CASE(statements) {
  std::string lotsOfWhite = AutPreprocessor::preprocess("h  e\t  \n  l\r l \vo\fworld;\t\n\r\f\vs        ec    on  dke   ywo  rd;\t  \n");
  std::string lotsOfWhiteExpected = "h e l l o world;s ec on dke ywo rd;";
  std::string endCurlies = AutPreprocessor::preprocess("out{inner;inner;};next{nextinner;};");
  std::string endCurliesExpected = "out{inner;inner;};next{nextinner;};";
  std::string endCurliesWithSpaces = AutPreprocessor::preprocess("out  {  inner;  inner;  }  ;  next{nextinner  ;  }  ;  ");
  std::string curliesWithSpaces = AutPreprocessor::preprocess("  {   { {{  {");
  std::string curliesWithSpacesExpected = "{{{{{";
  std::string endWithoutKeywordEnd = AutPreprocessor::preprocess("hello      ");
  std::string endWithoutKeywordEndExpected = "hello";
  BOOST_CHECK_EQUAL(lotsOfWhiteExpected, lotsOfWhite);
  BOOST_CHECK_EQUAL(endCurlies, endCurliesExpected);
  BOOST_CHECK_EQUAL(endCurliesWithSpaces, endCurliesExpected);
  BOOST_CHECK_EQUAL(curliesWithSpacesExpected, curliesWithSpaces);
  BOOST_CHECK_EQUAL(endWithoutKeywordEndExpected, endWithoutKeywordEnd);
}

BOOST_AUTO_TEST_CASE(leadingSpace) {
  std::string leadingSpacesExpected = "hi;";
  std::string leadingSpace = AutPreprocessor::preprocess(" hi;");
  std::string leadingSpaces = AutPreprocessor::preprocess("  hi;");
  std::string leadingNewlines = AutPreprocessor::preprocess("\n\nhi;");
  std::string leadingCrs = AutPreprocessor::preprocess("\r\rhi;");
  std::string leadingTabs = AutPreprocessor::preprocess("\t\thi;");
  std::string leadingComboWhite = AutPreprocessor::preprocess(" \t\r\n hi;");
  std::string leadingSpacesStrs[] = {leadingSpace, leadingSpaces, leadingNewlines, leadingCrs, leadingTabs, leadingComboWhite};
  checkStringArrayMatches(leadingSpacesExpected, leadingSpacesStrs, 6);
}

BOOST_AUTO_TEST_CASE(spcSemicolon) {
  std::string spacesBeforeSemiExpected = "hi;";
  std::string spaceBeforeSemi = AutPreprocessor::preprocess("hi ;");
  std::string spacesBeforeSemi = AutPreprocessor::preprocess("hi  ;");
  std::string newlinesBeforeSemi = AutPreprocessor::preprocess("hi\n\n;");
  std::string crsBeforeSemi = AutPreprocessor::preprocess("hi\r\r;");
  std::string tabsBeforeSemi = AutPreprocessor::preprocess("hi\t\t;");
  std::string comboWhiteBeforeSemi = AutPreprocessor::preprocess("hi \t\r\n;");
  std::string beforeSemiStrs[] = {spaceBeforeSemi, spacesBeforeSemi, newlinesBeforeSemi, crsBeforeSemi, crsBeforeSemi, tabsBeforeSemi, comboWhiteBeforeSemi};
  checkStringArrayMatches(spacesBeforeSemiExpected, beforeSemiStrs, 6);
}

BOOST_AUTO_TEST_CASE(spcCurly) {
  std::string spacesBeforeCurlyExpected = "hi{";
  std::string spaceBeforeCurly = AutPreprocessor::preprocess("hi {");
  std::string spacesBeforeCurly = AutPreprocessor::preprocess("hi  {");
  std::string newlinesBeforeCurly = AutPreprocessor::preprocess("hi\n\n{");
  std::string crsBeforeCurly = AutPreprocessor::preprocess("hi\r\r{");
  std::string tabsBeforeCurly = AutPreprocessor::preprocess("hi\t\t{");
  std::string comboWhiteBeforeCurly= AutPreprocessor::preprocess("hi \t\r\n{");
  std::string spacesBeforeCurlyStrs[] = {spaceBeforeCurly, spacesBeforeCurly, newlinesBeforeCurly, crsBeforeCurly, tabsBeforeCurly, comboWhiteBeforeCurly};
  checkStringArrayMatches(spacesBeforeCurlyExpected, spacesBeforeCurlyStrs, 6);
}

BOOST_AUTO_TEST_CASE(spcInKeyword) {
  std::string whitespaceInKeywordExpected = "hi hi;";
  std::string spaceInKeyword = AutPreprocessor::preprocess("hi hi;");
  std::string spacesInKeyword = AutPreprocessor::preprocess("hi  hi;");
  std::string newlinesInKeyword = AutPreprocessor::preprocess("hi\n\nhi;");
  std::string crsInKeyword = AutPreprocessor::preprocess("hi\r\rhi;");
  std::string tabsInKeyword = AutPreprocessor::preprocess("hi\t\thi;");
  std::string comboWhiteInKeyword = AutPreprocessor::preprocess("hi \t\r\nhi;");
  std::string whitespaceInKeywordStrs[] = {spaceInKeyword, spacesInKeyword, newlinesInKeyword, crsInKeyword, tabsInKeyword, comboWhiteInKeyword};
  checkStringArrayMatches(whitespaceInKeywordExpected, whitespaceInKeywordStrs, 6);
}

BOOST_AUTO_TEST_CASE(spcOutsideKeyword) {
  std::string whitespaceOutsideKeywordExpected = "hi;hi;";
  std::string spaceOutsideKeyword = AutPreprocessor::preprocess("hi; hi; ");
  std::string spacesOutsideKeyword = AutPreprocessor::preprocess("hi;  hi;  ");
  std::string newlinesOutsideKeyword = AutPreprocessor::preprocess("hi;\n\nhi;\n\n");
  std::string crsOutsideKeyword = AutPreprocessor::preprocess("hi;\r\rhi;\r\r");
  std::string tabsOutsideKeyword = AutPreprocessor::preprocess("hi;\t\thi;\t\t");
  std::string comboWhiteOutsideKeyword = AutPreprocessor::preprocess("hi; \t\r\nhi;\t\r\n");
  std::string whitespaceOutsideKeywordStrs[] = {spaceOutsideKeyword, spacesOutsideKeyword, newlinesOutsideKeyword, crsOutsideKeyword, tabsOutsideKeyword, comboWhiteOutsideKeyword};
  checkStringArrayMatches(whitespaceOutsideKeywordExpected, whitespaceOutsideKeywordStrs, 6);
}

BOOST_AUTO_TEST_CASE(noKeywordEnding) {
  std::string noKeywordEndingExpected = "hi";
  std::string trailingSpaces = AutPreprocessor::preprocess("hi \t\r\n");
  std::string leadingSpaces = AutPreprocessor::preprocess(" \t\r\nhi");
  std::string leadingAndTrailingSpaces = AutPreprocessor::preprocess(" \t\r\nhi \t\r\n");
  std::string noKeywordEndingStrs[] = {trailingSpaces, leadingSpaces, leadingAndTrailingSpaces};
  checkStringArrayMatches(noKeywordEndingExpected, noKeywordEndingStrs, 3);
}

BOOST_AUTO_TEST_CASE(fullFile) {
  std::string fullFileExpected = "This bogus keyword should cause everything to be ignored until the next semicolon, allowing for future expansion;Another{more evil bogus keyword;we must also consume;the inner bogus statements;};Xrange -10 10;Yrange -5 5;Initial{Y = 2 : -1;Y=1: -2, -1;Y=-1: 2,3,4;};";
  std::string fullFile = "\
#\n\
# Comments, to be ignored\n\
#\n\
This bogus keyword should cause everything to be ignored\n\
until the next semicolon, allowing for future expansion ;\n\n\
\
Another { more evil bogus keyword; we must also consume;\
the inner bogus statements; };\n\
# Ugly formatting, but allowed:\n\
Xrange\n\
-10 10; Yrange -5 5;\n\n\
\
Initial {\n\
  Y = 2 :   -1;         # Sets (-1, 2) to \"alive\"\n\
  Y=1:      -2, -1;     # Sets (-2, 1) and (-1, 1) to \"alive\"\n\
  Y=-1:     2,3,4;      # Sets (2, -1), (3, -1), and (4, -1) to \"alive\"\n\
};";
  std::string fullFilePre = AutPreprocessor::preprocess(fullFile);
  std::cout<<"EXPECTED:\n";
  std::cout<<fullFileExpected<<"\n";
  std::cout<<"RECEIVED:\n";
  std::cout<<fullFilePre<<"\n";
  BOOST_CHECK_EQUAL(fullFileExpected, fullFilePre);
}

BOOST_AUTO_TEST_CASE(comments) {
  std::string commentsExpected = "hi;";
  std::string commentWithSemi = AutPreprocessor::preprocess("hi;#;invisible;");
  std::string commentWithCurly = AutPreprocessor::preprocess("hi;#{invisible;");
  std::string commentWithComment = AutPreprocessor::preprocess("hi;##invisible");
  std::string commentInsideKeyword = AutPreprocessor::preprocess("hi#comment\n;");
  std::string commentStrs[] = {commentWithSemi, commentWithCurly, commentWithComment};
  checkStringArrayMatches(commentsExpected, commentStrs, 3);
}
<commit_msg>Removed test print in AutPreprocessorTest<commit_after>#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE AutPreprocessor test
#include <boost/test/unit_test.hpp>
#include <string>
#include "AutPreprocessor.h"

void checkStringArrayMatches(std::string model, std::string* arr, int size) {
  for(int i = 0; i < size; i++) {
    BOOST_CHECK_EQUAL(model, arr[i]);
  }
}

BOOST_AUTO_TEST_CASE(cornerCases) {
  std::string singleSemicolon = AutPreprocessor::preprocess(";");
  std::string singleCurly = AutPreprocessor::preprocess("{");
  std::string empty = AutPreprocessor::preprocess("");
  std::string singleChar = AutPreprocessor::preprocess("c");
  std::string singleWhitespace = AutPreprocessor::preprocess(" ");
  BOOST_CHECK_EQUAL(";", singleSemicolon);
  BOOST_CHECK_EQUAL("{", singleCurly);
  BOOST_CHECK_EQUAL("", empty);
  BOOST_CHECK_EQUAL("c", singleChar);
  BOOST_CHECK_EQUAL("", singleWhitespace);
}

BOOST_AUTO_TEST_CASE(statements) {
  std::string lotsOfWhite = AutPreprocessor::preprocess("h  e\t  \n  l\r l \vo\fworld;\t\n\r\f\vs        ec    on  dke   ywo  rd;\t  \n");
  std::string lotsOfWhiteExpected = "h e l l o world;s ec on dke ywo rd;";
  std::string endCurlies = AutPreprocessor::preprocess("out{inner;inner;};next{nextinner;};");
  std::string endCurliesExpected = "out{inner;inner;};next{nextinner;};";
  std::string endCurliesWithSpaces = AutPreprocessor::preprocess("out  {  inner;  inner;  }  ;  next{nextinner  ;  }  ;  ");
  std::string curliesWithSpaces = AutPreprocessor::preprocess("  {   { {{  {");
  std::string curliesWithSpacesExpected = "{{{{{";
  std::string endWithoutKeywordEnd = AutPreprocessor::preprocess("hello      ");
  std::string endWithoutKeywordEndExpected = "hello";
  BOOST_CHECK_EQUAL(lotsOfWhiteExpected, lotsOfWhite);
  BOOST_CHECK_EQUAL(endCurlies, endCurliesExpected);
  BOOST_CHECK_EQUAL(endCurliesWithSpaces, endCurliesExpected);
  BOOST_CHECK_EQUAL(curliesWithSpacesExpected, curliesWithSpaces);
  BOOST_CHECK_EQUAL(endWithoutKeywordEndExpected, endWithoutKeywordEnd);
}

BOOST_AUTO_TEST_CASE(leadingSpace) {
  std::string leadingSpacesExpected = "hi;";
  std::string leadingSpace = AutPreprocessor::preprocess(" hi;");
  std::string leadingSpaces = AutPreprocessor::preprocess("  hi;");
  std::string leadingNewlines = AutPreprocessor::preprocess("\n\nhi;");
  std::string leadingCrs = AutPreprocessor::preprocess("\r\rhi;");
  std::string leadingTabs = AutPreprocessor::preprocess("\t\thi;");
  std::string leadingComboWhite = AutPreprocessor::preprocess(" \t\r\n hi;");
  std::string leadingSpacesStrs[] = {leadingSpace, leadingSpaces, leadingNewlines, leadingCrs, leadingTabs, leadingComboWhite};
  checkStringArrayMatches(leadingSpacesExpected, leadingSpacesStrs, 6);
}

BOOST_AUTO_TEST_CASE(spcSemicolon) {
  std::string spacesBeforeSemiExpected = "hi;";
  std::string spaceBeforeSemi = AutPreprocessor::preprocess("hi ;");
  std::string spacesBeforeSemi = AutPreprocessor::preprocess("hi  ;");
  std::string newlinesBeforeSemi = AutPreprocessor::preprocess("hi\n\n;");
  std::string crsBeforeSemi = AutPreprocessor::preprocess("hi\r\r;");
  std::string tabsBeforeSemi = AutPreprocessor::preprocess("hi\t\t;");
  std::string comboWhiteBeforeSemi = AutPreprocessor::preprocess("hi \t\r\n;");
  std::string beforeSemiStrs[] = {spaceBeforeSemi, spacesBeforeSemi, newlinesBeforeSemi, crsBeforeSemi, crsBeforeSemi, tabsBeforeSemi, comboWhiteBeforeSemi};
  checkStringArrayMatches(spacesBeforeSemiExpected, beforeSemiStrs, 6);
}

BOOST_AUTO_TEST_CASE(spcCurly) {
  std::string spacesBeforeCurlyExpected = "hi{";
  std::string spaceBeforeCurly = AutPreprocessor::preprocess("hi {");
  std::string spacesBeforeCurly = AutPreprocessor::preprocess("hi  {");
  std::string newlinesBeforeCurly = AutPreprocessor::preprocess("hi\n\n{");
  std::string crsBeforeCurly = AutPreprocessor::preprocess("hi\r\r{");
  std::string tabsBeforeCurly = AutPreprocessor::preprocess("hi\t\t{");
  std::string comboWhiteBeforeCurly= AutPreprocessor::preprocess("hi \t\r\n{");
  std::string spacesBeforeCurlyStrs[] = {spaceBeforeCurly, spacesBeforeCurly, newlinesBeforeCurly, crsBeforeCurly, tabsBeforeCurly, comboWhiteBeforeCurly};
  checkStringArrayMatches(spacesBeforeCurlyExpected, spacesBeforeCurlyStrs, 6);
}

BOOST_AUTO_TEST_CASE(spcInKeyword) {
  std::string whitespaceInKeywordExpected = "hi hi;";
  std::string spaceInKeyword = AutPreprocessor::preprocess("hi hi;");
  std::string spacesInKeyword = AutPreprocessor::preprocess("hi  hi;");
  std::string newlinesInKeyword = AutPreprocessor::preprocess("hi\n\nhi;");
  std::string crsInKeyword = AutPreprocessor::preprocess("hi\r\rhi;");
  std::string tabsInKeyword = AutPreprocessor::preprocess("hi\t\thi;");
  std::string comboWhiteInKeyword = AutPreprocessor::preprocess("hi \t\r\nhi;");
  std::string whitespaceInKeywordStrs[] = {spaceInKeyword, spacesInKeyword, newlinesInKeyword, crsInKeyword, tabsInKeyword, comboWhiteInKeyword};
  checkStringArrayMatches(whitespaceInKeywordExpected, whitespaceInKeywordStrs, 6);
}

BOOST_AUTO_TEST_CASE(spcOutsideKeyword) {
  std::string whitespaceOutsideKeywordExpected = "hi;hi;";
  std::string spaceOutsideKeyword = AutPreprocessor::preprocess("hi; hi; ");
  std::string spacesOutsideKeyword = AutPreprocessor::preprocess("hi;  hi;  ");
  std::string newlinesOutsideKeyword = AutPreprocessor::preprocess("hi;\n\nhi;\n\n");
  std::string crsOutsideKeyword = AutPreprocessor::preprocess("hi;\r\rhi;\r\r");
  std::string tabsOutsideKeyword = AutPreprocessor::preprocess("hi;\t\thi;\t\t");
  std::string comboWhiteOutsideKeyword = AutPreprocessor::preprocess("hi; \t\r\nhi;\t\r\n");
  std::string whitespaceOutsideKeywordStrs[] = {spaceOutsideKeyword, spacesOutsideKeyword, newlinesOutsideKeyword, crsOutsideKeyword, tabsOutsideKeyword, comboWhiteOutsideKeyword};
  checkStringArrayMatches(whitespaceOutsideKeywordExpected, whitespaceOutsideKeywordStrs, 6);
}

BOOST_AUTO_TEST_CASE(noKeywordEnding) {
  std::string noKeywordEndingExpected = "hi";
  std::string trailingSpaces = AutPreprocessor::preprocess("hi \t\r\n");
  std::string leadingSpaces = AutPreprocessor::preprocess(" \t\r\nhi");
  std::string leadingAndTrailingSpaces = AutPreprocessor::preprocess(" \t\r\nhi \t\r\n");
  std::string noKeywordEndingStrs[] = {trailingSpaces, leadingSpaces, leadingAndTrailingSpaces};
  checkStringArrayMatches(noKeywordEndingExpected, noKeywordEndingStrs, 3);
}

BOOST_AUTO_TEST_CASE(fullFile) {
  std::string fullFileExpected = "This bogus keyword should cause everything to be ignored until the next semicolon, allowing for future expansion;Another{more evil bogus keyword;we must also consume;the inner bogus statements;};Xrange -10 10;Yrange -5 5;Initial{Y = 2 : -1;Y=1: -2, -1;Y=-1: 2,3,4;};";
  std::string fullFile = "\
#\n\
# Comments, to be ignored\n\
#\n\
This bogus keyword should cause everything to be ignored\n\
until the next semicolon, allowing for future expansion ;\n\n\
\
Another { more evil bogus keyword; we must also consume;\
the inner bogus statements; };\n\
# Ugly formatting, but allowed:\n\
Xrange\n\
-10 10; Yrange -5 5;\n\n\
\
Initial {\n\
  Y = 2 :   -1;         # Sets (-1, 2) to \"alive\"\n\
  Y=1:      -2, -1;     # Sets (-2, 1) and (-1, 1) to \"alive\"\n\
  Y=-1:     2,3,4;      # Sets (2, -1), (3, -1), and (4, -1) to \"alive\"\n\
};";
  std::string fullFilePre = AutPreprocessor::preprocess(fullFile);
  BOOST_CHECK_EQUAL(fullFileExpected, fullFilePre);
}

BOOST_AUTO_TEST_CASE(comments) {
  std::string commentsExpected = "hi;";
  std::string commentWithSemi = AutPreprocessor::preprocess("hi;#;invisible;");
  std::string commentWithCurly = AutPreprocessor::preprocess("hi;#{invisible;");
  std::string commentWithComment = AutPreprocessor::preprocess("hi;##invisible");
  std::string commentInsideKeyword = AutPreprocessor::preprocess("hi#comment\n;");
  std::string commentStrs[] = {commentWithSemi, commentWithCurly, commentWithComment};
  checkStringArrayMatches(commentsExpected, commentStrs, 3);
}
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: swblocks.hxx,v $
 *
 *  $Revision: 1.15 $
 *
 *  last change: $Author: hr $ $Date: 2007-09-27 08:58:25 $
 *
 *  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
 *
 ************************************************************************/
#ifndef _SWBLOCKS_HXX
#define _SWBLOCKS_HXX

#include <tools/string.hxx>

#ifndef _DATE_HXX //autogen
#include <tools/datetime.hxx>
#endif
#ifndef _SVARRAY_HXX //autogen
#include <svtools/svarray.hxx>
#endif

class SfxMedium;
class SwPaM;
class SwDoc;
class SvxMacroTableDtor;

// Name eines Textblocks:

class SwBlockName
{
    friend class SwImpBlocks;
    friend class Sw2TextBlocks;
    USHORT nHashS, nHashL;              // Hash-Codes zum Checken
    long   nPos;                        // Dateiposition (SW2-Format)
public:
    String aShort;                      // Short name
    String aLong;                       // Long name
    String aPackageName;                // Package name
    BOOL bIsOnlyTxtFlagInit : 1;        // ist das Flag gueltig?
    BOOL bIsOnlyTxt : 1;                // unformatted text
    BOOL bInPutMuchBlocks : 1;          // put serveral block entries

    SwBlockName( const String& rShort, const String& rLong, long n );
    SwBlockName( const String& rShort, const String& rLong, const String& rPackageName );

    // fuer das Einsortieren in das Array
    int operator==( const SwBlockName& r ) { return aShort == r.aShort; }
    int operator< ( const SwBlockName& r ) { return aShort <  r.aShort; }
};

SV_DECL_PTRARR_SORT( SwBlockNames, SwBlockName*, 10, 10 )

class SwImpBlocks
{
    friend class SwTextBlocks;
protected:
    String aFile;                       // physikalischer Dateiname
    String aName;                       // logischer Name der Datei
    String aCur;                        // aktueller Text
    String aShort, aLong;               // Kurz- und Langname (PutDoc)
    String sBaseURL;                    // base URL - has to be set at the Readers and Writers
    SwBlockNames aNames;                // Liste aller Bausteine
    Date aDateModified;                 // fuers abgleichen bei den Aktionen
    Time aTimeModified;
    SwDoc* pDoc;                        // Austauschdokument
    USHORT nCur;                        // aktueller Index
    BOOL bReadOnly : 1;
    BOOL bInPutMuchBlocks : 1;          // put serveral block entries
    BOOL bInfoChanged : 1;              // any Info of TextBlock is changed

    SwImpBlocks( const String&, BOOL = FALSE );
    virtual ~SwImpBlocks();

    static short GetFileType( const String& );
    virtual short GetFileType() const = 0;
#define SWBLK_NO_FILE   0               // nicht da
#define SWBLK_NONE      1               // keine TB-Datei
#define SWBLK_SW2       2               // SW2-Datei
#define SWBLK_SW3       3               // SW3-Datei
#define SWBLK_XML       4               // XML Block List

    virtual void   ClearDoc();                  // Doc-Inhalt loeschen
    SwPaM* MakePaM();                   // PaM ueber Doc aufspannen
    virtual void   AddName( const String&, const String&, BOOL bOnlyTxt = FALSE );
    BOOL   IsFileChanged() const;
    void   Touch();

public:
    static USHORT Hash( const String& );        // Hashcode fuer Blocknamen
    USHORT GetCount() const;                    // Anzahl Textbausteine ermitteln
    USHORT GetIndex( const String& ) const;     // Index fuer Kurznamen ermitteln
    USHORT GetLongIndex( const String& ) const; //Index fuer Langnamen ermitteln
    const String& GetShortName( USHORT ) const; // Kurzname fuer Index zurueck
    const String& GetLongName( USHORT ) const;  // Langname fuer Index zurueck
    const String& GetPackageName( USHORT ) const;   // Langname fuer Index zurueck

    const String& GetFileName() const {return aFile;}   // phys. Dateinamen liefern
    void SetName( const String& rName )                 // logic name
        { aName = rName; bInfoChanged = TRUE; }
    const String & GetName( void )
        { return aName; }

    const String&       GetBaseURL() const { return sBaseURL;}
    void                SetBaseURL( const String& rURL ) { sBaseURL = rURL; }

    virtual ULONG Delete( USHORT ) = 0;
    virtual ULONG Rename( USHORT, const String&, const String& ) = 0;
    virtual ULONG CopyBlock( SwImpBlocks& rImp, String& rShort, const String& rLong) = 0;
    virtual ULONG GetDoc( USHORT ) = 0;
    virtual ULONG GetDocForConversion( USHORT );
    virtual ULONG BeginPutDoc( const String&, const String& ) = 0;
    virtual ULONG PutDoc() = 0;
    virtual ULONG GetText( USHORT, String& ) = 0;
    virtual ULONG PutText( const String&, const String&, const String& ) = 0;
    virtual ULONG MakeBlockList() = 0;

    virtual ULONG OpenFile( BOOL bReadOnly = TRUE ) = 0;
    virtual void  CloseFile() = 0;

    virtual BOOL IsOnlyTextBlock( const String& rShort ) const;

    virtual ULONG GetMacroTable( USHORT nIdx, SvxMacroTableDtor& rMacroTbl,
                                 sal_Bool bFileAlreadyOpen = sal_False );
    virtual ULONG SetMacroTable( USHORT nIdx,
                                 const SvxMacroTableDtor& rMacroTbl,
                                 sal_Bool bFileAlreadyOpen = sal_False );
    virtual BOOL PutMuchEntries( BOOL bOn );
};

/*
class Sw3Persist : public SvPersist
{
    virtual void FillClass( SvGlobalName * pClassName,
                            ULONG * pClipFormat,
                            String * pAppName,
                            String * pLongUserName,
                            String * pUserName,
                            sal_Int32 nFileFormat=SOFFICE_FILEFORMAT_CURRENT ) const;
    virtual BOOL Save();
    virtual BOOL SaveCompleted( SvStorage * );
public:
    Sw3Persist();
};

class SwSwgReader;

class Sw2TextBlocks : public SwImpBlocks
{
    SvPersistRef refPersist;            // Fuer OLE-Objekte
    SwSwgReader* pRdr;                  // Lese-Routinen
    SfxMedium* pMed;                    // der logische Input-Stream
    String* pText;                      // String fuer GetText()
    long   nDocStart;                   // Beginn des Doc-Records
    long   nDocSize;                    // Laenge des Doc-Records
    long   nStart;                      // Beginn des CONTENTS-Records
    long   nSize;                       // Laenge des CONTENTS-Records
    USHORT nNamedFmts;                  // benannte Formate
    USHORT nColls;                      // Text-Collections
    USHORT nBlks;                       // Anzahl Elemente im CONTENTS-Record
public:
    Sw2TextBlocks( const String& );
    virtual ~Sw2TextBlocks();
    virtual ULONG Delete( USHORT );
    virtual ULONG Rename( USHORT, const String&, const String& );
    virtual ULONG CopyBlock( SwImpBlocks& rImp, String& rShort, const String& rLong);
    virtual ULONG GetDoc( USHORT );
    virtual ULONG BeginPutDoc( const String&, const String& );
    virtual ULONG PutDoc();
    virtual ULONG GetText( USHORT, String& );
    virtual ULONG PutText( const String&, const String&, const String& );
    virtual ULONG MakeBlockList();
    virtual short GetFileType( ) const;
    ULONG LoadDoc();

    virtual ULONG OpenFile( BOOL bReadOnly = TRUE );
    virtual void  CloseFile();

    void StatLineStartPercent();                // zum Anzeigen des Prozessbars
};

class Sw3Io;
class Sw3IoImp;

class Sw3TextBlocks : public SwImpBlocks
{
    Sw3Io*       pIo3;
    Sw3IoImp*    pImp;
    BOOL         bAutocorrBlock;

public:
    Sw3TextBlocks( const String& );
    Sw3TextBlocks( SvStorage& );
    virtual ~Sw3TextBlocks();
    virtual ULONG Delete( USHORT );
    virtual ULONG Rename( USHORT, const String&, const String& );
    virtual ULONG CopyBlock( SwImpBlocks& rImp, String& rShort, const String& rLong);
    virtual ULONG GetDoc( USHORT );
    virtual ULONG GetDocForConversion( USHORT );
    virtual ULONG BeginPutDoc( const String&, const String& );
    virtual ULONG PutDoc();
    virtual void SetDoc( SwDoc * pNewDoc);
    virtual ULONG GetText( USHORT, String& );
    virtual ULONG PutText( const String&, const String&, const String& );
    virtual ULONG MakeBlockList();
    virtual short GetFileType( ) const;

    virtual ULONG OpenFile( BOOL bReadOnly = TRUE );
    virtual void  CloseFile();

    // Methoden fuer die neue Autokorrektur
    ULONG GetText( const String& rShort, String& );
    SwDoc* GetDoc() const { return pDoc; }

    virtual BOOL IsOnlyTextBlock( const String& rShort ) const;

    virtual ULONG GetMacroTable( USHORT, SvxMacroTableDtor& rMacroTbl,
                                 sal_Bool bFileAlreadyOpen = sal_False );
    virtual ULONG SetMacroTable( USHORT nIdx,
                                 const SvxMacroTableDtor& rMacroTbl,
                                 sal_Bool bFileAlreadyOpen = sal_False );

    void ReadInfo();
};
*/
#endif
<commit_msg>INTEGRATION: CWS changefileheader (1.15.242); FILE MERGED 2008/04/01 15:57:12 thb 1.15.242.2: #i85898# Stripping all external header guards 2008/03/31 16:54:15 rt 1.15.242.1: #i87441# Change license header to LPGL v3.<commit_after>/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2008 by Sun Microsystems, Inc.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * $RCSfile: swblocks.hxx,v $
 * $Revision: 1.16 $
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org 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 version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/
#ifndef _SWBLOCKS_HXX
#define _SWBLOCKS_HXX

#include <tools/string.hxx>

#ifndef _DATE_HXX //autogen
#include <tools/datetime.hxx>
#endif
#include <svtools/svarray.hxx>

class SfxMedium;
class SwPaM;
class SwDoc;
class SvxMacroTableDtor;

// Name eines Textblocks:

class SwBlockName
{
    friend class SwImpBlocks;
    friend class Sw2TextBlocks;
    USHORT nHashS, nHashL;              // Hash-Codes zum Checken
    long   nPos;                        // Dateiposition (SW2-Format)
public:
    String aShort;                      // Short name
    String aLong;                       // Long name
    String aPackageName;                // Package name
    BOOL bIsOnlyTxtFlagInit : 1;        // ist das Flag gueltig?
    BOOL bIsOnlyTxt : 1;                // unformatted text
    BOOL bInPutMuchBlocks : 1;          // put serveral block entries

    SwBlockName( const String& rShort, const String& rLong, long n );
    SwBlockName( const String& rShort, const String& rLong, const String& rPackageName );

    // fuer das Einsortieren in das Array
    int operator==( const SwBlockName& r ) { return aShort == r.aShort; }
    int operator< ( const SwBlockName& r ) { return aShort <  r.aShort; }
};

SV_DECL_PTRARR_SORT( SwBlockNames, SwBlockName*, 10, 10 )

class SwImpBlocks
{
    friend class SwTextBlocks;
protected:
    String aFile;                       // physikalischer Dateiname
    String aName;                       // logischer Name der Datei
    String aCur;                        // aktueller Text
    String aShort, aLong;               // Kurz- und Langname (PutDoc)
    String sBaseURL;                    // base URL - has to be set at the Readers and Writers
    SwBlockNames aNames;                // Liste aller Bausteine
    Date aDateModified;                 // fuers abgleichen bei den Aktionen
    Time aTimeModified;
    SwDoc* pDoc;                        // Austauschdokument
    USHORT nCur;                        // aktueller Index
    BOOL bReadOnly : 1;
    BOOL bInPutMuchBlocks : 1;          // put serveral block entries
    BOOL bInfoChanged : 1;              // any Info of TextBlock is changed

    SwImpBlocks( const String&, BOOL = FALSE );
    virtual ~SwImpBlocks();

    static short GetFileType( const String& );
    virtual short GetFileType() const = 0;
#define SWBLK_NO_FILE   0               // nicht da
#define SWBLK_NONE      1               // keine TB-Datei
#define SWBLK_SW2       2               // SW2-Datei
#define SWBLK_SW3       3               // SW3-Datei
#define SWBLK_XML       4               // XML Block List

    virtual void   ClearDoc();                  // Doc-Inhalt loeschen
    SwPaM* MakePaM();                   // PaM ueber Doc aufspannen
    virtual void   AddName( const String&, const String&, BOOL bOnlyTxt = FALSE );
    BOOL   IsFileChanged() const;
    void   Touch();

public:
    static USHORT Hash( const String& );        // Hashcode fuer Blocknamen
    USHORT GetCount() const;                    // Anzahl Textbausteine ermitteln
    USHORT GetIndex( const String& ) const;     // Index fuer Kurznamen ermitteln
    USHORT GetLongIndex( const String& ) const; //Index fuer Langnamen ermitteln
    const String& GetShortName( USHORT ) const; // Kurzname fuer Index zurueck
    const String& GetLongName( USHORT ) const;  // Langname fuer Index zurueck
    const String& GetPackageName( USHORT ) const;   // Langname fuer Index zurueck

    const String& GetFileName() const {return aFile;}   // phys. Dateinamen liefern
    void SetName( const String& rName )                 // logic name
        { aName = rName; bInfoChanged = TRUE; }
    const String & GetName( void )
        { return aName; }

    const String&       GetBaseURL() const { return sBaseURL;}
    void                SetBaseURL( const String& rURL ) { sBaseURL = rURL; }

    virtual ULONG Delete( USHORT ) = 0;
    virtual ULONG Rename( USHORT, const String&, const String& ) = 0;
    virtual ULONG CopyBlock( SwImpBlocks& rImp, String& rShort, const String& rLong) = 0;
    virtual ULONG GetDoc( USHORT ) = 0;
    virtual ULONG GetDocForConversion( USHORT );
    virtual ULONG BeginPutDoc( const String&, const String& ) = 0;
    virtual ULONG PutDoc() = 0;
    virtual ULONG GetText( USHORT, String& ) = 0;
    virtual ULONG PutText( const String&, const String&, const String& ) = 0;
    virtual ULONG MakeBlockList() = 0;

    virtual ULONG OpenFile( BOOL bReadOnly = TRUE ) = 0;
    virtual void  CloseFile() = 0;

    virtual BOOL IsOnlyTextBlock( const String& rShort ) const;

    virtual ULONG GetMacroTable( USHORT nIdx, SvxMacroTableDtor& rMacroTbl,
                                 sal_Bool bFileAlreadyOpen = sal_False );
    virtual ULONG SetMacroTable( USHORT nIdx,
                                 const SvxMacroTableDtor& rMacroTbl,
                                 sal_Bool bFileAlreadyOpen = sal_False );
    virtual BOOL PutMuchEntries( BOOL bOn );
};

/*
class Sw3Persist : public SvPersist
{
    virtual void FillClass( SvGlobalName * pClassName,
                            ULONG * pClipFormat,
                            String * pAppName,
                            String * pLongUserName,
                            String * pUserName,
                            sal_Int32 nFileFormat=SOFFICE_FILEFORMAT_CURRENT ) const;
    virtual BOOL Save();
    virtual BOOL SaveCompleted( SvStorage * );
public:
    Sw3Persist();
};

class SwSwgReader;

class Sw2TextBlocks : public SwImpBlocks
{
    SvPersistRef refPersist;            // Fuer OLE-Objekte
    SwSwgReader* pRdr;                  // Lese-Routinen
    SfxMedium* pMed;                    // der logische Input-Stream
    String* pText;                      // String fuer GetText()
    long   nDocStart;                   // Beginn des Doc-Records
    long   nDocSize;                    // Laenge des Doc-Records
    long   nStart;                      // Beginn des CONTENTS-Records
    long   nSize;                       // Laenge des CONTENTS-Records
    USHORT nNamedFmts;                  // benannte Formate
    USHORT nColls;                      // Text-Collections
    USHORT nBlks;                       // Anzahl Elemente im CONTENTS-Record
public:
    Sw2TextBlocks( const String& );
    virtual ~Sw2TextBlocks();
    virtual ULONG Delete( USHORT );
    virtual ULONG Rename( USHORT, const String&, const String& );
    virtual ULONG CopyBlock( SwImpBlocks& rImp, String& rShort, const String& rLong);
    virtual ULONG GetDoc( USHORT );
    virtual ULONG BeginPutDoc( const String&, const String& );
    virtual ULONG PutDoc();
    virtual ULONG GetText( USHORT, String& );
    virtual ULONG PutText( const String&, const String&, const String& );
    virtual ULONG MakeBlockList();
    virtual short GetFileType( ) const;
    ULONG LoadDoc();

    virtual ULONG OpenFile( BOOL bReadOnly = TRUE );
    virtual void  CloseFile();

    void StatLineStartPercent();                // zum Anzeigen des Prozessbars
};

class Sw3Io;
class Sw3IoImp;

class Sw3TextBlocks : public SwImpBlocks
{
    Sw3Io*       pIo3;
    Sw3IoImp*    pImp;
    BOOL         bAutocorrBlock;

public:
    Sw3TextBlocks( const String& );
    Sw3TextBlocks( SvStorage& );
    virtual ~Sw3TextBlocks();
    virtual ULONG Delete( USHORT );
    virtual ULONG Rename( USHORT, const String&, const String& );
    virtual ULONG CopyBlock( SwImpBlocks& rImp, String& rShort, const String& rLong);
    virtual ULONG GetDoc( USHORT );
    virtual ULONG GetDocForConversion( USHORT );
    virtual ULONG BeginPutDoc( const String&, const String& );
    virtual ULONG PutDoc();
    virtual void SetDoc( SwDoc * pNewDoc);
    virtual ULONG GetText( USHORT, String& );
    virtual ULONG PutText( const String&, const String&, const String& );
    virtual ULONG MakeBlockList();
    virtual short GetFileType( ) const;

    virtual ULONG OpenFile( BOOL bReadOnly = TRUE );
    virtual void  CloseFile();

    // Methoden fuer die neue Autokorrektur
    ULONG GetText( const String& rShort, String& );
    SwDoc* GetDoc() const { return pDoc; }

    virtual BOOL IsOnlyTextBlock( const String& rShort ) const;

    virtual ULONG GetMacroTable( USHORT, SvxMacroTableDtor& rMacroTbl,
                                 sal_Bool bFileAlreadyOpen = sal_False );
    virtual ULONG SetMacroTable( USHORT nIdx,
                                 const SvxMacroTableDtor& rMacroTbl,
                                 sal_Bool bFileAlreadyOpen = sal_False );

    void ReadInfo();
};
*/
#endif
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: instable.cxx,v $
 *
 *  $Revision: 1.10 $
 *
 *  last change: $Author: rt $ $Date: 2004-08-23 09:09:21 $
 *
 *  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): _______________________________________
 *
 *
 ************************************************************************/

#ifdef SW_DLLIMPLEMENTATION
#undef SW_DLLIMPLEMENTATION
#endif

#pragma hdrstop

#ifndef _SV_MSGBOX_HXX //autogen
#include <vcl/msgbox.hxx>
#endif

#include "wrtsh.hxx"
#include "view.hxx"
#include "itabenum.hxx"
#include "instable.hxx"
//CHINA001 #include "tautofmt.hxx"
#include "tblafmt.hxx"
#include "modcfg.hxx"
#include "swmodule.hxx"
#ifndef _SVX_HTMLMODE_HXX //autogen
#include <svx/htmlmode.hxx>
#endif
#ifndef _VIEWOPT_HXX
#include <viewopt.hxx>
#endif

#include "table.hrc"
#include "instable.hrc"

#include "swabstdlg.hxx" //CHINA001

namespace swui
{
    SwAbstractDialogFactory * GetFactory();
}

#define ROW_COL_PROD 16384

void SwInsTableDlg::GetValues( String& rName, USHORT& rRow, USHORT& rCol,
                                SwInsertTableOptions& rInsTblOpts, String& rAutoName,
                                SwTableAutoFmt *& prTAFmt )
{
    USHORT nInsMode = 0;
    rName = aNameEdit.GetText();
    rRow = (USHORT)aRowEdit.GetValue();
    rCol = (USHORT)aColEdit.GetValue();

    if (aBorderCB.IsChecked())
        nInsMode |= tabopts::DEFAULT_BORDER;
    if (aHeaderCB.IsChecked())
        nInsMode |= tabopts::HEADLINE;
    if (aRepeatHeaderCB.IsEnabled() && aRepeatHeaderCB.IsChecked())
        rInsTblOpts.mnRowsToRepeat = USHORT( aRepeatHeaderNF.GetValue() );
    else
        rInsTblOpts.mnRowsToRepeat = 0;
    if (!aDontSplitCB.IsChecked())
        nInsMode |= tabopts::SPLIT_LAYOUT;
    if( pTAutoFmt )
    {
        prTAFmt = new SwTableAutoFmt( *pTAutoFmt );
        rAutoName = prTAFmt->GetName();
    }

    rInsTblOpts.mnInsMode = nInsMode;
}

// CTOR / DTOR -----------------------------------------------------------

SwInsTableDlg::SwInsTableDlg( SwView& rView )
    : SfxModalDialog( rView.GetWindow(), SW_RES(DLG_INSERT_TABLE) ),
    aNameEdit               (this, SW_RES(ED_NAME)),
    aNameFT                 (this, SW_RES(FT_NAME)),
    aColLbl                 (this, SW_RES(FT_COL)),
    aColEdit                (this, SW_RES(ED_COL)),
    aRowLbl                 (this, SW_RES(FT_ROW)),
    aRowEdit                (this, SW_RES(ED_ROW)),
    aFL                     (this, SW_RES(FL_TABLE)),
    aHeaderCB               (this, SW_RES(CB_HEADER)),
    aRepeatHeaderCB         (this, SW_RES(CB_REPEAT_HEADER)),
    aRepeatHeaderFT         (this, SW_RES(FT_REPEAT_HEADER)),
    aRepeatHeaderBeforeFT   (this),
    aRepeatHeaderNF         (this, SW_RES(NF_REPEAT_HEADER)),
    aRepeatHeaderAfterFT    (this),
    aRepeatHeaderCombo      (this, SW_RES(WIN_REPEAT_HEADER), aRepeatHeaderNF, aRepeatHeaderBeforeFT, aRepeatHeaderAfterFT),
    aDontSplitCB            (this, SW_RES(CB_DONT_SPLIT)),
    aBorderCB               (this, SW_RES(CB_BORDER)),
    aOptionsFL              (this, SW_RES(FL_OPTIONS)),
    aOkBtn                  (this, SW_RES(BT_OK)),
    aCancelBtn              (this, SW_RES(BT_CANCEL)),
    aHelpBtn                (this, SW_RES(BT_HELP)),
    aAutoFmtBtn             (this, SW_RES(BT_AUTOFORMAT)),
    pTAutoFmt( 0 ),
    pShell(&rView.GetWrtShell()),
    nEnteredValRepeatHeaderNF( -1 )
{
    FreeResource();
    aNameEdit.SetText(pShell->GetUniqueTblName());
    aNameEdit.SetModifyHdl(LINK(this, SwInsTableDlg, ModifyName));
    aColEdit.SetModifyHdl(LINK(this, SwInsTableDlg, ModifyRowCol));
    aRowEdit.SetModifyHdl(LINK(this, SwInsTableDlg, ModifyRowCol));

    aRowEdit.SetMax(ROW_COL_PROD/aColEdit.GetValue());
    aColEdit.SetMax(ROW_COL_PROD/aRowEdit.GetValue());
    aAutoFmtBtn.SetClickHdl(LINK(this, SwInsTableDlg, AutoFmtHdl));

    BOOL bHTMLMode = 0 != (::GetHtmlMode(rView.GetDocShell())&HTMLMODE_ON);
    const SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();

    SwInsertTableOptions aInsOpts = pModOpt->GetInsTblFlags(bHTMLMode);
    USHORT nInsTblFlags = aInsOpts.mnInsMode;

    aHeaderCB.Check(nInsTblFlags & tabopts::HEADLINE);
    aRepeatHeaderCB.Check(aInsOpts.mnRowsToRepeat > 0);
    if(bHTMLMode)
    {
        aDontSplitCB.Hide();
        aBorderCB.SetPosPixel(aDontSplitCB.GetPosPixel());
    }
    else
    {
        aDontSplitCB.Check(!(nInsTblFlags & tabopts::SPLIT_LAYOUT));
    }
    aBorderCB.Check(nInsTblFlags & tabopts::DEFAULT_BORDER);

    aRepeatHeaderNF.SetModifyHdl( LINK( this, SwInsTableDlg, ModifyRepeatHeaderNF_Hdl ) );
    aHeaderCB.SetClickHdl(LINK(this, SwInsTableDlg, CheckBoxHdl));
    aRepeatHeaderCB.SetClickHdl(LINK(this, SwInsTableDlg, ReapeatHeaderCheckBoxHdl));
    ReapeatHeaderCheckBoxHdl();
    CheckBoxHdl();

    long nMax = aRowEdit.GetValue();
    if( nMax <= 1 )
        nMax = 1;
    else
        --nMax;
    aRepeatHeaderNF.SetMax( nMax );

    aRepeatHeaderCombo.Arrange( aRepeatHeaderFT );
}

SwInsTableDlg::~SwInsTableDlg()
{
    delete pTAutoFmt;
}

IMPL_LINK_INLINE_START( SwInsTableDlg, ModifyName, Edit *, pEdit )
{
    String sTblName = pEdit->GetText();
    if(sTblName.Search(' ') != STRING_NOTFOUND)
    {
        sTblName.EraseAllChars( );
        pEdit->SetText(sTblName);
    }

    aOkBtn.Enable(pShell->GetTblStyle( sTblName ) == 0);
    return 0;
}
IMPL_LINK_INLINE_END( SwInsTableDlg, ModifyName, Edit *, EMPTYARG )

/*-----------------15.04.98 11:36-------------------

--------------------------------------------------*/
IMPL_LINK( SwInsTableDlg, ModifyRowCol, NumericField *, pField )
{
    if(pField == &aColEdit)
    {
        long nCol = aColEdit.GetValue();
        if(!nCol)
            nCol = 1;
        aRowEdit.SetMax(ROW_COL_PROD/nCol);
    }
    else
    {
        long nRow = aRowEdit.GetValue();
        if(!nRow)
            nRow = 1;
        aColEdit.SetMax(ROW_COL_PROD/nRow);

        // adjust depending NF for repeated rows
        long nMax = ( nRow == 1 )? 1 : nRow - 1 ;
        long nActVal = aRepeatHeaderNF.GetValue();

        aRepeatHeaderNF.SetMax( nMax );

        if( nActVal > nMax )
            aRepeatHeaderNF.SetValue( nMax );
        else if( nActVal < nEnteredValRepeatHeaderNF )
            aRepeatHeaderNF.SetValue( ( nEnteredValRepeatHeaderNF < nMax )? nEnteredValRepeatHeaderNF : nMax );
    }
    return 0;
}

IMPL_LINK( SwInsTableDlg, AutoFmtHdl, PushButton*, pButton )
{
    //CHINA001 SwAutoFormatDlg aDlg( pButton, pShell, FALSE, pTAutoFmt );
    SwAbstractDialogFactory* pFact = swui::GetFactory();//CHINA001
    DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");//CHINA001

    AbstractSwAutoFormatDlg* pDlg = pFact->CreateSwAutoFormatDlg(pButton,pShell,ResId( DLG_AUTOFMT_TABLE ), FALSE, pTAutoFmt );
    DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
    if( RET_OK == pDlg->Execute()) //CHINA001  if( RET_OK == aDlg.Execute())
        pDlg->FillAutoFmtOfIndex( pTAutoFmt ); //CHINA001 aDlg.FillAutoFmtOfIndex( pTAutoFmt );
    delete pDlg; //CHINA001
    return 0;
}

IMPL_LINK(SwInsTableDlg, CheckBoxHdl, CheckBox*, EMPTYARG)
{
    aRepeatHeaderCB.Enable(aHeaderCB.IsChecked());
    ReapeatHeaderCheckBoxHdl();

    return 0;
}

IMPL_LINK(SwInsTableDlg, ReapeatHeaderCheckBoxHdl, void*, EMPTYARG)
{
    aRepeatHeaderCombo.Enable(aHeaderCB.IsChecked() && aRepeatHeaderCB.IsChecked());

    return 0;
}

IMPL_LINK(SwInsTableDlg, ModifyRepeatHeaderNF_Hdl, void*, EMPTYARG)
{
    nEnteredValRepeatHeaderNF = aRepeatHeaderNF.GetValue();
    return 0;
}

<commit_msg>INTEGRATION: CWS ooo19126 (1.10.596); FILE MERGED 2005/09/05 13:47:24 rt 1.10.596.1: #i54170# Change license header: remove SISSL<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: instable.cxx,v $
 *
 *  $Revision: 1.11 $
 *
 *  last change: $Author: rt $ $Date: 2005-09-09 10:59:33 $
 *
 *  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
 *
 ************************************************************************/

#ifdef SW_DLLIMPLEMENTATION
#undef SW_DLLIMPLEMENTATION
#endif

#pragma hdrstop

#ifndef _SV_MSGBOX_HXX //autogen
#include <vcl/msgbox.hxx>
#endif

#include "wrtsh.hxx"
#include "view.hxx"
#include "itabenum.hxx"
#include "instable.hxx"
//CHINA001 #include "tautofmt.hxx"
#include "tblafmt.hxx"
#include "modcfg.hxx"
#include "swmodule.hxx"
#ifndef _SVX_HTMLMODE_HXX //autogen
#include <svx/htmlmode.hxx>
#endif
#ifndef _VIEWOPT_HXX
#include <viewopt.hxx>
#endif

#include "table.hrc"
#include "instable.hrc"

#include "swabstdlg.hxx" //CHINA001

namespace swui
{
    SwAbstractDialogFactory * GetFactory();
}

#define ROW_COL_PROD 16384

void SwInsTableDlg::GetValues( String& rName, USHORT& rRow, USHORT& rCol,
                                SwInsertTableOptions& rInsTblOpts, String& rAutoName,
                                SwTableAutoFmt *& prTAFmt )
{
    USHORT nInsMode = 0;
    rName = aNameEdit.GetText();
    rRow = (USHORT)aRowEdit.GetValue();
    rCol = (USHORT)aColEdit.GetValue();

    if (aBorderCB.IsChecked())
        nInsMode |= tabopts::DEFAULT_BORDER;
    if (aHeaderCB.IsChecked())
        nInsMode |= tabopts::HEADLINE;
    if (aRepeatHeaderCB.IsEnabled() && aRepeatHeaderCB.IsChecked())
        rInsTblOpts.mnRowsToRepeat = USHORT( aRepeatHeaderNF.GetValue() );
    else
        rInsTblOpts.mnRowsToRepeat = 0;
    if (!aDontSplitCB.IsChecked())
        nInsMode |= tabopts::SPLIT_LAYOUT;
    if( pTAutoFmt )
    {
        prTAFmt = new SwTableAutoFmt( *pTAutoFmt );
        rAutoName = prTAFmt->GetName();
    }

    rInsTblOpts.mnInsMode = nInsMode;
}

// CTOR / DTOR -----------------------------------------------------------

SwInsTableDlg::SwInsTableDlg( SwView& rView )
    : SfxModalDialog( rView.GetWindow(), SW_RES(DLG_INSERT_TABLE) ),
    aNameEdit               (this, SW_RES(ED_NAME)),
    aNameFT                 (this, SW_RES(FT_NAME)),
    aColLbl                 (this, SW_RES(FT_COL)),
    aColEdit                (this, SW_RES(ED_COL)),
    aRowLbl                 (this, SW_RES(FT_ROW)),
    aRowEdit                (this, SW_RES(ED_ROW)),
    aFL                     (this, SW_RES(FL_TABLE)),
    aHeaderCB               (this, SW_RES(CB_HEADER)),
    aRepeatHeaderCB         (this, SW_RES(CB_REPEAT_HEADER)),
    aRepeatHeaderFT         (this, SW_RES(FT_REPEAT_HEADER)),
    aRepeatHeaderBeforeFT   (this),
    aRepeatHeaderNF         (this, SW_RES(NF_REPEAT_HEADER)),
    aRepeatHeaderAfterFT    (this),
    aRepeatHeaderCombo      (this, SW_RES(WIN_REPEAT_HEADER), aRepeatHeaderNF, aRepeatHeaderBeforeFT, aRepeatHeaderAfterFT),
    aDontSplitCB            (this, SW_RES(CB_DONT_SPLIT)),
    aBorderCB               (this, SW_RES(CB_BORDER)),
    aOptionsFL              (this, SW_RES(FL_OPTIONS)),
    aOkBtn                  (this, SW_RES(BT_OK)),
    aCancelBtn              (this, SW_RES(BT_CANCEL)),
    aHelpBtn                (this, SW_RES(BT_HELP)),
    aAutoFmtBtn             (this, SW_RES(BT_AUTOFORMAT)),
    pTAutoFmt( 0 ),
    pShell(&rView.GetWrtShell()),
    nEnteredValRepeatHeaderNF( -1 )
{
    FreeResource();
    aNameEdit.SetText(pShell->GetUniqueTblName());
    aNameEdit.SetModifyHdl(LINK(this, SwInsTableDlg, ModifyName));
    aColEdit.SetModifyHdl(LINK(this, SwInsTableDlg, ModifyRowCol));
    aRowEdit.SetModifyHdl(LINK(this, SwInsTableDlg, ModifyRowCol));

    aRowEdit.SetMax(ROW_COL_PROD/aColEdit.GetValue());
    aColEdit.SetMax(ROW_COL_PROD/aRowEdit.GetValue());
    aAutoFmtBtn.SetClickHdl(LINK(this, SwInsTableDlg, AutoFmtHdl));

    BOOL bHTMLMode = 0 != (::GetHtmlMode(rView.GetDocShell())&HTMLMODE_ON);
    const SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();

    SwInsertTableOptions aInsOpts = pModOpt->GetInsTblFlags(bHTMLMode);
    USHORT nInsTblFlags = aInsOpts.mnInsMode;

    aHeaderCB.Check(nInsTblFlags & tabopts::HEADLINE);
    aRepeatHeaderCB.Check(aInsOpts.mnRowsToRepeat > 0);
    if(bHTMLMode)
    {
        aDontSplitCB.Hide();
        aBorderCB.SetPosPixel(aDontSplitCB.GetPosPixel());
    }
    else
    {
        aDontSplitCB.Check(!(nInsTblFlags & tabopts::SPLIT_LAYOUT));
    }
    aBorderCB.Check(nInsTblFlags & tabopts::DEFAULT_BORDER);

    aRepeatHeaderNF.SetModifyHdl( LINK( this, SwInsTableDlg, ModifyRepeatHeaderNF_Hdl ) );
    aHeaderCB.SetClickHdl(LINK(this, SwInsTableDlg, CheckBoxHdl));
    aRepeatHeaderCB.SetClickHdl(LINK(this, SwInsTableDlg, ReapeatHeaderCheckBoxHdl));
    ReapeatHeaderCheckBoxHdl();
    CheckBoxHdl();

    long nMax = aRowEdit.GetValue();
    if( nMax <= 1 )
        nMax = 1;
    else
        --nMax;
    aRepeatHeaderNF.SetMax( nMax );

    aRepeatHeaderCombo.Arrange( aRepeatHeaderFT );
}

SwInsTableDlg::~SwInsTableDlg()
{
    delete pTAutoFmt;
}

IMPL_LINK_INLINE_START( SwInsTableDlg, ModifyName, Edit *, pEdit )
{
    String sTblName = pEdit->GetText();
    if(sTblName.Search(' ') != STRING_NOTFOUND)
    {
        sTblName.EraseAllChars( );
        pEdit->SetText(sTblName);
    }

    aOkBtn.Enable(pShell->GetTblStyle( sTblName ) == 0);
    return 0;
}
IMPL_LINK_INLINE_END( SwInsTableDlg, ModifyName, Edit *, EMPTYARG )

/*-----------------15.04.98 11:36-------------------

--------------------------------------------------*/
IMPL_LINK( SwInsTableDlg, ModifyRowCol, NumericField *, pField )
{
    if(pField == &aColEdit)
    {
        long nCol = aColEdit.GetValue();
        if(!nCol)
            nCol = 1;
        aRowEdit.SetMax(ROW_COL_PROD/nCol);
    }
    else
    {
        long nRow = aRowEdit.GetValue();
        if(!nRow)
            nRow = 1;
        aColEdit.SetMax(ROW_COL_PROD/nRow);

        // adjust depending NF for repeated rows
        long nMax = ( nRow == 1 )? 1 : nRow - 1 ;
        long nActVal = aRepeatHeaderNF.GetValue();

        aRepeatHeaderNF.SetMax( nMax );

        if( nActVal > nMax )
            aRepeatHeaderNF.SetValue( nMax );
        else if( nActVal < nEnteredValRepeatHeaderNF )
            aRepeatHeaderNF.SetValue( ( nEnteredValRepeatHeaderNF < nMax )? nEnteredValRepeatHeaderNF : nMax );
    }
    return 0;
}

IMPL_LINK( SwInsTableDlg, AutoFmtHdl, PushButton*, pButton )
{
    //CHINA001 SwAutoFormatDlg aDlg( pButton, pShell, FALSE, pTAutoFmt );
    SwAbstractDialogFactory* pFact = swui::GetFactory();//CHINA001
    DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");//CHINA001

    AbstractSwAutoFormatDlg* pDlg = pFact->CreateSwAutoFormatDlg(pButton,pShell,ResId( DLG_AUTOFMT_TABLE ), FALSE, pTAutoFmt );
    DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
    if( RET_OK == pDlg->Execute()) //CHINA001  if( RET_OK == aDlg.Execute())
        pDlg->FillAutoFmtOfIndex( pTAutoFmt ); //CHINA001 aDlg.FillAutoFmtOfIndex( pTAutoFmt );
    delete pDlg; //CHINA001
    return 0;
}

IMPL_LINK(SwInsTableDlg, CheckBoxHdl, CheckBox*, EMPTYARG)
{
    aRepeatHeaderCB.Enable(aHeaderCB.IsChecked());
    ReapeatHeaderCheckBoxHdl();

    return 0;
}

IMPL_LINK(SwInsTableDlg, ReapeatHeaderCheckBoxHdl, void*, EMPTYARG)
{
    aRepeatHeaderCombo.Enable(aHeaderCB.IsChecked() && aRepeatHeaderCB.IsChecked());

    return 0;
}

IMPL_LINK(SwInsTableDlg, ModifyRepeatHeaderNF_Hdl, void*, EMPTYARG)
{
    nEnteredValRepeatHeaderNF = aRepeatHeaderNF.GetValue();
    return 0;
}

<|endoftext|>