19#include "kspread_propertyEditor.h"
21#include "kspread_object.h"
22#include "kspread_sheet.h"
23#include "kspread_doc.h"
36#include <kstdguiitem.h>
40PropertyEditor::PropertyEditor( TQWidget *parent,
const char *name, Sheet *page,
Doc *doc )
41 : TQTabDialog( parent, name, true )
44 , m_objects( page->getSelectedObjects() )
52 , m_generalProperty( 0 )
55 setCancelButton( KStdGuiItem::cancel().text() );
56 setOkButton( KStdGuiItem::ok().text() );
57 setApplyButton( KStdGuiItem::apply().text() );
59 connect(
this, TQ_SIGNAL( applyButtonPressed() ),
this, TQ_SLOT( slotDone() ) );
67PropertyEditor::~PropertyEditor()
73KCommand * PropertyEditor::getCommand()
75 KMacroCommand *macro = 0;
221 if ( m_generalProperty )
223 int change = m_generalProperty->getGeneralPropertyChange();
227 GeneralProperty::GeneralValue generalValue( m_generalProperty->getGeneralValue() );
229 if ( change & GeneralProperty::Name )
231 KCommand *cmd =
new RenameNameObjectCommand( i18n(
"Name Object" ), generalValue.m_name,
232 m_objects.at( 0 ), m_doc );
236 macro =
new KMacroCommand( i18n(
"Apply Properties" ) );
239 macro->addCommand( cmd );
242 if ( change & GeneralProperty::Protect )
244 KCommand *cmd=
new GeometryPropertiesCommand( i18n(
"Protect Object" ), m_objects,
245 generalValue.m_protect == STATE_ON,
246 GeometryPropertiesCommand::ProtectSize,m_doc );
250 macro =
new KMacroCommand( i18n(
"Apply Properties" ) );
253 macro->addCommand( cmd );
256 if ( change & GeneralProperty::KeepRatio )
258 KCommand *cmd=
new GeometryPropertiesCommand( i18n(
"Keep Ratio" ), m_objects,
259 generalValue.m_keepRatio == STATE_ON,
260 GeometryPropertiesCommand::KeepRatio,m_doc );
263 macro =
new KMacroCommand( i18n(
"Apply Properties" ) );
266 macro->addCommand( cmd );
269 if ( change & GeneralProperty::Left
270 || change & GeneralProperty::Top
271 || change & GeneralProperty::Width
272 || change & GeneralProperty::Height )
276 macro =
new KMacroCommand( i18n(
"Apply Properties" ) );
279 TQPtrListIterator<EmbeddedObject> it( m_objects );
280 for ( ; it.current(); ++it )
282 KoRect oldRect = it.current()->geometry();
283 KoRect newRect = oldRect;
285 if ( change & GeneralProperty::Left )
286 newRect.moveTopLeft( KoPoint( generalValue.m_rect.left(), newRect.top() ) );
288 if ( change & GeneralProperty::Top )
289 newRect.moveTopLeft( KoPoint( newRect.left(), generalValue.m_rect.top() ) );
291 if ( change & GeneralProperty::Width )
292 newRect.setWidth( generalValue.m_rect.width() );
294 if ( change & GeneralProperty::Height )
295 newRect.setHeight( generalValue.m_rect.height() );
297 KCommand *cmd =
new ChangeObjectGeometryCommand( it.current(), newRect.topLeft() - oldRect.topLeft(),
298 newRect.size() - oldRect.size() );
300 macro->addCommand( cmd );
310void PropertyEditor::setupTabs()
416void PropertyEditor::setupTabGeneral()
418 if ( m_generalProperty == 0 )
420 GeneralProperty::GeneralValue generalValue = getGeneralValue();
421 m_generalProperty =
new GeneralProperty(
this, 0, generalValue, m_doc->unit() );
422 addTab( m_generalProperty, i18n(
"&General" ) );
427GeneralProperty::GeneralValue PropertyEditor::getGeneralValue()
429 GeneralProperty::GeneralValue generalValue;
431 if ( m_objects.count() == 1 )
433 generalValue.m_name = m_objects.at( 0 )->getObjectName();
436 bool protect =
false;
437 generalValue.m_protect = STATE_OFF;
438 bool keepRatio =
false;
439 generalValue.m_keepRatio = STATE_OFF;
441 TQPtrListIterator<EmbeddedObject> it( m_objects );
444 protect = it.current()->isProtect();
445 generalValue.m_protect = protect ? STATE_ON : STATE_OFF;
446 keepRatio = it.current()->isKeepRatio();
447 generalValue.m_keepRatio = keepRatio ? STATE_ON : STATE_OFF;
448 generalValue.m_rect = it.current()->geometry();
452 for ( ; it.current(); ++it )
454 if ( protect != it.current()->isProtect() )
456 generalValue.m_protect = STATE_UNDEF;
457 if ( generalValue.m_keepRatio == STATE_UNDEF )
463 if ( keepRatio != it.current()->isKeepRatio() )
465 generalValue.m_keepRatio = STATE_UNDEF;
466 if ( generalValue.m_protect == STATE_UNDEF )
477void PropertyEditor::slotDone()
495 if ( m_generalProperty )
496 m_generalProperty->apply();
499#include "kspread_propertyEditor.moc"
This class holds the data that makes up a spreadsheet.