summaryrefslogtreecommitdiff
path: root/sw/source/core/frmedt/fefly1.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/core/frmedt/fefly1.cxx')
-rw-r--r--sw/source/core/frmedt/fefly1.cxx117
1 files changed, 116 insertions, 1 deletions
diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx
index 0dc721a62f12..e4d4f2e9b399 100644
--- a/sw/source/core/frmedt/fefly1.cxx
+++ b/sw/source/core/frmedt/fefly1.cxx
@@ -27,6 +27,7 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sw.hxx"
+
#include <hintids.hxx>
#include <svl/itemiter.hxx>
#include <svtools/imapobj.hxx>
@@ -69,10 +70,15 @@
#include <fldbas.hxx>
#include <fmtfld.hxx>
#include <swundo.hxx>
+#include <frame.hxx>
+#include <notxtfrm.hxx>
// --> OD 2006-03-06 #125892#
#include <HandleAnchorNodeChg.hxx>
// <--
#include <frmatr.hxx>
+// --> 3.7.2010 #i972#
+#include <ndole.hxx>
+// <--
// --> OD 2009-12-29 #i89920#
#include <fmtsrnd.hxx>
#include <editeng/opaqitem.hxx>
@@ -1522,6 +1528,12 @@ Size SwFEShell::RequestObjectResize( const SwRect &rRect, const uno::Reference <
pFly->ChgRelPos( aTmp );
}
}
+
+ SwFlyFrmFmt *pFlyFrmFmt = pFly->GetFmt();
+ ASSERT( pFlyFrmFmt, "fly frame format missing!" );
+ if ( pFlyFrmFmt )
+ pFlyFrmFmt->SetLastFlyFrmPrtRectPos( pFly->Prt().Pos() ); //stores the value of last Prt rect
+
EndAllAction();
return aResult;
@@ -1587,6 +1599,20 @@ const String& SwFEShell::GetFlyName() const
}
+const uno::Reference < embed::XEmbeddedObject > SwFEShell::GetOleRef() const
+{
+ uno::Reference < embed::XEmbeddedObject > xObj;
+ SwFlyFrm * pFly = FindFlyFrm();
+ if (pFly && pFly->Lower() && pFly->Lower()->IsNoTxtFrm())
+ {
+ SwOLENode *pNd = ((SwNoTxtFrm*)pFly->Lower())->GetNode()->GetOLENode();
+ if (pNd)
+ xObj = pNd->GetOLEObj().GetOleRef();
+ }
+ return xObj;
+}
+
+
String SwFEShell::GetUniqueGrfName() const
{
return GetDoc()->GetUniqueGrfName();
@@ -2153,4 +2179,93 @@ void SwFEShell::SetObjDescription( const String& rDescription )
}
}
}
-// <--
+
+
+void SwFEShell::AlignFormulaToBaseline( const uno::Reference < embed::XEmbeddedObject >& xObj, SwFlyFrm * pFly )
+{
+#if OSL_DEBUG_LEVEL > 1
+ SvGlobalName aCLSID( xObj->getClassID() );
+ const bool bStarMath = ( SotExchange::IsMath( aCLSID ) != 0 );
+ ASSERT( bStarMath, "AlignFormulaToBaseline should only be called for Math objects" );
+
+ if ( !bStarMath )
+ return;
+#endif
+
+ if (!pFly)
+ pFly = FindFlyFrm( xObj );
+ ASSERT( pFly , "No fly frame!" );
+ SwFrmFmt * pFrmFmt = pFly ? pFly->GetFmt() : 0;
+
+ // baseline to baseline alignment should only be applied to formulas anchored as char
+ if ( pFly && pFrmFmt && FLY_AS_CHAR == pFrmFmt->GetAnchor().GetAnchorId() )
+ {
+ // get baseline from Math object
+ uno::Any aBaseline;
+ if( svt::EmbeddedObjectRef::TryRunningState( xObj ) )
+ {
+ uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
+ if ( xSet.is() )
+ {
+ try
+ {
+ aBaseline = xSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BaseLine") ) );
+ }
+ catch ( uno::Exception& )
+ {
+ ASSERT( FALSE , "Baseline could not be retrieved from Starmath!" );
+ }
+ }
+ }
+
+ sal_Int32 nBaseline = ::comphelper::getINT32(aBaseline);
+ const MapMode aSourceMapMode( MAP_100TH_MM );
+ const MapMode aTargetMapMode( MAP_TWIP );
+ nBaseline = OutputDevice::LogicToLogic( nBaseline, aSourceMapMode.GetMapUnit(), aTargetMapMode.GetMapUnit() );
+
+ ASSERT( nBaseline > 0, "Wrong value of Baseline while retrieving from Starmath!" );
+ //nBaseline must be moved by aPrt position
+ const SwFlyFrmFmt *pFlyFrmFmt = pFly->GetFmt();
+ ASSERT( pFlyFrmFmt, "fly frame format missing!" );
+ if ( pFlyFrmFmt )
+ nBaseline += pFlyFrmFmt->GetLastFlyFrmPrtRectPos().Y();
+
+ const SwFmtVertOrient &rVert = pFrmFmt->GetVertOrient();
+ SwFmtVertOrient aVert( rVert );
+ aVert.SetPos( -nBaseline );
+ aVert.SetVertOrient( com::sun::star::text::VertOrientation::NONE );
+
+ pFrmFmt->LockModify();
+ pFrmFmt->SetFmtAttr( aVert );
+ pFrmFmt->UnlockModify();
+ pFly->InvalidatePos();
+ }
+}
+
+
+void SwFEShell::AlignAllFormulasToBaseline()
+{
+ StartAllAction();
+
+ SwStartNode *pStNd;
+ SwNodeIndex aIdx( *GetNodes().GetEndOfAutotext().StartOfSectionNode(), 1 );
+ while ( 0 != (pStNd = aIdx.GetNode().GetStartNode()) )
+ {
+ ++aIdx;
+ SwOLENode *pOleNode = dynamic_cast< SwOLENode * >( &aIdx.GetNode() );
+ if ( pOleNode )
+ {
+ const uno::Reference < embed::XEmbeddedObject > & xObj( pOleNode->GetOLEObj().GetOleRef() );
+ if (xObj.is())
+ {
+ SvGlobalName aCLSID( xObj->getClassID() );
+ if ( SotExchange::IsMath( aCLSID ) )
+ AlignFormulaToBaseline( xObj );
+ }
+ }
+
+ aIdx.Assign( *pStNd->EndOfSectionNode(), + 1 );
+ }
+
+ EndAllAction();
+}