<commit_before>#include <nan.h>

// toys used in testing
#include <cmath>
#include <time.h>

//==============================================================================
// Implementation sketch
//==============================================================================

namespace NanIntern { // scnr

// TODO: Generalize
template <typename T> v8::Local<T> To(v8::Handle<v8::Integer> i);

template <>
v8::Local<v8::Integer>
To<v8::Integer>(v8::Handle<v8::Integer> i) { return i->ToInteger(); }

template <>
v8::Local<v8::Int32>
To<v8::Int32>(v8::Handle<v8::Integer> i)   { return i->ToInt32(); }

template <>
v8::Local<v8::Uint32>
To<v8::Uint32>(v8::Handle<v8::Integer> i)  { return i->ToUint32(); }

template <typename T> struct FactoryBase { typedef v8::Local<T> return_t; };

template <typename T> struct Factory;

template <>
struct Factory<v8::Array> : public FactoryBase<v8::Array> {
  static inline return_t New();
  static inline return_t New(int length);
};

template <>
struct Factory<v8::Boolean> : public FactoryBase<v8::Boolean> {
  static inline return_t New(bool value);
};

template <>
struct Factory<v8::External> : public FactoryBase<v8::External> {
  static inline return_t New(void *value);
};

template <>
struct Factory<v8::Date> : public FactoryBase<v8::Date> {
  static inline return_t New(double value);
};

template <>
struct Factory<v8::String> : public FactoryBase<v8::String> {
  static inline return_t New(const char *value);
  static inline return_t New(const char *value, int length);
  static inline return_t New(std::string const& value);
};

//=== Numeric Types ============================================================

template <>
struct Factory<v8::Number> : public FactoryBase<v8::Number> {
  static inline return_t New(double value);
};

template <typename T>
struct IntegerFactory : public FactoryBase<T>{
  typedef typename FactoryBase<T>::return_t return_t;
  static inline return_t New(int32_t value);
  static inline return_t New(uint32_t value);
};

template <>
struct Factory<v8::Integer> : public IntegerFactory<v8::Integer> {};

template <>
struct Factory<v8::Int32> : public IntegerFactory<v8::Int32> {};

template <>
struct Factory<v8::Uint32> : public IntegerFactory<v8::Uint32> {};

} // end of namespace NanIntern

#if (NODE_MODULE_VERSION < 12)
# include "nan_implementation_pre_12.inl"
#else
# include "nan_implementation_12.inl"
#endif

//=== API ======================================================================

template <typename T>
typename NanIntern::Factory<T>::return_t
NanNew2() {
  return NanIntern::Factory<T>::New();
}

template <typename T, typename A0>
typename NanIntern::Factory<T>::return_t
NanNew2(A0 arg0) {
  return NanIntern::Factory<T>::New(arg0);
}

template <typename T, typename A0, typename A1>
typename NanIntern::Factory<T>::return_t
NanNew2(A0 arg0, A1 arg1) {
  return NanIntern::Factory<T>::New(arg0, arg1);
}

void
NanExport(v8::Handle<v8::Object> target, const char * name,
    NanFunctionCallback f)
{
  target->Set(NanNew<v8::String>(name),
      NanNew<v8::FunctionTemplate>(f)->GetFunction());
}

#define return_NanValue(v) NanReturnValue(v)
#define NAN_EXPORT(target, function) NanExport(target, #function, function)

//==============================================================================
// Sample Module
//==============================================================================

NAN_METHOD(newIntegerWithValue) {
  NanScope();
  return_NanValue(NanNew2<v8::Integer>(args[0]->Int32Value()));
}

NAN_METHOD(newNumberWithValue) {
  NanScope();
  return_NanValue(NanNew2<v8::Number>(args[0]->NumberValue()));
}

NAN_METHOD(newUint32WithValue) {
  NanScope();
  return_NanValue(NanNew2<v8::Uint32>(args[0]->Uint32Value()));
}

NAN_METHOD(newStringFromChars) {
  NanScope();
  return_NanValue(NanNew2<v8::String>("hello?"));
}

NAN_METHOD(newStringFromCharsWithLength) {
  NanScope();
  return_NanValue(NanNew2<v8::String>("hello?", 4));
}

NAN_METHOD(newStringFromStdString) {
  NanScope();
  return_NanValue(NanNew2<v8::String>(std::string("hello!")));
}

NAN_METHOD(demoDateAndNumber) {
  NanScope();
  v8::Local<v8::Value> number = NanNew<v8::Number>(M_PI);
  v8::Local<v8::Value> date   = NanNew<v8::Date>(double(time(NULL)));
  (void)number; (void)date; // unused
  NanReturnUndefined();
}

int ttt = 23;

NAN_METHOD(newExternal) {
  NanScope();
  return_NanValue(NanNew2<v8::External>(&ttt));
}
void Init(v8::Handle<v8::Object> exports) {
  NanExport(exports, "newIntegerWithValue", newIntegerWithValue);
  NAN_EXPORT(exports, newNumberWithValue);
  NAN_EXPORT(exports, newUint32WithValue);
  NAN_EXPORT(exports, newStringFromChars);
  NAN_EXPORT(exports, newStringFromCharsWithLength);
  NAN_EXPORT(exports, newStringFromStdString);
  NAN_EXPORT(exports, demoDateAndNumber);

  NAN_EXPORT(exports, newExternal);
}

NODE_MODULE(nan_sketch, Init)

<commit_msg>Tell windows about π.<commit_after>#include <nan.h>

// toys used in testing
#ifdef _WIN32
# define _USE_MATH_DEFINES
#endif
#include <cmath>
#include <time.h>

//==============================================================================
// Implementation sketch
//==============================================================================

namespace NanIntern { // scnr

// TODO: Generalize
template <typename T> v8::Local<T> To(v8::Handle<v8::Integer> i);

template <>
v8::Local<v8::Integer>
To<v8::Integer>(v8::Handle<v8::Integer> i) { return i->ToInteger(); }

template <>
v8::Local<v8::Int32>
To<v8::Int32>(v8::Handle<v8::Integer> i)   { return i->ToInt32(); }

template <>
v8::Local<v8::Uint32>
To<v8::Uint32>(v8::Handle<v8::Integer> i)  { return i->ToUint32(); }

template <typename T> struct FactoryBase { typedef v8::Local<T> return_t; };

template <typename T> struct Factory;

template <>
struct Factory<v8::Array> : public FactoryBase<v8::Array> {
  static inline return_t New();
  static inline return_t New(int length);
};

template <>
struct Factory<v8::Boolean> : public FactoryBase<v8::Boolean> {
  static inline return_t New(bool value);
};

template <>
struct Factory<v8::External> : public FactoryBase<v8::External> {
  static inline return_t New(void *value);
};

template <>
struct Factory<v8::Date> : public FactoryBase<v8::Date> {
  static inline return_t New(double value);
};

template <>
struct Factory<v8::String> : public FactoryBase<v8::String> {
  static inline return_t New(const char *value);
  static inline return_t New(const char *value, int length);
  static inline return_t New(std::string const& value);
};

//=== Numeric Types ============================================================

template <>
struct Factory<v8::Number> : public FactoryBase<v8::Number> {
  static inline return_t New(double value);
};

template <typename T>
struct IntegerFactory : public FactoryBase<T>{
  typedef typename FactoryBase<T>::return_t return_t;
  static inline return_t New(int32_t value);
  static inline return_t New(uint32_t value);
};

template <>
struct Factory<v8::Integer> : public IntegerFactory<v8::Integer> {};

template <>
struct Factory<v8::Int32> : public IntegerFactory<v8::Int32> {};

template <>
struct Factory<v8::Uint32> : public IntegerFactory<v8::Uint32> {};

} // end of namespace NanIntern

#if (NODE_MODULE_VERSION < 12)
# include "nan_implementation_pre_12.inl"
#else
# include "nan_implementation_12.inl"
#endif

//=== API ======================================================================

template <typename T>
typename NanIntern::Factory<T>::return_t
NanNew2() {
  return NanIntern::Factory<T>::New();
}

template <typename T, typename A0>
typename NanIntern::Factory<T>::return_t
NanNew2(A0 arg0) {
  return NanIntern::Factory<T>::New(arg0);
}

template <typename T, typename A0, typename A1>
typename NanIntern::Factory<T>::return_t
NanNew2(A0 arg0, A1 arg1) {
  return NanIntern::Factory<T>::New(arg0, arg1);
}

void
NanExport(v8::Handle<v8::Object> target, const char * name,
    NanFunctionCallback f)
{
  target->Set(NanNew<v8::String>(name),
      NanNew<v8::FunctionTemplate>(f)->GetFunction());
}

#define return_NanValue(v) NanReturnValue(v)
#define NAN_EXPORT(target, function) NanExport(target, #function, function)

//==============================================================================
// Sample Module
//==============================================================================

NAN_METHOD(newIntegerWithValue) {
  NanScope();
  return_NanValue(NanNew2<v8::Integer>(args[0]->Int32Value()));
}

NAN_METHOD(newNumberWithValue) {
  NanScope();
  return_NanValue(NanNew2<v8::Number>(args[0]->NumberValue()));
}

NAN_METHOD(newUint32WithValue) {
  NanScope();
  return_NanValue(NanNew2<v8::Uint32>(args[0]->Uint32Value()));
}

NAN_METHOD(newStringFromChars) {
  NanScope();
  return_NanValue(NanNew2<v8::String>("hello?"));
}

NAN_METHOD(newStringFromCharsWithLength) {
  NanScope();
  return_NanValue(NanNew2<v8::String>("hello?", 4));
}

NAN_METHOD(newStringFromStdString) {
  NanScope();
  return_NanValue(NanNew2<v8::String>(std::string("hello!")));
}

NAN_METHOD(demoDateAndNumber) {
  NanScope();
  v8::Local<v8::Value> number = NanNew<v8::Number>(M_PI);
  v8::Local<v8::Value> date   = NanNew<v8::Date>(double(time(NULL)));
  (void)number; (void)date; // unused
  NanReturnUndefined();
}

int ttt = 23;

NAN_METHOD(newExternal) {
  NanScope();
  return_NanValue(NanNew2<v8::External>(&ttt));
}
void Init(v8::Handle<v8::Object> exports) {
  NanExport(exports, "newIntegerWithValue", newIntegerWithValue);
  NAN_EXPORT(exports, newNumberWithValue);
  NAN_EXPORT(exports, newUint32WithValue);
  NAN_EXPORT(exports, newStringFromChars);
  NAN_EXPORT(exports, newStringFromCharsWithLength);
  NAN_EXPORT(exports, newStringFromStdString);
  NAN_EXPORT(exports, demoDateAndNumber);

  NAN_EXPORT(exports, newExternal);
}

NODE_MODULE(nan_sketch, Init)

<|endoftext|>


<commit_before>/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#ifndef INCLUDED_FILTER_SOURCE_GRAPHICFILTER_IPICT_HXX
#define INCLUDED_FILTER_SOURCE_GRAPHICFILTER_IPICT_HXX

#include <sal/config.h>
#include <sal/types.h>

class GDIMetaFile;
class SvStream;

namespace pict {

/// Function to access PictReader::ReadPict for unit testing.
void ReadPictFile(SvStream &rStreamPict, GDIMetaFile& rGDIMetaFile);

}

#endif // INCLUDED_FILTER_SOURCE_GRAPHICFILTER_IPICT_HXX

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
<commit_msg>Unnecessary #include<commit_after>/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#ifndef INCLUDED_FILTER_SOURCE_GRAPHICFILTER_IPICT_HXX
#define INCLUDED_FILTER_SOURCE_GRAPHICFILTER_IPICT_HXX

#include <sal/config.h>

class GDIMetaFile;
class SvStream;

namespace pict {

/// Function to access PictReader::ReadPict for unit testing.
void ReadPictFile(SvStream &rStreamPict, GDIMetaFile& rGDIMetaFile);

}

#endif // INCLUDED_FILTER_SOURCE_GRAPHICFILTER_IPICT_HXX

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
<|endoftext|>


<commit_before>#include <string.h>

#include <command.h>
#include <main.h>

int main (int argc, char **argv) {
	if (argc == 2) {
		if (strcmp(argv[1], "--vanilla") == 0 ||
			strcmp(argv[1], "-v") == 0)
			USRINTERFACE::instance(CLTMODE);
		else if (	strcmp(argv[1], "--test") == 0 ||
					strcmp(argv[1], "-t") == 0)
			USRINTERFACE::instance(TSTMODE | CLTMODE);
	}
	while (true) {
		try {
			USRINTERFACE::instance()->Run();
		}
		catch (INITMODES state) {
			if (state & QUIT_APP) {
				delete USRINTERFACE::instance();
				return 0;
			}
			USRINTERFACE::instance(state);
		}
	}
}
<commit_msg>Mode switcher on main now defined to no-stub modes<commit_after>// C++ Libs
///////////
#include <stdexcept>
#include <iostream>
using namespace std;

// ANSI C Libs
//////////////
#include <string.h>

// Local Libs
/////////////
#include <command.h>
#include <main.h>

#define	ctab	"\t"

int main (int argc, char **argv) {
	try {
		if (argc == 2) {
			if (strcmp(argv[1], "vanilla") == 0)
				USRINTERFACE::instance(CLTMODE);
			else if (strcmp(argv[1], "test") == 0)
				USRINTERFACE::instance(TSTMODE | CLTMODE);
		}
	}
	catch (INITMODES state) {
		if (state & QUIT_APP) {
			delete USRINTERFACE::instance();
			return 0;
		}
		USRINTERFACE::instance(state);
	}
	catch (invalid_argument error) {
		cout << ctab << error.what();
		getchar();
		return 0;
	}

	while (true) {
		try {
			USRINTERFACE::instance()->Run();
		}
		catch (INITMODES state) {
			if (state & QUIT_APP) {
				delete USRINTERFACE::instance();
				return 0;
			}
			USRINTERFACE::instance(state);
		}
		catch (invalid_argument error) {
			cout << ctab << error.what();
			delete USRINTERFACE::instance();
		}
	}
}
<|endoftext|>


<commit_before><commit_msg>Generate shape-independent graph if any input dimension < 2 (#6581)<commit_after><|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: FPentry.cxx,v $
 *
 *  $Revision: 1.5 $
 *
 *  last change: $Author: ihi $ $Date: 2007-11-19 16:25:55 $
 *
 *  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_fpicker.hxx"

//----------------------------------------------
//  includes of other projects
//----------------------------------------------

#ifndef _CPPUHELPER_FACTORY_HXX_
#include <cppuhelper/factory.hxx>
#endif

#ifndef _COM_SUN_STAR_CONTAINER_XSET_HPP_
#include <com/sun/star/container/XSet.hpp>
#endif

#ifndef _OSL_DIAGNOSE_H_
#include <osl/diagnose.h>
#endif

#ifndef _FILEPICKER_HXX_
#include "FilePicker.hxx"
#endif

#ifndef _FPSERVICEINFO_HXX_
#include "FPServiceInfo.hxx"
#endif

//-----------------------------------------------
// namespace directives
//-----------------------------------------------

using namespace ::rtl                       ;
using namespace ::com::sun::star::uno       ;
using namespace ::com::sun::star::container ;
using namespace ::com::sun::star::lang      ;
using namespace ::com::sun::star::registry  ;
using namespace ::cppu                      ;
using ::com::sun::star::ui::dialogs::XFilePicker;
using ::com::sun::star::ui::dialogs::XFilePicker2;

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

static Reference< XInterface > SAL_CALL createInstance(
    const Reference< XMultiServiceFactory >& rServiceManager )
{
    return Reference< XInterface >(
        static_cast< XFilePicker2* >(
            new CFilePicker( rServiceManager ) ) );
}

//------------------------------------------------
// the three uno functions that will be exported
//------------------------------------------------

extern "C"
{

//------------------------------------------------
// component_getImplementationEnvironment
//------------------------------------------------

void SAL_CALL component_getImplementationEnvironment(
    const sal_Char ** ppEnvTypeName, uno_Environment ** )
{
    *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
}

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

sal_Bool SAL_CALL component_writeInfo( void*, void* pRegistryKey )
{
    sal_Bool bRetVal = sal_True;

    if ( pRegistryKey )
    {
        try
        {
            Reference< XRegistryKey > pXNewKey( static_cast< XRegistryKey* >( pRegistryKey ) );
            pXNewKey->createKey( OUString::createFromAscii( FILE_PICKER_REGKEY_NAME ) );
        }
        catch( InvalidRegistryException& )
        {
            OSL_ENSURE( sal_False, "InvalidRegistryException caught" );
            bRetVal = sal_False;
        }
    }

    return bRetVal;
}

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

void* SAL_CALL component_getFactory(
    const sal_Char* pImplName, uno_Interface* pSrvManager, uno_Interface* )
{
    void* pRet = 0;

    if ( pSrvManager && ( 0 == rtl_str_compare( pImplName, FILE_PICKER_IMPL_NAME ) ) )
    {
        Sequence< OUString > aSNS( 1 );
        aSNS.getArray( )[0] = OUString::createFromAscii( FILE_PICKER_SERVICE_NAME );

        Reference< XSingleServiceFactory > xFactory ( createSingleFactory(
            reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ),
            OUString::createFromAscii( pImplName ),
            createInstance,
            aSNS ) );
        if ( xFactory.is() )
        {
            xFactory->acquire();
            pRet = xFactory.get();
        }
    }

    return pRet;
}

} // extern "C"
<commit_msg>INTEGRATION: CWS hro34 (1.5.42); FILE MERGED 2008/03/07 10:38:14 hro 1.5.42.1: #i78851# #i72556# Implemented Vista style File Dialog<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: FPentry.cxx,v $
 *
 *  $Revision: 1.6 $
 *
 *  last change: $Author: rt $ $Date: 2008-03-12 07:31:09 $
 *
 *  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_fpicker.hxx"

//----------------------------------------------
//  includes of other projects
//----------------------------------------------

#ifndef _CPPUHELPER_FACTORY_HXX_
#include <cppuhelper/factory.hxx>
#endif

#ifndef _COM_SUN_STAR_CONTAINER_XSET_HPP_
#include <com/sun/star/container/XSet.hpp>
#endif

#ifndef _OSL_DIAGNOSE_H_
#include <osl/diagnose.h>
#endif

#ifndef _FILEPICKER_HXX_
#include "FilePicker.hxx"
#endif

#ifndef _FPSERVICEINFO_HXX_
#include "FPServiceInfo.hxx"
#endif

#pragma warning (disable:4917)
#include "VistaFilePicker.hxx"
#include "..\misc\WinImplHelper.hxx"
#include <stdio.h>

//-----------------------------------------------
// namespace directives
//-----------------------------------------------

using namespace ::rtl                       ;
using namespace ::com::sun::star::uno       ;
using namespace ::com::sun::star::container ;
using namespace ::com::sun::star::lang      ;
using namespace ::com::sun::star::registry  ;
using namespace ::cppu                      ;
using ::com::sun::star::ui::dialogs::XFilePicker;
using ::com::sun::star::ui::dialogs::XFilePicker2;

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

static Reference< XInterface > SAL_CALL createInstance(
    const Reference< XMultiServiceFactory >& rServiceManager )
{
    Reference< XInterface > xDlg;
    bool                    bVista = IsWindowsVista();

    if (bVista)
    {
        fprintf(stdout, "use special (vista) system file picker ...\n");
        xDlg.set(
            static_cast< XFilePicker2* >(
                new ::fpicker::win32::vista::VistaFilePicker( rServiceManager ) ) );
    }
    else
    {
        fprintf(stdout, "use normal system file picker ...\n");
        xDlg.set(
            static_cast< XFilePicker2* >(
                new CFilePicker( rServiceManager ) ) );
    }

    return xDlg;
}

//------------------------------------------------
// the three uno functions that will be exported
//------------------------------------------------

extern "C"
{

//------------------------------------------------
// component_getImplementationEnvironment
//------------------------------------------------

void SAL_CALL component_getImplementationEnvironment(
    const sal_Char ** ppEnvTypeName, uno_Environment ** )
{
    *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
}

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

sal_Bool SAL_CALL component_writeInfo( void*, void* pRegistryKey )
{
    sal_Bool bRetVal = sal_True;

    if ( pRegistryKey )
    {
        try
        {
            Reference< XRegistryKey > pXNewKey( static_cast< XRegistryKey* >( pRegistryKey ) );
            pXNewKey->createKey( OUString::createFromAscii( FILE_PICKER_REGKEY_NAME ) );
        }
        catch( InvalidRegistryException& )
        {
            OSL_ENSURE( sal_False, "InvalidRegistryException caught" );
            bRetVal = sal_False;
        }
    }

    return bRetVal;
}

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

void* SAL_CALL component_getFactory(
    const sal_Char* pImplName, uno_Interface* pSrvManager, uno_Interface* )
{
    void* pRet = 0;

    if ( pSrvManager && ( 0 == rtl_str_compare( pImplName, FILE_PICKER_IMPL_NAME ) ) )
    {
        Sequence< OUString > aSNS( 1 );
        aSNS.getArray( )[0] = OUString::createFromAscii( FILE_PICKER_SERVICE_NAME );

        Reference< XSingleServiceFactory > xFactory ( createSingleFactory(
            reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ),
            OUString::createFromAscii( pImplName ),
            createInstance,
            aSNS ) );
        if ( xFactory.is() )
        {
            xFactory->acquire();
            pRet = xFactory.get();
        }
    }

    return pRet;
}

} // extern "C"
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: resetableguard.hxx,v $
 *
 *  $Revision: 1.2 $
 *
 *  last change: $Author: as $ $Date: 2001-06-11 10:24:36 $
 *
 *  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 __FRAMEWORK_THREADHELP_RESETABLEGUARD_HXX_
#define __FRAMEWORK_THREADHELP_RESETABLEGUARD_HXX_

//_________________________________________________________________________________________________________________
//  my own includes
//_________________________________________________________________________________________________________________

#ifndef __FRAMEWORK_THREADHELP_INONCOPYABLE_H_
#include <threadhelp/inoncopyable.h>
#endif

#ifndef __FRAMEWORK_THREADHELP_IMUTEX_H_
#include <threadhelp/imutex.h>
#endif

//#ifndef __FRAMEWORK_THREADHELP_THREADHELPBASE_HXX_
//#include <threadhelp/threadhelpbase.hxx>
//#endif

//_________________________________________________________________________________________________________________
//  interface includes
//_________________________________________________________________________________________________________________

//_________________________________________________________________________________________________________________
//  other includes
//_________________________________________________________________________________________________________________

#ifndef _SAL_TYPES_H_
#include <sal/types.h>
#endif

//_________________________________________________________________________________________________________________
//  namespace
//_________________________________________________________________________________________________________________

namespace framework{

//_________________________________________________________________________________________________________________
//  const
//_________________________________________________________________________________________________________________

//_________________________________________________________________________________________________________________
//  declarations
//_________________________________________________________________________________________________________________

/*-************************************************************************************************************//**
    @short          implement a guard for implementing save thread access
    @descr          These guard has an additional feature to well known one ::osl::Guard.
                    You can lock() and unlock() it very often!
                    A set bool flag inside protect this implementation against multiple lock() calls
                    without any unlock()! So the increasing of guarded mutex couldn't be greater then 1 ...

    @attention      a) To prevent us against wrong using, the default ctor, copy ctor and the =operator are maked private!
                    b) Use interface "IMutex" of set LockHelper only - because we must support an exclusiv locking.
                       Interface "IRWLock" should be used by special guard implementations ... like "ReadGuard" or "WriteGuard"!

    @implements     -
    @base           INonCopyable

    @devstatus      ready to use
*//*-*************************************************************************************************************/
class ResetableGuard : private INonCopyable
{
    //-------------------------------------------------------------------------------------------------------------
    //  public methods
    //-------------------------------------------------------------------------------------------------------------
    public:

        /*-****************************************************************************************************//**
            @short      ctors
            @descr      Use these ctor methods to initialize the guard right.
                        Given lock reference must be valid - otherwise crashes could occure!

            @seealso    -

            @param      "pLock", pointer to lock helper of user
            @param      "rLock", reference to lock helper of user
            @return     -

            @onerror    -
        *//*-*****************************************************************************************************/
        inline ResetableGuard( IMutex* pLock )
            :   m_pLock    ( pLock     )
            ,   m_bLocked  ( sal_False )
        {
            lock();
        }

        //*********************************************************************************************************
        inline ResetableGuard( IMutex& rLock )
            :   m_pLock    ( &rLock    )
            ,   m_bLocked  ( sal_False )
        {
            lock();
        }

        /*-****************************************************************************************************//**
            @short      dtor
            @descr      We must release set mutex if programmer forget it ...

            @seealso    -

            @param      -
            @return     -

            @onerror    -
        *//*-*****************************************************************************************************/
        inline ~ResetableGuard()
        {
            unlock();
        }

        /*-****************************************************************************************************//**
            @short      enable/disable the lock
            @descr      Use this methods to lock or unlock the mutex.
                        You can do it so often you wish to do that ...

            @attention  We use another member to prevent us against multiple acquire calls of the same guard
                        without suitable release calls!
                        You don't must protect access at these bool member by using an own mutex ....
                        because nobody use the same guard instance from different threads!
                        It will be a function-local object every time.

            @seealso    -

            @param      -
            @return     -

            @onerror    -
        *//*-*****************************************************************************************************/
        inline void lock()
        {
            if( m_bLocked == sal_False )
            {
                m_pLock->acquire();
                m_bLocked = sal_True;
            }
        }

        //*********************************************************************************************************
        inline void unlock()
        {
            if( m_bLocked == sal_True )
            {
                m_pLock->release();
                m_bLocked = sal_False;
            }
        }

    //-------------------------------------------------------------------------------------------------------------
    //  private methods
    //-------------------------------------------------------------------------------------------------------------
    private:

        /*-****************************************************************************************************//**
            @short      disable using of these functions!
            @descr      It's not allowed to use this methods. Different problem can occure otherwise.
                        Thats why we disable it by make it private.

            @seealso    other ctor

            @param      -
            @return     -

            @onerror    -
        *//*-*****************************************************************************************************/
        ResetableGuard();

    //-------------------------------------------------------------------------------------------------------------
    //  private member
    //-------------------------------------------------------------------------------------------------------------
    private:

        IMutex*         m_pLock     ;   /// pointer to safed lock member of user
        sal_Bool        m_bLocked   ;   /// protection against multiple lock() calls without unlock()

};      //  class ResetableGuard

}       //  namespace framework

#endif  //  #ifndef __FRAMEWORK_THREADHELP_RESETABLEGUARD_HXX_
<commit_msg>INTEGRATION: CWS ooo19126 (1.2.584); FILE MERGED 2005/09/05 13:05:24 rt 1.2.584.1: #i54170# Change license header: remove SISSL<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: resetableguard.hxx,v $
 *
 *  $Revision: 1.3 $
 *
 *  last change: $Author: rt $ $Date: 2005-09-09 00:37:42 $
 *
 *  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 __FRAMEWORK_THREADHELP_RESETABLEGUARD_HXX_
#define __FRAMEWORK_THREADHELP_RESETABLEGUARD_HXX_

//_________________________________________________________________________________________________________________
//  my own includes
//_________________________________________________________________________________________________________________

#ifndef __FRAMEWORK_THREADHELP_INONCOPYABLE_H_
#include <threadhelp/inoncopyable.h>
#endif

#ifndef __FRAMEWORK_THREADHELP_IMUTEX_H_
#include <threadhelp/imutex.h>
#endif

//#ifndef __FRAMEWORK_THREADHELP_THREADHELPBASE_HXX_
//#include <threadhelp/threadhelpbase.hxx>
//#endif

//_________________________________________________________________________________________________________________
//  interface includes
//_________________________________________________________________________________________________________________

//_________________________________________________________________________________________________________________
//  other includes
//_________________________________________________________________________________________________________________

#ifndef _SAL_TYPES_H_
#include <sal/types.h>
#endif

//_________________________________________________________________________________________________________________
//  namespace
//_________________________________________________________________________________________________________________

namespace framework{

//_________________________________________________________________________________________________________________
//  const
//_________________________________________________________________________________________________________________

//_________________________________________________________________________________________________________________
//  declarations
//_________________________________________________________________________________________________________________

/*-************************************************************************************************************//**
    @short          implement a guard for implementing save thread access
    @descr          These guard has an additional feature to well known one ::osl::Guard.
                    You can lock() and unlock() it very often!
                    A set bool flag inside protect this implementation against multiple lock() calls
                    without any unlock()! So the increasing of guarded mutex couldn't be greater then 1 ...

    @attention      a) To prevent us against wrong using, the default ctor, copy ctor and the =operator are maked private!
                    b) Use interface "IMutex" of set LockHelper only - because we must support an exclusiv locking.
                       Interface "IRWLock" should be used by special guard implementations ... like "ReadGuard" or "WriteGuard"!

    @implements     -
    @base           INonCopyable

    @devstatus      ready to use
*//*-*************************************************************************************************************/
class ResetableGuard : private INonCopyable
{
    //-------------------------------------------------------------------------------------------------------------
    //  public methods
    //-------------------------------------------------------------------------------------------------------------
    public:

        /*-****************************************************************************************************//**
            @short      ctors
            @descr      Use these ctor methods to initialize the guard right.
                        Given lock reference must be valid - otherwise crashes could occure!

            @seealso    -

            @param      "pLock", pointer to lock helper of user
            @param      "rLock", reference to lock helper of user
            @return     -

            @onerror    -
        *//*-*****************************************************************************************************/
        inline ResetableGuard( IMutex* pLock )
            :   m_pLock    ( pLock     )
            ,   m_bLocked  ( sal_False )
        {
            lock();
        }

        //*********************************************************************************************************
        inline ResetableGuard( IMutex& rLock )
            :   m_pLock    ( &rLock    )
            ,   m_bLocked  ( sal_False )
        {
            lock();
        }

        /*-****************************************************************************************************//**
            @short      dtor
            @descr      We must release set mutex if programmer forget it ...

            @seealso    -

            @param      -
            @return     -

            @onerror    -
        *//*-*****************************************************************************************************/
        inline ~ResetableGuard()
        {
            unlock();
        }

        /*-****************************************************************************************************//**
            @short      enable/disable the lock
            @descr      Use this methods to lock or unlock the mutex.
                        You can do it so often you wish to do that ...

            @attention  We use another member to prevent us against multiple acquire calls of the same guard
                        without suitable release calls!
                        You don't must protect access at these bool member by using an own mutex ....
                        because nobody use the same guard instance from different threads!
                        It will be a function-local object every time.

            @seealso    -

            @param      -
            @return     -

            @onerror    -
        *//*-*****************************************************************************************************/
        inline void lock()
        {
            if( m_bLocked == sal_False )
            {
                m_pLock->acquire();
                m_bLocked = sal_True;
            }
        }

        //*********************************************************************************************************
        inline void unlock()
        {
            if( m_bLocked == sal_True )
            {
                m_pLock->release();
                m_bLocked = sal_False;
            }
        }

    //-------------------------------------------------------------------------------------------------------------
    //  private methods
    //-------------------------------------------------------------------------------------------------------------
    private:

        /*-****************************************************************************************************//**
            @short      disable using of these functions!
            @descr      It's not allowed to use this methods. Different problem can occure otherwise.
                        Thats why we disable it by make it private.

            @seealso    other ctor

            @param      -
            @return     -

            @onerror    -
        *//*-*****************************************************************************************************/
        ResetableGuard();

    //-------------------------------------------------------------------------------------------------------------
    //  private member
    //-------------------------------------------------------------------------------------------------------------
    private:

        IMutex*         m_pLock     ;   /// pointer to safed lock member of user
        sal_Bool        m_bLocked   ;   /// protection against multiple lock() calls without unlock()

};      //  class ResetableGuard

}       //  namespace framework

#endif  //  #ifndef __FRAMEWORK_THREADHELP_RESETABLEGUARD_HXX_
<|endoftext|>


<commit_before>/*************************************************************************
 *
 * 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: backingwindow.hxx,v $
 * $Revision: 1.8 $
 *
 * 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 FRAMEWORK_BACKINGWINDOW_HXX
#define FRAMEWORK_BACKINGWINDOW_HXX

#include "rtl/ustring.hxx"

#include "vcl/button.hxx"
#include "vcl/fixed.hxx"
#include "vcl/bitmapex.hxx"
#include "vcl/toolbox.hxx"

#include "svtools/moduleoptions.hxx"
#include "svtools/acceleratorexecute.hxx"

#include "com/sun/star/frame/XDispatchProvider.hpp"
#include "com/sun/star/frame/XDesktop.hpp"
#include "com/sun/star/frame/XFrame.hpp"
#include "com/sun/star/frame/XTerminateListener.hpp"
#include "com/sun/star/document/XEventListener.hpp"
#include "com/sun/star/document/XEventBroadcaster.hpp"
#include "com/sun/star/util/XURLTransformer.hpp"
#include "com/sun/star/ui/dialogs/XFilePicker.hpp"
#include "com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp"
#include "com/sun/star/ui/dialogs/XFilterManager.hpp"
#include "com/sun/star/ui/dialogs/XFolderPicker.hpp"
#include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
#include "com/sun/star/ui/dialogs/ExecutableDialogResults.hpp"

#include <set>

class MnemonicGenerator;

namespace framework
{
        // To get the transparent mouse-over look, the closer is actually a toolbox
    // overload DataChange to handle style changes correctly
    class DecoToolBox : public ToolBox
    {
        Size maMinSize;

        using Window::ImplInit;
    public:
                DecoToolBox( Window* pParent, WinBits nStyle = 0 );
                DecoToolBox( Window* pParent, const ResId& rResId );

        void    DataChanged( const DataChangedEvent& rDCEvt );

        void    calcMinSize();
        Size    getMinSize();
    };

    class BackingWindow : public Window
    {
        com::sun::star::uno::Reference<com::sun::star::frame::XDesktop>                  mxDesktop;
        com::sun::star::uno::Reference<com::sun::star::frame::XDispatchProvider >        mxDesktopDispatchProvider;
        com::sun::star::uno::Reference<com::sun::star::frame::XFrame>                    mxFrame;
        com::sun::star::uno::Reference<com::sun::star::document::XEventBroadcaster>      mxBroadcaster;

        FixedText                       maWelcome;
        Size                            maWelcomeSize;
        FixedText                       maProduct;
        Size                            maProductSize;
        FixedText                       maCreateText;
        Size                            maCreateSize;
        FixedText                       maWriterText;
        ImageButton                     maWriterButton;
        FixedText                       maCalcText;
        ImageButton                     maCalcButton;
        FixedText                       maImpressText;
        ImageButton                     maImpressButton;
        FixedText                       maDrawText;
        ImageButton                     maDrawButton;
        FixedText                       maDBText;
        ImageButton                     maDBButton;
        FixedText                       maTemplateText;
        ImageButton                     maTemplateButton;
        FixedText                       maOpenText;
        ImageButton                     maOpenButton;

        DecoToolBox                     maToolbox;

        BitmapEx                        maBackgroundLeft;
        BitmapEx                        maBackgroundMiddle;
        BitmapEx                        maBackgroundRight;

        String                          maWelcomeString;
        String                          maProductString;
        String                          maCreateString;
        String                          maOpenString;
        String                          maTemplateString;

        Font                            maTextFont;
        Rectangle                       maControlRect;

        long                            mnColumnWidth[2];
        Color                           maLabelTextColor;
        Color                           maWelcomeTextColor;

        Size                            maButtonImageSize;

        bool                            mbInitControls;
        svt::AcceleratorExecute*        mpAccExec;

        static const long nBtnPos = 240;
        static const int nItemId_Extensions = 1;
        static const int nItemId_Reg = 2;
        static const int nItemId_Info = 3;
        static const int nItemId_TplRep = 4;
        static const int nShadowTop = 32;
        static const int nShadowLeft = 35;
        static const int nShadowRight = 45;
        static const int nShadowBottom = 50;

        void loadImage( const ResId& i_rId, ImageButton& i_rButton );

        void layoutButtonAndText( const char* i_pURL, int nColumn, const std::set<rtl::OUString>& i_rURLS,
                                  SvtModuleOptions& i_rOpt, SvtModuleOptions::EModule i_eMod,
                                  ImageButton& i_rBtn, FixedText& i_rText,
                                  MnemonicGenerator& i_rMnemonicGen,
                                  const String& i_rStr = String()
                                  );

        void dispatchURL( const rtl::OUString& i_rURL,
                          const rtl::OUString& i_rTarget = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_default" ) ),
                          const com::sun::star::uno::Reference< com::sun::star::frame::XDispatchProvider >& i_xProv = com::sun::star::uno::Reference< com::sun::star::frame::XDispatchProvider >(),
                          const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& = com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >()
                          );

        DECL_LINK( ClickHdl, Button* );
        DECL_LINK( ToolboxHdl, void* );

        void initControls();
        void initBackground();
        public:
        BackingWindow( Window* pParent );
        ~BackingWindow();

        virtual void        Paint( const Rectangle& rRect );
        virtual void        Resize();
        virtual long        Notify( NotifyEvent& rNEvt );
        virtual void        DataChanged( const DataChangedEvent& rDCEvt );
        virtual Window*     GetParentLabelFor( const Window* pLabel ) const;
        virtual Window*     GetParentLabeledBy( const Window* pLabeled ) const;

        void setOwningFrame( const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& xFrame );
    };

}

#endif
<commit_msg>INTEGRATION: CWS obo30 (1.7.8); FILE MERGED 2008/06/20 09:59:54 obo 1.7.8.2: RESYNC: (1.7-1.8); FILE MERGED 2008/06/06 06:38:56 obo 1.7.8.1: #i90100# EOL missing<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: backingwindow.hxx,v $
 * $Revision: 1.9 $
 *
 * 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 FRAMEWORK_BACKINGWINDOW_HXX
#define FRAMEWORK_BACKINGWINDOW_HXX

#include "rtl/ustring.hxx"

#include "vcl/button.hxx"
#include "vcl/fixed.hxx"
#include "vcl/bitmapex.hxx"
#include "vcl/toolbox.hxx"

#include "svtools/moduleoptions.hxx"
#include "svtools/acceleratorexecute.hxx"

#include "com/sun/star/frame/XDispatchProvider.hpp"
#include "com/sun/star/frame/XDesktop.hpp"
#include "com/sun/star/frame/XFrame.hpp"
#include "com/sun/star/frame/XTerminateListener.hpp"
#include "com/sun/star/document/XEventListener.hpp"
#include "com/sun/star/document/XEventBroadcaster.hpp"
#include "com/sun/star/util/XURLTransformer.hpp"
#include "com/sun/star/ui/dialogs/XFilePicker.hpp"
#include "com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp"
#include "com/sun/star/ui/dialogs/XFilterManager.hpp"
#include "com/sun/star/ui/dialogs/XFolderPicker.hpp"
#include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
#include "com/sun/star/ui/dialogs/ExecutableDialogResults.hpp"

#include <set>

class MnemonicGenerator;

namespace framework
{
        // To get the transparent mouse-over look, the closer is actually a toolbox
    // overload DataChange to handle style changes correctly
    class DecoToolBox : public ToolBox
    {
        Size maMinSize;

        using Window::ImplInit;
    public:
                DecoToolBox( Window* pParent, WinBits nStyle = 0 );
                DecoToolBox( Window* pParent, const ResId& rResId );

        void    DataChanged( const DataChangedEvent& rDCEvt );

        void    calcMinSize();
        Size    getMinSize();
    };

    class BackingWindow : public Window
    {
        com::sun::star::uno::Reference<com::sun::star::frame::XDesktop>                  mxDesktop;
        com::sun::star::uno::Reference<com::sun::star::frame::XDispatchProvider >        mxDesktopDispatchProvider;
        com::sun::star::uno::Reference<com::sun::star::frame::XFrame>                    mxFrame;
        com::sun::star::uno::Reference<com::sun::star::document::XEventBroadcaster>      mxBroadcaster;

        FixedText                       maWelcome;
        Size                            maWelcomeSize;
        FixedText                       maProduct;
        Size                            maProductSize;
        FixedText                       maCreateText;
        Size                            maCreateSize;
        FixedText                       maWriterText;
        ImageButton                     maWriterButton;
        FixedText                       maCalcText;
        ImageButton                     maCalcButton;
        FixedText                       maImpressText;
        ImageButton                     maImpressButton;
        FixedText                       maDrawText;
        ImageButton                     maDrawButton;
        FixedText                       maDBText;
        ImageButton                     maDBButton;
        FixedText                       maTemplateText;
        ImageButton                     maTemplateButton;
        FixedText                       maOpenText;
        ImageButton                     maOpenButton;

        DecoToolBox                     maToolbox;

        BitmapEx                        maBackgroundLeft;
        BitmapEx                        maBackgroundMiddle;
        BitmapEx                        maBackgroundRight;

        String                          maWelcomeString;
        String                          maProductString;
        String                          maCreateString;
        String                          maOpenString;
        String                          maTemplateString;

        Font                            maTextFont;
        Rectangle                       maControlRect;

        long                            mnColumnWidth[2];
        Color                           maLabelTextColor;
        Color                           maWelcomeTextColor;

        Size                            maButtonImageSize;

        bool                            mbInitControls;
        svt::AcceleratorExecute*        mpAccExec;

        static const long nBtnPos = 240;
        static const int nItemId_Extensions = 1;
        static const int nItemId_Reg = 2;
        static const int nItemId_Info = 3;
        static const int nItemId_TplRep = 4;
        static const int nShadowTop = 32;
        static const int nShadowLeft = 35;
        static const int nShadowRight = 45;
        static const int nShadowBottom = 50;

        void loadImage( const ResId& i_rId, ImageButton& i_rButton );

        void layoutButtonAndText( const char* i_pURL, int nColumn, const std::set<rtl::OUString>& i_rURLS,
                                  SvtModuleOptions& i_rOpt, SvtModuleOptions::EModule i_eMod,
                                  ImageButton& i_rBtn, FixedText& i_rText,
                                  MnemonicGenerator& i_rMnemonicGen,
                                  const String& i_rStr = String()
                                  );

        void dispatchURL( const rtl::OUString& i_rURL,
                          const rtl::OUString& i_rTarget = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_default" ) ),
                          const com::sun::star::uno::Reference< com::sun::star::frame::XDispatchProvider >& i_xProv = com::sun::star::uno::Reference< com::sun::star::frame::XDispatchProvider >(),
                          const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& = com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >()
                          );

        DECL_LINK( ClickHdl, Button* );
        DECL_LINK( ToolboxHdl, void* );

        void initControls();
        void initBackground();
        public:
        BackingWindow( Window* pParent );
        ~BackingWindow();

        virtual void        Paint( const Rectangle& rRect );
        virtual void        Resize();
        virtual long        Notify( NotifyEvent& rNEvt );
        virtual void        DataChanged( const DataChangedEvent& rDCEvt );
        virtual Window*     GetParentLabelFor( const Window* pLabel ) const;
        virtual Window*     GetParentLabeledBy( const Window* pLabeled ) const;

        void setOwningFrame( const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& xFrame );
    };

}

#endif

<|endoftext|>


<commit_before>#include <Python.h>
#include "Quantuccia/ql/time/calendars/unitedstates.hpp"

static PyObject*
get_holiday_date(PyObject *self, PyObject *args)
{
    return NULL;
}

static PyMethodDef QuantucciaMethods[] = {
	{"get_holiday_date", (PyCFunction)get_holiday_date, METH_VARARGS, NULL},
	{NULL,     NULL}        /* Sentinel */
};

static struct PyModuleDef quantuccia_module_def = {
	PyModuleDef_HEAD_INIT,
	"quantuccia",
	NULL,
	-1,
	QuantucciaMethods,
};

PyObject* PyInit_pyQuantuccia(void){
    PyObject *m;
    m = PyModule_Create(&quantuccia_module_def);
    return m;
}
<commit_msg>Some changes to see if we can still build it.<commit_after>#include <Python.h>
#include "Quantuccia/ql/time/calendars/unitedstates.hpp"

static PyObject*
get_holiday_date(PyObject *self, PyObject *args)
{
    return NULL;
}

static PyMethodDef QuantucciaMethods[] = {
	{"get_holiday_date", (PyCFunction)get_holiday_date, METH_VARARGS, NULL},
	{NULL, NULL, 0, NULL}
};

static struct PyModuleDef quantuccia_module_def = {
	PyModuleDef_HEAD_INIT,
	"quantuccia",
	NULL,
	-1,
	QuantucciaMethods,
	NULL,
	NULL,
	NULL,
	NULL
};

PyMODINIT_FUNC PyInit_pyQuantuccia(void){
    PyObject *m;
    m = PyModule_Create(&quantuccia_module_def);
    return m;
}
<|endoftext|>


<commit_before>// Meteor.cpp : ܼ  α׷   մϴ.
//

#include "stdafx.h"

int _tmain(int argc, _TCHAR* argv[])
{
	return 0;
}

<commit_msg>second<commit_after>// Meteor.cpp : ܼ  α׷   մϴ.
//

#include "stdafx.h"

int _tmain(int argc, _TCHAR* argv[])
{
	//hi hello init
	//adfasdf
	return 0;
}

<|endoftext|>


<commit_before>#include "MainForm.h"
#include <algorithm>

MainForm::MainForm(QWidget *parent, Qt::WFlags flags)
    : QMainWindow(parent, flags)
{
    ui.setupUi(this);
    Center();
    DoEvents();
    ui.fileSystemTree->setColumnWidth(0, 240);
    ui.fileSystemTree->setColumnWidth(1, 150);

    // Set the context menus
    SetContextMenus();

    iDisk.addFile(QString::fromUtf8(":/File System Icons/iDisk"), QSize(), QIcon::Normal, QIcon::Off);
    iFile.addFile(QString::fromUtf8(":/File System Icons/iFile"), QSize(), QIcon::Normal, QIcon::Off);
    iUsb.addFile(QString::fromUtf8(":/File System Icons/iUsb"), QSize(), QIcon::Normal, QIcon::Off);
    iFolder.addFile(QString::fromUtf8(":/File System Icons/iFolder"), QSize(), QIcon::Normal, QIcon::Off);
    iPartition.addFile(QString::fromUtf8(":/File System Icons/iPartition"), QSize(), QIcon::Normal, QIcon::Off);

    std::string s("dicks");
    QString::fromAscii(s.c_str());
    return;
}

MainForm::~MainForm()
{

}

string MainForm::GetCurrentItemPath(QTreeWidgetItem *Item)
{
    vector<std::string> ItemNames;
    QTreeWidgetItem *temp = Item;
    while (temp != 0)
    {
        ItemNames.push_back(Helpers::QStringToStdString(temp->text(0)));
        qDebug("Item: %s", Helpers::QStringToStdString(temp->text(0)).c_str());
        temp = temp->parent();
    }
    string built;
    for (int i = ItemNames.size() - 1; i >= 0; i--)
    {
        qDebug("Item: %s", ItemNames.at(i).c_str());
        built += ItemNames.at(i);
        if (i != 0)
            built += "/";
    }
    return built;
}

void MainForm::OnCopyToLocalDiskClick( void )
{
    QString s;
    int size = ui.fileSystemTree->selectedItems().size();
    if (size == 0)
        return;
    else if (size == 1 && ui.fileSystemTree->selectedItems().at(0)->text(2) != QString::fromAscii("Folder"))
    {
        s = QFileDialog::getSaveFileName(this, QString::fromAscii("Select Where to Save File"), ui.fileSystemTree->selectedItems().at(0)->text(0));
    }
    else
    {
        QFileDialog qfd;
        qfd.setFileMode(QFileDialog::Directory);
        qfd.setOption(QFileDialog::ShowDirsOnly);
        s = qfd.getExistingDirectory(this, QString::fromAscii("Select Directory to Save Files"));
    }
    if (s.isEmpty() || s.isNull())
    {
        return;
    }

    // Get the paths of all selected items
    vector<std::string> Paths;
    for (int i = 0; i < ui.fileSystemTree->selectedItems().size(); i++)
        Paths.push_back(GetCurrentItemPath(ui.fileSystemTree->selectedItems().at(i)));

    ProgressDialog *pd = new ProgressDialog(this, OperationCopyToDisk, Paths, Helpers::QStringToStdString(s), ActiveDrives);

    pd->setModal(true);
    pd->show();
}

void MainForm::SetContextMenus( void )
{
    ui.fileSystemTree->addAction(ui.actionCopy_File_to_Local_Disk);
    QAction *sep = new QAction(this);
    sep->setSeparator(true);
    ui.fileSystemTree->addAction(sep);
    ui.fileSystemTree->addAction(ui.actionRename);

    connect(ui.actionCopy_File_to_Local_Disk, SIGNAL(triggered()), this, SLOT(OnCopyToLocalDiskClick()));
}

void MainForm::Center( void )
{
    QRect frect = frameGeometry();
    frect.moveCenter(QDesktopWidget().availableGeometry().center());
    move(frect.topLeft());
}

void MainForm::DoEvents( void )
{
    connect(ui.actionLoad_Devices, SIGNAL(triggered()), this, SLOT(OnLoadDevicesClick()));
    connect(ui.actionAbout, SIGNAL(triggered()), this, SLOT(ShowAbout()));
    connect(ui.fileSystemTree, SIGNAL(itemExpanded(QTreeWidgetItem*)), this, SLOT(OnTreeItemExpand(QTreeWidgetItem*)));
    connect(ui.fileSystemTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(OnTreeItemDoubleClick(QTreeWidgetItem*, int)));
}

Drive *MainForm::GetCurrentItemDrive(QTreeWidgetItem* Item)
{
    QString text = Item->text(0);
    qDebug(Helpers::QStringToStdString(text).c_str());
    QTreeWidgetItem *Parent = Item;
    while (Parent->parent() != 0)
        Parent = Parent->parent();

    for (int i = 0; i < (int)ActiveDrives.size(); i++)
    {
        Drive* d = ActiveDrives.at(i);

        if (QString::fromWCharArray(d->FriendlyName.c_str()) == Parent->text(0))
            return d;
    }
    qDebug("returned nothing");
    return 0;
}

std::string MainForm::GetItemPath(QTreeWidgetItem *Item)
{
    string Path;
    QTreeWidgetItem* Parent = Item;
    do
    {
        if (Path.length() != 0)
        {
            string pathtemp = Path;
            Path = "/";
            Path += pathtemp;
        }
        string pathtemp = Path;

        Path = string(Parent->text(0).toLocal8Bit().data()) + pathtemp;
        Parent = Parent->parent();
    }
    while (Parent != 0);

    return Path;
}

QTreeWidgetItem *MainForm::AddFolder(QTreeWidgetItem* Item, Folder *f)
{
    QTreeWidgetItem *fItem = new QTreeWidgetItem(Item);
    fItem->setText(0, QString::fromAscii(f->Dirent.Name));
    fItem->setData(0, Qt::UserRole, QVariant(false));
    QDateTime ModifiedDate = f->DateModified;
    fItem->setText(1, ModifiedDate.toString());
    fItem->setText(2, QString::fromAscii("Folder"));
    fItem->setIcon(0, iFolder);
    return fItem;
}

QTreeWidgetItem *MainForm::AddFile(QTreeWidgetItem* Item, File *f, Drive *device)
{
    QTreeWidgetItem *fItem = new QTreeWidgetItem(Item);
    fItem->setText(0, QString::fromAscii(f->Dirent.Name));
    fItem->setIcon(0, iFile);

    QDateTime ModifiedDate = f->DateModified;
    fItem->setText(1, ModifiedDate.toString());
    fItem->setText(2, QString::fromAscii("File"));
    fItem->setText(3, QString::fromLocal8Bit(Helpers::ConvertToFriendlySize(f->Dirent.FileSize).c_str()));

    // Determine if the file is a valid STFS package
    Streams::xDeviceFileStream *fs = new Streams::xDeviceFileStream(f->FullPath, device);
    STFSPackage pack(fs);
    if (pack.IsStfsPackage())
    {
        fItem->setText(2, pack.ContentType_s());
        QIcon *Icon = 0;
        if (Icons.size())
        {
            map<DWORD, QIcon*>::iterator it;
            it = Icons.find(pack.TitleId());
            if (it != Icons.end())
                Icon = it->second;
        }
        if (!Icon)
        {
            Icon = new QIcon(QPixmap::fromImage(pack.ThumbnailImage()));
            Icons.insert(Icons.begin(), pair<DWORD, QIcon*>(pack.TitleId(), Icon));
        }
        fItem->setIcon(0, *Icon);
        fItem->setText(4, pack.DisplayName());
    }

    return fItem;
}

void MainForm::PopulateTreeItems(QTreeWidgetItem *Item, bool expand)
{
    string Path = GetItemPath(Item);
    qDebug("Item path: %s", Path.c_str());
    Drive* currentDrive = GetCurrentItemDrive(Item);
    Folder *f = currentDrive->FolderFromPath(Path);
    int Folders = f->CachedFolders.size();
    for (int i = 0; i < Folders; i++)
    {
        Folder *sub = f->CachedFolders.at(i);
        string path = sub->FullPath;
        sub = currentDrive->FolderFromPath(path);

        QTreeWidgetItem *subItem = 0;
        if (!expand)
            subItem = AddFolder(Item, sub);
        else
        {
            for (int x = 0; x < Item->childCount(); x++)
            {
                if (Item->child(x)->text(0) == QString::fromAscii(sub->Dirent.Name))
                {
                    subItem = Item->child(x);
                    break;
                }
            }
        }

        for (int j = 0; j < (int)sub->CachedFolders.size(); j++)
            AddFolder(subItem, sub->CachedFolders.at(j));

        for (int x = 0;  x < (int)sub->CachedFiles.size(); x++)
            AddFile(subItem, sub->CachedFiles.at(x), currentDrive);
    }
    if (!expand)
    {
        for (int i = 0; i < (int)f->CachedFiles.size(); i++)
        {
            File *file = f->CachedFiles.at(i);
            AddFile(Item, file, currentDrive);
        }
    }
    Item->setData(0, Qt::UserRole, QVariant(true));
}

void MainForm::OnTreeItemExpand( QTreeWidgetItem* Item)
{
    if (Item->parent() != 0 && Item->parent()->parent() != 0)
    {
        if (!Item->data(0, Qt::UserRole).toBool())
        {
            PopulateTreeItems(Item, true);
        }
    }
}

void MainForm::OnTreeItemDoubleClick(QTreeWidgetItem *Item, int)
{
    ui.textEdit->setText(Helpers::QStringFromStdString(GetCurrentItemPath(Item)));
}

void MainForm::ShowAbout( void )
{
    AboutForm* about = new AboutForm(this);
    about->show();
}

void MainForm::OnLoadDevicesClick( void )
{
    vector<Drive *> Drives;
    try
    {
        Drives = Drive::GetFATXDrives(true);
    }
    catch (exception e)
    {
        QMessageBox mb;
        mb.setText("Exception was thrown");
        mb.show();
    }

    for (int i = 0; i < (int)Drives.size(); i++)
    {
        Drive *current = Drives.at(i);
        bool Skip = false;
        // Do a check to make sure we aren't adding the same device twice
        for (int j = 0; j < (int)ui.fileSystemTree->topLevelItemCount(); j++)
        {
            if (QString::fromWCharArray(current->FriendlyName.c_str()) == ui.fileSystemTree->topLevelItem(j)->text(0))
            {
                // Skip this item
                Skip = true;
                break;
            }
        }
        if (Skip)
        {
            current->Close();
            delete current;
            continue;
        }
        ActiveDrives.push_back(current);
        QTreeWidgetItem* item = new QTreeWidgetItem();
        item->setText(0, QString::fromWCharArray(current->FriendlyName.c_str()));			// Drive name
        char* Type = 0;
        switch (current->Type)
        {
        case DeviceUsb:
            Type = "USB Removable Storage";
            break;
        case DeviceDisk:
            Type = "Disk Drive";
            break;
        case DeviceBackup:
            Type = "Disk Backup";
            break;
        }

        item->setText(2, QString::fromAscii(Type));     									// Drive type
        item->setText(3, QString::fromAscii(current->FriendlySize.c_str()));                // Drive size
        // if it's a USB device
        if (current->Type == DeviceUsb)
        {
            // Assign it the USB icon
            item->setIcon(0, iUsb);
        }
        else
        {
            item->setIcon(0, iDisk);
        }

        for (int j = 0; j < (int)current->Partitions().size(); j++)
        {
            if (!item)
            {
                break;
            }
            QTreeWidgetItem* partition = new QTreeWidgetItem(item);
            string currentVolume = current->Partitions().at(j);
            partition->setText(0, QString::fromAscii(currentVolume.c_str()));	// Partition name
            partition->setText(2, QString::fromAscii("Partition"));
            partition->setText(3, QString::fromAscii(Helpers::ConvertToFriendlySize((INT64)current->PartitionGetLength(currentVolume)).c_str()));
            partition->setIcon(0, iPartition);
            partition->setData(0, Qt::UserRole, QVariant(false));

            QString text(partition->text(0));
            PopulateTreeItems(partition, false);
        }
        ui.fileSystemTree->insertTopLevelItem(ui.fileSystemTree->topLevelItemCount(), item);
        ui.activeDevicesComboBox->addItem(item->icon(0), item->text(0));
    }
}
<commit_msg>Fixed stream leak, added disk name<commit_after>#include "MainForm.h"
#include <algorithm>

MainForm::MainForm(QWidget *parent, Qt::WFlags flags)
    : QMainWindow(parent, flags)
{
    ui.setupUi(this);
    Center();
    DoEvents();
    ui.fileSystemTree->setColumnWidth(0, 240);
    ui.fileSystemTree->setColumnWidth(1, 150);

    // Set the context menus
    SetContextMenus();

    iDisk.addFile(QString::fromUtf8(":/File System Icons/iDisk"), QSize(), QIcon::Normal, QIcon::Off);
    iFile.addFile(QString::fromUtf8(":/File System Icons/iFile"), QSize(), QIcon::Normal, QIcon::Off);
    iUsb.addFile(QString::fromUtf8(":/File System Icons/iUsb"), QSize(), QIcon::Normal, QIcon::Off);
    iFolder.addFile(QString::fromUtf8(":/File System Icons/iFolder"), QSize(), QIcon::Normal, QIcon::Off);
    iPartition.addFile(QString::fromUtf8(":/File System Icons/iPartition"), QSize(), QIcon::Normal, QIcon::Off);
}

MainForm::~MainForm()
{

}

string MainForm::GetCurrentItemPath(QTreeWidgetItem *Item)
{
    vector<std::string> ItemNames;
    QTreeWidgetItem *temp = Item;
    while (temp != 0)
    {
        ItemNames.push_back(Helpers::QStringToStdString(temp->text(0)));
        qDebug("Item: %s", Helpers::QStringToStdString(temp->text(0)).c_str());
        temp = temp->parent();
    }
    string built;
    for (int i = ItemNames.size() - 1; i >= 0; i--)
    {
        qDebug("Item: %s", ItemNames.at(i).c_str());
        built += ItemNames.at(i);
        if (i != 0)
            built += "/";
    }
    return built;
}

void MainForm::OnCopyToLocalDiskClick( void )
{
    QString s;
    int size = ui.fileSystemTree->selectedItems().size();
    if (size == 0)
        return;
    else if (size == 1 && ui.fileSystemTree->selectedItems().at(0)->text(2) != QString::fromAscii("Folder"))
    {
        s = QFileDialog::getSaveFileName(this, QString::fromAscii("Select Where to Save File"), ui.fileSystemTree->selectedItems().at(0)->text(0));
    }
    else
    {
        QFileDialog qfd;
        qfd.setFileMode(QFileDialog::Directory);
        qfd.setOption(QFileDialog::ShowDirsOnly);
        s = qfd.getExistingDirectory(this, QString::fromAscii("Select Directory to Save Files"));
    }
    if (s.isEmpty() || s.isNull())
    {
        return;
    }

    // Get the paths of all selected items
    vector<std::string> Paths;
    for (int i = 0; i < ui.fileSystemTree->selectedItems().size(); i++)
        Paths.push_back(GetCurrentItemPath(ui.fileSystemTree->selectedItems().at(i)));

    ProgressDialog *pd = new ProgressDialog(this, OperationCopyToDisk, Paths, Helpers::QStringToStdString(s), ActiveDrives);

    pd->setModal(true);
    pd->show();
}

void MainForm::SetContextMenus( void )
{
    ui.fileSystemTree->addAction(ui.actionCopy_File_to_Local_Disk);
    QAction *sep = new QAction(this);
    sep->setSeparator(true);
    ui.fileSystemTree->addAction(sep);
    ui.fileSystemTree->addAction(ui.actionRename);

    connect(ui.actionCopy_File_to_Local_Disk, SIGNAL(triggered()), this, SLOT(OnCopyToLocalDiskClick()));
}

void MainForm::Center( void )
{
    QRect frect = frameGeometry();
    frect.moveCenter(QDesktopWidget().availableGeometry().center());
    move(frect.topLeft());
}

void MainForm::DoEvents( void )
{
    connect(ui.actionLoad_Devices, SIGNAL(triggered()), this, SLOT(OnLoadDevicesClick()));
    connect(ui.actionAbout, SIGNAL(triggered()), this, SLOT(ShowAbout()));
    connect(ui.fileSystemTree, SIGNAL(itemExpanded(QTreeWidgetItem*)), this, SLOT(OnTreeItemExpand(QTreeWidgetItem*)));
    connect(ui.fileSystemTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(OnTreeItemDoubleClick(QTreeWidgetItem*, int)));
}

Drive *MainForm::GetCurrentItemDrive(QTreeWidgetItem* Item)
{
    QString text = Item->text(0);
    qDebug(Helpers::QStringToStdString(text).c_str());
    QTreeWidgetItem *Parent = Item;
    while (Parent->parent() != 0)
        Parent = Parent->parent();

    for (int i = 0; i < (int)ActiveDrives.size(); i++)
    {
        Drive* d = ActiveDrives.at(i);

        if (QString::fromWCharArray(d->FriendlyName.c_str()) == Parent->text(0))
            return d;
    }
    qDebug("returned nothing");
    return 0;
}

std::string MainForm::GetItemPath(QTreeWidgetItem *Item)
{
    string Path;
    QTreeWidgetItem* Parent = Item;
    do
    {
        if (Path.length() != 0)
        {
            string pathtemp = Path;
            Path = "/";
            Path += pathtemp;
        }
        string pathtemp = Path;

        Path = string(Parent->text(0).toLocal8Bit().data()) + pathtemp;
        Parent = Parent->parent();
    }
    while (Parent != 0);

    return Path;
}

QTreeWidgetItem *MainForm::AddFolder(QTreeWidgetItem* Item, Folder *f)
{
    QTreeWidgetItem *fItem = new QTreeWidgetItem(Item);
    fItem->setText(0, QString::fromAscii(f->Dirent.Name));
    fItem->setData(0, Qt::UserRole, QVariant(false));
    QDateTime ModifiedDate = f->DateModified;
    fItem->setText(1, ModifiedDate.toString());
    fItem->setText(2, QString::fromAscii("Folder"));
    fItem->setIcon(0, iFolder);
    return fItem;
}

QTreeWidgetItem *MainForm::AddFile(QTreeWidgetItem* Item, File *f, Drive *device)
{
    QTreeWidgetItem *fItem = new QTreeWidgetItem(Item);
    fItem->setText(0, QString::fromAscii(f->Dirent.Name));
    fItem->setIcon(0, iFile);

    QDateTime ModifiedDate = f->DateModified;
    fItem->setText(1, ModifiedDate.toString());
    fItem->setText(2, QString::fromAscii("File"));
    fItem->setText(3, QString::fromLocal8Bit(Helpers::ConvertToFriendlySize(f->Dirent.FileSize).c_str()));

    // Determine if the file is a valid STFS package
    Streams::xDeviceFileStream *fs = new Streams::xDeviceFileStream(f->FullPath, device);
    STFSPackage pack(fs);
    if (pack.IsStfsPackage())
    {
        fItem->setText(2, pack.ContentType_s());
        QIcon *Icon = 0;
        if (Icons.size())
        {
            map<DWORD, QIcon*>::iterator it;
            it = Icons.find(pack.TitleId());
            if (it != Icons.end())
                Icon = it->second;
        }
        if (!Icon)
        {
            Icon = new QIcon(QPixmap::fromImage(pack.ThumbnailImage()));
            Icons.insert(Icons.begin(), pair<DWORD, QIcon*>(pack.TitleId(), Icon));
        }
        fItem->setIcon(0, *Icon);
        fItem->setText(4, pack.DisplayName());
    }
    fs->Close();
    delete fs;

    return fItem;
}

void MainForm::PopulateTreeItems(QTreeWidgetItem *Item, bool expand)
{
    string Path = GetItemPath(Item);
    qDebug("Item path: %s", Path.c_str());
    Drive* currentDrive = GetCurrentItemDrive(Item);
    Folder *f = currentDrive->FolderFromPath(Path);
    int Folders = f->CachedFolders.size();
    for (int i = 0; i < Folders; i++)
    {
        Folder *sub = f->CachedFolders.at(i);
        string path = sub->FullPath;
        sub = currentDrive->FolderFromPath(path);

        QTreeWidgetItem *subItem = 0;
        if (!expand)
            subItem = AddFolder(Item, sub);
        else
        {
            for (int x = 0; x < Item->childCount(); x++)
            {
                if (Item->child(x)->text(0) == QString::fromAscii(sub->Dirent.Name))
                {
                    subItem = Item->child(x);
                    break;
                }
            }
        }

        for (int j = 0; j < (int)sub->CachedFolders.size(); j++)
            AddFolder(subItem, sub->CachedFolders.at(j));

        for (int x = 0;  x < (int)sub->CachedFiles.size(); x++)
            AddFile(subItem, sub->CachedFiles.at(x), currentDrive);
    }
    if (!expand)
    {
        for (int i = 0; i < (int)f->CachedFiles.size(); i++)
        {
            File *file = f->CachedFiles.at(i);
            AddFile(Item, file, currentDrive);
        }
    }
    Item->setData(0, Qt::UserRole, QVariant(true));
}

void MainForm::OnTreeItemExpand( QTreeWidgetItem* Item)
{
    if (Item->parent() != 0 && Item->parent()->parent() != 0)
    {
        if (!Item->data(0, Qt::UserRole).toBool())
        {
            PopulateTreeItems(Item, true);
        }
    }
}

void MainForm::OnTreeItemDoubleClick(QTreeWidgetItem *Item, int)
{
    ui.textEdit->setText(Helpers::QStringFromStdString(GetCurrentItemPath(Item)));
}

void MainForm::ShowAbout( void )
{
    AboutForm* about = new AboutForm(this);
    about->show();
}

void MainForm::OnLoadDevicesClick( void )
{
    vector<Drive *> Drives;
    try
    {
        Drives = Drive::GetFATXDrives(true);
    }
    catch (exception e)
    {
        QMessageBox mb;
        mb.setText("Exception was thrown");
        mb.show();
    }

    for (int i = 0; i < (int)Drives.size(); i++)
    {
        Drive *current = Drives.at(i);
        bool Skip = false;
        // Do a check to make sure we aren't adding the same device twice
        for (int j = 0; j < (int)ui.fileSystemTree->topLevelItemCount(); j++)
        {
            if (QString::fromWCharArray(current->FriendlyName.c_str()) == ui.fileSystemTree->topLevelItem(j)->text(0))
            {
                // Skip this item
                Skip = true;
                break;
            }
        }
        if (Skip)
        {
            current->Close();
            delete current;
            continue;
        }
        ActiveDrives.push_back(current);
        QTreeWidgetItem* item = new QTreeWidgetItem();
        item->setText(0, QString::fromWCharArray(current->FriendlyName.c_str()));			// Drive name
        char* Type = 0;
        switch (current->Type)
        {
        case DeviceUsb:
            Type = "USB Removable Storage";
            break;
        case DeviceDisk:
            Type = "Disk Drive";
            break;
        case DeviceBackup:
            Type = "Disk Backup";
            break;
        }

        item->setText(2, QString::fromAscii(Type));     									// Drive type
        item->setText(3, QString::fromAscii(current->FriendlySize.c_str()));                // Drive size
        // if it's a USB device
        if (current->Type == DeviceUsb)
        {
            // Assign it the USB icon
            item->setIcon(0, iUsb);
        }
        else
        {
            item->setIcon(0, iDisk);
        }

        try
        {
            QString Name = current->GetDiskName();
            item->setText(4, Name);
        }
        catch (...){}

        for (int j = 0; j < (int)current->Partitions().size(); j++)
        {
            if (!item)
            {
                break;
            }
            QTreeWidgetItem* partition = new QTreeWidgetItem(item);
            string currentVolume = current->Partitions().at(j);
            partition->setText(0, QString::fromAscii(currentVolume.c_str()));	// Partition name
            partition->setText(2, QString::fromAscii("Partition"));
            partition->setText(3, QString::fromAscii(Helpers::ConvertToFriendlySize((INT64)current->PartitionGetLength(currentVolume)).c_str()));
            partition->setIcon(0, iPartition);
            partition->setData(0, Qt::UserRole, QVariant(false));

            QString text(partition->text(0));
            PopulateTreeItems(partition, false);
        }
        ui.fileSystemTree->insertTopLevelItem(ui.fileSystemTree->topLevelItemCount(), item);
        ui.activeDevicesComboBox->addItem(item->icon(0), item->text(0));
    }
}
<|endoftext|>


<commit_before><?hh //strict

/**
 * This file is part of hhack/typesafety package.
 *
 * (c) Noritaka Horio <holy.shared.design@gmail.com>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace HHPack\Typesafety\Reporter;

use HHPack\TypeChecker\Check\Result;
use HHPack\TypeChecker\Check\Error;
use HHPack\TypeChecker\Check\Message;
use HHPack\Publisher\Message as TypeCheckMessage;
use HHPack\Publisher\Subscribable;
use HHPack\Typesafety\Message\StoppedMessage;
use HHPack\Typesafety\TypeCheckReporter;
use HHPack\Typesafety\Output;

final class TextReporter implements TypeCheckReporter
{

    private (function(string, ...):void) $errorPrinter;

    public function __construct
    (
        private Output $output
    )
    {
        $this->errorPrinter = inst_meth($this->output, 'error');
    }

    public async function onStop(StoppedMessage $message) : Awaitable<void>
    {
        $this->displayErrors($message);
        $this->displayStatus($message);
    }

    private function displayStatus(StoppedMessage $message) : void
    {
        if ($message->isOk()) {
            $this->output->success('type check passed.');
        } else {
            $this->output->fail("type checker found %d errors.", $message->errorCount());
        }
    }

    private function displayErrors(StoppedMessage $message) : void
    {
        foreach ($message->errors() as $errorNumber => $error) {
            $this->displayError($errorNumber, $error);
        }
    }

    private function displayError(int $errorNumber, Error $error) : void
    {
        foreach ($error->messages()->lazy() as $number => $message) {
            if ($number === 0) {
                $this->errorPrinter = inst_meth($this->output, 'error');
                $this->display('Error: %d - %s%s', $errorNumber, $message->path(), PHP_EOL);
            } else {
                $this->errorPrinter = inst_meth($this->output, 'info');
            }
            $this->displayMessage($message);
        }
    }

    private function displayMessage(Message $message) : void
    {
        $this->displayDescription($message);
        $this->displayErrorMessage($message);
    }

    private function displayDescription(Message $message) : void
    {
        $description = $message->description();
        $texts = explode(PHP_EOL, $description);

        foreach ($texts as $text) {
            $this->display('  %s', $text);
        }
        $this->output->write("\n");
    }

    private function displayErrorMessage(Message $message) : void
    {
        $startAt = $message->startColumnNumber();
        $endAt = $message->endColumnNumber();
        $lineNumber = $message->lineNumber();

        $stringText = str_pad("^", $startAt, " ", STR_PAD_LEFT);
        $length = $startAt + ($endAt - $startAt);
        $stringText = str_pad($stringText, $length, "^");

        $paddingSpace = str_repeat(' ', strlen((string) $lineNumber) + 1);

        $this->display('    %d: %s', $lineNumber, $message->lineCode());
        $this->display('    %s %s%s', $paddingSpace, $stringText, PHP_EOL);
    }

    private function display(string $format, ...) : void
    {
        $args = Vector { $format };
        $args->addAll(func_get_args());
        call_user_func_array($this->errorPrinter, $args->toValuesArray());
    }

}
<commit_msg>fix reporter arguments bug<commit_after><?hh //strict

/**
 * This file is part of hhack/typesafety package.
 *
 * (c) Noritaka Horio <holy.shared.design@gmail.com>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace HHPack\Typesafety\Reporter;

use HHPack\TypeChecker\Check\Result;
use HHPack\TypeChecker\Check\Error;
use HHPack\TypeChecker\Check\Message;
use HHPack\Publisher\Message as TypeCheckMessage;
use HHPack\Publisher\Subscribable;
use HHPack\Typesafety\Message\StoppedMessage;
use HHPack\Typesafety\TypeCheckReporter;
use HHPack\Typesafety\Output;

final class TextReporter implements TypeCheckReporter
{

    private (function(string, ...):void) $errorPrinter;

    public function __construct
    (
        private Output $output
    )
    {
        $this->errorPrinter = inst_meth($this->output, 'error');
    }

    public async function onStop(StoppedMessage $message) : Awaitable<void>
    {
        $this->displayErrors($message);
        $this->displayStatus($message);
    }

    private function displayStatus(StoppedMessage $message) : void
    {
        if ($message->isOk()) {
            $this->output->success('type check passed.');
        } else {
            $this->output->fail("type checker found %d errors.", $message->errorCount());
        }
    }

    private function displayErrors(StoppedMessage $message) : void
    {
        foreach ($message->errors() as $errorNumber => $error) {
            $this->displayError($errorNumber, $error);
        }
    }

    private function displayError(int $errorNumber, Error $error) : void
    {
        foreach ($error->messages()->lazy() as $number => $message) {
            if ($number === 0) {
                $this->errorPrinter = inst_meth($this->output, 'error');
                $this->display('Error: %d - %s%s', $errorNumber, $message->path(), PHP_EOL);
            } else {
                $this->errorPrinter = inst_meth($this->output, 'info');
            }
            $this->displayMessage($message);
        }
    }

    private function displayMessage(Message $message) : void
    {
        $this->displayDescription($message);
        $this->displayErrorMessage($message);
    }

    private function displayDescription(Message $message) : void
    {
        $description = $message->description();
        $texts = explode(PHP_EOL, $description);

        foreach ($texts as $text) {
            $this->display('  %s', $text);
        }
        $this->output->write("\n");
    }

    private function displayErrorMessage(Message $message) : void
    {
        $startAt = $message->startColumnNumber();
        $endAt = $message->endColumnNumber();
        $lineNumber = $message->lineNumber();

        $stringText = str_pad("^", $startAt, " ", STR_PAD_LEFT);
        $length = $startAt + ($endAt - $startAt);
        $stringText = str_pad($stringText, $length, "^");

        $paddingSpace = str_repeat(' ', strlen((string) $lineNumber) + 1);

        $this->display('    %d: %s', $lineNumber, $message->lineCode());
        $this->display('    %s %s%s', $paddingSpace, $stringText, PHP_EOL);
    }

    private function display(string $format, ...) : void
    {
        $args = Vector {};
        $args->addAll(func_get_args());
        call_user_func_array($this->errorPrinter, $args->toValuesArray());
    }

}
<|endoftext|>