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 $
*
* $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
* either of the following licenses
@@ -225,7 +225,8 @@ VCDlgEditor::VCDlgEditor( StarBASIC* pBas ) :
bGridVisible(FALSE),
bClipPrivate(FALSE),
bCreateOK(TRUE),
pSdrView(NULL)
pSdrView(NULL),
bDialogModelChanged(FALSE)
{
pWindow = NULL;
@@ -595,47 +596,58 @@ IMPL_LINK( VCDlgEditor, PaintTimeout, Timer *, EMPTYARG )
{
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
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()) )
if ( nWidth == 0 && nHeight == 0 )
{
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.Y() -= aPos.Y() % aGridSize.Height();
}
// 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++ )
// don't put in the corner
Point aMinPos = pWindow->PixelToLogic( Point( 30, 20 ) );
if( (aPos.X() < aMinPos.X()) || (aPos.Y() < aMinPos.Y()) )
{
SdrObject* pObj = pSdrPage->GetObj(i);
DlgEdObj* pDlgEdObj = PTR_CAST(DlgEdObj, pObj);
if (pDlgEdObj)
pDlgEdObj->SetRectFromProps();
aPos = aMinPos;
aPos.X() -= aPos.X() % aGridSize.Width();
aPos.Y() -= aPos.Y() % aGridSize.Height();
}
// 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
{
return pSdrModel->IsChanged();
return pSdrModel->IsChanged() || bDialogModelChanged;
}
//----------------------------------------------------------------------------
@@ -822,6 +834,7 @@ BOOL VCDlgEditor::IsModified() const
void VCDlgEditor::ClearModifyFlag()
{
pSdrModel->SetChanged( FALSE );
bDialogModelChanged = FALSE;
}
//----------------------------------------------------------------------------

View File

@@ -2,9 +2,9 @@
*
* $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
* either of the following licenses
@@ -123,6 +123,10 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
#include <com/sun/star/beans/PropertyAttribute.hpp>
#endif
#include "vcsbxdef.hxx"
using namespace ::com::sun::star;
@@ -354,7 +358,7 @@ void DlgEdObj::SetPropsFromRect()
if ( !ISA(DlgEdForm) )
{
EndPropertyListening(sal_False);
//EndPropertyListening(sal_False);
// get control property set
::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 );
}
StartPropertyListening();
//StartPropertyListening();
}
else if ( ISA(DlgEdForm) )
{
EndPropertyListening(sal_False);
//EndPropertyListening(sal_False);
// get control property set
::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 );
}
StartPropertyListening();
//StartPropertyListening();
}
/* old method
@@ -745,6 +749,16 @@ void SAL_CALL DlgEdObj::_propertyChange( const ::com::sun::star::beans::Propert
{
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
if ( evt.PropertyName == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Width")) ||
evt.PropertyName == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Height")) ||
@@ -753,6 +767,7 @@ void SAL_CALL DlgEdObj::_propertyChange( const ::com::sun::star::beans::Propert
{
SetRectFromProps();
}
// change name of control in dialog model
else if ( evt.PropertyName == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name")) )
{
SetNameFromProp(evt);
@@ -776,11 +791,17 @@ void DlgEdObj::StartPropertyListening()
m_xListener = static_cast< ::com::sun::star::beans::XPropertyChangeListener*>( new DlgEdListenerImpl( (DlgEdObj*)this ) );
// register listener to properties
xControlModel->addPropertyChangeListener(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Width")), m_xListener);
xControlModel->addPropertyChangeListener(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Height")), m_xListener);
xControlModel->addPropertyChangeListener(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PositionX")), m_xListener);
xControlModel->addPropertyChangeListener(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PositionY")), m_xListener);
xControlModel->addPropertyChangeListener(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name")), m_xListener);
Reference< XPropertySetInfo > xControlModelInfo( xControlModel->getPropertySetInfo() );
DBG_ASSERT(xControlModelInfo.is(), "DlgEdObj::StartPropertyListening: control model has no property info!");
Sequence< Property > aProps = xControlModelInfo->getProperties();
Property* pProps = aProps.getArray();
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;
@@ -803,11 +824,17 @@ void DlgEdObj::EndPropertyListening(sal_Bool bRemoveListener)
if (m_xListener.is() && xControlModel.is())
{
// remove listener
xControlModel->removePropertyChangeListener(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Width")), m_xListener);
xControlModel->removePropertyChangeListener(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Height")), m_xListener);
xControlModel->removePropertyChangeListener(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PositionX")), m_xListener);
xControlModel->removePropertyChangeListener(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PositionY")), m_xListener);
xControlModel->removePropertyChangeListener(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name")), m_xListener);
Reference< XPropertySetInfo > xControlModelInfo( xControlModel->getPropertySetInfo() );
DBG_ASSERT(xControlModelInfo.is(), "DlgEdObj::EndPropertyListening: control model has no property info!");
Sequence< Property > aProps = xControlModelInfo->getProperties();
Property* pProps = aProps.getArray();
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();

View File

@@ -2,9 +2,9 @@
*
* $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
* either of the following licenses
@@ -128,6 +128,7 @@ protected:
BOOL bCreateOK;
Timer aPaintTimer;
Rectangle aPaintRect;
BOOL bDialogModelChanged;
// Data for new library container mechanism
@@ -162,6 +163,9 @@ public:
BOOL UnmarkDialog();
void RemarkDialog();
void SetDialogModelChanged( BOOL bChanged = TRUE ) { bDialogModelChanged = bChanged; }
BOOL IsDialogModelChanged() const { return bDialogModelChanged; }
BOOL IsModified() const;
void ClearModifyFlag();