[Libreoffice-commits] .: Branch 'libreoffice-3-5' - sfx2/source

Caolán McNamara caolan at kemper.freedesktop.org
Thu Mar 8 09:15:46 PST 2012


 sfx2/source/dialog/dinfdlg.cxx |   95 +++++++++++++++++++++++++----------------
 1 file changed, 60 insertions(+), 35 deletions(-)

New commits:
commit cc58c49eb492e4515e058ba1ce43378d976d9953
Author: William Gathoye <william at gathoye.be>
Date:   Tue Feb 28 11:55:29 2012 +0100

    Fix controls size and position on the document information dialog
    (cherry picked from commit 21d85dabe5d780571ad8ca39c8e6d30be90a0bf4)
    
    Signed-off-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
index df7f963..e812d52 100644
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -828,46 +828,71 @@ SfxDocumentPage::SfxDocumentPage( Window* pParent, const SfxItemSet& rItemSet )
     bHandleDelete       ( sal_False )
 
 {
-    aNameED.SetAccessibleName(String(SfxResId(EDIT_FILE_NAME)));
+    aNameED.SetAccessibleName( String( SfxResId( EDIT_FILE_NAME ) ) );
     FreeResource();
-
     ImplUpdateSignatures();
     ImplCheckPasswordState();
-    aDeleteBtn.SetClickHdl( LINK( this, SfxDocumentPage, DeleteHdl ) );
-    aSignatureBtn.SetClickHdl( LINK( this, SfxDocumentPage, SignatureHdl ) );
     aChangePassBtn.SetClickHdl( LINK( this, SfxDocumentPage, ChangePassHdl ) );
+    aSignatureBtn.SetClickHdl( LINK( this, SfxDocumentPage, SignatureHdl ) );
+    aDeleteBtn.SetClickHdl( LINK( this, SfxDocumentPage, DeleteHdl ) );
 
-    // if the button text is too wide, then broaden it
-    const long nOffset = 12;
-    String sText = aSignatureBtn.GetText();
-    long nTxtW = aSignatureBtn.GetTextWidth( sText );
-    if ( sText.Search( '~' ) == STRING_NOTFOUND )
-        nTxtW += nOffset;
-    long nBtnW = aSignatureBtn.GetSizePixel().Width();
-    if ( nTxtW >= nBtnW )
-    {
-        long nDelta = Max( nTxtW - nBtnW, nOffset/3 );
-        Size aNewSize = aSignatureBtn.GetSizePixel();
-        aNewSize.Width() += nDelta;
-        aSignatureBtn.SetSizePixel( aNewSize );
-        aDeleteBtn.SetSizePixel( aNewSize );
-        // and give them a new position
-        Point aNewPos = aSignatureBtn.GetPosPixel();
-        aNewPos.X() -= nDelta;
-        aSignatureBtn.SetPosPixel( aNewPos );
-        aNewPos = aDeleteBtn.GetPosPixel();
-        aNewPos.X() -= nDelta;
-        aDeleteBtn.SetPosPixel( aNewPos );
-
-        aNewSize = aSignedValFt.GetSizePixel();
-        aNewSize.Width() -= nDelta;
-        aSignedValFt.SetSizePixel( aNewSize );
-        aNewSize = aUseUserDataCB.GetSizePixel();
-        aNewSize.Width() -= nDelta;
-        aUseUserDataCB.SetSizePixel( aNewSize );
-    }
-    // See i96288
-    // Check if the document signature command is enabled
+    // Get the max size needed for the 'Change Password', 'Signature' and 'Delete' buttons
+    // and set their size according to this max size to get perfect aligment
+    long nTxtW = ( aChangePassBtn.GetTextWidth( aChangePassBtn.GetText() ) + IMPL_EXTRA_BUTTON_WIDTH );
+    nTxtW = Max( ( aSignatureBtn.GetTextWidth( aSignatureBtn.GetText() ) + IMPL_EXTRA_BUTTON_WIDTH ), nTxtW);
+    nTxtW = Max( ( aDeleteBtn.GetTextWidth( aDeleteBtn.GetText() ) + IMPL_EXTRA_BUTTON_WIDTH ), nTxtW);
+
+    // New size and position for the 'Change Password' button
+    Size aNewSize = aChangePassBtn.GetSizePixel();
+    long nDelta = nTxtW - aNewSize.Width();
+    aNewSize.Width() = nTxtW;
+    aChangePassBtn.SetSizePixel( aNewSize );
+    Point aNewPos = aChangePassBtn.GetPosPixel();
+    aNewPos.X() -= nDelta;
+    aChangePassBtn.SetPosPixel( aNewPos );
+
+    // Calculate the space between the bmp image and the 'Change password' button
+    nDelta = aNewPos.X() - IMPL_EXTRA_BUTTON_WIDTH / 2 \
+             - ( aBmp1.GetPosPixel().X() + aBmp1.GetSizePixel().Width() );
+
+    // Reduces the filename field size if space size is not large enough
+    aNewSize = aNameED.GetSizePixel();
+    if ( nDelta - aNewSize.Width() < IMPL_EXTRA_BUTTON_WIDTH )
+    {
+        aNewSize.Width() -= IMPL_EXTRA_BUTTON_WIDTH - ( nDelta - aNewSize.Width() );
+        aNameED.SetSizePixel( aNewSize );
+    }
+
+    // Centers the filename field in the space
+    aNewPos = aNameED.GetPosPixel();
+    nDelta -= aNewSize.Width();
+    aNewPos.X() = aBmp1.GetPosPixel().X() + aBmp1.GetSizePixel().Width() + nDelta / 2;
+    aNameED.SetPosPixel( aNewPos );
+
+    // New size and position for the 'Signature' button
+    aNewSize = aSignatureBtn.GetSizePixel();
+    nDelta = nTxtW - aNewSize.Width();
+    aNewSize.Width() = nTxtW;
+    aSignatureBtn.SetSizePixel( aNewSize );
+    aNewPos = aSignatureBtn.GetPosPixel();
+    aNewPos.X() -= nDelta;
+    aSignatureBtn.SetPosPixel( aNewPos );
+
+    // New size for the signature field
+    aNewSize = aSignedValFt.GetSizePixel();
+    aNewSize.Width() -= nDelta;
+    aSignedValFt.SetSizePixel( aNewSize );
+
+    // New size and position for the 'Delete' button
+    aNewSize = aDeleteBtn.GetSizePixel();
+    nDelta = nTxtW - aNewSize.Width();
+    aNewSize.Width() = nTxtW;
+    aDeleteBtn.SetSizePixel( aNewSize );
+    aNewPos = aDeleteBtn.GetPosPixel();
+    aNewPos.X() -= nDelta;
+    aDeleteBtn.SetPosPixel( aNewPos );
+
+    // [i96288] Check if the document signature command is enabled
     // on the main list enable/disable the pushbutton accordingly
     SvtCommandOptions aCmdOptions;
     if ( aCmdOptions.Lookup( SvtCommandOptions::CMDOPTION_DISABLED,


More information about the Libreoffice-commits mailing list