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

Miklos Vajna vmiklos at collabora.co.uk
Tue Jan 28 08:02:02 PST 2014


 sw/inc/fmtfsize.hxx               |    3 +++
 sw/inc/unomid.h                   |    1 +
 sw/inc/unoprnms.hxx               |    1 +
 sw/source/core/layout/atrfrm.cxx  |   14 +++++++++++++-
 sw/source/core/layout/fly.cxx     |   12 ++++++++++--
 sw/source/core/unocore/unomap.cxx |    2 ++
 6 files changed, 30 insertions(+), 3 deletions(-)

New commits:
commit f71dc0ec8372208318199ede36bc93de38d6c216
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Jan 28 16:36:44 2014 +0100

    swpagerelsize: take care of Sz.GetWidthPercentRelation() in SwFlyFrm::CalcRel
    
    This allows two type of relative sizes: relative to margin (default,
    what we had before) and relative to the entire page.
    
    Change-Id: I1625f072365e418352f3d507764e03484bb812be

diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index bccf60b..26550da 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -2482,14 +2482,22 @@ Size SwFlyFrm::CalcRel( const SwFmtFrmSize &rSz ) const
             if ( nDiff > 0 )
                 nRelHeight -= nDiff;
         }
-        nRelWidth  = std::min( nRelWidth,  pRel->Prt().Width() );
+
+        // At the moment only the "== PAGE_FRAME" and "!= PAGE_FRAME" cases are handled.
+        // When size is a relative to page size, ignore size of SwBodyFrm.
+        if (rSz.GetWidthPercentRelation() != text::RelOrientation::PAGE_FRAME)
+            nRelWidth  = std::min( nRelWidth,  pRel->Prt().Width() );
         nRelHeight = std::min( nRelHeight, pRel->Prt().Height() );
         if( !pRel->IsPageFrm() )
         {
             const SwPageFrm* pPage = FindPageFrm();
             if( pPage )
             {
-                nRelWidth  = std::min( nRelWidth,  pPage->Prt().Width() );
+                if (rSz.GetWidthPercentRelation() == text::RelOrientation::PAGE_FRAME)
+                    // Ignore margins of pPage.
+                    nRelWidth  = std::min( nRelWidth,  pPage->Frm().Width() );
+                else
+                    nRelWidth  = std::min( nRelWidth,  pPage->Prt().Width() );
                 nRelHeight = std::min( nRelHeight, pPage->Prt().Height() );
             }
         }
commit b7b57bbce3f3b171f3a85a8d93ab29f0d9a049cf
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Jan 28 15:26:47 2014 +0100

    swpagerelsize: implement RelativeWidthRelation UNO property for SwXFrame
    
    Which exposes SwFmtFrmSize::eWidthPercentRelation. Do not document yet,
    will be done if layout/filters/UI confirms that the data structure is
    suitable.
    
    Change-Id: Ic4eac3356452f4bedf9809ff5678e299b7339053

diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx
index 0065f12..d0db5b0 100644
--- a/sw/inc/unoprnms.hxx
+++ b/sw/inc/unoprnms.hxx
@@ -209,6 +209,7 @@
 #define UNO_NAME_PRINT_PAPER_FROM_SETUP "PrintPaperFromSetup"
 #define UNO_NAME_REGISTER_MODE_ACTIVE "RegisterModeActive"
 #define UNO_NAME_RELATIVE_WIDTH "RelativeWidth"
+#define UNO_NAME_RELATIVE_WIDTH_RELATION "RelativeWidthRelation"
 #define UNO_NAME_RELATIVE_HEIGHT "RelativeHeight"
 #define UNO_NAME_REPEAT_HEADLINE "RepeatHeadline"
 #define UNO_NAME_SEARCH_STYLES "SearchStyles"
diff --git a/sw/source/core/unocore/unomap.cxx b/sw/source/core/unocore/unomap.cxx
index 6617e7e..0f69154 100644
--- a/sw/source/core/unocore/unomap.cxx
+++ b/sw/source/core/unocore/unomap.cxx
@@ -372,6 +372,7 @@ SwUnoPropertyMapProvider::~SwUnoPropertyMapProvider()
     { OUString(UNO_NAME_PRINT), RES_PRINT,              cppu::UnoType<bool>::get(),         PROPERTY_NONE, 0},                                        \
     { OUString(UNO_NAME_RELATIVE_HEIGHT), RES_FRM_SIZE,         cppu::UnoType<sal_Int16>::get()  ,         PROPERTY_NONE,   MID_FRMSIZE_REL_HEIGHT },            \
     { OUString(UNO_NAME_RELATIVE_WIDTH), RES_FRM_SIZE,          cppu::UnoType<sal_Int16>::get()  ,         PROPERTY_NONE,   MID_FRMSIZE_REL_WIDTH  },         \
+    { OUString(UNO_NAME_RELATIVE_WIDTH_RELATION), RES_FRM_SIZE, cppu::UnoType<sal_Int16>::get()  ,         PROPERTY_NONE,   MID_FRMSIZE_REL_WIDTH_RELATION  },         \
     { OUString(UNO_NAME_SHADOW_FORMAT), RES_SHADOW,             cppu::UnoType<css::table::ShadowFormat>::get(),   PROPERTY_NONE, CONVERT_TWIPS},             \
     { OUString(UNO_NAME_SHADOW_TRANSPARENCE), RES_SHADOW,       cppu::UnoType<sal_Int16>::get(),       PROPERTY_NONE, MID_SHADOW_TRANSPARENCE},             \
     { OUString(UNO_NAME_IMAGE_MAP), RES_URL,                    cppu::UnoType<css::container::XIndexContainer>::get(), PROPERTY_NONE, MID_URL_CLIENTMAP}, \
@@ -828,6 +829,7 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s
                     { OUString(UNO_NAME_HEIGHT), RES_FRM_SIZE,          cppu::UnoType<sal_Int32>::get()  ,         PROPERTY_NONE, MID_FRMSIZE_HEIGHT|CONVERT_TWIPS         },
                     { OUString(UNO_NAME_RELATIVE_HEIGHT), RES_FRM_SIZE,         cppu::UnoType<sal_Int16>::get()  ,         PROPERTY_NONE,   MID_FRMSIZE_REL_HEIGHT },
                     { OUString(UNO_NAME_RELATIVE_WIDTH), RES_FRM_SIZE,          cppu::UnoType<sal_Int16>::get()  ,         PROPERTY_NONE,   MID_FRMSIZE_REL_WIDTH  },
+                    { OUString(UNO_NAME_RELATIVE_WIDTH_RELATION), RES_FRM_SIZE,          cppu::UnoType<sal_Int16>::get()  ,         PROPERTY_NONE,   MID_FRMSIZE_REL_WIDTH_RELATION  },
                     { OUString(UNO_NAME_SIZE_TYPE), RES_FRM_SIZE,           cppu::UnoType<sal_Int16>::get()  ,         PROPERTY_NONE,   MID_FRMSIZE_SIZE_TYPE  },
                     { OUString(UNO_NAME_WIDTH_TYPE), RES_FRM_SIZE,          cppu::UnoType<sal_Int16>::get()  ,         PROPERTY_NONE,   MID_FRMSIZE_WIDTH_TYPE },
                     { OUString(UNO_NAME_SIZE), RES_FRM_SIZE,            cppu::UnoType<css::awt::Size>::get(),             PROPERTY_NONE, MID_FRMSIZE_SIZE|CONVERT_TWIPS},
commit 493bee473ad2ed52f12030d302e2850d35b20093
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Jan 28 15:17:35 2014 +0100

    swpagerelsize: add an eWidthPercentRelation member to SwFmtFrmSize
    
    Relative width so far was always relative to margin. This new member can
    describe if the relative width should be relative to e.g. page.
    
    Change-Id: Idaed3c1ade8cd49021ed3406abd6f79cf8e742be

diff --git a/sw/inc/fmtfsize.hxx b/sw/inc/fmtfsize.hxx
index 699d3b2..2b1622e 100644
--- a/sw/inc/fmtfsize.hxx
+++ b/sw/inc/fmtfsize.hxx
@@ -44,6 +44,7 @@ class SW_DLLPUBLIC SwFmtFrmSize: public SfxPoolItem
     SwFrmSize eFrmHeightType;
     SwFrmSize eFrmWidthType;
     sal_uInt8     nWidthPercent;
+    sal_Int16     eWidthPercentRelation;
     sal_uInt8     nHeightPercent;
 
     // For tables: width can be given in percent.
@@ -91,8 +92,10 @@ public:
 
     sal_uInt8    GetHeightPercent() const{ return nHeightPercent; }
     sal_uInt8   GetWidthPercent() const { return nWidthPercent;  }
+    sal_Int16   GetWidthPercentRelation() const { return eWidthPercentRelation;  }
     void    SetHeightPercent( sal_uInt8 n ) { nHeightPercent = n; }
     void    SetWidthPercent ( sal_uInt8 n ) { nWidthPercent  = n; }
+    void    SetWidthPercentRelation ( sal_Int16 n ) { eWidthPercentRelation  = n; }
 };
 
 inline const SwFmtFrmSize &SwAttrSet::GetFrmSize(sal_Bool bInP) const
diff --git a/sw/inc/unomid.h b/sw/inc/unomid.h
index 981a309..56956fb 100644
--- a/sw/inc/unomid.h
+++ b/sw/inc/unomid.h
@@ -84,6 +84,7 @@
 #define MID_FRMSIZE_IS_SYNC_WIDTH_TO_HEIGHT     12
 #define MID_FRMSIZE_IS_SYNC_HEIGHT_TO_WIDTH     13
 #define MID_FRMSIZE_WIDTH_TYPE                  14
+#define MID_FRMSIZE_REL_WIDTH_RELATION          15
 
 #define MID_COLUMNS                             0
 #define MID_COLUMN_SEPARATOR_LINE               1
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index b9c00a3..4fd4ce6 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -176,7 +176,7 @@ SwFmtFrmSize::SwFmtFrmSize( SwFrmSize eSize, SwTwips nWidth, SwTwips nHeight )
     eFrmHeightType( eSize ),
     eFrmWidthType( ATT_FIX_SIZE )
 {
-    nWidthPercent = nHeightPercent = 0;
+    nWidthPercent = eWidthPercentRelation = nHeightPercent = 0;
 }
 
 SwFmtFrmSize& SwFmtFrmSize::operator=( const SwFmtFrmSize& rCpy )
@@ -186,6 +186,7 @@ SwFmtFrmSize& SwFmtFrmSize::operator=( const SwFmtFrmSize& rCpy )
     eFrmWidthType = rCpy.GetWidthSizeType();
     nHeightPercent = rCpy.GetHeightPercent();
     nWidthPercent  = rCpy.GetWidthPercent();
+    eWidthPercentRelation  = rCpy.GetWidthPercentRelation();
     return *this;
 }
 
@@ -196,6 +197,7 @@ bool SwFmtFrmSize::operator==( const SfxPoolItem& rAttr ) const
             eFrmWidthType  == ((SwFmtFrmSize&)rAttr).eFrmWidthType &&
             aSize           == ((SwFmtFrmSize&)rAttr).GetSize()&&
             nWidthPercent   == ((SwFmtFrmSize&)rAttr).GetWidthPercent() &&
+            eWidthPercentRelation == ((SwFmtFrmSize&)rAttr).GetWidthPercentRelation() &&
             nHeightPercent  == ((SwFmtFrmSize&)rAttr).GetHeightPercent() );
 }
 
@@ -224,6 +226,9 @@ bool SwFmtFrmSize::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
         case MID_FRMSIZE_REL_WIDTH:
             rVal <<= (sal_Int16)(GetWidthPercent() != 0xFF ? GetWidthPercent() : 0);
         break;
+        case MID_FRMSIZE_REL_WIDTH_RELATION:
+            rVal <<= GetWidthPercentRelation();
+        break;
         case MID_FRMSIZE_IS_SYNC_HEIGHT_TO_WIDTH:
         {
             sal_Bool bTmp = 0xFF == GetHeightPercent();
@@ -309,6 +314,13 @@ bool SwFmtFrmSize::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
                 bRet = false;
         }
         break;
+        case MID_FRMSIZE_REL_WIDTH_RELATION:
+        {
+            sal_Int16 eSet = 0;
+            rVal >>= eSet;
+            SetWidthPercentRelation(eSet);
+        }
+        break;
         case MID_FRMSIZE_IS_SYNC_HEIGHT_TO_WIDTH:
         {
             sal_Bool bSet = *(sal_Bool*)rVal.getValue();


More information about the Libreoffice-commits mailing list