[Libreoffice-commits] .: 2 commits - oovbaapi/ooo sc/inc sc/source svl/inc svl/source vbahelper/source

Noel Power noelp at kemper.freedesktop.org
Tue Apr 17 06:30:36 PDT 2012


 oovbaapi/ooo/vba/msforms/XControl.idl   |    1 
 sc/inc/cellform.hxx                     |    4 +
 sc/source/core/tool/cellform.cxx        |    5 +
 sc/source/ui/view/output2.cxx           |   43 +++++++++++++++-
 svl/inc/svl/zforlist.hxx                |    4 -
 svl/source/numbers/zforlist.cxx         |   16 ++++--
 vbahelper/source/msforms/vbacontrol.cxx |   84 +++++++++++++++++++++++++++++++-
 vbahelper/source/msforms/vbacontrol.hxx |    2 
 8 files changed, 146 insertions(+), 13 deletions(-)

New commits:
commit 46e18bc915ac94a81462642cc9d56d29c04d0c46
Author: Noel Power <noel.power at novell.com>
Date:   Mon Apr 16 16:20:51 2012 +0100

    enable '*' repeat next char to fill available width for calc num formats
    
    but - however no support to import/export this to file format yet

diff --git a/sc/inc/cellform.hxx b/sc/inc/cellform.hxx
index cdfa09c..3a5418d 100644
--- a/sc/inc/cellform.hxx
+++ b/sc/inc/cellform.hxx
@@ -53,7 +53,9 @@ public:
                                Color** ppColor, SvNumberFormatter& rFormatter,
                                sal_Bool bNullVals = sal_True,
                                sal_Bool bFormula  = false,
-                               ScForceTextFmt eForceTextFmt = ftDontForce );
+                               ScForceTextFmt eForceTextFmt = ftDontForce,
+                               bool bUseStarFormat = false );
+
 
     static void     GetInputString( ScBaseCell* pCell, sal_uLong nFormat, rtl::OUString& rString,
                                       SvNumberFormatter& rFormatter );
diff --git a/sc/source/core/tool/cellform.cxx b/sc/source/core/tool/cellform.cxx
index f33a48c..0da6866 100644
--- a/sc/source/core/tool/cellform.cxx
+++ b/sc/source/core/tool/cellform.cxx
@@ -49,7 +49,8 @@ void ScCellFormat::GetString( ScBaseCell* pCell, sal_uLong nFormat, rtl::OUStrin
                               Color** ppColor, SvNumberFormatter& rFormatter,
                               sal_Bool bNullVals,
                               sal_Bool bFormula,
-                              ScForceTextFmt eForceTextFmt )
+                              ScForceTextFmt eForceTextFmt,
+                              bool bUseStarFormat )
 {
     *ppColor = NULL;
     if (&rFormatter==NULL)
@@ -92,7 +93,7 @@ void ScCellFormat::GetString( ScBaseCell* pCell, sal_uLong nFormat, rtl::OUStrin
                         rFormatter.GetOutputString( aTemp, nFormat, rString, ppColor );
                     }
                     else
-                        rFormatter.GetOutputString( nValue, nFormat, rString, ppColor );
+                        rFormatter.GetOutputString( nValue, nFormat, rString, ppColor, bUseStarFormat );
                 }
             }
             break;
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 2b99bb8..6c616eb 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -128,6 +128,8 @@ class ScDrawStringsVars
 
     Color               aBackConfigColor;       // used for ScPatternAttr::GetFont calls
     Color               aTextConfigColor;
+    sal_Int32           nPos;
+    sal_Unicode         nChar;
 
 public:
                 ScDrawStringsVars(ScOutputData* pData, sal_Bool bPTL);
@@ -162,6 +164,7 @@ public:
     sal_Bool    GetLineBreak() const                    { return bLineBreak; }
     sal_Bool    IsRepeat() const                        { return bRepeat; }
     sal_Bool    IsShrink() const                        { return bShrink; }
+    void        RepeatToFill( long colWidth );
 
     long    GetAscent() const   { return nAscentPixel; }
     sal_Bool    IsRotated() const   { return bRotated; }
@@ -206,7 +209,9 @@ ScDrawStringsVars::ScDrawStringsVars(ScOutputData* pData, sal_Bool bPTL) :
     bLineBreak  ( false ),
     bRepeat     ( false ),
     bShrink     ( false ),
-    bPixelToLogic( bPTL )
+    bPixelToLogic( bPTL ),
+    nPos( STRING_NOTFOUND ),
+    nChar( 0x0 )
 {
     ScModule* pScMod = SC_MOD();
     bCellContrast = pOutput->bUseStyleColor &&
@@ -502,9 +507,19 @@ sal_Bool ScDrawStringsVars::SetText( ScBaseCell* pCell )
                                      *pOutput->pDoc->GetFormatTable(),
                                      pOutput->bShowNullValues,
                                      pOutput->bShowFormulas,
-                                     ftCheck );
+                                     ftCheck, true );
             aString = aOUString;
-
+            if ( nFormat )
+            {
+                nPos = aString.Search( 0x1B );
+                if ( nPos != STRING_NOTFOUND )
+                {
+                    nPos = nPos - 1;
+                    nChar = aString.GetChar( nPos );
+                    // delete placeholder and char to repeat
+                    aString.Erase( nPos, 2 );
+                }
+            }
             if (aString.Len() > DRAWTEXT_MAX)
                 aString.Erase(DRAWTEXT_MAX);
 
@@ -537,6 +552,27 @@ void ScDrawStringsVars::SetHashText()
     SetAutoText( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("###")) );
 }
 
+void ScDrawStringsVars::RepeatToFill( long colWidth )
+{
+    if ( nPos ==  STRING_NOTFOUND || nPos >= aString.Len() )
+        return;
+
+    long charWidth = pOutput->pFmtDevice->GetTextWidth(String(nChar));
+    if (bPixelToLogic)
+        colWidth = pOutput->pRefDevice->PixelToLogic(Size(colWidth,0)).Width();
+    // Are there restrictions on the cell type we should filter out here ?
+    long aSpaceToFill = ( colWidth - aTextSize.Width() );
+
+    if ( aSpaceToFill <= charWidth )
+        return;
+
+    long nCharsToInsert = aSpaceToFill / charWidth;
+    for ( int i = 0; i < nCharsToInsert; ++i )
+        aString.Insert( nChar, nPos );
+
+    TextChanged();
+}
+
 void ScDrawStringsVars::SetTextToWidthOrHash( ScBaseCell* pCell, long nWidth )
 {
     // #i113045# do the single-character width calculations in logic units
@@ -1618,6 +1654,7 @@ void ScOutputData::DrawStrings( sal_Bool bPixelToLogic )
                                    bCellIsValue || bRepeat || bShrink, bBreak, false,
                                    aAreaParam );
 
+                    aVars.RepeatToFill( aAreaParam.mnColWidth - nTotalMargin );
                     if ( bShrink )
                     {
                         if ( aVars.GetOrient() != SVX_ORIENTATION_STANDARD )
diff --git a/svl/inc/svl/zforlist.hxx b/svl/inc/svl/zforlist.hxx
index 1249250..7f2a7ff 100644
--- a/svl/inc/svl/zforlist.hxx
+++ b/svl/inc/svl/zforlist.hxx
@@ -483,11 +483,11 @@ public:
 
     /// Format a number according to a format index, return string and color
     void GetOutputString( const double& fOutNumber, sal_uInt32 nFIndex,
-                          String& sOutString, Color** ppColor );
+                          String& sOutString, Color** ppColor, bool bUseStarFormat = false );
 
     /// Format a number according to a format index, return string and color
     void GetOutputString( const double& fOutNumber, sal_uInt32 nFIndex,
-                          rtl::OUString& sOutString, Color** ppColor );
+                          rtl::OUString& sOutString, Color** ppColor, bool bUseStarFormat = false );
 
     /** Format a string according to a format index, return string and color.
         Formats only if the format code is of type text or the 4th subcode
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index 5a6848c..d897274 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -1546,7 +1546,8 @@ void SvNumberFormatter::GetInputLineString(const double& fOutNumber,
 void SvNumberFormatter::GetOutputString(const double& fOutNumber,
                                         sal_uInt32 nFIndex,
                                         String& sOutString,
-                                        Color** ppColor)
+                                        Color** ppColor,
+                                        bool bUseStarFormat )
 {
     if (bNoZero && fOutNumber == 0.0)
     {
@@ -1557,13 +1558,17 @@ void SvNumberFormatter::GetOutputString(const double& fOutNumber,
     if (!pFormat)
         pFormat = GetFormatEntry(ZF_STANDARD);
     ChangeIntl(pFormat->GetLanguage());
+    if ( bUseStarFormat )
+        pFormat->SetStarFormatSupport( true );
     pFormat->GetOutputString(fOutNumber, sOutString, ppColor);
+    if ( bUseStarFormat )
+        pFormat->SetStarFormatSupport( false );
 }
 
 void SvNumberFormatter::GetOutputString(String& sString,
                                         sal_uInt32 nFIndex,
                                         String& sOutString,
-                                        Color** ppColor)
+                                        Color** ppColor )
 {
     SvNumberformat* pFormat = GetFormatEntry( nFIndex );
     if (!pFormat)
@@ -1583,7 +1588,8 @@ void SvNumberFormatter::GetOutputString(String& sString,
 void SvNumberFormatter::GetOutputString(const double& fOutNumber,
                                         sal_uInt32 nFIndex,
                                         rtl::OUString& sOutString,
-                                        Color** ppColor)
+                                        Color** ppColor,
+                                        bool bUseStarFormat )
 {
     if (bNoZero && fOutNumber == 0.0)
     {
@@ -1595,7 +1601,11 @@ void SvNumberFormatter::GetOutputString(const double& fOutNumber,
         pFormat = GetFormatEntry(ZF_STANDARD);
     ChangeIntl(pFormat->GetLanguage());
     String aOutString;
+    if ( bUseStarFormat )
+        pFormat->SetStarFormatSupport( true );
     pFormat->GetOutputString(fOutNumber, aOutString, ppColor);
+    if ( bUseStarFormat )
+        pFormat->SetStarFormatSupport( false );
     sOutString = aOutString;
 }
 
commit f39d0b837742c69488e43e919f7f1a927c2859ed
Author: Noel Power <noel.power at novell.com>
Date:   Thu Apr 5 14:17:24 2012 +0100

    add support for MousePointer attribute in controls
    
    For Useforms it doesn't quite work exactly as MSO, for examply if we set the MousePointer for the Userform it works as expected until we mouse over another control at which point the mouse pointer is changed to that of the control. In MSO it would appear that the Userform mousepointer is king, perhaps all that is necessary is to apply the mouse pointer to each contained control, needs some investigation. Also only a limited number of the possible mouse pointer styles are processed, the conversions of mso -> lo pointer styles ( and vice-versa ) and not really tested to see if they all make sense

diff --git a/oovbaapi/ooo/vba/msforms/XControl.idl b/oovbaapi/ooo/vba/msforms/XControl.idl
index 5ece205..9f2c6ee 100644
--- a/oovbaapi/ooo/vba/msforms/XControl.idl
+++ b/oovbaapi/ooo/vba/msforms/XControl.idl
@@ -44,6 +44,7 @@ interface XControl
     [attribute] string RowSource;
     [attribute] boolean Enabled;
     [attribute] boolean Visible;
+    [attribute] long MousePointer;
     //Size. there are some defferent between Mso and OOo.
     //Mso use double but OOo use long. OOo 1 =  1/100mm but Mso use pt.
     //in Dialogs Mso uses pixels
diff --git a/vbahelper/source/msforms/vbacontrol.cxx b/vbahelper/source/msforms/vbacontrol.cxx
index f092f17..caf5491 100644
--- a/vbahelper/source/msforms/vbacontrol.cxx
+++ b/vbahelper/source/msforms/vbacontrol.cxx
@@ -44,6 +44,7 @@
 #include <com/sun/star/document/XCodeNameQuery.hpp>
 #include <com/sun/star/form/XChangeListener.hpp>
 #include <ooo/vba/XControlProvider.hpp>
+#include <ooo/vba/msforms/fmMousePointer.hpp>
 #ifdef VBA_OOBUILD_HACK
 #include <svtools/bindablecontrolhelper.hxx>
 #endif
@@ -64,8 +65,8 @@
 #include "vbasystemaxcontrol.hxx"
 #include "vbaimage.hxx"
 #include <vbahelper/helperdecl.hxx>
-
-
+#include <toolkit/helper/vclunohelper.hxx>
+#include <vcl/window.hxx>
 using namespace com::sun::star;
 using namespace ooo::vba;
 
@@ -422,6 +423,85 @@ void SAL_CALL ScVbaControl::setForeColor( ::sal_Int32 _forecolor ) throw (::com:
      m_xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TextColor" ) ), uno::makeAny( XLRGBToOORGB( _forecolor ) ) );
 }
 
+struct PointerStyles
+{
+   long msoPointerStyle;
+   PointerStyle loPointStyle;
+};
+
+// 1 -> 1 map of styles ( some dubious choices in there though )
+PointerStyles styles[] = {
+  /// assuming pointer default is Arrow
+  { msforms::fmMousePointer::fmMousePointerDefault, POINTER_ARROW },
+  { msforms::fmMousePointer::fmMousePointerArrow, POINTER_ARROW },
+  { msforms::fmMousePointer::fmMousePointerCross, POINTER_CROSS },
+  { msforms::fmMousePointer::fmMousePointerIBeam, POINTER_TEXT },
+  { msforms::fmMousePointer::fmMousePointerSizeNESW,  POINTER_AUTOSCROLL_NSWE   }, // #TODO not correct, need to check, need to find the right one
+  { msforms::fmMousePointer::fmMousePointerSizeNS,  POINTER_AUTOSCROLL_NS  },
+  { msforms::fmMousePointer::fmMousePointerSizeNWSE,  POINTER_AUTOSCROLL_NSWE  }, // #TODO not correct, need to check, need to find the right one
+  { msforms::fmMousePointer::fmMousePointerSizeWE,  POINTER_AUTOSCROLL_WE },
+  { msforms::fmMousePointer::fmMousePointerUpArrow, POINTER_WINDOW_NSIZE  },
+  { msforms::fmMousePointer::fmMousePointerHourGlass, POINTER_WAIT  },
+  { msforms::fmMousePointer::fmMousePointerNoDrop, POINTER_NOTALLOWED },
+  { msforms::fmMousePointer::fmMousePointerAppStarting, POINTER_WAIT },
+  { msforms::fmMousePointer::fmMousePointerHelp, POINTER_HELP },
+  { msforms::fmMousePointer::fmMousePointerSizeAll, POINTER_CROSS },
+  { msforms::fmMousePointer::fmMousePointerCustom, POINTER_ARROW }, // not supported I guess
+
+};
+
+long lcl_loPointerToMsoPointer( PointerStyle eType )
+{
+    long nRet = msforms::fmMousePointer::fmMousePointerDefault;
+    for ( int i = 0, nElems = SAL_N_ELEMENTS( styles ); i < nElems; ++i )
+    {
+        if ( styles[ i ].loPointStyle == eType )
+        {
+            nRet = styles[ i ].msoPointerStyle;
+            break;
+        }
+    }
+    return nRet;
+}
+
+Pointer lcl_msoPointerToLOPointer( long msoPointerStyle )
+{
+    Pointer aPointer( POINTER_ARROW );
+    for ( int i = 0, nElems = SAL_N_ELEMENTS( styles ); i < nElems; ++i )
+    {
+        if ( styles[ i ].msoPointerStyle == msoPointerStyle )
+        {
+            aPointer = Pointer( styles[ i ].loPointStyle );
+            break;
+         }
+    }
+    return aPointer;
+}
+
+::sal_Int32 SAL_CALL
+ScVbaControl::getMousePointer() throw (::com::sun::star::uno::RuntimeException)
+{
+    PointerStyle eType = POINTER_ARROW; // default ?
+    Window* pWindow = VCLUnoHelper::GetWindow( getWindowPeer() );
+    if ( pWindow )
+    {
+        eType = pWindow->GetPointer().GetStyle();
+    }
+    return lcl_loPointerToMsoPointer( eType );
+}
+
+void SAL_CALL
+ScVbaControl::setMousePointer( ::sal_Int32 _mousepointer ) throw (::com::sun::star::uno::RuntimeException)
+{
+    Window* pWindow = VCLUnoHelper::GetWindow( getWindowPeer() );
+    if ( pWindow )
+    {
+        Pointer aPointer( POINTER_ARROW );
+        aPointer = lcl_msoPointerToLOPointer( _mousepointer );
+        pWindow->SetPointer( aPointer );
+    }
+}
+
 void ScVbaControl::fireEvent( script::ScriptEvent& evt )
 {
     uno::Reference<lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_QUERY_THROW );
diff --git a/vbahelper/source/msforms/vbacontrol.hxx b/vbahelper/source/msforms/vbacontrol.hxx
index 7712980..871d9a6 100644
--- a/vbahelper/source/msforms/vbacontrol.hxx
+++ b/vbahelper/source/msforms/vbacontrol.hxx
@@ -107,6 +107,8 @@ public:
     virtual void SAL_CALL setTag( const ::rtl::OUString& aTag ) throw (css::uno::RuntimeException);
     virtual sal_Int32 SAL_CALL getTabIndex() throw (css::uno::RuntimeException);
     virtual void SAL_CALL setTabIndex( sal_Int32 nTabIndex ) throw (css::uno::RuntimeException);
+    virtual ::sal_Int32 SAL_CALL getMousePointer() throw (::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL setMousePointer( ::sal_Int32 _mousepointer ) throw (::com::sun::star::uno::RuntimeException);
     //remove resouce because ooo.vba.excel.XControl is a wrapper of com.sun.star.drawing.XControlShape
     virtual void removeResouce() throw( css::uno::RuntimeException );
     virtual ::sal_Int32 SAL_CALL getForeColor() throw (::com::sun::star::uno::RuntimeException);


More information about the Libreoffice-commits mailing list