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

Caolán McNamara caolanm at redhat.com
Thu Sep 3 03:14:29 PDT 2015


 sw/inc/fmtfsize.hxx                    |    5 ++++-
 sw/source/core/doc/doclay.cxx          |    4 ++--
 sw/source/core/draw/dflyobj.cxx        |    4 ++--
 sw/source/core/layout/atrfrm.cxx       |   20 ++++++++++----------
 sw/source/core/layout/fly.cxx          |    8 ++++----
 sw/source/core/layout/flycnt.cxx       |    4 ++--
 sw/source/core/layout/wsfrm.cxx        |    2 +-
 sw/source/filter/ww8/docxsdrexport.cxx |    1 +
 sw/source/ui/frmdlg/column.cxx         |    2 +-
 sw/source/ui/frmdlg/frmpage.cxx        |   14 +++++++-------
 sw/source/ui/frmdlg/wrap.cxx           |    4 ++--
 sw/source/uibase/shells/frmsh.cxx      |    4 ++--
 sw/source/uibase/shells/grfsh.cxx      |    8 ++++----
 13 files changed, 42 insertions(+), 38 deletions(-)

New commits:
commit da6dc61f03db45a50dd5e31c2ca808bdf7adf0ab
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Sep 3 11:11:01 2015 +0100

    0xFF is reserved in [Height|Width]Percent as a special flag
    
    no logic change here, just collect all the uses of 0xff, 0xFF, 255, 0xfe that
    are for this hackery together under SwFormatFrmSize::SYNCED
    
    Change-Id: I061da70962e410903aed94b62868dec1d61e54b9

diff --git a/sw/inc/fmtfsize.hxx b/sw/inc/fmtfsize.hxx
index 52804be..40cc4dd 100644
--- a/sw/inc/fmtfsize.hxx
+++ b/sw/inc/fmtfsize.hxx
@@ -89,8 +89,11 @@ public:
     void    SetHeight( const SwTwips nNew ) { m_aSize.Height() = nNew; }
     void    SetWidth ( const SwTwips nNew ) { m_aSize.Width()  = nNew; }
 
-    sal_uInt8    GetHeightPercent() const{ return m_nHeightPercent; }
+    enum PercentFlags { SYNCED = 0xff };
+    //0xff is reserved to indicate height is synced to width
+    sal_uInt8   GetHeightPercent() const{ return m_nHeightPercent; }
     sal_Int16   GetHeightPercentRelation() const { return m_eHeightPercentRelation;  }
+    //0xff is reserved to indicate width is synced to height
     sal_uInt8   GetWidthPercent() const { return m_nWidthPercent;  }
     sal_Int16   GetWidthPercentRelation() const { return m_eWidthPercentRelation;  }
     void    SetHeightPercent( sal_uInt8 n ) { m_nHeightPercent = n; }
diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx
index 214187c..dc42c5c 100644
--- a/sw/source/core/doc/doclay.cxx
+++ b/sw/source/core/doc/doclay.cxx
@@ -825,8 +825,8 @@ lcl_InsertLabel(SwDoc & rDoc, SwTextFormatColls *const pTextFormatCollTable,
                 pNewSet->Put( SwFormatHoriOrient( 0, text::HoriOrientation::CENTER ) );
 
                 aFrmSize = pOldFormat->GetFrmSize();
-                aFrmSize.SetWidthPercent( 0 );
-                aFrmSize.SetHeightPercent( 255 );
+                aFrmSize.SetWidthPercent(0);
+                aFrmSize.SetHeightPercent(SwFormatFrmSize::SYNCED);
                 pNewSet->Put( aFrmSize );
 
                 // Hard-set the attributes, because they could come from the Template
diff --git a/sw/source/core/draw/dflyobj.cxx b/sw/source/core/draw/dflyobj.cxx
index 8a4b261..f44ee9a 100644
--- a/sw/source/core/draw/dflyobj.cxx
+++ b/sw/source/core/draw/dflyobj.cxx
@@ -876,10 +876,10 @@ void SwVirtFlyDrawObj::NbcResize(const Point& rRef,
                 nRelWidth  = pRel->Prt().Width();
                 nRelHeight = pRel->Prt().Height();
             }
-            if ( aFrmSz.GetWidthPercent() && aFrmSz.GetWidthPercent() != 0xFF &&
+            if ( aFrmSz.GetWidthPercent() && aFrmSz.GetWidthPercent() != SwFormatFrmSize::SYNCED &&
                  aOldFrmSz.GetWidth() != aFrmSz.GetWidth() )
                 aFrmSz.SetWidthPercent( sal_uInt8(aSz.Width() * 100.0 / nRelWidth + 0.5) );
-            if ( aFrmSz.GetHeightPercent() && aFrmSz.GetHeightPercent() != 0xFF &&
+            if ( aFrmSz.GetHeightPercent() && aFrmSz.GetHeightPercent() != SwFormatFrmSize::SYNCED &&
                  aOldFrmSz.GetHeight() != aFrmSz.GetHeight() )
                 aFrmSz.SetHeightPercent( sal_uInt8(aSz.Height() * 100.0 / nRelHeight + 0.5) );
             pFormat->GetDoc()->SetAttr( aFrmSz, *pFormat );
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index 65679b1..b131719 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -226,22 +226,22 @@ bool SwFormatFrmSize::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
         }
         break;
         case MID_FRMSIZE_REL_HEIGHT:
-            rVal <<= (sal_Int16)(GetHeightPercent() != 0xFF ? GetHeightPercent() : 0);
+            rVal <<= (sal_Int16)(GetHeightPercent() != SwFormatFrmSize::SYNCED ? GetHeightPercent() : 0);
         break;
         case MID_FRMSIZE_REL_HEIGHT_RELATION:
             rVal <<= GetHeightPercentRelation();
         break;
         case MID_FRMSIZE_REL_WIDTH:
-            rVal <<= (sal_Int16)(GetWidthPercent() != 0xFF ? GetWidthPercent() : 0);
+            rVal <<= (sal_Int16)(GetWidthPercent() != SwFormatFrmSize::SYNCED ? GetWidthPercent() : 0);
         break;
         case MID_FRMSIZE_REL_WIDTH_RELATION:
             rVal <<= GetWidthPercentRelation();
         break;
         case MID_FRMSIZE_IS_SYNC_HEIGHT_TO_WIDTH:
-            rVal <<= 0xFF == GetHeightPercent();
+            rVal <<= SwFormatFrmSize::SYNCED == GetHeightPercent();
         break;
         case MID_FRMSIZE_IS_SYNC_WIDTH_TO_HEIGHT:
-            rVal <<= 0xFF == GetWidthPercent();
+            rVal <<= SwFormatFrmSize::SYNCED == GetWidthPercent();
         break;
         case MID_FRMSIZE_WIDTH :
             rVal <<= (sal_Int32)convertTwipToMm100(m_aSize.Width());
@@ -297,7 +297,7 @@ bool SwFormatFrmSize::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
         {
             sal_Int16 nSet = 0;
             rVal >>= nSet;
-            if(nSet >= 0 && nSet <= 0xfe)
+            if(nSet >= 0 && nSet < SwFormatFrmSize::SYNCED)
                 SetHeightPercent((sal_uInt8)nSet);
             else
                 bRet = false;
@@ -314,7 +314,7 @@ bool SwFormatFrmSize::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
         {
             sal_Int16 nSet = 0;
             rVal >>= nSet;
-            if(nSet >= 0 && nSet <= 0xfe)
+            if(nSet >= 0 && nSet < SwFormatFrmSize::SYNCED)
                 SetWidthPercent((sal_uInt8)nSet);
             else
                 bRet = false;
@@ -331,8 +331,8 @@ bool SwFormatFrmSize::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
         {
             bool bSet = *static_cast<sal_Bool const *>(rVal.getValue());
             if(bSet)
-                SetHeightPercent(0xff);
-            else if( 0xff == GetHeightPercent() )
+                SetHeightPercent(SwFormatFrmSize::SYNCED);
+            else if( SwFormatFrmSize::SYNCED == GetHeightPercent() )
                 SetHeightPercent( 0 );
         }
         break;
@@ -340,8 +340,8 @@ bool SwFormatFrmSize::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
         {
             bool bSet = *static_cast<sal_Bool const *>(rVal.getValue());
             if(bSet)
-                SetWidthPercent(0xff);
-            else if( 0xff == GetWidthPercent() )
+                SetWidthPercent(SwFormatFrmSize::SYNCED);
+            else if( SwFormatFrmSize::SYNCED == GetWidthPercent() )
                 SetWidthPercent(0);
         }
         break;
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index 1d054b9..311cb61 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -2386,17 +2386,17 @@ Size SwFlyFrm::CalcRel( const SwFormatFrmSize &rSz ) const
             }
         }
 
-        if ( rSz.GetWidthPercent() && rSz.GetWidthPercent() != 0xFF )
+        if ( rSz.GetWidthPercent() && rSz.GetWidthPercent() != SwFormatFrmSize::SYNCED )
             aRet.Width() = nRelWidth * rSz.GetWidthPercent() / 100;
-        if ( rSz.GetHeightPercent() && rSz.GetHeightPercent() != 0xFF )
+        if ( rSz.GetHeightPercent() && rSz.GetHeightPercent() != SwFormatFrmSize::SYNCED )
             aRet.Height() = nRelHeight * rSz.GetHeightPercent() / 100;
 
-        if ( rSz.GetWidthPercent() == 0xFF )
+        if ( rSz.GetWidthPercent() == SwFormatFrmSize::SYNCED )
         {
             aRet.Width() *= aRet.Height();
             aRet.Width() /= rSz.GetHeight();
         }
-        else if ( rSz.GetHeightPercent() == 0xFF )
+        else if ( rSz.GetHeightPercent() == SwFormatFrmSize::SYNCED )
         {
             aRet.Height() *= aRet.Width();
             aRet.Height() /= rSz.GetWidth();
diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx
index f630bb0..5f045d5 100644
--- a/sw/source/core/layout/flycnt.cxx
+++ b/sw/source/core/layout/flycnt.cxx
@@ -345,7 +345,7 @@ void SwFlyAtCntFrm::MakeAll(vcl::RenderContext* pRenderContext)
             {
                 SwFlyFrameFormat *pFormat = GetFormat();
                 const SwFormatFrmSize &rFrmSz = GetFormat()->GetFrmSize();
-                if( rFrmSz.GetHeightPercent() != 0xFF &&
+                if( rFrmSz.GetHeightPercent() != SwFormatFrmSize::SYNCED &&
                     rFrmSz.GetHeightPercent() >= 100 )
                 {
                     pFormat->LockModify();
@@ -465,7 +465,7 @@ void SwFlyAtCntFrm::MakeAll(vcl::RenderContext* pRenderContext)
                         SwFrameFormat* pFormat = GetFormat();
                         const SwFormatFrmSize& rFrmSz = pFormat->GetFrmSize();
                         if ( rFrmSz.GetWidthPercent() &&
-                             rFrmSz.GetHeightPercent() == 0xFF )
+                             rFrmSz.GetHeightPercent() == SwFormatFrmSize::SYNCED )
                         {
                             SwFormatSurround aSurround( pFormat->GetSurround() );
                             if ( aSurround.GetSurround() == SURROUND_NONE )
diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index ae2fbc0..6c47b1a 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -3029,7 +3029,7 @@ static void InvaPercentFlys( SwFrm *pFrm, SwTwips nDiff )
                 bool bNotify = true;
                 // If we've a fly with more than 90% relative height...
                 if( rSz.GetHeightPercent() > 90 && pFly->GetAnchorFrm() &&
-                    rSz.GetHeightPercent() != 0xFF && nDiff )
+                    rSz.GetHeightPercent() != SwFormatFrmSize::SYNCED && nDiff )
                 {
                     const SwFrm *pRel = pFly->IsFlyLayFrm() ? pFly->GetAnchorFrm():
                                         pFly->GetAnchorFrm()->GetUpper();
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx
index d5773ca..3d2ba4c 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -1609,6 +1609,7 @@ void DocxSdrExport::writeDMLTextFrame(sw::Frame* pParentFrame, int nAnchorId, bo
                                 XML_relativeFrom, (rSize.GetHeightPercentRelation() == text::RelOrientation::PAGE_FRAME ? "page" : "margin"),
                                 FSEND);
             pFS->startElementNS(XML_wp14, XML_pctHeight, FSEND);
+            fprintf(stderr, "height pc is %d\n", rSize.GetHeightPercent());
             pFS->writeEscaped(OUString::number(rSize.GetHeightPercent() * oox::drawingml::PER_PERCENT));
             pFS->endElementNS(XML_wp14, XML_pctHeight);
             pFS->endElementNS(XML_wp14, XML_sizeRelV);
diff --git a/sw/source/ui/frmdlg/column.cxx b/sw/source/ui/frmdlg/column.cxx
index afc8515..bd2c1fa 100644
--- a/sw/source/ui/frmdlg/column.cxx
+++ b/sw/source/ui/frmdlg/column.cxx
@@ -1263,7 +1263,7 @@ void SwColumnPage::ActivatePage(const SfxItemSet& rSet)
         }
         bool bPercent;
         // only relative data in frame format
-        if ( bFormat || (rSize.GetWidthPercent() && rSize.GetWidthPercent() != 0xff) )
+        if ( bFormat || (rSize.GetWidthPercent() && rSize.GetWidthPercent() != SwFormatFrmSize::SYNCED) )
         {
             // set value for 100%
             aEd1.SetRefValue(nTotalWish);
diff --git a/sw/source/ui/frmdlg/frmpage.cxx b/sw/source/ui/frmdlg/frmpage.cxx
index 582537c..983d9a0 100644
--- a/sw/source/ui/frmdlg/frmpage.cxx
+++ b/sw/source/ui/frmdlg/frmpage.cxx
@@ -969,7 +969,7 @@ void SwFrmPage::Reset( const SfxItemSet *rSet )
 
     m_pRelWidthRelationLB->InsertEntry(aFramePosString.GetString(SwFPos::FRAME));
     m_pRelWidthRelationLB->InsertEntry(aFramePosString.GetString(SwFPos::REL_PG_FRAME));
-    if (rFrmSize.GetWidthPercent() != 0xff && rFrmSize.GetWidthPercent() != 0)
+    if (rFrmSize.GetWidthPercent() != SwFormatFrmSize::SYNCED && rFrmSize.GetWidthPercent() != 0)
     {
         //calculate the rerference value from the with and relative width values
         sal_Int32 nSpace = rFrmSize.GetWidth() * 100 / rFrmSize.GetWidthPercent();
@@ -982,7 +982,7 @@ void SwFrmPage::Reset( const SfxItemSet *rSet )
 
     m_pRelHeightRelationLB->InsertEntry(aFramePosString.GetString(SwFPos::FRAME));
     m_pRelHeightRelationLB->InsertEntry(aFramePosString.GetString(SwFPos::REL_PG_FRAME));
-    if (rFrmSize.GetHeightPercent() != 0xff && rFrmSize.GetHeightPercent() != 0)
+    if (rFrmSize.GetHeightPercent() != SwFormatFrmSize::SYNCED && rFrmSize.GetHeightPercent() != 0)
     {
         //calculate the rerference value from the with and relative width values
         sal_Int32 nSpace = rFrmSize.GetHeight() * 100 / rFrmSize.GetHeightPercent();
@@ -1213,9 +1213,9 @@ bool SwFrmPage::FillItemSet(SfxItemSet *rSet)
         if (m_pFixedRatioCB->IsChecked() && (m_pRelWidthCB->IsChecked() != m_pRelHeightCB->IsChecked()))
         {
             if (m_pRelWidthCB->IsChecked())
-                aSz.SetHeightPercent(0xff);
+                aSz.SetHeightPercent(SwFormatFrmSize::SYNCED);
             else
-                aSz.SetWidthPercent(0xff);
+                aSz.SetWidthPercent(SwFormatFrmSize::SYNCED);
         }
     }
     if( !IsInGraficMode() )
@@ -2324,16 +2324,16 @@ void SwFrmPage::Init(const SfxItemSet& rSet, bool bReset)
     // switch to percent if applicable
     RangeModifyHdl(&m_aWidthED);  // set reference values (for 100%)
 
-    if (rSize.GetWidthPercent() == 0xff || rSize.GetHeightPercent() == 0xff)
+    if (rSize.GetWidthPercent() == SwFormatFrmSize::SYNCED || rSize.GetHeightPercent() == SwFormatFrmSize::SYNCED)
         m_pFixedRatioCB->Check();
-    if (rSize.GetWidthPercent() && rSize.GetWidthPercent() != 0xff &&
+    if (rSize.GetWidthPercent() && rSize.GetWidthPercent() != SwFormatFrmSize::SYNCED &&
         !m_pRelWidthCB->IsChecked())
     {
         m_pRelWidthCB->Check();
         RelSizeClickHdl(m_pRelWidthCB);
         m_aWidthED.SetPrcntValue(rSize.GetWidthPercent(), FUNIT_CUSTOM);
     }
-    if (rSize.GetHeightPercent() && rSize.GetHeightPercent() != 0xff &&
+    if (rSize.GetHeightPercent() && rSize.GetHeightPercent() != SwFormatFrmSize::SYNCED &&
         !m_pRelHeightCB->IsChecked())
     {
         m_pRelHeightCB->Check();
diff --git a/sw/source/ui/frmdlg/wrap.cxx b/sw/source/ui/frmdlg/wrap.cxx
index d5f83ee..f7081b7 100644
--- a/sw/source/ui/frmdlg/wrap.cxx
+++ b/sw/source/ui/frmdlg/wrap.cxx
@@ -437,10 +437,10 @@ void SwWrapTabPage::ActivatePage(const SfxItemSet& rSet)
         aVal.nVPos = rVert.GetPos();
         aVal.nVRelOrient = rVert.GetRelationOrient();
 
-        if (rFrmSize.GetWidthPercent() && rFrmSize.GetWidthPercent() != 0xff)
+        if (rFrmSize.GetWidthPercent() && rFrmSize.GetWidthPercent() != SwFormatFrmSize::SYNCED)
             aSize.Width() = aSize.Width() * rFrmSize.GetWidthPercent() / 100;
 
-        if (rFrmSize.GetHeightPercent() && rFrmSize.GetHeightPercent() != 0xff)
+        if (rFrmSize.GetHeightPercent() && rFrmSize.GetHeightPercent() != SwFormatFrmSize::SYNCED)
             aSize.Height() = aSize.Height() * rFrmSize.GetHeightPercent() / 100;
 
         aVal.nWidth  = aSize.Width();
diff --git a/sw/source/uibase/shells/frmsh.cxx b/sw/source/uibase/shells/frmsh.cxx
index cfa9ffe..c6c4391 100644
--- a/sw/source/uibase/shells/frmsh.cxx
+++ b/sw/source/uibase/shells/frmsh.cxx
@@ -443,9 +443,9 @@ void SwFrameShell::Execute(SfxRequest &rReq)
 
                 // On % values initialize size
                 SwFormatFrmSize& rSize = const_cast<SwFormatFrmSize&>(static_cast<const SwFormatFrmSize&>(aSet.Get(RES_FRM_SIZE)));
-                if (rSize.GetWidthPercent() && rSize.GetWidthPercent() != 0xff)
+                if (rSize.GetWidthPercent() && rSize.GetWidthPercent() != SwFormatFrmSize::SYNCED)
                     rSize.SetWidth(rSh.GetAnyCurRect(RECT_FLY_EMBEDDED).Width());
-                if (rSize.GetHeightPercent() && rSize.GetHeightPercent() != 0xff)
+                if (rSize.GetHeightPercent() && rSize.GetHeightPercent() != SwFormatFrmSize::SYNCED)
                     rSize.SetHeight(rSh.GetAnyCurRect(RECT_FLY_EMBEDDED).Height());
 
                 // disable vertical positioning for Math Objects anchored 'as char' if baseline alignment is activated
diff --git a/sw/source/uibase/shells/grfsh.cxx b/sw/source/uibase/shells/grfsh.cxx
index fb4a14d..5ac6ca9 100644
--- a/sw/source/uibase/shells/grfsh.cxx
+++ b/sw/source/uibase/shells/grfsh.cxx
@@ -281,9 +281,9 @@ void SwGrfShell::Execute(SfxRequest &rReq)
 
             // At percentage values initialize size
             SwFormatFrmSize aSizeCopy = static_cast<const SwFormatFrmSize&>(aSet.Get(RES_FRM_SIZE));
-            if (aSizeCopy.GetWidthPercent() && aSizeCopy.GetWidthPercent() != 0xff)
+            if (aSizeCopy.GetWidthPercent() && aSizeCopy.GetWidthPercent() != SwFormatFrmSize::SYNCED)
                 aSizeCopy.SetWidth(rSh.GetAnyCurRect(RECT_FLY_EMBEDDED).Width());
-            if (aSizeCopy.GetHeightPercent() && aSizeCopy.GetHeightPercent() != 0xff)
+            if (aSizeCopy.GetHeightPercent() && aSizeCopy.GetHeightPercent() != SwFormatFrmSize::SYNCED)
                 aSizeCopy.SetHeight(rSh.GetAnyCurRect(RECT_FLY_EMBEDDED).Height());
             // and now set the size for "external" tabpages
             {
@@ -291,8 +291,8 @@ void SwGrfShell::Execute(SfxRequest &rReq)
                 aSet.Put( aSzItm );
 
                 Size aSz( aSizeCopy.GetWidthPercent(), aSizeCopy.GetHeightPercent() );
-                if( 0xff == aSz.Width() )   aSz.Width() = 0;
-                if( 0xff == aSz.Height() )  aSz.Height() = 0;
+                if( SwFormatFrmSize::SYNCED == aSz.Width() )   aSz.Width() = 0;
+                if( SwFormatFrmSize::SYNCED == aSz.Height() )  aSz.Height() = 0;
 
                 aSzItm.SetSize( aSz );
                 aSzItm.SetWhich( SID_ATTR_GRAF_FRMSIZE_PERCENT );


More information about the Libreoffice-commits mailing list