<commit_before>// Copyright (c) 2009 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/browser/gtk/blocked_popup_container_view_gtk.h"

#include "app/gfx/gtk_util.h"
#include "app/l10n_util.h"
#include "base/string_util.h"
#include "chrome/browser/gtk/custom_button.h"
#include "chrome/browser/gtk/gtk_chrome_button.h"
#include "chrome/browser/gtk/gtk_theme_provider.h"
#include "chrome/browser/gtk/rounded_window.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/tab_contents/tab_contents_view_gtk.h"
#include "chrome/common/gtk_util.h"
#include "chrome/common/notification_service.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"

namespace {

// The minimal border around the edge of the notification.
const int kSmallPadding = 2;

// Color of the gradient in the background.
const double kBackgroundColorTop[] = { 246.0 / 255, 250.0 / 255, 1.0 };
const double kBackgroundColorBottom[] = { 219.0 / 255, 235.0 / 255, 1.0 };

// Rounded corner radius (in pixels).
const int kCornerSize = 4;

}  // namespace

// static
BlockedPopupContainerView* BlockedPopupContainerView::Create(
    BlockedPopupContainer* container) {
  return new BlockedPopupContainerViewGtk(container);
}

BlockedPopupContainerViewGtk::~BlockedPopupContainerViewGtk() {
  container_.Destroy();
}

TabContentsViewGtk* BlockedPopupContainerViewGtk::ContainingView() {
  return static_cast<TabContentsViewGtk*>(
      model_->GetConstrainingContents(NULL)->view());
}

void BlockedPopupContainerViewGtk::GetURLAndTitleForPopup(
    size_t index, string16* url, string16* title) const {
  DCHECK(url);
  DCHECK(title);
  TabContents* tab_contents = model_->GetTabContentsAt(index);
  const GURL& tab_contents_url = tab_contents->GetURL().GetOrigin();
  *url = UTF8ToUTF16(tab_contents_url.possibly_invalid_spec());
  *title = tab_contents->GetTitle();
}

// Overridden from BlockedPopupContainerView:
void BlockedPopupContainerViewGtk::SetPosition() {
  // No-op. Not required with the GTK version.
}

void BlockedPopupContainerViewGtk::ShowView() {
  // TODO(erg): Animate in.
  gtk_widget_show_all(container_.get());
}

void BlockedPopupContainerViewGtk::UpdateLabel() {
  size_t blocked_notices = model_->GetBlockedNoticeCount();
  size_t blocked_items = model_->GetBlockedPopupCount() + blocked_notices;

  GtkWidget* label = gtk_bin_get_child(GTK_BIN(menu_button_));
  if (!label) {
    label = gtk_label_new("");
    gtk_container_add(GTK_CONTAINER(menu_button_), label);
  }

  std::string label_text;
  if (blocked_items == 0) {
    label_text = l10n_util::GetStringUTF8(IDS_POPUPS_UNBLOCKED);
  } else if (blocked_notices == 0) {
    label_text = l10n_util::GetStringFUTF8(IDS_POPUPS_BLOCKED_COUNT,
                                           UintToString16(blocked_items));
  } else {
    label_text = l10n_util::GetStringFUTF8(IDS_BLOCKED_NOTICE_COUNT,
                                           UintToString16(blocked_items));
  }
  gtk_label_set_text(GTK_LABEL(label), label_text.c_str());
}

void BlockedPopupContainerViewGtk::HideView() {
  // TODO(erg): Animate out.
  gtk_widget_hide(container_.get());
}

void BlockedPopupContainerViewGtk::Destroy() {
  ContainingView()->RemoveBlockedPopupView(this);
  delete this;
}

void BlockedPopupContainerViewGtk::Observe(NotificationType type,
                                           const NotificationSource& source,
                                           const NotificationDetails& details) {
  DCHECK(type == NotificationType::BROWSER_THEME_CHANGED);

  // Make sure the label exists (so we can change its colors).
  UpdateLabel();

  // Update the label's colors.
  GtkWidget* label = gtk_bin_get_child(GTK_BIN(menu_button_));
  if (theme_provider_->UseGtkTheme()) {
    gtk_util::SetLabelColor(label, NULL);
  } else {
    GdkColor color = theme_provider_->GetGdkColor(
        BrowserThemeProvider::COLOR_BOOKMARK_TEXT);
    gtk_util::SetLabelColor(label, &color);
  }

  GdkColor color = theme_provider_->GetBorderColor();
  gtk_util::SetRoundedWindowBorderColor(container_.get(), color);
}

bool BlockedPopupContainerViewGtk::IsCommandEnabled(int command_id) const {
  return true;
}

bool BlockedPopupContainerViewGtk::IsItemChecked(int id) const {
  // |id| should be > 0 since all index based commands have 1 added to them.
  DCHECK_GT(id, 0);
  size_t id_size_t = static_cast<size_t>(id);

  if (id_size_t > BlockedPopupContainer::kImpossibleNumberOfPopups) {
    id_size_t -= BlockedPopupContainer::kImpossibleNumberOfPopups + 1;
    if (id_size_t < model_->GetPopupHostCount())
      return model_->IsHostWhitelisted(id_size_t);
  }

  return false;
}

void BlockedPopupContainerViewGtk::ExecuteCommand(int id) {
  DCHECK_GT(id, 0);
  size_t id_size_t = static_cast<size_t>(id);

  // Is this a click on a popup?
  if (id_size_t < BlockedPopupContainer::kImpossibleNumberOfPopups) {
    model_->LaunchPopupAtIndex(id_size_t - 1);
    return;
  }

  // |id| shouldn't be == kImpossibleNumberOfPopups since the popups end before
  // this and the hosts start after it.  (If it is used, it is as a separator.)
  DCHECK_NE(id_size_t, BlockedPopupContainer::kImpossibleNumberOfPopups);
  id_size_t -= BlockedPopupContainer::kImpossibleNumberOfPopups + 1;

  // Is this a click on a host?
  size_t host_count = model_->GetPopupHostCount();
  if (id_size_t < host_count) {
    model_->ToggleWhitelistingForHost(id_size_t);
    return;
  }

  // |id shouldn't be == host_count since this is the separator between hosts
  // and notices.
  DCHECK_NE(id_size_t, host_count);
  id_size_t -= host_count + 1;

  // Nothing to do for now for notices.
}

BlockedPopupContainerViewGtk::BlockedPopupContainerViewGtk(
    BlockedPopupContainer* container)
    : model_(container),
      theme_provider_(GtkThemeProvider::GetFrom(container->profile())),
      close_button_(CustomDrawButton::CloseButton(theme_provider_)) {
  Init();

  registrar_.Add(this,
                 NotificationType::BROWSER_THEME_CHANGED,
                 NotificationService::AllSources());
  theme_provider_->InitThemesFor(this);
}

void BlockedPopupContainerViewGtk::Init() {
  menu_button_ = theme_provider_->BuildChromeButton();
  UpdateLabel();
  g_signal_connect(menu_button_, "clicked",
                   G_CALLBACK(OnMenuButtonClicked), this);

  GtkWidget* hbox = gtk_hbox_new(FALSE, 0);
  gtk_box_pack_start(GTK_BOX(hbox), menu_button_, FALSE, FALSE, kSmallPadding);
  gtk_util::CenterWidgetInHBox(hbox, close_button_->widget(), true, 0);
  g_signal_connect(close_button_->widget(), "clicked",
                   G_CALLBACK(OnCloseButtonClicked), this);

  container_.Own(gtk_util::CreateGtkBorderBin(hbox, NULL,
      kSmallPadding, kSmallPadding, kSmallPadding, kSmallPadding));
  // Connect an expose signal that draws the background. Most connect before
  // the ActAsRoundedWindow one.
  g_signal_connect(container_.get(), "expose-event",
                   G_CALLBACK(OnRoundedExposeCallback), this);
  gtk_util::ActAsRoundedWindow(
      container_.get(), gfx::kGdkBlack, kCornerSize,
      gtk_util::ROUNDED_TOP_LEFT | gtk_util::ROUNDED_TOP_RIGHT,
      gtk_util::BORDER_LEFT | gtk_util::BORDER_TOP | gtk_util::BORDER_RIGHT);

  ContainingView()->AttachBlockedPopupView(this);
}

void BlockedPopupContainerViewGtk::OnMenuButtonClicked(
    GtkButton *button, BlockedPopupContainerViewGtk* container) {
  container->launch_menu_.reset(new MenuGtk(container, false));

  // Set items 1 .. popup_count as individual popups.
  size_t popup_count = container->model_->GetBlockedPopupCount();
  for (size_t i = 0; i < popup_count; ++i) {
    string16 url, title;
    container->GetURLAndTitleForPopup(i, &url, &title);
    // We can't just use the index into container_ here because Menu reserves
    // the value 0 as the nop command.
    container->launch_menu_->AppendMenuItemWithLabel(i + 1,
        l10n_util::GetStringFUTF8(IDS_POPUP_TITLE_FORMAT, url, title));
  }

  // Set items (kImpossibleNumberOfPopups + 1) ..
  // (kImpossibleNumberOfPopups + hosts.size()) as hosts.
  std::vector<std::string> hosts(container->model_->GetHosts());
  if (!hosts.empty() && (popup_count > 0))
    container->launch_menu_->AppendSeparator();
  size_t first_host = BlockedPopupContainer::kImpossibleNumberOfPopups + 1;
  for (size_t i = 0; i < hosts.size(); ++i) {
    container->launch_menu_->AppendCheckMenuItemWithLabel(first_host + i,
        l10n_util::GetStringFUTF8(IDS_POPUP_HOST_FORMAT,
                                  UTF8ToUTF16(hosts[i])));
  }

  // Set items (kImpossibleNumberOfPopups + hosts.size() + 2) ..
  // (kImpossibleNumberOfPopups + hosts.size() + 1 + notice_count) as notices.
  size_t notice_count = container->model_->GetBlockedNoticeCount();
  if (notice_count && (!hosts.empty() || (popup_count > 0)))
    container->launch_menu_->AppendSeparator();
  size_t first_notice = first_host + hosts.size() + 1;
  for (size_t i = 0; i < notice_count; ++i) {
    std::string host;
    string16 reason;
    container->model_->GetHostAndReasonForNotice(i, &host, &reason);
    container->launch_menu_->AppendMenuItemWithLabel(first_notice + i,
        l10n_util::GetStringFUTF8(IDS_NOTICE_TITLE_FORMAT, UTF8ToUTF16(host),
                                  reason));
  }

  container->launch_menu_->PopupAsContext(gtk_get_current_event_time());
}

void BlockedPopupContainerViewGtk::OnCloseButtonClicked(
    GtkButton *button, BlockedPopupContainerViewGtk* container) {
  container->model_->set_dismissed();
  container->model_->CloseAll();
}

gboolean BlockedPopupContainerViewGtk::OnRoundedExposeCallback(
    GtkWidget* widget, GdkEventExpose* event,
    BlockedPopupContainerViewGtk* container) {
  if (!container->theme_provider_->UseGtkTheme()) {
    int width = widget->allocation.width;
    int height = widget->allocation.height;

    // Clip to our damage rect.
    cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(event->window));
    cairo_rectangle(cr, event->area.x, event->area.y,
                    event->area.width, event->area.height);
    cairo_clip(cr);

    // TODO(erg): We draw the gradient background only when GTK themes are
    // off. This isn't a perfect solution as this isn't themed! The views
    // version doesn't appear to be themed either, so at least for now,
    // constants are OK.
    int half_width = width / 2;
    cairo_pattern_t* pattern = cairo_pattern_create_linear(
        half_width, 0,  half_width, height);
    cairo_pattern_add_color_stop_rgb(
        pattern, 0.0,
        kBackgroundColorTop[0], kBackgroundColorTop[1], kBackgroundColorTop[2]);
    cairo_pattern_add_color_stop_rgb(
        pattern, 1.0,
        kBackgroundColorBottom[0], kBackgroundColorBottom[1],
        kBackgroundColorBottom[2]);
    cairo_set_source(cr, pattern);
    cairo_paint(cr);
    cairo_pattern_destroy(pattern);

    cairo_destroy(cr);
  }

  return FALSE;
}
<commit_msg>GTK: The blocked popup notification should obey chrome themes.<commit_after>// Copyright (c) 2009 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/browser/gtk/blocked_popup_container_view_gtk.h"

#include "app/gfx/gtk_util.h"
#include "app/l10n_util.h"
#include "base/string_util.h"
#include "chrome/browser/gtk/custom_button.h"
#include "chrome/browser/gtk/gtk_chrome_button.h"
#include "chrome/browser/gtk/gtk_theme_provider.h"
#include "chrome/browser/gtk/rounded_window.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/tab_contents/tab_contents_view_gtk.h"
#include "chrome/common/gtk_util.h"
#include "chrome/common/notification_service.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"

namespace {

// The minimal border around the edge of the notification.
const int kSmallPadding = 2;

// Color of the gradient in the background.
const double kBackgroundColorTop[] = { 246.0 / 255, 250.0 / 255, 1.0 };
const double kBackgroundColorBottom[] = { 219.0 / 255, 235.0 / 255, 1.0 };

// Rounded corner radius (in pixels).
const int kCornerSize = 4;

}  // namespace

// static
BlockedPopupContainerView* BlockedPopupContainerView::Create(
    BlockedPopupContainer* container) {
  return new BlockedPopupContainerViewGtk(container);
}

BlockedPopupContainerViewGtk::~BlockedPopupContainerViewGtk() {
  container_.Destroy();
}

TabContentsViewGtk* BlockedPopupContainerViewGtk::ContainingView() {
  return static_cast<TabContentsViewGtk*>(
      model_->GetConstrainingContents(NULL)->view());
}

void BlockedPopupContainerViewGtk::GetURLAndTitleForPopup(
    size_t index, string16* url, string16* title) const {
  DCHECK(url);
  DCHECK(title);
  TabContents* tab_contents = model_->GetTabContentsAt(index);
  const GURL& tab_contents_url = tab_contents->GetURL().GetOrigin();
  *url = UTF8ToUTF16(tab_contents_url.possibly_invalid_spec());
  *title = tab_contents->GetTitle();
}

// Overridden from BlockedPopupContainerView:
void BlockedPopupContainerViewGtk::SetPosition() {
  // No-op. Not required with the GTK version.
}

void BlockedPopupContainerViewGtk::ShowView() {
  // TODO(erg): Animate in.
  gtk_widget_show_all(container_.get());
}

void BlockedPopupContainerViewGtk::UpdateLabel() {
  size_t blocked_notices = model_->GetBlockedNoticeCount();
  size_t blocked_items = model_->GetBlockedPopupCount() + blocked_notices;

  GtkWidget* label = gtk_bin_get_child(GTK_BIN(menu_button_));
  if (!label) {
    label = gtk_label_new("");
    gtk_container_add(GTK_CONTAINER(menu_button_), label);
  }

  std::string label_text;
  if (blocked_items == 0) {
    label_text = l10n_util::GetStringUTF8(IDS_POPUPS_UNBLOCKED);
  } else if (blocked_notices == 0) {
    label_text = l10n_util::GetStringFUTF8(IDS_POPUPS_BLOCKED_COUNT,
                                           UintToString16(blocked_items));
  } else {
    label_text = l10n_util::GetStringFUTF8(IDS_BLOCKED_NOTICE_COUNT,
                                           UintToString16(blocked_items));
  }
  gtk_label_set_text(GTK_LABEL(label), label_text.c_str());
}

void BlockedPopupContainerViewGtk::HideView() {
  // TODO(erg): Animate out.
  gtk_widget_hide(container_.get());
}

void BlockedPopupContainerViewGtk::Destroy() {
  ContainingView()->RemoveBlockedPopupView(this);
  delete this;
}

void BlockedPopupContainerViewGtk::Observe(NotificationType type,
                                           const NotificationSource& source,
                                           const NotificationDetails& details) {
  DCHECK(type == NotificationType::BROWSER_THEME_CHANGED);

  // Make sure the label exists (so we can change its colors).
  UpdateLabel();

  // Update the label's colors.
  GtkWidget* label = gtk_bin_get_child(GTK_BIN(menu_button_));
  if (theme_provider_->UseGtkTheme()) {
    gtk_util::SetLabelColor(label, NULL);
  } else {
    GdkColor color = theme_provider_->GetGdkColor(
        BrowserThemeProvider::COLOR_BOOKMARK_TEXT);
    gtk_util::SetLabelColor(label, &color);
  }

  GdkColor color = theme_provider_->GetBorderColor();
  gtk_util::SetRoundedWindowBorderColor(container_.get(), color);
}

bool BlockedPopupContainerViewGtk::IsCommandEnabled(int command_id) const {
  return true;
}

bool BlockedPopupContainerViewGtk::IsItemChecked(int id) const {
  // |id| should be > 0 since all index based commands have 1 added to them.
  DCHECK_GT(id, 0);
  size_t id_size_t = static_cast<size_t>(id);

  if (id_size_t > BlockedPopupContainer::kImpossibleNumberOfPopups) {
    id_size_t -= BlockedPopupContainer::kImpossibleNumberOfPopups + 1;
    if (id_size_t < model_->GetPopupHostCount())
      return model_->IsHostWhitelisted(id_size_t);
  }

  return false;
}

void BlockedPopupContainerViewGtk::ExecuteCommand(int id) {
  DCHECK_GT(id, 0);
  size_t id_size_t = static_cast<size_t>(id);

  // Is this a click on a popup?
  if (id_size_t < BlockedPopupContainer::kImpossibleNumberOfPopups) {
    model_->LaunchPopupAtIndex(id_size_t - 1);
    return;
  }

  // |id| shouldn't be == kImpossibleNumberOfPopups since the popups end before
  // this and the hosts start after it.  (If it is used, it is as a separator.)
  DCHECK_NE(id_size_t, BlockedPopupContainer::kImpossibleNumberOfPopups);
  id_size_t -= BlockedPopupContainer::kImpossibleNumberOfPopups + 1;

  // Is this a click on a host?
  size_t host_count = model_->GetPopupHostCount();
  if (id_size_t < host_count) {
    model_->ToggleWhitelistingForHost(id_size_t);
    return;
  }

  // |id shouldn't be == host_count since this is the separator between hosts
  // and notices.
  DCHECK_NE(id_size_t, host_count);
  id_size_t -= host_count + 1;

  // Nothing to do for now for notices.
}

BlockedPopupContainerViewGtk::BlockedPopupContainerViewGtk(
    BlockedPopupContainer* container)
    : model_(container),
      theme_provider_(GtkThemeProvider::GetFrom(container->profile())),
      close_button_(CustomDrawButton::CloseButton(theme_provider_)) {
  Init();

  registrar_.Add(this,
                 NotificationType::BROWSER_THEME_CHANGED,
                 NotificationService::AllSources());
  theme_provider_->InitThemesFor(this);
}

void BlockedPopupContainerViewGtk::Init() {
  menu_button_ = theme_provider_->BuildChromeButton();
  UpdateLabel();
  g_signal_connect(menu_button_, "clicked",
                   G_CALLBACK(OnMenuButtonClicked), this);

  GtkWidget* hbox = gtk_hbox_new(FALSE, 0);
  gtk_box_pack_start(GTK_BOX(hbox), menu_button_, FALSE, FALSE, kSmallPadding);
  gtk_util::CenterWidgetInHBox(hbox, close_button_->widget(), true, 0);
  g_signal_connect(close_button_->widget(), "clicked",
                   G_CALLBACK(OnCloseButtonClicked), this);

  container_.Own(gtk_util::CreateGtkBorderBin(hbox, NULL,
      kSmallPadding, kSmallPadding, kSmallPadding, kSmallPadding));
  // Connect an expose signal that draws the background. Most connect before
  // the ActAsRoundedWindow one.
  g_signal_connect(container_.get(), "expose-event",
                   G_CALLBACK(OnRoundedExposeCallback), this);
  gtk_util::ActAsRoundedWindow(
      container_.get(), gfx::kGdkBlack, kCornerSize,
      gtk_util::ROUNDED_TOP_LEFT | gtk_util::ROUNDED_TOP_RIGHT,
      gtk_util::BORDER_LEFT | gtk_util::BORDER_TOP | gtk_util::BORDER_RIGHT);

  ContainingView()->AttachBlockedPopupView(this);
}

void BlockedPopupContainerViewGtk::OnMenuButtonClicked(
    GtkButton *button, BlockedPopupContainerViewGtk* container) {
  container->launch_menu_.reset(new MenuGtk(container, false));

  // Set items 1 .. popup_count as individual popups.
  size_t popup_count = container->model_->GetBlockedPopupCount();
  for (size_t i = 0; i < popup_count; ++i) {
    string16 url, title;
    container->GetURLAndTitleForPopup(i, &url, &title);
    // We can't just use the index into container_ here because Menu reserves
    // the value 0 as the nop command.
    container->launch_menu_->AppendMenuItemWithLabel(i + 1,
        l10n_util::GetStringFUTF8(IDS_POPUP_TITLE_FORMAT, url, title));
  }

  // Set items (kImpossibleNumberOfPopups + 1) ..
  // (kImpossibleNumberOfPopups + hosts.size()) as hosts.
  std::vector<std::string> hosts(container->model_->GetHosts());
  if (!hosts.empty() && (popup_count > 0))
    container->launch_menu_->AppendSeparator();
  size_t first_host = BlockedPopupContainer::kImpossibleNumberOfPopups + 1;
  for (size_t i = 0; i < hosts.size(); ++i) {
    container->launch_menu_->AppendCheckMenuItemWithLabel(first_host + i,
        l10n_util::GetStringFUTF8(IDS_POPUP_HOST_FORMAT,
                                  UTF8ToUTF16(hosts[i])));
  }

  // Set items (kImpossibleNumberOfPopups + hosts.size() + 2) ..
  // (kImpossibleNumberOfPopups + hosts.size() + 1 + notice_count) as notices.
  size_t notice_count = container->model_->GetBlockedNoticeCount();
  if (notice_count && (!hosts.empty() || (popup_count > 0)))
    container->launch_menu_->AppendSeparator();
  size_t first_notice = first_host + hosts.size() + 1;
  for (size_t i = 0; i < notice_count; ++i) {
    std::string host;
    string16 reason;
    container->model_->GetHostAndReasonForNotice(i, &host, &reason);
    container->launch_menu_->AppendMenuItemWithLabel(first_notice + i,
        l10n_util::GetStringFUTF8(IDS_NOTICE_TITLE_FORMAT, UTF8ToUTF16(host),
                                  reason));
  }

  container->launch_menu_->PopupAsContext(gtk_get_current_event_time());
}

void BlockedPopupContainerViewGtk::OnCloseButtonClicked(
    GtkButton *button, BlockedPopupContainerViewGtk* container) {
  container->model_->set_dismissed();
  container->model_->CloseAll();
}

gboolean BlockedPopupContainerViewGtk::OnRoundedExposeCallback(
    GtkWidget* widget, GdkEventExpose* event,
    BlockedPopupContainerViewGtk* container) {
  if (!container->theme_provider_->UseGtkTheme()) {
    int width = widget->allocation.width;
    int height = widget->allocation.height;

    // Clip to our damage rect.
    cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(event->window));
    cairo_rectangle(cr, event->area.x, event->area.y,
                    event->area.width, event->area.height);
    cairo_clip(cr);

    if (container->theme_provider_->GetThemeID() ==
        BrowserThemeProvider::kDefaultThemeID) {
      // We are using the default theme. Use a fairly soft gradient for the
      // background of the blocked popup notification.
      int half_width = width / 2;
      cairo_pattern_t* pattern = cairo_pattern_create_linear(
          half_width, 0,  half_width, height);
      cairo_pattern_add_color_stop_rgb(
          pattern, 0.0, kBackgroundColorTop[0], kBackgroundColorTop[1],
          kBackgroundColorTop[2]);
      cairo_pattern_add_color_stop_rgb(
          pattern, 1.0,
          kBackgroundColorBottom[0], kBackgroundColorBottom[1],
          kBackgroundColorBottom[2]);
      cairo_set_source(cr, pattern);
      cairo_paint(cr);
      cairo_pattern_destroy(pattern);
    } else {
      // Use the toolbar color the theme specifies instead. It would be nice to
      // have a gradient here, but there isn't a second color to use...
      GdkColor color = container->theme_provider_->GetGdkColor(
          BrowserThemeProvider::COLOR_TOOLBAR);
      gdk_cairo_set_source_color(cr, &color);
      cairo_paint(cr);
    }

    cairo_destroy(cr);
  }

  return FALSE;
}
<|endoftext|>


<commit_before>// Copyright (c) 2009 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.

// TODO(jorlow): Reenable when https://bugs.webkit.org/show_bug.cgi?id=28094
//               is fixed.  Until then, this will cause crashes even if the
//               individual tests are disabled.
#if 0

#include "chrome/common/chrome_switches.h"
#include "chrome/test/ui/ui_layout_test.h"

// TODO(jorlow): Enable these tests when we remove them from the
//               test_exceptions.txt file.
//static const char* kTopLevelFiles[] = {
  //"window-attributes-exist.html"
//};

// TODO(jorlow): Enable these tests when we remove them from the
//               test_exceptions.txt file.
static const char* kSubDirFiles[] = {
  "clear.html",
  "delete-removal.html",
  "enumerate-storage.html",
  "enumerate-with-length-and-key.html",
  //"iframe-events.html",
  //"index-get-and-set.html",
  //"onstorage-attribute-markup.html",
  //"onstorage-attribute-setattribute.html",
  //"localstorage/onstorage-attribute-setwindow.html",
  //"simple-events.html",
  "simple-usage.html",
  //"string-conversion.html",
//  "window-open.html"
};

class DOMStorageTest : public UILayoutTest {
 protected:
  DOMStorageTest()
      : UILayoutTest(),
        test_dir_(FilePath().AppendASCII("LayoutTests").
                  AppendASCII("storage").AppendASCII("domstorage"))
  {
  }

  virtual ~DOMStorageTest() { }

  virtual void SetUp() {
    launch_arguments_.AppendSwitch(switches::kDisablePopupBlocking);
    launch_arguments_.AppendSwitch(switches::kEnableLocalStorage);
    launch_arguments_.AppendSwitch(switches::kEnableSessionStorage);
    UILayoutTest::SetUp();
  }

  FilePath test_dir_;
};

TEST_F(DOMStorageTest, DOMStorageLayoutTests) {
  // TODO(jorlow): Enable these tests when we remove them from the
  //               test_exceptions.txt file.
  //InitializeForLayoutTest(test_dir_, FilePath(), false);
  //for (size_t i=0; i<arraysize(kTopLevelFiles); ++i)
  //  RunLayoutTest(kTopLevelFiles[i], false, true);
}

TEST_F(DOMStorageTest, LocalStorageLayoutTests) {
  InitializeForLayoutTest(test_dir_, FilePath().AppendASCII("localstorage"),
                          false);
  for (size_t i=0; i<arraysize(kSubDirFiles); ++i)
    RunLayoutTest(kSubDirFiles[i], false);
}

TEST_F(DOMStorageTest, SessionStorageLayoutTests) {
  InitializeForLayoutTest(test_dir_, FilePath().AppendASCII("sessionstorage"),
                          false);
  for (size_t i=0; i<arraysize(kSubDirFiles); ++i)
    RunLayoutTest(kSubDirFiles[i], false);
}

#endif
<commit_msg>Another attempt to enable the local storage ui test based layout tests.<commit_after>// Copyright (c) 2009 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/common/chrome_switches.h"
#include "chrome/test/ui/ui_layout_test.h"

// TODO(jorlow): Enable these tests when we remove them from the
//               test_exceptions.txt file.
//static const char* kTopLevelFiles[] = {
  //"window-attributes-exist.html"
//};

// TODO(jorlow): Enable these tests when we remove them from the
//               test_exceptions.txt file.
static const char* kSubDirFiles[] = {
  "clear.html",
  "delete-removal.html",
  "enumerate-storage.html",
  "enumerate-with-length-and-key.html",
  //"iframe-events.html",
  //"index-get-and-set.html",
  //"onstorage-attribute-markup.html",
  //"onstorage-attribute-setattribute.html",
  //"localstorage/onstorage-attribute-setwindow.html",
  //"simple-events.html",
  "simple-usage.html",
  //"string-conversion.html",
//  "window-open.html"
};

class DOMStorageTest : public UILayoutTest {
 protected:
  DOMStorageTest()
      : UILayoutTest(),
        test_dir_(FilePath().AppendASCII("LayoutTests").
                  AppendASCII("storage").AppendASCII("domstorage"))
  {
  }

  virtual ~DOMStorageTest() { }

  virtual void SetUp() {
    launch_arguments_.AppendSwitch(switches::kDisablePopupBlocking);
    launch_arguments_.AppendSwitch(switches::kEnableLocalStorage);
    launch_arguments_.AppendSwitch(switches::kEnableSessionStorage);
    UILayoutTest::SetUp();
  }

  FilePath test_dir_;
};

TEST_F(DOMStorageTest, DOMStorageLayoutTests) {
  // TODO(jorlow): Enable these tests when we remove them from the
  //               test_exceptions.txt file.
  //InitializeForLayoutTest(test_dir_, FilePath(), false);
  //for (size_t i=0; i<arraysize(kTopLevelFiles); ++i)
  //  RunLayoutTest(kTopLevelFiles[i], false, true);
}

TEST_F(DOMStorageTest, LocalStorageLayoutTests) {
  InitializeForLayoutTest(test_dir_, FilePath().AppendASCII("localstorage"),
                          false);
  for (size_t i=0; i<arraysize(kSubDirFiles); ++i)
    RunLayoutTest(kSubDirFiles[i], false);
}

TEST_F(DOMStorageTest, SessionStorageLayoutTests) {
  InitializeForLayoutTest(test_dir_, FilePath().AppendASCII("sessionstorage"),
                          false);
  for (size_t i=0; i<arraysize(kSubDirFiles); ++i)
    RunLayoutTest(kSubDirFiles[i], false);
}
<|endoftext|>


<commit_before>/** \copyright
 * Copyright (c) 2017, Balazs Racz
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are  permitted provided that the following conditions are met:
 *
 *  - Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 *
 *  - Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 * \file HwInit.cxx
 * This file represents the hardware initialization for the TI CC3220SF Wireless MCU.
 *
 * @author Balazs Racz
 * @date 29 March 2017
 */

#include <new>
#include <cstdint>

#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "inc/hw_ints.h"
#include "inc/hw_nvic.h"
#include "inc/hw_gpio.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include "driverlib/gpio.h"
#include "driverlib/timer.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin.h"
#include "driverlib/utils.h"
#include "os/OS.hxx"
#include "DummyGPIO.hxx"
#include "CC32xxUart.hxx"
#include "CC32xxSPI.hxx"
#include "CC32xxWiFi.hxx"
#include "MCP2515Can.hxx"
#include "CC32xxEEPROMEmulation.hxx"
#include "hardware.hxx"
#include "bootloader_hal.h"

/** override stdin */
const char *STDIN_DEVICE = "/dev/ser0";

/** override stdout */
const char *STDOUT_DEVICE = "/dev/ser0";

/** override stderr */
const char *STDERR_DEVICE = "/dev/ser0";

/** Assert the RS-485 transmit enable line.
 */
static void rs485_enable_assert()
{
    RS485_TX_EN_Pin::set(true);
    UtilsDelay(100);
}

/** Deassert the RS-485 transmit enable line.
 */
static void rs485_enable_deassert()
{
    RS485_TX_EN_Pin::set(false);
}

/** UART 0 serial driver instance */
static CC32xxUart uart0("/dev/ser0", UARTA0_BASE, INT_UARTA0, 250000,
                        CC32xxUart::CS8, true,
                        rs485_enable_assert, rs485_enable_deassert);

/** Wi-Fi instance */
CC32xxWiFi wifi;

static CC32xxEEPROMEmulation eeprom("/usr/dmxeeprom", 1500);

/** Assert the chip select for the MCP2515 CAN controller.
 */
static void mcp2515_cs_assert()
{
    MCP2515_CS_N_Pin::set(false);
}

/** Deassert the chip select for the MCP2515 CAN controller.
 */
static void mcp2515_cs_deassert()
{
    MCP2515_CS_N_Pin::set(true);
}

/** Enable MCP2515 CAN controller interrupt.
 */
static void mcp2515_int_enable()
{
    GPIOIntEnable(MCP2515_INT_N_Pin::GPIO_BASE, MCP2515_INT_N_Pin::GPIO_PIN);
}

/** Disable MCP2515 CAN controller interrupt.
 */
static void mcp2515_int_disable()
{
    GPIOIntDisable(MCP2515_INT_N_Pin::GPIO_BASE, MCP2515_INT_N_Pin::GPIO_PIN);
}

/** SPI 0.0 driver instance */
static CC32xxSPI spi0_0("/dev/spidev0.0", GSPI_BASE, INT_GSPI,
                        mcp2515_cs_assert, mcp2515_cs_deassert);

static MCP2515Can can0("/dev/can0", mcp2515_int_enable, mcp2515_int_disable);

extern void eeprom_flush() {
    eeprom.flush();
}

extern "C"
{

void __attribute__((__weak__)) eeprom_updated_notification() {
    eeprom_flush();
}

extern void (* const __interrupt_vector[])(void);
void hw_set_to_safe(void);

static uint32_t nsec_per_clock = 0;
/// Calculate partial timing information from the tick counter.
long long hw_get_partial_tick_time_nsec(void)
{
    volatile uint32_t * tick_current_reg = (volatile uint32_t *)0xe000e018;
    long long tick_val = *tick_current_reg;
    tick_val *= nsec_per_clock;
    long long elapsed = (1ULL << NSEC_TO_TICK_SHIFT) - tick_val;
    if (elapsed < 0) elapsed = 0;
    return elapsed;
}

/** Blink LED */
uint32_t blinker_pattern = 0;
static volatile uint32_t rest_pattern = 0;

void dcc_generator_init(void);

void hw_set_to_safe(void)
{
    GpioInit::hw_set_to_safe();
}

void resetblink(uint32_t pattern)
{
    blinker_pattern = pattern;
}

void setblink(uint32_t pattern)
{
    resetblink(pattern);
}

void timer1a_interrupt_handler(void)
{
    //
    // Clear the timer interrupt.
    //
    MAP_TimerIntClear(BLINKER_TIMER_BASE, BLINKER_TIMER_TIMEOUT);
    // Set output LED.
    BLINKER_RAW_Pin::set((rest_pattern & 1));

    // Shift and maybe reset pattern.
    rest_pattern >>= 1;
    if (!rest_pattern)
        rest_pattern = blinker_pattern;
}

void diewith(uint32_t pattern)
{
    /* Globally disables interrupts. */
    asm("cpsid i\n");
    hw_set_to_safe();

    resetblink(pattern);
    while (1)
    {
        if (MAP_TimerIntStatus(BLINKER_TIMER_BASE, true) & BLINKER_TIMER_TIMEOUT)
        {
            timer1a_interrupt_handler();
        }
    }
}

/** Initialize the processor hardware pre C runtime init.
 */
void hw_preinit(void)
{
    /* Globally disables interrupts until the FreeRTOS scheduler is up. */
    asm("cpsid i\n");

    nsec_per_clock = 1000000000 / cm3_cpu_clock_hz;

    /* Setup the interrupt vector table */
    MAP_IntVTableBaseSet((unsigned long)&__interrupt_vector[0]);

    // Disables all interrupts that the bootloader might have enabled.
    HWREG(NVIC_DIS0) = 0xffffffffU;
    HWREG(NVIC_DIS1) = 0xffffffffU;
    HWREG(NVIC_DIS2) = 0xffffffffU;
    HWREG(NVIC_DIS3) = 0xffffffffU;
    HWREG(NVIC_DIS4) = 0xffffffffU;
    HWREG(NVIC_DIS5) = 0xffffffffU;

    /* Setup the system clock. */
    PRCMCC3200MCUInit();

    // initilize pin modes:
    init_pinmux<0>();
    GpioInit::hw_init();

    /* Blinker timer initialization. */
    MAP_PRCMPeripheralClkEnable(PRCM_TIMERA1, PRCM_RUN_MODE_CLK);
    MAP_TimerConfigure(BLINKER_TIMER_BASE, TIMER_CFG_PERIODIC);
    MAP_TimerLoadSet(BLINKER_TIMER_BASE, BLINKER_TIMER, cm3_cpu_clock_hz / 8);
    MAP_IntEnable(BLINKER_TIMER_INT);

    /* This interrupt should hit even during kernel operations. */
    MAP_IntPrioritySet(BLINKER_TIMER_INT, 0);
    MAP_TimerIntEnable(BLINKER_TIMER_BASE, BLINKER_TIMER_TIMEOUT);
    MAP_TimerEnable(BLINKER_TIMER_BASE, BLINKER_TIMER);

    /* MCP2515 CAN Controller reset hold */
    MCP2515_RESET_N_Pin::set(false);

    /* MCP2515 CAN Controller clock timer initialization. */
    MAP_PRCMPeripheralClkEnable(PRCM_TIMERA2, PRCM_RUN_MODE_CLK);
    MAP_TimerConfigure(TIMERA2_BASE,
        TIMER_CFG_SPLIT_PAIR | TIMER_CFG_B_PWM | TIMER_CFG_A_PERIODIC);
    MAP_TimerLoadSet(TIMERA2_BASE, TIMER_B, 3);
    MAP_TimerMatchSet(TIMERA2_BASE, TIMER_B, 1);
    MAP_TimerEnable(TIMERA2_BASE, TIMER_B);

    /* MCP2515 CAN Controller gpio interrupt initialization */
    GPIOIntTypeSet(MCP2515_INT_N_Pin::GPIO_BASE, MCP2515_INT_N_Pin::GPIO_PIN, GPIO_LOW_LEVEL);
    MAP_IntPrioritySet(MCP2515_INT_N_Pin::GPIO_INT, configKERNEL_INTERRUPT_PRIORITY);
    MAP_IntEnable(MCP2515_INT_N_Pin::GPIO_INT);

    /* MCP2515 CAN Controller reset release */
    MCP2515_RESET_N_Pin::set(true);

    /* Checks the SW2 pin at boot time in case we want to allow for a debugger
     * to connect.
    asm volatile ("cpsie i\n");
    do {
      if (SW2_Pin::get()) {
        blinker_pattern = 0xAAAA;
      } else {
        blinker_pattern = 0;
      }
    } while (blinker_pattern || rest_pattern);
    asm volatile ("cpsid i\n"); */
}

/** PORTA0 interrupt handler.
 */
void porta0_interrupt_handler(void)
{
    long status = GPIOIntStatus(GPIOA0_BASE, true);

    if (status & GPIO_INT_PIN_7)
    {
        /* MCP2515 CAN Controller interrupt */
        can0.interrupt_handler();
    }
}

/** Initialize the processor hardware post C runtime init.
 */
void hw_init(void)
{
    // Initialize the SPI driver for the CC32xx network processor connection.
    extern void SPI_init(void);
    SPI_init();

    wifi.instance()->start();
}

/** Initialize the processor hardware post platform init.
 */
void hw_postinit(void)
{
    can0.init("/dev/spidev0.0", 20000000, config_nmranet_can_bitrate());
    SyncNotifiable n;
    wifi.run_on_network_thread([&n]() {
        eeprom.mount();
        n.notify();
    });
    n.wait_for_notification();
}

} /* extern "C" */
<commit_msg>removes automatic rs485 mode.<commit_after>/** \copyright
 * Copyright (c) 2017, Balazs Racz
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are  permitted provided that the following conditions are met:
 *
 *  - Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 *
 *  - Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 * \file HwInit.cxx
 * This file represents the hardware initialization for the TI CC3220SF Wireless MCU.
 *
 * @author Balazs Racz
 * @date 29 March 2017
 */

#include <new>
#include <cstdint>

#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "inc/hw_ints.h"
#include "inc/hw_nvic.h"
#include "inc/hw_gpio.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include "driverlib/gpio.h"
#include "driverlib/timer.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin.h"
#include "driverlib/utils.h"
#include "os/OS.hxx"
#include "DummyGPIO.hxx"
#include "CC32xxUart.hxx"
#include "CC32xxSPI.hxx"
#include "CC32xxWiFi.hxx"
#include "MCP2515Can.hxx"
#include "CC32xxEEPROMEmulation.hxx"
#include "hardware.hxx"
#include "bootloader_hal.h"

/** override stdin */
const char *STDIN_DEVICE = "/dev/ser0";

/** override stdout */
const char *STDOUT_DEVICE = "/dev/ser0";

/** override stderr */
const char *STDERR_DEVICE = "/dev/ser0";

/*
// Assert the RS-485 transmit enable line.
static void rs485_enable_assert()
{
    RS485_TX_EN_Pin::set(true);
    UtilsDelay(100);
}

// Deassert the RS-485 transmit enable line.
static void rs485_enable_deassert()
{
    RS485_TX_EN_Pin::set(false);
}*/

/** UART 0 serial driver instance */
static CC32xxUart uart0("/dev/ser0", UARTA0_BASE, INT_UARTA0, 250000,
                        CC32xxUart::CS8 | CC32xxUart::CSTOPB, true);

/** Wi-Fi instance */
CC32xxWiFi wifi;

static CC32xxEEPROMEmulation eeprom("/usr/dmxeeprom", 1500);

/** Assert the chip select for the MCP2515 CAN controller.
 */
static void mcp2515_cs_assert()
{
    MCP2515_CS_N_Pin::set(false);
}

/** Deassert the chip select for the MCP2515 CAN controller.
 */
static void mcp2515_cs_deassert()
{
    MCP2515_CS_N_Pin::set(true);
}

/** Enable MCP2515 CAN controller interrupt.
 */
static void mcp2515_int_enable()
{
    GPIOIntEnable(MCP2515_INT_N_Pin::GPIO_BASE, MCP2515_INT_N_Pin::GPIO_PIN);
}

/** Disable MCP2515 CAN controller interrupt.
 */
static void mcp2515_int_disable()
{
    GPIOIntDisable(MCP2515_INT_N_Pin::GPIO_BASE, MCP2515_INT_N_Pin::GPIO_PIN);
}

/** SPI 0.0 driver instance */
static CC32xxSPI spi0_0("/dev/spidev0.0", GSPI_BASE, INT_GSPI,
                        mcp2515_cs_assert, mcp2515_cs_deassert);

static MCP2515Can can0("/dev/can0", mcp2515_int_enable, mcp2515_int_disable);

extern void eeprom_flush() {
    eeprom.flush();
}

extern "C"
{

void __attribute__((__weak__)) eeprom_updated_notification() {
    eeprom_flush();
}

extern void (* const __interrupt_vector[])(void);
void hw_set_to_safe(void);

static uint32_t nsec_per_clock = 0;
/// Calculate partial timing information from the tick counter.
long long hw_get_partial_tick_time_nsec(void)
{
    volatile uint32_t * tick_current_reg = (volatile uint32_t *)0xe000e018;
    long long tick_val = *tick_current_reg;
    tick_val *= nsec_per_clock;
    long long elapsed = (1ULL << NSEC_TO_TICK_SHIFT) - tick_val;
    if (elapsed < 0) elapsed = 0;
    return elapsed;
}

/** Blink LED */
uint32_t blinker_pattern = 0;
static volatile uint32_t rest_pattern = 0;

void dcc_generator_init(void);

void hw_set_to_safe(void)
{
    GpioInit::hw_set_to_safe();
}

void resetblink(uint32_t pattern)
{
    blinker_pattern = pattern;
}

void setblink(uint32_t pattern)
{
    resetblink(pattern);
}

void timer1a_interrupt_handler(void)
{
    //
    // Clear the timer interrupt.
    //
    MAP_TimerIntClear(BLINKER_TIMER_BASE, BLINKER_TIMER_TIMEOUT);
    // Set output LED.
    BLINKER_RAW_Pin::set((rest_pattern & 1));

    // Shift and maybe reset pattern.
    rest_pattern >>= 1;
    if (!rest_pattern)
        rest_pattern = blinker_pattern;
}

void diewith(uint32_t pattern)
{
    /* Globally disables interrupts. */
    asm("cpsid i\n");
    hw_set_to_safe();

    resetblink(pattern);
    while (1)
    {
        if (MAP_TimerIntStatus(BLINKER_TIMER_BASE, true) & BLINKER_TIMER_TIMEOUT)
        {
            timer1a_interrupt_handler();
        }
    }
}

/** Initialize the processor hardware pre C runtime init.
 */
void hw_preinit(void)
{
    /* Globally disables interrupts until the FreeRTOS scheduler is up. */
    asm("cpsid i\n");

    nsec_per_clock = 1000000000 / cm3_cpu_clock_hz;

    /* Setup the interrupt vector table */
    MAP_IntVTableBaseSet((unsigned long)&__interrupt_vector[0]);

    // Disables all interrupts that the bootloader might have enabled.
    HWREG(NVIC_DIS0) = 0xffffffffU;
    HWREG(NVIC_DIS1) = 0xffffffffU;
    HWREG(NVIC_DIS2) = 0xffffffffU;
    HWREG(NVIC_DIS3) = 0xffffffffU;
    HWREG(NVIC_DIS4) = 0xffffffffU;
    HWREG(NVIC_DIS5) = 0xffffffffU;

    /* Setup the system clock. */
    PRCMCC3200MCUInit();

    // initilize pin modes:
    init_pinmux<0>();
    GpioInit::hw_init();

    /* Blinker timer initialization. */
    MAP_PRCMPeripheralClkEnable(PRCM_TIMERA1, PRCM_RUN_MODE_CLK);
    MAP_TimerConfigure(BLINKER_TIMER_BASE, TIMER_CFG_PERIODIC);
    MAP_TimerLoadSet(BLINKER_TIMER_BASE, BLINKER_TIMER, cm3_cpu_clock_hz / 8);
    MAP_IntEnable(BLINKER_TIMER_INT);

    /* This interrupt should hit even during kernel operations. */
    MAP_IntPrioritySet(BLINKER_TIMER_INT, 0);
    MAP_TimerIntEnable(BLINKER_TIMER_BASE, BLINKER_TIMER_TIMEOUT);
    MAP_TimerEnable(BLINKER_TIMER_BASE, BLINKER_TIMER);

    /* MCP2515 CAN Controller reset hold */
    MCP2515_RESET_N_Pin::set(false);

    /* MCP2515 CAN Controller clock timer initialization. */
    MAP_PRCMPeripheralClkEnable(PRCM_TIMERA2, PRCM_RUN_MODE_CLK);
    MAP_TimerConfigure(TIMERA2_BASE,
        TIMER_CFG_SPLIT_PAIR | TIMER_CFG_B_PWM | TIMER_CFG_A_PERIODIC);
    MAP_TimerLoadSet(TIMERA2_BASE, TIMER_B, 3);
    MAP_TimerMatchSet(TIMERA2_BASE, TIMER_B, 1);
    MAP_TimerEnable(TIMERA2_BASE, TIMER_B);

    /* MCP2515 CAN Controller gpio interrupt initialization */
    GPIOIntTypeSet(MCP2515_INT_N_Pin::GPIO_BASE, MCP2515_INT_N_Pin::GPIO_PIN, GPIO_LOW_LEVEL);
    MAP_IntPrioritySet(MCP2515_INT_N_Pin::GPIO_INT, configKERNEL_INTERRUPT_PRIORITY);
    MAP_IntEnable(MCP2515_INT_N_Pin::GPIO_INT);

    /* MCP2515 CAN Controller reset release */
    MCP2515_RESET_N_Pin::set(true);

    /* Checks the SW2 pin at boot time in case we want to allow for a debugger
     * to connect.
    asm volatile ("cpsie i\n");
    do {
      if (SW2_Pin::get()) {
        blinker_pattern = 0xAAAA;
      } else {
        blinker_pattern = 0;
      }
    } while (blinker_pattern || rest_pattern);
    asm volatile ("cpsid i\n"); */
}

/** PORTA0 interrupt handler.
 */
void porta0_interrupt_handler(void)
{
    long status = GPIOIntStatus(GPIOA0_BASE, true);

    if (status & GPIO_INT_PIN_7)
    {
        /* MCP2515 CAN Controller interrupt */
        can0.interrupt_handler();
    }
}

/** Initialize the processor hardware post C runtime init.
 */
void hw_init(void)
{
    // Initialize the SPI driver for the CC32xx network processor connection.
    extern void SPI_init(void);
    SPI_init();

    wifi.instance()->start();
}

/** Initialize the processor hardware post platform init.
 */
void hw_postinit(void)
{
    can0.init("/dev/spidev0.0", 20000000, config_nmranet_can_bitrate());
    SyncNotifiable n;
    wifi.run_on_network_thread([&n]() {
        eeprom.mount();
        n.notify();
    });
    n.wait_for_notification();
}

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


<commit_before>//////////////////////////////////////////////////////////////////////////
//
//  Copyright (c) 2007-2008, Image Engine Design Inc. All rights reserved.
//
//  Redistribution and use in source and binary forms, with or without
//  modification, are permitted provided that the following conditions are
//  met:
//
//     * Redistributions of source code must retain the above copyright
//       notice, this list of conditions and the following disclaimer.
//
//     * Redistributions in binary form must reproduce the above copyright
//       notice, this list of conditions and the following disclaimer in the
//       documentation and/or other materials provided with the distribution.
//
//     * Neither the name of Image Engine Design nor the names of any
//       other contributors to this software may be used to endorse or
//       promote products derived from this software without specific prior
//       written permission.
//
//  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
//  IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
//  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
//  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
//  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
//  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
//  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
//  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
//  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
//  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
//  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////

#include <boost/format.hpp>

#include "IECore/DataPromoteOp.h"
#include "IECore/SimpleTypedData.h"
#include "IECore/VectorTypedData.h"
#include "IECore/ObjectParameter.h"
#include "IECore/CompoundParameter.h"
#include "IECore/CompoundObject.h"
#include "IECore/Object.h"
#include "IECore/NullObject.h"
#include "IECore/DespatchTypedData.h"

#include <cassert>

using namespace IECore;
using namespace Imath;
using namespace std;
using namespace boost;

DataPromoteOp::DataPromoteOp()
		:	Op(
		        staticTypeName(),
		        "Promotes scalar data types to compound data types.",
		        new ObjectParameter(
		                "result",
		                "Promoted Data object.",
		                new NullObject(),
		                DataTypeId
		        )
		)
{
	m_objectParameter = new ObjectParameter(
	        "object",
	        "The Data object that will be promoted.",
	        new NullObject(),
	        DataTypeId
	);
	m_targetTypeParameter = new IntParameter(
	        "targetType",
	        "The target Data typeId.",
	        InvalidTypeId,
	        0,
	        Imath::limits<int>::max()
	);
	parameters()->addParameter( m_objectParameter );
	parameters()->addParameter( m_targetTypeParameter );
}

DataPromoteOp::~DataPromoteOp()
{
}

namespace IECore
{

template<typename T>
struct DataPromoteOp::Promote2Fn<T, typename boost::enable_if< TypeTraits::IsVectorTypedData<T> >::type >
{
	typedef DataPtr ReturnType;

	template<typename F>
	ReturnType operator()( typename F::ConstPtr d ) const
	{
		assert( d );
		typename T::Ptr result = new T;
		typename T::ValueType &vt = result->writable();
		const typename F::ValueType &vf = d->readable();
		vt.resize( vf.size() );
		typename T::ValueType::iterator tIt = vt.begin();
		for ( typename F::ValueType::const_iterator it = vf.begin(); it!=vf.end(); it++ )
		{
			*tIt++ = typename T::ValueType::value_type( *it );
		}
		return result;
	}
};

template<typename T>
struct DataPromoteOp::Promote2Fn<T, typename boost::enable_if< TypeTraits::IsSimpleTypedData<T> >::type >
{
	typedef DataPtr ReturnType;

	template<typename F>
	ReturnType operator()( typename F::ConstPtr d ) const
	{
		assert( d );
		typename T::Ptr result = new T;

		result->writable() = typename T::ValueType( d->readable() );

		return result;
	}
};

struct DataPromoteOp::Promote1Fn
{
	typedef DataPtr ReturnType;

	TypeId m_targetType;

	Promote1Fn( TypeId targetType ) : m_targetType( targetType )
	{
	}

	template<typename T, typename Enable = void >
	struct Func
	{
		ReturnType operator()( typename T::ConstPtr d, TypeId ) const
		{
			assert( d );
			throw Exception( "DataPromoteOp: Unsupported source data type \"" + d->typeName() + "\"." );
		}
	};

	template<typename F>
	ReturnType operator()( typename F::ConstPtr d ) const
	{
		assert( d );
		Func<F> f;
		return f(d, m_targetType);
	}

};

template<typename F >
struct DataPromoteOp::Promote1Fn::Func< F, typename boost::enable_if< TypeTraits::IsNumericVectorTypedData<F> >::type >
{
	ReturnType operator()( typename F::ConstPtr d, TypeId targetType ) const
	{
		assert( d );
		switch ( targetType )
		{
		case V2fVectorDataTypeId :
		{
			Promote2Fn<V2fVectorData> fn;
			return fn.template operator()<F>( d );
		}
		case V2dVectorDataTypeId :
		{
			Promote2Fn<V2dVectorData> fn;
			return fn.template operator()<F>( d );
		}
		case V3fVectorDataTypeId :
		{
			Promote2Fn<V3fVectorData> fn;
			return fn.template operator()<F>( d );
		}
		case V3dVectorDataTypeId :
		{
			Promote2Fn<V3dVectorData> fn;
			return fn.template operator()<F>( d );
		}
		case Color3fVectorDataTypeId :
		{
			Promote2Fn<Color3fVectorData> fn;
			return fn.template operator()<F>( d );
		}
		default :
			throw Exception( "DataPromoteOp: Unsupported target data type \"" + Object::typeNameFromTypeId( targetType ) + "\"." );
		}
	}
};

template<typename F >
struct DataPromoteOp::Promote1Fn::Func< F, typename boost::enable_if< TypeTraits::IsNumericSimpleTypedData<F> >::type >
{
	ReturnType operator()( typename F::ConstPtr d, TypeId targetType ) const
	{
		assert( d );
		switch ( targetType )
		{
		case V2fDataTypeId :
		{
			Promote2Fn<V2fData> fn;
			return fn.template operator()<F>( d );
		}
		case V2dDataTypeId :
		{
			Promote2Fn<V2dData> fn;
			return fn.template operator()<F>( d );
		}
		case V3fDataTypeId :
		{
			Promote2Fn<V3fData> fn;
			return fn.template operator()<F>( d );
		}
		case V3dDataTypeId :
		{
			Promote2Fn<V3dData> fn;
			return fn.template operator()<F>( d );
		}
		case Color3fDataTypeId :
		{
			Promote2Fn<Color3fData> fn;
			return fn.template operator()<F>( d );
		}
		default :
			throw Exception( "DataPromoteOp: Unsupported target data type \"" + Object::typeNameFromTypeId( targetType ) + "\"." );
		}
	}
};

} // namespace IECore

ObjectPtr DataPromoteOp::doOperation( ConstCompoundObjectPtr operands )
{
	assert( operands );

	const TypeId targetType = (TypeId)m_targetTypeParameter->getNumericValue();
	DataPtr srcData = static_pointer_cast<Data>( m_objectParameter->getValue() );
	assert( srcData );

	Promote1Fn fn( targetType );

	DataPtr targetData = despatchTypedData< Promote1Fn, TypeTraits::IsNumericTypedData >( srcData, fn );
	assert( targetData );

#ifndef NDEBUG
	size_t srcSize = despatchTypedData< TypedDataSize >( srcData ) ;
	size_t targetSize = despatchTypedData< TypedDataSize >( targetData ) ;

	/// This post-condition is stated in the class documentation
	assert( srcSize == targetSize );
#endif

	return targetData;
}
<commit_msg>Added assert<commit_after>//////////////////////////////////////////////////////////////////////////
//
//  Copyright (c) 2007-2008, Image Engine Design Inc. All rights reserved.
//
//  Redistribution and use in source and binary forms, with or without
//  modification, are permitted provided that the following conditions are
//  met:
//
//     * Redistributions of source code must retain the above copyright
//       notice, this list of conditions and the following disclaimer.
//
//     * Redistributions in binary form must reproduce the above copyright
//       notice, this list of conditions and the following disclaimer in the
//       documentation and/or other materials provided with the distribution.
//
//     * Neither the name of Image Engine Design nor the names of any
//       other contributors to this software may be used to endorse or
//       promote products derived from this software without specific prior
//       written permission.
//
//  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
//  IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
//  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
//  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
//  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
//  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
//  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
//  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
//  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
//  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
//  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////

#include <boost/format.hpp>

#include "IECore/DataPromoteOp.h"
#include "IECore/SimpleTypedData.h"
#include "IECore/VectorTypedData.h"
#include "IECore/ObjectParameter.h"
#include "IECore/CompoundParameter.h"
#include "IECore/CompoundObject.h"
#include "IECore/Object.h"
#include "IECore/NullObject.h"
#include "IECore/DespatchTypedData.h"

#include <cassert>

using namespace IECore;
using namespace Imath;
using namespace std;
using namespace boost;

DataPromoteOp::DataPromoteOp()
		:	Op(
		        staticTypeName(),
		        "Promotes scalar data types to compound data types.",
		        new ObjectParameter(
		                "result",
		                "Promoted Data object.",
		                new NullObject(),
		                DataTypeId
		        )
		)
{
	m_objectParameter = new ObjectParameter(
	        "object",
	        "The Data object that will be promoted.",
	        new NullObject(),
	        DataTypeId
	);
	m_targetTypeParameter = new IntParameter(
	        "targetType",
	        "The target Data typeId.",
	        InvalidTypeId,
	        0,
	        Imath::limits<int>::max()
	);
	parameters()->addParameter( m_objectParameter );
	parameters()->addParameter( m_targetTypeParameter );
}

DataPromoteOp::~DataPromoteOp()
{
}

namespace IECore
{

template<typename T>
struct DataPromoteOp::Promote2Fn<T, typename boost::enable_if< TypeTraits::IsVectorTypedData<T> >::type >
{
	typedef DataPtr ReturnType;

	template<typename F>
	ReturnType operator()( typename F::ConstPtr d ) const
	{
		assert( d );
		typename T::Ptr result = new T;
		typename T::ValueType &vt = result->writable();
		const typename F::ValueType &vf = d->readable();
		vt.resize( vf.size() );
		typename T::ValueType::iterator tIt = vt.begin();
		for ( typename F::ValueType::const_iterator it = vf.begin(); it!=vf.end(); it++ )
		{
			*tIt++ = typename T::ValueType::value_type( *it );
		}
		return result;
	}
};

template<typename T>
struct DataPromoteOp::Promote2Fn<T, typename boost::enable_if< TypeTraits::IsSimpleTypedData<T> >::type >
{
	typedef DataPtr ReturnType;

	template<typename F>
	ReturnType operator()( typename F::ConstPtr d ) const
	{
		assert( d );
		typename T::Ptr result = new T;

		result->writable() = typename T::ValueType( d->readable() );

		return result;
	}
};

struct DataPromoteOp::Promote1Fn
{
	typedef DataPtr ReturnType;

	TypeId m_targetType;

	Promote1Fn( TypeId targetType ) : m_targetType( targetType )
	{
	}

	template<typename T, typename Enable = void >
	struct Func
	{
		ReturnType operator()( typename T::ConstPtr d, TypeId ) const
		{
			assert( d );
			throw Exception( "DataPromoteOp: Unsupported source data type \"" + d->typeName() + "\"." );
		}
	};

	template<typename F>
	ReturnType operator()( typename F::ConstPtr d ) const
	{
		assert( d );
		Func<F> f;
		return f(d, m_targetType);
	}

};

template<typename F >
struct DataPromoteOp::Promote1Fn::Func< F, typename boost::enable_if< TypeTraits::IsNumericVectorTypedData<F> >::type >
{
	ReturnType operator()( typename F::ConstPtr d, TypeId targetType ) const
	{
		assert( d );
		switch ( targetType )
		{
		case V2fVectorDataTypeId :
		{
			Promote2Fn<V2fVectorData> fn;
			return fn.template operator()<F>( d );
		}
		case V2dVectorDataTypeId :
		{
			Promote2Fn<V2dVectorData> fn;
			return fn.template operator()<F>( d );
		}
		case V3fVectorDataTypeId :
		{
			Promote2Fn<V3fVectorData> fn;
			return fn.template operator()<F>( d );
		}
		case V3dVectorDataTypeId :
		{
			Promote2Fn<V3dVectorData> fn;
			return fn.template operator()<F>( d );
		}
		case Color3fVectorDataTypeId :
		{
			Promote2Fn<Color3fVectorData> fn;
			return fn.template operator()<F>( d );
		}
		default :
			throw Exception( "DataPromoteOp: Unsupported target data type \"" + Object::typeNameFromTypeId( targetType ) + "\"." );
		}
	}
};

template<typename F >
struct DataPromoteOp::Promote1Fn::Func< F, typename boost::enable_if< TypeTraits::IsNumericSimpleTypedData<F> >::type >
{
	ReturnType operator()( typename F::ConstPtr d, TypeId targetType ) const
	{
		assert( d );
		switch ( targetType )
		{
		case V2fDataTypeId :
		{
			Promote2Fn<V2fData> fn;
			return fn.template operator()<F>( d );
		}
		case V2dDataTypeId :
		{
			Promote2Fn<V2dData> fn;
			return fn.template operator()<F>( d );
		}
		case V3fDataTypeId :
		{
			Promote2Fn<V3fData> fn;
			return fn.template operator()<F>( d );
		}
		case V3dDataTypeId :
		{
			Promote2Fn<V3dData> fn;
			return fn.template operator()<F>( d );
		}
		case Color3fDataTypeId :
		{
			Promote2Fn<Color3fData> fn;
			return fn.template operator()<F>( d );
		}
		default :
			throw Exception( "DataPromoteOp: Unsupported target data type \"" + Object::typeNameFromTypeId( targetType ) + "\"." );
		}
	}
};

} // namespace IECore

ObjectPtr DataPromoteOp::doOperation( ConstCompoundObjectPtr operands )
{
	assert( operands );

	const TypeId targetType = (TypeId)m_targetTypeParameter->getNumericValue();
	DataPtr srcData = static_pointer_cast<Data>( m_objectParameter->getValue() );
	assert( srcData );

	Promote1Fn fn( targetType );

	DataPtr targetData = despatchTypedData< Promote1Fn, TypeTraits::IsNumericTypedData >( srcData, fn );
	assert( targetData );
	assert( targetData->typeId() == targetType );

#ifndef NDEBUG
	size_t srcSize = despatchTypedData< TypedDataSize >( srcData ) ;
	size_t targetSize = despatchTypedData< TypedDataSize >( targetData ) ;

	/// This post-condition is stated in the class documentation
	assert( srcSize == targetSize );
#endif

	return targetData;
}
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: SchWhichPairs.hxx,v $
 *
 *  $Revision: 1.2 $
 *
 *  last change: $Author: bm $ $Date: 2003-12-09 16:30:51 $
 *
 *  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 CHART_SCHWHICHPAIRS_HXX
#define CHART_SCHWHICHPAIRS_HXX

#ifndef _SVX_SVXIDS_HRC
#include <svx/svxids.hrc>
#endif

#ifndef _XDEF_HXX
#include <svx/xdef.hxx>
#endif
#ifndef _SVDDEF_HXX
#include <svx/svddef.hxx>
#endif
#ifndef _EEITEM_HXX
#include <svx/eeitem.hxx>
#endif

#include "SchSfxItemIds.hxx"
#include "SchSlotIds.hxx"

namespace
{

const USHORT nTitleWhichPairs[] =
{
//  SCHATTR_TEXT_ORIENT, SCHATTR_TEXT_ORIENT,       //     4          sch/schattr.hxx
    SCHATTR_TEXT_STACKED, SCHATTR_TEXT_STACKED,       //     4          sch/schattr.hxx
    SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES,      //    53          sch/schattr.hxx
    SCHATTR_USER_DEFINED_ATTR, SCHATTR_USER_DEFINED_ATTR, //     100  sch/schattr.hxx
    XATTR_LINE_FIRST, XATTR_LINE_LAST,              //  1000 -  1016  svx/xdef.hxx
    XATTR_FILL_FIRST, XATTR_FILL_LAST,              //  1018 -  1046  svx/xdef.hxx
    SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST,      //  1067 -  1078  svx/svddef.hxx
    EE_ITEMS_START, EE_ITEMS_END,                   //  3994 -  4037  svx/eeitem.hxx
    0
};

const USHORT nAxisWhichPairs[] =
{
    XATTR_LINE_FIRST, XATTR_LINE_LAST,                          //  1000 -  1016  svx/xdef.hxx
    EE_ITEMS_START, EE_ITEMS_END,                               //  3994 -  4037  svx/eeitem.hxx
    SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_VALUE,   // 10585 - 10585  svx/svxids.hrc
    SID_ATTR_NUMBERFORMAT_SOURCE, SID_ATTR_NUMBERFORMAT_SOURCE, // 11432          svx/svxids.hrc
    SCHATTR_AXISTYPE, SCHATTR_AXISTYPE,                         //    39          sch/schattr.hxx
    SCHATTR_TEXT_START, SCHATTR_TEXT_END,                       //     4 -     6  sch/schattr.hxx
    SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES,                  //    53          sch/schattr.hxx
    SCHATTR_TEXT_OVERLAP, SCHATTR_TEXT_OVERLAP,                 //    54          sch/schattr.hxx
    SCHATTR_AXIS_START, SCHATTR_AXIS_END,                       //    70 -    95  sch/schattr.hxx
    SCHATTR_USER_DEFINED_ATTR, SCHATTR_USER_DEFINED_ATTR,       //   100          sch/schattr.hxx
    // SID_TEXTBREAK, SID_TEXTBREAK,                                // 30587          sch/app.hrc
    SCHATTR_TEXTBREAK, SCHATTR_TEXTBREAK,                       // 30587          sch/schattr.hxx
    0
};

const USHORT nAllAxisWhichPairs[] =
{
    XATTR_LINE_FIRST, XATTR_LINE_LAST,              //  1000 -  1016  svx/xdef.hxx
    EE_ITEMS_START, EE_ITEMS_END,                   //  3994 -  4037  svx/eeitem.hxx
//  SCHATTR_TEXT_ORIENT, SCHATTR_TEXT_ORIENT,       //    4           sch/schattr.hxx
    SCHATTR_TEXT_START, SCHATTR_TEXT_END,           //     4 -     6  sch/schattr.hxx
    SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES,      //    53          sch/schattr.hxx
    SCHATTR_TEXT_OVERLAP, SCHATTR_TEXT_OVERLAP,     //    54          sch/schattr.hxx
    SCHATTR_AXIS_SHOWDESCR, SCHATTR_AXIS_SHOWDESCR, //    85          sch/schattr.hxx
    // SID_TEXTBREAK, SID_TEXTBREAK,                    // 30587          sch/app.hrc
    SCHATTR_TEXTBREAK, SCHATTR_TEXTBREAK,           // 30587          sch/schattr.hxx
    0
};

const USHORT nGridWhichPairs[] =
{
    XATTR_LINE_FIRST, XATTR_LINE_LAST,              //  1000 -  1016  svx/xdef.hxx
    SCHATTR_USER_DEFINED_ATTR, SCHATTR_USER_DEFINED_ATTR, //     100  sch/schattr.hxx
    0
};

const USHORT nChartWhichPairs[] =
{
    SCHATTR_STYLE_START,SCHATTR_STYLE_END,          //    59 -    68  sch/schattr.hxx
    SCHATTR_USER_DEFINED_ATTR, SCHATTR_USER_DEFINED_ATTR, //     100  sch/schattr.hxx
    0
};

const USHORT nDiagramAreaWhichPairs[] =
{
    XATTR_LINE_FIRST, XATTR_LINE_LAST,              //  1000 -  1016  svx/xdef.hxx
    XATTR_FILL_FIRST, XATTR_FILL_LAST,              //  1018 -  1046  svx/xdef.hxx
    SCHATTR_USER_DEFINED_ATTR, SCHATTR_USER_DEFINED_ATTR, //     100  sch/schattr.hxx
    0
};

const USHORT nAreaAndChartWhichPairs[] =   // pairs for chart AND area
{
    XATTR_LINE_FIRST, XATTR_LINE_LAST,              //  1000 -  1016  svx/xdef.hxx
    XATTR_FILL_FIRST, XATTR_FILL_LAST,              //  1018 -  1046  svx/xdef.hxx
    SCHATTR_STYLE_START,SCHATTR_STYLE_END,          //    59 -    68  sch/schattr.hxx
    SCHATTR_USER_DEFINED_ATTR, SCHATTR_USER_DEFINED_ATTR, //     100  sch/schattr.hxx
    0
};

const USHORT nLegendWhichPairs[] =
{
    XATTR_LINE_FIRST, XATTR_LINE_LAST,              //  1000 -  1016  svx/xdef.hxx
    XATTR_FILL_FIRST, XATTR_FILL_LAST,              //  1018 -  1046  svx/xdef.hxx
    SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST,      //  1067 -  1078  svx/svddef.hxx
    EE_ITEMS_START, EE_ITEMS_END,                   //  3994 -  4037  svx/eeitem.hxx
    SCHATTR_LEGEND_START, SCHATTR_LEGEND_END,       //     3 -     3  sch/schattr.hxx
    SCHATTR_USER_DEFINED_ATTR, SCHATTR_USER_DEFINED_ATTR, //     100  sch/schattr.hxx
    0
};

const USHORT nDataLabelWhichPairs[] =
{
    SCHATTR_DATADESCR_START, SCHATTR_DATADESCR_END,
    0
};

#define CHART_POINT_WHICHPAIRS  \
    XATTR_LINE_FIRST, XATTR_LINE_LAST,              /*  1000 -  1016  svx/xdef.hxx   */ \
    XATTR_FILL_FIRST, XATTR_FILL_LAST,              /*  1018 -  1046  svx/xdef.hxx   */ \
    EE_ITEMS_START, EE_ITEMS_END,                   /*  3994 -  4037  svx/eeitem.hxx */ \
    SCHATTR_DATADESCR_START, SCHATTR_DATADESCR_END, /*     1 -     2  sch/schattr.hxx*/ \
    SCHATTR_DUMMY0, SCHATTR_DUMMY0,                 /*    40          sch/schattr.hxx*/ \
    SCHATTR_DUMMY1, SCHATTR_DUMMY1,                 /*    41          sch/schattr.hxx*/ \
    SCHATTR_STYLE_START,SCHATTR_STYLE_END,          /*    59 -    68  sch/schattr.hxx*/ \
    SCHATTR_SYMBOL_BRUSH,SCHATTR_SYMBOL_BRUSH,      /*    96          sch/schattr.hxx*/ \
    SCHATTR_SYMBOL_SIZE,SCHATTR_USER_DEFINED_ATTR,  /*    99 -   100  sch/schattr.hxx*/ \
    SDRATTR_3D_FIRST, SDRATTR_3D_LAST               /*  1244 -  1334  svx/svddef.hxx */

const USHORT nDataPointWhichPairs[] =
{
    CHART_POINT_WHICHPAIRS,
    0
};

const USHORT nRowWhichPairs[] =
{
    CHART_POINT_WHICHPAIRS,
    SCHATTR_STAT_START, SCHATTR_STAT_END,           /*    45 -    52  sch/schattr.hxx*/ \
    SCHATTR_AXIS,SCHATTR_AXIS,                      /*    69          sch/schattr.hxx*/ \
    0
};

const USHORT nAreaWhichPairs[] =
{
    XATTR_LINE_FIRST, XATTR_LINE_LAST,              //  1000 -  1016  svx/xdef.hxx
    XATTR_FILL_FIRST, XATTR_FILL_LAST,              //  1000 -  1016  svx/xdef.hxx
    SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST,      //  1067 -  1078  svx/svddef.hxx
    SCHATTR_USER_DEFINED_ATTR, SCHATTR_USER_DEFINED_ATTR, //     100  sch/schattr.hxx
    0
};

const USHORT nTextWhichPairs[] =
{
    EE_ITEMS_START, EE_ITEMS_END,                   //  3994 -  4037  svx/eeitem.hxx
//  SCHATTR_TEXT_ORIENT, SCHATTR_TEXT_ORIENT,       //     4          sch/schattr.hxx
    SCHATTR_TEXT_STACKED, SCHATTR_TEXT_STACKED,       //     4          sch/schattr.hxx
    SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES,      //    53          sch/schattr.hxx
    SCHATTR_USER_DEFINED_ATTR, SCHATTR_USER_DEFINED_ATTR, //     100  sch/schattr.hxx
    0
};

const USHORT nTextOrientWhichPairs[] =
{
    EE_ITEMS_START, EE_ITEMS_END,                   //  3994 -  4037  svx/eeitem.hxx
//  SCHATTR_TEXT_ORIENT, SCHATTR_TEXT_ORIENT,       //     4          sch/schattr.hxx
    SCHATTR_TEXT_STACKED, SCHATTR_TEXT_STACKED,       //     4          sch/schattr.hxx
    SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES,      //    53          sch/schattr.hxx
    0
};

const USHORT nStatWhichPairs[]=
{
    SCHATTR_STAT_START, SCHATTR_STAT_END,           //    45 -    52  sch/schattr.hxx
    0
};

// for CharacterProperties

const USHORT nCharacterPropertyWhichPairs[] =
{
    EE_ITEMS_START, EE_ITEMS_END,                   //  3994 -  4037  svx/eeitem.hxx
    0
};

const USHORT nLinePropertyWhichPairs[] =
{
    XATTR_LINE_FIRST, XATTR_LINE_LAST,              //  1000 -  1016  svx/xdef.hxx
    0
};

const USHORT nFillPropertyWhichPairs[] =
{
    XATTR_FILL_FIRST, XATTR_FILL_LAST,              //  1000 -  1016  svx/xdef.hxx
    SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST,      //  1067 -  1078  svx/svddef.hxx
    0
};

const USHORT nLineAndFillPropertyWhichPairs[] =
{
    XATTR_LINE_FIRST, XATTR_LINE_LAST,              //  1000 -  1016  svx/xdef.hxx
    XATTR_FILL_FIRST, XATTR_FILL_LAST,              //  1000 -  1016  svx/xdef.hxx
    SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST,      //  1067 -  1078  svx/svddef.hxx
    0
};

const USHORT nChartStyleWhichPairs[] =
{
    SCHATTR_DIAGRAM_STYLE,                SCHATTR_DIAGRAM_STYLE,
    SCHATTR_STYLE_SHAPE,                  SCHATTR_STYLE_SHAPE,
    SCHATTR_NUM_OF_LINES_FOR_BAR,         SCHATTR_NUM_OF_LINES_FOR_BAR,
    SCHATTR_SPLINE_ORDER,                 SCHATTR_SPLINE_ORDER,
    SCHATTR_SPLINE_RESOLUTION,            SCHATTR_SPLINE_RESOLUTION,
    0
};

} //  anonymous namespace

// CHART_SCHWHICHPAIRS_HXX
#endif
<commit_msg>INTEGRATION: CWS ooo19126 (1.2.110); FILE MERGED 2005/09/05 18:42:40 rt 1.2.110.1: #i54170# Change license header: remove SISSL<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: SchWhichPairs.hxx,v $
 *
 *  $Revision: 1.3 $
 *
 *  last change: $Author: rt $ $Date: 2005-09-08 00:30:39 $
 *
 *  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 CHART_SCHWHICHPAIRS_HXX
#define CHART_SCHWHICHPAIRS_HXX

#ifndef _SVX_SVXIDS_HRC
#include <svx/svxids.hrc>
#endif

#ifndef _XDEF_HXX
#include <svx/xdef.hxx>
#endif
#ifndef _SVDDEF_HXX
#include <svx/svddef.hxx>
#endif
#ifndef _EEITEM_HXX
#include <svx/eeitem.hxx>
#endif

#include "SchSfxItemIds.hxx"
#include "SchSlotIds.hxx"

namespace
{

const USHORT nTitleWhichPairs[] =
{
//  SCHATTR_TEXT_ORIENT, SCHATTR_TEXT_ORIENT,       //     4          sch/schattr.hxx
    SCHATTR_TEXT_STACKED, SCHATTR_TEXT_STACKED,       //     4          sch/schattr.hxx
    SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES,      //    53          sch/schattr.hxx
    SCHATTR_USER_DEFINED_ATTR, SCHATTR_USER_DEFINED_ATTR, //     100  sch/schattr.hxx
    XATTR_LINE_FIRST, XATTR_LINE_LAST,              //  1000 -  1016  svx/xdef.hxx
    XATTR_FILL_FIRST, XATTR_FILL_LAST,              //  1018 -  1046  svx/xdef.hxx
    SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST,      //  1067 -  1078  svx/svddef.hxx
    EE_ITEMS_START, EE_ITEMS_END,                   //  3994 -  4037  svx/eeitem.hxx
    0
};

const USHORT nAxisWhichPairs[] =
{
    XATTR_LINE_FIRST, XATTR_LINE_LAST,                          //  1000 -  1016  svx/xdef.hxx
    EE_ITEMS_START, EE_ITEMS_END,                               //  3994 -  4037  svx/eeitem.hxx
    SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_VALUE,   // 10585 - 10585  svx/svxids.hrc
    SID_ATTR_NUMBERFORMAT_SOURCE, SID_ATTR_NUMBERFORMAT_SOURCE, // 11432          svx/svxids.hrc
    SCHATTR_AXISTYPE, SCHATTR_AXISTYPE,                         //    39          sch/schattr.hxx
    SCHATTR_TEXT_START, SCHATTR_TEXT_END,                       //     4 -     6  sch/schattr.hxx
    SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES,                  //    53          sch/schattr.hxx
    SCHATTR_TEXT_OVERLAP, SCHATTR_TEXT_OVERLAP,                 //    54          sch/schattr.hxx
    SCHATTR_AXIS_START, SCHATTR_AXIS_END,                       //    70 -    95  sch/schattr.hxx
    SCHATTR_USER_DEFINED_ATTR, SCHATTR_USER_DEFINED_ATTR,       //   100          sch/schattr.hxx
    // SID_TEXTBREAK, SID_TEXTBREAK,                                // 30587          sch/app.hrc
    SCHATTR_TEXTBREAK, SCHATTR_TEXTBREAK,                       // 30587          sch/schattr.hxx
    0
};

const USHORT nAllAxisWhichPairs[] =
{
    XATTR_LINE_FIRST, XATTR_LINE_LAST,              //  1000 -  1016  svx/xdef.hxx
    EE_ITEMS_START, EE_ITEMS_END,                   //  3994 -  4037  svx/eeitem.hxx
//  SCHATTR_TEXT_ORIENT, SCHATTR_TEXT_ORIENT,       //    4           sch/schattr.hxx
    SCHATTR_TEXT_START, SCHATTR_TEXT_END,           //     4 -     6  sch/schattr.hxx
    SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES,      //    53          sch/schattr.hxx
    SCHATTR_TEXT_OVERLAP, SCHATTR_TEXT_OVERLAP,     //    54          sch/schattr.hxx
    SCHATTR_AXIS_SHOWDESCR, SCHATTR_AXIS_SHOWDESCR, //    85          sch/schattr.hxx
    // SID_TEXTBREAK, SID_TEXTBREAK,                    // 30587          sch/app.hrc
    SCHATTR_TEXTBREAK, SCHATTR_TEXTBREAK,           // 30587          sch/schattr.hxx
    0
};

const USHORT nGridWhichPairs[] =
{
    XATTR_LINE_FIRST, XATTR_LINE_LAST,              //  1000 -  1016  svx/xdef.hxx
    SCHATTR_USER_DEFINED_ATTR, SCHATTR_USER_DEFINED_ATTR, //     100  sch/schattr.hxx
    0
};

const USHORT nChartWhichPairs[] =
{
    SCHATTR_STYLE_START,SCHATTR_STYLE_END,          //    59 -    68  sch/schattr.hxx
    SCHATTR_USER_DEFINED_ATTR, SCHATTR_USER_DEFINED_ATTR, //     100  sch/schattr.hxx
    0
};

const USHORT nDiagramAreaWhichPairs[] =
{
    XATTR_LINE_FIRST, XATTR_LINE_LAST,              //  1000 -  1016  svx/xdef.hxx
    XATTR_FILL_FIRST, XATTR_FILL_LAST,              //  1018 -  1046  svx/xdef.hxx
    SCHATTR_USER_DEFINED_ATTR, SCHATTR_USER_DEFINED_ATTR, //     100  sch/schattr.hxx
    0
};

const USHORT nAreaAndChartWhichPairs[] =   // pairs for chart AND area
{
    XATTR_LINE_FIRST, XATTR_LINE_LAST,              //  1000 -  1016  svx/xdef.hxx
    XATTR_FILL_FIRST, XATTR_FILL_LAST,              //  1018 -  1046  svx/xdef.hxx
    SCHATTR_STYLE_START,SCHATTR_STYLE_END,          //    59 -    68  sch/schattr.hxx
    SCHATTR_USER_DEFINED_ATTR, SCHATTR_USER_DEFINED_ATTR, //     100  sch/schattr.hxx
    0
};

const USHORT nLegendWhichPairs[] =
{
    XATTR_LINE_FIRST, XATTR_LINE_LAST,              //  1000 -  1016  svx/xdef.hxx
    XATTR_FILL_FIRST, XATTR_FILL_LAST,              //  1018 -  1046  svx/xdef.hxx
    SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST,      //  1067 -  1078  svx/svddef.hxx
    EE_ITEMS_START, EE_ITEMS_END,                   //  3994 -  4037  svx/eeitem.hxx
    SCHATTR_LEGEND_START, SCHATTR_LEGEND_END,       //     3 -     3  sch/schattr.hxx
    SCHATTR_USER_DEFINED_ATTR, SCHATTR_USER_DEFINED_ATTR, //     100  sch/schattr.hxx
    0
};

const USHORT nDataLabelWhichPairs[] =
{
    SCHATTR_DATADESCR_START, SCHATTR_DATADESCR_END,
    0
};

#define CHART_POINT_WHICHPAIRS  \
    XATTR_LINE_FIRST, XATTR_LINE_LAST,              /*  1000 -  1016  svx/xdef.hxx   */ \
    XATTR_FILL_FIRST, XATTR_FILL_LAST,              /*  1018 -  1046  svx/xdef.hxx   */ \
    EE_ITEMS_START, EE_ITEMS_END,                   /*  3994 -  4037  svx/eeitem.hxx */ \
    SCHATTR_DATADESCR_START, SCHATTR_DATADESCR_END, /*     1 -     2  sch/schattr.hxx*/ \
    SCHATTR_DUMMY0, SCHATTR_DUMMY0,                 /*    40          sch/schattr.hxx*/ \
    SCHATTR_DUMMY1, SCHATTR_DUMMY1,                 /*    41          sch/schattr.hxx*/ \
    SCHATTR_STYLE_START,SCHATTR_STYLE_END,          /*    59 -    68  sch/schattr.hxx*/ \
    SCHATTR_SYMBOL_BRUSH,SCHATTR_SYMBOL_BRUSH,      /*    96          sch/schattr.hxx*/ \
    SCHATTR_SYMBOL_SIZE,SCHATTR_USER_DEFINED_ATTR,  /*    99 -   100  sch/schattr.hxx*/ \
    SDRATTR_3D_FIRST, SDRATTR_3D_LAST               /*  1244 -  1334  svx/svddef.hxx */

const USHORT nDataPointWhichPairs[] =
{
    CHART_POINT_WHICHPAIRS,
    0
};

const USHORT nRowWhichPairs[] =
{
    CHART_POINT_WHICHPAIRS,
    SCHATTR_STAT_START, SCHATTR_STAT_END,           /*    45 -    52  sch/schattr.hxx*/ \
    SCHATTR_AXIS,SCHATTR_AXIS,                      /*    69          sch/schattr.hxx*/ \
    0
};

const USHORT nAreaWhichPairs[] =
{
    XATTR_LINE_FIRST, XATTR_LINE_LAST,              //  1000 -  1016  svx/xdef.hxx
    XATTR_FILL_FIRST, XATTR_FILL_LAST,              //  1000 -  1016  svx/xdef.hxx
    SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST,      //  1067 -  1078  svx/svddef.hxx
    SCHATTR_USER_DEFINED_ATTR, SCHATTR_USER_DEFINED_ATTR, //     100  sch/schattr.hxx
    0
};

const USHORT nTextWhichPairs[] =
{
    EE_ITEMS_START, EE_ITEMS_END,                   //  3994 -  4037  svx/eeitem.hxx
//  SCHATTR_TEXT_ORIENT, SCHATTR_TEXT_ORIENT,       //     4          sch/schattr.hxx
    SCHATTR_TEXT_STACKED, SCHATTR_TEXT_STACKED,       //     4          sch/schattr.hxx
    SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES,      //    53          sch/schattr.hxx
    SCHATTR_USER_DEFINED_ATTR, SCHATTR_USER_DEFINED_ATTR, //     100  sch/schattr.hxx
    0
};

const USHORT nTextOrientWhichPairs[] =
{
    EE_ITEMS_START, EE_ITEMS_END,                   //  3994 -  4037  svx/eeitem.hxx
//  SCHATTR_TEXT_ORIENT, SCHATTR_TEXT_ORIENT,       //     4          sch/schattr.hxx
    SCHATTR_TEXT_STACKED, SCHATTR_TEXT_STACKED,       //     4          sch/schattr.hxx
    SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES,      //    53          sch/schattr.hxx
    0
};

const USHORT nStatWhichPairs[]=
{
    SCHATTR_STAT_START, SCHATTR_STAT_END,           //    45 -    52  sch/schattr.hxx
    0
};

// for CharacterProperties

const USHORT nCharacterPropertyWhichPairs[] =
{
    EE_ITEMS_START, EE_ITEMS_END,                   //  3994 -  4037  svx/eeitem.hxx
    0
};

const USHORT nLinePropertyWhichPairs[] =
{
    XATTR_LINE_FIRST, XATTR_LINE_LAST,              //  1000 -  1016  svx/xdef.hxx
    0
};

const USHORT nFillPropertyWhichPairs[] =
{
    XATTR_FILL_FIRST, XATTR_FILL_LAST,              //  1000 -  1016  svx/xdef.hxx
    SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST,      //  1067 -  1078  svx/svddef.hxx
    0
};

const USHORT nLineAndFillPropertyWhichPairs[] =
{
    XATTR_LINE_FIRST, XATTR_LINE_LAST,              //  1000 -  1016  svx/xdef.hxx
    XATTR_FILL_FIRST, XATTR_FILL_LAST,              //  1000 -  1016  svx/xdef.hxx
    SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST,      //  1067 -  1078  svx/svddef.hxx
    0
};

const USHORT nChartStyleWhichPairs[] =
{
    SCHATTR_DIAGRAM_STYLE,                SCHATTR_DIAGRAM_STYLE,
    SCHATTR_STYLE_SHAPE,                  SCHATTR_STYLE_SHAPE,
    SCHATTR_NUM_OF_LINES_FOR_BAR,         SCHATTR_NUM_OF_LINES_FOR_BAR,
    SCHATTR_SPLINE_ORDER,                 SCHATTR_SPLINE_ORDER,
    SCHATTR_SPLINE_RESOLUTION,            SCHATTR_SPLINE_RESOLUTION,
    0
};

} //  anonymous namespace

// CHART_SCHWHICHPAIRS_HXX
#endif
<|endoftext|>


<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/browser/chromeos/browser_notification_observers.h"

#include "chrome/browser/chrome_thread.h"
#include "chrome/common/notification_service.h"

namespace {

// Static function that records uptime in /proc/uptime to tmp for metrics use.
void RecordUptime() {
  system("cat /proc/uptime > /tmp/uptime-chrome-first-render &");
}

}  // namespace

namespace chromeos {

InitialTabNotificationObserver::InitialTabNotificationObserver() {
  registrar_.Add(this, NotificationType::LOAD_START,
                 NotificationService::AllSources());
}

InitialTabNotificationObserver::~InitialTabNotificationObserver() {
}

void InitialTabNotificationObserver::Observe(
    NotificationType type,
    const NotificationSource& source,
    const NotificationDetails& details) {
  // Only log for first tab to render.  Make sure this is only done once.
  if (type == NotificationType::LOAD_START &&
      num_tabs_.GetNext() == 0) {
    // If we can't post it, it doesn't matter.
    ChromeThread::PostTask(
        ChromeThread::FILE, FROM_HERE,
        NewRunnableFunction(RecordUptime));
    registrar_.Remove(this, NotificationType::LOAD_START,
                      NotificationService::AllSources());
  }
}

}  // namespace chromeos
<commit_msg>ChromiumOS: read /proc/uptime without using system().<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/browser/chromeos/browser_notification_observers.h"

#include <string>

#include "base/file_util.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/common/notification_service.h"

namespace {

// Static function that records uptime in /proc/uptime to tmp for metrics use.
void RecordUptime() {
  std::string uptime;
  const FilePath proc_uptime = FilePath("/proc/uptime");
  const FilePath uptime_output = FilePath("/tmp/uptime-chrome-first-render");

  if (file_util::ReadFileToString(proc_uptime, &uptime))
    file_util::WriteFile(uptime_output, uptime.data(), uptime.size());
}

}  // namespace

namespace chromeos {

InitialTabNotificationObserver::InitialTabNotificationObserver() {
  registrar_.Add(this, NotificationType::LOAD_START,
                 NotificationService::AllSources());
}

InitialTabNotificationObserver::~InitialTabNotificationObserver() {
}

void InitialTabNotificationObserver::Observe(
    NotificationType type,
    const NotificationSource& source,
    const NotificationDetails& details) {
  // Only log for first tab to render.  Make sure this is only done once.
  if (type == NotificationType::LOAD_START &&
      num_tabs_.GetNext() == 0) {
    // If we can't post it, it doesn't matter.
    ChromeThread::PostTask(
        ChromeThread::FILE, FROM_HERE,
        NewRunnableFunction(RecordUptime));
    registrar_.Remove(this, NotificationType::LOAD_START,
                      NotificationService::AllSources());
  }
}

}  // namespace chromeos
<|endoftext|>