[Libreoffice-commits] core.git: 2 commits - sw/source

Caolán McNamara caolanm at redhat.com
Thu Sep 24 17:20:53 PDT 2015


 sw/source/ui/frmdlg/column.cxx    |   46 +++++++++++++++++++++++-----
 sw/source/uibase/frmdlg/colex.cxx |   61 ++++++++++++++++++++++++++++++--------
 2 files changed, 87 insertions(+), 20 deletions(-)

New commits:
commit 589143bc486058e42df5484c111df38c236bc9b7
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Sep 25 00:41:21 2015 +0100

    hackfect 2015: vertical text columns need page height not width
    
    the "width" of columns for preview of vertical text is not
    based on on the width of the host page, but the height of the host page
    
    Change-Id: I1f1e611f251760bbb9b095839214289bcbd6492a

diff --git a/sw/source/ui/frmdlg/column.cxx b/sw/source/ui/frmdlg/column.cxx
index ead5720..c6d2f35 100644
--- a/sw/source/ui/frmdlg/column.cxx
+++ b/sw/source/ui/frmdlg/column.cxx
@@ -1217,17 +1217,41 @@ void SwColumnPage::Update(MetricField *pInteractiveField)
 // Update Bsp
 void SwColumnPage::ActivatePage(const SfxItemSet& rSet)
 {
-    if(!bFrm)
+    bool bVertical = false;
+    if (SfxItemState::DEFAULT <= rSet.GetItemState(RES_FRAMEDIR, true))
+    {
+        const SvxFrameDirectionItem& rDirItem =
+                    static_cast<const SvxFrameDirectionItem&>(rSet.Get(RES_FRAMEDIR));
+        bVertical = rDirItem.GetValue() == FRMDIR_VERT_TOP_RIGHT||
+                    rDirItem.GetValue() == FRMDIR_VERT_TOP_LEFT;
+    }
+
+    if (!bFrm)
     {
         if( SfxItemState::SET == rSet.GetItemState( SID_ATTR_PAGE_SIZE ))
         {
             const SvxSizeItem& rSize = static_cast<const SvxSizeItem&>(rSet.Get(
                                                 SID_ATTR_PAGE_SIZE));
-            const SvxLRSpaceItem& rLRSpace = static_cast<const SvxLRSpaceItem&>(rSet.Get(
-                                                                RES_LR_SPACE ));
-            const SvxBoxItem& rBox = static_cast<const SvxBoxItem&>( rSet.Get(RES_BOX));
-            const sal_uInt16 nActWidth = static_cast< sal_uInt16 >(rSize.GetSize().Width()
-                            - rLRSpace.GetLeft() - rLRSpace.GetRight() - rBox.GetDistance());
+
+            sal_uInt16 nActWidth;
+
+            if (!bVertical)
+            {
+                const SvxLRSpaceItem& rLRSpace = static_cast<const SvxLRSpaceItem&>(rSet.Get(
+                                                                    RES_LR_SPACE ));
+                const SvxBoxItem& rBox = static_cast<const SvxBoxItem&>( rSet.Get(RES_BOX));
+                nActWidth = rSize.GetSize().Width()
+                                - rLRSpace.GetLeft() - rLRSpace.GetRight() - rBox.GetDistance();
+            }
+            else
+            {
+                const SvxULSpaceItem& rULSpace = static_cast<const SvxULSpaceItem&>(rSet.Get(
+                                                                    RES_UL_SPACE ));
+                const SvxBoxItem& rBox = static_cast<const SvxBoxItem&>( rSet.Get(RES_BOX));
+                nActWidth = rSize.GetSize().Height()
+                                - rULSpace.GetUpper() - rULSpace.GetLower() - rBox.GetDistance();
+
+            }
 
             if( pColMgr->GetActualSize() != nActWidth)
             {
@@ -1250,8 +1274,14 @@ void SwColumnPage::ActivatePage(const SfxItemSet& rSet)
         const SwFormatFrmSize& rSize = static_cast<const SwFormatFrmSize&>(rSet.Get(RES_FRM_SIZE));
         const SvxBoxItem& rBox = static_cast<const SvxBoxItem&>( rSet.Get(RES_BOX));
 
-        long nDistance = rBox.GetDistance();
-        const sal_uInt16 nTotalWish = bFormat ? FRAME_FORMAT_WIDTH : sal_uInt16(rSize.GetWidth() - 2 * nDistance);
+        sal_uInt16 nTotalWish;
+        if (bFormat)
+            nTotalWish = FRAME_FORMAT_WIDTH;
+        else
+        {
+            long nDistance = rBox.GetDistance();
+            nTotalWish = (!bVertical ? rSize.GetWidth() : rSize.GetHeight()) - 2 * nDistance;
+        }
 
         // set maximum values of column width
         SetPageWidth(nTotalWish);
commit f697e020e8af5dbe31148858ee4dbd26c58bb7de
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Sep 24 17:39:02 2015 +0100

    hackfest 2015: show vertical columns for vertical text layout
    
    for vertical text layout the preview needs to show columns
    across the page not down the page
    
    Change-Id: Iead153923a8a1242d08e7f082e5e3c987ebd46fa

diff --git a/sw/source/uibase/frmdlg/colex.cxx b/sw/source/uibase/frmdlg/colex.cxx
index 1bf1963..f0f9047 100644
--- a/sw/source/uibase/frmdlg/colex.cxx
+++ b/sw/source/uibase/frmdlg/colex.cxx
@@ -274,33 +274,61 @@ void SwColExample::DrawPage(vcl::RenderContext& rRenderContext, const Point& rOr
     {
         if (!bAutoWidth)
             nAutoColWidth = pColMgr->GetColWidth(i);
-        aRect.Right() = aRect.Left() + nAutoColWidth;
+
+        if (!m_bVertical)
+            aRect.Right() = aRect.Left() + nAutoColWidth;
+        else
+            aRect.Bottom() = aRect.Top() + nAutoColWidth;
 
         //UUUU use primitive draw command
         drawFillAttributes(rRenderContext, getPageFillAttributes(), aRect, aDefineRect);
 
         if (i < nColumnCount - 1)
-            aRect.Left() = aRect.Right() + pColMgr->GetGutterWidth(i);
+        {
+            if (!m_bVertical)
+                aRect.Left() = aRect.Right() + pColMgr->GetGutterWidth(i);
+            else
+                aRect.Top() = aRect.Bottom() + pColMgr->GetGutterWidth(i);
+        }
     }
     if (pColMgr->HasLine())
     {
         Point aUp(rOrg.X() + nL, rOrg.Y() + GetTop());
         Point aDown(rOrg.X() + nL,
-                    rOrg.Y() + GetSize().Height() - GetBottom() - GetFtHeight() - GetFtDist());
+                        rOrg.Y() + GetSize().Height() - GetBottom() - GetFtHeight() - GetFtDist());
 
         if (pColMgr->GetLineHeightPercent() != 100)
         {
-            long nLength = aDown.Y() - aUp.Y();
+            long nLength = !m_bVertical ? aDown.Y() - aUp.Y() : aDown.X() - aUp.X();
             nLength -= nLength * pColMgr->GetLineHeightPercent() / 100;
             switch (pColMgr->GetAdjust())
             {
-                case COLADJ_BOTTOM: aUp.Y() += nLength; break;
-                case COLADJ_TOP: aDown.Y() -= nLength; break;
+                case COLADJ_BOTTOM:
+                    if (!m_bVertical)
+                        aUp.Y() += nLength;
+                    else
+                        aUp.X() += nLength;
+                    break;
+                case COLADJ_TOP:
+                    if (!m_bVertical)
+                        aDown.Y() -= nLength;
+                    else
+                        aDown.X() -= nLength;
+                    break;
                 case COLADJ_CENTER:
-                    aUp.Y() += nLength / 2;
-                    aDown.Y() -= nLength / 2;
-                break;
-                default:; // prevent warning
+                    if (!m_bVertical)
+                    {
+                        aUp.Y() += nLength / 2;
+                        aDown.Y() -= nLength / 2;
+                    }
+                    else
+                    {
+                        aUp.X() += nLength / 2;
+                        aDown.X() -= nLength / 2;
+                    }
+                    break;
+                default:
+                    break; // prevent warning
             }
         }
 
@@ -309,8 +337,17 @@ void SwColExample::DrawPage(vcl::RenderContext& rRenderContext, const Point& rOr
             int nGutter = pColMgr->GetGutterWidth(i);
             int nDist = pColMgr->GetColWidth( i ) + nGutter;
             nDist -= (i == 0) ? nGutter / 2 : 0;
-            aUp.X() += nDist;
-            aDown.X() += nDist;
+            if (!m_bVertical)
+            {
+                aUp.X() += nDist;
+                aDown.X() += nDist;
+            }
+            else
+            {
+                aUp.Y() += nDist;
+                aDown.Y() += nDist;
+            }
+
             rRenderContext.DrawLine(aUp, aDown);
         }
     }


More information about the Libreoffice-commits mailing list