Tag: cws_src680_reportdesign02
User: oj      
Date: 2007-10-30 06:56:31+0000
Modified:
   dba/reportdesign/source/core/inc/Tools.hxx
   dba/reportdesign/source/ui/dlg/Navigator.cxx
   dba/reportdesign/source/ui/inc/UITools.hxx
   dba/reportdesign/source/ui/misc/UITools.cxx
   dba/reportdesign/source/ui/report/ReportController.cxx
   dba/reportdesign/source/ui/report/ReportSection.cxx
   dba/reportdesign/source/ui/report/ViewsWindow.cxx

Log:
 #i78939# change pos and size when control is outside page

File Changes:

Directory: /dba/reportdesign/source/core/inc/
=============================================

File [changed]: Tools.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/source/core/inc/Tools.hxx?r1=1.2&r2=1.2.44.1
Delta lines:  +25 -4
--------------------
--- Tools.hxx   2007-07-09 11:56:15+0000        1.2
+++ Tools.hxx   2007-10-30 06:56:28+0000        1.2.44.1
@@ -6,9 +6,9 @@
  *
  *  $RCSfile: Tools.hxx,v $
  *
- *  $Revision: 1.2 $
+ *  $Revision: 1.2.44.1 $
  *
- *  last change: $Author: rt $ $Date: 2007/07/09 11:56:15 $
+ *  last change: $Author: oj $ $Date: 2007/10/30 06:56:28 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -106,9 +106,16 @@
     public:
         template<typename T> static void setSize(const 
::com::sun::star::awt::Size& aSize,T* _pShape)
         {
+            OSL_ENSURE(aSize.Width > 0 && aSize.Height > 0,"Illegal with or 
height!");
+
             ::osl::MutexGuard aGuard(_pShape->m_aMutex);
             if ( _pShape->m_aProps.aComponent.m_xShape.is() )
+            {
+                ::com::sun::star::awt::Size aOldSize = 
_pShape->m_aProps.aComponent.m_xShape->getSize();
+                _pShape->m_aProps.aComponent.m_nWidth = aOldSize.Width;
+                _pShape->m_aProps.aComponent.m_nHeight = aOldSize.Height;
                 _pShape->m_aProps.aComponent.m_xShape->setSize(aSize);
+            }
             
_pShape->set(PROPERTY_WIDTH,aSize.Width,_pShape->m_aProps.aComponent.m_nWidth);
             
_pShape->set(PROPERTY_HEIGHT,aSize.Height,_pShape->m_aProps.aComponent.m_nHeight);
         }
@@ -116,15 +123,25 @@
         {
                ::osl::MutexGuard aGuard(_pShape->m_aMutex);
             if ( _pShape->m_aProps.aComponent.m_xShape.is() )
-                return _pShape->m_aProps.aComponent.m_xShape->getSize();
+            {
+                ::com::sun::star::awt::Size aSize = 
_pShape->m_aProps.aComponent.m_xShape->getSize();
+                OSL_ENSURE(aSize.Width > 0 && aSize.Height > 0,"Illegal with 
or height!");
+                return aSize;
+            }
                return 
::com::sun::star::awt::Size(_pShape->m_aProps.aComponent.m_nWidth,_pShape->m_aProps.aComponent.m_nHeight);
         }
 
         template<typename T> static void setPosition( const 
::com::sun::star::awt::Point& aPosition ,T* _pShape)
         {
+            OSL_ENSURE(aPosition.X >= 0 && aPosition.Y >= 0,"Illegal 
position!");
             ::osl::MutexGuard aGuard(_pShape->m_aMutex);
             if ( _pShape->m_aProps.aComponent.m_xShape.is() )
+            {
+                ::com::sun::star::awt::Point aOldPos = 
_pShape->m_aProps.aComponent.m_xShape->getPosition();
+                _pShape->m_aProps.aComponent.m_nPosX = aOldPos.X;
+                _pShape->m_aProps.aComponent.m_nPosY = aOldPos.Y;
                 _pShape->m_aProps.aComponent.m_xShape->setPosition(aPosition);
+            }
             
_pShape->set(PROPERTY_POSITIONX,aPosition.X,_pShape->m_aProps.aComponent.m_nPosX);
             
_pShape->set(PROPERTY_POSITIONY,aPosition.Y,_pShape->m_aProps.aComponent.m_nPosY);
         }
@@ -132,7 +149,11 @@
         {
             ::osl::MutexGuard aGuard(_pShape->m_aMutex);
             if ( _pShape->m_aProps.aComponent.m_xShape.is() )
-                return _pShape->m_aProps.aComponent.m_xShape->getPosition();
+            {
+                ::com::sun::star::awt::Point aPosition = 
_pShape->m_aProps.aComponent.m_xShape->getPosition();
+                OSL_ENSURE(aPosition.X >= 0 && aPosition.Y >= 0,"Illegal 
position!");
+                return aPosition;
+            }
                return 
::com::sun::star::awt::Point(_pShape->m_aProps.aComponent.m_nPosX,_pShape->m_aProps.aComponent.m_nPosY);
         }
         template<typename T> static void setParent( const 
com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& Parent, T* 
_pShape)

Directory: /dba/reportdesign/source/ui/dlg/
===========================================

File [changed]: Navigator.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/source/ui/dlg/Navigator.cxx?r1=1.3&r2=1.3.36.1
Delta lines:  +4 -4
-------------------
--- Navigator.cxx       2007-08-03 10:00:48+0000        1.3
+++ Navigator.cxx       2007-10-30 06:56:28+0000        1.3.36.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: Navigator.cxx,v $
  *
- *  $Revision: 1.3 $
+ *  $Revision: 1.3.36.1 $
  *
- *  last change: $Author: hr $ $Date: 2007/08/03 10:00:48 $
+ *  last change: $Author: oj $ $Date: 2007/10/30 06:56:28 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -592,7 +592,7 @@
     const sal_Int32 nCount = _xSection->getCount();
     for (sal_Int32 i = 0; i < nCount; ++i)
     {
-        uno::Reference< report::XReportComponent> 
xElement(_xSection->getByIndex(i),uno::UNO_QUERY);
+        uno::Reference< report::XReportComponent> 
xElement(_xSection->getByIndex(i),uno::UNO_QUERY_THROW);
         OSL_ENSURE(xElement.is(),"Found report element which is NULL!");
         
insertEntry(lcl_getName(xElement),pSection,lcl_getImageId(xElement),LIST_APPEND,new
 UserData(this,xElement));
         uno::Reference< report::XReportDefinition> 
xSubReport(xElement,uno::UNO_QUERY);

Directory: /dba/reportdesign/source/ui/inc/
===========================================

File [changed]: UITools.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/source/ui/inc/UITools.hxx?r1=1.2&r2=1.2.44.1
Delta lines:  +11 -3
--------------------
--- UITools.hxx 2007-07-09 11:56:30+0000        1.2
+++ UITools.hxx 2007-10-30 06:56:28+0000        1.2.44.1
@@ -6,9 +6,9 @@
  *
  *  $RCSfile: UITools.hxx,v $
  *
- *  $Revision: 1.2 $
+ *  $Revision: 1.2.44.1 $
  *
- *  last change: $Author: rt $ $Date: 2007/07/09 11:56:30 $
+ *  last change: $Author: oj $ $Date: 2007/10/30 06:56:28 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -43,7 +43,7 @@
 #include <com/sun/star/beans/NamedValue.hpp>
 #include <com/sun/star/container/XIndexAccess.hpp>
 #include <com/sun/star/sdbc/XRowSet.hpp>
-
+#include "ReportSection.hxx"
 #include <rtl/ref.hxx>
 #include <vcl/taskpanelist.hxx>
 #include <comphelper/stl_types.hxx>
@@ -152,6 +152,14 @@
     */
     ::com::sun::star::uno::Sequence< ::rtl::OUString >
         getParameterNames( const ::com::sun::star::uno::Reference< 
::com::sun::star::sdbc::XRowSet >& _rxRowSet );
+
+    /** ensures that no control overlaps the given one.
+    *
+    * \param pControl           the control which should place in the section 
without overlapping
+    * \param _pReportSection    the section
+    * \param _bInsert           TRUE whe the control should be inserted, 
otherwise not.
+    */
+    void correctOverlapping(SdrObject* 
pControl,::boost::shared_ptr<OReportSection> _pReportSection,bool _bInsert = 
true);
 }
 #endif //RPTUI_UITOOLS_HXX
 

Directory: /dba/reportdesign/source/ui/misc/
============================================

File [changed]: UITools.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/source/ui/misc/UITools.cxx?r1=1.2&r2=1.2.44.1
Delta lines:  +27 -3
--------------------
--- UITools.cxx 2007-07-09 11:56:32+0000        1.2
+++ UITools.cxx 2007-10-30 06:56:28+0000        1.2.44.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: UITools.cxx,v $
  *
- *  $Revision: 1.2 $
+ *  $Revision: 1.2.44.1 $
  *
- *  last change: $Author: rt $ $Date: 2007/07/09 11:56:32 $
+ *  last change: $Author: oj $ $Date: 2007/10/30 06:56:28 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -70,6 +70,8 @@
 #include <svx/charscaleitem.hxx>
 #include <svx/algitem.hxx>
 #include <svx/svdpagv.hxx>
+#include <toolkit/helper/convert.hxx>
+#include "SectionView.hxx"
 #ifndef RPTUI_TOOLS_HXX
 #include "UITools.hxx"
 #endif
@@ -865,7 +867,29 @@
 
     return aNames;
 }
-
+// 
-----------------------------------------------------------------------------
+// check overlapping
+void correctOverlapping(SdrObject* 
pControl,::boost::shared_ptr<OReportSection> _pReportSection,bool _bInsert)
+{
+    OSectionView* pSectionView = _pReportSection->getView();
+    uno::Reference< report::XReportComponent> 
xComponent(pControl->getUnoShape(),uno::UNO_QUERY);
+    Rectangle 
aRet(VCLPoint(xComponent->getPosition()),VCLSize(xComponent->getSize()));
+    aRet.setHeight(aRet.getHeight() + 1);
+    aRet.setWidth(aRet.getWidth() + 1);
+    bool bOverlapping = true;
+    while ( bOverlapping )
+    {
+        SdrObject* pOverlappedObj = 
isOver(aRet,*_pReportSection->getPage(),*pSectionView,true,pControl);
+        bOverlapping = pOverlappedObj != NULL;
+        if ( bOverlapping )
+        {
+            aRet.Move(0,pOverlappedObj->GetLogicRect().getHeight());
+            xComponent->setPositionY(aRet.Top());
+        }
+    }
+    if ( !bOverlapping && _bInsert ) // now insert objects
+        
pSectionView->InsertObjectAtView(pControl,*pSectionView->GetSdrPageView(),SDRINSERT_ADDMARK);
+}
 // 
-----------------------------------------------------------------------------
 } // namespace rptui
 // 
-----------------------------------------------------------------------------

Directory: /dba/reportdesign/source/ui/report/
==============================================

File [changed]: ReportController.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/source/ui/report/ReportController.cxx?r1=1.4.36.1&r2=1.4.36.2
Delta lines:  +4 -27
--------------------
--- ReportController.cxx        2007-10-26 11:26:00+0000        1.4.36.1
+++ ReportController.cxx        2007-10-30 06:56:29+0000        1.4.36.2
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: ReportController.cxx,v $
  *
- *  $Revision: 1.4.36.1 $
+ *  $Revision: 1.4.36.2 $
  *
- *  last change: $Author: oj $ $Date: 2007/10/26 11:26:00 $
+ *  last change: $Author: oj $ $Date: 2007/10/30 06:56:29 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -341,29 +341,6 @@
                _xWindow = VCLUnoHelper::GetInterface(_pView);
        return xReportControlFormat;
 }
-// 
-----------------------------------------------------------------------------
-// check overlapping
-void lcl_correctOverlapping(SdrObject* 
pControl,::boost::shared_ptr<OReportSection> _pReportSection)
-{
-    OSectionView* pSectionView = _pReportSection->getView();
-    uno::Reference< report::XReportComponent> 
xComponent(pControl->getUnoShape(),uno::UNO_QUERY);
-    Rectangle 
aRet(VCLPoint(xComponent->getPosition()),VCLSize(xComponent->getSize()));
-    aRet.setHeight(aRet.getHeight() + 1);
-    aRet.setWidth(aRet.getWidth() + 1);
-    bool bOverlapping = true;
-    while ( bOverlapping )
-    {
-        SdrObject* pOverlappedObj = 
isOver(aRet,*_pReportSection->getPage(),*pSectionView,true,pControl);
-        bOverlapping = pOverlappedObj != NULL;
-        if ( bOverlapping )
-        {
-            aRet.Move(0,pOverlappedObj->GetLogicRect().getHeight());
-            xComponent->setPositionY(aRet.Top());
-        }
-    }
-    if ( !bOverlapping ) // now insert objects
-        
pSectionView->InsertObjectAtView(pControl,*pSectionView->GetSdrPageView(),SDRINSERT_ADDMARK);
-}
 
//------------------------------------------------------------------------------
 ::rtl::OUString SAL_CALL OReportController::getImplementationName() throw( 
RuntimeException )
 {
@@ -3342,7 +3319,7 @@
         aPos.X = nPaperWidth - nShapeWidth;
     xShapeProp->setPosition(aPos);
 
-    lcl_correctOverlapping(pNewControl,pReportSection);
+    correctOverlapping(pNewControl,pReportSection);
 }
 // 
-----------------------------------------------------------------------------
 void OReportController::createDateTime(const Sequence< PropertyValue >& _aArgs)
@@ -3652,7 +3629,7 @@
                     xShapeProp->setName(xShapeProp->getName() + sDefaultName );
 
                     for(i = 0; i < sizeof(pControl)/sizeof(pControl[0]);++i)
-                        
lcl_correctOverlapping(pControl[i],pReportSection[1-i]);
+                        correctOverlapping(pControl[i],pReportSection[1-i]);
                            }
                    }
                    else

File [changed]: ReportSection.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/source/ui/report/ReportSection.cxx?r1=1.5&r2=1.5.18.1
Delta lines:  +60 -6
--------------------
--- ReportSection.cxx   2007-08-17 15:35:19+0000        1.5
+++ ReportSection.cxx   2007-10-30 06:56:29+0000        1.5.18.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: ReportSection.cxx,v $
  *
- *  $Revision: 1.5 $
+ *  $Revision: 1.5.18.1 $
  *
- *  last change: $Author: ihi $ $Date: 2007/08/17 15:35:19 $
+ *  last change: $Author: oj $ $Date: 2007/10/30 06:56:29 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -584,18 +584,72 @@
                }
                else
                {
+            uno::Reference<report::XReportDefinition> xReportDefinition = 
m_xSection->getReportDefinition();
             if ( _rEvent.PropertyName == PROPERTY_LEFTMARGIN )
             {
-                const sal_Int32 nLeftMargin = 
getStyleProperty<sal_Int32>(m_xSection->getReportDefinition(),PROPERTY_LEFTMARGIN);
+                const sal_Int32 nLeftMargin = 
getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_LEFTMARGIN);
                    m_pPage->SetLftBorder(nLeftMargin);
-                
//m_pView->GetSdrPageView()->SetPageOrigin(Point(nLeftMargin,0));
             }
             else if ( _rEvent.PropertyName == PROPERTY_RIGHTMARGIN )
             {
-                const sal_Int32 nRightMargin = 
getStyleProperty<sal_Int32>(m_xSection->getReportDefinition(),PROPERTY_RIGHTMARGIN);
+                const sal_Int32 nRightMargin = 
getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_RIGHTMARGIN);
                    m_pPage->SetRgtBorder(nRightMargin);
             }
 
+            try
+            {
+                   const sal_Int32 nLeftMargin  = 
getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_LEFTMARGIN);
+                   const sal_Int32 nRightMargin = 
getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_RIGHTMARGIN);
+                   const sal_Int32 nPaperWidth  = 
getStyleProperty<awt::Size>(xReportDefinition,PROPERTY_PAPERSIZE).Width;
+                ::boost::shared_ptr<OReportSection>    aSection = 
m_pParent->getReportSection(m_xSection);
+                const sal_Int32 nCount = m_xSection->getCount();
+                for (sal_Int32 i = 0; i < nCount; ++i)
+                {
+                    bool bChanged = false;
+                    uno::Reference< report::XReportComponent> 
xReportComponent(m_xSection->getByIndex(i),uno::UNO_QUERY_THROW);
+                    awt::Point aPos = xReportComponent->getPosition();
+                    awt::Size aSize = xReportComponent->getSize();
+                    SvxShape* pShape = SvxShape::getImplementation( 
xReportComponent );
+                    SdrObject* pObject = pShape ? pShape->GetSdrObject() : 
NULL;
+                    if ( pObject )
+                    {
+                        OObjectBase* pBase = 
dynamic_cast<OObjectBase*>(pObject);
+                        pBase->EndListening(sal_False);
+                        if ( aPos.X < nLeftMargin )
+                        {
+                            aPos.X  = nLeftMargin;
+                            bChanged = true;
+                        }
+                        if ( (aPos.X + aSize.Width) > (nPaperWidth - 
nRightMargin) )
+                        {
+                            aPos.X = nPaperWidth - nRightMargin - aSize.Width;
+                            if ( aPos.X < nLeftMargin )
+                            {
+                                aSize.Width += aPos.X - nLeftMargin;
+                                aPos.X = nLeftMargin;
+                                // add listener around
+                                pBase->StartListening();
+                                xReportComponent->setSize(aSize);
+                                pBase->EndListening(sal_False);
+                            }
+                            bChanged = true;
+                        }
+                        if ( aPos.Y < 0 )
+                            aPos.Y = 0;
+                        if ( bChanged ) 
+                        {
+                            xReportComponent->setPosition(aPos);
+                            correctOverlapping(pObject,aSection,false);
+                        }
+                        pBase->StartListening();
+                    }
+                }
+            }
+            catch(uno::Exception)
+            {
+                OSL_ENSURE(0,"Exception caught: 
OReportSection::_propertyChanged(");
+            }
+
                        Resize();
                }
        }       

File [changed]: ViewsWindow.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/source/ui/report/ViewsWindow.cxx?r1=1.5.10.1&r2=1.5.10.2
Delta lines:  +8 -2
-------------------
--- ViewsWindow.cxx     2007-10-26 12:31:37+0000        1.5.10.1
+++ ViewsWindow.cxx     2007-10-30 06:56:29+0000        1.5.10.2
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: ViewsWindow.cxx,v $
  *
- *  $Revision: 1.5.10.1 $
+ *  $Revision: 1.5.10.2 $
  *
- *  last change: $Author: oj $ $Date: 2007/10/26 12:31:37 $
+ *  last change: $Author: oj $ $Date: 2007/10/30 06:56:29 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -1375,6 +1375,12 @@
                             aNewPos.X() = nPaperWidth - nRightMargin - 
aSize.Width;
                         if ( aNewPos.Y() < 0 )
                             aNewPos.Y() = 0;
+                        if ( aNewPos.X() < 0 )
+                        {
+                            aSize.Width += aNewPos.X();
+                            aNewPos.X()= 0;
+                            xRC->setSize(aSize);
+                        }
                         xRC->setPosition(AWTPoint(aNewPos));
                         if ( (pColIter+1) != pColEnd )
                         {




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to