summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorCédric Bosdonnat <cedric.bosdonnat@free.fr>2012-09-26 13:10:31 +0200
committerCédric Bosdonnat <cedric.bosdonnat@free.fr>2012-09-27 09:23:20 +0200
commitd4474dd0411d7de29ce42e181c97cbf032bf57ea (patch)
tree2c2751e078cf04da2991437d12e3ae8f09652f28 /sw
parent0f581ab761cefde208e576661850b57f2846fdb4 (diff)
sw: implement page-relative size for drawing objects and import them from docx
Change-Id: I98b5c53d4860278e3646324ca045114e37b4cf61
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/dcontact.hxx2
-rw-r--r--sw/source/core/draw/dcontact.cxx4
-rw-r--r--sw/source/core/draw/dflyobj.cxx2
-rw-r--r--sw/source/core/inc/dflyobj.hxx2
-rw-r--r--sw/source/core/layout/anchoreddrawobject.cxx23
-rw-r--r--sw/source/core/unocore/unodraw.cxx16
-rw-r--r--sw/source/core/unocore/unomap.cxx2
7 files changed, 46 insertions, 5 deletions
diff --git a/sw/inc/dcontact.hxx b/sw/inc/dcontact.hxx
index 2984872917a7..f0d7ab30a578 100644
--- a/sw/inc/dcontact.hxx
+++ b/sw/inc/dcontact.hxx
@@ -303,7 +303,7 @@ class SwDrawVirtObj : public SdrVirtObj
virtual void NbcMirror(const Point& rRef1, const Point& rRef2);
virtual void NbcShear(const Point& rRef, long nWink, double tn, bool bVShear);
virtual void Move(const Size& rSiz);
- virtual void Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact);
+ virtual void Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative = true);
virtual void Rotate(const Point& rRef, long nWink, double sn, double cs);
virtual void Mirror(const Point& rRef1, const Point& rRef2);
virtual void Shear(const Point& rRef, long nWink, double tn, bool bVShear);
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index ff2f27b7430b..6f72799d998d 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -2472,12 +2472,12 @@ void SwDrawVirtObj::Move(const Size& rSiz)
SdrObject::Move( rSiz );
}
-void SwDrawVirtObj::Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
+void SwDrawVirtObj::Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative)
{
if(xFact.GetNumerator() != xFact.GetDenominator() || yFact.GetNumerator() != yFact.GetDenominator())
{
Rectangle aBoundRect0; if(pUserCall) aBoundRect0 = GetLastBoundRect();
- rRefObj.Resize(rRef - GetOffset(), xFact, yFact);
+ rRefObj.Resize(rRef - GetOffset(), xFact, yFact, bUnsetRelative);
SetRectsDirty();
SendUserCall(SDRUSERCALL_RESIZE, aBoundRect0);
}
diff --git a/sw/source/core/draw/dflyobj.cxx b/sw/source/core/draw/dflyobj.cxx
index 19ec682bf011..d8bddbce0edf 100644
--- a/sw/source/core/draw/dflyobj.cxx
+++ b/sw/source/core/draw/dflyobj.cxx
@@ -923,7 +923,7 @@ void SwVirtFlyDrawObj::Move(const Size& rSiz)
void SwVirtFlyDrawObj::Resize(const Point& rRef,
- const Fraction& xFact, const Fraction& yFact)
+ const Fraction& xFact, const Fraction& yFact, bool /*bUnsetRelative*/)
{
NbcResize( rRef, xFact, yFact );
SetChanged();
diff --git a/sw/source/core/inc/dflyobj.hxx b/sw/source/core/inc/dflyobj.hxx
index fed3affe24d8..3ef6a226d24b 100644
--- a/sw/source/core/inc/dflyobj.hxx
+++ b/sw/source/core/inc/dflyobj.hxx
@@ -112,7 +112,7 @@ public:
const Fraction& yFact);
virtual void Move (const Size& rSiz);
virtual void Resize(const Point& rRef, const Fraction& xFact,
- const Fraction& yFact);
+ const Fraction& yFact, bool bUnsetRelative = true);
const SwFrmFmt *GetFmt() const;
SwFrmFmt *GetFmt();
diff --git a/sw/source/core/layout/anchoreddrawobject.cxx b/sw/source/core/layout/anchoreddrawobject.cxx
index 735878f98ea9..c36a49170c0b 100644
--- a/sw/source/core/layout/anchoreddrawobject.cxx
+++ b/sw/source/core/layout/anchoreddrawobject.cxx
@@ -659,6 +659,29 @@ const SwRect SwAnchoredDrawObject::GetObjRect() const
// --> #i70122#
const SwRect SwAnchoredDrawObject::GetObjBoundRect() const
{
+ // Resize objects with relative width or height
+#if 1
+ if ( GetDrawObj( )->GetRelativeWidth( ) || GetDrawObj()->GetRelativeHeight( ) )
+ {
+ Rectangle aPageRect = GetPageFrm( )->GetBoundRect( ).SVRect();
+ Rectangle aCurrObjRect = GetDrawObj()->GetCurrentBoundRect();
+
+ long nTargetWidth = aCurrObjRect.GetWidth( );
+ if ( GetDrawObj( )->GetRelativeWidth( ) )
+ nTargetWidth = aPageRect.GetWidth( ) * GetDrawObj( )->GetRelativeWidth( ).get( );
+
+ long nTargetHeight = aCurrObjRect.GetHeight( );
+ if ( GetDrawObj( )->GetRelativeHeight( ) )
+ nTargetHeight = aPageRect.GetHeight( ) * GetDrawObj( )->GetRelativeHeight( ).get( );
+
+ if ( nTargetWidth != aCurrObjRect.GetWidth( ) || nTargetHeight != aCurrObjRect.GetHeight( ) )
+ {
+ const_cast< SdrObject* >( GetDrawObj() )->Resize( aCurrObjRect.TopLeft(),
+ Fraction( nTargetWidth, aCurrObjRect.GetWidth() ),
+ Fraction( nTargetHeight, aCurrObjRect.GetHeight() ), false );
+ }
+ }
+#endif
return GetDrawObj()->GetCurrentBoundRect();
}
diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx
index 2e37dd618573..8b141e438b58 100644
--- a/sw/source/core/unocore/unodraw.cxx
+++ b/sw/source/core/unocore/unodraw.cxx
@@ -1265,6 +1265,22 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A
pFmt->SetFmtAttr(aSet);
}
}
+ else if( RES_FRM_SIZE == pEntry->nWID &&
+ ( pEntry->nMemberId == MID_FRMSIZE_REL_HEIGHT || pEntry->nMemberId == MID_FRMSIZE_REL_WIDTH ) )
+ {
+ SvxShape* pSvxShape = GetSvxShape();
+ SAL_WARN_IF(!pSvxShape, "sw.uno", "No SvxShape found!");
+ if(pSvxShape)
+ {
+ SdrObject* pObj = pSvxShape->GetSdrObject();
+ sal_Int16 nPercent;
+ aValue >>= nPercent;
+ if ( pEntry->nMemberId == MID_FRMSIZE_REL_WIDTH )
+ pObj->SetRelativeWidth( nPercent / 100.0 );
+ else
+ pObj->SetRelativeHeight( nPercent / 100.0 );
+ }
+ }
else
{
m_pPropSet->setPropertyValue( *pEntry, aValue, aSet );
diff --git a/sw/source/core/unocore/unomap.cxx b/sw/source/core/unocore/unomap.cxx
index 26348ed67236..a6832a9e1c20 100644
--- a/sw/source/core/unocore/unomap.cxx
+++ b/sw/source/core/unocore/unomap.cxx
@@ -1183,6 +1183,8 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s
// #i71182#
// missing map entry for property <PageToogle>
{ SW_PROP_NMID(UNO_NAME_PAGE_TOGGLE), RES_HORI_ORIENT, CPPU_E2T(CPPUTYPE_BOOLEAN), PROPERTY_NONE ,MID_HORIORIENT_PAGETOGGLE },
+ { SW_PROP_NMID(UNO_NAME_RELATIVE_HEIGHT), RES_FRM_SIZE, CPPU_E2T(CPPUTYPE_INT16) , PROPERTY_NONE, MID_FRMSIZE_REL_HEIGHT },
+ { SW_PROP_NMID(UNO_NAME_RELATIVE_WIDTH), RES_FRM_SIZE, CPPU_E2T(CPPUTYPE_INT16) , PROPERTY_NONE, MID_FRMSIZE_REL_WIDTH },
{0,0,0,0,0,0}
};
aMapEntriesArr[nPropertyId] = aShapeMap_Impl;