Tag: cws_ooh680_dba24g
User: lla     
Date: 2008-01-30 12:43:05+0000
Modified:
   dba/reportdesign/source/ui/inc/UITools.hxx
   dba/reportdesign/source/ui/misc/UITools.cxx
   dba/reportdesign/source/ui/report/ReportController.cxx

Log:
 #i85662# D&D loop fix

File Changes:

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.68.1&r2=1.2.68.1.2.1
Delta lines:  +13 -3
--------------------
--- UITools.hxx 2008-01-18 13:06:40+0000        1.2.68.1
+++ UITools.hxx 2008-01-30 12:43:02+0000        1.2.68.1.2.1
@@ -6,9 +6,9 @@
  *
  *  $RCSfile: UITools.hxx,v $
  *
- *  $Revision: 1.2.68.1 $
+ *  $Revision: 1.2.68.1.2.1 $
  *
- *  last change: $Author: kz $ $Date: 2008/01/18 13:06:40 $
+ *  last change: $Author: lla $ $Date: 2008/01/30 12:43:02 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -51,6 +51,7 @@
 
 class SdrPage;
 class SdrObject;
+class SdrUnoObj;
 class SdrView;
 class Rectangle;
 namespace comphelper
@@ -138,6 +139,8 @@
     */
     SdrObject* isOver(const Rectangle& _rRect,SdrPage& _rPage,SdrView& 
_rView,bool _bAllObjects = false,SdrObject* _pIgnore = NULL);
 
+    SdrObject* isOver(const Rectangle& _rRect,SdrPage& _rPage,SdrView& 
_rView,bool _bAllObjects, SdrUnoObj* _pIgnoreList[], int _nIgnoreListLength);
+
     /** checks whether the given OUnoObject object rectangle overlapps another 
object in that view.
     *
     * \param _pObj 
@@ -160,6 +163,13 @@
     * \param _bInsert           TRUE whe the control should be inserted, 
otherwise not.
     */
     void correctOverlapping(SdrObject* 
pControl,::boost::shared_ptr<OReportSection> _pReportSection,bool _bInsert = 
true);
+
+    /** returns a Rectangle of a given SdrObject
+     *
+     * \param pControl          the SdrObject
+     */
+
+    Rectangle getRectangleFromControl(SdrObject* pControl);
 }
 #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.68.1&r2=1.2.68.1.2.1
Delta lines:  +68 -12
---------------------
--- UITools.cxx 2008-01-18 13:08:19+0000        1.2.68.1
+++ UITools.cxx 2008-01-30 12:43:02+0000        1.2.68.1.2.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: UITools.cxx,v $
  *
- *  $Revision: 1.2.68.1 $
+ *  $Revision: 1.2.68.1.2.1 $
  *
- *  last change: $Author: kz $ $Date: 2008/01/18 13:08:19 $
+ *  last change: $Author: lla $ $Date: 2008/01/30 12:43:02 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -823,6 +823,44 @@
     }
     return pOverlappedObj;
 }
+// 
-----------------------------------------------------------------------------
+bool checkArrayForOccurance(SdrObject* _pObjToCheck, SdrUnoObj* _pIgnore[], 
int _nListLength)
+{
+    for(int i=0;i<_nListLength;i++)
+    {
+        SdrObject *pIgnore = _pIgnore[i];
+        if (pIgnore == _pObjToCheck)
+        {
+            return true;
+        }
+    }
+    return false;
+}
+
+SdrObject* isOver(const Rectangle& _rRect,SdrPage& _rPage,SdrView& _rView,bool 
_bAllObjects, SdrUnoObj * _pIgnoreList[], int _nIgnoreListLength)
+{
+    SdrObject* pOverlappedObj = NULL;
+    SdrObjListIter aIter(_rPage,IM_DEEPNOGROUPS);
+    SdrObject* pObjIter = NULL;
+
+    while( !pOverlappedObj && (pObjIter = aIter.Next()) != NULL )
+    {
+        if (checkArrayForOccurance(pObjIter, _pIgnoreList, _nIgnoreListLength))
+        {
+            continue;
+        }
+        
+        if ( (_bAllObjects || !_rView.IsObjMarked(pObjIter)) 
+             && dynamic_cast<OUnoObject*>(pObjIter) != NULL )
+        {
+            Rectangle aRect = 
_rRect.GetIntersection(pObjIter->GetLastBoundRect());
+            if ( !aRect.IsEmpty() && (aRect.Left() != aRect.Right() && 
aRect.Top() != aRect.Bottom() ) )
+                pOverlappedObj = pObjIter;
+        }
+    }
+    return pOverlappedObj;
+}
+
 //----------------------------------------------------------------------------
 SdrObject* isOver(SdrObject* _pObj,SdrPage& _rPage,SdrView& _rView,bool 
_bUnMarkedObjects)
 {
@@ -868,28 +906,46 @@
     return aNames;
 }
 // 
-----------------------------------------------------------------------------
+Rectangle getRectangleFromControl(SdrObject* _pControl)
+{
+    if (_pControl)
+    {
+        uno::Reference< report::XReportComponent > xComponent( 
_pControl->getUnoShape(), uno::UNO_QUERY);
+        if (xComponent.is())
+        {
+            Rectangle 
aRect(VCLPoint(xComponent->getPosition()),VCLSize(xComponent->getSize()));
+            aRect.setHeight(aRect.getHeight() + 1);
+            aRect.setWidth(aRect.getWidth() + 1);
+            return aRect;
+        }
+    }
+    return Rectangle();
+}
+// 
-----------------------------------------------------------------------------
 // check overlapping
-void correctOverlapping(SdrObject* 
pControl,::boost::shared_ptr<OReportSection> _pReportSection,bool _bInsert)
+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);
+    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);
+    Rectangle aRect = getRectangleFromControl(_pControl);
+
     bool bOverlapping = true;
     while ( bOverlapping )
     {
-        SdrObject* pOverlappedObj = 
isOver(aRet,*_pReportSection->getPage(),*pSectionView,true,pControl);
+        SdrObject* pOverlappedObj = 
isOver(aRect,*_pReportSection->getPage(),*pSectionView,true, _pControl);
         bOverlapping = pOverlappedObj != NULL;
         if ( bOverlapping )
         {
                        const Rectangle& aLogicRect = 
pOverlappedObj->GetLogicRect();
-                       aRet.Move(0,aLogicRect.Top() + aLogicRect.getHeight() - 
aRet.Top());
-            xComponent->setPositionY(aRet.Top());
+                       aRect.Move(0,aLogicRect.Top() + aLogicRect.getHeight() 
- aRect.Top());
+            xComponent->setPositionY(aRect.Top());
         }
     }
     if ( !bOverlapping && _bInsert ) // now insert objects
-        
pSectionView->InsertObjectAtView(pControl,*pSectionView->GetSdrPageView(),SDRINSERT_ADDMARK);
+        
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.6.12.2&r2=1.6.12.2.2.1
Delta lines:  +46 -19
---------------------
--- ReportController.cxx        2008-01-18 16:03:21+0000        1.6.12.2
+++ ReportController.cxx        2008-01-30 12:43:02+0000        1.6.12.2.2.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: ReportController.cxx,v $
  *
- *  $Revision: 1.6.12.2 $
+ *  $Revision: 1.6.12.2.2.1 $
  *
- *  last change: $Author: kz $ $Date: 2008/01/18 16:03:21 $
+ *  last change: $Author: lla $ $Date: 2008/01/30 12:43:02 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -341,7 +341,7 @@
                _xWindow = VCLUnoHelper::GetInterface(_pView);
        return xReportControlFormat;
 }
-//------------------------------------------------------------------------------
+// 
-----------------------------------------------------------------------------
 ::rtl::OUString SAL_CALL OReportController::getImplementationName() throw( 
RuntimeException )
 {
        return getImplementationName_Static();
@@ -3532,30 +3532,56 @@
                     uno::Reference< report::XReportComponent> 
xShapeProp(pObj->getUnoShape(),uno::UNO_QUERY_THROW);
                     xShapeProp->setName(xShapeProp->getName() + sDefaultName );
 
-                    for(i = 0; i < sizeof(pControl)/sizeof(pControl[0]);++i)
+                    for(i = 0; i < sizeof(pControl)/sizeof(pControl[0]);++i) 
// insert controls
+                    {
                         correctOverlapping(pControl[i],pReportSection[1-i]);
+                    }
 
                     if (!bLabelAboveTextField )
                     {
-                        uno::Reference< report::XReportComponent> 
xComponent(pControl[1]->getUnoShape(),uno::UNO_QUERY_THROW);
-                        sal_Int32 nY1 = xShapeProp->getPositionY();
-                        sal_Int32 nY2 = xComponent->getPositionY();
-                        while( nY1 != nY2 )
+                                               if ( pSectionViews[0] == 
pSectionViews[1] )
                         {
-                            size_t nWhich = 0;
-                            if ( nY1 > nY2 )
+                                                       Rectangle aLabel = 
getRectangleFromControl(pControl[0]);
+                                                       Rectangle aTextfield = 
getRectangleFromControl(pControl[1]);
+
+                                                       // create a Union of 
the given Label and Textfield
+                                                       Rectangle 
aLabelAndTextfield( aLabel );
+                            aLabelAndTextfield.Union(aTextfield);
+
+                                                       // check if there 
exists other fields and if yes, move down
+                            bool bOverlapping = true;
+                                                       bool bHasToMove = false;
+                            while ( bOverlapping )
                             {
-                                ++nWhich;
-                                xComponent->setPositionY(nY1);
+                                const SdrObject* pOverlappedObj = 
isOver(aLabelAndTextfield, *pReportSection[0]->getPage(), *pSectionViews[0], 
true, pControl, 2);
+                                bOverlapping = pOverlappedObj != NULL;
+                                if ( bOverlapping )
+                                {
+                                    const Rectangle& aLogicRect = 
pOverlappedObj->GetLogicRect();
+                                    aLabelAndTextfield.Move(0,aLogicRect.Top() 
+ aLogicRect.getHeight() - aLabelAndTextfield.Top());
+                                                                       
bHasToMove = true;
                             }
-                            else
-                                xShapeProp->setPositionY(nY2);
-                            
correctOverlapping(pControl[nWhich],pReportSection[1 - nWhich],false);
+                            }
+                            
+                                                       if (bHasToMove)
+                                                       {
+                                                               // There was a 
move down, we need to move the Label and the Textfield down
+                                                               aLabel.Move(0, 
aLabelAndTextfield.Top() - aLabel.Top());
+                                                               
aTextfield.Move(0, aLabelAndTextfield.Top() - aTextfield.Top());
+
+                                                               uno::Reference< 
report::XReportComponent> 
xLabel(pControl[0]->getUnoShape(),uno::UNO_QUERY_THROW);
+                                                               
xLabel->setPositionY(aLabel.Top());
                             
-                            nY1 = xShapeProp->getPositionY();
-                            nY2 = xComponent->getPositionY();
+                                                               uno::Reference< 
report::XReportComponent> 
xTextfield(pControl[1]->getUnoShape(),uno::UNO_QUERY_THROW);
+                                                               
xTextfield->setPositionY(aTextfield.Top());
                         }
                     }
+                                               // this should never happen.
+                                               // else
+                                               // {
+                                               //      DBG_ERROR("unhandled 
case.");
+                                               // }
+                                       }
                            }
                    }
                    else
@@ -3570,6 +3596,7 @@
        DBG_UNHANDLED_EXCEPTION();
     }
 }
+
 // 
-----------------------------------------------------------------------------
 OSectionView* OReportController::getCurrentSectionView() const
 {




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

Reply via email to