You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by af...@apache.org on 2013/04/08 12:59:21 UTC

svn commit: r1465588 - in /openoffice/branches/sidebar/main/sd/source/ui: sidebar/PanelFactory.cxx sidebar/makefile.mk table/TableDesignPane.cxx table/TableDesignPane.hxx table/TableDesignPane.src

Author: af
Date: Mon Apr  8 10:59:21 2013
New Revision: 1465588

URL: http://svn.apache.org/r1465588
Log:
i121420: Improved sizing for table panel.

Modified:
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/PanelFactory.cxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/makefile.mk
    openoffice/branches/sidebar/main/sd/source/ui/table/TableDesignPane.cxx
    openoffice/branches/sidebar/main/sd/source/ui/table/TableDesignPane.hxx
    openoffice/branches/sidebar/main/sd/source/ui/table/TableDesignPane.src

Modified: openoffice/branches/sidebar/main/sd/source/ui/sidebar/PanelFactory.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sd/source/ui/sidebar/PanelFactory.cxx?rev=1465588&r1=1465587&r2=1465588&view=diff
==============================================================================
--- openoffice/branches/sidebar/main/sd/source/ui/sidebar/PanelFactory.cxx (original)
+++ openoffice/branches/sidebar/main/sd/source/ui/sidebar/PanelFactory.cxx Mon Apr  8 10:59:21 2013
@@ -30,7 +30,6 @@
 #include "RecentMasterPagesSelector.hxx"
 #include "AllMasterPagesSelector.hxx"
 #include "CustomAnimationPanel.hxx"
-#include "TableDesignPanel.hxx"
 #include "SlideTransitionPanel.hxx"
 #include "NavigatorWrapper.hxx"
 
@@ -47,6 +46,10 @@ using ::rtl::OUString;
 
 #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
 
+namespace sd {
+	extern ::Window * createTableDesignPanel (::Window* pParent, ViewShellBase& rBase);
+}
+
 namespace sd { namespace sidebar {
 
 namespace {
@@ -170,7 +173,8 @@ Reference<ui::XUIElement> SAL_CALL Panel
 
     // Create a framework view.
     ::Window* pControl = NULL;
-
+    css::ui::LayoutSize aLayoutSize (-1,-1,-1);
+    
 #define EndsWith(s,t) s.endsWithAsciiL(t,strlen(t))
     if (EndsWith(rsUIElementResourceURL, gsResourceNameCustomAnimations))
         pControl = new CustomAnimationPanel(pParentWindow, *pBase);
@@ -185,7 +189,7 @@ Reference<ui::XUIElement> SAL_CALL Panel
     else if (EndsWith(rsUIElementResourceURL, gsResourceNameSlideTransitions))
         pControl = new SlideTransitionPanel(pParentWindow, *pBase);
     else if (EndsWith(rsUIElementResourceURL, gsResourceNameTableDesign))
-        pControl = new TableDesignPanel(pParentWindow, *pBase);
+        pControl = createTableDesignPanel(pParentWindow, *pBase);
     else if (EndsWith(rsUIElementResourceURL, gsResourceNameNavigator))
         pControl = new NavigatorWrapper(pParentWindow, *pBase, pBindings);
 #undef EndsWith
@@ -199,7 +203,7 @@ Reference<ui::XUIElement> SAL_CALL Panel
         rsUIElementResourceURL,
         xFrame,
         pControl,
-        ui::LayoutSize(-1,-1,-1));
+        aLayoutSize);
 }
 
 

Modified: openoffice/branches/sidebar/main/sd/source/ui/sidebar/makefile.mk
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sd/source/ui/sidebar/makefile.mk?rev=1465588&r1=1465587&r2=1465588&view=diff
==============================================================================
--- openoffice/branches/sidebar/main/sd/source/ui/sidebar/makefile.mk (original)
+++ openoffice/branches/sidebar/main/sd/source/ui/sidebar/makefile.mk Mon Apr  8 10:59:21 2013
@@ -57,8 +57,7 @@ SLOFILES =      							\
 	$(SLO)$/PreviewValueSet.obj				\
 	$(SLO)$/RecentlyUsedMasterPages.obj		\
 	$(SLO)$/RecentMasterPagesSelector.obj	\
-	$(SLO)$/SlideTransitionPanel.obj		\
-	$(SLO)$/TableDesignPanel.obj
+	$(SLO)$/SlideTransitionPanel.obj
 
 # --- Tagets -------------------------------------------------------
 

Modified: openoffice/branches/sidebar/main/sd/source/ui/table/TableDesignPane.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sd/source/ui/table/TableDesignPane.cxx?rev=1465588&r1=1465587&r2=1465588&view=diff
==============================================================================
--- openoffice/branches/sidebar/main/sd/source/ui/table/TableDesignPane.cxx (original)
+++ openoffice/branches/sidebar/main/sd/source/ui/table/TableDesignPane.cxx Mon Apr  8 10:59:21 2013
@@ -105,7 +105,7 @@ TableDesignPane::TableDesignPane( ::Wind
 {
 	Window* pControlParent = mbModal ? pParent : this;
 
-	mxControls[FL_TABLE_STYLES].reset( new FixedLine( pControlParent, SdResId( FL_TABLE_STYLES + 1 ) ) );
+    //	mxControls[FL_TABLE_STYLES].reset( new FixedLine( pControlParent, SdResId( FL_TABLE_STYLES + 1 ) ) );
 
 	ValueSet* pValueSet = new ValueSet( pControlParent, SdResId( CT_TABLE_STYLES+1 ) );
 	mxControls[CT_TABLE_STYLES].reset( pValueSet );
@@ -122,7 +122,7 @@ TableDesignPane::TableDesignPane( ::Wind
 	}
 	pValueSet->SetSelectHdl (LINK(this, TableDesignPane, implValueSetHdl));
 
-	mxControls[FL_STYLE_OPTIONS].reset( new FixedLine( pControlParent, SdResId( FL_STYLE_OPTIONS + 1 ) ) );
+    //	mxControls[FL_STYLE_OPTIONS].reset( new FixedLine( pControlParent, SdResId( FL_STYLE_OPTIONS + 1 ) ) );
 	sal_uInt16 i;
 	for( i = CB_HEADER_ROW; i <= CB_BANDED_COLUMNS; ++i )
 	{
@@ -132,8 +132,15 @@ TableDesignPane::TableDesignPane( ::Wind
 	}
 
 	for( i = 0; i < DESIGNPANE_CONTROL_COUNT; i++ )
-		mnOrgOffsetY[i] = mxControls[i]->GetPosPixel().Y();
-
+    {
+        if (mxControls[i])
+            mnOrgOffsetY[i] = mxControls[i]->GetPosPixel().Y();
+        else if (i > 0)
+            mnOrgOffsetY[i] = mnOrgOffsetY[i-1];
+        else
+            mnOrgOffsetY[i] = 0;
+    }
+    
 	// get current controller and initialize listeners
 	try
 	{
@@ -180,6 +187,60 @@ void TableDesignPane::Resize()
 	updateLayout();
 }
 
+
+
+
+LayoutSize TableDesignPane::GetHeightForWidth (const sal_Int32 nWidth)
+{
+    if ( ! IsVisible() || nWidth<=0)
+        return LayoutSize(0,0,0);
+
+    // Initialize the height with the offset above and below the value
+    // set and below the check boxes.
+    const Point aOffset (LogicToPixel( Point(3,3), MAP_APPFONT));
+    sal_Int32 nHeight (3 * aOffset.Y());
+
+    // Add the height for the check boxes.
+    nHeight += mnOrgOffsetY[CB_BANDED_COLUMNS] - mnOrgOffsetY[CB_HEADER_ROW]
+        + mxControls[CB_BANDED_COLUMNS]->GetSizePixel().Height();
+
+    // Setup minimal and maximal heights that include all check boxes
+    // and a small or large value set.
+    const sal_Int32 nMinimalHeight (nHeight+100);
+    const sal_Int32 nMaximalHeight (nHeight+450);
+
+    // Calculate the number of rows and columns and then add the
+    // preferred size of the value set.
+    ValueSet* pValueSet = static_cast< ValueSet* >( mxControls[CT_TABLE_STYLES].get() );
+    if (pValueSet->GetItemCount() > 0)
+    {
+        Image aImage = pValueSet->GetItemImage(pValueSet->GetItemId(0));
+        Size aItemSize = pValueSet->CalcItemSizePixel(aImage.GetSizePixel());
+        aItemSize.Width() += 10;
+        aItemSize.Height() += 10;
+        
+        int nColumnCount = (pValueSet->GetSizePixel().Width() - pValueSet->GetScrollWidth()) / aItemSize.Width();
+        if (nColumnCount < 1)
+            nColumnCount = 1;
+
+        int nRowCount = (pValueSet->GetItemCount() + nColumnCount - 1) / nColumnCount;
+        if (nRowCount < 1)
+            nRowCount = 1;
+
+        nHeight += nRowCount * aItemSize.Height();
+    }
+
+    // Clip the requested height.
+    if (nHeight<nMinimalHeight)
+        nHeight = nMinimalHeight;
+    else if (nHeight>nMaximalHeight)
+        nHeight = nMaximalHeight;
+    return LayoutSize(nMinimalHeight, nMaximalHeight, nHeight);
+}
+
+
+
+
 // --------------------------------------------------------------------
 
 static SfxBindings* getBindings( ViewShellBase& rBase )
@@ -378,16 +439,19 @@ void TableDesignPane::updateLayout()
 
 			const long nStylesHeight = aPaneSize.Height() - nOptionsHeight;
 
-			// set with of controls to size of pane
+			// set width of controls to size of pane
 			for( sal_Int32 nId = 0; nId < DESIGNPANE_CONTROL_COUNT; ++nId )
 			{
-				Size aSize( mxControls[nId]->GetSizePixel() );
-				aSize.Width() = aPaneSize.Width() - aOffset.X() - mxControls[nId]->GetPosPixel().X();
-				mxControls[nId]->SetSizePixel( aSize );
-				mxControls[nId]->SetPaintTransparent(sal_True);
-				mxControls[nId]->SetBackground();
+                if (mxControls[nId])
+                {
+                    Size aSize( mxControls[nId]->GetSizePixel() );
+                    aSize.Width() = aPaneSize.Width() - aOffset.X() - mxControls[nId]->GetPosPixel().X();
+                    mxControls[nId]->SetSizePixel( aSize );
+                    mxControls[nId]->SetPaintTransparent(sal_True);
+                    mxControls[nId]->SetBackground();
+                }
 			}
-			aValueSetSize = Size( pValueSet->GetSizePixel().Width(), nStylesHeight - mxControls[FL_TABLE_STYLES]->GetSizePixel().Height() - mnOrgOffsetY[FL_TABLE_STYLES]  );
+			aValueSetSize = Size( pValueSet->GetSizePixel().Width(), nStylesHeight  );
 		}
 		else
 		{
@@ -449,18 +513,22 @@ void TableDesignPane::updateLayout()
 
 			// shift show options section down
 			const long nOptionsPos = aPos.Y() + aValueSetSize.Height();
-			for( sal_Int32 nId = FL_STYLE_OPTIONS; nId <= CB_BANDED_COLUMNS; ++nId )
+            sal_Int32 nMaxY (0);
+			for( sal_Int32 nId = FL_STYLE_OPTIONS+1; nId <= CB_BANDED_COLUMNS; ++nId )
 			{
-				Point aCPos( mxControls[nId]->GetPosPixel() );
-				aCPos.X() = ( nId == FL_STYLE_OPTIONS ?  1 : 2 ) * aOffset.X();
-				aCPos.Y() = mnOrgOffsetY[nId] + nOptionsPos;
-				mxControls[nId]->SetPosPixel( aCPos );
+                if (mxControls[nId])
+                {
+                    Point aCPos( mxControls[nId]->GetPosPixel() );
+                    aCPos.X() = ( nId == FL_STYLE_OPTIONS ?  1 : 2 ) * aOffset.X();
+                    aCPos.Y() = mnOrgOffsetY[nId] + nOptionsPos;
+                    mxControls[nId]->SetPosPixel( aCPos );
+                    const sal_Int32 nBottom (aCPos.Y() + mxControls[nId]->GetSizePixel().Height());
+                    if (nBottom > nMaxY)
+                        nMaxY = nBottom;
+                }
 			}
 		}
     }
-
-	if( !mbModal )
-		SetBackground( GetSettings().GetStyleSettings().GetWindowColor() );
 }
 
 // --------------------------------------------------------------------

Modified: openoffice/branches/sidebar/main/sd/source/ui/table/TableDesignPane.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sd/source/ui/table/TableDesignPane.hxx?rev=1465588&r1=1465587&r2=1465588&view=diff
==============================================================================
--- openoffice/branches/sidebar/main/sd/source/ui/table/TableDesignPane.hxx (original)
+++ openoffice/branches/sidebar/main/sd/source/ui/table/TableDesignPane.hxx Mon Apr  8 10:59:21 2013
@@ -26,6 +26,7 @@
 
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/ui/XUIElement.hpp>
+#include <com/sun/star/ui/LayoutSize.hpp>
 #include <com/sun/star/drawing/XDrawView.hpp>
 #include <com/sun/star/container/XIndexAccess.hpp>
 
@@ -33,6 +34,7 @@
 #include <vcl/fixed.hxx>
 #include <vcl/button.hxx>
 #include <svtools/valueset.hxx>
+#include <sfx2/sidebar/ILayoutableWindow.hxx>
 
 #include <boost/scoped_ptr.hpp>
 
@@ -49,7 +51,7 @@ class ViewShellBase;
 
 // --------------------------------------------------------------------
 
-class TableDesignPane : public Control
+class TableDesignPane : public Control, public sfx2::sidebar::ILayoutableWindow
 {
 public:
 	TableDesignPane( ::Window* pParent, ViewShellBase& rBase, bool bModal );
@@ -61,6 +63,9 @@ public:
 	// Control
 	virtual void Resize();
 
+    // ILayoutableWindow
+    virtual ::com::sun::star::ui::LayoutSize GetHeightForWidth (const sal_Int32 nWidth);
+
     virtual void    DataChanged( const DataChangedEvent& rDCEvt );
 
 	void ApplyOptions();

Modified: openoffice/branches/sidebar/main/sd/source/ui/table/TableDesignPane.src
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sd/source/ui/table/TableDesignPane.src?rev=1465588&r1=1465587&r2=1465588&view=diff
==============================================================================
--- openoffice/branches/sidebar/main/sd/source/ui/table/TableDesignPane.src (original)
+++ openoffice/branches/sidebar/main/sd/source/ui/table/TableDesignPane.src Mon Apr  8 10:59:21 2013
@@ -30,7 +30,7 @@ Control DLG_TABLEDESIGNPANE
 	DialogControl = TRUE;
 	Border = FALSE;
 
-	Size = MAP_APPFONT( 264, 160 );
+	Size = MAP_APPFONT( 264, 134 );
 	Text [ en-US ] = "Table Design";
 	
 	FixedLine FL_STYLE_OPTIONS+1
@@ -43,7 +43,7 @@ Control DLG_TABLEDESIGNPANE
 	
 	CheckBox CB_HEADER_ROW+1
 	{
-        Pos = MAP_APPFONT ( 146, 16 ) ;
+        Pos = MAP_APPFONT ( 146, 3 ) ;
         Size = MAP_APPFONT ( 120 , 10 ) ;
 		TabStop = TRUE ;
 		Text [ en-US ] = "Header Row" ;	
@@ -51,7 +51,7 @@ Control DLG_TABLEDESIGNPANE
 	
 	CheckBox CB_TOTAL_ROW+1
 	{
-        Pos = MAP_APPFONT ( 146, 29 ) ;
+        Pos = MAP_APPFONT ( 146, 16 ) ;
         Size = MAP_APPFONT ( 120 , 10 ) ;
 		TabStop = TRUE ;
 		Text [ en-US ] = "Total Row" ;	
@@ -59,7 +59,7 @@ Control DLG_TABLEDESIGNPANE
 	
 	CheckBox CB_BANDED_ROWS+1
 	{
-        Pos = MAP_APPFONT ( 146, 42 ) ;
+        Pos = MAP_APPFONT ( 146, 29 ) ;
         Size = MAP_APPFONT ( 120 , 10 ) ;
 		TabStop = TRUE ;
 		Text [ en-US ] = "Banded Rows" ;	
@@ -67,7 +67,7 @@ Control DLG_TABLEDESIGNPANE
 
 	CheckBox CB_FIRST_COLUMN+1
 	{
-        Pos = MAP_APPFONT ( 146, 55 ) ;
+        Pos = MAP_APPFONT ( 146, 42 ) ;
         Size = MAP_APPFONT ( 120 , 10 ) ;
 		TabStop = TRUE ;
 		Text [ en-US ] = "First Column" ;	
@@ -75,7 +75,7 @@ Control DLG_TABLEDESIGNPANE
 
 	CheckBox CB_LAST_COLUMN+1
 	{
-        Pos = MAP_APPFONT ( 146, 68 ) ;
+        Pos = MAP_APPFONT ( 146, 55 ) ;
         Size = MAP_APPFONT ( 120 , 10 ) ;
 		TabStop = TRUE ;
 		Text [ en-US ] = "Last Column" ;	
@@ -83,7 +83,7 @@ Control DLG_TABLEDESIGNPANE
 
 	CheckBox CB_BANDED_COLUMNS+1
 	{
-        Pos = MAP_APPFONT ( 146, 82 ) ;
+        Pos = MAP_APPFONT ( 146, 68 ) ;
         Size = MAP_APPFONT ( 120 , 10 ) ;
 		TabStop = TRUE ;
 		Text [ en-US ] = "Banded Columns" ;	
@@ -99,7 +99,7 @@ Control DLG_TABLEDESIGNPANE
 	
 	Control CT_TABLE_STYLES+1
 	{
-        Pos = MAP_APPFONT ( 6, 14 ) ;
+        Pos = MAP_APPFONT ( 4, 3 ) ;
 		Size = MAP_APPFONT( 120, 143 );
 		Border = TRUE ;
 		TabStop = TRUE ;