added dialog model changed flag

This commit is contained in:
Thomas Benisch
2001-03-06 13:50:13 +00:00
parent d3294bc233
commit b631263524
3 changed files with 100 additions and 56 deletions

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: dlged.cxx,v $ * $RCSfile: dlged.cxx,v $
* *
* $Revision: 1.4 $ * $Revision: 1.5 $
* *
* last change: $Author: ab $ $Date: 2001-03-03 14:54:51 $ * last change: $Author: tbe $ $Date: 2001-03-06 14:44:59 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -225,7 +225,8 @@ VCDlgEditor::VCDlgEditor( StarBASIC* pBas ) :
bGridVisible(FALSE), bGridVisible(FALSE),
bClipPrivate(FALSE), bClipPrivate(FALSE),
bCreateOK(TRUE), bCreateOK(TRUE),
pSdrView(NULL) pSdrView(NULL),
bDialogModelChanged(FALSE)
{ {
pWindow = NULL; pWindow = NULL;
@@ -595,47 +596,58 @@ IMPL_LINK( VCDlgEditor, PaintTimeout, Timer *, EMPTYARG )
{ {
bFirstDraw = FALSE; bFirstDraw = FALSE;
if( pDlgEdForm->GetSnapRect().GetSize() == aMacSize ) // get property set
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xPSet(pDlgEdForm->GetUnoControlModel(), ::com::sun::star::uno::UNO_QUERY);
if ( xPSet.is() )
{ {
Size aSize = pWindow->PixelToLogic( Size( 400, 300 ) ); // get dialog size from properties
sal_Int32 nWidth, nHeight;
xPSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Width" ) ) ) >>= nWidth;
xPSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Height" ) ) ) >>= nHeight;
// align with grid if ( nWidth == 0 && nHeight == 0 )
Size aGridSize = pSdrView->GetSnapGrid();
aSize.Width() -= aSize.Width() % aGridSize.Width();
aSize.Height() -= aSize.Height() % aGridSize.Height();
Point aPos;
Size aOutSize = pWindow->GetOutputSize();
aPos.X() = (aOutSize.Width()>>1) - (aSize.Width()>>1);
aPos.Y() = (aOutSize.Height()>>1) - (aSize.Height()>>1);
// align with grid
aPos.X() -= aPos.X() % aGridSize.Width();
aPos.Y() -= aPos.Y() % aGridSize.Height();
// don't put in the corner
Point aMinPos = pWindow->PixelToLogic( Point( 30, 20 ) );
if( (aPos.X() < aMinPos.X()) || (aPos.Y() < aMinPos.Y()) )
{ {
aPos = aMinPos; Size aSize = pWindow->PixelToLogic( Size( 400, 300 ) );
// align with grid
Size aGridSize = pSdrView->GetSnapGrid();
aSize.Width() -= aSize.Width() % aGridSize.Width();
aSize.Height() -= aSize.Height() % aGridSize.Height();
Point aPos;
Size aOutSize = pWindow->GetOutputSize();
aPos.X() = (aOutSize.Width()>>1) - (aSize.Width()>>1);
aPos.Y() = (aOutSize.Height()>>1) - (aSize.Height()>>1);
// align with grid
aPos.X() -= aPos.X() % aGridSize.Width(); aPos.X() -= aPos.X() % aGridSize.Width();
aPos.Y() -= aPos.Y() % aGridSize.Height(); aPos.Y() -= aPos.Y() % aGridSize.Height();
}
// set dialog position and size // don't put in the corner
pDlgEdForm->SetSnapRect( Rectangle( aPos, aSize ) ); Point aMinPos = pWindow->PixelToLogic( Point( 30, 20 ) );
pDlgEdForm->SetPropsFromRect(); if( (aPos.X() < aMinPos.X()) || (aPos.Y() < aMinPos.Y()) )
// set position and size of controls
ULONG nObjCount;
if ( pSdrPage && ( ( nObjCount = pSdrPage->GetObjCount() ) > 0 ) )
{
for ( ULONG i = 1 ; i < nObjCount ; i++ )
{ {
SdrObject* pObj = pSdrPage->GetObj(i); aPos = aMinPos;
DlgEdObj* pDlgEdObj = PTR_CAST(DlgEdObj, pObj); aPos.X() -= aPos.X() % aGridSize.Width();
if (pDlgEdObj) aPos.Y() -= aPos.Y() % aGridSize.Height();
pDlgEdObj->SetRectFromProps(); }
// set dialog position and size
pDlgEdForm->SetSnapRect( Rectangle( aPos, aSize ) );
pDlgEdForm->SetPropsFromRect();
// set position and size of controls
ULONG nObjCount;
if ( pSdrPage && ( ( nObjCount = pSdrPage->GetObjCount() ) > 0 ) )
{
for ( ULONG i = 1 ; i < nObjCount ; i++ )
{
SdrObject* pObj = pSdrPage->GetObj(i);
DlgEdObj* pDlgEdObj = PTR_CAST(DlgEdObj, pObj);
if (pDlgEdObj)
pDlgEdObj->SetRectFromProps();
}
} }
} }
} }
@@ -814,7 +826,7 @@ void VCDlgEditor::Delete()
BOOL VCDlgEditor::IsModified() const BOOL VCDlgEditor::IsModified() const
{ {
return pSdrModel->IsChanged(); return pSdrModel->IsChanged() || bDialogModelChanged;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -822,6 +834,7 @@ BOOL VCDlgEditor::IsModified() const
void VCDlgEditor::ClearModifyFlag() void VCDlgEditor::ClearModifyFlag()
{ {
pSdrModel->SetChanged( FALSE ); pSdrModel->SetChanged( FALSE );
bDialogModelChanged = FALSE;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: dlgedobj.cxx,v $ * $RCSfile: dlgedobj.cxx,v $
* *
* $Revision: 1.5 $ * $Revision: 1.6 $
* *
* last change: $Author: tbe $ $Date: 2001-03-03 16:20:36 $ * last change: $Author: tbe $ $Date: 2001-03-06 14:49:21 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -123,6 +123,10 @@
#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertySet.hpp>
#endif #endif
#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
#include <com/sun/star/beans/PropertyAttribute.hpp>
#endif
#include "vcsbxdef.hxx" #include "vcsbxdef.hxx"
using namespace ::com::sun::star; using namespace ::com::sun::star;
@@ -354,7 +358,7 @@ void DlgEdObj::SetPropsFromRect()
if ( !ISA(DlgEdForm) ) if ( !ISA(DlgEdForm) )
{ {
EndPropertyListening(sal_False); //EndPropertyListening(sal_False);
// get control property set // get control property set
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xPSet(GetUnoControlModel(), ::com::sun::star::uno::UNO_QUERY); ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xPSet(GetUnoControlModel(), ::com::sun::star::uno::UNO_QUERY);
@@ -410,11 +414,11 @@ void DlgEdObj::SetPropsFromRect()
xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Height" ) ), aValue ); xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Height" ) ), aValue );
} }
StartPropertyListening(); //StartPropertyListening();
} }
else if ( ISA(DlgEdForm) ) else if ( ISA(DlgEdForm) )
{ {
EndPropertyListening(sal_False); //EndPropertyListening(sal_False);
// get control property set // get control property set
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xPSetForm(GetUnoControlModel(), ::com::sun::star::uno::UNO_QUERY); ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xPSetForm(GetUnoControlModel(), ::com::sun::star::uno::UNO_QUERY);
@@ -460,7 +464,7 @@ void DlgEdObj::SetPropsFromRect()
xPSetForm->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Height" ) ), aValue ); xPSetForm->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Height" ) ), aValue );
} }
StartPropertyListening(); //StartPropertyListening();
} }
/* old method /* old method
@@ -745,6 +749,16 @@ void SAL_CALL DlgEdObj::_propertyChange( const ::com::sun::star::beans::Propert
{ {
if (isListening()) if (isListening())
{ {
// dialog model changed
if ( ISA(DlgEdForm) )
{
((DlgEdForm*)this)->GetDlgEditor()->SetDialogModelChanged(TRUE);
}
else
{
GetDlgEdForm()->GetDlgEditor()->SetDialogModelChanged(TRUE);
}
// set rectangle, if geometry information in the model changed // set rectangle, if geometry information in the model changed
if ( evt.PropertyName == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Width")) || if ( evt.PropertyName == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Width")) ||
evt.PropertyName == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Height")) || evt.PropertyName == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Height")) ||
@@ -753,6 +767,7 @@ void SAL_CALL DlgEdObj::_propertyChange( const ::com::sun::star::beans::Propert
{ {
SetRectFromProps(); SetRectFromProps();
} }
// change name of control in dialog model
else if ( evt.PropertyName == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name")) ) else if ( evt.PropertyName == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name")) )
{ {
SetNameFromProp(evt); SetNameFromProp(evt);
@@ -776,11 +791,17 @@ void DlgEdObj::StartPropertyListening()
m_xListener = static_cast< ::com::sun::star::beans::XPropertyChangeListener*>( new DlgEdListenerImpl( (DlgEdObj*)this ) ); m_xListener = static_cast< ::com::sun::star::beans::XPropertyChangeListener*>( new DlgEdListenerImpl( (DlgEdObj*)this ) );
// register listener to properties // register listener to properties
xControlModel->addPropertyChangeListener(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Width")), m_xListener); Reference< XPropertySetInfo > xControlModelInfo( xControlModel->getPropertySetInfo() );
xControlModel->addPropertyChangeListener(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Height")), m_xListener); DBG_ASSERT(xControlModelInfo.is(), "DlgEdObj::StartPropertyListening: control model has no property info!");
xControlModel->addPropertyChangeListener(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PositionX")), m_xListener); Sequence< Property > aProps = xControlModelInfo->getProperties();
xControlModel->addPropertyChangeListener(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PositionY")), m_xListener); Property* pProps = aProps.getArray();
xControlModel->addPropertyChangeListener(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name")), m_xListener); for ( sal_Int32 i = 0 ; i < aProps.getLength() ; i++ )
{
if ( pProps[i].Attributes & PropertyAttribute::BOUND )
{
xControlModel->addPropertyChangeListener( pProps[i].Name , m_xListener );
}
}
} }
bIsListening = sal_True; bIsListening = sal_True;
@@ -803,11 +824,17 @@ void DlgEdObj::EndPropertyListening(sal_Bool bRemoveListener)
if (m_xListener.is() && xControlModel.is()) if (m_xListener.is() && xControlModel.is())
{ {
// remove listener // remove listener
xControlModel->removePropertyChangeListener(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Width")), m_xListener); Reference< XPropertySetInfo > xControlModelInfo( xControlModel->getPropertySetInfo() );
xControlModel->removePropertyChangeListener(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Height")), m_xListener); DBG_ASSERT(xControlModelInfo.is(), "DlgEdObj::EndPropertyListening: control model has no property info!");
xControlModel->removePropertyChangeListener(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PositionX")), m_xListener); Sequence< Property > aProps = xControlModelInfo->getProperties();
xControlModel->removePropertyChangeListener(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PositionY")), m_xListener); Property* pProps = aProps.getArray();
xControlModel->removePropertyChangeListener(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name")), m_xListener); for ( sal_Int32 i = 0 ; i < aProps.getLength() ; i++ )
{
if ( pProps[i].Attributes & PropertyAttribute::BOUND )
{
xControlModel->removePropertyChangeListener( pProps[i].Name , m_xListener );
}
}
} }
m_xListener.clear(); m_xListener.clear();

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: dlged.hxx,v $ * $RCSfile: dlged.hxx,v $
* *
* $Revision: 1.2 $ * $Revision: 1.3 $
* *
* last change: $Author: ab $ $Date: 2001-03-03 14:36:55 $ * last change: $Author: tbe $ $Date: 2001-03-06 14:50:13 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -128,6 +128,7 @@ protected:
BOOL bCreateOK; BOOL bCreateOK;
Timer aPaintTimer; Timer aPaintTimer;
Rectangle aPaintRect; Rectangle aPaintRect;
BOOL bDialogModelChanged;
// Data for new library container mechanism // Data for new library container mechanism
@@ -162,6 +163,9 @@ public:
BOOL UnmarkDialog(); BOOL UnmarkDialog();
void RemarkDialog(); void RemarkDialog();
void SetDialogModelChanged( BOOL bChanged = TRUE ) { bDialogModelChanged = bChanged; }
BOOL IsDialogModelChanged() const { return bDialogModelChanged; }
BOOL IsModified() const; BOOL IsModified() const;
void ClearModifyFlag(); void ClearModifyFlag();