<commit_before>#include "PagerWidget.h"
#include <blackbox/BlackBox.h>
#include <blackbox/gfx/ImGui/utils_imgui.h>
#include <bblib/codecvt.h>
#include <imgui/imgui_internal.h>
#include <blackbox/utils_window.h>
#include <yaml-cpp/yaml.h>
#include "utils_yaml.h"
#include "WidgetConfig_yaml.h"

namespace YAML {
	template<>
	struct convert<bb::imgui::PagerWidgetConfig>
	{
		static Node encode(bb::imgui::PagerWidgetConfig const & rhs)
		{
			Node node = convert<bb::WidgetConfig>::encode(rhs);
			//node.push_back(rhs.);
			return node;
		}

		static bool decode (Node const & node, bb::imgui::PagerWidgetConfig & rhs)
		{
			try
			{
				if (convert<bb::WidgetConfig>::decode(node, rhs))
				{
					return true;
				}
			}
			catch (std::exception const & e)
			{
				return false;
			}
			return true;
		}
	};
}

namespace bb {
namespace imgui {

	PagerWidget::PagerWidget ()
		: GuiWidget()
	{
		m_tasks.reserve(64);
	}

	bool PagerWidget::loadConfig (YAML::Node & y_cfg_node)
	{
		if (!y_cfg_node.IsNull())
		{
			PagerWidgetConfig tmp = y_cfg_node.as<PagerWidgetConfig>();
			m_config = std::move(tmp);
			return true;
		}
		return false;
	}

	void PagerWidget::UpdateTasks ()
	{
		m_tasks.clear();

		Tasks & tasks = BlackBox::Instance().GetTasks();
		tasks.MkDataCopy(m_tasks);
	}

	void PagerWidget::DrawUI ()
	{
		WorkSpaces const & ws = BlackBox::Instance().GetWorkSpaces();
		char title[256];
		bbstring const & cluster_id = ws.GetCurrentClusterId();
		WorkGraphConfig const * wg = ws.FindCluster(cluster_id);
		if (wg == nullptr)
			return;

		char curr_ws_u8[TaskInfo::e_wspaceLenMax];
		codecvt_utf16_utf8(wg->m_currentVertexId, curr_ws_u8, TaskInfo::e_wspaceLenMax);
		_snprintf(title, 256, "%s (%s)", curr_ws_u8, cluster_id.c_str());

		ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiSetCond_Always);

		ImVec2 const & display = ImGui::GetIO().DisplaySize;
		if (m_contentSize.x > 0 && m_contentSize.y > 0)
		{
			ImGuiStyle & style = ImGui::GetStyle();
			resizeWindowToContents(m_gfxWindow->m_hwnd, m_contentSize.x, m_contentSize.y, style.WindowMinSize.x, style.WindowMinSize.y, style.WindowRounding);
		}

		ImGui::Begin(title, &m_config.m_show, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize);

		UpdateTasks();

		uint32_t const rows = wg->MaxRowCount();
		uint32_t const cols = wg->MaxColCount();

		if (cols && rows)
		{
			ImGui::Columns(cols, "mixed", true);
			ImGui::Separator();

			for (uint32_t c = 0; c < cols; ++c)
			{
				for (uint32_t r = 0; r < rows; ++r)
				{
					bbstring const & vertex_id = wg->m_vertexlists[r][c];
					char idu8[TaskInfo::e_wspaceLenMax];
					codecvt_utf16_utf8(vertex_id, idu8, TaskInfo::e_wspaceLenMax);

					if (ImGui::Button(idu8))
					{
						BlackBox::Instance().WorkSpacesSetCurrentVertexId(vertex_id);
					}

					int tmp = 0;
					for (TaskInfo & t : m_tasks)
					{
// 						if (t.m_config && t.m_config->m_bbtasks)
// 							continue;
						if (t.m_wspace == vertex_id || t.IsSticky())
						{
							if (tmp++ % 3 != 0)
								ImGui::SameLine();

							Tasks & tasks = BlackBox::Instance().GetTasks();
							IconId const icoid = t.m_icoSmall;
							if (!icoid.IsValid())
							{
								// @TODO: assign color to hwnd?
								if (ImGui::ColorButton(ImColor(0, 0, 128, 255)))
								{
									tasks.Focus(t.m_hwnd);
								}
							}
							else
							{
								int framing = -1;
								ImGui::PushID(t.m_hwnd);
								bool const skip_taskman = t.IsTaskManIgnored();
								bool const is_sticky = t.IsSticky();
								ImColor const col_int = ImColor(0, 0, 0, 0);
								ImColor const col_border = ImColor(255, 255, 255, 255);
								ImColor const col_int_skip_taskman = ImColor(0, 0, 0, 128);
								ImColor const col_border_skip = ImColor(0, 0, 0, 128);
								bool const clkd = ImGui::IconButton(icoid, skip_taskman ? col_int_skip_taskman : col_int, skip_taskman ? col_border_skip : col_border, framing);
								if (ImGui::BeginPopupContextItem(""))
								{
									if (ImGui::Selectable(is_sticky ? "UnStick" : "Stick"))
									{
										if (is_sticky)
											tasks.UnsetSticky(t.m_hwnd);
										else
											tasks.SetSticky(t.m_hwnd);
									}

									if (ImGui::Selectable(skip_taskman ? "back to TaskMan" : "rm from TaskMan"))
									{
										if (skip_taskman)
											tasks.UnsetTaskManIgnored(t.m_hwnd);
										else
											tasks.SetTaskManIgnored(t.m_hwnd);
									}

									if (ImGui::Button("Close Menu"))
										ImGui::CloseCurrentPopup();
									ImGui::EndPopup();
								}
								if (clkd)
								{
									tasks.Focus(t.m_hwnd);
								}
								ImGui::PopID();
							}
						}
					}
				}
				ImGui::NextColumn();
			}
		}
		ImGuiWindow * w = ImGui::GetCurrentWindowRead();
		ImVec2 const & sz1 = w->SizeContents;
		m_contentSize = sz1;
		ImGui::End();
 	}

}}

<commit_msg>- separator<commit_after>#include "PagerWidget.h"
#include <blackbox/BlackBox.h>
#include <blackbox/gfx/ImGui/utils_imgui.h>
#include <bblib/codecvt.h>
#include <imgui/imgui_internal.h>
#include <blackbox/utils_window.h>
#include <yaml-cpp/yaml.h>
#include "utils_yaml.h"
#include "WidgetConfig_yaml.h"

namespace YAML {
	template<>
	struct convert<bb::imgui::PagerWidgetConfig>
	{
		static Node encode(bb::imgui::PagerWidgetConfig const & rhs)
		{
			Node node = convert<bb::WidgetConfig>::encode(rhs);
			//node.push_back(rhs.);
			return node;
		}

		static bool decode (Node const & node, bb::imgui::PagerWidgetConfig & rhs)
		{
			try
			{
				if (convert<bb::WidgetConfig>::decode(node, rhs))
				{
					return true;
				}
			}
			catch (std::exception const & e)
			{
				return false;
			}
			return true;
		}
	};
}

namespace bb {
namespace imgui {

	PagerWidget::PagerWidget ()
		: GuiWidget()
	{
		m_tasks.reserve(64);
	}

	bool PagerWidget::loadConfig (YAML::Node & y_cfg_node)
	{
		if (!y_cfg_node.IsNull())
		{
			PagerWidgetConfig tmp = y_cfg_node.as<PagerWidgetConfig>();
			m_config = std::move(tmp);
			return true;
		}
		return false;
	}

	void PagerWidget::UpdateTasks ()
	{
		m_tasks.clear();

		Tasks & tasks = BlackBox::Instance().GetTasks();
		tasks.MkDataCopy(m_tasks);
	}

	void PagerWidget::DrawUI ()
	{
		WorkSpaces const & ws = BlackBox::Instance().GetWorkSpaces();
		char title[256];
		bbstring const & cluster_id = ws.GetCurrentClusterId();
		WorkGraphConfig const * wg = ws.FindCluster(cluster_id);
		if (wg == nullptr)
			return;

		char curr_ws_u8[TaskInfo::e_wspaceLenMax];
		codecvt_utf16_utf8(wg->m_currentVertexId, curr_ws_u8, TaskInfo::e_wspaceLenMax);
		_snprintf(title, 256, "%s (%s)", curr_ws_u8, cluster_id.c_str());

		ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiSetCond_Always);

		ImVec2 const & display = ImGui::GetIO().DisplaySize;
		if (m_contentSize.x > 0 && m_contentSize.y > 0)
		{
			ImGuiStyle & style = ImGui::GetStyle();
			resizeWindowToContents(m_gfxWindow->m_hwnd, m_contentSize.x, m_contentSize.y, style.WindowMinSize.x, style.WindowMinSize.y, style.WindowRounding);
		}

		ImGui::Begin(title, &m_config.m_show, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize);

		UpdateTasks();

		uint32_t const rows = wg->MaxRowCount();
		uint32_t const cols = wg->MaxColCount();

		if (cols && rows)
		{
			ImGui::Columns(cols, "mixed", true);
			for (uint32_t c = 0; c < cols; ++c)
			{
				for (uint32_t r = 0; r < rows; ++r)
				{
					bbstring const & vertex_id = wg->m_vertexlists[r][c];
					char idu8[TaskInfo::e_wspaceLenMax];
					codecvt_utf16_utf8(vertex_id, idu8, TaskInfo::e_wspaceLenMax);

					if (ImGui::Button(idu8))
					{
						BlackBox::Instance().WorkSpacesSetCurrentVertexId(vertex_id);
					}

					int tmp = 0;
					for (TaskInfo & t : m_tasks)
					{
// 						if (t.m_config && t.m_config->m_bbtasks)
// 							continue;
						if (t.m_wspace == vertex_id || t.IsSticky())
						{
							if (tmp++ % 3 != 0)
								ImGui::SameLine();

							Tasks & tasks = BlackBox::Instance().GetTasks();
							IconId const icoid = t.m_icoSmall;
							if (!icoid.IsValid())
							{
								// @TODO: assign color to hwnd?
								if (ImGui::ColorButton(ImColor(0, 0, 128, 255)))
								{
									tasks.Focus(t.m_hwnd);
								}
							}
							else
							{
								int framing = -1;
								ImGui::PushID(t.m_hwnd);
								bool const skip_taskman = t.IsTaskManIgnored();
								bool const is_sticky = t.IsSticky();
								ImColor const col_int = ImColor(0, 0, 0, 0);
								ImColor const col_border = ImColor(255, 255, 255, 255);
								ImColor const col_int_skip_taskman = ImColor(0, 0, 0, 128);
								ImColor const col_border_skip = ImColor(0, 0, 0, 128);
								bool const clkd = ImGui::IconButton(icoid, skip_taskman ? col_int_skip_taskman : col_int, skip_taskman ? col_border_skip : col_border, framing);
								if (ImGui::BeginPopupContextItem(""))
								{
									if (ImGui::Selectable(is_sticky ? "UnStick" : "Stick"))
									{
										if (is_sticky)
											tasks.UnsetSticky(t.m_hwnd);
										else
											tasks.SetSticky(t.m_hwnd);
									}

									if (ImGui::Selectable(skip_taskman ? "back to TaskMan" : "rm from TaskMan"))
									{
										if (skip_taskman)
											tasks.UnsetTaskManIgnored(t.m_hwnd);
										else
											tasks.SetTaskManIgnored(t.m_hwnd);
									}

									if (ImGui::Button("Close Menu"))
										ImGui::CloseCurrentPopup();
									ImGui::EndPopup();
								}
								if (clkd)
								{
									tasks.Focus(t.m_hwnd);
								}
								ImGui::PopID();
							}
						}
					}
				}
				ImGui::NextColumn();
			}
		}
		ImGuiWindow * w = ImGui::GetCurrentWindowRead();
		ImVec2 const & sz1 = w->SizeContents;
		m_contentSize = sz1;
		ImGui::End();
 	}

}}

<|endoftext|>


<commit_before>//! Copyright (c) 2013 ASMlover. 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 ofconditions 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 materialsprovided 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.
#include "locker.h"
#include "thread.h"
#include "thread_pool.h"

thread_pool_t::thread_pool_t(void)
  : mutex_(NULL)
  , running_(false)
  , signal_(NULL)
{
}

thread_pool_t::~thread_pool_t(void)
{
  if (running_)
    stop();
}

void
thread_pool_t::start(int num_thread)
{
  if (num_thread < DEF_THREADS_MIN)
    num_thread = DEF_THREADS_MIN;
  if (num_thread > DEF_THREADS_MAX)
    num_thread = DEF_THREADS_MAX;

  mutex_ = new mutex_t();
  assert(NULL != mutex_);
  signal_ = CreateEvent(NULL, FALSE, FALSE, NULL);
  assert(NULL != signal_);
  running_ = true;

  for (int i = 0; i < num_thread; ++i) {
    threads_.push_back(new thread_t(&thread_pool_t::s_routine, this));
    threads_[i]->start();
  }
}

void
thread_pool_t::stop(void)
{
  if (!running_)
    return;

  running_ = false;
  SetEvent(signal_);

  int num_thread = (int)threads_.size();
  for (int i = 0; i < num_thread; ++i) {
    threads_[i]->join();
    delete threads_[i];
  }
  threads_.clear();

  CloseHandle(signal_);
  signal_ = NULL;
}

void
thread_pool_t::run(void (*routine)(void*), void* arg)
{
  if (threads_.empty())
    routine(arg);
  else {
    guard_t lock(mutex_);

    tasks_.push(task_t(routine, arg));
    SetEvent(signal_);
  }
}

task_t
thread_pool_t::take(void)
{
  while (tasks_.empty() && running_)
    WaitForSingleObject(signal_, 5);

  task_t task;
  guard_t lock(mutex_);
  if (!tasks_.empty()) {
    task = tasks_.front();
    tasks_.pop();
  }
  return task;
}

void
thread_pool_t::s_routine(void* arg)
{
  thread_pool_t* self = static_cast<thread_pool_t*>(arg);
  assert(NULL != self);

  while (self->running_) {
    task_t task = self->take();

    if (NULL != task.routine_)
      task.routine_(task.arg_);
  }
}
<commit_msg>add debug information for thread pool<commit_after>//! Copyright (c) 2013 ASMlover. 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 ofconditions 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 materialsprovided 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.
#include "locker.h"
#include "thread.h"
#include "thread_pool.h"

thread_pool_t::thread_pool_t(void)
  : mutex_(NULL)
  , running_(false)
  , signal_(NULL)
{
}

thread_pool_t::~thread_pool_t(void)
{
  if (running_)
    stop();
}

void
thread_pool_t::start(int num_thread)
{
  if (num_thread < DEF_THREADS_MIN)
    num_thread = DEF_THREADS_MIN;
  if (num_thread > DEF_THREADS_MAX)
    num_thread = DEF_THREADS_MAX;

  mutex_ = new mutex_t();
  assert(NULL != mutex_);
  signal_ = CreateEvent(NULL, FALSE, FALSE, NULL);
  assert(NULL != signal_);
  running_ = true;

  for (int i = 0; i < num_thread; ++i) {
    threads_.push_back(new thread_t(&thread_pool_t::s_routine, this));
    threads_[i]->start();
  }
}

void
thread_pool_t::stop(void)
{
  if (!running_)
    return;

  running_ = false;
  SetEvent(signal_);

  int num_thread = (int)threads_.size();
  for (int i = 0; i < num_thread; ++i) {
    threads_[i]->join();
    delete threads_[i];
  }
  threads_.clear();

  CloseHandle(signal_);
  signal_ = NULL;
}

void
thread_pool_t::run(void (*routine)(void*), void* arg)
{
  if (threads_.empty())
    routine(arg);
  else {
    guard_t lock(mutex_);

    tasks_.push(task_t(routine, arg));
    SetEvent(signal_);
  }
}

task_t
thread_pool_t::take(void)
{
  while (tasks_.empty() && running_)
    WaitForSingleObject(signal_, 5);

  task_t task;
  guard_t lock(mutex_);
  if (!tasks_.empty()) {
    task = tasks_.front();
    tasks_.pop();
  }
  return task;
}

void
thread_pool_t::s_routine(void* arg)
{
  thread_pool_t* self = static_cast<thread_pool_t*>(arg);
  assert(NULL != self);

  DWORD tid = GetCurrentThreadId();
  fprintf(stdout, "thread<%lu> running ...\n", tid);
  while (self->running_) {
    task_t task = self->take();

    if (NULL != task.routine_)
      task.routine_(task.arg_);
  }
  fprintf(stdout, "thread<%lu> exiting ...\n", tid);
}
<|endoftext|>


<commit_before>//
// Copyright (C) 2013-2018 University of Amsterdam
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public
// License along with this program.  If not, see
// <http://www.gnu.org/licenses/>.
//

#include "datasettablemodel.h"

#include <iostream>
#include <fstream>

#include <QSize>
#include <QDebug>
#include <QQmlEngine>

#include "qutils.h"

using namespace std;

DataSetTableModel::DataSetTableModel(QObject *parent) :
    QAbstractTableModel(parent)
{
	_dataSet = NULL;

	_nominalTextIcon = QIcon(":/icons/variable-nominal-text.svg");
	_nominalIcon = QIcon(":/icons/variable-nominal.svg");
	_ordinalIcon = QIcon(":/icons/variable-ordinal.svg");
	_scaleIcon = QIcon(":/icons/variable-scale.svg");
}

QVariant DataSetTableModel::getColumnTypesWithCorrespondingIcon(bool BothNominalVersions)
{
	QVariantList ColumnTypeAndIcons;

	ColumnTypeAndIcons.push_back(QVariant(QString("../icons/variable-scale.svg")));
	ColumnTypeAndIcons.push_back(QVariant(QString("../icons/variable-ordinal.svg")));
	ColumnTypeAndIcons.push_back(QVariant(QString("../icons/variable-nominal.svg")));
	if(BothNominalVersions)
		ColumnTypeAndIcons.push_back(QVariant(QString("../icons/variable-nominal-text.svg")));

	return QVariant(ColumnTypeAndIcons);
}

void DataSetTableModel::setDataSet(DataSet* dataSet)
{
    beginResetModel();
	_dataSet = dataSet;
    endResetModel();
}

int DataSetTableModel::rowCount(const QModelIndex &parent) const
{
	if (_dataSet == NULL)
		return 0;

	return parent.isValid() ? 0 : _dataSet->rowCount();
}

int DataSetTableModel::columnCount(const QModelIndex &parent) const
{
	if (_dataSet == NULL)
		return 0;

	return parent.isValid() ? 0 : _dataSet->columnCount();
}

QVariant DataSetTableModel::data(const QModelIndex &index, int role) const
{
	if (_dataSet == NULL)
		return QVariant();

	int column = -1;

	if (role == Qt::DisplayRole)
		column = index.column();
	else if(role >= Qt::UserRole)
		column = role - Qt::UserRole;

	if(column > -1)
	{
		QString value = tq(_dataSet->column(column)[index.row()]);
		return QVariant(value);
	}

    return QVariant();
}

QVariant DataSetTableModel::columnTitle(int column) const
{
	if(column >= 0 && column < _dataSet->columnCount())
	{
		QString value = tq(_dataSet->column(column).name());
		return QVariant(value);
	}
	else
		return QVariant();
}

QVariant DataSetTableModel::columnIcon(int column) const
{
	if(column >= 0 && column < _dataSet->columnCount())
	{
		Column &columnref = _dataSet->column(column);
		return QVariant(columnref.columnType());
	}
	else
		return QVariant();
}

QVariant DataSetTableModel::headerData ( int section, Qt::Orientation orientation, int role) const
{
	if (_dataSet == NULL)
		return QVariant();

	if (role == Qt::DisplayRole)
	{
		if (orientation == Qt::Horizontal)
		{
			QString value = tq(_dataSet->column(section).name()) + QString("        ");
			return QVariant(value);
		}
		else
		{
			return QVariant(section + 1);
		}
	}
	else if (role == Qt::DecorationRole && orientation == Qt::Horizontal)
	{
		Column &column = _dataSet->column(section);

		switch (column.columnType())
		{
		case Column::ColumnTypeNominalText:
			return QVariant(_nominalTextIcon);
		case Column::ColumnTypeNominal:
			return QVariant(_nominalIcon);
		case Column::ColumnTypeOrdinal:
			return QVariant(_ordinalIcon);
		case Column::ColumnTypeScale:
			return QVariant(_scaleIcon);
		default:
			return QVariant();
		}
	}
	else if (role == Qt::SizeHintRole && orientation == Qt::Vertical)
	{
		return QVariant(/*QSize(80, -1)*/);
	}
	else if (role == Qt::TextAlignmentRole)
	{
		return QVariant(Qt::AlignCenter);
	}

	return QVariant();
}

QHash<int, QByteArray> DataSetTableModel::roleNames() const
{
	QHash<int, QByteArray> roles = QAbstractTableModel::roleNames ();

	for(int i=0; i<columnCount(); i++)
		roles[Qt::UserRole + i] = (QString("column_")+QString::number(i)).toUtf8();

	return roles;
}

QStringList DataSetTableModel::userRoleNames() const
{
	QMap<int, QString> res;
	QHashIterator<int, QByteArray> i(roleNames());
	while (i.hasNext()) {
		i.next();
		if(i.key() >= Qt::UserRole)
			res[i.key()] = i.value();
	}
	return res.values();
}

bool DataSetTableModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
	/*if (_dataSet == NULL)
		return false;

	bool ok;

	Column &column = _dataSet->columns()[index.column()];
	if (column.dataType() == Column::DataTypeInt)
	{
		int v = value.toInt(&ok);
		if (ok)
			column.setValue(index.row(), v);
		else
			emit badDataEntered(index);

		return ok;
	}*/

	//_dataSet->columns()[index.column()].setValue(index.row(), v);

	return true;
}

Qt::ItemFlags DataSetTableModel::flags(const QModelIndex &index) const
{
	return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
}

bool DataSetTableModel::setColumnType(int columnIndex, Column::ColumnType newColumnType)
{
	if (_dataSet == NULL)
		return true;

	bool changed = _dataSet->column(columnIndex).changeColumnType(newColumnType);
	emit headerDataChanged(Qt::Horizontal, columnIndex, columnIndex);

	return changed;
}

Column::ColumnType DataSetTableModel::getColumnType(int columnIndex)
{
	return _dataSet->column(columnIndex).columnType();
}

void DataSetTableModel::refreshColumn(Column * column)
{
	for(int col=0; col<_dataSet->columns().size(); col++)
		if(&(_dataSet->columns()[col]) == column)
			emit dataChanged(index(0, col), index(rowCount()-1, col));
}
<commit_msg>Remove some QML warnings<commit_after>//
// Copyright (C) 2013-2018 University of Amsterdam
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public
// License along with this program.  If not, see
// <http://www.gnu.org/licenses/>.
//

#include "datasettablemodel.h"

#include <iostream>
#include <fstream>

#include <QSize>
#include <QDebug>
#include <QQmlEngine>

#include "qutils.h"

using namespace std;

DataSetTableModel::DataSetTableModel(QObject *parent) :
    QAbstractTableModel(parent)
{
	_dataSet = NULL;

	_nominalTextIcon = QIcon(":/icons/variable-nominal-text.svg");
	_nominalIcon = QIcon(":/icons/variable-nominal.svg");
	_ordinalIcon = QIcon(":/icons/variable-ordinal.svg");
	_scaleIcon = QIcon(":/icons/variable-scale.svg");
}

QVariant DataSetTableModel::getColumnTypesWithCorrespondingIcon(bool BothNominalVersions)
{
	QVariantList ColumnTypeAndIcons;

	ColumnTypeAndIcons.push_back(QVariant(QString("../icons/variable-scale.svg")));
	ColumnTypeAndIcons.push_back(QVariant(QString("../icons/variable-ordinal.svg")));
	ColumnTypeAndIcons.push_back(QVariant(QString("../icons/variable-nominal.svg")));
	if(BothNominalVersions)
		ColumnTypeAndIcons.push_back(QVariant(QString("../icons/variable-nominal-text.svg")));

	return QVariant(ColumnTypeAndIcons);
}

void DataSetTableModel::setDataSet(DataSet* dataSet)
{
    beginResetModel();
	_dataSet = dataSet;
    endResetModel();
}

int DataSetTableModel::rowCount(const QModelIndex &parent) const
{
	if (_dataSet == NULL)
		return 0;

	return parent.isValid() ? 0 : _dataSet->rowCount();
}

int DataSetTableModel::columnCount(const QModelIndex &parent) const
{
	if (_dataSet == NULL)
		return 0;

	return parent.isValid() ? 0 : _dataSet->columnCount();
}

QVariant DataSetTableModel::data(const QModelIndex &index, int role) const
{
	if (_dataSet == NULL)
		return QVariant();

	int column = -1;

	if (role == Qt::DisplayRole)
		column = index.column();
	else if(role >= Qt::UserRole)
		column = role - Qt::UserRole;

	if(column > -1)
	{
		QString value = tq(_dataSet->column(column)[index.row()]);
		return QVariant(value);
	}

    return QVariant();
}

QVariant DataSetTableModel::columnTitle(int column) const
{
	if(column >= 0 && column < _dataSet->columnCount())
	{
		QString value = tq(_dataSet->column(column).name());
		return QVariant(value);
	}
	else
		return QVariant();
}

QVariant DataSetTableModel::columnIcon(int column) const
{
	if(column >= 0 && column < _dataSet->columnCount())
	{
		Column &columnref = _dataSet->column(column);
		return QVariant(columnref.columnType());
	}
	else
		return QVariant(-1);
}

QVariant DataSetTableModel::headerData ( int section, Qt::Orientation orientation, int role) const
{
	if (_dataSet == NULL)
		return QVariant();

	if (role == Qt::DisplayRole)
	{
		if (orientation == Qt::Horizontal)
		{
			QString value = tq(_dataSet->column(section).name()) + QString("        ");
			return QVariant(value);
		}
		else
		{
			return QVariant(section + 1);
		}
	}
	else if (role == Qt::DecorationRole && orientation == Qt::Horizontal)
	{
		Column &column = _dataSet->column(section);

		switch (column.columnType())
		{
		case Column::ColumnTypeNominalText:
			return QVariant(_nominalTextIcon);
		case Column::ColumnTypeNominal:
			return QVariant(_nominalIcon);
		case Column::ColumnTypeOrdinal:
			return QVariant(_ordinalIcon);
		case Column::ColumnTypeScale:
			return QVariant(_scaleIcon);
		default:
			return QVariant();
		}
	}
	else if (role == Qt::SizeHintRole && orientation == Qt::Vertical)
	{
		return QVariant(/*QSize(80, -1)*/);
	}
	else if (role == Qt::TextAlignmentRole)
	{
		return QVariant(Qt::AlignCenter);
	}

	return QVariant();
}

QHash<int, QByteArray> DataSetTableModel::roleNames() const
{
	QHash<int, QByteArray> roles = QAbstractTableModel::roleNames ();

	for(int i=0; i<columnCount(); i++)
		roles[Qt::UserRole + i] = (QString("column_")+QString::number(i)).toUtf8();

	return roles;
}

QStringList DataSetTableModel::userRoleNames() const
{
	QMap<int, QString> res;
	QHashIterator<int, QByteArray> i(roleNames());
	while (i.hasNext()) {
		i.next();
		if(i.key() >= Qt::UserRole)
			res[i.key()] = i.value();
	}
	return res.values();
}

bool DataSetTableModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
	/*if (_dataSet == NULL)
		return false;

	bool ok;

	Column &column = _dataSet->columns()[index.column()];
	if (column.dataType() == Column::DataTypeInt)
	{
		int v = value.toInt(&ok);
		if (ok)
			column.setValue(index.row(), v);
		else
			emit badDataEntered(index);

		return ok;
	}*/

	//_dataSet->columns()[index.column()].setValue(index.row(), v);

	return true;
}

Qt::ItemFlags DataSetTableModel::flags(const QModelIndex &index) const
{
	return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
}

bool DataSetTableModel::setColumnType(int columnIndex, Column::ColumnType newColumnType)
{
	if (_dataSet == NULL)
		return true;

	bool changed = _dataSet->column(columnIndex).changeColumnType(newColumnType);
	emit headerDataChanged(Qt::Horizontal, columnIndex, columnIndex);

	return changed;
}

Column::ColumnType DataSetTableModel::getColumnType(int columnIndex)
{
	return _dataSet->column(columnIndex).columnType();
}

void DataSetTableModel::refreshColumn(Column * column)
{
	for(int col=0; col<_dataSet->columns().size(); col++)
		if(&(_dataSet->columns()[col]) == column)
			emit dataChanged(index(0, col), index(rowCount()-1, col));
}
<|endoftext|>


<commit_before><commit_msg>Removed unused variables.<commit_after><|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: c_gate.hxx,v $
 *
 *  $Revision: 1.2 $
 *
 *  last change: $Author: hr $ $Date: 2007-11-02 14:49:00 $
 *
 *  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 ARY_CPP_C_GATE_HXX
#define ARY_CPP_C_GATE_HXX

// USED SERVICES
    // BASE CLASSES
    // OTHER
#include <ary/cpp/c_types4cpp.hxx>

namespace autodoc
{
    class Options;
}
namespace ary
{
    class Entity;

namespace cpp
{
    class CodeEntity;
    class CppEntity;
    class CePilot;
    class DefPilot;
    class TypePilot;
}
namespace loc
{
    class LocationPilot;
}
}

namespace ary
{
namespace cpp
{

/** Acess to all stored objcts in the repository, which are
    relevant to C++.
*/
class Gate
{
  public:
    // LIFECYCLE
    virtual             ~Gate() {}

    // OPERATIONS
    virtual void        Calculate_AllSecondaryInformation() = 0;
//                            const ::autodoc::Options &
//                                                i_options ) = 0;

    // INQUIRY
    virtual const String &
                        RepositoryTitle() const = 0;
    virtual const CodeEntity *
                        Search_RelatedCe(
                            Type_id             i_type ) const = 0;
    virtual const ::ary::cpp::CppEntity *
                        Search_Entity(
                            GlobalId            i_id ) const = 0;
    virtual uintt       Get_AlphabeticalList(
                            List_GlobalIds &    o_result,
                            const char *        i_begin,
                            const char *        i_end ) const = 0;
    virtual const CePilot &
                        Ces() const = 0;
    virtual const DefPilot &
                        Defs() const = 0;
    virtual const TypePilot &
                        Types() const = 0;
    virtual const loc::LocationPilot &
                        Locations() const = 0;

    // ACCESS
    virtual CePilot &   Ces() = 0;
    virtual DefPilot &  Defs() = 0;
    virtual TypePilot & Types() = 0;
    virtual loc::LocationPilot &
                        Locations() = 0;
};

}   // namespace cpp
}   // namespace ary
#endif
<commit_msg>INTEGRATION: CWS changefileheader (1.2.22); FILE MERGED 2008/03/28 16:01:04 rt 1.2.22.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: c_gate.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 ARY_CPP_C_GATE_HXX
#define ARY_CPP_C_GATE_HXX

// USED SERVICES
    // BASE CLASSES
    // OTHER
#include <ary/cpp/c_types4cpp.hxx>

namespace autodoc
{
    class Options;
}
namespace ary
{
    class Entity;

namespace cpp
{
    class CodeEntity;
    class CppEntity;
    class CePilot;
    class DefPilot;
    class TypePilot;
}
namespace loc
{
    class LocationPilot;
}
}

namespace ary
{
namespace cpp
{

/** Acess to all stored objcts in the repository, which are
    relevant to C++.
*/
class Gate
{
  public:
    // LIFECYCLE
    virtual             ~Gate() {}

    // OPERATIONS
    virtual void        Calculate_AllSecondaryInformation() = 0;
//                            const ::autodoc::Options &
//                                                i_options ) = 0;

    // INQUIRY
    virtual const String &
                        RepositoryTitle() const = 0;
    virtual const CodeEntity *
                        Search_RelatedCe(
                            Type_id             i_type ) const = 0;
    virtual const ::ary::cpp::CppEntity *
                        Search_Entity(
                            GlobalId            i_id ) const = 0;
    virtual uintt       Get_AlphabeticalList(
                            List_GlobalIds &    o_result,
                            const char *        i_begin,
                            const char *        i_end ) const = 0;
    virtual const CePilot &
                        Ces() const = 0;
    virtual const DefPilot &
                        Defs() const = 0;
    virtual const TypePilot &
                        Types() const = 0;
    virtual const loc::LocationPilot &
                        Locations() const = 0;

    // ACCESS
    virtual CePilot &   Ces() = 0;
    virtual DefPilot &  Defs() = 0;
    virtual TypePilot & Types() = 0;
    virtual loc::LocationPilot &
                        Locations() = 0;
};

}   // namespace cpp
}   // namespace ary
#endif
<|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: luxenum.hxx,v $
 * $Revision: 1.6 $
 *
 * 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 UDM_LUXENUM_HXX
#define UDM_LUXENUM_HXX

// USED SERVICES
    // BASE CLASSES
    // COMPONENTS
    // PARAMETERS
#include <map>
#include <algorithm>

namespace lux
{

typedef std::map< intt, String  > EnumValueMap;

template <class DIFF>
class Enum // : public Template_Base
{
  public:
    // TYPES
    typedef Enum< DIFF >    self;

    // LIFECYCLE
                        Enum(
                            DIFF                i_nValue,
                            const char *        i_sText )
                                                :   nValue(i_nValue) { Values_()[nValue] = i_sText;
                                                                       // Sequence_().insert(
                                                                       //       std::lower_bound( Sequence_().begin(), Sequence_().end(), i_nValue ),
                                                                       //       i_nValue );
                                                                     }
                        Enum(
                            DIFF                i_nValue )
                                                :   nValue(i_nValue) { ; }
                        Enum(
                            intt                i_nValue = 0 )
                                                :   nValue(i_nValue) { if ( NOT CheckIntt(i_nValue) ) { csv_assert(false); } }
                        Enum(
                            const self &        i_rEnum )
                                                :   nValue(i_rEnum.nValue) {;}

    self &              operator=(
                            DIFF                i_nValue )
                                                { nValue = i_nValue; return *this; }
    self &              operator=(
                            intt                i_nValue )
                                                { if ( CheckIntt(i_nValue) ) nValue = DIFF(i_nValue);
                                                  else csv_assert(false); return *this; }
    self &              operator=(
                            const self &        i_rEnum )
                                                { nValue = i_rEnum.nValue; return *this; }
                        operator DIFF() const   { return DIFF(nValue); }

    DIFF                operator()() const      { return nValue; }
    const String  &     Text() const            { return Values_()[nValue]; }

  private:
    static EnumValueMap &
                        Values_();
    bool                CheckIntt(
                            intt                i_nNumber )
                                                { return Values_().find(i_nNumber) != Values_().end(); }
    // DATA
    intt                nValue;
};

}   // namespace lux
#endif

<commit_msg>INTEGRATION: CWS hr50 (1.5.20); FILE MERGED 2008/03/10 15:47:41 hr 1.5.20.1: #i86574#: fix warning (gcc-4.2.3)<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: luxenum.hxx,v $
 * $Revision: 1.7 $
 *
 * 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 UDM_LUXENUM_HXX
#define UDM_LUXENUM_HXX

// USED SERVICES
    // BASE CLASSES
    // COMPONENTS
    // PARAMETERS
#include <map>
#include <algorithm>

namespace lux
{

typedef std::map< intt, String  > EnumValueMap;

template <class DIFF>
class Enum // : public Template_Base
{
  public:
    // TYPES
    typedef Enum< DIFF >    self;

    // LIFECYCLE
                        Enum(
                            DIFF                i_nValue,
                            const char *        i_sText )
                                                :   nValue(i_nValue) { Values_()[nValue] = i_sText;
                                                                       // Sequence_().insert(
                                                                       //       std::lower_bound( Sequence_().begin(), Sequence_().end(), i_nValue ),
                                                                       //       i_nValue );
                                                                     }
                        Enum(
                            DIFF                i_nValue )
                                                :   nValue(i_nValue) { ; }
                        Enum(
                            intt                i_nValue = 0 )
                                                :   nValue(i_nValue) { if ( NOT CheckIntt(i_nValue) ) { csv_assert(false); } }
                        Enum(
                            const self &        i_rEnum )
                                                :   nValue(i_rEnum.nValue) {;}

    self &              operator=(
                            DIFF                i_nValue )
                                                { nValue = i_nValue; return *this; }
    self &              operator=(
                            intt                i_nValue )
                                                { if ( CheckIntt(i_nValue) ) {nValue = DIFF(i_nValue);}
                                                  else {csv_assert(false);} return *this; }
    self &              operator=(
                            const self &        i_rEnum )
                                                { nValue = i_rEnum.nValue; return *this; }
                        operator DIFF() const   { return DIFF(nValue); }

    DIFF                operator()() const      { return nValue; }
    const String  &     Text() const            { return Values_()[nValue]; }

  private:
    static EnumValueMap &
                        Values_();
    bool                CheckIntt(
                            intt                i_nNumber )
                                                { return Values_().find(i_nNumber) != Values_().end(); }
    // DATA
    intt                nValue;
};

}   // namespace lux
#endif

<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: player.hxx,v $
 *
 *  $Revision: 1.4 $
 *
 *  last change: $Author: rt $ $Date: 2005-09-07 19:48:23 $
 *
 *  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 _PLAYER_HXX
#define _PLAYER_HXX

#include "xinecommon.hxx"

#ifndef _COM_SUN_STAR_MEDIA_XPLAYER_HDL_
#include "com/sun/star/media/XPlayer.hdl"
#endif

namespace avmedia { namespace xine {

// ----------
// - Player -
// ----------

class Player : public ::cppu::WeakImplHelper2< ::com::sun::star::media::XPlayer,
                                               ::com::sun::star::lang::XServiceInfo >
{
public:

                        Player();
                        ~Player();

    bool                create( const ::rtl::OUString& rURL );

    // XPlayer
    virtual void SAL_CALL start(  ) throw (::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL stop(  ) throw (::com::sun::star::uno::RuntimeException);
    virtual sal_Bool SAL_CALL isPlaying(  ) throw (::com::sun::star::uno::RuntimeException);
    virtual double SAL_CALL getDuration(  ) throw (::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL setMediaTime( double fTime ) throw (::com::sun::star::uno::RuntimeException);
    virtual double SAL_CALL getMediaTime(  ) throw (::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL setStopTime( double fTime ) throw (::com::sun::star::uno::RuntimeException);
    virtual double SAL_CALL getStopTime(  ) throw (::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL setRate( double fRate ) throw (::com::sun::star::uno::RuntimeException);
    virtual double SAL_CALL getRate(  ) throw (::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL setPlaybackLoop( sal_Bool bSet ) throw (::com::sun::star::uno::RuntimeException);
    virtual sal_Bool SAL_CALL isPlaybackLoop(  ) throw (::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL setMute( sal_Bool bSet ) throw (::com::sun::star::uno::RuntimeException);
    virtual sal_Bool SAL_CALL isMute(  ) throw (::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL setVolumeDB( sal_Int16 nVolumeDB ) throw (::com::sun::star::uno::RuntimeException);
    virtual sal_Int16 SAL_CALL getVolumeDB(  ) throw (::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::awt::Size SAL_CALL getPreferredPlayerWindowSize(  ) throw (::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayerWindow > SAL_CALL createPlayerWindow( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Reference< ::com::sun::star::media::XFrameGrabber > SAL_CALL createFrameGrabber(  ) throw (::com::sun::star::uno::RuntimeException);
    // XServiceInfo
    virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException);
    virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw (::com::sun::star::uno::RuntimeException);

private:
};

} // namespace xine
} // namespace avmedia

#endif // _PLAYER_HXX
<commit_msg>INTEGRATION: CWS changefileheader (1.4.138); FILE MERGED 2008/03/28 16:04:00 rt 1.4.138.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: player.hxx,v $
 * $Revision: 1.5 $
 *
 * 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 _PLAYER_HXX
#define _PLAYER_HXX

#include "xinecommon.hxx"

#ifndef _COM_SUN_STAR_MEDIA_XPLAYER_HDL_
#include "com/sun/star/media/XPlayer.hdl"
#endif

namespace avmedia { namespace xine {

// ----------
// - Player -
// ----------

class Player : public ::cppu::WeakImplHelper2< ::com::sun::star::media::XPlayer,
                                               ::com::sun::star::lang::XServiceInfo >
{
public:

                        Player();
                        ~Player();

    bool                create( const ::rtl::OUString& rURL );

    // XPlayer
    virtual void SAL_CALL start(  ) throw (::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL stop(  ) throw (::com::sun::star::uno::RuntimeException);
    virtual sal_Bool SAL_CALL isPlaying(  ) throw (::com::sun::star::uno::RuntimeException);
    virtual double SAL_CALL getDuration(  ) throw (::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL setMediaTime( double fTime ) throw (::com::sun::star::uno::RuntimeException);
    virtual double SAL_CALL getMediaTime(  ) throw (::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL setStopTime( double fTime ) throw (::com::sun::star::uno::RuntimeException);
    virtual double SAL_CALL getStopTime(  ) throw (::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL setRate( double fRate ) throw (::com::sun::star::uno::RuntimeException);
    virtual double SAL_CALL getRate(  ) throw (::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL setPlaybackLoop( sal_Bool bSet ) throw (::com::sun::star::uno::RuntimeException);
    virtual sal_Bool SAL_CALL isPlaybackLoop(  ) throw (::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL setMute( sal_Bool bSet ) throw (::com::sun::star::uno::RuntimeException);
    virtual sal_Bool SAL_CALL isMute(  ) throw (::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL setVolumeDB( sal_Int16 nVolumeDB ) throw (::com::sun::star::uno::RuntimeException);
    virtual sal_Int16 SAL_CALL getVolumeDB(  ) throw (::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::awt::Size SAL_CALL getPreferredPlayerWindowSize(  ) throw (::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayerWindow > SAL_CALL createPlayerWindow( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Reference< ::com::sun::star::media::XFrameGrabber > SAL_CALL createFrameGrabber(  ) throw (::com::sun::star::uno::RuntimeException);
    // XServiceInfo
    virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException);
    virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw (::com::sun::star::uno::RuntimeException);

private:
};

} // namespace xine
} // namespace avmedia

#endif // _PLAYER_HXX
<|endoftext|>


<commit_before>/******************************************************************************
The MIT License(MIT)

Embedded Template Library.
https://github.com/ETLCPP/etl
http://www.etlcpp.com

Copyright(c) 2014 jwellbelove

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/

#include <UnitTest++/UnitTest++.h>
#if defined(PLATFORM_WINDOWS)
#include <Windows.h>
#endif
#include <sstream>
#include <string>

#include "../error_handler.h"
#include "../exception.h"

bool error_received;

//*****************************************************************************
// An exception.
//*****************************************************************************
class test_exception : public etl::exception
{
public:

  test_exception(string_type file_name, numeric_type line_number)
    : exception(ETL_ERROR_TEXT("test_exception", "123"), file_name, line_number)
  {
    error_received = false;
  }
};

//*****************************************************************************
// A free error handler function.
//*****************************************************************************
void receive_error(const etl::exception& e)
{
  error_received = true;
  std::ostringstream oss;
  oss << "Error '" << e.what() << "' in " << e.file_name() << " at line " << e.line_number() << "\n";

#if defined(PLATFORM_WINDOWS)
  std::string stext = oss.str();

  WCHAR text[200];
  MultiByteToWideChar(0, 0, stext.c_str(), stext.size() + 1, text, 200);
  LPCWSTR ltext = text;

  OutputDebugString(ltext);
#endif
}

//*****************************************************************************
class test_class
{
public:

  //***************************************************************************
  // A member error handler function.
  //***************************************************************************
  void receive_error(const etl::exception& e)
  {
    error_received = true;
    std::ostringstream oss;
    oss << "Error '" << e.what() << "' in " << e.file_name() << " at line " << e.line_number() << "\n";

#if defined(PLATFORM_WINDOWS)
    std::string stext = oss.str();

    WCHAR text[200];
    MultiByteToWideChar(0, 0, stext.c_str(), stext.size() + 1, text, 200);
    LPCWSTR ltext = text;

    OutputDebugString(ltext);
#endif
  }
};

namespace
{
  SUITE(test_error_handler)
  {
    //*************************************************************************
    TEST(test_free_handler_function)
    {
      // Create the function callback object.
      etl::error_handler::free_function error_callback(receive_error);

      // Tell the error handler about it.
      etl::error_handler::set_callback(error_callback);

      // Log an error.
      etl::error_handler::error(ETL_ERROR(test_exception));

      CHECK(error_received);
    }

    //*************************************************************************
    TEST(test_member_handler_function)
    {
      // Create the class that contains the handler.
      test_class test;

      // Create the function callback object.
      etl::error_handler::member_function<test_class> error_callback(test, &test_class::receive_error);

      // Tell the error handler about it.
      etl::error_handler::set_callback(error_callback);

      // Log an error.
      etl::error_handler::error(ETL_ERROR(test_exception));

      CHECK(error_received);
    }
  };
}
<commit_msg>Cross compiler compatibilty<commit_after>/******************************************************************************
The MIT License(MIT)

Embedded Template Library.
https://github.com/ETLCPP/etl
http://www.etlcpp.com

Copyright(c) 2014 jwellbelove

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/

#include <UnitTest++/UnitTest++.h>
#if defined(PLATFORM_WINDOWS)
#include <Windows.h>
#endif
#include <sstream>
#include <string>

#include "../error_handler.h"
#include "../exception.h"

bool error_received;

//*****************************************************************************
// An exception.
//*****************************************************************************
class test_exception : public etl::exception
{
public:

  test_exception(string_type file_name, numeric_type line_number)
    : exception(ETL_ERROR_TEXT("test_exception", "123"), file_name, line_number)
  {
    error_received = false;
  }
};

//*****************************************************************************
// A free error handler function.
//*****************************************************************************
void receive_error(const etl::exception& e)
{
  error_received = true;
  std::ostringstream oss;
  oss << "Error '" << e.what() << "' in " << e.file_name() << " at line " << e.line_number() << "\n";

#if defined(PLATFORM_WINDOWS) && defined(COMPILER_MICROSOFT)
  std::string stext = oss.str();

  WCHAR text[200];
  MultiByteToWideChar(0, 0, stext.c_str(), stext.size() + 1, text, 200);
  LPCWSTR ltext = text;

  OutputDebugString(ltext);
#endif
}

//*****************************************************************************
class test_class
{
public:

  //***************************************************************************
  // A member error handler function.
  //***************************************************************************
  void receive_error(const etl::exception& e)
  {
    error_received = true;
    std::ostringstream oss;
    oss << "Error '" << e.what() << "' in " << e.file_name() << " at line " << e.line_number() << "\n";

#if defined(PLATFORM_WINDOWS) && defined(COMPILER_MICROSOFT)
    std::string stext = oss.str();

    WCHAR text[200];
    MultiByteToWideChar(0, 0, stext.c_str(), stext.size() + 1, text, 200);
    LPCWSTR ltext = text;

    OutputDebugString(ltext);
#endif
  }
};

namespace
{
  SUITE(test_error_handler)
  {
    //*************************************************************************
    TEST(test_free_handler_function)
    {
      // Create the function callback object.
      etl::error_handler::free_function error_callback(receive_error);

      // Tell the error handler about it.
      etl::error_handler::set_callback(error_callback);

      // Log an error.
      etl::error_handler::error(ETL_ERROR(test_exception));

      CHECK(error_received);
    }

    //*************************************************************************
    TEST(test_member_handler_function)
    {
      // Create the class that contains the handler.
      test_class test;

      // Create the function callback object.
      etl::error_handler::member_function<test_class> error_callback(test, &test_class::receive_error);

      // Tell the error handler about it.
      etl::error_handler::set_callback(error_callback);

      // Log an error.
      etl::error_handler::error(ETL_ERROR(test_exception));

      CHECK(error_received);
    }
  };
}
<|endoftext|>


<commit_before>// Copyright Chsritian Neumüller 2013. Use, modification and distribution is
// subject to the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include "test.hpp"

#include <luabind/intrusive_ptr_converter.hpp>
#include <luabind/luabind.hpp>

#include <boost/noncopyable.hpp>

using boost::intrusive_ptr;

namespace {

    struct B: private boost::noncopyable, counted_type<B>
    {
        B(int val_): ref_cnt(0), val(val_) {}
        virtual ~B() {
            std::cout << "~B\n";
            TEST_CHECK(ref_cnt == 0);
        }

        int ref_cnt;
        int val;
    };

    COUNTER_GUARD(B);

    struct D: B
    {
        D(int val_): B(val_) {}
    };

    void intrusive_ptr_add_ref(B* b)
    {
        ++b->ref_cnt;
    }

    void intrusive_ptr_release(B* b)
    {
        if (!--b->ref_cnt)
            delete b;
    }

    void needs_b(intrusive_ptr<B> pb, int expected_rc)
    {
        TEST_CHECK(pb->ref_cnt == expected_rc);
    }

    void needs_d(intrusive_ptr<D> pd)
    {
        TEST_CHECK(pd->ref_cnt == 2);
    }

    intrusive_ptr<B> filter_b(intrusive_ptr<B> pb)
    {
        TEST_CHECK(pb->ref_cnt == 2);
        return pb;
    }

} // namespace unnamed

void test_main(lua_State* L)
{
    using namespace luabind;

    module(L) [
        class_<B, intrusive_ptr<B> >("B")
            .def(constructor<int>())
            .def_readonly("val", &B::val)
            .def_readonly("ref_cnt", &B::ref_cnt),
        class_<D, B, intrusive_ptr<D> >("D")
            .def(constructor<int>()),
        def("needs_b", &needs_b),
        def("needs_d", &needs_d),
        def("filter_b", &filter_b)
    ];

    DOSTRING(L,
        "d = D(1)\n"
        "print(d.val, d.ref_cnt)\n"
        "assert(d.val == 1)\n"
        "assert(d.ref_cnt == 1)\n"
    );

    DOSTRING(L,
        "needs_d(d)\n"
        "needs_b(d, 2)\n"
    );

    DOSTRING(L,
        "bd = filter_b(d)\n"
        "assert(bd.val == 1)\n"
        "assert(bd.ref_cnt == 2)\n"
        "needs_b(bd, 3)\n"
        "assert(bd.ref_cnt == 2)\n"
    );

    DOSTRING(L,
         "d = nil\n"
         "collectgarbage()\n"
         "collectgarbage()\n"
         "assert(bd.ref_cnt == 1)\n"
    );
}
<commit_msg>Fix missing include in test_intrusive_ptr.cpp.<commit_after>// Copyright Chsritian Neumüller 2013. Use, modification and distribution is
// subject to the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include "test.hpp"

#include <luabind/intrusive_ptr_converter.hpp>
#include <luabind/luabind.hpp>

#include <boost/noncopyable.hpp>
#include <iostream>

using boost::intrusive_ptr;

namespace {

    struct B: private boost::noncopyable, counted_type<B>
    {
        B(int val_): ref_cnt(0), val(val_) {}
        virtual ~B() {
            std::cout << "~B\n";
            TEST_CHECK(ref_cnt == 0);
        }

        int ref_cnt;
        int val;
    };

    COUNTER_GUARD(B);

    struct D: B
    {
        D(int val_): B(val_) {}
    };

    void intrusive_ptr_add_ref(B* b)
    {
        ++b->ref_cnt;
    }

    void intrusive_ptr_release(B* b)
    {
        if (!--b->ref_cnt)
            delete b;
    }

    void needs_b(intrusive_ptr<B> pb, int expected_rc)
    {
        TEST_CHECK(pb->ref_cnt == expected_rc);
    }

    void needs_d(intrusive_ptr<D> pd)
    {
        TEST_CHECK(pd->ref_cnt == 2);
    }

    intrusive_ptr<B> filter_b(intrusive_ptr<B> pb)
    {
        TEST_CHECK(pb->ref_cnt == 2);
        return pb;
    }

} // namespace unnamed

void test_main(lua_State* L)
{
    using namespace luabind;

    module(L) [
        class_<B, intrusive_ptr<B> >("B")
            .def(constructor<int>())
            .def_readonly("val", &B::val)
            .def_readonly("ref_cnt", &B::ref_cnt),
        class_<D, B, intrusive_ptr<D> >("D")
            .def(constructor<int>()),
        def("needs_b", &needs_b),
        def("needs_d", &needs_d),
        def("filter_b", &filter_b)
    ];

    DOSTRING(L,
        "d = D(1)\n"
        "print(d.val, d.ref_cnt)\n"
        "assert(d.val == 1)\n"
        "assert(d.ref_cnt == 1)\n"
    );

    DOSTRING(L,
        "needs_d(d)\n"
        "needs_b(d, 2)\n"
    );

    DOSTRING(L,
        "bd = filter_b(d)\n"
        "assert(bd.val == 1)\n"
        "assert(bd.ref_cnt == 2)\n"
        "needs_b(bd, 3)\n"
        "assert(bd.ref_cnt == 2)\n"
    );

    DOSTRING(L,
         "d = nil\n"
         "collectgarbage()\n"
         "collectgarbage()\n"
         "assert(bd.ref_cnt == 1)\n"
    );
}
<|endoftext|>


<commit_before>#ifndef _CHART2_BARCHART_HXX
#define _CHART2_BARCHART_HXX

#include "VSeriesPlotter.hxx"
#include "DatapointGeometry.hxx"

//.............................................................................
namespace chart
{
//.............................................................................
class BarPositionHelper;

enum Geometry3D { GEOMETRY_UNKNOWN
                , GEOMETRY_CUBOID
                , GEOMETRY_CYLINDER
                , GEOMETRY_CONE
                , GEOMETRY_PYRAMID };

class BarChart : public VSeriesPlotter
{
    //-------------------------------------------------------------------------
    // public methods
    //-------------------------------------------------------------------------
public:
    BarChart( const ::com::sun::star::uno::Reference<
            ::com::sun::star::chart2::XChartType >& xChartTypeModel );
    virtual ~BarChart();

    //-------------------------------------------------------------------------
    // chart2::XPlotter
    //-------------------------------------------------------------------------

    virtual void SAL_CALL createShapes();
    /*
    virtual ::rtl::OUString SAL_CALL getCoordinateSystemTypeID(  ) throw (::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL setScales( const ::com::sun::star::uno::Sequence< ::com::sun::star::chart2::ExplicitScaleData >& rScales ) throw (::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL setTransformation( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToLogicTarget, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToFinalPage ) throw (::com::sun::star::uno::RuntimeException);
    */

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

private: //methods
    //no default constructor
    BarChart();

    ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
        createDataPoint3D_Bar(
                          const ::com::sun::star::uno::Reference<
                                ::com::sun::star::drawing::XShapes >& xTarget
                        , const DataPointGeometry& rGeometry
                        , const ::com::sun::star::uno::Reference<
                                ::com::sun::star::beans::XPropertySet >& xObjectProperties
                        , Geometry3D eGeometry );
    ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
        createDataPoint2D_Bar(
                          const ::com::sun::star::uno::Reference<
                                ::com::sun::star::drawing::XShapes >& xTarget
                        , const DataPointGeometry& rGeometry
                        , const ::com::sun::star::uno::Reference<
                                ::com::sun::star::beans::XPropertySet >& xObjectProperties );

    ::com::sun::star::awt::Point getLabelScreenPositionAndAlignment(
                        LabelAlignment& rAlignment, bool bMiddlePosition
                        , const DataPointGeometry& rTransformedGeom ) const;

private: //member
    BarPositionHelper*                   m_pPosHelper;
};
//.............................................................................
} //namespace chart
//.............................................................................
#endif
<commit_msg>INTEGRATION: CWS chart2mst3 (1.5.4); FILE MERGED 2006/07/01 21:00:52 iha 1.5.4.17: define and respect aspect ratio of diagram 2006/03/09 17:41:16 iha 1.5.4.16: added header 2005/11/22 14:10:54 iha 1.5.4.15: support BarOverlap and GapWidth 2005/10/24 11:07:03 iha 1.5.4.14: coordinate system restructure 2005/08/18 11:42:03 iha 1.5.4.13: moved colorscheme transport 2005/07/28 09:34:54 bm 1.5.4.12: usage of color schemes and the VaryColorsByPoint property to have correct pie colors and legend entries 2005/04/28 15:49:13 dr 1.5.4.11: #i30426# enhanced linear scaling 2004/09/17 11:24:20 iha 1.5.4.10: implement api redesign - dimension property 2004/04/29 09:28:04 iha 1.5.4.9: correct 3d bar object position and size 2004/04/28 20:16:51 iha 1.5.4.8: removed /cvs/graphics/chart2/source/inc/RegressionCurveHelper.hxx,v: needs patch 2004/03/24 17:26:36 iha 1.5.4.7: changed method getLabelScreenPositionAndAlignment 2004/03/23 14:55:03 iha 1.5.4.6: removed method createDataPoint2D_Bar 2004/03/11 12:27:28 iha 1.5.4.5: added meethod getPreferredDiagramAspectRatio() for charttype dependent 3D scene aspect ratio 2004/03/09 09:03:11 iha 1.5.4.4: crash with negative pyramid; do not change base width of cuboids and cylinders with height 2004/03/08 19:00:51 iha 1.5.4.3: read DataPointGeometry from model 2004/02/28 08:47:14 iha 1.5.4.2: special autoscaling for Y (because of grounding line) 2004/02/23 18:55:02 iha 1.5.4.1: auto scaling: make automatic border charttype dependent<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: BarChart.hxx,v $
 *
 *  $Revision: 1.6 $
 *
 *  last change: $Author: vg $ $Date: 2007-05-22 19:14:54 $
 *
 *  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 _CHART2_BARCHART_HXX
#define _CHART2_BARCHART_HXX

#include "VSeriesPlotter.hxx"

//.............................................................................
namespace chart
{
//.............................................................................
class BarPositionHelper;

class BarChart : public VSeriesPlotter
{
    //-------------------------------------------------------------------------
    // public methods
    //-------------------------------------------------------------------------
public:
    BarChart( const ::com::sun::star::uno::Reference<
            ::com::sun::star::chart2::XChartType >& xChartTypeModel
            , sal_Int32 nDimensionCount );
    virtual ~BarChart();

    //-------------------------------------------------------------------------
    // chart2::XPlotter
    //-------------------------------------------------------------------------

    virtual void SAL_CALL createShapes();
    /*
    virtual ::rtl::OUString SAL_CALL getCoordinateSystemTypeID(  ) throw (::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL setScales( const ::com::sun::star::uno::Sequence< ::com::sun::star::chart2::ExplicitScaleData >& rScales ) throw (::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL setTransformation( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToLogicTarget, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToFinalPage ) throw (::com::sun::star::uno::RuntimeException);
    */

    virtual void addSeries( VDataSeries* pSeries, sal_Int32 zSlot = -1, sal_Int32 xSlot = -1,sal_Int32 ySlot = -1 );

    //-------------------
    virtual ::com::sun::star::drawing::Direction3D  getPreferredDiagramAspectRatio() const;
    virtual bool keepAspectRatio() const;

    //-------------------------------------------------------------------------
    // MinimumAndMaximumSupplier
    //-------------------------------------------------------------------------
    virtual double getMinimumX();
    virtual double getMaximumX();

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

private: //methods
    //no default constructor
    BarChart();

    ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
        createDataPoint3D_Bar(
                          const ::com::sun::star::uno::Reference<
                                ::com::sun::star::drawing::XShapes >& xTarget
                        , const ::com::sun::star::drawing::Position3D& rPosition
                        , const ::com::sun::star::drawing::Direction3D& rSize
                        , double fTopHeight, sal_Int32 nRotateZAngleHundredthDegree
                        , const ::com::sun::star::uno::Reference<
                                ::com::sun::star::beans::XPropertySet >& xObjectProperties
                        , sal_Int32 nGeometry3D );

    ::com::sun::star::awt::Point getLabelScreenPositionAndAlignment(
                        LabelAlignment& rAlignment, bool bMiddlePosition
                        , double fScaledX, double fScaledLowerYValue, double fScaledUpperYValue, double fScaledZ
                        , double fScaledLowerBarDepth, double fScaledUpperBarDepth
                        , BarPositionHelper* pPosHelper ) const;

    virtual PlottingPositionHelper& getPlottingPositionHelper( sal_Int32 nAxisIndex ) const;//nAxisIndex indicates wether the position belongs to the main axis ( nAxisIndex==0 ) or secondary axis ( nAxisIndex==1 )

private: //member
    BarPositionHelper*                   m_pMainPosHelper;
    ::com::sun::star::uno::Sequence< sal_Int32 > m_aOverlapSequence;
    ::com::sun::star::uno::Sequence< sal_Int32 > m_aGapwidthSequence;
};
//.............................................................................
} //namespace chart
//.............................................................................
#endif
<|endoftext|>