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

#include "chrome/test/in_process_browser_test.h"

#include "base/command_line.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/path_service.h"
#include "base/test/test_file_util.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_shutdown.h"
#include "chrome/browser/browser_window.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/intranet_redirect_detector.h"
#include "chrome/browser/io_thread.h"
#include "chrome/browser/net/url_request_mock_util.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/profile_manager.h"
#include "chrome/browser/renderer_host/render_process_host.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#if defined(OS_WIN)
#include "chrome/browser/views/frame/browser_view.h"
#endif
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/main_function_params.h"
#include "chrome/common/notification_registrar.h"
#include "chrome/common/notification_type.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/testing_browser_process.h"
#include "chrome/test/ui_test_utils.h"
#include "net/base/mock_host_resolver.h"
#include "sandbox/src/dep.h"

#if defined(OS_LINUX)
#include "base/singleton.h"
#include "chrome/browser/renderer_host/render_sandbox_host_linux.h"
#include "chrome/browser/zygote_host_linux.h"

namespace {

// A helper class to do Linux-only initialization only once per process.
class LinuxHostInit {
 public:
  LinuxHostInit() {
    RenderSandboxHostLinux* shost = Singleton<RenderSandboxHostLinux>::get();
    shost->Init("");
    ZygoteHost* zhost = Singleton<ZygoteHost>::get();
    zhost->Init("");
  }
  ~LinuxHostInit() {}
};

}  // namespace
#endif

extern int BrowserMain(const MainFunctionParams&);

const wchar_t kUnitTestShowWindows[] = L"show-windows";

// Default delay for the time-out at which we stop the
// inner-message loop the first time.
const int kInitialTimeoutInMS = 30000;

// Delay for sub-sequent time-outs once the initial time-out happened.
const int kSubsequentTimeoutInMS = 5000;

InProcessBrowserTest::InProcessBrowserTest()
    : browser_(NULL),
      show_window_(false),
      dom_automation_enabled_(false),
      single_process_(false),
      original_single_process_(false),
      initial_timeout_(kInitialTimeoutInMS) {
}

InProcessBrowserTest::~InProcessBrowserTest() {
}

void InProcessBrowserTest::SetUp() {
  // Cleanup the user data dir.
  FilePath user_data_dir;
  PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
  ASSERT_LT(10, static_cast<int>(user_data_dir.value().size())) <<
      "The user data directory name passed into this test was too "
      "short to delete safely.  Please check the user-data-dir "
      "argument and try again.";
  if (ShouldDeleteProfile())
    ASSERT_TRUE(file_util::DieFileDie(user_data_dir, true));

  // The unit test suite creates a testingbrowser, but we want the real thing.
  // Delete the current one. We'll install the testing one in TearDown.
  delete g_browser_process;

  // Don't delete the resources when BrowserMain returns. Many ui classes
  // cache SkBitmaps in a static field so that if we delete the resource
  // bundle we'll crash.
  browser_shutdown::delete_resources_on_shutdown = false;

  CommandLine* command_line = CommandLine::ForCurrentProcessMutable();
  original_command_line_.reset(new CommandLine(*command_line));

  SetUpCommandLine(command_line);

#if defined(OS_WIN)
  // Hide windows on show.
  if (!command_line->HasSwitch(kUnitTestShowWindows) && !show_window_)
    BrowserView::SetShowState(SW_HIDE);
#endif

  if (dom_automation_enabled_)
    command_line->AppendSwitch(switches::kDomAutomationController);

  if (single_process_)
    command_line->AppendSwitch(switches::kSingleProcess);

  // Turn off tip loading for tests; see http://crbug.com/17725
  command_line->AppendSwitch(switches::kDisableWebResources);

  command_line->AppendSwitchWithValue(switches::kUserDataDir,
                                      user_data_dir.ToWStringHack());

  // For some reason the sandbox wasn't happy running in test mode. These
  // tests aren't intended to test the sandbox, so we turn it off.
  command_line->AppendSwitch(switches::kNoSandbox);

  // Don't show the first run ui.
  command_line->AppendSwitch(switches::kNoFirstRun);

  // Single-process mode is not set in BrowserMain so it needs to be processed
  // explicitlty.
  original_single_process_ = RenderProcessHost::run_renderer_in_process();
  if (command_line->HasSwitch(switches::kSingleProcess))
    RenderProcessHost::set_run_renderer_in_process(true);

  // Explicitly set the path of the exe used for the renderer and plugin,
  // otherwise they'll try to use unit_test.exe.
  FilePath subprocess_path;
  PathService::Get(base::FILE_EXE, &subprocess_path);
  subprocess_path = subprocess_path.DirName();
  subprocess_path = subprocess_path.AppendASCII(WideToASCII(
      chrome::kBrowserProcessExecutablePath));
  command_line->AppendSwitchWithValue(switches::kBrowserSubprocessPath,
                                      subprocess_path.ToWStringHack());

  // Enable warning level logging so that we can see when bad stuff happens.
  command_line->AppendSwitch(switches::kEnableLogging);
  command_line->AppendSwitchWithValue(switches::kLoggingLevel,
                                      IntToWString(1));  // warning

  SandboxInitWrapper sandbox_wrapper;
  MainFunctionParams params(*command_line, sandbox_wrapper, NULL);
  params.ui_task =
      NewRunnableMethod(this, &InProcessBrowserTest::RunTestOnMainThreadLoop);

  host_resolver_ = new net::RuleBasedHostResolverProc(
      new IntranetRedirectHostResolverProc(NULL));

  // Something inside the browser does this lookup implicitly. Make it fail
  // to avoid external dependency. It won't break the tests.
  host_resolver_->AddSimulatedFailure("*.google.com");

  // See http://en.wikipedia.org/wiki/Web_Proxy_Autodiscovery_Protocol
  // We don't want the test code to use it.
  host_resolver_->AddSimulatedFailure("wpad");

  net::ScopedDefaultHostResolverProc scoped_host_resolver_proc(
      host_resolver_.get());

  SetUpInProcessBrowserTestFixture();
  BrowserMain(params);
  TearDownInProcessBrowserTestFixture();
}

void InProcessBrowserTest::TearDown() {
  // Reinstall testing browser process.
  delete g_browser_process;
  g_browser_process = new TestingBrowserProcess();

  browser_shutdown::delete_resources_on_shutdown = true;

#if defined(WIN)
  BrowserView::SetShowState(-1);
#endif

  *CommandLine::ForCurrentProcessMutable() = *original_command_line_;
  RenderProcessHost::set_run_renderer_in_process(original_single_process_);
}

HTTPTestServer* InProcessBrowserTest::StartHTTPServer() {
  // The HTTPServer must run on the IO thread.
  DCHECK(!http_server_.get());
  http_server_ = HTTPTestServer::CreateServer(
      L"chrome/test/data",
      g_browser_process->io_thread()->message_loop());
  return http_server_.get();
}

// Creates a browser with a single tab (about:blank), waits for the tab to
// finish loading and shows the browser.
Browser* InProcessBrowserTest::CreateBrowser(Profile* profile) {
  Browser* browser = Browser::Create(profile);

  browser->AddTabWithURL(GURL(chrome::kAboutBlankURL), GURL(),
                         PageTransition::START_PAGE, true, -1, false, NULL);

  // Wait for the page to finish loading.
  ui_test_utils::WaitForNavigation(
      &browser->GetSelectedTabContents()->controller());

  browser->window()->Show();

  return browser;
}

void InProcessBrowserTest::RunTestOnMainThreadLoop() {
  // In the long term it would be great if we could use a TestingProfile
  // here and only enable services you want tested, but that requires all
  // consumers of Profile to handle NULL services.
  FilePath user_data_dir;
  PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
  ProfileManager* profile_manager = g_browser_process->profile_manager();
  Profile* profile = profile_manager->GetDefaultProfile(user_data_dir);
  if (!profile) {
    // We should only be able to get here if the profile already exists and
    // has been created.
    NOTREACHED();
    MessageLoopForUI::current()->Quit();
    return;
  }

  // Before we run the browser, we have to hack the path to the exe to match
  // what it would be if Chrome was running, because it is used to fork renderer
  // processes, on Linux at least (failure to do so will cause a browser_test to
  // be run instead of a renderer).
  FilePath chrome_path;
  CHECK(PathService::Get(base::FILE_EXE, &chrome_path));
  chrome_path = chrome_path.DirName();
#if defined(OS_WIN)
  chrome_path = chrome_path.Append(chrome::kBrowserProcessExecutablePath);
#elif defined(OS_POSIX)
  chrome_path = chrome_path.Append(
      WideToASCII(chrome::kBrowserProcessExecutablePath));
#endif
  CHECK(PathService::Override(base::FILE_EXE, chrome_path));

  ChromeThread::PostTask(
      ChromeThread::IO, FROM_HERE,
      NewRunnableFunction(chrome_browser_net::SetUrlRequestMocksEnabled, true));

#if defined(OS_LINUX)
  // Initialize the RenderSandbox and Zygote hosts. Apparently they get used
  // for InProcessBrowserTest, and this is not the normal browser startup path.
  Singleton<LinuxHostInit>::get();
#endif

  browser_ = CreateBrowser(profile);

  // Start the timeout timer to prevent hangs.
  MessageLoopForUI::current()->PostDelayedTask(FROM_HERE,
      NewRunnableMethod(this, &InProcessBrowserTest::TimedOut),
      initial_timeout_);

  RunTestOnMainThread();
  CleanUpOnMainThread();

  // Close all browser windows.  This might not happen immediately, since some
  // may need to wait for beforeunload and unload handlers to fire in a tab.
  // When all windows are closed, the last window will call Quit().
#if defined(OS_MACOSX)
  // When the browser window closes, Cocoa will generate an inner-loop that
  // processes the RenderProcessHost delete task, so allow task nesting.
  bool old_state = MessageLoopForUI::current()->NestableTasksAllowed();
  MessageLoopForUI::current()->SetNestableTasksAllowed(true);
#endif
  BrowserList::const_iterator browser = BrowserList::begin();
  for (; browser != BrowserList::end(); ++browser)
    (*browser)->CloseWindow();
#if defined(OS_MACOSX)
  MessageLoopForUI::current()->SetNestableTasksAllowed(old_state);
#endif

  // Stop the HTTP server.
  http_server_ = NULL;
}

void InProcessBrowserTest::TimedOut() {
  DCHECK(MessageLoopForUI::current()->IsNested());

  std::string error_message = "Test timed out. Each test runs for a max of ";
  error_message += IntToString(kInitialTimeoutInMS);
  error_message += " ms (kInitialTimeoutInMS).";

  GTEST_NONFATAL_FAILURE_(error_message.c_str());

  // Start the timeout timer to prevent hangs.
  MessageLoopForUI::current()->PostDelayedTask(FROM_HERE,
      NewRunnableMethod(this, &InProcessBrowserTest::TimedOut),
      kSubsequentTimeoutInMS);

  MessageLoopForUI::current()->Quit();
}

void InProcessBrowserTest::SetInitialTimeoutInMS(int timeout_value) {
  DCHECK_GT(timeout_value, 0);
  initial_timeout_ = timeout_value;
}
<commit_msg>Linux: Make sure browser_tests fork()s the helper processes before starting up other threads. BUG=30501<commit_after>// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/test/in_process_browser_test.h"

#include "base/command_line.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/path_service.h"
#include "base/test/test_file_util.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_shutdown.h"
#include "chrome/browser/browser_window.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/intranet_redirect_detector.h"
#include "chrome/browser/io_thread.h"
#include "chrome/browser/net/url_request_mock_util.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/profile_manager.h"
#include "chrome/browser/renderer_host/render_process_host.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#if defined(OS_WIN)
#include "chrome/browser/views/frame/browser_view.h"
#endif
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/main_function_params.h"
#include "chrome/common/notification_registrar.h"
#include "chrome/common/notification_type.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/testing_browser_process.h"
#include "chrome/test/ui_test_utils.h"
#include "net/base/mock_host_resolver.h"
#include "sandbox/src/dep.h"

#if defined(OS_LINUX)
#include "base/singleton.h"
#include "chrome/browser/renderer_host/render_sandbox_host_linux.h"
#include "chrome/browser/zygote_host_linux.h"

namespace {

// A helper class to do Linux-only initialization only once per process.
class LinuxHostInit {
 public:
  LinuxHostInit() {
    RenderSandboxHostLinux* shost = Singleton<RenderSandboxHostLinux>::get();
    shost->Init("");
    ZygoteHost* zhost = Singleton<ZygoteHost>::get();
    zhost->Init("");
  }
  ~LinuxHostInit() {}
};

}  // namespace
#endif

extern int BrowserMain(const MainFunctionParams&);

const wchar_t kUnitTestShowWindows[] = L"show-windows";

// Default delay for the time-out at which we stop the
// inner-message loop the first time.
const int kInitialTimeoutInMS = 30000;

// Delay for sub-sequent time-outs once the initial time-out happened.
const int kSubsequentTimeoutInMS = 5000;

InProcessBrowserTest::InProcessBrowserTest()
    : browser_(NULL),
      show_window_(false),
      dom_automation_enabled_(false),
      single_process_(false),
      original_single_process_(false),
      initial_timeout_(kInitialTimeoutInMS) {
}

InProcessBrowserTest::~InProcessBrowserTest() {
}

void InProcessBrowserTest::SetUp() {
  // Cleanup the user data dir.
  FilePath user_data_dir;
  PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
  ASSERT_LT(10, static_cast<int>(user_data_dir.value().size())) <<
      "The user data directory name passed into this test was too "
      "short to delete safely.  Please check the user-data-dir "
      "argument and try again.";
  if (ShouldDeleteProfile())
    ASSERT_TRUE(file_util::DieFileDie(user_data_dir, true));

  // The unit test suite creates a testingbrowser, but we want the real thing.
  // Delete the current one. We'll install the testing one in TearDown.
  delete g_browser_process;

  // Don't delete the resources when BrowserMain returns. Many ui classes
  // cache SkBitmaps in a static field so that if we delete the resource
  // bundle we'll crash.
  browser_shutdown::delete_resources_on_shutdown = false;

  CommandLine* command_line = CommandLine::ForCurrentProcessMutable();
  original_command_line_.reset(new CommandLine(*command_line));

  SetUpCommandLine(command_line);

#if defined(OS_WIN)
  // Hide windows on show.
  if (!command_line->HasSwitch(kUnitTestShowWindows) && !show_window_)
    BrowserView::SetShowState(SW_HIDE);
#endif

  if (dom_automation_enabled_)
    command_line->AppendSwitch(switches::kDomAutomationController);

  if (single_process_)
    command_line->AppendSwitch(switches::kSingleProcess);

  // Turn off tip loading for tests; see http://crbug.com/17725
  command_line->AppendSwitch(switches::kDisableWebResources);

  command_line->AppendSwitchWithValue(switches::kUserDataDir,
                                      user_data_dir.ToWStringHack());

  // For some reason the sandbox wasn't happy running in test mode. These
  // tests aren't intended to test the sandbox, so we turn it off.
  command_line->AppendSwitch(switches::kNoSandbox);

  // Don't show the first run ui.
  command_line->AppendSwitch(switches::kNoFirstRun);

  // Single-process mode is not set in BrowserMain so it needs to be processed
  // explicitlty.
  original_single_process_ = RenderProcessHost::run_renderer_in_process();
  if (command_line->HasSwitch(switches::kSingleProcess))
    RenderProcessHost::set_run_renderer_in_process(true);

  // Explicitly set the path of the exe used for the renderer and plugin,
  // otherwise they'll try to use unit_test.exe.
  FilePath subprocess_path;
  PathService::Get(base::FILE_EXE, &subprocess_path);
  subprocess_path = subprocess_path.DirName();
  subprocess_path = subprocess_path.AppendASCII(WideToASCII(
      chrome::kBrowserProcessExecutablePath));
  command_line->AppendSwitchWithValue(switches::kBrowserSubprocessPath,
                                      subprocess_path.ToWStringHack());

  // Enable warning level logging so that we can see when bad stuff happens.
  command_line->AppendSwitch(switches::kEnableLogging);
  command_line->AppendSwitchWithValue(switches::kLoggingLevel,
                                      IntToWString(1));  // warning

  SandboxInitWrapper sandbox_wrapper;
  MainFunctionParams params(*command_line, sandbox_wrapper, NULL);
  params.ui_task =
      NewRunnableMethod(this, &InProcessBrowserTest::RunTestOnMainThreadLoop);

  host_resolver_ = new net::RuleBasedHostResolverProc(
      new IntranetRedirectHostResolverProc(NULL));

  // Something inside the browser does this lookup implicitly. Make it fail
  // to avoid external dependency. It won't break the tests.
  host_resolver_->AddSimulatedFailure("*.google.com");

  // See http://en.wikipedia.org/wiki/Web_Proxy_Autodiscovery_Protocol
  // We don't want the test code to use it.
  host_resolver_->AddSimulatedFailure("wpad");

  net::ScopedDefaultHostResolverProc scoped_host_resolver_proc(
      host_resolver_.get());

  SetUpInProcessBrowserTestFixture();

  // Before we run the browser, we have to hack the path to the exe to match
  // what it would be if Chrome was running, because it is used to fork renderer
  // processes, on Linux at least (failure to do so will cause a browser_test to
  // be run instead of a renderer).
  FilePath chrome_path;
  CHECK(PathService::Get(base::FILE_EXE, &chrome_path));
  chrome_path = chrome_path.DirName();
#if defined(OS_WIN)
  chrome_path = chrome_path.Append(chrome::kBrowserProcessExecutablePath);
#elif defined(OS_POSIX)
  chrome_path = chrome_path.Append(
      WideToASCII(chrome::kBrowserProcessExecutablePath));
#endif
  CHECK(PathService::Override(base::FILE_EXE, chrome_path));

#if defined(OS_LINUX)
  // Initialize the RenderSandbox and Zygote hosts. Apparently they get used
  // for InProcessBrowserTest, and this is not the normal browser startup path.
  Singleton<LinuxHostInit>::get();
#endif

  BrowserMain(params);
  TearDownInProcessBrowserTestFixture();
}

void InProcessBrowserTest::TearDown() {
  // Reinstall testing browser process.
  delete g_browser_process;
  g_browser_process = new TestingBrowserProcess();

  browser_shutdown::delete_resources_on_shutdown = true;

#if defined(WIN)
  BrowserView::SetShowState(-1);
#endif

  *CommandLine::ForCurrentProcessMutable() = *original_command_line_;
  RenderProcessHost::set_run_renderer_in_process(original_single_process_);
}

HTTPTestServer* InProcessBrowserTest::StartHTTPServer() {
  // The HTTPServer must run on the IO thread.
  DCHECK(!http_server_.get());
  http_server_ = HTTPTestServer::CreateServer(
      L"chrome/test/data",
      g_browser_process->io_thread()->message_loop());
  return http_server_.get();
}

// Creates a browser with a single tab (about:blank), waits for the tab to
// finish loading and shows the browser.
Browser* InProcessBrowserTest::CreateBrowser(Profile* profile) {
  Browser* browser = Browser::Create(profile);

  browser->AddTabWithURL(GURL(chrome::kAboutBlankURL), GURL(),
                         PageTransition::START_PAGE, true, -1, false, NULL);

  // Wait for the page to finish loading.
  ui_test_utils::WaitForNavigation(
      &browser->GetSelectedTabContents()->controller());

  browser->window()->Show();

  return browser;
}

void InProcessBrowserTest::RunTestOnMainThreadLoop() {
  // In the long term it would be great if we could use a TestingProfile
  // here and only enable services you want tested, but that requires all
  // consumers of Profile to handle NULL services.
  FilePath user_data_dir;
  PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
  ProfileManager* profile_manager = g_browser_process->profile_manager();
  Profile* profile = profile_manager->GetDefaultProfile(user_data_dir);
  if (!profile) {
    // We should only be able to get here if the profile already exists and
    // has been created.
    NOTREACHED();
    MessageLoopForUI::current()->Quit();
    return;
  }

  ChromeThread::PostTask(
      ChromeThread::IO, FROM_HERE,
      NewRunnableFunction(chrome_browser_net::SetUrlRequestMocksEnabled, true));

  browser_ = CreateBrowser(profile);

  // Start the timeout timer to prevent hangs.
  MessageLoopForUI::current()->PostDelayedTask(FROM_HERE,
      NewRunnableMethod(this, &InProcessBrowserTest::TimedOut),
      initial_timeout_);

  RunTestOnMainThread();
  CleanUpOnMainThread();

  // Close all browser windows.  This might not happen immediately, since some
  // may need to wait for beforeunload and unload handlers to fire in a tab.
  // When all windows are closed, the last window will call Quit().
#if defined(OS_MACOSX)
  // When the browser window closes, Cocoa will generate an inner-loop that
  // processes the RenderProcessHost delete task, so allow task nesting.
  bool old_state = MessageLoopForUI::current()->NestableTasksAllowed();
  MessageLoopForUI::current()->SetNestableTasksAllowed(true);
#endif
  BrowserList::const_iterator browser = BrowserList::begin();
  for (; browser != BrowserList::end(); ++browser)
    (*browser)->CloseWindow();
#if defined(OS_MACOSX)
  MessageLoopForUI::current()->SetNestableTasksAllowed(old_state);
#endif

  // Stop the HTTP server.
  http_server_ = NULL;
}

void InProcessBrowserTest::TimedOut() {
  DCHECK(MessageLoopForUI::current()->IsNested());

  std::string error_message = "Test timed out. Each test runs for a max of ";
  error_message += IntToString(kInitialTimeoutInMS);
  error_message += " ms (kInitialTimeoutInMS).";

  GTEST_NONFATAL_FAILURE_(error_message.c_str());

  // Start the timeout timer to prevent hangs.
  MessageLoopForUI::current()->PostDelayedTask(FROM_HERE,
      NewRunnableMethod(this, &InProcessBrowserTest::TimedOut),
      kSubsequentTimeoutInMS);

  MessageLoopForUI::current()->Quit();
}

void InProcessBrowserTest::SetInitialTimeoutInMS(int timeout_value) {
  DCHECK_GT(timeout_value, 0);
  initial_timeout_ = timeout_value;
}
<|endoftext|>


<commit_before>////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2014 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
//    you must not claim that you wrote the original software.
//    If you use this software in a product, an acknowledgment
//    in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
//    and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////

#ifndef LUA_PARSER_HPP
#define LUA_PARSER_HPP

////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////

#include <ResourceData.hpp>

////////////////////////////////////////////////////////////
/// Lua Parser that takes in a path name, and returns a list<ResourceData>.
/// The Parser will
////////////////////////////////////////////////////////////
<commit_msg>Header guards for LuaParser.hpp<commit_after>////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2014 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
//    you must not claim that you wrote the original software.
//    If you use this software in a product, an acknowledgment
//    in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
//    and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////

#ifndef LUA_PARSER_HPP
#define LUA_PARSER_HPP

////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////

#include <ResourceData.hpp>

////////////////////////////////////////////////////////////
/// Lua Parser that takes in a path name, and returns a list<ResourceData>.
/// The Parser will
////////////////////////////////////////////////////////////

#endif //LUA_PARSER_HPP<|endoftext|>


<commit_before>#ifndef ORM_DEBUG_HPP
#define ORM_DEBUG_HPP

#define ORM_DEFAULT_MAX_DEPTH 1 ///< maximum depth
#define ORM_ALLOW_EXCEPTION 1 ///< let them ?

/**********************************
 ******* DEBUG MOD ****************
 *********************************/
#define ORM_DEGUG_NO 0 ///< no debug print
#define ORM_DEBUG_SQL 1<<1 ///< print sql
#define ORM_DEBUG_REGISTER 1<<2 ///< print regiter of class
#define ORM_DEBUG_GET_OBJ 1<<3 ///< print object construction
#define ORM_DEBUG_GET_ATTR 1<<4 ///< print attr construction (verbose)

#define ORM_DEBUG_FULL (0xFFFF) ///< all debug mods

//#define ORM_DEBUG (ORM_DEBUG_REGISTER)
#define ORM_DEBUG (ORM_DEBUG_SQL | ORM_DEBUG_REGISTER | ORM_DEBUG_GET_ATTR)
//#define ORM_DEBUG (ORM_DEBUG_FULL) ///<current debug mod

#if ORM_DEBUG > 0
#include <iostream>
#endif

/*******************************
 ******** VEREBOSITY ***********
 ******************************/
#define ORM_VERBOSE 1<<1 ///< Notification
#define ORM_WARNING 1<<2 ///< semi important, could change the running
#define ORM_ERROR   1<<3 ///< critical

//#define ORM_VERBOSITY (ORM_VERBOSE | ORM_WARNING | ORM_ERROR) ///< current verbosity
#define ORM_VERBOSITY (ORM_ERROR) ///< current verbosity

/*** print macros ****/

#if ORM_VERBOSITY & ORM_ERROR
#define ORM_PRINT_ERROR(txt) {std::cerr<<ROUGE<<"[ERROR]("<<__FILE__<<":"<<__LINE__<<") "<<txt<<BLANC<<std::endl;}
#else
#define ORM_PRINT_ERROR(txt) {}
#endif

#if ORM_VERBOSITY & ORM_WARNING
#define ORM_PRINT_WARNING(txt) {std::cerr<<JAUNE<<"[WARNING]("<<__FILE__<<":"<<__LINE__<<") "<<txt<<BLANC<<std::endl;}
#else
#define ORM_PRINT_WARNING(txt) {}
#endif

#if ORM_VERBOSITY & ORM_VERBOSE
#define ORM_PRINT_VERBOSE(txt) {std::cerr<<COMMENTAIRE<<"[VERBOSE]("<<__FILE__<<":"<<__LINE__<<") "<<txt<<BLANC<<std::endl;}
#else
#define ORM_PRINT_VERBOSE(txt) {}
#endif

/**************************
******** COLORS ***********
**************************/

#define ROUGE  	"\033[31m"
#define VERT   	"\033[32m"
#define JAUNE  	"\033[33m"
#define BLEU   	"\033[34m"
#define MAGENTA "\033[35m"
#define LMAGENTA "\033[01;35m"
#define BLEU2 "\033[36m"
#define COMMENTAIRE "\033[31m"
#define BLANC 	"\033[00m"

#endif
<commit_msg>remove debug<commit_after>#ifndef ORM_DEBUG_HPP
#define ORM_DEBUG_HPP

#define ORM_DEFAULT_MAX_DEPTH 1 ///< maximum depth
#define ORM_ALLOW_EXCEPTION 1 ///< let them ?

/**********************************
 ******* DEBUG MOD ****************
 *********************************/
#define ORM_DEGUG_NO 0 ///< no debug print
#define ORM_DEBUG_SQL 1<<1 ///< print sql
#define ORM_DEBUG_REGISTER 1<<2 ///< print regiter of class
#define ORM_DEBUG_GET_OBJ 1<<3 ///< print object construction
#define ORM_DEBUG_GET_ATTR 1<<4 ///< print attr construction (verbose)

#define ORM_DEBUG_FULL (0xFFFF) ///< all debug mods

#define ORM_DEBUG (ORM_DEBUG_REGISTER)
//#define ORM_DEBUG (ORM_DEBUG_SQL | ORM_DEBUG_REGISTER | ORM_DEBUG_GET_ATTR)
//#define ORM_DEBUG (ORM_DEBUG_FULL) ///<current debug mod

#if ORM_DEBUG > 0
#include <iostream>
#endif

/*******************************
 ******** VEREBOSITY ***********
 ******************************/
#define ORM_VERBOSE 1<<1 ///< Notification
#define ORM_WARNING 1<<2 ///< semi important, could change the running
#define ORM_ERROR   1<<3 ///< critical

//#define ORM_VERBOSITY (ORM_VERBOSE | ORM_WARNING | ORM_ERROR) ///< current verbosity
#define ORM_VERBOSITY (ORM_ERROR) ///< current verbosity

/*** print macros ****/

#if ORM_VERBOSITY & ORM_ERROR
#define ORM_PRINT_ERROR(txt) {std::cerr<<ROUGE<<"[ERROR]("<<__FILE__<<":"<<__LINE__<<") "<<txt<<BLANC<<std::endl;}
#else
#define ORM_PRINT_ERROR(txt) {}
#endif

#if ORM_VERBOSITY & ORM_WARNING
#define ORM_PRINT_WARNING(txt) {std::cerr<<JAUNE<<"[WARNING]("<<__FILE__<<":"<<__LINE__<<") "<<txt<<BLANC<<std::endl;}
#else
#define ORM_PRINT_WARNING(txt) {}
#endif

#if ORM_VERBOSITY & ORM_VERBOSE
#define ORM_PRINT_VERBOSE(txt) {std::cerr<<COMMENTAIRE<<"[VERBOSE]("<<__FILE__<<":"<<__LINE__<<") "<<txt<<BLANC<<std::endl;}
#else
#define ORM_PRINT_VERBOSE(txt) {}
#endif

/**************************
******** COLORS ***********
**************************/

#define ROUGE  	"\033[31m"
#define VERT   	"\033[32m"
#define JAUNE  	"\033[33m"
#define BLEU   	"\033[34m"
#define MAGENTA "\033[35m"
#define LMAGENTA "\033[01;35m"
#define BLEU2 "\033[36m"
#define COMMENTAIRE "\033[31m"
#define BLANC 	"\033[00m"

#endif
<|endoftext|>


<commit_before>#ifndef STATUSBAR_HPP
#define STATUSBAR_HPP

#include <nana/gui/widgets/label.hpp>

class StatusBar : public nana::label
{
public:
    class Color
    {
    public:
        inline static nana::color FINISHED{5,255,51};
        inline static nana::color PROCESSING{255,128,0};
        inline static nana::color ERRORED{153,0,0};
    };
    explicit StatusBar(nana::window window);
    void change_color(const nana::color& color);
    void change_text(std::string text);
};

#endif<commit_msg>Added constness to colors defined in StatusBar::Color.<commit_after>#ifndef STATUSBAR_HPP
#define STATUSBAR_HPP

#include <nana/gui/widgets/label.hpp>

class StatusBar : public nana::label
{
public:
    class Color
    {
    public:
        inline const static nana::color FINISHED{5,255,51};
        inline const static nana::color PROCESSING{255,128,0};
        inline const static nana::color ERRORED{153,0,0};
    };
    explicit StatusBar(nana::window window);
    void change_color(const nana::color& color);
    void change_text(std::string text);
};

#endif<|endoftext|>


<commit_before>#include <utility>
#include "bitset.hpp"

template<typename T>
T* operatorNewCopiedArray(const T * source, size_t source_count, size_t destination_size) /*strong*/
{
	T* new_array = nullptr;
	size_t n_placed_elements = 0;
	try {
		new_array = static_cast<T*>(operator new(destination_size * sizeof(T)));
		for (size_t i = 0; i < source_count; ++i) {
			construct(&new_array[i], source[i]);
			++n_placed_elements;
		}
	}
	catch (...) {
		destroy(new_array, new_array + n_placed_elements);
		operator delete(new_array);
		throw;
	}
	return new_array;
}

template <typename T>
class allocator
{
public:
	explicit allocator(size_t size = 0); /*strong*/
	allocator(allocator const & other); /*strong*/
	auto operator=(allocator const & other) -> allocator & = delete;
	~allocator();

	auto resize() -> void; /*strong*/

	auto construct(size_t index, T const & value) -> void; /*strong*/
	auto destroy(size_t index) -> void; /*noexcept*/

	auto get() -> T * { return ptr_; } /*noexcept*/
	auto get() const -> T const * { return ptr_; } /*noexcept*/
	auto getElement(size_t index) -> T & { return ptr_[index]; } /*noexcept*/
	auto getElement(size_t index) const -> T const & { return ptr_[index]; } /*noexcept*/

	auto count() const -> size_t { return map_->counter(); } /*noexcept*/
	bool full() const { return map_->counter() == size_; } /*noexcept*/
	bool empty() const { return map_->counter() == 0; } /*noexcept*/
	void swap(allocator & other); /*noexcept*/
private:
	//auto destroy(T * first, T * last) -> void; /*noexcept*/

	T * ptr_;
	size_t size_;
	std::unique_ptr<bitset> map_;
};

template<typename T>
allocator<T>::allocator(size_t size)
	: ptr_(static_cast<T*>(operator new(size * sizeof(T)))),
	size_(size),
	map_(std::make_unique<bitset>(size))
{
	;
}

template<typename T>
allocator<T>::allocator(allocator const & other)
	: allocator<T>(other.size_)
{
	try {
		for (size_t i = 0; i < size_; ++i) {
			construct(i, other.ptr_[i]);
		}
	}
	catch (...) {
		this->~allocator();
	}
}

template<typename T>
allocator<T>::~allocator() {
	for (size_t i = 0; i < size_; ++i) {
		if (map_->test(i)) {
			this->destroy(i);
		}
	}
	operator delete(ptr_);
}

template<typename T>
void allocator<T>::resize() {
	allocator<T> temp((size_ * 3) / 2 + 1);
	for (size_t i = 0; i < size_; ++i) {
		if (map_->test(i)) {
			temp.construct(i, ptr_[i]);
		}
	}
	this->swap(temp);
}

template<typename T>
void allocator<T>::construct(size_t index, T const & value) {
	if (index < size_) {
		new (&(ptr_[index])) T(value);
		map_->set(index);
	}
	else {
		throw("index >= size_");
	}
}

template<typename T>
void allocator<T>::destroy(size_t index) {
	if (index < size_) {
		if (map_->test(index)) {
			ptr_->~T();
			map_->reset(index);
		}
		else {
			throw ("memory is occupied");
		}
	}
	else {
		throw ("index >= size_");
	}
}

/*template<typename T>
auto allocator<T>::destroy(T * first, T * last)->void {
	if (first >= ptr_&&last <= ptr_ + this->count())
		for (; first != last; ++first) {
			destroy(&*first);
		}
}*/

template<typename T>
void allocator<T>::swap(allocator & other) {
	std::swap(ptr_, other.ptr_);
	std::swap(size_, other.size_);
	std::swap(map_, other.map_);
}
<commit_msg>Update allocator.hpp<commit_after>#include <utility>
#include "bitset.hpp"

template<typename T>
T* operatorNewCopiedArray(const T * source, size_t source_count, size_t destination_size) /*strong*/
{
	T* new_array = nullptr;
	size_t n_placed_elements = 0;
	try {
		new_array = static_cast<T*>(operator new(destination_size * sizeof(T)));
		for (size_t i = 0; i < source_count; ++i) {
			construct(&new_array[i], source[i]);
			++n_placed_elements;
		}
	}
	catch (...) {
		destroy(new_array, new_array + n_placed_elements);
		operator delete(new_array);
		throw;
	}
	return new_array;
}

template <typename T>
class allocator
{
public:
	explicit allocator(size_t size = 0); /*strong*/
	allocator(allocator const & other); /*strong*/
	auto operator=(allocator const & other) -> allocator & = delete;
	~allocator();

	auto resize() -> void; /*strong*/

	auto construct(size_t index, T const & value) -> void; /*strong*/
	auto destroy(size_t index) -> void; /*noexcept*/

	auto get() -> T * { return ptr_; } /*noexcept*/
	auto get() const -> T const * { return ptr_; } /*noexcept*/
	auto getElement(size_t index) -> T & { return ptr_[index]; } /*noexcept*/
	auto getElement(size_t index) const -> T const & { return ptr_[index]; } /*noexcept*/

	auto count() const -> size_t { return map_->counter(); } /*noexcept*/
	bool full() const { return map_->counter() == size_; } /*noexcept*/
	bool empty() const { return map_->counter() == 0; } /*noexcept*/
	void swap(allocator & other); /*noexcept*/
private:
	//auto destroy(T * first, T * last) -> void; /*noexcept*/

	T * ptr_;
	size_t size_;
	std::unique_ptr<bitset> map_;
};

template<typename T>
allocator<T>::allocator(size_t size)
	: ptr_(static_cast<T*>(operator new(size * sizeof(T)))),
	size_(size),
	map_(std::make_unique<bitset>(size))
{
	;
}

template<typename T>
allocator<T>::allocator(allocator const & other)
	: allocator<T>(other.size_)
{
	try {
		for (size_t i = 0; i < size_; ++i) {
			construct(i, other.ptr_[i]);
		}
	}
	catch (...) {
		this->~allocator();
		throw;
	}
}

template<typename T>
allocator<T>::~allocator() {
	for (size_t i = 0; i < size_; ++i) {
		if (map_->test(i)) {
			this->destroy(i);
		}
	}
	operator delete(ptr_);
}

template<typename T>
void allocator<T>::resize() {
	allocator<T> temp((size_ * 3) / 2 + 1);
	for (size_t i = 0; i < size_; ++i) {
		if (map_->test(i)) {
			temp.construct(i, ptr_[i]);
		}
	}
	this->swap(temp);
}

template<typename T>
void allocator<T>::construct(size_t index, T const & value) {
	if (index < size_) {
		new (&(ptr_[index])) T(value);
		map_->set(index);
	}
	else {
		throw("index >= size_");
	}
}

template<typename T>
void allocator<T>::destroy(size_t index) {
	if (index < size_) {
		if (map_->test(index)) {
			ptr_->~T();
			map_->reset(index);
		}
		else {
			throw ("memory is occupied");
		}
	}
	else {
		throw ("index >= size_");
	}
}

/*template<typename T>
auto allocator<T>::destroy(T * first, T * last)->void {
	if (first >= ptr_&&last <= ptr_ + this->count())
		for (; first != last; ++first) {
			destroy(&*first);
		}
}*/

template<typename T>
void allocator<T>::swap(allocator & other) {
	std::swap(ptr_, other.ptr_);
	std::swap(size_, other.size_);
	std::swap(map_, other.map_);
}
<|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: char.hxx,v $
 * $Revision: 1.3 $
 *
 * 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 _CHAR_HXX
#define _CHAR_HXX

#include <tools/string.hxx>

/******************* T y p e s *******************************************/
class SvChar
{
public:
    static BOOL MakeChar( char * pChar, char ** ppStr );
    static char * GetTable( CharSet nSource, CharSet nDest );
};

#endif // _CHAR_HXX
<commit_msg>INTEGRATION: CWS mba30patches01 (1.2.56); FILE MERGED 2008/04/23 09:44:49 mba 1.2.56.2: RESYNC: (1.2-1.3); FILE MERGED 2008/03/18 15:40:03 mba 1.2.56.1: #i86353#: remove unused code<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: char.hxx,v $
 * $Revision: 1.4 $
 *
 * 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 _CHAR_HXX
#define _CHAR_HXX

#include <tools/string.hxx>

/******************* T y p e s *******************************************/
class SvChar
{
public:
    static char * GetTable( CharSet nSource, CharSet nDest );
};

#endif // _CHAR_HXX
<|endoftext|>


<commit_before>
#define CL_USE_DEPRECATED_OPENCL_1_1_APIS
#if defined(__APPLE__) || defined(__MACOSX)
#include <OpenCL/cl.h>
#else
#include <CL/cl.h>
#endif

#include <vector>
#include <string>
#include <iostream>
#include <sstream>

using namespace std;

string channelOrderName(cl_channel_order chan) {
    switch(chan) {
       case CL_R              : return "CL_R            ";
       case CL_A              : return "CL_A            ";
       case CL_RG             : return "CL_RG           ";
       case CL_RA             : return "CL_RA           ";
       case CL_RGB            : return "CL_RGB          ";
       case CL_RGBA           : return "CL_RGBA         ";
       case CL_BGRA           : return "CL_BGRA         ";
       case CL_ARGB           : return "CL_ARGB         ";
       case CL_INTENSITY      : return "CL_INTENSITY    ";
       case CL_LUMINANCE      : return "CL_LUMINANCE    ";
       case CL_Rx             : return "CL_Rx           ";
       case CL_RGx            : return "CL_RGx          ";
       case CL_RGBx           : return "CL_RGBx         ";
       case CL_DEPTH          : return "CL_DEPTH        ";
       case CL_DEPTH_STENCIL  : return "CL_DEPTH_STENCIL";
       default:
        std::ostringstream ss;
        ss << "Unknown order (" << chan << ")";
        return ss.str();
    }
}

string channelTypeName(cl_channel_type chan) {
    switch(chan) {
    case CL_SNORM_INT8        : return "CL_SNORM_INT8      ";
    case CL_SNORM_INT16       : return "CL_SNORM_INT16     ";
    case CL_UNORM_INT8        : return "CL_UNORM_INT8      ";
    case CL_UNORM_INT16       : return "CL_UNORM_INT16     ";
    case CL_UNORM_SHORT_565   : return "CL_UNORM_SHORT_565 ";
    case CL_UNORM_SHORT_555   : return "CL_UNORM_SHORT_555 ";
    case CL_UNORM_INT_101010  : return "CL_UNORM_INT_101010";
    case CL_SIGNED_INT8       : return "CL_SIGNED_INT8     ";
    case CL_SIGNED_INT16      : return "CL_SIGNED_INT16    ";
    case CL_SIGNED_INT32      : return "CL_SIGNED_INT32    ";
    case CL_UNSIGNED_INT8     : return "CL_UNSIGNED_INT8   ";
    case CL_UNSIGNED_INT16    : return "CL_UNSIGNED_INT16  ";
    case CL_UNSIGNED_INT32    : return "CL_UNSIGNED_INT32  ";
    case CL_HALF_FLOAT        : return "CL_HALF_FLOAT      ";
    case CL_FLOAT             : return "CL_FLOAT           ";
    case CL_UNORM_INT24       : return "CL_UNORM_INT24     ";
    default:
     std::ostringstream ss;
     ss << "Unknown type (" << chan << ")";
     return ss.str();
    }
}

int main(int argc, char** argv) {

    // Find the platforms
    //
    cl_uint numPlatforms;
    clGetPlatformIDs(0, NULL, &numPlatforms);
    if(numPlatforms==0) {
        cout << "No OpenCL platform found";
        return 1;
    }
    vector<cl_platform_id> platformIds(numPlatforms);
    clGetPlatformIDs(numPlatforms, &platformIds[0], NULL);

    // Iterate the platforms
    //
    for(auto &plat : platformIds){

        size_t size;
        clGetPlatformInfo(plat, CL_PLATFORM_NAME, 0, NULL, &size);
        vector<char> platformName(size);
        clGetPlatformInfo(plat, CL_PLATFORM_NAME, size, &platformName[0], NULL);
        cout << "Platform: " << string(platformName.begin(), platformName.end()-1) << "\n";

        cl_uint numDevAvail;
        clGetDeviceIDs(plat, CL_DEVICE_TYPE_ALL, 0, NULL, &numDevAvail);
        if(numDevAvail) {

            vector<cl_device_id> devAvail(numDevAvail);
            clGetDeviceIDs(plat, CL_DEVICE_TYPE_ALL, numDevAvail, &devAvail[0], NULL);

            // Iterate the devices on the platform
            //
            for(auto &dev : devAvail) {

                clGetDeviceInfo(dev, CL_DEVICE_NAME, 0, NULL, &size);
                vector<char> devName(size);
                clGetDeviceInfo(dev, CL_DEVICE_NAME, size, &devName[0], NULL);
                cout << "  Device: " << string(devName.begin(), devName.end()-1) << "\n";

                // check if it supports images
                cl_bool imageSupport = CL_FALSE;
                clGetDeviceInfo(dev, CL_DEVICE_IMAGE_SUPPORT, sizeof(cl_bool), &imageSupport, NULL);
                if ( imageSupport == CL_FALSE ) {
                    cout << "  Does not support images.\n";
                    continue;
                }

                // Create a context
                //
                cl_int err;
                cl_context_properties properties [] = {CL_CONTEXT_PLATFORM, (cl_context_properties)plat, 0};
                cl_context context = clCreateContext( properties, 1, &dev, NULL, NULL, &err);
                if (err != CL_SUCCESS) {
                    cout << "  Could not create context.\n";
                    continue;
                }

                // Enumerate the image formats
                //
                cl_uint nbFormats;
                clGetSupportedImageFormats( context, CL_MEM_READ_WRITE, CL_MEM_OBJECT_IMAGE2D, 0, NULL, &nbFormats );
                vector<cl_image_format> formats(nbFormats);
                clGetSupportedImageFormats( context, CL_MEM_READ_WRITE, CL_MEM_OBJECT_IMAGE2D, nbFormats, &formats[0], NULL );
                for(auto &form : formats)
                    cout << "  "  << channelOrderName(form.image_channel_order)
                         << " - " << channelTypeName (form.image_channel_data_type)
                         << "\n";
            }

        }
    }
}
<commit_msg>Cosmetic change<commit_after>
#define CL_USE_DEPRECATED_OPENCL_1_1_APIS
#if defined(__APPLE__) || defined(__MACOSX)
#include <OpenCL/cl.h>
#else
#include <CL/cl.h>
#endif

#include <vector>
#include <string>
#include <iostream>
#include <sstream>

using namespace std;

string channelOrderName(cl_channel_order chan) {
    switch(chan) {
       case CL_R              : return "CL_R            ";
       case CL_A              : return "CL_A            ";
       case CL_RG             : return "CL_RG           ";
       case CL_RA             : return "CL_RA           ";
       case CL_RGB            : return "CL_RGB          ";
       case CL_RGBA           : return "CL_RGBA         ";
       case CL_BGRA           : return "CL_BGRA         ";
       case CL_ARGB           : return "CL_ARGB         ";
       case CL_INTENSITY      : return "CL_INTENSITY    ";
       case CL_LUMINANCE      : return "CL_LUMINANCE    ";
       case CL_Rx             : return "CL_Rx           ";
       case CL_RGx            : return "CL_RGx          ";
       case CL_RGBx           : return "CL_RGBx         ";
       case CL_DEPTH          : return "CL_DEPTH        ";
       case CL_DEPTH_STENCIL  : return "CL_DEPTH_STENCIL";
       default:
        std::ostringstream ss;
        ss << "Unknown order (" << chan << ")";
        return ss.str();
    }
}

string channelTypeName(cl_channel_type chan) {
    switch(chan) {
    case CL_SNORM_INT8        : return "CL_SNORM_INT8      ";
    case CL_SNORM_INT16       : return "CL_SNORM_INT16     ";
    case CL_UNORM_INT8        : return "CL_UNORM_INT8      ";
    case CL_UNORM_INT16       : return "CL_UNORM_INT16     ";
    case CL_UNORM_SHORT_565   : return "CL_UNORM_SHORT_565 ";
    case CL_UNORM_SHORT_555   : return "CL_UNORM_SHORT_555 ";
    case CL_UNORM_INT_101010  : return "CL_UNORM_INT_101010";
    case CL_SIGNED_INT8       : return "CL_SIGNED_INT8     ";
    case CL_SIGNED_INT16      : return "CL_SIGNED_INT16    ";
    case CL_SIGNED_INT32      : return "CL_SIGNED_INT32    ";
    case CL_UNSIGNED_INT8     : return "CL_UNSIGNED_INT8   ";
    case CL_UNSIGNED_INT16    : return "CL_UNSIGNED_INT16  ";
    case CL_UNSIGNED_INT32    : return "CL_UNSIGNED_INT32  ";
    case CL_HALF_FLOAT        : return "CL_HALF_FLOAT      ";
    case CL_FLOAT             : return "CL_FLOAT           ";
    case CL_UNORM_INT24       : return "CL_UNORM_INT24     ";
    default:
     std::ostringstream ss;
     ss << "Unknown type (" << chan << ")";
     return ss.str();
    }
}

int main(int argc, char** argv) {

    // Find the platforms
    //
    cl_uint numPlatforms;
    clGetPlatformIDs(0, NULL, &numPlatforms);
    if(numPlatforms==0) {
        cout << "No OpenCL platform found";
        return 1;
    }
    vector<cl_platform_id> platformIds(numPlatforms);
    clGetPlatformIDs(numPlatforms, &platformIds[0], NULL);

    // Iterate the platforms
    //
    for(auto &plat : platformIds){

        size_t size;
        clGetPlatformInfo(plat, CL_PLATFORM_NAME, 0, NULL, &size);
        vector<char> platformName(size);
        clGetPlatformInfo(plat, CL_PLATFORM_NAME, size, &platformName[0], NULL);
        cout << "Platform: " << string(platformName.begin(), platformName.end()-1) << "\n";

        cl_uint numDevAvail;
        clGetDeviceIDs(plat, CL_DEVICE_TYPE_ALL, 0, NULL, &numDevAvail);
        if(numDevAvail) {

            vector<cl_device_id> devAvail(numDevAvail);
            clGetDeviceIDs(plat, CL_DEVICE_TYPE_ALL, numDevAvail, &devAvail[0], NULL);

            // Iterate the devices on the platform
            //
            for(auto &dev : devAvail) {

                clGetDeviceInfo(dev, CL_DEVICE_NAME, 0, NULL, &size);
                vector<char> devName(size);
                clGetDeviceInfo(dev, CL_DEVICE_NAME, size, &devName[0], NULL);
                cout << "  Device: " << string(devName.begin(), devName.end()-1) << "\n";

                // check if it supports images
                cl_bool imageSupport = CL_FALSE;
                clGetDeviceInfo(dev, CL_DEVICE_IMAGE_SUPPORT, sizeof(cl_bool), &imageSupport, NULL);
                if ( imageSupport == CL_FALSE ) {
                    cout << "  Does not support images.\n";
                    continue;
                }

                // Create a context
                //
                cl_int err;
                cl_context_properties properties [] = {CL_CONTEXT_PLATFORM, (cl_context_properties)plat, 0};
                cl_context context = clCreateContext( properties, 1, &dev, NULL, NULL, &err);
                if (err != CL_SUCCESS) {
                    cout << "  Could not create context.\n";
                    continue;
                }

                // Enumerate the image formats
                //
                cl_uint nbFormats;
                clGetSupportedImageFormats( context, CL_MEM_READ_WRITE, CL_MEM_OBJECT_IMAGE2D, 0, NULL, &nbFormats );
                vector<cl_image_format> formats(nbFormats);
                clGetSupportedImageFormats( context, CL_MEM_READ_WRITE, CL_MEM_OBJECT_IMAGE2D, nbFormats, &formats[0], NULL );
                for(auto &form : formats)
                    cout << "    "  << channelOrderName(form.image_channel_order)
                         << " - "   << channelTypeName (form.image_channel_data_type)
                         << "\n";
            }

        }
    }
}
<|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: root.hxx,v $
 * $Revision: 1.43 $
 *
 * 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 _ROOT_HXX
#define _ROOT_HXX

#include <tools/solar.h>
#include "global.hxx"
#include "address.hxx"
#include "flttypes.hxx"
#include "filter.hxx"
#include "excdefs.hxx"

class ScRangeName;

class NameBuffer;
class RangeNameBufferWK3;
class ShrfmlaBuffer;
class ExtNameBuff;
class ExtSheetBuffer;
class ExcelToSc;

class XclImpAutoFilterBuffer;
class XclImpPivotCacheList;
class _ScRangeListTabs;

class XclExpChTrTabId;
class XclExpUserBViewList;

class XclObjList;
class XclEscher;

class XclImpRoot;
class XclExpRoot;

// ---------------------------------------------------------- Excel Imp~/Exp~ -

struct RootData     // -> Inkarnation jeweils im ImportExcel-Objekt!
{
    BiffTyp             eDateiTyp;              // feine Differenzierung
    ExtSheetBuffer*     pExtSheetBuff;
    NameBuffer*         pTabNameBuff;
    ShrfmlaBuffer*      pShrfmlaBuff;
    ExtNameBuff*        pExtNameBuff;
    ExcelToSc*          pFmlaConverter;

    // Biff8
    XclImpAutoFilterBuffer* pAutoFilterBuffer;      // ranges for autofilter and advanced filter
    _ScRangeListTabs*       pPrintRanges;
    _ScRangeListTabs*       pPrintTitles;

    // Erweiterungen fuer Export
    XclExpChTrTabId*        pTabId;             // pointer to rec list, do not destroy
    XclExpUserBViewList*    pUserBViewList;     // pointer to rec list, do not destroy

    // Biff8
    XclObjList*         pObjRecs;
    XclEscher*          pEscher;

    XclImpRoot*         pIR;
    XclExpRoot*         pER;

                        RootData( void );       // -> exctools.cxx
                        ~RootData();            // -> exctools.cxx
};

class ExcRoot
{
protected:
    RootData*       pExcRoot;
    inline          ExcRoot( RootData* pNexExcRoot ) : pExcRoot( pNexExcRoot ) {}
    inline          ExcRoot( const ExcRoot& rCopy ) : pExcRoot( rCopy.pExcRoot ) {}
};

// ---------------------------------------------------------- Lotus Imp~/Exp~ -

class LotusRangeList;
class LotusFontBuffer;
class LotAttrTable;

struct LOTUS_ROOT
{
    ScDocument*         pDoc;
    LotusRangeList*     pRangeNames;
    ScRangeName*        pScRangeName;
    CharSet             eCharsetQ;
    Lotus123Typ         eFirstType;
    Lotus123Typ         eActType;
    ScRange             aActRange;
    RangeNameBufferWK3* pRngNmBffWK3;
    LotusFontBuffer*    pFontBuff;
    LotAttrTable*       pAttrTable;
};

extern LOTUS_ROOT*      pLotusRoot; // -> Inkarn. in filter.cxx

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

#endif

<commit_msg>INTEGRATION: CWS dr61 (1.43.16); FILE MERGED 2008/05/19 12:24:02 dr 1.43.16.1: #i10000# removed remaining include guards<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: root.hxx,v $
 * $Revision: 1.44 $
 *
 * 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 SC_ROOT_HXX
#define SC_ROOT_HXX

#include <tools/solar.h>
#include "global.hxx"
#include "address.hxx"
#include "flttypes.hxx"
#include "filter.hxx"
#include "excdefs.hxx"

class ScRangeName;

class NameBuffer;
class RangeNameBufferWK3;
class ShrfmlaBuffer;
class ExtNameBuff;
class ExtSheetBuffer;
class ExcelToSc;

class XclImpAutoFilterBuffer;
class XclImpPivotCacheList;
class _ScRangeListTabs;

class XclExpChTrTabId;
class XclExpUserBViewList;

class XclObjList;
class XclEscher;

class XclImpRoot;
class XclExpRoot;

// ---------------------------------------------------------- Excel Imp~/Exp~ -

struct RootData     // -> Inkarnation jeweils im ImportExcel-Objekt!
{
    BiffTyp             eDateiTyp;              // feine Differenzierung
    ExtSheetBuffer*     pExtSheetBuff;
    NameBuffer*         pTabNameBuff;
    ShrfmlaBuffer*      pShrfmlaBuff;
    ExtNameBuff*        pExtNameBuff;
    ExcelToSc*          pFmlaConverter;

    // Biff8
    XclImpAutoFilterBuffer* pAutoFilterBuffer;      // ranges for autofilter and advanced filter
    _ScRangeListTabs*       pPrintRanges;
    _ScRangeListTabs*       pPrintTitles;

    // Erweiterungen fuer Export
    XclExpChTrTabId*        pTabId;             // pointer to rec list, do not destroy
    XclExpUserBViewList*    pUserBViewList;     // pointer to rec list, do not destroy

    // Biff8
    XclObjList*         pObjRecs;
    XclEscher*          pEscher;

    XclImpRoot*         pIR;
    XclExpRoot*         pER;

                        RootData( void );       // -> exctools.cxx
                        ~RootData();            // -> exctools.cxx
};

class ExcRoot
{
protected:
    RootData*       pExcRoot;
    inline          ExcRoot( RootData* pNexExcRoot ) : pExcRoot( pNexExcRoot ) {}
    inline          ExcRoot( const ExcRoot& rCopy ) : pExcRoot( rCopy.pExcRoot ) {}
};

// ---------------------------------------------------------- Lotus Imp~/Exp~ -

class LotusRangeList;
class LotusFontBuffer;
class LotAttrTable;

struct LOTUS_ROOT
{
    ScDocument*         pDoc;
    LotusRangeList*     pRangeNames;
    ScRangeName*        pScRangeName;
    CharSet             eCharsetQ;
    Lotus123Typ         eFirstType;
    Lotus123Typ         eActType;
    ScRange             aActRange;
    RangeNameBufferWK3* pRngNmBffWK3;
    LotusFontBuffer*    pFontBuff;
    LotAttrTable*       pAttrTable;
};

extern LOTUS_ROOT*      pLotusRoot; // -> Inkarn. in filter.cxx

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

#endif

<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: drwtrans.hxx,v $
 *
 *  $Revision: 1.10 $
 *
 *  last change: $Author: obo $ $Date: 2004-06-04 11:32:53 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

#ifndef SC_DRWTRANS_HXX
#define SC_DRWTRANS_HXX

#ifndef _TRANSFER_HXX
#include <svtools/transfer.hxx>
#endif

#ifndef _IPOBJ_HXX
#include <so3/ipobj.hxx>
#endif

#ifndef SC_SCGLOB_HXX
#include "global.hxx"
#endif

class SdrModel;
class ScDocShell;
class INetBookmark;
class SdrObject;
class SdrView;
class ScDrawView;

class ScDrawTransferObj : public TransferableHelper
{
private:
    SdrModel*                       pModel;
    TransferableDataHelper          aOleData;
    TransferableObjectDescriptor    aObjDesc;
    SvEmbeddedObjectRef             aDocShellRef;
    SvEmbeddedObjectRef             aDrawPersistRef;
                                    // extracted from model in ctor:
    Size                            aSrcSize;
    INetBookmark*                   pBookmark;
    BOOL                            bGraphic;
    BOOL                            bGrIsBit;
    BOOL                            bOleObj;
                                    // source information for drag&drop:
                                    // (view is needed to handle drawing obejcts)
    SdrView*                        pDragSourceView;
    USHORT                          nDragSourceFlags;
    BOOL                            bDragWasInternal;

    sal_uInt32                      nSourceDocID;

    void                InitDocShell();
    SvInPlaceObjectRef  GetSingleObject();

public:
            ScDrawTransferObj( SdrModel* pClipModel, ScDocShell* pContainerShell,
                                const TransferableObjectDescriptor& rDesc );
    virtual ~ScDrawTransferObj();

    virtual void        AddSupportedFormats();
    virtual sal_Bool    GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
    virtual sal_Bool    WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId,
                                        const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
    virtual void        ObjectReleased();
    virtual void        DragFinished( sal_Int8 nDropAction );

    SdrModel*           GetModel()  { return pModel; }

    void                SetDrawPersist( const SvEmbeddedObjectRef& rRef );
    void                SetDragSource( ScDrawView* pView );
    void                SetDragSourceObj( SdrObject* pObj, SCTAB nTab );
    void                SetDragSourceFlags( USHORT nFlags );
    void                SetDragWasInternal();

    SdrView*            GetDragSourceView()             { return pDragSourceView; }
    USHORT              GetDragSourceFlags() const      { return nDragSourceFlags; }

    void                SetSourceDocID( sal_uInt32 nVal )
                            { nSourceDocID = nVal; }
    sal_uInt32          GetSourceDocID() const      { return nSourceDocID; }

    static ScDrawTransferObj* GetOwnClipboard( Window* pUIWin );
};

#endif

<commit_msg>INTEGRATION: CWS mav09 (1.9.430); FILE MERGED 2004/07/09 02:34:51 mav 1.9.430.3: RESYNC: (1.9-1.10); FILE MERGED 2004/05/04 14:01:47 mba 1.9.430.2: #i27773#: remove so3 2004/04/29 08:57:06 mav 1.9.430.1: #i27773# one more step further<commit_after>/*************************************************************************
 *
 *  $RCSfile: drwtrans.hxx,v $
 *
 *  $Revision: 1.11 $
 *
 *  last change: $Author: kz $ $Date: 2004-10-04 20:17:27 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

#ifndef SC_DRWTRANS_HXX
#define SC_DRWTRANS_HXX

#ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_
#include <com/sun/star/uno/Reference.hxx>
#endif

#ifndef _COM_SUN_STAR_EMBED_XEMBEDDEDOBJECT_HPP_
#include <com/sun/star/embed/XEmbeddedObject.hxx>
#endif

#ifndef _TRANSFER_HXX
#include <svtools/transfer.hxx>
#endif

//REMOVE    #ifndef _IPOBJ_HXX
//REMOVE    #include <so3/ipobj.hxx>
//REMOVE    #endif

#include <sfx2/objsh.hxx>

#ifndef SC_SCGLOB_HXX
#include "global.hxx"
#endif

class SdrModel;
class ScDocShell;
class INetBookmark;
class SdrObject;
class SdrView;
class ScDrawView;

class ScDrawTransferObj : public TransferableHelper
{
private:
    SdrModel*                       pModel;
    TransferableDataHelper          aOleData;
    TransferableObjectDescriptor    aObjDesc;
//REMOVE        SvEmbeddedObjectRef             aDocShellRef;
//REMOVE        SvEmbeddedObjectRef             aDrawPersistRef;
    SfxObjectShellRef               aDocShellRef;
    SfxObjectShellRef               aDrawPersistRef;

                                    // extracted from model in ctor:
    Size                            aSrcSize;
    INetBookmark*                   pBookmark;
    BOOL                            bGraphic;
    BOOL                            bGrIsBit;
    BOOL                            bOleObj;
                                    // source information for drag&drop:
                                    // (view is needed to handle drawing obejcts)
    SdrView*                        pDragSourceView;
    USHORT                          nDragSourceFlags;
    BOOL                            bDragWasInternal;

    sal_uInt32                      nSourceDocID;

    void                InitDocShell();
//REMOVE        SvInPlaceObjectRef  GetSingleObject();
    ::com::sun::star::uno::Reference< ::com::sun::star::embed::XEmbeddedObject > GetSingleObject();

public:
            ScDrawTransferObj( SdrModel* pClipModel, ScDocShell* pContainerShell,
                                const TransferableObjectDescriptor& rDesc );
    virtual ~ScDrawTransferObj();

    virtual void        AddSupportedFormats();
    virtual sal_Bool    GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
    virtual sal_Bool    WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId,
                                        const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
    virtual void        ObjectReleased();
    virtual void        DragFinished( sal_Int8 nDropAction );

    SdrModel*           GetModel()  { return pModel; }

    void                SetDrawPersist( const SfxObjectShellRef& rRef );
    void                SetDragSource( ScDrawView* pView );
    void                SetDragSourceObj( SdrObject* pObj, SCTAB nTab );
    void                SetDragSourceFlags( USHORT nFlags );
    void                SetDragWasInternal();

    SdrView*            GetDragSourceView()             { return pDragSourceView; }
    USHORT              GetDragSourceFlags() const      { return nDragSourceFlags; }

    void                SetSourceDocID( sal_uInt32 nVal )
                            { nSourceDocID = nVal; }
    sal_uInt32          GetSourceDocID() const      { return nSourceDocID; }

    static ScDrawTransferObj* GetOwnClipboard( Window* pUIWin );
};

#endif

<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: viewutil.hxx,v $
 *
 *  $Revision: 1.11 $
 *
 *  last change: $Author: obo $ $Date: 2005-11-16 10:14:04 $
 *
 *  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 SC_VIEWUTIL_HXX
#define SC_VIEWUTIL_HXX

#ifndef SC_ADDRESS_HXX
#include "address.hxx"
#endif

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

class String;
class SfxItemSet;
class SfxBindings;
class SvxFontItem;

class ScChangeAction;
class ScChangeViewSettings;
class ScDocument;
class ScAddress;
class ScRange;
class ScMarkData;

enum ScUpdateMode { SC_UPDATE_ALL, SC_UPDATE_CHANGED, SC_UPDATE_MARKS };

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

class ScViewUtil                                // static Methoden
{
public:
    static BOOL ExecuteCharMap( const SvxFontItem&  rOldFont,
                                SvxFontItem&        rNewFont,
                                String&             rString );

    static BOOL IsActionShown( const ScChangeAction& rAction,
                                const ScChangeViewSettings& rSettings,
                                ScDocument& rDocument );

    static void PutItemScript( SfxItemSet& rShellSet, const SfxItemSet& rCoreSet,
                                USHORT nWhichId, USHORT nScript );

    static USHORT GetEffLanguage( ScDocument* pDoc, const ScAddress& rPos );

    static sal_Int32 GetTransliterationType( USHORT nSlotID );

    static bool HasFiltered( const ScRange& rRange, ScDocument* pDoc );
    static void UnmarkFiltered( ScMarkData& rMark, ScDocument* pDoc );

    static void HideDisabledSlot( SfxItemSet& rSet, SfxBindings& rBindings, USHORT nSlotId );
};

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

class ScUpdateRect
{
private:
    SCCOL   nOldStartX;
    SCROW   nOldStartY;
    SCCOL   nOldEndX;
    SCROW   nOldEndY;
    SCCOL   nNewStartX;
    SCROW   nNewStartY;
    SCCOL   nNewEndX;
    SCROW   nNewEndY;
    SCCOL   nContX1;
    SCROW   nContY1;
    SCCOL   nContX2;
    SCROW   nContY2;
public:
            ScUpdateRect( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2 );
    void    SetNew( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2 );
    BOOL    GetDiff( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 );
    BOOL    GetXorDiff( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2, BOOL& rCont );
    void    GetContDiff( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 );
};

#endif

<commit_msg>INTEGRATION: CWS changefileheader (1.11.660); FILE MERGED 2008/04/01 15:31:04 thb 1.11.660.3: #i85898# Stripping all external header guards 2008/04/01 12:36:50 thb 1.11.660.2: #i85898# Stripping all external header guards 2008/03/31 17:15:51 rt 1.11.660.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: viewutil.hxx,v $
 * $Revision: 1.12 $
 *
 * 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 SC_VIEWUTIL_HXX
#define SC_VIEWUTIL_HXX

#include "address.hxx"
#include <tools/solar.h>
#include <sal/types.h>

class String;
class SfxItemSet;
class SfxBindings;
class SvxFontItem;

class ScChangeAction;
class ScChangeViewSettings;
class ScDocument;
class ScAddress;
class ScRange;
class ScMarkData;

enum ScUpdateMode { SC_UPDATE_ALL, SC_UPDATE_CHANGED, SC_UPDATE_MARKS };

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

class ScViewUtil                                // static Methoden
{
public:
    static BOOL ExecuteCharMap( const SvxFontItem&  rOldFont,
                                SvxFontItem&        rNewFont,
                                String&             rString );

    static BOOL IsActionShown( const ScChangeAction& rAction,
                                const ScChangeViewSettings& rSettings,
                                ScDocument& rDocument );

    static void PutItemScript( SfxItemSet& rShellSet, const SfxItemSet& rCoreSet,
                                USHORT nWhichId, USHORT nScript );

    static USHORT GetEffLanguage( ScDocument* pDoc, const ScAddress& rPos );

    static sal_Int32 GetTransliterationType( USHORT nSlotID );

    static bool HasFiltered( const ScRange& rRange, ScDocument* pDoc );
    static void UnmarkFiltered( ScMarkData& rMark, ScDocument* pDoc );

    static void HideDisabledSlot( SfxItemSet& rSet, SfxBindings& rBindings, USHORT nSlotId );
};

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

class ScUpdateRect
{
private:
    SCCOL   nOldStartX;
    SCROW   nOldStartY;
    SCCOL   nOldEndX;
    SCROW   nOldEndY;
    SCCOL   nNewStartX;
    SCROW   nNewStartY;
    SCCOL   nNewEndX;
    SCROW   nNewEndY;
    SCCOL   nContX1;
    SCROW   nContY1;
    SCCOL   nContX2;
    SCROW   nContY2;
public:
            ScUpdateRect( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2 );
    void    SetNew( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2 );
    BOOL    GetDiff( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 );
    BOOL    GetXorDiff( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2, BOOL& rCont );
    void    GetContDiff( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 );
};

#endif

<|endoftext|>